@ddd-ts-kit/eslint-plugin 0.10.0 → 0.12.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/README.md +3 -0
- package/dist/rules/domain-events-transactional-before-commit.js +2 -2
- package/dist/rules/domain-events-transactional-before-commit.js.map +1 -1
- package/dist/rules/lifecycle-status-through-machine.d.ts +3 -0
- package/dist/rules/lifecycle-status-through-machine.d.ts.map +1 -0
- package/dist/rules/lifecycle-status-through-machine.js +89 -0
- package/dist/rules/lifecycle-status-through-machine.js.map +1 -0
- package/dist/rules/presentation-shared-cache-varies.d.ts +2 -0
- package/dist/rules/presentation-shared-cache-varies.d.ts.map +1 -0
- package/dist/rules/presentation-shared-cache-varies.js +82 -0
- package/dist/rules/presentation-shared-cache-varies.js.map +1 -0
- package/dist/rules/process-sends-commands-only.d.ts +2 -0
- package/dist/rules/process-sends-commands-only.d.ts.map +1 -0
- package/dist/rules/process-sends-commands-only.js +46 -0
- package/dist/rules/process-sends-commands-only.js.map +1 -0
- package/dist/rules/rules.d.ts.map +1 -1
- package/dist/rules/rules.js +6 -0
- package/dist/rules/rules.js.map +1 -1
- package/dist/support/standard-interfaces/parallel-names.d.ts.map +1 -1
- package/dist/support/standard-interfaces/parallel-names.js +6 -0
- package/dist/support/standard-interfaces/parallel-names.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/rules/domain-events-transactional-before-commit.md +1 -1
- package/docs/rules/lifecycle-status-through-machine.md +69 -0
- package/docs/rules/presentation-shared-cache-varies.md +54 -0
- package/docs/rules/process-sends-commands-only.md +63 -0
- package/docs/rules/standard-no-parallel-interface.md +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,6 +113,7 @@ is an error whatever the configured limit). `strict` sets every rule to `error`.
|
|
|
113
113
|
| [`presentation/controller-shape`](docs/rules/presentation-controller-shape.md) | `ddd-ts-kit/presentation-controller-shape` | a `*.controller.ts` carrying `@Controller` exports one class whose single public method is `handle` | `error` | custom |
|
|
114
114
|
| [`presentation/controller-delegates`](docs/rules/presentation-controller-delegates.md) | `ddd-ts-kit/presentation-controller-delegates` | a controller is given the bus of its method, a request mapper and a serializer, nothing else | `error` | custom |
|
|
115
115
|
| [`presentation/guard-at-the-edge`](docs/rules/presentation-guard-at-the-edge.md) | `ddd-ts-kit/presentation-guard-at-the-edge` | a `*.guard.ts` imports nothing from `domain/` or `infrastructure/`, no repository, no unit of work, no command bus | `error` | custom |
|
|
116
|
+
| [`presentation/shared-cache-varies`](docs/rules/presentation-shared-cache-varies.md) | `ddd-ts-kit/presentation-shared-cache-varies` | a `public` cache policy of a route, a controller or a route group that knows its caller names in `vary` what its answer depends on | `error` | custom |
|
|
116
117
|
| [`application/command-query-separation`](docs/rules/application-command-query-separation.md) | `ddd-ts-kit/application-command-query-separation` | nothing under `application/queries` calls `save`, `delete`, `publish` on a dependency | `warn` | custom |
|
|
117
118
|
| [`domain-events/dispatched-on-save`](docs/rules/domain-events-dispatched-on-save.md) | `ddd-ts-kit/domain-events-dispatched-on-save` | no `pullEvents()` in `application/` and `infrastructure/`; no `DomainEventDispatcher` imported, listed as a dependency or received by a constructor in `application/commands`, `application/queries` and a repository adapter | `error` | custom |
|
|
118
119
|
| [`domain-events/transactional-before-commit`](docs/rules/domain-events-transactional-before-commit.md) | `ddd-ts-kit/domain-events-transactional-before-commit` | a class carrying `@DomainEventHandler` without `phase: 'after-commit'` depends on no `Cache`, `Lock`, `RateLimiter`, `JobScheduler` or `EventBus` of the kernel and on nothing imported from `infrastructure/`, another context, the platform or a package other than `@ddd-ts-kit/kernel` and `@ddd-ts-kit/auth`; an after-commit handler does not depend on `IntegrationEventPublisher`. The adapters of an `application/ports/` port and the phase of an explicit-style handler are held by the CLI checker | `error` | custom |
|
|
@@ -142,6 +143,8 @@ is an error whatever the configured limit). `strict` sets every rule to `error`.
|
|
|
142
143
|
| [`ports/value-import`](docs/rules/ports-value-import.md) | `ddd-ts-kit/ports-value-import` | a port named in a dependency list or given to `bind` is not a type-only import; fixable | `error` | custom |
|
|
143
144
|
| [`scheduling/job-triggers-use-case`](docs/rules/scheduling-job-triggers-use-case.md) | `ddd-ts-kit/scheduling-job-triggers-use-case` | a job lives in `application/scheduling/*.job.ts`, implements `ScheduledJob`, sends a command, and touches neither a repository nor the model | `error` | custom |
|
|
144
145
|
| [`scheduling/job-name`](docs/rules/scheduling-job-name.md) | `ddd-ts-kit/scheduling-job-name` | a job is named `<context>.<job-name>` by a string literal, and its `systemActor` carries that name | `error` | custom |
|
|
146
|
+
| [`lifecycle/status-through-machine`](docs/rules/lifecycle-status-through-machine.md) | `ddd-ts-kit/lifecycle-status-through-machine` | in an aggregate that imports its state machine, the status is written only from the machine (`next`, `start`) or copied from a status already read | `error` | custom |
|
|
147
|
+
| [`process/sends-commands-only`](docs/rules/process-sends-commands-only.md) | `ddd-ts-kit/process-sends-commands-only` | a process manager of `application/processes/` imports no aggregate, entity, repository, domain service, port or infrastructure: it changes the world through the commands it decides | `error` | custom |
|
|
145
148
|
| [`imports/alias-only`](docs/rules/imports-alias-only.md) | `ddd-ts-kit/imports-alias-only` | a file of the project is imported by its alias (`@/...`, `$test/...`, `$scripts/...`), never by a relative path, the same directory included; no `.` or `..` segment in an alias path; fixable | `error` | custom |
|
|
146
149
|
| [`imports/extension`](docs/rules/imports-extension.md) | `ddd-ts-kit/imports-extension` | an import of a file of the project ends as `importExtension` of the config says: no extension under `none`, `.js` under `js`; fixable | `error` | custom |
|
|
147
150
|
|
|
@@ -12,14 +12,14 @@ const DECORATOR = 'DomainEventHandler';
|
|
|
12
12
|
const KERNEL = '@ddd-ts-kit/kernel';
|
|
13
13
|
const TRUSTED_PACKAGES = new Set([KERNEL, '@ddd-ts-kit/auth']);
|
|
14
14
|
/** The ports of the kernel whose effect no transaction covers. */
|
|
15
|
-
const OUTSIDE_THE_TRANSACTION = new Set(['Cache', 'Lock', 'RateLimiter', 'JobScheduler', 'EventBus']);
|
|
15
|
+
const OUTSIDE_THE_TRANSACTION = new Set(['Cache', 'CachePurger', 'Lock', 'RateLimiter', 'JobScheduler', 'EventBus']);
|
|
16
16
|
const PUBLISHER = 'IntegrationEventPublisher';
|
|
17
17
|
const ROLLED_BACK = "A handler that runs before the commit runs inside the transaction, and the commit can still fail after it ran: it may only have effects the rollback undoes. Declare the handler `phase: 'after-commit'` when its effect may be lost on a crash (it then runs at most once), or publish an integration event from a publisher (outbox, at least once) and do the work in the handler of that event when it must not be lost.";
|
|
18
18
|
export const domainEventsTransactionalBeforeCommit = defineRule({
|
|
19
19
|
id: 'domain-events/transactional-before-commit',
|
|
20
20
|
type: 'problem',
|
|
21
21
|
recommended: 'error',
|
|
22
|
-
description: 'A declared domain event handler that runs before the commit has only effects the rollback undoes: no Cache, Lock, RateLimiter, JobScheduler or EventBus of the kernel, nothing from infrastructure/, another context, the platform or a foreign package; an after-commit handler never depends on IntegrationEventPublisher.',
|
|
22
|
+
description: 'A declared domain event handler that runs before the commit has only effects the rollback undoes: no Cache, CachePurger, Lock, RateLimiter, JobScheduler or EventBus of the kernel, nothing from infrastructure/, another context, the platform or a foreign package; an after-commit handler never depends on IntegrationEventPublisher.',
|
|
23
23
|
messages: {
|
|
24
24
|
beforeCommit: `{{handler}} runs before the commit and depends on {{name}}, {{why}}: its effect would survive a rollback. ${ROLLED_BACK}`,
|
|
25
25
|
afterCommit: `{{handler}} runs after the commit and depends on {{name}}: the event it publishes would be committed apart from the state change it announces. Send a command through the \`CommandBus\` port and let the publisher of the event that command records write to the outbox, or leave this handler before the commit.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-events-transactional-before-commit.js","sourceRoot":"","sources":["../../src/rules/domain-events-transactional-before-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAkB,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAoB,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAU5E,MAAM,SAAS,GAAG,oBAAoB,CAAC;AACvC,MAAM,MAAM,GAAG,oBAAoB,CAAC;AACpC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAC/D,kEAAkE;AAClE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"domain-events-transactional-before-commit.js","sourceRoot":"","sources":["../../src/rules/domain-events-transactional-before-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAkB,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAoB,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE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K,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,+BAA+B,CAAC;IACzC,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,gCAAgC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,KAAK,gBAAgB,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpG,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,QAAQ,EAAU,EAAE,WAAmB;IAC5D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,OAAO,gCAAgC,WAAW,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,WAAW,KAAK,MAAM,IAAI,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC;QACpE,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const lifecycleStatusThroughMachine: TSESLint.RuleModule<"notThroughMachine", [], import("../index.js").RuleDocs, TSESLint.RuleListener>;
|
|
3
|
+
//# sourceMappingURL=lifecycle-status-through-machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-status-through-machine.d.ts","sourceRoot":"","sources":["../../src/rules/lifecycle-status-through-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAYlG,eAAO,MAAM,6BAA6B,qGAgDxC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { AST_NODE_TYPES, ASTUtils } from '@typescript-eslint/utils';
|
|
2
|
+
import { className } from '../support/classes/class-name.js';
|
|
3
|
+
import { enclosingMember } from '../support/classes/enclosing-member.js';
|
|
4
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
5
|
+
const STATUS = 'status';
|
|
6
|
+
const MACHINE_FILE = /(?:^|\/)state-machines\/[^/]+\.state-machine(?:\.[cm]?[jt]s)?$/;
|
|
7
|
+
const THROUGH = new Set(['next', 'start']);
|
|
8
|
+
export const lifecycleStatusThroughMachine = defineRule({
|
|
9
|
+
id: 'lifecycle/status-through-machine',
|
|
10
|
+
type: 'problem',
|
|
11
|
+
recommended: 'error',
|
|
12
|
+
description: 'In an aggregate that imports its state machine, the status is written only from the machine (`machine.next(...)`, `machine.start(...)`) or copied from a status already read.',
|
|
13
|
+
messages: {
|
|
14
|
+
notThroughMachine: "{{className}} writes its status without its state machine ({{value}}). Ask the machine: `status: {{machine}}.next(this.state.status, '<transition>')`, so that a forbidden transition is refused in one place.",
|
|
15
|
+
},
|
|
16
|
+
create({ file, sourceCode, report }) {
|
|
17
|
+
if (!isAggregateFile(file)) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const machines = new Set();
|
|
21
|
+
const judge = (node, value) => {
|
|
22
|
+
const site = enclosingMember(node);
|
|
23
|
+
const machine = [...machines][0];
|
|
24
|
+
if (site === undefined || machine === undefined || isThroughMachine(value, { machines, sourceCode })) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const data = { className: className(site.body.parent), value: sourceCode.getText(value), machine };
|
|
28
|
+
report({ node: value, messageId: 'notThroughMachine', data });
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
ImportDeclaration(node) {
|
|
32
|
+
if (MACHINE_FILE.test(node.source.value)) {
|
|
33
|
+
node.specifiers.forEach((specifier) => machines.add(specifier.local.name));
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
Property(node) {
|
|
37
|
+
if (node.parent.type === AST_NODE_TYPES.ObjectExpression && keyIsStatus(node.key)) {
|
|
38
|
+
judge(node, node.value);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
AssignmentExpression(node) {
|
|
42
|
+
if (node.left.type === AST_NODE_TYPES.MemberExpression && keyIsStatus(node.left.property)) {
|
|
43
|
+
judge(node, node.right);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
function isAggregateFile(file) {
|
|
50
|
+
const { location } = file;
|
|
51
|
+
return (location.area === 'context' && location.layer === 'domain' && !file.isTest && location.inside[0] === 'aggregates');
|
|
52
|
+
}
|
|
53
|
+
function keyIsStatus(key) {
|
|
54
|
+
return ((key.type === AST_NODE_TYPES.Identifier && key.name === STATUS) ||
|
|
55
|
+
(key.type === AST_NODE_TYPES.Literal && key.value === STATUS));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A call of the machine, or a status copied from one already read (`this.state.status`, a
|
|
59
|
+
* parameter named `status`, `const { status } = ...`). A local binding is followed back to its value:
|
|
60
|
+
* `const status = InvoiceStatus.Paid; this.state = { ...this.state, status }` is a write by hand.
|
|
61
|
+
*/
|
|
62
|
+
function isThroughMachine(value, judged) {
|
|
63
|
+
if (value.type === AST_NODE_TYPES.Identifier) {
|
|
64
|
+
return isBoundThroughMachine(value, judged);
|
|
65
|
+
}
|
|
66
|
+
if (value.type === AST_NODE_TYPES.MemberExpression) {
|
|
67
|
+
return keyIsStatus(value.property);
|
|
68
|
+
}
|
|
69
|
+
return isMachineCall(value, judged.machines);
|
|
70
|
+
}
|
|
71
|
+
function isBoundThroughMachine(identifier, judged) {
|
|
72
|
+
const definition = ASTUtils.findVariable(judged.sourceCode.getScope(identifier), identifier.name)?.defs[0];
|
|
73
|
+
if (definition?.node.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
74
|
+
return definition !== undefined && identifier.name === STATUS;
|
|
75
|
+
}
|
|
76
|
+
const { id, init } = definition.node;
|
|
77
|
+
return id.type !== AST_NODE_TYPES.Identifier || (init !== null && isThroughMachine(init, judged));
|
|
78
|
+
}
|
|
79
|
+
function isMachineCall(value, machines) {
|
|
80
|
+
if (value.type !== AST_NODE_TYPES.CallExpression || value.callee.type !== AST_NODE_TYPES.MemberExpression) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const { object, property } = value.callee;
|
|
84
|
+
return (object.type === AST_NODE_TYPES.Identifier &&
|
|
85
|
+
machines.has(object.name) &&
|
|
86
|
+
property.type === AST_NODE_TYPES.Identifier &&
|
|
87
|
+
THROUGH.has(property.name));
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=lifecycle-status-through-machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-status-through-machine.js","sourceRoot":"","sources":["../../src/rules/lifecycle-status-through-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAgC,MAAM,0BAA0B,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,YAAY,GAAG,gEAAgE,CAAC;AACtF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAI3C,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAY;IACjE,EAAE,EAAE,kCAAkC;IACtC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,OAAO;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C,IAAI,KAAK,cAAc,CAAC,UAAU;QAC3C,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const presentationSharedCacheVaries: import("@typescript-eslint/utils/ts-eslint").RuleModule<"sharedWithoutVary", [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
2
|
+
//# sourceMappingURL=presentation-shared-cache-varies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-shared-cache-varies.d.ts","sourceRoot":"","sources":["../../src/rules/presentation-shared-cache-varies.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,6BAA6B,6KAiBxC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { calleeName } from '../support/calls/callee-name.js';
|
|
3
|
+
import { propertyOf } from '../support/calls/property-of.js';
|
|
4
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
5
|
+
const DECLARATIONS = new Set(['Controller', 'RouteGroup', 'defineRoute']);
|
|
6
|
+
const SHARED = 'public';
|
|
7
|
+
const OPEN_GUARD = 'Public';
|
|
8
|
+
export const presentationSharedCacheVaries = defineRule({
|
|
9
|
+
id: 'presentation/shared-cache-varies',
|
|
10
|
+
type: 'problem',
|
|
11
|
+
recommended: 'error',
|
|
12
|
+
description: 'A route, a controller or a route group that knows its caller (behind a guard other than `Public`, or naming security schemes) and declares a `public` cache policy names in `vary` the request headers its answer depends on: a shared cache never hands the answer of one caller to the next.',
|
|
13
|
+
messages: {
|
|
14
|
+
sharedWithoutVary: 'This {{what}} keeps its answers in shared caches (`scope: public`) and {{why}}. A shared cache files an answer by its URL and hands it to the next caller: declare `scope: CacheScope.private`, or name in `vary` the request headers the answer depends on (`Authorization`, a tenant header). Never cache a decision of authorization across actors.',
|
|
15
|
+
},
|
|
16
|
+
create({ file, report }) {
|
|
17
|
+
if (file.isTest) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
return { CallExpression: (node) => judgeDeclaration(node, report) };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
function judgeDeclaration(node, report) {
|
|
24
|
+
const name = calleeName(node) ?? '';
|
|
25
|
+
const [spec] = node.arguments;
|
|
26
|
+
if (!DECLARATIONS.has(name) || spec?.type !== AST_NODE_TYPES.ObjectExpression) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const cache = sharedWithoutVary(spec);
|
|
30
|
+
const why = name === 'defineRoute' ? namesSchemes(spec) : guarded(spec);
|
|
31
|
+
if (cache !== undefined && why !== undefined) {
|
|
32
|
+
report({ node: cache, messageId: 'sharedWithoutVary', data: { what: whatOf(name), why } });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The cache policy of a declaration, when shared caches keep its answers and it names nothing they vary on. */
|
|
36
|
+
function sharedWithoutVary(spec) {
|
|
37
|
+
const cache = propertyOf(spec, 'cache')?.value;
|
|
38
|
+
if (cache?.type !== AST_NODE_TYPES.ObjectExpression || !isShared(cache) || varies(cache)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return cache;
|
|
42
|
+
}
|
|
43
|
+
/** `scope: CacheScope.public` or `scope: 'public'`. */
|
|
44
|
+
function isShared(cache) {
|
|
45
|
+
const scope = propertyOf(cache, 'scope')?.value;
|
|
46
|
+
if (scope?.type === AST_NODE_TYPES.Literal) {
|
|
47
|
+
return scope.value === SHARED;
|
|
48
|
+
}
|
|
49
|
+
return (scope?.type === AST_NODE_TYPES.MemberExpression &&
|
|
50
|
+
scope.property.type === AST_NODE_TYPES.Identifier &&
|
|
51
|
+
scope.property.name === SHARED);
|
|
52
|
+
}
|
|
53
|
+
/** A `vary` written as anything but an empty list: what it holds is judged at run time. */
|
|
54
|
+
function varies(cache) {
|
|
55
|
+
const vary = propertyOf(cache, 'vary')?.value;
|
|
56
|
+
return vary !== undefined && !(vary.type === AST_NODE_TYPES.ArrayExpression && vary.elements.length === 0);
|
|
57
|
+
}
|
|
58
|
+
/** A function route that names security schemes knows its caller; `security: false` does not. */
|
|
59
|
+
function namesSchemes(spec) {
|
|
60
|
+
const security = propertyOf(spec, 'security')?.value;
|
|
61
|
+
return security?.type === AST_NODE_TYPES.ArrayExpression && security.elements.length > 0
|
|
62
|
+
? 'it names security schemes'
|
|
63
|
+
: undefined;
|
|
64
|
+
}
|
|
65
|
+
/** Guards written here, other than `Public` alone; a declaration that inherits its guards from its group is judged at run time. */
|
|
66
|
+
function guarded(spec) {
|
|
67
|
+
const guards = propertyOf(spec, 'guards')?.value;
|
|
68
|
+
if (guards?.type !== AST_NODE_TYPES.ArrayExpression) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const names = guards.elements.map((guard) => (guard?.type === AST_NODE_TYPES.Identifier ? guard.name : 'a guard'));
|
|
72
|
+
return names.length === 0 || (names.length === 1 && names[0] === OPEN_GUARD)
|
|
73
|
+
? undefined
|
|
74
|
+
: `it stands behind ${names.join(', ')}`;
|
|
75
|
+
}
|
|
76
|
+
function whatOf(name) {
|
|
77
|
+
if (name === 'RouteGroup') {
|
|
78
|
+
return 'route group';
|
|
79
|
+
}
|
|
80
|
+
return name === 'Controller' ? 'controller' : 'route';
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=presentation-shared-cache-varies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-shared-cache-varies.js","sourceRoot":"","sources":["../../src/rules/presentation-shared-cache-varies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAA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
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-sends-commands-only.d.ts","sourceRoot":"","sources":["../../src/rules/process-sends-commands-only.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,wBAAwB,kKAuBnC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
2
|
+
import { importListener } from '../support/imports/import-listener.js';
|
|
3
|
+
const WRITERS = {
|
|
4
|
+
domain: ['aggregates', 'entities', 'repositories', 'services'],
|
|
5
|
+
application: ['ports'],
|
|
6
|
+
};
|
|
7
|
+
export const processSendsCommandsOnly = defineRule({
|
|
8
|
+
id: 'process/sends-commands-only',
|
|
9
|
+
type: 'problem',
|
|
10
|
+
recommended: 'error',
|
|
11
|
+
description: 'A process manager of application/processes decides from its state and what happened, and changes the world only through the commands it sends: it imports no aggregate, entity, repository, domain service, port or infrastructure.',
|
|
12
|
+
messages: {
|
|
13
|
+
writes: 'This process imports {{target}}. A process never writes an aggregate, of its context or another, nor calls an outside system: it answers a decision whose commands do it, each authorized and transactional in its own handler. Remove the import and send a command instead.',
|
|
14
|
+
},
|
|
15
|
+
create({ file, report }) {
|
|
16
|
+
if (!isProcessFile(file)) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
return importListener(file, ({ node, target }) => {
|
|
20
|
+
const reached = reachedWriter(target);
|
|
21
|
+
if (reached !== undefined) {
|
|
22
|
+
report({ node, messageId: 'writes', data: { target: reached } });
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
function isProcessFile(file) {
|
|
28
|
+
const { location } = file;
|
|
29
|
+
return (!file.isTest &&
|
|
30
|
+
location.area === 'context' &&
|
|
31
|
+
location.layer === 'application' &&
|
|
32
|
+
location.inside[0] === 'processes' &&
|
|
33
|
+
file.path.endsWith('.process.ts'));
|
|
34
|
+
}
|
|
35
|
+
function reachedWriter(target) {
|
|
36
|
+
if (target.kind !== 'file' || target.location.area !== 'context') {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const { layer, inside } = target.location;
|
|
40
|
+
if (layer === 'infrastructure') {
|
|
41
|
+
return 'infrastructure/';
|
|
42
|
+
}
|
|
43
|
+
const [folder = ''] = inside;
|
|
44
|
+
return WRITERS[layer]?.includes(folder) === true ? `${layer}/${folder}/` : undefined;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=process-sends-commands-only.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-sends-commands-only.js","sourceRoot":"","sources":["../../src/rules/process-sends-commands-only.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAIvE,MAAM,OAAO,GAAgD;IAC3D,MAAM,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,CAAC;IAC9D,WAAW,EAAE,CAAC,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAY;IAC5D,EAAE,EAAE,6BAA6B;IACjC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,OAAO;IACpB,WAAW,EACT,qOAAqO;IACvO,QAAQ,EAAE;QACR,MAAM,EACJ,+QAA+Q;KAClR;IACD,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;YAEtC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,CAAC,EAAE,IAAI,EAA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.ts","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAwIlE,+HAA+H;AAC/H,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEnD,CAAC"}
|
package/dist/rules/rules.js
CHANGED
|
@@ -49,7 +49,10 @@ import { portsValueImport } from './ports-value-import.js';
|
|
|
49
49
|
import { presentationControllerDelegates } from './presentation-controller-delegates.js';
|
|
50
50
|
import { presentationControllerShape } from './presentation-controller-shape.js';
|
|
51
51
|
import { presentationGuardAtTheEdge } from './presentation-guard-at-the-edge.js';
|
|
52
|
+
import { presentationSharedCacheVaries } from './presentation-shared-cache-varies.js';
|
|
52
53
|
import { purityNoAmbientRandomness, purityNoEnvironment, purityNoSystemClock } from './purity.js';
|
|
54
|
+
import { lifecycleStatusThroughMachine } from './lifecycle-status-through-machine.js';
|
|
55
|
+
import { processSendsCommandsOnly } from './process-sends-commands-only.js';
|
|
53
56
|
import { schedulingJobName } from './scheduling-job-name.js';
|
|
54
57
|
import { schedulingJobTriggersUseCase } from './scheduling-job-triggers-use-case.js';
|
|
55
58
|
import { standardNoParallelInterface } from './standard-no-parallel-interface.js';
|
|
@@ -115,12 +118,15 @@ const ALL = [
|
|
|
115
118
|
portsNoConcreteDependency,
|
|
116
119
|
portsValueImport,
|
|
117
120
|
schedulingJobTriggersUseCase,
|
|
121
|
+
lifecycleStatusThroughMachine,
|
|
122
|
+
processSendsCommandsOnly,
|
|
118
123
|
schedulingJobName,
|
|
119
124
|
importsAliasOnly,
|
|
120
125
|
importsExtension,
|
|
121
126
|
presentationControllerShape,
|
|
122
127
|
presentationControllerDelegates,
|
|
123
128
|
presentationGuardAtTheEdge,
|
|
129
|
+
presentationSharedCacheVaries,
|
|
124
130
|
];
|
|
125
131
|
/** Keyed by ESLint name: the id of docs/ARCHITECTURE.md with its slash replaced by a dash, or the name of a companion rule. */
|
|
126
132
|
export const rules = Object.fromEntries(ALL.map((rule) => [docsOf(rule).name, rule]));
|
package/dist/rules/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,mCAAmC,EACnC,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;A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,4BAA4B;IAC5B,6BAA6B;IAC7B,wBAAwB;IACxB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,2BAA2B;IAC3B,+BAA+B;IAC/B,0BAA0B;IAC1B,6BAA6B;CAC9B,CAAC;AAEF,+HAA+H;AAC/H,MAAM,CAAC,MAAM,KAAK,GAAsC,MAAM,CAAC,WAAW,CACxE,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel-names.d.ts","sourceRoot":"","sources":["../../../src/support/standard-interfaces/parallel-names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"parallel-names.d.ts","sourceRoot":"","sources":["../../../src/support/standard-interfaces/parallel-names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAyEtD,6HAA6H;AAC7H,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,oBAAoB,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAYnG"}
|
|
@@ -36,6 +36,10 @@ const PARALLEL_NAMES = {
|
|
|
36
36
|
ErrorTracker: 'ErrorReporter',
|
|
37
37
|
ExceptionReporter: 'ErrorReporter',
|
|
38
38
|
CrashReporter: 'ErrorReporter',
|
|
39
|
+
CacheInvalidator: 'CacheInvalidation',
|
|
40
|
+
CacheInvalidationService: 'CacheInvalidation',
|
|
41
|
+
CachePurgeService: 'CachePurger',
|
|
42
|
+
CdnPurger: 'CachePurger',
|
|
39
43
|
};
|
|
40
44
|
/** The standard names themselves: the same name behind an `I` is the same interface declared twice. */
|
|
41
45
|
const STANDARD_NAMES = [
|
|
@@ -55,6 +59,8 @@ const STANDARD_NAMES = [
|
|
|
55
59
|
'JobScheduler',
|
|
56
60
|
'ScheduledJob',
|
|
57
61
|
'ErrorReporter',
|
|
62
|
+
'CacheInvalidation',
|
|
63
|
+
'CachePurger',
|
|
58
64
|
];
|
|
59
65
|
const DEFAULTS = {
|
|
60
66
|
...Object.fromEntries(STANDARD_NAMES.map((name) => [`I${name}`, name])),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel-names.js","sourceRoot":"","sources":["../../../src/support/standard-interfaces/parallel-names.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,cAAc,GAAqC;IACvD,SAAS,EAAE,QAAQ;IACnB,aAAa,EAAE,QAAQ;IACvB,eAAe,EAAE,QAAQ;IACzB,cAAc,EAAE,SAAS;IACzB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,2BAA2B;IACxC,WAAW,EAAE,2BAA2B;IACxC,WAAW,EAAE,2BAA2B;IACxC,cAAc,EAAE,2BAA2B;IAC3C,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,MAAM;IACvB,UAAU,EAAE,MAAM;IAClB,iBAAiB,EAAE,MAAM;IACzB,SAAS,EAAE,MAAM;IACjB,gBAAgB,EAAE,aAAa;IAC/B,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,gEAAgE;IAC1E,aAAa,EAAE,gEAAgE;IAC/E,WAAW,EAAE,gEAAgE;IAC7E,mBAAmB,EAAE,cAAc;IACnC,aAAa,EAAE,cAAc;IAC7B,aAAa,EAAE,cAAc;IAC7B,OAAO,EAAE,cAAc;IACvB,aAAa,EAAE,cAAc;IAC7B,aAAa,EAAE,cAAc;IAC7B,oBAAoB,EAAE,eAAe;IACrC,YAAY,EAAE,eAAe;IAC7B,iBAAiB,EAAE,eAAe;IAClC,aAAa,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"parallel-names.js","sourceRoot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,mBAAmB;IACnB,aAAa;CACd,CAAC;AAEF,MAAM,QAAQ,GAAqC;IACjD,GAAG,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IACvE,GAAG,cAAc;CAClB,CAAC;AAEF,6HAA6H;AAC7H,MAAM,UAAU,aAAa,CAAC,UAAwC;IACpE,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEhD,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;YACtB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.12.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.12.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -16,7 +16,7 @@ The phase of a handler is `after-commit` when the options object of its `@Domain
|
|
|
16
16
|
|
|
17
17
|
For a before-commit handler, a dependency that is:
|
|
18
18
|
|
|
19
|
-
- `Cache`, `Lock`, `RateLimiter`, `JobScheduler` or `EventBus` of `@ddd-ts-kit/kernel`
|
|
19
|
+
- `Cache`, `CachePurger`, `Lock`, `RateLimiter`, `JobScheduler` or `EventBus` of `@ddd-ts-kit/kernel`
|
|
20
20
|
- imported from `infrastructure/` of its context
|
|
21
21
|
- imported from another context
|
|
22
22
|
- imported from the platform directory
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# ddd-ts-kit/lifecycle-status-through-machine
|
|
2
|
+
|
|
3
|
+
Architecture id: `lifecycle/status-through-machine`. Default severity: `error` in `recommended`, `error` in `strict`.
|
|
4
|
+
|
|
5
|
+
Applies to: `domain/aggregates/*` of a context, specs aside, when the file imports a state machine
|
|
6
|
+
of `domain/state-machines/`.
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
A state machine says once which status follows which, and what refuses a forbidden transition.
|
|
11
|
+
An aggregate that also writes its status by hand keeps a second, silent copy of the lifecycle:
|
|
12
|
+
the diagram generated from the machine then lies, and a transition the machine forbids happens
|
|
13
|
+
anyway. The status is therefore only ever written from the machine, or copied from a status
|
|
14
|
+
already read.
|
|
15
|
+
|
|
16
|
+
## Reported
|
|
17
|
+
|
|
18
|
+
In an aggregate file that imports a `*.state-machine` module, inside a member of a class:
|
|
19
|
+
|
|
20
|
+
- an object property `status: <value>` whose value is not a call `<machine>.next(..)` or
|
|
21
|
+
`<machine>.start(..)` of an imported machine, a status read from somewhere (`this.state.status`,
|
|
22
|
+
`state.status`) or the variable `status`
|
|
23
|
+
- an assignment `<target>.status = <value>`, by the same test
|
|
24
|
+
|
|
25
|
+
Incorrect:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
confirm(now: Date): void {
|
|
29
|
+
if (this.state.status !== 'requested') {
|
|
30
|
+
throw AppointmentError.alreadyConfirmed(this.id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.state = { ...this.state, changedAt: now, status: 'booked' };
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Correct:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
confirm(now: Date): void {
|
|
41
|
+
this.state = { ...this.state, changedAt: now, status: appointmentLifecycle.next(this.state.status, 'confirm') };
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Details
|
|
46
|
+
|
|
47
|
+
The machine is any binding imported from a module whose path ends with
|
|
48
|
+
`state-machines/<name>.state-machine`. What the machine guarantees: `defineStateMachine` of
|
|
49
|
+
`@ddd-ts-kit/kernel`.
|
|
50
|
+
|
|
51
|
+
## Options
|
|
52
|
+
|
|
53
|
+
None.
|
|
54
|
+
|
|
55
|
+
`rules."lifecycle/status-through-machine"` in `ddd-ts-kit.config.json` set to `off` silences the
|
|
56
|
+
rule, and `// ddd-ts-kit-disable-next-line lifecycle/status-through-machine -- <reason>` silences
|
|
57
|
+
one line, exactly as for `ddd-ts-kit check`.
|
|
58
|
+
|
|
59
|
+
## Limits
|
|
60
|
+
|
|
61
|
+
- One file at a time: an aggregate whose state machine exists and is not imported is reported
|
|
62
|
+
by `ddd-ts-kit check` alone.
|
|
63
|
+
- A status written through a helper function, or held in a field initializer of the class, is
|
|
64
|
+
not followed.
|
|
65
|
+
|
|
66
|
+
## With the CLI checker
|
|
67
|
+
|
|
68
|
+
`ddd-ts-kit check` reports the same id from the text of the files, and also an aggregate whose
|
|
69
|
+
state machine exists (`domain/state-machines/<aggregate>.state-machine.ts`) and is not imported.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# ddd-ts-kit/presentation-shared-cache-varies
|
|
2
|
+
|
|
3
|
+
Architecture id: `presentation/shared-cache-varies` (added by this plugin). Default severity: `error` in `recommended`, `error` in `strict`.
|
|
4
|
+
|
|
5
|
+
Applies to: every `@Controller({...})`, `@RouteGroup({...})` and `defineRoute({...}, handler)` of `@ddd-ts-kit/http` outside the tests.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
A shared cache (Varnish, a CDN) files an answer by its URL and hands it to the next caller who asks the same URL. The answer of a route that knows its caller went through a decision of authorization made for that caller: its permission, its access scope, its tenant. Kept in a shared cache, it is served to the next caller without that decision being made again. A `public` cache policy on such a route must say what the answer depends on, in `vary`, so that the cache keeps one answer per value of it; usually the answer is `private` instead.
|
|
10
|
+
|
|
11
|
+
## Reported
|
|
12
|
+
|
|
13
|
+
A `cache` whose `scope` is `CacheScope.public` (or `'public'`), with no `vary` or an empty one, on:
|
|
14
|
+
|
|
15
|
+
- a controller or a route group that writes `guards` other than `[Public]`;
|
|
16
|
+
- a function route that writes `security` with at least one scheme.
|
|
17
|
+
|
|
18
|
+
Incorrect:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
@RouteGroup({
|
|
22
|
+
prefix: '/agenda',
|
|
23
|
+
guards: [Authenticated],
|
|
24
|
+
cache: { scope: CacheScope.public, maxAge: '1m' },
|
|
25
|
+
})
|
|
26
|
+
export class AgendaRoutes {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Correct:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
@RouteGroup({
|
|
33
|
+
prefix: '/agenda',
|
|
34
|
+
guards: [Authenticated],
|
|
35
|
+
cache: { scope: CacheScope.private, maxAge: '0s', mustRevalidate: true, etag: 'representation' },
|
|
36
|
+
})
|
|
37
|
+
export class AgendaRoutes {}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Details
|
|
41
|
+
|
|
42
|
+
A controller that names its group and writes no `guards` of its own takes the guards of the group, which another file declares: it is not judged here, and `@ddd-ts-kit/http` refuses the same declaration with a `DeclarationError` when the routes are built, for every route whatever the file. The rule is the editor's early view of that refusal.
|
|
43
|
+
|
|
44
|
+
What a non-empty `vary` names is held when the routes are mounted, where the options of the application are known: it must name `Authorization`, `Cookie` or the header the tenant is read from (`vary: ['Accept-Language']` alone is refused), and a cache that ignores `Vary` (Cloudflare, Bunny) refuses a varying public answer. The rule does not judge that: one file does not show the options.
|
|
45
|
+
|
|
46
|
+
## Options
|
|
47
|
+
|
|
48
|
+
None.
|
|
49
|
+
|
|
50
|
+
`rules."presentation/shared-cache-varies"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line presentation/shared-cache-varies -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
|
|
51
|
+
|
|
52
|
+
## With the CLI checker
|
|
53
|
+
|
|
54
|
+
New with this plugin: the CLI checker knows its id only; the routes are refused at run time by `@ddd-ts-kit/http`.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# ddd-ts-kit/process-sends-commands-only
|
|
2
|
+
|
|
3
|
+
Architecture id: `process/sends-commands-only`. Default severity: `error` in `recommended`, `error` in `strict`.
|
|
4
|
+
|
|
5
|
+
Applies to: `application/processes/*.process.ts` of a context, specs aside.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
A process manager coordinates a long-running process: it reacts to events, keeps a state of its
|
|
10
|
+
own and decides what happens next. When it also loads and saves aggregates, it becomes a use case
|
|
11
|
+
nobody can send, with no permission, no audit and a transaction that spans what it should only
|
|
12
|
+
coordinate; when it writes the aggregate of another context, the boundary is gone. Its steps
|
|
13
|
+
answer a decision, and the commands of that decision do the work, each in its own handler.
|
|
14
|
+
|
|
15
|
+
## Reported
|
|
16
|
+
|
|
17
|
+
An import, in a process file, of:
|
|
18
|
+
|
|
19
|
+
- `domain/aggregates/`, `domain/entities/`, `domain/repositories/` or `domain/services/` of any
|
|
20
|
+
context
|
|
21
|
+
- `application/ports/` of any context
|
|
22
|
+
- `infrastructure/` of any context
|
|
23
|
+
|
|
24
|
+
Incorrect:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { ReminderRepository } from '@/contexts/notification/domain/repositories/reminder.repository';
|
|
28
|
+
|
|
29
|
+
export class AppointmentReminderProcess { /* saves reminders itself */ }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Correct:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { PlanReminderCommand } from '@/contexts/notification/application/commands/plan-reminder/plan-reminder.command';
|
|
36
|
+
|
|
37
|
+
export class AppointmentReminderProcess implements ProcessManager<ReminderProcessState> {
|
|
38
|
+
booked(event: AppointmentBookedV1, current: ReminderProcessState | undefined): ProcessDecision<ReminderProcessState> | undefined {
|
|
39
|
+
return { state: { appointmentId: event.payload.appointmentId, stage: 'waiting' }, commands: [new PlanReminderCommand(/* ... */)] };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Details
|
|
45
|
+
|
|
46
|
+
Commands, the published language of upstream contexts, value objects, vocabularies and the
|
|
47
|
+
kernel stay allowed: a process builds commands and reads events.
|
|
48
|
+
|
|
49
|
+
## Options
|
|
50
|
+
|
|
51
|
+
None.
|
|
52
|
+
|
|
53
|
+
`rules."process/sends-commands-only"` in `ddd-ts-kit.config.json` set to `off` silences the rule,
|
|
54
|
+
and `// ddd-ts-kit-disable-next-line process/sends-commands-only -- <reason>` silences one line,
|
|
55
|
+
exactly as for `ddd-ts-kit check`.
|
|
56
|
+
|
|
57
|
+
## Limits
|
|
58
|
+
|
|
59
|
+
- An import read by a dynamic expression is not followed.
|
|
60
|
+
|
|
61
|
+
## With the CLI checker
|
|
62
|
+
|
|
63
|
+
`ddd-ts-kit check` reports the same id from the text of the files.
|
|
@@ -26,6 +26,8 @@ A class, an interface or a type alias declared under one of these names:
|
|
|
26
26
|
| `IJobScheduler`, `JobSchedulerService`, `CronScheduler`, `TaskScheduler` | `JobScheduler` |
|
|
27
27
|
| `IScheduledJob`, `CronJob`, `ScheduledTask`, `BackgroundJob` | `ScheduledJob` |
|
|
28
28
|
| `IErrorReporter`, `ErrorReporterService`, `ErrorTracker`, `ExceptionReporter`, `CrashReporter` | `ErrorReporter` |
|
|
29
|
+
| `ICacheInvalidation`, `CacheInvalidator`, `CacheInvalidationService` | `CacheInvalidation` |
|
|
30
|
+
| `ICachePurger`, `CachePurgeService`, `CdnPurger` | `CachePurger` |
|
|
29
31
|
|
|
30
32
|
Incorrect:
|
|
31
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "AST-accurate ESLint rules for DDD and Clean Architecture in TypeScript: layer and context isolation, domain purity, clean code ordering.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|