@ixo/topic-protocol 0.7.0 → 0.8.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.
Files changed (37) hide show
  1. package/README.md +4 -2
  2. package/dist/schemas/action-receipt.schema.json +105 -11
  3. package/dist/schemas/decision-to-pay-template.schema.json +346 -0
  4. package/dist/schemas/payable-obligation.schema.json +312 -0
  5. package/dist/schemas/payment-terms.schema.json +287 -0
  6. package/dist/schemas/topic-action-request.schema.json +30 -0
  7. package/dist/schemas/topic-contract-state.schema.json +29 -3
  8. package/dist/schemas/topic-flow-binding.schema.json +28 -0
  9. package/dist/schemas/topic-kind-profile.schema.json +32 -2
  10. package/dist/schemas/topic-operation.schema.json +2 -2
  11. package/dist/src/action-runtime/types.d.ts +101 -0
  12. package/dist/src/action-runtime/types.js +12 -0
  13. package/dist/src/action-runtime/types.js.map +1 -0
  14. package/dist/src/contracts/schemas.d.ts +2608 -463
  15. package/dist/src/contracts/schemas.js +10 -0
  16. package/dist/src/contracts/schemas.js.map +1 -1
  17. package/dist/src/contracts/topic-contract.d.ts +8 -1
  18. package/dist/src/contracts/topic-contract.js.map +1 -1
  19. package/dist/src/contracts/topic-kind-profile.d.ts +29 -0
  20. package/dist/src/contracts/topic-kind-profile.js +31 -0
  21. package/dist/src/contracts/topic-kind-profile.js.map +1 -1
  22. package/dist/src/index.d.ts +2 -1
  23. package/dist/src/index.js +2 -1
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/projector/payload.d.ts +18 -0
  26. package/dist/src/projector/payload.js +57 -1
  27. package/dist/src/projector/payload.js.map +1 -1
  28. package/dist/src/projector/state.js +144 -0
  29. package/dist/src/projector/state.js.map +1 -1
  30. package/dist/src/projector/types.d.ts +13 -3
  31. package/dist/src/projector/types.js.map +1 -1
  32. package/package.json +4 -2
  33. package/templates/decision-to-pay/README.md +59 -0
  34. package/templates/decision-to-pay/milestone-payment-release.template.json +195 -0
  35. package/templates/decision-to-pay/outcome-payment-claim.template.json +198 -0
  36. package/templates/decision-to-pay/payment-on-delivery.template.json +198 -0
  37. package/templates/decision-to-pay/verified-work-payment.template.json +283 -0
@@ -281,7 +281,22 @@
281
281
  "kindProfile": { "$ref": "#/$defs/kindProfileRef" },
282
282
  "appearance": { "$ref": "#/$defs/appearance" },
283
283
  "attachmentCount": { "type": "integer", "minimum": 0 },
284
- "operationCount": { "type": "integer", "minimum": 0 }
284
+ "operationCount": { "type": "integer", "minimum": 0 },
285
+ "actions": {
286
+ "type": "array",
287
+ "maxItems": 500,
288
+ "items": {
289
+ "type": "object",
290
+ "required": ["request", "status", "operationId"],
291
+ "properties": {
292
+ "request": { "$ref": "https://topic-protocol.ixo.world/schemas/topic-action-request.schema.json" },
293
+ "latestReceipt": { "$ref": "https://topic-protocol.ixo.world/schemas/action-receipt.schema.json#/$defs/v2" },
294
+ "status": { "enum": ["requested", "awaiting_confirmation", "running", "succeeded", "failed", "rejected", "cancelled", "needs_verification"] },
295
+ "operationId": { "type": "string", "minLength": 1 }
296
+ },
297
+ "additionalProperties": false
298
+ }
299
+ }
285
300
  },
286
301
  "additionalProperties": true
287
302
  },
@@ -293,16 +308,26 @@
293
308
  },
294
309
  "automation": {
295
310
  "type": "object",
296
- "required": ["provider", "scheduleId", "actionId", "recurrence", "status"],
311
+ "required": ["provider", "scheduleId", "recurrence", "status"],
297
312
  "properties": {
298
313
  "provider": { "const": "temporal" },
299
314
  "scheduleId": { "type": "string", "minLength": 1 },
300
315
  "actionId": { "type": "string", "minLength": 1 },
316
+ "target": {
317
+ "oneOf": [
318
+ { "type": "object", "required": ["kind", "actionType"], "properties": { "kind": { "const": "action" }, "actionType": { "type": "string", "pattern": "^qi/" } }, "additionalProperties": false },
319
+ { "type": "object", "required": ["kind", "bindingId"], "properties": { "kind": { "const": "flow" }, "bindingId": { "type": "string", "minLength": 1 } }, "additionalProperties": false }
320
+ ]
321
+ },
301
322
  "recurrence": { "$ref": "#/$defs/recurrence" },
302
323
  "status": { "type": "string", "enum": ["pending", "active", "paused", "failed"] },
303
324
  "nextRunAt": { "type": "string", "format": "date-time" }
304
325
  },
305
- "additionalProperties": false
326
+ "additionalProperties": false,
327
+ "anyOf": [
328
+ { "properties": { "actionId": true }, "required": ["actionId"] },
329
+ { "properties": { "target": true }, "required": ["target"] }
330
+ ]
306
331
  },
307
332
  "bindings": {
308
333
  "type": "object",
@@ -310,6 +335,7 @@
310
335
  "governanceProposal": { "type": "object" },
311
336
  "claims": { "type": "object" },
312
337
  "automations": { "type": "array", "maxItems": 20, "items": { "$ref": "#/$defs/automation" } },
338
+ "flows": { "type": "array", "maxItems": 20, "items": { "$ref": "https://topic-protocol.ixo.world/schemas/topic-flow-binding.schema.json" } },
313
339
  "context": { "type": "array", "maxItems": 100, "items": { "type": "object" } }
314
340
  },
315
341
  "additionalProperties": false
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://topic-protocol.ixo.world/schemas/topic-flow-binding.schema.json",
4
+ "title": "Topic Flow Binding v1",
5
+ "type": "object",
6
+ "required": ["version", "bindingId", "topicId", "flowUri", "flowRevision", "flowDigest", "role", "actionManifestDigest", "controllerDid", "startPolicy", "triggerPolicy", "receiptPolicy", "status", "capability", "capabilityReferences", "createdBy", "createdAt"],
7
+ "properties": {
8
+ "version": { "const": 1 },
9
+ "bindingId": { "type": "string", "minLength": 1 },
10
+ "topicId": { "type": "string", "pattern": "^ixo:topic:[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" },
11
+ "flowUri": { "type": "string", "pattern": "^ixo:flow:" },
12
+ "flowRevision": { "type": "string", "minLength": 1 },
13
+ "flowDigest": { "$ref": "#/$defs/digest" },
14
+ "role": { "enum": ["primary", "supporting"] },
15
+ "actionManifestDigest": { "$ref": "#/$defs/digest" },
16
+ "controllerDid": { "type": "string", "pattern": "^did:" },
17
+ "startPolicy": { "enum": ["manual", "on-topic-active", "scheduled", "event"] },
18
+ "triggerPolicy": { "type": "object" },
19
+ "receiptPolicy": { "enum": ["all", "terminal"] },
20
+ "status": { "enum": ["pending", "active", "paused", "closed", "failed"] },
21
+ "capability": { "type": "string", "minLength": 1 },
22
+ "capabilityReferences": { "type": "array", "minItems": 2, "items": { "type": "string", "minLength": 1 }, "uniqueItems": true },
23
+ "createdBy": { "type": "string", "pattern": "^did:" },
24
+ "createdAt": { "type": "string", "format": "date-time" }
25
+ },
26
+ "additionalProperties": false,
27
+ "$defs": { "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" } }
28
+ }
@@ -5,7 +5,7 @@
5
5
  "type": "object",
6
6
  "required": ["version", "id", "profileVersion", "label", "kind", "resource", "acceptance", "projection", "presentation"],
7
7
  "properties": {
8
- "version": { "const": 1 },
8
+ "version": { "enum": [1, 2] },
9
9
  "id": { "type": "string", "format": "uri" },
10
10
  "profileVersion": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
11
11
  "label": { "type": "string", "minLength": 1, "maxLength": 80 },
@@ -76,7 +76,37 @@
76
76
  "uniqueItems": true,
77
77
  "maxItems": 20,
78
78
  "items": { "type": "string", "minLength": 1, "maxLength": 128 }
79
+ },
80
+ "actionManifest": {
81
+ "type": "object",
82
+ "required": ["version", "digest"],
83
+ "properties": {
84
+ "version": { "type": "string", "minLength": 1, "maxLength": 40 },
85
+ "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
86
+ },
87
+ "additionalProperties": false
88
+ },
89
+ "actions": {
90
+ "type": "array",
91
+ "uniqueItems": true,
92
+ "maxItems": 50,
93
+ "items": {
94
+ "type": "object",
95
+ "required": ["type", "role"],
96
+ "properties": {
97
+ "type": { "type": "string", "pattern": "^qi/[a-z0-9]+(?:[._-][a-z0-9]+)*$" },
98
+ "role": { "enum": ["primary", "supporting"] },
99
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 }
100
+ },
101
+ "additionalProperties": false
102
+ }
79
103
  }
80
104
  },
81
- "additionalProperties": false
105
+ "additionalProperties": false,
106
+ "allOf": [
107
+ {
108
+ "if": { "properties": { "version": { "const": 2 } }, "required": ["version"] },
109
+ "then": { "properties": { "actionManifest": true, "actions": true }, "required": ["actionManifest", "actions"] }
110
+ }
111
+ ]
82
112
  }
@@ -8,7 +8,7 @@
8
8
  "version": { "enum": [1, 2] },
9
9
  "operationId": { "type": "string", "minLength": 1 },
10
10
  "topicId": { "type": "string", "pattern": "^ixo:topic:[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" },
11
- "type": { "type": "string", "enum": ["rename", "change-status", "update-overview", "link-context", "unlink-context", "attach-files", "detach-files", "record-decision", "propose-contract", "update-contract", "accept-contract", "supersede-contract", "bind-automation", "update-automation", "pause-automation", "remove-automation", "bind-external-work", "sync-external-work", "unlink-external-work", "submit-delivery", "record-delivery-decision", "record-evaluation", "record-approval", "record-claim", "record-settlement", "redirect", "branch", "merge", "resolve-conflict"] },
11
+ "type": { "type": "string", "enum": ["rename", "change-status", "update-overview", "link-context", "unlink-context", "attach-files", "detach-files", "record-decision", "propose-contract", "update-contract", "accept-contract", "supersede-contract", "bind-automation", "update-automation", "pause-automation", "remove-automation", "bind-flow", "update-flow-binding", "unbind-flow", "request-action", "cancel-action", "record-action-receipt", "bind-external-work", "sync-external-work", "unlink-external-work", "submit-delivery", "record-delivery-decision", "record-evaluation", "record-approval", "record-claim", "record-settlement", "redirect", "branch", "merge", "resolve-conflict"] },
12
12
  "previousRevision": { "type": "string", "minLength": 1 },
13
13
  "actor": { "type": "string", "minLength": 1 },
14
14
  "createdAt": { "type": "string", "format": "date-time" },
@@ -20,7 +20,7 @@
20
20
  {
21
21
  "if": {
22
22
  "properties": {
23
- "type": { "enum": ["propose-contract", "update-contract", "accept-contract", "supersede-contract", "bind-automation", "update-automation", "pause-automation", "remove-automation", "bind-external-work", "sync-external-work", "unlink-external-work", "submit-delivery", "record-delivery-decision", "record-evaluation", "record-approval", "record-claim", "record-settlement"] }
23
+ "type": { "enum": ["propose-contract", "update-contract", "accept-contract", "supersede-contract", "bind-automation", "update-automation", "pause-automation", "remove-automation", "bind-flow", "update-flow-binding", "unbind-flow", "request-action", "cancel-action", "record-action-receipt", "bind-external-work", "sync-external-work", "unlink-external-work", "submit-delivery", "record-delivery-decision", "record-evaluation", "record-approval", "record-claim", "record-settlement"] }
24
24
  },
25
25
  "required": ["type"]
26
26
  },
@@ -0,0 +1,101 @@
1
+ export declare const TOPIC_ACTION_RUNTIME_PROVIDERS: readonly ["qi-flow", "qiforge", "mcp"];
2
+ export declare const TOPIC_ACTION_STATUSES: readonly ["requested", "awaiting_confirmation", "running", "succeeded", "failed", "rejected", "cancelled", "needs_verification"];
3
+ export type TopicActionRuntimeProvider = (typeof TOPIC_ACTION_RUNTIME_PROVIDERS)[number];
4
+ export type TopicActionStatus = (typeof TOPIC_ACTION_STATUSES)[number];
5
+ export type Sha256Uri = `sha256:${string}`;
6
+ export interface TopicFlowBindingV1 {
7
+ readonly version: 1;
8
+ readonly bindingId: string;
9
+ readonly topicId: string;
10
+ readonly flowUri: string;
11
+ readonly flowRevision: string;
12
+ readonly flowDigest: Sha256Uri;
13
+ readonly role: "primary" | "supporting";
14
+ readonly actionManifestDigest: Sha256Uri;
15
+ readonly controllerDid: string;
16
+ readonly startPolicy: "manual" | "on-topic-active" | "scheduled" | "event";
17
+ readonly triggerPolicy: Readonly<Record<string, unknown>>;
18
+ readonly receiptPolicy: "all" | "terminal";
19
+ readonly status: "pending" | "active" | "paused" | "closed" | "failed";
20
+ readonly capability: string;
21
+ readonly capabilityReferences: readonly string[];
22
+ readonly createdBy: string;
23
+ readonly createdAt: string;
24
+ }
25
+ export interface TopicActionRequestV1 {
26
+ readonly version: 1;
27
+ readonly requestId: string;
28
+ readonly topicId: string;
29
+ readonly topicRevision: string;
30
+ readonly actionType: string;
31
+ readonly actionContractDigest: Sha256Uri;
32
+ readonly executor: TopicActionRuntimeProvider;
33
+ readonly inputs: {
34
+ readonly digest: Sha256Uri;
35
+ readonly ref?: string;
36
+ };
37
+ readonly requestedBy: string;
38
+ readonly requestedAt: string;
39
+ readonly idempotencyKey: string;
40
+ readonly confirmation: "not-required" | "required" | "confirmed";
41
+ readonly flowBindingId?: string;
42
+ readonly capability: string;
43
+ }
44
+ export interface ActionReceiptReference {
45
+ readonly digest: Sha256Uri;
46
+ readonly ref?: string;
47
+ readonly summary?: Readonly<Record<string, unknown>>;
48
+ }
49
+ export interface ActionReceiptV2 {
50
+ readonly version: 2;
51
+ readonly receiptId: string;
52
+ readonly sequence: number;
53
+ readonly requestId: string;
54
+ readonly topicId: string;
55
+ readonly topicRevision: string;
56
+ readonly action: {
57
+ readonly type: string;
58
+ readonly can: string;
59
+ readonly registryVersion: string;
60
+ readonly contractDigest: Sha256Uri;
61
+ };
62
+ readonly runtime: {
63
+ readonly provider: TopicActionRuntimeProvider;
64
+ readonly bindingId?: string;
65
+ readonly flowUri?: string;
66
+ readonly sessionRunId?: string;
67
+ readonly nodeId?: string;
68
+ readonly executionId: string;
69
+ };
70
+ readonly actorDid: string;
71
+ readonly executorDid: string;
72
+ readonly status: TopicActionStatus;
73
+ readonly idempotencyKey: string;
74
+ readonly occurredAt: string;
75
+ readonly authorization: {
76
+ readonly capability: string;
77
+ readonly invocation?: string;
78
+ readonly confirmation?: string;
79
+ };
80
+ readonly input: ActionReceiptReference;
81
+ readonly output?: ActionReceiptReference;
82
+ readonly proof?: {
83
+ readonly kind: "fields" | "custom" | "host-receipt";
84
+ readonly digest: Sha256Uri;
85
+ readonly refs?: readonly string[];
86
+ };
87
+ readonly evidenceRefs?: readonly string[];
88
+ readonly traceRef?: string;
89
+ readonly error?: {
90
+ readonly code?: string;
91
+ readonly message: string;
92
+ };
93
+ readonly issuerDid: string;
94
+ readonly signature: string;
95
+ }
96
+ export interface ProjectedTopicAction {
97
+ readonly request: TopicActionRequestV1;
98
+ readonly latestReceipt?: ActionReceiptV2;
99
+ readonly status: TopicActionStatus;
100
+ readonly operationId: string;
101
+ }
@@ -0,0 +1,12 @@
1
+ export const TOPIC_ACTION_RUNTIME_PROVIDERS = ["qi-flow", "qiforge", "mcp"];
2
+ export const TOPIC_ACTION_STATUSES = [
3
+ "requested",
4
+ "awaiting_confirmation",
5
+ "running",
6
+ "succeeded",
7
+ "failed",
8
+ "rejected",
9
+ "cancelled",
10
+ "needs_verification",
11
+ ];
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/action-runtime/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW;IACX,uBAAuB;IACvB,SAAS;IACT,WAAW;IACX,QAAQ;IACR,UAAU;IACV,WAAW;IACX,oBAAoB;CACZ,CAAC"}