@bleedingdev/modern-js-code-tools 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21

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.
Files changed (42) hide show
  1. package/bin/modern-api-check-files.mjs +7 -0
  2. package/bin/modern-api-check.mjs +4 -0
  3. package/bin/modern-i18n-check.mjs +4 -0
  4. package/dist/cjs/cli/microvertical-api-check.cjs +100 -0
  5. package/dist/cjs/cli/oxlint.cjs +9 -5
  6. package/dist/cjs/cli/workspace-source-check.cjs +90 -17
  7. package/dist/cjs/microvertical-api-baseline.cjs +505 -0
  8. package/dist/cjs/microvertical-api-boundary.cjs +586 -0
  9. package/dist/cjs/microvertical-api-owner.cjs +217 -0
  10. package/dist/cjs/module-graph.cjs +321 -0
  11. package/dist/cjs/oxlint-plugin/rules/strict-effect-api-boundaries.cjs +8 -6
  12. package/dist/cjs/source-analysis.cjs +104 -0
  13. package/dist/cjs/strict-effect-runtime.cjs +376 -0
  14. package/dist/esm/cli/microvertical-api-check.js +52 -0
  15. package/dist/esm/cli/oxlint.js +10 -6
  16. package/dist/esm/cli/workspace-source-check.js +86 -13
  17. package/dist/esm/microvertical-api-baseline.js +464 -0
  18. package/dist/esm/microvertical-api-boundary.js +525 -0
  19. package/dist/esm/microvertical-api-owner.js +162 -0
  20. package/dist/esm/module-graph.js +260 -0
  21. package/dist/esm/oxlint-plugin/rules/strict-effect-api-boundaries.js +8 -6
  22. package/dist/esm/source-analysis.js +44 -0
  23. package/dist/esm/strict-effect-runtime.js +324 -0
  24. package/dist/esm-node/cli/microvertical-api-check.js +53 -0
  25. package/dist/esm-node/cli/oxlint.js +10 -6
  26. package/dist/esm-node/cli/workspace-source-check.js +86 -13
  27. package/dist/esm-node/microvertical-api-baseline.js +465 -0
  28. package/dist/esm-node/microvertical-api-boundary.js +526 -0
  29. package/dist/esm-node/microvertical-api-owner.js +163 -0
  30. package/dist/esm-node/module-graph.js +261 -0
  31. package/dist/esm-node/oxlint-plugin/rules/strict-effect-api-boundaries.js +8 -6
  32. package/dist/esm-node/source-analysis.js +45 -0
  33. package/dist/esm-node/strict-effect-runtime.js +325 -0
  34. package/dist/types/cli/microvertical-api-check.d.ts +1 -0
  35. package/dist/types/cli/workspace-source-check.d.ts +1 -1
  36. package/dist/types/microvertical-api-baseline.d.ts +23 -0
  37. package/dist/types/microvertical-api-boundary.d.ts +46 -0
  38. package/dist/types/microvertical-api-owner.d.ts +6 -0
  39. package/dist/types/module-graph.d.ts +52 -0
  40. package/dist/types/source-analysis.d.ts +10 -0
  41. package/dist/types/strict-effect-runtime.d.ts +10 -0
  42. package/package.json +29 -6
@@ -0,0 +1,505 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ configuredMicroVerticalApiStem: ()=>configuredMicroVerticalApiStem,
32
+ microVerticalApiBaselineViolation: ()=>microVerticalApiBaselineViolation
33
+ });
34
+ const types_namespaceObject = require("@babel/types");
35
+ const external_microvertical_api_owner_cjs_namespaceObject = require("./microvertical-api-owner.cjs");
36
+ const external_module_graph_cjs_namespaceObject = require("./module-graph.cjs");
37
+ const external_source_analysis_cjs_namespaceObject = require("./source-analysis.cjs");
38
+ const camelCaseStem = (stem)=>stem.replaceAll(/-([a-z0-9])/gu, (_match, letter)=>letter.toUpperCase());
39
+ const pascalCaseStem = (stem)=>{
40
+ const camelStem = camelCaseStem(stem);
41
+ return `${camelStem.slice(0, 1).toUpperCase()}${camelStem.slice(1)}`;
42
+ };
43
+ const identifierName = (node)=>void 0 !== node && types_namespaceObject.isIdentifier(node) ? node.name : void 0;
44
+ const accessPath = (node)=>{
45
+ if (types_namespaceObject.isIdentifier(node)) return [
46
+ node.name
47
+ ];
48
+ if (types_namespaceObject.isMemberExpression(node) && !node.computed && types_namespaceObject.isIdentifier(node.property)) {
49
+ const parent = accessPath(node.object);
50
+ return void 0 === parent ? void 0 : [
51
+ ...parent,
52
+ node.property.name
53
+ ];
54
+ }
55
+ };
56
+ const isAccessPath = (node, expected)=>accessPath(node)?.join('.') === expected.join('.');
57
+ const stringLiteral = (expression)=>{
58
+ if (null == expression) return;
59
+ const unwrapped = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
60
+ return types_namespaceObject.isStringLiteral(unwrapped) ? unwrapped.value : void 0;
61
+ };
62
+ const numericLiteral = (expression)=>{
63
+ if (null == expression) return;
64
+ const unwrapped = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
65
+ return types_namespaceObject.isNumericLiteral(unwrapped) ? Number(unwrapped.value) : void 0;
66
+ };
67
+ const callExpression = (expression, callee)=>{
68
+ if (null == expression) return;
69
+ const unwrapped = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
70
+ return types_namespaceObject.isCallExpression(unwrapped) && isAccessPath(unwrapped.callee, callee) ? unwrapped : void 0;
71
+ };
72
+ const objectLiteral = (expression)=>{
73
+ if (null == expression) return;
74
+ const unwrapped = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
75
+ return types_namespaceObject.isObjectExpression(unwrapped) ? unwrapped : void 0;
76
+ };
77
+ const propertyAssignments = (properties)=>{
78
+ const assignments = new Map();
79
+ for (const property of properties){
80
+ if (!types_namespaceObject.isObjectProperty(property) || property.computed || property.shorthand) return;
81
+ const name = (0, external_module_graph_cjs_namespaceObject.propertyName)(property.key);
82
+ if (void 0 === name || assignments.has(name)) return;
83
+ assignments.set(name, property);
84
+ }
85
+ return assignments;
86
+ };
87
+ const exactCall = (expression, callee, argumentCount)=>{
88
+ const call = callExpression(expression, callee);
89
+ return call?.arguments.length === argumentCount ? call : void 0;
90
+ };
91
+ const sharedSchemaObject = (declaration, sharedSchemaName, protectedFields)=>{
92
+ if (declaration?.init == null) return;
93
+ const initializer = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(declaration.init);
94
+ if (types_namespaceObject.isIdentifier(initializer) && initializer.name === sharedSchemaName) return {
95
+ assignments: new Map(),
96
+ identity: true
97
+ };
98
+ const struct = exactCall(initializer, [
99
+ 'Schema',
100
+ 'Struct'
101
+ ], 1);
102
+ const schemaObject = objectLiteral(struct?.arguments[0]);
103
+ if (void 0 === schemaObject) return;
104
+ const spreads = schemaObject.properties.filter(types_namespaceObject.isSpreadElement);
105
+ const assignments = propertyAssignments(schemaObject.properties.filter((property)=>!types_namespaceObject.isSpreadElement(property)));
106
+ if (1 !== spreads.length || !spreads.every((spread)=>isAccessPath(spread.argument, [
107
+ sharedSchemaName,
108
+ 'fields'
109
+ ])) || void 0 === assignments || protectedFields.some((field)=>assignments.has(field))) return;
110
+ return {
111
+ assignments,
112
+ identity: false
113
+ };
114
+ };
115
+ const directCallChain = (expression)=>{
116
+ if (null == expression) return;
117
+ let current = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
118
+ const methods = [];
119
+ while(types_namespaceObject.isCallExpression(current) && types_namespaceObject.isMemberExpression(current.callee) && !current.callee.computed && types_namespaceObject.isIdentifier(current.callee.property) && !types_namespaceObject.isIdentifier(current.callee.object)){
120
+ methods.unshift({
121
+ arguments: current.arguments,
122
+ name: current.callee.property.name
123
+ });
124
+ current = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(current.callee.object);
125
+ }
126
+ if (!types_namespaceObject.isCallExpression(current)) return;
127
+ return {
128
+ base: current,
129
+ methods
130
+ };
131
+ };
132
+ const brandedStringSchemaIsExact = (declaration, brand)=>{
133
+ const initializer = declaration?.init;
134
+ if (null == initializer) return false;
135
+ const pipeCall = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(initializer);
136
+ if (!types_namespaceObject.isCallExpression(pipeCall) || !types_namespaceObject.isMemberExpression(pipeCall.callee) || pipeCall.callee.computed || !types_namespaceObject.isIdentifier(pipeCall.callee.property, {
137
+ name: 'pipe'
138
+ }) || !isAccessPath(pipeCall.callee.object, [
139
+ 'Schema',
140
+ 'String'
141
+ ]) || 1 !== pipeCall.arguments.length) return false;
142
+ const brandCall = exactCall(pipeCall.arguments[0], [
143
+ 'Schema',
144
+ 'brand'
145
+ ], 1);
146
+ return stringLiteral(brandCall?.arguments[0]) === brand;
147
+ };
148
+ const importedRuntimeNames = (statement, expectedPackage)=>{
149
+ if (!types_namespaceObject.isImportDeclaration(statement) || statement.source.value !== expectedPackage || 'type' === statement.importKind) return [];
150
+ return statement.specifiers.flatMap((value)=>types_namespaceObject.isImportSpecifier(value) && 'type' !== value.importKind && types_namespaceObject.isIdentifier(value.imported) && value.imported.name === value.local.name ? [
151
+ value.local.name
152
+ ] : []);
153
+ };
154
+ const importsExactBindings = (sourceFile, expectedPackage, expectedBindings)=>{
155
+ const names = new Set(sourceFile.program.body.flatMap((statement)=>importedRuntimeNames(statement, expectedPackage)));
156
+ return expectedBindings.every((name)=>names.has(name));
157
+ };
158
+ const baselineBindings = [
159
+ 'MicroVerticalBuildMarkerSchema',
160
+ 'MicroVerticalReadinessSchema',
161
+ 'createMicroVerticalOperationContext'
162
+ ];
163
+ const importsSharedBaselinePrimitives = (sourceFile, expectedPackage)=>importsExactBindings(sourceFile, expectedPackage, baselineBindings);
164
+ const singleAddedArgument = (expression, factory, names)=>{
165
+ const chain = directCallChain(expression);
166
+ if (void 0 === chain || !isAccessPath(chain.base.callee, factory)) return;
167
+ const [method] = chain.methods;
168
+ if (1 !== chain.base.arguments.length || !names.includes(stringLiteral(chain.base.arguments[0]) ?? '') || 1 !== chain.methods.length || method?.name !== 'add' || 1 !== method.arguments.length) return;
169
+ return method.arguments[0];
170
+ };
171
+ const rootGroupExpression = (graph, expression)=>{
172
+ if (void 0 === expression) return;
173
+ const node = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
174
+ if (!types_namespaceObject.isIdentifier(node)) return node;
175
+ const resolved = graph.resolve(graph.root, node.name, 'local');
176
+ return resolved?.kind === 'declaration' && resolved.module === graph.root ? (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(resolved.expression) : void 0;
177
+ };
178
+ const foundationGroup = (graph, declaration, stem, readinessSchemaName)=>{
179
+ const group = rootGroupExpression(graph, singleAddedArgument(declaration?.init, [
180
+ 'HttpApi',
181
+ 'make'
182
+ ], [
183
+ `${pascalCaseStem(stem)}FoundationApi`,
184
+ `${pascalCaseStem(stem)}ApiFoundation`
185
+ ]));
186
+ const endpointExpression = singleAddedArgument(group, [
187
+ 'HttpApiGroup',
188
+ 'make'
189
+ ], [
190
+ 'foundation'
191
+ ]);
192
+ const endpoint = exactCall(endpointExpression, [
193
+ 'HttpApiEndpoint',
194
+ 'get'
195
+ ], 3);
196
+ const endpointOptions = objectLiteral(endpoint?.arguments[2]);
197
+ const endpointProperties = void 0 === endpointOptions ? void 0 : propertyAssignments(endpointOptions.properties);
198
+ return void 0 !== endpoint && 'readiness' === stringLiteral(endpoint.arguments[0]) && stringLiteral(endpoint.arguments[1]) === `/${stem}/readiness` && endpointProperties?.size === 1 && identifierName(endpointProperties.get('success')?.value) === readinessSchemaName ? group : void 0;
199
+ };
200
+ const rootComposesFoundation = (graph, declaration, stem, foundationName, foundation)=>{
201
+ const sourceFile = graph.root.file;
202
+ const chain = directCallChain(declaration?.init);
203
+ const first = chain?.methods[0];
204
+ const firstArgument = first?.arguments[0];
205
+ return void 0 !== chain && isAccessPath(chain.base.callee, [
206
+ 'HttpApi',
207
+ 'make'
208
+ ]) && 1 === chain.base.arguments.length && stringLiteral(chain.base.arguments[0]) === `${pascalCaseStem(stem)}Api` && chain.methods.length > 0 && chain.methods.every((method, index)=>{
209
+ const combinatorArity = nonEndpointCombinators.api[method.name];
210
+ if (void 0 !== combinatorArity) return method.arguments.length === combinatorArity;
211
+ if ('add' === method.name) return method.arguments.length > 0;
212
+ return 1 === method.arguments.length && ('addHttpApi' === method.name || index === chain.methods.length - 1 && 'pipe' === method.name && 'identity' === identifierName(method.arguments[0]) && importsExactBindings(sourceFile, 'effect', [
213
+ 'identity'
214
+ ]));
215
+ }) && void 0 !== firstArgument && (first?.name === 'addHttpApi' && identifierName(firstArgument) === foundationName || first?.name === 'add' && types_namespaceObject.isIdentifier(firstArgument) && rootGroupExpression(graph, firstArgument) === foundation);
216
+ };
217
+ const nonEndpointCombinators = {
218
+ api: {
219
+ annotate: 2,
220
+ annotateMerge: 1,
221
+ middleware: 1
222
+ },
223
+ group: {
224
+ annotate: 2,
225
+ annotateEndpoints: 2,
226
+ annotateEndpointsMerge: 1,
227
+ annotateMerge: 1,
228
+ middleware: 1
229
+ }
230
+ };
231
+ const reachableEndpoints = (graph, declaration)=>{
232
+ const active = new Set();
233
+ const endpoints = [];
234
+ const identities = new Set();
235
+ const verbs = {
236
+ get: 'GET',
237
+ post: 'POST',
238
+ put: 'PUT',
239
+ patch: 'PATCH',
240
+ del: 'DELETE',
241
+ delete: 'DELETE',
242
+ head: 'HEAD',
243
+ options: 'OPTIONS'
244
+ };
245
+ let visits = 0;
246
+ const visit = (expression, module, kind, group = '')=>{
247
+ if (!expression) return false;
248
+ const node = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(expression);
249
+ if (active.has(node) || active.size >= 128 || ++visits > 2048) return false;
250
+ active.add(node);
251
+ try {
252
+ if (types_namespaceObject.isIdentifier(node)) {
253
+ const resolved = graph.resolve(module, node.name, 'local');
254
+ return resolved?.kind === 'declaration' && visit(resolved.expression, resolved.module, kind, group);
255
+ }
256
+ if ('endpoint' === kind) {
257
+ if (!types_namespaceObject.isCallExpression(node) || node.arguments.length < 2 || node.arguments.length > 3) return false;
258
+ const callee = accessPath(node.callee);
259
+ const method = callee?.length === 2 && 'HttpApiEndpoint' === callee[0] ? verbs[callee[1]] : void 0;
260
+ const name = stringLiteral(node.arguments[0]);
261
+ const routePath = stringLiteral(node.arguments[1]);
262
+ if (!method || !name || !routePath) return false;
263
+ const identity = `${group}:${name}`;
264
+ if (identities.has(identity)) return false;
265
+ identities.add(identity);
266
+ endpoints.push({
267
+ group,
268
+ name,
269
+ method,
270
+ routePath
271
+ });
272
+ return true;
273
+ }
274
+ const chain = directCallChain(node);
275
+ if (!chain || !isAccessPath(chain.base.callee, [
276
+ 'api' === kind ? 'HttpApi' : 'HttpApiGroup',
277
+ 'make'
278
+ ]) || 1 !== chain.base.arguments.length) return false;
279
+ const name = stringLiteral(chain.base.arguments[0]);
280
+ if (!name) return false;
281
+ const chainStart = endpoints.length;
282
+ const combinators = nonEndpointCombinators[kind];
283
+ return chain.methods.every((method)=>{
284
+ if ('prefix' === method.name) {
285
+ const prefix = stringLiteral(method.arguments[0]);
286
+ if (1 !== method.arguments.length || !prefix?.startsWith('/')) return false;
287
+ for(let index = chainStart; index < endpoints.length; index += 1){
288
+ const endpoint = endpoints[index];
289
+ endpoints[index] = {
290
+ ...endpoint,
291
+ routePath: `${prefix}${endpoint.routePath}`
292
+ };
293
+ }
294
+ return true;
295
+ }
296
+ const combinatorArity = combinators[method.name];
297
+ if (void 0 !== combinatorArity) return method.arguments.length === combinatorArity;
298
+ if ('add' === method.name) return method.arguments.length > 0 && method.arguments.every((argument)=>visitAdded(argument, module, 'api' === kind ? 'group' : 'endpoint', 'group' === kind ? name : ''));
299
+ if (1 !== method.arguments.length) return false;
300
+ if ('pipe' === method.name) return 'identity' === identifierName(method.arguments[0]) && importsExactBindings(module.file, 'effect', [
301
+ 'identity'
302
+ ]);
303
+ return 'api' === kind && 'addHttpApi' === method.name && visit(method.arguments[0], module, 'api');
304
+ });
305
+ } finally{
306
+ active.delete(node);
307
+ }
308
+ };
309
+ const visitAdded = (argument, module, kind, group)=>{
310
+ if (!types_namespaceObject.isSpreadElement(argument)) return visit(argument, module, kind, group);
311
+ let node = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(argument.argument);
312
+ let owner = module;
313
+ if (types_namespaceObject.isIdentifier(node)) {
314
+ const resolved = graph.resolve(module, node.name, 'local');
315
+ if (resolved?.kind !== 'declaration') return false;
316
+ node = (0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(resolved.expression);
317
+ owner = resolved.module;
318
+ }
319
+ if (!types_namespaceObject.isArrayExpression(node) || active.has(node) || ++visits > 2048) return false;
320
+ active.add(node);
321
+ try {
322
+ return node.elements.every((element)=>null !== element && visitAdded(element, owner, kind, group));
323
+ } finally{
324
+ active.delete(node);
325
+ }
326
+ };
327
+ return visit(declaration?.init, graph.root, 'api') ? endpoints : void 0;
328
+ };
329
+ const operationContextFields = (property)=>{
330
+ const constructorCall = exactCall(property.value, [
331
+ 'createMicroVerticalOperationContext'
332
+ ], 1);
333
+ const input = objectLiteral(constructorCall?.arguments[0]);
334
+ return void 0 === input ? void 0 : propertyAssignments(input.properties);
335
+ };
336
+ const operationContextIdentity = (property)=>{
337
+ const fields = operationContextFields(property);
338
+ const method = stringLiteral(fields?.get('method')?.value);
339
+ const operationId = stringLiteral(fields?.get('operationId')?.value);
340
+ const routePath = stringLiteral(fields?.get('routePath')?.value);
341
+ if (fields?.size !== 3 || void 0 === method || void 0 === operationId || void 0 === routePath) return;
342
+ return {
343
+ method,
344
+ operationId,
345
+ routePath
346
+ };
347
+ };
348
+ const operationContextIsConstructed = (property, stem, propertyKey, operationPaths, endpoints)=>{
349
+ const identity = operationContextIdentity(property);
350
+ if (void 0 === identity) return false;
351
+ const { method, operationId, routePath } = identity;
352
+ if (!/^[A-Z]+$/u.test(method) || !/^\/(?!.*(?:^|\/)\.\.?\/)[^\s?#]*$/u.test(routePath)) return false;
353
+ const apiName = `${pascalCaseStem(stem)}Api`;
354
+ if ('readiness' === propertyKey && ('GET' !== method || routePath !== `/${stem}/readiness`)) return false;
355
+ return operationId === `${apiName}:${routePath}` || operationPaths[operationId] === routePath || endpoints.some((endpoint)=>endpoint.name === propertyKey && endpoint.method === method && endpoint.routePath === routePath && (operationId === `${apiName}:${endpoint.group}:${propertyKey}` || 'readiness' === propertyKey && operationId === `${apiName}:${camelCaseStem(stem)}:readiness`));
356
+ };
357
+ const operationMapIsConnected = (declaration, stem, operationPaths, endpoints)=>{
358
+ const map = objectLiteral(declaration?.init);
359
+ const properties = void 0 === map ? void 0 : propertyAssignments(map.properties);
360
+ return void 0 !== properties && properties.has('readiness') && [
361
+ ...properties
362
+ ].every(([key, property])=>operationContextIsConstructed(property, stem, key, operationPaths, endpoints));
363
+ };
364
+ const constAssertionObject = (declaration)=>{
365
+ const initializer = declaration?.init;
366
+ if (null == initializer || !types_namespaceObject.isTSAsExpression(initializer) || !types_namespaceObject.isTSTypeReference(initializer.typeAnnotation) || !types_namespaceObject.isIdentifier(initializer.typeAnnotation.typeName, {
367
+ name: 'const'
368
+ })) return;
369
+ return objectLiteral(initializer.expression);
370
+ };
371
+ const metadataIsExact = (declaration, expectation, endpoints)=>{
372
+ const object = constAssertionObject(declaration);
373
+ const fields = void 0 === object ? void 0 : propertyAssignments(object.properties);
374
+ const expectedFields = [
375
+ [
376
+ 'apiPrefix',
377
+ expectation.apiPrefix
378
+ ],
379
+ [
380
+ 'basePath',
381
+ expectation.basePath
382
+ ],
383
+ [
384
+ 'ownerId',
385
+ expectation.ownerId
386
+ ],
387
+ [
388
+ 'readinessPath',
389
+ expectation.readinessPath
390
+ ]
391
+ ];
392
+ if (!fields || !expectedFields.every(([field, value])=>stringLiteral(fields.get(field)?.value) === value)) return false;
393
+ const common = new Set(expectedFields.map(([field])=>field));
394
+ return [
395
+ ...fields
396
+ ].every(([field, property])=>{
397
+ if (common.has(field)) return true;
398
+ const value = stringLiteral(property.value);
399
+ if (void 0 === value) return false;
400
+ const explicit = expectation.additionalPaths[field];
401
+ if (void 0 !== explicit) return value === explicit;
402
+ if (!value.startsWith(`${expectation.apiPrefix}/`) || /[\s?#]/u.test(value) || value.split('/').some((segment)=>'.' === segment || '..' === segment)) return false;
403
+ return endpoints.some((endpoint)=>{
404
+ const route = `${expectation.apiPrefix}${endpoint.routePath}`;
405
+ return route === value || route.startsWith(`${value}/`);
406
+ });
407
+ });
408
+ };
409
+ const markerSchemaIsShared = (sourceFile, declaration)=>{
410
+ const schema = sharedSchemaObject(declaration, 'MicroVerticalBuildMarkerSchema', [
411
+ 'build',
412
+ 'buildMarker',
413
+ 'deployProfile',
414
+ 'packageName',
415
+ 'sourceRevision',
416
+ 'surface',
417
+ 'version'
418
+ ]);
419
+ if (void 0 === schema || schema.identity) return schema?.identity === true;
420
+ const brandedField = (property, brand)=>identifierName(property.value) === `${brand}Schema` && brandedStringSchemaIsExact((0, external_module_graph_cjs_namespaceObject.localConst)(sourceFile, `${brand}Schema`), brand);
421
+ const validators = new Map([
422
+ [
423
+ 'appId',
424
+ (property)=>brandedField(property, 'AppId')
425
+ ],
426
+ [
427
+ 'unitId',
428
+ (property)=>brandedField(property, 'UnitId')
429
+ ],
430
+ [
431
+ 'kind',
432
+ (property)=>'microvertical-delivery-unit' === stringLiteral(exactCall(property.value, [
433
+ 'Schema',
434
+ 'Literal'
435
+ ], 1)?.arguments[0])
436
+ ],
437
+ [
438
+ 'schemaVersion',
439
+ (property)=>1 === numericLiteral(exactCall(property.value, [
440
+ 'Schema',
441
+ 'Literal'
442
+ ], 1)?.arguments[0])
443
+ ]
444
+ ]);
445
+ return [
446
+ ...schema.assignments
447
+ ].every(([field, property])=>validators.get(field)?.(property) === true);
448
+ };
449
+ const readinessSchemaIsShared = (declaration, markerSchemaName, ownerMarkerIsIdentity)=>{
450
+ const schema = sharedSchemaObject(declaration, 'MicroVerticalReadinessSchema', [
451
+ 'checks',
452
+ 'status',
453
+ 'versionSkew'
454
+ ]);
455
+ return void 0 !== schema && (schema.identity && ownerMarkerIsIdentity || 1 === schema.assignments.size && identifierName(schema.assignments.get('marker')?.value) === markerSchemaName);
456
+ };
457
+ const declarationIsIdentifier = (declaration, identifier)=>declaration?.init != null && identifierName((0, external_source_analysis_cjs_namespaceObject.unwrapExpression)(declaration.init)) === identifier;
458
+ const validateParsedContract = (graph, stem, expectation)=>{
459
+ const sourceFile = graph.root.file;
460
+ const exportStem = camelCaseStem(stem);
461
+ const foundationName = `${exportStem}FoundationApi`;
462
+ const markerSchemaName = `${exportStem}MarkerSchema`;
463
+ const readinessSchemaName = `${exportStem}ReadinessSchema`;
464
+ const markerDeclaration = (0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, markerSchemaName);
465
+ if (!importsExactBindings(sourceFile, expectation.effectClientPackage, [
466
+ 'HttpApi',
467
+ 'HttpApiEndpoint',
468
+ 'HttpApiGroup',
469
+ 'Schema'
470
+ ])) return 'MicroVertical root contract must import exact Effect API primitives from the framework client package';
471
+ if (!importsSharedBaselinePrimitives(sourceFile, expectation.baselinePackage)) return 'MicroVertical root contract must import exact baseline primitives from the framework baseline package';
472
+ if (!markerSchemaIsShared(sourceFile, markerDeclaration)) return 'MicroVertical root contract must consume the shared build marker schema without overriding shared fields';
473
+ if (!readinessSchemaIsShared((0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, readinessSchemaName), markerSchemaName, declarationIsIdentifier(markerDeclaration, 'MicroVerticalBuildMarkerSchema'))) return 'MicroVertical readiness schema must consume the shared readiness schema without overriding shared fields';
474
+ const foundation = foundationGroup(graph, (0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, foundationName), stem, readinessSchemaName);
475
+ if (void 0 === foundation) return 'MicroVertical readiness foundation API must directly compose its exact readiness endpoint and foundation identity';
476
+ if (!rootComposesFoundation(graph, (0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, `${exportStem}Api`), stem, foundationName, foundation)) return 'MicroVertical root API must explicitly compose its readiness foundation API';
477
+ const endpoints = reachableEndpoints(graph, (0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, `${exportStem}Api`));
478
+ if (!endpoints) return 'MicroVertical root API must compose bounded native endpoint declarations without ambiguous identities';
479
+ if (!operationMapIsConnected((0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, `${exportStem}OperationContexts`), stem, expectation.operationPaths ?? {}, endpoints)) return 'MicroVertical operation map must construct every operation with the shared context constructor';
480
+ if (!metadataIsExact((0, external_module_graph_cjs_namespaceObject.exportedConst)(sourceFile, `${exportStem}ApiContract`), expectation, endpoints)) return 'MicroVertical root contract must keep exact owner and API path metadata without forbidden fields';
481
+ };
482
+ const configuredMicroVerticalApiStem = (verticalPath, verticals)=>{
483
+ const topologyVertical = verticals.find((vertical)=>(vertical.path ?? `verticals/${vertical.id}`) === verticalPath);
484
+ const endpoint = topologyVertical?.api?.readiness?.endpoint;
485
+ return endpoint?.match(/^\/([a-z0-9]+(?:-[a-z0-9]+)*)\/readiness$/u)?.[1];
486
+ };
487
+ const microVerticalApiBaselineViolation = (stem, filePath, expectation)=>{
488
+ try {
489
+ const graph = (0, external_module_graph_cjs_namespaceObject.createModuleGraph)(filePath);
490
+ if (!(0, external_microvertical_api_owner_cjs_namespaceObject.baselinePublicIdentityIsExact)(filePath, expectation)) return 'MicroVertical baseline imports must resolve the exact framework owner public export and schema identity';
491
+ return validateParsedContract(graph, stem, expectation);
492
+ } catch (error) {
493
+ if (error instanceof external_source_analysis_cjs_namespaceObject.SourceSyntaxError) return `MicroVertical root contract must be valid TypeScript syntax (${error.message})`;
494
+ throw error;
495
+ }
496
+ };
497
+ exports.configuredMicroVerticalApiStem = __webpack_exports__.configuredMicroVerticalApiStem;
498
+ exports.microVerticalApiBaselineViolation = __webpack_exports__.microVerticalApiBaselineViolation;
499
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
500
+ "configuredMicroVerticalApiStem",
501
+ "microVerticalApiBaselineViolation"
502
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
503
+ Object.defineProperty(exports, '__esModule', {
504
+ value: true
505
+ });