onix-engine 0.1.1 → 0.1.2

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/dist/index.d.cts CHANGED
@@ -75,6 +75,173 @@ declare function getThemaHeading(code: string): string | undefined;
75
75
 
76
76
  declare function hasThemaCode(code: string): boolean;
77
77
 
78
+ /**
79
+ * Reviewed against the pinned Thema v1.6 notes. This is deliberately
80
+ * hand-maintained: changes require an explicit review of those notes and must
81
+ * not be inferred from source prose at runtime or during data generation.
82
+ */
83
+ declare const themaNonAssignableCodes: readonly ["1", "1Q", "2", "3", "4", "5", "5A", "5T", "5Y", "6", "C", "D", "F", "FY", "G", "L", "N", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "YFZ", "6A", "6B", "6C", "6D", "6E", "6F", "6G", "6H", "6J", "6K", "6L", "6M", "6N", "6P", "6Q", "6R", "6S", "6SX", "6T", "6U", "6V", "6W", "6X"];
84
+ declare function isThemaCodeAssignable(code: string): boolean;
85
+
86
+ type ValidationSeverity = "error" | "warning";
87
+ interface SourceLocation {
88
+ readonly line?: number;
89
+ readonly column?: number;
90
+ readonly xmlPath?: string;
91
+ readonly productIndex?: number;
92
+ }
93
+ interface ValidationSource {
94
+ readonly type: "codelist-note" | "schematron" | "thema" | "schema";
95
+ readonly list?: number;
96
+ readonly code?: string;
97
+ readonly text?: string;
98
+ readonly rule?: string;
99
+ }
100
+ interface ValidationFinding {
101
+ readonly ruleId: string;
102
+ readonly severity: ValidationSeverity;
103
+ readonly path: string;
104
+ readonly parameters: Readonly<Record<string, string | number | boolean | readonly string[]>>;
105
+ readonly source: ValidationSource;
106
+ readonly sourceLocation?: SourceLocation;
107
+ }
108
+ interface OnixSubjectAssignment {
109
+ readonly schemeCode: string;
110
+ readonly code: string;
111
+ readonly isMain?: boolean;
112
+ }
113
+ /** A repeatable ONIX <...Identifier> composite in one parent context. */
114
+ interface OnixIdentifier {
115
+ readonly typeCode: string;
116
+ readonly value: string;
117
+ readonly typeName?: string;
118
+ }
119
+ interface OnixIdentifierGroup {
120
+ /** Reference-tag composite name, eg ProductIdentifier. */
121
+ readonly context: string;
122
+ /** Canonical path for this repeated composite, eg /productIdentifiers. */
123
+ readonly path: string;
124
+ readonly identifiers: readonly OnixIdentifier[];
125
+ }
126
+ interface OnixCodeInput {
127
+ readonly productComposition?: string;
128
+ readonly productForm?: string;
129
+ readonly productFormDetails?: readonly string[];
130
+ readonly subjects?: readonly OnixSubjectAssignment[];
131
+ readonly identifierGroups?: readonly OnixIdentifierGroup[];
132
+ }
133
+ interface ValidationVersions {
134
+ readonly onixRelease: string;
135
+ readonly codelistIssue: number;
136
+ readonly themaVersion: string;
137
+ readonly semanticRulesVersion: string;
138
+ }
139
+ interface ValidationReport {
140
+ readonly findings: readonly ValidationFinding[];
141
+ readonly findingsByPath: Readonly<Record<string, readonly ValidationFinding[]>>;
142
+ readonly versions: ValidationVersions;
143
+ }
144
+ interface ValidationFieldReport {
145
+ readonly path: string;
146
+ readonly findings: readonly ValidationFinding[];
147
+ readonly versions: ValidationVersions;
148
+ }
149
+ interface ValidateOnixCodesOptions {
150
+ readonly rejectAncestorDescendant?: boolean;
151
+ }
152
+ type ValidateOnixXmlOptions = ValidateOnixCodesOptions;
153
+ interface OnixXmlValidationReport extends ValidationReport {
154
+ readonly malformedXml?: {
155
+ readonly message: string;
156
+ readonly line?: number;
157
+ readonly column?: number;
158
+ };
159
+ readonly unsupportedMessage?: {
160
+ readonly root?: string;
161
+ readonly release?: string;
162
+ readonly message: string;
163
+ };
164
+ }
165
+ interface SemanticManifestRule {
166
+ readonly ruleId: string;
167
+ readonly source: ValidationSource;
168
+ readonly sourceClassification: "normative" | "recommendation" | "informational" | "unsupported";
169
+ readonly enforcement: "error" | "warning" | "none";
170
+ readonly predicate: Readonly<Record<string, unknown>>;
171
+ }
172
+ /** A lexical, non-enforcing candidate extracted from pinned Thema prose. */
173
+ interface ThemaSemanticRuleAuditEntry {
174
+ readonly code: string;
175
+ readonly rawNote: string;
176
+ readonly source: Readonly<{
177
+ readonly type: "thema";
178
+ readonly code: string;
179
+ readonly version: string;
180
+ readonly issue: number;
181
+ readonly lastUpdated: string;
182
+ readonly file: string;
183
+ }>;
184
+ readonly cue: "Use with" | "Prefer" | "See also" | "other";
185
+ readonly referencedCodeLikeTokens: readonly string[];
186
+ readonly classification: "unsupported-candidate";
187
+ }
188
+
189
+ declare function validateOnixCodes(input: OnixCodeInput, options?: ValidateOnixCodesOptions): ValidationReport;
190
+ declare function validateOnixField(input: OnixCodeInput, path: string, options?: ValidateOnixCodesOptions): ValidationFieldReport;
191
+ declare function validateProductForm(input: Pick<OnixCodeInput, "productComposition" | "productForm" | "productFormDetails">): ValidationReport;
192
+ declare function validateThemaAssignments(assignments: readonly OnixSubjectAssignment[], options?: ValidateOnixCodesOptions): ValidationReport;
193
+
194
+ /** Parses only the fields consumed by validateOnixCodes; this is not XSD validation. */
195
+ declare function validateOnixXml(xml: string, options?: ValidateOnixXmlOptions): OnixXmlValidationReport;
196
+
197
+ /** Codelist notes reviewed by the deterministic extractor, including gaps. */
198
+ declare const semanticCodelistRuleAudit: readonly {
199
+ list: number;
200
+ code: string;
201
+ note: string;
202
+ source: {
203
+ type: string;
204
+ list: number;
205
+ code: string;
206
+ text: string;
207
+ };
208
+ extraction: string;
209
+ classification: string;
210
+ }[];
211
+ /** Pinned Thema prose retained as non-enforcing candidates for review. */
212
+ declare const themaSemanticRuleAudit: readonly ThemaSemanticRuleAuditEntry[];
213
+ /**
214
+ * Reviewed, deterministic compilation input. `source.text` retains the
215
+ * official source expression/note; runtime never attempts to parse prose.
216
+ */
217
+ declare const semanticManifest: readonly SemanticManifestRule[];
218
+
219
+ declare const semanticCodelistNoteAudit: readonly {
220
+ list: number;
221
+ code: string;
222
+ note: string;
223
+ source: {
224
+ type: string;
225
+ list: number;
226
+ code: string;
227
+ text: string;
228
+ };
229
+ extraction: string;
230
+ classification: string;
231
+ }[];
232
+ declare const identifierContextRegistry: readonly {
233
+ context: string;
234
+ typeName: string;
235
+ typeShortName: string;
236
+ typeList: number;
237
+ shortName: string;
238
+ source: {
239
+ type: string;
240
+ id: string;
241
+ };
242
+ }[];
243
+ declare const semanticSchemaSourceIds: readonly string[];
244
+
78
245
  interface CodelistMetadata {
79
246
  readonly issue: number;
80
247
  readonly generatedAt: string;
@@ -84,4 +251,4 @@ declare const metadata: CodelistMetadata;
84
251
 
85
252
  declare const themaMetadata: ThemaMetadata;
86
253
 
87
- export { type Codelist, type CodelistEntry, type CodelistMetadata, type SubjectVocabulary, type SubjectVocabularyDocument, type SubjectVocabularyEntry, type SubjectVocabularyMetadata, type ThemaEntry, type ThemaMetadata, createSubjectVocabulary, getCodelist, getCodelistEntries, getCodelistEntry, getCodelistHeading, getCodelists, getThemaChildren, getThemaEntries, getThemaEntry, getThemaHeading, hasCodelistCode, hasThemaCode, metadata, themaMetadata };
254
+ export { type Codelist, type CodelistEntry, type CodelistMetadata, type OnixCodeInput, type OnixIdentifier, type OnixIdentifierGroup, type OnixSubjectAssignment, type OnixXmlValidationReport, type SemanticManifestRule, type SourceLocation, type SubjectVocabulary, type SubjectVocabularyDocument, type SubjectVocabularyEntry, type SubjectVocabularyMetadata, type ThemaEntry, type ThemaMetadata, type ThemaSemanticRuleAuditEntry, type ValidateOnixCodesOptions, type ValidateOnixXmlOptions, type ValidationFieldReport, type ValidationFinding, type ValidationReport, type ValidationSeverity, type ValidationSource, type ValidationVersions, createSubjectVocabulary, getCodelist, getCodelistEntries, getCodelistEntry, getCodelistHeading, getCodelists, getThemaChildren, getThemaEntries, getThemaEntry, getThemaHeading, hasCodelistCode, hasThemaCode, identifierContextRegistry, isThemaCodeAssignable, metadata, semanticCodelistNoteAudit, semanticCodelistRuleAudit, semanticManifest, semanticSchemaSourceIds, themaMetadata, themaNonAssignableCodes, themaSemanticRuleAudit, validateOnixCodes, validateOnixField, validateOnixXml, validateProductForm, validateThemaAssignments };
package/dist/index.d.ts CHANGED
@@ -75,6 +75,173 @@ declare function getThemaHeading(code: string): string | undefined;
75
75
 
76
76
  declare function hasThemaCode(code: string): boolean;
77
77
 
78
+ /**
79
+ * Reviewed against the pinned Thema v1.6 notes. This is deliberately
80
+ * hand-maintained: changes require an explicit review of those notes and must
81
+ * not be inferred from source prose at runtime or during data generation.
82
+ */
83
+ declare const themaNonAssignableCodes: readonly ["1", "1Q", "2", "3", "4", "5", "5A", "5T", "5Y", "6", "C", "D", "F", "FY", "G", "L", "N", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "YFZ", "6A", "6B", "6C", "6D", "6E", "6F", "6G", "6H", "6J", "6K", "6L", "6M", "6N", "6P", "6Q", "6R", "6S", "6SX", "6T", "6U", "6V", "6W", "6X"];
84
+ declare function isThemaCodeAssignable(code: string): boolean;
85
+
86
+ type ValidationSeverity = "error" | "warning";
87
+ interface SourceLocation {
88
+ readonly line?: number;
89
+ readonly column?: number;
90
+ readonly xmlPath?: string;
91
+ readonly productIndex?: number;
92
+ }
93
+ interface ValidationSource {
94
+ readonly type: "codelist-note" | "schematron" | "thema" | "schema";
95
+ readonly list?: number;
96
+ readonly code?: string;
97
+ readonly text?: string;
98
+ readonly rule?: string;
99
+ }
100
+ interface ValidationFinding {
101
+ readonly ruleId: string;
102
+ readonly severity: ValidationSeverity;
103
+ readonly path: string;
104
+ readonly parameters: Readonly<Record<string, string | number | boolean | readonly string[]>>;
105
+ readonly source: ValidationSource;
106
+ readonly sourceLocation?: SourceLocation;
107
+ }
108
+ interface OnixSubjectAssignment {
109
+ readonly schemeCode: string;
110
+ readonly code: string;
111
+ readonly isMain?: boolean;
112
+ }
113
+ /** A repeatable ONIX <...Identifier> composite in one parent context. */
114
+ interface OnixIdentifier {
115
+ readonly typeCode: string;
116
+ readonly value: string;
117
+ readonly typeName?: string;
118
+ }
119
+ interface OnixIdentifierGroup {
120
+ /** Reference-tag composite name, eg ProductIdentifier. */
121
+ readonly context: string;
122
+ /** Canonical path for this repeated composite, eg /productIdentifiers. */
123
+ readonly path: string;
124
+ readonly identifiers: readonly OnixIdentifier[];
125
+ }
126
+ interface OnixCodeInput {
127
+ readonly productComposition?: string;
128
+ readonly productForm?: string;
129
+ readonly productFormDetails?: readonly string[];
130
+ readonly subjects?: readonly OnixSubjectAssignment[];
131
+ readonly identifierGroups?: readonly OnixIdentifierGroup[];
132
+ }
133
+ interface ValidationVersions {
134
+ readonly onixRelease: string;
135
+ readonly codelistIssue: number;
136
+ readonly themaVersion: string;
137
+ readonly semanticRulesVersion: string;
138
+ }
139
+ interface ValidationReport {
140
+ readonly findings: readonly ValidationFinding[];
141
+ readonly findingsByPath: Readonly<Record<string, readonly ValidationFinding[]>>;
142
+ readonly versions: ValidationVersions;
143
+ }
144
+ interface ValidationFieldReport {
145
+ readonly path: string;
146
+ readonly findings: readonly ValidationFinding[];
147
+ readonly versions: ValidationVersions;
148
+ }
149
+ interface ValidateOnixCodesOptions {
150
+ readonly rejectAncestorDescendant?: boolean;
151
+ }
152
+ type ValidateOnixXmlOptions = ValidateOnixCodesOptions;
153
+ interface OnixXmlValidationReport extends ValidationReport {
154
+ readonly malformedXml?: {
155
+ readonly message: string;
156
+ readonly line?: number;
157
+ readonly column?: number;
158
+ };
159
+ readonly unsupportedMessage?: {
160
+ readonly root?: string;
161
+ readonly release?: string;
162
+ readonly message: string;
163
+ };
164
+ }
165
+ interface SemanticManifestRule {
166
+ readonly ruleId: string;
167
+ readonly source: ValidationSource;
168
+ readonly sourceClassification: "normative" | "recommendation" | "informational" | "unsupported";
169
+ readonly enforcement: "error" | "warning" | "none";
170
+ readonly predicate: Readonly<Record<string, unknown>>;
171
+ }
172
+ /** A lexical, non-enforcing candidate extracted from pinned Thema prose. */
173
+ interface ThemaSemanticRuleAuditEntry {
174
+ readonly code: string;
175
+ readonly rawNote: string;
176
+ readonly source: Readonly<{
177
+ readonly type: "thema";
178
+ readonly code: string;
179
+ readonly version: string;
180
+ readonly issue: number;
181
+ readonly lastUpdated: string;
182
+ readonly file: string;
183
+ }>;
184
+ readonly cue: "Use with" | "Prefer" | "See also" | "other";
185
+ readonly referencedCodeLikeTokens: readonly string[];
186
+ readonly classification: "unsupported-candidate";
187
+ }
188
+
189
+ declare function validateOnixCodes(input: OnixCodeInput, options?: ValidateOnixCodesOptions): ValidationReport;
190
+ declare function validateOnixField(input: OnixCodeInput, path: string, options?: ValidateOnixCodesOptions): ValidationFieldReport;
191
+ declare function validateProductForm(input: Pick<OnixCodeInput, "productComposition" | "productForm" | "productFormDetails">): ValidationReport;
192
+ declare function validateThemaAssignments(assignments: readonly OnixSubjectAssignment[], options?: ValidateOnixCodesOptions): ValidationReport;
193
+
194
+ /** Parses only the fields consumed by validateOnixCodes; this is not XSD validation. */
195
+ declare function validateOnixXml(xml: string, options?: ValidateOnixXmlOptions): OnixXmlValidationReport;
196
+
197
+ /** Codelist notes reviewed by the deterministic extractor, including gaps. */
198
+ declare const semanticCodelistRuleAudit: readonly {
199
+ list: number;
200
+ code: string;
201
+ note: string;
202
+ source: {
203
+ type: string;
204
+ list: number;
205
+ code: string;
206
+ text: string;
207
+ };
208
+ extraction: string;
209
+ classification: string;
210
+ }[];
211
+ /** Pinned Thema prose retained as non-enforcing candidates for review. */
212
+ declare const themaSemanticRuleAudit: readonly ThemaSemanticRuleAuditEntry[];
213
+ /**
214
+ * Reviewed, deterministic compilation input. `source.text` retains the
215
+ * official source expression/note; runtime never attempts to parse prose.
216
+ */
217
+ declare const semanticManifest: readonly SemanticManifestRule[];
218
+
219
+ declare const semanticCodelistNoteAudit: readonly {
220
+ list: number;
221
+ code: string;
222
+ note: string;
223
+ source: {
224
+ type: string;
225
+ list: number;
226
+ code: string;
227
+ text: string;
228
+ };
229
+ extraction: string;
230
+ classification: string;
231
+ }[];
232
+ declare const identifierContextRegistry: readonly {
233
+ context: string;
234
+ typeName: string;
235
+ typeShortName: string;
236
+ typeList: number;
237
+ shortName: string;
238
+ source: {
239
+ type: string;
240
+ id: string;
241
+ };
242
+ }[];
243
+ declare const semanticSchemaSourceIds: readonly string[];
244
+
78
245
  interface CodelistMetadata {
79
246
  readonly issue: number;
80
247
  readonly generatedAt: string;
@@ -84,4 +251,4 @@ declare const metadata: CodelistMetadata;
84
251
 
85
252
  declare const themaMetadata: ThemaMetadata;
86
253
 
87
- export { type Codelist, type CodelistEntry, type CodelistMetadata, type SubjectVocabulary, type SubjectVocabularyDocument, type SubjectVocabularyEntry, type SubjectVocabularyMetadata, type ThemaEntry, type ThemaMetadata, createSubjectVocabulary, getCodelist, getCodelistEntries, getCodelistEntry, getCodelistHeading, getCodelists, getThemaChildren, getThemaEntries, getThemaEntry, getThemaHeading, hasCodelistCode, hasThemaCode, metadata, themaMetadata };
254
+ export { type Codelist, type CodelistEntry, type CodelistMetadata, type OnixCodeInput, type OnixIdentifier, type OnixIdentifierGroup, type OnixSubjectAssignment, type OnixXmlValidationReport, type SemanticManifestRule, type SourceLocation, type SubjectVocabulary, type SubjectVocabularyDocument, type SubjectVocabularyEntry, type SubjectVocabularyMetadata, type ThemaEntry, type ThemaMetadata, type ThemaSemanticRuleAuditEntry, type ValidateOnixCodesOptions, type ValidateOnixXmlOptions, type ValidationFieldReport, type ValidationFinding, type ValidationReport, type ValidationSeverity, type ValidationSource, type ValidationVersions, createSubjectVocabulary, getCodelist, getCodelistEntries, getCodelistEntry, getCodelistHeading, getCodelists, getThemaChildren, getThemaEntries, getThemaEntry, getThemaHeading, hasCodelistCode, hasThemaCode, identifierContextRegistry, isThemaCodeAssignable, metadata, semanticCodelistNoteAudit, semanticCodelistRuleAudit, semanticManifest, semanticSchemaSourceIds, themaMetadata, themaNonAssignableCodes, themaSemanticRuleAudit, validateOnixCodes, validateOnixField, validateOnixXml, validateProductForm, validateThemaAssignments };