@contractspec/example.versioned-knowledge-base 1.56.1 → 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 +53 -48
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +30 -0
- package/dist/browser/docs/index.js +44 -0
- package/dist/browser/docs/versioned-knowledge-base.docblock.js +44 -0
- package/dist/browser/entities/index.js +74 -0
- package/dist/browser/entities/models.js +74 -0
- package/dist/browser/events.js +101 -0
- package/dist/browser/example.js +35 -0
- package/dist/browser/handlers/index.js +115 -0
- package/dist/browser/handlers/memory.handlers.js +115 -0
- package/dist/browser/index.js +586 -0
- package/dist/browser/operations/index.js +257 -0
- package/dist/browser/operations/kb.js +257 -0
- package/dist/browser/versioned-knowledge-base.feature.js +36 -0
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +45 -1
- package/dist/docs/versioned-knowledge-base.docblock.d.ts +2 -1
- package/dist/docs/versioned-knowledge-base.docblock.d.ts.map +1 -0
- package/dist/docs/versioned-knowledge-base.docblock.js +42 -28
- package/dist/entities/index.d.ts +2 -2
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +75 -3
- package/dist/entities/models.d.ts +127 -132
- package/dist/entities/models.d.ts.map +1 -1
- package/dist/entities/models.js +69 -145
- package/dist/events.d.ts +52 -58
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +92 -114
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +33 -46
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +116 -3
- package/dist/handlers/memory.handlers.d.ts +62 -64
- package/dist/handlers/memory.handlers.d.ts.map +1 -1
- package/dist/handlers/memory.handlers.js +110 -97
- 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 +13 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +587 -11
- package/dist/node/docs/index.js +44 -0
- package/dist/node/docs/versioned-knowledge-base.docblock.js +44 -0
- package/dist/node/entities/index.js +74 -0
- package/dist/node/entities/models.js +74 -0
- package/dist/node/events.js +101 -0
- package/dist/node/example.js +35 -0
- package/dist/node/handlers/index.js +115 -0
- package/dist/node/handlers/memory.handlers.js +115 -0
- package/dist/node/index.js +586 -0
- package/dist/node/operations/index.js +257 -0
- package/dist/node/operations/kb.js +257 -0
- package/dist/node/versioned-knowledge-base.feature.js +36 -0
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +257 -2
- package/dist/operations/kb.d.ts +252 -258
- package/dist/operations/kb.d.ts.map +1 -1
- package/dist/operations/kb.js +246 -244
- package/dist/versioned-knowledge-base.feature.d.ts +1 -6
- package/dist/versioned-knowledge-base.feature.d.ts.map +1 -1
- package/dist/versioned-knowledge-base.feature.js +35 -68
- package/package.json +141 -38
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -47
- package/dist/docs/versioned-knowledge-base.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/operations/kb.js.map +0 -1
- package/dist/versioned-knowledge-base.feature.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,63 +1,166 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.versioned-knowledge-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"description": "Example: curated, versioned knowledge base with immutable sources, rule versions, and published snapshots.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
-
".": "./
|
|
9
|
-
"./docs": "./
|
|
10
|
-
"./docs/
|
|
11
|
-
"./
|
|
12
|
-
"./entities
|
|
13
|
-
"./
|
|
14
|
-
"./
|
|
15
|
-
"./
|
|
16
|
-
"./
|
|
17
|
-
"./
|
|
18
|
-
"./
|
|
19
|
-
"./
|
|
20
|
-
"
|
|
8
|
+
".": "./src/index.ts",
|
|
9
|
+
"./docs": "./src/docs/index.ts",
|
|
10
|
+
"./docs/index": "./src/docs/index.ts",
|
|
11
|
+
"./docs/versioned-knowledge-base.docblock": "./src/docs/versioned-knowledge-base.docblock.ts",
|
|
12
|
+
"./entities": "./src/entities/index.ts",
|
|
13
|
+
"./entities/index": "./src/entities/index.ts",
|
|
14
|
+
"./entities/models": "./src/entities/models.ts",
|
|
15
|
+
"./events": "./src/events.ts",
|
|
16
|
+
"./example": "./src/example.ts",
|
|
17
|
+
"./handlers": "./src/handlers/index.ts",
|
|
18
|
+
"./handlers/index": "./src/handlers/index.ts",
|
|
19
|
+
"./handlers/memory.handlers": "./src/handlers/memory.handlers.ts",
|
|
20
|
+
"./operations": "./src/operations/index.ts",
|
|
21
|
+
"./operations/index": "./src/operations/index.ts",
|
|
22
|
+
"./operations/kb": "./src/operations/kb.ts",
|
|
23
|
+
"./versioned-knowledge-base.feature": "./src/versioned-knowledge-base.feature.ts"
|
|
21
24
|
},
|
|
22
25
|
"scripts": {
|
|
23
26
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
24
27
|
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
25
|
-
"build": "bun build:
|
|
26
|
-
"build:bundle": "
|
|
27
|
-
"build:types": "
|
|
28
|
-
"dev": "bun
|
|
28
|
+
"build": "bun run prebuild && bun run build:bundle && bun run build:types",
|
|
29
|
+
"build:bundle": "contractspec-bun-build transpile",
|
|
30
|
+
"build:types": "contractspec-bun-build types",
|
|
31
|
+
"dev": "contractspec-bun-build dev",
|
|
29
32
|
"clean": "rimraf dist .turbo",
|
|
30
33
|
"lint": "bun lint:fix",
|
|
31
34
|
"lint:fix": "eslint src --fix",
|
|
32
35
|
"lint:check": "eslint src",
|
|
33
|
-
"test": "bun test"
|
|
36
|
+
"test": "bun test",
|
|
37
|
+
"prebuild": "contractspec-bun-build prebuild",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
34
39
|
},
|
|
35
40
|
"dependencies": {
|
|
36
|
-
"@contractspec/lib.contracts": "1.
|
|
37
|
-
"@contractspec/lib.schema": "1.
|
|
41
|
+
"@contractspec/lib.contracts": "1.58.0",
|
|
42
|
+
"@contractspec/lib.schema": "1.58.0"
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {
|
|
40
|
-
"@contractspec/tool.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"typescript": "^5.9.3"
|
|
45
|
+
"@contractspec/tool.typescript": "1.58.0",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"@contractspec/tool.bun": "1.57.0"
|
|
44
48
|
},
|
|
45
49
|
"publishConfig": {
|
|
46
50
|
"access": "public",
|
|
47
51
|
"exports": {
|
|
48
|
-
".":
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"./
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./dist/index.d.ts",
|
|
54
|
+
"bun": "./dist/index.js",
|
|
55
|
+
"node": "./dist/node/index.mjs",
|
|
56
|
+
"browser": "./dist/browser/index.js",
|
|
57
|
+
"default": "./dist/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./docs": {
|
|
60
|
+
"types": "./dist/docs/index.d.ts",
|
|
61
|
+
"bun": "./dist/docs/index.js",
|
|
62
|
+
"node": "./dist/node/docs/index.mjs",
|
|
63
|
+
"browser": "./dist/browser/docs/index.js",
|
|
64
|
+
"default": "./dist/docs/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./docs/index": {
|
|
67
|
+
"types": "./dist/docs/index.d.ts",
|
|
68
|
+
"bun": "./dist/docs/index.js",
|
|
69
|
+
"node": "./dist/node/docs/index.mjs",
|
|
70
|
+
"browser": "./dist/browser/docs/index.js",
|
|
71
|
+
"default": "./dist/docs/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./docs/versioned-knowledge-base.docblock": {
|
|
74
|
+
"types": "./dist/docs/versioned-knowledge-base.docblock.d.ts",
|
|
75
|
+
"bun": "./dist/docs/versioned-knowledge-base.docblock.js",
|
|
76
|
+
"node": "./dist/node/docs/versioned-knowledge-base.docblock.mjs",
|
|
77
|
+
"browser": "./dist/browser/docs/versioned-knowledge-base.docblock.js",
|
|
78
|
+
"default": "./dist/docs/versioned-knowledge-base.docblock.js"
|
|
79
|
+
},
|
|
80
|
+
"./entities": {
|
|
81
|
+
"types": "./dist/entities/index.d.ts",
|
|
82
|
+
"bun": "./dist/entities/index.js",
|
|
83
|
+
"node": "./dist/node/entities/index.mjs",
|
|
84
|
+
"browser": "./dist/browser/entities/index.js",
|
|
85
|
+
"default": "./dist/entities/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./entities/index": {
|
|
88
|
+
"types": "./dist/entities/index.d.ts",
|
|
89
|
+
"bun": "./dist/entities/index.js",
|
|
90
|
+
"node": "./dist/node/entities/index.mjs",
|
|
91
|
+
"browser": "./dist/browser/entities/index.js",
|
|
92
|
+
"default": "./dist/entities/index.js"
|
|
93
|
+
},
|
|
94
|
+
"./entities/models": {
|
|
95
|
+
"types": "./dist/entities/models.d.ts",
|
|
96
|
+
"bun": "./dist/entities/models.js",
|
|
97
|
+
"node": "./dist/node/entities/models.mjs",
|
|
98
|
+
"browser": "./dist/browser/entities/models.js",
|
|
99
|
+
"default": "./dist/entities/models.js"
|
|
100
|
+
},
|
|
101
|
+
"./events": {
|
|
102
|
+
"types": "./dist/events.d.ts",
|
|
103
|
+
"bun": "./dist/events.js",
|
|
104
|
+
"node": "./dist/node/events.mjs",
|
|
105
|
+
"browser": "./dist/browser/events.js",
|
|
106
|
+
"default": "./dist/events.js"
|
|
107
|
+
},
|
|
108
|
+
"./example": {
|
|
109
|
+
"types": "./dist/example.d.ts",
|
|
110
|
+
"bun": "./dist/example.js",
|
|
111
|
+
"node": "./dist/node/example.mjs",
|
|
112
|
+
"browser": "./dist/browser/example.js",
|
|
113
|
+
"default": "./dist/example.js"
|
|
114
|
+
},
|
|
115
|
+
"./handlers": {
|
|
116
|
+
"types": "./dist/handlers/index.d.ts",
|
|
117
|
+
"bun": "./dist/handlers/index.js",
|
|
118
|
+
"node": "./dist/node/handlers/index.mjs",
|
|
119
|
+
"browser": "./dist/browser/handlers/index.js",
|
|
120
|
+
"default": "./dist/handlers/index.js"
|
|
121
|
+
},
|
|
122
|
+
"./handlers/index": {
|
|
123
|
+
"types": "./dist/handlers/index.d.ts",
|
|
124
|
+
"bun": "./dist/handlers/index.js",
|
|
125
|
+
"node": "./dist/node/handlers/index.mjs",
|
|
126
|
+
"browser": "./dist/browser/handlers/index.js",
|
|
127
|
+
"default": "./dist/handlers/index.js"
|
|
128
|
+
},
|
|
129
|
+
"./handlers/memory.handlers": {
|
|
130
|
+
"types": "./dist/handlers/memory.handlers.d.ts",
|
|
131
|
+
"bun": "./dist/handlers/memory.handlers.js",
|
|
132
|
+
"node": "./dist/node/handlers/memory.handlers.mjs",
|
|
133
|
+
"browser": "./dist/browser/handlers/memory.handlers.js",
|
|
134
|
+
"default": "./dist/handlers/memory.handlers.js"
|
|
135
|
+
},
|
|
136
|
+
"./operations": {
|
|
137
|
+
"types": "./dist/operations/index.d.ts",
|
|
138
|
+
"bun": "./dist/operations/index.js",
|
|
139
|
+
"node": "./dist/node/operations/index.mjs",
|
|
140
|
+
"browser": "./dist/browser/operations/index.js",
|
|
141
|
+
"default": "./dist/operations/index.js"
|
|
142
|
+
},
|
|
143
|
+
"./operations/index": {
|
|
144
|
+
"types": "./dist/operations/index.d.ts",
|
|
145
|
+
"bun": "./dist/operations/index.js",
|
|
146
|
+
"node": "./dist/node/operations/index.mjs",
|
|
147
|
+
"browser": "./dist/browser/operations/index.js",
|
|
148
|
+
"default": "./dist/operations/index.js"
|
|
149
|
+
},
|
|
150
|
+
"./operations/kb": {
|
|
151
|
+
"types": "./dist/operations/kb.d.ts",
|
|
152
|
+
"bun": "./dist/operations/kb.js",
|
|
153
|
+
"node": "./dist/node/operations/kb.mjs",
|
|
154
|
+
"browser": "./dist/browser/operations/kb.js",
|
|
155
|
+
"default": "./dist/operations/kb.js"
|
|
156
|
+
},
|
|
157
|
+
"./versioned-knowledge-base.feature": {
|
|
158
|
+
"types": "./dist/versioned-knowledge-base.feature.d.ts",
|
|
159
|
+
"bun": "./dist/versioned-knowledge-base.feature.js",
|
|
160
|
+
"node": "./dist/node/versioned-knowledge-base.feature.mjs",
|
|
161
|
+
"browser": "./dist/browser/versioned-knowledge-base.feature.js",
|
|
162
|
+
"default": "./dist/versioned-knowledge-base.feature.js"
|
|
163
|
+
}
|
|
61
164
|
},
|
|
62
165
|
"registry": "https://registry.npmjs.org/"
|
|
63
166
|
},
|
package/tsdown.config.js
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
$ tsdown
|
|
2
|
-
[34mℹ[39m tsdown [2mv0.19.0[22m powered by rolldown [2mv1.0.0-beta.59[22m
|
|
3
|
-
[34mℹ[39m config file: [4m/home/runner/work/contractspec/contractspec/packages/examples/versioned-knowledge-base/tsdown.config.js[24m
|
|
4
|
-
[34mℹ[39m entry: [34msrc/events.ts, src/example.ts, src/index.ts, src/versioned-knowledge-base.feature.ts, src/docs/index.ts, src/docs/versioned-knowledge-base.docblock.ts, src/entities/index.ts, src/entities/models.ts, src/handlers/index.ts, src/handlers/memory.handlers.ts, src/operations/index.ts, src/operations/kb.ts[39m
|
|
5
|
-
[34mℹ[39m target: [34mesnext[39m
|
|
6
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
7
|
-
[34mℹ[39m Build start
|
|
8
|
-
[34mℹ[39m Cleaning 41 files
|
|
9
|
-
[34mℹ[39m [2mdist/[22m[1moperations/kb.js[22m [2m6.46 kB[22m [2m│ gzip: 1.58 kB[22m
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mhandlers/memory.handlers.js[22m [2m3.45 kB[22m [2m│ gzip: 1.20 kB[22m
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mentities/models.js[22m [2m3.39 kB[22m [2m│ gzip: 0.67 kB[22m
|
|
12
|
-
[34mℹ[39m [2mdist/[22m[1mevents.js[22m [2m3.15 kB[22m [2m│ gzip: 0.67 kB[22m
|
|
13
|
-
[34mℹ[39m [2mdist/[22m[1mdocs/versioned-knowledge-base.docblock.js[22m [2m1.52 kB[22m [2m│ gzip: 0.66 kB[22m
|
|
14
|
-
[34mℹ[39m [2mdist/[22m[1mversioned-knowledge-base.feature.js[22m [2m1.34 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
15
|
-
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m1.16 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
16
|
-
[34mℹ[39m [2mdist/[22m[1mexample.js[22m [2m1.07 kB[22m [2m│ gzip: 0.54 kB[22m
|
|
17
|
-
[34mℹ[39m [2mdist/[22m[1moperations/index.js[22m [2m0.29 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
18
|
-
[34mℹ[39m [2mdist/[22m[1mentities/index.js[22m [2m0.21 kB[22m [2m│ gzip: 0.11 kB[22m
|
|
19
|
-
[34mℹ[39m [2mdist/[22m[1mhandlers/index.js[22m [2m0.14 kB[22m [2m│ gzip: 0.09 kB[22m
|
|
20
|
-
[34mℹ[39m [2mdist/[22m[1mdocs/index.js[22m [2m0.05 kB[22m [2m│ gzip: 0.07 kB[22m
|
|
21
|
-
[34mℹ[39m [2mdist/[22moperations/kb.js.map [2m9.51 kB[22m [2m│ gzip: 2.10 kB[22m
|
|
22
|
-
[34mℹ[39m [2mdist/[22mhandlers/memory.handlers.js.map [2m8.44 kB[22m [2m│ gzip: 2.43 kB[22m
|
|
23
|
-
[34mℹ[39m [2mdist/[22mentities/models.js.map [2m5.09 kB[22m [2m│ gzip: 1.00 kB[22m
|
|
24
|
-
[34mℹ[39m [2mdist/[22mevents.js.map [2m4.72 kB[22m [2m│ gzip: 0.98 kB[22m
|
|
25
|
-
[34mℹ[39m [2mdist/[22mdocs/versioned-knowledge-base.docblock.js.map [2m2.02 kB[22m [2m│ gzip: 0.84 kB[22m
|
|
26
|
-
[34mℹ[39m [2mdist/[22mversioned-knowledge-base.feature.js.map [2m1.94 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
27
|
-
[34mℹ[39m [2mdist/[22mexample.js.map [2m1.53 kB[22m [2m│ gzip: 0.74 kB[22m
|
|
28
|
-
[34mℹ[39m [2mdist/[22mhandlers/memory.handlers.d.ts.map [2m1.17 kB[22m [2m│ gzip: 0.53 kB[22m
|
|
29
|
-
[34mℹ[39m [2mdist/[22moperations/kb.d.ts.map [2m1.11 kB[22m [2m│ gzip: 0.39 kB[22m
|
|
30
|
-
[34mℹ[39m [2mdist/[22mentities/models.d.ts.map [2m0.69 kB[22m [2m│ gzip: 0.32 kB[22m
|
|
31
|
-
[34mℹ[39m [2mdist/[22mevents.d.ts.map [2m0.67 kB[22m [2m│ gzip: 0.28 kB[22m
|
|
32
|
-
[34mℹ[39m [2mdist/[22mversioned-knowledge-base.feature.d.ts.map [2m0.19 kB[22m [2m│ gzip: 0.15 kB[22m
|
|
33
|
-
[34mℹ[39m [2mdist/[22mexample.d.ts.map [2m0.14 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
34
|
-
[34mℹ[39m [2mdist/[22m[32m[1moperations/kb.d.ts[22m[39m [2m7.75 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
35
|
-
[34mℹ[39m [2mdist/[22m[32m[1mentities/models.d.ts[22m[39m [2m3.88 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
36
|
-
[34mℹ[39m [2mdist/[22m[32m[1mevents.d.ts[22m[39m [2m2.14 kB[22m [2m│ gzip: 0.39 kB[22m
|
|
37
|
-
[34mℹ[39m [2mdist/[22m[32m[1mhandlers/memory.handlers.d.ts[22m[39m [2m1.94 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
38
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m1.18 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
39
|
-
[34mℹ[39m [2mdist/[22m[32m[1mversioned-knowledge-base.feature.d.ts[22m[39m [2m0.34 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
40
|
-
[34mℹ[39m [2mdist/[22m[32m[1moperations/index.d.ts[22m[39m [2m0.29 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
41
|
-
[34mℹ[39m [2mdist/[22m[32m[1mexample.d.ts[22m[39m [2m0.25 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
42
|
-
[34mℹ[39m [2mdist/[22m[32m[1mentities/index.d.ts[22m[39m [2m0.21 kB[22m [2m│ gzip: 0.11 kB[22m
|
|
43
|
-
[34mℹ[39m [2mdist/[22m[32m[1mhandlers/index.d.ts[22m[39m [2m0.20 kB[22m [2m│ gzip: 0.10 kB[22m
|
|
44
|
-
[34mℹ[39m [2mdist/[22m[32m[1mdocs/index.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
45
|
-
[34mℹ[39m [2mdist/[22m[32m[1mdocs/versioned-knowledge-base.docblock.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
46
|
-
[34mℹ[39m 37 files, total: 77.65 kB
|
|
47
|
-
[32m✔[39m Build complete in [32m23952ms[39m
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versioned-knowledge-base.docblock.js","names":[],"sources":["../../src/docs/versioned-knowledge-base.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\nconst docBlocks: DocBlock[] = [\n {\n id: 'docs.examples.versioned-knowledge-base.goal',\n title: 'Versioned Knowledge Base — Goal',\n summary:\n 'Curated KB with immutable sources, versioned rules, and published snapshots referenced by answers.',\n kind: 'goal',\n visibility: 'public',\n route: '/docs/examples/versioned-knowledge-base/goal',\n tags: ['knowledge', 'versioning', 'snapshots', 'traceability'],\n body: `## Why it matters\n- Separates raw sources from curated knowledge.\\n- Ensures assistant answers cite a published snapshot.\\n- Makes change review and safe regeneration possible.\\n\\n## Core invariants\\n- Sources are immutable and content-addressed (hash).\\n- Rule versions must cite at least one source.\\n- Snapshots include only approved rule versions.`,\n },\n {\n id: 'docs.examples.versioned-knowledge-base.reference',\n title: 'Versioned Knowledge Base — Reference',\n summary: 'Entities, contracts, and events for the versioned KB example.',\n kind: 'reference',\n visibility: 'public',\n route: '/docs/examples/versioned-knowledge-base',\n tags: ['knowledge', 'reference'],\n body: `## Contracts\\n- kb.ingestSource\\n- kb.upsertRuleVersion\\n- kb.approveRuleVersion\\n- kb.publishSnapshot\\n- kb.search\\n\\n## Events\\n- kb.source.ingested\\n- kb.ruleVersion.created\\n- kb.ruleVersion.approved\\n- kb.snapshot.published`,\n },\n];\n\nregisterDocBlocks(docBlocks);\n"],"mappings":";;;AA4BA,kBAzB8B,CAC5B;CACE,IAAI;CACJ,OAAO;CACP,SACE;CACF,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EAAC;EAAa;EAAc;EAAa;EAAe;CAC9D,MAAM;;CAEP,EACD;CACE,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM,CAAC,aAAa,YAAY;CAChC,MAAM;CACP,CACF,CAE2B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","names":[],"sources":["../../src/entities/models.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\n\nexport const SourceDocumentModel = defineSchemaModel({\n name: 'SourceDocument',\n description:\n 'Immutable raw source document metadata referencing a stored file.',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n authority: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fetchedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nexport const SourceRefModel = defineSchemaModel({\n name: 'SourceRef',\n description: 'Reference to a source document used to justify a rule version.',\n fields: {\n sourceDocumentId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nexport const RuleModel = defineSchemaModel({\n name: 'Rule',\n description:\n 'Curated rule (stable identity) with topic + jurisdiction scope.',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nexport const RuleVersionModel = defineSchemaModel({\n name: 'RuleVersion',\n description:\n 'A versioned rule content with source references and approval status.',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },\n status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }, // draft|approved|rejected\n approvedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n approvedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const KBSnapshotModel = defineSchemaModel({\n name: 'KBSnapshot',\n description:\n 'Published KB snapshot (as-of) referencing approved rule versions.',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n asOfDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n includedRuleVersionIds: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: false,\n },\n publishedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n"],"mappings":";;;AAEA,MAAa,sBAAsB,kBAAkB;CACnD,MAAM;CACN,aACE;CACF,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACpE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EACjE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE;CACF,CAAC;AAEF,MAAa,iBAAiB,kBAAkB;CAC9C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,kBAAkB;GAChB,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACtE;CACF,CAAC;AAEF,MAAa,YAAY,kBAAkB;CACzC,MAAM;CACN,aACE;CACF,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;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map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","names":[],"sources":["../src/events.ts"],"sourcesContent":["import { defineEvent, defineSchemaModel } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum } from '@contractspec/lib.schema';\n\nconst KbSourceIngestedPayload = defineSchemaModel({\n name: 'KbSourceIngestedPayload',\n description: 'Emitted when a source document is ingested.',\n fields: {\n sourceDocumentId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nexport const KbSourceIngestedEvent = defineEvent({\n meta: {\n key: 'kb.source.ingested',\n version: '1.0.0',\n description: 'Source document ingested (immutable).',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge'],\n },\n payload: KbSourceIngestedPayload,\n});\n\nconst KbRuleVersionCreatedPayload = defineSchemaModel({\n name: 'KbRuleVersionCreatedPayload',\n description: 'Emitted when a rule version draft is created.',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nexport const KbRuleVersionCreatedEvent = defineEvent({\n meta: {\n key: 'kb.ruleVersion.created',\n version: '1.0.0',\n description: 'Rule version created (draft).',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge'],\n },\n payload: KbRuleVersionCreatedPayload,\n});\n\nconst KbRuleVersionApprovedPayload = defineSchemaModel({\n name: 'KbRuleVersionApprovedPayload',\n description: 'Emitted when a rule version is approved.',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n approver: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nexport const KbRuleVersionApprovedEvent = defineEvent({\n meta: {\n key: 'kb.ruleVersion.approved',\n version: '1.0.0',\n description: 'Rule version approved (human verified).',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge'],\n },\n payload: KbRuleVersionApprovedPayload,\n});\n\nconst KbSnapshotPublishedPayload = defineSchemaModel({\n name: 'KbSnapshotPublishedPayload',\n description: 'Emitted when a KB snapshot is published.',\n fields: {\n snapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n includedRuleVersionsCount: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: false,\n },\n },\n});\n\nexport const KbSnapshotPublishedEvent = defineEvent({\n meta: {\n key: 'kb.snapshot.published',\n version: '1.0.0',\n description: 'KB snapshot published.',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge'],\n },\n payload: KbSnapshotPublishedPayload,\n});\n"],"mappings":";;;;AAGA,MAAM,0BAA0B,kBAAkB;CAChD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,kBAAkB;GAChB,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACpE;CACF,CAAC;AAEF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM,CAAC,YAAY;EACpB;CACD,SAAS;CACV,CAAC;AAEF,MAAM,8BAA8B,kBAAkB;CACpD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,eAAe;GACb,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACrE,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE;CACF,CAAC;AAEF,MAAa,4BAA4B,YAAY;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM,CAAC,YAAY;EACpB;CACD,SAAS;CACV,CAAC;AAEF,MAAM,+BAA+B,kBAAkB;CACrD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,eAAe;GACb,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE;CACF,CAAC;AAEF,MAAa,6BAA6B,YAAY;CACpD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM,CAAC,YAAY;EACpB;CACD,SAAS;CACV,CAAC;AAEF,MAAM,6BAA6B,kBAAkB;CACnD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,YAAY;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACzE,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,2BAA2B;GACzB,MAAM,eAAe,cAAc;GACnC,YAAY;GACb;EACF;CACF,CAAC;AAEF,MAAa,2BAA2B,YAAY;CAClD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM,CAAC,YAAY;EACpB;CACD,SAAS;CACV,CAAC"}
|
package/dist/example.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\nconst example = defineExample({\n meta: {\n key: 'versioned-knowledge-base',\n version: '1.0.0',\n title: 'Versioned Knowledge Base',\n description:\n 'Curated KB with immutable sources, reviewable rule versions, and published snapshots.',\n kind: 'knowledge',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@platform.core'],\n tags: ['knowledge', 'versioning', 'snapshots'],\n },\n docs: {\n rootDocId: 'docs.examples.versioned-knowledge-base',\n },\n entrypoints: {\n packageName: '@contractspec/example.versioned-knowledge-base',\n feature: './feature',\n contracts: './contracts',\n handlers: './handlers',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: { enabled: true, modes: ['markdown', 'specs', 'builder'] },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n});\n\nexport default example;\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAa;GAAc;GAAY;EAC/C;CACD,MAAM,EACJ,WAAW,0CACZ;CACD,aAAa;EACX,aAAa;EACb,SAAS;EACT,WAAW;EACX,UAAU;EACV,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GAAE,SAAS;GAAM,OAAO;IAAC;IAAY;IAAS;IAAU;GAAE;EACnE,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF,CAAC;AAEF,sBAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.handlers.js","names":[],"sources":["../../src/handlers/memory.handlers.ts"],"sourcesContent":["interface SourceRef {\n sourceDocumentId: string;\n excerpt?: string;\n}\ninterface SourceDocument {\n id: string;\n jurisdiction: string;\n authority: string;\n title: string;\n fetchedAt: Date;\n hash: string;\n fileId: string;\n}\ninterface Rule {\n id: string;\n jurisdiction: string;\n topicKey: string;\n}\ninterface RuleVersion {\n id: string;\n ruleId: string;\n jurisdiction: string;\n topicKey: string;\n version: string;\n content: string;\n sourceRefs: SourceRef[];\n status: 'draft' | 'approved' | 'rejected';\n approvedBy?: string;\n approvedAt?: Date;\n createdAt: Date;\n}\ninterface KBSnapshot {\n id: string;\n jurisdiction: string;\n asOfDate: Date;\n includedRuleVersionIds: string[];\n publishedAt: Date;\n}\n\nexport interface MemoryKbStore {\n sources: Map<string, SourceDocument>;\n rules: Map<string, Rule>;\n ruleVersions: Map<string, RuleVersion>;\n snapshots: Map<string, KBSnapshot>;\n nextRuleVersionNumberByRuleId: Map<string, number>;\n}\n\nexport function createMemoryKbStore(): MemoryKbStore {\n return {\n sources: new Map(),\n rules: new Map(),\n ruleVersions: new Map(),\n snapshots: new Map(),\n nextRuleVersionNumberByRuleId: new Map(),\n };\n}\n\nexport interface MemoryKbHandlers {\n createRule(rule: Rule): Promise<Rule>;\n ingestSource(input: Omit<SourceDocument, 'id'>): Promise<SourceDocument>;\n upsertRuleVersion(input: {\n ruleId: string;\n content: string;\n sourceRefs: SourceRef[];\n }): Promise<RuleVersion>;\n approveRuleVersion(input: {\n ruleVersionId: string;\n approver: string;\n }): Promise<RuleVersion>;\n publishSnapshot(input: {\n jurisdiction: string;\n asOfDate: Date;\n }): Promise<KBSnapshot>;\n search(input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }>;\n}\n\nfunction stableId(prefix: string, value: string): string {\n return `${prefix}_${value.replace(/[^a-zA-Z0-9_-]/g, '_')}`;\n}\n\nexport function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {\n async function createRule(rule: Rule): Promise<Rule> {\n store.rules.set(rule.id, rule);\n return rule;\n }\n\n async function ingestSource(\n input: Omit<SourceDocument, 'id'>\n ): Promise<SourceDocument> {\n const id = stableId('src', `${input.jurisdiction}_${input.hash}`);\n const doc: SourceDocument = { id, ...input };\n store.sources.set(id, doc);\n return doc;\n }\n\n async function upsertRuleVersion(input: {\n ruleId: string;\n content: string;\n sourceRefs: SourceRef[];\n }): Promise<RuleVersion> {\n if (!input.sourceRefs.length) {\n throw new Error('SOURCE_REFS_REQUIRED');\n }\n const rule = store.rules.get(input.ruleId);\n if (!rule) {\n throw new Error('RULE_NOT_FOUND');\n }\n const next =\n (store.nextRuleVersionNumberByRuleId.get(input.ruleId) ?? 0) + 1;\n const id = stableId('rv', `${input.ruleId}_${next}`);\n const ruleVersion: RuleVersion = {\n id,\n ruleId: input.ruleId,\n jurisdiction: rule.jurisdiction,\n topicKey: rule.topicKey,\n version: next.toString(),\n content: input.content,\n sourceRefs: input.sourceRefs,\n status: 'draft',\n createdAt: new Date(),\n approvedAt: undefined,\n approvedBy: undefined,\n };\n store.ruleVersions.set(id, ruleVersion);\n return ruleVersion;\n }\n\n async function approveRuleVersion(input: {\n ruleVersionId: string;\n approver: string;\n }): Promise<RuleVersion> {\n const existing = store.ruleVersions.get(input.ruleVersionId);\n if (!existing) {\n throw new Error('RULE_VERSION_NOT_FOUND');\n }\n const approved: RuleVersion = {\n ...existing,\n status: 'approved',\n approvedBy: input.approver,\n approvedAt: new Date(),\n };\n store.ruleVersions.set(approved.id, approved);\n return approved;\n }\n\n async function publishSnapshot(input: {\n jurisdiction: string;\n asOfDate: Date;\n }): Promise<KBSnapshot> {\n const approved = [...store.ruleVersions.values()].filter(\n (rv) => rv.status === 'approved' && rv.jurisdiction === input.jurisdiction\n );\n if (approved.length === 0) {\n throw new Error('NO_APPROVED_RULES');\n }\n const includedRuleVersionIds = approved.map((rv) => rv.id).sort();\n const id = stableId(\n 'snap',\n `${input.jurisdiction}_${input.asOfDate.toISOString().slice(0, 10)}_${includedRuleVersionIds.length}`\n );\n const snapshot: KBSnapshot = {\n id,\n jurisdiction: input.jurisdiction,\n asOfDate: input.asOfDate,\n includedRuleVersionIds,\n publishedAt: new Date(),\n };\n store.snapshots.set(id, snapshot);\n return snapshot;\n }\n\n async function search(input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }> {\n const snapshot = store.snapshots.get(input.snapshotId);\n if (!snapshot) {\n throw new Error('SNAPSHOT_NOT_FOUND');\n }\n if (snapshot.jurisdiction !== input.jurisdiction) {\n throw new Error('JURISDICTION_MISMATCH');\n }\n const q = input.query.toLowerCase();\n const tokens = q\n .split(/\\s+/)\n .map((t) => t.trim())\n .filter(Boolean);\n const items = snapshot.includedRuleVersionIds\n .map((id) => store.ruleVersions.get(id))\n .filter((rv): rv is RuleVersion => Boolean(rv))\n .filter((rv) => {\n if (tokens.length === 0) return true;\n const hay = rv.content.toLowerCase();\n return tokens.every((token) => hay.includes(token));\n })\n .map((rv) => ({\n ruleVersionId: rv.id,\n excerpt: rv.content.slice(0, 120),\n }));\n return { items };\n }\n\n return {\n createRule,\n ingestSource,\n upsertRuleVersion,\n approveRuleVersion,\n publishSnapshot,\n search,\n };\n}\n"],"mappings":";AA+CA,SAAgB,sBAAqC;AACnD,QAAO;EACL,yBAAS,IAAI,KAAK;EAClB,uBAAO,IAAI,KAAK;EAChB,8BAAc,IAAI,KAAK;EACvB,2BAAW,IAAI,KAAK;EACpB,+CAA+B,IAAI,KAAK;EACzC;;AA0BH,SAAS,SAAS,QAAgB,OAAuB;AACvD,QAAO,GAAG,OAAO,GAAG,MAAM,QAAQ,mBAAmB,IAAI;;AAG3D,SAAgB,uBAAuB,OAAwC;CAC7E,eAAe,WAAW,MAA2B;AACnD,QAAM,MAAM,IAAI,KAAK,IAAI,KAAK;AAC9B,SAAO;;CAGT,eAAe,aACb,OACyB;EACzB,MAAM,KAAK,SAAS,OAAO,GAAG,MAAM,aAAa,GAAG,MAAM,OAAO;EACjE,MAAM,MAAsB;GAAE;GAAI,GAAG;GAAO;AAC5C,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO;;CAGT,eAAe,kBAAkB,OAIR;AACvB,MAAI,CAAC,MAAM,WAAW,OACpB,OAAM,IAAI,MAAM,uBAAuB;EAEzC,MAAM,OAAO,MAAM,MAAM,IAAI,MAAM,OAAO;AAC1C,MAAI,CAAC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AIgD;EACpE,MAAM,WAAW,MAAM,UAAU,IAAI,MAAM,WAAW;AACtD,MAAI,CAAC,SACH,OAAM,IAAI,MAAM,qBAAqB;AAEvC,MAAI,SAAS,iBAAiB,MAAM,aAClC,OAAM,IAAI,MAAM,wBAAwB;EAG1C,MAAM,SADI,MAAM,MAAM,aAAa,CAEhC,MAAM,MAAM,CACZ,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,OAAO,QAAQ;AAalB,SAAO,EAAE,OAZK,SAAS,uBACpB,KAAK,OAAO,MAAM,aAAa,IAAI,GAAG,CAAC,CACvC,QAAQ,OAA0B,QAAQ,GAAG,CAAC,CAC9C,QAAQ,OAAO;AACd,OAAI,OAAO,WAAW,EAAG,QAAO;GAChC,MAAM,MAAM,GAAG,QAAQ,aAAa;AACpC,UAAO,OAAO,OAAO,UAAU,IAAI,SAAS,MAAM,CAAC;IACnD,CACD,KAAK,QAAQ;GACZ,eAAe,GAAG;GAClB,SAAS,GAAG,QAAQ,MAAM,GAAG,IAAI;GAClC,EAAE,EACW;;AAGlB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kb.js","names":["defineSchemaModel"],"sources":["../../src/operations/kb.ts"],"sourcesContent":["import { defineCommand, defineQuery } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\n\nimport {\n KBSnapshotModel,\n RuleVersionModel,\n SourceDocumentModel,\n SourceRefModel,\n} from '../entities/models';\n\nconst IngestSourceInput = defineSchemaModel({\n name: 'KbIngestSourceInput',\n description: 'Ingest immutable source metadata referencing a stored file.',\n fields: {\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n authority: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fetchedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst UpsertRuleVersionInput = defineSchemaModel({\n name: 'KbUpsertRuleVersionInput',\n description: 'Create a new draft rule version (immutable history).',\n fields: {\n ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },\n },\n});\n\nconst ApproveRuleVersionInput = defineSchemaModel({\n name: 'KbApproveRuleVersionInput',\n description: 'Approve a rule version (human verification).',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n approver: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst PublishSnapshotInput = defineSchemaModel({\n name: 'KbPublishSnapshotInput',\n description: 'Publish a snapshot for a jurisdiction as-of a date.',\n fields: {\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n asOfDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst SearchKbInput = defineSchemaModel({\n name: 'KbSearchInput',\n description: 'Search within a published snapshot.',\n fields: {\n snapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n query: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst SearchKbResultItem = defineSchemaModel({\n name: 'KbSearchResultItem',\n description: 'Search result referencing a specific rule version.',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst SearchKbOutput = defineSchemaModel({\n name: 'KbSearchOutput',\n description: 'Search results constrained to snapshot + jurisdiction.',\n fields: {\n items: { type: SearchKbResultItem, isArray: true, isOptional: false },\n },\n});\n\nexport const KbIngestSourceContract = defineCommand({\n meta: {\n key: 'kb.ingestSource',\n title: 'Ingest Source',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'sources', 'ingestion'],\n description: 'Ingest immutable source document metadata.',\n goal: 'Store traceable source documents for curated KB.',\n context: 'Called when an admin uploads/records authoritative sources.',\n },\n io: {\n input: IngestSourceInput,\n output: SourceDocumentModel,\n },\n policy: { auth: 'user' },\n});\n\nexport const KbUpsertRuleVersionContract = defineCommand({\n meta: {\n key: 'kb.upsertRuleVersion',\n title: 'Upsert Rule Version',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'rules', 'versioning'],\n description: 'Create a new draft rule version with source references.',\n goal: 'Propose curated knowledge updates with traceability.',\n context: 'Automation or curators propose draft rule versions.',\n },\n io: {\n input: UpsertRuleVersionInput,\n output: RuleVersionModel,\n errors: {\n SOURCE_REFS_REQUIRED: {\n description: 'Rule version must cite at least one sourceRef',\n http: 400,\n gqlCode: 'SOURCE_REFS_REQUIRED',\n when: 'sourceRefs is empty',\n },\n RULE_NOT_FOUND: {\n description: 'Rule does not exist',\n http: 404,\n gqlCode: 'RULE_NOT_FOUND',\n when: 'ruleId is unknown',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const KbApproveRuleVersionContract = defineCommand({\n meta: {\n key: 'kb.approveRuleVersion',\n title: 'Approve Rule Version',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'rules', 'approval'],\n description: 'Approve a draft rule version.',\n goal: 'Human verification step before publishing snapshots.',\n context: 'Curators/experts approve proposed KB changes.',\n },\n io: {\n input: ApproveRuleVersionInput,\n output: RuleVersionModel,\n },\n policy: { auth: 'user' },\n});\n\nexport const KbPublishSnapshotContract = defineCommand({\n meta: {\n key: 'kb.publishSnapshot',\n title: 'Publish Snapshot',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'snapshots', 'publishing'],\n description: 'Publish a KB snapshot for a jurisdiction.',\n goal: 'Create a stable snapshot that assistant answers can cite.',\n context:\n 'Publishing happens after approvals; snapshot is referenced by answers.',\n },\n io: {\n input: PublishSnapshotInput,\n output: KBSnapshotModel,\n errors: {\n NO_APPROVED_RULES: {\n description: 'No approved rule versions available to publish',\n http: 409,\n gqlCode: 'NO_APPROVED_RULES',\n when: 'jurisdiction has zero approved rule versions',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const KbSearchContract = defineQuery({\n meta: {\n key: 'kb.search',\n title: 'Search KB',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'search', 'snapshots'],\n description: 'Search within a published KB snapshot.',\n goal: 'Provide scoped retrieval for assistant answers.',\n context: 'Assistant queries curated rules from a specific snapshot.',\n },\n io: {\n input: SearchKbInput,\n output: SearchKbOutput,\n },\n policy: { auth: 'user' },\n});\n"],"mappings":";;;;;AAUA,MAAM,oBAAoBA,oBAAkB;CAC1C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACpE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EACjE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE;CACF,CAAC;AAEF,MAAM,yBAAyBA,oBAAkB;CAC/C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACrE,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE,YAAY;GAAE,MAAM;GAAgB,SAAS;GAAM,YAAY;GAAO;EAC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AQ,EAAE,MAAM,QAAQ;CACzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versioned-knowledge-base.feature.js","names":[],"sources":["../src/versioned-knowledge-base.feature.ts"],"sourcesContent":["import { defineFeature } from '@contractspec/lib.contracts';\n\nexport const VersionedKnowledgeBaseFeature = defineFeature({\n meta: {\n key: 'versioned-knowledge-base',\n version: '1.0.0',\n title: 'Versioned Knowledge Base',\n description:\n 'Curated KB with immutable sources, rule versions, and published snapshots.',\n domain: 'knowledge',\n owners: ['@examples'],\n tags: ['knowledge', 'versioning', 'snapshots'],\n stability: 'experimental',\n },\n operations: [\n { key: 'kb.ingestSource', version: '1.0.0' },\n { key: 'kb.upsertRuleVersion', version: '1.0.0' },\n { key: 'kb.approveRuleVersion', version: '1.0.0' },\n { key: 'kb.publishSnapshot', version: '1.0.0' },\n { key: 'kb.search', version: '1.0.0' },\n ],\n events: [\n { key: 'kb.source.ingested', version: '1.0.0' },\n { key: 'kb.ruleVersion.created', version: '1.0.0' },\n { key: 'kb.ruleVersion.approved', version: '1.0.0' },\n { key: 'kb.snapshot.published', version: '1.0.0' },\n ],\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n capabilities: {\n requires: [{ key: 'knowledge', version: '1.0.0' }],\n },\n});\n"],"mappings":";;;AAEA,MAAa,gCAAgC,cAAc;CACzD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,QAAQ;EACR,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAc;GAAY;EAC9C,WAAW;EACZ;CACD,YAAY;EACV;GAAE,KAAK;GAAmB,SAAS;GAAS;EAC5C;GAAE,KAAK;GAAwB,SAAS;GAAS;EACjD;GAAE,KAAK;GAAyB,SAAS;GAAS;EAClD;GAAE,KAAK;GAAsB,SAAS;GAAS;EAC/C;GAAE,KAAK;GAAa,SAAS;GAAS;EACvC;CACD,QAAQ;EACN;GAAE,KAAK;GAAsB,SAAS;GAAS;EAC/C;GAAE,KAAK;GAA0B,SAAS;GAAS;EACnD;GAAE,KAAK;GAA2B,SAAS;GAAS;EACpD;GAAE,KAAK;GAAyB,SAAS;GAAS;EACnD;CACD,eAAe,EAAE;CACjB,kBAAkB,EAAE;CACpB,sBAAsB,EAAE;CACxB,cAAc,EACZ,UAAU,CAAC;EAAE,KAAK;EAAa,SAAS;EAAS,CAAC,EACnD;CACF,CAAC"}
|