Skip to content

Commit 1273e3c

Browse files
committed
api.ts
1 parent 49d111f commit 1273e3c

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

site/src/api/api.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,11 @@ export type GetProvisionerDaemonsParams = {
411411
* lexical scope.
412412
*/
413413
class ApiMethods {
414-
constructor(protected readonly axios: AxiosInstance) {}
414+
experimental: ExperimentalApiMethods;
415+
416+
constructor(protected readonly axios: AxiosInstance) {
417+
this.experimental = new ExperimentalApiMethods(this.axios);
418+
}
415419

416420
login = async (
417421
email: string,
@@ -2599,6 +2603,36 @@ class ApiMethods {
25992603
};
26002604
}
26012605

2606+
// Experimental API methods call endpoints under the /api/experimental/ prefix.
2607+
// These endpoints are not stable and may change or be removed at any time.
2608+
//
2609+
// All methods must be defined with arrow function syntax. See the docstring
2610+
// above the ApiMethods class for a full explanation.
2611+
class ExperimentalApiMethods {
2612+
constructor(protected readonly axios: AxiosInstance) {}
2613+
2614+
getAITasksPrompts = async (
2615+
buildIds: TypesGen.WorkspaceBuild["id"][],
2616+
): Promise<TypesGen.AITasksPromptsResponse> => {
2617+
if (buildIds.length === 0) {
2618+
return {
2619+
prompts: {},
2620+
};
2621+
}
2622+
2623+
const response = await this.axios.get<TypesGen.AITasksPromptsResponse>(
2624+
"/api/experimental/aitasks/prompts",
2625+
{
2626+
params: {
2627+
build_ids: buildIds.join(","),
2628+
},
2629+
},
2630+
);
2631+
2632+
return response.data;
2633+
};
2634+
}
2635+
26022636
// This is a hard coded CSRF token/cookie pair for local development. In prod,
26032637
// the GoLang webserver generates a random cookie with a new token for each
26042638
// document request. For local development, we don't use the Go webserver for

0 commit comments

Comments
 (0)