@bleedingdev/modern-js-code-tools 3.9.0-ultramodern.3 → 3.9.0-ultramodern.5

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