@contractspec/lib.files 1.56.1 → 1.58.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/contracts/index.d.ts +1080 -1086
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +575 -854
- package/dist/docs/files.docblock.d.ts +2 -1
- package/dist/docs/files.docblock.d.ts.map +1 -0
- package/dist/docs/files.docblock.js +17 -22
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +66 -1
- package/dist/entities/index.d.ts +134 -139
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +228 -257
- package/dist/events.d.ts +357 -363
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +217 -400
- package/dist/files.capability.d.ts +2 -7
- package/dist/files.capability.d.ts.map +1 -1
- package/dist/files.capability.js +29 -25
- package/dist/files.feature.d.ts +1 -7
- package/dist/files.feature.d.ts.map +1 -1
- package/dist/files.feature.js +50 -131
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1411 -8
- package/dist/node/contracts/index.js +576 -0
- package/dist/node/docs/files.docblock.js +65 -0
- package/dist/node/docs/index.js +65 -0
- package/dist/node/entities/index.js +235 -0
- package/dist/node/events.js +219 -0
- package/dist/node/files.capability.js +28 -0
- package/dist/node/files.feature.js +51 -0
- package/dist/node/index.js +1410 -0
- package/dist/node/storage/index.js +268 -0
- package/dist/storage/index.d.ts +163 -166
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +266 -266
- package/package.json +104 -30
- package/dist/contracts/index.js.map +0 -1
- package/dist/docs/files.docblock.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/files.capability.js.map +0 -1
- package/dist/files.feature.js.map +0 -1
- package/dist/storage/index.js.map +0 -1
package/dist/contracts/index.js
CHANGED
|
@@ -1,856 +1,577 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/contracts/index.ts
|
|
1
3
|
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
2
4
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
goal: "Remove a file and all its versions and attachments.",
|
|
577
|
-
context: "Called when removing a file permanently."
|
|
578
|
-
},
|
|
579
|
-
io: {
|
|
580
|
-
input: DeleteFileInput,
|
|
581
|
-
output: SuccessOutput,
|
|
582
|
-
errors: { FILE_NOT_FOUND: {
|
|
583
|
-
description: "File does not exist",
|
|
584
|
-
http: 404,
|
|
585
|
-
gqlCode: "FILE_NOT_FOUND",
|
|
586
|
-
when: "File ID is invalid"
|
|
587
|
-
} }
|
|
588
|
-
},
|
|
589
|
-
policy: { auth: "user" }
|
|
590
|
-
});
|
|
591
|
-
/**
|
|
592
|
-
* Get a file by ID.
|
|
593
|
-
*/
|
|
594
|
-
const GetFileContract = defineQuery({
|
|
595
|
-
meta: {
|
|
596
|
-
key: "file.get",
|
|
597
|
-
version: "1.0.0",
|
|
598
|
-
stability: "stable",
|
|
599
|
-
owners: [...OWNERS],
|
|
600
|
-
tags: ["files", "get"],
|
|
601
|
-
description: "Get a file by ID.",
|
|
602
|
-
goal: "Retrieve file metadata.",
|
|
603
|
-
context: "Called to inspect file details."
|
|
604
|
-
},
|
|
605
|
-
io: {
|
|
606
|
-
input: GetFileInput,
|
|
607
|
-
output: FileModel,
|
|
608
|
-
errors: { FILE_NOT_FOUND: {
|
|
609
|
-
description: "File does not exist",
|
|
610
|
-
http: 404,
|
|
611
|
-
gqlCode: "FILE_NOT_FOUND",
|
|
612
|
-
when: "File ID is invalid"
|
|
613
|
-
} }
|
|
614
|
-
},
|
|
615
|
-
policy: { auth: "user" }
|
|
616
|
-
});
|
|
617
|
-
/**
|
|
618
|
-
* List files.
|
|
619
|
-
*/
|
|
620
|
-
const ListFilesContract = defineQuery({
|
|
621
|
-
meta: {
|
|
622
|
-
key: "file.list",
|
|
623
|
-
version: "1.0.0",
|
|
624
|
-
stability: "stable",
|
|
625
|
-
owners: [...OWNERS],
|
|
626
|
-
tags: ["files", "list"],
|
|
627
|
-
description: "List files with filtering.",
|
|
628
|
-
goal: "Browse uploaded files.",
|
|
629
|
-
context: "Called to browse file library."
|
|
630
|
-
},
|
|
631
|
-
io: {
|
|
632
|
-
input: ListFilesInput,
|
|
633
|
-
output: ListFilesOutput
|
|
634
|
-
},
|
|
635
|
-
policy: { auth: "user" }
|
|
636
|
-
});
|
|
637
|
-
/**
|
|
638
|
-
* Get download URL.
|
|
639
|
-
*/
|
|
640
|
-
const GetDownloadUrlContract = defineQuery({
|
|
641
|
-
meta: {
|
|
642
|
-
key: "file.downloadUrl",
|
|
643
|
-
version: "1.0.0",
|
|
644
|
-
stability: "stable",
|
|
645
|
-
owners: [...OWNERS],
|
|
646
|
-
tags: ["files", "download"],
|
|
647
|
-
description: "Get a presigned download URL.",
|
|
648
|
-
goal: "Generate a temporary URL for downloading.",
|
|
649
|
-
context: "Called when user wants to download a file."
|
|
650
|
-
},
|
|
651
|
-
io: {
|
|
652
|
-
input: GetDownloadUrlInput,
|
|
653
|
-
output: PresignedUrlModel,
|
|
654
|
-
errors: { FILE_NOT_FOUND: {
|
|
655
|
-
description: "File does not exist",
|
|
656
|
-
http: 404,
|
|
657
|
-
gqlCode: "FILE_NOT_FOUND",
|
|
658
|
-
when: "File ID is invalid"
|
|
659
|
-
} }
|
|
660
|
-
},
|
|
661
|
-
policy: { auth: "user" }
|
|
662
|
-
});
|
|
663
|
-
/**
|
|
664
|
-
* Create a file version.
|
|
665
|
-
*/
|
|
666
|
-
const CreateVersionContract = defineCommand({
|
|
667
|
-
meta: {
|
|
668
|
-
key: "file.version.create",
|
|
669
|
-
version: "1.0.0",
|
|
670
|
-
stability: "stable",
|
|
671
|
-
owners: [...OWNERS],
|
|
672
|
-
tags: [
|
|
673
|
-
"files",
|
|
674
|
-
"version",
|
|
675
|
-
"create"
|
|
676
|
-
],
|
|
677
|
-
description: "Create a new version of a file.",
|
|
678
|
-
goal: "Upload a new version while preserving history.",
|
|
679
|
-
context: "Called when updating a document."
|
|
680
|
-
},
|
|
681
|
-
io: {
|
|
682
|
-
input: CreateVersionInput,
|
|
683
|
-
output: FileVersionModel,
|
|
684
|
-
errors: { FILE_NOT_FOUND: {
|
|
685
|
-
description: "File does not exist",
|
|
686
|
-
http: 404,
|
|
687
|
-
gqlCode: "FILE_NOT_FOUND",
|
|
688
|
-
when: "File ID is invalid"
|
|
689
|
-
} }
|
|
690
|
-
},
|
|
691
|
-
policy: { auth: "user" }
|
|
692
|
-
});
|
|
693
|
-
/**
|
|
694
|
-
* Get file versions.
|
|
695
|
-
*/
|
|
696
|
-
const GetVersionsContract = defineQuery({
|
|
697
|
-
meta: {
|
|
698
|
-
key: "file.version.list",
|
|
699
|
-
version: "1.0.0",
|
|
700
|
-
stability: "stable",
|
|
701
|
-
owners: [...OWNERS],
|
|
702
|
-
tags: [
|
|
703
|
-
"files",
|
|
704
|
-
"version",
|
|
705
|
-
"list"
|
|
706
|
-
],
|
|
707
|
-
description: "Get file version history.",
|
|
708
|
-
goal: "View all versions of a file.",
|
|
709
|
-
context: "Called to browse file history."
|
|
710
|
-
},
|
|
711
|
-
io: {
|
|
712
|
-
input: GetVersionsInput,
|
|
713
|
-
output: GetVersionsOutput,
|
|
714
|
-
errors: { FILE_NOT_FOUND: {
|
|
715
|
-
description: "File does not exist",
|
|
716
|
-
http: 404,
|
|
717
|
-
gqlCode: "FILE_NOT_FOUND",
|
|
718
|
-
when: "File ID is invalid"
|
|
719
|
-
} }
|
|
720
|
-
},
|
|
721
|
-
policy: { auth: "user" }
|
|
722
|
-
});
|
|
723
|
-
/**
|
|
724
|
-
* Attach a file to an entity.
|
|
725
|
-
*/
|
|
726
|
-
const AttachFileContract = defineCommand({
|
|
727
|
-
meta: {
|
|
728
|
-
key: "attachment.attach",
|
|
729
|
-
version: "1.0.0",
|
|
730
|
-
stability: "stable",
|
|
731
|
-
owners: [...OWNERS],
|
|
732
|
-
tags: [
|
|
733
|
-
"files",
|
|
734
|
-
"attachment",
|
|
735
|
-
"attach"
|
|
736
|
-
],
|
|
737
|
-
description: "Attach a file to an entity.",
|
|
738
|
-
goal: "Link a file to a business entity.",
|
|
739
|
-
context: "Called when associating files with entities."
|
|
740
|
-
},
|
|
741
|
-
io: {
|
|
742
|
-
input: AttachFileInput,
|
|
743
|
-
output: AttachmentModel,
|
|
744
|
-
errors: {
|
|
745
|
-
FILE_NOT_FOUND: {
|
|
746
|
-
description: "File does not exist",
|
|
747
|
-
http: 404,
|
|
748
|
-
gqlCode: "FILE_NOT_FOUND",
|
|
749
|
-
when: "File ID is invalid"
|
|
750
|
-
},
|
|
751
|
-
ATTACHMENT_EXISTS: {
|
|
752
|
-
description: "Attachment already exists",
|
|
753
|
-
http: 409,
|
|
754
|
-
gqlCode: "ATTACHMENT_EXISTS",
|
|
755
|
-
when: "File is already attached to this entity"
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
},
|
|
759
|
-
policy: { auth: "user" }
|
|
760
|
-
});
|
|
761
|
-
/**
|
|
762
|
-
* Detach a file from an entity.
|
|
763
|
-
*/
|
|
764
|
-
const DetachFileContract = defineCommand({
|
|
765
|
-
meta: {
|
|
766
|
-
key: "attachment.detach",
|
|
767
|
-
version: "1.0.0",
|
|
768
|
-
stability: "stable",
|
|
769
|
-
owners: [...OWNERS],
|
|
770
|
-
tags: [
|
|
771
|
-
"files",
|
|
772
|
-
"attachment",
|
|
773
|
-
"detach"
|
|
774
|
-
],
|
|
775
|
-
description: "Detach a file from an entity.",
|
|
776
|
-
goal: "Remove a file association.",
|
|
777
|
-
context: "Called when removing file from entity."
|
|
778
|
-
},
|
|
779
|
-
io: {
|
|
780
|
-
input: DetachFileInput,
|
|
781
|
-
output: SuccessOutput,
|
|
782
|
-
errors: { ATTACHMENT_NOT_FOUND: {
|
|
783
|
-
description: "Attachment does not exist",
|
|
784
|
-
http: 404,
|
|
785
|
-
gqlCode: "ATTACHMENT_NOT_FOUND",
|
|
786
|
-
when: "Attachment ID is invalid"
|
|
787
|
-
} }
|
|
788
|
-
},
|
|
789
|
-
policy: { auth: "user" }
|
|
790
|
-
});
|
|
791
|
-
/**
|
|
792
|
-
* List attachments for an entity.
|
|
793
|
-
*/
|
|
794
|
-
const ListAttachmentsContract = defineQuery({
|
|
795
|
-
meta: {
|
|
796
|
-
key: "attachment.list",
|
|
797
|
-
version: "1.0.0",
|
|
798
|
-
stability: "stable",
|
|
799
|
-
owners: [...OWNERS],
|
|
800
|
-
tags: [
|
|
801
|
-
"files",
|
|
802
|
-
"attachment",
|
|
803
|
-
"list"
|
|
804
|
-
],
|
|
805
|
-
description: "List attachments for an entity.",
|
|
806
|
-
goal: "Get all files attached to an entity.",
|
|
807
|
-
context: "Called to display attached files."
|
|
808
|
-
},
|
|
809
|
-
io: {
|
|
810
|
-
input: ListAttachmentsInput,
|
|
811
|
-
output: ListAttachmentsOutput
|
|
812
|
-
},
|
|
813
|
-
policy: { auth: "user" }
|
|
814
|
-
});
|
|
815
|
-
/**
|
|
816
|
-
* Create a presigned upload URL.
|
|
817
|
-
*/
|
|
818
|
-
const CreatePresignedUrlContract = defineCommand({
|
|
819
|
-
meta: {
|
|
820
|
-
key: "file.presignedUrl.create",
|
|
821
|
-
version: "1.0.0",
|
|
822
|
-
stability: "stable",
|
|
823
|
-
owners: [...OWNERS],
|
|
824
|
-
tags: [
|
|
825
|
-
"files",
|
|
826
|
-
"presigned",
|
|
827
|
-
"upload"
|
|
828
|
-
],
|
|
829
|
-
description: "Create a presigned URL for direct upload.",
|
|
830
|
-
goal: "Enable direct-to-storage uploads.",
|
|
831
|
-
context: "Called for large file uploads."
|
|
832
|
-
},
|
|
833
|
-
io: {
|
|
834
|
-
input: CreatePresignedUrlInput,
|
|
835
|
-
output: PresignedUrlModel,
|
|
836
|
-
errors: {
|
|
837
|
-
FILE_TOO_LARGE: {
|
|
838
|
-
description: "File exceeds size limit",
|
|
839
|
-
http: 413,
|
|
840
|
-
gqlCode: "FILE_TOO_LARGE",
|
|
841
|
-
when: "Requested file size exceeds limit"
|
|
842
|
-
},
|
|
843
|
-
INVALID_MIME_TYPE: {
|
|
844
|
-
description: "MIME type not allowed",
|
|
845
|
-
http: 415,
|
|
846
|
-
gqlCode: "INVALID_MIME_TYPE",
|
|
847
|
-
when: "File type is not in allowed list"
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
},
|
|
851
|
-
policy: { auth: "user" }
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
//#endregion
|
|
855
|
-
export { AttachFileContract, AttachmentModel, CreatePresignedUrlContract, CreateVersionContract, DeleteFileContract, DetachFileContract, FileModel, FileVersionModel, GetDownloadUrlContract, GetFileContract, GetVersionsContract, ListAttachmentsContract, ListFilesContract, PresignedUrlModel, UpdateFileContract, UploadFileContract };
|
|
856
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
var OWNERS = ["platform.files"];
|
|
6
|
+
var FileModel = defineSchemaModel({
|
|
7
|
+
name: "File",
|
|
8
|
+
description: "Represents an uploaded file",
|
|
9
|
+
fields: {
|
|
10
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
mimeType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
+
size: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
14
|
+
storageProvider: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false
|
|
17
|
+
},
|
|
18
|
+
storagePath: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
19
|
+
checksum: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
20
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
22
|
+
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
23
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
+
metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
25
|
+
width: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
26
|
+
height: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
27
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
28
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var FileVersionModel = defineSchemaModel({
|
|
32
|
+
name: "FileVersion",
|
|
33
|
+
description: "Represents a file version",
|
|
34
|
+
fields: {
|
|
35
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
36
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
37
|
+
version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
38
|
+
size: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
39
|
+
storagePath: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
40
|
+
checksum: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
41
|
+
comment: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
42
|
+
createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
43
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var AttachmentModel = defineSchemaModel({
|
|
47
|
+
name: "Attachment",
|
|
48
|
+
description: "Represents an attachment",
|
|
49
|
+
fields: {
|
|
50
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
51
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
52
|
+
entityType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
53
|
+
entityId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
54
|
+
attachmentType: {
|
|
55
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
56
|
+
isOptional: true
|
|
57
|
+
},
|
|
58
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
59
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
60
|
+
order: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
61
|
+
metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
62
|
+
createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
63
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
64
|
+
file: { type: FileModel, isOptional: true }
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
var PresignedUrlModel = defineSchemaModel({
|
|
68
|
+
name: "PresignedUrl",
|
|
69
|
+
description: "A presigned URL for file operations",
|
|
70
|
+
fields: {
|
|
71
|
+
url: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
72
|
+
fields: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
73
|
+
expiresAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
74
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
75
|
+
sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var UploadFileInput = defineSchemaModel({
|
|
79
|
+
name: "UploadFileInput",
|
|
80
|
+
description: "Input for uploading a file",
|
|
81
|
+
fields: {
|
|
82
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
83
|
+
mimeType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
84
|
+
size: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
85
|
+
content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
86
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
87
|
+
isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: true },
|
|
88
|
+
metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
89
|
+
tags: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var UpdateFileInput = defineSchemaModel({
|
|
93
|
+
name: "UpdateFileInput",
|
|
94
|
+
description: "Input for updating a file",
|
|
95
|
+
fields: {
|
|
96
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
97
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
98
|
+
isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: true },
|
|
99
|
+
metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
100
|
+
tags: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
var DeleteFileInput = defineSchemaModel({
|
|
104
|
+
name: "DeleteFileInput",
|
|
105
|
+
description: "Input for deleting a file",
|
|
106
|
+
fields: {
|
|
107
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
var GetFileInput = defineSchemaModel({
|
|
111
|
+
name: "GetFileInput",
|
|
112
|
+
description: "Input for getting a file",
|
|
113
|
+
fields: {
|
|
114
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
var ListFilesInput = defineSchemaModel({
|
|
118
|
+
name: "ListFilesInput",
|
|
119
|
+
description: "Input for listing files",
|
|
120
|
+
fields: {
|
|
121
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
122
|
+
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
123
|
+
mimeType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
124
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
125
|
+
tags: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
126
|
+
limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
127
|
+
offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
var ListFilesOutput = defineSchemaModel({
|
|
131
|
+
name: "ListFilesOutput",
|
|
132
|
+
description: "Output for listing files",
|
|
133
|
+
fields: {
|
|
134
|
+
files: { type: FileModel, isArray: true, isOptional: false },
|
|
135
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
var GetDownloadUrlInput = defineSchemaModel({
|
|
139
|
+
name: "GetDownloadUrlInput",
|
|
140
|
+
description: "Input for getting a download URL",
|
|
141
|
+
fields: {
|
|
142
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
143
|
+
expiresInSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
var CreateVersionInput = defineSchemaModel({
|
|
147
|
+
name: "CreateVersionInput",
|
|
148
|
+
description: "Input for creating a file version",
|
|
149
|
+
fields: {
|
|
150
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
151
|
+
content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
152
|
+
comment: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
var GetVersionsInput = defineSchemaModel({
|
|
156
|
+
name: "GetVersionsInput",
|
|
157
|
+
description: "Input for getting file versions",
|
|
158
|
+
fields: {
|
|
159
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
160
|
+
limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
161
|
+
offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
var GetVersionsOutput = defineSchemaModel({
|
|
165
|
+
name: "GetVersionsOutput",
|
|
166
|
+
description: "Output for getting file versions",
|
|
167
|
+
fields: {
|
|
168
|
+
versions: { type: FileVersionModel, isArray: true, isOptional: false },
|
|
169
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
var AttachFileInput = defineSchemaModel({
|
|
173
|
+
name: "AttachFileInput",
|
|
174
|
+
description: "Input for attaching a file to an entity",
|
|
175
|
+
fields: {
|
|
176
|
+
fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
177
|
+
entityType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
178
|
+
entityId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
179
|
+
attachmentType: {
|
|
180
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
181
|
+
isOptional: true
|
|
182
|
+
},
|
|
183
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
184
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
185
|
+
order: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
186
|
+
metadata: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
var DetachFileInput = defineSchemaModel({
|
|
190
|
+
name: "DetachFileInput",
|
|
191
|
+
description: "Input for detaching a file",
|
|
192
|
+
fields: {
|
|
193
|
+
attachmentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
var ListAttachmentsInput = defineSchemaModel({
|
|
197
|
+
name: "ListAttachmentsInput",
|
|
198
|
+
description: "Input for listing attachments",
|
|
199
|
+
fields: {
|
|
200
|
+
entityType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
201
|
+
entityId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
202
|
+
attachmentType: {
|
|
203
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
204
|
+
isOptional: true
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
var ListAttachmentsOutput = defineSchemaModel({
|
|
209
|
+
name: "ListAttachmentsOutput",
|
|
210
|
+
description: "Output for listing attachments",
|
|
211
|
+
fields: {
|
|
212
|
+
attachments: { type: AttachmentModel, isArray: true, isOptional: false },
|
|
213
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
var CreatePresignedUrlInput = defineSchemaModel({
|
|
217
|
+
name: "CreatePresignedUrlInput",
|
|
218
|
+
description: "Input for creating a presigned upload URL",
|
|
219
|
+
fields: {
|
|
220
|
+
fileName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
221
|
+
mimeType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
222
|
+
size: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
223
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
224
|
+
expiresInSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
var SuccessOutput = defineSchemaModel({
|
|
228
|
+
name: "SuccessOutput",
|
|
229
|
+
description: "Generic success output",
|
|
230
|
+
fields: {
|
|
231
|
+
success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
var UploadFileContract = defineCommand({
|
|
235
|
+
meta: {
|
|
236
|
+
key: "file.upload",
|
|
237
|
+
version: "1.0.0",
|
|
238
|
+
stability: "stable",
|
|
239
|
+
owners: [...OWNERS],
|
|
240
|
+
tags: ["files", "upload"],
|
|
241
|
+
description: "Upload a new file.",
|
|
242
|
+
goal: "Store a file and create a file record.",
|
|
243
|
+
context: "Called when uploading files directly."
|
|
244
|
+
},
|
|
245
|
+
io: {
|
|
246
|
+
input: UploadFileInput,
|
|
247
|
+
output: FileModel,
|
|
248
|
+
errors: {
|
|
249
|
+
FILE_TOO_LARGE: {
|
|
250
|
+
description: "File exceeds size limit",
|
|
251
|
+
http: 413,
|
|
252
|
+
gqlCode: "FILE_TOO_LARGE",
|
|
253
|
+
when: "File size exceeds configured limit"
|
|
254
|
+
},
|
|
255
|
+
INVALID_MIME_TYPE: {
|
|
256
|
+
description: "MIME type not allowed",
|
|
257
|
+
http: 415,
|
|
258
|
+
gqlCode: "INVALID_MIME_TYPE",
|
|
259
|
+
when: "File type is not in allowed list"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
policy: {
|
|
264
|
+
auth: "user"
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
var UpdateFileContract = defineCommand({
|
|
268
|
+
meta: {
|
|
269
|
+
key: "file.update",
|
|
270
|
+
version: "1.0.0",
|
|
271
|
+
stability: "stable",
|
|
272
|
+
owners: [...OWNERS],
|
|
273
|
+
tags: ["files", "update"],
|
|
274
|
+
description: "Update file metadata.",
|
|
275
|
+
goal: "Modify file properties without replacing content.",
|
|
276
|
+
context: "Called when renaming or updating file metadata."
|
|
277
|
+
},
|
|
278
|
+
io: {
|
|
279
|
+
input: UpdateFileInput,
|
|
280
|
+
output: FileModel,
|
|
281
|
+
errors: {
|
|
282
|
+
FILE_NOT_FOUND: {
|
|
283
|
+
description: "File does not exist",
|
|
284
|
+
http: 404,
|
|
285
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
286
|
+
when: "File ID is invalid"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
policy: {
|
|
291
|
+
auth: "user"
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
var DeleteFileContract = defineCommand({
|
|
295
|
+
meta: {
|
|
296
|
+
key: "file.delete",
|
|
297
|
+
version: "1.0.0",
|
|
298
|
+
stability: "stable",
|
|
299
|
+
owners: [...OWNERS],
|
|
300
|
+
tags: ["files", "delete"],
|
|
301
|
+
description: "Delete a file.",
|
|
302
|
+
goal: "Remove a file and all its versions and attachments.",
|
|
303
|
+
context: "Called when removing a file permanently."
|
|
304
|
+
},
|
|
305
|
+
io: {
|
|
306
|
+
input: DeleteFileInput,
|
|
307
|
+
output: SuccessOutput,
|
|
308
|
+
errors: {
|
|
309
|
+
FILE_NOT_FOUND: {
|
|
310
|
+
description: "File does not exist",
|
|
311
|
+
http: 404,
|
|
312
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
313
|
+
when: "File ID is invalid"
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
policy: {
|
|
318
|
+
auth: "user"
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
var GetFileContract = defineQuery({
|
|
322
|
+
meta: {
|
|
323
|
+
key: "file.get",
|
|
324
|
+
version: "1.0.0",
|
|
325
|
+
stability: "stable",
|
|
326
|
+
owners: [...OWNERS],
|
|
327
|
+
tags: ["files", "get"],
|
|
328
|
+
description: "Get a file by ID.",
|
|
329
|
+
goal: "Retrieve file metadata.",
|
|
330
|
+
context: "Called to inspect file details."
|
|
331
|
+
},
|
|
332
|
+
io: {
|
|
333
|
+
input: GetFileInput,
|
|
334
|
+
output: FileModel,
|
|
335
|
+
errors: {
|
|
336
|
+
FILE_NOT_FOUND: {
|
|
337
|
+
description: "File does not exist",
|
|
338
|
+
http: 404,
|
|
339
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
340
|
+
when: "File ID is invalid"
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
policy: {
|
|
345
|
+
auth: "user"
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
var ListFilesContract = defineQuery({
|
|
349
|
+
meta: {
|
|
350
|
+
key: "file.list",
|
|
351
|
+
version: "1.0.0",
|
|
352
|
+
stability: "stable",
|
|
353
|
+
owners: [...OWNERS],
|
|
354
|
+
tags: ["files", "list"],
|
|
355
|
+
description: "List files with filtering.",
|
|
356
|
+
goal: "Browse uploaded files.",
|
|
357
|
+
context: "Called to browse file library."
|
|
358
|
+
},
|
|
359
|
+
io: {
|
|
360
|
+
input: ListFilesInput,
|
|
361
|
+
output: ListFilesOutput
|
|
362
|
+
},
|
|
363
|
+
policy: {
|
|
364
|
+
auth: "user"
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
var GetDownloadUrlContract = defineQuery({
|
|
368
|
+
meta: {
|
|
369
|
+
key: "file.downloadUrl",
|
|
370
|
+
version: "1.0.0",
|
|
371
|
+
stability: "stable",
|
|
372
|
+
owners: [...OWNERS],
|
|
373
|
+
tags: ["files", "download"],
|
|
374
|
+
description: "Get a presigned download URL.",
|
|
375
|
+
goal: "Generate a temporary URL for downloading.",
|
|
376
|
+
context: "Called when user wants to download a file."
|
|
377
|
+
},
|
|
378
|
+
io: {
|
|
379
|
+
input: GetDownloadUrlInput,
|
|
380
|
+
output: PresignedUrlModel,
|
|
381
|
+
errors: {
|
|
382
|
+
FILE_NOT_FOUND: {
|
|
383
|
+
description: "File does not exist",
|
|
384
|
+
http: 404,
|
|
385
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
386
|
+
when: "File ID is invalid"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
policy: {
|
|
391
|
+
auth: "user"
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
var CreateVersionContract = defineCommand({
|
|
395
|
+
meta: {
|
|
396
|
+
key: "file.version.create",
|
|
397
|
+
version: "1.0.0",
|
|
398
|
+
stability: "stable",
|
|
399
|
+
owners: [...OWNERS],
|
|
400
|
+
tags: ["files", "version", "create"],
|
|
401
|
+
description: "Create a new version of a file.",
|
|
402
|
+
goal: "Upload a new version while preserving history.",
|
|
403
|
+
context: "Called when updating a document."
|
|
404
|
+
},
|
|
405
|
+
io: {
|
|
406
|
+
input: CreateVersionInput,
|
|
407
|
+
output: FileVersionModel,
|
|
408
|
+
errors: {
|
|
409
|
+
FILE_NOT_FOUND: {
|
|
410
|
+
description: "File does not exist",
|
|
411
|
+
http: 404,
|
|
412
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
413
|
+
when: "File ID is invalid"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
policy: {
|
|
418
|
+
auth: "user"
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
var GetVersionsContract = defineQuery({
|
|
422
|
+
meta: {
|
|
423
|
+
key: "file.version.list",
|
|
424
|
+
version: "1.0.0",
|
|
425
|
+
stability: "stable",
|
|
426
|
+
owners: [...OWNERS],
|
|
427
|
+
tags: ["files", "version", "list"],
|
|
428
|
+
description: "Get file version history.",
|
|
429
|
+
goal: "View all versions of a file.",
|
|
430
|
+
context: "Called to browse file history."
|
|
431
|
+
},
|
|
432
|
+
io: {
|
|
433
|
+
input: GetVersionsInput,
|
|
434
|
+
output: GetVersionsOutput,
|
|
435
|
+
errors: {
|
|
436
|
+
FILE_NOT_FOUND: {
|
|
437
|
+
description: "File does not exist",
|
|
438
|
+
http: 404,
|
|
439
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
440
|
+
when: "File ID is invalid"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
policy: {
|
|
445
|
+
auth: "user"
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
var AttachFileContract = defineCommand({
|
|
449
|
+
meta: {
|
|
450
|
+
key: "attachment.attach",
|
|
451
|
+
version: "1.0.0",
|
|
452
|
+
stability: "stable",
|
|
453
|
+
owners: [...OWNERS],
|
|
454
|
+
tags: ["files", "attachment", "attach"],
|
|
455
|
+
description: "Attach a file to an entity.",
|
|
456
|
+
goal: "Link a file to a business entity.",
|
|
457
|
+
context: "Called when associating files with entities."
|
|
458
|
+
},
|
|
459
|
+
io: {
|
|
460
|
+
input: AttachFileInput,
|
|
461
|
+
output: AttachmentModel,
|
|
462
|
+
errors: {
|
|
463
|
+
FILE_NOT_FOUND: {
|
|
464
|
+
description: "File does not exist",
|
|
465
|
+
http: 404,
|
|
466
|
+
gqlCode: "FILE_NOT_FOUND",
|
|
467
|
+
when: "File ID is invalid"
|
|
468
|
+
},
|
|
469
|
+
ATTACHMENT_EXISTS: {
|
|
470
|
+
description: "Attachment already exists",
|
|
471
|
+
http: 409,
|
|
472
|
+
gqlCode: "ATTACHMENT_EXISTS",
|
|
473
|
+
when: "File is already attached to this entity"
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
policy: {
|
|
478
|
+
auth: "user"
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
var DetachFileContract = defineCommand({
|
|
482
|
+
meta: {
|
|
483
|
+
key: "attachment.detach",
|
|
484
|
+
version: "1.0.0",
|
|
485
|
+
stability: "stable",
|
|
486
|
+
owners: [...OWNERS],
|
|
487
|
+
tags: ["files", "attachment", "detach"],
|
|
488
|
+
description: "Detach a file from an entity.",
|
|
489
|
+
goal: "Remove a file association.",
|
|
490
|
+
context: "Called when removing file from entity."
|
|
491
|
+
},
|
|
492
|
+
io: {
|
|
493
|
+
input: DetachFileInput,
|
|
494
|
+
output: SuccessOutput,
|
|
495
|
+
errors: {
|
|
496
|
+
ATTACHMENT_NOT_FOUND: {
|
|
497
|
+
description: "Attachment does not exist",
|
|
498
|
+
http: 404,
|
|
499
|
+
gqlCode: "ATTACHMENT_NOT_FOUND",
|
|
500
|
+
when: "Attachment ID is invalid"
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
policy: {
|
|
505
|
+
auth: "user"
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
var ListAttachmentsContract = defineQuery({
|
|
509
|
+
meta: {
|
|
510
|
+
key: "attachment.list",
|
|
511
|
+
version: "1.0.0",
|
|
512
|
+
stability: "stable",
|
|
513
|
+
owners: [...OWNERS],
|
|
514
|
+
tags: ["files", "attachment", "list"],
|
|
515
|
+
description: "List attachments for an entity.",
|
|
516
|
+
goal: "Get all files attached to an entity.",
|
|
517
|
+
context: "Called to display attached files."
|
|
518
|
+
},
|
|
519
|
+
io: {
|
|
520
|
+
input: ListAttachmentsInput,
|
|
521
|
+
output: ListAttachmentsOutput
|
|
522
|
+
},
|
|
523
|
+
policy: {
|
|
524
|
+
auth: "user"
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
var CreatePresignedUrlContract = defineCommand({
|
|
528
|
+
meta: {
|
|
529
|
+
key: "file.presignedUrl.create",
|
|
530
|
+
version: "1.0.0",
|
|
531
|
+
stability: "stable",
|
|
532
|
+
owners: [...OWNERS],
|
|
533
|
+
tags: ["files", "presigned", "upload"],
|
|
534
|
+
description: "Create a presigned URL for direct upload.",
|
|
535
|
+
goal: "Enable direct-to-storage uploads.",
|
|
536
|
+
context: "Called for large file uploads."
|
|
537
|
+
},
|
|
538
|
+
io: {
|
|
539
|
+
input: CreatePresignedUrlInput,
|
|
540
|
+
output: PresignedUrlModel,
|
|
541
|
+
errors: {
|
|
542
|
+
FILE_TOO_LARGE: {
|
|
543
|
+
description: "File exceeds size limit",
|
|
544
|
+
http: 413,
|
|
545
|
+
gqlCode: "FILE_TOO_LARGE",
|
|
546
|
+
when: "Requested file size exceeds limit"
|
|
547
|
+
},
|
|
548
|
+
INVALID_MIME_TYPE: {
|
|
549
|
+
description: "MIME type not allowed",
|
|
550
|
+
http: 415,
|
|
551
|
+
gqlCode: "INVALID_MIME_TYPE",
|
|
552
|
+
when: "File type is not in allowed list"
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
policy: {
|
|
557
|
+
auth: "user"
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
export {
|
|
561
|
+
UploadFileContract,
|
|
562
|
+
UpdateFileContract,
|
|
563
|
+
PresignedUrlModel,
|
|
564
|
+
ListFilesContract,
|
|
565
|
+
ListAttachmentsContract,
|
|
566
|
+
GetVersionsContract,
|
|
567
|
+
GetFileContract,
|
|
568
|
+
GetDownloadUrlContract,
|
|
569
|
+
FileVersionModel,
|
|
570
|
+
FileModel,
|
|
571
|
+
DetachFileContract,
|
|
572
|
+
DeleteFileContract,
|
|
573
|
+
CreateVersionContract,
|
|
574
|
+
CreatePresignedUrlContract,
|
|
575
|
+
AttachmentModel,
|
|
576
|
+
AttachFileContract
|
|
577
|
+
};
|