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

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/dist/application-authorization.d.ts +32 -0
  3. package/dist/application-authorization.js +207 -0
  4. package/dist/capabilities.d.ts +73 -0
  5. package/dist/capabilities.js +92 -0
  6. package/dist/collection-setup.d.ts +90 -0
  7. package/dist/collection-setup.js +1 -0
  8. package/dist/compatibility.d.ts +37 -0
  9. package/dist/compatibility.js +65 -0
  10. package/dist/connect-problems.generated.d.ts +1388 -0
  11. package/dist/connect-problems.generated.js +574 -0
  12. package/dist/files.d.ts +269 -0
  13. package/dist/files.js +426 -0
  14. package/dist/index.d.ts +878 -0
  15. package/dist/index.js +94 -0
  16. package/dist/manifest.d.ts +62 -0
  17. package/dist/manifest.js +527 -0
  18. package/dist/mutation-fingerprint.d.ts +6 -0
  19. package/dist/mutation-fingerprint.js +116 -0
  20. package/dist/operations.d.ts +15 -0
  21. package/dist/operations.js +194 -0
  22. package/dist/type-packs.d.ts +133 -0
  23. package/dist/type-packs.js +30 -0
  24. package/package.json +42 -0
  25. package/schemas/application-capability-catalog.v1.json +40 -0
  26. package/schemas/application-capability-catalog.v2.json +68 -0
  27. package/schemas/catalog.json +17 -0
  28. package/schemas/connect-problem.v1.schema.json +5132 -0
  29. package/schemas/connect-problems.v1.catalog.json +351 -0
  30. package/schemas/connect-protocol.v1.schema.json +800 -0
  31. package/schemas/data-contract.schema.json +163 -0
  32. package/schemas/encrypted-relay.v1.schema.json +63 -0
  33. package/schemas/encrypted-relay.v2.schema.json +63 -0
  34. package/schemas/encrypted-relay.v3.schema.json +64 -0
  35. package/schemas/files.v1.schema.json +507 -0
  36. package/schemas/interop/v0.1/action-cancellation.schema.json +6 -0
  37. package/schemas/interop/v0.1/action-invocation.schema.json +6 -0
  38. package/schemas/interop/v0.1/action-outcome.schema.json +6 -0
  39. package/schemas/interop/v0.1/action-provider-declaration.schema.json +6 -0
  40. package/schemas/interop/v0.1/action-request.schema.json +6 -0
  41. package/schemas/interop/v0.1/conformance-claim.schema.json +6 -0
  42. package/schemas/interop/v0.1/event-source-declaration.schema.json +6 -0
  43. package/schemas/interop/v0.1/event.schema.json +6 -0
  44. package/schemas/interop/v0.1/profile.schema.json +456 -0
  45. package/schemas/mdbase-app.legacy-v1.schema.json +405 -0
  46. package/schemas/mdbase-app.schema.json +381 -0
  47. package/schemas/mdbase-query.v0.3.schema.json +171 -0
  48. package/schemas/notification-webhook.v1.schema.json +56 -0
  49. package/schemas/operation-catalog.v1.json +42 -0
  50. package/schemas/operation-mutation-classification.v1.json +537 -0
  51. package/schemas/sync.v1.schema.json +483 -0
@@ -0,0 +1,6 @@
1
+ import { type EncryptedOperation } from "./operations.js";
2
+ export declare const MUTATION_FINGERPRINT_SCHEMA_VERSION: 1;
3
+ export declare const MUTATION_FINGERPRINT_DOMAIN: "mdbase-connect mutation fingerprint v1\0";
4
+ export declare function canonicalMutationInput(input: unknown): string;
5
+ export declare function mutationFingerprintTranscript(operation: EncryptedOperation, input: unknown): Uint8Array<ArrayBuffer>;
6
+ export declare function mutationFingerprint(operation: EncryptedOperation, input: unknown): Promise<string>;
@@ -0,0 +1,116 @@
1
+ import { mutationOperationIdentifier, operationInputSchemaVersion } from "./operations.js";
2
+ export const MUTATION_FINGERPRINT_SCHEMA_VERSION = 1;
3
+ export const MUTATION_FINGERPRINT_DOMAIN = "mdbase-connect mutation fingerprint v1\0";
4
+ const encoder = new TextEncoder();
5
+ export function canonicalMutationInput(input) {
6
+ return canonicalize(input, new Set());
7
+ }
8
+ export function mutationFingerprintTranscript(operation, input) {
9
+ const identifier = mutationOperationIdentifier(operation, input);
10
+ if (identifier === null)
11
+ throw new TypeError("The operation is not a canonical mutation.");
12
+ const identifierBytes = encoder.encode(identifier);
13
+ const inputBytes = encoder.encode(canonicalMutationInput(input));
14
+ const domainBytes = encoder.encode(MUTATION_FINGERPRINT_DOMAIN);
15
+ const transcript = new Uint8Array(domainBytes.length + 4 + 8 + identifierBytes.length + 4 + 8 + inputBytes.length);
16
+ const view = new DataView(transcript.buffer);
17
+ let offset = 0;
18
+ transcript.set(domainBytes, offset);
19
+ offset += domainBytes.length;
20
+ view.setUint32(offset, MUTATION_FINGERPRINT_SCHEMA_VERSION, false);
21
+ offset += 4;
22
+ offset = writeField(transcript, view, offset, identifierBytes);
23
+ view.setUint32(offset, operationInputSchemaVersion(operation, input), false);
24
+ offset += 4;
25
+ writeField(transcript, view, offset, inputBytes);
26
+ return transcript;
27
+ }
28
+ export async function mutationFingerprint(operation, input) {
29
+ const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", mutationFingerprintTranscript(operation, input).buffer));
30
+ return base64Url(digest);
31
+ }
32
+ function canonicalize(value, ancestors) {
33
+ if (value === null)
34
+ return "null";
35
+ if (value === true)
36
+ return "true";
37
+ if (value === false)
38
+ return "false";
39
+ if (typeof value === "string") {
40
+ assertUnicodeScalarString(value);
41
+ return JSON.stringify(value);
42
+ }
43
+ if (typeof value === "number") {
44
+ if (!Number.isFinite(value))
45
+ throw new TypeError("Mutation input numbers must be finite.");
46
+ return JSON.stringify(value);
47
+ }
48
+ if (typeof value !== "object") {
49
+ throw new TypeError(`Mutation input contains unsupported ${typeof value}.`);
50
+ }
51
+ if (ancestors.has(value))
52
+ throw new TypeError("Mutation input must not contain cycles.");
53
+ ancestors.add(value);
54
+ try {
55
+ if (Array.isArray(value)) {
56
+ if (Object.getOwnPropertySymbols(value).length > 0) {
57
+ throw new TypeError("Mutation input must not contain symbol properties.");
58
+ }
59
+ const children = [];
60
+ for (let index = 0; index < value.length; index += 1) {
61
+ if (!Object.hasOwn(value, index))
62
+ throw new TypeError("Mutation input arrays must not be sparse.");
63
+ children.push(canonicalize(value[index], ancestors));
64
+ }
65
+ return `[${children.join(",")}]`;
66
+ }
67
+ const prototype = Object.getPrototypeOf(value);
68
+ if (prototype !== Object.prototype && prototype !== null) {
69
+ throw new TypeError("Mutation input objects must be plain JSON objects.");
70
+ }
71
+ if (Object.getOwnPropertySymbols(value).length > 0) {
72
+ throw new TypeError("Mutation input must not contain symbol properties.");
73
+ }
74
+ const entries = Object.entries(value);
75
+ for (const [key] of entries)
76
+ assertUnicodeScalarString(key);
77
+ entries.sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
78
+ return `{${entries.map(([key, child]) => {
79
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
80
+ if (!descriptor || descriptor.get || descriptor.set) {
81
+ throw new TypeError("Mutation input must not contain accessor properties.");
82
+ }
83
+ return `${JSON.stringify(key)}:${canonicalize(child, ancestors)}`;
84
+ }).join(",")}}`;
85
+ }
86
+ finally {
87
+ ancestors.delete(value);
88
+ }
89
+ }
90
+ function assertUnicodeScalarString(value) {
91
+ for (let index = 0; index < value.length; index += 1) {
92
+ const unit = value.charCodeAt(index);
93
+ if (unit >= 0xd800 && unit <= 0xdbff) {
94
+ const next = value.charCodeAt(index + 1);
95
+ if (!(next >= 0xdc00 && next <= 0xdfff)) {
96
+ throw new TypeError("Mutation input strings must not contain lone surrogates.");
97
+ }
98
+ index += 1;
99
+ }
100
+ else if (unit >= 0xdc00 && unit <= 0xdfff) {
101
+ throw new TypeError("Mutation input strings must not contain lone surrogates.");
102
+ }
103
+ }
104
+ }
105
+ function writeField(transcript, view, offset, value) {
106
+ view.setBigUint64(offset, BigInt(value.length), false);
107
+ offset += 8;
108
+ transcript.set(value, offset);
109
+ return offset + value.length;
110
+ }
111
+ function base64Url(value) {
112
+ return btoa(String.fromCharCode(...value))
113
+ .replaceAll("+", "-")
114
+ .replaceAll("/", "_")
115
+ .replace(/=+$/u, "");
116
+ }
@@ -0,0 +1,15 @@
1
+ export declare const OPERATION_CATALOG_VERSION: 1;
2
+ export declare const COLLECTION_OPERATIONS: readonly ["describe", "changes", "read", "query", "list_views", "execute_view", "read_view_source", "create_view_source", "update_view_source", "delete_view_source", "validate", "create", "update", "delete", "rename", "read_type", "create_type", "update_type", "assess_type_pack", "apply_type_pack", "assess_collection_setup", "apply_collection_setup", "list_timers", "put_timer", "cancel_timer", "reconcile_timers", "sync"];
3
+ export type CollectionOperation = typeof COLLECTION_OPERATIONS[number];
4
+ export declare const FILE_CONTROL_MESSAGE_TYPES: readonly ["list_files", "open_file_upload", "open_file_download", "move_file", "delete_file", "get_file_transfer_status", "commit_file_upload", "abort_file_transfer"];
5
+ export type FileControlMessageType = typeof FILE_CONTROL_MESSAGE_TYPES[number];
6
+ export type EncryptedOperation = CollectionOperation | "file_control";
7
+ export declare const MUTATING_OPERATION_IDENTIFIERS: readonly ["create_view_source", "update_view_source", "delete_view_source", "create", "update", "delete", "rename", "create_type", "update_type", "apply_type_pack", "apply_collection_setup", "put_timer", "cancel_timer", "reconcile_timers", "sync:mutate", "file_control:open_file_upload", "file_control:move_file", "file_control:delete_file", "file_control:commit_file_upload", "file_control:abort_file_transfer"];
8
+ export type MutationOperationIdentifier = typeof MUTATING_OPERATION_IDENTIFIERS[number];
9
+ export declare function isCollectionOperation(value: string): value is CollectionOperation;
10
+ export declare function areCollectionOperations(values: readonly string[]): values is readonly CollectionOperation[];
11
+ export declare function operationRequiresTimerCriterion(operation: CollectionOperation): boolean;
12
+ export declare function isFileControlMessageType(value: string): value is FileControlMessageType;
13
+ export declare function operationInputSchemaVersion(operation: EncryptedOperation, input: unknown): number;
14
+ export declare function mutationOperationIdentifier(operation: EncryptedOperation, input: unknown): MutationOperationIdentifier | null;
15
+ export declare function isMutatingOperation(operation: EncryptedOperation, input: unknown): boolean;
@@ -0,0 +1,194 @@
1
+ // Generated by scripts/generate-operation-catalog.mjs. Do not edit directly.
2
+ export const OPERATION_CATALOG_VERSION = 1;
3
+ export const COLLECTION_OPERATIONS = [
4
+ "describe",
5
+ "changes",
6
+ "read",
7
+ "query",
8
+ "list_views",
9
+ "execute_view",
10
+ "read_view_source",
11
+ "create_view_source",
12
+ "update_view_source",
13
+ "delete_view_source",
14
+ "validate",
15
+ "create",
16
+ "update",
17
+ "delete",
18
+ "rename",
19
+ "read_type",
20
+ "create_type",
21
+ "update_type",
22
+ "assess_type_pack",
23
+ "apply_type_pack",
24
+ "assess_collection_setup",
25
+ "apply_collection_setup",
26
+ "list_timers",
27
+ "put_timer",
28
+ "cancel_timer",
29
+ "reconcile_timers",
30
+ "sync"
31
+ ];
32
+ export const FILE_CONTROL_MESSAGE_TYPES = [
33
+ "list_files",
34
+ "open_file_upload",
35
+ "open_file_download",
36
+ "move_file",
37
+ "delete_file",
38
+ "get_file_transfer_status",
39
+ "commit_file_upload",
40
+ "abort_file_transfer"
41
+ ];
42
+ const COLLECTION_MUTATION_RULES = {
43
+ "describe": "never",
44
+ "changes": "never",
45
+ "read": "never",
46
+ "query": "never",
47
+ "list_views": "never",
48
+ "execute_view": "never",
49
+ "read_view_source": "never",
50
+ "create_view_source": "always",
51
+ "update_view_source": "always",
52
+ "delete_view_source": "always",
53
+ "validate": "never",
54
+ "create": "always",
55
+ "update": "always",
56
+ "delete": "always",
57
+ "rename": "always",
58
+ "read_type": "never",
59
+ "create_type": "always",
60
+ "update_type": "always",
61
+ "assess_type_pack": "never",
62
+ "apply_type_pack": "always",
63
+ "assess_collection_setup": "never",
64
+ "apply_collection_setup": "always",
65
+ "list_timers": "never",
66
+ "put_timer": "always",
67
+ "cancel_timer": "always",
68
+ "reconcile_timers": "always",
69
+ "sync": "sync_action"
70
+ };
71
+ const COLLECTION_INPUT_SCHEMA_VERSIONS = {
72
+ "describe": 1,
73
+ "changes": 1,
74
+ "read": 1,
75
+ "query": 1,
76
+ "list_views": 1,
77
+ "execute_view": 1,
78
+ "read_view_source": 1,
79
+ "create_view_source": 1,
80
+ "update_view_source": 1,
81
+ "delete_view_source": 1,
82
+ "validate": 1,
83
+ "create": 1,
84
+ "update": 1,
85
+ "delete": 1,
86
+ "rename": 1,
87
+ "read_type": 1,
88
+ "create_type": 1,
89
+ "update_type": 1,
90
+ "assess_type_pack": 1,
91
+ "apply_type_pack": 1,
92
+ "assess_collection_setup": 1,
93
+ "apply_collection_setup": 1,
94
+ "list_timers": 1,
95
+ "put_timer": 1,
96
+ "cancel_timer": 1,
97
+ "reconcile_timers": 1,
98
+ "sync": 1
99
+ };
100
+ const FILE_CONTROL_INPUT_SCHEMA_VERSIONS = {
101
+ "list_files": 1,
102
+ "open_file_upload": 1,
103
+ "open_file_download": 1,
104
+ "move_file": 1,
105
+ "delete_file": 1,
106
+ "get_file_transfer_status": 1,
107
+ "commit_file_upload": 1,
108
+ "abort_file_transfer": 1
109
+ };
110
+ const MUTATING_FILE_CONTROL_MESSAGE_TYPES = new Set([
111
+ "open_file_upload",
112
+ "move_file",
113
+ "delete_file",
114
+ "commit_file_upload",
115
+ "abort_file_transfer"
116
+ ]);
117
+ const NONMUTATING_DRY_RUN_OPERATIONS = new Set([
118
+ "delete",
119
+ "rename"
120
+ ]);
121
+ export const MUTATING_OPERATION_IDENTIFIERS = [
122
+ "create_view_source",
123
+ "update_view_source",
124
+ "delete_view_source",
125
+ "create",
126
+ "update",
127
+ "delete",
128
+ "rename",
129
+ "create_type",
130
+ "update_type",
131
+ "apply_type_pack",
132
+ "apply_collection_setup",
133
+ "put_timer",
134
+ "cancel_timer",
135
+ "reconcile_timers",
136
+ "sync:mutate",
137
+ "file_control:open_file_upload",
138
+ "file_control:move_file",
139
+ "file_control:delete_file",
140
+ "file_control:commit_file_upload",
141
+ "file_control:abort_file_transfer"
142
+ ];
143
+ const TIMER_CRITERION_OPERATIONS = new Set([
144
+ "list_timers",
145
+ "put_timer",
146
+ "cancel_timer",
147
+ "reconcile_timers"
148
+ ]);
149
+ const COLLECTION_OPERATION_SET = new Set(COLLECTION_OPERATIONS);
150
+ const FILE_CONTROL_MESSAGE_TYPE_SET = new Set(FILE_CONTROL_MESSAGE_TYPES);
151
+ export function isCollectionOperation(value) {
152
+ return COLLECTION_OPERATION_SET.has(value);
153
+ }
154
+ export function areCollectionOperations(values) {
155
+ return values.every(isCollectionOperation);
156
+ }
157
+ export function operationRequiresTimerCriterion(operation) {
158
+ return TIMER_CRITERION_OPERATIONS.has(operation);
159
+ }
160
+ export function isFileControlMessageType(value) {
161
+ return FILE_CONTROL_MESSAGE_TYPE_SET.has(value);
162
+ }
163
+ export function operationInputSchemaVersion(operation, input) {
164
+ if (operation === "file_control") {
165
+ const type = isObject(input) && typeof input.type === "string" ? input.type : "";
166
+ if (!isFileControlMessageType(type))
167
+ throw new Error(`Unknown file-control message: ${type}`);
168
+ return FILE_CONTROL_INPUT_SCHEMA_VERSIONS[type];
169
+ }
170
+ return COLLECTION_INPUT_SCHEMA_VERSIONS[operation];
171
+ }
172
+ export function mutationOperationIdentifier(operation, input) {
173
+ const object = isObject(input) ? input : {};
174
+ if (object.dry_run === true && NONMUTATING_DRY_RUN_OPERATIONS.has(operation))
175
+ return null;
176
+ if (operation === "file_control") {
177
+ const type = typeof object.type === "string" ? object.type : "";
178
+ return MUTATING_FILE_CONTROL_MESSAGE_TYPES.has(type)
179
+ ? `file_control:${type}`
180
+ : null;
181
+ }
182
+ const rule = COLLECTION_MUTATION_RULES[operation];
183
+ if (rule === "always")
184
+ return operation;
185
+ if (rule === "sync_action" && object.action === "mutate")
186
+ return "sync:mutate";
187
+ return null;
188
+ }
189
+ export function isMutatingOperation(operation, input) {
190
+ return mutationOperationIdentifier(operation, input) !== null;
191
+ }
192
+ function isObject(value) {
193
+ return value !== null && typeof value === "object" && !Array.isArray(value);
194
+ }
@@ -0,0 +1,133 @@
1
+ export interface ContractRequirement {
2
+ id: string;
3
+ /** Exact semantic version of the collection-local mdbase data contract. */
4
+ version: string;
5
+ /** Exact digest of the resolved portable contract identity. */
6
+ digest: string;
7
+ }
8
+ /** Exact identity of the standard record-created runtime event contract. */
9
+ export declare const MDBASE_RECORD_CREATED_CONTRACT: {
10
+ readonly id: "mdbase.record.created";
11
+ readonly version: "1.0.0";
12
+ readonly digest: "sha256:7f3bed6baa356ee9389e977ae7b77a102e2bee871a7c1d9f2026fc21cacdbfc9";
13
+ };
14
+ /** Exact identity of the standard record-modified runtime event contract. */
15
+ export declare const MDBASE_RECORD_MODIFIED_CONTRACT: {
16
+ readonly id: "mdbase.record.modified";
17
+ readonly version: "1.0.0";
18
+ readonly digest: "sha256:064187148a95701a1f5c749643d306d3c6708470b6b7ab0bf0c698d38dbcabe3";
19
+ };
20
+ /** Exact identity of the standard record-deleted runtime event contract. */
21
+ export declare const MDBASE_RECORD_DELETED_CONTRACT: {
22
+ readonly id: "mdbase.record.deleted";
23
+ readonly version: "1.0.0";
24
+ readonly digest: "sha256:84e5fb0f9d3bfdcd53f76cdc5035f94c7693fdea39a8ead190b10b422dd2ee09";
25
+ };
26
+ /** Exact identity of the standard record-renamed runtime event contract. */
27
+ export declare const MDBASE_RECORD_RENAMED_CONTRACT: {
28
+ readonly id: "mdbase.record.renamed";
29
+ readonly version: "1.0.0";
30
+ readonly digest: "sha256:c825ef8d7db775b784d7af27e6acdf6f2799d2c6440d486f5bfa78afcca71471";
31
+ };
32
+ /** Exact identity of the standard timer-fired runtime event contract. */
33
+ export declare const MDBASE_TIMER_FIRED_CONTRACT: {
34
+ readonly id: "mdbase.runtime.timer.fired";
35
+ readonly version: "1.0.0";
36
+ readonly digest: "sha256:41105be7a7abf33b31ced47e1e1965242236e40ccaea286b959b0a8c591f5642";
37
+ };
38
+ export interface TypePackManifestResource {
39
+ kind: "contract" | "type" | "schema";
40
+ mode: "managed" | "seed";
41
+ source: string;
42
+ target: string;
43
+ digest: string;
44
+ }
45
+ export interface TypePackManifest {
46
+ kind: "mdbase.type-pack";
47
+ id: string;
48
+ version: string;
49
+ name?: string;
50
+ description?: string;
51
+ resources: TypePackManifestResource[];
52
+ [extension: `x-${string}`]: unknown;
53
+ }
54
+ export interface TypePackSourceResource {
55
+ source: string;
56
+ document: string;
57
+ }
58
+ export interface TypePackProvision {
59
+ /** Canonical type-pack manifest shown during approval and verified on install. */
60
+ manifest: TypePackManifest;
61
+ /** Exact UTF-8 resource bytes, keyed by each manifest source path. */
62
+ resources: TypePackSourceResource[];
63
+ /** Data contracts expected after the complete pack is installed. */
64
+ provides: ContractRequirement[];
65
+ }
66
+ export interface TypePackResourceDiff {
67
+ source: string;
68
+ target: string;
69
+ kind: "contract" | "type" | "schema";
70
+ mode: "managed" | "seed";
71
+ action: "create" | "update" | "delete" | "adopt" | "unchanged" | "preserve" | "conflict";
72
+ digest: string;
73
+ current_digest?: string;
74
+ installed_digest?: string;
75
+ adopted_from_digest?: string;
76
+ reason?: string;
77
+ }
78
+ export interface TypePackReceipt {
79
+ id: string;
80
+ version: string;
81
+ digest: string;
82
+ installed_by: string;
83
+ resources: Omit<TypePackResourceDiff, "action" | "current_digest" | "installed_digest" | "reason">[];
84
+ }
85
+ export interface TypePackAssessment {
86
+ status: "current" | "install" | "upgrade" | "downgrade" | "reconfigure" | "conflict";
87
+ applicable: boolean;
88
+ assessment_digest: string;
89
+ current?: TypePackReceipt;
90
+ desired: TypePackReceipt;
91
+ resources: TypePackResourceDiff[];
92
+ lock: {
93
+ target: "mdbase.lock.yaml";
94
+ action: "create" | "update" | "unchanged";
95
+ digest: string;
96
+ };
97
+ contract_setups: {
98
+ choices: ContractSetupChoice[];
99
+ resources: TypePackResourceDiff[];
100
+ };
101
+ }
102
+ export interface TypePackApplyResult extends TypePackAssessment {
103
+ receipt: TypePackReceipt;
104
+ cleanup_deferred: boolean;
105
+ }
106
+ export interface AssessTypePackInput {
107
+ provision: TypePackProvision;
108
+ installed_by: string;
109
+ /** Explicit digest-pinned consent to claim differing unmanaged managed targets. */
110
+ adopt_resources?: Record<string, string>;
111
+ /** Seed resources deliberately omitted because the user selected an existing implementation. */
112
+ preserve_seed_targets?: string[];
113
+ /** Resolve canonical manifest targets to collection-specific paths. */
114
+ target_overrides?: Record<string, string>;
115
+ /** Reviewed edits to user-owned types, committed atomically with the pack. */
116
+ contract_setups?: ContractSetupChoice[];
117
+ }
118
+ export interface ApplyTypePackInput extends AssessTypePackInput {
119
+ expected_assessment_digest: string;
120
+ allow_downgrade?: boolean;
121
+ }
122
+ export type ContractSetupChoice = {
123
+ contract: ContractRequirement;
124
+ mode: "starter";
125
+ } | {
126
+ contract: ContractRequirement;
127
+ mode: "existing";
128
+ type_name: string;
129
+ /** Exact type source revision shown during approval. */
130
+ type_revision: string;
131
+ fields: Record<string, string>;
132
+ binding?: Record<string, unknown>;
133
+ };
@@ -0,0 +1,30 @@
1
+ /** Exact identity of the standard record-created runtime event contract. */
2
+ export const MDBASE_RECORD_CREATED_CONTRACT = {
3
+ id: "mdbase.record.created",
4
+ version: "1.0.0",
5
+ digest: "sha256:7f3bed6baa356ee9389e977ae7b77a102e2bee871a7c1d9f2026fc21cacdbfc9",
6
+ };
7
+ /** Exact identity of the standard record-modified runtime event contract. */
8
+ export const MDBASE_RECORD_MODIFIED_CONTRACT = {
9
+ id: "mdbase.record.modified",
10
+ version: "1.0.0",
11
+ digest: "sha256:064187148a95701a1f5c749643d306d3c6708470b6b7ab0bf0c698d38dbcabe3",
12
+ };
13
+ /** Exact identity of the standard record-deleted runtime event contract. */
14
+ export const MDBASE_RECORD_DELETED_CONTRACT = {
15
+ id: "mdbase.record.deleted",
16
+ version: "1.0.0",
17
+ digest: "sha256:84e5fb0f9d3bfdcd53f76cdc5035f94c7693fdea39a8ead190b10b422dd2ee09",
18
+ };
19
+ /** Exact identity of the standard record-renamed runtime event contract. */
20
+ export const MDBASE_RECORD_RENAMED_CONTRACT = {
21
+ id: "mdbase.record.renamed",
22
+ version: "1.0.0",
23
+ digest: "sha256:c825ef8d7db775b784d7af27e6acdf6f2799d2c6440d486f5bfa78afcca71471",
24
+ };
25
+ /** Exact identity of the standard timer-fired runtime event contract. */
26
+ export const MDBASE_TIMER_FIRED_CONTRACT = {
27
+ id: "mdbase.runtime.timer.fired",
28
+ version: "1.0.0",
29
+ digest: "sha256:41105be7a7abf33b31ced47e1e1965242236e40ccaea286b959b0a8c591f5642",
30
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@mdbase-dev/connect-protocol",
3
+ "version": "0.1.0-beta.100",
4
+ "private": false,
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mdbase-dev/mdbase-connect.git",
10
+ "directory": "packages/protocol"
11
+ },
12
+ "homepage": "https://mdbase.dev",
13
+ "sideEffects": false,
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ },
19
+ "./manifest": {
20
+ "types": "./dist/manifest.d.ts",
21
+ "import": "./dist/manifest.js"
22
+ },
23
+ "./schemas/*": "./schemas/*"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "schemas"
28
+ ],
29
+ "dependencies": {
30
+ "ajv": "^8.20.0",
31
+ "ajv-formats": "^3.0.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^24.0.0",
35
+ "typescript": "^7.0.2"
36
+ },
37
+ "scripts": {
38
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
39
+ "test": "node --test test/*.test.mjs && node ../../scripts/generate-connect-problems.mjs --check && node ../../scripts/generate-operation-catalog.mjs --check && node ../../scripts/generate-application-capabilities.mjs --check",
40
+ "typecheck": "tsc -p tsconfig.json --noEmit"
41
+ }
42
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "catalog_version": 1,
4
+ "capabilities": [
5
+ { "id": "collection.inspect", "operations": ["describe"] },
6
+ { "id": "records.watch", "operations": ["changes"] },
7
+ { "id": "records.read", "operations": ["read"] },
8
+ { "id": "records.query", "operations": ["query"] },
9
+ { "id": "records.validate", "operations": ["validate"] },
10
+ { "id": "records.create", "operations": ["create"] },
11
+ { "id": "records.update", "operations": ["update"] },
12
+ { "id": "records.delete", "operations": ["delete"] },
13
+ { "id": "records.rename", "operations": ["rename"] },
14
+ { "id": "views.list", "operations": ["list_views"] },
15
+ { "id": "views.execute", "operations": ["execute_view"] },
16
+ { "id": "views.source.read", "operations": ["read_view_source"] },
17
+ { "id": "views.source.create", "operations": ["create_view_source"] },
18
+ { "id": "views.source.update", "operations": ["update_view_source"] },
19
+ { "id": "views.source.delete", "operations": ["delete_view_source"] },
20
+ { "id": "definitions.contracts.current", "operations": [] },
21
+ { "id": "definitions.read", "operations": ["read_type"] },
22
+ { "id": "definitions.create", "operations": ["create_type"] },
23
+ { "id": "definitions.update", "operations": ["update_type"] },
24
+ { "id": "definitions.type-pack.inspect", "operations": ["assess_type_pack"] },
25
+ { "id": "definitions.type-pack.apply", "operations": ["assess_type_pack", "apply_type_pack"] },
26
+ { "id": "collection.setup.apply", "operations": ["assess_collection_setup", "apply_collection_setup"] },
27
+ { "id": "timers.list", "operations": ["list_timers"] },
28
+ { "id": "timers.put", "operations": ["put_timer"] },
29
+ { "id": "timers.cancel", "operations": ["cancel_timer"] },
30
+ { "id": "timers.reconcile", "operations": ["reconcile_timers"] },
31
+ { "id": "sync.offline-replica", "operations": ["sync"] },
32
+ { "id": "notifications.background-delivery", "operations": [] },
33
+ { "id": "files.list", "operations": [] },
34
+ { "id": "files.read", "operations": [] },
35
+ { "id": "files.add", "operations": [] },
36
+ { "id": "files.replace", "operations": [] },
37
+ { "id": "files.move", "operations": [] },
38
+ { "id": "files.delete", "operations": [] }
39
+ ]
40
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "catalog_version": 2,
4
+ "capabilities": [
5
+ {
6
+ "id": "collection.read",
7
+ "operations": [
8
+ "describe",
9
+ "changes",
10
+ "read",
11
+ "query",
12
+ "list_views",
13
+ "execute_view",
14
+ "read_view_source",
15
+ "validate",
16
+ "read_type"
17
+ ]
18
+ },
19
+ {
20
+ "id": "records.create",
21
+ "operations": ["create"]
22
+ },
23
+ {
24
+ "id": "records.edit",
25
+ "operations": ["update", "rename"]
26
+ },
27
+ {
28
+ "id": "records.delete",
29
+ "operations": ["delete"]
30
+ },
31
+ {
32
+ "id": "views.manage",
33
+ "operations": [
34
+ "create_view_source",
35
+ "update_view_source",
36
+ "delete_view_source"
37
+ ]
38
+ },
39
+ {
40
+ "id": "definitions.manage",
41
+ "operations": [
42
+ "create_type",
43
+ "update_type",
44
+ "assess_type_pack",
45
+ "apply_type_pack"
46
+ ]
47
+ },
48
+ {
49
+ "id": "background.schedule",
50
+ "operations": [
51
+ "list_timers",
52
+ "put_timer",
53
+ "cancel_timer",
54
+ "reconcile_timers"
55
+ ]
56
+ },
57
+ {
58
+ "id": "offline.replica",
59
+ "operations": ["sync"]
60
+ }
61
+ ],
62
+ "structured_authorities": {
63
+ "application_setup": [
64
+ "assess_collection_setup",
65
+ "apply_collection_setup"
66
+ ]
67
+ }
68
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "manifest_version": 1,
3
+ "schemas": {
4
+ "app_manifest": "./mdbase-app.schema.json",
5
+ "data_contract": "./data-contract.schema.json",
6
+ "event_action_interop": "./interop/v0.1/profile.schema.json",
7
+ "connect_protocol": "./connect-protocol.v1.schema.json",
8
+ "connect_problem": "./connect-problem.v1.schema.json",
9
+ "connect_problem_catalog": "./connect-problems.v1.catalog.json",
10
+ "mdbase_query_v0_3": "./mdbase-query.v0.3.schema.json",
11
+ "encrypted_relay": "./encrypted-relay.v3.schema.json",
12
+ "encrypted_relay_legacy_v2": "./encrypted-relay.v2.schema.json",
13
+ "files": "./files.v1.schema.json",
14
+ "notification_webhook": "./notification-webhook.v1.schema.json",
15
+ "sync": "./sync.v1.schema.json"
16
+ }
17
+ }