@voyantjs/types 0.31.1 → 0.31.3

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.
@@ -1,156 +1,242 @@
1
1
  import { z } from "zod";
2
- /**
3
- * API Key Scope Definitions
4
- *
5
- * Following resource:action pattern similar to Stripe/Shopify
6
- * Format: "{resource}:{action}" or wildcards
7
- */
8
- export declare const API_KEY_RESOURCES: readonly ["operators", "connections", "oauth-clients", "products", "availability", "bookings", "suppliers", "grants", "audit-logs"];
9
- export type ApiKeyResource = (typeof API_KEY_RESOURCES)[number];
10
- export declare const API_KEY_ACTIONS: readonly ["read", "write", "delete"];
2
+ export declare const API_KEY_ACTIONS: readonly ["read", "write", "delete", "trigger", "relay", "search"];
11
3
  export type ApiKeyAction = (typeof API_KEY_ACTIONS)[number];
12
- /**
13
- * Valid scope patterns:
14
- * - Specific: "operators:read", "connections:write"
15
- * - Resource wildcard: "operators:*" (all actions on operators)
16
- * - Action wildcard: "*:read" (read all resources)
17
- * - Full wildcard: "*" (all resources, all actions)
18
- */
19
- export declare const VALID_SCOPES: readonly ["operators:read", "operators:write", "operators:delete", "operators:*", "connections:read", "connections:write", "connections:delete", "connections:*", "oauth-clients:read", "oauth-clients:write", "oauth-clients:delete", "oauth-clients:*", "products:read", "products:*", "availability:read", "availability:*", "bookings:read", "bookings:write", "bookings:delete", "bookings:*", "suppliers:read", "suppliers:*", "grants:read", "grants:write", "grants:delete", "grants:*", "audit-logs:read", "audit-logs:*", "*:read", "*:write", "*:delete", "*"];
20
- export type ApiKeyScope = (typeof VALID_SCOPES)[number];
21
- export declare const apiKeyScopeSchema: z.ZodEnum<{
22
- "operators:read": "operators:read";
23
- "operators:write": "operators:write";
24
- "operators:delete": "operators:delete";
25
- "operators:*": "operators:*";
26
- "connections:read": "connections:read";
27
- "connections:write": "connections:write";
28
- "connections:delete": "connections:delete";
29
- "connections:*": "connections:*";
30
- "oauth-clients:read": "oauth-clients:read";
31
- "oauth-clients:write": "oauth-clients:write";
32
- "oauth-clients:delete": "oauth-clients:delete";
33
- "oauth-clients:*": "oauth-clients:*";
34
- "products:read": "products:read";
35
- "products:*": "products:*";
36
- "availability:read": "availability:read";
37
- "availability:*": "availability:*";
38
- "bookings:read": "bookings:read";
39
- "bookings:write": "bookings:write";
40
- "bookings:delete": "bookings:delete";
41
- "bookings:*": "bookings:*";
42
- "suppliers:read": "suppliers:read";
43
- "suppliers:*": "suppliers:*";
44
- "grants:read": "grants:read";
45
- "grants:write": "grants:write";
46
- "grants:delete": "grants:delete";
47
- "grants:*": "grants:*";
48
- "audit-logs:read": "audit-logs:read";
49
- "audit-logs:*": "audit-logs:*";
50
- "*:read": "*:read";
51
- "*:write": "*:write";
52
- "*:delete": "*:delete";
53
- "*": "*";
54
- }>;
55
- export declare const apiKeyScopesSchema: z.ZodDefault<z.ZodArray<z.ZodEnum<{
56
- "operators:read": "operators:read";
57
- "operators:write": "operators:write";
58
- "operators:delete": "operators:delete";
59
- "operators:*": "operators:*";
60
- "connections:read": "connections:read";
61
- "connections:write": "connections:write";
62
- "connections:delete": "connections:delete";
63
- "connections:*": "connections:*";
64
- "oauth-clients:read": "oauth-clients:read";
65
- "oauth-clients:write": "oauth-clients:write";
66
- "oauth-clients:delete": "oauth-clients:delete";
67
- "oauth-clients:*": "oauth-clients:*";
68
- "products:read": "products:read";
69
- "products:*": "products:*";
70
- "availability:read": "availability:read";
71
- "availability:*": "availability:*";
72
- "bookings:read": "bookings:read";
73
- "bookings:write": "bookings:write";
74
- "bookings:delete": "bookings:delete";
75
- "bookings:*": "bookings:*";
76
- "suppliers:read": "suppliers:read";
77
- "suppliers:*": "suppliers:*";
78
- "grants:read": "grants:read";
79
- "grants:write": "grants:write";
80
- "grants:delete": "grants:delete";
81
- "grants:*": "grants:*";
82
- "audit-logs:read": "audit-logs:read";
83
- "audit-logs:*": "audit-logs:*";
84
- "*:read": "*:read";
85
- "*:write": "*:write";
86
- "*:delete": "*:delete";
87
- "*": "*";
88
- }>>>;
89
- /**
90
- * Scope groups for UI display
91
- * Grouped by resource for nested checkbox UX
92
- */
93
- export declare const SCOPE_GROUPS: {
94
- readonly operators: {
95
- readonly label: "Operators";
96
- readonly description: "Manage operator registrations and configuration";
97
- readonly scopes: readonly ["operators:read", "operators:write", "operators:delete"];
98
- };
99
- readonly connections: {
100
- readonly label: "Connections";
101
- readonly description: "Manage supplier connections and credentials";
102
- readonly scopes: readonly ["connections:read", "connections:write", "connections:delete"];
103
- };
104
- readonly "oauth-clients": {
105
- readonly label: "OAuth Clients";
106
- readonly description: "Manage OAuth client credentials for M2M access";
107
- readonly scopes: readonly ["oauth-clients:read", "oauth-clients:write", "oauth-clients:delete"];
108
- };
109
- readonly products: {
110
- readonly label: "Products";
111
- readonly description: "Query supplier product catalogs via OCTO";
112
- readonly scopes: readonly ["products:read"];
113
- };
114
- readonly availability: {
115
- readonly label: "Availability";
116
- readonly description: "Query supplier availability via OCTO";
117
- readonly scopes: readonly ["availability:read"];
4
+ export declare const API_KEY_RESOURCES: readonly ["availability", "bookings", "catalog", "crm", "cruises", "departures", "finance", "ground", "hospitality", "itineraries", "legal", "notifications", "pricing", "products", "resources", "storefront", "suppliers", "transactions", "webhooks", "workflows"];
5
+ export type ApiKeyResource = (typeof API_KEY_RESOURCES)[number];
6
+ export type ApiKeyPermissions = Record<string, string[]>;
7
+ export type ApiKeyPermissionString = "*" | "*:*" | `${string}:*` | `*:${string}` | `${string}:${string}`;
8
+ export interface ApiKeyPermissionDescriptor {
9
+ resource: string;
10
+ action: string;
11
+ label: string;
12
+ description: string;
13
+ }
14
+ export interface ApiKeyPermissionGroup {
15
+ resource: string;
16
+ label: string;
17
+ description: string;
18
+ permissions: ApiKeyPermissionDescriptor[];
19
+ }
20
+ export declare const API_KEY_PERMISSION_GROUPS: readonly [{
21
+ readonly resource: "catalog";
22
+ readonly label: "Catalog";
23
+ readonly description: "Search and read unified catalog content.";
24
+ readonly permissions: [{
25
+ resource: string;
26
+ action: string;
27
+ label: string;
28
+ description: string;
29
+ }, {
30
+ resource: string;
31
+ action: string;
32
+ label: string;
33
+ description: string;
34
+ }];
35
+ }, {
36
+ readonly resource: "products";
37
+ readonly label: "Products";
38
+ readonly description: "Read and manage products, options, content, and media.";
39
+ readonly permissions: [{
40
+ resource: string;
41
+ action: string;
42
+ label: string;
43
+ description: string;
44
+ }, {
45
+ resource: string;
46
+ action: string;
47
+ label: string;
48
+ description: string;
49
+ }, {
50
+ resource: string;
51
+ action: string;
52
+ label: string;
53
+ description: string;
54
+ }];
55
+ }, {
56
+ readonly resource: "departures";
57
+ readonly label: "Departures";
58
+ readonly description: "Read and manage scheduled departures.";
59
+ readonly permissions: [{
60
+ resource: string;
61
+ action: string;
62
+ label: string;
63
+ description: string;
64
+ }, {
65
+ resource: string;
66
+ action: string;
67
+ label: string;
68
+ description: string;
69
+ }];
70
+ }, {
71
+ readonly resource: "itineraries";
72
+ readonly label: "Itineraries";
73
+ readonly description: "Read and manage day-by-day itinerary content.";
74
+ readonly permissions: [{
75
+ resource: string;
76
+ action: string;
77
+ label: string;
78
+ description: string;
79
+ }, {
80
+ resource: string;
81
+ action: string;
82
+ label: string;
83
+ description: string;
84
+ }];
85
+ }, {
86
+ readonly resource: "bookings";
87
+ readonly label: "Bookings";
88
+ readonly description: "Read and manage booking records and booking workflows.";
89
+ readonly permissions: [{
90
+ resource: string;
91
+ action: string;
92
+ label: string;
93
+ description: string;
94
+ }, {
95
+ resource: string;
96
+ action: string;
97
+ label: string;
98
+ description: string;
99
+ }, {
100
+ resource: string;
101
+ action: string;
102
+ label: string;
103
+ description: string;
104
+ }];
105
+ }, {
106
+ readonly resource: "availability";
107
+ readonly label: "Availability";
108
+ readonly description: "Read and manage availability rules, slots, and closeouts.";
109
+ readonly permissions: [{
110
+ resource: string;
111
+ action: string;
112
+ label: string;
113
+ description: string;
114
+ }, {
115
+ resource: string;
116
+ action: string;
117
+ label: string;
118
+ description: string;
119
+ }];
120
+ }, {
121
+ readonly resource: "hospitality";
122
+ readonly label: "Hospitality";
123
+ readonly description: "Read and manage properties, rooms, rates, and hospitality bookings.";
124
+ readonly permissions: [{
125
+ resource: string;
126
+ action: string;
127
+ label: string;
128
+ description: string;
129
+ }, {
130
+ resource: string;
131
+ action: string;
132
+ label: string;
133
+ description: string;
134
+ }];
135
+ }, {
136
+ readonly resource: "ground";
137
+ readonly label: "Ground";
138
+ readonly description: "Read and manage ground transport operations.";
139
+ readonly permissions: [{
140
+ resource: string;
141
+ action: string;
142
+ label: string;
143
+ description: string;
144
+ }, {
145
+ resource: string;
146
+ action: string;
147
+ label: string;
148
+ description: string;
149
+ }];
150
+ }, {
151
+ readonly resource: "cruises";
152
+ readonly label: "Cruises";
153
+ readonly description: "Read and manage cruise products and sailing data.";
154
+ readonly permissions: [{
155
+ resource: string;
156
+ action: string;
157
+ label: string;
158
+ description: string;
159
+ }, {
160
+ resource: string;
161
+ action: string;
162
+ label: string;
163
+ description: string;
164
+ }];
165
+ }, {
166
+ readonly resource: "workflows";
167
+ readonly label: "Workflows";
168
+ readonly description: "Trigger workflow automation from external systems.";
169
+ readonly permissions: [{
170
+ resource: string;
171
+ action: string;
172
+ label: string;
173
+ description: string;
174
+ }];
175
+ }, {
176
+ readonly resource: "webhooks";
177
+ readonly label: "Webhooks";
178
+ readonly description: "Relay webhook events into Voyant runtimes.";
179
+ readonly permissions: [{
180
+ resource: string;
181
+ action: string;
182
+ label: string;
183
+ description: string;
184
+ }];
185
+ }];
186
+ export declare const API_KEY_PERMISSION_PRESETS: {
187
+ readonly "catalog-read": {
188
+ readonly label: "Catalog read";
189
+ readonly description: "Read/search catalog, product, departure, and itinerary content.";
190
+ readonly permissions: {
191
+ readonly catalog: ["read", "search"];
192
+ readonly products: ["read"];
193
+ readonly departures: ["read"];
194
+ readonly itineraries: ["read"];
195
+ };
118
196
  };
119
- readonly bookings: {
120
- readonly label: "Bookings";
121
- readonly description: "Create, confirm, and cancel bookings via OCTO";
122
- readonly scopes: readonly ["bookings:read", "bookings:write", "bookings:delete"];
197
+ readonly "commerce-read": {
198
+ readonly label: "Commerce read";
199
+ readonly description: "Read bookings, availability, products, pricing, and suppliers.";
200
+ readonly permissions: {
201
+ readonly bookings: ["read"];
202
+ readonly availability: ["read"];
203
+ readonly products: ["read"];
204
+ readonly pricing: ["read"];
205
+ readonly suppliers: ["read"];
206
+ };
123
207
  };
124
- readonly suppliers: {
125
- readonly label: "Suppliers";
126
- readonly description: "Query supplier information via OCTO";
127
- readonly scopes: readonly ["suppliers:read"];
208
+ readonly automation: {
209
+ readonly label: "Automation";
210
+ readonly description: "Trigger workflows and relay webhooks.";
211
+ readonly permissions: {
212
+ readonly workflows: ["trigger"];
213
+ readonly webhooks: ["relay"];
214
+ };
128
215
  };
129
- readonly grants: {
130
- readonly label: "Grants";
131
- readonly description: "Manage cross-organization operator access grants";
132
- readonly scopes: readonly ["grants:read", "grants:write", "grants:delete"];
216
+ readonly "read-only": {
217
+ readonly label: "Read only";
218
+ readonly description: "Read across every resource that accepts API tokens.";
219
+ readonly permissions: {
220
+ readonly "*": ["read"];
221
+ };
133
222
  };
134
- readonly "audit-logs": {
135
- readonly label: "Audit Logs";
136
- readonly description: "Query API audit logs for your organization";
137
- readonly scopes: readonly ["audit-logs:read"];
223
+ readonly "full-access": {
224
+ readonly label: "Full access";
225
+ readonly description: "All resources and all actions. Use only for trusted automation.";
226
+ readonly permissions: {
227
+ readonly "*": ["*"];
228
+ };
138
229
  };
139
230
  };
140
- export type ScopeGroupKey = keyof typeof SCOPE_GROUPS;
141
- /**
142
- * Predefined scope templates for quick setup
143
- */
144
- interface ScopeTemplate {
145
- name: string;
146
- description: string;
147
- scopes: ApiKeyScope[];
148
- }
149
- export declare const SCOPE_TEMPLATES: Record<string, ScopeTemplate>;
150
- export type ScopeTemplateKey = "read-only" | "full-access" | "operator-admin" | "reseller";
151
- /**
152
- * Expiration presets for key creation
153
- */
231
+ export type ApiKeyPermissionPresetKey = keyof typeof API_KEY_PERMISSION_PRESETS;
232
+ export declare const apiKeyPermissionStringSchema: z.ZodString & z.ZodType<ApiKeyPermissionString, string, z.core.$ZodTypeInternals<ApiKeyPermissionString, string>>;
233
+ export declare const apiKeyPermissionsSchema: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>, z.ZodTransform<ApiKeyPermissions, Record<string, string[]>>>;
234
+ export declare function normalizeApiKeyPermissions(permissions: string | ApiKeyPermissions | null | undefined): ApiKeyPermissions;
235
+ export declare function permissionStringsToPermissions(permissions: readonly string[]): ApiKeyPermissions;
236
+ export declare function permissionsToStrings(permissions: string | ApiKeyPermissions | null | undefined): ApiKeyPermissionString[];
237
+ export declare function hasApiKeyPermission(permissions: string | ApiKeyPermissions | null | undefined, resource: string, action: string): boolean;
238
+ export declare function hasApiKeyPermissions(permissions: string | ApiKeyPermissions | null | undefined, required: ApiKeyPermissions): boolean;
239
+ export declare function describePermissions(permissions: string | ApiKeyPermissions | null | undefined): string;
154
240
  export declare const EXPIRATION_PRESETS: {
155
241
  readonly never: {
156
242
  readonly label: "Never";
@@ -182,25 +268,283 @@ export declare const EXPIRATION_PRESETS: {
182
268
  };
183
269
  };
184
270
  export type ExpirationPresetKey = keyof typeof EXPIRATION_PRESETS;
185
- /**
186
- * Helper functions for scope validation
187
- */
188
- /**
189
- * Check if a scope pattern matches a required scope
190
- * Handles wildcards: "operators:*", "*:read", "*"
191
- */
192
- export declare function scopeMatches(userScope: string, requiredScope: string): boolean;
193
- /**
194
- * Check if user has all required scopes
195
- */
196
- export declare function hasScopes(userScopes: string[], requiredScopes: string[]): boolean;
197
- /**
198
- * Get human-readable description of scopes
199
- */
200
- export declare function describescopes(scopes: string[]): string;
201
- /**
202
- * Calculate expiration date from preset
203
- */
204
271
  export declare function calculateExpirationDate(preset: ExpirationPresetKey, customDate?: Date): Date | null;
205
- export {};
272
+ /** @deprecated Use ApiKeyPermissionString. */
273
+ export type ApiKeyScope = ApiKeyPermissionString;
274
+ /** @deprecated Use ApiKeyPermissionDescriptor. */
275
+ export type ApiKeyScopeDescriptor = ApiKeyPermissionDescriptor & {
276
+ scope: ApiKeyPermissionString;
277
+ };
278
+ /** @deprecated Use API_KEY_PERMISSION_GROUPS. */
279
+ export declare const API_KEY_SCOPE_GROUPS: ({
280
+ scopes: {
281
+ scope: ApiKeyPermissionString;
282
+ resource: string;
283
+ action: string;
284
+ label: string;
285
+ description: string;
286
+ }[];
287
+ resource: "catalog";
288
+ label: "Catalog";
289
+ description: "Search and read unified catalog content.";
290
+ permissions: [{
291
+ resource: string;
292
+ action: string;
293
+ label: string;
294
+ description: string;
295
+ }, {
296
+ resource: string;
297
+ action: string;
298
+ label: string;
299
+ description: string;
300
+ }];
301
+ } | {
302
+ scopes: {
303
+ scope: ApiKeyPermissionString;
304
+ resource: string;
305
+ action: string;
306
+ label: string;
307
+ description: string;
308
+ }[];
309
+ resource: "products";
310
+ label: "Products";
311
+ description: "Read and manage products, options, content, and media.";
312
+ permissions: [{
313
+ resource: string;
314
+ action: string;
315
+ label: string;
316
+ description: string;
317
+ }, {
318
+ resource: string;
319
+ action: string;
320
+ label: string;
321
+ description: string;
322
+ }, {
323
+ resource: string;
324
+ action: string;
325
+ label: string;
326
+ description: string;
327
+ }];
328
+ } | {
329
+ scopes: {
330
+ scope: ApiKeyPermissionString;
331
+ resource: string;
332
+ action: string;
333
+ label: string;
334
+ description: string;
335
+ }[];
336
+ resource: "departures";
337
+ label: "Departures";
338
+ description: "Read and manage scheduled departures.";
339
+ permissions: [{
340
+ resource: string;
341
+ action: string;
342
+ label: string;
343
+ description: string;
344
+ }, {
345
+ resource: string;
346
+ action: string;
347
+ label: string;
348
+ description: string;
349
+ }];
350
+ } | {
351
+ scopes: {
352
+ scope: ApiKeyPermissionString;
353
+ resource: string;
354
+ action: string;
355
+ label: string;
356
+ description: string;
357
+ }[];
358
+ resource: "itineraries";
359
+ label: "Itineraries";
360
+ description: "Read and manage day-by-day itinerary content.";
361
+ permissions: [{
362
+ resource: string;
363
+ action: string;
364
+ label: string;
365
+ description: string;
366
+ }, {
367
+ resource: string;
368
+ action: string;
369
+ label: string;
370
+ description: string;
371
+ }];
372
+ } | {
373
+ scopes: {
374
+ scope: ApiKeyPermissionString;
375
+ resource: string;
376
+ action: string;
377
+ label: string;
378
+ description: string;
379
+ }[];
380
+ resource: "bookings";
381
+ label: "Bookings";
382
+ description: "Read and manage booking records and booking workflows.";
383
+ permissions: [{
384
+ resource: string;
385
+ action: string;
386
+ label: string;
387
+ description: string;
388
+ }, {
389
+ resource: string;
390
+ action: string;
391
+ label: string;
392
+ description: string;
393
+ }, {
394
+ resource: string;
395
+ action: string;
396
+ label: string;
397
+ description: string;
398
+ }];
399
+ } | {
400
+ scopes: {
401
+ scope: ApiKeyPermissionString;
402
+ resource: string;
403
+ action: string;
404
+ label: string;
405
+ description: string;
406
+ }[];
407
+ resource: "availability";
408
+ label: "Availability";
409
+ description: "Read and manage availability rules, slots, and closeouts.";
410
+ permissions: [{
411
+ resource: string;
412
+ action: string;
413
+ label: string;
414
+ description: string;
415
+ }, {
416
+ resource: string;
417
+ action: string;
418
+ label: string;
419
+ description: string;
420
+ }];
421
+ } | {
422
+ scopes: {
423
+ scope: ApiKeyPermissionString;
424
+ resource: string;
425
+ action: string;
426
+ label: string;
427
+ description: string;
428
+ }[];
429
+ resource: "hospitality";
430
+ label: "Hospitality";
431
+ description: "Read and manage properties, rooms, rates, and hospitality bookings.";
432
+ permissions: [{
433
+ resource: string;
434
+ action: string;
435
+ label: string;
436
+ description: string;
437
+ }, {
438
+ resource: string;
439
+ action: string;
440
+ label: string;
441
+ description: string;
442
+ }];
443
+ } | {
444
+ scopes: {
445
+ scope: ApiKeyPermissionString;
446
+ resource: string;
447
+ action: string;
448
+ label: string;
449
+ description: string;
450
+ }[];
451
+ resource: "ground";
452
+ label: "Ground";
453
+ description: "Read and manage ground transport operations.";
454
+ permissions: [{
455
+ resource: string;
456
+ action: string;
457
+ label: string;
458
+ description: string;
459
+ }, {
460
+ resource: string;
461
+ action: string;
462
+ label: string;
463
+ description: string;
464
+ }];
465
+ } | {
466
+ scopes: {
467
+ scope: ApiKeyPermissionString;
468
+ resource: string;
469
+ action: string;
470
+ label: string;
471
+ description: string;
472
+ }[];
473
+ resource: "cruises";
474
+ label: "Cruises";
475
+ description: "Read and manage cruise products and sailing data.";
476
+ permissions: [{
477
+ resource: string;
478
+ action: string;
479
+ label: string;
480
+ description: string;
481
+ }, {
482
+ resource: string;
483
+ action: string;
484
+ label: string;
485
+ description: string;
486
+ }];
487
+ } | {
488
+ scopes: {
489
+ scope: ApiKeyPermissionString;
490
+ resource: string;
491
+ action: string;
492
+ label: string;
493
+ description: string;
494
+ }[];
495
+ resource: "workflows";
496
+ label: "Workflows";
497
+ description: "Trigger workflow automation from external systems.";
498
+ permissions: [{
499
+ resource: string;
500
+ action: string;
501
+ label: string;
502
+ description: string;
503
+ }];
504
+ } | {
505
+ scopes: {
506
+ scope: ApiKeyPermissionString;
507
+ resource: string;
508
+ action: string;
509
+ label: string;
510
+ description: string;
511
+ }[];
512
+ resource: "webhooks";
513
+ label: "Webhooks";
514
+ description: "Relay webhook events into Voyant runtimes.";
515
+ permissions: [{
516
+ resource: string;
517
+ action: string;
518
+ label: string;
519
+ description: string;
520
+ }];
521
+ })[];
522
+ /** @deprecated Use API_KEY_PERMISSION_PRESETS. */
523
+ export declare const API_KEY_SCOPE_PRESETS: Record<string, {
524
+ label: string;
525
+ description: string;
526
+ scopes: ApiKeyPermissionString[];
527
+ }>;
528
+ /** @deprecated Use ApiKeyPermissionPresetKey. */
529
+ export type ApiKeyScopePresetKey = ApiKeyPermissionPresetKey;
530
+ /** @deprecated Use apiKeyPermissionStringSchema. */
531
+ export declare const apiKeyScopeSchema: z.ZodString & z.ZodType<ApiKeyPermissionString, string, z.core.$ZodTypeInternals<ApiKeyPermissionString, string>>;
532
+ /** @deprecated Use array of apiKeyPermissionStringSchema only for display strings. */
533
+ export declare const apiKeyScopesSchema: z.ZodDefault<z.ZodArray<z.ZodString & z.ZodType<ApiKeyPermissionString, string, z.core.$ZodTypeInternals<ApiKeyPermissionString, string>>>>;
534
+ /** @deprecated Use permissionStringsToPermissions. */
535
+ export declare const scopesToPermissions: typeof permissionStringsToPermissions;
536
+ /** @deprecated Use permissionsToStrings. */
537
+ export declare const permissionsToScopes: typeof permissionsToStrings;
538
+ /** @deprecated Use permissionsToStrings. */
539
+ export declare const normalizeApiKeyScopes: typeof permissionsToStrings;
540
+ /** @deprecated Use apiKeyPermissionStringSchema.parse. */
541
+ export declare function normalizeApiKeyScope(scope: string): ApiKeyPermissionString;
542
+ /** @deprecated Use hasApiKeyPermission. */
543
+ export declare function scopeMatches(userScope: string, requiredScope: string): boolean;
544
+ /** @deprecated Use hasApiKeyPermissions. */
545
+ export declare function hasScopes(userScopes: readonly string[], requiredScopes: readonly string[]): boolean;
546
+ /** @deprecated Use describePermissions. */
547
+ export declare const describeScopes: typeof describePermissions;
548
+ /** @deprecated Use describePermissions. */
549
+ export declare const describescopes: typeof describePermissions;
206
550
  //# sourceMappingURL=api-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;GAKG;AAGH,eAAO,MAAM,iBAAiB,qIAUpB,CAAA;AAEV,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAG/D,eAAO,MAAM,eAAe,sCAAuC,CAAA;AAEnE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,2iBAoDf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAGvD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;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GAChC,OAAO,CAKT;AACD,2CAA2C;AAC3C,eAAO,MAAM,cAAc,4BAAsB,CAAA;AACjD,2CAA2C;AAC3C,eAAO,MAAM,cAAc,4BAAsB,CAAA"}
package/dist/api-keys.js CHANGED
@@ -1,161 +1,275 @@
1
1
  import { z } from "zod";
2
- /**
3
- * API Key Scope Definitions
4
- *
5
- * Following resource:action pattern similar to Stripe/Shopify
6
- * Format: "{resource}:{action}" or wildcards
7
- */
8
- // Resource types
2
+ export const API_KEY_ACTIONS = ["read", "write", "delete", "trigger", "relay", "search"];
9
3
  export const API_KEY_RESOURCES = [
10
- "operators",
11
- "connections",
12
- "oauth-clients",
13
- "products",
14
4
  "availability",
15
5
  "bookings",
6
+ "catalog",
7
+ "crm",
8
+ "cruises",
9
+ "departures",
10
+ "finance",
11
+ "ground",
12
+ "hospitality",
13
+ "itineraries",
14
+ "legal",
15
+ "notifications",
16
+ "pricing",
17
+ "products",
18
+ "resources",
19
+ "storefront",
16
20
  "suppliers",
17
- "grants",
18
- "audit-logs",
21
+ "transactions",
22
+ "webhooks",
23
+ "workflows",
19
24
  ];
20
- // Action types
21
- export const API_KEY_ACTIONS = ["read", "write", "delete"];
22
- /**
23
- * Valid scope patterns:
24
- * - Specific: "operators:read", "connections:write"
25
- * - Resource wildcard: "operators:*" (all actions on operators)
26
- * - Action wildcard: "*:read" (read all resources)
27
- * - Full wildcard: "*" (all resources, all actions)
28
- */
29
- export const VALID_SCOPES = [
30
- // Operators
31
- "operators:read",
32
- "operators:write",
33
- "operators:delete",
34
- "operators:*",
35
- // Connections
36
- "connections:read",
37
- "connections:write",
38
- "connections:delete",
39
- "connections:*",
40
- // OAuth Clients
41
- "oauth-clients:read",
42
- "oauth-clients:write",
43
- "oauth-clients:delete",
44
- "oauth-clients:*",
45
- // Products
46
- "products:read",
47
- "products:*",
48
- // Availability
49
- "availability:read",
50
- "availability:*",
51
- // Bookings
52
- "bookings:read",
53
- "bookings:write",
54
- "bookings:delete",
55
- "bookings:*",
56
- // Suppliers
57
- "suppliers:read",
58
- "suppliers:*",
59
- // Grants
60
- "grants:read",
61
- "grants:write",
62
- "grants:delete",
63
- "grants:*",
64
- // Audit Logs
65
- "audit-logs:read",
66
- "audit-logs:*",
67
- // Wildcard patterns
68
- "*:read", // Read-only access to all resources
69
- "*:write", // Write access to all resources
70
- "*:delete", // Delete access to all resources
71
- "*", // Full access (God mode)
72
- ];
73
- // Zod schema for scope validation
74
- export const apiKeyScopeSchema = z.enum(VALID_SCOPES);
75
- export const apiKeyScopesSchema = z.array(apiKeyScopeSchema).default([]);
76
- /**
77
- * Scope groups for UI display
78
- * Grouped by resource for nested checkbox UX
79
- */
80
- export const SCOPE_GROUPS = {
81
- operators: {
82
- label: "Operators",
83
- description: "Manage operator registrations and configuration",
84
- scopes: ["operators:read", "operators:write", "operators:delete"],
25
+ function permission(resource, action, label, description) {
26
+ return { resource, action, label, description };
27
+ }
28
+ export const API_KEY_PERMISSION_GROUPS = [
29
+ {
30
+ resource: "catalog",
31
+ label: "Catalog",
32
+ description: "Search and read unified catalog content.",
33
+ permissions: [
34
+ permission("catalog", "read", "Read catalog", "Read catalog records and storefront-ready content."),
35
+ permission("catalog", "search", "Search catalog", "Run catalog search and discovery requests."),
36
+ ],
37
+ },
38
+ {
39
+ resource: "products",
40
+ label: "Products",
41
+ description: "Read and manage products, options, content, and media.",
42
+ permissions: [
43
+ permission("products", "read", "Read products", "Read product, option, media, category, and tag data."),
44
+ permission("products", "write", "Write products", "Create or update products and product content."),
45
+ permission("products", "delete", "Delete products", "Delete products and product-owned records."),
46
+ ],
85
47
  },
86
- connections: {
87
- label: "Connections",
88
- description: "Manage supplier connections and credentials",
89
- scopes: ["connections:read", "connections:write", "connections:delete"],
48
+ {
49
+ resource: "departures",
50
+ label: "Departures",
51
+ description: "Read and manage scheduled departures.",
52
+ permissions: [
53
+ permission("departures", "read", "Read departures", "Read departure schedules and availability context."),
54
+ permission("departures", "write", "Write departures", "Create or update scheduled departures."),
55
+ ],
90
56
  },
91
- "oauth-clients": {
92
- label: "OAuth Clients",
93
- description: "Manage OAuth client credentials for M2M access",
94
- scopes: ["oauth-clients:read", "oauth-clients:write", "oauth-clients:delete"],
57
+ {
58
+ resource: "itineraries",
59
+ label: "Itineraries",
60
+ description: "Read and manage day-by-day itinerary content.",
61
+ permissions: [
62
+ permission("itineraries", "read", "Read itineraries", "Read itinerary days, services, and descriptions."),
63
+ permission("itineraries", "write", "Write itineraries", "Create or update itinerary content."),
64
+ ],
95
65
  },
96
- products: {
97
- label: "Products",
98
- description: "Query supplier product catalogs via OCTO",
99
- scopes: ["products:read"],
66
+ {
67
+ resource: "bookings",
68
+ label: "Bookings",
69
+ description: "Read and manage booking records and booking workflows.",
70
+ permissions: [
71
+ permission("bookings", "read", "Read bookings", "Read booking records and non-sensitive booking state."),
72
+ permission("bookings", "write", "Write bookings", "Create, update, confirm, or cancel bookings."),
73
+ permission("bookings", "delete", "Delete bookings", "Delete booking-owned records where supported."),
74
+ ],
100
75
  },
101
- availability: {
76
+ {
77
+ resource: "availability",
102
78
  label: "Availability",
103
- description: "Query supplier availability via OCTO",
104
- scopes: ["availability:read"],
79
+ description: "Read and manage availability rules, slots, and closeouts.",
80
+ permissions: [
81
+ permission("availability", "read", "Read availability", "Read availability slots, rules, pickup points, and closeouts."),
82
+ permission("availability", "write", "Write availability", "Create or update availability configuration."),
83
+ ],
105
84
  },
106
- bookings: {
107
- label: "Bookings",
108
- description: "Create, confirm, and cancel bookings via OCTO",
109
- scopes: ["bookings:read", "bookings:write", "bookings:delete"],
85
+ {
86
+ resource: "hospitality",
87
+ label: "Hospitality",
88
+ description: "Read and manage properties, rooms, rates, and hospitality bookings.",
89
+ permissions: [
90
+ permission("hospitality", "read", "Read hospitality", "Read hospitality inventory, properties, and rates."),
91
+ permission("hospitality", "write", "Write hospitality", "Create or update hospitality records."),
92
+ ],
110
93
  },
111
- suppliers: {
112
- label: "Suppliers",
113
- description: "Query supplier information via OCTO",
114
- scopes: ["suppliers:read"],
94
+ {
95
+ resource: "ground",
96
+ label: "Ground",
97
+ description: "Read and manage ground transport operations.",
98
+ permissions: [
99
+ permission("ground", "read", "Read ground", "Read transport schedules, vehicles, dispatch, and operations data."),
100
+ permission("ground", "write", "Write ground", "Create or update ground transport records."),
101
+ ],
115
102
  },
116
- grants: {
117
- label: "Grants",
118
- description: "Manage cross-organization operator access grants",
119
- scopes: ["grants:read", "grants:write", "grants:delete"],
103
+ {
104
+ resource: "cruises",
105
+ label: "Cruises",
106
+ description: "Read and manage cruise products and sailing data.",
107
+ permissions: [
108
+ permission("cruises", "read", "Read cruises", "Read cruise products, sailings, cabins, and itinerary data."),
109
+ permission("cruises", "write", "Write cruises", "Create or update cruise records."),
110
+ ],
120
111
  },
121
- "audit-logs": {
122
- label: "Audit Logs",
123
- description: "Query API audit logs for your organization",
124
- scopes: ["audit-logs:read"],
112
+ {
113
+ resource: "workflows",
114
+ label: "Workflows",
115
+ description: "Trigger workflow automation from external systems.",
116
+ permissions: [
117
+ permission("workflows", "trigger", "Trigger workflows", "Trigger workflow runs and ingest workflow events."),
118
+ ],
125
119
  },
126
- };
127
- export const SCOPE_TEMPLATES = {
128
- "read-only": {
129
- name: "Read Only",
130
- description: "Read-only access to all resources",
131
- scopes: ["*:read"],
120
+ {
121
+ resource: "webhooks",
122
+ label: "Webhooks",
123
+ description: "Relay webhook events into Voyant runtimes.",
124
+ permissions: [
125
+ permission("webhooks", "relay", "Relay webhooks", "Relay validated third-party webhook events."),
126
+ ],
132
127
  },
133
- "full-access": {
134
- name: "Full Access",
135
- description: "Complete access to all resources and actions",
136
- scopes: ["*"],
128
+ ];
129
+ export const API_KEY_PERMISSION_PRESETS = {
130
+ "catalog-read": {
131
+ label: "Catalog read",
132
+ description: "Read/search catalog, product, departure, and itinerary content.",
133
+ permissions: {
134
+ catalog: ["read", "search"],
135
+ products: ["read"],
136
+ departures: ["read"],
137
+ itineraries: ["read"],
138
+ },
137
139
  },
138
- "operator-admin": {
139
- name: "Operator Admin",
140
- description: "Full operator and connection management",
141
- scopes: ["operators:*", "connections:*", "oauth-clients:*"],
140
+ "commerce-read": {
141
+ label: "Commerce read",
142
+ description: "Read bookings, availability, products, pricing, and suppliers.",
143
+ permissions: {
144
+ bookings: ["read"],
145
+ availability: ["read"],
146
+ products: ["read"],
147
+ pricing: ["read"],
148
+ suppliers: ["read"],
149
+ },
142
150
  },
143
- reseller: {
144
- name: "OCTO Reseller",
145
- description: "Full data-plane access for resellers",
146
- scopes: [
147
- "products:read",
148
- "availability:read",
149
- "bookings:read",
150
- "bookings:write",
151
- "bookings:delete",
152
- "suppliers:read",
153
- ],
151
+ automation: {
152
+ label: "Automation",
153
+ description: "Trigger workflows and relay webhooks.",
154
+ permissions: {
155
+ workflows: ["trigger"],
156
+ webhooks: ["relay"],
157
+ },
158
+ },
159
+ "read-only": {
160
+ label: "Read only",
161
+ description: "Read across every resource that accepts API tokens.",
162
+ permissions: {
163
+ "*": ["read"],
164
+ },
165
+ },
166
+ "full-access": {
167
+ label: "Full access",
168
+ description: "All resources and all actions. Use only for trusted automation.",
169
+ permissions: {
170
+ "*": ["*"],
171
+ },
154
172
  },
155
173
  };
156
- /**
157
- * Expiration presets for key creation
158
- */
174
+ const permissionNamePattern = /^(\*|[a-z][a-z0-9-]*)$/;
175
+ const permissionStringPattern = /^(\*|[a-z][a-z0-9-]*):(\*|[a-z][a-z0-9-]*)$/;
176
+ export const apiKeyPermissionStringSchema = z
177
+ .string()
178
+ .trim()
179
+ .refine((value) => value === "*" || value === "*:*" || permissionStringPattern.test(value), {
180
+ message: "Permission must be '*' or use the resource:action format.",
181
+ });
182
+ export const apiKeyPermissionsSchema = z
183
+ .record(z.string(), z.array(z.string()))
184
+ .transform((permissions) => normalizeApiKeyPermissions(permissions));
185
+ function parsePermissionsJson(permissions) {
186
+ try {
187
+ const parsed = JSON.parse(permissions);
188
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
189
+ return {};
190
+ return normalizeApiKeyPermissions(parsed);
191
+ }
192
+ catch {
193
+ return {};
194
+ }
195
+ }
196
+ export function normalizeApiKeyPermissions(permissions) {
197
+ if (!permissions)
198
+ return {};
199
+ if (typeof permissions === "string")
200
+ return parsePermissionsJson(permissions);
201
+ const normalized = {};
202
+ for (const [resourceInput, actionsInput] of Object.entries(permissions)) {
203
+ const resource = resourceInput.trim().toLowerCase();
204
+ if (!permissionNamePattern.test(resource) || !Array.isArray(actionsInput))
205
+ continue;
206
+ const actions = Array.from(new Set(actionsInput
207
+ .map((action) => action.trim().toLowerCase())
208
+ .filter((action) => permissionNamePattern.test(action)))).sort();
209
+ if (actions.length > 0) {
210
+ normalized[resource] = actions;
211
+ }
212
+ }
213
+ return normalized;
214
+ }
215
+ export function permissionStringsToPermissions(permissions) {
216
+ const next = {};
217
+ for (const permissionInput of permissions) {
218
+ const permission = permissionInput.trim().toLowerCase();
219
+ if (permission === "*" || permission === "*:*") {
220
+ next["*"] = ["*"];
221
+ continue;
222
+ }
223
+ if (!permissionStringPattern.test(permission))
224
+ continue;
225
+ const [resource, action] = permission.split(":");
226
+ if (!resource || !action)
227
+ continue;
228
+ next[resource] = Array.from(new Set([...(next[resource] ?? []), action])).sort();
229
+ }
230
+ return normalizeApiKeyPermissions(next);
231
+ }
232
+ export function permissionsToStrings(permissions) {
233
+ const normalized = normalizeApiKeyPermissions(permissions);
234
+ const strings = [];
235
+ for (const [resource, actions] of Object.entries(normalized)) {
236
+ if (resource === "*" && actions.includes("*")) {
237
+ strings.push("*");
238
+ continue;
239
+ }
240
+ for (const action of actions) {
241
+ strings.push(`${resource}:${action}`);
242
+ }
243
+ }
244
+ return Array.from(new Set(strings)).sort();
245
+ }
246
+ export function hasApiKeyPermission(permissions, resource, action) {
247
+ const normalized = normalizeApiKeyPermissions(permissions);
248
+ const resourceKey = resource.trim().toLowerCase();
249
+ const actionKey = action.trim().toLowerCase();
250
+ return (normalized["*"]?.includes("*") === true ||
251
+ normalized["*"]?.includes(actionKey) === true ||
252
+ normalized[resourceKey]?.includes("*") === true ||
253
+ normalized[resourceKey]?.includes(actionKey) === true);
254
+ }
255
+ export function hasApiKeyPermissions(permissions, required) {
256
+ return Object.entries(normalizeApiKeyPermissions(required)).every(([resource, actions]) => actions.every((action) => hasApiKeyPermission(permissions, resource, action)));
257
+ }
258
+ export function describePermissions(permissions) {
259
+ const normalized = normalizeApiKeyPermissions(permissions);
260
+ const permissionStrings = permissionsToStrings(normalized);
261
+ if (normalized["*"]?.includes("*"))
262
+ return "Full access";
263
+ if (permissionStrings.length === 0)
264
+ return "No permissions";
265
+ if (permissionStrings.length === 1 && permissionStrings[0] === "*:read")
266
+ return "Read-only access";
267
+ const resources = Object.keys(normalized).filter((resource) => resource !== "*");
268
+ const actions = new Set(Object.values(normalized)
269
+ .flat()
270
+ .filter((action) => action !== "*"));
271
+ return `${resources.length || "All"} resource${resources.length === 1 ? "" : "s"} / ${actions.size || "all"} action${actions.size === 1 ? "" : "s"}`;
272
+ }
159
273
  export const EXPIRATION_PRESETS = {
160
274
  never: {
161
275
  label: "Never",
@@ -186,63 +300,6 @@ export const EXPIRATION_PRESETS = {
186
300
  days: null,
187
301
  },
188
302
  };
189
- /**
190
- * Helper functions for scope validation
191
- */
192
- /**
193
- * Check if a scope pattern matches a required scope
194
- * Handles wildcards: "operators:*", "*:read", "*"
195
- */
196
- export function scopeMatches(userScope, requiredScope) {
197
- // Full wildcard
198
- if (userScope === "*")
199
- return true;
200
- // Exact match
201
- if (userScope === requiredScope)
202
- return true;
203
- const [userResource, userAction] = userScope.split(":");
204
- const [reqResource, reqAction] = requiredScope.split(":");
205
- // Resource wildcard (e.g., "operators:*" matches "operators:read")
206
- if (userResource === reqResource && userAction === "*")
207
- return true;
208
- // Action wildcard (e.g., "*:read" matches "operators:read")
209
- if (userResource === "*" && userAction === reqAction)
210
- return true;
211
- return false;
212
- }
213
- /**
214
- * Check if user has all required scopes
215
- */
216
- export function hasScopes(userScopes, requiredScopes) {
217
- return requiredScopes.every((required) => userScopes.some((userScope) => scopeMatches(userScope, required)));
218
- }
219
- /**
220
- * Get human-readable description of scopes
221
- */
222
- export function describescopes(scopes) {
223
- if (scopes.includes("*")) {
224
- return "Full access to all resources";
225
- }
226
- if (scopes.includes("*:read") && scopes.length === 1) {
227
- return "Read-only access to all resources";
228
- }
229
- const resources = new Set();
230
- const actions = new Set();
231
- for (const scope of scopes) {
232
- const [resource, action] = scope.split(":");
233
- if (resource && resource !== "*")
234
- resources.add(resource);
235
- if (action && action !== "*")
236
- actions.add(action);
237
- }
238
- if (resources.size === 0) {
239
- return `${actions.size} permission${actions.size > 1 ? "s" : ""}`;
240
- }
241
- return `${resources.size} resource${resources.size > 1 ? "s" : ""}`;
242
- }
243
- /**
244
- * Calculate expiration date from preset
245
- */
246
303
  export function calculateExpirationDate(preset, customDate) {
247
304
  if (preset === "never")
248
305
  return null;
@@ -255,4 +312,49 @@ export function calculateExpirationDate(preset, customDate) {
255
312
  expiresAt.setDate(expiresAt.getDate() + config.days);
256
313
  return expiresAt;
257
314
  }
315
+ /** @deprecated Use API_KEY_PERMISSION_GROUPS. */
316
+ export const API_KEY_SCOPE_GROUPS = API_KEY_PERMISSION_GROUPS.map((group) => ({
317
+ ...group,
318
+ scopes: group.permissions.map((item) => ({
319
+ ...item,
320
+ scope: `${item.resource}:${item.action}`,
321
+ })),
322
+ }));
323
+ /** @deprecated Use API_KEY_PERMISSION_PRESETS. */
324
+ export const API_KEY_SCOPE_PRESETS = Object.fromEntries(Object.entries(API_KEY_PERMISSION_PRESETS).map(([key, preset]) => [
325
+ key,
326
+ { ...preset, scopes: permissionsToStrings(preset.permissions) },
327
+ ]));
328
+ /** @deprecated Use apiKeyPermissionStringSchema. */
329
+ export const apiKeyScopeSchema = apiKeyPermissionStringSchema;
330
+ /** @deprecated Use array of apiKeyPermissionStringSchema only for display strings. */
331
+ export const apiKeyScopesSchema = z.array(apiKeyPermissionStringSchema).default([]);
332
+ /** @deprecated Use permissionStringsToPermissions. */
333
+ export const scopesToPermissions = permissionStringsToPermissions;
334
+ /** @deprecated Use permissionsToStrings. */
335
+ export const permissionsToScopes = permissionsToStrings;
336
+ /** @deprecated Use permissionsToStrings. */
337
+ export const normalizeApiKeyScopes = permissionsToStrings;
338
+ /** @deprecated Use apiKeyPermissionStringSchema.parse. */
339
+ export function normalizeApiKeyScope(scope) {
340
+ const normalized = scope.trim().toLowerCase();
341
+ if (normalized === "*:*")
342
+ return "*";
343
+ return apiKeyPermissionStringSchema.parse(normalized);
344
+ }
345
+ /** @deprecated Use hasApiKeyPermission. */
346
+ export function scopeMatches(userScope, requiredScope) {
347
+ const [resource, action] = requiredScope.split(":");
348
+ if (!resource || !action)
349
+ return false;
350
+ return hasApiKeyPermission(permissionStringsToPermissions([userScope]), resource, action);
351
+ }
352
+ /** @deprecated Use hasApiKeyPermissions. */
353
+ export function hasScopes(userScopes, requiredScopes) {
354
+ return hasApiKeyPermissions(permissionStringsToPermissions(userScopes), permissionStringsToPermissions(requiredScopes));
355
+ }
356
+ /** @deprecated Use describePermissions. */
357
+ export const describeScopes = describePermissions;
358
+ /** @deprecated Use describePermissions. */
359
+ export const describescopes = describePermissions;
258
360
  //# sourceMappingURL=api-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;GAKG;AAEH,iBAAiB;AACjB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW;IACX,aAAa;IACb,eAAe;IACf,UAAU;IACV,cAAc;IACd,UAAU;IACV,WAAW;IACX,QAAQ;IACR,YAAY;CACJ,CAAA;AAIV,eAAe;AACf,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AAInE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY;IACZ,gBAAgB;IAChB,iBAA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GAAG,oBAAoB,CAAA;AACvD,4CAA4C;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAA;AACzD,0DAA0D;AAC1D,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAC7C,IAAI,UAAU,KAAK,KAAK;QAAE,OAAO,GAAG,CAAA;IACpC,OAAO,4BAA4B,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AACvD,CAAC;AACD,2CAA2C;AAC3C,MAAM,UAAU,YAAY,CAAC,SAAiB,EAAE,aAAqB;IACnE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnD,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACtC,OAAO,mBAAmB,CAAC,8BAA8B,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AAC3F,CAAC;AACD,4CAA4C;AAC5C,MAAM,UAAU,SAAS,CACvB,UAA6B,EAC7B,cAAiC;IAEjC,OAAO,oBAAoB,CACzB,8BAA8B,CAAC,UAAU,CAAC,EAC1C,8BAA8B,CAAC,cAAc,CAAC,CAC/C,CAAA;AACH,CAAC;AACD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAA;AACjD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/types",
3
- "version": "0.31.1",
3
+ "version": "0.31.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "zod": "^4.3.6",
37
- "@voyantjs/db": "0.31.1"
37
+ "@voyantjs/db": "0.31.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "typescript": "^6.0.2",