@living-architecture/riviere-extract-config-published-language 0.7.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,313 @@
1
+ /**
2
+ * AST element type to search for during extraction.
3
+ */
4
+ /** @riviere-role published-language-union */
5
+ export type FindTarget = 'classes' | 'methods' | 'functions';
6
+ /**
7
+ * Standard architectural component types recognized by the Riviere extractor.
8
+ * Each type represents a distinct role in the system's flow-based architecture.
9
+ */
10
+ /** @riviere-role published-language-union */
11
+ export type ComponentType = 'api' | 'useCase' | 'domainOp' | 'event' | 'eventHandler' | 'ui';
12
+ /** Matches elements with a specific decorator. */
13
+ /** @riviere-role published-language-data-structure */
14
+ export interface HasDecoratorPredicate {
15
+ hasDecorator: {
16
+ name: string | string[];
17
+ from?: string;
18
+ };
19
+ }
20
+ /** Matches elements with a specific JSDoc tag. */
21
+ /** @riviere-role published-language-data-structure */
22
+ export interface HasJSDocPredicate {
23
+ hasJSDoc: {
24
+ tag: string;
25
+ };
26
+ }
27
+ /** Matches classes extending a specific base class. */
28
+ /** @riviere-role published-language-data-structure */
29
+ export interface ExtendsClassPredicate {
30
+ extendsClass: {
31
+ name: string;
32
+ };
33
+ }
34
+ /** Matches classes implementing a specific interface. */
35
+ /** @riviere-role published-language-data-structure */
36
+ export interface ImplementsInterfacePredicate {
37
+ implementsInterface: {
38
+ name: string;
39
+ };
40
+ }
41
+ /** Matches elements whose name ends with a suffix. */
42
+ /** @riviere-role published-language-data-structure */
43
+ export interface NameEndsWithPredicate {
44
+ nameEndsWith: {
45
+ suffix: string;
46
+ };
47
+ }
48
+ /** Matches elements whose name matches a regex pattern. */
49
+ /** @riviere-role published-language-data-structure */
50
+ export interface NameMatchesPredicate {
51
+ nameMatches: {
52
+ pattern: string;
53
+ };
54
+ }
55
+ /** Matches methods inside classes satisfying a predicate. */
56
+ /** @riviere-role published-language-data-structure */
57
+ export interface InClassWithPredicate {
58
+ inClassWith: Predicate;
59
+ }
60
+ /** Combines predicates with AND logic. */
61
+ /** @riviere-role published-language-data-structure */
62
+ export interface AndPredicate {
63
+ and: Predicate[];
64
+ }
65
+ /** Combines predicates with OR logic. */
66
+ /** @riviere-role published-language-data-structure */
67
+ export interface OrPredicate {
68
+ or: Predicate[];
69
+ }
70
+ /** Union of all predicate types for filtering AST elements. */
71
+ /** @riviere-role published-language-union */
72
+ export type Predicate = HasDecoratorPredicate | HasJSDocPredicate | ExtendsClassPredicate | ImplementsInterfacePredicate | NameEndsWithPredicate | NameMatchesPredicate | InClassWithPredicate | AndPredicate | OrPredicate;
73
+ /** Marker indicating a component type is not used in the module. */
74
+ /** @riviere-role published-language-data-structure */
75
+ export interface NotUsed {
76
+ notUsed: true;
77
+ }
78
+ /** Transform operations to apply to extracted values. */
79
+ /** @riviere-role published-language-data-structure */
80
+ export interface Transform {
81
+ stripSuffix?: string;
82
+ stripPrefix?: string;
83
+ toLowerCase?: true;
84
+ toUpperCase?: true;
85
+ kebabToPascal?: true;
86
+ pascalToKebab?: true;
87
+ }
88
+ /** Extracts a hardcoded literal value. */
89
+ /** @riviere-role published-language-data-structure */
90
+ export interface LiteralExtractionRule {
91
+ literal: string | boolean | number;
92
+ }
93
+ /** Extracts value from the class name. */
94
+ /** @riviere-role published-language-data-structure */
95
+ export interface FromClassNameExtractionRule {
96
+ fromClassName: true | {
97
+ transform?: Transform;
98
+ };
99
+ }
100
+ /** Extracts value from the method name. */
101
+ /** @riviere-role published-language-data-structure */
102
+ export interface FromMethodNameExtractionRule {
103
+ fromMethodName: true | {
104
+ transform?: Transform;
105
+ };
106
+ }
107
+ /** Extracts value from the file path using regex capture. */
108
+ /** @riviere-role published-language-data-structure */
109
+ export interface FromFilePathExtractionRule {
110
+ fromFilePath: {
111
+ pattern: string;
112
+ capture: number;
113
+ transform?: Transform;
114
+ };
115
+ }
116
+ /** Extracts value from a class property. */
117
+ /** @riviere-role published-language-data-structure */
118
+ export interface FromPropertyExtractionRule {
119
+ fromProperty: {
120
+ name: string;
121
+ kind: 'static' | 'instance';
122
+ transform?: Transform;
123
+ };
124
+ }
125
+ /** Extracts value from decorator argument. */
126
+ /** @riviere-role published-language-data-structure */
127
+ export interface FromDecoratorArgExtractionRule {
128
+ fromDecoratorArg: {
129
+ decorator?: string;
130
+ position?: number;
131
+ name?: string;
132
+ transform?: Transform;
133
+ };
134
+ }
135
+ /** Extracts value from decorator argument on the containing class. */
136
+ /** @riviere-role published-language-data-structure */
137
+ export interface FromClassDecoratorArgExtractionRule {
138
+ fromClassDecoratorArg: {
139
+ decorator: string;
140
+ position: number;
141
+ name?: never;
142
+ transform?: Transform;
143
+ } | {
144
+ decorator: string;
145
+ name: string;
146
+ position?: never;
147
+ transform?: Transform;
148
+ };
149
+ }
150
+ /** Extracts value from the decorator name itself. */
151
+ /** @riviere-role published-language-data-structure */
152
+ export interface FromDecoratorNameExtractionRule {
153
+ fromDecoratorName: true | {
154
+ mapping?: Record<string, string>;
155
+ transform?: Transform;
156
+ };
157
+ }
158
+ /** Extracts value from generic type argument. */
159
+ /** @riviere-role published-language-data-structure */
160
+ export interface FromGenericArgExtractionRule {
161
+ fromGenericArg: {
162
+ interface: string;
163
+ position: number;
164
+ transform?: Transform;
165
+ };
166
+ }
167
+ /** Extracts method parameters and return type. */
168
+ /** @riviere-role published-language-data-structure */
169
+ export interface FromMethodSignatureExtractionRule {
170
+ fromMethodSignature: true;
171
+ }
172
+ /** Extracts constructor parameter names and types. */
173
+ /** @riviere-role published-language-data-structure */
174
+ export interface FromConstructorParamsExtractionRule {
175
+ fromConstructorParams: true;
176
+ }
177
+ /** Extracts type name of parameter at position. */
178
+ /** @riviere-role published-language-data-structure */
179
+ export interface FromParameterTypeExtractionRule {
180
+ fromParameterType: {
181
+ position: number;
182
+ transform?: Transform;
183
+ };
184
+ }
185
+ /**
186
+ * Union of all extraction rule types.
187
+ * Each rule type corresponds to a different source of metadata.
188
+ */
189
+ /** @riviere-role published-language-union */
190
+ export type ExtractionRule = LiteralExtractionRule | FromClassNameExtractionRule | FromMethodNameExtractionRule | FromFilePathExtractionRule | FromPropertyExtractionRule | FromDecoratorArgExtractionRule | FromClassDecoratorArgExtractionRule | FromDecoratorNameExtractionRule | FromGenericArgExtractionRule | FromMethodSignatureExtractionRule | FromConstructorParamsExtractionRule | FromParameterTypeExtractionRule;
191
+ /**
192
+ * Extract block mapping field names to extraction rules.
193
+ * Each key is a Riviere schema field name (e.g., apiType, httpMethod, path).
194
+ */
195
+ /** @riviere-role published-language-data-structure */
196
+ export interface ExtractBlock {
197
+ [fieldName: string]: ExtractionRule;
198
+ }
199
+ /** Rule specifying what to find and how to filter matches. */
200
+ /** @riviere-role published-language-data-structure */
201
+ export interface DetectionRule {
202
+ find: FindTarget;
203
+ where: Predicate;
204
+ extract?: ExtractBlock;
205
+ }
206
+ /** Either a detection rule or a marker that the component type is unused. */
207
+ /** @riviere-role published-language-union */
208
+ export type ComponentRule = NotUsed | DetectionRule;
209
+ /** User-defined component types with their detection rules. */
210
+ /** @riviere-role published-language-data-structure */
211
+ export interface CustomTypes {
212
+ [customTypeName: string]: DetectionRule;
213
+ }
214
+ /**
215
+ * Declares a custom component type as an event publisher.
216
+ * The component type must be defined in customTypes in at least one module.
217
+ */
218
+ /** @riviere-role published-language-data-structure */
219
+ export interface EventPublisherConfig {
220
+ /** The custom component type name (e.g. 'eventPublisher'). */
221
+ fromType: string;
222
+ /** The metadata key on this component type that holds the published event type name. */
223
+ metadataKey: string;
224
+ }
225
+ /**
226
+ * Declares how to resolve HTTP client calls into cross-domain Links.
227
+ * The custom type must be defined in customTypes in at least one module.
228
+ */
229
+ /** @riviere-role published-language-data-structure */
230
+ export interface HttpLinkConfig {
231
+ /** The custom component type name for HTTP clients (e.g. 'httpCall'). */
232
+ fromCustomType: string;
233
+ /** Metadata key whose value identifies the target domain. */
234
+ matchDomainBy: string;
235
+ /** Metadata keys used to match the target API component. */
236
+ matchApiBy: string[];
237
+ }
238
+ /** Connection detection configuration. */
239
+ /** @riviere-role published-language-data-structure */
240
+ export interface ConnectionsConfig {
241
+ /** Declares which custom component types publish events and how to detect them. */
242
+ eventPublishers?: EventPublisherConfig[];
243
+ /** Declares how to resolve HTTP client calls into cross-domain Links. */
244
+ httpLinks?: HttpLinkConfig[];
245
+ }
246
+ /**
247
+ * Reference to an external module definition file.
248
+ * The CLI expands these references before extraction by loading the referenced file.
249
+ */
250
+ /** @riviere-role published-language-data-structure */
251
+ export interface ModuleRef {
252
+ $ref: string;
253
+ }
254
+ /**
255
+ * A module config as written in the extraction config file.
256
+ * When `extends` is present, component rules are inherited from the extended config.
257
+ * Local rules override inherited rules.
258
+ */
259
+ interface ModuleIdentity {
260
+ name: string;
261
+ domain: string;
262
+ path: string;
263
+ glob: string;
264
+ /** Path pattern with `{module}` placeholder for resolving module names from file paths. */
265
+ modules?: string;
266
+ customTypes?: CustomTypes;
267
+ }
268
+ interface ModuleRules {
269
+ api: ComponentRule;
270
+ useCase: ComponentRule;
271
+ domainOp: ComponentRule;
272
+ event: ComponentRule;
273
+ eventHandler: ComponentRule;
274
+ ui: ComponentRule;
275
+ }
276
+ /** @riviere-role published-language-data-structure */
277
+ export interface StandaloneDraftModule extends ModuleIdentity, ModuleRules {
278
+ extends?: never;
279
+ }
280
+ /** @riviere-role published-language-union */
281
+ export type DraftModule = StandaloneDraftModule | (ModuleIdentity & Partial<ModuleRules> & {
282
+ extends: string;
283
+ });
284
+ /**
285
+ * A fully resolved module with all component rules.
286
+ * This is what the extractor uses after config resolution.
287
+ */
288
+ /** @riviere-role published-language-data-structure */
289
+ export interface ValidatedModuleInput extends ModuleIdentity, ModuleRules {
290
+ }
291
+ /**
292
+ * Extraction config after $ref expansion.
293
+ * At this point all ModuleRef entries have been resolved to DraftModule.
294
+ * This is what the extractor uses for processing.
295
+ */
296
+ /** @riviere-role published-language-schema */
297
+ export interface DraftConfiguration {
298
+ $schema?: string;
299
+ modules: DraftModule[];
300
+ connections?: ConnectionsConfig;
301
+ }
302
+ /**
303
+ * Fully resolved extraction config ready for the extractor.
304
+ * All extends references resolved, all modules have complete rules.
305
+ */
306
+ /** @riviere-role published-language-data-structure */
307
+ export interface ValidatedConfigurationInput {
308
+ $schema?: string;
309
+ modules: ValidatedModuleInput[];
310
+ connections?: ConnectionsConfig;
311
+ }
312
+ export {};
313
+ //# sourceMappingURL=extraction-config-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction-config-schema.d.ts","sourceRoot":"","sources":["../../src/published-language/extraction-config-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAA;AAE5D;;;GAGG;AACH,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,IAAI,CAAA;AAE5F,kDAAkD;AAClD,sDAAsD;AACtD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE;QACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;CACF;AAED,kDAAkD;AAClD,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1B;AAED,uDAAuD;AACvD,sDAAsD;AACtD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/B;AAED,yDAAyD;AACzD,sDAAsD;AACtD,MAAM,WAAW,4BAA4B;IAC3C,mBAAmB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CACtC;AAED,sDAAsD;AACtD,sDAAsD;AACtD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CACjC;AAED,2DAA2D;AA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CAChB;AAED,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GACnB,qBAAqB,GACrB,CAAC,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEjE;;;GAGG;AACH,sDAAsD;AACtD,MAAM,WAAW,oBAAqB,SAAQ,cAAc,EAAE,WAAW;CAAG;AAE5E;;;;GAIG;AACH,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC;AAED;;;GAGG;AACH,sDAAsD;AACtD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAC/B,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC"}
@@ -0,0 +1,48 @@
1
+ import type { ComponentRule, ComponentType, ConnectionsConfig, CustomTypes, ValidatedConfigurationInput, ValidatedModuleInput } from './extraction-config-schema';
2
+ import type { ValidationError } from './validation';
3
+ type ValidatedModuleParseResult = {
4
+ success: true;
5
+ data: ValidatedModule;
6
+ } | {
7
+ success: false;
8
+ errors: ValidationError[];
9
+ };
10
+ /** @riviere-role value-object */
11
+ export declare class ValidatedModule {
12
+ #private;
13
+ private readonly brand;
14
+ private constructor();
15
+ static parse(input: Readonly<ValidatedModuleInput>): ValidatedModuleParseResult;
16
+ get name(): string;
17
+ get domain(): string;
18
+ get path(): string;
19
+ get glob(): string;
20
+ get modules(): string | undefined;
21
+ get api(): ComponentRule;
22
+ get useCase(): ComponentRule;
23
+ get domainOp(): ComponentRule;
24
+ get event(): ComponentRule;
25
+ get eventHandler(): ComponentRule;
26
+ get ui(): ComponentRule;
27
+ get customTypes(): CustomTypes | undefined;
28
+ ruleFor(componentType: ComponentType): ComponentRule;
29
+ }
30
+ type ValidatedConfigurationParseResult = {
31
+ success: true;
32
+ data: ValidatedConfiguration;
33
+ } | {
34
+ success: false;
35
+ errors: ValidationError[];
36
+ };
37
+ /** @riviere-role value-object */
38
+ export declare class ValidatedConfiguration {
39
+ #private;
40
+ readonly connections: ConnectionsConfig | undefined;
41
+ readonly schema: string | undefined;
42
+ private readonly brand;
43
+ private constructor();
44
+ static parse(input: Readonly<ValidatedConfigurationInput>): ValidatedConfigurationParseResult;
45
+ get modules(): readonly ValidatedModule[];
46
+ }
47
+ export {};
48
+ //# sourceMappingURL=validated-configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validated-configuration.d.ts","sourceRoot":"","sources":["../../src/published-language/validated-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAoBnD,KAAK,0BAA0B,GAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GACxC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAA;AAEjD,iCAAiC;AACjC,qBAAa,eAAe;;IAC1B,iBAAyB,KAAK,CAAmB;IAGjD,OAAO;IAIP,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,0BAA0B;IAQ/E,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,IAAI,GAAG,IAAI,aAAa,CAEvB;IAED,IAAI,OAAO,IAAI,aAAa,CAE3B;IAED,IAAI,QAAQ,IAAI,aAAa,CAE5B;IAED,IAAI,KAAK,IAAI,aAAa,CAEzB;IAED,IAAI,YAAY,IAAI,aAAa,CAEhC;IAED,IAAI,EAAE,IAAI,aAAa,CAEtB;IAED,IAAI,WAAW,IAAI,WAAW,GAAG,SAAS,CAEzC;IAED,OAAO,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa;CAGrD;AAED,KAAK,iCAAiC,GAClC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAC/C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAA;AAEjD,iCAAiC;AACjC,qBAAa,sBAAsB;;IAM/B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,GAAG,SAAS;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IANrC,iBAAyB,KAAK,CAA0B;IAGxD,OAAO;IAQP,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GAAG,iCAAiC;IA4B7F,IAAI,OAAO,IAAI,SAAS,eAAe,EAAE,CAExC;CACF"}
@@ -0,0 +1,186 @@
1
+ const REQUIRED_FIELDS = {
2
+ api: ['apiType'],
3
+ useCase: [],
4
+ domainOp: ['operationName'],
5
+ event: ['eventName'],
6
+ eventHandler: ['subscribedEvents'],
7
+ ui: ['route'],
8
+ };
9
+ const COMPONENT_TYPES = [
10
+ 'api',
11
+ 'useCase',
12
+ 'domainOp',
13
+ 'event',
14
+ 'eventHandler',
15
+ 'ui',
16
+ ];
17
+ /** @riviere-role value-object */
18
+ export class ValidatedModule {
19
+ #values;
20
+ constructor(values) {
21
+ this.#values = values;
22
+ }
23
+ static parse(input) {
24
+ const errors = validateModule(input);
25
+ if (errors.length > 0) {
26
+ return { success: false, errors };
27
+ }
28
+ return { success: true, data: new ValidatedModule(input) };
29
+ }
30
+ get name() {
31
+ return this.#values.name;
32
+ }
33
+ get domain() {
34
+ return this.#values.domain;
35
+ }
36
+ get path() {
37
+ return this.#values.path;
38
+ }
39
+ get glob() {
40
+ return this.#values.glob;
41
+ }
42
+ get modules() {
43
+ return this.#values.modules;
44
+ }
45
+ get api() {
46
+ return this.#values.api;
47
+ }
48
+ get useCase() {
49
+ return this.#values.useCase;
50
+ }
51
+ get domainOp() {
52
+ return this.#values.domainOp;
53
+ }
54
+ get event() {
55
+ return this.#values.event;
56
+ }
57
+ get eventHandler() {
58
+ return this.#values.eventHandler;
59
+ }
60
+ get ui() {
61
+ return this.#values.ui;
62
+ }
63
+ get customTypes() {
64
+ return this.#values.customTypes;
65
+ }
66
+ ruleFor(componentType) {
67
+ return this.#values[componentType];
68
+ }
69
+ }
70
+ /** @riviere-role value-object */
71
+ export class ValidatedConfiguration {
72
+ connections;
73
+ schema;
74
+ #modules;
75
+ constructor(modules, connections, schema) {
76
+ this.connections = connections;
77
+ this.schema = schema;
78
+ this.#modules = modules;
79
+ }
80
+ static parse(input) {
81
+ const modules = [];
82
+ const moduleErrors = [];
83
+ input.modules.forEach((module, index) => {
84
+ const result = ValidatedModule.parse(module);
85
+ if (result.success) {
86
+ modules.push(result.data);
87
+ return;
88
+ }
89
+ moduleErrors.push(...result.errors.map((error) => ({
90
+ ...error,
91
+ path: `/modules/${index}${error.path}`,
92
+ })));
93
+ });
94
+ const connectionErrors = validateConnections(input);
95
+ const errors = [...moduleErrors, ...connectionErrors];
96
+ if (errors.length > 0) {
97
+ return { success: false, errors };
98
+ }
99
+ return {
100
+ success: true,
101
+ data: new ValidatedConfiguration(modules, input.connections, input.$schema),
102
+ };
103
+ }
104
+ get modules() {
105
+ return this.#modules;
106
+ }
107
+ }
108
+ function validateModule(module) {
109
+ return COMPONENT_TYPES.flatMap((componentType) => {
110
+ const rule = module[componentType];
111
+ if ('notUsed' in rule) {
112
+ return [];
113
+ }
114
+ const extractedFields = new Set(Object.keys(rule.extract ?? {}));
115
+ const missingFields = REQUIRED_FIELDS[componentType].filter((field) => !extractedFields.has(field));
116
+ return missingFields.length === 0
117
+ ? []
118
+ : [
119
+ {
120
+ path: `/${componentType}`,
121
+ message: `Missing required extraction rules: ${missingFields.join(', ')}. ` +
122
+ `Add extraction rules to the 'extract' block or use 'notUsed: true' if not extracting ${componentType} components.`,
123
+ },
124
+ ];
125
+ });
126
+ }
127
+ function validateConnections(input) {
128
+ if (input.connections === undefined)
129
+ return [];
130
+ const customTypeFields = new Map();
131
+ for (const module of input.modules) {
132
+ for (const [typeName, rule] of Object.entries(module.customTypes ?? {})) {
133
+ const fields = customTypeFields.get(typeName) ?? new Set();
134
+ for (const field of Object.keys(rule.extract ?? {}))
135
+ fields.add(field);
136
+ customTypeFields.set(typeName, fields);
137
+ }
138
+ }
139
+ return [
140
+ ...validateEventPublishers(input.connections, customTypeFields),
141
+ ...validateHttpLinks(input.connections, customTypeFields),
142
+ ];
143
+ }
144
+ function validateEventPublishers(connections, customTypeFields) {
145
+ return (connections.eventPublishers ?? []).flatMap((publisher, index) => {
146
+ const fields = customTypeFields.get(publisher.fromType);
147
+ if (fields === undefined) {
148
+ return [
149
+ {
150
+ path: `/connections/eventPublishers/${index}/fromType`,
151
+ message: `"${publisher.fromType}" is not defined as a customType in any module.`,
152
+ },
153
+ ];
154
+ }
155
+ return fields.has(publisher.metadataKey)
156
+ ? []
157
+ : [
158
+ {
159
+ path: `/connections/eventPublishers/${index}/metadataKey`,
160
+ message: `customType "${publisher.fromType}" does not extract "${publisher.metadataKey}".`,
161
+ },
162
+ ];
163
+ });
164
+ }
165
+ function validateHttpLinks(connections, customTypeFields) {
166
+ return (connections.httpLinks ?? []).flatMap((httpLink, index) => {
167
+ const fields = customTypeFields.get(httpLink.fromCustomType);
168
+ if (fields === undefined) {
169
+ return [
170
+ {
171
+ path: `/connections/httpLinks/${index}/fromCustomType`,
172
+ message: `"${httpLink.fromCustomType}" is not defined as a customType in any module.`,
173
+ },
174
+ ];
175
+ }
176
+ const requiredFields = [httpLink.matchDomainBy, ...httpLink.matchApiBy];
177
+ return requiredFields.flatMap((field) => fields.has(field)
178
+ ? []
179
+ : [
180
+ {
181
+ path: `/connections/httpLinks/${index}`,
182
+ message: `customType "${httpLink.fromCustomType}" does not extract "${field}".`,
183
+ },
184
+ ]);
185
+ });
186
+ }
@@ -0,0 +1,36 @@
1
+ import type { DraftConfiguration } from './extraction-config-schema';
2
+ /** A validation error with JSON path and message. */
3
+ /** @riviere-role published-language-data-structure */
4
+ export interface ValidationError {
5
+ path: string;
6
+ message: string;
7
+ }
8
+ /**
9
+ * Parses an extraction configuration against the structural schema.
10
+ *
11
+ * @riviere-role published-language-parser
12
+ * @param data - Configuration value to parse
13
+ * @returns The draft configuration or its validation errors
14
+ */
15
+ export declare function parseExtractionConfigSchema(data: unknown): {
16
+ success: true;
17
+ configuration: DraftConfiguration;
18
+ } | {
19
+ success: false;
20
+ errors: ValidationError[];
21
+ };
22
+ /**
23
+ * Parses and semantically validates an extraction configuration.
24
+ *
25
+ * @riviere-role published-language-parser
26
+ * @param data - Configuration value to parse
27
+ * @returns The draft configuration or its validation errors
28
+ */
29
+ export declare function parseExtractionConfig(data: unknown): {
30
+ success: true;
31
+ configuration: DraftConfiguration;
32
+ } | {
33
+ success: false;
34
+ errors: ValidationError[];
35
+ };
36
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/published-language/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,kBAAkB,EAGnB,MAAM,4BAA4B,CAAA;AAuCnC,qDAAqD;AACrD,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAwPD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,OAAO,GAEX;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,kBAAkB,CAAA;CAAE,GACpD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAMhD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GAEX;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,kBAAkB,CAAA;CAAE,GACpD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAMhD"}