@contractspec/example.kb-update-pipeline 3.7.16 → 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 +22 -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 +7 -7
@@ -1,109 +1 @@
1
- // src/handlers/memory.handlers.ts
2
- function createPipelineMemoryStore() {
3
- return {
4
- candidates: new Map,
5
- reviewTasks: new Map,
6
- proposedRuleVersionIdsByCandidate: new Map,
7
- approvedRuleVersionIds: new Set,
8
- notifications: []
9
- };
10
- }
11
- function stableId(prefix, value) {
12
- return `${prefix}_${value.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
13
- }
14
- function createPipelineMemoryHandlers(store) {
15
- async function runWatch(input) {
16
- const candidates = [...store.candidates.values()].filter((c) => c.sourceDocumentId.startsWith(`${input.jurisdiction}_`) || true);
17
- return { candidates };
18
- }
19
- async function createReviewTask(input) {
20
- const candidate = store.candidates.get(input.changeCandidateId);
21
- if (!candidate)
22
- throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
23
- const assignedRole = candidate.riskLevel === "high" ? "expert" : "curator";
24
- const id = stableId("review", input.changeCandidateId);
25
- const task = {
26
- id,
27
- changeCandidateId: input.changeCandidateId,
28
- status: "open",
29
- assignedRole,
30
- decision: undefined,
31
- decidedAt: undefined,
32
- decidedBy: undefined
33
- };
34
- store.reviewTasks.set(id, task);
35
- store.notifications.push({
36
- kind: "kb.review.requested",
37
- reviewTaskId: id,
38
- changeCandidateId: input.changeCandidateId,
39
- assignedRole,
40
- createdAt: new Date
41
- });
42
- return task;
43
- }
44
- async function proposeRulePatch(input) {
45
- if (!store.candidates.has(input.changeCandidateId)) {
46
- throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
47
- }
48
- store.proposedRuleVersionIdsByCandidate.set(input.changeCandidateId, [
49
- ...input.proposedRuleVersionIds
50
- ]);
51
- return { proposedRuleVersionIds: [...input.proposedRuleVersionIds] };
52
- }
53
- async function markRuleVersionApproved(input) {
54
- store.approvedRuleVersionIds.add(input.ruleVersionId);
55
- return { ruleVersionId: input.ruleVersionId };
56
- }
57
- async function submitDecision(input) {
58
- const task = store.reviewTasks.get(input.reviewTaskId);
59
- if (!task)
60
- throw new Error("REVIEW_TASK_NOT_FOUND");
61
- const candidate = store.candidates.get(task.changeCandidateId);
62
- if (!candidate)
63
- throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
64
- if (candidate.riskLevel === "high" && input.decision === "approve") {
65
- if (input.decidedByRole !== "expert")
66
- throw new Error("FORBIDDEN_ROLE");
67
- }
68
- const decided = {
69
- ...task,
70
- status: "decided",
71
- decision: input.decision,
72
- decidedAt: new Date,
73
- decidedBy: input.decidedBy
74
- };
75
- store.reviewTasks.set(decided.id, decided);
76
- return decided;
77
- }
78
- async function publishIfReady(_input) {
79
- const openTasks = [...store.reviewTasks.values()].filter((t) => t.status !== "decided");
80
- if (openTasks.length) {
81
- throw new Error("NOT_READY");
82
- }
83
- const rejected = [...store.reviewTasks.values()].some((t) => t.decision === "reject");
84
- if (rejected)
85
- return { published: false, reason: "REJECTED" };
86
- for (const task of store.reviewTasks.values()) {
87
- if (task.decision !== "approve")
88
- continue;
89
- const proposed = store.proposedRuleVersionIdsByCandidate.get(task.changeCandidateId) ?? [];
90
- const unapproved = proposed.filter((id) => !store.approvedRuleVersionIds.has(id));
91
- if (unapproved.length) {
92
- throw new Error("NOT_READY");
93
- }
94
- }
95
- return { published: true };
96
- }
97
- return {
98
- runWatch,
99
- createReviewTask,
100
- proposeRulePatch,
101
- markRuleVersionApproved,
102
- submitDecision,
103
- publishIfReady
104
- };
105
- }
106
- export {
107
- createPipelineMemoryStore,
108
- createPipelineMemoryHandlers
109
- };
1
+ function S(){return{candidates:new Map,reviewTasks:new Map,proposedRuleVersionIdsByCandidate:new Map,approvedRuleVersionIds:new Set,notifications:[]}}function O(q,F){return`${q}_${F.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function U(q){async function F(j){return{candidates:[...q.candidates.values()].filter((C)=>C.sourceDocumentId.startsWith(`${j.jurisdiction}_`)||!0)}}async function H(j){let B=q.candidates.get(j.changeCandidateId);if(!B)throw Error("CHANGE_CANDIDATE_NOT_FOUND");let C=B.riskLevel==="high"?"expert":"curator",z=O("review",j.changeCandidateId),G={id:z,changeCandidateId:j.changeCandidateId,status:"open",assignedRole:C,decision:void 0,decidedAt:void 0,decidedBy:void 0};return q.reviewTasks.set(z,G),q.notifications.push({kind:"kb.review.requested",reviewTaskId:z,changeCandidateId:j.changeCandidateId,assignedRole:C,createdAt:new Date}),G}async function J(j){if(!q.candidates.has(j.changeCandidateId))throw Error("CHANGE_CANDIDATE_NOT_FOUND");return q.proposedRuleVersionIdsByCandidate.set(j.changeCandidateId,[...j.proposedRuleVersionIds]),{proposedRuleVersionIds:[...j.proposedRuleVersionIds]}}async function K(j){return q.approvedRuleVersionIds.add(j.ruleVersionId),{ruleVersionId:j.ruleVersionId}}async function L(j){let B=q.reviewTasks.get(j.reviewTaskId);if(!B)throw Error("REVIEW_TASK_NOT_FOUND");let C=q.candidates.get(B.changeCandidateId);if(!C)throw Error("CHANGE_CANDIDATE_NOT_FOUND");if(C.riskLevel==="high"&&j.decision==="approve"){if(j.decidedByRole!=="expert")throw Error("FORBIDDEN_ROLE")}let z={...B,status:"decided",decision:j.decision,decidedAt:new Date,decidedBy:j.decidedBy};return q.reviewTasks.set(z.id,z),z}async function M(j){if([...q.reviewTasks.values()].filter((z)=>z.status!=="decided").length)throw Error("NOT_READY");if([...q.reviewTasks.values()].some((z)=>z.decision==="reject"))return{published:!1,reason:"REJECTED"};for(let z of q.reviewTasks.values()){if(z.decision!=="approve")continue;if((q.proposedRuleVersionIdsByCandidate.get(z.changeCandidateId)??[]).filter((N)=>!q.approvedRuleVersionIds.has(N)).length)throw Error("NOT_READY")}return{published:!0}}return{runWatch:F,createReviewTask:H,proposeRulePatch:J,markRuleVersionApproved:K,submitDecision:L,publishIfReady:M}}export{S as createPipelineMemoryStore,U as createPipelineMemoryHandlers};