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