@contractspec/example.kb-update-pipeline 3.7.17 → 3.7.18

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 (45) hide show
  1. package/.turbo/turbo-build.log +45 -45
  2. package/CHANGELOG.md +10 -0
  3. package/dist/browser/docs/index.js +3 -27
  4. package/dist/browser/docs/kb-update-pipeline.docblock.js +3 -27
  5. package/dist/browser/entities/index.js +1 -56
  6. package/dist/browser/entities/models.js +1 -56
  7. package/dist/browser/events.js +1 -128
  8. package/dist/browser/example.js +1 -35
  9. package/dist/browser/handlers/index.js +1 -109
  10. package/dist/browser/handlers/memory.handlers.js +1 -109
  11. package/dist/browser/index.js +3 -636
  12. package/dist/browser/kb-update-pipeline.feature.js +1 -68
  13. package/dist/browser/operations/index.js +1 -199
  14. package/dist/browser/operations/pipeline.js +1 -199
  15. package/dist/browser/presentations.js +1 -123
  16. package/dist/browser/tests/operations.test-spec.js +1 -85
  17. package/dist/docs/index.js +3 -27
  18. package/dist/docs/kb-update-pipeline.docblock.js +3 -27
  19. package/dist/entities/index.js +1 -56
  20. package/dist/entities/models.js +1 -56
  21. package/dist/events.js +1 -128
  22. package/dist/example.js +1 -35
  23. package/dist/handlers/index.js +1 -109
  24. package/dist/handlers/memory.handlers.js +1 -109
  25. package/dist/index.js +3 -636
  26. package/dist/kb-update-pipeline.feature.js +1 -68
  27. package/dist/node/docs/index.js +3 -27
  28. package/dist/node/docs/kb-update-pipeline.docblock.js +3 -27
  29. package/dist/node/entities/index.js +1 -56
  30. package/dist/node/entities/models.js +1 -56
  31. package/dist/node/events.js +1 -128
  32. package/dist/node/example.js +1 -35
  33. package/dist/node/handlers/index.js +1 -109
  34. package/dist/node/handlers/memory.handlers.js +1 -109
  35. package/dist/node/index.js +3 -636
  36. package/dist/node/kb-update-pipeline.feature.js +1 -68
  37. package/dist/node/operations/index.js +1 -199
  38. package/dist/node/operations/pipeline.js +1 -199
  39. package/dist/node/presentations.js +1 -123
  40. package/dist/node/tests/operations.test-spec.js +1 -85
  41. package/dist/operations/index.js +1 -199
  42. package/dist/operations/pipeline.js +1 -199
  43. package/dist/presentations.js +1 -123
  44. package/dist/tests/operations.test-spec.js +1 -85
  45. package/package.json +5 -5
@@ -1,85 +1 @@
1
- // src/tests/operations.test-spec.ts
2
- import { defineTestSpec } from "@contractspec/lib.contracts-spec/tests";
3
- var RunWatchTest = defineTestSpec({
4
- meta: {
5
- key: "kbPipeline.runWatch.test",
6
- version: "1.0.0",
7
- stability: "experimental",
8
- owners: ["@example.kb-update-pipeline"],
9
- description: "Test for run watch operation",
10
- tags: ["test"]
11
- },
12
- target: {
13
- type: "operation",
14
- operation: { key: "kbPipeline.runWatch", version: "1.0.0" }
15
- },
16
- scenarios: [
17
- {
18
- key: "success",
19
- when: { operation: { key: "kbPipeline.runWatch" } },
20
- then: [{ type: "expectOutput", match: {} }]
21
- },
22
- {
23
- key: "error",
24
- when: { operation: { key: "kbPipeline.runWatch" } },
25
- then: [{ type: "expectError" }]
26
- }
27
- ]
28
- });
29
- var CreateReviewTaskTest = defineTestSpec({
30
- meta: {
31
- key: "kbPipeline.createReviewTask.test",
32
- version: "1.0.0",
33
- stability: "experimental",
34
- owners: ["@example.kb-update-pipeline"],
35
- description: "Test for creating review task",
36
- tags: ["test"]
37
- },
38
- target: {
39
- type: "operation",
40
- operation: { key: "kbPipeline.createReviewTask", version: "1.0.0" }
41
- },
42
- scenarios: [
43
- {
44
- key: "success",
45
- when: { operation: { key: "kbPipeline.createReviewTask" } },
46
- then: [{ type: "expectOutput", match: {} }]
47
- },
48
- {
49
- key: "error",
50
- when: { operation: { key: "kbPipeline.createReviewTask" } },
51
- then: [{ type: "expectError" }]
52
- }
53
- ]
54
- });
55
- var SubmitDecisionTest = defineTestSpec({
56
- meta: {
57
- key: "kbPipeline.submitDecision.test",
58
- version: "1.0.0",
59
- stability: "experimental",
60
- owners: ["@example.kb-update-pipeline"],
61
- description: "Test for submitting decision",
62
- tags: ["test"]
63
- },
64
- target: {
65
- type: "operation",
66
- operation: { key: "kbPipeline.submitDecision", version: "1.0.0" }
67
- },
68
- scenarios: [
69
- {
70
- key: "success",
71
- when: { operation: { key: "kbPipeline.submitDecision" } },
72
- then: [{ type: "expectOutput", match: {} }]
73
- },
74
- {
75
- key: "error",
76
- when: { operation: { key: "kbPipeline.submitDecision" } },
77
- then: [{ type: "expectError" }]
78
- }
79
- ]
80
- });
81
- export {
82
- SubmitDecisionTest,
83
- RunWatchTest,
84
- CreateReviewTaskTest
85
- };
1
+ import{defineTestSpec as g}from"@contractspec/lib.contracts-spec/tests";var j=g({meta:{key:"kbPipeline.runWatch.test",version:"1.0.0",stability:"experimental",owners:["@example.kb-update-pipeline"],description:"Test for run watch operation",tags:["test"]},target:{type:"operation",operation:{key:"kbPipeline.runWatch",version:"1.0.0"}},scenarios:[{key:"success",when:{operation:{key:"kbPipeline.runWatch"}},then:[{type:"expectOutput",match:{}}]},{key:"error",when:{operation:{key:"kbPipeline.runWatch"}},then:[{type:"expectError"}]}]}),k=g({meta:{key:"kbPipeline.createReviewTask.test",version:"1.0.0",stability:"experimental",owners:["@example.kb-update-pipeline"],description:"Test for creating review task",tags:["test"]},target:{type:"operation",operation:{key:"kbPipeline.createReviewTask",version:"1.0.0"}},scenarios:[{key:"success",when:{operation:{key:"kbPipeline.createReviewTask"}},then:[{type:"expectOutput",match:{}}]},{key:"error",when:{operation:{key:"kbPipeline.createReviewTask"}},then:[{type:"expectError"}]}]}),m=g({meta:{key:"kbPipeline.submitDecision.test",version:"1.0.0",stability:"experimental",owners:["@example.kb-update-pipeline"],description:"Test for submitting decision",tags:["test"]},target:{type:"operation",operation:{key:"kbPipeline.submitDecision",version:"1.0.0"}},scenarios:[{key:"success",when:{operation:{key:"kbPipeline.submitDecision"}},then:[{type:"expectOutput",match:{}}]},{key:"error",when:{operation:{key:"kbPipeline.submitDecision"}},then:[{type:"expectError"}]}]});export{m as SubmitDecisionTest,j as RunWatchTest,k as CreateReviewTaskTest};
@@ -1,200 +1,2 @@
1
1
  // @bun
2
- // src/entities/models.ts
3
- import {
4
- defineEnum,
5
- defineSchemaModel,
6
- ScalarTypeEnum
7
- } from "@contractspec/lib.schema";
8
- var ChangeRiskLevelEnum = defineEnum("ChangeRiskLevel", [
9
- "low",
10
- "medium",
11
- "high"
12
- ]);
13
- var ReviewAssignedRoleEnum = defineEnum("ReviewAssignedRole", [
14
- "curator",
15
- "expert"
16
- ]);
17
- var ReviewDecisionEnum = defineEnum("ReviewDecision", [
18
- "approve",
19
- "reject"
20
- ]);
21
- var ChangeCandidateModel = defineSchemaModel({
22
- name: "ChangeCandidate",
23
- description: "Candidate change detected in a source document.",
24
- fields: {
25
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
- sourceDocumentId: {
27
- type: ScalarTypeEnum.String_unsecure(),
28
- isOptional: false
29
- },
30
- detectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
31
- diffSummary: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
- riskLevel: { type: ChangeRiskLevelEnum, isOptional: false }
33
- }
34
- });
35
- var ReviewTaskModel = defineSchemaModel({
36
- name: "ReviewTask",
37
- description: "Human verification task for a change candidate.",
38
- fields: {
39
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
- changeCandidateId: {
41
- type: ScalarTypeEnum.String_unsecure(),
42
- isOptional: false
43
- },
44
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
- assignedRole: { type: ReviewAssignedRoleEnum, isOptional: false },
46
- decision: { type: ReviewDecisionEnum, isOptional: true },
47
- decidedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
48
- decidedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
49
- }
50
- });
51
-
52
- // src/operations/pipeline.ts
53
- import { defineCommand } from "@contractspec/lib.contracts-spec";
54
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
55
- var RunWatchInput = defineSchemaModel2({
56
- name: "KbPipelineRunWatchInput",
57
- description: "Trigger a watch cycle for KB sources (demo).",
58
- fields: {
59
- jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
60
- }
61
- });
62
- var RunWatchOutput = defineSchemaModel2({
63
- name: "KbPipelineRunWatchOutput",
64
- description: "Output containing detected changes.",
65
- fields: {
66
- candidates: {
67
- type: ChangeCandidateModel,
68
- isArray: true,
69
- isOptional: false
70
- }
71
- }
72
- });
73
- var CreateReviewTaskInput = defineSchemaModel2({
74
- name: "KbPipelineCreateReviewTaskInput",
75
- description: "Create a review task for a change candidate.",
76
- fields: {
77
- changeCandidateId: {
78
- type: ScalarTypeEnum2.String_unsecure(),
79
- isOptional: false
80
- }
81
- }
82
- });
83
- var SubmitDecisionInput = defineSchemaModel2({
84
- name: "KbPipelineSubmitDecisionInput",
85
- description: "Submit a decision for a review task.",
86
- fields: {
87
- reviewTaskId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
88
- decision: { type: ReviewDecisionEnum, isOptional: false },
89
- decidedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
90
- decidedByRole: {
91
- type: ScalarTypeEnum2.String_unsecure(),
92
- isOptional: false
93
- }
94
- }
95
- });
96
- var PublishIfReadyInput = defineSchemaModel2({
97
- name: "KbPipelinePublishIfReadyInput",
98
- description: "Publish snapshot if approvals are satisfied for a jurisdiction.",
99
- fields: {
100
- jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
101
- }
102
- });
103
- var PublishIfReadyOutput = defineSchemaModel2({
104
- name: "KbPipelinePublishIfReadyOutput",
105
- description: "Output for publish-if-ready operation.",
106
- fields: {
107
- published: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
108
- reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
109
- }
110
- });
111
- var KbPipelineRunWatchContract = defineCommand({
112
- meta: {
113
- key: "kbPipeline.runWatch",
114
- version: "1.0.0",
115
- stability: "experimental",
116
- owners: ["@examples"],
117
- tags: ["knowledge", "pipeline", "jobs"],
118
- description: "Detect source changes and create change candidates.",
119
- goal: "Automate discovery of updates needing review.",
120
- context: "Scheduled job or manual trigger in demos."
121
- },
122
- io: { input: RunWatchInput, output: RunWatchOutput },
123
- policy: { auth: "user" }
124
- });
125
- var KbPipelineCreateReviewTaskContract = defineCommand({
126
- meta: {
127
- key: "kbPipeline.createReviewTask",
128
- version: "1.0.0",
129
- stability: "experimental",
130
- owners: ["@examples"],
131
- tags: ["knowledge", "pipeline", "hitl"],
132
- description: "Create a review task for a detected change.",
133
- goal: "Route work to human verifiers.",
134
- context: "Called after change detection or manual selection."
135
- },
136
- io: { input: CreateReviewTaskInput, output: ReviewTaskModel },
137
- policy: { auth: "user" }
138
- });
139
- var KbPipelineSubmitDecisionContract = defineCommand({
140
- meta: {
141
- key: "kbPipeline.submitDecision",
142
- version: "1.0.0",
143
- stability: "experimental",
144
- owners: ["@examples"],
145
- tags: ["knowledge", "pipeline", "hitl", "rbac"],
146
- description: "Submit approve/reject decision for a review task.",
147
- goal: "Ensure humans verify before publishing.",
148
- context: "Curator/expert reviews and decides."
149
- },
150
- io: {
151
- input: SubmitDecisionInput,
152
- output: ReviewTaskModel,
153
- errors: {
154
- FORBIDDEN_ROLE: {
155
- description: "Role not allowed to approve the given risk level",
156
- http: 403,
157
- gqlCode: "FORBIDDEN_ROLE",
158
- when: "curator attempts to approve a high-risk change"
159
- },
160
- REVIEW_TASK_NOT_FOUND: {
161
- description: "Review task not found",
162
- http: 404,
163
- gqlCode: "REVIEW_TASK_NOT_FOUND",
164
- when: "reviewTaskId is invalid"
165
- }
166
- }
167
- },
168
- policy: { auth: "user" }
169
- });
170
- var KbPipelinePublishIfReadyContract = defineCommand({
171
- meta: {
172
- key: "kbPipeline.publishIfReady",
173
- version: "1.0.0",
174
- stability: "experimental",
175
- owners: ["@examples"],
176
- tags: ["knowledge", "pipeline", "publishing"],
177
- description: "Publish snapshot if ready (all approvals satisfied).",
178
- goal: "Prevent publishing until all required approvals exist.",
179
- context: "Called by job or UI to attempt publish."
180
- },
181
- io: {
182
- input: PublishIfReadyInput,
183
- output: PublishIfReadyOutput,
184
- errors: {
185
- NOT_READY: {
186
- description: "Publishing is blocked because approvals are incomplete",
187
- http: 409,
188
- gqlCode: "NOT_READY",
189
- when: "there are open review tasks or unapproved rule versions"
190
- }
191
- }
192
- },
193
- policy: { auth: "user" }
194
- });
195
- export {
196
- KbPipelineSubmitDecisionContract,
197
- KbPipelineRunWatchContract,
198
- KbPipelinePublishIfReadyContract,
199
- KbPipelineCreateReviewTaskContract
200
- };
2
+ import{defineEnum as n,defineSchemaModel as p,ScalarTypeEnum as e}from"@contractspec/lib.schema";var a=n("ChangeRiskLevel",["low","medium","high"]),d=n("ReviewAssignedRole",["curator","expert"]),r=n("ReviewDecision",["approve","reject"]),g=p({name:"ChangeCandidate",description:"Candidate change detected in a source document.",fields:{id:{type:e.String_unsecure(),isOptional:!1},sourceDocumentId:{type:e.String_unsecure(),isOptional:!1},detectedAt:{type:e.DateTime(),isOptional:!1},diffSummary:{type:e.String_unsecure(),isOptional:!1},riskLevel:{type:a,isOptional:!1}}}),o=p({name:"ReviewTask",description:"Human verification task for a change candidate.",fields:{id:{type:e.String_unsecure(),isOptional:!1},changeCandidateId:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},assignedRole:{type:d,isOptional:!1},decision:{type:r,isOptional:!0},decidedAt:{type:e.DateTime(),isOptional:!0},decidedBy:{type:e.String_unsecure(),isOptional:!0}}});import{defineCommand as s}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as t,ScalarTypeEnum as i}from"@contractspec/lib.schema";var l=t({name:"KbPipelineRunWatchInput",description:"Trigger a watch cycle for KB sources (demo).",fields:{jurisdiction:{type:i.String_unsecure(),isOptional:!1}}}),O=t({name:"KbPipelineRunWatchOutput",description:"Output containing detected changes.",fields:{candidates:{type:g,isArray:!0,isOptional:!1}}}),u=t({name:"KbPipelineCreateReviewTaskInput",description:"Create a review task for a change candidate.",fields:{changeCandidateId:{type:i.String_unsecure(),isOptional:!1}}}),f=t({name:"KbPipelineSubmitDecisionInput",description:"Submit a decision for a review task.",fields:{reviewTaskId:{type:i.String_unsecure(),isOptional:!1},decision:{type:r,isOptional:!1},decidedBy:{type:i.String_unsecure(),isOptional:!1},decidedByRole:{type:i.String_unsecure(),isOptional:!1}}}),v=t({name:"KbPipelinePublishIfReadyInput",description:"Publish snapshot if approvals are satisfied for a jurisdiction.",fields:{jurisdiction:{type:i.String_unsecure(),isOptional:!1}}}),x=t({name:"KbPipelinePublishIfReadyOutput",description:"Output for publish-if-ready operation.",fields:{published:{type:i.Boolean(),isOptional:!1},reason:{type:i.String_unsecure(),isOptional:!0}}}),w=s({meta:{key:"kbPipeline.runWatch",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","jobs"],description:"Detect source changes and create change candidates.",goal:"Automate discovery of updates needing review.",context:"Scheduled job or manual trigger in demos."},io:{input:l,output:O},policy:{auth:"user"}}),D=s({meta:{key:"kbPipeline.createReviewTask",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","hitl"],description:"Create a review task for a detected change.",goal:"Route work to human verifiers.",context:"Called after change detection or manual selection."},io:{input:u,output:o},policy:{auth:"user"}}),L=s({meta:{key:"kbPipeline.submitDecision",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","hitl","rbac"],description:"Submit approve/reject decision for a review task.",goal:"Ensure humans verify before publishing.",context:"Curator/expert reviews and decides."},io:{input:f,output:o,errors:{FORBIDDEN_ROLE:{description:"Role not allowed to approve the given risk level",http:403,gqlCode:"FORBIDDEN_ROLE",when:"curator attempts to approve a high-risk change"},REVIEW_TASK_NOT_FOUND:{description:"Review task not found",http:404,gqlCode:"REVIEW_TASK_NOT_FOUND",when:"reviewTaskId is invalid"}}},policy:{auth:"user"}}),R=s({meta:{key:"kbPipeline.publishIfReady",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","publishing"],description:"Publish snapshot if ready (all approvals satisfied).",goal:"Prevent publishing until all required approvals exist.",context:"Called by job or UI to attempt publish."},io:{input:v,output:x,errors:{NOT_READY:{description:"Publishing is blocked because approvals are incomplete",http:409,gqlCode:"NOT_READY",when:"there are open review tasks or unapproved rule versions"}}},policy:{auth:"user"}});export{L as KbPipelineSubmitDecisionContract,w as KbPipelineRunWatchContract,R as KbPipelinePublishIfReadyContract,D as KbPipelineCreateReviewTaskContract};
@@ -1,200 +1,2 @@
1
1
  // @bun
2
- // src/entities/models.ts
3
- import {
4
- defineEnum,
5
- defineSchemaModel,
6
- ScalarTypeEnum
7
- } from "@contractspec/lib.schema";
8
- var ChangeRiskLevelEnum = defineEnum("ChangeRiskLevel", [
9
- "low",
10
- "medium",
11
- "high"
12
- ]);
13
- var ReviewAssignedRoleEnum = defineEnum("ReviewAssignedRole", [
14
- "curator",
15
- "expert"
16
- ]);
17
- var ReviewDecisionEnum = defineEnum("ReviewDecision", [
18
- "approve",
19
- "reject"
20
- ]);
21
- var ChangeCandidateModel = defineSchemaModel({
22
- name: "ChangeCandidate",
23
- description: "Candidate change detected in a source document.",
24
- fields: {
25
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
- sourceDocumentId: {
27
- type: ScalarTypeEnum.String_unsecure(),
28
- isOptional: false
29
- },
30
- detectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
31
- diffSummary: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
- riskLevel: { type: ChangeRiskLevelEnum, isOptional: false }
33
- }
34
- });
35
- var ReviewTaskModel = defineSchemaModel({
36
- name: "ReviewTask",
37
- description: "Human verification task for a change candidate.",
38
- fields: {
39
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
- changeCandidateId: {
41
- type: ScalarTypeEnum.String_unsecure(),
42
- isOptional: false
43
- },
44
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
- assignedRole: { type: ReviewAssignedRoleEnum, isOptional: false },
46
- decision: { type: ReviewDecisionEnum, isOptional: true },
47
- decidedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
48
- decidedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
49
- }
50
- });
51
-
52
- // src/operations/pipeline.ts
53
- import { defineCommand } from "@contractspec/lib.contracts-spec";
54
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
55
- var RunWatchInput = defineSchemaModel2({
56
- name: "KbPipelineRunWatchInput",
57
- description: "Trigger a watch cycle for KB sources (demo).",
58
- fields: {
59
- jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
60
- }
61
- });
62
- var RunWatchOutput = defineSchemaModel2({
63
- name: "KbPipelineRunWatchOutput",
64
- description: "Output containing detected changes.",
65
- fields: {
66
- candidates: {
67
- type: ChangeCandidateModel,
68
- isArray: true,
69
- isOptional: false
70
- }
71
- }
72
- });
73
- var CreateReviewTaskInput = defineSchemaModel2({
74
- name: "KbPipelineCreateReviewTaskInput",
75
- description: "Create a review task for a change candidate.",
76
- fields: {
77
- changeCandidateId: {
78
- type: ScalarTypeEnum2.String_unsecure(),
79
- isOptional: false
80
- }
81
- }
82
- });
83
- var SubmitDecisionInput = defineSchemaModel2({
84
- name: "KbPipelineSubmitDecisionInput",
85
- description: "Submit a decision for a review task.",
86
- fields: {
87
- reviewTaskId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
88
- decision: { type: ReviewDecisionEnum, isOptional: false },
89
- decidedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
90
- decidedByRole: {
91
- type: ScalarTypeEnum2.String_unsecure(),
92
- isOptional: false
93
- }
94
- }
95
- });
96
- var PublishIfReadyInput = defineSchemaModel2({
97
- name: "KbPipelinePublishIfReadyInput",
98
- description: "Publish snapshot if approvals are satisfied for a jurisdiction.",
99
- fields: {
100
- jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
101
- }
102
- });
103
- var PublishIfReadyOutput = defineSchemaModel2({
104
- name: "KbPipelinePublishIfReadyOutput",
105
- description: "Output for publish-if-ready operation.",
106
- fields: {
107
- published: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
108
- reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
109
- }
110
- });
111
- var KbPipelineRunWatchContract = defineCommand({
112
- meta: {
113
- key: "kbPipeline.runWatch",
114
- version: "1.0.0",
115
- stability: "experimental",
116
- owners: ["@examples"],
117
- tags: ["knowledge", "pipeline", "jobs"],
118
- description: "Detect source changes and create change candidates.",
119
- goal: "Automate discovery of updates needing review.",
120
- context: "Scheduled job or manual trigger in demos."
121
- },
122
- io: { input: RunWatchInput, output: RunWatchOutput },
123
- policy: { auth: "user" }
124
- });
125
- var KbPipelineCreateReviewTaskContract = defineCommand({
126
- meta: {
127
- key: "kbPipeline.createReviewTask",
128
- version: "1.0.0",
129
- stability: "experimental",
130
- owners: ["@examples"],
131
- tags: ["knowledge", "pipeline", "hitl"],
132
- description: "Create a review task for a detected change.",
133
- goal: "Route work to human verifiers.",
134
- context: "Called after change detection or manual selection."
135
- },
136
- io: { input: CreateReviewTaskInput, output: ReviewTaskModel },
137
- policy: { auth: "user" }
138
- });
139
- var KbPipelineSubmitDecisionContract = defineCommand({
140
- meta: {
141
- key: "kbPipeline.submitDecision",
142
- version: "1.0.0",
143
- stability: "experimental",
144
- owners: ["@examples"],
145
- tags: ["knowledge", "pipeline", "hitl", "rbac"],
146
- description: "Submit approve/reject decision for a review task.",
147
- goal: "Ensure humans verify before publishing.",
148
- context: "Curator/expert reviews and decides."
149
- },
150
- io: {
151
- input: SubmitDecisionInput,
152
- output: ReviewTaskModel,
153
- errors: {
154
- FORBIDDEN_ROLE: {
155
- description: "Role not allowed to approve the given risk level",
156
- http: 403,
157
- gqlCode: "FORBIDDEN_ROLE",
158
- when: "curator attempts to approve a high-risk change"
159
- },
160
- REVIEW_TASK_NOT_FOUND: {
161
- description: "Review task not found",
162
- http: 404,
163
- gqlCode: "REVIEW_TASK_NOT_FOUND",
164
- when: "reviewTaskId is invalid"
165
- }
166
- }
167
- },
168
- policy: { auth: "user" }
169
- });
170
- var KbPipelinePublishIfReadyContract = defineCommand({
171
- meta: {
172
- key: "kbPipeline.publishIfReady",
173
- version: "1.0.0",
174
- stability: "experimental",
175
- owners: ["@examples"],
176
- tags: ["knowledge", "pipeline", "publishing"],
177
- description: "Publish snapshot if ready (all approvals satisfied).",
178
- goal: "Prevent publishing until all required approvals exist.",
179
- context: "Called by job or UI to attempt publish."
180
- },
181
- io: {
182
- input: PublishIfReadyInput,
183
- output: PublishIfReadyOutput,
184
- errors: {
185
- NOT_READY: {
186
- description: "Publishing is blocked because approvals are incomplete",
187
- http: 409,
188
- gqlCode: "NOT_READY",
189
- when: "there are open review tasks or unapproved rule versions"
190
- }
191
- }
192
- },
193
- policy: { auth: "user" }
194
- });
195
- export {
196
- KbPipelineSubmitDecisionContract,
197
- KbPipelineRunWatchContract,
198
- KbPipelinePublishIfReadyContract,
199
- KbPipelineCreateReviewTaskContract
200
- };
2
+ import{defineEnum as n,defineSchemaModel as p,ScalarTypeEnum as e}from"@contractspec/lib.schema";var a=n("ChangeRiskLevel",["low","medium","high"]),d=n("ReviewAssignedRole",["curator","expert"]),r=n("ReviewDecision",["approve","reject"]),g=p({name:"ChangeCandidate",description:"Candidate change detected in a source document.",fields:{id:{type:e.String_unsecure(),isOptional:!1},sourceDocumentId:{type:e.String_unsecure(),isOptional:!1},detectedAt:{type:e.DateTime(),isOptional:!1},diffSummary:{type:e.String_unsecure(),isOptional:!1},riskLevel:{type:a,isOptional:!1}}}),o=p({name:"ReviewTask",description:"Human verification task for a change candidate.",fields:{id:{type:e.String_unsecure(),isOptional:!1},changeCandidateId:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},assignedRole:{type:d,isOptional:!1},decision:{type:r,isOptional:!0},decidedAt:{type:e.DateTime(),isOptional:!0},decidedBy:{type:e.String_unsecure(),isOptional:!0}}});import{defineCommand as s}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as t,ScalarTypeEnum as i}from"@contractspec/lib.schema";var l=t({name:"KbPipelineRunWatchInput",description:"Trigger a watch cycle for KB sources (demo).",fields:{jurisdiction:{type:i.String_unsecure(),isOptional:!1}}}),O=t({name:"KbPipelineRunWatchOutput",description:"Output containing detected changes.",fields:{candidates:{type:g,isArray:!0,isOptional:!1}}}),u=t({name:"KbPipelineCreateReviewTaskInput",description:"Create a review task for a change candidate.",fields:{changeCandidateId:{type:i.String_unsecure(),isOptional:!1}}}),v=t({name:"KbPipelineSubmitDecisionInput",description:"Submit a decision for a review task.",fields:{reviewTaskId:{type:i.String_unsecure(),isOptional:!1},decision:{type:r,isOptional:!1},decidedBy:{type:i.String_unsecure(),isOptional:!1},decidedByRole:{type:i.String_unsecure(),isOptional:!1}}}),_=t({name:"KbPipelinePublishIfReadyInput",description:"Publish snapshot if approvals are satisfied for a jurisdiction.",fields:{jurisdiction:{type:i.String_unsecure(),isOptional:!1}}}),c=t({name:"KbPipelinePublishIfReadyOutput",description:"Output for publish-if-ready operation.",fields:{published:{type:i.Boolean(),isOptional:!1},reason:{type:i.String_unsecure(),isOptional:!0}}}),w=s({meta:{key:"kbPipeline.runWatch",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","jobs"],description:"Detect source changes and create change candidates.",goal:"Automate discovery of updates needing review.",context:"Scheduled job or manual trigger in demos."},io:{input:l,output:O},policy:{auth:"user"}}),D=s({meta:{key:"kbPipeline.createReviewTask",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","hitl"],description:"Create a review task for a detected change.",goal:"Route work to human verifiers.",context:"Called after change detection or manual selection."},io:{input:u,output:o},policy:{auth:"user"}}),L=s({meta:{key:"kbPipeline.submitDecision",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","hitl","rbac"],description:"Submit approve/reject decision for a review task.",goal:"Ensure humans verify before publishing.",context:"Curator/expert reviews and decides."},io:{input:v,output:o,errors:{FORBIDDEN_ROLE:{description:"Role not allowed to approve the given risk level",http:403,gqlCode:"FORBIDDEN_ROLE",when:"curator attempts to approve a high-risk change"},REVIEW_TASK_NOT_FOUND:{description:"Review task not found",http:404,gqlCode:"REVIEW_TASK_NOT_FOUND",when:"reviewTaskId is invalid"}}},policy:{auth:"user"}}),R=s({meta:{key:"kbPipeline.publishIfReady",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","pipeline","publishing"],description:"Publish snapshot if ready (all approvals satisfied).",goal:"Prevent publishing until all required approvals exist.",context:"Called by job or UI to attempt publish."},io:{input:_,output:c,errors:{NOT_READY:{description:"Publishing is blocked because approvals are incomplete",http:409,gqlCode:"NOT_READY",when:"there are open review tasks or unapproved rule versions"}}},policy:{auth:"user"}});export{L as KbPipelineSubmitDecisionContract,w as KbPipelineRunWatchContract,R as KbPipelinePublishIfReadyContract,D as KbPipelineCreateReviewTaskContract};
@@ -1,124 +1,2 @@
1
1
  // @bun
2
- // src/entities/models.ts
3
- import {
4
- defineEnum,
5
- defineSchemaModel,
6
- ScalarTypeEnum
7
- } from "@contractspec/lib.schema";
8
- var ChangeRiskLevelEnum = defineEnum("ChangeRiskLevel", [
9
- "low",
10
- "medium",
11
- "high"
12
- ]);
13
- var ReviewAssignedRoleEnum = defineEnum("ReviewAssignedRole", [
14
- "curator",
15
- "expert"
16
- ]);
17
- var ReviewDecisionEnum = defineEnum("ReviewDecision", [
18
- "approve",
19
- "reject"
20
- ]);
21
- var ChangeCandidateModel = defineSchemaModel({
22
- name: "ChangeCandidate",
23
- description: "Candidate change detected in a source document.",
24
- fields: {
25
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
- sourceDocumentId: {
27
- type: ScalarTypeEnum.String_unsecure(),
28
- isOptional: false
29
- },
30
- detectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
31
- diffSummary: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
- riskLevel: { type: ChangeRiskLevelEnum, isOptional: false }
33
- }
34
- });
35
- var ReviewTaskModel = defineSchemaModel({
36
- name: "ReviewTask",
37
- description: "Human verification task for a change candidate.",
38
- fields: {
39
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
- changeCandidateId: {
41
- type: ScalarTypeEnum.String_unsecure(),
42
- isOptional: false
43
- },
44
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
- assignedRole: { type: ReviewAssignedRoleEnum, isOptional: false },
46
- decision: { type: ReviewDecisionEnum, isOptional: true },
47
- decidedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
48
- decidedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
49
- }
50
- });
51
-
52
- // src/presentations.ts
53
- import {
54
- definePresentation,
55
- StabilityEnum
56
- } from "@contractspec/lib.contracts-spec";
57
- var KbDashboardPresentation = definePresentation({
58
- meta: {
59
- key: "kb.dashboard",
60
- version: "1.0.0",
61
- title: "KB Update Dashboard",
62
- description: "Overview of KB change candidates and review tasks.",
63
- domain: "knowledge",
64
- owners: ["@examples"],
65
- tags: ["dashboard", "knowledge"],
66
- stability: StabilityEnum.Experimental,
67
- goal: "Visualize status",
68
- context: "Dashboard"
69
- },
70
- source: {
71
- type: "component",
72
- framework: "react",
73
- componentKey: "KbDashboard",
74
- props: ChangeCandidateModel
75
- },
76
- targets: ["react", "markdown"]
77
- });
78
- var KbReviewListPresentation = definePresentation({
79
- meta: {
80
- key: "kb.review.list",
81
- version: "1.0.0",
82
- title: "Review Tasks",
83
- description: "List of pending review tasks for the current user.",
84
- domain: "knowledge",
85
- owners: ["@examples"],
86
- tags: ["list", "review"],
87
- stability: StabilityEnum.Experimental,
88
- goal: "List tasks",
89
- context: "Inbox"
90
- },
91
- source: {
92
- type: "component",
93
- framework: "react",
94
- componentKey: "ReviewTaskList",
95
- props: ReviewTaskModel
96
- },
97
- targets: ["react", "markdown"]
98
- });
99
- var KbReviewFormPresentation = definePresentation({
100
- meta: {
101
- key: "kb.review.form",
102
- version: "1.0.0",
103
- title: "Review Change",
104
- description: "Form to approve or reject a KB change candidate.",
105
- domain: "knowledge",
106
- owners: ["@examples"],
107
- tags: ["form", "review"],
108
- stability: StabilityEnum.Experimental,
109
- goal: "Review",
110
- context: "Detail"
111
- },
112
- source: {
113
- type: "component",
114
- framework: "react",
115
- componentKey: "ReviewDecisionForm",
116
- props: ReviewTaskModel
117
- },
118
- targets: ["react"]
119
- });
120
- export {
121
- KbReviewListPresentation,
122
- KbReviewFormPresentation,
123
- KbDashboardPresentation
124
- };
2
+ import{defineEnum as i,defineSchemaModel as a,ScalarTypeEnum as e}from"@contractspec/lib.schema";var p=i("ChangeRiskLevel",["low","medium","high"]),r=i("ReviewAssignedRole",["curator","expert"]),d=i("ReviewDecision",["approve","reject"]),o=a({name:"ChangeCandidate",description:"Candidate change detected in a source document.",fields:{id:{type:e.String_unsecure(),isOptional:!1},sourceDocumentId:{type:e.String_unsecure(),isOptional:!1},detectedAt:{type:e.DateTime(),isOptional:!1},diffSummary:{type:e.String_unsecure(),isOptional:!1},riskLevel:{type:p,isOptional:!1}}}),t=a({name:"ReviewTask",description:"Human verification task for a change candidate.",fields:{id:{type:e.String_unsecure(),isOptional:!1},changeCandidateId:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},assignedRole:{type:r,isOptional:!1},decision:{type:d,isOptional:!0},decidedAt:{type:e.DateTime(),isOptional:!0},decidedBy:{type:e.String_unsecure(),isOptional:!0}}});import{definePresentation as n,StabilityEnum as s}from"@contractspec/lib.contracts-spec";var f=n({meta:{key:"kb.dashboard",version:"1.0.0",title:"KB Update Dashboard",description:"Overview of KB change candidates and review tasks.",domain:"knowledge",owners:["@examples"],tags:["dashboard","knowledge"],stability:s.Experimental,goal:"Visualize status",context:"Dashboard"},source:{type:"component",framework:"react",componentKey:"KbDashboard",props:o},targets:["react","markdown"]}),m=n({meta:{key:"kb.review.list",version:"1.0.0",title:"Review Tasks",description:"List of pending review tasks for the current user.",domain:"knowledge",owners:["@examples"],tags:["list","review"],stability:s.Experimental,goal:"List tasks",context:"Inbox"},source:{type:"component",framework:"react",componentKey:"ReviewTaskList",props:t},targets:["react","markdown"]}),y=n({meta:{key:"kb.review.form",version:"1.0.0",title:"Review Change",description:"Form to approve or reject a KB change candidate.",domain:"knowledge",owners:["@examples"],tags:["form","review"],stability:s.Experimental,goal:"Review",context:"Detail"},source:{type:"component",framework:"react",componentKey:"ReviewDecisionForm",props:t},targets:["react"]});export{m as KbReviewListPresentation,y as KbReviewFormPresentation,f as KbDashboardPresentation};