@mitre/hdf-openapi 0.0.0-stage → 0.0.1-reserve.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.
@@ -0,0 +1,236 @@
1
+ //#region src/components.d.ts
2
+ interface JsonSchema {
3
+ [key: string]: unknown;
4
+ }
5
+ interface ComponentsDocument {
6
+ openapi: string;
7
+ info: {
8
+ title: string;
9
+ version: string;
10
+ description: string;
11
+ license: {
12
+ name: string;
13
+ identifier: string;
14
+ };
15
+ contact: {
16
+ name: string;
17
+ url: string;
18
+ };
19
+ };
20
+ jsonSchemaDialect: string;
21
+ components: {
22
+ schemas: Record<string, JsonSchema>;
23
+ };
24
+ }
25
+ /** The bundler's own list (hdf-schema/src/bundle-schemas.ts), in its order. */
26
+ export declare const MAIN_SCHEMAS: readonly ["hdf-results.schema.json", "hdf-baseline.schema.json", "hdf-comparison.schema.json", "hdf-system.schema.json", "hdf-plan.schema.json", "hdf-amendments.schema.json", "hdf-evidence-package.schema.json", "hdf-requirement-change-event.schema.json"];
27
+ export declare const ROOT_COMPONENT_NAMES: Record<string, string>;
28
+ /** Named definitions across the bundles, excluding the eight roots. */
29
+ export declare const EXPECTED_DEFINITIONS = 115;
30
+ interface BuildOptions {
31
+ /** Tracked expectation for the named-definition count; a mismatch fails. */
32
+ expectedDefinitions?: number;
33
+ }
34
+ export declare function buildComponentsDocument(bundles: Map<string, JsonSchema>, options?: BuildOptions): ComponentsDocument;
35
+ //#endregion
36
+ //#region src/embed.d.ts
37
+ /**
38
+ * The tracked embed, not `hdf-schema/dist/` — dist is gitignored, so a glob of it
39
+ * silently yields whatever the last local build left behind. The embed is the
40
+ * copy `build:schemas` writes and CI reviews.
41
+ */
42
+ export declare const EMBED_DIR: string;
43
+ /**
44
+ * Reads the eight bundles. The file set must equal MAIN_SCHEMAS exactly: a bundle
45
+ * that appeared or vanished changes which document types the contract covers, and
46
+ * that is a reviewed change, never an inferred one.
47
+ */
48
+ export declare function loadBundles(embedDir: string): Map<string, JsonSchema>;
49
+ //#endregion
50
+ //#region src/extract.d.ts
51
+ /**
52
+ * Lifts one component out of the components document as a schema that validates on its
53
+ * own — the inverse of the components transform, and the only way to check that the
54
+ * transform preserved meaning rather than merely producing well-formed output.
55
+ *
56
+ * The closure is walked transitively rather than copying every component, so what comes
57
+ * back is the subgraph the named component actually depends on. A component that dragged
58
+ * in the whole document would make the test pass for the wrong reason.
59
+ *
60
+ * Validate the result with a 2020-12 engine. This repository's own validators are
61
+ * draft-07 and ignore `unevaluatedProperties` (ADR-0009 §5), so they would accept
62
+ * documents the schema text rejects.
63
+ */
64
+ export declare function extractStandaloneSchema(doc: ComponentsDocument, name: string): JsonSchema;
65
+ //#endregion
66
+ //#region src/bindings.d.ts
67
+ /**
68
+ * Every key the table may use. ADR-0008 §2 defines the grammar; anything outside this set
69
+ * is a fault, which is what stops the table growing an API by accretion.
70
+ *
71
+ * `class` is deliberately absent for real tools — it derives from the tool's
72
+ * `readOnlyHint` — and legal only inside `synthetic`, where no hint exists.
73
+ */
74
+ export declare const CLOSED_KEYS: Set<string>;
75
+ /**
76
+ * Input names that are filesystem-shaped whatever their schema says: the service owns
77
+ * where bytes live, so none may reach HTTP. ADR-0008 §2 requires a hard-fail on each
78
+ * unless the table drops it with a reason.
79
+ */
80
+ export declare const FILESYSTEM_FIELDS: Set<string>;
81
+ /**
82
+ * `sources` is deliberately NOT gated, and that is a correction to ADR-0008 §2.
83
+ *
84
+ * Its hard-fail list names `sources`, but every `source`/`sources` input on every tool has
85
+ * the same properties — `{handle, path}` — so the name carries no filesystem meaning of its
86
+ * own. Only the descriptions differ (hdf_convert calls it a batch of tool-output files; the
87
+ * others call it a set of documents), and prose is not a contract. The filesystem half is
88
+ * `path`, which the fixed `handle` -> `id` rewrite drops by taking the id instead.
89
+ *
90
+ * The ADR's own Context list of filesystem-shaped inputs omits `sources`, which is the
91
+ * clue that the hard-fail list over-reached. Gating it by name would drop cross-document
92
+ * query, compliance and aggregate for a rule that is really about the traversal inputs
93
+ * above — directory, pattern, failFast and outputDir — which stay gated.
94
+ */
95
+ interface ToolBinding {
96
+ method?: string;
97
+ path?: string;
98
+ fields?: Record<string, {
99
+ placement?: string;
100
+ enumFrom?: string;
101
+ }>;
102
+ drop?: {
103
+ name: string;
104
+ reason: string;
105
+ }[];
106
+ bodyRef?: string;
107
+ /** A fullShapes key whose shape becomes the envelope's `summary` member. */
108
+ summaryRef?: string;
109
+ items?: string;
110
+ fullResponse?: string | string[];
111
+ class?: string;
112
+ }
113
+ interface BindingTable {
114
+ tools?: Record<string, ToolBinding>;
115
+ resources?: Record<string, {
116
+ method?: string;
117
+ path?: string;
118
+ }>;
119
+ synthetic?: Record<string, ToolBinding & {
120
+ scopes?: string[];
121
+ }>;
122
+ absent?: {
123
+ tool?: string;
124
+ resource?: string;
125
+ field?: string;
126
+ reason: string;
127
+ }[];
128
+ }
129
+ export declare function loadBindings(yamlText: string): BindingTable;
130
+ interface Surface {
131
+ toolsList: {
132
+ tools: {
133
+ name: string;
134
+ inputSchema?: {
135
+ properties?: Record<string, unknown>;
136
+ };
137
+ }[];
138
+ };
139
+ contract: Record<string, unknown>;
140
+ /** Conventions component names, the one hand-authored shape input §2 admits. */
141
+ conventions?: string[];
142
+ }
143
+ /**
144
+ * Resource and template names from the contract. Both live one level down — the golden
145
+ * wraps each list with its cache policy (`ttlMs`, `cacheScope`) — so the nesting is read
146
+ * here rather than assumed by every caller.
147
+ */
148
+ export declare function resourceNames(contract: Record<string, unknown>): string[];
149
+ /**
150
+ * Every way the table fails to map the live surface, as one flat list so a caller can
151
+ * report all of them rather than the first. Each fault is prefixed with the tool it
152
+ * belongs to, so a per-tool test can filter.
153
+ */
154
+ export declare function bindingFaults(table: BindingTable, surface: Surface): string[];
155
+ //#endregion
156
+ //#region src/generate-api.d.ts
157
+ /**
158
+ * ADR-0010 §6, consumed as written: the codes it gives an HTTP status, with the status and
159
+ * the kebab-cased problem type. The `type` is the hosted prefix plus the kebab code, which
160
+ * §6 states rather than leaves to the reader.
161
+ */
162
+ export declare const PROBLEM_TYPES: Record<string, {
163
+ status: number;
164
+ type: string;
165
+ }>;
166
+ /**
167
+ * The codes ADR-0010 §6 marks `never`. Recorded rather than silently dropped: each is a
168
+ * `file`-adapter concern with no HTTP surface, and TRUNCATED is dead in the MCP too.
169
+ */
170
+ export declare const UNMAPPED_CODES: string[];
171
+ /** Schemas exempt from the additionalProperties:false rule, each with its reason. */
172
+ export declare const STRICTNESS_EXEMPT: Record<string, string>;
173
+ /** ADR-0008 §4's format allowlist. A format outside it hard-fails rather than shipping. */
174
+ export declare const ALLOWED_FORMATS: Set<string>;
175
+ /**
176
+ * ADR-0008 §2's fixed rewrite map, output half. These are MCP transport state — a
177
+ * filesystem path, a write gate, a page index, a handle — and none may reach HTTP. Stripped
178
+ * from every response shape rather than waived per operation.
179
+ */
180
+ export declare const STRIPPED_OUTPUT_FIELDS: Set<string>;
181
+ /**
182
+ * Nested leaves that are open on purpose, each with the reason. Everything else that is
183
+ * not a document schema must set additionalProperties: false.
184
+ */
185
+ export declare const OPEN_LEAF_EXEMPT: Record<string, string>;
186
+ interface Operation {
187
+ operationId: string;
188
+ summary?: string;
189
+ parameters?: unknown[];
190
+ requestBody?: unknown;
191
+ responses: Record<string, unknown>;
192
+ security?: Record<string, string[]>[];
193
+ }
194
+ interface ApiDocument {
195
+ openapi: string;
196
+ info: Record<string, string>;
197
+ paths: Record<string, Record<string, Operation>>;
198
+ components: Record<string, unknown>;
199
+ }
200
+ interface GenerateOptions {
201
+ /** Replace the tracked table, so a test can plant a fault the real one cannot carry. */
202
+ tableOverride?: BindingTable;
203
+ /** Extra component schemas, so a test can plant one the strictness rules must reject. */
204
+ extraSchemas?: Record<string, unknown>;
205
+ /** Extra path items, so a test can plant a leak the rewrite map would otherwise remove. */
206
+ extraPaths?: Record<string, Record<string, unknown>>;
207
+ }
208
+ declare function generateApiDocument(options?: GenerateOptions): ApiDocument;
209
+ //#endregion
210
+ //#region src/conventions.d.ts
211
+ export declare const CONVENTIONS_DIR: string;
212
+ interface ConventionComponent {
213
+ file: string;
214
+ /** The component name the binding table references, derived from the title. */
215
+ name: string;
216
+ schema: Record<string, unknown>;
217
+ }
218
+ /** PascalCase from the title, so the file, the title and the reference cannot disagree. */
219
+ export declare function componentName(title: string): string;
220
+ export declare function loadConventions(dir?: string): ConventionComponent[];
221
+ //#endregion
222
+ //#region src/validate-example.d.ts
223
+ interface ExampleFault {
224
+ index: number;
225
+ errors: string;
226
+ }
227
+ /**
228
+ * Faults in a schema's own examples. An empty array means every example validates.
229
+ *
230
+ * `references` supplies the components an example's schema may `$ref` — the ingest request
231
+ * points at the eight document roots, so without them it cannot compile.
232
+ */
233
+ export declare function validateExample(schema: Record<string, unknown>, references?: Record<string, unknown>): ExampleFault[];
234
+ //#endregion
235
+ export { type ApiDocument, type BindingTable, type BuildOptions, type ComponentsDocument, type ConventionComponent, type ExampleFault, type GenerateOptions, type JsonSchema, type ToolBinding, generateApiDocument as apiSpec };
236
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/components.ts","../src/embed.ts","../src/extract.ts","../src/bindings.ts","../src/generate-api.ts","../src/conventions.ts","../src/validate-example.ts"],"mappings":";UAAiB;GACd;;UAGc;EACf;EACA;IACE;IACA;IACA;IACA;MAAW;MAAc;;IACzB;MAAW;MAAc;;;EAE3B;EACA;IAAc,SAAS,eAAe;;;;qBAI3B;qBAWA,sBAAsB;;qBAYtB;UA4JI;;EAEf;;wBAGc,wBACd,SAAS,YAAY,aACrB,UAAS,eACR;;;;;;;;qBChMU;;;;;;wBAOG,YAAY,mBAAmB,YAAY;;;;;;;;;;;;;;;;wBCgC3C,wBAAwB,KAAK,oBAAoB,eAAe;;;;;;;;;;qBCrCnE,aAAW;;;;;;qBAgCX,mBAAiB;;;;;;;;;;;;;;;UAyBb;EACf;EACA;EACA,SAAS;IAAiB;IAAoB;;EAC9C;IAAS;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