@meistrari/vault-http-client 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,981 @@
1
+ import { makeApi, Zodios } from '@zodios/core';
2
+ import { z } from 'zod';
3
+
4
+ const put_WorkspacesByWorkspaceIdSettings_Body = z.object({
5
+ bucketName: z.string().min(1),
6
+ keyArns: z.array(z.string()).min(1),
7
+ defaultS3LinkTtl: z.number().gte(1)
8
+ }).strict();
9
+ const post_Files_Body = z.object({
10
+ fileName: z.string(),
11
+ sha256sum: z.string().optional(),
12
+ size: z.number().optional(),
13
+ mimeType: z.string().optional(),
14
+ createdBy: z.string().optional()
15
+ }).strict();
16
+ const postFilesBulk_Body = z.union([
17
+ z.array(
18
+ z.object({
19
+ fileName: z.string(),
20
+ sha256sum: z.string().optional(),
21
+ size: z.number().optional(),
22
+ mimeType: z.string().optional(),
23
+ createdBy: z.string().optional()
24
+ }).strict()
25
+ ),
26
+ z.object({ files: z.array(z.string()) }).strict()
27
+ ]);
28
+ const postFilesByFilename_Body = z.object({
29
+ fileName: z.string(),
30
+ sha256sum: z.string(),
31
+ size: z.number(),
32
+ mimeType: z.string(),
33
+ createdBy: z.string()
34
+ }).partial().strict();
35
+ const endpoints = makeApi([
36
+ {
37
+ method: "get",
38
+ path: "/_/files",
39
+ description: `Get a list of files.`,
40
+ requestFormat: "json",
41
+ parameters: [
42
+ {
43
+ name: "workspaceId",
44
+ type: "Query",
45
+ schema: z.string()
46
+ },
47
+ {
48
+ name: "includeDeleted",
49
+ type: "Query",
50
+ schema: z.boolean().optional().default(false)
51
+ },
52
+ {
53
+ name: "size",
54
+ type: "Query",
55
+ schema: z.number().optional().default(100)
56
+ },
57
+ {
58
+ name: "page",
59
+ type: "Query",
60
+ schema: z.number().optional().default(1)
61
+ },
62
+ {
63
+ name: "orderByField",
64
+ type: "Query",
65
+ schema: z.enum(["id", "createdAt", "deletedAt"]).optional()
66
+ },
67
+ {
68
+ name: "orderByDirection",
69
+ type: "Query",
70
+ schema: z.enum(["asc", "desc"]).optional()
71
+ },
72
+ {
73
+ name: "search",
74
+ type: "Query",
75
+ schema: z.string().optional()
76
+ }
77
+ ],
78
+ response: z.object({
79
+ files: z.array(
80
+ z.object({
81
+ id: z.string(),
82
+ path: z.string(),
83
+ workspaceId: z.string(),
84
+ originalFileName: z.union([z.string(), z.null()]).optional(),
85
+ mimeType: z.union([z.string(), z.null()]).optional(),
86
+ size: z.union([z.number(), z.null()]).optional(),
87
+ legacyKey: z.union([z.string(), z.null()]).optional(),
88
+ bucketName: z.union([z.string(), z.null()]).optional(),
89
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
90
+ createdBy: z.union([z.string(), z.null()]).optional(),
91
+ createdAt: z.string(),
92
+ deletedAt: z.union([z.string(), z.null()]).optional()
93
+ }).strict()
94
+ ),
95
+ count: z.number(),
96
+ pages: z.number()
97
+ }).strict()
98
+ },
99
+ {
100
+ method: "post",
101
+ path: "/_/files",
102
+ description: `Create a file and get a pre-signed upload URL.
103
+
104
+ The `sha256` body param is used as the file's primary key. If not provided, a random UUID will be generated.
105
+
106
+ The `filename` parameter is deprecated. Use the `originalFileName` parameter in the request body instead. Either way, the information about the file name is stored in the `metadata.originalFileName` field.
107
+
108
+ The returned `uploadUrl` is valid for 1 hour by default. You can change the expiration time by passing the `expiresIn` query parameter.
109
+ `,
110
+ requestFormat: "json",
111
+ parameters: [
112
+ {
113
+ name: "body",
114
+ type: "Body",
115
+ schema: post_Files_Body
116
+ },
117
+ {
118
+ name: "expiresIn",
119
+ type: "Query",
120
+ schema: z.number().optional().default(3600)
121
+ },
122
+ {
123
+ name: "workspaceId",
124
+ type: "Query",
125
+ schema: z.string()
126
+ }
127
+ ],
128
+ response: z.union([
129
+ z.object({
130
+ id: z.string(),
131
+ uploadUrl: z.string(),
132
+ expiresAt: z.string().datetime({ offset: true }),
133
+ metadata: z.object({
134
+ id: z.string(),
135
+ path: z.string(),
136
+ workspaceId: z.string(),
137
+ originalFileName: z.union([z.string(), z.null()]).optional(),
138
+ mimeType: z.union([z.string(), z.null()]).optional(),
139
+ size: z.union([z.number(), z.null()]).optional(),
140
+ legacyKey: z.union([z.string(), z.null()]).optional(),
141
+ bucketName: z.union([z.string(), z.null()]).optional(),
142
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
143
+ createdBy: z.union([z.string(), z.null()]).optional(),
144
+ createdAt: z.string(),
145
+ deletedAt: z.union([z.string(), z.null()]).optional()
146
+ }).strict()
147
+ }).strict(),
148
+ z.object({
149
+ url: z.string(),
150
+ expiresAt: z.string().datetime({ offset: true })
151
+ }).strict()
152
+ ])
153
+ },
154
+ {
155
+ method: "get",
156
+ path: "/_/files/:fileId",
157
+ description: `Get a pre-signed download URL for a file.`,
158
+ requestFormat: "json",
159
+ parameters: [
160
+ {
161
+ name: "expiresIn",
162
+ type: "Query",
163
+ schema: z.number().optional().default(3600)
164
+ },
165
+ {
166
+ name: "workspaceId",
167
+ type: "Query",
168
+ schema: z.string()
169
+ },
170
+ {
171
+ name: "fileId",
172
+ type: "Path",
173
+ schema: z.string()
174
+ }
175
+ ],
176
+ response: z.object({
177
+ url: z.string(),
178
+ expiresAt: z.string().datetime({ offset: true }),
179
+ metadata: z.union([
180
+ z.object({
181
+ id: z.string(),
182
+ path: z.string(),
183
+ workspaceId: z.string(),
184
+ originalFileName: z.union([z.string(), z.null()]).optional(),
185
+ mimeType: z.union([z.string(), z.null()]).optional(),
186
+ size: z.union([z.number(), z.null()]).optional(),
187
+ legacyKey: z.union([z.string(), z.null()]).optional(),
188
+ bucketName: z.union([z.string(), z.null()]).optional(),
189
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
190
+ createdBy: z.union([z.string(), z.null()]).optional(),
191
+ createdAt: z.string(),
192
+ deletedAt: z.union([z.string(), z.null()]).optional()
193
+ }).strict(),
194
+ z.null()
195
+ ])
196
+ }).strict(),
197
+ errors: [
198
+ {
199
+ status: 404,
200
+ description: `File not found`,
201
+ schema: z.void()
202
+ }
203
+ ]
204
+ },
205
+ {
206
+ method: "put",
207
+ path: "/_/files/:id",
208
+ description: `Get a pre-signed upload URL for a file.`,
209
+ requestFormat: "json",
210
+ parameters: [
211
+ {
212
+ name: "expiresIn",
213
+ type: "Query",
214
+ schema: z.number().optional().default(3600)
215
+ },
216
+ {
217
+ name: "workspaceId",
218
+ type: "Query",
219
+ schema: z.string()
220
+ },
221
+ {
222
+ name: "id",
223
+ type: "Path",
224
+ schema: z.string()
225
+ }
226
+ ],
227
+ response: z.union([
228
+ z.object({
229
+ id: z.string(),
230
+ uploadUrl: z.string().url(),
231
+ expiresAt: z.string().datetime({ offset: true }),
232
+ metadata: z.object({
233
+ id: z.string(),
234
+ path: z.string(),
235
+ workspaceId: z.string(),
236
+ originalFileName: z.union([z.string(), z.null()]).optional(),
237
+ mimeType: z.union([z.string(), z.null()]).optional(),
238
+ size: z.union([z.number(), z.null()]).optional(),
239
+ legacyKey: z.union([z.string(), z.null()]).optional(),
240
+ bucketName: z.union([z.string(), z.null()]).optional(),
241
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
242
+ createdBy: z.union([z.string(), z.null()]).optional(),
243
+ createdAt: z.string(),
244
+ deletedAt: z.union([z.string(), z.null()]).optional()
245
+ }).strict()
246
+ }).strict(),
247
+ z.object({
248
+ url: z.string().url(),
249
+ expiresAt: z.string().datetime({ offset: true })
250
+ }).strict()
251
+ ])
252
+ },
253
+ {
254
+ method: "delete",
255
+ path: "/_/files/:id",
256
+ description: `Delete a file.`,
257
+ requestFormat: "json",
258
+ parameters: [
259
+ {
260
+ name: "workspaceId",
261
+ type: "Query",
262
+ schema: z.string()
263
+ },
264
+ {
265
+ name: "id",
266
+ type: "Path",
267
+ schema: z.string()
268
+ }
269
+ ],
270
+ response: z.void()
271
+ },
272
+ {
273
+ method: "get",
274
+ path: "/_/files/:id/metadata",
275
+ description: `Get the metadata for a file.`,
276
+ requestFormat: "json",
277
+ parameters: [
278
+ {
279
+ name: "workspaceId",
280
+ type: "Query",
281
+ schema: z.string()
282
+ },
283
+ {
284
+ name: "id",
285
+ type: "Path",
286
+ schema: z.string()
287
+ }
288
+ ],
289
+ response: z.object({
290
+ id: z.string(),
291
+ path: z.string(),
292
+ workspaceId: z.string(),
293
+ originalFileName: z.union([z.string(), z.null()]).optional(),
294
+ mimeType: z.union([z.string(), z.null()]).optional(),
295
+ size: z.union([z.number(), z.null()]).optional(),
296
+ legacyKey: z.union([z.string(), z.null()]).optional(),
297
+ bucketName: z.union([z.string(), z.null()]).optional(),
298
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
299
+ createdBy: z.union([z.string(), z.null()]).optional(),
300
+ createdAt: z.string(),
301
+ deletedAt: z.union([z.string(), z.null()]).optional()
302
+ }).strict(),
303
+ errors: [
304
+ {
305
+ status: 404,
306
+ description: `File not found`,
307
+ schema: z.void()
308
+ }
309
+ ]
310
+ },
311
+ {
312
+ method: "get",
313
+ path: "/_/files/by-workspace",
314
+ description: `List workspaces and their file counts`,
315
+ requestFormat: "json",
316
+ response: z.array(
317
+ z.object({
318
+ workspaceId: z.string(),
319
+ files: z.number(),
320
+ permalinks: z.number(),
321
+ hasCustomSettings: z.boolean()
322
+ }).strict()
323
+ )
324
+ },
325
+ {
326
+ method: "put",
327
+ path: "/_/workspaces/:workspaceId/settings",
328
+ description: `Defines settings for a workspace.`,
329
+ requestFormat: "json",
330
+ parameters: [
331
+ {
332
+ name: "body",
333
+ type: "Body",
334
+ schema: put_WorkspacesByWorkspaceIdSettings_Body
335
+ },
336
+ {
337
+ name: "workspaceId",
338
+ type: "Path",
339
+ schema: z.string()
340
+ }
341
+ ],
342
+ response: z.void(),
343
+ errors: [
344
+ {
345
+ status: 401,
346
+ description: `Unauthorized`,
347
+ schema: z.void()
348
+ }
349
+ ]
350
+ },
351
+ {
352
+ method: "get",
353
+ path: "/_/workspaces/:workspaceId/settings",
354
+ description: `Gets settings for a workspace.`,
355
+ requestFormat: "json",
356
+ parameters: [
357
+ {
358
+ name: "workspaceId",
359
+ type: "Path",
360
+ schema: z.string()
361
+ }
362
+ ],
363
+ response: z.object({
364
+ bucketName: z.string().min(1),
365
+ keyArns: z.array(z.string()).min(1),
366
+ defaultS3LinkTtl: z.number().gte(1)
367
+ }).strict()
368
+ },
369
+ {
370
+ method: "get",
371
+ path: "/files/:fileId",
372
+ description: `Get a pre-signed download URL for a file.`,
373
+ requestFormat: "json",
374
+ parameters: [
375
+ {
376
+ name: "fileId",
377
+ type: "Path",
378
+ schema: z.string()
379
+ }
380
+ ],
381
+ response: z.object({
382
+ url: z.string(),
383
+ expiresAt: z.string().datetime({ offset: true }),
384
+ metadata: z.union([
385
+ z.object({
386
+ id: z.string(),
387
+ path: z.string(),
388
+ workspaceId: z.string(),
389
+ originalFileName: z.union([z.string(), z.null()]).optional(),
390
+ mimeType: z.union([z.string(), z.null()]).optional(),
391
+ size: z.union([z.number(), z.null()]).optional(),
392
+ legacyKey: z.union([z.string(), z.null()]).optional(),
393
+ bucketName: z.union([z.string(), z.null()]).optional(),
394
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
395
+ createdBy: z.union([z.string(), z.null()]).optional(),
396
+ createdAt: z.string(),
397
+ deletedAt: z.union([z.string(), z.null()]).optional()
398
+ }).strict(),
399
+ z.null()
400
+ ])
401
+ }).strict(),
402
+ errors: [
403
+ {
404
+ status: 404,
405
+ description: `File not found`,
406
+ schema: z.void()
407
+ }
408
+ ]
409
+ },
410
+ {
411
+ method: "post",
412
+ path: "/files/:fileId/permalinks",
413
+ description: `Create a public, direct, and optionally expiring download link for a file.
414
+
415
+ The returned permalink ID should be used with the `/permalinks/:permalinkId` endpoint to download the file via a 302 redirect.
416
+ `,
417
+ requestFormat: "json",
418
+ parameters: [
419
+ {
420
+ name: "body",
421
+ type: "Body",
422
+ schema: z.object({ expiresAt: z.string().datetime({ offset: true }) }).partial().strict()
423
+ },
424
+ {
425
+ name: "fileId",
426
+ type: "Path",
427
+ schema: z.string()
428
+ }
429
+ ],
430
+ response: z.object({
431
+ id: z.string(),
432
+ fileId: z.string(),
433
+ workspaceId: z.string(),
434
+ createdAt: z.string(),
435
+ expiresAt: z.union([z.string(), z.null()]),
436
+ createdBy: z.union([z.string(), z.null()])
437
+ }).strict()
438
+ },
439
+ {
440
+ method: "get",
441
+ path: "/files/:fileId/permalinks",
442
+ description: `Get all permalinks for a file.`,
443
+ requestFormat: "json",
444
+ parameters: [
445
+ {
446
+ name: "fileId",
447
+ type: "Path",
448
+ schema: z.string()
449
+ }
450
+ ],
451
+ response: z.array(
452
+ z.object({
453
+ id: z.string(),
454
+ fileId: z.string(),
455
+ workspaceId: z.string(),
456
+ createdAt: z.string(),
457
+ expiresAt: z.union([z.string(), z.null()]),
458
+ createdBy: z.union([z.string(), z.null()])
459
+ }).strict()
460
+ )
461
+ },
462
+ {
463
+ method: "post",
464
+ path: "/files/:filename",
465
+ description: `Create a file and get a pre-signed upload URL.
466
+
467
+ The `sha256` body param is used as the file's primary key. If not provided, a random UUID will be generated.
468
+
469
+ The `filename` parameter is deprecated. Use the `originalFileName` parameter in the request body instead. Either way, the information about the file name is stored in the `metadata.originalFileName` field.
470
+
471
+ The returned `uploadUrl` is valid for 1 hour by default. You can change the expiration time by passing the `expiresIn` query parameter.
472
+ `,
473
+ requestFormat: "json",
474
+ parameters: [
475
+ {
476
+ name: "body",
477
+ type: "Body",
478
+ schema: postFilesByFilename_Body
479
+ },
480
+ {
481
+ name: "expiresIn",
482
+ type: "Query",
483
+ schema: z.number().optional().default(3600)
484
+ },
485
+ {
486
+ name: "filename",
487
+ type: "Path",
488
+ schema: z.string()
489
+ }
490
+ ],
491
+ response: z.union([
492
+ z.object({
493
+ id: z.string(),
494
+ uploadUrl: z.string(),
495
+ expiresAt: z.string().datetime({ offset: true }),
496
+ metadata: z.object({
497
+ id: z.string(),
498
+ path: z.string(),
499
+ workspaceId: z.string(),
500
+ originalFileName: z.union([z.string(), z.null()]).optional(),
501
+ mimeType: z.union([z.string(), z.null()]).optional(),
502
+ size: z.union([z.number(), z.null()]).optional(),
503
+ legacyKey: z.union([z.string(), z.null()]).optional(),
504
+ bucketName: z.union([z.string(), z.null()]).optional(),
505
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
506
+ createdBy: z.union([z.string(), z.null()]).optional(),
507
+ createdAt: z.string(),
508
+ deletedAt: z.union([z.string(), z.null()]).optional()
509
+ }).strict()
510
+ }).strict(),
511
+ z.object({
512
+ url: z.string(),
513
+ expiresAt: z.string().datetime({ offset: true })
514
+ }).strict()
515
+ ])
516
+ },
517
+ {
518
+ method: "put",
519
+ path: "/files/:id",
520
+ description: `Create a file and get a pre-signed upload URL.`,
521
+ requestFormat: "json",
522
+ parameters: [
523
+ {
524
+ name: "expiresIn",
525
+ type: "Query",
526
+ schema: z.number().optional().default(3600)
527
+ },
528
+ {
529
+ name: "id",
530
+ type: "Path",
531
+ schema: z.string()
532
+ }
533
+ ],
534
+ response: z.union([
535
+ z.object({
536
+ id: z.string(),
537
+ uploadUrl: z.string().url(),
538
+ expiresAt: z.string().datetime({ offset: true }),
539
+ metadata: z.object({
540
+ id: z.string(),
541
+ path: z.string(),
542
+ workspaceId: z.string(),
543
+ originalFileName: z.union([z.string(), z.null()]).optional(),
544
+ mimeType: z.union([z.string(), z.null()]).optional(),
545
+ size: z.union([z.number(), z.null()]).optional(),
546
+ legacyKey: z.union([z.string(), z.null()]).optional(),
547
+ bucketName: z.union([z.string(), z.null()]).optional(),
548
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
549
+ createdBy: z.union([z.string(), z.null()]).optional(),
550
+ createdAt: z.string(),
551
+ deletedAt: z.union([z.string(), z.null()]).optional()
552
+ }).strict()
553
+ }).strict(),
554
+ z.object({
555
+ url: z.string().url(),
556
+ expiresAt: z.string().datetime({ offset: true })
557
+ }).strict()
558
+ ])
559
+ },
560
+ {
561
+ method: "delete",
562
+ path: "/files/:id",
563
+ description: `Delete a file.`,
564
+ requestFormat: "json",
565
+ parameters: [
566
+ {
567
+ name: "id",
568
+ type: "Path",
569
+ schema: z.string()
570
+ }
571
+ ],
572
+ response: z.void()
573
+ },
574
+ {
575
+ method: "get",
576
+ path: "/files/:id/metadata",
577
+ description: `Get the metadata for a file.`,
578
+ requestFormat: "json",
579
+ parameters: [
580
+ {
581
+ name: "id",
582
+ type: "Path",
583
+ schema: z.string()
584
+ }
585
+ ],
586
+ response: z.object({
587
+ id: z.string(),
588
+ path: z.string(),
589
+ workspaceId: z.string(),
590
+ originalFileName: z.union([z.string(), z.null()]).optional(),
591
+ mimeType: z.union([z.string(), z.null()]).optional(),
592
+ size: z.union([z.number(), z.null()]).optional(),
593
+ legacyKey: z.union([z.string(), z.null()]).optional(),
594
+ bucketName: z.union([z.string(), z.null()]).optional(),
595
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
596
+ createdBy: z.union([z.string(), z.null()]).optional(),
597
+ createdAt: z.string(),
598
+ deletedAt: z.union([z.string(), z.null()]).optional()
599
+ }).strict(),
600
+ errors: [
601
+ {
602
+ status: 404,
603
+ description: `File not found`,
604
+ schema: z.void()
605
+ }
606
+ ]
607
+ },
608
+ {
609
+ method: "post",
610
+ path: "/files/bulk",
611
+ description: `Create multiple files in bulk and get pre-signed upload URLs.`,
612
+ requestFormat: "json",
613
+ parameters: [
614
+ {
615
+ name: "body",
616
+ type: "Body",
617
+ schema: postFilesBulk_Body
618
+ }
619
+ ],
620
+ response: z.union([
621
+ z.array(
622
+ z.object({
623
+ id: z.string(),
624
+ path: z.string(),
625
+ workspaceId: z.string(),
626
+ originalFileName: z.union([z.string(), z.null()]).optional(),
627
+ mimeType: z.union([z.string(), z.null()]).optional(),
628
+ size: z.union([z.number(), z.null()]).optional(),
629
+ legacyKey: z.union([z.string(), z.null()]).optional(),
630
+ bucketName: z.union([z.string(), z.null()]).optional(),
631
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
632
+ createdBy: z.union([z.string(), z.null()]).optional(),
633
+ createdAt: z.string(),
634
+ deletedAt: z.union([z.string(), z.null()]).optional()
635
+ }).strict()
636
+ ),
637
+ z.object({
638
+ files: z.array(
639
+ z.object({
640
+ id: z.string(),
641
+ path: z.string(),
642
+ workspaceId: z.string(),
643
+ originalFileName: z.union([z.string(), z.null()]).optional(),
644
+ mimeType: z.union([z.string(), z.null()]).optional(),
645
+ size: z.union([z.number(), z.null()]).optional(),
646
+ legacyKey: z.union([z.string(), z.null()]).optional(),
647
+ bucketName: z.union([z.string(), z.null()]).optional(),
648
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
649
+ createdBy: z.union([z.string(), z.null()]).optional(),
650
+ createdAt: z.string(),
651
+ deletedAt: z.union([z.string(), z.null()]).optional()
652
+ }).strict()
653
+ )
654
+ }).strict()
655
+ ])
656
+ },
657
+ {
658
+ method: "get",
659
+ path: "/permalinks/:permalinkId",
660
+ description: `Download a file via a permalink.
661
+
662
+ Make sure to follow redirects to the actual file download URL.
663
+ `,
664
+ requestFormat: "json",
665
+ parameters: [
666
+ {
667
+ name: "permalinkId",
668
+ type: "Path",
669
+ schema: z.string()
670
+ }
671
+ ],
672
+ response: z.void(),
673
+ errors: [
674
+ {
675
+ status: 302,
676
+ description: `Redirect to the file download URL`,
677
+ schema: z.void()
678
+ },
679
+ {
680
+ status: 404,
681
+ description: `Permalink not found`,
682
+ schema: z.void()
683
+ }
684
+ ]
685
+ },
686
+ {
687
+ method: "delete",
688
+ path: "/permalinks/:permalinkId",
689
+ description: `Delete a permalink.`,
690
+ requestFormat: "json",
691
+ parameters: [
692
+ {
693
+ name: "permalinkId",
694
+ type: "Path",
695
+ schema: z.string()
696
+ }
697
+ ],
698
+ response: z.void()
699
+ },
700
+ {
701
+ method: "get",
702
+ path: "/permalinks/:permalinkId/metadata",
703
+ description: `Get the metadata for a permalink.`,
704
+ requestFormat: "json",
705
+ parameters: [
706
+ {
707
+ name: "permalinkId",
708
+ type: "Path",
709
+ schema: z.string()
710
+ }
711
+ ],
712
+ response: z.object({
713
+ id: z.string(),
714
+ fileId: z.string(),
715
+ workspaceId: z.string(),
716
+ createdAt: z.string(),
717
+ expiresAt: z.union([z.string(), z.null()]),
718
+ createdBy: z.union([z.string(), z.null()])
719
+ }).strict(),
720
+ errors: [
721
+ {
722
+ status: 404,
723
+ description: `Permalink not found`,
724
+ schema: z.void()
725
+ }
726
+ ]
727
+ },
728
+ {
729
+ method: "get",
730
+ path: "/v2/files/:fileId",
731
+ description: `Get a pre-signed download URL for a file.`,
732
+ requestFormat: "json",
733
+ parameters: [
734
+ {
735
+ name: "fileId",
736
+ type: "Path",
737
+ schema: z.string()
738
+ }
739
+ ],
740
+ response: z.object({
741
+ url: z.string(),
742
+ expiresAt: z.string().datetime({ offset: true }),
743
+ metadata: z.union([
744
+ z.object({
745
+ id: z.string(),
746
+ path: z.string(),
747
+ workspaceId: z.string(),
748
+ originalFileName: z.union([z.string(), z.null()]).optional(),
749
+ mimeType: z.union([z.string(), z.null()]).optional(),
750
+ size: z.union([z.number(), z.null()]).optional(),
751
+ legacyKey: z.union([z.string(), z.null()]).optional(),
752
+ bucketName: z.union([z.string(), z.null()]).optional(),
753
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
754
+ createdBy: z.union([z.string(), z.null()]).optional(),
755
+ createdAt: z.string(),
756
+ deletedAt: z.union([z.string(), z.null()]).optional()
757
+ }).strict(),
758
+ z.null()
759
+ ])
760
+ }).strict(),
761
+ errors: [
762
+ {
763
+ status: 404,
764
+ description: `File not found`,
765
+ schema: z.void()
766
+ }
767
+ ]
768
+ },
769
+ {
770
+ method: "post",
771
+ path: "/v2/files/:filename",
772
+ description: `Create a file and get a pre-signed upload URL.
773
+
774
+ The `sha256` body param is used as the file's primary key. If not provided, a random UUID will be generated.
775
+
776
+ The `filename` parameter is deprecated. Use the `originalFileName` parameter in the request body instead. Either way, the information about the file name is stored in the `metadata.originalFileName` field.
777
+
778
+ The returned `uploadUrl` is valid for 1 hour by default. You can change the expiration time by passing the `expiresIn` query parameter.
779
+ `,
780
+ requestFormat: "json",
781
+ parameters: [
782
+ {
783
+ name: "body",
784
+ type: "Body",
785
+ schema: postFilesByFilename_Body
786
+ },
787
+ {
788
+ name: "expiresIn",
789
+ type: "Query",
790
+ schema: z.number().optional().default(3600)
791
+ },
792
+ {
793
+ name: "filename",
794
+ type: "Path",
795
+ schema: z.string()
796
+ }
797
+ ],
798
+ response: z.union([
799
+ z.object({
800
+ id: z.string(),
801
+ uploadUrl: z.string(),
802
+ expiresAt: z.string().datetime({ offset: true }),
803
+ metadata: z.object({
804
+ id: z.string(),
805
+ path: z.string(),
806
+ workspaceId: z.string(),
807
+ originalFileName: z.union([z.string(), z.null()]).optional(),
808
+ mimeType: z.union([z.string(), z.null()]).optional(),
809
+ size: z.union([z.number(), z.null()]).optional(),
810
+ legacyKey: z.union([z.string(), z.null()]).optional(),
811
+ bucketName: z.union([z.string(), z.null()]).optional(),
812
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
813
+ createdBy: z.union([z.string(), z.null()]).optional(),
814
+ createdAt: z.string(),
815
+ deletedAt: z.union([z.string(), z.null()]).optional()
816
+ }).strict()
817
+ }).strict(),
818
+ z.object({
819
+ url: z.string(),
820
+ expiresAt: z.string().datetime({ offset: true })
821
+ }).strict()
822
+ ])
823
+ },
824
+ {
825
+ method: "put",
826
+ path: "/v2/files/:id",
827
+ description: `Create a file and get a pre-signed upload URL.`,
828
+ requestFormat: "json",
829
+ parameters: [
830
+ {
831
+ name: "expiresIn",
832
+ type: "Query",
833
+ schema: z.number().optional().default(3600)
834
+ },
835
+ {
836
+ name: "id",
837
+ type: "Path",
838
+ schema: z.string()
839
+ }
840
+ ],
841
+ response: z.union([
842
+ z.object({
843
+ id: z.string(),
844
+ uploadUrl: z.string().url(),
845
+ expiresAt: z.string().datetime({ offset: true }),
846
+ metadata: z.object({
847
+ id: z.string(),
848
+ path: z.string(),
849
+ workspaceId: z.string(),
850
+ originalFileName: z.union([z.string(), z.null()]).optional(),
851
+ mimeType: z.union([z.string(), z.null()]).optional(),
852
+ size: z.union([z.number(), z.null()]).optional(),
853
+ legacyKey: z.union([z.string(), z.null()]).optional(),
854
+ bucketName: z.union([z.string(), z.null()]).optional(),
855
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
856
+ createdBy: z.union([z.string(), z.null()]).optional(),
857
+ createdAt: z.string(),
858
+ deletedAt: z.union([z.string(), z.null()]).optional()
859
+ }).strict()
860
+ }).strict(),
861
+ z.object({
862
+ url: z.string().url(),
863
+ expiresAt: z.string().datetime({ offset: true })
864
+ }).strict()
865
+ ])
866
+ },
867
+ {
868
+ method: "delete",
869
+ path: "/v2/files/:id",
870
+ description: `Delete a file.`,
871
+ requestFormat: "json",
872
+ parameters: [
873
+ {
874
+ name: "id",
875
+ type: "Path",
876
+ schema: z.string()
877
+ }
878
+ ],
879
+ response: z.void()
880
+ },
881
+ {
882
+ method: "get",
883
+ path: "/v2/files/:id/metadata",
884
+ description: `Get the metadata for a file.`,
885
+ requestFormat: "json",
886
+ parameters: [
887
+ {
888
+ name: "id",
889
+ type: "Path",
890
+ schema: z.string()
891
+ }
892
+ ],
893
+ response: z.object({
894
+ id: z.string(),
895
+ path: z.string(),
896
+ workspaceId: z.string(),
897
+ originalFileName: z.union([z.string(), z.null()]).optional(),
898
+ mimeType: z.union([z.string(), z.null()]).optional(),
899
+ size: z.union([z.number(), z.null()]).optional(),
900
+ legacyKey: z.union([z.string(), z.null()]).optional(),
901
+ bucketName: z.union([z.string(), z.null()]).optional(),
902
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
903
+ createdBy: z.union([z.string(), z.null()]).optional(),
904
+ createdAt: z.string(),
905
+ deletedAt: z.union([z.string(), z.null()]).optional()
906
+ }).strict(),
907
+ errors: [
908
+ {
909
+ status: 404,
910
+ description: `File not found`,
911
+ schema: z.void()
912
+ }
913
+ ]
914
+ },
915
+ {
916
+ method: "post",
917
+ path: "/v2/files/bulk",
918
+ description: `Create multiple files in bulk and get pre-signed upload URLs.`,
919
+ requestFormat: "json",
920
+ parameters: [
921
+ {
922
+ name: "body",
923
+ type: "Body",
924
+ schema: postFilesBulk_Body
925
+ }
926
+ ],
927
+ response: z.union([
928
+ z.array(
929
+ z.object({
930
+ id: z.string(),
931
+ path: z.string(),
932
+ workspaceId: z.string(),
933
+ originalFileName: z.union([z.string(), z.null()]).optional(),
934
+ mimeType: z.union([z.string(), z.null()]).optional(),
935
+ size: z.union([z.number(), z.null()]).optional(),
936
+ legacyKey: z.union([z.string(), z.null()]).optional(),
937
+ bucketName: z.union([z.string(), z.null()]).optional(),
938
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
939
+ createdBy: z.union([z.string(), z.null()]).optional(),
940
+ createdAt: z.string(),
941
+ deletedAt: z.union([z.string(), z.null()]).optional()
942
+ }).strict()
943
+ ),
944
+ z.object({
945
+ files: z.array(
946
+ z.object({
947
+ id: z.string(),
948
+ path: z.string(),
949
+ workspaceId: z.string(),
950
+ originalFileName: z.union([z.string(), z.null()]).optional(),
951
+ mimeType: z.union([z.string(), z.null()]).optional(),
952
+ size: z.union([z.number(), z.null()]).optional(),
953
+ legacyKey: z.union([z.string(), z.null()]).optional(),
954
+ bucketName: z.union([z.string(), z.null()]).optional(),
955
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
956
+ createdBy: z.union([z.string(), z.null()]).optional(),
957
+ createdAt: z.string(),
958
+ deletedAt: z.union([z.string(), z.null()]).optional()
959
+ }).strict()
960
+ )
961
+ }).strict()
962
+ ])
963
+ }
964
+ ]);
965
+ new Zodios(endpoints);
966
+ function createApiClient(baseUrl, options) {
967
+ return new Zodios(baseUrl, endpoints, options);
968
+ }
969
+
970
+ function useVaultClient(vaultUrl, token) {
971
+ const api = createApiClient(vaultUrl, {
972
+ axiosConfig: {
973
+ headers: {
974
+ Authorization: token
975
+ }
976
+ }
977
+ });
978
+ return api;
979
+ }
980
+
981
+ export { createApiClient, useVaultClient };