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

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,246 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mdbase.dev/connect/schemas/mdbase-app.v1.json",
4
+ "title": "mdbase connect bundled application manifest v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["manifest_version", "id", "name"],
8
+ "properties": {
9
+ "manifest_version": { "const": 1 },
10
+ "distribution": {
11
+ "enum": ["web", "portable"],
12
+ "description": "Portable declarations use device authorization and do not claim a browser origin."
13
+ },
14
+ "id": {
15
+ "type": "string",
16
+ "minLength": 5,
17
+ "maxLength": 150,
18
+ "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*){2,}$",
19
+ "description": "Stable reverse-domain application identifier. This is presentation metadata, not publisher authentication."
20
+ },
21
+ "name": { "type": "string", "minLength": 1, "maxLength": 100 },
22
+ "homepage": { "type": "string", "format": "uri", "pattern": "^https://" },
23
+ "project_url": { "type": "string", "format": "uri", "pattern": "^https://" },
24
+ "icon": { "type": "string", "format": "uri", "pattern": "^https://" },
25
+ "redirect_uris": {
26
+ "type": "array",
27
+ "minItems": 1,
28
+ "maxItems": 10,
29
+ "uniqueItems": true,
30
+ "items": {
31
+ "type": "string",
32
+ "format": "uri",
33
+ "description": "An HTTPS URI on the homepage origin or a private-use scheme derived from the application ID."
34
+ }
35
+ },
36
+ "requirements": { "$ref": "#/$defs/requirements" },
37
+ "provisions": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "required": ["type_packs"],
41
+ "properties": {
42
+ "type_packs": {
43
+ "type": "array",
44
+ "maxItems": 20,
45
+ "items": { "$ref": "#/$defs/typePackProvision" }
46
+ }
47
+ }
48
+ },
49
+ "notifications": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["criteria"],
53
+ "properties": {
54
+ "criteria": {
55
+ "type": "array",
56
+ "maxItems": 50,
57
+ "items": { "$ref": "#/$defs/notificationCriterion" }
58
+ },
59
+ "native_delivery": { "$ref": "#/$defs/nativeNotificationDelivery" }
60
+ }
61
+ }
62
+ },
63
+ "oneOf": [
64
+ {
65
+ "required": ["homepage", "redirect_uris"],
66
+ "properties": {
67
+ "distribution": { "const": "web" },
68
+ "homepage": true,
69
+ "redirect_uris": true,
70
+ "project_url": false
71
+ }
72
+ },
73
+ {
74
+ "required": ["distribution"],
75
+ "properties": {
76
+ "distribution": { "const": "portable" },
77
+ "homepage": false,
78
+ "redirect_uris": false
79
+ }
80
+ }
81
+ ],
82
+ "$defs": {
83
+ "identifier": {
84
+ "type": "string",
85
+ "minLength": 1,
86
+ "maxLength": 100,
87
+ "pattern": "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"
88
+ },
89
+ "duration": {
90
+ "type": "string",
91
+ "pattern": "^[0-9]+(ms|s|m|h|d)$"
92
+ },
93
+ "contract": {
94
+ "type": "object",
95
+ "additionalProperties": false,
96
+ "required": ["id", "version"],
97
+ "properties": {
98
+ "id": { "$ref": "#/$defs/identifier" },
99
+ "version": {
100
+ "type": "string",
101
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
102
+ }
103
+ }
104
+ },
105
+ "requirements": {
106
+ "type": "object",
107
+ "additionalProperties": false,
108
+ "required": ["contracts"],
109
+ "properties": {
110
+ "access": {
111
+ "enum": ["contract", "full_collection"],
112
+ "description": "Access boundary requested after compatibility and provisioning checks."
113
+ },
114
+ "collection_kind": {
115
+ "const": "hosted",
116
+ "description": "Require a durable provider-backed collection with direct sync support."
117
+ },
118
+ "contracts": {
119
+ "type": "array",
120
+ "maxItems": 20,
121
+ "uniqueItems": true,
122
+ "items": { "$ref": "#/$defs/contract" }
123
+ }
124
+ }
125
+ },
126
+ "typePackProvision": {
127
+ "type": "object",
128
+ "additionalProperties": false,
129
+ "required": ["manifest", "resources", "provides"],
130
+ "properties": {
131
+ "manifest": { "$ref": "#/$defs/typePackManifest" },
132
+ "resources": {
133
+ "type": "array",
134
+ "minItems": 1,
135
+ "maxItems": 100,
136
+ "items": { "$ref": "#/$defs/typePackSourceResource" }
137
+ },
138
+ "provides": {
139
+ "type": "array",
140
+ "maxItems": 20,
141
+ "uniqueItems": true,
142
+ "items": { "$ref": "#/$defs/contract" }
143
+ }
144
+ }
145
+ },
146
+ "typePackManifest": {
147
+ "type": "object",
148
+ "required": ["kind", "id", "version", "resources"],
149
+ "properties": {
150
+ "kind": { "const": "mdbase.type-pack" },
151
+ "id": { "$ref": "#/$defs/identifier" },
152
+ "version": { "$ref": "#/$defs/contract/properties/version" },
153
+ "name": { "type": "string", "minLength": 1, "maxLength": 100 },
154
+ "description": { "type": "string", "maxLength": 500 },
155
+ "resources": {
156
+ "type": "array",
157
+ "minItems": 1,
158
+ "maxItems": 100,
159
+ "items": { "$ref": "#/$defs/typePackManifestResource" }
160
+ }
161
+ },
162
+ "patternProperties": { "^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": true },
163
+ "additionalProperties": false
164
+ },
165
+ "typePackManifestResource": {
166
+ "type": "object",
167
+ "additionalProperties": false,
168
+ "required": ["kind", "source", "target", "digest"],
169
+ "properties": {
170
+ "kind": { "enum": ["contract", "type", "schema"] },
171
+ "source": { "type": "string", "minLength": 1, "maxLength": 240 },
172
+ "target": { "type": "string", "minLength": 1, "maxLength": 240 },
173
+ "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
174
+ }
175
+ },
176
+ "typePackSourceResource": {
177
+ "type": "object",
178
+ "additionalProperties": false,
179
+ "required": ["source", "document"],
180
+ "properties": {
181
+ "source": { "type": "string", "minLength": 1, "maxLength": 240 },
182
+ "document": { "type": "string", "maxLength": 262144 }
183
+ }
184
+ },
185
+ "notificationCriterion": {
186
+ "type": "object",
187
+ "additionalProperties": false,
188
+ "required": ["id", "event", "presentation"],
189
+ "properties": {
190
+ "id": { "$ref": "#/$defs/identifier" },
191
+ "event": { "$ref": "#/$defs/contract" },
192
+ "if": {
193
+ "type": "object",
194
+ "additionalProperties": false,
195
+ "required": ["$expr"],
196
+ "properties": {
197
+ "$expr": { "type": "string", "minLength": 1, "maxLength": 4096 }
198
+ }
199
+ },
200
+ "debounce": { "$ref": "#/$defs/duration" },
201
+ "minimum_interval": { "$ref": "#/$defs/duration" },
202
+ "presentation": {
203
+ "type": "object",
204
+ "additionalProperties": false,
205
+ "required": ["title"],
206
+ "properties": {
207
+ "title": { "type": "string", "minLength": 1, "maxLength": 80 },
208
+ "body": { "type": "string", "maxLength": 160 },
209
+ "tag": { "type": "string", "minLength": 1, "maxLength": 80 }
210
+ }
211
+ }
212
+ }
213
+ },
214
+ "nativeNotificationDelivery": {
215
+ "oneOf": [
216
+ {
217
+ "type": "object",
218
+ "additionalProperties": false,
219
+ "required": ["mode", "firebase_project_id"],
220
+ "properties": {
221
+ "mode": { "const": "managed_fcm" },
222
+ "firebase_project_id": {
223
+ "type": "string",
224
+ "minLength": 6,
225
+ "maxLength": 63,
226
+ "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$"
227
+ }
228
+ }
229
+ },
230
+ {
231
+ "type": "object",
232
+ "additionalProperties": false,
233
+ "required": ["mode", "url"],
234
+ "properties": {
235
+ "mode": { "const": "webhook" },
236
+ "url": {
237
+ "type": "string",
238
+ "format": "uri",
239
+ "pattern": "^https://"
240
+ }
241
+ }
242
+ }
243
+ ]
244
+ }
245
+ }
246
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mdbase.dev/connect/schemas/notification-webhook.v1.json",
4
+ "title": "mdbase notification webhook v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "type",
9
+ "version",
10
+ "delivery_id",
11
+ "connection_id",
12
+ "notification"
13
+ ],
14
+ "properties": {
15
+ "type": { "const": "mdbase.notification.webhook" },
16
+ "version": { "const": 1 },
17
+ "delivery_id": { "type": "string", "format": "uuid" },
18
+ "connection_id": {
19
+ "type": "string",
20
+ "format": "uuid",
21
+ "description": "Opaque application grant reference returned during authorization."
22
+ },
23
+ "notification": { "$ref": "#/$defs/notification" }
24
+ },
25
+ "$defs": {
26
+ "notification": {
27
+ "type": "object",
28
+ "additionalProperties": false,
29
+ "required": [
30
+ "type",
31
+ "version",
32
+ "signal_id",
33
+ "criterion_id",
34
+ "cursor",
35
+ "presentation"
36
+ ],
37
+ "properties": {
38
+ "type": { "const": "mdbase.notification" },
39
+ "version": { "const": 1 },
40
+ "signal_id": { "type": "string", "minLength": 1, "maxLength": 200 },
41
+ "criterion_id": { "type": "string", "minLength": 1, "maxLength": 100 },
42
+ "cursor": { "type": "string", "minLength": 1, "maxLength": 2000 },
43
+ "presentation": {
44
+ "type": "object",
45
+ "additionalProperties": false,
46
+ "required": ["title"],
47
+ "properties": {
48
+ "title": { "type": "string", "minLength": 1, "maxLength": 80 },
49
+ "body": { "type": "string", "maxLength": 160 },
50
+ "tag": { "type": "string", "minLength": 1, "maxLength": 80 }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,256 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mdbase.dev/connect/schemas/sync.v1.json",
4
+ "title": "mdbase connect replication protocol 1",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/session" },
7
+ { "$ref": "#/$defs/snapshotPage" },
8
+ { "$ref": "#/$defs/changesPage" },
9
+ { "$ref": "#/$defs/mutation" },
10
+ { "$ref": "#/$defs/receipt" }
11
+ ],
12
+ "$defs": {
13
+ "uuid": { "type": "string", "format": "uuid" },
14
+ "semanticVersion": {
15
+ "type": "string",
16
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
17
+ },
18
+ "digest": {
19
+ "type": "string",
20
+ "pattern": "^sha256:[0-9a-f]{64}$"
21
+ },
22
+ "collectionType": {
23
+ "type": "object",
24
+ "additionalProperties": false,
25
+ "required": ["name", "schema", "extensions"],
26
+ "properties": {
27
+ "name": { "type": "string", "minLength": 1 },
28
+ "version": { "type": "integer", "minimum": 1 },
29
+ "description": { "type": "string" },
30
+ "schema": { "type": "object" },
31
+ "collection": { "type": "object" },
32
+ "lifecycle": { "type": "object" },
33
+ "extensions": { "type": "object" }
34
+ }
35
+ },
36
+ "contract": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "required": ["contract_type", "id", "version", "digest", "schema", "implementations"],
40
+ "properties": {
41
+ "contract_type": { "const": "record" },
42
+ "id": { "type": "string", "minLength": 1 },
43
+ "version": { "$ref": "#/$defs/semanticVersion" },
44
+ "digest": { "$ref": "#/$defs/digest" },
45
+ "schema": { "type": "object" },
46
+ "binding_schema": { "type": "object" },
47
+ "implementations": {
48
+ "type": "array",
49
+ "minItems": 1,
50
+ "items": { "$ref": "#/$defs/contractImplementation" }
51
+ }
52
+ }
53
+ },
54
+ "contractImplementation": {
55
+ "type": "object",
56
+ "additionalProperties": false,
57
+ "required": ["type_name", "type_version", "digest", "fields"],
58
+ "properties": {
59
+ "type_name": { "type": "string", "minLength": 1 },
60
+ "type_version": { "type": "integer", "minimum": 1 },
61
+ "type_path": { "type": "string", "minLength": 1 },
62
+ "digest": { "$ref": "#/$defs/digest" },
63
+ "fields": {
64
+ "type": "object",
65
+ "additionalProperties": { "type": "string", "minLength": 1 }
66
+ },
67
+ "binding": { "type": "object" }
68
+ }
69
+ },
70
+ "resources": {
71
+ "type": "object",
72
+ "additionalProperties": false,
73
+ "required": ["revision", "spec_version", "types", "contracts"],
74
+ "properties": {
75
+ "revision": { "type": "string", "minLength": 1 },
76
+ "spec_version": { "type": "string", "minLength": 1 },
77
+ "types": { "type": "array", "items": { "$ref": "#/$defs/collectionType" } },
78
+ "contracts": { "type": "array", "items": { "$ref": "#/$defs/contract" } },
79
+ "documents": { "type": "array", "items": { "$ref": "#/$defs/resourceDocument" } }
80
+ }
81
+ },
82
+ "resourceDocument": {
83
+ "type": "object",
84
+ "additionalProperties": false,
85
+ "required": ["path", "kind", "revision", "document"],
86
+ "properties": {
87
+ "path": { "type": "string", "minLength": 1 },
88
+ "kind": { "enum": ["configuration", "type", "contract", "schema", "view"] },
89
+ "revision": { "$ref": "#/$defs/digest" },
90
+ "document": { "type": "string" }
91
+ }
92
+ },
93
+ "record": {
94
+ "type": "object",
95
+ "additionalProperties": false,
96
+ "required": ["record_id", "path", "revision", "frontmatter", "body", "types"],
97
+ "properties": {
98
+ "record_id": { "$ref": "#/$defs/uuid" },
99
+ "path": { "type": "string", "minLength": 1 },
100
+ "revision": { "type": "string", "minLength": 1 },
101
+ "frontmatter": { "type": "object" },
102
+ "body": { "type": "string" },
103
+ "types": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }
104
+ }
105
+ },
106
+ "snapshotRecord": {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "required": ["record_id", "path", "revision", "frontmatter", "body", "types", "document"],
110
+ "properties": {
111
+ "record_id": { "$ref": "#/$defs/uuid" },
112
+ "path": { "type": "string", "minLength": 1 },
113
+ "revision": { "$ref": "#/$defs/digest" },
114
+ "frontmatter": { "type": "object" },
115
+ "body": { "type": "string" },
116
+ "types": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
117
+ "document": { "type": "string" }
118
+ }
119
+ },
120
+ "session": {
121
+ "type": "object",
122
+ "additionalProperties": false,
123
+ "required": ["protocol_version", "session_id", "replica_id", "collection_id", "mode", "scope_epoch", "retained_after", "head", "snapshot_id", "resources"],
124
+ "properties": {
125
+ "protocol_version": { "const": 1 },
126
+ "session_id": { "$ref": "#/$defs/uuid" },
127
+ "replica_id": { "$ref": "#/$defs/uuid" },
128
+ "collection_id": { "$ref": "#/$defs/uuid" },
129
+ "mode": { "enum": ["read_only", "read_write"] },
130
+ "scope_epoch": { "type": "integer", "minimum": 1 },
131
+ "retained_after": { "type": "integer", "minimum": 0 },
132
+ "head": { "type": "integer", "minimum": 0 },
133
+ "snapshot_id": { "$ref": "#/$defs/uuid" },
134
+ "resources": { "$ref": "#/$defs/resources" }
135
+ }
136
+ },
137
+ "snapshotPage": {
138
+ "type": "object",
139
+ "additionalProperties": false,
140
+ "required": ["protocol_version", "snapshot_id", "scope_epoch", "cursor", "records"],
141
+ "properties": {
142
+ "protocol_version": { "const": 1 },
143
+ "snapshot_id": { "$ref": "#/$defs/uuid" },
144
+ "scope_epoch": { "type": "integer", "minimum": 1 },
145
+ "cursor": { "type": "integer", "minimum": 0 },
146
+ "records": { "type": "array", "items": { "$ref": "#/$defs/snapshotRecord" } },
147
+ "next_page": { "type": "string", "pattern": "^[1-9][0-9]*$" }
148
+ }
149
+ },
150
+ "put": {
151
+ "type": "object",
152
+ "additionalProperties": false,
153
+ "required": ["sequence", "type", "record"],
154
+ "properties": {
155
+ "sequence": { "type": "integer", "minimum": 1 },
156
+ "type": { "const": "put" },
157
+ "record": { "$ref": "#/$defs/record" }
158
+ }
159
+ },
160
+ "remove": {
161
+ "type": "object",
162
+ "additionalProperties": false,
163
+ "required": ["sequence", "type", "record_id", "previous_path", "revision"],
164
+ "properties": {
165
+ "sequence": { "type": "integer", "minimum": 1 },
166
+ "type": { "const": "remove" },
167
+ "record_id": { "$ref": "#/$defs/uuid" },
168
+ "previous_path": { "type": "string", "minLength": 1 },
169
+ "revision": { "type": "string", "minLength": 1 }
170
+ }
171
+ },
172
+ "changesPage": {
173
+ "type": "object",
174
+ "additionalProperties": false,
175
+ "required": ["protocol_version", "scope_epoch", "events", "cursor", "head", "has_more", "reset_required"],
176
+ "properties": {
177
+ "protocol_version": { "const": 1 },
178
+ "scope_epoch": { "type": "integer", "minimum": 1 },
179
+ "events": { "type": "array", "items": { "oneOf": [{ "$ref": "#/$defs/put" }, { "$ref": "#/$defs/remove" }] } },
180
+ "cursor": { "type": "integer", "minimum": 0 },
181
+ "head": { "type": "integer", "minimum": 0 },
182
+ "has_more": { "type": "boolean" },
183
+ "reset_required": { "type": "boolean" }
184
+ }
185
+ },
186
+ "mutation": {
187
+ "type": "object",
188
+ "additionalProperties": false,
189
+ "required": ["mutation_id", "replica_id", "scope_epoch", "operation", "record_id", "input", "created_at"],
190
+ "properties": {
191
+ "mutation_id": { "$ref": "#/$defs/uuid" },
192
+ "replica_id": { "$ref": "#/$defs/uuid" },
193
+ "scope_epoch": { "type": "integer", "minimum": 1 },
194
+ "operation": { "enum": ["create", "update", "rename", "delete"] },
195
+ "record_id": { "$ref": "#/$defs/uuid" },
196
+ "base_revision": { "type": "string", "minLength": 1 },
197
+ "input": { "type": "object" },
198
+ "created_at": { "type": "string", "format": "date-time" },
199
+ "causal_predecessor": { "$ref": "#/$defs/uuid" }
200
+ }
201
+ },
202
+ "receipt": {
203
+ "oneOf": [
204
+ {
205
+ "type": "object",
206
+ "additionalProperties": false,
207
+ "required": ["mutation_id", "status", "sequence"],
208
+ "properties": {
209
+ "mutation_id": { "$ref": "#/$defs/uuid" },
210
+ "status": { "enum": ["applied", "previously_applied"] },
211
+ "sequence": { "type": "integer", "minimum": 1 },
212
+ "record": { "$ref": "#/$defs/record" }
213
+ }
214
+ },
215
+ {
216
+ "type": "object",
217
+ "additionalProperties": false,
218
+ "required": ["mutation_id", "status", "conflict"],
219
+ "properties": {
220
+ "mutation_id": { "$ref": "#/$defs/uuid" },
221
+ "status": { "const": "conflicted" },
222
+ "conflict": {
223
+ "type": "object",
224
+ "additionalProperties": false,
225
+ "required": ["record_id", "mutation"],
226
+ "properties": {
227
+ "record_id": { "$ref": "#/$defs/uuid" },
228
+ "mutation": { "$ref": "#/$defs/mutation" },
229
+ "current": { "$ref": "#/$defs/record" },
230
+ "current_revision": { "type": "string" }
231
+ }
232
+ }
233
+ }
234
+ },
235
+ {
236
+ "type": "object",
237
+ "additionalProperties": false,
238
+ "required": ["mutation_id", "status", "error"],
239
+ "properties": {
240
+ "mutation_id": { "$ref": "#/$defs/uuid" },
241
+ "status": { "const": "rejected" },
242
+ "error": {
243
+ "type": "object",
244
+ "additionalProperties": false,
245
+ "required": ["code", "message"],
246
+ "properties": {
247
+ "code": { "type": "string", "minLength": 1 },
248
+ "message": { "type": "string" }
249
+ }
250
+ }
251
+ }
252
+ }
253
+ ]
254
+ }
255
+ }
256
+ }