@vinaverse/server 0.0.0-stage → 0.1.0-alpha.2

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 (65) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +165 -2
  3. package/dist/api.cjs +528 -0
  4. package/dist/api.cjs.map +1 -0
  5. package/dist/api.d.cts +453 -0
  6. package/dist/api.d.ts +453 -0
  7. package/dist/api.js +516 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/chunk-FEEJNQXV.js +64 -0
  10. package/dist/chunk-FEEJNQXV.js.map +1 -0
  11. package/dist/chunk-GTPMQKGX.js +277 -0
  12. package/dist/chunk-GTPMQKGX.js.map +1 -0
  13. package/dist/chunk-NPXO6SMZ.js +84 -0
  14. package/dist/chunk-NPXO6SMZ.js.map +1 -0
  15. package/dist/chunk-SDJFZPHJ.js +141 -0
  16. package/dist/chunk-SDJFZPHJ.js.map +1 -0
  17. package/dist/express.cjs +397 -0
  18. package/dist/express.cjs.map +1 -0
  19. package/dist/express.d.cts +43 -0
  20. package/dist/express.d.ts +43 -0
  21. package/dist/express.js +87 -0
  22. package/dist/express.js.map +1 -0
  23. package/dist/fastify.cjs +363 -0
  24. package/dist/fastify.cjs.map +1 -0
  25. package/dist/fastify.d.cts +62 -0
  26. package/dist/fastify.d.ts +62 -0
  27. package/dist/fastify.js +54 -0
  28. package/dist/fastify.js.map +1 -0
  29. package/dist/hono.cjs +421 -0
  30. package/dist/hono.cjs.map +1 -0
  31. package/dist/hono.d.cts +21 -0
  32. package/dist/hono.d.ts +21 -0
  33. package/dist/hono.js +34 -0
  34. package/dist/hono.js.map +1 -0
  35. package/dist/index.cjs +1481 -0
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.cts +196 -0
  38. package/dist/index.d.ts +196 -0
  39. package/dist/index.js +920 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/lambda.cjs +405 -0
  42. package/dist/lambda.cjs.map +1 -0
  43. package/dist/lambda.d.cts +53 -0
  44. package/dist/lambda.d.ts +53 -0
  45. package/dist/lambda.js +86 -0
  46. package/dist/lambda.js.map +1 -0
  47. package/dist/nonces-scwljZwl.d.cts +92 -0
  48. package/dist/nonces-scwljZwl.d.ts +92 -0
  49. package/dist/provider-BqfTvF3g.d.ts +2016 -0
  50. package/dist/provider-Miaa9V7I.d.cts +2016 -0
  51. package/dist/stores.cjs +315 -0
  52. package/dist/stores.cjs.map +1 -0
  53. package/dist/stores.d.cts +52 -0
  54. package/dist/stores.d.ts +52 -0
  55. package/dist/stores.js +306 -0
  56. package/dist/stores.js.map +1 -0
  57. package/dist/testing.cjs +135 -0
  58. package/dist/testing.cjs.map +1 -0
  59. package/dist/testing.d.cts +29 -0
  60. package/dist/testing.d.ts +29 -0
  61. package/dist/testing.js +49 -0
  62. package/dist/testing.js.map +1 -0
  63. package/dist/vinaverse-v1.d-BVc4uyUd.d.cts +3460 -0
  64. package/dist/vinaverse-v1.d-BVc4uyUd.d.ts +3460 -0
  65. package/package.json +225 -3
package/dist/api.d.ts ADDED
@@ -0,0 +1,453 @@
1
+ import { o as operations, p as paths, c as components } from './vinaverse-v1.d-BVc4uyUd.js';
2
+ import { Client } from 'openapi-fetch';
3
+
4
+ interface RetryOptions {
5
+ /** Retries after the first try: a whole number, 0 or more; default 2. */
6
+ readonly maxRetries?: number;
7
+ /** The longest wait, in seconds, before a retry: 0 to 2 147 483 (a timer's limit); default 30. */
8
+ readonly maxRetryDelay?: number;
9
+ /** One try's timeout, reading the body included, in milliseconds: more than 0, at most 2 147 483 647; default 30 000. */
10
+ readonly timeout?: number;
11
+ /** Waits, in milliseconds; tests replace it. The wait ends early when the call is aborted. */
12
+ readonly sleep?: (ms: number) => Promise<void>;
13
+ readonly random?: () => number;
14
+ }
15
+ /**
16
+ * The API did not answer within `timeout` on the last try. `idempotencyKey` is the key the call carried: pass it as
17
+ * `{ idempotencyKey }` to try the same call again later without doing it twice.
18
+ */
19
+ declare class VinaverseTimeoutError extends Error {
20
+ readonly name = "VinaverseTimeoutError";
21
+ readonly idempotencyKey: string | undefined;
22
+ constructor(ms: number, idempotencyKey?: string);
23
+ }
24
+ /** The call could not reach the API (`cause` holds why). `idempotencyKey` as for a timeout. */
25
+ declare class VinaverseNetworkError extends Error {
26
+ readonly name = "VinaverseNetworkError";
27
+ readonly idempotencyKey: string | undefined;
28
+ constructor(cause: unknown, idempotencyKey?: string);
29
+ }
30
+
31
+ type Op = operations;
32
+ /** An operation's JSON request body. */
33
+ type ApiBody<K extends keyof Op> = Op[K] extends {
34
+ requestBody?: {
35
+ content: {
36
+ 'application/json': infer B;
37
+ };
38
+ };
39
+ } ? B : never;
40
+ /** An operation's success result. */
41
+ type ApiResult<K extends keyof Op> = Success<Op[K]['responses']>;
42
+ type Success<R> = R extends {
43
+ 200: {
44
+ content: {
45
+ 'application/json': infer B;
46
+ };
47
+ };
48
+ } ? B : R extends {
49
+ 201: {
50
+ content: {
51
+ 'application/json': infer B;
52
+ };
53
+ };
54
+ } ? B : R extends {
55
+ 202: {
56
+ content: {
57
+ 'application/json': infer B;
58
+ };
59
+ };
60
+ } ? B : undefined;
61
+ type QueryOf<K extends keyof Op> = Op[K]['parameters'] extends {
62
+ query?: infer Q;
63
+ } ? NonNullable<Q> : never;
64
+ /** Per call: a signal that stops it at once, waits between tries included. */
65
+ interface CallOptions {
66
+ readonly signal?: AbortSignal;
67
+ }
68
+ /**
69
+ * For the calls the contract makes idempotent: a key of your own, 1 to 255 characters (one is made otherwise).
70
+ * After a `VinaverseTimeoutError` or a `VinaverseNetworkError`, try again later with the error's `idempotencyKey`,
71
+ * so the call is done once however many times it is sent.
72
+ */
73
+ interface KeyedCallOptions extends CallOptions {
74
+ readonly idempotencyKey?: string;
75
+ }
76
+ interface ApiClientOptions extends RetryOptions {
77
+ /** A service key, `vv_sk_<mock|dev|live>_…`: from your secrets store, never from code. */
78
+ readonly apiKey: string;
79
+ /**
80
+ * Default: `https://api.vinaverse.com` for a live key, `https://api-dev.vinaverse.com` for mock and dev keys. Any
81
+ * other URL must be `https:` (a proxy you run, say), or `http:` on this machine only (`localhost`, `127.0.0.1`,
82
+ * `[::1]`): a service key never travels in clear.
83
+ */
84
+ readonly baseUrl?: string;
85
+ readonly fetch?: (request: Request) => Promise<Response>;
86
+ /** Extra headers on every call, for example `Vinaverse-Mock-Scenario` in tests against the mock environment. */
87
+ readonly headers?: Readonly<Record<string, string>>;
88
+ }
89
+ /** The client was made where a service key must never be: a browser or an app. */
90
+ declare class ServiceKeyExposureError extends Error {
91
+ readonly name = "ServiceKeyExposureError";
92
+ }
93
+ declare function createApiClient(options: ApiClientOptions): {
94
+ /** Every operation of the contract, typed, for what the helpers below do not cover (openapi-fetch). */
95
+ api: Client<paths, `${string}/${string}`>;
96
+ sessions: {
97
+ /** Mint a session for the person in your app; give the app its `id`, URLs and `client_secret` only. */
98
+ create: (body: ApiBody<"createSession">, o?: KeyedCallOptions) => Promise<{
99
+ id: string;
100
+ status: "open";
101
+ agent: {
102
+ id: string;
103
+ version: string;
104
+ display_name: string;
105
+ };
106
+ client_secret: components["schemas"]["ClientSecret"];
107
+ realtime_url: string;
108
+ turns_url: string;
109
+ expires_at: string;
110
+ disclosure: string;
111
+ conversation_id?: components["schemas"]["ConversationId"];
112
+ }>;
113
+ get: (sessionId: string, o?: CallOptions) => Promise<{
114
+ id: string;
115
+ status: "open" | "closed" | "revoked" | "expired";
116
+ subject_id: components["schemas"]["SubjectId"];
117
+ agent_version?: string;
118
+ turns: number;
119
+ handoff_ticket_ids?: string[];
120
+ end_reason?: "expired" | "revoked" | "limit_reached" | "idle" | "server_restart" | "user_left";
121
+ created_at: string;
122
+ closed_at?: string;
123
+ usage?: components["schemas"]["Usage"];
124
+ }>;
125
+ revoke: (sessionId: string, o?: CallOptions) => Promise<{
126
+ id: string;
127
+ status: "open" | "closed" | "revoked" | "expired";
128
+ subject_id: components["schemas"]["SubjectId"];
129
+ agent_version?: string;
130
+ turns: number;
131
+ handoff_ticket_ids?: string[];
132
+ end_reason?: "expired" | "revoked" | "limit_reached" | "idle" | "server_restart" | "user_left";
133
+ created_at: string;
134
+ closed_at?: string;
135
+ usage?: components["schemas"]["Usage"];
136
+ }>;
137
+ /** A fresh client secret for an open session: what an app's `refreshSecret(sessionId)` asks your backend for. */
138
+ refreshClientSecret: (sessionId: string, o?: CallOptions) => Promise<{
139
+ value: string;
140
+ expires_at: string;
141
+ }>;
142
+ };
143
+ conversations: {
144
+ get: (conversationId: string, o?: CallOptions) => Promise<{
145
+ conversation_id: components["schemas"]["ConversationId"];
146
+ subject_id: components["schemas"]["SubjectId"];
147
+ agent: string;
148
+ flow: string | null;
149
+ version: number | null;
150
+ status: "in_progress" | "completed" | "failed" | "expired";
151
+ sequence: number;
152
+ progress: {
153
+ answered: number;
154
+ total_estimate: number | null;
155
+ };
156
+ pending_question_id: components["schemas"]["QuestionId"] | null;
157
+ answers?: components["schemas"]["ConversationAnswer"][];
158
+ remarks?: {
159
+ [key: string]: string;
160
+ };
161
+ answers_omitted?: boolean;
162
+ last_activity_at: string;
163
+ session_id: string;
164
+ }>;
165
+ };
166
+ suggestions: {
167
+ create: (body: ApiBody<"createSuggestions">, o?: CallOptions) => Promise<{
168
+ decision_id: string;
169
+ suggestions: components["schemas"]["Suggestion"][];
170
+ personalized: boolean;
171
+ usage: components["schemas"]["SuggestionsUsage"];
172
+ }>;
173
+ };
174
+ moderation: {
175
+ createJob: (body: ApiBody<"createModerationJob">, o?: KeyedCallOptions) => Promise<{
176
+ id: string;
177
+ status: "queued" | "processing" | "completed" | "partially_failed";
178
+ items: components["schemas"]["ModerationItem"][];
179
+ estimated_completion_seconds?: {
180
+ [key: string]: number;
181
+ };
182
+ }>;
183
+ getJob: (jobId: string, o?: CallOptions) => Promise<{
184
+ id: string;
185
+ status: "queued" | "processing" | "completed" | "partially_failed";
186
+ items: components["schemas"]["ModerationItem"][];
187
+ estimated_completion_seconds?: {
188
+ [key: string]: number;
189
+ };
190
+ }>;
191
+ getItem: (itemId: string, o?: CallOptions) => Promise<{
192
+ id: string;
193
+ ref: string;
194
+ surface: components["schemas"]["Surface"];
195
+ kind: "image" | "video" | "text";
196
+ status: "queued" | "processing" | "completed" | "failed";
197
+ decision?: components["schemas"]["Decision"];
198
+ quality?: components["schemas"]["Quality"];
199
+ video?: components["schemas"]["VideoFindings"];
200
+ error?: components["schemas"]["Problem"];
201
+ completed_at?: string;
202
+ processing_ms?: number;
203
+ usage?: components["schemas"]["Usage"];
204
+ }>;
205
+ };
206
+ media: {
207
+ createJob: (body: ApiBody<"createMediaJob">, o?: KeyedCallOptions) => Promise<{
208
+ id: string;
209
+ ref: string;
210
+ surface: components["schemas"]["Surface"];
211
+ kind: "image" | "video";
212
+ subject: {
213
+ id: components["schemas"]["SubjectId"];
214
+ type: components["schemas"]["SubjectType"];
215
+ };
216
+ status: "queued" | "processing" | "completed" | "failed" | "cancelled";
217
+ stage: "waiting" | "fetching" | "analyzing" | "transcoding" | "uploading" | "done";
218
+ progress_percent: number;
219
+ priority: "high" | "normal" | "low";
220
+ queue_position: number | null;
221
+ estimated_completion_at: string | null;
222
+ steps: {
223
+ moderate?: components["schemas"]["MediaJobStep"];
224
+ transcode?: components["schemas"]["MediaJobStep"];
225
+ poster?: components["schemas"]["MediaJobStep"];
226
+ captions?: components["schemas"]["MediaJobStep"];
227
+ };
228
+ outputs: components["schemas"]["MediaOutput"][] | null;
229
+ error?: components["schemas"]["Problem"];
230
+ attempts: number;
231
+ context: {
232
+ [key: string]: string;
233
+ };
234
+ created_at: string;
235
+ completed_at?: string;
236
+ } & {
237
+ delayed?: boolean;
238
+ deduplicated?: boolean;
239
+ }>;
240
+ listJobs: (query?: QueryOf<"listMediaJobs">, o?: CallOptions) => Promise<{
241
+ data: components["schemas"]["MediaJob"][];
242
+ next_cursor: string | null;
243
+ }>;
244
+ getJob: (jobId: string, o?: CallOptions) => Promise<{
245
+ id: string;
246
+ ref: string;
247
+ surface: components["schemas"]["Surface"];
248
+ kind: "image" | "video";
249
+ subject: {
250
+ id: components["schemas"]["SubjectId"];
251
+ type: components["schemas"]["SubjectType"];
252
+ };
253
+ status: "queued" | "processing" | "completed" | "failed" | "cancelled";
254
+ stage: "waiting" | "fetching" | "analyzing" | "transcoding" | "uploading" | "done";
255
+ progress_percent: number;
256
+ priority: "high" | "normal" | "low";
257
+ queue_position: number | null;
258
+ estimated_completion_at: string | null;
259
+ steps: {
260
+ moderate?: components["schemas"]["MediaJobStep"];
261
+ transcode?: components["schemas"]["MediaJobStep"];
262
+ poster?: components["schemas"]["MediaJobStep"];
263
+ captions?: components["schemas"]["MediaJobStep"];
264
+ };
265
+ outputs: components["schemas"]["MediaOutput"][] | null;
266
+ error?: components["schemas"]["Problem"];
267
+ attempts: number;
268
+ context: {
269
+ [key: string]: string;
270
+ };
271
+ created_at: string;
272
+ completed_at?: string;
273
+ }>;
274
+ cancelJob: (jobId: string, o?: CallOptions) => Promise<{
275
+ id: string;
276
+ ref: string;
277
+ surface: components["schemas"]["Surface"];
278
+ kind: "image" | "video";
279
+ subject: {
280
+ id: components["schemas"]["SubjectId"];
281
+ type: components["schemas"]["SubjectType"];
282
+ };
283
+ status: "queued" | "processing" | "completed" | "failed" | "cancelled";
284
+ stage: "waiting" | "fetching" | "analyzing" | "transcoding" | "uploading" | "done";
285
+ progress_percent: number;
286
+ priority: "high" | "normal" | "low";
287
+ queue_position: number | null;
288
+ estimated_completion_at: string | null;
289
+ steps: {
290
+ moderate?: components["schemas"]["MediaJobStep"];
291
+ transcode?: components["schemas"]["MediaJobStep"];
292
+ poster?: components["schemas"]["MediaJobStep"];
293
+ captions?: components["schemas"]["MediaJobStep"];
294
+ };
295
+ outputs: components["schemas"]["MediaOutput"][] | null;
296
+ error?: components["schemas"]["Problem"];
297
+ attempts: number;
298
+ context: {
299
+ [key: string]: string;
300
+ };
301
+ created_at: string;
302
+ completed_at?: string;
303
+ }>;
304
+ listProfiles: (o?: CallOptions) => Promise<{
305
+ data: components["schemas"]["MediaProfile"][];
306
+ }>;
307
+ };
308
+ screening: {
309
+ text: (body: ApiBody<"screenText">, o?: CallOptions) => Promise<{
310
+ decision: components["schemas"]["Decision"];
311
+ action: "allow" | "nudge" | "hold" | "block";
312
+ nudge?: {
313
+ audience: "author" | "recipient" | "both";
314
+ text: string;
315
+ };
316
+ }>;
317
+ };
318
+ documentChecks: {
319
+ create: (body: ApiBody<"createDocumentCheck">, o?: KeyedCallOptions) => Promise<{
320
+ id: string;
321
+ status: "queued";
322
+ estimated_completion_seconds?: number;
323
+ }>;
324
+ get: (checkId: string, o?: CallOptions) => Promise<{
325
+ id: string;
326
+ ref: string;
327
+ status: "queued" | "processing" | "completed" | "failed";
328
+ document_type_detected?: string | null;
329
+ fields?: {
330
+ full_name?: string | null;
331
+ document_number?: string | null;
332
+ issuer?: string | null;
333
+ region?: string | null;
334
+ license_class?: string | null;
335
+ issued_on?: string | null;
336
+ expires_on?: string | null;
337
+ date_of_birth_present?: boolean | null;
338
+ business_name?: string | null;
339
+ insured_name?: string | null;
340
+ policy_number?: string | null;
341
+ carrier?: string | null;
342
+ coverage_end?: string | null;
343
+ } | null;
344
+ field_sources?: {
345
+ [key: string]: "barcode" | "text_recognition" | "visual";
346
+ } | null;
347
+ flags?: components["schemas"]["DocumentFlag"][];
348
+ decision?: components["schemas"]["Decision"];
349
+ model?: {
350
+ id?: string;
351
+ provider?: string;
352
+ };
353
+ error?: components["schemas"]["Problem"];
354
+ completed_at?: string;
355
+ fields_expire_at?: string;
356
+ processing_ms?: number;
357
+ }>;
358
+ };
359
+ subjects: {
360
+ erase: (subjectId: string, o?: KeyedCallOptions) => Promise<{
361
+ subject_id: components["schemas"]["SubjectId"];
362
+ status: "accepted" | "completed";
363
+ sessions_revoked: number;
364
+ deadline: string;
365
+ }>;
366
+ };
367
+ feedback: {
368
+ send: (body: ApiBody<"sendFeedback">, o?: CallOptions) => Promise<{
369
+ accepted: number;
370
+ rejected: {
371
+ index: number;
372
+ code: string;
373
+ detail?: string;
374
+ }[];
375
+ }>;
376
+ };
377
+ events: {
378
+ send: (body: ApiBody<"sendEvents">, o?: CallOptions) => Promise<{
379
+ accepted: number;
380
+ duplicates: number;
381
+ batch_id: string;
382
+ batch_cid: string;
383
+ }>;
384
+ };
385
+ knowledge: {
386
+ sendDocument: (body: ApiBody<"sendKnowledgeDocument">, o?: CallOptions) => Promise<{
387
+ doc_id: string;
388
+ version: string;
389
+ audience: string;
390
+ artifact_cid: string;
391
+ chunks: number;
392
+ }>;
393
+ };
394
+ catalog: {
395
+ put: (type: Op["putCatalogEntity"]["parameters"]["path"]["type"], id: string, body: ApiBody<"putCatalogEntity">, o?: CallOptions) => Promise<{
396
+ type: string;
397
+ id: string;
398
+ changed: boolean;
399
+ snapshot_cid: string | null;
400
+ }>;
401
+ };
402
+ usage: {
403
+ get: (query?: QueryOf<"getUsage">, o?: CallOptions) => Promise<{
404
+ period: string;
405
+ features: {
406
+ feature: components["schemas"]["Feature"];
407
+ quantity: number;
408
+ cost: components["schemas"]["MicroMoney"];
409
+ cap: components["schemas"]["MicroMoney"] | null;
410
+ state: "enabled" | "disabled";
411
+ }[];
412
+ }>;
413
+ };
414
+ };
415
+ type ApiClient = ReturnType<typeof createApiClient>;
416
+
417
+ type ApiProblem = components['schemas']['Problem'];
418
+ type ApiProblemCode = ApiProblem['code'];
419
+ /** The API refused a call: its problem details, typed, with the request id to quote to support. */
420
+ declare class VinaverseApiError extends Error {
421
+ readonly name = "VinaverseApiError";
422
+ readonly status: number;
423
+ /** The problem's code (`invalid_request`, `rate_limited`, …), or `http_<status>` when the body was not a problem. */
424
+ readonly code: ApiProblemCode | `http_${number}`;
425
+ /** Whether the same call may succeed later: the problem's `retryable`, else true for 429 and 5xx. */
426
+ readonly retryable: boolean;
427
+ /** `Vinaverse-Request-Id`, or the problem's `request_id`. */
428
+ readonly requestId: string | undefined;
429
+ /** `Retry-After`, in seconds, when the API sent one. */
430
+ readonly retryAfter: number | undefined;
431
+ /** For `invalid_request`: the fields refused, as JSON Pointers into the request. */
432
+ readonly errors: readonly {
433
+ pointer: string;
434
+ message: string;
435
+ }[];
436
+ /** The problem as sent, or undefined when the body was not one. */
437
+ readonly problem: ApiProblem | undefined;
438
+ /** The `Idempotency-Key` the call carried: send the same call again with it to have it done once. */
439
+ readonly idempotencyKey: string | undefined;
440
+ constructor(init: {
441
+ status: number;
442
+ problem?: ApiProblem | undefined;
443
+ requestId?: string | undefined;
444
+ retryAfter?: number | undefined;
445
+ idempotencyKey?: string | undefined;
446
+ });
447
+ }
448
+ /** The error for a refused response and its parsed body: what every call of the API client throws. */
449
+ declare function apiError(response: Response, body: unknown, idempotencyKey?: string): VinaverseApiError;
450
+ /** `Retry-After` in seconds: a number of seconds or an HTTP date; undefined when absent or unreadable. */
451
+ declare function retryAfterSeconds(response: Response, now?: () => number): number | undefined;
452
+
453
+ export { type ApiBody, type ApiClient, type ApiClientOptions, type ApiProblem, type ApiProblemCode, type ApiResult, type CallOptions, type KeyedCallOptions, type RetryOptions, ServiceKeyExposureError, VinaverseApiError, VinaverseNetworkError, VinaverseTimeoutError, apiError, createApiClient, retryAfterSeconds };