@vertesia/client 0.78.0-dev-28b447d → 0.79.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 +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 +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/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 +58 -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/InteractionsApi.js +217 -0
- package/lib/cjs/InteractionsApi.js.map +1 -0
- package/lib/cjs/ProjectsApi.js +48 -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 +279 -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 +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 +101 -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 +147 -0
- package/lib/cjs/store/FilesApi.js.map +1 -0
- package/lib/cjs/store/ObjectsApi.js +281 -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 +265 -0
- package/lib/cjs/store/WorkflowsApi.js.map +1 -0
- package/lib/cjs/store/client.js +71 -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/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 +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/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 +55 -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/InteractionsApi.js +214 -0
- package/lib/esm/InteractionsApi.js.map +1 -0
- package/lib/esm/ProjectsApi.js +45 -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 +270 -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 +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 +97 -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 +142 -0
- package/lib/esm/store/FilesApi.js.map +1 -0
- package/lib/esm/store/ObjectsApi.js +277 -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 +259 -0
- package/lib/esm/store/WorkflowsApi.js.map +1 -0
- package/lib/esm/store/client.js +67 -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/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 +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/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 +30 -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/InteractionsApi.d.ts +156 -0
- package/lib/types/InteractionsApi.d.ts.map +1 -0
- package/lib/types/ProjectsApi.d.ts +17 -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 +119 -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 +8 -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 +66 -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 +47 -0
- package/lib/types/store/FilesApi.d.ts.map +1 -0
- package/lib/types/store/ObjectsApi.d.ts +122 -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 +50 -0
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -0
- package/lib/types/store/client.d.ts +34 -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/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 +54 -59
- package/src/InteractionsApi.ts +1 -2
- package/src/RunsApi.ts +1 -8
- package/src/client.test.ts +0 -2
- package/src/client.ts +69 -129
- package/src/store/FilesApi.ts +2 -2
- package/src/store/WorkflowsApi.ts +0 -166
- package/src/store/client.ts +12 -3
- package/src/store/version.ts +2 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ExecutionRunStatus } from '@vertesia/common';
|
|
2
|
+
export async function EventSourceProvider() {
|
|
3
|
+
if (typeof globalThis.EventSource === 'function') {
|
|
4
|
+
return globalThis.EventSource;
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
return (await import('eventsource')).EventSource;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* Execute an interaction and return a promise which will be resolved with the executed run when
|
|
13
|
+
* the run completes or fails.
|
|
14
|
+
* If the onChunk callback is passed then the streaming of the result is enabled.
|
|
15
|
+
* The onChunk callback with be called with the next chunk of the result as soon as it is available.
|
|
16
|
+
* When all chunks are received the function will return the resolved promise
|
|
17
|
+
* @param id of the interaction to execute
|
|
18
|
+
* @param payload InteractionExecutionPayload
|
|
19
|
+
* @param onChunk callback to be called when the next chunk of the response is available
|
|
20
|
+
*/
|
|
21
|
+
export async function executeInteraction(client, interactionId, payload = {}, onChunk) {
|
|
22
|
+
const stream = !!onChunk;
|
|
23
|
+
const response = await client.runs.create({
|
|
24
|
+
...payload, interaction: interactionId, stream
|
|
25
|
+
});
|
|
26
|
+
if (stream) {
|
|
27
|
+
if (response.status === ExecutionRunStatus.failed) {
|
|
28
|
+
return response;
|
|
29
|
+
}
|
|
30
|
+
await handleStreaming(client, response.id, onChunk);
|
|
31
|
+
}
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Same as executeInteraction but uses the interaction name selector instead of the id.
|
|
36
|
+
* A name selector is the interaction endpoint name suffixed with an optional tag or version which is starting with a `@` character.
|
|
37
|
+
* 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.
|
|
38
|
+
* Examples of selectors:
|
|
39
|
+
* - `ReviewContract` - select the latest version of the ReviewContract interaction
|
|
40
|
+
* - `ReviewContract@1` - select the version 1 of the ReviewContract interaction
|
|
41
|
+
* - `ReviewContract@draft` - select the draft version of the ReviewContract interaction
|
|
42
|
+
* - `ReviewContract@fixed` - select the ReviewContract interaction which is tagged with 'fixed' tag.
|
|
43
|
+
*
|
|
44
|
+
* @param client
|
|
45
|
+
* @param interaction
|
|
46
|
+
* @param payload
|
|
47
|
+
* @param onChunk
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
export async function executeInteractionByName(client, interaction, payload = {}, onChunk) {
|
|
51
|
+
const stream = !!onChunk;
|
|
52
|
+
const response = await client.post('/api/v1/execute', {
|
|
53
|
+
payload: {
|
|
54
|
+
...payload,
|
|
55
|
+
interaction,
|
|
56
|
+
stream
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
if (stream) {
|
|
60
|
+
if (response.status === ExecutionRunStatus.failed) {
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
await handleStreaming(client, response.id, onChunk);
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
function handleStreaming(client, runId, onChunk) {
|
|
68
|
+
return new Promise(async (resolve, reject) => {
|
|
69
|
+
try {
|
|
70
|
+
const EventSourceImpl = await EventSourceProvider();
|
|
71
|
+
const streamUrl = new URL(client.runs.baseUrl + '/' + runId + '/stream');
|
|
72
|
+
const bearerToken = client._auth ? await client._auth() : undefined;
|
|
73
|
+
if (bearerToken) {
|
|
74
|
+
const token = bearerToken.split(' ')[1];
|
|
75
|
+
streamUrl.searchParams.set('access_token', token);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new Error('No auth token available');
|
|
79
|
+
}
|
|
80
|
+
const sse = new EventSourceImpl(streamUrl.href);
|
|
81
|
+
sse.addEventListener("message", ev => {
|
|
82
|
+
try {
|
|
83
|
+
const data = JSON.parse(ev.data);
|
|
84
|
+
if (data) {
|
|
85
|
+
onChunk && onChunk(data);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
reject(err);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
sse.addEventListener("close", (ev) => {
|
|
93
|
+
try {
|
|
94
|
+
sse.close();
|
|
95
|
+
const msg = JSON.parse(ev.data);
|
|
96
|
+
resolve(msg);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
reject(err);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
reject(err);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
export async function executeInteractionAsync(client, payload) {
|
|
109
|
+
return await client.post('/api/v1/execute/async', {
|
|
110
|
+
payload,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export async function checkRateLimit(client, payload) {
|
|
114
|
+
return await client.post('/api/v1/execute/rate-limit/request', {
|
|
115
|
+
payload
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,kBAAkB,EAAgJ,MAAM,kBAAkB,CAAC;AAG3N,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACrC,IAAI,OAAO,UAAU,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QAC/C,OAAO,UAAU,CAAC,WAAW,CAAC;IAClC,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC;IACrD,CAAC;AACL,CAAC;AACD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAU,MAAsB,EACpE,aAAqB,EACrB,UAAuC,EAAE,EACzC,OAAiC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC;IACzB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACtC,GAAG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM;KACjD,CAAC,CAAC;IACH,IAAI,MAAM,EAAE,CAAC;QACT,IAAI,QAAQ,CAAC,MAAM,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;YAChD,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,MAAM,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAU,MAA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C"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AAKrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ReadableStream as NodeReadableStream } from "node:stream/web";
|
|
2
|
+
import { StreamSource } from "../StreamSource.js";
|
|
3
|
+
/**
|
|
4
|
+
* A stream source that wraps a Node.js Readable stream.
|
|
5
|
+
* This class is only works in Node.js environments.
|
|
6
|
+
*/
|
|
7
|
+
export class NodeStreamSource extends StreamSource {
|
|
8
|
+
constructor(stream, name, type, id) {
|
|
9
|
+
super(readableToWebStream(stream), name, type, id);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function readableToWebStream(stream) {
|
|
13
|
+
if (NodeReadableStream.from) {
|
|
14
|
+
return NodeReadableStream.from(stream);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return readableToWebStream_BUN(stream);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Bun implementation since bun is not yet supporting NodeReadableStream.from
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
function readableToWebStream_BUN(stream) {
|
|
25
|
+
const it = stream[Symbol.asyncIterator]();
|
|
26
|
+
return new ReadableStream({
|
|
27
|
+
async pull(controller) {
|
|
28
|
+
const { value, done } = await it.next();
|
|
29
|
+
if (done) {
|
|
30
|
+
controller.close();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
controller.enqueue(value);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
cancel() {
|
|
37
|
+
it.return?.();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=NodeStreamSource.js.map
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1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nodejs/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
export class AgentsApi extends ApiTopic {
|
|
3
|
+
constructor(parent) {
|
|
4
|
+
super(parent, "/api/v1/agents");
|
|
5
|
+
}
|
|
6
|
+
async deploy(payload) {
|
|
7
|
+
return this.post('/', {
|
|
8
|
+
payload
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=AgentsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentsApi.js","sourceRoot":"","sources":["../../../src/store/AgentsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAIlE,MAAM,OAAO,SAAU,SAAQ,QAAQ;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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
export class AnalyzeDocApi extends ApiTopic {
|
|
3
|
+
objectId;
|
|
4
|
+
constructor(parent, objectId) {
|
|
5
|
+
super(parent, `/${objectId}/analyze`);
|
|
6
|
+
this.objectId = objectId;
|
|
7
|
+
}
|
|
8
|
+
async start(payload) {
|
|
9
|
+
return this.post("/", { payload });
|
|
10
|
+
}
|
|
11
|
+
async getStatus() {
|
|
12
|
+
return this.get("/status");
|
|
13
|
+
}
|
|
14
|
+
async getResults() {
|
|
15
|
+
return this.get("/results");
|
|
16
|
+
}
|
|
17
|
+
async adaptTables(payload) {
|
|
18
|
+
return this.post("/adapt_tables", { payload });
|
|
19
|
+
}
|
|
20
|
+
async getAdaptedTables(runId, query) {
|
|
21
|
+
const path = runId ? `/adapt_tables/${runId}` : "/adapt_tables";
|
|
22
|
+
// Build query parameters
|
|
23
|
+
const queryParams = {};
|
|
24
|
+
if (query?.format)
|
|
25
|
+
queryParams.format = query.format;
|
|
26
|
+
if (query?.raw !== undefined)
|
|
27
|
+
queryParams.raw = query.raw;
|
|
28
|
+
// If format is CSV, set response type to text to avoid automatic JSON parsing
|
|
29
|
+
const options = { query: queryParams };
|
|
30
|
+
if (query?.format === 'csv') {
|
|
31
|
+
options.responseType = 'text';
|
|
32
|
+
}
|
|
33
|
+
return this.get(path, options);
|
|
34
|
+
}
|
|
35
|
+
async getXml() {
|
|
36
|
+
return this.get("/xml");
|
|
37
|
+
}
|
|
38
|
+
async getTables(format) {
|
|
39
|
+
const options = {};
|
|
40
|
+
if (format) {
|
|
41
|
+
options.query = { format: format };
|
|
42
|
+
}
|
|
43
|
+
return this.get("/tables", options);
|
|
44
|
+
}
|
|
45
|
+
async getImages() {
|
|
46
|
+
return this.get("/images");
|
|
47
|
+
}
|
|
48
|
+
async getAnnotated() {
|
|
49
|
+
return this.get("/annotated");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=AnalyzeDocApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnalyzeDocApi.js","sourceRoot":"","sources":["../../../src/store/AnalyzeDocApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAGlE,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACA;IAAvC,YAAY,MAAkB,EAAS,QAAgB;QACnD,KAAK,CAAC,MAAM,EAAE,IAAI,QAAQ,UAAU,CAAC,CAAC;QADH,aAAQ,GAAR,QAAQ,CAAQ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,OAAO,GAAQ,EAAE,CAAC;QACxB,IAAI,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"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
export class CollectionsApi extends ApiTopic {
|
|
3
|
+
constructor(parent) {
|
|
4
|
+
super(parent, "/api/v1/collections");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* List collections
|
|
8
|
+
* @param payload: CollectionSearchPayload
|
|
9
|
+
* @returns CollectionItem[] list of collections
|
|
10
|
+
**/
|
|
11
|
+
search(payload) {
|
|
12
|
+
return this.post("/search", { payload });
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Compute facets for List collections
|
|
16
|
+
* @param query: ComputeCollectionFacetPayload
|
|
17
|
+
* @returns ComputeFacetsResponse list of facets
|
|
18
|
+
**/
|
|
19
|
+
computeListFacets(query) {
|
|
20
|
+
return this.post("/facets", {
|
|
21
|
+
payload: query
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the collection data without members
|
|
26
|
+
* @param collectionId
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
retrieve(collectionId) {
|
|
30
|
+
return this.get(`/${collectionId}`);
|
|
31
|
+
}
|
|
32
|
+
create(payload) {
|
|
33
|
+
return this.post(`/`, {
|
|
34
|
+
payload
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
update(collectionId, payload) {
|
|
38
|
+
return this.put(`/${collectionId}`, {
|
|
39
|
+
payload
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
addMembers(collectionId, members) {
|
|
43
|
+
return this.post(`/${collectionId}/members`, {
|
|
44
|
+
payload: {
|
|
45
|
+
action: 'add',
|
|
46
|
+
members
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
listMembers(collectionId, payload) {
|
|
51
|
+
return this.get(`/${collectionId}/members`, {
|
|
52
|
+
query: {
|
|
53
|
+
...payload
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
computeFacets(collectionId, query) {
|
|
58
|
+
return this.post(`/${collectionId}/facets`, {
|
|
59
|
+
payload: query
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
searchMembers(collectionId, payload) {
|
|
63
|
+
return this.post(`/${collectionId}/search`, { payload });
|
|
64
|
+
}
|
|
65
|
+
deleteMembers(collectionId, members) {
|
|
66
|
+
return this.post(`/${collectionId}/members`, {
|
|
67
|
+
payload: {
|
|
68
|
+
action: 'delete',
|
|
69
|
+
members
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
delete(id) {
|
|
74
|
+
return this.del(`/${id}`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Update collection permissions and propagate to member objects
|
|
78
|
+
* @param collectionId - The collection ID
|
|
79
|
+
* @param permissions - Map of permission types to principal arrays
|
|
80
|
+
* @returns Object with collection id, updated security, and number of objects updated
|
|
81
|
+
*/
|
|
82
|
+
updatePermissions(collectionId, permissions) {
|
|
83
|
+
return this.put(`/${collectionId}/permissions`, {
|
|
84
|
+
payload: permissions
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Manually trigger permission propagation from collection to member objects
|
|
89
|
+
* Useful for debugging and fixing permission issues
|
|
90
|
+
* @param collectionId - The collection ID
|
|
91
|
+
* @returns Object with collection id, message, and number of objects updated
|
|
92
|
+
*/
|
|
93
|
+
propagatePermissions(collectionId) {
|
|
94
|
+
return this.post(`/${collectionId}/propagate-permissions`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=CollectionsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionsApi.js","sourceRoot":"","sources":["../../../src/store/CollectionsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAKlE,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAExC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAqC;QACxC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,KAAoC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACxB,OAAO,EAAE,KAAK;SACjB,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,YAAoB;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,OAAgC;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YAClB,OAAO;SACV,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,YAAoB,EAAE,OAAyC;QAClE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,YAAY,EAAE,EAAE;YAChC,OAAO;SACV,CAAC,CAAC;IACP,CAAC;IAED,UAAU,CAAC,YAAoB,EAAE,OAAiB;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,YAAY,UAAU,EAAE;YACzC,OAAO,EAAE;g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.js";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use EmbeddingsApi instead
|
|
5
|
+
* @see EmbeddingsApi
|
|
6
|
+
*/
|
|
7
|
+
export class CommandsApi extends ApiTopic {
|
|
8
|
+
constructor(parent) {
|
|
9
|
+
super(parent, "/api/v1/commands");
|
|
10
|
+
}
|
|
11
|
+
embeddings = new EmbeddingsApi(this, "/embeddings");
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=CommandsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandsApi.js","sourceRoot":"","sources":["../../../src/store/CommandsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,QAAQ;IAErC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,UAAU,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;CACvD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
/**
|
|
3
|
+
* @since 0.52.0
|
|
4
|
+
*/
|
|
5
|
+
export class EmbeddingsApi extends ApiTopic {
|
|
6
|
+
constructor(parent, basePath = "/api/v1/embeddings") {
|
|
7
|
+
super(parent, basePath);
|
|
8
|
+
}
|
|
9
|
+
async status(type) {
|
|
10
|
+
return this.get(type + "/status");
|
|
11
|
+
}
|
|
12
|
+
async activate(type, config) {
|
|
13
|
+
if (!config.environment) {
|
|
14
|
+
throw new Error("Invalid configuration: select environment");
|
|
15
|
+
}
|
|
16
|
+
return this.post(type + "/enable", { payload: config });
|
|
17
|
+
}
|
|
18
|
+
async disable(type) {
|
|
19
|
+
return this.post(type + "/disable");
|
|
20
|
+
}
|
|
21
|
+
async recalculate(type) {
|
|
22
|
+
return this.post(type + "/recalculate");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=EmbeddingsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingsApi.js","sourceRoot":"","sources":["../../../src/store/EmbeddingsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAQlE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAEvC,YAAY,MAAkB,EAAE,WAAmB,oBAAoB;QACnE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAA6B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAA6B,EAAE,MAA+C;QAEzF,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAA6B;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAA6B;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,CAAC;IAC5C,CAAC;CAEJ"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
+
import { StreamSource } from "../StreamSource.js";
|
|
3
|
+
export const MEMORIES_PREFIX = "memories";
|
|
4
|
+
export function getMemoryFilePath(name) {
|
|
5
|
+
const nameWithExt = name.endsWith(".tar.gz") ? name : name + ".tar.gz";
|
|
6
|
+
return `${MEMORIES_PREFIX}/${nameWithExt}`;
|
|
7
|
+
}
|
|
8
|
+
export class FilesApi extends ApiTopic {
|
|
9
|
+
constructor(parent) {
|
|
10
|
+
super(parent, "/api/v1/files");
|
|
11
|
+
}
|
|
12
|
+
async deleteFile(path, prefix) {
|
|
13
|
+
const res = await this.delete(`/${path}`, { query: { prefix } });
|
|
14
|
+
return res.count;
|
|
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;
|
|
57
|
+
const { url, id, 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
|
+
})
|
|
67
|
+
.then((res) => {
|
|
68
|
+
if (res.ok) {
|
|
69
|
+
return res;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(res);
|
|
73
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.catch((err) => {
|
|
77
|
+
console.error("Failed to upload file", { err, url, id, path });
|
|
78
|
+
throw err;
|
|
79
|
+
});
|
|
80
|
+
return id;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param location can be a relative path in the project, a reference to a cloud storage, or a accessible HTTPS URL (typically signed URL)
|
|
85
|
+
* @returns ReadableStream
|
|
86
|
+
*/
|
|
87
|
+
async downloadFile(location) {
|
|
88
|
+
//if start with HTTPS, no download url needed - assume it's signed already
|
|
89
|
+
const needSign = !location.startsWith("https:");
|
|
90
|
+
const { url } = needSign
|
|
91
|
+
? await this.getDownloadUrl(location)
|
|
92
|
+
: { url: location };
|
|
93
|
+
const res = await fetch(url, {
|
|
94
|
+
method: "GET",
|
|
95
|
+
})
|
|
96
|
+
.then((res) => {
|
|
97
|
+
if (res.ok) {
|
|
98
|
+
return res;
|
|
99
|
+
}
|
|
100
|
+
else if (res.status === 404) {
|
|
101
|
+
throw new Error(`File ${location} not found`); //TODO: type fetch error better with a fetch error class
|
|
102
|
+
}
|
|
103
|
+
else if (res.status === 403) {
|
|
104
|
+
throw new Error(`File ${location} is forbidden`);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.log(res);
|
|
108
|
+
throw new Error(`Failed to download file ${location}: ${res.statusText}`);
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
.catch((err) => {
|
|
112
|
+
console.error(`Failed to download file ${location}.`, err);
|
|
113
|
+
throw err;
|
|
114
|
+
});
|
|
115
|
+
if (!res.body) {
|
|
116
|
+
throw new Error(`No body in response while downloading file ${location}`);
|
|
117
|
+
}
|
|
118
|
+
return res.body;
|
|
119
|
+
}
|
|
120
|
+
async uploadMemoryPack(source) {
|
|
121
|
+
const fileId = getMemoryFilePath(source.name);
|
|
122
|
+
const nameWithExt = source.name.endsWith(".tar.gz")
|
|
123
|
+
? source.name
|
|
124
|
+
: source.name + ".tar.gz";
|
|
125
|
+
if (source instanceof File) {
|
|
126
|
+
let file = source;
|
|
127
|
+
return this.uploadFile(new StreamSource(file.stream(), nameWithExt, file.type, fileId));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return this.uploadFile(new StreamSource(source.stream, nameWithExt, source.type, fileId));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async downloadMemoryPack(name, gunzip = false) {
|
|
134
|
+
let stream = await this.downloadFile(getMemoryFilePath(name));
|
|
135
|
+
if (gunzip) {
|
|
136
|
+
const ds = new DecompressionStream("gzip");
|
|
137
|
+
stream = stream.pipeThrough(ds);
|
|
138
|
+
}
|
|
139
|
+
return stream;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=FilesApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesApi.js","sourceRoot":"","sources":["../../../src/store/FilesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU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