@dataparade/cli 0.0.26 → 0.0.28

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 (108) hide show
  1. package/README.md +52 -12
  2. package/dist/package.json +7 -7
  3. package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +0 -1
  4. package/dist/src/cli.js +37 -37
  5. package/dist/src/discoveries/contract/ocsf-discovery-record.d.ts +1 -1
  6. package/dist/src/discoveries/load-ocsf-discoveries.d.ts +0 -8
  7. package/dist/src/discoveries/load-ocsf-discoveries.js +0 -31
  8. package/dist/src/discoveries/write-ocsf-discoveries.d.ts +0 -8
  9. package/dist/src/discoveries/write-ocsf-discoveries.js +0 -38
  10. package/dist/src/evals/run-model-matrix.js +0 -1
  11. package/dist/src/export/export-ocsf.d.ts +18 -0
  12. package/dist/src/export/export-ocsf.js +104 -0
  13. package/dist/src/export/register-export-commands.d.ts +2 -0
  14. package/dist/src/export/register-export-commands.js +30 -0
  15. package/dist/src/facts/apply-answers.d.ts +29 -0
  16. package/dist/src/facts/apply-answers.js +202 -0
  17. package/dist/src/facts/build-facts.d.ts +24 -0
  18. package/dist/src/facts/build-facts.js +198 -0
  19. package/dist/src/facts/io.d.ts +17 -0
  20. package/dist/src/facts/io.js +67 -0
  21. package/dist/src/facts/layout.d.ts +29 -0
  22. package/dist/src/facts/layout.js +38 -0
  23. package/dist/src/facts/schema.d.ts +265 -0
  24. package/dist/src/facts/schema.js +122 -0
  25. package/dist/src/facts/slug.d.ts +7 -0
  26. package/dist/src/facts/slug.js +47 -0
  27. package/dist/src/kb/brief.d.ts +1 -2
  28. package/dist/src/kb/brief.js +2 -4
  29. package/dist/src/kb/interview-record.d.ts +18 -0
  30. package/dist/src/kb/interview-record.js +70 -0
  31. package/dist/src/kb/kb-store.d.ts +24 -18
  32. package/dist/src/kb/kb-store.js +89 -28
  33. package/dist/src/kb/land.d.ts +32 -12
  34. package/dist/src/kb/land.js +97 -90
  35. package/dist/src/kb/migrate.d.ts +23 -0
  36. package/dist/src/kb/migrate.js +91 -0
  37. package/dist/src/kb/project-diagram.js +4 -4
  38. package/dist/src/kb/register-kb-commands.js +71 -20
  39. package/dist/src/observability/scan-sentry.js +0 -1
  40. package/dist/src/output/scan-output-excludes.d.ts +1 -1
  41. package/dist/src/output/scan-output-excludes.js +14 -5
  42. package/dist/src/output/write-scan-knowledge.d.ts +33 -0
  43. package/dist/src/output/write-scan-knowledge.js +115 -0
  44. package/dist/src/platform-api/estimate-scan-footprint.d.ts +31 -0
  45. package/dist/src/platform-api/estimate-scan-footprint.js +75 -2
  46. package/dist/src/ui/scan-progress-renderer.d.ts +2 -0
  47. package/dist/src/ui/scan-progress-renderer.js +10 -0
  48. package/dist/src/ui/teaching-lines.js +18 -6
  49. package/dist/src/upload/collect-scan-sidecars.d.ts +2 -27
  50. package/dist/src/upload/collect-scan-sidecars.js +25 -121
  51. package/dist/src/upload/run-upload.js +0 -3
  52. package/dist/tests/cli/cli.spec.js +30 -13
  53. package/dist/tests/helpers/facts-fixture.d.ts +9 -0
  54. package/dist/tests/helpers/facts-fixture.js +72 -0
  55. package/dist/tests/unit/export/export-ocsf.spec.js +72 -0
  56. package/dist/tests/unit/facts/apply-answers.spec.js +128 -0
  57. package/dist/tests/unit/facts/build-facts.spec.d.ts +1 -0
  58. package/dist/tests/unit/facts/build-facts.spec.js +161 -0
  59. package/dist/tests/unit/facts/slug.spec.d.ts +1 -0
  60. package/dist/tests/unit/facts/slug.spec.js +30 -0
  61. package/dist/tests/unit/kb/kb-interview-loop.spec.js +83 -35
  62. package/dist/tests/unit/kb/migrate.spec.d.ts +1 -0
  63. package/dist/tests/unit/kb/migrate.spec.js +108 -0
  64. package/dist/tests/unit/output/graphify-cache-dir.spec.d.ts +1 -0
  65. package/dist/tests/unit/output/graphify-cache-dir.spec.js +20 -0
  66. package/dist/tests/unit/output/scan-output-excludes.spec.js +4 -2
  67. package/dist/tests/unit/platform-api/estimate-scan-footprint.spec.js +77 -0
  68. package/dist/tests/unit/platform-api/upload-client.spec.js +2 -2
  69. package/dist/tests/unit/ui/teaching-lines.spec.js +16 -0
  70. package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +46 -46
  71. package/dist/tests/unit/upload/pack-scan-upload.spec.js +6 -6
  72. package/dist/vendor/scanner/dist/src/classifier/component-factory.js +6 -14
  73. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.d.ts +1 -0
  74. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.js +32 -1
  75. package/dist/vendor/scanner/dist/src/classifier/naming.d.ts +5 -0
  76. package/dist/vendor/scanner/dist/src/classifier/naming.js +8 -4
  77. package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +26 -14
  78. package/dist/vendor/scanner/dist/src/core/pipeline/enrich-personal-data-layers.js +3 -1
  79. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +18 -0
  80. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +125 -66
  81. package/dist/vendor/scanner/dist/src/index.d.ts +2 -0
  82. package/dist/vendor/scanner/dist/src/index.js +7 -2
  83. package/dist/vendor/scanner/dist/src/ingest/file-system.d.ts +5 -0
  84. package/dist/vendor/scanner/dist/src/ingest/file-system.js +5 -0
  85. package/dist/vendor/scanner/dist/src/ingest/gitignore.d.ts +17 -0
  86. package/dist/vendor/scanner/dist/src/ingest/gitignore.js +47 -9
  87. package/dist/vendor/scanner/dist/src/ingest/schema-files.d.ts +10 -2
  88. package/dist/vendor/scanner/dist/src/ingest/schema-files.js +24 -7
  89. package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.d.ts +3 -0
  90. package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.js +45 -0
  91. package/dist/vendor/scanner/dist/src/patterns/scan-exclusions.js +7 -0
  92. package/dist/vendor/scanner/patterns/classifier/third-party.classifier.yaml +8 -0
  93. package/dist/vendor/scanner/patterns/third-party.patterns.yaml +9 -0
  94. package/package.json +7 -7
  95. package/dist/src/discoveries/project-collected-diagram.d.ts +0 -7
  96. package/dist/src/discoveries/project-collected-diagram.js +0 -182
  97. package/dist/src/discoveries/project-ocsf-to-discoveries-document.d.ts +0 -16
  98. package/dist/src/discoveries/project-ocsf-to-discoveries-document.js +0 -269
  99. package/dist/src/discoveries/scan-result-to-discovery-input.d.ts +0 -13
  100. package/dist/src/discoveries/scan-result-to-discovery-input.js +0 -60
  101. package/dist/src/output/write-knowledge-graph.d.ts +0 -20
  102. package/dist/src/output/write-knowledge-graph.js +0 -53
  103. package/dist/src/output/write-scan-discoveries.d.ts +0 -17
  104. package/dist/src/output/write-scan-discoveries.js +0 -61
  105. package/dist/tests/unit/discoveries/project-collected-diagram.spec.js +0 -97
  106. package/dist/tests/unit/discoveries/rescan-replaces-scan-records.spec.js +0 -89
  107. /package/dist/tests/unit/{discoveries/project-collected-diagram.spec.d.ts → export/export-ocsf.spec.d.ts} +0 -0
  108. /package/dist/tests/unit/{discoveries/rescan-replaces-scan-records.spec.d.ts → facts/apply-answers.spec.d.ts} +0 -0
@@ -0,0 +1,29 @@
1
+ /** Default folder a scan writes into, relative to the current directory. */
2
+ export declare const DEFAULT_OUTPUT_DIRNAME = ".dataparade";
3
+ /** Default path of the diagram file (`-o/--output`). */
4
+ export declare const DEFAULT_DATAFLOW_OUTPUT: string;
5
+ export declare const DATAFLOW_BASENAME = "dataflow.json";
6
+ export declare const FACTS_BASENAME = "facts.json";
7
+ export declare const DATA_ITEMS_DIRNAME = "data-items";
8
+ export declare const GRAPHIFY_BASENAME = "graphify.json";
9
+ export declare const ANSWERS_BASENAME = "answers.json";
10
+ /** Every file and folder a scan or `dataparade kb` keeps in the output folder. */
11
+ export interface OutputLayout {
12
+ /** The output folder, i.e. the folder that holds dataflow.json. */
13
+ dir: string;
14
+ dataflowPath: string;
15
+ factsPath: string;
16
+ dataItemsDir: string;
17
+ graphifyPath: string;
18
+ answersPath: string;
19
+ /** Interview briefs (`dataparade kb brief`). */
20
+ briefsDir: string;
21
+ /** Unedited interview transcripts. */
22
+ evidenceDir: string;
23
+ /** Latest diagram projection (`dataparade kb project`). */
24
+ diagramPath: string;
25
+ }
26
+ /** `-o/--output` names dataflow.json; every other file sits next to it. */
27
+ export declare function resolveOutputLayout(dataflowOutputPath: string): OutputLayout;
28
+ /** The layout for an output folder (the folder that holds dataflow.json). */
29
+ export declare function layoutForDir(dir: string, dataflowPath?: string): OutputLayout;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ANSWERS_BASENAME = exports.GRAPHIFY_BASENAME = exports.DATA_ITEMS_DIRNAME = exports.FACTS_BASENAME = exports.DATAFLOW_BASENAME = exports.DEFAULT_DATAFLOW_OUTPUT = exports.DEFAULT_OUTPUT_DIRNAME = void 0;
7
+ exports.resolveOutputLayout = resolveOutputLayout;
8
+ exports.layoutForDir = layoutForDir;
9
+ const path_1 = __importDefault(require("path"));
10
+ /** Default folder a scan writes into, relative to the current directory. */
11
+ exports.DEFAULT_OUTPUT_DIRNAME = ".dataparade";
12
+ /** Default path of the diagram file (`-o/--output`). */
13
+ exports.DEFAULT_DATAFLOW_OUTPUT = path_1.default.join(exports.DEFAULT_OUTPUT_DIRNAME, "dataflow.json");
14
+ exports.DATAFLOW_BASENAME = "dataflow.json";
15
+ exports.FACTS_BASENAME = "facts.json";
16
+ exports.DATA_ITEMS_DIRNAME = "data-items";
17
+ exports.GRAPHIFY_BASENAME = "graphify.json";
18
+ exports.ANSWERS_BASENAME = "answers.json";
19
+ /** `-o/--output` names dataflow.json; every other file sits next to it. */
20
+ function resolveOutputLayout(dataflowOutputPath) {
21
+ const dataflowPath = path_1.default.resolve(dataflowOutputPath);
22
+ return layoutForDir(path_1.default.dirname(dataflowPath), dataflowPath);
23
+ }
24
+ /** The layout for an output folder (the folder that holds dataflow.json). */
25
+ function layoutForDir(dir, dataflowPath) {
26
+ const root = path_1.default.resolve(dir);
27
+ return {
28
+ dir: root,
29
+ dataflowPath: dataflowPath ?? path_1.default.join(root, exports.DATAFLOW_BASENAME),
30
+ factsPath: path_1.default.join(root, exports.FACTS_BASENAME),
31
+ dataItemsDir: path_1.default.join(root, exports.DATA_ITEMS_DIRNAME),
32
+ graphifyPath: path_1.default.join(root, exports.GRAPHIFY_BASENAME),
33
+ answersPath: path_1.default.join(root, exports.ANSWERS_BASENAME),
34
+ briefsDir: path_1.default.join(root, "briefs"),
35
+ evidenceDir: path_1.default.join(root, "evidence"),
36
+ diagramPath: path_1.default.join(root, "diagram.json"),
37
+ };
38
+ }
@@ -0,0 +1,265 @@
1
+ /**
2
+ * The DataParade knowledge base format, schema v1.
3
+ *
4
+ * A scan writes Facts: components, data flows, data items (with their groups and
5
+ * occurrences). People's decisions are Answers, kept apart so a rescan never loses them.
6
+ * See docs/cli/scan-output.md.
7
+ */
8
+ import { z } from "zod";
9
+ export declare const SCHEMA_VERSION: 1;
10
+ export declare const sourceLocationSchema: z.ZodObject<{
11
+ filePath: z.ZodString;
12
+ startLine: z.ZodNumber;
13
+ endLine: z.ZodNumber;
14
+ }, z.core.$strip>;
15
+ /** A link from a Fact to a node of the code-structure graph (graphify.json). */
16
+ export declare const codeRefSchema: z.ZodObject<{
17
+ nodeId: z.ZodString;
18
+ kind: z.ZodOptional<z.ZodString>;
19
+ filePath: z.ZodOptional<z.ZodString>;
20
+ line: z.ZodOptional<z.ZodNumber>;
21
+ }, z.core.$strip>;
22
+ export declare const componentFactSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ name: z.ZodString;
25
+ type: z.ZodString;
26
+ subType: z.ZodString;
27
+ confidence: z.ZodNumber;
28
+ sourceLocations: z.ZodArray<z.ZodObject<{
29
+ filePath: z.ZodString;
30
+ startLine: z.ZodNumber;
31
+ endLine: z.ZodNumber;
32
+ }, z.core.$strip>>;
33
+ codeRefs: z.ZodArray<z.ZodObject<{
34
+ nodeId: z.ZodString;
35
+ kind: z.ZodOptional<z.ZodString>;
36
+ filePath: z.ZodOptional<z.ZodString>;
37
+ line: z.ZodOptional<z.ZodNumber>;
38
+ }, z.core.$strip>>;
39
+ }, z.core.$strip>;
40
+ export declare const dataFlowFactSchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ sourceComponentId: z.ZodString;
43
+ targetComponentId: z.ZodString;
44
+ type: z.ZodString;
45
+ targetScope: z.ZodOptional<z.ZodString>;
46
+ confidence: z.ZodNumber;
47
+ sourceLocations: z.ZodArray<z.ZodObject<{
48
+ filePath: z.ZodString;
49
+ startLine: z.ZodNumber;
50
+ endLine: z.ZodNumber;
51
+ }, z.core.$strip>>;
52
+ codeRefs: z.ZodArray<z.ZodObject<{
53
+ nodeId: z.ZodString;
54
+ kind: z.ZodOptional<z.ZodString>;
55
+ filePath: z.ZodOptional<z.ZodString>;
56
+ line: z.ZodOptional<z.ZodNumber>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export declare const dataItemGroupSchema: z.ZodObject<{
60
+ id: z.ZodString;
61
+ label: z.ZodString;
62
+ basis: z.ZodOptional<z.ZodString>;
63
+ occurrenceCount: z.ZodNumber;
64
+ handledBy: z.ZodArray<z.ZodString>;
65
+ }, z.core.$strip>;
66
+ export declare const dataItemSummarySchema: z.ZodObject<{
67
+ id: z.ZodString;
68
+ name: z.ZodString;
69
+ labels: z.ZodArray<z.ZodString>;
70
+ occurrenceCount: z.ZodNumber;
71
+ file: z.ZodString;
72
+ groups: z.ZodArray<z.ZodObject<{
73
+ id: z.ZodString;
74
+ label: z.ZodString;
75
+ basis: z.ZodOptional<z.ZodString>;
76
+ occurrenceCount: z.ZodNumber;
77
+ handledBy: z.ZodArray<z.ZodString>;
78
+ }, z.core.$strip>>;
79
+ }, z.core.$strip>;
80
+ export declare const relationSchema: z.ZodObject<{
81
+ type: z.ZodString;
82
+ source: z.ZodString;
83
+ target: z.ZodString;
84
+ confidence: z.ZodOptional<z.ZodString>;
85
+ basis: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
+ }, z.core.$strip>;
87
+ export declare const factsFileSchema: z.ZodObject<{
88
+ schemaVersion: z.ZodLiteral<1>;
89
+ scan: z.ZodObject<{
90
+ projectName: z.ZodString;
91
+ scannedAt: z.ZodString;
92
+ cliVersion: z.ZodString;
93
+ scannerVersion: z.ZodString;
94
+ }, z.core.$strip>;
95
+ components: z.ZodArray<z.ZodObject<{
96
+ id: z.ZodString;
97
+ name: z.ZodString;
98
+ type: z.ZodString;
99
+ subType: z.ZodString;
100
+ confidence: z.ZodNumber;
101
+ sourceLocations: z.ZodArray<z.ZodObject<{
102
+ filePath: z.ZodString;
103
+ startLine: z.ZodNumber;
104
+ endLine: z.ZodNumber;
105
+ }, z.core.$strip>>;
106
+ codeRefs: z.ZodArray<z.ZodObject<{
107
+ nodeId: z.ZodString;
108
+ kind: z.ZodOptional<z.ZodString>;
109
+ filePath: z.ZodOptional<z.ZodString>;
110
+ line: z.ZodOptional<z.ZodNumber>;
111
+ }, z.core.$strip>>;
112
+ }, z.core.$strip>>;
113
+ dataFlows: z.ZodArray<z.ZodObject<{
114
+ id: z.ZodString;
115
+ sourceComponentId: z.ZodString;
116
+ targetComponentId: z.ZodString;
117
+ type: z.ZodString;
118
+ targetScope: z.ZodOptional<z.ZodString>;
119
+ confidence: z.ZodNumber;
120
+ sourceLocations: z.ZodArray<z.ZodObject<{
121
+ filePath: z.ZodString;
122
+ startLine: z.ZodNumber;
123
+ endLine: z.ZodNumber;
124
+ }, z.core.$strip>>;
125
+ codeRefs: z.ZodArray<z.ZodObject<{
126
+ nodeId: z.ZodString;
127
+ kind: z.ZodOptional<z.ZodString>;
128
+ filePath: z.ZodOptional<z.ZodString>;
129
+ line: z.ZodOptional<z.ZodNumber>;
130
+ }, z.core.$strip>>;
131
+ }, z.core.$strip>>;
132
+ dataItems: z.ZodArray<z.ZodObject<{
133
+ id: z.ZodString;
134
+ name: z.ZodString;
135
+ labels: z.ZodArray<z.ZodString>;
136
+ occurrenceCount: z.ZodNumber;
137
+ file: z.ZodString;
138
+ groups: z.ZodArray<z.ZodObject<{
139
+ id: z.ZodString;
140
+ label: z.ZodString;
141
+ basis: z.ZodOptional<z.ZodString>;
142
+ occurrenceCount: z.ZodNumber;
143
+ handledBy: z.ZodArray<z.ZodString>;
144
+ }, z.core.$strip>>;
145
+ }, z.core.$strip>>;
146
+ relations: z.ZodArray<z.ZodObject<{
147
+ type: z.ZodString;
148
+ source: z.ZodString;
149
+ target: z.ZodString;
150
+ confidence: z.ZodOptional<z.ZodString>;
151
+ basis: z.ZodOptional<z.ZodNullable<z.ZodString>>;
152
+ }, z.core.$strip>>;
153
+ }, z.core.$strip>;
154
+ export declare const occurrenceFactSchema: z.ZodObject<{
155
+ id: z.ZodString;
156
+ groupId: z.ZodNullable<z.ZodString>;
157
+ filePath: z.ZodString;
158
+ startLine: z.ZodNumber;
159
+ endLine: z.ZodNumber;
160
+ code: z.ZodOptional<z.ZodString>;
161
+ labels: z.ZodArray<z.ZodString>;
162
+ location: z.ZodOptional<z.ZodEnum<{
163
+ code: "code";
164
+ comment: "comment";
165
+ }>>;
166
+ codeRefs: z.ZodArray<z.ZodObject<{
167
+ nodeId: z.ZodString;
168
+ kind: z.ZodOptional<z.ZodString>;
169
+ filePath: z.ZodOptional<z.ZodString>;
170
+ line: z.ZodOptional<z.ZodNumber>;
171
+ }, z.core.$strip>>;
172
+ declaredBy: z.ZodOptional<z.ZodObject<{
173
+ id: z.ZodString;
174
+ kind: z.ZodOptional<z.ZodString>;
175
+ }, z.core.$strip>>;
176
+ }, z.core.$strip>;
177
+ export declare const dataItemFileSchema: z.ZodObject<{
178
+ schemaVersion: z.ZodLiteral<1>;
179
+ id: z.ZodString;
180
+ name: z.ZodString;
181
+ labels: z.ZodArray<z.ZodString>;
182
+ groups: z.ZodArray<z.ZodObject<{
183
+ id: z.ZodString;
184
+ label: z.ZodString;
185
+ basis: z.ZodOptional<z.ZodString>;
186
+ occurrenceCount: z.ZodNumber;
187
+ handledBy: z.ZodArray<z.ZodString>;
188
+ }, z.core.$strip>>;
189
+ occurrences: z.ZodArray<z.ZodObject<{
190
+ id: z.ZodString;
191
+ groupId: z.ZodNullable<z.ZodString>;
192
+ filePath: z.ZodString;
193
+ startLine: z.ZodNumber;
194
+ endLine: z.ZodNumber;
195
+ code: z.ZodOptional<z.ZodString>;
196
+ labels: z.ZodArray<z.ZodString>;
197
+ location: z.ZodOptional<z.ZodEnum<{
198
+ code: "code";
199
+ comment: "comment";
200
+ }>>;
201
+ codeRefs: z.ZodArray<z.ZodObject<{
202
+ nodeId: z.ZodString;
203
+ kind: z.ZodOptional<z.ZodString>;
204
+ filePath: z.ZodOptional<z.ZodString>;
205
+ line: z.ZodOptional<z.ZodNumber>;
206
+ }, z.core.$strip>>;
207
+ declaredBy: z.ZodOptional<z.ZodObject<{
208
+ id: z.ZodString;
209
+ kind: z.ZodOptional<z.ZodString>;
210
+ }, z.core.$strip>>;
211
+ }, z.core.$strip>>;
212
+ }, z.core.$strip>;
213
+ export declare const answerSchema: z.ZodObject<{
214
+ id: z.ZodString;
215
+ factId: z.ZodString;
216
+ action: z.ZodEnum<{
217
+ set: "set";
218
+ remove: "remove";
219
+ }>;
220
+ property: z.ZodOptional<z.ZodString>;
221
+ value: z.ZodOptional<z.ZodUnknown>;
222
+ by: z.ZodString;
223
+ at: z.ZodString;
224
+ source: z.ZodEnum<{
225
+ interview: "interview";
226
+ review: "review";
227
+ }>;
228
+ evidence: z.ZodOptional<z.ZodString>;
229
+ briefSha: z.ZodOptional<z.ZodString>;
230
+ skillSha: z.ZodOptional<z.ZodString>;
231
+ }, z.core.$strip>;
232
+ export declare const answersFileSchema: z.ZodObject<{
233
+ schemaVersion: z.ZodLiteral<1>;
234
+ answers: z.ZodArray<z.ZodObject<{
235
+ id: z.ZodString;
236
+ factId: z.ZodString;
237
+ action: z.ZodEnum<{
238
+ set: "set";
239
+ remove: "remove";
240
+ }>;
241
+ property: z.ZodOptional<z.ZodString>;
242
+ value: z.ZodOptional<z.ZodUnknown>;
243
+ by: z.ZodString;
244
+ at: z.ZodString;
245
+ source: z.ZodEnum<{
246
+ interview: "interview";
247
+ review: "review";
248
+ }>;
249
+ evidence: z.ZodOptional<z.ZodString>;
250
+ briefSha: z.ZodOptional<z.ZodString>;
251
+ skillSha: z.ZodOptional<z.ZodString>;
252
+ }, z.core.$strip>>;
253
+ }, z.core.$strip>;
254
+ export type SourceLocation = z.infer<typeof sourceLocationSchema>;
255
+ export type CodeRef = z.infer<typeof codeRefSchema>;
256
+ export type ComponentFact = z.infer<typeof componentFactSchema>;
257
+ export type DataFlowFact = z.infer<typeof dataFlowFactSchema>;
258
+ export type DataItemGroup = z.infer<typeof dataItemGroupSchema>;
259
+ export type DataItemSummary = z.infer<typeof dataItemSummarySchema>;
260
+ export type Relation = z.infer<typeof relationSchema>;
261
+ export type FactsFile = z.infer<typeof factsFileSchema>;
262
+ export type OccurrenceFact = z.infer<typeof occurrenceFactSchema>;
263
+ export type DataItemFile = z.infer<typeof dataItemFileSchema>;
264
+ export type Answer = z.infer<typeof answerSchema>;
265
+ export type AnswersFile = z.infer<typeof answersFileSchema>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.answersFileSchema = exports.answerSchema = exports.dataItemFileSchema = exports.occurrenceFactSchema = exports.factsFileSchema = exports.relationSchema = exports.dataItemSummarySchema = exports.dataItemGroupSchema = exports.dataFlowFactSchema = exports.componentFactSchema = exports.codeRefSchema = exports.sourceLocationSchema = exports.SCHEMA_VERSION = void 0;
4
+ /**
5
+ * The DataParade knowledge base format, schema v1.
6
+ *
7
+ * A scan writes Facts: components, data flows, data items (with their groups and
8
+ * occurrences). People's decisions are Answers, kept apart so a rescan never loses them.
9
+ * See docs/cli/scan-output.md.
10
+ */
11
+ const zod_1 = require("zod");
12
+ exports.SCHEMA_VERSION = 1;
13
+ exports.sourceLocationSchema = zod_1.z.object({
14
+ filePath: zod_1.z.string(),
15
+ startLine: zod_1.z.number(),
16
+ endLine: zod_1.z.number(),
17
+ });
18
+ /** A link from a Fact to a node of the code-structure graph (graphify.json). */
19
+ exports.codeRefSchema = zod_1.z.object({
20
+ nodeId: zod_1.z.string(),
21
+ kind: zod_1.z.string().optional(),
22
+ filePath: zod_1.z.string().optional(),
23
+ line: zod_1.z.number().optional(),
24
+ });
25
+ exports.componentFactSchema = zod_1.z.object({
26
+ id: zod_1.z.string(),
27
+ name: zod_1.z.string(),
28
+ type: zod_1.z.string(),
29
+ subType: zod_1.z.string(),
30
+ confidence: zod_1.z.number(),
31
+ sourceLocations: zod_1.z.array(exports.sourceLocationSchema),
32
+ codeRefs: zod_1.z.array(exports.codeRefSchema),
33
+ });
34
+ exports.dataFlowFactSchema = zod_1.z.object({
35
+ id: zod_1.z.string(),
36
+ sourceComponentId: zod_1.z.string(),
37
+ targetComponentId: zod_1.z.string(),
38
+ type: zod_1.z.string(),
39
+ targetScope: zod_1.z.string().optional(),
40
+ confidence: zod_1.z.number(),
41
+ sourceLocations: zod_1.z.array(exports.sourceLocationSchema),
42
+ codeRefs: zod_1.z.array(exports.codeRefSchema),
43
+ });
44
+ exports.dataItemGroupSchema = zod_1.z.object({
45
+ id: zod_1.z.string(),
46
+ label: zod_1.z.string(),
47
+ /** The evidence that named the group (column, record-key, name, ...). */
48
+ basis: zod_1.z.string().optional(),
49
+ occurrenceCount: zod_1.z.number(),
50
+ handledBy: zod_1.z.array(zod_1.z.string()),
51
+ });
52
+ exports.dataItemSummarySchema = zod_1.z.object({
53
+ id: zod_1.z.string(),
54
+ name: zod_1.z.string(),
55
+ labels: zod_1.z.array(zod_1.z.string()),
56
+ occurrenceCount: zod_1.z.number(),
57
+ /** Path of this item's file, relative to the output folder: `data-items/<slug>.json`. */
58
+ file: zod_1.z.string(),
59
+ groups: zod_1.z.array(exports.dataItemGroupSchema),
60
+ });
61
+ exports.relationSchema = zod_1.z.object({
62
+ type: zod_1.z.string(),
63
+ source: zod_1.z.string(),
64
+ target: zod_1.z.string(),
65
+ confidence: zod_1.z.string().optional(),
66
+ basis: zod_1.z.string().nullable().optional(),
67
+ });
68
+ exports.factsFileSchema = zod_1.z.object({
69
+ schemaVersion: zod_1.z.literal(exports.SCHEMA_VERSION),
70
+ scan: zod_1.z.object({
71
+ projectName: zod_1.z.string(),
72
+ scannedAt: zod_1.z.string(),
73
+ cliVersion: zod_1.z.string(),
74
+ scannerVersion: zod_1.z.string(),
75
+ }),
76
+ components: zod_1.z.array(exports.componentFactSchema),
77
+ dataFlows: zod_1.z.array(exports.dataFlowFactSchema),
78
+ dataItems: zod_1.z.array(exports.dataItemSummarySchema),
79
+ relations: zod_1.z.array(exports.relationSchema),
80
+ });
81
+ exports.occurrenceFactSchema = zod_1.z.object({
82
+ id: zod_1.z.string(),
83
+ /** The group this occurrence belongs to, or null when the scanner could not tell. */
84
+ groupId: zod_1.z.string().nullable(),
85
+ filePath: zod_1.z.string(),
86
+ startLine: zod_1.z.number(),
87
+ endLine: zod_1.z.number(),
88
+ code: zod_1.z.string().optional(),
89
+ labels: zod_1.z.array(zod_1.z.string()),
90
+ /** `comment` when the match sits only in a comment or docstring. */
91
+ location: zod_1.z.enum(["code", "comment"]).optional(),
92
+ codeRefs: zod_1.z.array(exports.codeRefSchema),
93
+ /** The same-file occurrence that declares the name this one uses. */
94
+ declaredBy: zod_1.z.object({ id: zod_1.z.string(), kind: zod_1.z.string().optional() }).optional(),
95
+ });
96
+ exports.dataItemFileSchema = zod_1.z.object({
97
+ schemaVersion: zod_1.z.literal(exports.SCHEMA_VERSION),
98
+ id: zod_1.z.string(),
99
+ name: zod_1.z.string(),
100
+ labels: zod_1.z.array(zod_1.z.string()),
101
+ groups: zod_1.z.array(exports.dataItemGroupSchema),
102
+ occurrences: zod_1.z.array(exports.occurrenceFactSchema),
103
+ });
104
+ exports.answerSchema = zod_1.z.object({
105
+ id: zod_1.z.string(),
106
+ factId: zod_1.z.string(),
107
+ action: zod_1.z.enum(["set", "remove"]),
108
+ property: zod_1.z.string().optional(),
109
+ value: zod_1.z.unknown().optional(),
110
+ by: zod_1.z.string(),
111
+ at: zod_1.z.string(),
112
+ source: zod_1.z.enum(["interview", "review"]),
113
+ /** Where the decision came from: an interview transcript path, or a note. */
114
+ evidence: zod_1.z.string().optional(),
115
+ /** Interview answers: the KB snapshot the question was asked from, and the interview skill. */
116
+ briefSha: zod_1.z.string().optional(),
117
+ skillSha: zod_1.z.string().optional(),
118
+ });
119
+ exports.answersFileSchema = zod_1.z.object({
120
+ schemaVersion: zod_1.z.literal(exports.SCHEMA_VERSION),
121
+ answers: zod_1.z.array(exports.answerSchema),
122
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * File-safe, stable slugs for data item names. A name keeps its plain slug unless
3
+ * another name shares it; then every name in the clash gets a short hash of its own
4
+ * name, so the result does not depend on the order of the list.
5
+ */
6
+ export declare function dataItemSlugs(names: string[]): Map<string, string>;
7
+ export declare function dataItemFilePath(slug: string): string;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataItemSlugs = dataItemSlugs;
4
+ exports.dataItemFilePath = dataItemFilePath;
5
+ const crypto_1 = require("crypto");
6
+ /** Longest slug before the `.json` suffix; far below filesystem limits. */
7
+ const MAX_SLUG = 80;
8
+ function baseSlug(name) {
9
+ const slug = name
10
+ .normalize("NFKD")
11
+ .replace(/\p{M}/gu, "")
12
+ .toLowerCase()
13
+ .replace(/[^a-z0-9._-]+/g, "-")
14
+ .replace(/^[-.]+|[-.]+$/g, "")
15
+ .replace(/-{2,}/g, "-")
16
+ .slice(0, MAX_SLUG)
17
+ .replace(/[-.]+$/g, "");
18
+ return slug || "item";
19
+ }
20
+ function shortHash(name) {
21
+ return (0, crypto_1.createHash)("sha256").update(name).digest("hex").slice(0, 6);
22
+ }
23
+ /**
24
+ * File-safe, stable slugs for data item names. A name keeps its plain slug unless
25
+ * another name shares it; then every name in the clash gets a short hash of its own
26
+ * name, so the result does not depend on the order of the list.
27
+ */
28
+ function dataItemSlugs(names) {
29
+ const byBase = new Map();
30
+ for (const name of names) {
31
+ const base = baseSlug(name);
32
+ const list = byBase.get(base) ?? [];
33
+ if (!list.includes(name))
34
+ list.push(name);
35
+ byBase.set(base, list);
36
+ }
37
+ const slugs = new Map();
38
+ for (const [base, list] of byBase) {
39
+ for (const name of list) {
40
+ slugs.set(name, list.length === 1 ? base : `${base}-${shortHash(name)}`);
41
+ }
42
+ }
43
+ return slugs;
44
+ }
45
+ function dataItemFilePath(slug) {
46
+ return `data-items/${slug}.json`;
47
+ }
@@ -3,7 +3,7 @@ import { type KbPaths } from "./kb-store";
3
3
  import { type EligibleShape, type InterviewSlot } from "./slot-shapes";
4
4
  /**
5
5
  * A KB brief is a snapshot of what the knowledge base knows and what an
6
- * interview may ask, generated from the Discovery records. It replaces the
6
+ * interview may ask, generated from facts.json, the data item files and answers.json. It replaces the
7
7
  * hand-pinned dogfood brief for live sessions: its content SHA is the
8
8
  * `brief_sha` every answer cites, and the file stays in `<kb>/briefs/` so that
9
9
  * provenance resolves to the exact state the question was asked from.
@@ -36,7 +36,6 @@ export interface KbBrief {
36
36
  kind: "dataparade_kb_brief";
37
37
  version: 1;
38
38
  ontology_version: string;
39
- scan_paths: string[];
40
39
  system: {
41
40
  asserts: string;
42
41
  in_scope: string | null;
@@ -11,7 +11,6 @@ const crypto_1 = require("crypto");
11
11
  const fs_1 = __importDefault(require("fs"));
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const ontology_pins_1 = require("../discoveries/contract/ontology-pins");
14
- const scan_entity_uri_1 = require("../discoveries/scan-entity-uri");
15
14
  const kb_store_1 = require("./kb-store");
16
15
  const slot_shapes_1 = require("./slot-shapes");
17
16
  const RAW_ID_SEPARATOR = "::";
@@ -19,8 +18,9 @@ function rawEntityId(projectedId) {
19
18
  const at = projectedId.lastIndexOf(RAW_ID_SEPARATOR);
20
19
  return at === -1 ? projectedId : projectedId.slice(at + RAW_ID_SEPARATOR.length);
21
20
  }
21
+ /** What a question is about: the Fact's id (or `dp:a0/system`). */
22
22
  function entityAsserts(entity) {
23
- return (0, scan_entity_uri_1.scanEntityAsserts)(entity.scanPath || undefined, rawEntityId(entity.id));
23
+ return rawEntityId(entity.id);
24
24
  }
25
25
  function buildKbBrief(document) {
26
26
  const components = new Map(document.components.map((c) => [c.id, c]));
@@ -75,12 +75,10 @@ function buildKbBrief(document) {
75
75
  ]);
76
76
  questions.push(...flowQuestions("outbound_third_party"));
77
77
  questions.push(...actors.map((a) => question(a.asserts, "actor_kind", Boolean(a.actor_kind), `Is "${a.name}" a specific person, a role, or a persona?`)));
78
- const scanPaths = Array.from(new Set(document.components.map((c) => c.scanPath).filter((p) => Boolean(p)))).sort();
79
78
  return {
80
79
  kind: "dataparade_kb_brief",
81
80
  version: 1,
82
81
  ontology_version: ontology_pins_1.PINNED_ONTOLOGY_VERSION,
83
- scan_paths: scanPaths,
84
82
  system: { asserts: slot_shapes_1.SYSTEM_ASSERTS_URI, in_scope: inScope },
85
83
  actors,
86
84
  external_systems: externalSystems,
@@ -0,0 +1,18 @@
1
+ import type { OcsfDiscoveryRecord } from "../discoveries/contract/ocsf-discovery-record";
2
+ import type { Answer } from "../facts/schema";
3
+ import { type InterviewSlot } from "./slot-shapes";
4
+ /** The OCSF `asserts` URI for a Fact id (the system keeps its own URI). */
5
+ export declare function factAssertsUri(factId: string): string;
6
+ /** The slot value as OCSF stores it: text, with a category list as JSON. */
7
+ export declare function slotValueText(value: unknown): string;
8
+ export interface InterviewRecordInput {
9
+ uid: string;
10
+ answer: Answer;
11
+ slot: InterviewSlot;
12
+ briefSha: string;
13
+ skillSha: string;
14
+ supersedes?: string;
15
+ }
16
+ /** One OCSF Architecture Discovery (`source=interview`) for an interview answer. */
17
+ export declare function buildInterviewOcsfRecord(input: InterviewRecordInput): OcsfDiscoveryRecord;
18
+ export declare function interviewRecordUid(answerId: string): string;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.factAssertsUri = factAssertsUri;
4
+ exports.slotValueText = slotValueText;
5
+ exports.buildInterviewOcsfRecord = buildInterviewOcsfRecord;
6
+ exports.interviewRecordUid = interviewRecordUid;
7
+ const ocsf_pins_1 = require("../discoveries/contract/ocsf-pins");
8
+ const ontology_pins_1 = require("../discoveries/contract/ontology-pins");
9
+ const scan_entity_uri_1 = require("../discoveries/scan-entity-uri");
10
+ const write_ocsf_discoveries_1 = require("../discoveries/write-ocsf-discoveries");
11
+ const slot_shapes_1 = require("./slot-shapes");
12
+ /** The OCSF `asserts` URI for a Fact id (the system keeps its own URI). */
13
+ function factAssertsUri(factId) {
14
+ return factId.startsWith("dp:") ? factId : (0, scan_entity_uri_1.scanEntityAsserts)(undefined, factId);
15
+ }
16
+ /** The slot value as OCSF stores it: text, with a category list as JSON. */
17
+ function slotValueText(value) {
18
+ return typeof value === "string" ? value : JSON.stringify(value);
19
+ }
20
+ /** One OCSF Architecture Discovery (`source=interview`) for an interview answer. */
21
+ function buildInterviewOcsfRecord(input) {
22
+ const { answer, slot } = input;
23
+ const asserts = factAssertsUri(answer.factId);
24
+ const time = Date.parse(answer.at);
25
+ const at = new Date(time).toISOString();
26
+ return {
27
+ class_name: "Architecture Discovery",
28
+ class_uid: ocsf_pins_1.OCSF_ARCHITECTURE_DISCOVERY_CLASS_UID,
29
+ category_name: "Architecture",
30
+ category_uid: ocsf_pins_1.OCSF_ARCHITECTURE_CATEGORY_UID,
31
+ activity_id: 1,
32
+ activity_name: "Create",
33
+ type_uid: ocsf_pins_1.OCSF_ARCHITECTURE_DISCOVERY_TYPE_UID,
34
+ time: Math.floor(time / 1000),
35
+ metadata: {
36
+ version: ocsf_pins_1.PINNED_OCSF_BASE_VERSION,
37
+ uid: input.uid,
38
+ extension: { name: ocsf_pins_1.PINNED_OCSF_EXTENSION_NAME, version: ocsf_pins_1.PINNED_OCSF_EXTENSION_VERSION },
39
+ product: { name: "dataparade-cli", vendor_name: "DataParade" },
40
+ profiles: ["architecture_privacy"],
41
+ },
42
+ resources: [
43
+ {
44
+ uid: asserts,
45
+ name: answer.factId,
46
+ type: asserts === slot_shapes_1.SYSTEM_ASSERTS_URI ? "system" : "entity",
47
+ },
48
+ ],
49
+ dataparade: {
50
+ record_kind: "discovery",
51
+ ontology_version: ontology_pins_1.PINNED_ONTOLOGY_VERSION,
52
+ source: "interview",
53
+ asserted_at: at,
54
+ asserts,
55
+ asserted_slot: slot,
56
+ asserted_value: slotValueText(answer.value),
57
+ eligible_shape: slot_shapes_1.SHAPE_FOR_SLOT[slot].shape,
58
+ raw_evidence_ref: answer.evidence ?? "evidence/unknown",
59
+ reviewer: answer.by,
60
+ reviewed_at: at,
61
+ brief_sha: input.briefSha,
62
+ skill_sha: input.skillSha,
63
+ ...(input.supersedes ? { supersedes: input.supersedes } : {}),
64
+ ...(asserts !== slot_shapes_1.SYSTEM_ASSERTS_URI ? { related_resource_refs: [answer.factId] } : {}),
65
+ },
66
+ };
67
+ }
68
+ function interviewRecordUid(answerId) {
69
+ return `dp:discovery/interview/${(0, write_ocsf_discoveries_1.slugifyDiscoveryId)(answerId)}`;
70
+ }