@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,516 @@
|
|
|
1
|
+
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
+
import {
|
|
3
|
+
AlterTablePayload,
|
|
4
|
+
CreateDataStorePayload,
|
|
5
|
+
CreateSnapshotPayload,
|
|
6
|
+
CreateTablesPayload,
|
|
7
|
+
DataSchema,
|
|
8
|
+
DataSchemaForAI,
|
|
9
|
+
DataStore,
|
|
10
|
+
DataStoreApiHeaders,
|
|
11
|
+
DataStoreItem,
|
|
12
|
+
DataStoreVersion,
|
|
13
|
+
DataTable,
|
|
14
|
+
DataTableSummary,
|
|
15
|
+
ImportDataPayload,
|
|
16
|
+
ImportJob,
|
|
17
|
+
QueryPayload,
|
|
18
|
+
QueryResult,
|
|
19
|
+
UpdateSchemaPayload,
|
|
20
|
+
} from "@vertesia/common";
|
|
21
|
+
import { DashboardApi } from "./DashboardApi.js";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Client API for managing versioned analytical data stores.
|
|
25
|
+
*
|
|
26
|
+
* Data stores provide DuckDB-powered analytical databases with:
|
|
27
|
+
* - AI-manageable schemas
|
|
28
|
+
* - Multi-table atomic imports
|
|
29
|
+
* - Version history and rollback
|
|
30
|
+
* - Named snapshots
|
|
31
|
+
*/
|
|
32
|
+
export class DataApi extends ApiTopic {
|
|
33
|
+
constructor(parent: ClientBase) {
|
|
34
|
+
super(parent, "/api/v1/data");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create headers with data store ID for Cloud Run session affinity.
|
|
39
|
+
* This routes requests for the same store to the same instance.
|
|
40
|
+
*/
|
|
41
|
+
private storeHeaders(id: string): Record<string, string> {
|
|
42
|
+
return { [DataStoreApiHeaders.DATA_STORE_ID]: id };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ============================================================
|
|
46
|
+
// Store Operations
|
|
47
|
+
// ============================================================
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* List all data stores in the project.
|
|
51
|
+
*/
|
|
52
|
+
list(): Promise<DataStoreItem[]> {
|
|
53
|
+
return this.get("/");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Create a new data store.
|
|
58
|
+
*
|
|
59
|
+
* @param payload - Store configuration including name and optional description
|
|
60
|
+
* @returns The created data store
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const store = await client.data.create({
|
|
65
|
+
* name: 'analytics',
|
|
66
|
+
* description: 'Customer analytics data'
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
create(payload: CreateDataStorePayload): Promise<DataStore> {
|
|
71
|
+
return this.post("/", { payload });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Retrieve a data store by ID.
|
|
76
|
+
*
|
|
77
|
+
* @param id - Data store ID
|
|
78
|
+
* @returns The data store with full details
|
|
79
|
+
*/
|
|
80
|
+
retrieve(id: string): Promise<DataStore> {
|
|
81
|
+
return this.get(`/${id}`, { headers: this.storeHeaders(id) });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Archive (soft delete) a data store.
|
|
86
|
+
*
|
|
87
|
+
* The store data remains in GCS but is no longer accessible via API.
|
|
88
|
+
*
|
|
89
|
+
* @param id - Data store ID
|
|
90
|
+
* @returns Object with the archived store ID
|
|
91
|
+
*/
|
|
92
|
+
delete(id: string): Promise<{ id: string }> {
|
|
93
|
+
return this.del(`/${id}`, { headers: this.storeHeaders(id) });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ============================================================
|
|
97
|
+
// Schema Operations
|
|
98
|
+
// ============================================================
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the schema of a data store.
|
|
102
|
+
*
|
|
103
|
+
* @param id - Data store ID
|
|
104
|
+
* @param format - Optional format: 'ai' returns AI-friendly simplified schema
|
|
105
|
+
* @returns The schema (full or AI-friendly format)
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* // Get full schema
|
|
110
|
+
* const schema = await client.data.getSchema(storeId);
|
|
111
|
+
*
|
|
112
|
+
* // Get AI-friendly schema for agent context
|
|
113
|
+
* const aiSchema = await client.data.getSchema(storeId, 'ai');
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
getSchema(id: string, format?: 'ai'): Promise<DataSchema | DataSchemaForAI> {
|
|
117
|
+
const query = format ? `?format=${format}` : '';
|
|
118
|
+
return this.get(`/${id}/schema${query}`, { headers: this.storeHeaders(id) });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Update the schema of a data store.
|
|
123
|
+
*
|
|
124
|
+
* Use this for AI-driven schema evolution. The schema version is automatically
|
|
125
|
+
* incremented based on the type of change (major, minor, patch).
|
|
126
|
+
*
|
|
127
|
+
* @param id - Data store ID
|
|
128
|
+
* @param payload - Schema update payload with bump type
|
|
129
|
+
* @returns The updated schema
|
|
130
|
+
*/
|
|
131
|
+
updateSchema(id: string, payload: UpdateSchemaPayload): Promise<DataSchema> {
|
|
132
|
+
return this.put(`/${id}/schema`, { payload, headers: this.storeHeaders(id) });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get the schema version history of a data store.
|
|
137
|
+
*
|
|
138
|
+
* @param id - Data store ID
|
|
139
|
+
* @returns List of schema versions with timestamps
|
|
140
|
+
*/
|
|
141
|
+
getSchemaHistory(id: string): Promise<DataStoreVersion[]> {
|
|
142
|
+
return this.get(`/${id}/schema/history`, { headers: this.storeHeaders(id) });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ============================================================
|
|
146
|
+
// Table Operations
|
|
147
|
+
// ============================================================
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* List all tables in a data store.
|
|
151
|
+
*
|
|
152
|
+
* @param id - Data store ID
|
|
153
|
+
* @returns List of table summaries with metadata
|
|
154
|
+
*/
|
|
155
|
+
listTables(id: string): Promise<DataTableSummary[]> {
|
|
156
|
+
return this.get(`/${id}/tables`, { headers: this.storeHeaders(id) });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Create tables in a data store atomically.
|
|
161
|
+
*
|
|
162
|
+
* All tables are created in a single transaction - if any table fails,
|
|
163
|
+
* no tables are created.
|
|
164
|
+
*
|
|
165
|
+
* @param id - Data store ID
|
|
166
|
+
* @param payload - Tables to create and commit message
|
|
167
|
+
* @returns Array of created tables
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const tables = await client.data.createTables(storeId, {
|
|
172
|
+
* message: 'Create e-commerce schema',
|
|
173
|
+
* tables: [
|
|
174
|
+
* {
|
|
175
|
+
* name: 'customers',
|
|
176
|
+
* columns: [
|
|
177
|
+
* { name: 'id', type: 'INTEGER', primary_key: true },
|
|
178
|
+
* { name: 'email', type: 'STRING' },
|
|
179
|
+
* ]
|
|
180
|
+
* },
|
|
181
|
+
* {
|
|
182
|
+
* name: 'orders',
|
|
183
|
+
* columns: [
|
|
184
|
+
* { name: 'id', type: 'INTEGER', primary_key: true },
|
|
185
|
+
* { name: 'customer_id', type: 'INTEGER' },
|
|
186
|
+
* ],
|
|
187
|
+
* foreign_keys: [
|
|
188
|
+
* { column: 'customer_id', references_table: 'customers', references_column: 'id' }
|
|
189
|
+
* ]
|
|
190
|
+
* }
|
|
191
|
+
* ]
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
createTables(id: string, payload: CreateTablesPayload): Promise<DataTable[]> {
|
|
196
|
+
return this.post(`/${id}/tables`, { payload, headers: this.storeHeaders(id) });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Get a table by name.
|
|
201
|
+
*
|
|
202
|
+
* @param id - Data store ID
|
|
203
|
+
* @param tableName - Table name
|
|
204
|
+
* @param sample - If true, includes sample rows
|
|
205
|
+
* @returns The table with metadata and optional sample data
|
|
206
|
+
*/
|
|
207
|
+
getTable(id: string, tableName: string, sample?: boolean): Promise<DataTable & { sampleRows?: Record<string, unknown>[] }> {
|
|
208
|
+
const query = sample ? '?sample=true' : '';
|
|
209
|
+
return this.get(`/${id}/tables/${tableName}${query}`, { headers: this.storeHeaders(id) });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Alter a table schema.
|
|
214
|
+
*
|
|
215
|
+
* @param id - Data store ID
|
|
216
|
+
* @param tableName - Table name
|
|
217
|
+
* @param payload - Changes to apply (add/drop/modify columns, etc.)
|
|
218
|
+
* @returns The updated table
|
|
219
|
+
*/
|
|
220
|
+
alterTable(id: string, tableName: string, payload: AlterTablePayload): Promise<DataTable> {
|
|
221
|
+
return this.put(`/${id}/tables/${tableName}`, { payload, headers: this.storeHeaders(id) });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Drop a table from the data store.
|
|
226
|
+
*
|
|
227
|
+
* @param id - Data store ID
|
|
228
|
+
* @param tableName - Table name
|
|
229
|
+
*/
|
|
230
|
+
dropTable(id: string, tableName: string): Promise<void> {
|
|
231
|
+
return this.del(`/${id}/tables/${tableName}`, { headers: this.storeHeaders(id) });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ============================================================
|
|
235
|
+
// Import Operations
|
|
236
|
+
// ============================================================
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Import data into one or more tables atomically.
|
|
240
|
+
*
|
|
241
|
+
* If any table import fails, the entire operation is rolled back.
|
|
242
|
+
* Creates a version snapshot before the import for recovery.
|
|
243
|
+
*
|
|
244
|
+
* @param id - Data store ID
|
|
245
|
+
* @param payload - Import configuration with tables and data
|
|
246
|
+
* @returns Import job with status
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* const job = await client.data.import(storeId, {
|
|
251
|
+
* mode: 'append',
|
|
252
|
+
* message: 'Monthly data import',
|
|
253
|
+
* tables: {
|
|
254
|
+
* customers: {
|
|
255
|
+
* source: 'gs://bucket/customers.csv',
|
|
256
|
+
* format: 'csv'
|
|
257
|
+
* },
|
|
258
|
+
* orders: {
|
|
259
|
+
* data: [
|
|
260
|
+
* { id: 1, customer_id: 1, amount: 99.99 }
|
|
261
|
+
* ]
|
|
262
|
+
* }
|
|
263
|
+
* }
|
|
264
|
+
* });
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
import(id: string, payload: ImportDataPayload): Promise<ImportJob> {
|
|
268
|
+
return this.post(`/${id}/import`, { payload, headers: this.storeHeaders(id) });
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get the status of an import job.
|
|
273
|
+
*
|
|
274
|
+
* @param id - Data store ID
|
|
275
|
+
* @param importId - Import job ID
|
|
276
|
+
* @returns Import job status
|
|
277
|
+
*/
|
|
278
|
+
getImportStatus(id: string, importId: string): Promise<ImportJob> {
|
|
279
|
+
return this.get(`/${id}/import/${importId}`, { headers: this.storeHeaders(id) });
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ============================================================
|
|
283
|
+
// Version Operations
|
|
284
|
+
// ============================================================
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* List versions of a data store.
|
|
288
|
+
*
|
|
289
|
+
* @param id - Data store ID
|
|
290
|
+
* @param snapshotsOnly - If true, only returns named snapshots
|
|
291
|
+
* @returns List of versions
|
|
292
|
+
*/
|
|
293
|
+
listVersions(id: string, snapshotsOnly?: boolean): Promise<DataStoreVersion[]> {
|
|
294
|
+
const query = snapshotsOnly ? '?snapshots_only=true' : '';
|
|
295
|
+
return this.get(`/${id}/versions${query}`, { headers: this.storeHeaders(id) });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Create a named snapshot of the current state.
|
|
300
|
+
*
|
|
301
|
+
* Named snapshots are kept indefinitely (not subject to 30-day cleanup).
|
|
302
|
+
*
|
|
303
|
+
* @param id - Data store ID
|
|
304
|
+
* @param payload - Snapshot name and optional message
|
|
305
|
+
* @returns The created version/snapshot
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const snapshot = await client.data.createSnapshot(storeId, {
|
|
310
|
+
* name: 'before-migration',
|
|
311
|
+
* message: 'Snapshot before major schema change'
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
createSnapshot(id: string, payload: CreateSnapshotPayload): Promise<DataStoreVersion> {
|
|
316
|
+
return this.post(`/${id}/versions`, { payload, headers: this.storeHeaders(id) });
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Rollback to a previous version.
|
|
321
|
+
*
|
|
322
|
+
* Creates a new version that is a copy of the target version.
|
|
323
|
+
*
|
|
324
|
+
* @param id - Data store ID
|
|
325
|
+
* @param versionId - Version ID to rollback to
|
|
326
|
+
* @returns The updated data store
|
|
327
|
+
*/
|
|
328
|
+
rollback(id: string, versionId: string): Promise<DataStore> {
|
|
329
|
+
return this.post(`/${id}/versions/${versionId}/rollback`, { headers: this.storeHeaders(id) });
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Query a specific version or snapshot without rolling back.
|
|
334
|
+
*
|
|
335
|
+
* Useful for migrations: read data from old schema format to transform it.
|
|
336
|
+
*
|
|
337
|
+
* @param id - Data store ID
|
|
338
|
+
* @param versionId - Version ID or snapshot ID to query
|
|
339
|
+
* @param payload - Query configuration
|
|
340
|
+
* @returns Query results from the version
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* // Create snapshot before migration
|
|
345
|
+
* const snapshot = await client.data.createSnapshot(storeId, {
|
|
346
|
+
* name: 'pre-migration',
|
|
347
|
+
* message: 'Before name split migration'
|
|
348
|
+
* });
|
|
349
|
+
*
|
|
350
|
+
* // Query old data from snapshot
|
|
351
|
+
* const oldData = await client.data.queryVersion(storeId, snapshot.id, {
|
|
352
|
+
* sql: 'SELECT id, full_name, email FROM customers'
|
|
353
|
+
* });
|
|
354
|
+
*
|
|
355
|
+
* // Transform and import with new schema...
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
queryVersion(id: string, versionId: string, payload: QueryPayload): Promise<QueryResult> {
|
|
359
|
+
return this.post(`/${id}/versions/${versionId}/query`, { payload, headers: this.storeHeaders(id) });
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ============================================================
|
|
363
|
+
// Query Operations
|
|
364
|
+
// ============================================================
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Execute a read-only SQL query against the data store.
|
|
368
|
+
*
|
|
369
|
+
* @param id - Data store ID
|
|
370
|
+
* @param payload - Query configuration
|
|
371
|
+
* @returns Query results
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* const result = await client.data.query(storeId, {
|
|
376
|
+
* sql: 'SELECT customer_id, SUM(amount) as total FROM orders GROUP BY customer_id',
|
|
377
|
+
* limit: 100
|
|
378
|
+
* });
|
|
379
|
+
* console.log(result.rows);
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
query(id: string, payload: QueryPayload): Promise<QueryResult> {
|
|
383
|
+
return this.post(`/${id}/query`, { payload, headers: this.storeHeaders(id) });
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Validate SQL queries without executing them.
|
|
388
|
+
*
|
|
389
|
+
* Uses DuckDB's EXPLAIN to check syntax and table/column references
|
|
390
|
+
* against the store's schema. Useful for validating dashboard queries
|
|
391
|
+
* before saving.
|
|
392
|
+
*
|
|
393
|
+
* @param id - Data store ID
|
|
394
|
+
* @param queries - Array of queries to validate
|
|
395
|
+
* @returns Validation result with any errors
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```typescript
|
|
399
|
+
* const result = await client.data.validateQueries(storeId, [
|
|
400
|
+
* { name: 'sales', sql: 'SELECT * FROM sales WHERE date > {{start_date}}' },
|
|
401
|
+
* { name: 'products', sql: 'SELECT * FROM productss' } // typo!
|
|
402
|
+
* ]);
|
|
403
|
+
*
|
|
404
|
+
* if (!result.valid) {
|
|
405
|
+
* for (const err of result.errors) {
|
|
406
|
+
* console.log(`Query '${err.query}': ${err.error}`);
|
|
407
|
+
* }
|
|
408
|
+
* }
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
validateQueries(
|
|
412
|
+
id: string,
|
|
413
|
+
queries: Array<{ name: string; sql: string }>
|
|
414
|
+
): Promise<QueryValidationResult> {
|
|
415
|
+
return this.post(`/${id}/query/validate`, { payload: { queries }, headers: this.storeHeaders(id) });
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// ============================================================
|
|
419
|
+
// Download Operations (for sandbox sync)
|
|
420
|
+
// ============================================================
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Get a signed download URL for the database file.
|
|
424
|
+
*
|
|
425
|
+
* Used by sandbox to sync databases for native DuckDB access.
|
|
426
|
+
* Returns signed URL + gcs_generation for cache validation.
|
|
427
|
+
*
|
|
428
|
+
* @param id - Data store ID
|
|
429
|
+
* @param versionId - Optional: specific version/snapshot ID (default: latest)
|
|
430
|
+
* @returns Download info with signed URL and cache validation data
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* const info = await client.data.getDownloadInfo(storeId);
|
|
435
|
+
* // Download if gcs_generation changed
|
|
436
|
+
* if (info.gcs_generation !== localGeneration) {
|
|
437
|
+
* await downloadFile(info.url, '/home/daytona/databases/store.duckdb');
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
getDownloadInfo(id: string, versionId?: string): Promise<DataStoreDownloadInfo> {
|
|
442
|
+
const query = versionId ? `?version_id=${versionId}` : '';
|
|
443
|
+
return this.get(`/${id}/download${query}`, { headers: this.storeHeaders(id) });
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// ============================================================
|
|
447
|
+
// Dashboard Operations
|
|
448
|
+
// ============================================================
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Get the Dashboard API for a specific data store.
|
|
452
|
+
*
|
|
453
|
+
* @param storeId - Data store ID
|
|
454
|
+
* @returns DashboardApi instance for managing dashboards
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* ```typescript
|
|
458
|
+
* // List dashboards
|
|
459
|
+
* const dashboards = await client.data.dashboards(storeId).list();
|
|
460
|
+
*
|
|
461
|
+
* // Preview a dashboard before creating
|
|
462
|
+
* const preview = await client.data.dashboards(storeId).preview({
|
|
463
|
+
* queries: [{ name: 'sales', sql: 'SELECT * FROM sales' }],
|
|
464
|
+
* panels: [{ title: 'Sales', dataSources: ['sales'], ... }]
|
|
465
|
+
* });
|
|
466
|
+
*
|
|
467
|
+
* // Create a dashboard
|
|
468
|
+
* const dashboard = await client.data.dashboards(storeId).create({
|
|
469
|
+
* name: 'Sales Overview',
|
|
470
|
+
* queries: [...],
|
|
471
|
+
* panels: [...]
|
|
472
|
+
* });
|
|
473
|
+
*
|
|
474
|
+
* // Render dashboard to PNG
|
|
475
|
+
* const result = await client.data.dashboards(storeId).render(dashboardId);
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
dashboards(storeId: string): DashboardApi {
|
|
479
|
+
return new DashboardApi(this.client, storeId);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Response from the download endpoint.
|
|
485
|
+
*/
|
|
486
|
+
export interface DataStoreDownloadInfo {
|
|
487
|
+
/** Signed download URL (expires in 15 min) */
|
|
488
|
+
url: string;
|
|
489
|
+
/** GCS generation number for cache validation */
|
|
490
|
+
gcs_generation: number;
|
|
491
|
+
/** Schema version */
|
|
492
|
+
schema_version: string;
|
|
493
|
+
/** Store ID */
|
|
494
|
+
store_id: string;
|
|
495
|
+
/** Store name */
|
|
496
|
+
store_name: string;
|
|
497
|
+
/** List of table names */
|
|
498
|
+
tables: string[];
|
|
499
|
+
/** URL expiry time in seconds */
|
|
500
|
+
expires_in: number;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Result from SQL query validation.
|
|
505
|
+
*/
|
|
506
|
+
export interface QueryValidationResult {
|
|
507
|
+
/** Whether all queries are valid */
|
|
508
|
+
valid: boolean;
|
|
509
|
+
/** Validation errors (if any) */
|
|
510
|
+
errors: Array<{
|
|
511
|
+
/** Query name that failed validation */
|
|
512
|
+
query: string;
|
|
513
|
+
/** Error message describing the issue */
|
|
514
|
+
error: string;
|
|
515
|
+
}>;
|
|
516
|
+
}
|