@simway/spica 0.0.0-stage → 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/LICENSE +190 -0
- package/dist/admValidator.d.ts +28 -0
- package/dist/admValidator.d.ts.map +1 -0
- package/dist/admValidator.js +233 -0
- package/dist/admValidator.js.map +1 -0
- package/dist/contractProjector.d.ts +23 -0
- package/dist/contractProjector.d.ts.map +1 -0
- package/dist/contractProjector.js +269 -0
- package/dist/contractProjector.js.map +1 -0
- package/dist/dddCrewParser.d.ts +11 -0
- package/dist/dddCrewParser.d.ts.map +1 -0
- package/dist/dddCrewParser.js +519 -0
- package/dist/dddCrewParser.js.map +1 -0
- package/dist/dddCrewProjector.d.ts +16 -0
- package/dist/dddCrewProjector.d.ts.map +1 -0
- package/dist/dddCrewProjector.js +227 -0
- package/dist/dddCrewProjector.js.map +1 -0
- package/dist/defaultTemplate.d.ts +3 -0
- package/dist/defaultTemplate.d.ts.map +1 -0
- package/dist/defaultTemplate.js +1442 -0
- package/dist/defaultTemplate.js.map +1 -0
- package/dist/excalidrawProjector.d.ts +56 -0
- package/dist/excalidrawProjector.d.ts.map +1 -0
- package/dist/excalidrawProjector.js +235 -0
- package/dist/excalidrawProjector.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/openApiProjector.d.ts +17 -0
- package/dist/openApiProjector.d.ts.map +1 -0
- package/dist/openApiProjector.js +298 -0
- package/dist/openApiProjector.js.map +1 -0
- package/dist/schema.d.ts +670 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +296 -0
- package/dist/schema.js.map +1 -0
- package/dist/templates/aggregate-design-canvas-v1.1.excalidraw.json +1441 -0
- package/package.json +24 -3
- package/README.md +0 -3
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 Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
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 exemplary 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 Simway
|
|
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.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AstRoot } from "./schema.js";
|
|
2
|
+
export interface ValidationError {
|
|
3
|
+
code: string;
|
|
4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ValidationWarning {
|
|
8
|
+
code: string;
|
|
9
|
+
path: string;
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ValidationResult {
|
|
13
|
+
valid: boolean;
|
|
14
|
+
errors: ValidationError[];
|
|
15
|
+
warnings: ValidationWarning[];
|
|
16
|
+
model?: AstRoot;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper to convert camelCase identifier prefix to PascalCase entity name.
|
|
20
|
+
* e.g., "patronId" -> "patron" -> "Patron"
|
|
21
|
+
* "bookCopyId" -> "bookCopy" -> "BookCopy"
|
|
22
|
+
*/
|
|
23
|
+
export declare function idFieldToEntityName(fieldName: string): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Pure, deterministic mathematical AST validator for Virgo Application Domain Models.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateAdm(rawInput: unknown): ValidationResult;
|
|
28
|
+
//# sourceMappingURL=admValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admValidator.d.ts","sourceRoot":"","sources":["../src/admValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyC,MAAM,aAAa,CAAC;AAE7E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUpE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CA+O/D"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { AstRootSchema } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helper to convert camelCase identifier prefix to PascalCase entity name.
|
|
4
|
+
* e.g., "patronId" -> "patron" -> "Patron"
|
|
5
|
+
* "bookCopyId" -> "bookCopy" -> "BookCopy"
|
|
6
|
+
*/
|
|
7
|
+
export function idFieldToEntityName(fieldName) {
|
|
8
|
+
if (fieldName === "$id" || fieldName === "id") {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const match = fieldName.match(/^([a-z][a-zA-Z0-9]*)Id$/);
|
|
12
|
+
if (!match) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const prefix = match[1];
|
|
16
|
+
return prefix.charAt(0).toUpperCase() + prefix.slice(1);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pure, deterministic mathematical AST validator for Virgo Application Domain Models.
|
|
20
|
+
*/
|
|
21
|
+
export function validateAdm(rawInput) {
|
|
22
|
+
const errors = [];
|
|
23
|
+
const warnings = [];
|
|
24
|
+
// Step 1: Syntactic Schema Validation via Zod
|
|
25
|
+
const parseResult = AstRootSchema.safeParse(rawInput);
|
|
26
|
+
if (!parseResult.success) {
|
|
27
|
+
for (const issue of parseResult.error.issues) {
|
|
28
|
+
errors.push({
|
|
29
|
+
code: "E_SCHEMA_INVALID",
|
|
30
|
+
path: issue.path.join("."),
|
|
31
|
+
message: issue.message
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return { valid: false, errors, warnings };
|
|
35
|
+
}
|
|
36
|
+
const model = parseResult.data;
|
|
37
|
+
// Global Registry for cross-aggregate reference auditing
|
|
38
|
+
const aggregateNames = new Set();
|
|
39
|
+
const entityNames = new Set();
|
|
40
|
+
const entitiesByAggregate = new Map();
|
|
41
|
+
// Step 2: Build Global Namespaces & Check Uniqueness
|
|
42
|
+
for (let i = 0; i < model.aggregates.length; i++) {
|
|
43
|
+
const agg = model.aggregates[i];
|
|
44
|
+
const aggPath = `aggregates[${i}]`;
|
|
45
|
+
if (aggregateNames.has(agg.name)) {
|
|
46
|
+
errors.push({
|
|
47
|
+
code: "E_DUPLICATE_AGGREGATE_NAME",
|
|
48
|
+
path: `${aggPath}.name`,
|
|
49
|
+
message: `Duplicate AggregateNode name detected: '${agg.name}'. AggregateNode names must be globally unique.`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
aggregateNames.add(agg.name);
|
|
53
|
+
const aggEntities = new Set();
|
|
54
|
+
for (let j = 0; j < (agg.entities ?? []).length; j++) {
|
|
55
|
+
const ent = (agg.entities ?? [])[j];
|
|
56
|
+
const entPath = `${aggPath}.entities[${j}]`;
|
|
57
|
+
if (entityNames.has(ent.name)) {
|
|
58
|
+
errors.push({
|
|
59
|
+
code: "E_DUPLICATE_ENTITY_NAME",
|
|
60
|
+
path: `${entPath}.name`,
|
|
61
|
+
message: `Duplicate EntityNode name detected: '${ent.name}'. EntityNode names must be globally unique across the domain.`
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
entityNames.add(ent.name);
|
|
65
|
+
aggEntities.add(ent.name);
|
|
66
|
+
}
|
|
67
|
+
entitiesByAggregate.set(agg.name, aggEntities);
|
|
68
|
+
}
|
|
69
|
+
// Step 3: Validate Invariants per AggregateNode
|
|
70
|
+
for (let i = 0; i < model.aggregates.length; i++) {
|
|
71
|
+
const agg = model.aggregates[i];
|
|
72
|
+
const aggPath = `aggregates[${i}]`;
|
|
73
|
+
// InvariantNode 3.1: Root EntityNode must exist in aggregate's entities
|
|
74
|
+
const aggEntities = entitiesByAggregate.get(agg.name);
|
|
75
|
+
if (!aggEntities?.has(agg.rootEntity)) {
|
|
76
|
+
errors.push({
|
|
77
|
+
code: "E_MISSING_ROOT_ENTITY",
|
|
78
|
+
path: `${aggPath}.rootEntity`,
|
|
79
|
+
message: `AggregateNode '${agg.name}' specifies rootEntity '${agg.rootEntity}', but no entity with that name exists in this aggregate.`
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// InvariantNode 3.2: Non-Anemic Modeling (Must have at least one lifecycle state)
|
|
83
|
+
const effectiveStates = agg.states || [];
|
|
84
|
+
if (effectiveStates.length === 0) {
|
|
85
|
+
errors.push({
|
|
86
|
+
code: "E_STATELESS_AGGREGATE",
|
|
87
|
+
path: `${aggPath}.states`,
|
|
88
|
+
message: `AggregateNode '${agg.name}' has no declared lifecycle states. Non-anemic modeling requires at least one state in 'states'.`
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const stateSet = new Set(effectiveStates);
|
|
92
|
+
// InvariantNode 3.3: Root EntityNode fields and identity check
|
|
93
|
+
const rootEntityObj = (agg.entities ?? []).find((e) => e.name === agg.rootEntity);
|
|
94
|
+
if (rootEntityObj) {
|
|
95
|
+
const hasId = rootEntityObj.fields.some((f) => f.name === "$id" || f.name === `${agg.rootEntity.charAt(0).toLowerCase() + agg.rootEntity.slice(1)}Id` || f.name === "id");
|
|
96
|
+
if (!hasId) {
|
|
97
|
+
warnings.push({
|
|
98
|
+
code: "W_IMPLICIT_ROOT_ID",
|
|
99
|
+
path: `${aggPath}.entities[${agg.rootEntity}].fields`,
|
|
100
|
+
message: `Root EntityNode '${agg.rootEntity}' has no explicit '$id' or '${agg.rootEntity.charAt(0).toLowerCase() + agg.rootEntity.slice(1)}Id' field. Compiler will synthesize '$id'.`
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// InvariantNode 3.4: Foreign Key InvariantNode (E_UNRESOLVED_ENTITY_ID_REF) on EntityNode Fields
|
|
105
|
+
for (let j = 0; j < (agg.entities ?? []).length; j++) {
|
|
106
|
+
const ent = (agg.entities ?? [])[j];
|
|
107
|
+
const entPath = `${aggPath}.entities[${j}]`;
|
|
108
|
+
for (let k = 0; k < ent.fields.length; k++) {
|
|
109
|
+
const field = ent.fields[k];
|
|
110
|
+
const targetEntity = idFieldToEntityName(field.name);
|
|
111
|
+
if (targetEntity) {
|
|
112
|
+
// It's a foreign key reference. Ensure target entity or aggregate exists.
|
|
113
|
+
if (!entityNames.has(targetEntity) && !aggregateNames.has(targetEntity)) {
|
|
114
|
+
errors.push({
|
|
115
|
+
code: "E_UNRESOLVED_ENTITY_ID_REF",
|
|
116
|
+
path: `${entPath}.fields[${k}].name`,
|
|
117
|
+
message: `FieldNode '${field.name}' in entity '${ent.name}' references entity '${targetEntity}', which does not exist in the domain model.`
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// InvariantNode 3.5: CommandNode State Consistency & Parameter Foreign Key Checks
|
|
124
|
+
const commandMap = new Map();
|
|
125
|
+
for (let c = 0; c < (agg.commands ?? []).length; c++) {
|
|
126
|
+
const cmd = (agg.commands ?? [])[c];
|
|
127
|
+
const cmdPath = `${aggPath}.commands[${c}]`;
|
|
128
|
+
commandMap.set(cmd.name, cmd);
|
|
129
|
+
// Creation command check
|
|
130
|
+
const isCreation = cmd.isCreation ?? (cmd.requiredState === "");
|
|
131
|
+
// State check on requiredState
|
|
132
|
+
if (!isCreation && cmd.requiredState !== "") {
|
|
133
|
+
if (!stateSet.has(cmd.requiredState)) {
|
|
134
|
+
errors.push({
|
|
135
|
+
code: "E_INVALID_STATE_TRANSITION",
|
|
136
|
+
path: `${cmdPath}.requiredState`,
|
|
137
|
+
message: `CommandNode '${cmd.name}' requires state '${cmd.requiredState}', which is not declared in 'states' of aggregate '${agg.name}'.`
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// State check on targetState
|
|
142
|
+
if (cmd.targetState && !stateSet.has(cmd.targetState)) {
|
|
143
|
+
errors.push({
|
|
144
|
+
code: "E_INVALID_STATE_TRANSITION",
|
|
145
|
+
path: `${cmdPath}.targetState`,
|
|
146
|
+
message: `CommandNode '${cmd.name}' transitions to targetState '${cmd.targetState}', which is not declared in 'states' of aggregate '${agg.name}'.`
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// Foreign key check on command parameters
|
|
150
|
+
const params = cmd.parameters || cmd.payload || [];
|
|
151
|
+
for (let p = 0; p < params.length; p++) {
|
|
152
|
+
const param = params[p];
|
|
153
|
+
const targetEntity = idFieldToEntityName(param.name);
|
|
154
|
+
if (targetEntity) {
|
|
155
|
+
if (!entityNames.has(targetEntity) && !aggregateNames.has(targetEntity)) {
|
|
156
|
+
errors.push({
|
|
157
|
+
code: "E_UNRESOLVED_ENTITY_ID_REF",
|
|
158
|
+
path: `${cmdPath}.parameters[${p}].name`,
|
|
159
|
+
message: `Parameter '${param.name}' in command '${cmd.name}' references entity '${targetEntity}', which does not exist in the domain model.`
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// InvariantNode 3.6: Explicit TransitionNode Consistency
|
|
166
|
+
const transitions = agg.transitions ?? [];
|
|
167
|
+
for (let t = 0; t < transitions.length; t++) {
|
|
168
|
+
const tr = transitions[t];
|
|
169
|
+
const trPath = `${aggPath}.transitions[${t}]`;
|
|
170
|
+
if (!stateSet.has(tr.fromState)) {
|
|
171
|
+
errors.push({
|
|
172
|
+
code: "E_INVALID_STATE_TRANSITION",
|
|
173
|
+
path: `${trPath}.fromState`,
|
|
174
|
+
message: `TransitionNode '${tr.trigger}' has fromState '${tr.fromState}', which is not in 'states'.`
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (!stateSet.has(tr.toState)) {
|
|
178
|
+
errors.push({
|
|
179
|
+
code: "E_INVALID_STATE_TRANSITION",
|
|
180
|
+
path: `${trPath}.toState`,
|
|
181
|
+
message: `TransitionNode '${tr.trigger}' has toState '${tr.toState}', which is not in 'states'.`
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (!commandMap.has(tr.trigger)) {
|
|
185
|
+
warnings.push({
|
|
186
|
+
code: "W_UNRESOLVED_TRANSITION_TRIGGER",
|
|
187
|
+
path: `${trPath}.trigger`,
|
|
188
|
+
message: `TransitionNode trigger '${tr.trigger}' does not match any declared command in aggregate '${agg.name}'.`
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// InvariantNode 3.7: ReducerDescriptor Integrity
|
|
193
|
+
const reducers = agg.reducers || [];
|
|
194
|
+
const rootEntityFields = new Set(rootEntityObj?.fields.map((f) => f.name) || []);
|
|
195
|
+
for (let r = 0; r < reducers.length; r++) {
|
|
196
|
+
const red = reducers[r];
|
|
197
|
+
const redPath = `${aggPath}.reducers[${r}]`;
|
|
198
|
+
const triggeringCmd = commandMap.get(red.commandName);
|
|
199
|
+
if (!triggeringCmd) {
|
|
200
|
+
errors.push({
|
|
201
|
+
code: "E_INVALID_REDUCER_REF",
|
|
202
|
+
path: `${redPath}.commandName`,
|
|
203
|
+
message: `ReducerDescriptor references unknown command '${red.commandName}' in aggregate '${agg.name}'.`
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (rootEntityObj && !rootEntityFields.has(red.targetField)) {
|
|
207
|
+
errors.push({
|
|
208
|
+
code: "E_INVALID_REDUCER_REF",
|
|
209
|
+
path: `${redPath}.targetField`,
|
|
210
|
+
message: `ReducerDescriptor targetField '${red.targetField}' does not exist on root entity '${agg.rootEntity}'.`
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (triggeringCmd) {
|
|
214
|
+
const cmdParams = triggeringCmd.parameters || triggeringCmd.payload || [];
|
|
215
|
+
const hasParam = cmdParams.some((p) => p.name === red.sourceParameter);
|
|
216
|
+
if (!hasParam) {
|
|
217
|
+
errors.push({
|
|
218
|
+
code: "E_INVALID_REDUCER_REF",
|
|
219
|
+
path: `${redPath}.sourceParameter`,
|
|
220
|
+
message: `ReducerDescriptor sourceParameter '${red.sourceParameter}' not found in parameters of command '${red.commandName}'.`
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
valid: errors.length === 0,
|
|
228
|
+
errors,
|
|
229
|
+
warnings,
|
|
230
|
+
model: errors.length === 0 ? model : undefined
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=admValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admValidator.js","sourceRoot":"","sources":["../src/admValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAA0B,MAAM,aAAa,CAAC;AAqB7E;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAiB;IAC3C,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAwB,EAAE,CAAC;IAEzC,8CAA8C;IAC9C,MAAM,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,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
|
|
1
|
+
import { AstRoot } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Projects a validated AstRoot into a visual Mermaid Domain AggregateNode Map (graph TD).
|
|
4
|
+
* Renders aggregate subgraphs, internal commands/states, entity foreign-key dependencies,
|
|
5
|
+
* and cross-aggregate domain event flow edges.
|
|
6
|
+
*/
|
|
7
|
+
export declare function projectDomainAggregateMap(model: AstRoot): string;
|
|
8
|
+
/**
|
|
9
|
+
* Projects a validated AstRoot into a formal UML Class Diagram (Mermaid classDiagram)
|
|
10
|
+
* with explicit composition (*--) and association (-->) semantics.
|
|
11
|
+
*/
|
|
12
|
+
export declare function projectClassDiagram(model: AstRoot): string;
|
|
13
|
+
/**
|
|
14
|
+
* Projects a validated AstRoot into a formal UML State Machine Diagram (Mermaid stateDiagram-v2)
|
|
15
|
+
* for lifecycle soundness, state reachability, guard evaluation, and command triggers.
|
|
16
|
+
*/
|
|
17
|
+
export declare function projectStateMachineDiagram(model: AstRoot): string;
|
|
18
|
+
/**
|
|
19
|
+
* Projects a validated AstRoot into Simon Brown's C4 Model Level 1 (System Context Diagram)
|
|
20
|
+
* using Mermaid's native C4Context syntax with explicit integration transport protocols.
|
|
21
|
+
*/
|
|
22
|
+
export declare function projectSystemContextDiagram(model: AstRoot): string;
|
|
23
|
+
//# sourceMappingURL=contractProjector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractProjector.d.ts","sourceRoot":"","sources":["../src/contractProjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAyFhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA8C1D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAoCjE;AAWD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgGlE"}
|