@living-architecture/riviere-extract-config 0.1.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.
- package/LICENSE +190 -0
- package/README.md +35 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/validation-fixtures.d.ts +11 -0
- package/dist/validation-fixtures.d.ts.map +1 -0
- package/dist/validation-fixtures.js +77 -0
- package/dist/validation.d.ts +20 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +44 -0
- package/extraction-config.schema.json +315 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright
|
|
52
|
+
owner or by an individual or Legal Entity authorized to submit on behalf
|
|
53
|
+
of the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Nick Tune
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# riviere-extract-config
|
|
2
|
+
|
|
3
|
+
JSON Schema validation for extraction configuration DSL.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import {
|
|
9
|
+
validateExtractionConfig,
|
|
10
|
+
parseExtractionConfig,
|
|
11
|
+
isValidExtractionConfig,
|
|
12
|
+
} from '@living-architecture/riviere-extract-config';
|
|
13
|
+
|
|
14
|
+
const config = { modules: [{ path: 'src/**', api: { find: 'class' } }] };
|
|
15
|
+
|
|
16
|
+
if (isValidExtractionConfig(config)) {
|
|
17
|
+
// config is typed as ExtractionConfig
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const result = validateExtractionConfig(config);
|
|
21
|
+
if (result.valid) {
|
|
22
|
+
// use result.data
|
|
23
|
+
} else {
|
|
24
|
+
// handle result.errors
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
- [CLAUDE.md](./CLAUDE.md) — Design principles and schema overview
|
|
31
|
+
- [extraction-config.schema.json](./extraction-config.schema.json) — JSON Schema reference
|
|
32
|
+
|
|
33
|
+
## Building
|
|
34
|
+
|
|
35
|
+
Run `nx build riviere-extract-config` to build the library.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAA"}
|
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type FindTarget = 'classes' | 'methods' | 'functions';
|
|
2
|
+
export type ComponentType = 'api' | 'useCase' | 'domainOp' | 'event' | 'eventHandler' | 'ui';
|
|
3
|
+
export interface HasDecoratorPredicate {
|
|
4
|
+
hasDecorator: {
|
|
5
|
+
name: string | string[];
|
|
6
|
+
from?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface HasJSDocPredicate {
|
|
10
|
+
hasJSDoc: {
|
|
11
|
+
tag: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ExtendsClassPredicate {
|
|
15
|
+
extendsClass: {
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface ImplementsInterfacePredicate {
|
|
20
|
+
implementsInterface: {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface NameEndsWithPredicate {
|
|
25
|
+
nameEndsWith: {
|
|
26
|
+
suffix: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface NameMatchesPredicate {
|
|
30
|
+
nameMatches: {
|
|
31
|
+
pattern: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface InClassWithPredicate {
|
|
35
|
+
inClassWith: Predicate;
|
|
36
|
+
}
|
|
37
|
+
export interface AndPredicate {
|
|
38
|
+
and: Predicate[];
|
|
39
|
+
}
|
|
40
|
+
export interface OrPredicate {
|
|
41
|
+
or: Predicate[];
|
|
42
|
+
}
|
|
43
|
+
export type Predicate = HasDecoratorPredicate | HasJSDocPredicate | ExtendsClassPredicate | ImplementsInterfacePredicate | NameEndsWithPredicate | NameMatchesPredicate | InClassWithPredicate | AndPredicate | OrPredicate;
|
|
44
|
+
export interface NotUsed {
|
|
45
|
+
notUsed: true;
|
|
46
|
+
}
|
|
47
|
+
export interface DetectionRule {
|
|
48
|
+
find: FindTarget;
|
|
49
|
+
where: Predicate;
|
|
50
|
+
}
|
|
51
|
+
export type ComponentRule = NotUsed | DetectionRule;
|
|
52
|
+
export interface Module {
|
|
53
|
+
path: string;
|
|
54
|
+
api: ComponentRule;
|
|
55
|
+
useCase: ComponentRule;
|
|
56
|
+
domainOp: ComponentRule;
|
|
57
|
+
event: ComponentRule;
|
|
58
|
+
eventHandler: ComponentRule;
|
|
59
|
+
ui: ComponentRule;
|
|
60
|
+
}
|
|
61
|
+
export interface ExtractionConfig {
|
|
62
|
+
$schema?: string;
|
|
63
|
+
modules: Module[];
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAA;AAE5D,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,IAAI,CAAA;AAE5F,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE;QACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;CACF;AAED,MAAM,WAAW,iBAAiB;IAAE,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAC;AAE9D,MAAM,WAAW,qBAAqB;IAAE,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAC;AAEvE,MAAM,WAAW,4BAA4B;IAAE,mBAAmB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAC;AAErF,MAAM,WAAW,qBAAqB;IAAE,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAC;AAEzE,MAAM,WAAW,oBAAoB;IAAE,WAAW,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAC;AAExE,MAAM,WAAW,oBAAoB;IAAE,WAAW,EAAE,SAAS,CAAA;CAAC;AAE9D,MAAM,WAAW,YAAY;IAAE,GAAG,EAAE,SAAS,EAAE,CAAA;CAAC;AAEhD,MAAM,WAAW,WAAW;IAAE,EAAE,EAAE,SAAS,EAAE,CAAA;CAAC;AAE9C,MAAM,MAAM,SAAS,GACjB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,4BAA4B,GAC5B,qBAAqB,GACrB,oBAAoB,GACpB,oBAAoB,GACpB,YAAY,GACZ,WAAW,CAAA;AAEf,MAAM,WAAW,OAAO;IAAE,OAAO,EAAE,IAAI,CAAA;CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,SAAS,CAAA;CACjB;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,aAAa,CAAA;AAEnD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,aAAa,CAAA;IAClB,OAAO,EAAE,aAAa,CAAA;IACtB,QAAQ,EAAE,aAAa,CAAA;IACvB,KAAK,EAAE,aAAa,CAAA;IACpB,YAAY,EAAE,aAAa,CAAA;IAC3B,EAAE,EAAE,aAAa,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExtractionConfig, Module } from './types';
|
|
2
|
+
export declare function createModuleWithoutPath(): Omit<Module, 'path'>;
|
|
3
|
+
export declare function createModuleWithoutApi(): Omit<Module, 'api'>;
|
|
4
|
+
export declare function createMinimalModule(): Module;
|
|
5
|
+
export declare function createMinimalConfig(): ExtractionConfig;
|
|
6
|
+
export declare function createMutableConfig(): {
|
|
7
|
+
config: ExtractionConfig;
|
|
8
|
+
module: Module;
|
|
9
|
+
};
|
|
10
|
+
export declare function createFullConfig(): ExtractionConfig;
|
|
11
|
+
//# sourceMappingURL=validation-fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-fixtures.d.ts","sourceRoot":"","sources":["../src/validation-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAAE,MAAM,EACzB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,uBAAuB,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAS9D;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAS5D;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAU5C;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD;AAED,wBAAgB,mBAAmB,IAAI;IACrC,MAAM,EAAE,gBAAgB,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;CACf,CAOA;AAED,wBAAgB,gBAAgB,IAAI,gBAAgB,CAkCnD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export function createModuleWithoutPath() {
|
|
2
|
+
return {
|
|
3
|
+
api: { notUsed: true },
|
|
4
|
+
useCase: { notUsed: true },
|
|
5
|
+
domainOp: { notUsed: true },
|
|
6
|
+
event: { notUsed: true },
|
|
7
|
+
eventHandler: { notUsed: true },
|
|
8
|
+
ui: { notUsed: true },
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function createModuleWithoutApi() {
|
|
12
|
+
return {
|
|
13
|
+
path: 'src/**',
|
|
14
|
+
useCase: { notUsed: true },
|
|
15
|
+
domainOp: { notUsed: true },
|
|
16
|
+
event: { notUsed: true },
|
|
17
|
+
eventHandler: { notUsed: true },
|
|
18
|
+
ui: { notUsed: true },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function createMinimalModule() {
|
|
22
|
+
return {
|
|
23
|
+
path: 'src/**',
|
|
24
|
+
api: { notUsed: true },
|
|
25
|
+
useCase: { notUsed: true },
|
|
26
|
+
domainOp: { notUsed: true },
|
|
27
|
+
event: { notUsed: true },
|
|
28
|
+
eventHandler: { notUsed: true },
|
|
29
|
+
ui: { notUsed: true },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function createMinimalConfig() {
|
|
33
|
+
return { modules: [createMinimalModule()] };
|
|
34
|
+
}
|
|
35
|
+
export function createMutableConfig() {
|
|
36
|
+
const module = createMinimalModule();
|
|
37
|
+
const config = { modules: [module] };
|
|
38
|
+
return {
|
|
39
|
+
config,
|
|
40
|
+
module,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function createFullConfig() {
|
|
44
|
+
return {
|
|
45
|
+
modules: [
|
|
46
|
+
{
|
|
47
|
+
path: 'orders/**',
|
|
48
|
+
api: {
|
|
49
|
+
find: 'methods',
|
|
50
|
+
where: {
|
|
51
|
+
hasDecorator: {
|
|
52
|
+
name: ['Get', 'Post', 'Put', 'Delete'],
|
|
53
|
+
from: '@nestjs/common',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
useCase: {
|
|
58
|
+
find: 'classes',
|
|
59
|
+
where: { hasDecorator: { name: 'UseCase' } },
|
|
60
|
+
},
|
|
61
|
+
domainOp: {
|
|
62
|
+
find: 'functions',
|
|
63
|
+
where: { hasJSDoc: { tag: 'domainOp' } },
|
|
64
|
+
},
|
|
65
|
+
event: {
|
|
66
|
+
find: 'classes',
|
|
67
|
+
where: { extendsClass: { name: 'DomainEvent' } },
|
|
68
|
+
},
|
|
69
|
+
eventHandler: {
|
|
70
|
+
find: 'classes',
|
|
71
|
+
where: { implementsInterface: { name: 'EventHandler' } },
|
|
72
|
+
},
|
|
73
|
+
ui: { notUsed: true },
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExtractionConfig } from './types';
|
|
2
|
+
export declare function isValidExtractionConfig(data: unknown): data is ExtractionConfig;
|
|
3
|
+
export interface ValidationError {
|
|
4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ValidationResult {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
errors: ValidationError[];
|
|
10
|
+
}
|
|
11
|
+
interface AjvErrorLike {
|
|
12
|
+
instancePath: string;
|
|
13
|
+
message?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function mapAjvErrors(errors: AjvErrorLike[] | null | undefined): ValidationError[];
|
|
16
|
+
export declare function validateExtractionConfig(data: unknown): ValidationResult;
|
|
17
|
+
export declare function formatValidationErrors(errors: ValidationError[]): string;
|
|
18
|
+
export declare function parseExtractionConfig(data: unknown): ExtractionConfig;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAQ/C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAE/E;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AAED,UAAU,YAAY;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,EAAE,CAQzF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAaxE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAKxE;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAMrE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import addFormats from 'ajv-formats';
|
|
3
|
+
import rawSchema from '../extraction-config.schema.json' with { type: 'json' };
|
|
4
|
+
const ajv = new Ajv({ allErrors: true });
|
|
5
|
+
addFormats(ajv);
|
|
6
|
+
const validate = ajv.compile(rawSchema);
|
|
7
|
+
export function isValidExtractionConfig(data) {
|
|
8
|
+
return validate(data) === true;
|
|
9
|
+
}
|
|
10
|
+
export function mapAjvErrors(errors) {
|
|
11
|
+
if (!errors) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return errors.map((e) => ({
|
|
15
|
+
path: e.instancePath || '/',
|
|
16
|
+
message: e.message ?? 'unknown error',
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
export function validateExtractionConfig(data) {
|
|
20
|
+
const valid = validate(data) === true;
|
|
21
|
+
if (valid) {
|
|
22
|
+
return {
|
|
23
|
+
valid: true,
|
|
24
|
+
errors: [],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
valid: false,
|
|
29
|
+
errors: mapAjvErrors(validate.errors),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function formatValidationErrors(errors) {
|
|
33
|
+
if (errors.length === 0) {
|
|
34
|
+
return 'validation failed without specific errors';
|
|
35
|
+
}
|
|
36
|
+
return errors.map((e) => `${e.path}: ${e.message}`).join('\n');
|
|
37
|
+
}
|
|
38
|
+
export function parseExtractionConfig(data) {
|
|
39
|
+
if (isValidExtractionConfig(data)) {
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
const result = validateExtractionConfig(data);
|
|
43
|
+
throw new Error(`Invalid extraction config:\n${formatValidationErrors(result.errors)}`);
|
|
44
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://living-architecture.dev/schemas/extraction-config.schema.json",
|
|
4
|
+
"title": "Extraction Config",
|
|
5
|
+
"description": "Configuration for extracting architectural components from source code",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["modules"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "JSON Schema reference"
|
|
13
|
+
},
|
|
14
|
+
"modules": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"description": "Module definitions for component extraction",
|
|
17
|
+
"minItems": 1,
|
|
18
|
+
"items": {
|
|
19
|
+
"$ref": "#/$defs/module"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"$defs": {
|
|
24
|
+
"module": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"description": "A module defines extraction rules for a path pattern",
|
|
27
|
+
"required": ["path", "api", "useCase", "domainOp", "event", "eventHandler", "ui"],
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"path": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Glob pattern for files in this module",
|
|
33
|
+
"minLength": 1
|
|
34
|
+
},
|
|
35
|
+
"api": {
|
|
36
|
+
"$ref": "#/$defs/componentRule",
|
|
37
|
+
"description": "Detection rule for API components"
|
|
38
|
+
},
|
|
39
|
+
"useCase": {
|
|
40
|
+
"$ref": "#/$defs/componentRule",
|
|
41
|
+
"description": "Detection rule for UseCase components"
|
|
42
|
+
},
|
|
43
|
+
"domainOp": {
|
|
44
|
+
"$ref": "#/$defs/componentRule",
|
|
45
|
+
"description": "Detection rule for DomainOp components"
|
|
46
|
+
},
|
|
47
|
+
"event": {
|
|
48
|
+
"$ref": "#/$defs/componentRule",
|
|
49
|
+
"description": "Detection rule for Event components"
|
|
50
|
+
},
|
|
51
|
+
"eventHandler": {
|
|
52
|
+
"$ref": "#/$defs/componentRule",
|
|
53
|
+
"description": "Detection rule for EventHandler components"
|
|
54
|
+
},
|
|
55
|
+
"ui": {
|
|
56
|
+
"$ref": "#/$defs/componentRule",
|
|
57
|
+
"description": "Detection rule for UI components"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"componentRule": {
|
|
62
|
+
"oneOf": [
|
|
63
|
+
{
|
|
64
|
+
"$ref": "#/$defs/notUsed"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"$ref": "#/$defs/detectionRule"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"notUsed": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"description": "Marks this component type as not used in the module",
|
|
74
|
+
"required": ["notUsed"],
|
|
75
|
+
"additionalProperties": false,
|
|
76
|
+
"properties": {
|
|
77
|
+
"notUsed": {
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"const": true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"detectionRule": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"description": "Rule for detecting components of this type",
|
|
86
|
+
"required": ["find", "where"],
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"properties": {
|
|
89
|
+
"find": {
|
|
90
|
+
"$ref": "#/$defs/findTarget"
|
|
91
|
+
},
|
|
92
|
+
"where": {
|
|
93
|
+
"$ref": "#/$defs/predicate"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"findTarget": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"description": "The code construct to search for",
|
|
100
|
+
"enum": ["classes", "methods", "functions"]
|
|
101
|
+
},
|
|
102
|
+
"predicate": {
|
|
103
|
+
"oneOf": [
|
|
104
|
+
{
|
|
105
|
+
"$ref": "#/$defs/hasDecoratorPredicate"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"$ref": "#/$defs/hasJSDocPredicate"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"$ref": "#/$defs/extendsClassPredicate"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"$ref": "#/$defs/implementsInterfacePredicate"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"$ref": "#/$defs/nameEndsWithPredicate"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"$ref": "#/$defs/nameMatchesPredicate"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"$ref": "#/$defs/inClassWithPredicate"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"$ref": "#/$defs/andPredicate"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"$ref": "#/$defs/orPredicate"
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"hasDecoratorPredicate": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"description": "Matches if the target has a specified decorator",
|
|
136
|
+
"required": ["hasDecorator"],
|
|
137
|
+
"additionalProperties": false,
|
|
138
|
+
"properties": {
|
|
139
|
+
"hasDecorator": {
|
|
140
|
+
"type": "object",
|
|
141
|
+
"required": ["name"],
|
|
142
|
+
"additionalProperties": false,
|
|
143
|
+
"properties": {
|
|
144
|
+
"name": {
|
|
145
|
+
"oneOf": [
|
|
146
|
+
{
|
|
147
|
+
"type": "string",
|
|
148
|
+
"minLength": 1
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"type": "array",
|
|
152
|
+
"items": {
|
|
153
|
+
"type": "string",
|
|
154
|
+
"minLength": 1
|
|
155
|
+
},
|
|
156
|
+
"minItems": 1
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"description": "Decorator name(s) to match"
|
|
160
|
+
},
|
|
161
|
+
"from": {
|
|
162
|
+
"type": "string",
|
|
163
|
+
"minLength": 1,
|
|
164
|
+
"description": "Package the decorator is imported from"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"hasJSDocPredicate": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"description": "Matches if the target has a specified JSDoc tag",
|
|
173
|
+
"required": ["hasJSDoc"],
|
|
174
|
+
"additionalProperties": false,
|
|
175
|
+
"properties": {
|
|
176
|
+
"hasJSDoc": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"required": ["tag"],
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"properties": {
|
|
181
|
+
"tag": {
|
|
182
|
+
"type": "string",
|
|
183
|
+
"minLength": 1,
|
|
184
|
+
"description": "JSDoc tag to match (without @)"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"extendsClassPredicate": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"description": "Matches if the class extends a specified base class",
|
|
193
|
+
"required": ["extendsClass"],
|
|
194
|
+
"additionalProperties": false,
|
|
195
|
+
"properties": {
|
|
196
|
+
"extendsClass": {
|
|
197
|
+
"type": "object",
|
|
198
|
+
"required": ["name"],
|
|
199
|
+
"additionalProperties": false,
|
|
200
|
+
"properties": {
|
|
201
|
+
"name": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"minLength": 1,
|
|
204
|
+
"description": "Base class name to match"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"implementsInterfacePredicate": {
|
|
211
|
+
"type": "object",
|
|
212
|
+
"description": "Matches if the class implements a specified interface",
|
|
213
|
+
"required": ["implementsInterface"],
|
|
214
|
+
"additionalProperties": false,
|
|
215
|
+
"properties": {
|
|
216
|
+
"implementsInterface": {
|
|
217
|
+
"type": "object",
|
|
218
|
+
"required": ["name"],
|
|
219
|
+
"additionalProperties": false,
|
|
220
|
+
"properties": {
|
|
221
|
+
"name": {
|
|
222
|
+
"type": "string",
|
|
223
|
+
"minLength": 1,
|
|
224
|
+
"description": "Interface name to match"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"nameEndsWithPredicate": {
|
|
231
|
+
"type": "object",
|
|
232
|
+
"description": "Matches if the target name ends with a specified suffix",
|
|
233
|
+
"required": ["nameEndsWith"],
|
|
234
|
+
"additionalProperties": false,
|
|
235
|
+
"properties": {
|
|
236
|
+
"nameEndsWith": {
|
|
237
|
+
"type": "object",
|
|
238
|
+
"required": ["suffix"],
|
|
239
|
+
"additionalProperties": false,
|
|
240
|
+
"properties": {
|
|
241
|
+
"suffix": {
|
|
242
|
+
"type": "string",
|
|
243
|
+
"minLength": 1,
|
|
244
|
+
"description": "Suffix to match"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"nameMatchesPredicate": {
|
|
251
|
+
"type": "object",
|
|
252
|
+
"description": "Matches if the target name matches a regex pattern",
|
|
253
|
+
"required": ["nameMatches"],
|
|
254
|
+
"additionalProperties": false,
|
|
255
|
+
"properties": {
|
|
256
|
+
"nameMatches": {
|
|
257
|
+
"type": "object",
|
|
258
|
+
"required": ["pattern"],
|
|
259
|
+
"additionalProperties": false,
|
|
260
|
+
"properties": {
|
|
261
|
+
"pattern": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"minLength": 1,
|
|
264
|
+
"description": "Regex pattern to match against the name"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"inClassWithPredicate": {
|
|
271
|
+
"type": "object",
|
|
272
|
+
"description": "Matches if the method is in a class matching the predicate",
|
|
273
|
+
"required": ["inClassWith"],
|
|
274
|
+
"additionalProperties": false,
|
|
275
|
+
"properties": {
|
|
276
|
+
"inClassWith": {
|
|
277
|
+
"$ref": "#/$defs/predicate",
|
|
278
|
+
"description": "Predicate the containing class must satisfy"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"andPredicate": {
|
|
283
|
+
"type": "object",
|
|
284
|
+
"description": "Matches if all predicates match",
|
|
285
|
+
"required": ["and"],
|
|
286
|
+
"additionalProperties": false,
|
|
287
|
+
"properties": {
|
|
288
|
+
"and": {
|
|
289
|
+
"type": "array",
|
|
290
|
+
"items": {
|
|
291
|
+
"$ref": "#/$defs/predicate"
|
|
292
|
+
},
|
|
293
|
+
"minItems": 2,
|
|
294
|
+
"description": "All predicates must match"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"orPredicate": {
|
|
299
|
+
"type": "object",
|
|
300
|
+
"description": "Matches if any predicate matches",
|
|
301
|
+
"required": ["or"],
|
|
302
|
+
"additionalProperties": false,
|
|
303
|
+
"properties": {
|
|
304
|
+
"or": {
|
|
305
|
+
"type": "array",
|
|
306
|
+
"items": {
|
|
307
|
+
"$ref": "#/$defs/predicate"
|
|
308
|
+
},
|
|
309
|
+
"minItems": 2,
|
|
310
|
+
"description": "Any predicate must match"
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@living-architecture/riviere-extract-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
"./package.json": "./package.json",
|
|
13
|
+
".": {
|
|
14
|
+
"@living-architecture/source": "./src/index.ts",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./schema.json": "./extraction-config.schema.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"extraction-config.schema.json",
|
|
24
|
+
"!**/*.tsbuildinfo"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"ajv": "^8.17.1",
|
|
28
|
+
"ajv-formats": "^3.0.1"
|
|
29
|
+
}
|
|
30
|
+
}
|