@starci/eslint-canon-be 3.5.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +11 -2
  3. package/dist/ambient-id.d.ts +9 -0
  4. package/{ambient-id.mjs → dist/ambient-id.js} +43 -39
  5. package/dist/app-composition.d.ts +21 -0
  6. package/{app-composition.mjs → dist/app-composition.js} +396 -300
  7. package/dist/async-discipline.d.ts +9 -0
  8. package/dist/async-discipline.js +77 -0
  9. package/dist/authorization.d.ts +12 -0
  10. package/{authorization.mjs → dist/authorization.js} +53 -59
  11. package/dist/boundary-schema.d.ts +15 -0
  12. package/{boundary-schema.mjs → dist/boundary-schema.js} +120 -105
  13. package/dist/builders.d.ts +21 -0
  14. package/{builders.mjs → dist/builders.js} +162 -146
  15. package/dist/cli.d.ts +15 -0
  16. package/{cli.mjs → dist/cli.js} +97 -82
  17. package/dist/comments.d.ts +52 -0
  18. package/dist/comments.js +412 -0
  19. package/dist/config-owner.d.ts +24 -0
  20. package/{config-owner.mjs → dist/config-owner.js} +256 -219
  21. package/dist/connections.d.ts +12 -0
  22. package/{connections.mjs → dist/connections.js} +138 -140
  23. package/dist/cookies.d.ts +9 -0
  24. package/{cookies.mjs → dist/cookies.js} +58 -58
  25. package/dist/cqrs.d.ts +27 -0
  26. package/{cqrs.mjs → dist/cqrs.js} +341 -282
  27. package/dist/data-access.d.ts +50 -0
  28. package/{data-access.mjs → dist/data-access.js} +238 -243
  29. package/dist/default-deny.d.ts +15 -0
  30. package/{default-deny.mjs → dist/default-deny.js} +103 -88
  31. package/dist/e2e-flow.d.ts +25 -0
  32. package/{e2e-flow.mjs → dist/e2e-flow.js} +113 -112
  33. package/dist/edge-hardening.d.ts +10 -0
  34. package/dist/edge-hardening.js +173 -0
  35. package/dist/error-handling.d.ts +21 -0
  36. package/{error-handling.mjs → dist/error-handling.js} +289 -239
  37. package/dist/event-bus.d.ts +14 -0
  38. package/{event-bus.mjs → dist/event-bus.js} +146 -129
  39. package/dist/feature-thin.d.ts +12 -0
  40. package/{feature-thin.mjs → dist/feature-thin.js} +208 -191
  41. package/dist/function-budget.d.ts +7 -0
  42. package/{function-budget.mjs → dist/function-budget.js} +24 -27
  43. package/dist/health-ready.d.ts +10 -0
  44. package/dist/health-ready.js +703 -0
  45. package/dist/idempotency.d.ts +10 -0
  46. package/{idempotency.mjs → dist/idempotency.js} +296 -226
  47. package/dist/index.d.ts +54 -0
  48. package/{index.mjs → dist/index.js} +91 -109
  49. package/dist/infra-owner.d.ts +18 -0
  50. package/{infra-owner.mjs → dist/infra-owner.js} +58 -51
  51. package/dist/injection.d.ts +30 -0
  52. package/{injection.mjs → dist/injection.js} +397 -344
  53. package/dist/input-bounds.d.ts +15 -0
  54. package/{input-bounds.mjs → dist/input-bounds.js} +143 -132
  55. package/dist/jobs.d.ts +17 -0
  56. package/{jobs.mjs → dist/jobs.js} +116 -99
  57. package/dist/jwt-alg.d.ts +6 -0
  58. package/dist/jwt-alg.js +49 -0
  59. package/dist/lib/app-roles.d.ts +25 -0
  60. package/{lib/app-roles.mjs → dist/lib/app-roles.js} +15 -17
  61. package/dist/lib/ast.d.ts +40 -0
  62. package/dist/lib/ast.js +100 -0
  63. package/dist/lib/client-idempotency.d.ts +3 -0
  64. package/{lib/client-idempotency.mjs → dist/lib/client-idempotency.js} +316 -268
  65. package/dist/lib/config.d.ts +36 -0
  66. package/{lib/config.mjs → dist/lib/config.js} +24 -27
  67. package/dist/lib/db-writes.d.ts +29 -0
  68. package/{lib/db-writes.mjs → dist/lib/db-writes.js} +27 -27
  69. package/dist/lib/declared.d.ts +77 -0
  70. package/{lib/declared.mjs → dist/lib/declared.js} +83 -78
  71. package/dist/lib/doors.d.ts +50 -0
  72. package/{lib/doors.mjs → dist/lib/doors.js} +45 -50
  73. package/dist/lib/edition.d.ts +25 -0
  74. package/{lib/edition.mjs → dist/lib/edition.js} +15 -20
  75. package/dist/lib/entity-writes.d.ts +7 -0
  76. package/{lib/entity-writes.mjs → dist/lib/entity-writes.js} +31 -22
  77. package/dist/lib/hfs.d.ts +34 -0
  78. package/{lib/hfs.mjs → dist/lib/hfs.js} +31 -29
  79. package/dist/lib/import-source.d.ts +63 -0
  80. package/dist/lib/import-source.js +134 -0
  81. package/dist/lib/path.d.ts +8 -0
  82. package/{lib/path.mjs → dist/lib/path.js} +4 -7
  83. package/dist/lib/persistence.d.ts +115 -0
  84. package/{lib/persistence.mjs → dist/lib/persistence.js} +55 -66
  85. package/dist/lib/ports.d.ts +70 -0
  86. package/{lib/ports.mjs → dist/lib/ports.js} +62 -66
  87. package/dist/lib/rule.d.ts +31 -0
  88. package/dist/lib/rule.js +2 -0
  89. package/dist/lib/runtime-root.d.ts +4 -0
  90. package/dist/lib/runtime-root.js +10 -0
  91. package/dist/lib/schema-values.d.ts +13 -0
  92. package/{lib/schema-values.mjs → dist/lib/schema-values.js} +67 -59
  93. package/dist/lib/specifier.d.ts +12 -0
  94. package/dist/lib/specifier.js +29 -0
  95. package/dist/lib/subject-values.d.ts +4 -0
  96. package/dist/lib/subject-values.js +61 -0
  97. package/dist/lib/transactions.d.ts +18 -0
  98. package/{lib/transactions.mjs → dist/lib/transactions.js} +17 -15
  99. package/dist/lib/transport-slots.d.ts +17 -0
  100. package/{lib/transport-slots.mjs → dist/lib/transport-slots.js} +2 -4
  101. package/dist/lib/types.d.ts +96 -0
  102. package/dist/lib/types.js +150 -0
  103. package/dist/lib/unit-spec.d.ts +48 -0
  104. package/{lib/unit-spec.mjs → dist/lib/unit-spec.js} +35 -44
  105. package/dist/lib/webhook-ack.d.ts +4 -0
  106. package/{lib/webhook-ack.mjs → dist/lib/webhook-ack.js} +78 -62
  107. package/dist/lib/webhook-handoff-inbox.d.ts +3 -0
  108. package/{lib/webhook-handoff-inbox.mjs → dist/lib/webhook-handoff-inbox.js} +195 -167
  109. package/dist/lib/webhook-handoff-intake.d.ts +4 -0
  110. package/{lib/webhook-handoff-intake.mjs → dist/lib/webhook-handoff-intake.js} +125 -102
  111. package/dist/lib/webhook-handoff.d.ts +15 -0
  112. package/{lib/webhook-handoff.mjs → dist/lib/webhook-handoff.js} +107 -100
  113. package/dist/lib/webhook-verifiers.d.ts +20 -0
  114. package/{lib/webhook-verifiers.mjs → dist/lib/webhook-verifiers.js} +108 -104
  115. package/dist/lib/why.d.ts +9 -0
  116. package/{lib/why.mjs → dist/lib/why.js} +6 -6
  117. package/dist/log-safety.d.ts +20 -0
  118. package/dist/log-safety.js +308 -0
  119. package/dist/module-layering.d.ts +42 -0
  120. package/dist/module-layering.js +257 -0
  121. package/dist/module-shape.d.ts +47 -0
  122. package/{module-shape.mjs → dist/module-shape.js} +278 -236
  123. package/dist/naming.d.ts +49 -0
  124. package/dist/naming.js +246 -0
  125. package/dist/observability.d.ts +25 -0
  126. package/dist/observability.js +245 -0
  127. package/dist/operations.d.ts +23 -0
  128. package/{operations.mjs → dist/operations.js} +410 -332
  129. package/dist/project-graph.d.ts +9 -0
  130. package/{project-graph.mjs → dist/project-graph.js} +8 -13
  131. package/dist/projections.d.ts +11 -0
  132. package/{projections.mjs → dist/projections.js} +60 -57
  133. package/dist/query-safety.d.ts +21 -0
  134. package/{query-safety.mjs → dist/query-safety.js} +92 -108
  135. package/dist/realtime.d.ts +15 -0
  136. package/{realtime.mjs → dist/realtime.js} +108 -106
  137. package/dist/resilience.d.ts +15 -0
  138. package/dist/resilience.js +319 -0
  139. package/dist/schema-authority.d.ts +15 -0
  140. package/{schema-authority.mjs → dist/schema-authority.js} +256 -220
  141. package/dist/service-deps.d.ts +17 -0
  142. package/{service-deps.mjs → dist/service-deps.js} +133 -130
  143. package/dist/service-isolation.d.ts +8 -0
  144. package/dist/service-isolation.js +76 -0
  145. package/dist/size-budget.d.ts +9 -0
  146. package/{size-budget.mjs → dist/size-budget.js} +27 -27
  147. package/dist/sonar-parity.d.ts +5 -0
  148. package/{sonar-parity.mjs → dist/sonar-parity.js} +7 -7
  149. package/dist/spec-no-skip.d.ts +9 -0
  150. package/dist/spec-no-skip.js +81 -0
  151. package/dist/spec-quality.d.ts +10 -0
  152. package/{spec-quality.mjs → dist/spec-quality.js} +103 -87
  153. package/dist/suppression.d.ts +26 -0
  154. package/{suppression.mjs → dist/suppression.js} +30 -45
  155. package/dist/temporal.d.ts +9 -0
  156. package/{temporal.mjs → dist/temporal.js} +75 -65
  157. package/dist/test-world.d.ts +28 -0
  158. package/{test-world.mjs → dist/test-world.js} +102 -83
  159. package/dist/testing.d.ts +51 -0
  160. package/dist/testing.js +368 -0
  161. package/dist/third-party-owner.d.ts +8 -0
  162. package/{third-party-owner.mjs → dist/third-party-owner.js} +105 -91
  163. package/dist/transport.d.ts +24 -0
  164. package/{transport.mjs → dist/transport.js} +279 -240
  165. package/dist/type-safety.d.ts +25 -0
  166. package/dist/type-safety.js +297 -0
  167. package/dist/unit-spec.d.ts +30 -0
  168. package/{unit-spec.mjs → dist/unit-spec.js} +473 -399
  169. package/dist/uploads.d.ts +9 -0
  170. package/{uploads.mjs → dist/uploads.js} +62 -54
  171. package/dist/user-copy.d.ts +9 -0
  172. package/{user-copy.mjs → dist/user-copy.js} +76 -67
  173. package/dist/webhooks.d.ts +16 -0
  174. package/{webhooks.mjs → dist/webhooks.js} +243 -231
  175. package/package.json +17 -8
  176. package/runtime/knowledge/hfs/canon-pins.yaml +17 -10
  177. package/async-discipline.mjs +0 -83
  178. package/comments.mjs +0 -416
  179. package/edge-hardening.mjs +0 -139
  180. package/health-ready.mjs +0 -539
  181. package/jwt-alg.mjs +0 -45
  182. package/lib/ast.mjs +0 -88
  183. package/lib/import-source.mjs +0 -104
  184. package/lib/specifier.mjs +0 -27
  185. package/lib/subject-values.mjs +0 -55
  186. package/lib/types.mjs +0 -133
  187. package/log-safety.mjs +0 -303
  188. package/module-layering.mjs +0 -270
  189. package/naming.mjs +0 -251
  190. package/observability.mjs +0 -241
  191. package/resilience.mjs +0 -304
  192. package/service-isolation.mjs +0 -75
  193. package/spec-no-skip.mjs +0 -85
  194. package/testing.mjs +0 -384
  195. package/type-safety.mjs +0 -323
@@ -0,0 +1,15 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** Every property of an input class carries the validators its type calls for. */
3
+ export declare const inputBounded: RuleModule;
4
+ /** Reads are paged by cursor: no `skip`, `offset`, `OFFSET` or page number anywhere. */
5
+ export declare const noOffsetPagination: RuleModule;
6
+ /** A door opened for a handshake or a webhook is on the strict rate-limit tier. */
7
+ export declare const authDoorStrictRateTier: RuleModule;
8
+ /** The rules this law contributes to the plugin. */
9
+ export declare const rules: {
10
+ "input-bounded": RuleModule;
11
+ "no-offset-pagination": RuleModule;
12
+ "auth-door-strict-rate-tier": RuleModule;
13
+ };
14
+ /** All start at error: no baseline exists, and the repositories' fix lanes clear the debt. */
15
+ export declare const recommended: Recommended;
@@ -16,55 +16,57 @@
16
16
  * argument is `RateTier.Strict` of `platform/http-security`, on the method or on its class. A sign-in, sign-up,
17
17
  * password-reset or callback door on the default tier is the brute-force path the strict tier exists for.
18
18
  */
19
- import { isTransportSlot } from "./lib/transport-slots.mjs"
20
- import ts from "typescript"
21
- import { decoratorName, keyName, staticText } from "./lib/ast.mjs"
22
- import { importsFrom, isOwnedEnumMember, partsOf, presentParts, typeOf } from "./lib/declared.mjs"
23
- import { hfsOf } from "./lib/hfs.mjs"
24
- import { normalizePath } from "./lib/path.mjs"
25
- import { isPackageType, typed } from "./lib/types.mjs"
26
-
19
+ import { isTransportSlot } from "./lib/transport-slots.js";
20
+ import ts from "typescript";
21
+ import { decoratorName, keyName, staticText } from "./lib/ast.js";
22
+ import { importsFrom, isOwnedEnumMember, partsOf, presentParts, typeOf } from "./lib/declared.js";
23
+ import { hfsOf } from "./lib/hfs.js";
24
+ import { normalizePath } from "./lib/path.js";
25
+ import { isPackageType, typed } from "./lib/types.js";
27
26
  /** True when the file sits in a transport slot inside a `dto/` folder, judged by the slot and the owner-relative path. */
28
27
  const isTransportDto = (hfs, filename) => {
29
- const slot = hfs.slotOf(filename) ?? ""
30
- if (!isTransportSlot(slot) && !slot.startsWith("be.feature.transport.")) return false
31
- return hfs.relative(filename).split("/").slice(0, -1).includes("dto")
32
- }
33
-
34
- const INPUT_FILE = /\.(?:input|args|request)\.ts$/
35
- const INPUT_DECORATORS = new Set(["InputType", "ArgsType"])
36
-
37
- const decoratorsOf = (node) => node.decorators ?? []
38
-
28
+ const slot = hfs.slotOf(filename) ?? "";
29
+ if (!isTransportSlot(slot) && !slot.startsWith("be.feature.transport."))
30
+ return false;
31
+ return hfs.relative(filename).split("/").slice(0, -1).includes("dto");
32
+ };
33
+ const INPUT_FILE = /\.(?:input|args|request)\.ts$/;
34
+ const INPUT_DECORATORS = new Set(["InputType", "ArgsType"]);
35
+ const decoratorsOf = (node) => ("decorators" in node ? node.decorators ?? [] : []);
39
36
  /** The imported names of the decorators a member carries, mapped through the file's `class-validator`/`class-transformer` imports. */
40
37
  const boundsOf = (member, validators, transformers) => {
41
- const names = new Set()
38
+ const names = new Set();
42
39
  for (const decorator of decoratorsOf(member)) {
43
- const local = decoratorName(decorator)
44
- if (local === null) continue
45
- if (validators.has(local)) names.add(validators.get(local))
46
- if (transformers.has(local)) names.add(`transform:${transformers.get(local)}`)
40
+ const local = decoratorName(decorator);
41
+ if (local === null)
42
+ continue;
43
+ const validator = validators.get(local);
44
+ if (validator !== undefined)
45
+ names.add(validator);
46
+ if (transformers.has(local))
47
+ names.add(`transform:${transformers.get(local)}`);
47
48
  }
48
- return names
49
- }
50
-
51
- const STRINGY = ts.TypeFlags.String | ts.TypeFlags.StringLiteral | ts.TypeFlags.TemplateLiteral
52
- const NOT_NESTED = new Set(["Date", "Array", "ReadonlyArray", "Map", "Set", "Buffer", "Promise"])
53
-
49
+ return names;
50
+ };
51
+ const STRINGY = ts.TypeFlags.String | ts.TypeFlags.StringLiteral | ts.TypeFlags.TemplateLiteral;
52
+ const NOT_NESTED = new Set(["Date", "Array", "ReadonlyArray", "Map", "Set", "Buffer", "Promise"]);
54
53
  /** What a property's type obliges: `enum`, `string`, `array`, `nested` or null for a scalar with no further bound. */
55
54
  const obligationOf = (checker, type) => {
56
- const parts = presentParts(type)
57
- if (parts.length === 0) return null
58
- if (parts.every((part) => part.flags & ts.TypeFlags.EnumLike)) return "enum"
59
- if (parts.every((part) => part.flags & STRINGY)) return "string"
60
- if (parts.some((part) => (checker.isArrayType?.(part) ?? false) || part.getSymbol()?.name === "Array" || part.getSymbol()?.name === "ReadonlyArray")) return "array"
61
- if (parts.some((part) => part.flags & ts.TypeFlags.Object && !NOT_NESTED.has(part.getSymbol()?.name ?? "") && part.getCallSignatures().length === 0)) return "nested"
62
- return null
63
- }
64
-
55
+ const parts = presentParts(type);
56
+ if (parts.length === 0)
57
+ return null;
58
+ if (parts.every((part) => part.flags & ts.TypeFlags.EnumLike))
59
+ return "enum";
60
+ if (parts.every((part) => part.flags & STRINGY))
61
+ return "string";
62
+ if (parts.some((part) => (checker.isArrayType?.(part) ?? false) || part.getSymbol()?.name === "Array" || part.getSymbol()?.name === "ReadonlyArray"))
63
+ return "array";
64
+ if (parts.some((part) => part.flags & ts.TypeFlags.Object && !NOT_NESTED.has(part.getSymbol()?.name ?? "") && part.getCallSignatures().length === 0))
65
+ return "nested";
66
+ return null;
67
+ };
65
68
  /** True when a string-typed property can only hold a fixed set of literals (`"paid" | "failed"`): a membership validator bounds it as `@MaxLength` does. */
66
- const isLiteralSet = (type) => presentParts(type).every((part) => part.flags & ts.TypeFlags.StringLiteral)
67
-
69
+ const isLiteralSet = (type) => presentParts(type).every((part) => part.flags & ts.TypeFlags.StringLiteral);
68
70
  /** Every property of an input class carries the validators its type calls for. */
69
71
  export const inputBounded = {
70
72
  meta: {
@@ -72,8 +74,7 @@ export const inputBounded = {
72
74
  docs: { description: "Every property of an input class is validated and bounded by its type." },
73
75
  schema: [],
74
76
  messages: {
75
- missing:
76
- "`{{name}}` has no `class-validator` decorator, so the wire may deliver any value here. Add the validators the field needs (`@IsString() @MaxLength(n)`, `@IsInt() @Min(0) @Max(n)`, `@IsEnum(E)`, `@IsArray() @ArrayMaxSize(n)`, `@IsOptional()` for a nullable field).",
77
+ missing: "`{{name}}` has no `class-validator` decorator, so the wire may deliver any value here. Add the validators the field needs (`@IsString() @MaxLength(n)`, `@IsInt() @Min(0) @Max(n)`, `@IsEnum(E)`, `@IsArray() @ArrayMaxSize(n)`, `@IsOptional()` for a nullable field).",
77
78
  string: "`{{name}}` is a `string` with no `@MaxLength(n)`, so a string of any length is accepted. Bound it with `@MaxLength`.",
78
79
  enum: "`{{name}}` is enum-typed with no `@IsEnum(...)`, so any string is accepted. Add `@IsEnum(TheEnum)`.",
79
80
  array: "`{{name}}` is an array with no `@ArrayMaxSize(n)`, so an array of any count is accepted. Bound it with `@ArrayMaxSize`.",
@@ -81,50 +82,54 @@ export const inputBounded = {
81
82
  },
82
83
  },
83
84
  create(context) {
84
- const hfs = hfsOf(context)
85
- const filename = normalizePath(context.filename)
86
- const sourceCode = context.sourceCode
87
- const { checker } = typed(context)
88
- const fileIsInput = isTransportDto(hfs, filename) && INPUT_FILE.test(filename)
89
- let validators = new Map()
90
- let transformers = new Map()
85
+ const hfs = hfsOf(context);
86
+ const filename = normalizePath(context.filename);
87
+ const sourceCode = context.sourceCode;
88
+ const { checker } = typed(context);
89
+ const fileIsInput = isTransportDto(hfs, filename) && INPUT_FILE.test(filename);
90
+ let validators = new Map();
91
+ let transformers = new Map();
91
92
  const checkClass = (node) => {
92
- const target = node.parent?.type === "ExportNamedDeclaration" || node.parent?.type === "ExportDefaultDeclaration" ? node.parent : node
93
- const decorated = [...decoratorsOf(node), ...decoratorsOf(target)].map(decoratorName).some((name) => INPUT_DECORATORS.has(name))
94
- if (!fileIsInput && !decorated) return
93
+ const target = node.parent?.type === "ExportNamedDeclaration" || node.parent?.type === "ExportDefaultDeclaration" ? node.parent : node;
94
+ const decorated = [...decoratorsOf(node), ...decoratorsOf(target)].map(decoratorName).some((name) => INPUT_DECORATORS.has(name));
95
+ if (!fileIsInput && !decorated)
96
+ return;
95
97
  for (const member of node.body.body) {
96
- if (member.type !== "PropertyDefinition" || member.static || member.computed || member.key.type !== "Identifier") continue
97
- const name = sourceCode.getText(member.key)
98
- const have = boundsOf(member, validators, transformers)
99
- const validated = [...have].some((entry) => !entry.startsWith("transform:"))
98
+ if (member.type !== "PropertyDefinition" || member.static || member.computed || member.key.type !== "Identifier")
99
+ continue;
100
+ const name = sourceCode.getText(member.key);
101
+ const have = boundsOf(member, validators, transformers);
102
+ const validated = [...have].some((entry) => !entry.startsWith("transform:"));
100
103
  if (!validated) {
101
- context.report({ node: member.key, messageId: "missing", data: { name } })
102
- continue
104
+ context.report({ node: member.key, messageId: "missing", data: { name } });
105
+ continue;
103
106
  }
104
- const obligation = obligationOf(checker, typeOf(context, member))
105
- const memberType = typeOf(context, member)
106
- const boundedByMembership = obligation === "string" && isLiteralSet(memberType) && (have.has("IsIn") || have.has("Equals"))
107
- if (obligation === "string" && !have.has("MaxLength") && !boundedByMembership) context.report({ node: member.key, messageId: "string", data: { name } })
108
- else if (obligation === "enum" && !have.has("IsEnum")) context.report({ node: member.key, messageId: "enum", data: { name } })
109
- else if (obligation === "array" && !have.has("ArrayMaxSize")) context.report({ node: member.key, messageId: "array", data: { name } })
110
- else if (obligation === "nested" && !(have.has("ValidateNested") && have.has("transform:Type"))) context.report({ node: member.key, messageId: "nested", data: { name } })
107
+ const obligation = obligationOf(checker, typeOf(context, member));
108
+ const memberType = typeOf(context, member);
109
+ const boundedByMembership = obligation === "string" && isLiteralSet(memberType) && (have.has("IsIn") || have.has("Equals"));
110
+ if (obligation === "string" && !have.has("MaxLength") && !boundedByMembership)
111
+ context.report({ node: member.key, messageId: "string", data: { name } });
112
+ else if (obligation === "enum" && !have.has("IsEnum"))
113
+ context.report({ node: member.key, messageId: "enum", data: { name } });
114
+ else if (obligation === "array" && !have.has("ArrayMaxSize"))
115
+ context.report({ node: member.key, messageId: "array", data: { name } });
116
+ else if (obligation === "nested" && !(have.has("ValidateNested") && have.has("transform:Type")))
117
+ context.report({ node: member.key, messageId: "nested", data: { name } });
111
118
  }
112
- }
119
+ };
113
120
  return {
114
121
  Program(node) {
115
- validators = importsFrom(node, (source) => source === "class-validator")
116
- transformers = importsFrom(node, (source) => source === "class-transformer")
122
+ validators = importsFrom(node, (source) => source === "class-validator");
123
+ transformers = importsFrom(node, (source) => source === "class-transformer");
117
124
  },
118
125
  ClassDeclaration: checkClass,
119
126
  ClassExpression: checkClass,
120
- }
127
+ };
121
128
  },
122
- }
123
-
124
- const PAGE_PROPERTIES = new Set(["page", "pageNumber", "offset"])
125
- const OFFSET_KEYS = new Set(["skip", "offset"])
126
- const OFFSET_KEYWORD = /\bOFFSET\b/i
127
-
129
+ };
130
+ const PAGE_PROPERTIES = new Set(["page", "pageNumber", "offset"]);
131
+ const OFFSET_KEYS = new Set(["skip", "offset"]);
132
+ const OFFSET_KEYWORD = /\bOFFSET\b/i;
128
133
  /** Reads are paged by cursor: no `skip`, `offset`, `OFFSET` or page number anywhere. */
129
134
  export const noOffsetPagination = {
130
135
  meta: {
@@ -138,63 +143,68 @@ export const noOffsetPagination = {
138
143
  },
139
144
  },
140
145
  create(context) {
141
- const hfs = hfsOf(context)
142
- const filename = normalizePath(context.filename)
143
- const { checker } = typed(context)
144
- const inDto = isTransportDto(hfs, filename)
146
+ const hfs = hfsOf(context);
147
+ const filename = normalizePath(context.filename);
148
+ const { checker } = typed(context);
149
+ const inDto = isTransportDto(hfs, filename);
145
150
  return {
146
151
  CallExpression(node) {
147
- const callee = node.callee
148
- if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier") return
149
- const method = callee.property.name
150
- if (!isPackageType(context, callee.object, "EntityManager", "typeorm")) return
152
+ const callee = node.callee;
153
+ if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier")
154
+ return;
155
+ const method = callee.property.name;
156
+ if (!isPackageType(context, callee.object, "EntityManager", "typeorm"))
157
+ return;
151
158
  if (method === "query") {
152
- const text = staticText(node.arguments[0])
153
- if (text !== null && OFFSET_KEYWORD.test(text)) context.report({ node: node.arguments[0], messageId: "sql" })
154
- return
159
+ const first = node.arguments[0];
160
+ const text = staticText(first);
161
+ if (first && text !== null && OFFSET_KEYWORD.test(text))
162
+ context.report({ node: first, messageId: "sql" });
163
+ return;
155
164
  }
156
- if (!method.startsWith("find")) return
165
+ if (!method.startsWith("find"))
166
+ return;
157
167
  for (const argument of node.arguments) {
158
- const type = typeOf(context, argument)
159
- if (!type) continue
168
+ const type = typeOf(context, argument);
169
+ if (!type)
170
+ continue;
160
171
  for (const property of checker.getPropertiesOfType(type)) {
161
- if (!OFFSET_KEYS.has(property.name)) continue
162
- const literal = argument.type === "ObjectExpression" ? argument.properties.find((item) => item.type === "Property" && keyName(item.key) === property.name) : null
163
- context.report({ node: literal ?? argument, messageId: "option", data: { key: property.name } })
172
+ if (!OFFSET_KEYS.has(property.name))
173
+ continue;
174
+ const literal = argument.type === "ObjectExpression" ? argument.properties.find((item) => item.type === "Property" && keyName(item.key) === property.name) : null;
175
+ context.report({ node: literal ?? argument, messageId: "option", data: { key: property.name } });
164
176
  }
165
177
  }
166
178
  },
167
179
  TaggedTemplateExpression(node) {
168
- const tag = node.tag
169
- const isSql = (tag.type === "Identifier" && tag.name === "sql") || (tag.type === "MemberExpression" && !tag.computed && keyName(tag.property) === "sql")
170
- if (isSql && node.quasi.quasis.some((quasi) => OFFSET_KEYWORD.test(quasi.value.cooked ?? ""))) context.report({ node: node.quasi, messageId: "sql" })
180
+ const tag = node.tag;
181
+ const isSql = (tag.type === "Identifier" && tag.name === "sql") || (tag.type === "MemberExpression" && !tag.computed && keyName(tag.property) === "sql");
182
+ if (isSql && node.quasi.quasis.some((quasi) => OFFSET_KEYWORD.test(quasi.value.cooked ?? "")))
183
+ context.report({ node: node.quasi, messageId: "sql" });
171
184
  },
172
185
  PropertyDefinition(node) {
173
- if (!inDto || node.static || node.computed || node.key.type !== "Identifier") return
174
- if (PAGE_PROPERTIES.has(node.key.name)) context.report({ node: node.key, messageId: "field", data: { name: node.key.name } })
186
+ if (!inDto || node.static || node.computed || node.key.type !== "Identifier")
187
+ return;
188
+ if (PAGE_PROPERTIES.has(node.key.name))
189
+ context.report({ node: node.key, messageId: "field", data: { name: node.key.name } });
175
190
  },
176
- }
191
+ };
177
192
  },
178
- }
179
-
193
+ };
180
194
  /** The `PublicReason` members whose doors are the brute-force and forgery paths: they owe the strict tier. */
181
- const STRICT_REASONS = new Set(["AuthHandshake", "SignedWebhook"])
182
-
195
+ const STRICT_REASONS = new Set(["AuthHandshake", "SignedWebhook"]);
183
196
  /** The member names of an enum-typed value, when every part of its type is a member of the owned enum; else []. */
184
- const ownedMembers = (context, node, enumName, tier, capability) =>
185
- isOwnedEnumMember(context, node, enumName, tier, capability) ? partsOf(typeOf(context, node)).map((part) => part.getSymbol()?.name ?? "") : []
186
-
197
+ const ownedMembers = (context, node, enumName, tier, capability) => isOwnedEnumMember(context, node, enumName, tier, capability) ? partsOf(typeOf(context, node)).map((part) => part.getSymbol()?.name ?? "") : [];
187
198
  /** The arguments of a decorator call (`@X(a, b)`), or [] for a bare `@X`. */
188
- const argumentsOf = (decorator) => (decorator.expression.type === "CallExpression" ? decorator.expression.arguments : [])
189
-
199
+ const argumentsOf = (decorator) => (decorator.expression.type === "CallExpression" ? decorator.expression.arguments : []);
190
200
  /** The `reason` value of an opening decorator's options object (`@Public({ reason })`), or null. */
191
201
  const reasonOf = (decorator) => {
192
- const options = argumentsOf(decorator)[0]
193
- if (options?.type !== "ObjectExpression") return null
194
- const property = options.properties.find((item) => item.type === "Property" && !item.computed && keyName(item.key) === "reason")
195
- return property ? property.value : null
196
- }
197
-
202
+ const options = argumentsOf(decorator)[0];
203
+ if (options?.type !== "ObjectExpression")
204
+ return null;
205
+ const property = options.properties.find((item) => item.type === "Property" && !item.computed && keyName(item.key) === "reason");
206
+ return property ? property.value : null;
207
+ };
198
208
  /** A door opened for a handshake or a webhook is on the strict rate-limit tier. */
199
209
  export const authDoorStrictRateTier = {
200
210
  meta: {
@@ -207,41 +217,42 @@ export const authDoorStrictRateTier = {
207
217
  },
208
218
  create(context) {
209
219
  const isStrict = (decorator) => argumentsOf(decorator).some((argument) => {
210
- const members = ownedMembers(context, argument, "RateTier", "platform", "http-security")
211
- return members.length > 0 && members.every((name) => name === "Strict")
212
- })
220
+ const members = ownedMembers(context, argument, "RateTier", "platform", "http-security");
221
+ return members.length > 0 && members.every((name) => name === "Strict");
222
+ });
213
223
  const judge = (target, enclosing) => {
214
224
  for (const decorator of target.decorators ?? []) {
215
- const reason = reasonOf(decorator)
216
- if (reason === null) continue
217
- const opened = ownedMembers(context, reason, "PublicReason", "domain", "identity").find((name) => STRICT_REASONS.has(name))
218
- if (opened === undefined) continue
219
- if ([...(target.decorators ?? []), ...(enclosing?.decorators ?? [])].some(isStrict)) continue
220
- context.report({ node: decorator, messageId: "strict", data: { reason: opened } })
225
+ const reason = reasonOf(decorator);
226
+ if (reason === null)
227
+ continue;
228
+ const opened = ownedMembers(context, reason, "PublicReason", "domain", "identity").find((name) => STRICT_REASONS.has(name));
229
+ if (opened === undefined)
230
+ continue;
231
+ if ([...(target.decorators ?? []), ...(enclosing?.decorators ?? [])].some(isStrict))
232
+ continue;
233
+ context.report({ node: decorator, messageId: "strict", data: { reason: opened } });
221
234
  }
222
- }
235
+ };
223
236
  return {
224
237
  ClassDeclaration(node) {
225
- judge(node, null)
238
+ judge(node, null);
226
239
  },
227
240
  MethodDefinition(node) {
228
- const owner = node.parent?.parent
229
- judge(node, owner?.type === "ClassDeclaration" || owner?.type === "ClassExpression" ? owner : null)
241
+ const owner = node.parent?.parent;
242
+ judge(node, owner?.type === "ClassDeclaration" || owner?.type === "ClassExpression" ? owner : null);
230
243
  },
231
- }
244
+ };
232
245
  },
233
- }
234
-
246
+ };
235
247
  /** The rules this law contributes to the plugin. */
236
248
  export const rules = {
237
249
  "input-bounded": inputBounded,
238
250
  "no-offset-pagination": noOffsetPagination,
239
251
  "auth-door-strict-rate-tier": authDoorStrictRateTier,
240
- }
241
-
252
+ };
242
253
  /** All start at error: no baseline exists, and the repositories' fix lanes clear the debt. */
243
254
  export const recommended = {
244
255
  "starci-be/input-bounded": "error",
245
256
  "starci-be/no-offset-pagination": "error",
246
257
  "starci-be/auth-door-strict-rate-tier": "error",
247
- }
258
+ };
package/dist/jobs.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** A write to an entity that `platform/jobs` declares (the job row) is made only by `platform/jobs`. */
3
+ export declare const jobWriteOwner: RuleModule;
4
+ /** Calls on the `JobClaims` port, and what a guarded write is: required token, no cast to get around it, and `JobFencedOut` is not swallowed. */
5
+ export declare const jobFenceRequired: RuleModule;
6
+ /** The class of an external effect of a step passes the key `JobClaims.runKey` made. */
7
+ export declare const jobRunKey: RuleModule;
8
+ /** A processor extends the fenced base and is named after its job; a step implements `JobStep` in `steps/`. */
9
+ export declare const jobShape: RuleModule;
10
+ export declare const rules: {
11
+ "job-write-owner": RuleModule;
12
+ "job-fence-required": RuleModule;
13
+ "job-run-key": RuleModule;
14
+ "job-shape": RuleModule;
15
+ };
16
+ /** The level these laws ask for: `error`, switched off nowhere. */
17
+ export declare const recommended: Recommended;