@vertesia/client 0.54.0 → 0.56.0
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/lib/cjs/AccountApi.js +84 -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 +13 -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/CommandsApi.js +19 -0
- package/lib/cjs/CommandsApi.js.map +1 -0
- package/lib/cjs/EnvironmentsApi.js +58 -0
- package/lib/cjs/EnvironmentsApi.js.map +1 -0
- package/lib/cjs/IamApi.js +51 -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/InteractionsApi.js +209 -0
- package/lib/cjs/InteractionsApi.js.map +1 -0
- package/lib/cjs/PluginsApi.js +27 -0
- package/lib/cjs/PluginsApi.js.map +1 -0
- package/lib/cjs/ProjectsApi.js +54 -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 +105 -0
- package/lib/cjs/RunsApi.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 +218 -0
- package/lib/cjs/client.js.map +1 -0
- package/lib/cjs/execute.js +152 -0
- package/lib/cjs/execute.js.map +1 -0
- package/lib/cjs/index.js +21 -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/AgentsApi.js +16 -0
- package/lib/cjs/store/AgentsApi.js.map +1 -0
- package/lib/cjs/store/AnalyzeDocApi.js +56 -0
- package/lib/cjs/store/AnalyzeDocApi.js.map +1 -0
- package/lib/cjs/store/CollectionsApi.js +77 -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/EmbeddingsApi.js +29 -0
- package/lib/cjs/store/EmbeddingsApi.js.map +1 -0
- package/lib/cjs/store/FilesApi.js +128 -0
- package/lib/cjs/store/FilesApi.js.map +1 -0
- package/lib/cjs/store/ObjectsApi.js +254 -0
- package/lib/cjs/store/ObjectsApi.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/WorkflowsApi.js +179 -0
- package/lib/cjs/store/WorkflowsApi.js.map +1 -0
- package/lib/cjs/store/client.js +55 -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 +22 -0
- package/lib/cjs/store/index.js.map +1 -0
- package/lib/esm/AccountApi.js +81 -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 +10 -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/CommandsApi.js +16 -0
- package/lib/esm/CommandsApi.js.map +1 -0
- package/lib/esm/EnvironmentsApi.js +55 -0
- package/lib/esm/EnvironmentsApi.js.map +1 -0
- package/lib/esm/IamApi.js +45 -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/InteractionsApi.js +206 -0
- package/lib/esm/InteractionsApi.js.map +1 -0
- package/lib/esm/PluginsApi.js +24 -0
- package/lib/esm/PluginsApi.js.map +1 -0
- package/lib/esm/ProjectsApi.js +51 -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 +101 -0
- package/lib/esm/RunsApi.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 +211 -0
- package/lib/esm/client.js.map +1 -0
- package/lib/esm/execute.js +113 -0
- package/lib/esm/execute.js.map +1 -0
- package/lib/esm/index.js +5 -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/AgentsApi.js +12 -0
- package/lib/esm/store/AgentsApi.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 +73 -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/EmbeddingsApi.js +25 -0
- package/lib/esm/store/EmbeddingsApi.js.map +1 -0
- package/lib/esm/store/FilesApi.js +123 -0
- package/lib/esm/store/FilesApi.js.map +1 -0
- package/lib/esm/store/ObjectsApi.js +250 -0
- package/lib/esm/store/ObjectsApi.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/WorkflowsApi.js +173 -0
- package/lib/esm/store/WorkflowsApi.js.map +1 -0
- package/lib/esm/store/client.js +51 -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 +6 -0
- package/lib/esm/store/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AccountApi.d.ts +58 -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 +6 -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/CommandsApi.d.ts +10 -0
- package/lib/types/CommandsApi.d.ts.map +1 -0
- package/lib/types/EnvironmentsApi.d.ts +30 -0
- package/lib/types/EnvironmentsApi.d.ts.map +1 -0
- package/lib/types/IamApi.d.ts +39 -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/InteractionsApi.d.ts +150 -0
- package/lib/types/InteractionsApi.d.ts.map +1 -0
- package/lib/types/PluginsApi.d.ts +12 -0
- package/lib/types/PluginsApi.d.ts.map +1 -0
- package/lib/types/ProjectsApi.d.ts +21 -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 +77 -0
- package/lib/types/RunsApi.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 +103 -0
- package/lib/types/client.d.ts.map +1 -0
- package/lib/types/execute.d.ts +36 -0
- package/lib/types/execute.d.ts.map +1 -0
- package/lib/types/index.d.ts +7 -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/AgentsApi.d.ts +6 -0
- package/lib/types/store/AgentsApi.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 +37 -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/EmbeddingsApi.d.ts +12 -0
- package/lib/types/store/EmbeddingsApi.d.ts.map +1 -0
- package/lib/types/store/FilesApi.d.ts +41 -0
- package/lib/types/store/FilesApi.d.ts.map +1 -0
- package/lib/types/store/ObjectsApi.d.ts +113 -0
- package/lib/types/store/ObjectsApi.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/WorkflowsApi.d.ts +47 -0
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -0
- package/lib/types/store/client.d.ts +29 -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 +5 -0
- package/lib/types/store/index.d.ts.map +1 -0
- package/lib/vertesia-client.js +2 -0
- package/lib/vertesia-client.js.map +1 -0
- package/package.json +10 -5
- package/src/EnvironmentsApi.ts +1 -1
- package/src/PluginsApi.ts +7 -5
- package/src/ProjectsApi.ts +2 -2
- package/src/RunsApi.ts +1 -1
- package/src/TrainingApi.ts +1 -1
- package/src/store/ObjectsApi.ts +7 -1
- package/src/store/WorkflowsApi.ts +73 -68
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EventSourceProvider = EventSourceProvider;
|
|
37
|
+
exports.executeInteraction = executeInteraction;
|
|
38
|
+
exports.executeInteractionByName = executeInteractionByName;
|
|
39
|
+
exports.executeInteractionAsync = executeInteractionAsync;
|
|
40
|
+
const common_1 = require("@vertesia/common");
|
|
41
|
+
async function EventSourceProvider() {
|
|
42
|
+
if (typeof globalThis.EventSource === 'function') {
|
|
43
|
+
return globalThis.EventSource;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return (await Promise.resolve().then(() => __importStar(require('eventsource')))).EventSource;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* Execute an interaction and return a promise which will be resolved with the executed run when
|
|
52
|
+
* the run completes or fails.
|
|
53
|
+
* If the onChunk callback is passed then the streaming of the result is enabled.
|
|
54
|
+
* The onChunk callback with be called with the next chunk of the result as soon as it is available.
|
|
55
|
+
* When all chunks are received the function will return the resolved promise
|
|
56
|
+
* @param id of the interaction to execute
|
|
57
|
+
* @param payload InteractionExecutionPayload
|
|
58
|
+
* @param onChunk callback to be called when the next chunk of the response is available
|
|
59
|
+
*/
|
|
60
|
+
async function executeInteraction(client, interactionId, payload = {}, onChunk) {
|
|
61
|
+
const stream = !!onChunk;
|
|
62
|
+
const response = await client.runs.create({
|
|
63
|
+
...payload, interaction: interactionId, stream
|
|
64
|
+
});
|
|
65
|
+
if (stream) {
|
|
66
|
+
if (response.status === common_1.ExecutionRunStatus.failed) {
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
await handleStreaming(client, response.id, onChunk);
|
|
70
|
+
}
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Same as executeInteraction but uses the interaction name selector instead of the id.
|
|
75
|
+
* A name selector is the interaction endpoint name suffixed with an optional tag or version which is starting with a `@` character.
|
|
76
|
+
* The special `draft` tag is used to select the draft version of the interaction. If no tag or version is specified then the latest version is selected.
|
|
77
|
+
* Examples of selectors:
|
|
78
|
+
* - `ReviewContract` - select the latest version of the ReviewContract interaction
|
|
79
|
+
* - `ReviewContract@1` - select the version 1 of the ReviewContract interaction
|
|
80
|
+
* - `ReviewContract@draft` - select the draft version of the ReviewContract interaction
|
|
81
|
+
* - `ReviewContract@fixed` - select the ReviewContract interaction which is tagged with 'fixed' tag.
|
|
82
|
+
*
|
|
83
|
+
* @param client
|
|
84
|
+
* @param interaction
|
|
85
|
+
* @param payload
|
|
86
|
+
* @param onChunk
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
async function executeInteractionByName(client, interaction, payload = {}, onChunk) {
|
|
90
|
+
const stream = !!onChunk;
|
|
91
|
+
const response = await client.post('/api/v1/execute', {
|
|
92
|
+
payload: {
|
|
93
|
+
...payload,
|
|
94
|
+
interaction,
|
|
95
|
+
stream
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
if (stream) {
|
|
99
|
+
if (response.status === common_1.ExecutionRunStatus.failed) {
|
|
100
|
+
return response;
|
|
101
|
+
}
|
|
102
|
+
await handleStreaming(client, response.id, onChunk);
|
|
103
|
+
}
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
function handleStreaming(client, runId, onChunk) {
|
|
107
|
+
return new Promise(async (resolve, reject) => {
|
|
108
|
+
try {
|
|
109
|
+
const EventSourceImpl = await EventSourceProvider();
|
|
110
|
+
const streamUrl = new URL(client.runs.baseUrl + '/' + runId + '/stream');
|
|
111
|
+
const bearerToken = client._auth ? await client._auth() : undefined;
|
|
112
|
+
if (bearerToken) {
|
|
113
|
+
const token = bearerToken.split(' ')[1];
|
|
114
|
+
streamUrl.searchParams.set('access_token', token);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new Error('No auth token available');
|
|
118
|
+
}
|
|
119
|
+
const sse = new EventSourceImpl(streamUrl.href);
|
|
120
|
+
sse.addEventListener("message", ev => {
|
|
121
|
+
try {
|
|
122
|
+
const data = JSON.parse(ev.data);
|
|
123
|
+
if (data) {
|
|
124
|
+
onChunk && onChunk(data);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
reject(err);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
sse.addEventListener("close", (ev) => {
|
|
132
|
+
try {
|
|
133
|
+
sse.close();
|
|
134
|
+
const msg = JSON.parse(ev.data);
|
|
135
|
+
resolve(msg);
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
reject(err);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
reject(err);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async function executeInteractionAsync(client, payload) {
|
|
148
|
+
return await client.post('/api/v1/execute/async', {
|
|
149
|
+
payload,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/execute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,kDAMC;AAYD,gDAeC;AAkBD,4DAmBC;AA0CD,0DAIC;AAvHD,6CAAwK;AAGjK,K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CAAC,CAAC;gBAChB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE;gBACjC,IAAI,CAAC;oBACD,GAAG,CAAC,KAAK,EAAE,CAAC;oBACZ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;oBAC/B,OAAO,CAAC,GAAG,CAAC,CAAC;gBACjB,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACX,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,MAAsB,EAAE,OAA8B;IAChG,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE;QAC9C,OAAO;KACV,CAAC,CAAC;AACP,CAAC"}
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client.js"), exports);
|
|
18
|
+
__exportStar(require("./InteractionBase.js"), exports);
|
|
19
|
+
__exportStar(require("./store/index.js"), exports);
|
|
20
|
+
__exportStar(require("./StreamSource.js"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,uDAAqC;AAIrC,mDAAiC;AACjC,oDAAkC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeStreamSource = void 0;
|
|
4
|
+
const web_1 = require("node:stream/web");
|
|
5
|
+
const StreamSource_js_1 = require("../StreamSource.js");
|
|
6
|
+
/**
|
|
7
|
+
* A stream source that wraps a Node.js Readable stream.
|
|
8
|
+
* This class is only works in Node.js environments.
|
|
9
|
+
*/
|
|
10
|
+
class NodeStreamSource extends StreamSource_js_1.StreamSource {
|
|
11
|
+
constructor(stream, name, type, id) {
|
|
12
|
+
super(readableToWebStream(stream), name, type, id);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.NodeStreamSource = NodeStreamSource;
|
|
16
|
+
function readableToWebStream(stream) {
|
|
17
|
+
if (web_1.ReadableStream.from) {
|
|
18
|
+
return web_1.ReadableStream.from(stream);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return readableToWebStream_BUN(stream);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Bun implementation since bun is not yet supporting NodeReadableStream.from
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
function readableToWebStream_BUN(stream) {
|
|
29
|
+
const it = stream[Symbol.asyncIterator]();
|
|
30
|
+
return new ReadableStream({
|
|
31
|
+
async pull(controller) {
|
|
32
|
+
const { value, done } = await it.next();
|
|
33
|
+
if (done) {
|
|
34
|
+
controller.close();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
controller.enqueue(value);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
cancel() {
|
|
41
|
+
it.return?.();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=NodeStreamSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeStreamSource.js","sourceRoot":"","sources":["../../../src/nodejs/NodeStreamSource.ts"],"names":[],"mappings":";;;AACA,yCAAuE;AACvE,wDAAkD;AAGlD;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,8BAAY;IAC9C,YAAY,MAAgB,EAAE,IAAY,EAAE,IAAa,EAAE,EAAW;QAClE,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;CACJ;AAJD,4CAIC;AAED,SAAS,mBAAmB,CAAsB,MAAgB;IAC9D,IAAI,oBAAkB,CAAC,IAAI,EAAE,CAAC;QAC1B,OAAO,oBAAkB,CAAC,IAAI,CAAC,MAAM,CAAsB,CAAC;IAChE,CAAC;SAAM,CAAC;QACJ,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,uBAAuB,CAAsB,MAAgB;IAClE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAC1C,OAAO,IAAI,cAAc,CAAI;QACzB,KAAK,CAAC,IAAI,CAAC,UAAU;YACjB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,IAAI,IAAI,EAAE,CAAC;gBACP,UAAU,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACJ,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACL,CAAC;QACD,MAAM;YACF,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;QAClB,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./NodeStreamSource.js"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nodejs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentsApi = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
class AgentsApi extends api_fetch_client_1.ApiTopic {
|
|
6
|
+
constructor(parent) {
|
|
7
|
+
super(parent, "/api/v1/agents");
|
|
8
|
+
}
|
|
9
|
+
async deploy(payload) {
|
|
10
|
+
return this.post('/', {
|
|
11
|
+
payload
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AgentsApi = AgentsApi;
|
|
16
|
+
//# sourceMappingURL=AgentsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentsApi.js","sourceRoot":"","sources":["../../../src/store/AgentsApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAIlE,MAAa,SAAU,SAAQ,2BAAQ;IAEnC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAqC;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YAClB,OAAO;SACV,CAAC,CAAC;IACP,CAAC;CAEJ;AAZD,8BAYC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnalyzeDocApi = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
class AnalyzeDocApi extends api_fetch_client_1.ApiTopic {
|
|
6
|
+
objectId;
|
|
7
|
+
constructor(parent, objectId) {
|
|
8
|
+
super(parent, `/${objectId}/analyze`);
|
|
9
|
+
this.objectId = objectId;
|
|
10
|
+
}
|
|
11
|
+
async start(payload) {
|
|
12
|
+
return this.post("/", { payload });
|
|
13
|
+
}
|
|
14
|
+
async getStatus() {
|
|
15
|
+
return this.get("/status");
|
|
16
|
+
}
|
|
17
|
+
async getResults() {
|
|
18
|
+
return this.get("/results");
|
|
19
|
+
}
|
|
20
|
+
async adaptTables(payload) {
|
|
21
|
+
return this.post("/adapt_tables", { payload });
|
|
22
|
+
}
|
|
23
|
+
async getAdaptedTables(runId, query) {
|
|
24
|
+
const path = runId ? `/adapt_tables/${runId}` : "/adapt_tables";
|
|
25
|
+
// Build query parameters
|
|
26
|
+
const queryParams = {};
|
|
27
|
+
if (query?.format)
|
|
28
|
+
queryParams.format = query.format;
|
|
29
|
+
if (query?.raw !== undefined)
|
|
30
|
+
queryParams.raw = query.raw;
|
|
31
|
+
// If format is CSV, set response type to text to avoid automatic JSON parsing
|
|
32
|
+
const options = { query: queryParams };
|
|
33
|
+
if (query?.format === 'csv') {
|
|
34
|
+
options.responseType = 'text';
|
|
35
|
+
}
|
|
36
|
+
return this.get(path, options);
|
|
37
|
+
}
|
|
38
|
+
async getXml() {
|
|
39
|
+
return this.get("/xml");
|
|
40
|
+
}
|
|
41
|
+
async getTables(format) {
|
|
42
|
+
const options = {};
|
|
43
|
+
if (format) {
|
|
44
|
+
options.query = { format: format };
|
|
45
|
+
}
|
|
46
|
+
return this.get("/tables", options);
|
|
47
|
+
}
|
|
48
|
+
async getImages() {
|
|
49
|
+
return this.get("/images");
|
|
50
|
+
}
|
|
51
|
+
async getAnnotated() {
|
|
52
|
+
return this.get("/annotated");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.AnalyzeDocApi = AnalyzeDocApi;
|
|
56
|
+
//# sourceMappingURL=AnalyzeDocApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnalyzeDocApi.js","sourceRoot":"","sources":["../../../src/store/AnalyzeDocApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAGlE,MAAa,aAAc,SAAQ,2BAAQ;IACA;IAAvC,YAAY,MAAkB,EAAS,QAAgB;QACnD,KAAK,CAAC,MAAM,EAAE,IAAI,QAAQ,UAAU,CAAC,CAAC;QADH,aAAQ,GAAR,QAAQ,CAAQ;IAEvD,CAAC;IAED,KAAK,CAAC,KAA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I,MAAM,EAAE,CAAC;YACT,OAAO,CAAC,KAAK,GAAG,EAAC,MAAM,EAAE,MAAM,EAAC,CAAA;QACpC,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,YAAY;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;CACJ;AAzDD,sCAyDC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionsApi = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
class CollectionsApi extends api_fetch_client_1.ApiTopic {
|
|
6
|
+
constructor(parent) {
|
|
7
|
+
super(parent, "/api/v1/collections");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List collections
|
|
11
|
+
* @param payload
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
list(payload = {}) {
|
|
15
|
+
return this.get("/", {
|
|
16
|
+
query: {
|
|
17
|
+
limit: 100,
|
|
18
|
+
offset: 0,
|
|
19
|
+
...payload
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the collection data without members
|
|
25
|
+
* @param collectionId
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
retrieve(collectionId) {
|
|
29
|
+
return this.get(`/${collectionId}`);
|
|
30
|
+
}
|
|
31
|
+
create(payload) {
|
|
32
|
+
return this.post(`/`, {
|
|
33
|
+
payload
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
update(collectionId, payload) {
|
|
37
|
+
return this.put(`/${collectionId}`, {
|
|
38
|
+
payload
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
addMembers(collectionId, members) {
|
|
42
|
+
return this.post(`/${collectionId}/members`, {
|
|
43
|
+
payload: {
|
|
44
|
+
action: 'add',
|
|
45
|
+
members
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
listMembers(collectionId, payload) {
|
|
50
|
+
return this.get(`/${collectionId}/members`, {
|
|
51
|
+
query: {
|
|
52
|
+
...payload
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
computeFacets(collectionId, query) {
|
|
57
|
+
return this.post(`/${collectionId}/facets`, {
|
|
58
|
+
payload: query
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
searchMembers(collectionId, payload) {
|
|
62
|
+
return this.post(`/${collectionId}/search`, { payload });
|
|
63
|
+
}
|
|
64
|
+
deleteMembers(collectionId, members) {
|
|
65
|
+
return this.post(`/${collectionId}/members`, {
|
|
66
|
+
payload: {
|
|
67
|
+
action: 'delete',
|
|
68
|
+
members
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
delete(id) {
|
|
73
|
+
return this.del(`/${id}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.CollectionsApi = CollectionsApi;
|
|
77
|
+
//# sourceMappingURL=CollectionsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionsApi.js","sourceRoot":"","sources":["../../../src/store/CollectionsApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAKlE,MAAa,cAAe,SAAQ,2BAAQ;IAExC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,UAAmC,EAAE;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,KAAK,EAAE;gBACH,KAAK,EAAE,GAAG;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ChB,OAAO;aACV;SACJ,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,EAAU;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;CAEJ;AAvFD,wCAuFC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandsApi = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
const EmbeddingsApi_js_1 = require("./EmbeddingsApi.js");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use EmbeddingsApi instead
|
|
8
|
+
* @see EmbeddingsApi
|
|
9
|
+
*/
|
|
10
|
+
class CommandsApi extends api_fetch_client_1.ApiTopic {
|
|
11
|
+
constructor(parent) {
|
|
12
|
+
super(parent, "/api/v1/commands");
|
|
13
|
+
}
|
|
14
|
+
embeddings = new EmbeddingsApi_js_1.EmbeddingsApi(this, "/embeddings");
|
|
15
|
+
}
|
|
16
|
+
exports.CommandsApi = CommandsApi;
|
|
17
|
+
//# sourceMappingURL=CommandsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandsApi.js","sourceRoot":"","sources":["../../../src/store/CommandsApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAClE,yDAAmD;AAEnD;;;GAGG;AACH,MAAa,WAAY,SAAQ,2BAAQ;IAErC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,UAAU,GAAG,IAAI,gCAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;CACvD;AAPD,kCAOC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmbeddingsApi = void 0;
|
|
4
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
5
|
+
/**
|
|
6
|
+
* @since 0.52.0
|
|
7
|
+
*/
|
|
8
|
+
class EmbeddingsApi extends api_fetch_client_1.ApiTopic {
|
|
9
|
+
constructor(parent, basePath = "/api/v1/embeddings") {
|
|
10
|
+
super(parent, basePath);
|
|
11
|
+
}
|
|
12
|
+
async status(type) {
|
|
13
|
+
return this.get(type + "/status");
|
|
14
|
+
}
|
|
15
|
+
async activate(type, config) {
|
|
16
|
+
if (!config.environment) {
|
|
17
|
+
throw new Error("Invalid configuration: select environment");
|
|
18
|
+
}
|
|
19
|
+
return this.post(type + "/enable", { payload: config });
|
|
20
|
+
}
|
|
21
|
+
async disable(type) {
|
|
22
|
+
return this.post(type + "/disable");
|
|
23
|
+
}
|
|
24
|
+
async recalculate(type) {
|
|
25
|
+
return this.post(type + "/recalculate");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.EmbeddingsApi = EmbeddingsApi;
|
|
29
|
+
//# sourceMappingURL=EmbeddingsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingsApi.js","sourceRoot":"","sources":["../../../src/store/EmbeddingsApi.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAQlE;;GAEG;AACH,MAAa,aAAc,SAAQ,2BAAQ;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;AA3BD,sCA2BC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilesApi = exports.MEMORIES_PREFIX = void 0;
|
|
4
|
+
exports.getMemoryFilePath = getMemoryFilePath;
|
|
5
|
+
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
6
|
+
const StreamSource_js_1 = require("../StreamSource.js");
|
|
7
|
+
exports.MEMORIES_PREFIX = 'memories';
|
|
8
|
+
function getMemoryFilePath(name) {
|
|
9
|
+
const nameWithExt = name.endsWith(".tar.gz") ? name : name + ".tar.gz";
|
|
10
|
+
return `${exports.MEMORIES_PREFIX}/${nameWithExt}`;
|
|
11
|
+
}
|
|
12
|
+
class FilesApi extends api_fetch_client_1.ApiTopic {
|
|
13
|
+
constructor(parent) {
|
|
14
|
+
super(parent, "/api/v1/files");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* get the metadata of a blob given its URI. Supported URI are:
|
|
18
|
+
* starting with s3:// and gs://.
|
|
19
|
+
* For s3 blobs use #region to specify the region. Ex: s3://bucket/key#us-west-2
|
|
20
|
+
* @param uri
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
getMetadata(uri) {
|
|
24
|
+
return this.get("/metadata", {
|
|
25
|
+
query: {
|
|
26
|
+
file: uri
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get or create a bucket for the project. If the bucket already exists, it does nothing.
|
|
32
|
+
* The bucket URI is returned.
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
getOrCreateBucket() {
|
|
36
|
+
return this.post('/bucket');
|
|
37
|
+
}
|
|
38
|
+
getUploadUrl(payload) {
|
|
39
|
+
return this.post('/upload-url', {
|
|
40
|
+
payload
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getDownloadUrl(file) {
|
|
44
|
+
return this.post('/download-url', {
|
|
45
|
+
payload: {
|
|
46
|
+
file
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Upload content to a file and return the full path (including bucket name) of the uploaded file
|
|
52
|
+
* @param source
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
async uploadFile(source) {
|
|
56
|
+
const isStream = source instanceof StreamSource_js_1.StreamSource;
|
|
57
|
+
const { url, path } = await this.getUploadUrl(source);
|
|
58
|
+
await fetch(url, {
|
|
59
|
+
method: 'PUT',
|
|
60
|
+
body: isStream ? source.stream : source,
|
|
61
|
+
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
62
|
+
duplex: isStream ? "half" : undefined,
|
|
63
|
+
headers: {
|
|
64
|
+
'Content-Type': source.type || 'application/gzip'
|
|
65
|
+
}
|
|
66
|
+
}).then((res) => {
|
|
67
|
+
if (res.ok) {
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.log(res);
|
|
72
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
73
|
+
}
|
|
74
|
+
}).catch(err => {
|
|
75
|
+
console.error('Failed to upload file', err);
|
|
76
|
+
throw err;
|
|
77
|
+
});
|
|
78
|
+
return path;
|
|
79
|
+
}
|
|
80
|
+
async downloadFile(name) {
|
|
81
|
+
const { url } = await this.getDownloadUrl(name);
|
|
82
|
+
const res = await fetch(url, {
|
|
83
|
+
method: 'GET',
|
|
84
|
+
}).then((res) => {
|
|
85
|
+
if (res.ok) {
|
|
86
|
+
return res;
|
|
87
|
+
}
|
|
88
|
+
else if (res.status === 404) {
|
|
89
|
+
throw new Error(`File ${name} not found`); //TODO: type fetch error better with a fetch error class
|
|
90
|
+
}
|
|
91
|
+
else if (res.status === 403) {
|
|
92
|
+
throw new Error(`File ${name} is forbidden`);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
console.log(res);
|
|
96
|
+
throw new Error(`Failed to download file ${name}: ${res.statusText}`);
|
|
97
|
+
}
|
|
98
|
+
}).catch(err => {
|
|
99
|
+
console.error(`Failed to download file ${name}.`, err);
|
|
100
|
+
throw err;
|
|
101
|
+
});
|
|
102
|
+
if (!res.body) {
|
|
103
|
+
throw new Error(`No body in response while downloading memory pack ${name}`);
|
|
104
|
+
}
|
|
105
|
+
return res.body;
|
|
106
|
+
}
|
|
107
|
+
async uploadMemoryPack(source) {
|
|
108
|
+
const fileId = getMemoryFilePath(source.name);
|
|
109
|
+
const nameWithExt = source.name.endsWith(".tar.gz") ? source.name : source.name + ".tar.gz";
|
|
110
|
+
if (source instanceof File) {
|
|
111
|
+
let file = source;
|
|
112
|
+
return this.uploadFile(new StreamSource_js_1.StreamSource(file.stream(), nameWithExt, file.type, fileId));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return this.uploadFile(new StreamSource_js_1.StreamSource(source.stream, nameWithExt, source.type, fileId));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async downloadMemoryPack(name, gunzip = false) {
|
|
119
|
+
let stream = await this.downloadFile(getMemoryFilePath(name));
|
|
120
|
+
if (gunzip) {
|
|
121
|
+
const ds = new DecompressionStream("gzip");
|
|
122
|
+
stream = stream.pipeThrough(ds);
|
|
123
|
+
}
|
|
124
|
+
return stream;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.FilesApi = FilesApi;
|
|
128
|
+
//# sourceMappingURL=FilesApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesApi.js","sourceRoot":"","sources":["../../../src/store/FilesApi.ts"],"names":[],"mappings":";;;AAMA,8CAGC;AATD,iEAAkE;AAElE,wDAAkD;AAErC,QAAA,eAAe,GAAG,UAAU,CAAC;AAE1C,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;AAGD,MAAa,QAAS,SAAQ,2BAAQ;IAElC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,GAAW;QAQnB,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE;YACzB,KAAK,EAAE;gBACH,IAAI,EAAE,GAAG;aACZ;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,iBAAiB;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,YAAY,CAAC,OAA4B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YAC5B,OAAO;SACV,CAAC,CAAA;IACN,CAAC;IAED,cAAc,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YAC9B,OAAO,EAAE;gBACL,IAAI;aACqB;SAChC,CAAC,CAAA;IACN,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,MAA2B;QACxC,MAAM,QAAQ,GAAG,MAAM,YAAY,8BAAY,CAAC;QAChD,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG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