@lssm/example.versioned-knowledge-base 1.41.0 → 1.42.1

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 (51) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +47 -0
  2. package/.turbo/turbo-build.log +43 -18
  3. package/CHANGELOG.md +22 -0
  4. package/LICENSE +21 -0
  5. package/README.md +3 -0
  6. package/dist/docs/index.d.ts +1 -0
  7. package/dist/docs/index.js +1 -1
  8. package/dist/docs/versioned-knowledge-base.docblock.d.ts +1 -0
  9. package/dist/docs/versioned-knowledge-base.docblock.js +29 -18
  10. package/dist/docs/versioned-knowledge-base.docblock.js.map +1 -0
  11. package/dist/entities/index.d.ts +2 -0
  12. package/dist/entities/index.js +3 -1
  13. package/dist/entities/models.d.ts +139 -0
  14. package/dist/entities/models.d.ts.map +1 -0
  15. package/dist/entities/models.js +151 -1
  16. package/dist/entities/models.js.map +1 -0
  17. package/dist/events.d.ts +63 -0
  18. package/dist/events.d.ts.map +1 -0
  19. package/dist/events.js +124 -1
  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 +42 -1
  24. package/dist/example.js.map +1 -0
  25. package/dist/handlers/index.d.ts +2 -0
  26. package/dist/handlers/index.js +3 -1
  27. package/dist/handlers/memory.handlers.d.ts +78 -0
  28. package/dist/handlers/memory.handlers.d.ts.map +1 -0
  29. package/dist/handlers/memory.handlers.js +104 -1
  30. package/dist/handlers/memory.handlers.js.map +1 -0
  31. package/dist/index.d.ts +9 -0
  32. package/dist/index.js +11 -1
  33. package/dist/operations/index.d.ts +2 -0
  34. package/dist/operations/index.js +3 -0
  35. package/dist/operations/kb.d.ts +267 -0
  36. package/dist/operations/kb.d.ts.map +1 -0
  37. package/dist/operations/kb.js +256 -0
  38. package/dist/operations/kb.js.map +1 -0
  39. package/dist/versioned-knowledge-base.feature.d.ts +7 -0
  40. package/dist/versioned-knowledge-base.feature.d.ts.map +1 -0
  41. package/dist/versioned-knowledge-base.feature.js +68 -1
  42. package/dist/versioned-knowledge-base.feature.js.map +1 -0
  43. package/package.json +29 -20
  44. package/src/events.ts +32 -12
  45. package/src/index.ts +1 -1
  46. package/src/{contracts → operations}/kb.ts +10 -5
  47. package/src/versioned-knowledge-base.feature.ts +10 -9
  48. package/dist/contracts/index.js +0 -1
  49. package/dist/contracts/kb.js +0 -1
  50. package/tsconfig.tsbuildinfo +0 -1
  51. /package/src/{contracts → operations}/index.ts +0 -0
package/package.json CHANGED
@@ -1,28 +1,30 @@
1
1
  {
2
2
  "name": "@lssm/example.versioned-knowledge-base",
3
- "version": "1.41.0",
3
+ "version": "1.42.1",
4
4
  "description": "Example: curated, versioned knowledge base with immutable sources, rule versions, and published snapshots.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
- ".": "./src/index.ts",
11
- "./contracts": "./src/contracts/index.ts",
12
- "./contracts/kb": "./src/contracts/kb.ts",
13
- "./docs": "./src/docs/index.ts",
14
- "./docs/versioned-knowledge-base.docblock": "./src/docs/versioned-knowledge-base.docblock.ts",
15
- "./entities": "./src/entities/index.ts",
16
- "./entities/models": "./src/entities/models.ts",
17
- "./events": "./src/events.ts",
18
- "./example": "./src/example.ts",
19
- "./handlers": "./src/handlers/index.ts",
20
- "./handlers/memory.handlers": "./src/handlers/memory.handlers.ts",
21
- "./versioned-knowledge-base.feature": "./src/versioned-knowledge-base.feature.ts",
10
+ ".": "./dist/index.js",
11
+ "./docs": "./dist/docs/index.js",
12
+ "./docs/versioned-knowledge-base.docblock": "./dist/docs/versioned-knowledge-base.docblock.js",
13
+ "./entities": "./dist/entities/index.js",
14
+ "./entities/models": "./dist/entities/models.js",
15
+ "./events": "./dist/events.js",
16
+ "./example": "./dist/example.js",
17
+ "./handlers": "./dist/handlers/index.js",
18
+ "./handlers/memory.handlers": "./dist/handlers/memory.handlers.js",
19
+ "./operations": "./dist/operations/index.js",
20
+ "./operations/kb": "./dist/operations/kb.js",
21
+ "./versioned-knowledge-base.feature": "./dist/versioned-knowledge-base.feature.js",
22
22
  "./*": "./*"
23
23
  },
24
24
  "scripts": {
25
- "build": "bun build:bundle && bun build:types",
25
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
26
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
27
+ "build": "bun build:types && bun build:bundle",
26
28
  "build:bundle": "tsdown",
27
29
  "build:types": "tsc --noEmit",
28
30
  "dev": "bun build:bundle --watch",
@@ -33,14 +35,14 @@
33
35
  "test": "bun test"
34
36
  },
35
37
  "dependencies": {
36
- "@lssm/lib.contracts": "workspace:*",
37
- "@lssm/lib.schema": "workspace:*",
38
+ "@lssm/lib.contracts": "1.42.1",
39
+ "@lssm/lib.schema": "1.42.1",
38
40
  "zod": "^4.1.13"
39
41
  },
40
42
  "devDependencies": {
41
- "@lssm/tool.tsdown": "workspace:*",
42
- "@lssm/tool.typescript": "workspace:*",
43
- "tsdown": "^0.17.4",
43
+ "@lssm/tool.tsdown": "1.42.1",
44
+ "@lssm/tool.typescript": "1.42.1",
45
+ "tsdown": "^0.18.3",
44
46
  "typescript": "^5.9.3"
45
47
  },
46
48
  "publishConfig": {
@@ -59,6 +61,13 @@
59
61
  "./handlers/memory.handlers": "./dist/handlers/memory.handlers.js",
60
62
  "./versioned-knowledge-base.feature": "./dist/versioned-knowledge-base.feature.js",
61
63
  "./*": "./*"
62
- }
64
+ },
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "license": "MIT",
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "https://github.com/lssm-tech/contractspec.git",
71
+ "directory": "packages/examples/versioned-knowledge-base"
63
72
  }
64
73
  }
package/src/events.ts CHANGED
@@ -15,9 +15,14 @@ const KbSourceIngestedPayload = defineSchemaModel({
15
15
  });
16
16
 
17
17
  export const KbSourceIngestedEvent = defineEvent({
18
- name: 'kb.source.ingested',
19
- version: 1,
20
- description: 'Source document ingested (immutable).',
18
+ meta: {
19
+ key: 'kb.source.ingested',
20
+ version: 1,
21
+ description: 'Source document ingested (immutable).',
22
+ stability: 'experimental',
23
+ owners: ['@examples'],
24
+ tags: ['knowledge'],
25
+ },
21
26
  payload: KbSourceIngestedPayload,
22
27
  });
23
28
 
@@ -36,9 +41,14 @@ const KbRuleVersionCreatedPayload = defineSchemaModel({
36
41
  });
37
42
 
38
43
  export const KbRuleVersionCreatedEvent = defineEvent({
39
- name: 'kb.ruleVersion.created',
40
- version: 1,
41
- description: 'Rule version created (draft).',
44
+ meta: {
45
+ key: 'kb.ruleVersion.created',
46
+ version: 1,
47
+ description: 'Rule version created (draft).',
48
+ stability: 'experimental',
49
+ owners: ['@examples'],
50
+ tags: ['knowledge'],
51
+ },
42
52
  payload: KbRuleVersionCreatedPayload,
43
53
  });
44
54
 
@@ -55,9 +65,14 @@ const KbRuleVersionApprovedPayload = defineSchemaModel({
55
65
  });
56
66
 
57
67
  export const KbRuleVersionApprovedEvent = defineEvent({
58
- name: 'kb.ruleVersion.approved',
59
- version: 1,
60
- description: 'Rule version approved (human verified).',
68
+ meta: {
69
+ key: 'kb.ruleVersion.approved',
70
+ version: 1,
71
+ description: 'Rule version approved (human verified).',
72
+ stability: 'experimental',
73
+ owners: ['@examples'],
74
+ tags: ['knowledge'],
75
+ },
61
76
  payload: KbRuleVersionApprovedPayload,
62
77
  });
63
78
 
@@ -75,8 +90,13 @@ const KbSnapshotPublishedPayload = defineSchemaModel({
75
90
  });
76
91
 
77
92
  export const KbSnapshotPublishedEvent = defineEvent({
78
- name: 'kb.snapshot.published',
79
- version: 1,
80
- description: 'KB snapshot published.',
93
+ meta: {
94
+ key: 'kb.snapshot.published',
95
+ version: 1,
96
+ description: 'KB snapshot published.',
97
+ stability: 'experimental',
98
+ owners: ['@examples'],
99
+ tags: ['knowledge'],
100
+ },
81
101
  payload: KbSnapshotPublishedPayload,
82
102
  });
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Curated KB with immutable sources, reviewable rule versions, and published snapshots.
5
5
  */
6
6
  export * from './entities';
7
- export * from './contracts';
7
+ export * from './operations';
8
8
  export * from './events';
9
9
  export * from './handlers';
10
10
  export * from './versioned-knowledge-base.feature';
@@ -84,7 +84,8 @@ const SearchKbOutput = defineSchemaModel({
84
84
 
85
85
  export const KbIngestSourceContract = defineCommand({
86
86
  meta: {
87
- name: 'kb.ingestSource',
87
+ key: 'kb.ingestSource',
88
+ title: 'Ingest Source',
88
89
  version: 1,
89
90
  stability: 'experimental',
90
91
  owners: ['@examples'],
@@ -102,7 +103,8 @@ export const KbIngestSourceContract = defineCommand({
102
103
 
103
104
  export const KbUpsertRuleVersionContract = defineCommand({
104
105
  meta: {
105
- name: 'kb.upsertRuleVersion',
106
+ key: 'kb.upsertRuleVersion',
107
+ title: 'Upsert Rule Version',
106
108
  version: 1,
107
109
  stability: 'experimental',
108
110
  owners: ['@examples'],
@@ -134,7 +136,8 @@ export const KbUpsertRuleVersionContract = defineCommand({
134
136
 
135
137
  export const KbApproveRuleVersionContract = defineCommand({
136
138
  meta: {
137
- name: 'kb.approveRuleVersion',
139
+ key: 'kb.approveRuleVersion',
140
+ title: 'Approve Rule Version',
138
141
  version: 1,
139
142
  stability: 'experimental',
140
143
  owners: ['@examples'],
@@ -152,7 +155,8 @@ export const KbApproveRuleVersionContract = defineCommand({
152
155
 
153
156
  export const KbPublishSnapshotContract = defineCommand({
154
157
  meta: {
155
- name: 'kb.publishSnapshot',
158
+ key: 'kb.publishSnapshot',
159
+ title: 'Publish Snapshot',
156
160
  version: 1,
157
161
  stability: 'experimental',
158
162
  owners: ['@examples'],
@@ -179,7 +183,8 @@ export const KbPublishSnapshotContract = defineCommand({
179
183
 
180
184
  export const KbSearchContract = defineQuery({
181
185
  meta: {
182
- name: 'kb.search',
186
+ key: 'kb.search',
187
+ title: 'Search KB',
183
188
  version: 1,
184
189
  stability: 'experimental',
185
190
  owners: ['@examples'],
@@ -3,6 +3,7 @@ import type { FeatureModuleSpec } from '@lssm/lib.contracts';
3
3
  export const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {
4
4
  meta: {
5
5
  key: 'versioned-knowledge-base',
6
+ version: 1,
6
7
  title: 'Versioned Knowledge Base',
7
8
  description:
8
9
  'Curated KB with immutable sources, rule versions, and published snapshots.',
@@ -12,17 +13,17 @@ export const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {
12
13
  stability: 'experimental',
13
14
  },
14
15
  operations: [
15
- { name: 'kb.ingestSource', version: 1 },
16
- { name: 'kb.upsertRuleVersion', version: 1 },
17
- { name: 'kb.approveRuleVersion', version: 1 },
18
- { name: 'kb.publishSnapshot', version: 1 },
19
- { name: 'kb.search', version: 1 },
16
+ { key: 'kb.ingestSource', version: 1 },
17
+ { key: 'kb.upsertRuleVersion', version: 1 },
18
+ { key: 'kb.approveRuleVersion', version: 1 },
19
+ { key: 'kb.publishSnapshot', version: 1 },
20
+ { key: 'kb.search', version: 1 },
20
21
  ],
21
22
  events: [
22
- { name: 'kb.source.ingested', version: 1 },
23
- { name: 'kb.ruleVersion.created', version: 1 },
24
- { name: 'kb.ruleVersion.approved', version: 1 },
25
- { name: 'kb.snapshot.published', version: 1 },
23
+ { key: 'kb.source.ingested', version: 1 },
24
+ { key: 'kb.ruleVersion.created', version: 1 },
25
+ { key: 'kb.ruleVersion.approved', version: 1 },
26
+ { key: 'kb.snapshot.published', version: 1 },
26
27
  ],
27
28
  presentations: [],
28
29
  opToPresentation: [],
@@ -1 +0,0 @@
1
- import{KbApproveRuleVersionContract as e,KbIngestSourceContract as t,KbPublishSnapshotContract as n,KbSearchContract as r,KbUpsertRuleVersionContract as i}from"./kb.js";export{e as KbApproveRuleVersionContract,t as KbIngestSourceContract,n as KbPublishSnapshotContract,r as KbSearchContract,i as KbUpsertRuleVersionContract};
@@ -1 +0,0 @@
1
- import{KBSnapshotModel as e,RuleVersionModel as t,SourceDocumentModel as n,SourceRefModel as r}from"../entities/models.js";import{defineCommand as i,defineQuery as a}from"@lssm/lib.contracts";import{ScalarTypeEnum as o,defineSchemaModel as s}from"@lssm/lib.schema";const c=s({name:`KbIngestSourceInput`,description:`Ingest immutable source metadata referencing a stored file.`,fields:{jurisdiction:{type:o.String_unsecure(),isOptional:!1},authority:{type:o.String_unsecure(),isOptional:!1},title:{type:o.String_unsecure(),isOptional:!1},fetchedAt:{type:o.DateTime(),isOptional:!1},hash:{type:o.String_unsecure(),isOptional:!1},fileId:{type:o.String_unsecure(),isOptional:!1}}}),l=s({name:`KbUpsertRuleVersionInput`,description:`Create a new draft rule version (immutable history).`,fields:{ruleId:{type:o.String_unsecure(),isOptional:!1},content:{type:o.String_unsecure(),isOptional:!1},sourceRefs:{type:r,isArray:!0,isOptional:!1}}}),u=s({name:`KbApproveRuleVersionInput`,description:`Approve a rule version (human verification).`,fields:{ruleVersionId:{type:o.String_unsecure(),isOptional:!1},approver:{type:o.String_unsecure(),isOptional:!1}}}),d=s({name:`KbPublishSnapshotInput`,description:`Publish a snapshot for a jurisdiction as-of a date.`,fields:{jurisdiction:{type:o.String_unsecure(),isOptional:!1},asOfDate:{type:o.DateTime(),isOptional:!1}}}),f=s({name:`KbSearchInput`,description:`Search within a published snapshot.`,fields:{snapshotId:{type:o.String_unsecure(),isOptional:!1},jurisdiction:{type:o.String_unsecure(),isOptional:!1},query:{type:o.String_unsecure(),isOptional:!1}}}),p=s({name:`KbSearchOutput`,description:`Search results constrained to snapshot + jurisdiction.`,fields:{items:{type:s({name:`KbSearchResultItem`,description:`Search result referencing a specific rule version.`,fields:{ruleVersionId:{type:o.String_unsecure(),isOptional:!1},excerpt:{type:o.String_unsecure(),isOptional:!0}}}),isArray:!0,isOptional:!1}}}),m=i({meta:{name:`kb.ingestSource`,version:1,stability:`experimental`,owners:[`@examples`],tags:[`knowledge`,`sources`,`ingestion`],description:`Ingest immutable source document metadata.`,goal:`Store traceable source documents for curated KB.`,context:`Called when an admin uploads/records authoritative sources.`},io:{input:c,output:n},policy:{auth:`user`}}),h=i({meta:{name:`kb.upsertRuleVersion`,version:1,stability:`experimental`,owners:[`@examples`],tags:[`knowledge`,`rules`,`versioning`],description:`Create a new draft rule version with source references.`,goal:`Propose curated knowledge updates with traceability.`,context:`Automation or curators propose draft rule versions.`},io:{input:l,output:t,errors:{SOURCE_REFS_REQUIRED:{description:`Rule version must cite at least one sourceRef`,http:400,gqlCode:`SOURCE_REFS_REQUIRED`,when:`sourceRefs is empty`},RULE_NOT_FOUND:{description:`Rule does not exist`,http:404,gqlCode:`RULE_NOT_FOUND`,when:`ruleId is unknown`}}},policy:{auth:`user`}}),g=i({meta:{name:`kb.approveRuleVersion`,version:1,stability:`experimental`,owners:[`@examples`],tags:[`knowledge`,`rules`,`approval`],description:`Approve a draft rule version.`,goal:`Human verification step before publishing snapshots.`,context:`Curators/experts approve proposed KB changes.`},io:{input:u,output:t},policy:{auth:`user`}}),_=i({meta:{name:`kb.publishSnapshot`,version:1,stability:`experimental`,owners:[`@examples`],tags:[`knowledge`,`snapshots`,`publishing`],description:`Publish a KB snapshot for a jurisdiction.`,goal:`Create a stable snapshot that assistant answers can cite.`,context:`Publishing happens after approvals; snapshot is referenced by answers.`},io:{input:d,output:e,errors:{NO_APPROVED_RULES:{description:`No approved rule versions available to publish`,http:409,gqlCode:`NO_APPROVED_RULES`,when:`jurisdiction has zero approved rule versions`}}},policy:{auth:`user`}}),v=a({meta:{name:`kb.search`,version:1,stability:`experimental`,owners:[`@examples`],tags:[`knowledge`,`search`,`snapshots`],description:`Search within a published KB snapshot.`,goal:`Provide scoped retrieval for assistant answers.`,context:`Assistant queries curated rules from a specific snapshot.`},io:{input:f,output:p},policy:{auth:`user`}});export{g as KbApproveRuleVersionContract,m as KbIngestSourceContract,_ as KbPublishSnapshotContract,v as KbSearchContract,h as KbUpsertRuleVersionContract};