@mdbase-dev/connect-protocol 0.1.0-beta.38 → 0.1.0-beta.41
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.d.ts +24 -12
- package/package.json +1 -1
- package/schemas/sync.v1.schema.json +52 -10
package/dist/index.d.ts
CHANGED
|
@@ -279,9 +279,14 @@ export type EncryptedRelayOperation = CollectionOperation | "file_control";
|
|
|
279
279
|
export interface SyncRecord<Frontmatter extends JsonObject = JsonObject> {
|
|
280
280
|
record_id: string;
|
|
281
281
|
path: string;
|
|
282
|
+
/** Exact authoritative Markdown bytes. `revision` is the SHA-256 digest of this value. */
|
|
283
|
+
document: string;
|
|
282
284
|
revision: string;
|
|
285
|
+
/** Derived query projection. It never participates in mirror materialization. */
|
|
283
286
|
frontmatter: Frontmatter;
|
|
287
|
+
/** Derived query projection. It never participates in mirror materialization. */
|
|
284
288
|
body: string;
|
|
289
|
+
/** Derived authority projection used for scope checks. */
|
|
285
290
|
types: string[];
|
|
286
291
|
}
|
|
287
292
|
export interface SyncCollectionResources {
|
|
@@ -298,10 +303,7 @@ export interface SyncResourceDocument {
|
|
|
298
303
|
revision: string;
|
|
299
304
|
document: string;
|
|
300
305
|
}
|
|
301
|
-
export
|
|
302
|
-
record: SyncRecord<Frontmatter>;
|
|
303
|
-
document: string;
|
|
304
|
-
}
|
|
306
|
+
export type AuthoritySnapshotRecord<Frontmatter extends JsonObject = JsonObject> = SyncRecord<Frontmatter>;
|
|
305
307
|
export interface AuthoritySnapshot<Frontmatter extends JsonObject = JsonObject> {
|
|
306
308
|
protocol_version: 1;
|
|
307
309
|
collection_id: string;
|
|
@@ -345,6 +347,8 @@ export interface AuthorityImportRecordPage {
|
|
|
345
347
|
}
|
|
346
348
|
export interface SyncSession {
|
|
347
349
|
protocol_version: 1;
|
|
350
|
+
/** Exact-document prerelease v1. Missing or different profiles are incompatible. */
|
|
351
|
+
protocol_profile: "exact_document_v1";
|
|
348
352
|
session_id: string;
|
|
349
353
|
replica_id: string;
|
|
350
354
|
collection_id: string;
|
|
@@ -363,10 +367,7 @@ export interface SyncSnapshotPage<Frontmatter extends JsonObject = JsonObject> {
|
|
|
363
367
|
records: Array<SyncSnapshotRecord<Frontmatter>>;
|
|
364
368
|
next_page?: string;
|
|
365
369
|
}
|
|
366
|
-
export
|
|
367
|
-
/** Exact bytes whose SHA-256 revision and parsed metadata match this record. */
|
|
368
|
-
document: string;
|
|
369
|
-
}
|
|
370
|
+
export type SyncSnapshotRecord<Frontmatter extends JsonObject = JsonObject> = SyncRecord<Frontmatter>;
|
|
370
371
|
/** Manifest-only snapshot page. File bytes are fetched by digest via the file data plane. */
|
|
371
372
|
export interface SyncFileSnapshotPage {
|
|
372
373
|
protocol_version: 1;
|
|
@@ -407,17 +408,28 @@ export interface SyncChangesPage<Frontmatter extends JsonObject = JsonObject> {
|
|
|
407
408
|
has_more: boolean;
|
|
408
409
|
reset_required: boolean;
|
|
409
410
|
}
|
|
410
|
-
|
|
411
|
+
interface SyncMutationBase {
|
|
411
412
|
mutation_id: string;
|
|
412
413
|
replica_id: string;
|
|
413
414
|
scope_epoch: number;
|
|
414
|
-
operation: "create" | "update" | "rename" | "delete";
|
|
415
415
|
record_id: string;
|
|
416
|
-
base_revision?: string;
|
|
417
|
-
input: JsonObject;
|
|
418
416
|
created_at: string;
|
|
419
417
|
causal_predecessor?: string;
|
|
420
418
|
}
|
|
419
|
+
export type SyncMutation = (SyncMutationBase & {
|
|
420
|
+
operation: "put";
|
|
421
|
+
/** Omitted only when creating this stable identity. */
|
|
422
|
+
base_revision?: string;
|
|
423
|
+
path: string;
|
|
424
|
+
document: string;
|
|
425
|
+
}) | (SyncMutationBase & {
|
|
426
|
+
operation: "move";
|
|
427
|
+
base_revision: string;
|
|
428
|
+
path: string;
|
|
429
|
+
}) | (SyncMutationBase & {
|
|
430
|
+
operation: "delete";
|
|
431
|
+
base_revision: string;
|
|
432
|
+
});
|
|
421
433
|
interface SyncFileMutationBase {
|
|
422
434
|
mutation_id: string;
|
|
423
435
|
replica_id: string;
|
package/package.json
CHANGED
|
@@ -97,11 +97,12 @@
|
|
|
97
97
|
"record": {
|
|
98
98
|
"type": "object",
|
|
99
99
|
"additionalProperties": false,
|
|
100
|
-
"required": ["record_id", "path", "revision", "frontmatter", "body", "types"],
|
|
100
|
+
"required": ["record_id", "path", "document", "revision", "frontmatter", "body", "types"],
|
|
101
101
|
"properties": {
|
|
102
102
|
"record_id": { "$ref": "#/$defs/uuid" },
|
|
103
103
|
"path": { "type": "string", "minLength": 1 },
|
|
104
|
-
"
|
|
104
|
+
"document": { "type": "string" },
|
|
105
|
+
"revision": { "$ref": "#/$defs/digest" },
|
|
105
106
|
"frontmatter": { "type": "object" },
|
|
106
107
|
"body": { "type": "string" },
|
|
107
108
|
"types": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"snapshotRecord": {
|
|
111
112
|
"type": "object",
|
|
112
113
|
"additionalProperties": false,
|
|
113
|
-
"required": ["record_id", "path", "revision", "frontmatter", "body", "types"
|
|
114
|
+
"required": ["record_id", "path", "document", "revision", "frontmatter", "body", "types"],
|
|
114
115
|
"properties": {
|
|
115
116
|
"record_id": { "$ref": "#/$defs/uuid" },
|
|
116
117
|
"path": { "type": "string", "minLength": 1 },
|
|
@@ -124,9 +125,10 @@
|
|
|
124
125
|
"session": {
|
|
125
126
|
"type": "object",
|
|
126
127
|
"additionalProperties": false,
|
|
127
|
-
"required": ["protocol_version", "session_id", "replica_id", "collection_id", "mode", "scope_epoch", "retained_after", "head", "snapshot_id", "resources"],
|
|
128
|
+
"required": ["protocol_version", "protocol_profile", "session_id", "replica_id", "collection_id", "mode", "scope_epoch", "retained_after", "head", "snapshot_id", "resources"],
|
|
128
129
|
"properties": {
|
|
129
130
|
"protocol_version": { "const": 1 },
|
|
131
|
+
"protocol_profile": { "const": "exact_document_v1" },
|
|
130
132
|
"session_id": { "$ref": "#/$defs/uuid" },
|
|
131
133
|
"replica_id": { "$ref": "#/$defs/uuid" },
|
|
132
134
|
"collection_id": { "$ref": "#/$defs/uuid" },
|
|
@@ -233,18 +235,50 @@
|
|
|
233
235
|
"reset_required": { "type": "boolean" }
|
|
234
236
|
}
|
|
235
237
|
},
|
|
236
|
-
"
|
|
238
|
+
"recordPutMutation": {
|
|
239
|
+
"type": "object",
|
|
240
|
+
"additionalProperties": false,
|
|
241
|
+
"required": ["mutation_id", "replica_id", "scope_epoch", "operation", "record_id", "path", "document", "created_at"],
|
|
242
|
+
"properties": {
|
|
243
|
+
"mutation_id": { "$ref": "#/$defs/uuid" },
|
|
244
|
+
"replica_id": { "$ref": "#/$defs/uuid" },
|
|
245
|
+
"scope_epoch": { "type": "integer", "minimum": 1 },
|
|
246
|
+
"operation": { "const": "put" },
|
|
247
|
+
"record_id": { "$ref": "#/$defs/uuid" },
|
|
248
|
+
"base_revision": { "type": "string", "minLength": 1 },
|
|
249
|
+
"path": { "type": "string", "minLength": 1 },
|
|
250
|
+
"document": { "type": "string" },
|
|
251
|
+
"created_at": { "type": "string", "format": "date-time" },
|
|
252
|
+
"causal_predecessor": { "$ref": "#/$defs/uuid" }
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"recordDeleteMutation": {
|
|
256
|
+
"type": "object",
|
|
257
|
+
"additionalProperties": false,
|
|
258
|
+
"required": ["mutation_id", "replica_id", "scope_epoch", "operation", "record_id", "base_revision", "created_at"],
|
|
259
|
+
"properties": {
|
|
260
|
+
"mutation_id": { "$ref": "#/$defs/uuid" },
|
|
261
|
+
"replica_id": { "$ref": "#/$defs/uuid" },
|
|
262
|
+
"scope_epoch": { "type": "integer", "minimum": 1 },
|
|
263
|
+
"operation": { "const": "delete" },
|
|
264
|
+
"record_id": { "$ref": "#/$defs/uuid" },
|
|
265
|
+
"base_revision": { "type": "string", "minLength": 1 },
|
|
266
|
+
"created_at": { "type": "string", "format": "date-time" },
|
|
267
|
+
"causal_predecessor": { "$ref": "#/$defs/uuid" }
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"recordMoveMutation": {
|
|
237
271
|
"type": "object",
|
|
238
272
|
"additionalProperties": false,
|
|
239
|
-
"required": ["mutation_id", "replica_id", "scope_epoch", "operation", "record_id", "
|
|
273
|
+
"required": ["mutation_id", "replica_id", "scope_epoch", "operation", "record_id", "base_revision", "path", "created_at"],
|
|
240
274
|
"properties": {
|
|
241
275
|
"mutation_id": { "$ref": "#/$defs/uuid" },
|
|
242
276
|
"replica_id": { "$ref": "#/$defs/uuid" },
|
|
243
277
|
"scope_epoch": { "type": "integer", "minimum": 1 },
|
|
244
|
-
"operation": { "
|
|
278
|
+
"operation": { "const": "move" },
|
|
245
279
|
"record_id": { "$ref": "#/$defs/uuid" },
|
|
246
280
|
"base_revision": { "type": "string", "minLength": 1 },
|
|
247
|
-
"
|
|
281
|
+
"path": { "type": "string", "minLength": 1 },
|
|
248
282
|
"created_at": { "type": "string", "format": "date-time" },
|
|
249
283
|
"causal_predecessor": { "$ref": "#/$defs/uuid" }
|
|
250
284
|
}
|
|
@@ -312,7 +346,9 @@
|
|
|
312
346
|
},
|
|
313
347
|
"mutation": {
|
|
314
348
|
"oneOf": [
|
|
315
|
-
{ "$ref": "#/$defs/
|
|
349
|
+
{ "$ref": "#/$defs/recordPutMutation" },
|
|
350
|
+
{ "$ref": "#/$defs/recordMoveMutation" },
|
|
351
|
+
{ "$ref": "#/$defs/recordDeleteMutation" },
|
|
316
352
|
{ "$ref": "#/$defs/filePutMutation" },
|
|
317
353
|
{ "$ref": "#/$defs/fileMoveMutation" },
|
|
318
354
|
{ "$ref": "#/$defs/fileDeleteMutation" }
|
|
@@ -344,7 +380,13 @@
|
|
|
344
380
|
"required": ["record_id", "mutation"],
|
|
345
381
|
"properties": {
|
|
346
382
|
"record_id": { "$ref": "#/$defs/uuid" },
|
|
347
|
-
"mutation": {
|
|
383
|
+
"mutation": {
|
|
384
|
+
"oneOf": [
|
|
385
|
+
{ "$ref": "#/$defs/recordPutMutation" },
|
|
386
|
+
{ "$ref": "#/$defs/recordMoveMutation" },
|
|
387
|
+
{ "$ref": "#/$defs/recordDeleteMutation" }
|
|
388
|
+
]
|
|
389
|
+
},
|
|
348
390
|
"current": { "$ref": "#/$defs/record" },
|
|
349
391
|
"current_revision": { "type": "string" }
|
|
350
392
|
}
|