@mdbase-dev/connect-protocol 0.1.0-beta.21 → 0.1.0-beta.23

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.
@@ -0,0 +1,502 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mdbase.dev/connect/schemas/files.v1.json",
4
+ "title": "mdbase connect collection file protocol 1",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/applicationFileRequirement" },
7
+ { "$ref": "#/$defs/selectiveSyncPolicy" },
8
+ { "$ref": "#/$defs/fileCapability" },
9
+ { "$ref": "#/$defs/fileDescriptor" },
10
+ { "$ref": "#/$defs/listFilesRequest" },
11
+ { "$ref": "#/$defs/listFilesPage" },
12
+ { "$ref": "#/$defs/openUploadRequest" },
13
+ { "$ref": "#/$defs/openDownloadRequest" },
14
+ { "$ref": "#/$defs/moveFileRequest" },
15
+ { "$ref": "#/$defs/moveFileReceipt" },
16
+ { "$ref": "#/$defs/deleteFileRequest" },
17
+ { "$ref": "#/$defs/deleteFileReceipt" },
18
+ { "$ref": "#/$defs/transferSession" },
19
+ { "$ref": "#/$defs/transferStatus" },
20
+ { "$ref": "#/$defs/prepareUploadPartRequest" },
21
+ { "$ref": "#/$defs/preparedPart" },
22
+ { "$ref": "#/$defs/commitUploadRequest" },
23
+ { "$ref": "#/$defs/commitUploadReceipt" },
24
+ { "$ref": "#/$defs/abortTransferRequest" },
25
+ { "$ref": "#/$defs/getTransferStatusRequest" }
26
+ ],
27
+ "$defs": {
28
+ "uuid": { "type": "string", "format": "uuid" },
29
+ "digest": {
30
+ "type": "string",
31
+ "pattern": "^sha256:[0-9a-f]{64}$"
32
+ },
33
+ "path": {
34
+ "type": "string",
35
+ "minLength": 1,
36
+ "maxLength": 1024,
37
+ "pattern": "^(?!/)(?!\\.)(?!.*//)(?!.*\\\\)(?!.*/\\.)(?!(?:_contracts|_schemas|_types|_views|node_modules)(?:/|$))(?!.*\\/(?:_contracts|_schemas|_types|_views|node_modules)(?:/|$))(?!.*/$).+$"
38
+ },
39
+ "mediaClass": {
40
+ "enum": ["image", "audio", "video", "pdf", "other"]
41
+ },
42
+ "selectiveSyncPolicy": {
43
+ "type": "object",
44
+ "additionalProperties": false,
45
+ "required": ["file_classes", "excluded_folders"],
46
+ "properties": {
47
+ "file_classes": {
48
+ "type": "array",
49
+ "maxItems": 5,
50
+ "uniqueItems": true,
51
+ "items": { "$ref": "#/$defs/mediaClass" }
52
+ },
53
+ "excluded_folders": {
54
+ "type": "array",
55
+ "maxItems": 100,
56
+ "uniqueItems": true,
57
+ "items": { "$ref": "#/$defs/path" }
58
+ }
59
+ }
60
+ },
61
+ "fileDescriptor": {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": [
65
+ "file_id",
66
+ "path",
67
+ "revision",
68
+ "content_digest",
69
+ "size",
70
+ "media_class",
71
+ "modified_at"
72
+ ],
73
+ "properties": {
74
+ "file_id": { "$ref": "#/$defs/uuid" },
75
+ "path": { "$ref": "#/$defs/path" },
76
+ "revision": { "type": "string", "minLength": 1, "maxLength": 255 },
77
+ "content_digest": { "$ref": "#/$defs/digest" },
78
+ "size": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
79
+ "media_type": { "type": "string", "minLength": 1, "maxLength": 255 },
80
+ "media_class": { "$ref": "#/$defs/mediaClass" },
81
+ "modified_at": { "type": "string", "format": "date-time" }
82
+ }
83
+ },
84
+ "fileAction": {
85
+ "enum": ["list", "read", "add", "replace", "move", "delete"]
86
+ },
87
+ "fileScope": {
88
+ "oneOf": [
89
+ {
90
+ "type": "object",
91
+ "additionalProperties": false,
92
+ "required": ["kind", "folders"],
93
+ "properties": {
94
+ "kind": { "const": "selected_folders" },
95
+ "folders": {
96
+ "type": "array",
97
+ "minItems": 1,
98
+ "maxItems": 100,
99
+ "uniqueItems": true,
100
+ "items": { "$ref": "#/$defs/path" }
101
+ }
102
+ }
103
+ },
104
+ {
105
+ "type": "object",
106
+ "additionalProperties": false,
107
+ "required": ["kind"],
108
+ "properties": { "kind": { "const": "collection" } }
109
+ }
110
+ ]
111
+ },
112
+ "applicationFileRequirement": {
113
+ "type": "object",
114
+ "additionalProperties": false,
115
+ "required": ["actions", "scope"],
116
+ "properties": {
117
+ "actions": {
118
+ "type": "array",
119
+ "minItems": 1,
120
+ "maxItems": 6,
121
+ "uniqueItems": true,
122
+ "items": { "$ref": "#/$defs/fileAction" }
123
+ },
124
+ "scope": { "$ref": "#/$defs/fileScope" }
125
+ }
126
+ },
127
+ "fileCapability": {
128
+ "type": "object",
129
+ "additionalProperties": false,
130
+ "required": ["kind", "protocol_version", "actions", "scope"],
131
+ "properties": {
132
+ "kind": { "const": "files" },
133
+ "protocol_version": { "const": 1 },
134
+ "actions": {
135
+ "type": "array",
136
+ "minItems": 1,
137
+ "maxItems": 6,
138
+ "uniqueItems": true,
139
+ "items": { "$ref": "#/$defs/fileAction" }
140
+ },
141
+ "scope": { "$ref": "#/$defs/fileScope" }
142
+ }
143
+ },
144
+ "listFilesRequest": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": ["protocol_version", "type"],
148
+ "properties": {
149
+ "protocol_version": { "const": 1 },
150
+ "type": { "const": "list_files" },
151
+ "folder": { "$ref": "#/$defs/path" },
152
+ "after": { "type": "string", "minLength": 1 },
153
+ "limit": { "type": "integer", "minimum": 1, "maximum": 1000 }
154
+ }
155
+ },
156
+ "listFilesPage": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": ["protocol_version", "type", "files"],
160
+ "properties": {
161
+ "protocol_version": { "const": 1 },
162
+ "type": { "const": "files_page" },
163
+ "files": { "type": "array", "items": { "$ref": "#/$defs/fileDescriptor" } },
164
+ "next": { "type": "string", "minLength": 1 }
165
+ }
166
+ },
167
+ "openUploadRequest": {
168
+ "type": "object",
169
+ "additionalProperties": false,
170
+ "required": ["protocol_version", "type", "transfer_id", "path", "size", "content_digest"],
171
+ "properties": {
172
+ "protocol_version": { "const": 1 },
173
+ "type": { "const": "open_file_upload" },
174
+ "transfer_id": { "$ref": "#/$defs/uuid" },
175
+ "path": { "$ref": "#/$defs/path" },
176
+ "size": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
177
+ "content_digest": { "$ref": "#/$defs/digest" },
178
+ "media_type": { "type": "string", "minLength": 1, "maxLength": 255 },
179
+ "if_revision": { "type": "string", "minLength": 1, "maxLength": 255 }
180
+ }
181
+ },
182
+ "openDownloadRequest": {
183
+ "type": "object",
184
+ "additionalProperties": false,
185
+ "required": ["protocol_version", "type", "transfer_id", "file_id"],
186
+ "properties": {
187
+ "protocol_version": { "const": 1 },
188
+ "type": { "const": "open_file_download" },
189
+ "transfer_id": { "$ref": "#/$defs/uuid" },
190
+ "file_id": { "$ref": "#/$defs/uuid" },
191
+ "revision": { "type": "string", "minLength": 1, "maxLength": 255 }
192
+ }
193
+ },
194
+ "moveFileRequest": {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "required": [
198
+ "protocol_version", "type", "mutation_id", "file_id", "if_revision", "from_path", "path", "update_references"
199
+ ],
200
+ "properties": {
201
+ "protocol_version": { "const": 1 },
202
+ "type": { "const": "move_file" },
203
+ "mutation_id": { "$ref": "#/$defs/uuid" },
204
+ "file_id": { "$ref": "#/$defs/uuid" },
205
+ "if_revision": { "type": "string", "minLength": 1, "maxLength": 255 },
206
+ "from_path": { "$ref": "#/$defs/path" },
207
+ "path": { "$ref": "#/$defs/path" },
208
+ "update_references": { "type": "boolean" }
209
+ }
210
+ },
211
+ "moveFileReceipt": {
212
+ "type": "object",
213
+ "additionalProperties": false,
214
+ "required": ["protocol_version", "type", "mutation_id", "file"],
215
+ "properties": {
216
+ "protocol_version": { "const": 1 },
217
+ "type": { "const": "file_moved" },
218
+ "mutation_id": { "$ref": "#/$defs/uuid" },
219
+ "file": { "$ref": "#/$defs/fileDescriptor" }
220
+ }
221
+ },
222
+ "deleteFileRequest": {
223
+ "type": "object",
224
+ "additionalProperties": false,
225
+ "required": ["protocol_version", "type", "mutation_id", "file_id", "if_revision", "path"],
226
+ "properties": {
227
+ "protocol_version": { "const": 1 },
228
+ "type": { "const": "delete_file" },
229
+ "mutation_id": { "$ref": "#/$defs/uuid" },
230
+ "file_id": { "$ref": "#/$defs/uuid" },
231
+ "if_revision": { "type": "string", "minLength": 1, "maxLength": 255 },
232
+ "path": { "$ref": "#/$defs/path" }
233
+ }
234
+ },
235
+ "deleteFileReceipt": {
236
+ "type": "object",
237
+ "additionalProperties": false,
238
+ "required": ["protocol_version", "type", "mutation_id", "file_id", "previous_path", "revision"],
239
+ "properties": {
240
+ "protocol_version": { "const": 1 },
241
+ "type": { "const": "file_deleted" },
242
+ "mutation_id": { "$ref": "#/$defs/uuid" },
243
+ "file_id": { "$ref": "#/$defs/uuid" },
244
+ "previous_path": { "$ref": "#/$defs/path" },
245
+ "revision": { "type": "string", "minLength": 1, "maxLength": 255 }
246
+ }
247
+ },
248
+ "transferProtection": {
249
+ "enum": ["grant_aead_v1", "transport_tls"]
250
+ },
251
+ "transferStrategy": {
252
+ "oneOf": [
253
+ {
254
+ "type": "object",
255
+ "additionalProperties": false,
256
+ "required": ["kind"],
257
+ "properties": { "kind": { "const": "object_put" } }
258
+ },
259
+ {
260
+ "type": "object",
261
+ "additionalProperties": false,
262
+ "required": ["kind", "chunk_size"],
263
+ "properties": {
264
+ "kind": { "const": "framed_chunks" },
265
+ "chunk_size": { "type": "integer", "minimum": 65536, "maximum": 4194304 }
266
+ }
267
+ },
268
+ {
269
+ "type": "object",
270
+ "additionalProperties": false,
271
+ "required": ["kind", "part_size"],
272
+ "properties": {
273
+ "kind": { "const": "object_multipart" },
274
+ "part_size": { "type": "integer", "minimum": 5242880, "maximum": 5368709120 }
275
+ }
276
+ },
277
+ {
278
+ "type": "object",
279
+ "additionalProperties": false,
280
+ "required": ["kind", "part_size"],
281
+ "properties": {
282
+ "kind": { "const": "object_ranges" },
283
+ "part_size": { "type": "integer", "minimum": 65536, "maximum": 5368709120 }
284
+ }
285
+ }
286
+ ]
287
+ },
288
+ "transferSession": {
289
+ "type": "object",
290
+ "additionalProperties": false,
291
+ "required": [
292
+ "protocol_version",
293
+ "type",
294
+ "transfer_id",
295
+ "direction",
296
+ "protection",
297
+ "strategy",
298
+ "total_size",
299
+ "expires_at",
300
+ "received"
301
+ ],
302
+ "properties": {
303
+ "protocol_version": { "const": 1 },
304
+ "type": { "const": "file_transfer" },
305
+ "transfer_id": { "$ref": "#/$defs/uuid" },
306
+ "direction": { "enum": ["upload", "download"] },
307
+ "protection": { "$ref": "#/$defs/transferProtection" },
308
+ "strategy": { "$ref": "#/$defs/transferStrategy" },
309
+ "total_size": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
310
+ "expires_at": { "type": "string", "format": "date-time" },
311
+ "received": {
312
+ "type": "array",
313
+ "uniqueItems": true,
314
+ "items": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }
315
+ },
316
+ "uploaded_parts": {
317
+ "type": "array",
318
+ "maxItems": 10000,
319
+ "items": { "$ref": "#/$defs/uploadedPart" }
320
+ }
321
+ }
322
+ },
323
+ "transferStatus": {
324
+ "type": "object",
325
+ "additionalProperties": false,
326
+ "required": ["protocol_version", "type", "transfer_id", "state", "received", "received_bytes"],
327
+ "properties": {
328
+ "protocol_version": { "const": 1 },
329
+ "type": { "const": "file_transfer_status" },
330
+ "transfer_id": { "$ref": "#/$defs/uuid" },
331
+ "state": { "enum": ["open", "committed", "aborted", "expired"] },
332
+ "received": {
333
+ "type": "array",
334
+ "uniqueItems": true,
335
+ "items": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }
336
+ },
337
+ "received_bytes": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }
338
+ }
339
+ },
340
+ "prepareUploadPartRequest": {
341
+ "type": "object",
342
+ "additionalProperties": false,
343
+ "required": ["protocol_version", "type", "transfer_id", "part_number", "content_length"],
344
+ "properties": {
345
+ "protocol_version": { "const": 1 },
346
+ "type": { "const": "prepare_file_upload_part" },
347
+ "transfer_id": { "$ref": "#/$defs/uuid" },
348
+ "part_number": { "type": "integer", "minimum": 1, "maximum": 10000 },
349
+ "content_length": { "type": "integer", "minimum": 0, "maximum": 5368709120 }
350
+ }
351
+ },
352
+ "preparedPart": {
353
+ "type": "object",
354
+ "additionalProperties": false,
355
+ "required": ["protocol_version", "type", "transfer_id", "part_index", "offset", "content_length", "method", "url", "headers", "expires_at"],
356
+ "properties": {
357
+ "protocol_version": { "const": 1 },
358
+ "type": { "const": "file_part" },
359
+ "transfer_id": { "$ref": "#/$defs/uuid" },
360
+ "part_index": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
361
+ "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
362
+ "content_length": { "type": "integer", "minimum": 0, "maximum": 5368709120 },
363
+ "method": { "const": "PUT" },
364
+ "url": { "type": "string", "format": "uri", "pattern": "^https://" },
365
+ "headers": {
366
+ "type": "object",
367
+ "additionalProperties": { "type": "string" }
368
+ },
369
+ "expires_at": { "type": "string", "format": "date-time" }
370
+ }
371
+ },
372
+ "uploadedPart": {
373
+ "type": "object",
374
+ "additionalProperties": false,
375
+ "required": ["part_number", "etag"],
376
+ "properties": {
377
+ "part_number": { "type": "integer", "minimum": 1, "maximum": 10000 },
378
+ "etag": { "type": "string", "minLength": 1, "maxLength": 255 }
379
+ }
380
+ },
381
+ "commitUploadRequest": {
382
+ "type": "object",
383
+ "additionalProperties": false,
384
+ "required": ["protocol_version", "type", "transfer_id"],
385
+ "properties": {
386
+ "protocol_version": { "const": 1 },
387
+ "type": { "const": "commit_file_upload" },
388
+ "transfer_id": { "$ref": "#/$defs/uuid" },
389
+ "parts": {
390
+ "type": "array",
391
+ "minItems": 1,
392
+ "maxItems": 10000,
393
+ "items": { "$ref": "#/$defs/uploadedPart" }
394
+ }
395
+ }
396
+ },
397
+ "commitUploadReceipt": {
398
+ "type": "object",
399
+ "additionalProperties": false,
400
+ "required": ["protocol_version", "type", "transfer_id", "file"],
401
+ "properties": {
402
+ "protocol_version": { "const": 1 },
403
+ "type": { "const": "file_upload_committed" },
404
+ "transfer_id": { "$ref": "#/$defs/uuid" },
405
+ "file": { "$ref": "#/$defs/fileDescriptor" }
406
+ }
407
+ },
408
+ "abortTransferRequest": {
409
+ "type": "object",
410
+ "additionalProperties": false,
411
+ "required": ["protocol_version", "type", "transfer_id"],
412
+ "properties": {
413
+ "protocol_version": { "const": 1 },
414
+ "type": { "const": "abort_file_transfer" },
415
+ "transfer_id": { "$ref": "#/$defs/uuid" }
416
+ }
417
+ },
418
+ "relayFileHeader": {
419
+ "type": "object",
420
+ "additionalProperties": false,
421
+ "required": [
422
+ "protocol_version",
423
+ "type",
424
+ "request_id",
425
+ "grant_id",
426
+ "transfer_id",
427
+ "chunk_index"
428
+ ],
429
+ "properties": {
430
+ "protocol_version": { "const": 1 },
431
+ "type": {
432
+ "enum": [
433
+ "upload_chunk",
434
+ "upload_acknowledged",
435
+ "download_request",
436
+ "download_chunk",
437
+ "rejected"
438
+ ]
439
+ },
440
+ "request_id": { "$ref": "#/$defs/uuid" },
441
+ "grant_id": { "$ref": "#/$defs/uuid" },
442
+ "transfer_id": { "$ref": "#/$defs/uuid" },
443
+ "chunk_index": {
444
+ "type": "integer",
445
+ "minimum": 0,
446
+ "maximum": 9007199254740991
447
+ }
448
+ }
449
+ },
450
+ "frameHeader": {
451
+ "type": "object",
452
+ "additionalProperties": false,
453
+ "required": [
454
+ "protocol_version",
455
+ "protection",
456
+ "grant_id",
457
+ "authority_id",
458
+ "collection_id",
459
+ "transfer_id",
460
+ "direction",
461
+ "chunk_size",
462
+ "chunk_index",
463
+ "offset",
464
+ "plaintext_length",
465
+ "total_size",
466
+ "scope_epoch"
467
+ ],
468
+ "properties": {
469
+ "protocol_version": { "const": 1 },
470
+ "protection": { "$ref": "#/$defs/transferProtection" },
471
+ "grant_id": { "$ref": "#/$defs/uuid" },
472
+ "authority_id": { "$ref": "#/$defs/uuid" },
473
+ "collection_id": { "$ref": "#/$defs/uuid" },
474
+ "transfer_id": { "$ref": "#/$defs/uuid" },
475
+ "direction": { "enum": ["upload", "download"] },
476
+ "chunk_size": { "type": "integer", "minimum": 65536, "maximum": 4194304 },
477
+ "chunk_index": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
478
+ "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
479
+ "plaintext_length": { "type": "integer", "minimum": 0, "maximum": 4194304 },
480
+ "total_size": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
481
+ "scope_epoch": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
482
+ "key_id": { "type": "string", "minLength": 1, "maxLength": 255 }
483
+ },
484
+ "allOf": [
485
+ {
486
+ "if": { "properties": { "protection": { "const": "grant_aead_v1" } } },
487
+ "then": { "required": ["key_id"] }
488
+ }
489
+ ]
490
+ },
491
+ "getTransferStatusRequest": {
492
+ "type": "object",
493
+ "additionalProperties": false,
494
+ "required": ["protocol_version", "type", "transfer_id"],
495
+ "properties": {
496
+ "protocol_version": { "const": 1 },
497
+ "type": { "const": "get_file_transfer_status" },
498
+ "transfer_id": { "$ref": "#/$defs/uuid" }
499
+ }
500
+ }
501
+ }
502
+ }
@@ -115,6 +115,7 @@
115
115
  "const": "hosted",
116
116
  "description": "Require a durable provider-backed collection with direct sync support."
117
117
  },
118
+ "files": { "$ref": "#/$defs/fileRequirement" },
118
119
  "contracts": {
119
120
  "type": "array",
120
121
  "maxItems": 20,
@@ -123,6 +124,53 @@
123
124
  }
124
125
  }
125
126
  },
127
+ "fileRequirement": {
128
+ "type": "object",
129
+ "additionalProperties": false,
130
+ "required": ["actions", "scope"],
131
+ "properties": {
132
+ "actions": {
133
+ "type": "array",
134
+ "minItems": 1,
135
+ "maxItems": 6,
136
+ "uniqueItems": true,
137
+ "items": {
138
+ "enum": ["list", "read", "add", "replace", "move", "delete"]
139
+ }
140
+ },
141
+ "scope": { "$ref": "#/$defs/fileScope" }
142
+ }
143
+ },
144
+ "fileScope": {
145
+ "oneOf": [
146
+ {
147
+ "type": "object",
148
+ "additionalProperties": false,
149
+ "required": ["kind", "folders"],
150
+ "properties": {
151
+ "kind": { "const": "selected_folders" },
152
+ "folders": {
153
+ "type": "array",
154
+ "minItems": 1,
155
+ "maxItems": 100,
156
+ "uniqueItems": true,
157
+ "items": {
158
+ "type": "string",
159
+ "minLength": 1,
160
+ "maxLength": 1024,
161
+ "pattern": "^(?!/)(?!\\.)(?!.*//)(?!.*\\\\)(?!.*/\\.)(?!(?:_contracts|_schemas|_types|_views|node_modules)(?:/|$))(?!.*\\/(?:_contracts|_schemas|_types|_views|node_modules)(?:/|$))(?!.*/$).+$"
162
+ }
163
+ }
164
+ }
165
+ },
166
+ {
167
+ "type": "object",
168
+ "additionalProperties": false,
169
+ "required": ["kind"],
170
+ "properties": { "kind": { "const": "collection" } }
171
+ }
172
+ ]
173
+ },
126
174
  "typePackProvision": {
127
175
  "type": "object",
128
176
  "additionalProperties": false,