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