@contractspec/example.kb-update-pipeline 1.57.0 → 1.59.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 +25 -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
|
@@ -1,93 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/handlers/memory.handlers.ts
|
|
2
3
|
function createPipelineMemoryStore() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
return {
|
|
5
|
+
candidates: new Map,
|
|
6
|
+
reviewTasks: new Map,
|
|
7
|
+
proposedRuleVersionIdsByCandidate: new Map,
|
|
8
|
+
approvedRuleVersionIds: new Set,
|
|
9
|
+
notifications: []
|
|
10
|
+
};
|
|
10
11
|
}
|
|
11
12
|
function stableId(prefix, value) {
|
|
12
|
-
|
|
13
|
+
return `${prefix}_${value.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
13
14
|
}
|
|
14
15
|
function createPipelineMemoryHandlers(store) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
16
|
+
async function runWatch(input) {
|
|
17
|
+
const candidates = [...store.candidates.values()].filter((c) => c.sourceDocumentId.startsWith(`${input.jurisdiction}_`) || true);
|
|
18
|
+
return { candidates };
|
|
19
|
+
}
|
|
20
|
+
async function createReviewTask(input) {
|
|
21
|
+
const candidate = store.candidates.get(input.changeCandidateId);
|
|
22
|
+
if (!candidate)
|
|
23
|
+
throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
|
|
24
|
+
const assignedRole = candidate.riskLevel === "high" ? "expert" : "curator";
|
|
25
|
+
const id = stableId("review", input.changeCandidateId);
|
|
26
|
+
const task = {
|
|
27
|
+
id,
|
|
28
|
+
changeCandidateId: input.changeCandidateId,
|
|
29
|
+
status: "open",
|
|
30
|
+
assignedRole,
|
|
31
|
+
decision: undefined,
|
|
32
|
+
decidedAt: undefined,
|
|
33
|
+
decidedBy: undefined
|
|
34
|
+
};
|
|
35
|
+
store.reviewTasks.set(id, task);
|
|
36
|
+
store.notifications.push({
|
|
37
|
+
kind: "kb.review.requested",
|
|
38
|
+
reviewTaskId: id,
|
|
39
|
+
changeCandidateId: input.changeCandidateId,
|
|
40
|
+
assignedRole,
|
|
41
|
+
createdAt: new Date
|
|
42
|
+
});
|
|
43
|
+
return task;
|
|
44
|
+
}
|
|
45
|
+
async function proposeRulePatch(input) {
|
|
46
|
+
if (!store.candidates.has(input.changeCandidateId)) {
|
|
47
|
+
throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
|
|
48
|
+
}
|
|
49
|
+
store.proposedRuleVersionIdsByCandidate.set(input.changeCandidateId, [
|
|
50
|
+
...input.proposedRuleVersionIds
|
|
51
|
+
]);
|
|
52
|
+
return { proposedRuleVersionIds: [...input.proposedRuleVersionIds] };
|
|
53
|
+
}
|
|
54
|
+
async function markRuleVersionApproved(input) {
|
|
55
|
+
store.approvedRuleVersionIds.add(input.ruleVersionId);
|
|
56
|
+
return { ruleVersionId: input.ruleVersionId };
|
|
57
|
+
}
|
|
58
|
+
async function submitDecision(input) {
|
|
59
|
+
const task = store.reviewTasks.get(input.reviewTaskId);
|
|
60
|
+
if (!task)
|
|
61
|
+
throw new Error("REVIEW_TASK_NOT_FOUND");
|
|
62
|
+
const candidate = store.candidates.get(task.changeCandidateId);
|
|
63
|
+
if (!candidate)
|
|
64
|
+
throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
|
|
65
|
+
if (candidate.riskLevel === "high" && input.decision === "approve") {
|
|
66
|
+
if (input.decidedByRole !== "expert")
|
|
67
|
+
throw new Error("FORBIDDEN_ROLE");
|
|
68
|
+
}
|
|
69
|
+
const decided = {
|
|
70
|
+
...task,
|
|
71
|
+
status: "decided",
|
|
72
|
+
decision: input.decision,
|
|
73
|
+
decidedAt: new Date,
|
|
74
|
+
decidedBy: input.decidedBy
|
|
75
|
+
};
|
|
76
|
+
store.reviewTasks.set(decided.id, decided);
|
|
77
|
+
return decided;
|
|
78
|
+
}
|
|
79
|
+
async function publishIfReady(_input) {
|
|
80
|
+
const openTasks = [...store.reviewTasks.values()].filter((t) => t.status !== "decided");
|
|
81
|
+
if (openTasks.length) {
|
|
82
|
+
throw new Error("NOT_READY");
|
|
83
|
+
}
|
|
84
|
+
const rejected = [...store.reviewTasks.values()].some((t) => t.decision === "reject");
|
|
85
|
+
if (rejected)
|
|
86
|
+
return { published: false, reason: "REJECTED" };
|
|
87
|
+
for (const task of store.reviewTasks.values()) {
|
|
88
|
+
if (task.decision !== "approve")
|
|
89
|
+
continue;
|
|
90
|
+
const proposed = store.proposedRuleVersionIdsByCandidate.get(task.changeCandidateId) ?? [];
|
|
91
|
+
const unapproved = proposed.filter((id) => !store.approvedRuleVersionIds.has(id));
|
|
92
|
+
if (unapproved.length) {
|
|
93
|
+
throw new Error("NOT_READY");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return { published: true };
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
runWatch,
|
|
100
|
+
createReviewTask,
|
|
101
|
+
proposeRulePatch,
|
|
102
|
+
markRuleVersionApproved,
|
|
103
|
+
submitDecision,
|
|
104
|
+
publishIfReady
|
|
105
|
+
};
|
|
89
106
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
export {
|
|
108
|
+
createPipelineMemoryStore,
|
|
109
|
+
createPipelineMemoryHandlers
|
|
110
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.handlers.test.d.ts","sourceRoot":"","sources":["../../src/handlers/memory.handlers.test.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* KB Update Pipeline Example
|
|
3
|
+
*
|
|
4
|
+
* Automation proposes KB updates; humans verify; everything audited and notified.
|
|
5
|
+
*/
|
|
6
|
+
export * from './entities';
|
|
7
|
+
export * from './operations';
|
|
8
|
+
export * from './events';
|
|
9
|
+
export * from './handlers';
|
|
10
|
+
export * from './kb-update-pipeline.feature';
|
|
11
|
+
export { default as example } from './example';
|
|
12
|
+
export * from './presentations';
|
|
13
|
+
import './docs';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAE/C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,QAAQ,CAAC"}
|