@substrat-run/engine-protocol 0.7.3 → 0.9.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.
@@ -0,0 +1,136 @@
1
+ /**
2
+ * The shapes this engine PUBLISHES — what a composing vertical returns from an
3
+ * operation it has bound, and what reaches its API document.
4
+ *
5
+ * These existed only as TypeScript interfaces, which is enough to implement
6
+ * against and not enough to DECLARE against: `defineOperations` takes a schema,
7
+ * so without these a vertical binding `protocol/get` had nothing to point at.
8
+ *
9
+ * **Each one is asserted against its interface, in both directions.** A schema
10
+ * that drifts from the shape the handler actually returns is worse than no
11
+ * schema — it publishes a contract nobody honours, which is exactly the defect
12
+ * #695 found eleven times. The assertions below fail to compile if either side
13
+ * gains, loses or retypes a field.
14
+ */
15
+ import { z } from '@substrat-run/contracts';
16
+ import { protocolInstanceRow } from './entities.js';
17
+ import { contentUnion } from './inputs.js';
18
+ export const protocolTemplateRow = z.object({
19
+ id: z.string(),
20
+ key: z.string(),
21
+ version: z.number(),
22
+ title: z.string(),
23
+ content_json: z.string(),
24
+ created_at: z.string(),
25
+ });
26
+ export const protocolResponseRow = z.object({
27
+ id: z.string(),
28
+ instance_id: z.string(),
29
+ item_key: z.string(),
30
+ value_json: z.string(),
31
+ note: z.string().nullable(),
32
+ responded_by: z.string(),
33
+ responded_at: z.string(),
34
+ });
35
+ export const protocolSignatureRow = z.object({
36
+ id: z.string(),
37
+ instance_id: z.string(),
38
+ signed_by: z.string(),
39
+ kind: z.enum(['primary', 'counter']),
40
+ method: z.string(),
41
+ content_hash: z.string(),
42
+ evidence_ref: z.string().nullable(),
43
+ signed_at: z.string(),
44
+ request_id: z.string().nullable(),
45
+ signatory_kind: z.enum(['principal', 'external']),
46
+ signatory_label: z.string().nullable(),
47
+ });
48
+ export const protocolSignatureRequestRow = z.object({
49
+ id: z.string(),
50
+ instance_id: z.string(),
51
+ party_label: z.string(),
52
+ party_kind: z.enum(['principal', 'external']),
53
+ party_ref: z.string().nullable(),
54
+ signature_kind: z.enum(['primary', 'counter']),
55
+ method: z.string(),
56
+ auth_level: z.enum(['basic', 'strong']).nullable(),
57
+ contact_key_id: z.string().nullable(),
58
+ contact_ciphertext: z.string().nullable(),
59
+ status: z.enum(['pending', 'signed', 'declined', 'expired', 'cancelled']),
60
+ content_hash: z.string(),
61
+ external_ref: z.string().nullable(),
62
+ resolved_note: z.string().nullable(),
63
+ requested_by: z.string(),
64
+ requested_at: z.string(),
65
+ resolved_at: z.string().nullable(),
66
+ });
67
+ /**
68
+ * The COMPOSITE returns — what the operations answer with, as opposed to the
69
+ * rows above.
70
+ *
71
+ * These existed only as interfaces, and an interface is exactly as much as an
72
+ * operation cannot be declared against. `output` on a declared operation is a
73
+ * Zod schema, so without these four `protocol/get` and `protocol/sign` had
74
+ * nothing to point at and the engine could declare only the half of its surface
75
+ * that happens to return one row.
76
+ *
77
+ * They are assembled from the row schemas rather than restating their fields,
78
+ * so a column added to a row reaches every projection that carries it.
79
+ */
80
+ export const signResult = z.object({
81
+ instance: protocolInstanceRow,
82
+ signature: protocolSignatureRow,
83
+ });
84
+ export const requestSignaturesResult = z.object({
85
+ instance: protocolInstanceRow,
86
+ contentHash: z.string(),
87
+ requests: z.array(protocolSignatureRequestRow),
88
+ });
89
+ export const protocolDetail = z.object({
90
+ instance: protocolInstanceRow,
91
+ template: z.object({
92
+ key: z.string(),
93
+ version: z.number(),
94
+ title: z.string(),
95
+ content: contentUnion,
96
+ }),
97
+ /** The full append-only history — every edit, in order. */
98
+ responses: z.array(protocolResponseRow),
99
+ /** Per item, last append wins — the current answers. */
100
+ latest: z.record(z.string(), protocolResponseRow),
101
+ /** The primary (issuing) signature, or null while unsigned. */
102
+ signature: protocolSignatureRow.nullable(),
103
+ /** Every row: the primary plus any counter-signatures. */
104
+ signatures: z.array(protocolSignatureRow),
105
+ requests: z.array(protocolSignatureRequestRow),
106
+ });
107
+ export const protocolSummary = z.object({
108
+ instance: protocolInstanceRow,
109
+ title: z.string(),
110
+ contentKind: z.enum(['checklist', 'document']),
111
+ answered: z.number(),
112
+ total: z.number(),
113
+ signedBy: z.string().nullable(),
114
+ signedAt: z.string().nullable(),
115
+ countersignedBy: z.string().nullable(),
116
+ countersignedAt: z.string().nullable(),
117
+ /** How many requested signatures are still outstanding. */
118
+ pendingSignatures: z.number(),
119
+ });
120
+ const _templateRow = true;
121
+ const _responseRow = true;
122
+ const _signatureRow = true;
123
+ const _requestRow = true;
124
+ const _signResult = true;
125
+ const _requestResult = true;
126
+ const _detail = true;
127
+ const _summary = true;
128
+ void _templateRow;
129
+ void _responseRow;
130
+ void _signatureRow;
131
+ void _requestRow;
132
+ void _signResult;
133
+ void _requestResult;
134
+ void _detail;
135
+ void _summary;
136
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,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CAAC,CAAC;AAQH,MAAM,YAAY,GAAoE,IAAI,CAAC;AAC3F,MAAM,YAAY,GAAoE,IAAI,CAAC;AAC3F,MAAM,aAAa,GAAsE,IAAI,CAAC;AAC9F,MAAM,WAAW,GAGb,IAAI,CAAC;AACT,MAAM,WAAW,GAAkD,IAAI,CAAC;AACxE,MAAM,cAAc,GAClB,IAAI,CAAC;AACP,MAAM,OAAO,GAA0D,IAAI,CAAC;AAC5E,MAAM,QAAQ,GAA4D,IAAI,CAAC;AAE/E,KAAK,YAAY,CAAC;AAClB,KAAK,YAAY,CAAC;AAClB,KAAK,aAAa,CAAC;AACnB,KAAK,WAAW,CAAC;AACjB,KAAK,WAAW,CAAC;AACjB,KAAK,cAAc,CAAC;AACpB,KAAK,OAAO,CAAC;AACb,KAAK,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/engine-protocol",
3
- "version": "0.7.3",
3
+ "version": "0.9.0",
4
4
  "description": "Substrat engine: protocols, checklists and signed documents with the freeze → immutable invariant — versioned templates, append-only responses, verifiable content hash, counter-signatures on frozen content, and asynchronous multi-party signatures by external (non-principal) signatories",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -25,16 +25,20 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "zod": "^4.4.3",
29
- "@substrat-run/contracts": "^0.71.0",
30
- "@substrat-run/kernel": "^0.71.0"
28
+ "@substrat-run/contracts": "^0.73.0",
29
+ "@substrat-run/kernel": "^0.73.0"
31
30
  },
32
31
  "devDependencies": {
33
32
  "typescript": "^7.0.0",
34
- "vitest": "^3.0.0",
35
- "@substrat-run/model-emit": "0.1.0",
36
- "@substrat-run/adapter-sqlite": "^0.71.0",
37
- "@substrat-run/engine-test-kit": "^0.1.3"
33
+ "vitest": "^3.2.7",
34
+ "zod": "^4.4.3",
35
+ "@substrat-run/contract-tests": "^0.73.0",
36
+ "@substrat-run/model-emit": "0.3.0",
37
+ "@substrat-run/engine-test-kit": "^0.3.0",
38
+ "@substrat-run/adapter-sqlite": "^0.73.0"
39
+ },
40
+ "peerDependencies": {
41
+ "zod": "^4.4.0"
38
42
  },
39
43
  "scripts": {
40
44
  "build": "tsc -p tsconfig.json",