@vertesia/client 1.6.0-dev.20261019.172735Z → 1.7.0-dev.20261120.100641Z
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/AccountApi.d.ts +2 -0
- package/lib/AccountApi.d.ts.map +1 -1
- package/lib/AccountApi.js +3 -0
- package/lib/AccountApi.js.map +1 -1
- package/lib/AccountRolesApi.d.ts +11 -0
- package/lib/AccountRolesApi.d.ts.map +1 -0
- package/lib/AccountRolesApi.js +22 -0
- package/lib/AccountRolesApi.js.map +1 -0
- package/lib/ApiKeysApi.d.ts +4 -7
- package/lib/ApiKeysApi.d.ts.map +1 -1
- package/lib/ApiKeysApi.js +5 -4
- package/lib/ApiKeysApi.js.map +1 -1
- package/lib/AppsApi.d.ts +18 -3
- package/lib/AppsApi.d.ts.map +1 -1
- package/lib/AppsApi.js +34 -4
- package/lib/AppsApi.js.map +1 -1
- package/lib/AuditTrailApi.d.ts +6 -1
- package/lib/AuditTrailApi.d.ts.map +1 -1
- package/lib/AuditTrailApi.js +8 -0
- package/lib/AuditTrailApi.js.map +1 -1
- package/lib/EnvironmentsApi.d.ts +2 -2
- package/lib/EnvironmentsApi.d.ts.map +1 -1
- package/lib/IamApi.d.ts +1 -1
- package/lib/IamApi.js +1 -1
- package/lib/InteractionCatalogApi.d.ts +19 -1
- package/lib/InteractionCatalogApi.d.ts.map +1 -1
- package/lib/InteractionCatalogApi.js +30 -0
- package/lib/InteractionCatalogApi.js.map +1 -1
- package/lib/InteractionsApi.d.ts +6 -13
- package/lib/InteractionsApi.d.ts.map +1 -1
- package/lib/InteractionsApi.js +4 -24
- package/lib/InteractionsApi.js.map +1 -1
- package/lib/OAuthClientsApi.d.ts +3 -1
- package/lib/OAuthClientsApi.d.ts.map +1 -1
- package/lib/OAuthClientsApi.js +4 -0
- package/lib/OAuthClientsApi.js.map +1 -1
- package/lib/OAuthProvidersApi.d.ts +6 -2
- package/lib/OAuthProvidersApi.d.ts.map +1 -1
- package/lib/OAuthProvidersApi.js +6 -2
- package/lib/OAuthProvidersApi.js.map +1 -1
- package/lib/RemoteMcpConnectionsApi.d.ts +5 -1
- package/lib/RemoteMcpConnectionsApi.d.ts.map +1 -1
- package/lib/RemoteMcpConnectionsApi.js +6 -2
- package/lib/RemoteMcpConnectionsApi.js.map +1 -1
- package/lib/RunsApi.d.ts +3 -2
- package/lib/RunsApi.d.ts.map +1 -1
- package/lib/RunsApi.js +3 -2
- package/lib/RunsApi.js.map +1 -1
- package/lib/StreamSource.d.ts +19 -1
- package/lib/StreamSource.d.ts.map +1 -1
- package/lib/StreamSource.js +31 -1
- package/lib/StreamSource.js.map +1 -1
- package/lib/UsersApi.d.ts +7 -1
- package/lib/UsersApi.d.ts.map +1 -1
- package/lib/UsersApi.js +8 -0
- package/lib/UsersApi.js.map +1 -1
- package/lib/client.d.ts +14 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +57 -8
- package/lib/client.js.map +1 -1
- package/lib/execute.d.ts +16 -2
- package/lib/execute.d.ts.map +1 -1
- package/lib/execute.js +16 -3
- package/lib/execute.js.map +1 -1
- package/lib/idempotency-key.d.ts +19 -0
- package/lib/idempotency-key.d.ts.map +1 -0
- package/lib/idempotency-key.js +34 -0
- package/lib/idempotency-key.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/nodejs/NodeStreamSource.d.ts +11 -1
- package/lib/nodejs/NodeStreamSource.d.ts.map +1 -1
- package/lib/nodejs/NodeStreamSource.js +56 -16
- package/lib/nodejs/NodeStreamSource.js.map +1 -1
- package/lib/store/AgentsApi.d.ts +3 -0
- package/lib/store/AgentsApi.d.ts.map +1 -1
- package/lib/store/AgentsApi.js +10 -1
- package/lib/store/AgentsApi.js.map +1 -1
- package/lib/store/ContentSourcesApi.d.ts +57 -0
- package/lib/store/ContentSourcesApi.d.ts.map +1 -0
- package/lib/store/ContentSourcesApi.js +92 -0
- package/lib/store/ContentSourcesApi.js.map +1 -0
- package/lib/store/CostApi.d.ts +9 -1
- package/lib/store/CostApi.d.ts.map +1 -1
- package/lib/store/CostApi.js +16 -0
- package/lib/store/CostApi.js.map +1 -1
- package/lib/store/DashboardApi.d.ts +61 -19
- package/lib/store/DashboardApi.d.ts.map +1 -1
- package/lib/store/DashboardApi.js +75 -19
- package/lib/store/DashboardApi.js.map +1 -1
- package/lib/store/DataApi.d.ts +9 -9
- package/lib/store/DataApi.d.ts.map +1 -1
- package/lib/store/DataApi.js +14 -10
- package/lib/store/DataApi.js.map +1 -1
- package/lib/store/FilesApi.d.ts +15 -1
- package/lib/store/FilesApi.d.ts.map +1 -1
- package/lib/store/FilesApi.js +54 -69
- package/lib/store/FilesApi.js.map +1 -1
- package/lib/store/IndexingApi.d.ts +0 -6
- package/lib/store/IndexingApi.d.ts.map +1 -1
- package/lib/store/IndexingApi.js +3 -17
- package/lib/store/IndexingApi.js.map +1 -1
- package/lib/store/NotificationsApi.d.ts +39 -0
- package/lib/store/NotificationsApi.d.ts.map +1 -0
- package/lib/store/NotificationsApi.js +68 -0
- package/lib/store/NotificationsApi.js.map +1 -0
- package/lib/store/ObjectsApi.d.ts +6 -7
- package/lib/store/ObjectsApi.d.ts.map +1 -1
- package/lib/store/ObjectsApi.js +25 -46
- package/lib/store/ObjectsApi.js.map +1 -1
- package/lib/store/RenderingApi.d.ts.map +1 -1
- package/lib/store/RenderingApi.js +1 -0
- package/lib/store/RenderingApi.js.map +1 -1
- package/lib/store/WorkflowsApi.d.ts +19 -1
- package/lib/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/store/WorkflowsApi.js +21 -0
- package/lib/store/WorkflowsApi.js.map +1 -1
- package/lib/store/chunked-upload.d.ts +71 -0
- package/lib/store/chunked-upload.d.ts.map +1 -0
- package/lib/store/chunked-upload.js +206 -0
- package/lib/store/chunked-upload.js.map +1 -0
- package/lib/store/client.d.ts +9 -1
- package/lib/store/client.d.ts.map +1 -1
- package/lib/store/client.js +17 -1
- package/lib/store/client.js.map +1 -1
- package/lib/store/index.d.ts +3 -0
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +3 -0
- package/lib/store/index.js.map +1 -1
- package/lib/store/node-request.browser.d.ts +14 -0
- package/lib/store/node-request.browser.d.ts.map +1 -0
- package/lib/store/node-request.browser.js +20 -0
- package/lib/store/node-request.browser.js.map +1 -0
- package/lib/store/node-request.d.ts +20 -0
- package/lib/store/node-request.d.ts.map +1 -0
- package/lib/store/node-request.js +116 -0
- package/lib/store/node-request.js.map +1 -0
- package/lib/store/node-sessions.browser.d.ts +3 -0
- package/lib/store/node-sessions.browser.d.ts.map +1 -0
- package/lib/store/node-sessions.browser.js +15 -0
- package/lib/store/node-sessions.browser.js.map +1 -0
- package/lib/store/node-sessions.d.ts +14 -0
- package/lib/store/node-sessions.d.ts.map +1 -0
- package/lib/store/node-sessions.js +88 -0
- package/lib/store/node-sessions.js.map +1 -0
- package/lib/store/signed-url.d.ts +12 -16
- package/lib/store/signed-url.d.ts.map +1 -1
- package/lib/store/signed-url.js +111 -71
- package/lib/store/signed-url.js.map +1 -1
- package/lib/store/stream-bytes.d.ts +16 -0
- package/lib/store/stream-bytes.d.ts.map +1 -0
- package/lib/store/stream-bytes.js +70 -0
- package/lib/store/stream-bytes.js.map +1 -0
- package/lib/store/stream-termination.d.ts.map +1 -1
- package/lib/store/stream-termination.js +17 -16
- package/lib/store/stream-termination.js.map +1 -1
- package/lib/store/upload-body.d.ts +21 -0
- package/lib/store/upload-body.d.ts.map +1 -0
- package/lib/store/upload-body.js +32 -0
- package/lib/store/upload-body.js.map +1 -0
- package/lib/store/upload-content.d.ts +21 -0
- package/lib/store/upload-content.d.ts.map +1 -0
- package/lib/store/upload-content.js +113 -0
- package/lib/store/upload-content.js.map +1 -0
- package/lib/store/upload-runtime.d.ts +21 -0
- package/lib/store/upload-runtime.d.ts.map +1 -0
- package/lib/store/upload-runtime.js +40 -0
- package/lib/store/upload-runtime.js.map +1 -0
- package/lib/store/zeno-bulk.d.ts +9 -0
- package/lib/store/zeno-bulk.d.ts.map +1 -0
- package/lib/store/zeno-bulk.js +26 -0
- package/lib/store/zeno-bulk.js.map +1 -0
- package/lib/user-agent.d.ts +11 -0
- package/lib/user-agent.d.ts.map +1 -0
- package/lib/user-agent.js +35 -0
- package/lib/user-agent.js.map +1 -0
- package/lib/vertesia-client.js +10 -9
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +38 -9
- package/src/AccountApi.ts +3 -0
- package/src/AccountRolesApi.ts +29 -0
- package/src/ApiKeysApi.ts +4 -12
- package/src/AppsApi.ts +58 -4
- package/src/AuditTrailApi.ts +11 -0
- package/src/EnvironmentsApi.ts +2 -2
- package/src/IamApi.ts +1 -1
- package/src/InteractionCatalogApi.ts +44 -1
- package/src/InteractionsApi.ts +11 -33
- package/src/OAuthClientsApi.ts +6 -0
- package/src/OAuthProvidersApi.ts +7 -2
- package/src/RemoteMcpConnectionsApi.ts +7 -3
- package/src/RunsApi.ts +7 -2
- package/src/StreamSource.ts +29 -0
- package/src/UsersApi.ts +10 -1
- package/src/client.ts +74 -8
- package/src/execute.ts +33 -4
- package/src/idempotency-key.ts +34 -0
- package/src/index.ts +1 -0
- package/src/nodejs/NodeStreamSource.ts +63 -24
- package/src/store/AgentsApi.ts +13 -1
- package/src/store/ContentSourcesApi.ts +135 -0
- package/src/store/CostApi.ts +24 -0
- package/src/store/DashboardApi.ts +93 -18
- package/src/store/DataApi.ts +14 -10
- package/src/store/FilesApi.ts +84 -72
- package/src/store/IndexingApi.ts +3 -18
- package/src/store/NotificationsApi.ts +103 -0
- package/src/store/ObjectsApi.ts +32 -51
- package/src/store/RenderingApi.ts +1 -0
- package/src/store/WorkflowsApi.ts +25 -0
- package/src/store/chunked-upload.ts +272 -0
- package/src/store/client.ts +23 -1
- package/src/store/index.ts +3 -0
- package/src/store/node-request.browser.ts +22 -0
- package/src/store/node-request.ts +120 -0
- package/src/store/node-sessions.browser.ts +16 -0
- package/src/store/node-sessions.ts +109 -0
- package/src/store/signed-url.ts +126 -72
- package/src/store/stream-bytes.ts +79 -0
- package/src/store/stream-termination.ts +24 -24
- package/src/store/upload-body.ts +37 -0
- package/src/store/upload-content.ts +129 -0
- package/src/store/upload-runtime.ts +42 -0
- package/src/store/zeno-bulk.ts +30 -0
- package/src/user-agent.ts +41 -0
package/src/store/ObjectsApi.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type BulkObjectDeleteResult,
|
|
6
6
|
type BulkObjectUpdateOptions,
|
|
7
7
|
type BulkObjectUpdateResult,
|
|
8
|
+
type BulkOperationPayload,
|
|
8
9
|
type Collection,
|
|
9
10
|
type ComplexSearchPayload,
|
|
10
11
|
type ComputedFacetResponse,
|
|
@@ -34,6 +35,8 @@ import {
|
|
|
34
35
|
type GetUploadUrlPayload,
|
|
35
36
|
type ListContentObjectExportsResponse,
|
|
36
37
|
type ListWorkflowRunsResponse,
|
|
38
|
+
type ObjectIntakeCostQuery,
|
|
39
|
+
type ObjectIntakeCostResponse,
|
|
37
40
|
type ObjectSearchPayload,
|
|
38
41
|
type ObjectSearchQuery,
|
|
39
42
|
type ObjectSearchResponse,
|
|
@@ -58,11 +61,14 @@ export { getSupportedRenditionFormats, supportsVisualRendition } from '@vertesia
|
|
|
58
61
|
// Re-export rendition utilities for consumers
|
|
59
62
|
export { canGenerateRendition };
|
|
60
63
|
|
|
64
|
+
import { withIdempotencyKey } from '../idempotency-key.js';
|
|
61
65
|
import { StreamSource } from '../StreamSource.js';
|
|
62
66
|
import { AnalyzeDocApi } from './AnalyzeDocApi.js';
|
|
63
67
|
import type { ZenoClient } from './client.js';
|
|
64
68
|
import { fetchSignedUrl } from './signed-url.js';
|
|
65
|
-
import {
|
|
69
|
+
import { uploadContent } from './upload-content.js';
|
|
70
|
+
import { getUploadMimeTypeHint } from './uploadMimeType.js';
|
|
71
|
+
import { zenoBulkBaseUrl } from './zeno-bulk.js';
|
|
66
72
|
|
|
67
73
|
/**
|
|
68
74
|
* The two write payloads, each widened at `content` so callers can hand us a browser `File` or a
|
|
@@ -215,24 +221,8 @@ export class ObjectsApi extends ApiTopic {
|
|
|
215
221
|
return this.zenoBulkPost('/export/compose', payload, timeoutMs);
|
|
216
222
|
}
|
|
217
223
|
|
|
218
|
-
/**
|
|
219
|
-
* Get the zeno-bulk base URL.
|
|
220
|
-
* Dev branches: store URL contains "zeno-server" -> replace with "zeno-bulk".
|
|
221
|
-
* Production/preview: same domain, LB routes /export to zeno-bulk.
|
|
222
|
-
*/
|
|
223
|
-
private get zenoBulkBaseUrl(): string {
|
|
224
|
-
const storeBaseUrl = this.client.baseUrl;
|
|
225
|
-
if (storeBaseUrl.includes('localhost:') || storeBaseUrl.includes('127.0.0.1:')) {
|
|
226
|
-
return 'https://zeno-bulk-dev-main.api.dev1.vertesia.io';
|
|
227
|
-
}
|
|
228
|
-
if (storeBaseUrl.includes('zeno-server')) {
|
|
229
|
-
return storeBaseUrl.replace(/zeno-server/, 'zeno-bulk');
|
|
230
|
-
}
|
|
231
|
-
return storeBaseUrl;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
224
|
private zenoBulkPost<T>(path: string, body: object, timeoutMs?: number | false | null): Promise<T> {
|
|
235
|
-
return this.client.post(this.
|
|
225
|
+
return this.client.post(zenoBulkBaseUrl(this.client.baseUrl) + path, { payload: body, timeoutMs });
|
|
236
226
|
}
|
|
237
227
|
|
|
238
228
|
listFolders(_path: string = '/') {
|
|
@@ -294,39 +284,19 @@ export class ObjectsApi extends ApiTopic {
|
|
|
294
284
|
}
|
|
295
285
|
|
|
296
286
|
async upload(source: StreamSource | File) {
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const { url, id, mime_type } = await this.getUploadUrl({
|
|
300
|
-
id: isStream ? source.id : undefined,
|
|
287
|
+
const request = {
|
|
288
|
+
id: source instanceof StreamSource ? source.id : undefined,
|
|
301
289
|
name: source.name,
|
|
302
290
|
mime_type: getUploadMimeTypeHint(source.type),
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
method: 'PUT',
|
|
309
|
-
body: isStream ? source.stream : source,
|
|
310
|
-
headers: sourceMimeType ? { 'Content-Type': sourceMimeType } : undefined,
|
|
311
|
-
}).catch((err) => {
|
|
312
|
-
console.error('Failed to upload file', err);
|
|
313
|
-
throw err;
|
|
314
|
-
});
|
|
315
|
-
if (!res.ok) {
|
|
316
|
-
console.error('Failed to upload file', { status: res.status, statusText: res.statusText, url });
|
|
317
|
-
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
//Etag need to be unquoted
|
|
321
|
-
//When a server returns an ETag header, it includes the quotes around the actual hash value.
|
|
322
|
-
//This is part of the HTTP specification (RFC 7232), which states that ETags should be
|
|
323
|
-
//enclosed in double quotes.
|
|
324
|
-
const etag = res.headers.get('etag')?.replace(/^"(.*)"$/, '$1');
|
|
325
|
-
|
|
291
|
+
};
|
|
292
|
+
// A signed URL for the object's content file, or an upload session for a long stream.
|
|
293
|
+
const { id, mime_type, etag } = await uploadContent(this.client.files, source, request, () =>
|
|
294
|
+
this.getUploadUrl(request),
|
|
295
|
+
);
|
|
326
296
|
return {
|
|
327
297
|
source: id,
|
|
328
298
|
name: source.name,
|
|
329
|
-
type:
|
|
299
|
+
type: mime_type,
|
|
330
300
|
etag,
|
|
331
301
|
};
|
|
332
302
|
}
|
|
@@ -339,9 +309,10 @@ export class ObjectsApi extends ApiTopic {
|
|
|
339
309
|
},
|
|
340
310
|
): Promise<ContentObject> {
|
|
341
311
|
const { content, ...payloadWithoutContent } = payload;
|
|
342
|
-
|
|
312
|
+
// One key per call, reused by every retry of the POST below.
|
|
313
|
+
const createPayload: CreateContentObjectPayload = withIdempotencyKey(this.client, {
|
|
343
314
|
...payloadWithoutContent,
|
|
344
|
-
};
|
|
315
|
+
});
|
|
345
316
|
if (content instanceof StreamSource || content instanceof File) {
|
|
346
317
|
createPayload.content = await this.upload(content);
|
|
347
318
|
} else {
|
|
@@ -380,7 +351,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
380
351
|
},
|
|
381
352
|
): Promise<ContentObject> {
|
|
382
353
|
const metadata = await this.client.files.getMetadata(uri);
|
|
383
|
-
const createPayload: CreateContentObjectPayload = {
|
|
354
|
+
const createPayload: CreateContentObjectPayload = withIdempotencyKey(this.client, {
|
|
384
355
|
...payload,
|
|
385
356
|
content: {
|
|
386
357
|
source: uri,
|
|
@@ -388,7 +359,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
388
359
|
type: metadata.contentType,
|
|
389
360
|
etag: metadata.etag,
|
|
390
361
|
},
|
|
391
|
-
};
|
|
362
|
+
});
|
|
392
363
|
|
|
393
364
|
const headers: Record<string, string> = {};
|
|
394
365
|
if (options?.processing_priority) {
|
|
@@ -518,7 +489,9 @@ export class ObjectsApi extends ApiTopic {
|
|
|
518
489
|
return this.client.runOperation({
|
|
519
490
|
name: 'create',
|
|
520
491
|
ids: [],
|
|
521
|
-
|
|
492
|
+
// `CreateContentObjectPayload` keeps the known metadata interfaces assignable, so it is wider than the
|
|
493
|
+
// wire type the bulk payload names; the server checks each object against the single-create contract.
|
|
494
|
+
params: { objects, ...options } as BulkOperationPayload['params'],
|
|
522
495
|
}) as Promise<BulkObjectCreateResult>;
|
|
523
496
|
}
|
|
524
497
|
|
|
@@ -526,6 +499,14 @@ export class ObjectsApi extends ApiTopic {
|
|
|
526
499
|
return this.get(`/${documentId}/workflow-runs`);
|
|
527
500
|
}
|
|
528
501
|
|
|
502
|
+
/**
|
|
503
|
+
* The LLM and embedding cost of the intake workflows that processed a content object, per run and in total.
|
|
504
|
+
* Requires read access to the object and a billing read permission.
|
|
505
|
+
*/
|
|
506
|
+
getIntakeCost(documentId: string, query?: ObjectIntakeCostQuery): Promise<ObjectIntakeCostResponse> {
|
|
507
|
+
return this.get(`/${documentId}/intake-cost`, { query });
|
|
508
|
+
}
|
|
509
|
+
|
|
529
510
|
listRenditions(documentId: string): Promise<ContentObjectItem[]> {
|
|
530
511
|
return this.get(`/${documentId}/renditions`);
|
|
531
512
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApiTopic, type ClientBase, type IRequestParams } from '@vertesia/api-fetch-client';
|
|
2
|
+
import type { WorkflowUsageQuery, WorkflowUsageStanding } from '@vertesia/common';
|
|
2
3
|
import {
|
|
3
4
|
type ActivityCatalog,
|
|
4
5
|
type AgentEvent,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
type RunsByAgentAnalyticsResponse,
|
|
21
22
|
type SignalAgentPayload,
|
|
22
23
|
type SignalAgentResponse,
|
|
24
|
+
type SubscriptionWorkflowCatalog,
|
|
23
25
|
type TimeToFirstResponseAnalyticsResponse,
|
|
24
26
|
type TokenUsageAnalyticsResponse,
|
|
25
27
|
type ToolAnalyticsResponse,
|
|
@@ -55,6 +57,14 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
55
57
|
super(parent, '/api/v1/workflows');
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
usage(query?: WorkflowUsageQuery): Promise<WorkflowUsageStanding> {
|
|
61
|
+
return this.get('/usage', { query });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getSubscriptionWorkflowCatalog(): Promise<SubscriptionWorkflowCatalog> {
|
|
65
|
+
return this.get('/subscription-catalog');
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
getActivityCatalog(): Promise<ActivityCatalog> {
|
|
59
69
|
return this.get('/activity-catalog');
|
|
60
70
|
}
|
|
@@ -729,39 +739,48 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
729
739
|
return this.post('/analytics/first-response-behavior', { payload: query });
|
|
730
740
|
}
|
|
731
741
|
|
|
742
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
732
743
|
rules = new WorkflowsRulesApi(this);
|
|
744
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
733
745
|
definitions = new WorkflowsDefinitionApi(this);
|
|
734
746
|
}
|
|
735
747
|
|
|
748
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
736
749
|
export class WorkflowsRulesApi extends ApiTopic {
|
|
737
750
|
constructor(parent: WorkflowsApi) {
|
|
738
751
|
super(parent, '/rules');
|
|
739
752
|
}
|
|
740
753
|
|
|
754
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
741
755
|
list(): Promise<WorkflowRuleItem[]> {
|
|
742
756
|
return this.get('/');
|
|
743
757
|
}
|
|
744
758
|
|
|
759
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
745
760
|
retrieve(id: string): Promise<WorkflowRule> {
|
|
746
761
|
return this.get(`/${id}`);
|
|
747
762
|
}
|
|
748
763
|
|
|
764
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
749
765
|
update(id: string, payload: UpdateWorkflowRulePayload): Promise<WorkflowRule> {
|
|
750
766
|
return this.put(`/${id}`, {
|
|
751
767
|
payload,
|
|
752
768
|
});
|
|
753
769
|
}
|
|
754
770
|
|
|
771
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
755
772
|
create(payload: CreateWorkflowRulePayload): Promise<WorkflowRule> {
|
|
756
773
|
return this.post('/', {
|
|
757
774
|
payload,
|
|
758
775
|
});
|
|
759
776
|
}
|
|
760
777
|
|
|
778
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
761
779
|
delete(id: string) {
|
|
762
780
|
return this.del(`/${id}`);
|
|
763
781
|
}
|
|
764
782
|
|
|
783
|
+
/** @deprecated Workflow rules are deprecated; use event subscriptions instead. */
|
|
765
784
|
execute(
|
|
766
785
|
id: string,
|
|
767
786
|
objectIds?: string[],
|
|
@@ -775,6 +794,7 @@ export class WorkflowsRulesApi extends ApiTopic {
|
|
|
775
794
|
}
|
|
776
795
|
}
|
|
777
796
|
|
|
797
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
778
798
|
export class WorkflowsDefinitionApi extends ApiTopic {
|
|
779
799
|
//model: DSLWorkflowDefinition;
|
|
780
800
|
|
|
@@ -782,26 +802,31 @@ export class WorkflowsDefinitionApi extends ApiTopic {
|
|
|
782
802
|
super(parent, '/definitions');
|
|
783
803
|
}
|
|
784
804
|
|
|
805
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
785
806
|
list(): Promise<WorkflowDefinitionRef[]> {
|
|
786
807
|
return this.get('/');
|
|
787
808
|
}
|
|
788
809
|
|
|
810
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
789
811
|
retrieve(id: string): Promise<DSLWorkflowDefinition> {
|
|
790
812
|
return this.get(`/${id}`);
|
|
791
813
|
}
|
|
792
814
|
|
|
815
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
793
816
|
update(id: string, payload: UpdateWorkflowDefinitionPayload): Promise<DSLWorkflowDefinition> {
|
|
794
817
|
return this.put(`/${id}`, {
|
|
795
818
|
payload,
|
|
796
819
|
});
|
|
797
820
|
}
|
|
798
821
|
|
|
822
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
799
823
|
create(payload: DSLWorkflowSpec): Promise<DSLWorkflowDefinition> {
|
|
800
824
|
return this.post('/', {
|
|
801
825
|
payload,
|
|
802
826
|
});
|
|
803
827
|
}
|
|
804
828
|
|
|
829
|
+
/** @deprecated Workflow definitions are deprecated. */
|
|
805
830
|
delete(id: string) {
|
|
806
831
|
return this.del(`/${id}`);
|
|
807
832
|
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uploads in parts, for stream sources longer than one part (Node.js only).
|
|
3
|
+
*
|
|
4
|
+
* A single signed PUT is capped by the store (5 GB on S3, about 5,000 MiB on Azure) and cannot resume. A source
|
|
5
|
+
* longer than {@link UPLOAD_PART_SIZE} therefore goes through an upload session, sent with the store's own protocol:
|
|
6
|
+
*
|
|
7
|
+
* - Google Cloud Storage: a resumable upload, written by `@google-cloud/storage`, which retries a failed chunk from
|
|
8
|
+
* the offset the service persisted.
|
|
9
|
+
* - Azure Blob Storage: Put Block for each part then Put Block List, written by `@azure/storage-blob`.
|
|
10
|
+
* - Amazon S3: a multipart upload. Each part is a `PUT` to a URL the server signs, retried like any signed-URL
|
|
11
|
+
* transfer, and the server completes the upload, or aborts it when a part cannot be sent.
|
|
12
|
+
*
|
|
13
|
+
* Memory stays about one part per upload, and nothing is written to disk. Parts are 16 MiB, or larger for content
|
|
14
|
+
* whose length would need more parts than the store allows: S3 takes 10,000 and Azure 50,000.
|
|
15
|
+
*
|
|
16
|
+
* The two SDKs are optional peer dependencies, loaded only on this path. Without the one a session needs, the
|
|
17
|
+
* upload falls back to a single signed PUT.
|
|
18
|
+
*/
|
|
19
|
+
import type { CompletedUploadPart, S3MultipartUploadSession, UploadSession } from '@vertesia/common';
|
|
20
|
+
import { StreamSource } from '../StreamSource.js';
|
|
21
|
+
// hasNodeHttp from node-request, whose browser build answers false: a bundle without the Node transport never
|
|
22
|
+
// opens a session.
|
|
23
|
+
import { hasNodeHttp } from './node-request.js';
|
|
24
|
+
import { uploadAzureBlocks, uploadGcsResumable } from './node-sessions.js';
|
|
25
|
+
import { fetchSignedUrl, MAX_BUFFERED_STREAM_BYTES } from './signed-url.js';
|
|
26
|
+
import { chunkToBlobPart, continueStream } from './stream-bytes.js';
|
|
27
|
+
import { getUploadBody, type UploadBody, unquoteEtag } from './upload-body.js';
|
|
28
|
+
import { ContentLengthMismatchError, UploadSessionUnavailableError } from './upload-runtime.js';
|
|
29
|
+
|
|
30
|
+
export { UploadSessionUnavailableError } from './upload-runtime.js';
|
|
31
|
+
|
|
32
|
+
/** Sources longer than this are sent in parts: the most of a stream that is held in memory at once. */
|
|
33
|
+
export const UPLOAD_PART_SIZE = MAX_BUFFERED_STREAM_BYTES;
|
|
34
|
+
|
|
35
|
+
const MiB = 1024 * 1024;
|
|
36
|
+
/** S3 numbers parts from 1 to 10,000 and takes objects up to 5 TiB. */
|
|
37
|
+
const S3_MAX_PARTS = 10_000;
|
|
38
|
+
const S3_MAX_OBJECT_SIZE = 5 * 1024 * 1024 * MiB;
|
|
39
|
+
/** For a stream of unknown length, S3 parts double in size every this many parts: 16 MiB parts reach 968 GiB. */
|
|
40
|
+
const S3_PARTS_PER_SIZE = 2_000;
|
|
41
|
+
/** Azure commits at most 50,000 blocks. */
|
|
42
|
+
const AZURE_MAX_BLOCKS = 50_000;
|
|
43
|
+
/**
|
|
44
|
+
* Part URLs are signed this many at a time, and signed again once this old, since they expire (S3 default, one hour,
|
|
45
|
+
* or sooner with the signer's credentials) while a slow source fills the parts before them.
|
|
46
|
+
*/
|
|
47
|
+
const PART_URL_BATCH = 100;
|
|
48
|
+
const PART_URL_MAX_AGE_MS = 15 * 60_000;
|
|
49
|
+
|
|
50
|
+
/** Content to send in parts, with its declared length when it is a stream whose length is known. */
|
|
51
|
+
export interface PartsBody {
|
|
52
|
+
body: Blob | ReadableStream<Uint8Array>;
|
|
53
|
+
size?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type UploadPlan = { kind: 'single'; upload: UploadBody } | { kind: 'parts'; parts: PartsBody };
|
|
57
|
+
|
|
58
|
+
/** The operations an S3 multipart upload needs from the API. */
|
|
59
|
+
export interface MultipartUploadApi {
|
|
60
|
+
getUploadPartUrls(payload: {
|
|
61
|
+
id: string;
|
|
62
|
+
upload_id: string;
|
|
63
|
+
part_numbers: number[];
|
|
64
|
+
}): Promise<{ parts: { part_number: number; url: string }[] }>;
|
|
65
|
+
completeUploadSession(payload: {
|
|
66
|
+
id: string;
|
|
67
|
+
upload_id: string;
|
|
68
|
+
parts: CompletedUploadPart[];
|
|
69
|
+
}): Promise<{ etag?: string }>;
|
|
70
|
+
abortUploadSession(payload: { id: string; upload_id: string }): Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* How to upload a source. A `File`, and anything in a browser, is sent in one PUT as before. In Node.js, a stream
|
|
75
|
+
* source longer than one part is sent in parts. A plain stream is read up to one part to find out: one that ends
|
|
76
|
+
* first is sent whole, from memory, so it keeps its retries.
|
|
77
|
+
*/
|
|
78
|
+
export async function planUpload(source: StreamSource | File): Promise<UploadPlan> {
|
|
79
|
+
const upload = await getUploadBody(source);
|
|
80
|
+
if (!(source instanceof StreamSource) || !hasNodeHttp()) return { kind: 'single', upload };
|
|
81
|
+
const { body, contentLength } = upload;
|
|
82
|
+
if (body instanceof Blob) {
|
|
83
|
+
return body.size > UPLOAD_PART_SIZE ? { kind: 'parts', parts: { body } } : { kind: 'single', upload };
|
|
84
|
+
}
|
|
85
|
+
if (contentLength !== undefined && contentLength <= UPLOAD_PART_SIZE) return { kind: 'single', upload };
|
|
86
|
+
|
|
87
|
+
const reader = (body as ReadableStream<unknown>).getReader();
|
|
88
|
+
const head: BlobPart[] = [];
|
|
89
|
+
let read = 0;
|
|
90
|
+
try {
|
|
91
|
+
while (read <= UPLOAD_PART_SIZE) {
|
|
92
|
+
const { done, value } = await reader.read();
|
|
93
|
+
if (done) {
|
|
94
|
+
reader.releaseLock();
|
|
95
|
+
// a declared length is over one part here, so a stream that ended is short of it
|
|
96
|
+
if (contentLength !== undefined) throw new ContentLengthMismatchError(contentLength, read, 'short');
|
|
97
|
+
return { kind: 'single', upload: { body: new Blob(head) } };
|
|
98
|
+
}
|
|
99
|
+
const part = chunkToBlobPart(value);
|
|
100
|
+
head.push(part);
|
|
101
|
+
read += part instanceof Blob ? part.size : (part as Uint8Array).byteLength;
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
await reader.cancel(err).catch(() => undefined);
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
return { kind: 'parts', parts: { body: continueStream(head, reader), size: contentLength } };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The same content as one stream, for a single PUT when no session can be used. */
|
|
111
|
+
export function partsAsUploadBody(parts: PartsBody): UploadBody {
|
|
112
|
+
return parts.body instanceof Blob ? { body: parts.body } : { body: parts.body, contentLength: parts.size };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Sends the content through the session. Returns the stored object's ETag, unquoted, when the store gives one. */
|
|
116
|
+
export async function uploadInParts(
|
|
117
|
+
api: MultipartUploadApi,
|
|
118
|
+
session: UploadSession,
|
|
119
|
+
parts: PartsBody,
|
|
120
|
+
): Promise<string | undefined> {
|
|
121
|
+
switch (session.protocol) {
|
|
122
|
+
case 's3_multipart':
|
|
123
|
+
return uploadS3Parts(api, session, parts);
|
|
124
|
+
case 'gcs_resumable':
|
|
125
|
+
return uploadGcsResumable(session, parts);
|
|
126
|
+
case 'azure_block_blob':
|
|
127
|
+
return unquoteEtag(
|
|
128
|
+
await uploadAzureBlocks(
|
|
129
|
+
session.url,
|
|
130
|
+
fitParts(session.part_size, knownSize(parts), AZURE_MAX_BLOCKS),
|
|
131
|
+
session.mime_type,
|
|
132
|
+
parts,
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
default:
|
|
136
|
+
// A protocol from a newer server: upload in one request instead, before reading anything.
|
|
137
|
+
throw new UploadSessionUnavailableError(
|
|
138
|
+
`support for the ${(session as { protocol: unknown }).protocol} protocol`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function knownSize(parts: PartsBody): number | undefined {
|
|
144
|
+
return parts.body instanceof Blob ? parts.body.size : parts.size;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** `base`, or when `size` bytes would need more than `maxParts` parts of it, the whole number of MiB that fits. */
|
|
148
|
+
function fitParts(base: number, size: number | undefined, maxParts: number): number {
|
|
149
|
+
const needed = size === undefined ? 0 : Math.ceil(size / maxParts);
|
|
150
|
+
return needed <= base ? base : Math.ceil(needed / MiB) * MiB;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The size of each S3 part. With the length known, one size that fits it in 10,000 parts. Without, parts grow as the
|
|
155
|
+
* upload does, so a stream of unknown length can reach 968 GiB while short uploads keep small parts.
|
|
156
|
+
*/
|
|
157
|
+
function s3PartSizes(base: number, size: number | undefined): (partNumber: number) => number {
|
|
158
|
+
if (size !== undefined) {
|
|
159
|
+
if (size > S3_MAX_OBJECT_SIZE) {
|
|
160
|
+
throw new Error(`S3 takes objects up to 5 TiB; this upload is declared at ${size} bytes`);
|
|
161
|
+
}
|
|
162
|
+
const fixed = fitParts(base, size, S3_MAX_PARTS);
|
|
163
|
+
return () => fixed;
|
|
164
|
+
}
|
|
165
|
+
return (partNumber) => base * 2 ** Math.floor((partNumber - 1) / S3_PARTS_PER_SIZE);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Splits the content into parts, part `n` of `partSize(n)` bytes; the last may be shorter. */
|
|
169
|
+
async function* blobParts(
|
|
170
|
+
body: Blob | ReadableStream<Uint8Array>,
|
|
171
|
+
partSize: (partNumber: number) => number,
|
|
172
|
+
): AsyncGenerator<Blob> {
|
|
173
|
+
let partNumber = 1;
|
|
174
|
+
if (body instanceof Blob) {
|
|
175
|
+
for (let offset = 0; offset < body.size; partNumber++) {
|
|
176
|
+
const end = Math.min(offset + partSize(partNumber), body.size);
|
|
177
|
+
yield body.slice(offset, end);
|
|
178
|
+
offset = end;
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const reader = body.getReader();
|
|
183
|
+
let pending: Uint8Array[] = [];
|
|
184
|
+
let pendingBytes = 0;
|
|
185
|
+
let finished = false;
|
|
186
|
+
try {
|
|
187
|
+
for (;;) {
|
|
188
|
+
const { done, value } = await reader.read();
|
|
189
|
+
if (done) break;
|
|
190
|
+
let chunk = value;
|
|
191
|
+
while (pendingBytes + chunk.byteLength >= partSize(partNumber)) {
|
|
192
|
+
const take = partSize(partNumber) - pendingBytes;
|
|
193
|
+
pending.push(chunk.subarray(0, take));
|
|
194
|
+
yield new Blob(pending as BlobPart[]);
|
|
195
|
+
partNumber++;
|
|
196
|
+
pending = [];
|
|
197
|
+
pendingBytes = 0;
|
|
198
|
+
chunk = chunk.subarray(take);
|
|
199
|
+
}
|
|
200
|
+
if (chunk.byteLength > 0) {
|
|
201
|
+
pending.push(chunk);
|
|
202
|
+
pendingBytes += chunk.byteLength;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
finished = true;
|
|
206
|
+
if (pendingBytes > 0) yield new Blob(pending as BlobPart[]);
|
|
207
|
+
} finally {
|
|
208
|
+
if (!finished) await reader.cancel().catch(() => undefined);
|
|
209
|
+
reader.releaseLock();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function uploadS3Parts(
|
|
214
|
+
api: MultipartUploadApi,
|
|
215
|
+
session: S3MultipartUploadSession,
|
|
216
|
+
parts: PartsBody,
|
|
217
|
+
): Promise<string | undefined> {
|
|
218
|
+
const { id, upload_id } = session;
|
|
219
|
+
const uploaded: CompletedUploadPart[] = [];
|
|
220
|
+
let urls = new Map<number, string>();
|
|
221
|
+
let signedAt = 0;
|
|
222
|
+
let sent = 0;
|
|
223
|
+
|
|
224
|
+
async function partUrl(partNumber: number, renew: boolean): Promise<string> {
|
|
225
|
+
if (renew || !urls.has(partNumber) || Date.now() - signedAt > PART_URL_MAX_AGE_MS) {
|
|
226
|
+
const last = Math.min(partNumber + PART_URL_BATCH - 1, S3_MAX_PARTS);
|
|
227
|
+
const part_numbers = Array.from({ length: last - partNumber + 1 }, (_, i) => partNumber + i);
|
|
228
|
+
const signed = await api.getUploadPartUrls({ id, upload_id, part_numbers });
|
|
229
|
+
urls = new Map(signed.parts.map((p) => [p.part_number, p.url]));
|
|
230
|
+
signedAt = Date.now();
|
|
231
|
+
}
|
|
232
|
+
const url = urls.get(partNumber);
|
|
233
|
+
if (!url) throw new Error(`No upload URL was signed for part ${partNumber}`);
|
|
234
|
+
return url;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
for await (const part of blobParts(parts.body, s3PartSizes(session.part_size, knownSize(parts)))) {
|
|
239
|
+
const partNumber = uploaded.length + 1;
|
|
240
|
+
if (partNumber > S3_MAX_PARTS) {
|
|
241
|
+
throw new Error(`Upload needs more than ${S3_MAX_PARTS} parts`);
|
|
242
|
+
}
|
|
243
|
+
sent += part.size;
|
|
244
|
+
if (parts.size !== undefined && sent > parts.size) {
|
|
245
|
+
throw new ContentLengthMismatchError(parts.size, sent, 'long');
|
|
246
|
+
}
|
|
247
|
+
let res = await fetchSignedUrl(await partUrl(partNumber, false), { method: 'PUT', body: part });
|
|
248
|
+
if (res.status === 403) {
|
|
249
|
+
// An expired URL, or one whose signing credentials expired: sign it again, once.
|
|
250
|
+
await res.body?.cancel().catch(() => undefined);
|
|
251
|
+
res = await fetchSignedUrl(await partUrl(partNumber, true), { method: 'PUT', body: part });
|
|
252
|
+
}
|
|
253
|
+
const detail = res.ok ? '' : await res.text().catch(() => '');
|
|
254
|
+
if (res.ok) await res.body?.cancel().catch(() => undefined);
|
|
255
|
+
const etag = res.headers.get('etag');
|
|
256
|
+
if (!res.ok || !etag) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
`Failed to upload part ${partNumber}: ${res.status} ${res.statusText}${detail ? ` ${detail}` : ''}`,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
uploaded.push({ part_number: partNumber, etag });
|
|
262
|
+
}
|
|
263
|
+
if (parts.size !== undefined && sent < parts.size) {
|
|
264
|
+
throw new ContentLengthMismatchError(parts.size, sent, 'short');
|
|
265
|
+
}
|
|
266
|
+
const completed = await api.completeUploadSession({ id, upload_id, parts: uploaded });
|
|
267
|
+
return unquoteEtag(completed.etag);
|
|
268
|
+
} catch (err) {
|
|
269
|
+
await api.abortUploadSession({ id, upload_id }).catch(() => undefined);
|
|
270
|
+
throw err;
|
|
271
|
+
}
|
|
272
|
+
}
|
package/src/store/client.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AbstractFetchClient,
|
|
3
3
|
type FETCH_FN,
|
|
4
|
+
type IPacingRetryPolicy,
|
|
4
5
|
type IRequestRetryPolicy,
|
|
5
6
|
type RequestError,
|
|
7
|
+
type RequestIdentityProvider,
|
|
6
8
|
} from '@vertesia/api-fetch-client';
|
|
7
9
|
import { APP_VERSION_HEADER, type BulkOperationPayload, type BulkOperationResponse } from '@vertesia/common';
|
|
8
10
|
import { warnUnknownOptions } from '../unknown-options.js';
|
|
11
|
+
import { clientUserAgentHeaders } from '../user-agent.js';
|
|
9
12
|
import { AgentsApi } from './AgentsApi.js';
|
|
10
13
|
import { CollectionsApi } from './CollectionsApi.js';
|
|
11
14
|
import { ContentApi } from './ContentApi.js';
|
|
15
|
+
import { ContentSourcesApi } from './ContentSourcesApi.js';
|
|
12
16
|
import { CostApi } from './CostApi.js';
|
|
13
17
|
import { DataApi } from './DataApi.js';
|
|
14
18
|
import { EmailApi } from './EmailApi.js';
|
|
@@ -17,6 +21,7 @@ import { EventsApi } from './EventsApi.js';
|
|
|
17
21
|
import { ZenoClientNotFoundError } from './errors.js';
|
|
18
22
|
import { FilesApi } from './FilesApi.js';
|
|
19
23
|
import { IndexingApi } from './IndexingApi.js';
|
|
24
|
+
import { NotificationsApi } from './NotificationsApi.js';
|
|
20
25
|
import { ObjectsApi } from './ObjectsApi.js';
|
|
21
26
|
import { PendingAsksApi } from './PendingAsksApi.js';
|
|
22
27
|
import { ProcessApi } from './ProcessApi.js';
|
|
@@ -34,9 +39,13 @@ export interface ZenoClientProps {
|
|
|
34
39
|
serverUrl?: string;
|
|
35
40
|
tokenServerUrl?: string;
|
|
36
41
|
apikey?: string;
|
|
42
|
+
/** Supplies the complete Authorization header; takes precedence over apikey. */
|
|
43
|
+
authCallback?: () => Promise<string>;
|
|
44
|
+
requestIdentity?: RequestIdentityProvider;
|
|
37
45
|
onRequest?: (request: Request) => void;
|
|
38
46
|
onResponse?: (response: Response) => void;
|
|
39
47
|
retryPolicy?: IRequestRetryPolicy;
|
|
48
|
+
pacingRetry?: IPacingRetryPolicy | false;
|
|
40
49
|
timeout?: number | false | null;
|
|
41
50
|
fetch?: FETCH_FN | Promise<FETCH_FN>;
|
|
42
51
|
}
|
|
@@ -46,9 +55,12 @@ const KNOWN_STORE_OPTIONS: Record<keyof Required<ZenoClientProps>, true> = {
|
|
|
46
55
|
serverUrl: true,
|
|
47
56
|
tokenServerUrl: true,
|
|
48
57
|
apikey: true,
|
|
58
|
+
authCallback: true,
|
|
59
|
+
requestIdentity: true,
|
|
49
60
|
onRequest: true,
|
|
50
61
|
onResponse: true,
|
|
51
62
|
retryPolicy: true,
|
|
63
|
+
pacingRetry: true,
|
|
52
64
|
timeout: true,
|
|
53
65
|
fetch: true,
|
|
54
66
|
};
|
|
@@ -64,15 +76,22 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
64
76
|
constructor(opts: ZenoClientProps = {}) {
|
|
65
77
|
warnUnknownOptions('ZenoClient', opts, KNOWN_STORE_OPTIONS);
|
|
66
78
|
super(ensureDefined(opts.serverUrl), opts.fetch);
|
|
67
|
-
if (opts.
|
|
79
|
+
if (opts.authCallback) {
|
|
80
|
+
this.withAuthCallback(opts.authCallback);
|
|
81
|
+
} else if (opts.apikey) {
|
|
68
82
|
this.withApiKey(opts.apikey);
|
|
69
83
|
}
|
|
70
84
|
if (opts.retryPolicy) {
|
|
71
85
|
this.withRetryPolicy(opts.retryPolicy);
|
|
72
86
|
}
|
|
87
|
+
if (opts.pacingRetry !== undefined) {
|
|
88
|
+
this.withPacingRetry(opts.pacingRetry);
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
if (opts.timeout !== undefined) {
|
|
74
92
|
this.withTimeout(opts.timeout);
|
|
75
93
|
}
|
|
94
|
+
this.requestIdentity = opts.requestIdentity;
|
|
76
95
|
this.onRequest = opts.onRequest;
|
|
77
96
|
this.onResponse = opts.onResponse;
|
|
78
97
|
this.errorFactory = (err: RequestError) => {
|
|
@@ -116,6 +135,7 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
116
135
|
get initialHeaders() {
|
|
117
136
|
return {
|
|
118
137
|
...super.initialHeaders,
|
|
138
|
+
...clientUserAgentHeaders(),
|
|
119
139
|
[VERSION_HEADER]: VERSION,
|
|
120
140
|
};
|
|
121
141
|
}
|
|
@@ -127,6 +147,7 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
127
147
|
types = new TypesApi(this);
|
|
128
148
|
workflows = new WorkflowsApi(this);
|
|
129
149
|
schedules = new SchedulesApi(this);
|
|
150
|
+
contentSources = new ContentSourcesApi(this);
|
|
130
151
|
processes = new ProcessApi(this);
|
|
131
152
|
processTestRuns = new ProcessTestRunApi(this);
|
|
132
153
|
tasks = new TaskApi(this);
|
|
@@ -138,6 +159,7 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
138
159
|
/** @deprecated Use events.subscriptions. */
|
|
139
160
|
eventSubscriptions = this.events.subscriptions;
|
|
140
161
|
pendingAsks = new PendingAsksApi(this);
|
|
162
|
+
notifications = new NotificationsApi(this);
|
|
141
163
|
data = new DataApi(this);
|
|
142
164
|
indexing = new IndexingApi(this);
|
|
143
165
|
query = new QueryApi(this);
|
package/src/store/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './AgentsApi.js';
|
|
2
2
|
export * from './ContentApi.js';
|
|
3
|
+
export * from './ContentSourcesApi.js';
|
|
3
4
|
export * from './client.js';
|
|
5
|
+
export * from './DashboardApi.js';
|
|
4
6
|
export * from './DataApi.js';
|
|
5
7
|
export * from './EmailApi.js';
|
|
6
8
|
export * from './EmbeddingsApi.js';
|
|
@@ -10,6 +12,7 @@ export * from './EventsApi.js';
|
|
|
10
12
|
export * from './errors.js';
|
|
11
13
|
export * from './FilesApi.js';
|
|
12
14
|
export * from './IndexingApi.js';
|
|
15
|
+
export * from './NotificationsApi.js';
|
|
13
16
|
export * from './ObjectsApi.js';
|
|
14
17
|
export * from './PendingAsksApi.js';
|
|
15
18
|
export * from './ProcessApi.js';
|