@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,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilesApi = exports.ARTIFACTS_PREFIX = exports.MEMORIES_PREFIX = void 0;
|
|
4
|
+
exports.getMemoryFilePath = getMemoryFilePath;
|
|
5
|
+
exports.getAgentArtifactPath = getAgentArtifactPath;
|
|
6
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
7
|
+
const StreamSource_js_1 = require("../StreamSource.js");
|
|
8
|
+
exports.MEMORIES_PREFIX = "memories";
|
|
9
|
+
exports.ARTIFACTS_PREFIX = "agents";
|
|
10
|
+
function getMemoryFilePath(name) {
|
|
11
|
+
const nameWithExt = name.endsWith(".tar.gz") ? name : name + ".tar.gz";
|
|
12
|
+
return `${exports.MEMORIES_PREFIX}/${nameWithExt}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build the storage path for an agent artifact
|
|
16
|
+
* @param runId - The workflow run ID
|
|
17
|
+
* @param name - The artifact filename
|
|
18
|
+
*/
|
|
19
|
+
function getAgentArtifactPath(runId, name) {
|
|
20
|
+
return `${exports.ARTIFACTS_PREFIX}/${runId}/${name}`;
|
|
21
|
+
}
|
|
22
|
+
class FilesApi extends api_fetch_client_1.ApiTopic {
|
|
23
|
+
constructor(parent) {
|
|
24
|
+
super(parent, "/api/v1/files");
|
|
25
|
+
}
|
|
26
|
+
async deleteFile(path, prefix) {
|
|
27
|
+
const res = await this.delete(`/${path}`, { query: { prefix } });
|
|
28
|
+
return res.count;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* get the metadata of a blob given its URI. Supported URI are:
|
|
32
|
+
* starting with s3:// and gs://.
|
|
33
|
+
* For s3 blobs use #region to specify the region. Ex: s3://bucket/key#us-west-2
|
|
34
|
+
* @param uri
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
getMetadata(uri) {
|
|
38
|
+
return this.get("/metadata", {
|
|
39
|
+
query: {
|
|
40
|
+
file: uri,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Set custom metadata on a file
|
|
46
|
+
* @param file - The file path or URI
|
|
47
|
+
* @param metadata - Custom metadata key-value pairs
|
|
48
|
+
* @returns Success status
|
|
49
|
+
*/
|
|
50
|
+
setFileMetadata(file, metadata) {
|
|
51
|
+
const payload = { file, metadata };
|
|
52
|
+
return this.put("/metadata", { payload });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get or create a bucket for the project. If the bucket already exists, it does nothing.
|
|
56
|
+
* The bucket URI is returned.
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
getOrCreateBucket() {
|
|
60
|
+
return this.post("/bucket");
|
|
61
|
+
}
|
|
62
|
+
getUploadUrl(payload) {
|
|
63
|
+
return this.post("/upload-url", {
|
|
64
|
+
payload,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Strictly typed: provide either simple args or a full payload via a separate method
|
|
68
|
+
getDownloadUrl(file, name, disposition) {
|
|
69
|
+
const payload = { file, name, disposition };
|
|
70
|
+
return this.post("/download-url", { payload });
|
|
71
|
+
}
|
|
72
|
+
getDownloadUrlWithOptions(payload) {
|
|
73
|
+
return this.post("/download-url", { payload });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Upload content to a file and return the full path (including bucket name) of the uploaded file
|
|
77
|
+
* @param source
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
async uploadFile(source) {
|
|
81
|
+
const isStream = source instanceof StreamSource_js_1.StreamSource;
|
|
82
|
+
const { url, id, path } = await this.getUploadUrl(source);
|
|
83
|
+
await fetch(url, {
|
|
84
|
+
method: "PUT",
|
|
85
|
+
body: isStream ? source.stream : source,
|
|
86
|
+
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
87
|
+
duplex: isStream ? "half" : undefined,
|
|
88
|
+
headers: {
|
|
89
|
+
"Content-Type": source.type || "application/gzip",
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
.then((res) => {
|
|
93
|
+
if (res.ok) {
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
console.log(res);
|
|
98
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
.catch((err) => {
|
|
102
|
+
console.error("Failed to upload file", { err, url, id, path });
|
|
103
|
+
throw err;
|
|
104
|
+
});
|
|
105
|
+
return id;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param location can be a relative path in the project, a reference to a cloud storage, or a accessible HTTPS URL (typically signed URL)
|
|
110
|
+
* @returns ReadableStream
|
|
111
|
+
*/
|
|
112
|
+
async downloadFile(location) {
|
|
113
|
+
//if start with HTTPS, no download url needed - assume it's signed already
|
|
114
|
+
const needSign = !location.startsWith("https:");
|
|
115
|
+
const { url } = needSign
|
|
116
|
+
? await this.getDownloadUrl(location)
|
|
117
|
+
: { url: location };
|
|
118
|
+
const res = await fetch(url, {
|
|
119
|
+
method: "GET",
|
|
120
|
+
})
|
|
121
|
+
.then((res) => {
|
|
122
|
+
if (res.ok) {
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
else if (res.status === 404) {
|
|
126
|
+
throw new Error(`File at ${url} not found`); //TODO: type fetch error better with a fetch error class
|
|
127
|
+
}
|
|
128
|
+
else if (res.status === 403) {
|
|
129
|
+
throw new Error(`File at ${url} is forbidden`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.log(res);
|
|
133
|
+
throw new Error(`Failed to download file ${location}: ${res.statusText}`);
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
.catch((err) => {
|
|
137
|
+
console.error(`Failed to download file ${location}.`, err);
|
|
138
|
+
throw err;
|
|
139
|
+
});
|
|
140
|
+
if (!res.body) {
|
|
141
|
+
throw new Error(`No body in response while downloading file ${location}`);
|
|
142
|
+
}
|
|
143
|
+
return res.body;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Copy a file to a new destination within the same bucket.
|
|
147
|
+
* @param source - Source file path (relative to project bucket)
|
|
148
|
+
* @param dest - Destination file path (relative to project bucket)
|
|
149
|
+
* @returns The destination file URI
|
|
150
|
+
*/
|
|
151
|
+
async copyFile(source, dest) {
|
|
152
|
+
const response = await this.post("/copy", {
|
|
153
|
+
payload: { source, dest },
|
|
154
|
+
});
|
|
155
|
+
return response.dest;
|
|
156
|
+
}
|
|
157
|
+
async uploadMemoryPack(source) {
|
|
158
|
+
const fileId = getMemoryFilePath(source.name);
|
|
159
|
+
const nameWithExt = source.name.endsWith(".tar.gz")
|
|
160
|
+
? source.name
|
|
161
|
+
: source.name + ".tar.gz";
|
|
162
|
+
if (source instanceof File) {
|
|
163
|
+
let file = source;
|
|
164
|
+
return this.uploadFile(new StreamSource_js_1.StreamSource(file.stream(), nameWithExt, file.type, fileId));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return this.uploadFile(new StreamSource_js_1.StreamSource(source.stream, nameWithExt, source.type, fileId));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async downloadMemoryPack(name, gunzip = false) {
|
|
171
|
+
let stream = await this.downloadFile(getMemoryFilePath(name));
|
|
172
|
+
if (gunzip) {
|
|
173
|
+
const ds = new DecompressionStream("gzip");
|
|
174
|
+
stream = stream.pipeThrough(ds);
|
|
175
|
+
}
|
|
176
|
+
return stream;
|
|
177
|
+
}
|
|
178
|
+
// ==================== Agent Artifact Methods ====================
|
|
179
|
+
/**
|
|
180
|
+
* List files by prefix
|
|
181
|
+
* @param prefix - Path prefix to filter files
|
|
182
|
+
* @returns Array of file paths matching the prefix
|
|
183
|
+
*/
|
|
184
|
+
listByPrefix(prefix) {
|
|
185
|
+
return this.get("/list", { query: { prefix } });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Upload an artifact for an agent run
|
|
189
|
+
* @param runId - The workflow run ID
|
|
190
|
+
* @param name - Artifact name (e.g., "output.json")
|
|
191
|
+
* @param source - File content source
|
|
192
|
+
* @returns The full path of the uploaded artifact
|
|
193
|
+
*/
|
|
194
|
+
async uploadArtifact(runId, name, source) {
|
|
195
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
196
|
+
if (source instanceof File) {
|
|
197
|
+
const file = source;
|
|
198
|
+
return this.uploadFile(new StreamSource_js_1.StreamSource(file.stream(), name, file.type, artifactPath));
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return this.uploadFile(new StreamSource_js_1.StreamSource(source.stream, name, source.type, artifactPath));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Download an artifact from an agent run
|
|
206
|
+
* @param runId - The workflow run ID
|
|
207
|
+
* @param name - Artifact name
|
|
208
|
+
* @returns ReadableStream of the artifact content
|
|
209
|
+
*/
|
|
210
|
+
async downloadArtifact(runId, name) {
|
|
211
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
212
|
+
return this.downloadFile(artifactPath);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get download URL for an artifact
|
|
216
|
+
* @param runId - The workflow run ID
|
|
217
|
+
* @param name - Artifact name
|
|
218
|
+
* @param disposition - Content disposition (inline or attachment)
|
|
219
|
+
* @returns Signed URL response
|
|
220
|
+
*/
|
|
221
|
+
getArtifactDownloadUrl(runId, name, disposition) {
|
|
222
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
223
|
+
return this.getDownloadUrl(artifactPath, name, disposition);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* List artifacts for an agent run
|
|
227
|
+
* @param runId - The workflow run ID
|
|
228
|
+
* @returns Array of artifact file paths
|
|
229
|
+
*/
|
|
230
|
+
async listArtifacts(runId) {
|
|
231
|
+
const prefix = `${exports.ARTIFACTS_PREFIX}/${runId}/`;
|
|
232
|
+
const result = await this.listByPrefix(prefix);
|
|
233
|
+
return result.files;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.FilesApi = FilesApi;
|
|
237
|
+
//# sourceMappingURL=FilesApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesApi.js","sourceRoot":"","sources":["../../../src/store/FilesApi.ts"],"names":[],"mappings":";;;AAYA,8CAGC;AAOD,oDAEC;AAxBD,iEAAkE;AAOlE,wDAAkD;AAErC,QAAA,eAAe,GAAG,UAAU,CAAC;AAC7B,QAAA,gBAAgB,GAAG,QAAQ,CAAC;AAEzC,SAAgB,iBAAiB,CAAC,IAAY;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;IACvE,OAAO,GAAG,uBAAe,IAAI,WAAW,EAAE,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,KAAa,EAAE,IAAY;IAC5D,OAAO,GAAG,wBAAgB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;AAClD,CAAC;AAED,MAAa,QAAS,SAAQ,2BAAQ;IAClC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,E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O,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC;CACJ;AArQD,4BAqQC"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectsApi = exports.supportsVisualRendition = exports.getSupportedRenditionFormats = exports.canGenerateRendition = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
const common_1 = require("@vertesia/common");
|
|
6
|
+
Object.defineProperty(exports, "canGenerateRendition", { enumerable: true, get: function () { return common_1.canGenerateRendition; } });
|
|
7
|
+
Object.defineProperty(exports, "getSupportedRenditionFormats", { enumerable: true, get: function () { return common_1.getSupportedRenditionFormats; } });
|
|
8
|
+
Object.defineProperty(exports, "supportsVisualRendition", { enumerable: true, get: function () { return common_1.supportsVisualRendition; } });
|
|
9
|
+
const StreamSource_js_1 = require("../StreamSource.js");
|
|
10
|
+
const AnalyzeDocApi_js_1 = require("./AnalyzeDocApi.js");
|
|
11
|
+
class ObjectsApi extends api_fetch_client_1.ApiTopic {
|
|
12
|
+
constructor(parent) {
|
|
13
|
+
super(parent, "/api/v1/objects");
|
|
14
|
+
}
|
|
15
|
+
analyze(objectId) {
|
|
16
|
+
return new AnalyzeDocApi_js_1.AnalyzeDocApi(this, objectId);
|
|
17
|
+
}
|
|
18
|
+
getUploadUrl(payload) {
|
|
19
|
+
return this.post("/upload-url", {
|
|
20
|
+
payload,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
getDownloadUrl(fileUri, name, disposition) {
|
|
24
|
+
return this.post("/download-url", {
|
|
25
|
+
payload: { file: fileUri, name, disposition },
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getDownloadUrlWithOptions(payload) {
|
|
29
|
+
return this.post("/download-url", { payload });
|
|
30
|
+
}
|
|
31
|
+
getContentSource(objectId) {
|
|
32
|
+
return this.get(`/${objectId}/content-source`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* List objects with revision filtering options
|
|
36
|
+
*
|
|
37
|
+
* @param payload Search/filter parameters
|
|
38
|
+
* @returns Matching content objects
|
|
39
|
+
*/
|
|
40
|
+
list(payload = {}) {
|
|
41
|
+
const limit = payload.limit || 100;
|
|
42
|
+
const offset = payload.offset || 0;
|
|
43
|
+
const query = payload.query || {};
|
|
44
|
+
return this.get("/", {
|
|
45
|
+
query: {
|
|
46
|
+
limit,
|
|
47
|
+
offset,
|
|
48
|
+
...query,
|
|
49
|
+
all_revisions: payload.all_revisions,
|
|
50
|
+
from_root: payload.from_root || undefined,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
computeFacets(query) {
|
|
55
|
+
return this.post("/facets", {
|
|
56
|
+
payload: query,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
listFolders(path = "/") {
|
|
60
|
+
path; //TODO
|
|
61
|
+
}
|
|
62
|
+
/** Find object based on query */
|
|
63
|
+
find(payload) {
|
|
64
|
+
return this.post("/find", {
|
|
65
|
+
payload,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Count number of objects matching this query */
|
|
69
|
+
count(payload) {
|
|
70
|
+
return this.post("/count", {
|
|
71
|
+
payload,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** Search object — different from find because allow full text search */
|
|
75
|
+
search(payload) {
|
|
76
|
+
return this.post("/search", {
|
|
77
|
+
payload,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
retrieve(id, select) {
|
|
81
|
+
return this.get(`/${id}`, {
|
|
82
|
+
query: {
|
|
83
|
+
select,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
getObjectText(id) {
|
|
88
|
+
return this.get(`/${id}/text`);
|
|
89
|
+
}
|
|
90
|
+
async upload(source) {
|
|
91
|
+
const isStream = source instanceof StreamSource_js_1.StreamSource;
|
|
92
|
+
// get a signed URL to upload the file a computed mimeType and the file object id.
|
|
93
|
+
const { url, id, mime_type } = await this.getUploadUrl({
|
|
94
|
+
id: isStream ? source.id : undefined,
|
|
95
|
+
name: source.name,
|
|
96
|
+
mime_type: source.type,
|
|
97
|
+
});
|
|
98
|
+
// upload the file content to the signed URL
|
|
99
|
+
/*const res = await this.fetch(url, {
|
|
100
|
+
method: 'PUT',
|
|
101
|
+
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
102
|
+
duplex: isStream ? "half" : undefined,
|
|
103
|
+
body: isStream ? source.stream : source,
|
|
104
|
+
headers: {
|
|
105
|
+
'Content-Type': mime_type || 'application/octet-stream'
|
|
106
|
+
}
|
|
107
|
+
}).then((res: Response) => {
|
|
108
|
+
if (res.ok) {
|
|
109
|
+
return res;
|
|
110
|
+
} else {
|
|
111
|
+
console.log(res);
|
|
112
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
113
|
+
}
|
|
114
|
+
});*/
|
|
115
|
+
const res = await fetch(url, {
|
|
116
|
+
method: "PUT",
|
|
117
|
+
body: isStream ? source.stream : source,
|
|
118
|
+
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
119
|
+
duplex: isStream ? "half" : undefined,
|
|
120
|
+
headers: {
|
|
121
|
+
"Content-Type": mime_type || "application/octet-stream",
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
.then((res) => {
|
|
125
|
+
if (res.ok) {
|
|
126
|
+
return res;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.log(res);
|
|
130
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
.catch((err) => {
|
|
134
|
+
console.error("Failed to upload file", err);
|
|
135
|
+
throw err;
|
|
136
|
+
});
|
|
137
|
+
//Etag need to be unquoted
|
|
138
|
+
//When a server returns an ETag header, it includes the quotes around the actual hash value.
|
|
139
|
+
//This is part of the HTTP specification (RFC 7232), which states that ETags should be
|
|
140
|
+
//enclosed in double quotes.
|
|
141
|
+
const etag = res.headers.get("etag")?.replace(/^"(.*)"$/, "$1");
|
|
142
|
+
return {
|
|
143
|
+
source: id,
|
|
144
|
+
name: source.name,
|
|
145
|
+
type: mime_type,
|
|
146
|
+
etag,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
async create(payload, options) {
|
|
150
|
+
const createPayload = {
|
|
151
|
+
...payload,
|
|
152
|
+
};
|
|
153
|
+
if (payload.content instanceof StreamSource_js_1.StreamSource ||
|
|
154
|
+
payload.content instanceof File) {
|
|
155
|
+
createPayload.content = await this.upload(payload.content);
|
|
156
|
+
}
|
|
157
|
+
const headers = {};
|
|
158
|
+
if (options?.processing_priority) {
|
|
159
|
+
headers[common_1.ContentObjectApiHeaders.PROCESSING_PRIORITY] = options.processing_priority;
|
|
160
|
+
}
|
|
161
|
+
if (options?.collection_id) {
|
|
162
|
+
headers[common_1.ContentObjectApiHeaders.COLLECTION_ID] = options.collection_id;
|
|
163
|
+
}
|
|
164
|
+
return await this.post("/", {
|
|
165
|
+
payload: createPayload,
|
|
166
|
+
headers: headers,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create an object which holds a reference to an external blob (i.e. not in the project bucket)
|
|
171
|
+
* The uri should starts either with gs:// or s3://. Not other protocols are supported yet.
|
|
172
|
+
* For the s3 blobs you must use a hash with the blob #region. Ex: s3://bucket/path/to/file#us-east-1
|
|
173
|
+
* @param uri
|
|
174
|
+
* @param payload
|
|
175
|
+
* @param options
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
async createFromExternalSource(uri, payload = {}, options) {
|
|
179
|
+
const metadata = await this.client.files.getMetadata(uri);
|
|
180
|
+
const createPayload = {
|
|
181
|
+
...payload,
|
|
182
|
+
content: {
|
|
183
|
+
source: uri,
|
|
184
|
+
name: metadata.name,
|
|
185
|
+
type: metadata.contentType,
|
|
186
|
+
etag: metadata.etag,
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
const headers = {};
|
|
190
|
+
if (options?.processing_priority) {
|
|
191
|
+
headers[common_1.ContentObjectApiHeaders.PROCESSING_PRIORITY] = options.processing_priority;
|
|
192
|
+
}
|
|
193
|
+
if (options?.collection_id) {
|
|
194
|
+
headers[common_1.ContentObjectApiHeaders.COLLECTION_ID] = options.collection_id;
|
|
195
|
+
}
|
|
196
|
+
return await this.post("/", {
|
|
197
|
+
payload: createPayload,
|
|
198
|
+
headers: headers,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Updates an existing object or creates a new revision
|
|
203
|
+
* Handles file uploads similar to the create method
|
|
204
|
+
*
|
|
205
|
+
* @param id The ID of the object to update
|
|
206
|
+
* @param payload The changes to apply
|
|
207
|
+
* @param options Additional options
|
|
208
|
+
* @param options.createRevision Whether to create a new revision instead of updating in place
|
|
209
|
+
* @param options.revisionLabel Optional label for the revision (e.g., "v1.2")
|
|
210
|
+
* @param options.suppressWorkflows When true, prevents this update from triggering workflow rules
|
|
211
|
+
* @returns The updated object or newly created revision
|
|
212
|
+
*/
|
|
213
|
+
async update(id, payload, options) {
|
|
214
|
+
const updatePayload = {
|
|
215
|
+
...payload,
|
|
216
|
+
};
|
|
217
|
+
// Handle file upload if content is provided as File or StreamSource
|
|
218
|
+
if (payload.content instanceof StreamSource_js_1.StreamSource ||
|
|
219
|
+
payload.content instanceof File) {
|
|
220
|
+
updatePayload.content = await this.upload(payload.content);
|
|
221
|
+
}
|
|
222
|
+
const headers = {};
|
|
223
|
+
if (options?.processing_priority) {
|
|
224
|
+
headers[common_1.ContentObjectApiHeaders.PROCESSING_PRIORITY] = options.processing_priority;
|
|
225
|
+
}
|
|
226
|
+
if (options?.createRevision) {
|
|
227
|
+
headers[common_1.ContentObjectApiHeaders.CREATE_REVISION] = "true";
|
|
228
|
+
if (options.revisionLabel) {
|
|
229
|
+
headers[common_1.ContentObjectApiHeaders.REVISION_LABEL] = options.revisionLabel;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (options?.suppressWorkflows) {
|
|
233
|
+
headers[common_1.ContentObjectApiHeaders.SUPPRESS_WORKFLOWS] = "true";
|
|
234
|
+
}
|
|
235
|
+
return this.put(`/${id}`, {
|
|
236
|
+
payload: updatePayload,
|
|
237
|
+
headers,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Retrieves all revisions of a content object
|
|
242
|
+
*
|
|
243
|
+
* @param id The ID of any revision in the object's history
|
|
244
|
+
* @returns Array of all revisions sharing the same root
|
|
245
|
+
*/
|
|
246
|
+
getRevisions(id) {
|
|
247
|
+
return this.get(`/${id}/revisions`);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Retrieves all collections that contain a specific object
|
|
251
|
+
*
|
|
252
|
+
* @param id The ID of the object
|
|
253
|
+
* @returns Array of collections containing this object (both static and dynamic)
|
|
254
|
+
*/
|
|
255
|
+
getCollections(id) {
|
|
256
|
+
return this.get(`/${id}/collections`);
|
|
257
|
+
}
|
|
258
|
+
delete(id) {
|
|
259
|
+
return this.del(`/${id}`);
|
|
260
|
+
}
|
|
261
|
+
listWorkflowRuns(documentId) {
|
|
262
|
+
return this.get(`/${documentId}/workflow-runs`);
|
|
263
|
+
}
|
|
264
|
+
listRenditions(documentId) {
|
|
265
|
+
return this.get(`/${documentId}/renditions`);
|
|
266
|
+
}
|
|
267
|
+
getRendition(documentId, options) {
|
|
268
|
+
const query = {
|
|
269
|
+
max_hw: options.max_hw,
|
|
270
|
+
generate_if_missing: options.generate_if_missing,
|
|
271
|
+
sign_url: options.sign_url,
|
|
272
|
+
block_on_generation: options.block_on_generation,
|
|
273
|
+
};
|
|
274
|
+
return this.get(`/${documentId}/renditions/${options.format}`, {
|
|
275
|
+
query,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get rendition with pre-validation of content type compatibility.
|
|
280
|
+
* Returns null instead of throwing if the format is not supported for the content type.
|
|
281
|
+
*
|
|
282
|
+
* @param documentId - The document ID
|
|
283
|
+
* @param contentType - The content type of the document (e.g., 'image/png', 'text/markdown')
|
|
284
|
+
* @param options - Rendition options including format
|
|
285
|
+
* @returns The rendition response, or null if format is not supported for the content type
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* const rendition = await client.objects.getRenditionSafe(docId, doc.content?.type, {
|
|
289
|
+
* format: ImageRenditionFormat.jpeg,
|
|
290
|
+
* generate_if_missing: true
|
|
291
|
+
* });
|
|
292
|
+
* if (!rendition) {
|
|
293
|
+
* console.log('Document does not support JPEG renditions');
|
|
294
|
+
* }
|
|
295
|
+
*/
|
|
296
|
+
getRenditionSafe(documentId, contentType, options) {
|
|
297
|
+
if (!(0, common_1.canGenerateRendition)(contentType, options.format)) {
|
|
298
|
+
return Promise.resolve(null);
|
|
299
|
+
}
|
|
300
|
+
return this.getRendition(documentId, options);
|
|
301
|
+
}
|
|
302
|
+
exportProperties(payload) {
|
|
303
|
+
return this.post("/export", {
|
|
304
|
+
payload,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
setEmbedding(id, type, payload) {
|
|
308
|
+
return this.put(`/${id}/embeddings/${type}`, {
|
|
309
|
+
payload,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.ObjectsApi = ObjectsApi;
|
|
314
|
+
//# sourceMappingURL=ObjectsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectsApi.js","sourceRoot":"","sources":["../../../src/store/ObjectsApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAClE,6CAyB0B;AAGjB,qGA3BL,6BAAoB,OA2BK;AAAE,6GAV3B,qCAA4B,OAU2B;AAAE,wGAJzD,gCAAuB,OAIyD;AAEpF,wDAAkD;AAClD,yDAAmD;AAenD,MAAa,UAAW,SAAQ,2BAAQ;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AC;IACP,CAAC;IAED,YAAY,CACR,EAAU,EACV,IAA6B,EAC7B,OAAkB;QAElB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,IAAI,EAAE,EAAE;YACzC,OAAO;SACV,CAAC,CAAC;IACP,CAAC;CACJ;AAhYD,gCAgYC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PendingAsksApi = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
/**
|
|
6
|
+
* Pending Asks API for tracking ask_user requests.
|
|
7
|
+
* Handles registration, resolution, and listing of pending asks.
|
|
8
|
+
*/
|
|
9
|
+
class PendingAsksApi extends api_fetch_client_1.ApiTopic {
|
|
10
|
+
constructor(parent) {
|
|
11
|
+
super(parent, "/api/v1/pending-asks");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register a new pending ask.
|
|
15
|
+
* Called when an agent calls ask_user.
|
|
16
|
+
* Stores in Redis and sends webhook if configured.
|
|
17
|
+
*/
|
|
18
|
+
register(request) {
|
|
19
|
+
return this.post("/", { payload: request });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a pending ask with the user's response.
|
|
23
|
+
* Called when a user responds to an ask.
|
|
24
|
+
* Updates Redis and sends webhook if configured.
|
|
25
|
+
*/
|
|
26
|
+
resolve(askId, request) {
|
|
27
|
+
return this.post(`/${askId}/resolve`, { payload: request });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* List all pending asks for the current project.
|
|
31
|
+
*/
|
|
32
|
+
list() {
|
|
33
|
+
return this.get("/");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get a specific pending ask by ID.
|
|
37
|
+
*/
|
|
38
|
+
retrieve(askId) {
|
|
39
|
+
return this.get(`/${askId}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.PendingAsksApi = PendingAsksApi;
|
|
43
|
+
//# sourceMappingURL=PendingAsksApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingAsksApi.js","sourceRoot":"","sources":["../../../src/store/PendingAsksApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAyDlE;;;GAGG;AACH,MAAa,cAAe,SAAQ,2BAAQ;IACxC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,OAAkC;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,KAAa,EAAE,OAAiC;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,IAAI;QACA,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IACjC,CAAC;CACJ;AApCD,wCAoCC"}
|