@vertesia/client 1.0.0 → 1.1.0-dev.20260427.060440Z

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.
Files changed (149) hide show
  1. package/lib/cjs/AnalyticsApi.js +3 -1
  2. package/lib/cjs/AnalyticsApi.js.map +1 -1
  3. package/lib/cjs/AppsApi.js +18 -2
  4. package/lib/cjs/AppsApi.js.map +1 -1
  5. package/lib/cjs/AuditTrailApi.js +6 -2
  6. package/lib/cjs/AuditTrailApi.js.map +1 -1
  7. package/lib/cjs/GroupsApi.js +8 -0
  8. package/lib/cjs/GroupsApi.js.map +1 -1
  9. package/lib/cjs/InteractionsApi.js.map +1 -1
  10. package/lib/cjs/OAuthClientsApi.js +25 -0
  11. package/lib/cjs/OAuthClientsApi.js.map +1 -0
  12. package/lib/cjs/OAuthGrantsApi.js +30 -0
  13. package/lib/cjs/OAuthGrantsApi.js.map +1 -0
  14. package/lib/cjs/OAuthProvidersApi.js +43 -0
  15. package/lib/cjs/OAuthProvidersApi.js.map +1 -0
  16. package/lib/cjs/OAuthServerApi.js +22 -0
  17. package/lib/cjs/OAuthServerApi.js.map +1 -0
  18. package/lib/cjs/RemoteMcpConnectionsApi.js +38 -0
  19. package/lib/cjs/RemoteMcpConnectionsApi.js.map +1 -0
  20. package/lib/cjs/RunsApi.js +4 -12
  21. package/lib/cjs/RunsApi.js.map +1 -1
  22. package/lib/cjs/client.js +48 -45
  23. package/lib/cjs/client.js.map +1 -1
  24. package/lib/cjs/index.js +14 -0
  25. package/lib/cjs/index.js.map +1 -1
  26. package/lib/cjs/store/AgentsApi.js +30 -6
  27. package/lib/cjs/store/AgentsApi.js.map +1 -1
  28. package/lib/cjs/store/CostApi.js +56 -0
  29. package/lib/cjs/store/CostApi.js.map +1 -0
  30. package/lib/cjs/store/IndexingApi.js +94 -30
  31. package/lib/cjs/store/IndexingApi.js.map +1 -1
  32. package/lib/cjs/store/ObjectsApi.js +3 -2
  33. package/lib/cjs/store/ObjectsApi.js.map +1 -1
  34. package/lib/cjs/store/WorkflowsApi.js +258 -236
  35. package/lib/cjs/store/WorkflowsApi.js.map +1 -1
  36. package/lib/cjs/store/client.js +2 -0
  37. package/lib/cjs/store/client.js.map +1 -1
  38. package/lib/esm/AnalyticsApi.js +3 -1
  39. package/lib/esm/AnalyticsApi.js.map +1 -1
  40. package/lib/esm/AppsApi.js +18 -2
  41. package/lib/esm/AppsApi.js.map +1 -1
  42. package/lib/esm/AuditTrailApi.js +6 -2
  43. package/lib/esm/AuditTrailApi.js.map +1 -1
  44. package/lib/esm/GroupsApi.js +8 -0
  45. package/lib/esm/GroupsApi.js.map +1 -1
  46. package/lib/esm/InteractionsApi.js.map +1 -1
  47. package/lib/esm/OAuthClientsApi.js +22 -0
  48. package/lib/esm/OAuthClientsApi.js.map +1 -0
  49. package/lib/esm/OAuthGrantsApi.js +27 -0
  50. package/lib/esm/OAuthGrantsApi.js.map +1 -0
  51. package/lib/esm/OAuthProvidersApi.js +40 -0
  52. package/lib/esm/OAuthProvidersApi.js.map +1 -0
  53. package/lib/esm/OAuthServerApi.js +19 -0
  54. package/lib/esm/OAuthServerApi.js.map +1 -0
  55. package/lib/esm/RemoteMcpConnectionsApi.js +35 -0
  56. package/lib/esm/RemoteMcpConnectionsApi.js.map +1 -0
  57. package/lib/esm/RunsApi.js +4 -12
  58. package/lib/esm/RunsApi.js.map +1 -1
  59. package/lib/esm/client.js +48 -45
  60. package/lib/esm/client.js.map +1 -1
  61. package/lib/esm/index.js +5 -0
  62. package/lib/esm/index.js.map +1 -1
  63. package/lib/esm/store/AgentsApi.js +30 -6
  64. package/lib/esm/store/AgentsApi.js.map +1 -1
  65. package/lib/esm/store/CostApi.js +52 -0
  66. package/lib/esm/store/CostApi.js.map +1 -0
  67. package/lib/esm/store/IndexingApi.js +94 -30
  68. package/lib/esm/store/IndexingApi.js.map +1 -1
  69. package/lib/esm/store/ObjectsApi.js +3 -2
  70. package/lib/esm/store/ObjectsApi.js.map +1 -1
  71. package/lib/esm/store/WorkflowsApi.js +258 -236
  72. package/lib/esm/store/WorkflowsApi.js.map +1 -1
  73. package/lib/esm/store/client.js +2 -0
  74. package/lib/esm/store/client.js.map +1 -1
  75. package/lib/tsconfig.tsbuildinfo +1 -1
  76. package/lib/types/AnalyticsApi.d.ts +1 -1
  77. package/lib/types/AnalyticsApi.d.ts.map +1 -1
  78. package/lib/types/AppsApi.d.ts +20 -2
  79. package/lib/types/AppsApi.d.ts.map +1 -1
  80. package/lib/types/AuditTrailApi.d.ts.map +1 -1
  81. package/lib/types/GroupsApi.d.ts +6 -0
  82. package/lib/types/GroupsApi.d.ts.map +1 -1
  83. package/lib/types/InteractionsApi.d.ts +2 -0
  84. package/lib/types/InteractionsApi.d.ts.map +1 -1
  85. package/lib/types/OAuthClientsApi.d.ts +12 -0
  86. package/lib/types/OAuthClientsApi.d.ts.map +1 -0
  87. package/lib/types/OAuthGrantsApi.d.ts +11 -0
  88. package/lib/types/OAuthGrantsApi.d.ts.map +1 -0
  89. package/lib/types/OAuthProvidersApi.d.ts +22 -0
  90. package/lib/types/OAuthProvidersApi.d.ts.map +1 -0
  91. package/lib/types/OAuthServerApi.d.ts +10 -0
  92. package/lib/types/OAuthServerApi.d.ts.map +1 -0
  93. package/lib/types/RemoteMcpConnectionsApi.d.ts +13 -0
  94. package/lib/types/RemoteMcpConnectionsApi.d.ts.map +1 -0
  95. package/lib/types/RunsApi.d.ts +4 -16
  96. package/lib/types/RunsApi.d.ts.map +1 -1
  97. package/lib/types/client.d.ts +15 -9
  98. package/lib/types/client.d.ts.map +1 -1
  99. package/lib/types/index.d.ts +5 -0
  100. package/lib/types/index.d.ts.map +1 -1
  101. package/lib/types/store/AgentsApi.d.ts +27 -47
  102. package/lib/types/store/AgentsApi.d.ts.map +1 -1
  103. package/lib/types/store/CostApi.d.ts +35 -0
  104. package/lib/types/store/CostApi.d.ts.map +1 -0
  105. package/lib/types/store/IndexingApi.d.ts +48 -23
  106. package/lib/types/store/IndexingApi.d.ts.map +1 -1
  107. package/lib/types/store/ObjectsApi.d.ts +7 -2
  108. package/lib/types/store/ObjectsApi.d.ts.map +1 -1
  109. package/lib/types/store/WorkflowsApi.d.ts +84 -34
  110. package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
  111. package/lib/types/store/client.d.ts +2 -0
  112. package/lib/types/store/client.d.ts.map +1 -1
  113. package/lib/vertesia-client.js +1 -1
  114. package/lib/vertesia-client.js.map +1 -1
  115. package/package.json +8 -8
  116. package/src/AnalyticsApi.ts +2 -1
  117. package/src/AppsApi.ts +26 -3
  118. package/src/AuditTrailApi.ts +3 -1
  119. package/src/GroupsApi.ts +9 -0
  120. package/src/InteractionsApi.ts +6 -1
  121. package/src/OAuthClientsApi.ts +33 -0
  122. package/src/OAuthGrantsApi.ts +42 -0
  123. package/src/OAuthProvidersApi.ts +59 -0
  124. package/src/OAuthServerApi.ts +30 -0
  125. package/src/RemoteMcpConnectionsApi.ts +53 -0
  126. package/src/RunsApi.ts +6 -13
  127. package/src/client.test.ts +9 -11
  128. package/src/client.ts +83 -55
  129. package/src/index.ts +5 -0
  130. package/src/store/AgentsApi.ts +62 -43
  131. package/src/store/CostApi.ts +67 -0
  132. package/src/store/IndexingApi.ts +124 -35
  133. package/src/store/ObjectsApi.ts +7 -3
  134. package/src/store/WorkflowsApi.ts +327 -252
  135. package/src/store/client.ts +2 -0
  136. package/lib/cjs/MCPOAuthApi.js +0 -69
  137. package/lib/cjs/MCPOAuthApi.js.map +0 -1
  138. package/lib/cjs/OAuthAppsApi.js +0 -72
  139. package/lib/cjs/OAuthAppsApi.js.map +0 -1
  140. package/lib/esm/MCPOAuthApi.js +0 -66
  141. package/lib/esm/MCPOAuthApi.js.map +0 -1
  142. package/lib/esm/OAuthAppsApi.js +0 -69
  143. package/lib/esm/OAuthAppsApi.js.map +0 -1
  144. package/lib/types/MCPOAuthApi.d.ts +0 -50
  145. package/lib/types/MCPOAuthApi.d.ts.map +0 -1
  146. package/lib/types/OAuthAppsApi.d.ts +0 -51
  147. package/lib/types/OAuthAppsApi.d.ts.map +0 -1
  148. package/src/MCPOAuthApi.ts +0 -74
  149. package/src/OAuthAppsApi.ts +0 -87
@@ -1,4 +1,4 @@
1
- import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
1
+ import { ApiTopic, ClientBase, ServerSentEvent } from "@vertesia/api-fetch-client";
2
2
  import {
3
3
  IndexingStatusResponse,
4
4
  GenericCommandResponse,
@@ -7,7 +7,6 @@ import {
7
7
  CreateReindexTargetResult,
8
8
  ReindexRangeResult,
9
9
  FetchBatchResult,
10
- IndexBatchResult,
11
10
  NextIndexCursorResult,
12
11
  TriggerReindexResult,
13
12
  ElasticsearchIndexStats,
@@ -15,9 +14,17 @@ import {
15
14
  FetchDocumentsByIdsResult,
16
15
  BulkDeleteResult,
17
16
  EnsureIndexResult,
18
- SwapAliasResult,
19
17
  AnalyzeDriftBatchResult,
20
18
  DriftAnalysisStatusResponse,
19
+ ComputeShardsRequest,
20
+ ComputeShardsResult,
21
+ IndexShardParams,
22
+ IndexShardRequest,
23
+ IndexShardResult,
24
+ SwapAliasRequest,
25
+ SwapAliasResult,
26
+ ReindexViaBulkRequest,
27
+ ReindexViaBulkResult,
21
28
  } from "@vertesia/common";
22
29
 
23
30
  /**
@@ -45,11 +52,19 @@ export class IndexingApi extends ApiTopic {
45
52
  }
46
53
 
47
54
  /**
48
- * Trigger a full reindex of all documents
49
- * @param recreateIndex If true, drops and recreates the index before reindexing
55
+ * Trigger a full reindex of all documents.
56
+ * Starts a Temporal workflow that uses zeno-bulk for high-throughput indexing.
57
+ *
58
+ * @param options Optional workflow tuning parameters
50
59
  */
51
- async reindex(recreateIndex?: boolean): Promise<GenericCommandResponse> {
52
- return this.post("/reindex", { payload: { recreate_index: recreateIndex } });
60
+ async reindex(options?: {
61
+ shard_size?: number;
62
+ parallel_shard_count?: number;
63
+ concurrency?: number;
64
+ bulk_size_bytes?: number;
65
+ bulk_concurrency?: number;
66
+ }): Promise<GenericCommandResponse> {
67
+ return this.post("/reindex", { payload: options });
53
68
  }
54
69
 
55
70
  /**
@@ -154,18 +169,6 @@ export class IndexingApi extends ApiTopic {
154
169
  });
155
170
  }
156
171
 
157
- /**
158
- * Atomically swap the alias from old index to new index
159
- *
160
- * @param newIndexName The new index to point the alias to
161
- * @param deleteOld If true, deletes the old index after swapping
162
- */
163
- swapAlias(newIndexName: string, deleteOld?: boolean): Promise<SwapAliasResult> {
164
- return this.post("/internal/swap-alias", {
165
- payload: { new_index_name: newIndexName, delete_old: deleteOld },
166
- });
167
- }
168
-
169
172
  /**
170
173
  * Get Elasticsearch index statistics for the project
171
174
  */
@@ -198,22 +201,6 @@ export class IndexingApi extends ApiTopic {
198
201
  });
199
202
  }
200
203
 
201
- /**
202
- * Fetch and index a batch of documents (server-side)
203
- * Uses cursor-based pagination for reliability
204
- *
205
- * @param cursor Cursor from previous batch (null for first batch)
206
- * @param limit Maximum documents to process (default: 500)
207
- * @param targetIndex Optional explicit index name for zero-downtime reindexing
208
- * @param since Only index docs with updated_at >= this ISO timestamp (for catch-up after reindex)
209
- * @param endCursor End cursor (inclusive) for partitioned reindexing
210
- */
211
- indexBatch(cursor?: string | null, limit?: number, targetIndex?: string, since?: string, endCursor?: string | null): Promise<IndexBatchResult> {
212
- return this.post("/internal/index-batch", {
213
- payload: { cursor, limit, target_index: targetIndex, since, end_cursor: endCursor },
214
- });
215
- }
216
-
217
204
  /**
218
205
  * Discover one or more cursor boundaries for partitioned reindexing
219
206
  *
@@ -291,4 +278,106 @@ export class IndexingApi extends ApiTopic {
291
278
  payload: {},
292
279
  });
293
280
  }
281
+
282
+ // ========================================================================
283
+ // Zeno Bulk endpoints (Go migration service)
284
+ // Routes via LB path rules in prod, or derived URL in dev.
285
+ // ========================================================================
286
+
287
+ /**
288
+ * Get the zeno-bulk base URL.
289
+ * Dev branches: store URL contains "zeno-server" -> replace with "zeno-bulk".
290
+ * Production/preview: same domain, LB routes /reindex/* to zeno-bulk.
291
+ */
292
+ private get zenoBulkBaseUrl(): string {
293
+ const storeBaseUrl = this.client.baseUrl;
294
+ if (storeBaseUrl.includes('zeno-server')) {
295
+ return storeBaseUrl.replace(/zeno-server/, 'zeno-bulk');
296
+ }
297
+ return storeBaseUrl;
298
+ }
299
+
300
+ /**
301
+ * POST to a zeno-bulk endpoint. Resolves the path against the zeno-bulk base URL.
302
+ */
303
+ private zenoBulkPost<T>(path: string, body: object): Promise<T> {
304
+ return this.client.post(this.zenoBulkBaseUrl + path, { payload: body });
305
+ }
306
+
307
+ /**
308
+ * Compute shard boundaries for a tenant via zeno-bulk.
309
+ * Creates the target index and returns shard ranges for parallel indexing.
310
+ */
311
+ computeShards(tenantId: string, shardSize?: number): Promise<ComputeShardsResult> {
312
+ return this.zenoBulkPost('/reindex/compute-shards', {
313
+ tenant_id: tenantId,
314
+ shard_size: shardSize ?? 50000,
315
+ } satisfies ComputeShardsRequest);
316
+ }
317
+
318
+ /**
319
+ * Index a single shard via zeno-bulk (retryable by Temporal).
320
+ * The Go service reads from MongoDB and writes to ES directly.
321
+ */
322
+ indexShard(params: IndexShardParams): Promise<IndexShardResult> {
323
+ return this.zenoBulkPost('/reindex/shard', { params } satisfies IndexShardRequest);
324
+ }
325
+
326
+ /**
327
+ * Atomically swap ES alias via zeno-bulk.
328
+ * @param alias Optional alias name. If not provided, the Go service derives it from the tenant ID.
329
+ */
330
+ swapAlias(tenantId: string, targetIndex: string, alias?: string): Promise<SwapAliasResult> {
331
+ return this.zenoBulkPost('/reindex/swap-alias', {
332
+ tenant_id: tenantId,
333
+ target_index: targetIndex,
334
+ alias,
335
+ } satisfies SwapAliasRequest);
336
+ }
337
+
338
+ /**
339
+ * Full reindex of a tenant via zeno-bulk (all-in-one).
340
+ * The Go service handles sharding, indexing, catch-up, and alias swap internally.
341
+ *
342
+ * In JSON mode (default): waits for completion and returns the final result.
343
+ * In SSE mode (when onEvent is provided): streams progress events from zeno-bulk
344
+ * and returns the final result. The onEvent callback receives parsed SSE events
345
+ * with { event: "progress" | "done", data: string (JSON) }.
346
+ */
347
+ async reindexViaBulk(
348
+ tenantId: string,
349
+ onEvent?: ((event: ServerSentEvent) => void) | null,
350
+ dryRun?: boolean,
351
+ ): Promise<ReindexViaBulkResult> {
352
+ const bulkUrl = this.zenoBulkBaseUrl + '/reindex';
353
+ const payload = {
354
+ tenant_id: tenantId,
355
+ dry_run: dryRun ?? false,
356
+ } satisfies ReindexViaBulkRequest;
357
+
358
+ if (!onEvent) {
359
+ return this.client.post(bulkUrl, { payload });
360
+ }
361
+
362
+ // SSE mode: stream progress events from zeno-bulk
363
+ let lastResult: ReindexViaBulkResult | undefined;
364
+
365
+ await this.client.sseRequest('POST', bulkUrl, {
366
+ payload,
367
+ }, (event) => {
368
+ onEvent(event);
369
+ if (event.type === 'event' && event.event === 'done') {
370
+ try {
371
+ lastResult = JSON.parse(event.data) as ReindexViaBulkResult;
372
+ } catch {
373
+ // data might not be valid JSON
374
+ }
375
+ }
376
+ });
377
+
378
+ if (!lastResult) {
379
+ throw new Error('zeno-bulk SSE stream ended without a done event');
380
+ }
381
+ return lastResult;
382
+ }
294
383
  }
@@ -20,17 +20,17 @@ import {
20
20
  GetFileUrlResponse,
21
21
  GetRenditionParams,
22
22
  GetRenditionResponse,
23
- getSupportedRenditionFormats,
23
+
24
24
  GetUploadUrlPayload,
25
25
  ListWorkflowRunsResponse,
26
26
  ObjectSearchPayload,
27
27
  ObjectSearchQuery,
28
28
  SupportedEmbeddingTypes,
29
- supportsVisualRendition
30
29
  } from "@vertesia/common";
31
30
 
32
31
  // Re-export rendition utilities for consumers
33
- export { canGenerateRendition, getSupportedRenditionFormats, supportsVisualRendition };
32
+ export { canGenerateRendition };
33
+ export { getSupportedRenditionFormats, supportsVisualRendition } from "@vertesia/common";
34
34
 
35
35
  import { StreamSource } from "../StreamSource.js";
36
36
  import { AnalyzeDocApi } from "./AnalyzeDocApi.js";
@@ -40,6 +40,10 @@ export interface ComputeFacetsResponse {
40
40
  type?: { _id: string; count: number }[];
41
41
  location?: { _id: string; count: number }[];
42
42
  status?: { _id: string; count: number }[];
43
+ [key: string]:
44
+ | { _id: string; count: number }[]
45
+ | number
46
+ | undefined;
43
47
  total?: number;
44
48
  }
45
49