@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.
- package/CHANGELOG.md +15 -0
- package/README.md +11 -2
- package/dist/ambient-id.d.ts +9 -0
- package/{ambient-id.mjs → dist/ambient-id.js} +43 -39
- package/dist/app-composition.d.ts +21 -0
- package/{app-composition.mjs → dist/app-composition.js} +396 -300
- package/dist/async-discipline.d.ts +9 -0
- package/dist/async-discipline.js +77 -0
- package/dist/authorization.d.ts +12 -0
- package/{authorization.mjs → dist/authorization.js} +53 -59
- package/dist/boundary-schema.d.ts +15 -0
- package/{boundary-schema.mjs → dist/boundary-schema.js} +120 -105
- package/dist/builders.d.ts +21 -0
- package/{builders.mjs → dist/builders.js} +162 -146
- package/dist/cli.d.ts +15 -0
- package/{cli.mjs → dist/cli.js} +97 -82
- package/dist/comments.d.ts +52 -0
- package/dist/comments.js +412 -0
- package/dist/config-owner.d.ts +24 -0
- package/{config-owner.mjs → dist/config-owner.js} +256 -219
- package/dist/connections.d.ts +12 -0
- package/{connections.mjs → dist/connections.js} +138 -140
- package/dist/cookies.d.ts +9 -0
- package/{cookies.mjs → dist/cookies.js} +58 -58
- package/dist/cqrs.d.ts +27 -0
- package/{cqrs.mjs → dist/cqrs.js} +341 -282
- package/dist/data-access.d.ts +50 -0
- package/{data-access.mjs → dist/data-access.js} +238 -243
- package/dist/default-deny.d.ts +15 -0
- package/{default-deny.mjs → dist/default-deny.js} +103 -88
- package/dist/e2e-flow.d.ts +25 -0
- package/{e2e-flow.mjs → dist/e2e-flow.js} +113 -112
- package/dist/edge-hardening.d.ts +10 -0
- package/dist/edge-hardening.js +173 -0
- package/dist/error-handling.d.ts +21 -0
- package/{error-handling.mjs → dist/error-handling.js} +289 -239
- package/dist/event-bus.d.ts +14 -0
- package/{event-bus.mjs → dist/event-bus.js} +146 -129
- package/dist/feature-thin.d.ts +12 -0
- package/{feature-thin.mjs → dist/feature-thin.js} +208 -191
- package/dist/function-budget.d.ts +7 -0
- package/{function-budget.mjs → dist/function-budget.js} +24 -27
- package/dist/health-ready.d.ts +10 -0
- package/dist/health-ready.js +703 -0
- package/dist/idempotency.d.ts +10 -0
- package/{idempotency.mjs → dist/idempotency.js} +296 -226
- package/dist/index.d.ts +54 -0
- package/{index.mjs → dist/index.js} +91 -109
- package/dist/infra-owner.d.ts +18 -0
- package/{infra-owner.mjs → dist/infra-owner.js} +58 -51
- package/dist/injection.d.ts +30 -0
- package/{injection.mjs → dist/injection.js} +397 -344
- package/dist/input-bounds.d.ts +15 -0
- package/{input-bounds.mjs → dist/input-bounds.js} +143 -132
- package/dist/jobs.d.ts +17 -0
- package/{jobs.mjs → dist/jobs.js} +116 -99
- package/dist/jwt-alg.d.ts +6 -0
- package/dist/jwt-alg.js +49 -0
- package/dist/lib/app-roles.d.ts +25 -0
- package/{lib/app-roles.mjs → dist/lib/app-roles.js} +15 -17
- package/dist/lib/ast.d.ts +40 -0
- package/dist/lib/ast.js +100 -0
- package/dist/lib/client-idempotency.d.ts +3 -0
- package/{lib/client-idempotency.mjs → dist/lib/client-idempotency.js} +316 -268
- package/dist/lib/config.d.ts +36 -0
- package/{lib/config.mjs → dist/lib/config.js} +24 -27
- package/dist/lib/db-writes.d.ts +29 -0
- package/{lib/db-writes.mjs → dist/lib/db-writes.js} +27 -27
- package/dist/lib/declared.d.ts +77 -0
- package/{lib/declared.mjs → dist/lib/declared.js} +83 -78
- package/dist/lib/doors.d.ts +50 -0
- package/{lib/doors.mjs → dist/lib/doors.js} +45 -50
- package/dist/lib/edition.d.ts +25 -0
- package/{lib/edition.mjs → dist/lib/edition.js} +15 -20
- package/dist/lib/entity-writes.d.ts +7 -0
- package/{lib/entity-writes.mjs → dist/lib/entity-writes.js} +31 -22
- package/dist/lib/hfs.d.ts +34 -0
- package/{lib/hfs.mjs → dist/lib/hfs.js} +31 -29
- package/dist/lib/import-source.d.ts +63 -0
- package/dist/lib/import-source.js +134 -0
- package/dist/lib/path.d.ts +8 -0
- package/{lib/path.mjs → dist/lib/path.js} +4 -7
- package/dist/lib/persistence.d.ts +115 -0
- package/{lib/persistence.mjs → dist/lib/persistence.js} +55 -66
- package/dist/lib/ports.d.ts +70 -0
- package/{lib/ports.mjs → dist/lib/ports.js} +62 -66
- package/dist/lib/rule.d.ts +31 -0
- package/dist/lib/rule.js +2 -0
- package/dist/lib/runtime-root.d.ts +4 -0
- package/dist/lib/runtime-root.js +10 -0
- package/dist/lib/schema-values.d.ts +13 -0
- package/{lib/schema-values.mjs → dist/lib/schema-values.js} +67 -59
- package/dist/lib/specifier.d.ts +12 -0
- package/dist/lib/specifier.js +29 -0
- package/dist/lib/subject-values.d.ts +4 -0
- package/dist/lib/subject-values.js +61 -0
- package/dist/lib/transactions.d.ts +18 -0
- package/{lib/transactions.mjs → dist/lib/transactions.js} +17 -15
- package/dist/lib/transport-slots.d.ts +17 -0
- package/{lib/transport-slots.mjs → dist/lib/transport-slots.js} +2 -4
- package/dist/lib/types.d.ts +96 -0
- package/dist/lib/types.js +150 -0
- package/dist/lib/unit-spec.d.ts +48 -0
- package/{lib/unit-spec.mjs → dist/lib/unit-spec.js} +35 -44
- package/dist/lib/webhook-ack.d.ts +4 -0
- package/{lib/webhook-ack.mjs → dist/lib/webhook-ack.js} +78 -62
- package/dist/lib/webhook-handoff-inbox.d.ts +3 -0
- package/{lib/webhook-handoff-inbox.mjs → dist/lib/webhook-handoff-inbox.js} +195 -167
- package/dist/lib/webhook-handoff-intake.d.ts +4 -0
- package/{lib/webhook-handoff-intake.mjs → dist/lib/webhook-handoff-intake.js} +125 -102
- package/dist/lib/webhook-handoff.d.ts +15 -0
- package/{lib/webhook-handoff.mjs → dist/lib/webhook-handoff.js} +107 -100
- package/dist/lib/webhook-verifiers.d.ts +20 -0
- package/{lib/webhook-verifiers.mjs → dist/lib/webhook-verifiers.js} +108 -104
- package/dist/lib/why.d.ts +9 -0
- package/{lib/why.mjs → dist/lib/why.js} +6 -6
- package/dist/log-safety.d.ts +20 -0
- package/dist/log-safety.js +308 -0
- package/dist/module-layering.d.ts +42 -0
- package/dist/module-layering.js +257 -0
- package/dist/module-shape.d.ts +47 -0
- package/{module-shape.mjs → dist/module-shape.js} +278 -236
- package/dist/naming.d.ts +49 -0
- package/dist/naming.js +246 -0
- package/dist/observability.d.ts +25 -0
- package/dist/observability.js +245 -0
- package/dist/operations.d.ts +23 -0
- package/{operations.mjs → dist/operations.js} +410 -332
- package/dist/project-graph.d.ts +9 -0
- package/{project-graph.mjs → dist/project-graph.js} +8 -13
- package/dist/projections.d.ts +11 -0
- package/{projections.mjs → dist/projections.js} +60 -57
- package/dist/query-safety.d.ts +21 -0
- package/{query-safety.mjs → dist/query-safety.js} +92 -108
- package/dist/realtime.d.ts +15 -0
- package/{realtime.mjs → dist/realtime.js} +108 -106
- package/dist/resilience.d.ts +15 -0
- package/dist/resilience.js +319 -0
- package/dist/schema-authority.d.ts +15 -0
- package/{schema-authority.mjs → dist/schema-authority.js} +256 -220
- package/dist/service-deps.d.ts +17 -0
- package/{service-deps.mjs → dist/service-deps.js} +133 -130
- package/dist/service-isolation.d.ts +8 -0
- package/dist/service-isolation.js +76 -0
- package/dist/size-budget.d.ts +9 -0
- package/{size-budget.mjs → dist/size-budget.js} +27 -27
- package/dist/sonar-parity.d.ts +5 -0
- package/{sonar-parity.mjs → dist/sonar-parity.js} +7 -7
- package/dist/spec-no-skip.d.ts +9 -0
- package/dist/spec-no-skip.js +81 -0
- package/dist/spec-quality.d.ts +10 -0
- package/{spec-quality.mjs → dist/spec-quality.js} +103 -87
- package/dist/suppression.d.ts +26 -0
- package/{suppression.mjs → dist/suppression.js} +30 -45
- package/dist/temporal.d.ts +9 -0
- package/{temporal.mjs → dist/temporal.js} +75 -65
- package/dist/test-world.d.ts +28 -0
- package/{test-world.mjs → dist/test-world.js} +102 -83
- package/dist/testing.d.ts +51 -0
- package/dist/testing.js +368 -0
- package/dist/third-party-owner.d.ts +8 -0
- package/{third-party-owner.mjs → dist/third-party-owner.js} +105 -91
- package/dist/transport.d.ts +24 -0
- package/{transport.mjs → dist/transport.js} +279 -240
- package/dist/type-safety.d.ts +25 -0
- package/dist/type-safety.js +297 -0
- package/dist/unit-spec.d.ts +30 -0
- package/{unit-spec.mjs → dist/unit-spec.js} +473 -399
- package/dist/uploads.d.ts +9 -0
- package/{uploads.mjs → dist/uploads.js} +62 -54
- package/dist/user-copy.d.ts +9 -0
- package/{user-copy.mjs → dist/user-copy.js} +76 -67
- package/dist/webhooks.d.ts +16 -0
- package/{webhooks.mjs → dist/webhooks.js} +243 -231
- package/package.json +17 -8
- package/runtime/knowledge/hfs/canon-pins.yaml +17 -10
- package/async-discipline.mjs +0 -83
- package/comments.mjs +0 -416
- package/edge-hardening.mjs +0 -139
- package/health-ready.mjs +0 -539
- package/jwt-alg.mjs +0 -45
- package/lib/ast.mjs +0 -88
- package/lib/import-source.mjs +0 -104
- package/lib/specifier.mjs +0 -27
- package/lib/subject-values.mjs +0 -55
- package/lib/types.mjs +0 -133
- package/log-safety.mjs +0 -303
- package/module-layering.mjs +0 -270
- package/naming.mjs +0 -251
- package/observability.mjs +0 -241
- package/resilience.mjs +0 -304
- package/service-isolation.mjs +0 -75
- package/spec-no-skip.mjs +0 -85
- package/testing.mjs +0 -384
- package/type-safety.mjs +0 -323
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
+
/** One physical database is one connection, one injector, one config and one registration. */
|
|
3
|
+
export declare const oneConnectionPerDatabase: RuleModule;
|
|
4
|
+
/** An EntityManager is injected in an application handler, a domain service or a platform persistence capability only. */
|
|
5
|
+
export declare const emInjectionSlots: RuleModule;
|
|
6
|
+
/** The rules this law contributes to the plugin. */
|
|
7
|
+
export declare const rules: {
|
|
8
|
+
"one-connection-per-database": RuleModule;
|
|
9
|
+
"em-injection-slots": RuleModule;
|
|
10
|
+
};
|
|
11
|
+
/** Every rule of this law ships at `error`. */
|
|
12
|
+
export declare const recommended: Recommended;
|
|
@@ -17,101 +17,91 @@
|
|
|
17
17
|
* Every question about a receiver is a question about its TypeScript type, every question about a path is a question
|
|
18
18
|
* to the HFS slot view.
|
|
19
19
|
*/
|
|
20
|
-
import ts from "typescript"
|
|
21
|
-
import { hfsOf, inTestWorld } from "./lib/hfs.
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
connectionFileOf,
|
|
25
|
-
connectionsOf,
|
|
26
|
-
inDatabaseCapability,
|
|
27
|
-
inCli,
|
|
28
|
-
infraTypeOf,
|
|
29
|
-
injectionSites,
|
|
30
|
-
injectorNameOf,
|
|
31
|
-
mayHoldEntityManager,
|
|
32
|
-
} from "./lib/persistence.mjs"
|
|
33
|
-
import { isPackageType, originsOfType, typed, typeOrigins } from "./lib/types.mjs"
|
|
34
|
-
|
|
20
|
+
import ts from "typescript";
|
|
21
|
+
import { hfsOf, inTestWorld } from "./lib/hfs.js";
|
|
22
|
+
import { baseNameOf, connectionFileOf, connectionsOf, inDatabaseCapability, inCli, infraTypeOf, injectionSites, injectorNameOf, mayHoldEntityManager, } from "./lib/persistence.js";
|
|
23
|
+
import { isPackageType, originsOfType, typed, typeOrigins } from "./lib/types.js";
|
|
35
24
|
/** The `@nestjs/typeorm` calls that build a second door to a connection. */
|
|
36
|
-
const RAW_CONNECTION_CALLS = new Set(["InjectEntityManager", "InjectDataSource", "getEntityManagerToken"])
|
|
37
|
-
|
|
25
|
+
const RAW_CONNECTION_CALLS = new Set(["InjectEntityManager", "InjectDataSource", "getEntityManagerToken"]);
|
|
38
26
|
/** The initializers that can be an injector factory; a plain value is never typed here. */
|
|
39
|
-
const FUNCTION_LIKE = new Set(["ArrowFunctionExpression", "FunctionExpression", "CallExpression"])
|
|
40
|
-
|
|
27
|
+
const FUNCTION_LIKE = new Set(["ArrowFunctionExpression", "FunctionExpression", "CallExpression"]);
|
|
41
28
|
/** Whether a file may build connections: the platform database capability and the cli app. */
|
|
42
|
-
const mayBuildConnections = (hfs, file) => inDatabaseCapability(hfs, file) || inCli(hfs, file)
|
|
43
|
-
|
|
29
|
+
const mayBuildConnections = (hfs, file) => inDatabaseCapability(hfs, file) || inCli(hfs, file);
|
|
44
30
|
/** `new DataSource(` also in the test world (`src/tests/world`), which owns the shared test infrastructure (owner ruling 2026-09-30). */
|
|
45
|
-
const mayConstructDataSource = (hfs, file) => mayBuildConnections(hfs, file) || inTestWorld(hfs, file)
|
|
46
|
-
|
|
31
|
+
const mayConstructDataSource = (hfs, file) => mayBuildConnections(hfs, file) || inTestWorld(hfs, file);
|
|
47
32
|
/** The connection whose name a string literal spells, or undefined. */
|
|
48
|
-
const connectionNamed = (hfs, node) =>
|
|
49
|
-
node?.type === "Literal" && typeof node.value === "string" ? connectionsOf(hfs).find((connection) => connection.name === node.value) : undefined
|
|
50
|
-
|
|
33
|
+
const connectionNamed = (hfs, node) => node?.type === "Literal" && typeof node.value === "string" ? connectionsOf(hfs).find((connection) => connection.name === node.value) : undefined;
|
|
51
34
|
/** Whether a symbol is the platform composition's `TypedParameterDecorator` alias. */
|
|
52
35
|
const isTypedParameterDecorator = (hfs, checker, symbol) => {
|
|
53
|
-
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol
|
|
54
|
-
const declaration = target.declarations?.find(ts.isTypeAliasDeclaration)
|
|
55
|
-
if (target.name !== "TypedParameterDecorator" || !declaration)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
37
|
+
const declaration = target.declarations?.find(ts.isTypeAliasDeclaration);
|
|
38
|
+
if (target.name !== "TypedParameterDecorator" || !declaration)
|
|
39
|
+
return false;
|
|
40
|
+
const found = hfs.classify(declaration.getSourceFile().fileName);
|
|
41
|
+
return found.slot === "be.platform" && found.bindings?.capability === "composition";
|
|
42
|
+
};
|
|
60
43
|
/** Whether a type argument is typeorm's `EntityManager`. */
|
|
61
|
-
const isEntityManagerArgument = (checker, type) => originsOfType(checker, type).some((origin) => origin.module === "typeorm" && origin.name === "EntityManager")
|
|
62
|
-
|
|
44
|
+
const isEntityManagerArgument = (checker, type) => originsOfType(checker, type).some((origin) => origin.module === "typeorm" && origin.name === "EntityManager");
|
|
63
45
|
/** Whether a written type is `TypedParameterDecorator<EntityManager>`, following the aliases written over it. */
|
|
64
46
|
const isEntityManagerDecoratorNode = (hfs, checker, node, depth) => {
|
|
65
|
-
if (!ts.isTypeReferenceNode(node) || depth > 4)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
if (!ts.isTypeReferenceNode(node) || depth > 4)
|
|
48
|
+
return false;
|
|
49
|
+
const symbol = checker.getSymbolAtLocation(node.typeName);
|
|
50
|
+
if (!symbol)
|
|
51
|
+
return false;
|
|
52
|
+
if (isTypedParameterDecorator(hfs, checker, symbol)) {
|
|
53
|
+
const argument = node.typeArguments?.[0];
|
|
54
|
+
return argument ? isEntityManagerArgument(checker, checker.getTypeFromTypeNode(argument)) : false;
|
|
55
|
+
}
|
|
56
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
57
|
+
const declaration = target.declarations?.find(ts.isTypeAliasDeclaration);
|
|
58
|
+
return declaration ? isEntityManagerDecoratorNode(hfs, checker, declaration.type, depth + 1) : false;
|
|
59
|
+
};
|
|
74
60
|
/** Whether a type is `TypedParameterDecorator<EntityManager>`, however an alias renamed it. */
|
|
75
61
|
const isEntityManagerDecorator = (hfs, checker, type) => {
|
|
76
|
-
const alias = type?.aliasSymbol
|
|
77
|
-
if (!alias)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
62
|
+
const alias = type?.aliasSymbol;
|
|
63
|
+
if (!alias)
|
|
64
|
+
return false;
|
|
65
|
+
if (isTypedParameterDecorator(hfs, checker, alias)) {
|
|
66
|
+
const argument = type.aliasTypeArguments?.[0];
|
|
67
|
+
return argument ? isEntityManagerArgument(checker, argument) : false;
|
|
68
|
+
}
|
|
69
|
+
const declaration = alias.declarations?.find(ts.isTypeAliasDeclaration);
|
|
70
|
+
return declaration ? isEntityManagerDecoratorNode(hfs, checker, declaration.type, 1) : false;
|
|
71
|
+
};
|
|
83
72
|
/** Whether the value written at `node` is an EntityManager injector: it, or what it returns, is `TypedParameterDecorator<EntityManager>`. */
|
|
84
73
|
const isEntityManagerInjector = (context, hfs, node) => {
|
|
85
|
-
const { checker, toTs } = typed(context)
|
|
86
|
-
const tsNode = toTs(node)
|
|
87
|
-
if (!tsNode)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
const { checker, toTs } = typed(context);
|
|
75
|
+
const tsNode = toTs(node);
|
|
76
|
+
if (!tsNode)
|
|
77
|
+
return false;
|
|
78
|
+
const type = checker.getTypeAtLocation(tsNode);
|
|
79
|
+
return [type, ...type.getCallSignatures().map((signature) => signature.getReturnType())].some((candidate) => isEntityManagerDecorator(hfs, checker, candidate));
|
|
80
|
+
};
|
|
92
81
|
/** Whether a call reaches a value declared by `pkg` under one of `names`, however it was imported. */
|
|
93
|
-
const callsPackage = (context, node, names, pkg) => typeOrigins(context, node).some((origin) => origin.module === pkg && names.has(origin.name))
|
|
94
|
-
|
|
82
|
+
const callsPackage = (context, node, names, pkg) => typeOrigins(context, node).some((origin) => origin.module === pkg && names.has(origin.name));
|
|
95
83
|
/** The constant a declared connection name is exported as: `expert-academy` gives `EXPERT_ACADEMY_CONNECTION`. */
|
|
96
|
-
const constantOf = (name) => `${name.toUpperCase().replace(/-/g, "_")}_CONNECTION
|
|
97
|
-
|
|
84
|
+
const constantOf = (name) => `${name.toUpperCase().replace(/-/g, "_")}_CONNECTION`;
|
|
98
85
|
/** The string an env key argument spells, or null when it is not a plain string. */
|
|
99
86
|
const keyText = (node) => {
|
|
100
|
-
if (node?.type === "Literal" && typeof node.value === "string")
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
87
|
+
if (node?.type === "Literal" && typeof node.value === "string")
|
|
88
|
+
return node.value;
|
|
89
|
+
if (node?.type !== "TemplateLiteral" || node.expressions.length !== 0)
|
|
90
|
+
return null;
|
|
91
|
+
const [quasi] = node.quasis;
|
|
92
|
+
return quasi ? quasi.value.cooked : null;
|
|
93
|
+
};
|
|
104
94
|
/** Whether a call's receiver is an `EnvSource` instance (the reader), not the class itself. */
|
|
105
95
|
const isEnvSourceReader = (context, hfs, object) => {
|
|
106
96
|
const isEnvSource = typeOrigins(context, object).some((origin) => {
|
|
107
|
-
const found = hfs.classify(origin.file)
|
|
108
|
-
return origin.name === "EnvSource" && found.slot === "be.platform" && found.bindings?.capability === "config"
|
|
109
|
-
})
|
|
110
|
-
if (!isEnvSource)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
97
|
+
const found = hfs.classify(origin.file);
|
|
98
|
+
return origin.name === "EnvSource" && found.slot === "be.platform" && found.bindings?.capability === "config";
|
|
99
|
+
});
|
|
100
|
+
if (!isEnvSource)
|
|
101
|
+
return false;
|
|
102
|
+
const { checker, toTs } = typed(context);
|
|
103
|
+
return checker.getTypeAtLocation(toTs(object)).getConstructSignatures().length === 0;
|
|
104
|
+
};
|
|
115
105
|
/** One physical database is one connection, one injector, one config and one registration. */
|
|
116
106
|
export const oneConnectionPerDatabase = {
|
|
117
107
|
meta: {
|
|
@@ -119,94 +109,104 @@ export const oneConnectionPerDatabase = {
|
|
|
119
109
|
docs: { description: "One database = one connection = one named `Inject<Conn>EntityManager` declared once in `platform/database`." },
|
|
120
110
|
schema: [],
|
|
121
111
|
messages: {
|
|
122
|
-
rawInjector:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"`{{what}}` builds a connection outside the platform database capability and the cli app. A connection is registered once, in `platform/database`; the cli app builds its `DataSource` from the same `<connection>.config.ts`.",
|
|
128
|
-
literal:
|
|
129
|
-
"The connection name `{{name}}` is written as a string here. It is written once, as `export const {{constant}} = \"{{name}}\"` in `platform/database/{{name}}.connection.ts`; import that constant.",
|
|
130
|
-
envKey:
|
|
131
|
-
"`{{key}}` is read in the config of connection `{{connection}}`, whose environment keys all start with `{{prefix}}_`. A key of another prefix would point this connection at another connection's database. Read `{{prefix}}_<NAME>` only, spelled as a string literal.",
|
|
112
|
+
rawInjector: "`{{name}}` is called here. A connection is reached only through its own injector: `{{name}}` is written in `platform/database/<connection>.decorators.ts`, the cli app and the test database fixture, and nowhere else. Inject the shared EntityManager with `Inject<Connection>EntityManager()`.",
|
|
113
|
+
injectorHome: "`{{name}}` is an EntityManager injector that is not the one injector of a declared connection. The only allowed injector is `Inject<Pascal(connection)>EntityManager`, exported from `platform/database/<connection>.decorators.ts` of a connection declared in `hfs.json`. A capability- or feature-specific injector, a second injector for one database and an alias are all a second door to the same database: use the connection's own injector.",
|
|
114
|
+
registration: "`{{what}}` builds a connection outside the platform database capability and the cli app. A connection is registered once, in `platform/database`; the cli app builds its `DataSource` from the same `<connection>.config.ts`.",
|
|
115
|
+
literal: "The connection name `{{name}}` is written as a string here. It is written once, as `export const {{constant}} = \"{{name}}\"` in `platform/database/{{name}}.connection.ts`; import that constant.",
|
|
116
|
+
envKey: "`{{key}}` is read in the config of connection `{{connection}}`, whose environment keys all start with `{{prefix}}_`. A key of another prefix would point this connection at another connection's database. Read `{{prefix}}_<NAME>` only, spelled as a string literal.",
|
|
132
117
|
},
|
|
133
118
|
},
|
|
134
119
|
create(context) {
|
|
135
|
-
const hfs = hfsOf(context)
|
|
136
|
-
const filename = context.filename || context.getFilename()
|
|
137
|
-
const decoratorsFile = connectionFileOf(hfs, filename, "decorators")
|
|
138
|
-
const connectionFile = connectionFileOf(hfs, filename, "connection")
|
|
139
|
-
const configFile = connectionFileOf(hfs, filename, "config")
|
|
140
|
-
const fixtureDatabase = hfs.slotOf(filename) === "be.tests.fixtures" && baseNameOf(filename) === "database.ts"
|
|
141
|
-
const mayRawInject = Boolean(decoratorsFile) || inCli(hfs, filename) || fixtureDatabase
|
|
142
|
-
const declaredNames = new Set(connectionsOf(hfs).map((connection) => injectorNameOf(connection.name)))
|
|
143
|
-
|
|
120
|
+
const hfs = hfsOf(context);
|
|
121
|
+
const filename = context.filename || context.getFilename();
|
|
122
|
+
const decoratorsFile = connectionFileOf(hfs, filename, "decorators");
|
|
123
|
+
const connectionFile = connectionFileOf(hfs, filename, "connection");
|
|
124
|
+
const configFile = connectionFileOf(hfs, filename, "config");
|
|
125
|
+
const fixtureDatabase = hfs.slotOf(filename) === "be.tests.fixtures" && baseNameOf(filename) === "database.ts";
|
|
126
|
+
const mayRawInject = Boolean(decoratorsFile) || inCli(hfs, filename) || fixtureDatabase;
|
|
127
|
+
const declaredNames = new Set(connectionsOf(hfs).map((connection) => injectorNameOf(connection.name)));
|
|
144
128
|
/** Reports each injector-typed value written at `node`, unless it is the declared injector of this file's own connection. */
|
|
145
129
|
const checkInjector = (name, node, reportNode) => {
|
|
146
|
-
if (!isEntityManagerInjector(context, hfs, node))
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
130
|
+
if (!isEntityManagerInjector(context, hfs, node))
|
|
131
|
+
return;
|
|
132
|
+
if (decoratorsFile && name === injectorNameOf(decoratorsFile.name))
|
|
133
|
+
return;
|
|
134
|
+
context.report({ node: reportNode, messageId: "injectorHome", data: { name } });
|
|
135
|
+
};
|
|
150
136
|
/** Reports a connection-name literal inside the options object of a registration. */
|
|
151
137
|
const checkOptionsName = (options) => {
|
|
152
|
-
if (options?.type !== "ObjectExpression")
|
|
138
|
+
if (options?.type !== "ObjectExpression")
|
|
139
|
+
return;
|
|
153
140
|
for (const property of options.properties) {
|
|
154
|
-
if (property.type !== "Property" || property.computed || property.key.name !== "name")
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
if (property.type !== "Property" || property.computed || property.key.type !== "Identifier" || property.key.name !== "name")
|
|
142
|
+
continue;
|
|
143
|
+
const named = connectionNamed(hfs, property.value);
|
|
144
|
+
if (named)
|
|
145
|
+
context.report({ node: property.value, messageId: "literal", data: { name: named.name, constant: constantOf(named.name) } });
|
|
157
146
|
}
|
|
158
|
-
}
|
|
147
|
+
};
|
|
159
148
|
return {
|
|
160
149
|
CallExpression(node) {
|
|
161
|
-
const { callee } = node
|
|
150
|
+
const { callee } = node;
|
|
162
151
|
if (callsPackage(context, callee, RAW_CONNECTION_CALLS, "@nestjs/typeorm")) {
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
152
|
+
const origin = typeOrigins(context, callee).find((candidate) => RAW_CONNECTION_CALLS.has(candidate.name));
|
|
153
|
+
if (!origin)
|
|
154
|
+
return;
|
|
155
|
+
const { name } = origin;
|
|
156
|
+
if (!mayRawInject)
|
|
157
|
+
context.report({ node, messageId: "rawInjector", data: { name } });
|
|
165
158
|
for (const argument of node.arguments) {
|
|
166
|
-
const named = connectionNamed(hfs, argument)
|
|
167
|
-
if (named)
|
|
159
|
+
const named = connectionNamed(hfs, argument);
|
|
160
|
+
if (named)
|
|
161
|
+
context.report({ node: argument, messageId: "literal", data: { name: named.name, constant: constantOf(named.name) } });
|
|
168
162
|
}
|
|
169
|
-
return
|
|
163
|
+
return;
|
|
170
164
|
}
|
|
171
165
|
if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && ["forRoot", "forRootAsync"].includes(callee.property.name)
|
|
172
166
|
&& isPackageType(context, callee.object, "TypeOrmModule", "@nestjs/typeorm")) {
|
|
173
|
-
if (!mayBuildConnections(hfs, filename))
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
if (!mayBuildConnections(hfs, filename))
|
|
168
|
+
context.report({ node, messageId: "registration", data: { what: `TypeOrmModule.${callee.property.name}` } });
|
|
169
|
+
checkOptionsName(node.arguments[0]);
|
|
170
|
+
return;
|
|
176
171
|
}
|
|
177
172
|
if (configFile && callee.type === "MemberExpression" && isEnvSourceReader(context, hfs, callee.object)) {
|
|
178
|
-
const key = keyText(node.arguments[0])
|
|
173
|
+
const key = keyText(node.arguments[0]);
|
|
179
174
|
if (key === null || !key.startsWith(`${configFile.envPrefix}_`)) {
|
|
180
|
-
context.report({ node: node.arguments[0] ?? node, messageId: "envKey", data: { key: key ?? "<not a string literal>", connection: configFile.name, prefix: configFile.envPrefix } })
|
|
175
|
+
context.report({ node: node.arguments[0] ?? node, messageId: "envKey", data: { key: key ?? "<not a string literal>", connection: configFile.name, prefix: configFile.envPrefix } });
|
|
181
176
|
}
|
|
182
177
|
}
|
|
183
178
|
},
|
|
184
179
|
NewExpression(node) {
|
|
185
|
-
if (!isPackageType(context, node.callee, "DataSource", "typeorm"))
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
if (!isPackageType(context, node.callee, "DataSource", "typeorm"))
|
|
181
|
+
return;
|
|
182
|
+
if (!mayConstructDataSource(hfs, filename))
|
|
183
|
+
context.report({ node, messageId: "registration", data: { what: "new DataSource(...)" } });
|
|
184
|
+
checkOptionsName(node.arguments[0]);
|
|
188
185
|
},
|
|
189
186
|
VariableDeclarator(node) {
|
|
190
|
-
if (node.id.type !== "Identifier")
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
if (node.id.type !== "Identifier")
|
|
188
|
+
return;
|
|
189
|
+
const named = connectionNamed(hfs, node.init);
|
|
190
|
+
if (named && node.init && node.id.name === constantOf(named.name) && connectionFile?.name !== named.name) {
|
|
191
|
+
context.report({ node: node.init, messageId: "literal", data: { name: named.name, constant: node.id.name } });
|
|
194
192
|
}
|
|
195
|
-
if (node.init && FUNCTION_LIKE.has(node.init.type))
|
|
193
|
+
if (node.init && FUNCTION_LIKE.has(node.init.type))
|
|
194
|
+
checkInjector(node.id.name, node.id, node.id);
|
|
196
195
|
},
|
|
197
196
|
FunctionDeclaration(node) {
|
|
198
|
-
if (node.id)
|
|
197
|
+
if (node.id)
|
|
198
|
+
checkInjector(node.id.name, node.id, node.id);
|
|
199
199
|
},
|
|
200
200
|
ExportSpecifier(node) {
|
|
201
|
-
const exported = node.exported.name
|
|
201
|
+
const exported = node.exported.type === "Identifier" ? node.exported.name : node.exported.value;
|
|
202
202
|
// Re-exporting a declared injector under its own name is the owner's public surface; an alias is a second injector.
|
|
203
|
-
if (declaredNames.has(exported) || (!node.parent.source && node.local.name === exported))
|
|
204
|
-
|
|
203
|
+
if (declaredNames.has(exported) || (!node.parent.source && node.local.type === "Identifier" && node.local.name === exported))
|
|
204
|
+
return;
|
|
205
|
+
checkInjector(exported, node.local, node.exported);
|
|
205
206
|
},
|
|
206
|
-
}
|
|
207
|
+
};
|
|
207
208
|
},
|
|
208
|
-
}
|
|
209
|
-
|
|
209
|
+
};
|
|
210
210
|
/** An EntityManager is injected in an application handler, a domain service or a platform persistence capability only. */
|
|
211
211
|
export const emInjectionSlots = {
|
|
212
212
|
meta: {
|
|
@@ -214,30 +214,28 @@ export const emInjectionSlots = {
|
|
|
214
214
|
docs: { description: "An `EntityManager` is injected only in application handlers, domain services, projections and the platform capabilities that own a `persistence/`." },
|
|
215
215
|
schema: [],
|
|
216
216
|
messages: {
|
|
217
|
-
slot:
|
|
218
|
-
"`EntityManager` is injected in a file of slot `{{slot}}`. Only an application `*.handler.ts`, a domain `*.service.ts`, a projection's `*.projection.ts` and the platform database, inbox, event-bus, queue and jobs capabilities reach the database. Transport dispatches a command or query, an integration calls its provider, an app composes: move the data access into a handler or a domain service.",
|
|
217
|
+
slot: "`EntityManager` is injected in a file of slot `{{slot}}`. Only an application `*.handler.ts`, a domain `*.service.ts`, a projection's `*.projection.ts` and the platform database, inbox, event-bus, queue and jobs capabilities reach the database. Transport dispatches a command or query, an integration calls its provider, an app composes: move the data access into a handler or a domain service.",
|
|
219
218
|
},
|
|
220
219
|
},
|
|
221
220
|
create(context) {
|
|
222
|
-
const hfs = hfsOf(context)
|
|
223
|
-
const filename = context.filename || context.getFilename()
|
|
224
|
-
if (mayHoldEntityManager(hfs, filename))
|
|
221
|
+
const hfs = hfsOf(context);
|
|
222
|
+
const filename = context.filename || context.getFilename();
|
|
223
|
+
if (mayHoldEntityManager(hfs, filename))
|
|
224
|
+
return {};
|
|
225
225
|
return injectionSites(({ node, annotation }) => {
|
|
226
226
|
if (annotation && infraTypeOf(context, annotation) === "EntityManager") {
|
|
227
|
-
context.report({ node, messageId: "slot", data: { slot: hfs.slotOf(filename) ?? "no slot" } })
|
|
227
|
+
context.report({ node, messageId: "slot", data: { slot: hfs.slotOf(filename) ?? "no slot" } });
|
|
228
228
|
}
|
|
229
|
-
})
|
|
229
|
+
});
|
|
230
230
|
},
|
|
231
|
-
}
|
|
232
|
-
|
|
231
|
+
};
|
|
233
232
|
/** The rules this law contributes to the plugin. */
|
|
234
233
|
export const rules = {
|
|
235
234
|
"one-connection-per-database": oneConnectionPerDatabase,
|
|
236
235
|
"em-injection-slots": emInjectionSlots,
|
|
237
|
-
}
|
|
238
|
-
|
|
236
|
+
};
|
|
239
237
|
/** Every rule of this law ships at `error`. */
|
|
240
238
|
export const recommended = {
|
|
241
239
|
"starci-be/one-connection-per-database": "error",
|
|
242
240
|
"starci-be/em-injection-slots": "error",
|
|
243
|
-
}
|
|
241
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
+
/** A cookie a door writes states httpOnly, secure and sameSite, and no door writes `Set-Cookie` by hand. */
|
|
3
|
+
export declare const responseCookieAttributes: RuleModule;
|
|
4
|
+
/** Every rule this module ships, by the name a config switches it on under. */
|
|
5
|
+
export declare const rules: {
|
|
6
|
+
"response-cookie-attributes": RuleModule;
|
|
7
|
+
};
|
|
8
|
+
/** The level a consuming repository switches this on at. */
|
|
9
|
+
export declare const recommended: Recommended;
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* states none of the three. The call is recognised by where its signature is declared (the `express` or `fastify` family of
|
|
9
9
|
* packages), never by the name of the receiver.
|
|
10
10
|
*/
|
|
11
|
-
import ts from "typescript"
|
|
12
|
-
import { moduleOf, typed } from "./lib/types.
|
|
13
|
-
|
|
11
|
+
import ts from "typescript";
|
|
12
|
+
import { moduleOf, typed } from "./lib/types.js";
|
|
14
13
|
/** The packages whose response types declare the cookie writers: Express with its typings, and Fastify with its cookie plugin. */
|
|
15
14
|
const RESPONSE_PACKAGES = new Set([
|
|
16
15
|
"express",
|
|
@@ -19,46 +18,45 @@ const RESPONSE_PACKAGES = new Set([
|
|
|
19
18
|
"@types/express-serve-static-core",
|
|
20
19
|
"fastify",
|
|
21
20
|
"@fastify/cookie",
|
|
22
|
-
])
|
|
23
|
-
|
|
21
|
+
]);
|
|
24
22
|
/** The response methods that write a cookie by name, value and options, and the ones that write a header by name. */
|
|
25
|
-
const COOKIE_WRITERS = new Set(["cookie", "setCookie"])
|
|
26
|
-
const HEADER_WRITERS = new Set(["setHeader", "append", "header", "set", "appendHeader"])
|
|
27
|
-
const SAME_SITE = new Set(["lax", "strict"])
|
|
28
|
-
|
|
23
|
+
const COOKIE_WRITERS = new Set(["cookie", "setCookie"]);
|
|
24
|
+
const HEADER_WRITERS = new Set(["setHeader", "append", "header", "set", "appendHeader"]);
|
|
25
|
+
const SAME_SITE = new Set(["lax", "strict"]);
|
|
29
26
|
/** The declaration a call resolves to, when it is a method of a response type of the express or fastify family; else null. */
|
|
30
27
|
const responseMethodOf = (checker, toTs, call) => {
|
|
31
|
-
const tsCall = toTs(call)
|
|
32
|
-
const declaration = tsCall ? checker.getResolvedSignature(tsCall)?.declaration : undefined
|
|
33
|
-
if (!declaration || !(ts.isMethodSignature(declaration) || ts.isMethodDeclaration(declaration)) || !declaration.name)
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const tsCall = toTs(call);
|
|
29
|
+
const declaration = tsCall ? checker.getResolvedSignature(tsCall)?.declaration : undefined;
|
|
30
|
+
if (!declaration || !(ts.isMethodSignature(declaration) || ts.isMethodDeclaration(declaration)) || !declaration.name)
|
|
31
|
+
return null;
|
|
32
|
+
const file = String(declaration.getSourceFile().fileName).split("\\").join("/");
|
|
33
|
+
const pkg = moduleOf(declaration, file);
|
|
34
|
+
return pkg !== null && RESPONSE_PACKAGES.has(pkg) ? declaration.name.getText() : null;
|
|
35
|
+
};
|
|
39
36
|
/** The present (non-nullish) members of a property's type on an options type, or [] when the property is absent or only nullish. */
|
|
40
37
|
const presentParts = (checker, type, name, at) => {
|
|
41
|
-
const symbol = type.getProperty(name)
|
|
42
|
-
if (!symbol)
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const isBooleanLiteral = (part, value) => Boolean(part.flags & ts.TypeFlags.BooleanLiteral) && part.intrinsicName === String(value)
|
|
49
|
-
|
|
38
|
+
const symbol = type.getProperty(name);
|
|
39
|
+
if (!symbol)
|
|
40
|
+
return [];
|
|
41
|
+
const propertyType = checker.getTypeOfSymbolAtLocation(symbol, at);
|
|
42
|
+
const parts = propertyType.isUnion() ? propertyType.types : [propertyType];
|
|
43
|
+
return parts.filter((part) => !(part.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Void)));
|
|
44
|
+
};
|
|
45
|
+
const isBooleanLiteral = (part, value) => Boolean(part.flags & ts.TypeFlags.BooleanLiteral) && "intrinsicName" in part && part.intrinsicName === String(value);
|
|
50
46
|
/** The attributes a written cookie is missing, judged on the type of its options. */
|
|
51
47
|
const missingAttributes = (checker, type, at) => {
|
|
52
|
-
const missing = []
|
|
53
|
-
const httpOnly = presentParts(checker, type, "httpOnly", at)
|
|
54
|
-
if (httpOnly.length === 0 || !httpOnly.every((part) => isBooleanLiteral(part, true)))
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
const missing = [];
|
|
49
|
+
const httpOnly = presentParts(checker, type, "httpOnly", at);
|
|
50
|
+
if (httpOnly.length === 0 || !httpOnly.every((part) => isBooleanLiteral(part, true)))
|
|
51
|
+
missing.push("`httpOnly: true`");
|
|
52
|
+
const secure = presentParts(checker, type, "secure", at);
|
|
53
|
+
if (secure.length === 0 || !secure.every((part) => isBooleanLiteral(part, true)))
|
|
54
|
+
missing.push("`secure: true`");
|
|
55
|
+
const sameSite = presentParts(checker, type, "sameSite", at);
|
|
56
|
+
if (sameSite.length === 0 || !sameSite.every((part) => part.isStringLiteral() && SAME_SITE.has(part.value)))
|
|
57
|
+
missing.push('`sameSite: "lax"` or `"strict"`');
|
|
58
|
+
return missing;
|
|
59
|
+
};
|
|
62
60
|
/** A cookie a door writes states httpOnly, secure and sameSite, and no door writes `Set-Cookie` by hand. */
|
|
63
61
|
export const responseCookieAttributes = {
|
|
64
62
|
meta: {
|
|
@@ -66,41 +64,43 @@ export const responseCookieAttributes = {
|
|
|
66
64
|
docs: { description: "A cookie written through an Express or Fastify response states `httpOnly: true`, `secure: true` and `sameSite` `lax` or `strict`; `Set-Cookie` is never written as a header." },
|
|
67
65
|
schema: [],
|
|
68
66
|
messages: {
|
|
69
|
-
attributes:
|
|
70
|
-
"This cookie is written without {{missing}}. A cookie left to the defaults is readable by page script, travels over plain HTTP and is sent on cross-site requests: pass one options constant, declared `as const` by the owner of the cookie, that states `httpOnly: true`, `secure: true` and `sameSite` `lax` or `strict`.",
|
|
67
|
+
attributes: "This cookie is written without {{missing}}. A cookie left to the defaults is readable by page script, travels over plain HTTP and is sent on cross-site requests: pass one options constant, declared `as const` by the owner of the cookie, that states `httpOnly: true`, `secure: true` and `sameSite` `lax` or `strict`.",
|
|
71
68
|
raw: "`Set-Cookie` is written here as a header, which states none of `httpOnly`, `secure` and `sameSite`. Write the cookie through the response's `cookie(name, value, options)` with an options constant that states all three.",
|
|
72
69
|
},
|
|
73
70
|
},
|
|
74
71
|
create(context) {
|
|
75
|
-
const { checker, toTs } = typed(context)
|
|
72
|
+
const { checker, toTs } = typed(context);
|
|
76
73
|
return {
|
|
77
74
|
CallExpression(node) {
|
|
78
|
-
if (node.callee.type !== "MemberExpression")
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
if (node.callee.type !== "MemberExpression")
|
|
76
|
+
return;
|
|
77
|
+
const method = responseMethodOf(checker, toTs, node);
|
|
78
|
+
if (method === null)
|
|
79
|
+
return;
|
|
81
80
|
if (COOKIE_WRITERS.has(method)) {
|
|
82
|
-
const options = node.arguments[2]
|
|
83
|
-
const tsOptions = options ? toTs(options) : undefined
|
|
84
|
-
const missing = tsOptions ? missingAttributes(checker, checker.getTypeAtLocation(tsOptions), tsOptions) : ["`httpOnly: true`", "`secure: true`", '`sameSite: "lax"` or `"strict"`']
|
|
85
|
-
if (missing.length > 0)
|
|
86
|
-
|
|
81
|
+
const options = node.arguments[2];
|
|
82
|
+
const tsOptions = options ? toTs(options) : undefined;
|
|
83
|
+
const missing = tsOptions ? missingAttributes(checker, checker.getTypeAtLocation(tsOptions), tsOptions) : ["`httpOnly: true`", "`secure: true`", '`sameSite: "lax"` or `"strict"`'];
|
|
84
|
+
if (missing.length > 0)
|
|
85
|
+
context.report({ node, messageId: "attributes", data: { missing: missing.join(", ") } });
|
|
86
|
+
return;
|
|
87
87
|
}
|
|
88
|
-
if (!HEADER_WRITERS.has(method))
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
88
|
+
if (!HEADER_WRITERS.has(method))
|
|
89
|
+
return;
|
|
90
|
+
const name = node.arguments[0];
|
|
91
|
+
const tsName = name ? toTs(name) : undefined;
|
|
92
|
+
const type = tsName ? checker.getTypeAtLocation(tsName) : undefined;
|
|
93
|
+
if (type?.isStringLiteral() && type.value.toLowerCase() === "set-cookie")
|
|
94
|
+
context.report({ node, messageId: "raw" });
|
|
93
95
|
},
|
|
94
|
-
}
|
|
96
|
+
};
|
|
95
97
|
},
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
+
};
|
|
98
99
|
/** Every rule this module ships, by the name a config switches it on under. */
|
|
99
100
|
export const rules = {
|
|
100
101
|
"response-cookie-attributes": responseCookieAttributes,
|
|
101
|
-
}
|
|
102
|
-
|
|
102
|
+
};
|
|
103
103
|
/** The level a consuming repository switches this on at. */
|
|
104
104
|
export const recommended = {
|
|
105
105
|
"starci-be/response-cookie-attributes": "error",
|
|
106
|
-
}
|
|
106
|
+
};
|
package/dist/cqrs.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
+
/** A handler implements the template's `process` and never overrides its public `execute`. */
|
|
3
|
+
export declare const handlerOverridesProcess: RuleModule;
|
|
4
|
+
/** A handler maps its input, calls exactly one method of an injected service and returns its result. */
|
|
5
|
+
export declare const handlerIsThin: RuleModule;
|
|
6
|
+
/** A message carries request context and nothing else. */
|
|
7
|
+
export declare const messageCarriesParamsOnly: RuleModule;
|
|
8
|
+
/** A message states the type of its result: `Command<R>` / `Query<R>` from `@nestjs/cqrs`, one readonly `params`. */
|
|
9
|
+
export declare const messageTypedResult: RuleModule;
|
|
10
|
+
/** A message's `params` is `ExecuteParams<X>` / `PublicExecuteParams<X>` of `platform/cqrs` and X holds no entity. */
|
|
11
|
+
export declare const executeParamsShape: RuleModule;
|
|
12
|
+
/** No use-case class and no forwarder service: the transport dispatches on the bus itself. */
|
|
13
|
+
export declare const noUseCase: RuleModule;
|
|
14
|
+
/** No in-process events: a side effect that must happen anyway is an event published through the bus. */
|
|
15
|
+
export declare const noEventBus: RuleModule;
|
|
16
|
+
/** The rules this law contributes to the plugin. */
|
|
17
|
+
export declare const rules: {
|
|
18
|
+
"handler-overrides-process": RuleModule;
|
|
19
|
+
"handler-is-thin": RuleModule;
|
|
20
|
+
"message-carries-params-only": RuleModule;
|
|
21
|
+
"message-typed-result": RuleModule;
|
|
22
|
+
"execute-params-shape": RuleModule;
|
|
23
|
+
"no-use-case": RuleModule;
|
|
24
|
+
"no-event-bus": RuleModule;
|
|
25
|
+
};
|
|
26
|
+
/** Every rule of this law at `error`. */
|
|
27
|
+
export declare const recommended: Recommended;
|