@contractspec/example.versioned-knowledge-base 3.7.7 → 3.7.12
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 +45 -42
- package/CHANGELOG.md +43 -0
- package/README.md +5 -0
- package/dist/browser/index.js +49 -0
- package/dist/browser/knowledge-snapshot-publication.migration.js +50 -0
- package/dist/contracts.test.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +49 -0
- package/dist/knowledge-snapshot-publication.migration.d.ts +2 -0
- package/dist/knowledge-snapshot-publication.migration.js +51 -0
- package/dist/node/index.js +49 -0
- package/dist/node/knowledge-snapshot-publication.migration.js +50 -0
- package/package.json +19 -5
- package/src/contracts.test.ts +17 -0
- package/src/index.ts +1 -0
- package/src/knowledge-snapshot-publication.migration.ts +51 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -2,52 +2,55 @@ $ contractspec-bun-build prebuild
|
|
|
2
2
|
$ bun run prebuild && bun run build:bundle && bun run build:types
|
|
3
3
|
$ contractspec-bun-build prebuild
|
|
4
4
|
$ contractspec-bun-build transpile
|
|
5
|
-
[contractspec-bun-build] transpile target=bun root=src entries=
|
|
6
|
-
Bundled
|
|
5
|
+
[contractspec-bun-build] transpile target=bun root=src entries=13 noBundle=false
|
|
6
|
+
Bundled 13 modules in 40ms
|
|
7
7
|
|
|
8
|
-
docs/index.js
|
|
9
|
-
./index.js
|
|
10
|
-
|
|
11
|
-
operations/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
entities/
|
|
16
|
-
|
|
17
|
-
./
|
|
18
|
-
|
|
19
|
-
handlers/
|
|
8
|
+
docs/index.js 1.51 KB (entry point)
|
|
9
|
+
./index.js 21.87 KB (entry point)
|
|
10
|
+
./knowledge-snapshot-publication.migration.js 1.57 KB (entry point)
|
|
11
|
+
operations/index.js 9.56 KB (entry point)
|
|
12
|
+
operations/kb.js 9.56 KB (entry point)
|
|
13
|
+
./versioned-knowledge-base.feature.js 1.41 KB (entry point)
|
|
14
|
+
docs/versioned-knowledge-base.docblock.js 1.51 KB (entry point)
|
|
15
|
+
entities/index.js 3.22 KB (entry point)
|
|
16
|
+
entities/models.js 3.22 KB (entry point)
|
|
17
|
+
./events.js 3.17 KB (entry point)
|
|
18
|
+
./example.js 1.0 KB (entry point)
|
|
19
|
+
handlers/index.js 3.56 KB (entry point)
|
|
20
|
+
handlers/memory.handlers.js 3.56 KB (entry point)
|
|
20
21
|
|
|
21
|
-
[contractspec-bun-build] transpile target=node root=src entries=
|
|
22
|
-
Bundled
|
|
22
|
+
[contractspec-bun-build] transpile target=node root=src entries=13 noBundle=false
|
|
23
|
+
Bundled 13 modules in 33ms
|
|
23
24
|
|
|
24
|
-
docs/index.js
|
|
25
|
-
./index.js
|
|
26
|
-
|
|
27
|
-
operations/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
entities/
|
|
32
|
-
|
|
33
|
-
./
|
|
34
|
-
|
|
35
|
-
handlers/
|
|
25
|
+
docs/index.js 1.50 KB (entry point)
|
|
26
|
+
./index.js 21.85 KB (entry point)
|
|
27
|
+
./knowledge-snapshot-publication.migration.js 1.56 KB (entry point)
|
|
28
|
+
operations/index.js 9.55 KB (entry point)
|
|
29
|
+
operations/kb.js 9.55 KB (entry point)
|
|
30
|
+
./versioned-knowledge-base.feature.js 1.40 KB (entry point)
|
|
31
|
+
docs/versioned-knowledge-base.docblock.js 1.50 KB (entry point)
|
|
32
|
+
entities/index.js 3.22 KB (entry point)
|
|
33
|
+
entities/models.js 3.22 KB (entry point)
|
|
34
|
+
./events.js 3.16 KB (entry point)
|
|
35
|
+
./example.js 1.0 KB (entry point)
|
|
36
|
+
handlers/index.js 3.55 KB (entry point)
|
|
37
|
+
handlers/memory.handlers.js 3.55 KB (entry point)
|
|
36
38
|
|
|
37
|
-
[contractspec-bun-build] transpile target=browser root=src entries=
|
|
38
|
-
Bundled
|
|
39
|
+
[contractspec-bun-build] transpile target=browser root=src entries=13 noBundle=false
|
|
40
|
+
Bundled 13 modules in 29ms
|
|
39
41
|
|
|
40
|
-
docs/index.js
|
|
41
|
-
./index.js
|
|
42
|
-
|
|
43
|
-
operations/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
entities/
|
|
48
|
-
|
|
49
|
-
./
|
|
50
|
-
|
|
51
|
-
handlers/
|
|
42
|
+
docs/index.js 1.50 KB (entry point)
|
|
43
|
+
./index.js 21.85 KB (entry point)
|
|
44
|
+
./knowledge-snapshot-publication.migration.js 1.56 KB (entry point)
|
|
45
|
+
operations/index.js 9.55 KB (entry point)
|
|
46
|
+
operations/kb.js 9.55 KB (entry point)
|
|
47
|
+
./versioned-knowledge-base.feature.js 1.40 KB (entry point)
|
|
48
|
+
docs/versioned-knowledge-base.docblock.js 1.50 KB (entry point)
|
|
49
|
+
entities/index.js 3.22 KB (entry point)
|
|
50
|
+
entities/models.js 3.22 KB (entry point)
|
|
51
|
+
./events.js 3.16 KB (entry point)
|
|
52
|
+
./example.js 1.0 KB (entry point)
|
|
53
|
+
handlers/index.js 3.55 KB (entry point)
|
|
54
|
+
handlers/memory.handlers.js 3.55 KB (entry point)
|
|
52
55
|
|
|
53
56
|
$ contractspec-bun-build types
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @contractspec/example.versioned-knowledge-base
|
|
2
2
|
|
|
3
|
+
## 3.7.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [81256ea]
|
|
8
|
+
- Updated dependencies [2619dd8]
|
|
9
|
+
- Updated dependencies [6de2f1c]
|
|
10
|
+
- Updated dependencies [81256ea]
|
|
11
|
+
- Updated dependencies [a4489bb]
|
|
12
|
+
- Updated dependencies [9cb304e]
|
|
13
|
+
- @contractspec/lib.contracts-spec@5.0.0
|
|
14
|
+
- @contractspec/lib.schema@3.7.10
|
|
15
|
+
|
|
16
|
+
## 3.7.11
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- fix: release
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @contractspec/lib.contracts-spec@4.1.3
|
|
23
|
+
- @contractspec/lib.schema@3.7.9
|
|
24
|
+
|
|
25
|
+
## 3.7.10
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 1a44cb6: feat: improve examples to increase coverage of Contracts type
|
|
30
|
+
- Updated dependencies [1a44cb6]
|
|
31
|
+
- @contractspec/lib.contracts-spec@4.1.2
|
|
32
|
+
- @contractspec/lib.schema@3.7.8
|
|
33
|
+
|
|
34
|
+
## 3.7.9
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- fix: release
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
- @contractspec/lib.contracts-spec@4.1.1
|
|
41
|
+
- @contractspec/lib.schema@3.7.7
|
|
42
|
+
|
|
3
43
|
## 3.7.6
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
|
@@ -704,14 +744,17 @@
|
|
|
704
744
|
feat: Contract layers support (features, examples, app-configs)
|
|
705
745
|
|
|
706
746
|
### New CLI Commands
|
|
747
|
+
|
|
707
748
|
- `contractspec list layers` - List all contract layers with filtering
|
|
708
749
|
|
|
709
750
|
### Enhanced Commands
|
|
751
|
+
|
|
710
752
|
- `contractspec ci` - New `layers` check category validates features/examples/config
|
|
711
753
|
- `contractspec doctor` - New `layers` health checks
|
|
712
754
|
- `contractspec integrity` - Now shows layer statistics
|
|
713
755
|
|
|
714
756
|
### New APIs
|
|
757
|
+
|
|
715
758
|
- `discoverLayers()` - Scan workspace for all layer files
|
|
716
759
|
- `scanExampleSource()` - Parse ExampleSpec from source code
|
|
717
760
|
- `isExampleFile()` - Check if file is an example spec
|
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ Website: https://contractspec.io
|
|
|
8
8
|
|
|
9
9
|
- Immutable source and versioned rule management.
|
|
10
10
|
- Snapshot publishing pattern.
|
|
11
|
+
- Canonical `migration` export via `KnowledgeSnapshotPublicationMigration`.
|
|
11
12
|
- Entity models for KB domain.
|
|
12
13
|
- Memory-based handler implementation.
|
|
13
14
|
- Feature definition and event-driven architecture.
|
|
@@ -33,6 +34,7 @@ Use `@contractspec/example.versioned-knowledge-base` as a reference implementati
|
|
|
33
34
|
- `src/example.ts` is the runnable example entrypoint.
|
|
34
35
|
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
35
36
|
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
37
|
+
- `src/knowledge-snapshot-publication.migration.ts` defines the exported migration spec.
|
|
36
38
|
- `src/operations` is part of the package's public or composition surface.
|
|
37
39
|
|
|
38
40
|
## Public Entry Points
|
|
@@ -46,7 +48,10 @@ Use `@contractspec/example.versioned-knowledge-base` as a reference implementati
|
|
|
46
48
|
- Export `./example` resolves through `./src/example.ts`.
|
|
47
49
|
- Export `./handlers` resolves through `./src/handlers/index.ts`.
|
|
48
50
|
- Export `./handlers/memory.handlers` resolves through `./src/handlers/memory.handlers.ts`.
|
|
51
|
+
- Export `./knowledge-snapshot-publication.migration` resolves through `./src/knowledge-snapshot-publication.migration.ts`.
|
|
49
52
|
- Export `./operations` resolves through `./src/operations/index.ts`.
|
|
53
|
+
- Export `./operations/kb` resolves through `./src/operations/kb.ts`.
|
|
54
|
+
- Export `./versioned-knowledge-base.feature` resolves through `./src/versioned-knowledge-base.feature.ts`.
|
|
50
55
|
- The package publishes 12 total export subpaths; keep docs aligned with `package.json`.
|
|
51
56
|
|
|
52
57
|
## Local Commands
|
package/dist/browser/index.js
CHANGED
|
@@ -349,6 +349,54 @@ function createMemoryKbHandlers(store) {
|
|
|
349
349
|
search
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
+
// src/knowledge-snapshot-publication.migration.ts
|
|
353
|
+
import {
|
|
354
|
+
OwnersEnum,
|
|
355
|
+
StabilityEnum,
|
|
356
|
+
TagsEnum
|
|
357
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
358
|
+
var KnowledgeSnapshotPublicationMigration = {
|
|
359
|
+
meta: {
|
|
360
|
+
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
361
|
+
version: "1.0.0",
|
|
362
|
+
title: "Knowledge Snapshot Publication Migration",
|
|
363
|
+
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
364
|
+
domain: "knowledge",
|
|
365
|
+
owners: [OwnersEnum.PlatformContent],
|
|
366
|
+
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
367
|
+
stability: StabilityEnum.Experimental
|
|
368
|
+
},
|
|
369
|
+
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
370
|
+
plan: {
|
|
371
|
+
up: [
|
|
372
|
+
{
|
|
373
|
+
kind: "schema",
|
|
374
|
+
description: "Create the published snapshot audit table.",
|
|
375
|
+
sql: `
|
|
376
|
+
CREATE TABLE kb_snapshot_publications (
|
|
377
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
378
|
+
published_by TEXT NOT NULL,
|
|
379
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
380
|
+
source_count INTEGER NOT NULL,
|
|
381
|
+
rule_version_count INTEGER NOT NULL
|
|
382
|
+
);`
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
kind: "validation",
|
|
386
|
+
description: "Ensure snapshots have at least one approved rule version.",
|
|
387
|
+
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
down: [
|
|
391
|
+
{
|
|
392
|
+
kind: "schema",
|
|
393
|
+
description: "Remove the snapshot publication audit table.",
|
|
394
|
+
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
395
|
+
}
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
352
400
|
// src/operations/kb.ts
|
|
353
401
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
354
402
|
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
@@ -578,6 +626,7 @@ export {
|
|
|
578
626
|
SourceDocumentModel,
|
|
579
627
|
RuleVersionModel,
|
|
580
628
|
RuleModel,
|
|
629
|
+
KnowledgeSnapshotPublicationMigration,
|
|
581
630
|
KbUpsertRuleVersionContract,
|
|
582
631
|
KbSourceIngestedEvent,
|
|
583
632
|
KbSnapshotPublishedEvent,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/knowledge-snapshot-publication.migration.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
var KnowledgeSnapshotPublicationMigration = {
|
|
8
|
+
meta: {
|
|
9
|
+
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
title: "Knowledge Snapshot Publication Migration",
|
|
12
|
+
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
13
|
+
domain: "knowledge",
|
|
14
|
+
owners: [OwnersEnum.PlatformContent],
|
|
15
|
+
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
16
|
+
stability: StabilityEnum.Experimental
|
|
17
|
+
},
|
|
18
|
+
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
19
|
+
plan: {
|
|
20
|
+
up: [
|
|
21
|
+
{
|
|
22
|
+
kind: "schema",
|
|
23
|
+
description: "Create the published snapshot audit table.",
|
|
24
|
+
sql: `
|
|
25
|
+
CREATE TABLE kb_snapshot_publications (
|
|
26
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
27
|
+
published_by TEXT NOT NULL,
|
|
28
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
29
|
+
source_count INTEGER NOT NULL,
|
|
30
|
+
rule_version_count INTEGER NOT NULL
|
|
31
|
+
);`
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
kind: "validation",
|
|
35
|
+
description: "Ensure snapshots have at least one approved rule version.",
|
|
36
|
+
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
down: [
|
|
40
|
+
{
|
|
41
|
+
kind: "schema",
|
|
42
|
+
description: "Remove the snapshot publication audit table.",
|
|
43
|
+
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
KnowledgeSnapshotPublicationMigration
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './entities';
|
|
|
7
7
|
export * from './events';
|
|
8
8
|
export { default as example } from './example';
|
|
9
9
|
export * from './handlers';
|
|
10
|
+
export * from './knowledge-snapshot-publication.migration';
|
|
10
11
|
export * from './operations';
|
|
11
12
|
export * from './versioned-knowledge-base.feature';
|
|
12
13
|
import './docs';
|
package/dist/index.js
CHANGED
|
@@ -350,6 +350,54 @@ function createMemoryKbHandlers(store) {
|
|
|
350
350
|
search
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
+
// src/knowledge-snapshot-publication.migration.ts
|
|
354
|
+
import {
|
|
355
|
+
OwnersEnum,
|
|
356
|
+
StabilityEnum,
|
|
357
|
+
TagsEnum
|
|
358
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
359
|
+
var KnowledgeSnapshotPublicationMigration = {
|
|
360
|
+
meta: {
|
|
361
|
+
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
362
|
+
version: "1.0.0",
|
|
363
|
+
title: "Knowledge Snapshot Publication Migration",
|
|
364
|
+
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
365
|
+
domain: "knowledge",
|
|
366
|
+
owners: [OwnersEnum.PlatformContent],
|
|
367
|
+
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
368
|
+
stability: StabilityEnum.Experimental
|
|
369
|
+
},
|
|
370
|
+
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
371
|
+
plan: {
|
|
372
|
+
up: [
|
|
373
|
+
{
|
|
374
|
+
kind: "schema",
|
|
375
|
+
description: "Create the published snapshot audit table.",
|
|
376
|
+
sql: `
|
|
377
|
+
CREATE TABLE kb_snapshot_publications (
|
|
378
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
379
|
+
published_by TEXT NOT NULL,
|
|
380
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
381
|
+
source_count INTEGER NOT NULL,
|
|
382
|
+
rule_version_count INTEGER NOT NULL
|
|
383
|
+
);`
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
kind: "validation",
|
|
387
|
+
description: "Ensure snapshots have at least one approved rule version.",
|
|
388
|
+
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
down: [
|
|
392
|
+
{
|
|
393
|
+
kind: "schema",
|
|
394
|
+
description: "Remove the snapshot publication audit table.",
|
|
395
|
+
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
353
401
|
// src/operations/kb.ts
|
|
354
402
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
355
403
|
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
@@ -579,6 +627,7 @@ export {
|
|
|
579
627
|
SourceDocumentModel,
|
|
580
628
|
RuleVersionModel,
|
|
581
629
|
RuleModel,
|
|
630
|
+
KnowledgeSnapshotPublicationMigration,
|
|
582
631
|
KbUpsertRuleVersionContract,
|
|
583
632
|
KbSourceIngestedEvent,
|
|
584
633
|
KbSnapshotPublishedEvent,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/knowledge-snapshot-publication.migration.ts
|
|
3
|
+
import {
|
|
4
|
+
OwnersEnum,
|
|
5
|
+
StabilityEnum,
|
|
6
|
+
TagsEnum
|
|
7
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
8
|
+
var KnowledgeSnapshotPublicationMigration = {
|
|
9
|
+
meta: {
|
|
10
|
+
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
title: "Knowledge Snapshot Publication Migration",
|
|
13
|
+
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
14
|
+
domain: "knowledge",
|
|
15
|
+
owners: [OwnersEnum.PlatformContent],
|
|
16
|
+
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
17
|
+
stability: StabilityEnum.Experimental
|
|
18
|
+
},
|
|
19
|
+
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
20
|
+
plan: {
|
|
21
|
+
up: [
|
|
22
|
+
{
|
|
23
|
+
kind: "schema",
|
|
24
|
+
description: "Create the published snapshot audit table.",
|
|
25
|
+
sql: `
|
|
26
|
+
CREATE TABLE kb_snapshot_publications (
|
|
27
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
28
|
+
published_by TEXT NOT NULL,
|
|
29
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
30
|
+
source_count INTEGER NOT NULL,
|
|
31
|
+
rule_version_count INTEGER NOT NULL
|
|
32
|
+
);`
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
kind: "validation",
|
|
36
|
+
description: "Ensure snapshots have at least one approved rule version.",
|
|
37
|
+
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
down: [
|
|
41
|
+
{
|
|
42
|
+
kind: "schema",
|
|
43
|
+
description: "Remove the snapshot publication audit table.",
|
|
44
|
+
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
KnowledgeSnapshotPublicationMigration
|
|
51
|
+
};
|
package/dist/node/index.js
CHANGED
|
@@ -349,6 +349,54 @@ function createMemoryKbHandlers(store) {
|
|
|
349
349
|
search
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
+
// src/knowledge-snapshot-publication.migration.ts
|
|
353
|
+
import {
|
|
354
|
+
OwnersEnum,
|
|
355
|
+
StabilityEnum,
|
|
356
|
+
TagsEnum
|
|
357
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
358
|
+
var KnowledgeSnapshotPublicationMigration = {
|
|
359
|
+
meta: {
|
|
360
|
+
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
361
|
+
version: "1.0.0",
|
|
362
|
+
title: "Knowledge Snapshot Publication Migration",
|
|
363
|
+
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
364
|
+
domain: "knowledge",
|
|
365
|
+
owners: [OwnersEnum.PlatformContent],
|
|
366
|
+
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
367
|
+
stability: StabilityEnum.Experimental
|
|
368
|
+
},
|
|
369
|
+
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
370
|
+
plan: {
|
|
371
|
+
up: [
|
|
372
|
+
{
|
|
373
|
+
kind: "schema",
|
|
374
|
+
description: "Create the published snapshot audit table.",
|
|
375
|
+
sql: `
|
|
376
|
+
CREATE TABLE kb_snapshot_publications (
|
|
377
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
378
|
+
published_by TEXT NOT NULL,
|
|
379
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
380
|
+
source_count INTEGER NOT NULL,
|
|
381
|
+
rule_version_count INTEGER NOT NULL
|
|
382
|
+
);`
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
kind: "validation",
|
|
386
|
+
description: "Ensure snapshots have at least one approved rule version.",
|
|
387
|
+
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
down: [
|
|
391
|
+
{
|
|
392
|
+
kind: "schema",
|
|
393
|
+
description: "Remove the snapshot publication audit table.",
|
|
394
|
+
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
395
|
+
}
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
352
400
|
// src/operations/kb.ts
|
|
353
401
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
354
402
|
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
@@ -578,6 +626,7 @@ export {
|
|
|
578
626
|
SourceDocumentModel,
|
|
579
627
|
RuleVersionModel,
|
|
580
628
|
RuleModel,
|
|
629
|
+
KnowledgeSnapshotPublicationMigration,
|
|
581
630
|
KbUpsertRuleVersionContract,
|
|
582
631
|
KbSourceIngestedEvent,
|
|
583
632
|
KbSnapshotPublishedEvent,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/knowledge-snapshot-publication.migration.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
var KnowledgeSnapshotPublicationMigration = {
|
|
8
|
+
meta: {
|
|
9
|
+
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
title: "Knowledge Snapshot Publication Migration",
|
|
12
|
+
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
13
|
+
domain: "knowledge",
|
|
14
|
+
owners: [OwnersEnum.PlatformContent],
|
|
15
|
+
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
16
|
+
stability: StabilityEnum.Experimental
|
|
17
|
+
},
|
|
18
|
+
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
19
|
+
plan: {
|
|
20
|
+
up: [
|
|
21
|
+
{
|
|
22
|
+
kind: "schema",
|
|
23
|
+
description: "Create the published snapshot audit table.",
|
|
24
|
+
sql: `
|
|
25
|
+
CREATE TABLE kb_snapshot_publications (
|
|
26
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
27
|
+
published_by TEXT NOT NULL,
|
|
28
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
29
|
+
source_count INTEGER NOT NULL,
|
|
30
|
+
rule_version_count INTEGER NOT NULL
|
|
31
|
+
);`
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
kind: "validation",
|
|
35
|
+
description: "Ensure snapshots have at least one approved rule version.",
|
|
36
|
+
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
down: [
|
|
40
|
+
{
|
|
41
|
+
kind: "schema",
|
|
42
|
+
description: "Remove the snapshot publication audit table.",
|
|
43
|
+
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
KnowledgeSnapshotPublicationMigration
|
|
50
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.versioned-knowledge-base",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.12",
|
|
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",
|
|
@@ -68,6 +68,13 @@
|
|
|
68
68
|
"node": "./dist/node/handlers/memory.handlers.js",
|
|
69
69
|
"default": "./dist/handlers/memory.handlers.js"
|
|
70
70
|
},
|
|
71
|
+
"./knowledge-snapshot-publication.migration": {
|
|
72
|
+
"types": "./dist/knowledge-snapshot-publication.migration.d.ts",
|
|
73
|
+
"browser": "./dist/browser/knowledge-snapshot-publication.migration.js",
|
|
74
|
+
"bun": "./dist/knowledge-snapshot-publication.migration.js",
|
|
75
|
+
"node": "./dist/node/knowledge-snapshot-publication.migration.js",
|
|
76
|
+
"default": "./dist/knowledge-snapshot-publication.migration.js"
|
|
77
|
+
},
|
|
71
78
|
"./operations": {
|
|
72
79
|
"types": "./dist/operations/index.d.ts",
|
|
73
80
|
"browser": "./dist/browser/operations/index.js",
|
|
@@ -106,13 +113,13 @@
|
|
|
106
113
|
"typecheck": "tsc --noEmit"
|
|
107
114
|
},
|
|
108
115
|
"dependencies": {
|
|
109
|
-
"@contractspec/lib.contracts-spec": "
|
|
110
|
-
"@contractspec/lib.schema": "3.7.
|
|
116
|
+
"@contractspec/lib.contracts-spec": "5.0.0",
|
|
117
|
+
"@contractspec/lib.schema": "3.7.10"
|
|
111
118
|
},
|
|
112
119
|
"devDependencies": {
|
|
113
|
-
"@contractspec/tool.typescript": "3.7.
|
|
120
|
+
"@contractspec/tool.typescript": "3.7.9",
|
|
114
121
|
"typescript": "^5.9.3",
|
|
115
|
-
"@contractspec/tool.bun": "3.7.
|
|
122
|
+
"@contractspec/tool.bun": "3.7.9"
|
|
116
123
|
},
|
|
117
124
|
"publishConfig": {
|
|
118
125
|
"access": "public",
|
|
@@ -180,6 +187,13 @@
|
|
|
180
187
|
"node": "./dist/node/handlers/memory.handlers.js",
|
|
181
188
|
"default": "./dist/handlers/memory.handlers.js"
|
|
182
189
|
},
|
|
190
|
+
"./knowledge-snapshot-publication.migration": {
|
|
191
|
+
"types": "./dist/knowledge-snapshot-publication.migration.d.ts",
|
|
192
|
+
"browser": "./dist/browser/knowledge-snapshot-publication.migration.js",
|
|
193
|
+
"bun": "./dist/knowledge-snapshot-publication.migration.js",
|
|
194
|
+
"node": "./dist/node/knowledge-snapshot-publication.migration.js",
|
|
195
|
+
"default": "./dist/knowledge-snapshot-publication.migration.js"
|
|
196
|
+
},
|
|
183
197
|
"./operations": {
|
|
184
198
|
"types": "./dist/operations/index.d.ts",
|
|
185
199
|
"browser": "./dist/browser/operations/index.js",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
KnowledgeSnapshotPublicationMigration,
|
|
4
|
+
VersionedKnowledgeBaseFeature,
|
|
5
|
+
} from './index';
|
|
6
|
+
|
|
7
|
+
describe('@contractspec/example.versioned-knowledge-base', () => {
|
|
8
|
+
test('exports the canonical migration spec', () => {
|
|
9
|
+
expect(KnowledgeSnapshotPublicationMigration.meta.key).toBe(
|
|
10
|
+
'versioned-knowledge-base.migration.snapshot-publication'
|
|
11
|
+
);
|
|
12
|
+
expect(KnowledgeSnapshotPublicationMigration.plan.up).toHaveLength(2);
|
|
13
|
+
expect(VersionedKnowledgeBaseFeature.meta.key).toBe(
|
|
14
|
+
'versioned-knowledge-base'
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './entities';
|
|
|
7
7
|
export * from './events';
|
|
8
8
|
export { default as example } from './example';
|
|
9
9
|
export * from './handlers';
|
|
10
|
+
export * from './knowledge-snapshot-publication.migration';
|
|
10
11
|
export * from './operations';
|
|
11
12
|
export * from './versioned-knowledge-base.feature';
|
|
12
13
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { MigrationSpec } from '@contractspec/lib.contracts-spec/migrations';
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum,
|
|
6
|
+
} from '@contractspec/lib.contracts-spec/ownership';
|
|
7
|
+
|
|
8
|
+
export const KnowledgeSnapshotPublicationMigration: MigrationSpec = {
|
|
9
|
+
meta: {
|
|
10
|
+
key: 'versioned-knowledge-base.migration.snapshot-publication',
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
title: 'Knowledge Snapshot Publication Migration',
|
|
13
|
+
description:
|
|
14
|
+
'Adds publication audit fields and validation checks for published knowledge snapshots.',
|
|
15
|
+
domain: 'knowledge',
|
|
16
|
+
owners: [OwnersEnum.PlatformContent],
|
|
17
|
+
tags: ['knowledge', 'migration', 'snapshots', TagsEnum.Hygiene],
|
|
18
|
+
stability: StabilityEnum.Experimental,
|
|
19
|
+
},
|
|
20
|
+
dependencies: ['versioned-knowledge-base.migration.bootstrap'],
|
|
21
|
+
plan: {
|
|
22
|
+
up: [
|
|
23
|
+
{
|
|
24
|
+
kind: 'schema',
|
|
25
|
+
description: 'Create the published snapshot audit table.',
|
|
26
|
+
sql: `
|
|
27
|
+
CREATE TABLE kb_snapshot_publications (
|
|
28
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
29
|
+
published_by TEXT NOT NULL,
|
|
30
|
+
published_at TIMESTAMPTZ NOT NULL,
|
|
31
|
+
source_count INTEGER NOT NULL,
|
|
32
|
+
rule_version_count INTEGER NOT NULL
|
|
33
|
+
);`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
kind: 'validation',
|
|
37
|
+
description:
|
|
38
|
+
'Ensure snapshots have at least one approved rule version.',
|
|
39
|
+
assertion:
|
|
40
|
+
'SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
down: [
|
|
44
|
+
{
|
|
45
|
+
kind: 'schema',
|
|
46
|
+
description: 'Remove the snapshot publication audit table.',
|
|
47
|
+
sql: 'DROP TABLE IF EXISTS kb_snapshot_publications;',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
};
|