@vertesia/client 0.24.0-dev.202601221707
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +110 -0
- package/lib/cjs/AccountApi.js +85 -0
- package/lib/cjs/AccountApi.js.map +1 -0
- package/lib/cjs/AccountsApi.js +16 -0
- package/lib/cjs/AccountsApi.js.map +1 -0
- package/lib/cjs/AnalyticsApi.js +41 -0
- package/lib/cjs/AnalyticsApi.js.map +1 -0
- package/lib/cjs/ApiKeysApi.js +63 -0
- package/lib/cjs/ApiKeysApi.js.map +1 -0
- package/lib/cjs/AppsApi.js +119 -0
- package/lib/cjs/AppsApi.js.map +1 -0
- package/lib/cjs/CommandsApi.js +19 -0
- package/lib/cjs/CommandsApi.js.map +1 -0
- package/lib/cjs/EnvironmentsApi.js +72 -0
- package/lib/cjs/EnvironmentsApi.js.map +1 -0
- package/lib/cjs/GroupsApi.js +78 -0
- package/lib/cjs/GroupsApi.js.map +1 -0
- package/lib/cjs/IamApi.js +53 -0
- package/lib/cjs/IamApi.js.map +1 -0
- package/lib/cjs/InteractionBase.js +44 -0
- package/lib/cjs/InteractionBase.js.map +1 -0
- package/lib/cjs/InteractionCatalogApi.js +64 -0
- package/lib/cjs/InteractionCatalogApi.js.map +1 -0
- package/lib/cjs/InteractionOutput.js +300 -0
- package/lib/cjs/InteractionOutput.js.map +1 -0
- package/lib/cjs/InteractionResult.example.js +57 -0
- package/lib/cjs/InteractionResult.example.js.map +1 -0
- package/lib/cjs/InteractionsApi.js +262 -0
- package/lib/cjs/InteractionsApi.js.map +1 -0
- package/lib/cjs/MCPOAuthApi.js +62 -0
- package/lib/cjs/MCPOAuthApi.js.map +1 -0
- package/lib/cjs/ProjectsApi.js +72 -0
- package/lib/cjs/ProjectsApi.js.map +1 -0
- package/lib/cjs/PromptsApi.js +133 -0
- package/lib/cjs/PromptsApi.js.map +1 -0
- package/lib/cjs/RefsApi.js +14 -0
- package/lib/cjs/RefsApi.js.map +1 -0
- package/lib/cjs/RunsApi.js +113 -0
- package/lib/cjs/RunsApi.js.map +1 -0
- package/lib/cjs/SkillsApi.js +39 -0
- package/lib/cjs/SkillsApi.js.map +1 -0
- package/lib/cjs/StreamSource.js +17 -0
- package/lib/cjs/StreamSource.js.map +1 -0
- package/lib/cjs/TrainingApi.js +54 -0
- package/lib/cjs/TrainingApi.js.map +1 -0
- package/lib/cjs/UsersApi.js +13 -0
- package/lib/cjs/UsersApi.js.map +1 -0
- package/lib/cjs/client.js +360 -0
- package/lib/cjs/client.js.map +1 -0
- package/lib/cjs/execute.js +158 -0
- package/lib/cjs/execute.js.map +1 -0
- package/lib/cjs/index.js +22 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/nodejs/NodeStreamSource.js +45 -0
- package/lib/cjs/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/cjs/nodejs/index.js +18 -0
- package/lib/cjs/nodejs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/store/AnalyzeDocApi.js +56 -0
- package/lib/cjs/store/AnalyzeDocApi.js.map +1 -0
- package/lib/cjs/store/CollectionsApi.js +131 -0
- package/lib/cjs/store/CollectionsApi.js.map +1 -0
- package/lib/cjs/store/CommandsApi.js +17 -0
- package/lib/cjs/store/CommandsApi.js.map +1 -0
- package/lib/cjs/store/DashboardApi.js +182 -0
- package/lib/cjs/store/DashboardApi.js.map +1 -0
- package/lib/cjs/store/DataApi.js +433 -0
- package/lib/cjs/store/DataApi.js.map +1 -0
- package/lib/cjs/store/EmailApi.js +103 -0
- package/lib/cjs/store/EmailApi.js.map +1 -0
- package/lib/cjs/store/EmbeddingsApi.js +29 -0
- package/lib/cjs/store/EmbeddingsApi.js.map +1 -0
- package/lib/cjs/store/FilesApi.js +237 -0
- package/lib/cjs/store/FilesApi.js.map +1 -0
- package/lib/cjs/store/ObjectsApi.js +314 -0
- package/lib/cjs/store/ObjectsApi.js.map +1 -0
- package/lib/cjs/store/PendingAsksApi.js +43 -0
- package/lib/cjs/store/PendingAsksApi.js.map +1 -0
- package/lib/cjs/store/SchedulesApi.js +103 -0
- package/lib/cjs/store/SchedulesApi.js.map +1 -0
- package/lib/cjs/store/ToolsApi.js +21 -0
- package/lib/cjs/store/ToolsApi.js.map +1 -0
- package/lib/cjs/store/TypesApi.js +57 -0
- package/lib/cjs/store/TypesApi.js.map +1 -0
- package/lib/cjs/store/WorkersApi.js +16 -0
- package/lib/cjs/store/WorkersApi.js.map +1 -0
- package/lib/cjs/store/WorkflowsApi.js +596 -0
- package/lib/cjs/store/WorkflowsApi.js.map +1 -0
- package/lib/cjs/store/client.js +81 -0
- package/lib/cjs/store/client.js.map +1 -0
- package/lib/cjs/store/errors.js +11 -0
- package/lib/cjs/store/errors.js.map +1 -0
- package/lib/cjs/store/index.js +27 -0
- package/lib/cjs/store/index.js.map +1 -0
- package/lib/cjs/store/version.js +6 -0
- package/lib/cjs/store/version.js.map +1 -0
- package/lib/esm/AccountApi.js +82 -0
- package/lib/esm/AccountApi.js.map +1 -0
- package/lib/esm/AccountsApi.js +13 -0
- package/lib/esm/AccountsApi.js.map +1 -0
- package/lib/esm/AnalyticsApi.js +38 -0
- package/lib/esm/AnalyticsApi.js.map +1 -0
- package/lib/esm/ApiKeysApi.js +59 -0
- package/lib/esm/ApiKeysApi.js.map +1 -0
- package/lib/esm/AppsApi.js +116 -0
- package/lib/esm/AppsApi.js.map +1 -0
- package/lib/esm/CommandsApi.js +16 -0
- package/lib/esm/CommandsApi.js.map +1 -0
- package/lib/esm/EnvironmentsApi.js +69 -0
- package/lib/esm/EnvironmentsApi.js.map +1 -0
- package/lib/esm/GroupsApi.js +74 -0
- package/lib/esm/GroupsApi.js.map +1 -0
- package/lib/esm/IamApi.js +47 -0
- package/lib/esm/IamApi.js.map +1 -0
- package/lib/esm/InteractionBase.js +40 -0
- package/lib/esm/InteractionBase.js.map +1 -0
- package/lib/esm/InteractionCatalogApi.js +60 -0
- package/lib/esm/InteractionCatalogApi.js.map +1 -0
- package/lib/esm/InteractionOutput.js +293 -0
- package/lib/esm/InteractionOutput.js.map +1 -0
- package/lib/esm/InteractionResult.example.js +55 -0
- package/lib/esm/InteractionResult.example.js.map +1 -0
- package/lib/esm/InteractionsApi.js +259 -0
- package/lib/esm/InteractionsApi.js.map +1 -0
- package/lib/esm/MCPOAuthApi.js +59 -0
- package/lib/esm/MCPOAuthApi.js.map +1 -0
- package/lib/esm/ProjectsApi.js +69 -0
- package/lib/esm/ProjectsApi.js.map +1 -0
- package/lib/esm/PromptsApi.js +130 -0
- package/lib/esm/PromptsApi.js.map +1 -0
- package/lib/esm/RefsApi.js +10 -0
- package/lib/esm/RefsApi.js.map +1 -0
- package/lib/esm/RunsApi.js +109 -0
- package/lib/esm/RunsApi.js.map +1 -0
- package/lib/esm/SkillsApi.js +36 -0
- package/lib/esm/SkillsApi.js.map +1 -0
- package/lib/esm/StreamSource.js +13 -0
- package/lib/esm/StreamSource.js.map +1 -0
- package/lib/esm/TrainingApi.js +51 -0
- package/lib/esm/TrainingApi.js.map +1 -0
- package/lib/esm/UsersApi.js +10 -0
- package/lib/esm/UsersApi.js.map +1 -0
- package/lib/esm/client.js +351 -0
- package/lib/esm/client.js.map +1 -0
- package/lib/esm/execute.js +118 -0
- package/lib/esm/execute.js.map +1 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/nodejs/NodeStreamSource.js +41 -0
- package/lib/esm/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/esm/nodejs/index.js +2 -0
- package/lib/esm/nodejs/index.js.map +1 -0
- package/lib/esm/store/AnalyzeDocApi.js +52 -0
- package/lib/esm/store/AnalyzeDocApi.js.map +1 -0
- package/lib/esm/store/CollectionsApi.js +127 -0
- package/lib/esm/store/CollectionsApi.js.map +1 -0
- package/lib/esm/store/CommandsApi.js +13 -0
- package/lib/esm/store/CommandsApi.js.map +1 -0
- package/lib/esm/store/DashboardApi.js +178 -0
- package/lib/esm/store/DashboardApi.js.map +1 -0
- package/lib/esm/store/DataApi.js +429 -0
- package/lib/esm/store/DataApi.js.map +1 -0
- package/lib/esm/store/EmailApi.js +99 -0
- package/lib/esm/store/EmailApi.js.map +1 -0
- package/lib/esm/store/EmbeddingsApi.js +25 -0
- package/lib/esm/store/EmbeddingsApi.js.map +1 -0
- package/lib/esm/store/FilesApi.js +231 -0
- package/lib/esm/store/FilesApi.js.map +1 -0
- package/lib/esm/store/ObjectsApi.js +309 -0
- package/lib/esm/store/ObjectsApi.js.map +1 -0
- package/lib/esm/store/PendingAsksApi.js +39 -0
- package/lib/esm/store/PendingAsksApi.js.map +1 -0
- package/lib/esm/store/SchedulesApi.js +99 -0
- package/lib/esm/store/SchedulesApi.js.map +1 -0
- package/lib/esm/store/ToolsApi.js +17 -0
- package/lib/esm/store/ToolsApi.js.map +1 -0
- package/lib/esm/store/TypesApi.js +53 -0
- package/lib/esm/store/TypesApi.js.map +1 -0
- package/lib/esm/store/WorkersApi.js +12 -0
- package/lib/esm/store/WorkersApi.js.map +1 -0
- package/lib/esm/store/WorkflowsApi.js +590 -0
- package/lib/esm/store/WorkflowsApi.js.map +1 -0
- package/lib/esm/store/client.js +77 -0
- package/lib/esm/store/client.js.map +1 -0
- package/lib/esm/store/errors.js +7 -0
- package/lib/esm/store/errors.js.map +1 -0
- package/lib/esm/store/index.js +11 -0
- package/lib/esm/store/index.js.map +1 -0
- package/lib/esm/store/version.js +3 -0
- package/lib/esm/store/version.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AccountApi.d.ts +59 -0
- package/lib/types/AccountApi.d.ts.map +1 -0
- package/lib/types/AccountsApi.d.ts +7 -0
- package/lib/types/AccountsApi.d.ts.map +1 -0
- package/lib/types/AnalyticsApi.d.ts +11 -0
- package/lib/types/AnalyticsApi.d.ts.map +1 -0
- package/lib/types/ApiKeysApi.d.ts +42 -0
- package/lib/types/ApiKeysApi.d.ts.map +1 -0
- package/lib/types/AppsApi.d.ts +65 -0
- package/lib/types/AppsApi.d.ts.map +1 -0
- package/lib/types/CommandsApi.d.ts +10 -0
- package/lib/types/CommandsApi.d.ts.map +1 -0
- package/lib/types/EnvironmentsApi.d.ts +40 -0
- package/lib/types/EnvironmentsApi.d.ts.map +1 -0
- package/lib/types/GroupsApi.d.ts +65 -0
- package/lib/types/GroupsApi.d.ts.map +1 -0
- package/lib/types/IamApi.d.ts +41 -0
- package/lib/types/IamApi.d.ts.map +1 -0
- package/lib/types/InteractionBase.d.ts +22 -0
- package/lib/types/InteractionBase.d.ts.map +1 -0
- package/lib/types/InteractionCatalogApi.d.ts +36 -0
- package/lib/types/InteractionCatalogApi.d.ts.map +1 -0
- package/lib/types/InteractionOutput.d.ts +174 -0
- package/lib/types/InteractionOutput.d.ts.map +1 -0
- package/lib/types/InteractionResult.example.d.ts +6 -0
- package/lib/types/InteractionResult.example.d.ts.map +1 -0
- package/lib/types/InteractionsApi.d.ts +183 -0
- package/lib/types/InteractionsApi.d.ts.map +1 -0
- package/lib/types/MCPOAuthApi.d.ts +45 -0
- package/lib/types/MCPOAuthApi.d.ts.map +1 -0
- package/lib/types/ProjectsApi.d.ts +28 -0
- package/lib/types/ProjectsApi.d.ts.map +1 -0
- package/lib/types/PromptsApi.d.ts +106 -0
- package/lib/types/PromptsApi.d.ts.map +1 -0
- package/lib/types/RefsApi.d.ts +6 -0
- package/lib/types/RefsApi.d.ts.map +1 -0
- package/lib/types/RunsApi.d.ts +79 -0
- package/lib/types/RunsApi.d.ts.map +1 -0
- package/lib/types/SkillsApi.d.ts +26 -0
- package/lib/types/SkillsApi.d.ts.map +1 -0
- package/lib/types/StreamSource.d.ts +7 -0
- package/lib/types/StreamSource.d.ts.map +1 -0
- package/lib/types/TrainingApi.d.ts +27 -0
- package/lib/types/TrainingApi.d.ts.map +1 -0
- package/lib/types/UsersApi.d.ts +6 -0
- package/lib/types/UsersApi.d.ts.map +1 -0
- package/lib/types/client.d.ts +136 -0
- package/lib/types/client.d.ts.map +1 -0
- package/lib/types/execute.d.ts +37 -0
- package/lib/types/execute.d.ts.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/nodejs/NodeStreamSource.d.ts +9 -0
- package/lib/types/nodejs/NodeStreamSource.d.ts.map +1 -0
- package/lib/types/nodejs/index.d.ts +1 -0
- package/lib/types/nodejs/index.d.ts.map +1 -0
- package/lib/types/store/AnalyzeDocApi.d.ts +17 -0
- package/lib/types/store/AnalyzeDocApi.d.ts.map +1 -0
- package/lib/types/store/CollectionsApi.d.ts +82 -0
- package/lib/types/store/CollectionsApi.d.ts.map +1 -0
- package/lib/types/store/CommandsApi.d.ts +10 -0
- package/lib/types/store/CommandsApi.d.ts.map +1 -0
- package/lib/types/store/DashboardApi.d.ts +149 -0
- package/lib/types/store/DashboardApi.d.ts.map +1 -0
- package/lib/types/store/DataApi.d.ts +392 -0
- package/lib/types/store/DataApi.d.ts.map +1 -0
- package/lib/types/store/EmailApi.d.ts +185 -0
- package/lib/types/store/EmailApi.d.ts.map +1 -0
- package/lib/types/store/EmbeddingsApi.d.ts +12 -0
- package/lib/types/store/EmbeddingsApi.d.ts.map +1 -0
- package/lib/types/store/FilesApi.d.ts +110 -0
- package/lib/types/store/FilesApi.d.ts.map +1 -0
- package/lib/types/store/ObjectsApi.d.ts +139 -0
- package/lib/types/store/ObjectsApi.d.ts.map +1 -0
- package/lib/types/store/PendingAsksApi.d.ts +79 -0
- package/lib/types/store/PendingAsksApi.d.ts.map +1 -0
- package/lib/types/store/SchedulesApi.d.ts +89 -0
- package/lib/types/store/SchedulesApi.d.ts.map +1 -0
- package/lib/types/store/ToolsApi.d.ts +13 -0
- package/lib/types/store/ToolsApi.d.ts.map +1 -0
- package/lib/types/store/TypesApi.d.ts +23 -0
- package/lib/types/store/TypesApi.d.ts.map +1 -0
- package/lib/types/store/WorkersApi.d.ts +6 -0
- package/lib/types/store/WorkersApi.d.ts.map +1 -0
- package/lib/types/store/WorkflowsApi.d.ts +167 -0
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -0
- package/lib/types/store/client.d.ts +45 -0
- package/lib/types/store/client.d.ts.map +1 -0
- package/lib/types/store/errors.d.ts +4 -0
- package/lib/types/store/errors.d.ts.map +1 -0
- package/lib/types/store/index.d.ts +10 -0
- package/lib/types/store/index.d.ts.map +1 -0
- package/lib/types/store/version.d.ts +2 -0
- package/lib/types/store/version.d.ts.map +1 -0
- package/lib/vertesia-client.js +2 -0
- package/lib/vertesia-client.js.map +1 -0
- package/package.json +71 -0
- package/src/AccountApi.ts +96 -0
- package/src/AccountsApi.ts +22 -0
- package/src/AnalyticsApi.ts +36 -0
- package/src/ApiKeysApi.ts +67 -0
- package/src/AppsApi.ts +134 -0
- package/src/CommandsApi.ts +23 -0
- package/src/EnvironmentsApi.ts +94 -0
- package/src/GroupsApi.ts +92 -0
- package/src/IamApi.ts +70 -0
- package/src/InteractionBase.ts +44 -0
- package/src/InteractionCatalogApi.ts +72 -0
- package/src/InteractionOutput.test.ts +305 -0
- package/src/InteractionOutput.ts +328 -0
- package/src/InteractionResult.example.ts +72 -0
- package/src/InteractionsApi.ts +308 -0
- package/src/MCPOAuthApi.ts +67 -0
- package/src/ProjectsApi.ts +85 -0
- package/src/PromptsApi.ts +160 -0
- package/src/RefsApi.ts +18 -0
- package/src/RunsApi.ts +151 -0
- package/src/SkillsApi.ts +46 -0
- package/src/StreamSource.ts +3 -0
- package/src/TrainingApi.ts +71 -0
- package/src/UsersApi.ts +18 -0
- package/src/client.test.ts +99 -0
- package/src/client.ts +419 -0
- package/src/execute.ts +126 -0
- package/src/index.ts +10 -0
- package/src/nodejs/NodeStreamSource.ts +43 -0
- package/src/nodejs/index.ts +1 -0
- package/src/store/AnalyzeDocApi.ts +61 -0
- package/src/store/CollectionsApi.ts +166 -0
- package/src/store/CommandsApi.ts +15 -0
- package/src/store/DashboardApi.ts +216 -0
- package/src/store/DataApi.ts +516 -0
- package/src/store/EmailApi.ts +211 -0
- package/src/store/EmbeddingsApi.ts +39 -0
- package/src/store/FilesApi.ts +288 -0
- package/src/store/ObjectsApi.ts +432 -0
- package/src/store/PendingAsksApi.ts +98 -0
- package/src/store/SchedulesApi.ts +114 -0
- package/src/store/ToolsApi.ts +19 -0
- package/src/store/TypesApi.ts +65 -0
- package/src/store/WorkersApi.ts +17 -0
- package/src/store/WorkflowsApi.ts +752 -0
- package/src/store/client.ts +95 -0
- package/src/store/errors.ts +7 -0
- package/src/store/index.ts +11 -0
- package/src/store/version.ts +2 -0
- package/tsconfig.dist.json +20 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
import { DataStoreApiHeaders, } from "@vertesia/common";
|
|
3
|
+
import { DashboardApi } from "./DashboardApi.js";
|
|
4
|
+
/**
|
|
5
|
+
* Client API for managing versioned analytical data stores.
|
|
6
|
+
*
|
|
7
|
+
* Data stores provide DuckDB-powered analytical databases with:
|
|
8
|
+
* - AI-manageable schemas
|
|
9
|
+
* - Multi-table atomic imports
|
|
10
|
+
* - Version history and rollback
|
|
11
|
+
* - Named snapshots
|
|
12
|
+
*/
|
|
13
|
+
export class DataApi extends ApiTopic {
|
|
14
|
+
constructor(parent) {
|
|
15
|
+
super(parent, "/api/v1/data");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create headers with data store ID for Cloud Run session affinity.
|
|
19
|
+
* This routes requests for the same store to the same instance.
|
|
20
|
+
*/
|
|
21
|
+
storeHeaders(id) {
|
|
22
|
+
return { [DataStoreApiHeaders.DATA_STORE_ID]: id };
|
|
23
|
+
}
|
|
24
|
+
// ============================================================
|
|
25
|
+
// Store Operations
|
|
26
|
+
// ============================================================
|
|
27
|
+
/**
|
|
28
|
+
* List all data stores in the project.
|
|
29
|
+
*/
|
|
30
|
+
list() {
|
|
31
|
+
return this.get("/");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new data store.
|
|
35
|
+
*
|
|
36
|
+
* @param payload - Store configuration including name and optional description
|
|
37
|
+
* @returns The created data store
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const store = await client.data.create({
|
|
42
|
+
* name: 'analytics',
|
|
43
|
+
* description: 'Customer analytics data'
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
create(payload) {
|
|
48
|
+
return this.post("/", { payload });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieve a data store by ID.
|
|
52
|
+
*
|
|
53
|
+
* @param id - Data store ID
|
|
54
|
+
* @returns The data store with full details
|
|
55
|
+
*/
|
|
56
|
+
retrieve(id) {
|
|
57
|
+
return this.get(`/${id}`, { headers: this.storeHeaders(id) });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Archive (soft delete) a data store.
|
|
61
|
+
*
|
|
62
|
+
* The store data remains in GCS but is no longer accessible via API.
|
|
63
|
+
*
|
|
64
|
+
* @param id - Data store ID
|
|
65
|
+
* @returns Object with the archived store ID
|
|
66
|
+
*/
|
|
67
|
+
delete(id) {
|
|
68
|
+
return this.del(`/${id}`, { headers: this.storeHeaders(id) });
|
|
69
|
+
}
|
|
70
|
+
// ============================================================
|
|
71
|
+
// Schema Operations
|
|
72
|
+
// ============================================================
|
|
73
|
+
/**
|
|
74
|
+
* Get the schema of a data store.
|
|
75
|
+
*
|
|
76
|
+
* @param id - Data store ID
|
|
77
|
+
* @param format - Optional format: 'ai' returns AI-friendly simplified schema
|
|
78
|
+
* @returns The schema (full or AI-friendly format)
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* // Get full schema
|
|
83
|
+
* const schema = await client.data.getSchema(storeId);
|
|
84
|
+
*
|
|
85
|
+
* // Get AI-friendly schema for agent context
|
|
86
|
+
* const aiSchema = await client.data.getSchema(storeId, 'ai');
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
getSchema(id, format) {
|
|
90
|
+
const query = format ? `?format=${format}` : '';
|
|
91
|
+
return this.get(`/${id}/schema${query}`, { headers: this.storeHeaders(id) });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Update the schema of a data store.
|
|
95
|
+
*
|
|
96
|
+
* Use this for AI-driven schema evolution. The schema version is automatically
|
|
97
|
+
* incremented based on the type of change (major, minor, patch).
|
|
98
|
+
*
|
|
99
|
+
* @param id - Data store ID
|
|
100
|
+
* @param payload - Schema update payload with bump type
|
|
101
|
+
* @returns The updated schema
|
|
102
|
+
*/
|
|
103
|
+
updateSchema(id, payload) {
|
|
104
|
+
return this.put(`/${id}/schema`, { payload, headers: this.storeHeaders(id) });
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the schema version history of a data store.
|
|
108
|
+
*
|
|
109
|
+
* @param id - Data store ID
|
|
110
|
+
* @returns List of schema versions with timestamps
|
|
111
|
+
*/
|
|
112
|
+
getSchemaHistory(id) {
|
|
113
|
+
return this.get(`/${id}/schema/history`, { headers: this.storeHeaders(id) });
|
|
114
|
+
}
|
|
115
|
+
// ============================================================
|
|
116
|
+
// Table Operations
|
|
117
|
+
// ============================================================
|
|
118
|
+
/**
|
|
119
|
+
* List all tables in a data store.
|
|
120
|
+
*
|
|
121
|
+
* @param id - Data store ID
|
|
122
|
+
* @returns List of table summaries with metadata
|
|
123
|
+
*/
|
|
124
|
+
listTables(id) {
|
|
125
|
+
return this.get(`/${id}/tables`, { headers: this.storeHeaders(id) });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create tables in a data store atomically.
|
|
129
|
+
*
|
|
130
|
+
* All tables are created in a single transaction - if any table fails,
|
|
131
|
+
* no tables are created.
|
|
132
|
+
*
|
|
133
|
+
* @param id - Data store ID
|
|
134
|
+
* @param payload - Tables to create and commit message
|
|
135
|
+
* @returns Array of created tables
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const tables = await client.data.createTables(storeId, {
|
|
140
|
+
* message: 'Create e-commerce schema',
|
|
141
|
+
* tables: [
|
|
142
|
+
* {
|
|
143
|
+
* name: 'customers',
|
|
144
|
+
* columns: [
|
|
145
|
+
* { name: 'id', type: 'INTEGER', primary_key: true },
|
|
146
|
+
* { name: 'email', type: 'STRING' },
|
|
147
|
+
* ]
|
|
148
|
+
* },
|
|
149
|
+
* {
|
|
150
|
+
* name: 'orders',
|
|
151
|
+
* columns: [
|
|
152
|
+
* { name: 'id', type: 'INTEGER', primary_key: true },
|
|
153
|
+
* { name: 'customer_id', type: 'INTEGER' },
|
|
154
|
+
* ],
|
|
155
|
+
* foreign_keys: [
|
|
156
|
+
* { column: 'customer_id', references_table: 'customers', references_column: 'id' }
|
|
157
|
+
* ]
|
|
158
|
+
* }
|
|
159
|
+
* ]
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
createTables(id, payload) {
|
|
164
|
+
return this.post(`/${id}/tables`, { payload, headers: this.storeHeaders(id) });
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get a table by name.
|
|
168
|
+
*
|
|
169
|
+
* @param id - Data store ID
|
|
170
|
+
* @param tableName - Table name
|
|
171
|
+
* @param sample - If true, includes sample rows
|
|
172
|
+
* @returns The table with metadata and optional sample data
|
|
173
|
+
*/
|
|
174
|
+
getTable(id, tableName, sample) {
|
|
175
|
+
const query = sample ? '?sample=true' : '';
|
|
176
|
+
return this.get(`/${id}/tables/${tableName}${query}`, { headers: this.storeHeaders(id) });
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Alter a table schema.
|
|
180
|
+
*
|
|
181
|
+
* @param id - Data store ID
|
|
182
|
+
* @param tableName - Table name
|
|
183
|
+
* @param payload - Changes to apply (add/drop/modify columns, etc.)
|
|
184
|
+
* @returns The updated table
|
|
185
|
+
*/
|
|
186
|
+
alterTable(id, tableName, payload) {
|
|
187
|
+
return this.put(`/${id}/tables/${tableName}`, { payload, headers: this.storeHeaders(id) });
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Drop a table from the data store.
|
|
191
|
+
*
|
|
192
|
+
* @param id - Data store ID
|
|
193
|
+
* @param tableName - Table name
|
|
194
|
+
*/
|
|
195
|
+
dropTable(id, tableName) {
|
|
196
|
+
return this.del(`/${id}/tables/${tableName}`, { headers: this.storeHeaders(id) });
|
|
197
|
+
}
|
|
198
|
+
// ============================================================
|
|
199
|
+
// Import Operations
|
|
200
|
+
// ============================================================
|
|
201
|
+
/**
|
|
202
|
+
* Import data into one or more tables atomically.
|
|
203
|
+
*
|
|
204
|
+
* If any table import fails, the entire operation is rolled back.
|
|
205
|
+
* Creates a version snapshot before the import for recovery.
|
|
206
|
+
*
|
|
207
|
+
* @param id - Data store ID
|
|
208
|
+
* @param payload - Import configuration with tables and data
|
|
209
|
+
* @returns Import job with status
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const job = await client.data.import(storeId, {
|
|
214
|
+
* mode: 'append',
|
|
215
|
+
* message: 'Monthly data import',
|
|
216
|
+
* tables: {
|
|
217
|
+
* customers: {
|
|
218
|
+
* source: 'gs://bucket/customers.csv',
|
|
219
|
+
* format: 'csv'
|
|
220
|
+
* },
|
|
221
|
+
* orders: {
|
|
222
|
+
* data: [
|
|
223
|
+
* { id: 1, customer_id: 1, amount: 99.99 }
|
|
224
|
+
* ]
|
|
225
|
+
* }
|
|
226
|
+
* }
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
import(id, payload) {
|
|
231
|
+
return this.post(`/${id}/import`, { payload, headers: this.storeHeaders(id) });
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get the status of an import job.
|
|
235
|
+
*
|
|
236
|
+
* @param id - Data store ID
|
|
237
|
+
* @param importId - Import job ID
|
|
238
|
+
* @returns Import job status
|
|
239
|
+
*/
|
|
240
|
+
getImportStatus(id, importId) {
|
|
241
|
+
return this.get(`/${id}/import/${importId}`, { headers: this.storeHeaders(id) });
|
|
242
|
+
}
|
|
243
|
+
// ============================================================
|
|
244
|
+
// Version Operations
|
|
245
|
+
// ============================================================
|
|
246
|
+
/**
|
|
247
|
+
* List versions of a data store.
|
|
248
|
+
*
|
|
249
|
+
* @param id - Data store ID
|
|
250
|
+
* @param snapshotsOnly - If true, only returns named snapshots
|
|
251
|
+
* @returns List of versions
|
|
252
|
+
*/
|
|
253
|
+
listVersions(id, snapshotsOnly) {
|
|
254
|
+
const query = snapshotsOnly ? '?snapshots_only=true' : '';
|
|
255
|
+
return this.get(`/${id}/versions${query}`, { headers: this.storeHeaders(id) });
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Create a named snapshot of the current state.
|
|
259
|
+
*
|
|
260
|
+
* Named snapshots are kept indefinitely (not subject to 30-day cleanup).
|
|
261
|
+
*
|
|
262
|
+
* @param id - Data store ID
|
|
263
|
+
* @param payload - Snapshot name and optional message
|
|
264
|
+
* @returns The created version/snapshot
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const snapshot = await client.data.createSnapshot(storeId, {
|
|
269
|
+
* name: 'before-migration',
|
|
270
|
+
* message: 'Snapshot before major schema change'
|
|
271
|
+
* });
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
createSnapshot(id, payload) {
|
|
275
|
+
return this.post(`/${id}/versions`, { payload, headers: this.storeHeaders(id) });
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Rollback to a previous version.
|
|
279
|
+
*
|
|
280
|
+
* Creates a new version that is a copy of the target version.
|
|
281
|
+
*
|
|
282
|
+
* @param id - Data store ID
|
|
283
|
+
* @param versionId - Version ID to rollback to
|
|
284
|
+
* @returns The updated data store
|
|
285
|
+
*/
|
|
286
|
+
rollback(id, versionId) {
|
|
287
|
+
return this.post(`/${id}/versions/${versionId}/rollback`, { headers: this.storeHeaders(id) });
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Query a specific version or snapshot without rolling back.
|
|
291
|
+
*
|
|
292
|
+
* Useful for migrations: read data from old schema format to transform it.
|
|
293
|
+
*
|
|
294
|
+
* @param id - Data store ID
|
|
295
|
+
* @param versionId - Version ID or snapshot ID to query
|
|
296
|
+
* @param payload - Query configuration
|
|
297
|
+
* @returns Query results from the version
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* // Create snapshot before migration
|
|
302
|
+
* const snapshot = await client.data.createSnapshot(storeId, {
|
|
303
|
+
* name: 'pre-migration',
|
|
304
|
+
* message: 'Before name split migration'
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* // Query old data from snapshot
|
|
308
|
+
* const oldData = await client.data.queryVersion(storeId, snapshot.id, {
|
|
309
|
+
* sql: 'SELECT id, full_name, email FROM customers'
|
|
310
|
+
* });
|
|
311
|
+
*
|
|
312
|
+
* // Transform and import with new schema...
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
queryVersion(id, versionId, payload) {
|
|
316
|
+
return this.post(`/${id}/versions/${versionId}/query`, { payload, headers: this.storeHeaders(id) });
|
|
317
|
+
}
|
|
318
|
+
// ============================================================
|
|
319
|
+
// Query Operations
|
|
320
|
+
// ============================================================
|
|
321
|
+
/**
|
|
322
|
+
* Execute a read-only SQL query against the data store.
|
|
323
|
+
*
|
|
324
|
+
* @param id - Data store ID
|
|
325
|
+
* @param payload - Query configuration
|
|
326
|
+
* @returns Query results
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const result = await client.data.query(storeId, {
|
|
331
|
+
* sql: 'SELECT customer_id, SUM(amount) as total FROM orders GROUP BY customer_id',
|
|
332
|
+
* limit: 100
|
|
333
|
+
* });
|
|
334
|
+
* console.log(result.rows);
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
query(id, payload) {
|
|
338
|
+
return this.post(`/${id}/query`, { payload, headers: this.storeHeaders(id) });
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Validate SQL queries without executing them.
|
|
342
|
+
*
|
|
343
|
+
* Uses DuckDB's EXPLAIN to check syntax and table/column references
|
|
344
|
+
* against the store's schema. Useful for validating dashboard queries
|
|
345
|
+
* before saving.
|
|
346
|
+
*
|
|
347
|
+
* @param id - Data store ID
|
|
348
|
+
* @param queries - Array of queries to validate
|
|
349
|
+
* @returns Validation result with any errors
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const result = await client.data.validateQueries(storeId, [
|
|
354
|
+
* { name: 'sales', sql: 'SELECT * FROM sales WHERE date > {{start_date}}' },
|
|
355
|
+
* { name: 'products', sql: 'SELECT * FROM productss' } // typo!
|
|
356
|
+
* ]);
|
|
357
|
+
*
|
|
358
|
+
* if (!result.valid) {
|
|
359
|
+
* for (const err of result.errors) {
|
|
360
|
+
* console.log(`Query '${err.query}': ${err.error}`);
|
|
361
|
+
* }
|
|
362
|
+
* }
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
validateQueries(id, queries) {
|
|
366
|
+
return this.post(`/${id}/query/validate`, { payload: { queries }, headers: this.storeHeaders(id) });
|
|
367
|
+
}
|
|
368
|
+
// ============================================================
|
|
369
|
+
// Download Operations (for sandbox sync)
|
|
370
|
+
// ============================================================
|
|
371
|
+
/**
|
|
372
|
+
* Get a signed download URL for the database file.
|
|
373
|
+
*
|
|
374
|
+
* Used by sandbox to sync databases for native DuckDB access.
|
|
375
|
+
* Returns signed URL + gcs_generation for cache validation.
|
|
376
|
+
*
|
|
377
|
+
* @param id - Data store ID
|
|
378
|
+
* @param versionId - Optional: specific version/snapshot ID (default: latest)
|
|
379
|
+
* @returns Download info with signed URL and cache validation data
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const info = await client.data.getDownloadInfo(storeId);
|
|
384
|
+
* // Download if gcs_generation changed
|
|
385
|
+
* if (info.gcs_generation !== localGeneration) {
|
|
386
|
+
* await downloadFile(info.url, '/home/daytona/databases/store.duckdb');
|
|
387
|
+
* }
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
getDownloadInfo(id, versionId) {
|
|
391
|
+
const query = versionId ? `?version_id=${versionId}` : '';
|
|
392
|
+
return this.get(`/${id}/download${query}`, { headers: this.storeHeaders(id) });
|
|
393
|
+
}
|
|
394
|
+
// ============================================================
|
|
395
|
+
// Dashboard Operations
|
|
396
|
+
// ============================================================
|
|
397
|
+
/**
|
|
398
|
+
* Get the Dashboard API for a specific data store.
|
|
399
|
+
*
|
|
400
|
+
* @param storeId - Data store ID
|
|
401
|
+
* @returns DashboardApi instance for managing dashboards
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* // List dashboards
|
|
406
|
+
* const dashboards = await client.data.dashboards(storeId).list();
|
|
407
|
+
*
|
|
408
|
+
* // Preview a dashboard before creating
|
|
409
|
+
* const preview = await client.data.dashboards(storeId).preview({
|
|
410
|
+
* queries: [{ name: 'sales', sql: 'SELECT * FROM sales' }],
|
|
411
|
+
* panels: [{ title: 'Sales', dataSources: ['sales'], ... }]
|
|
412
|
+
* });
|
|
413
|
+
*
|
|
414
|
+
* // Create a dashboard
|
|
415
|
+
* const dashboard = await client.data.dashboards(storeId).create({
|
|
416
|
+
* name: 'Sales Overview',
|
|
417
|
+
* queries: [...],
|
|
418
|
+
* panels: [...]
|
|
419
|
+
* });
|
|
420
|
+
*
|
|
421
|
+
* // Render dashboard to PNG
|
|
422
|
+
* const result = await client.data.dashboards(storeId).render(dashboardId);
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
dashboards(storeId) {
|
|
426
|
+
return new DashboardApi(this.client, storeId);
|
|
427
|
+
}
|
|
428
|
+
}
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E,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,CACX,EAAU,EACV,OAA6C;QAE7C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxG,CAAC;IAED,+DAA+D;IAC/D,yCAAyC;IACzC,+DAA+D;IAE/D;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,EAAU,EAAE,SAAkB;QAC1C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,+DAA+D;IAC/D,uBAAuB;IACvB,+DAA+D;IAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,UAAU,CAAC,OAAe;QACtB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACJ"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
/**
|
|
3
|
+
* Email API for sending emails from workflows.
|
|
4
|
+
*/
|
|
5
|
+
export class EmailApi extends ApiTopic {
|
|
6
|
+
constructor(parent) {
|
|
7
|
+
super(parent, "/api/v1/email");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Send an email from an agent/workflow.
|
|
11
|
+
* Creates a route key if not provided, sends via Resend, and returns routing info.
|
|
12
|
+
*/
|
|
13
|
+
send(request) {
|
|
14
|
+
return this.post("/send", { payload: request });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a route key to get email context.
|
|
18
|
+
* Used by webhook handler to look up workflow info from reply email.
|
|
19
|
+
* @deprecated Use getRoute() instead
|
|
20
|
+
*/
|
|
21
|
+
resolveRoute(routeKey) {
|
|
22
|
+
return this.post("/resolve-route", { payload: { route_key: routeKey } });
|
|
23
|
+
}
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Routes API - for external service integration
|
|
26
|
+
// ============================================================================
|
|
27
|
+
/**
|
|
28
|
+
* Create a new email route without sending an email.
|
|
29
|
+
* Useful for external services that want to handle email sending themselves
|
|
30
|
+
* but need reply routing back to Vertesia workflows.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const { route_key, reply_to } = await client.store.email.createRoute({
|
|
35
|
+
* run_id: workflowRunId,
|
|
36
|
+
* user_email: "user@example.com",
|
|
37
|
+
* thread_subject: "Contract Review"
|
|
38
|
+
* });
|
|
39
|
+
* // Use reply_to as the Reply-To header when sending your own email
|
|
40
|
+
* // Replies will be routed back to the workflow
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
createRoute(request) {
|
|
44
|
+
return this.post("/routes", { payload: request });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get an email route by key.
|
|
48
|
+
*/
|
|
49
|
+
getRoute(routeKey) {
|
|
50
|
+
return this.get(`/routes/${routeKey}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Update an email route (e.g., to update threading info).
|
|
54
|
+
*/
|
|
55
|
+
updateRoute(routeKey, updates) {
|
|
56
|
+
return this.put(`/routes/${routeKey}`, { payload: updates });
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Forward an email to a workflow via route key.
|
|
60
|
+
*
|
|
61
|
+
* Use this when your service receives an email reply and needs to forward
|
|
62
|
+
* it to the Vertesia workflow. You can add custom context data (like auth
|
|
63
|
+
* tokens or user IDs) that will be merged into `payload.vars.data`.
|
|
64
|
+
*
|
|
65
|
+
* **Important**: Use camelCase keys in context to match the agent start
|
|
66
|
+
* pattern. This ensures tools work identically whether the agent was
|
|
67
|
+
* started directly or received an email reply.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* // In your email webhook handler:
|
|
72
|
+
* const result = await client.store.email.forwardEmail(routeKey, {
|
|
73
|
+
* email: {
|
|
74
|
+
* from: inboundEmail.from,
|
|
75
|
+
* subject: inboundEmail.subject,
|
|
76
|
+
* text: inboundEmail.text,
|
|
77
|
+
* message_id: inboundEmail.messageId,
|
|
78
|
+
* },
|
|
79
|
+
* context: {
|
|
80
|
+
* // Use camelCase - merged into payload.vars.data
|
|
81
|
+
* apiKey: generateServiceToken(),
|
|
82
|
+
* tenantId: resolvedUser.tenantId,
|
|
83
|
+
* userId: resolvedUser.id,
|
|
84
|
+
* userEmail: resolvedUser.email,
|
|
85
|
+
* },
|
|
86
|
+
* attachments: inboundEmail.attachments?.map(att => ({
|
|
87
|
+
* filename: att.filename,
|
|
88
|
+
* content_type: att.contentType,
|
|
89
|
+
* size: att.size,
|
|
90
|
+
* download_url: att.url,
|
|
91
|
+
* })),
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
forwardEmail(routeKey, request) {
|
|
96
|
+
return this.post(`/routes/${routeKey}/forward`, { payload: request });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=EmailApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailApi.js","sourceRoot":"","sources":["../../../src/store/EmailApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AA2GlE;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,QAAQ;IA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eddingsApi extends ApiTopic {
|
|
6
|
+
constructor(parent, basePath = "/api/v1/embeddings") {
|
|
7
|
+
super(parent, basePath);
|
|
8
|
+
}
|
|
9
|
+
async status(type) {
|
|
10
|
+
return this.get(type + "/status");
|
|
11
|
+
}
|
|
12
|
+
async activate(type, config) {
|
|
13
|
+
if (!config.environment) {
|
|
14
|
+
throw new Error("Invalid configuration: select environment");
|
|
15
|
+
}
|
|
16
|
+
return this.post(type + "/enable", { payload: config });
|
|
17
|
+
}
|
|
18
|
+
async disable(type) {
|
|
19
|
+
return this.post(type + "/disable");
|
|
20
|
+
}
|
|
21
|
+
async recalculate(type) {
|
|
22
|
+
return this.post(type + "/recalculate");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=EmbeddingsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingsApi.js","sourceRoot":"","sources":["../../../src/store/EmbeddingsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAQlE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAEvC,YAAY,MAAkB,EAAE,WAAmB,oBAAoB;QACnE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAA6B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAA6B,EAAE,MAA+C;QAEzF,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAA6B;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAA6B;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,CAAC;IAC5C,CAAC;CAEJ"}
|