@webpieces/nx-webpieces-rules 0.4.865 → 0.4.867

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 (59) hide show
  1. package/package.json +7 -7
  2. package/src/configs/wiring-format-config.d.ts +7 -0
  3. package/src/configs/wiring-format-config.js +14 -0
  4. package/src/configs/wiring-format-config.js.map +1 -0
  5. package/src/executors/generate/executor.d.ts +11 -0
  6. package/src/executors/generate/executor.js +49 -42
  7. package/src/executors/generate/executor.js.map +1 -1
  8. package/src/executors/validate-architecture-unchanged/executor.js +0 -2
  9. package/src/executors/validate-architecture-unchanged/executor.js.map +1 -1
  10. package/src/index.d.ts +1 -0
  11. package/src/index.js +3 -1
  12. package/src/index.js.map +1 -1
  13. package/src/lib/di-graph/angular-providers.js +67 -39
  14. package/src/lib/di-graph/angular-providers.js.map +1 -1
  15. package/src/lib/di-graph/runtime-client-bindings.d.ts +1 -0
  16. package/src/lib/di-graph/runtime-client-bindings.js +10 -0
  17. package/src/lib/di-graph/runtime-client-bindings.js.map +1 -1
  18. package/src/lib/runtime-wiring/approved-graph.js +1 -2
  19. package/src/lib/runtime-wiring/approved-graph.js.map +1 -1
  20. package/src/lib/runtime-wiring/assembler.d.ts +2 -1
  21. package/src/lib/runtime-wiring/assembler.js +38 -18
  22. package/src/lib/runtime-wiring/assembler.js.map +1 -1
  23. package/src/lib/runtime-wiring/canonical-clients.d.ts +1 -8
  24. package/src/lib/runtime-wiring/canonical-clients.js +6 -45
  25. package/src/lib/runtime-wiring/canonical-clients.js.map +1 -1
  26. package/src/lib/runtime-wiring/codec.js +29 -9
  27. package/src/lib/runtime-wiring/codec.js.map +1 -1
  28. package/src/lib/runtime-wiring/declaration.d.ts +11 -6
  29. package/src/lib/runtime-wiring/declaration.js +8 -4
  30. package/src/lib/runtime-wiring/declaration.js.map +1 -1
  31. package/src/lib/runtime-wiring/prepared-targets.d.ts +11 -0
  32. package/src/lib/runtime-wiring/prepared-targets.js +82 -0
  33. package/src/lib/runtime-wiring/prepared-targets.js.map +1 -0
  34. package/src/lib/runtime-wiring/source-extractor.d.ts +4 -3
  35. package/src/lib/runtime-wiring/source-extractor.js +77 -118
  36. package/src/lib/runtime-wiring/source-extractor.js.map +1 -1
  37. package/src/lib/runtime-wiring/source-types.d.ts +13 -0
  38. package/src/lib/runtime-wiring/source-types.js +75 -0
  39. package/src/lib/runtime-wiring/source-types.js.map +1 -0
  40. package/src/lib/runtime-wiring/source-values.d.ts +4 -2
  41. package/src/lib/runtime-wiring/source-values.js +86 -35
  42. package/src/lib/runtime-wiring/source-values.js.map +1 -1
  43. package/src/lib/runtime-wiring/wiring-format.d.ts +15 -0
  44. package/src/lib/runtime-wiring/wiring-format.js +160 -0
  45. package/src/lib/runtime-wiring/wiring-format.js.map +1 -0
  46. package/src/lib/runtime-wiring/workspace-format.d.ts +6 -0
  47. package/src/lib/runtime-wiring/workspace-format.js +39 -0
  48. package/src/lib/runtime-wiring/workspace-format.js.map +1 -0
  49. package/src/native-actions.d.ts +1 -0
  50. package/src/native-actions.js +6 -0
  51. package/src/native-actions.js.map +1 -1
  52. package/src/nx-policy-registry.js +2 -0
  53. package/src/nx-policy-registry.js.map +1 -1
  54. package/src/rule-help.js +2 -1
  55. package/src/rule-help.js.map +1 -1
  56. package/src/rule-settings.js +7 -0
  57. package/src/rule-settings.js.map +1 -1
  58. package/src/runtime-wiring-targets.js +2 -0
  59. package/src/runtime-wiring-targets.js.map +1 -1
@@ -6,6 +6,8 @@ const path = tslib_1.__importStar(require("path"));
6
6
  const ts = tslib_1.__importStar(require("typescript"));
7
7
  const rules_config_1 = require("@webpieces/rules-config");
8
8
  const declaration_1 = require("./declaration");
9
+ const prepared_targets_1 = require("./prepared-targets");
10
+ const source_types_1 = require("./source-types");
9
11
  /** Resolves imported symbols and bounded literal expressions without invoking application code. */
10
12
  class WiringSourceValues {
11
13
  workspaceRoot;
@@ -47,23 +49,21 @@ class WiringSourceValues {
47
49
  const value = expression;
48
50
  if (ts.isStringLiteralLike(value))
49
51
  return { kind: 'service', service: value.text };
50
- if (ts.isCallExpression(value) && this.symbolName(value.expression) === 'rpcTarget') {
51
- const target = this.target(value.arguments[1], depth + 1);
52
- if (target.kind !== 'service')
53
- this.fail('rpcTarget requires a literal deployment identity.');
54
- return { ...target, contract: this.identity(value.arguments[0]) };
55
- }
56
- if (ts.isNewExpression(value) &&
57
- ['RpcTarget', 'ClientConfig', 'TaskClientConfig'].includes(this.symbolName(value.expression)))
58
- return this.target(value.arguments?.[this.symbolName(value.expression) === 'RpcTarget' ? 1 : 0], depth + 1);
52
+ if (ts.isNewExpression(value) && ['ClientConfig', 'TaskClientConfig'].includes(this.symbolName(value.expression)))
53
+ return this.target(value.arguments?.[0], depth + 1);
59
54
  const declaration = this.symbol(value)?.declarations?.[0];
60
55
  if (declaration !== undefined && ts.isVariableDeclaration(declaration))
61
56
  return this.target(declaration.initializer, depth + 1);
62
57
  if (declaration !== undefined && ts.isPropertyAssignment(declaration))
63
58
  return this.target(declaration.initializer, depth + 1);
64
59
  if (declaration !== undefined && ts.isParameter(declaration))
65
- return { kind: 'parameter', parameter: declaration.name.getText() };
66
- this.fail(`Unsupported target ${value.getText()}; use a literal service, rpcTarget, or an explicit typed target parameter.`);
60
+ return { kind: 'parameter', parameter: this.parameterPath(value) };
61
+ if (ts.isPropertyAccessExpression(value)) {
62
+ const type = this.checker.getTypeAtLocation(value);
63
+ if ((type.flags & ts.TypeFlags.StringLike) !== 0)
64
+ return { kind: 'parameter', parameter: this.parameterPath(value) };
65
+ }
66
+ this.fail(`Unsupported target ${value.getText()}; use a literal service or a prepared constructor field.`);
67
67
  }
68
68
  transport(expression) {
69
69
  const declaration = this.symbol(expression)?.declarations?.[0];
@@ -80,14 +80,21 @@ class WiringSourceValues {
80
80
  arguments(invocation) {
81
81
  const targets = {};
82
82
  const signature = this.checker.getResolvedSignature(invocation);
83
- for (const [index, parameter] of (signature?.getParameters() ?? []).entries()) {
84
- const declaration = parameter.valueDeclaration;
85
- if (declaration === undefined)
86
- continue;
87
- const type = this.checker.typeToString(this.checker.getTypeOfSymbolAtLocation(parameter, declaration));
88
- if (type.includes('RpcTarget') ||
89
- (type === 'string' && /target/i.test(parameter.getName()))) {
90
- targets[parameter.getName()] = this.target(invocation.arguments?.[index]);
83
+ const prepared = new prepared_targets_1.PreparedTargets(this.checker);
84
+ for (const path of prepared.paths(invocation, 'target')) {
85
+ const parts = path.split('.');
86
+ const name = parts[0];
87
+ const suffix = parts.slice(1);
88
+ const index = signature?.getParameters().findIndex((parameter) => parameter.name === name) ?? -1;
89
+ const expression = invocation.arguments?.[index];
90
+ if (expression === undefined)
91
+ this.fail(`Missing prepared destination argument ${path}.`);
92
+ if (suffix.length === 0)
93
+ targets[path] = this.target(expression);
94
+ else {
95
+ const value = this.preparedValue(expression, suffix);
96
+ targets[path] = value instanceof ForwardedParameter
97
+ ? { kind: 'parameter', parameter: value.parameter } : this.target(value);
91
98
  }
92
99
  }
93
100
  return targets;
@@ -142,25 +149,29 @@ class WiringSourceValues {
142
149
  policies(invocation) {
143
150
  const policies = {};
144
151
  const signature = this.checker.getResolvedSignature(invocation);
145
- for (const [index, parameter] of (signature?.getParameters() ?? []).entries()) {
146
- const declaration = parameter.valueDeclaration;
147
- if (declaration === undefined)
152
+ const prepared = new prepared_targets_1.PreparedTargets(this.checker);
153
+ for (const path of prepared.paths(invocation, 'policy')) {
154
+ const parts = path.split('.');
155
+ const name = parts[0];
156
+ const suffix = parts.slice(1);
157
+ const index = signature?.getParameters().findIndex((parameter) => parameter.name === name) ?? -1;
158
+ const supplied = invocation.arguments?.[index];
159
+ if (supplied === undefined)
160
+ this.fail(`Missing explicit policy argument ${path}.`);
161
+ const argument = suffix.length === 0 ? supplied : this.preparedValue(supplied, suffix);
162
+ if (argument instanceof ForwardedParameter) {
163
+ policies[path] = { parameter: argument.parameter };
148
164
  continue;
149
- const type = this.checker.typeToString(this.checker.getTypeOfSymbolAtLocation(parameter, declaration));
150
- if (!type.includes('WiringPolicy'))
165
+ }
166
+ if (ts.isIdentifier(argument) || ts.isPropertyAccessExpression(argument)) {
167
+ policies[path] = { parameter: this.parameterPath(argument) };
151
168
  continue;
152
- const argument = invocation.arguments?.[index];
153
- if (argument === undefined ||
154
- !ts.isNewExpression(argument) ||
155
- this.symbolName(argument.expression) !== 'WiringPolicy')
169
+ }
170
+ if (!ts.isNewExpression(argument) || !new source_types_1.WiringSourceTypes(this.checker).isFramework(argument.expression, 'WiringPolicy'))
156
171
  this.fail('Pass an explicit named WiringPolicy to conditional modules.');
157
172
  const condition = argument.arguments?.[1];
158
- policies[parameter.getName()] =
159
- condition?.kind === ts.SyntaxKind.TrueKeyword
160
- ? true
161
- : condition?.kind === ts.SyntaxKind.FalseKeyword
162
- ? false
163
- : 'runtime';
173
+ policies[path] = condition?.kind === ts.SyntaxKind.TrueKeyword ? true
174
+ : condition?.kind === ts.SyntaxKind.FalseKeyword ? false : 'runtime';
164
175
  }
165
176
  return policies;
166
177
  }
@@ -177,7 +188,7 @@ class WiringSourceValues {
177
188
  const condition = node.expression;
178
189
  if (!ts.isPropertyAccessExpression(condition) || condition.name.text !== 'enabled')
179
190
  this.fail('Topology conditions must use a named WiringPolicy.enabled.');
180
- policy = this.symbolName(condition.expression);
191
+ policy = this.parameterPath(condition.expression);
181
192
  }
182
193
  if (ts.isConditionalExpression(node) ||
183
194
  ts.isSwitchStatement(node) ||
@@ -188,6 +199,40 @@ class WiringSourceValues {
188
199
  }
189
200
  return policy;
190
201
  }
202
+ preparedValue(expression, suffix) {
203
+ const base = this.symbol(expression)?.declarations?.[0];
204
+ if (base !== undefined && ts.isParameter(base))
205
+ return new ForwardedParameter([this.parameterPath(expression), ...suffix].join('.'));
206
+ if (ts.isPropertyAccessExpression(expression)) {
207
+ const root = expression.expression;
208
+ if (root.kind === ts.SyntaxKind.ThisKeyword || ts.isPropertyAccessExpression(root))
209
+ return new ForwardedParameter([this.parameterPath(expression), ...suffix].join('.'));
210
+ }
211
+ let type = this.checker.getTypeAtLocation(expression);
212
+ let declaration;
213
+ for (const name of suffix) {
214
+ const property = type.getProperty(name);
215
+ declaration = property?.valueDeclaration;
216
+ if (property === undefined || declaration === undefined)
217
+ this.fail(`Cannot resolve prepared destination ${expression.getText()}.${suffix.join('.')}.`);
218
+ type = this.checker.getTypeOfSymbolAtLocation(property, declaration);
219
+ }
220
+ if (declaration !== undefined && ts.isPropertyAssignment(declaration))
221
+ return declaration.initializer;
222
+ if (declaration !== undefined && ts.isPropertyDeclaration(declaration) && declaration.initializer !== undefined)
223
+ return declaration.initializer;
224
+ this.fail(`Unresolved destination ${expression.getText()}.${suffix.join('.')}; prepare a statically resolvable destination, never a computed config function.`);
225
+ }
226
+ parameterPath(expression) {
227
+ if (ts.isPropertyAccessExpression(expression)) {
228
+ if (expression.expression.kind === ts.SyntaxKind.ThisKeyword)
229
+ return expression.name.text;
230
+ return `${this.parameterPath(expression.expression)}.${expression.name.text}`;
231
+ }
232
+ if (ts.isIdentifier(expression))
233
+ return expression.text;
234
+ this.fail(`Unsupported prepared parameter path ${expression.getText()}.`);
235
+ }
191
236
  symbol(node) {
192
237
  const symbol = this.checker.getSymbolAtLocation(node);
193
238
  return symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0
@@ -201,4 +246,10 @@ class WiringSourceValues {
201
246
  }
202
247
  }
203
248
  exports.WiringSourceValues = WiringSourceValues;
249
+ class ForwardedParameter {
250
+ parameter;
251
+ constructor(parameter) {
252
+ this.parameter = parameter;
253
+ }
254
+ }
204
255
  //# sourceMappingURL=source-values.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-values.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-wiring/source-values.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAgE;AAEhE,+CAAiD;AAGjD,mGAAmG;AACnG,MAAa,kBAAkB;IAEN;IACA;IACA;IAHrB,YACqB,aAA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ACvB,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,MAAM,CAAC,IAAa;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC;YACtE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC;YACvC,CAAC,CAAC,MAAM,CAAC;IACjB,CAAC;IAEO,IAAI,CAAC,OAAe;QACxB,MAAM,IAAI,4BAAa,CAAC,+BAA+B,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE;YACpF,IAAI,qBAAM,CACN,yEAAyE,EACzE,IAAI,CACP;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AAlPD,gDAkPC","sourcesContent":["import * as path from 'path';\nimport * as ts from 'typescript';\nimport { Option, RuleFailError } from '@webpieces/rules-config';\nimport type { ProjectInfo } from '../project-info';\nimport { ContractIdentity } from './declaration';\nimport type { DeclaredTarget } from './declaration';\n\n/** Resolves imported symbols and bounded literal expressions without invoking application code. */\nexport class WiringSourceValues {\n constructor(\n private readonly workspaceRoot: string,\n private readonly infos: ReadonlyMap<string, ProjectInfo>,\n private readonly checker: ts.TypeChecker,\n ) {}\n\n symbolName(node: ts.Node): string {\n const symbol = this.symbol(node);\n const declaration = symbol?.declarations?.[0];\n if (\n declaration !== undefined &&\n ts.isVariableDeclaration(declaration) &&\n declaration.initializer !== undefined &&\n (ts.isPropertyAccessExpression(declaration.initializer) ||\n ts.isElementAccessExpression(declaration.initializer))\n )\n return this.symbolName(declaration.initializer);\n return symbol?.getName() ?? node.getText().split('.').pop()!;\n }\n\n identity(node: ts.Node): ContractIdentity {\n const symbol = this.symbol(node);\n const declaration = symbol?.declarations?.[0];\n if (declaration === undefined)\n this.fail(`Cannot resolve canonical identity for ${node.getText()}.`);\n const file = path.resolve(declaration!.getSourceFile().fileName);\n const owners = [...this.infos.values()].filter(\n (info) =>\n info.root !== '.' &&\n info.root !== '' &&\n file.startsWith(path.resolve(this.workspaceRoot, info.root) + path.sep),\n );\n owners.sort((left, right) => right.root.length - left.root.length);\n if (owners.length === 0)\n this.fail(\n `No workspace owner for ${node.getText()} at ${file}; configure source tsconfig paths.`,\n );\n return new ContractIdentity(owners[0].name, symbol!.getName());\n }\n\n target(expression: ts.Expression | undefined, depth: number = 0): DeclaredTarget {\n if (expression === undefined || depth > 20)\n this.fail('Missing or cyclic runtime target expression.');\n const value = expression!;\n if (ts.isStringLiteralLike(value)) return { kind: 'service', service: value.text };\n if (ts.isCallExpression(value) && this.symbolName(value.expression) === 'rpcTarget') {\n const target = this.target(value.arguments[1], depth + 1);\n if (target.kind !== 'service')\n this.fail('rpcTarget requires a literal deployment identity.');\n return { ...target, contract: this.identity(value.arguments[0]) };\n }\n if (\n ts.isNewExpression(value) &&\n ['RpcTarget', 'ClientConfig', 'TaskClientConfig'].includes(\n this.symbolName(value.expression),\n )\n )\n return this.target(\n value.arguments?.[this.symbolName(value.expression) === 'RpcTarget' ? 1 : 0],\n depth + 1,\n );\n const declaration = this.symbol(value)?.declarations?.[0];\n if (declaration !== undefined && ts.isVariableDeclaration(declaration))\n return this.target(declaration.initializer, depth + 1);\n if (declaration !== undefined && ts.isPropertyAssignment(declaration))\n return this.target(declaration.initializer, depth + 1);\n if (declaration !== undefined && ts.isParameter(declaration))\n return { kind: 'parameter', parameter: declaration.name.getText() };\n this.fail(\n `Unsupported target ${value.getText()}; use a literal service, rpcTarget, or an explicit typed target parameter.`,\n );\n }\n\n transport(expression: ts.Expression): 'rpc' | 'pubsub' {\n const declaration = this.symbol(expression)?.declarations?.[0];\n if (declaration === undefined || !ts.isClassDeclaration(declaration))\n this.fail(`API ${expression.getText()} must resolve to its source contract class.`);\n for (const decorator of ts.getDecorators(declaration as ts.ClassDeclaration) ?? []) {\n const expression = decorator.expression;\n const name = this.symbolName(\n ts.isCallExpression(expression) ? expression.expression : expression,\n );\n if (name === 'PubSub') return 'pubsub';\n }\n return 'rpc';\n }\n\n arguments(invocation: ts.NewExpression | ts.CallExpression): Record<string, DeclaredTarget> {\n const targets: Record<string, DeclaredTarget> = {};\n const signature = this.checker.getResolvedSignature(invocation);\n for (const [index, parameter] of (signature?.getParameters() ?? []).entries()) {\n const declaration = parameter.valueDeclaration;\n if (declaration === undefined) continue;\n const type = this.checker.typeToString(\n this.checker.getTypeOfSymbolAtLocation(parameter, declaration),\n );\n if (\n type.includes('RpcTarget') ||\n (type === 'string' && /target/i.test(parameter.getName()))\n ) {\n targets[parameter.getName()] = this.target(invocation.arguments?.[index]);\n }\n }\n return targets;\n }\n\n hasExternalConsumer(\n owner: string,\n project: string,\n exportedName: string,\n program: ts.Program,\n ): boolean {\n const info = this.infos.get(owner);\n if (info === undefined) return false;\n const root = path.resolve(this.workspaceRoot, info.root) + path.sep;\n let found = false;\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node)) {\n // An adapter implements a seam; it does not prove a business caller uses that seam.\n const adapter = node.heritageClauses?.some(\n (clause) =>\n clause.token === ts.SyntaxKind.ImplementsKeyword &&\n clause.types.some((type) => {\n if (this.symbol(type.expression)?.getName() !== exportedName)\n return false;\n return this.identity(type.expression).project === project;\n }),\n );\n if (adapter) return;\n for (const member of node.members) {\n if (!ts.isConstructorDeclaration(member)) continue;\n for (const parameter of member.parameters) {\n if (parameter.type === undefined || !ts.isTypeReferenceNode(parameter.type))\n continue;\n const symbol = this.symbol(parameter.type.typeName);\n const declaration = symbol?.declarations?.[0];\n if (\n declaration === undefined ||\n symbol?.getName() !== exportedName ||\n !(\n ts.isInterfaceDeclaration(declaration) ||\n ts.isClassDeclaration(declaration)\n )\n )\n continue;\n const identity = this.identity(parameter.type.typeName);\n if (identity.project === project && identity.exportedName === exportedName)\n found = true;\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n for (const file of program.getSourceFiles()) {\n if (\n file.isDeclarationFile ||\n !file.fileName.startsWith(root) ||\n /(?:\\.spec\\.|\\.test\\.|\\/__tests__\\/)/.test(file.fileName)\n )\n continue;\n visit(file);\n }\n return found;\n }\n\n policies(\n invocation: ts.NewExpression | ts.CallExpression,\n ): Record<string, boolean | 'runtime'> {\n const policies: Record<string, boolean | 'runtime'> = {};\n const signature = this.checker.getResolvedSignature(invocation);\n for (const [index, parameter] of (signature?.getParameters() ?? []).entries()) {\n const declaration = parameter.valueDeclaration;\n if (declaration === undefined) continue;\n const type = this.checker.typeToString(\n this.checker.getTypeOfSymbolAtLocation(parameter, declaration),\n );\n if (!type.includes('WiringPolicy')) continue;\n const argument = invocation.arguments?.[index];\n if (\n argument === undefined ||\n !ts.isNewExpression(argument) ||\n this.symbolName(argument.expression) !== 'WiringPolicy'\n )\n this.fail('Pass an explicit named WiringPolicy to conditional modules.');\n const condition = argument.arguments?.[1];\n policies[parameter.getName()] =\n condition?.kind === ts.SyntaxKind.TrueKeyword\n ? true\n : condition?.kind === ts.SyntaxKind.FalseKeyword\n ? false\n : 'runtime';\n }\n return policies;\n }\n\n condition(call: ts.Node): string | undefined {\n let child = call;\n let node: ts.Node | undefined = call.parent;\n let policy: string | undefined;\n while (\n node !== undefined &&\n !ts.isClassDeclaration(node) &&\n !ts.isFunctionDeclaration(node)\n ) {\n if (ts.isIfStatement(node)) {\n if (policy !== undefined || child === node.elseStatement)\n this.fail(\n 'Nested topology policies and else branches require separate explicitly selected modules.',\n );\n const condition = node.expression;\n if (!ts.isPropertyAccessExpression(condition) || condition.name.text !== 'enabled')\n this.fail('Topology conditions must use a named WiringPolicy.enabled.');\n policy = this.symbolName((condition as ts.PropertyAccessExpression).expression);\n }\n if (\n ts.isConditionalExpression(node) ||\n ts.isSwitchStatement(node) ||\n ts.isIterationStatement(node, false)\n )\n this.fail('Dynamic topology branches and loops require explicit selected modules.');\n child = node;\n node = node.parent;\n }\n return policy;\n }\n\n private symbol(node: ts.Node): ts.Symbol | undefined {\n const symbol = this.checker.getSymbolAtLocation(node);\n return symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0\n ? this.checker.getAliasedSymbol(symbol)\n : symbol;\n }\n\n private fail(message: string): never {\n throw new RuleFailError('validate-runtime-architecture', message, undefined, undefined, [\n new Option(\n 'Use qualified imports and bounded target declarations in src/wiring.ts.',\n true,\n ),\n ]);\n }\n}\n"]}
1
+ {"version":3,"file":"source-values.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-wiring/source-values.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAgE;AAEhE,+CAAiD;AAEjD,yDAAqD;AACrD,iDAAmD;AAEnD,mGAAmG;AACnG,MAAa,kBAAkB;IAEN;IACA;IACA;IAHrB,YACqB,aAAqB,EACrB,KAAuC,EACvC,OAAuB;QAFvB,kBAAa,GAAb,aAAa,CAAQ;QACrB,UAAK,GAAL,KAAK,CAAkC;QACvC,YAAO,GAAP,OAAO,CAAgB;IACzC,CAAC;IAEJ,UAAU,CAAC,IAAa;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,WAAW,GAAG,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9C,IACI,WAAW,KAAK,SAAS;YACzB,EAAE,CAAC,qBAAqB,CAAC,WAAW,CAAC;YACrC,WAAW,CAAC,WAAW,KAAK,SAAS;YACrC,CAAC,EAAE,CAAC,0BAA0B,CAAC,WAAW,CAAC,WAAW,CAAC;gBACnD,EAAE,CAAC,yBAAyB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAE1D,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACpD,OAAO,MAAM,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG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;IAEO,MAAM,CAAC,IAAa;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC;YACtE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC;YACvC,CAAC,CAAC,MAAM,CAAC;IACjB,CAAC;IAEO,IAAI,CAAC,OAAe;QACxB,MAAM,IAAI,4BAAa,CAAC,+BAA+B,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE;YACpF,IAAI,qBAAM,CACN,yEAAyE,EACzE,IAAI,CACP;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AA9QD,gDA8QC;AAED,MAAM,kBAAkB;IACC;IAArB,YAAqB,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;CAC7C","sourcesContent":["import * as path from 'path';\nimport * as ts from 'typescript';\nimport { Option, RuleFailError } from '@webpieces/rules-config';\nimport type { ProjectInfo } from '../project-info';\nimport { ContractIdentity } from './declaration';\nimport type { DeclaredTarget, PolicyValue } from './declaration';\nimport { PreparedTargets } from './prepared-targets';\nimport { WiringSourceTypes } from './source-types';\n\n/** Resolves imported symbols and bounded literal expressions without invoking application code. */\nexport class WiringSourceValues {\n constructor(\n private readonly workspaceRoot: string,\n private readonly infos: ReadonlyMap<string, ProjectInfo>,\n private readonly checker: ts.TypeChecker,\n ) {}\n\n symbolName(node: ts.Node): string {\n const symbol = this.symbol(node);\n const declaration = symbol?.declarations?.[0];\n if (\n declaration !== undefined &&\n ts.isVariableDeclaration(declaration) &&\n declaration.initializer !== undefined &&\n (ts.isPropertyAccessExpression(declaration.initializer) ||\n ts.isElementAccessExpression(declaration.initializer))\n )\n return this.symbolName(declaration.initializer);\n return symbol?.getName() ?? node.getText().split('.').pop()!;\n }\n\n identity(node: ts.Node): ContractIdentity {\n const symbol = this.symbol(node);\n const declaration = symbol?.declarations?.[0];\n if (declaration === undefined)\n this.fail(`Cannot resolve canonical identity for ${node.getText()}.`);\n const file = path.resolve(declaration!.getSourceFile().fileName);\n const owners = [...this.infos.values()].filter(\n (info) =>\n info.root !== '.' &&\n info.root !== '' &&\n file.startsWith(path.resolve(this.workspaceRoot, info.root) + path.sep),\n );\n owners.sort((left, right) => right.root.length - left.root.length);\n if (owners.length === 0)\n this.fail(\n `No workspace owner for ${node.getText()} at ${file}; configure source tsconfig paths.`,\n );\n return new ContractIdentity(owners[0].name, symbol!.getName());\n }\n\n target(expression: ts.Expression | undefined, depth: number = 0): DeclaredTarget {\n if (expression === undefined || depth > 20)\n this.fail('Missing or cyclic runtime target expression.');\n const value = expression!;\n if (ts.isStringLiteralLike(value)) return { kind: 'service', service: value.text };\n if (ts.isNewExpression(value) && ['ClientConfig', 'TaskClientConfig'].includes(this.symbolName(value.expression)))\n return this.target(value.arguments?.[0], depth + 1);\n const declaration = this.symbol(value)?.declarations?.[0];\n if (declaration !== undefined && ts.isVariableDeclaration(declaration))\n return this.target(declaration.initializer, depth + 1);\n if (declaration !== undefined && ts.isPropertyAssignment(declaration))\n return this.target(declaration.initializer, depth + 1);\n if (declaration !== undefined && ts.isParameter(declaration))\n return { kind: 'parameter', parameter: this.parameterPath(value) };\n if (ts.isPropertyAccessExpression(value)) {\n const type = this.checker.getTypeAtLocation(value);\n if ((type.flags & ts.TypeFlags.StringLike) !== 0)\n return { kind: 'parameter', parameter: this.parameterPath(value) };\n }\n this.fail(\n `Unsupported target ${value.getText()}; use a literal service or a prepared constructor field.`,\n );\n }\n\n transport(expression: ts.Expression): 'rpc' | 'pubsub' {\n const declaration = this.symbol(expression)?.declarations?.[0];\n if (declaration === undefined || !ts.isClassDeclaration(declaration))\n this.fail(`API ${expression.getText()} must resolve to its source contract class.`);\n for (const decorator of ts.getDecorators(declaration as ts.ClassDeclaration) ?? []) {\n const expression = decorator.expression;\n const name = this.symbolName(\n ts.isCallExpression(expression) ? expression.expression : expression,\n );\n if (name === 'PubSub') return 'pubsub';\n }\n return 'rpc';\n }\n\n arguments(invocation: ts.NewExpression | ts.CallExpression): Record<string, DeclaredTarget> {\n const targets: Record<string, DeclaredTarget> = {};\n const signature = this.checker.getResolvedSignature(invocation);\n const prepared = new PreparedTargets(this.checker);\n for (const path of prepared.paths(invocation, 'target')) {\n const parts = path.split('.');\n const name = parts[0];\n const suffix = parts.slice(1);\n const index = signature?.getParameters().findIndex((parameter: ts.Symbol) => parameter.name === name) ?? -1;\n const expression = invocation.arguments?.[index];\n if (expression === undefined) this.fail(`Missing prepared destination argument ${path}.`);\n if (suffix.length === 0) targets[path] = this.target(expression);\n else {\n const value = this.preparedValue(expression!, suffix);\n targets[path] = value instanceof ForwardedParameter\n ? { kind: 'parameter', parameter: value.parameter } : this.target(value);\n }\n }\n return targets;\n }\n\n hasExternalConsumer(\n owner: string,\n project: string,\n exportedName: string,\n program: ts.Program,\n ): boolean {\n const info = this.infos.get(owner);\n if (info === undefined) return false;\n const root = path.resolve(this.workspaceRoot, info.root) + path.sep;\n let found = false;\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node)) {\n // An adapter implements a seam; it does not prove a business caller uses that seam.\n const adapter = node.heritageClauses?.some(\n (clause) =>\n clause.token === ts.SyntaxKind.ImplementsKeyword &&\n clause.types.some((type) => {\n if (this.symbol(type.expression)?.getName() !== exportedName)\n return false;\n return this.identity(type.expression).project === project;\n }),\n );\n if (adapter) return;\n for (const member of node.members) {\n if (!ts.isConstructorDeclaration(member)) continue;\n for (const parameter of member.parameters) {\n if (parameter.type === undefined || !ts.isTypeReferenceNode(parameter.type))\n continue;\n const symbol = this.symbol(parameter.type.typeName);\n const declaration = symbol?.declarations?.[0];\n if (\n declaration === undefined ||\n symbol?.getName() !== exportedName ||\n !(\n ts.isInterfaceDeclaration(declaration) ||\n ts.isClassDeclaration(declaration)\n )\n )\n continue;\n const identity = this.identity(parameter.type.typeName);\n if (identity.project === project && identity.exportedName === exportedName)\n found = true;\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n for (const file of program.getSourceFiles()) {\n if (\n file.isDeclarationFile ||\n !file.fileName.startsWith(root) ||\n /(?:\\.spec\\.|\\.test\\.|\\/__tests__\\/)/.test(file.fileName)\n )\n continue;\n visit(file);\n }\n return found;\n }\n\n policies(\n invocation: ts.NewExpression | ts.CallExpression,\n ): Record<string, PolicyValue> {\n const policies: Record<string, PolicyValue> = {};\n const signature = this.checker.getResolvedSignature(invocation);\n const prepared = new PreparedTargets(this.checker);\n for (const path of prepared.paths(invocation, 'policy')) {\n const parts = path.split('.');\n const name = parts[0];\n const suffix = parts.slice(1);\n const index = signature?.getParameters().findIndex((parameter: ts.Symbol) => parameter.name === name) ?? -1;\n const supplied = invocation.arguments?.[index];\n if (supplied === undefined) this.fail(`Missing explicit policy argument ${path}.`);\n const argument = suffix.length === 0 ? supplied! : this.preparedValue(supplied!, suffix);\n if (argument instanceof ForwardedParameter) {\n policies[path] = { parameter: argument.parameter };\n continue;\n }\n if (ts.isIdentifier(argument) || ts.isPropertyAccessExpression(argument)) {\n policies[path] = { parameter: this.parameterPath(argument) };\n continue;\n }\n if (!ts.isNewExpression(argument) || !new WiringSourceTypes(this.checker).isFramework(argument.expression, 'WiringPolicy'))\n this.fail('Pass an explicit named WiringPolicy to conditional modules.');\n const condition = argument.arguments?.[1];\n policies[path] = condition?.kind === ts.SyntaxKind.TrueKeyword ? true\n : condition?.kind === ts.SyntaxKind.FalseKeyword ? false : 'runtime';\n }\n return policies;\n }\n\n condition(call: ts.Node): string | undefined {\n let child = call;\n let node: ts.Node | undefined = call.parent;\n let policy: string | undefined;\n while (\n node !== undefined &&\n !ts.isClassDeclaration(node) &&\n !ts.isFunctionDeclaration(node)\n ) {\n if (ts.isIfStatement(node)) {\n if (policy !== undefined || child === node.elseStatement)\n this.fail(\n 'Nested topology policies and else branches require separate explicitly selected modules.',\n );\n const condition = node.expression;\n if (!ts.isPropertyAccessExpression(condition) || condition.name.text !== 'enabled')\n this.fail('Topology conditions must use a named WiringPolicy.enabled.');\n policy = this.parameterPath((condition as ts.PropertyAccessExpression).expression);\n }\n if (\n ts.isConditionalExpression(node) ||\n ts.isSwitchStatement(node) ||\n ts.isIterationStatement(node, false)\n )\n this.fail('Dynamic topology branches and loops require explicit selected modules.');\n child = node;\n node = node.parent;\n }\n return policy;\n }\n\n private preparedValue(expression: ts.Expression, suffix: readonly string[]): ts.Expression | ForwardedParameter {\n const base = this.symbol(expression)?.declarations?.[0];\n if (base !== undefined && ts.isParameter(base))\n return new ForwardedParameter([this.parameterPath(expression), ...suffix].join('.'));\n if (ts.isPropertyAccessExpression(expression)) {\n const root = expression.expression;\n if (root.kind === ts.SyntaxKind.ThisKeyword || ts.isPropertyAccessExpression(root))\n return new ForwardedParameter([this.parameterPath(expression), ...suffix].join('.'));\n }\n let type = this.checker.getTypeAtLocation(expression);\n let declaration: ts.Declaration | undefined;\n for (const name of suffix) {\n const property = type.getProperty(name);\n declaration = property?.valueDeclaration;\n if (property === undefined || declaration === undefined)\n this.fail(`Cannot resolve prepared destination ${expression.getText()}.${suffix.join('.')}.`);\n type = this.checker.getTypeOfSymbolAtLocation(property!, declaration!);\n }\n if (declaration !== undefined && ts.isPropertyAssignment(declaration))\n return declaration.initializer;\n if (declaration !== undefined && ts.isPropertyDeclaration(declaration) && declaration.initializer !== undefined)\n return declaration.initializer;\n this.fail(`Unresolved destination ${expression.getText()}.${suffix.join('.')}; prepare a statically resolvable destination, never a computed config function.`);\n }\n\n private parameterPath(expression: ts.Expression): string {\n if (ts.isPropertyAccessExpression(expression)) {\n if (expression.expression.kind === ts.SyntaxKind.ThisKeyword) return expression.name.text;\n return `${this.parameterPath(expression.expression)}.${expression.name.text}`;\n }\n if (ts.isIdentifier(expression)) return expression.text;\n this.fail(`Unsupported prepared parameter path ${expression.getText()}.`);\n }\n\n private symbol(node: ts.Node): ts.Symbol | undefined {\n const symbol = this.checker.getSymbolAtLocation(node);\n return symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0\n ? this.checker.getAliasedSymbol(symbol)\n : symbol;\n }\n\n private fail(message: string): never {\n throw new RuleFailError('validate-runtime-architecture', message, undefined, undefined, [\n new Option(\n 'Use qualified imports and bounded target declarations in src/wiring.ts.',\n true,\n ),\n ]);\n }\n}\n\nclass ForwardedParameter {\n constructor(readonly parameter: string) {}\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import * as ts from 'typescript';
2
+ /** One canonical-file grammar. Symbol resolution may read imports; format checking never does. */
3
+ export declare class WiringFormat {
4
+ private readonly checker;
5
+ private readonly maxLines;
6
+ private readonly types;
7
+ constructor(checker: ts.TypeChecker, maxLines: number);
8
+ problems(file: ts.SourceFile): string[];
9
+ assert(problems: readonly string[]): void;
10
+ private classProblems;
11
+ private arrayProblems;
12
+ private prepared;
13
+ private configureProblems;
14
+ private declarationCall;
15
+ }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WiringFormat = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ const rules_config_1 = require("@webpieces/rules-config");
7
+ const source_types_1 = require("./source-types");
8
+ const canonical_clients_1 = require("./canonical-clients");
9
+ /** One canonical-file grammar. Symbol resolution may read imports; format checking never does. */
10
+ class WiringFormat {
11
+ checker;
12
+ maxLines;
13
+ types;
14
+ constructor(checker, maxLines) {
15
+ this.checker = checker;
16
+ this.maxLines = maxLines;
17
+ this.types = new source_types_1.WiringSourceTypes(checker);
18
+ }
19
+ problems(file) {
20
+ if (!/(?:^|\/)wiring\.ts$/.test(file.fileName))
21
+ return [];
22
+ const problems = new canonical_clients_1.CanonicalClientBindings(this.checker).problems(file);
23
+ const report = (node, message) => {
24
+ const at = file.getLineAndCharacterOfPosition(node.getStart(file));
25
+ problems.push(`${file.fileName}:${at.line + 1}:${at.character + 1}: ${message}`);
26
+ };
27
+ if (file.text.trimEnd().split('\n').length > this.maxLines)
28
+ report(file, `wiring.ts exceeds ${this.maxLines} lines; move implementations to imported named modules.`);
29
+ for (const statement of file.statements) {
30
+ if (ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement))
31
+ continue;
32
+ if (!ts.isClassDeclaration(statement)) {
33
+ report(statement, 'Only imports, exports and named declarative classes belong in wiring.ts.');
34
+ continue;
35
+ }
36
+ const kind = this.types.kind(statement);
37
+ if (kind === undefined) {
38
+ report(statement, 'Implement the framework Wiring, AppWiring, BindingModule or RouteModule contract.');
39
+ continue;
40
+ }
41
+ this.classProblems(statement, kind, report);
42
+ }
43
+ return problems;
44
+ }
45
+ assert(problems) {
46
+ if (problems.length === 0)
47
+ return;
48
+ throw new rules_config_1.RuleFailError('wiring-format', problems.join('\n'), undefined, undefined, [
49
+ new rules_config_1.Option('Use Wiring/AppWiring with literal named module selections. Move setup and business logic out of wiring.ts; keep named WiringPolicy conditions explicit.', true),
50
+ ]);
51
+ }
52
+ classProblems(declaration, kind, report) {
53
+ for (const member of declaration.members) {
54
+ if (ts.isConstructorDeclaration(member)) {
55
+ if (member.body !== undefined && member.body.statements.length > 0)
56
+ report(member, 'Use constructor parameter properties to store prepared inputs; no setup logic.');
57
+ continue;
58
+ }
59
+ if (!ts.isMethodDeclaration(member)) {
60
+ report(member, 'Store prepared inputs in constructor parameter properties.');
61
+ continue;
62
+ }
63
+ const name = member.name.getText();
64
+ if (['getBindingModules', 'getRoutingModules', 'getWirings'].includes(name)) {
65
+ const expected = name === 'getWirings' ? 'wiring' : name === 'getBindingModules' ? 'binding' : 'routing';
66
+ if (name === 'getWirings' && kind !== 'app')
67
+ report(member, 'Only AppWiring can declare getWirings; libraries cannot compose libraries.');
68
+ this.arrayProblems(member, expected, report);
69
+ }
70
+ else if (name === 'configure' && ['binding', 'routing'].includes(kind)) {
71
+ for (const statement of member.body?.statements ?? [])
72
+ this.configureProblems(statement, report);
73
+ }
74
+ else if (name !== 'getHeaders' || kind !== 'app')
75
+ report(member, 'Keep only canonical selection getters and short configure declarations; getRuntimeWiring and helper methods were removed.');
76
+ }
77
+ if (kind === 'app' || kind === 'wiring') {
78
+ const names = ['getBindingModules', 'getRoutingModules', ...(kind === 'app' ? ['getWirings'] : [])];
79
+ for (const name of names) {
80
+ const method = this.types.method(declaration, name);
81
+ if (method === undefined)
82
+ report(declaration, `Missing ${name} literal array getter.`);
83
+ }
84
+ if (kind === 'wiring' && this.types.method(declaration, 'getWirings') !== undefined)
85
+ report(declaration, 'A library Wiring must not inherit getWirings.');
86
+ }
87
+ }
88
+ arrayProblems(method, expected, report) {
89
+ const statements = method.body?.statements;
90
+ const returned = statements?.length === 1 && ts.isReturnStatement(statements[0]) ? statements[0].expression : undefined;
91
+ if (returned === undefined || !ts.isArrayLiteralExpression(returned)) {
92
+ report(method, 'Getter body must be exactly return [new NamedModule(preparedInputs)]; no delegation, spreads, helpers or conditions.');
93
+ return;
94
+ }
95
+ for (const element of returned.elements) {
96
+ if (!ts.isNewExpression(element) || this.types.kind(element.expression) !== expected)
97
+ report(element, `Select a named framework ${expected} instance; nested arrays and AppWiring children are forbidden.`);
98
+ else
99
+ for (const argument of element.arguments ?? []) {
100
+ if (!this.prepared(argument))
101
+ report(argument, 'Pass prepared inputs or a named WiringPolicy; no callbacks, topology wrappers or computed setup.');
102
+ }
103
+ }
104
+ }
105
+ prepared(expression) {
106
+ if (ts.isIdentifier(expression) || ts.isLiteralExpression(expression))
107
+ return true;
108
+ if (ts.isPropertyAccessExpression(expression))
109
+ return this.prepared(expression.expression);
110
+ if ([ts.SyntaxKind.TrueKeyword, ts.SyntaxKind.FalseKeyword, ts.SyntaxKind.ThisKeyword].includes(expression.kind))
111
+ return true;
112
+ if (!ts.isNewExpression(expression))
113
+ return false;
114
+ return this.types.isFramework(expression.expression, 'WiringPolicy');
115
+ }
116
+ configureProblems(statement, report) {
117
+ if (ts.isVariableStatement(statement)) {
118
+ const declarations = statement.declarationList.declarations;
119
+ const initializer = declarations.length === 1 ? declarations[0].initializer : undefined;
120
+ if ((statement.declarationList.flags & ts.NodeFlags.Const) !== 0 && initializer !== undefined && ts.isNewExpression(initializer) &&
121
+ ['RuntimeClients', 'RuntimeTaskClients'].some((name) => this.types.isFramework(initializer.expression, name)) &&
122
+ (initializer.arguments ?? []).every((argument) => this.prepared(argument)))
123
+ return;
124
+ }
125
+ if (ts.isIfStatement(statement) && ts.isPropertyAccessExpression(statement.expression) && statement.expression.name.text === 'enabled' && this.types.isPolicy(statement.expression.expression) && statement.elseStatement === undefined) {
126
+ const body = ts.isBlock(statement.thenStatement) ? statement.thenStatement.statements : [statement.thenStatement];
127
+ for (const child of body)
128
+ this.configureProblems(child, report);
129
+ return;
130
+ }
131
+ const expression = ts.isExpressionStatement(statement) || ts.isReturnStatement(statement) ? statement.expression : undefined;
132
+ if (expression === undefined || (!ts.isCallExpression(expression) && !ts.isNewExpression(expression))) {
133
+ report(statement, 'configure contains only short binding, route, external-contract or module-load declarations and named policy conditions.');
134
+ return;
135
+ }
136
+ const text = expression.getText();
137
+ if (!this.declarationCall(expression) || /(?:=>|\bfunction\b|\brpcTarget\b|\bContainerModule\b)/.test(text))
138
+ report(expression, 'Use recognized declarative registration calls; move custom setup and factories into imported implementations.');
139
+ }
140
+ declarationCall(expression) {
141
+ if (ts.isNewExpression(expression)) {
142
+ return this.types.isFramework(expression.expression, 'ExternalContractUse');
143
+ }
144
+ if (!ts.isPropertyAccessExpression(expression.expression))
145
+ return false;
146
+ const receiver = expression.expression.expression;
147
+ if (ts.isCallExpression(receiver))
148
+ return this.declarationCall(receiver);
149
+ if (!['bind', 'bindRpc', 'bindPubSub', 'add', 'addRoutes', 'addFilter', 'load'].includes(expression.expression.name.text))
150
+ return false;
151
+ const declaration = this.checker.getResolvedSignature(expression)?.declaration;
152
+ if (declaration === undefined)
153
+ return false;
154
+ const file = declaration.getSourceFile().fileName.replace(/\\/g, '/');
155
+ return /(?:\/packages\/(?:http|cloud)\/|\/node_modules\/@webpieces\/)(?:http-routing|http-client-node|http-client-browser|cloudtasks-client)\//.test(file) ||
156
+ /\/node_modules\/(?:@inversifyjs\/|inversify\/)/.test(file);
157
+ }
158
+ }
159
+ exports.WiringFormat = WiringFormat;
160
+ //# sourceMappingURL=wiring-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiring-format.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-wiring/wiring-format.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,0DAAgE;AAChE,iDAA+D;AAC/D,2DAA8D;AAE9D,kGAAkG;AAClG,MAAa,YAAY;IAGQ;IAA0C;IAFtD,KAAK,CAAoB;IAE1C,YAA6B,OAAuB,EAAmB,QAAgB;QAA1D,YAAO,GAAP,OAAO,CAAgB;QAAmB,aAAQ,GAAR,QAAQ,CAAQ;QACnF,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAiB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,QAAQ,CAAC,IAAmB;QACxB,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,OAAO,EAAE,CAAC;QAC1D,MAAM,QAAQ,GAAa,IAAI,2CAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,CAAC,IAAa,EAAE,OAAe,EAAQ,EAAE;YACpD,MAAM,EAAE,GAAG,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YACnE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;QACrF,CAAC,CAAC;QACF,IAAI,IAAI,CAAC,IAAI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YAAE,OAAO,KAAK,CAAC;QACxI,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;QAC/E,IAAI,WAAW,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC5C,MAAM,IAAI,GAAG,WAAW,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtE,OAAO,wIAAwI,CAAC,IAAI,CAAC,IAAI,CAAC;YACtJ,gDAAgD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;CACJ;AA9ID,oCA8IC","sourcesContent":["import * as ts from 'typescript';\nimport { Option, RuleFailError } from '@webpieces/rules-config';\nimport { WiringSourceTypes, WiringKind } from './source-types';\nimport { CanonicalClientBindings } from './canonical-clients';\n\n/** One canonical-file grammar. Symbol resolution may read imports; format checking never does. */\nexport class WiringFormat {\n private readonly types: WiringSourceTypes;\n\n constructor(private readonly checker: ts.TypeChecker, private readonly maxLines: number) {\n this.types = new WiringSourceTypes(checker);\n }\n\n problems(file: ts.SourceFile): string[] {\n if (!/(?:^|\\/)wiring\\.ts$/.test(file.fileName)) return [];\n const problems: string[] = new CanonicalClientBindings(this.checker).problems(file);\n const report = (node: ts.Node, message: string): void => {\n const at = file.getLineAndCharacterOfPosition(node.getStart(file));\n problems.push(`${file.fileName}:${at.line + 1}:${at.character + 1}: ${message}`);\n };\n if (file.text.trimEnd().split('\\n').length > this.maxLines)\n report(file, `wiring.ts exceeds ${this.maxLines} lines; move implementations to imported named modules.`);\n for (const statement of file.statements) {\n if (ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) continue;\n if (!ts.isClassDeclaration(statement)) {\n report(statement, 'Only imports, exports and named declarative classes belong in wiring.ts.');\n continue;\n }\n const kind = this.types.kind(statement);\n if (kind === undefined) {\n report(statement, 'Implement the framework Wiring, AppWiring, BindingModule or RouteModule contract.');\n continue;\n }\n this.classProblems(statement, kind, report);\n }\n return problems;\n }\n\n assert(problems: readonly string[]): void {\n if (problems.length === 0) return;\n throw new RuleFailError('wiring-format', problems.join('\\n'), undefined, undefined, [\n new Option('Use Wiring/AppWiring with literal named module selections. Move setup and business logic out of wiring.ts; keep named WiringPolicy conditions explicit.', true),\n ]);\n }\n\n private classProblems(\n declaration: ts.ClassDeclaration,\n kind: WiringKind,\n report: (node: ts.Node, message: string) => void,\n ): void {\n for (const member of declaration.members) {\n if (ts.isConstructorDeclaration(member)) {\n if (member.body !== undefined && member.body.statements.length > 0)\n report(member, 'Use constructor parameter properties to store prepared inputs; no setup logic.');\n continue;\n }\n if (!ts.isMethodDeclaration(member)) {\n report(member, 'Store prepared inputs in constructor parameter properties.');\n continue;\n }\n const name = member.name.getText();\n if (['getBindingModules', 'getRoutingModules', 'getWirings'].includes(name)) {\n const expected = name === 'getWirings' ? 'wiring' : name === 'getBindingModules' ? 'binding' : 'routing';\n if (name === 'getWirings' && kind !== 'app')\n report(member, 'Only AppWiring can declare getWirings; libraries cannot compose libraries.');\n this.arrayProblems(member, expected, report);\n } else if (name === 'configure' && ['binding', 'routing'].includes(kind)) {\n for (const statement of member.body?.statements ?? [])\n this.configureProblems(statement, report);\n } else if (name !== 'getHeaders' || kind !== 'app')\n report(member, 'Keep only canonical selection getters and short configure declarations; getRuntimeWiring and helper methods were removed.');\n }\n if (kind === 'app' || kind === 'wiring') {\n const names = ['getBindingModules', 'getRoutingModules', ...(kind === 'app' ? ['getWirings'] : [])];\n for (const name of names) {\n const method = this.types.method(declaration, name);\n if (method === undefined) report(declaration, `Missing ${name} literal array getter.`);\n }\n if (kind === 'wiring' && this.types.method(declaration, 'getWirings') !== undefined)\n report(declaration, 'A library Wiring must not inherit getWirings.');\n }\n }\n\n private arrayProblems(\n method: ts.MethodDeclaration,\n expected: WiringKind,\n report: (node: ts.Node, message: string) => void,\n ): void {\n const statements = method.body?.statements;\n const returned = statements?.length === 1 && ts.isReturnStatement(statements[0]) ? statements[0].expression : undefined;\n if (returned === undefined || !ts.isArrayLiteralExpression(returned)) {\n report(method, 'Getter body must be exactly return [new NamedModule(preparedInputs)]; no delegation, spreads, helpers or conditions.');\n return;\n }\n for (const element of returned.elements) {\n if (!ts.isNewExpression(element) || this.types.kind(element.expression) !== expected)\n report(element, `Select a named framework ${expected} instance; nested arrays and AppWiring children are forbidden.`);\n else for (const argument of element.arguments ?? []) {\n if (!this.prepared(argument)) report(argument, 'Pass prepared inputs or a named WiringPolicy; no callbacks, topology wrappers or computed setup.');\n }\n }\n }\n\n private prepared(expression: ts.Expression): boolean {\n if (ts.isIdentifier(expression) || ts.isLiteralExpression(expression)) return true;\n if (ts.isPropertyAccessExpression(expression)) return this.prepared(expression.expression);\n if ([ts.SyntaxKind.TrueKeyword, ts.SyntaxKind.FalseKeyword, ts.SyntaxKind.ThisKeyword].includes(expression.kind)) return true;\n if (!ts.isNewExpression(expression)) return false;\n return this.types.isFramework(expression.expression, 'WiringPolicy');\n }\n\n private configureProblems(statement: ts.Statement, report: (node: ts.Node, message: string) => void): void {\n if (ts.isVariableStatement(statement)) {\n const declarations = statement.declarationList.declarations;\n const initializer = declarations.length === 1 ? declarations[0].initializer : undefined;\n if ((statement.declarationList.flags & ts.NodeFlags.Const) !== 0 && initializer !== undefined && ts.isNewExpression(initializer) &&\n ['RuntimeClients', 'RuntimeTaskClients'].some((name: string) => this.types.isFramework(initializer.expression, name)) &&\n (initializer.arguments ?? []).every((argument: ts.Expression) => this.prepared(argument))) return;\n }\n if (ts.isIfStatement(statement) && ts.isPropertyAccessExpression(statement.expression) && statement.expression.name.text === 'enabled' && this.types.isPolicy(statement.expression.expression) && statement.elseStatement === undefined) {\n const body = ts.isBlock(statement.thenStatement) ? statement.thenStatement.statements : [statement.thenStatement];\n for (const child of body) this.configureProblems(child, report);\n return;\n }\n const expression = ts.isExpressionStatement(statement) || ts.isReturnStatement(statement) ? statement.expression : undefined;\n if (expression === undefined || (!ts.isCallExpression(expression) && !ts.isNewExpression(expression))) {\n report(statement, 'configure contains only short binding, route, external-contract or module-load declarations and named policy conditions.');\n return;\n }\n const text = expression.getText();\n if (!this.declarationCall(expression) || /(?:=>|\\bfunction\\b|\\brpcTarget\\b|\\bContainerModule\\b)/.test(text))\n report(expression, 'Use recognized declarative registration calls; move custom setup and factories into imported implementations.');\n }\n\n private declarationCall(expression: ts.CallExpression | ts.NewExpression): boolean {\n if (ts.isNewExpression(expression)) {\n return this.types.isFramework(expression.expression, 'ExternalContractUse');\n }\n if (!ts.isPropertyAccessExpression(expression.expression)) return false;\n const receiver = expression.expression.expression;\n if (ts.isCallExpression(receiver)) return this.declarationCall(receiver);\n if (!['bind', 'bindRpc', 'bindPubSub', 'add', 'addRoutes', 'addFilter', 'load'].includes(expression.expression.name.text)) return false;\n const declaration = this.checker.getResolvedSignature(expression)?.declaration;\n if (declaration === undefined) return false;\n const file = declaration.getSourceFile().fileName.replace(/\\\\/g, '/');\n return /(?:\\/packages\\/(?:http|cloud)\\/|\\/node_modules\\/@webpieces\\/)(?:http-routing|http-client-node|http-client-browser|cloudtasks-client)\\//.test(file) ||\n /\\/node_modules\\/(?:@inversifyjs\\/|inversify\\/)/.test(file);\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ProjectInfo } from '../project-info';
2
+ /** Every participating canonical file is checked, irrespective of the current diff. */
3
+ export declare class WorkspaceWiringFormat {
4
+ assert(root: string, infos: ReadonlyMap<string, ProjectInfo>, maxLines: number): void;
5
+ run(root: string, infos: ReadonlyMap<string, ProjectInfo>): void;
6
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkspaceWiringFormat = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const ts = tslib_1.__importStar(require("typescript"));
7
+ const rules_config_1 = require("@webpieces/rules-config");
8
+ const rule_gate_1 = require("../rule-gate");
9
+ const source_extractor_1 = require("./source-extractor");
10
+ const wiring_format_1 = require("./wiring-format");
11
+ /** Every participating canonical file is checked, irrespective of the current diff. */
12
+ class WorkspaceWiringFormat {
13
+ assert(root, infos, maxLines) {
14
+ const problems = [];
15
+ for (const info of infos.values()) {
16
+ if (!info.tags.some((tag) => ['webpieces', 'webpieces-lib'].includes(tag)))
17
+ continue;
18
+ const program = new source_extractor_1.WiringProjectProgram().create(root, info);
19
+ const file = program.getSourceFile(path.resolve(root, info.root, 'src/wiring.ts'));
20
+ if (file === undefined)
21
+ problems.push(`${info.root}/src/wiring.ts: missing canonical Wiring/AppWiring declaration.`);
22
+ else
23
+ problems.push(...new wiring_format_1.WiringFormat(program.getTypeChecker(), maxLines).problems(file));
24
+ }
25
+ // Rendering the aggregate needs no source compiler.
26
+ new wiring_format_1.WiringFormat(ts.createProgram([], {}).getTypeChecker(), maxLines).assert(problems);
27
+ }
28
+ run(root, infos) {
29
+ if (new rule_gate_1.RuleGate().skipReason(root, 'wiring-format', true) !== null)
30
+ return;
31
+ const rule = (0, rules_config_1.loadAndValidate)(root).resolved.rules.get('wiring-format');
32
+ const maxLines = rule?.options['maxLines'];
33
+ if (typeof maxLines !== 'number' || !Number.isInteger(maxLines) || maxLines < 1)
34
+ throw new rules_config_1.RuleFailError('wiring-format', 'Declare wiring-format.maxLines as a positive integer (agreed limit: 200).');
35
+ this.assert(root, infos, maxLines);
36
+ }
37
+ }
38
+ exports.WorkspaceWiringFormat = WorkspaceWiringFormat;
39
+ //# sourceMappingURL=workspace-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-format.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-wiring/workspace-format.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAyE;AAEzE,4CAAwC;AACxC,yDAA0D;AAC1D,mDAA+C;AAE/C,uFAAuF;AACvF,MAAa,qBAAqB;IAC9B,MAAM,CAAC,IAAY,EAAE,KAAuC,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Q,GAAG,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC;YAC3E,MAAM,IAAI,4BAAa,CAAC,eAAe,EAAE,2EAA2E,CAAC,CAAC;QAC1H,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;CACJ;AAtBD,sDAsBC","sourcesContent":["import * as path from 'path';\nimport * as ts from 'typescript';\nimport { loadAndValidate, RuleFailError } from '@webpieces/rules-config';\nimport type { ProjectInfo } from '../project-info';\nimport { RuleGate } from '../rule-gate';\nimport { WiringProjectProgram } from './source-extractor';\nimport { WiringFormat } from './wiring-format';\n\n/** Every participating canonical file is checked, irrespective of the current diff. */\nexport class WorkspaceWiringFormat {\n assert(root: string, infos: ReadonlyMap<string, ProjectInfo>, maxLines: number): void {\n const problems: string[] = [];\n for (const info of infos.values()) {\n if (!info.tags.some((tag: string) => ['webpieces', 'webpieces-lib'].includes(tag))) continue;\n const program = new WiringProjectProgram().create(root, info);\n const file = program.getSourceFile(path.resolve(root, info.root, 'src/wiring.ts'));\n if (file === undefined) problems.push(`${info.root}/src/wiring.ts: missing canonical Wiring/AppWiring declaration.`);\n else problems.push(...new WiringFormat(program.getTypeChecker(), maxLines).problems(file));\n }\n // Rendering the aggregate needs no source compiler.\n new WiringFormat(ts.createProgram([], {}).getTypeChecker(), maxLines).assert(problems);\n }\n\n run(root: string, infos: ReadonlyMap<string, ProjectInfo>): void {\n if (new RuleGate().skipReason(root, 'wiring-format', true) !== null) return;\n const rule = loadAndValidate(root).resolved.rules.get('wiring-format');\n const maxLines = rule?.options['maxLines'];\n if (typeof maxLines !== 'number' || !Number.isInteger(maxLines) || maxLines < 1)\n throw new RuleFailError('wiring-format', 'Declare wiring-format.maxLines as a positive integer (agreed limit: 200).');\n this.assert(root, infos, maxLines);\n }\n}\n"]}
@@ -9,6 +9,7 @@ export declare class NativeAction {
9
9
  }
10
10
  /** Metadata holds lazy imports only; importing the pack never imports an executor or the Nx runtime. */
11
11
  export declare class NativeActions {
12
+ readonly wiringFormat: NativeAction;
12
13
  readonly fileCycles: NativeAction;
13
14
  readonly runtime: NativeAction;
14
15
  readonly wiring: NativeAction;
@@ -49,6 +49,12 @@ class NativeAction {
49
49
  exports.NativeAction = NativeAction;
50
50
  /** Metadata holds lazy imports only; importing the pack never imports an executor or the Nx runtime. */
51
51
  class NativeActions {
52
+ wiringFormat = new NativeAction('wiring-format', 'workspace', async (context) => {
53
+ const format = await Promise.resolve().then(() => __importStar(require('./lib/runtime-wiring/workspace-format')));
54
+ const metadata = await Promise.resolve().then(() => __importStar(require('./lib/graph-metadata')));
55
+ new format.WorkspaceWiringFormat().run(context.root, await metadata.collectProjectInfo());
56
+ return new rules_sdk_1.BuildPolicyResult(true);
57
+ });
52
58
  fileCycles = new NativeAction('file-cycles', 'projects', async (context) => (await Promise.resolve().then(() => __importStar(require('./executors/validate-no-file-import-cycles/executor')))).default({}, context));
53
59
  runtime = new NativeAction('runtime', 'workspace', async (context) => (await Promise.resolve().then(() => __importStar(require('./executors/validate-runtime-architecture/executor')))).default({}, context));
54
60
  wiring = new NativeAction('wiring', 'workspace', async (context) => (await Promise.resolve().then(() => __importStar(require('./executors/validate-nx-wiring/executor')))).default({}, context));