@ddd-ts-kit/eslint-plugin 0.17.0 → 0.18.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.fr.md +5 -5
- package/README.md +3 -3
- package/dist/rules/declarations-role-declared.d.ts +2 -2
- package/dist/rules/declarations-role-declared.d.ts.map +1 -1
- package/dist/rules/declarations-role-declared.js +4 -68
- package/dist/rules/declarations-role-declared.js.map +1 -1
- package/dist/support/declarations/written-names.d.ts +1 -1
- package/dist/support/declarations/written-names.d.ts.map +1 -1
- package/dist/support/declarations/written-names.js +1 -2
- package/dist/support/declarations/written-names.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/rules/context-extractable.fr.md +9 -5
- package/docs/rules/context-extractable.md +8 -4
- package/docs/rules/declarations-role-declared.fr.md +3 -11
- package/docs/rules/declarations-role-declared.md +2 -10
- package/docs/rules/domain-events-dispatched-on-save.fr.md +3 -3
- package/docs/rules/domain-events-dispatched-on-save.md +2 -2
- package/docs/rules/domain-events-transactional-before-commit.fr.md +24 -10
- package/docs/rules/domain-events-transactional-before-commit.md +23 -9
- package/docs/rules/events-consumer-idempotent.fr.md +9 -5
- package/docs/rules/events-consumer-idempotent.md +8 -4
- package/docs/rules/events-name-format.fr.md +2 -2
- package/docs/rules/events-name-format.md +1 -1
- package/docs/rules/layer-application-inward.fr.md +9 -3
- package/docs/rules/layer-application-inward.md +8 -2
- package/docs/rules/ports-implements-never-extends.fr.md +9 -5
- package/docs/rules/ports-implements-never-extends.md +8 -4
- package/docs/rules/ports-no-concrete-dependency.fr.md +15 -5
- package/docs/rules/ports-no-concrete-dependency.md +14 -4
- package/docs/rules/ports-value-import.fr.md +5 -5
- package/docs/rules/ports-value-import.md +4 -4
- package/docs/rules/scheduling-job-name.fr.md +7 -3
- package/docs/rules/scheduling-job-name.md +6 -2
- package/docs/rules/scheduling-job-triggers-use-case.fr.md +8 -3
- package/docs/rules/scheduling-job-triggers-use-case.md +7 -2
- package/package.json +13 -9
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:297709003d7940b5 -->
|
|
3
3
|
|
|
4
4
|
# @ddd-ts-kit/eslint-plugin
|
|
5
5
|
|
|
@@ -257,7 +257,7 @@ chaque règle à `error`.
|
|
|
257
257
|
| [`tracing/platform-only`](docs/rules/tracing-platform-only.fr.md) | `ddd-ts-kit/tracing-platform-only` | `@ddd-ts-kit/tracing` et `@opentelemetry/*` ne sont importés que par le répertoire de la plateforme, `main.ts` et `apps/` | `error` | maison |
|
|
258
258
|
| [`standard/no-parallel-interface`](docs/rules/standard-no-parallel-interface.fr.md) | `ddd-ts-kit/standard-no-parallel-interface` | aucun `ILogger`, `UserContext`, `PaginatedResult`, `CronJob`, `ErrorTracker` ni semblable déclaré à côté des interfaces standard du kernel (`standardInterfaces` dans la config) | `warn` | maison |
|
|
259
259
|
| [`governance/recorded-deviation`](docs/rules/governance-recorded-deviation.fr.md) | `ddd-ts-kit/governance-recorded-deviation` | chaque désactivation nomme ses règles et renvoie à `ADR-<number>` après `--` | `error` | maison |
|
|
260
|
-
| [`declarations/role-declared`](docs/rules/declarations-role-declared.fr.md) | `ddd-ts-kit/declarations-role-declared` | style déclaré seulement : un fichier de rôle exporte une classe portant le décorateur de son rôle, le `consumer` et le `name` d'une déclaration sont des chaînes littérales,
|
|
260
|
+
| [`declarations/role-declared`](docs/rules/declarations-role-declared.fr.md) | `ddd-ts-kit/declarations-role-declared` | style déclaré seulement : un fichier de rôle exporte une classe portant le décorateur de son rôle, le `consumer` et le `name` d'une déclaration sont des chaînes littérales, `domain/` ne porte aucun décorateur de déclaration | `error` | maison |
|
|
261
261
|
| [`declarations/constructor-injection`](docs/rules/declarations-constructor-injection.fr.md) | `ddd-ts-kit/declarations-constructor-injection` | style déclaré seulement : une classe dont le décorateur ne liste aucune dépendance type chaque paramètre de son constructeur par une classe, sans `?`, valeur par défaut, paramètre rest ni déstructuration ; sous `stack.dependencies: signature`, un décorateur ne porte aucune liste (une liste qui répète le constructeur est retirée par la correction, une liste qui en diffère est signalée) | `error` | maison |
|
|
262
262
|
| [`ports/abstract-class`](docs/rules/ports-abstract-class.fr.md) | `ddd-ts-kit/ports-abstract-class` | un port (`domain/repositories/*.repository.ts`, `application/ports/*.port.ts`) est une classe abstraite aux seuls membres abstraits, jamais une interface | `error` | maison |
|
|
263
263
|
| [`ports/implements-never-extends`](docs/rules/ports-implements-never-extends.fr.md) | `ddd-ts-kit/ports-implements-never-extends` | un adaptateur (`@Repository`, `@Gateway`, `@Adapter`, `bind(Port).toClass(Class)`) implémente son port et ne l'étend jamais | `error` | maison |
|
|
@@ -303,9 +303,9 @@ signalé.
|
|
|
303
303
|
|
|
304
304
|
Un décorateur est lu dans l'arbre syntaxique et compte quand son nom est importé de
|
|
305
305
|
`@ddd-ts-kit/kernel/declarations` dans le fichier, y compris sous un alias
|
|
306
|
-
(`{ Repository as Repo }`) ou un espace de noms (`declarations.Repository`).
|
|
307
|
-
regardent une classe d'un autre fichier (le message qu'enregistre un module,
|
|
308
|
-
|
|
306
|
+
(`{ Repository as Repo }`) ou un espace de noms (`declarations.Repository`). Deux vérifications
|
|
307
|
+
regardent une classe d'un autre fichier (le message qu'enregistre un module, la classe donnée à
|
|
308
|
+
`toClass`) : l'import est résolu comme tout autre, le
|
|
309
309
|
fichier est lu sur le disque et analysé sans types, et rien n'est conclu quand cela échoue.
|
|
310
310
|
`stack.assembly` (`barrel` ou `discovery`) est lu avec le style ; aucune règle de ce plugin n'en
|
|
311
311
|
dépend, puisque le barrel est un fait du projet que tient `ddd-ts-kit check`
|
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ is an error whatever the configured limit). `strict` sets every rule to `error`.
|
|
|
253
253
|
| [`tracing/platform-only`](docs/rules/tracing-platform-only.md) | `ddd-ts-kit/tracing-platform-only` | `@ddd-ts-kit/tracing` and `@opentelemetry/*` are imported only by the platform directory, `main.ts` and `apps/` | `error` | custom |
|
|
254
254
|
| [`standard/no-parallel-interface`](docs/rules/standard-no-parallel-interface.md) | `ddd-ts-kit/standard-no-parallel-interface` | no declared `ILogger`, `UserContext`, `PaginatedResult`, `CronJob`, `ErrorTracker` and the like next to the standard interfaces of the kernel (`standardInterfaces` in the config) | `warn` | custom |
|
|
255
255
|
| [`governance/recorded-deviation`](docs/rules/governance-recorded-deviation.md) | `ddd-ts-kit/governance-recorded-deviation` | every suppression names its rules and points to `ADR-<number>` after `--` | `error` | custom |
|
|
256
|
-
| [`declarations/role-declared`](docs/rules/declarations-role-declared.md) | `ddd-ts-kit/declarations-role-declared` | declared style only: a role file exports a class carrying the decorator of its role, the `consumer` and `name` of a declaration are string literals,
|
|
256
|
+
| [`declarations/role-declared`](docs/rules/declarations-role-declared.md) | `ddd-ts-kit/declarations-role-declared` | declared style only: a role file exports a class carrying the decorator of its role, the `consumer` and `name` of a declaration are string literals, `domain/` carries no declaration decorator | `error` | custom |
|
|
257
257
|
| [`declarations/constructor-injection`](docs/rules/declarations-constructor-injection.md) | `ddd-ts-kit/declarations-constructor-injection` | declared style only: a class whose decorator lists no dependency types each constructor parameter by one class, with no `?`, default value, rest or destructuring; under `stack.dependencies: signature` a decorator carries no list (a list that repeats the constructor is removed by the fix, one that differs is reported) | `error` | custom |
|
|
258
258
|
| [`ports/abstract-class`](docs/rules/ports-abstract-class.md) | `ddd-ts-kit/ports-abstract-class` | a port (`domain/repositories/*.repository.ts`, `application/ports/*.port.ts`) is an abstract class with abstract members only, never an interface | `error` | custom |
|
|
259
259
|
| [`ports/implements-never-extends`](docs/rules/ports-implements-never-extends.md) | `ddd-ts-kit/ports-implements-never-extends` | an adapter (`@Repository`, `@Gateway`, `@Adapter`, `bind(Port).toClass(Class)`) implements its port and never extends it | `error` | custom |
|
|
@@ -297,8 +297,8 @@ so a module that registers it without `.requires(...)` or `.public()` is not rep
|
|
|
297
297
|
|
|
298
298
|
A decorator is read from the syntax tree and counts when its name is imported from
|
|
299
299
|
`@ddd-ts-kit/kernel/declarations` in the file, under an alias (`{ Repository as Repo }`) or a
|
|
300
|
-
namespace (`declarations.Repository`) too.
|
|
301
|
-
message a module registers, the
|
|
300
|
+
namespace (`declarations.Repository`) too. Two checks look at a class of another file (the
|
|
301
|
+
message a module registers, the class given to `toClass`): the import is resolved
|
|
302
302
|
like any other, the file is read from disk and parsed without types, and nothing is concluded
|
|
303
303
|
when it cannot be. `stack.assembly` (`barrel` or `discovery`) is read with the style; no rule of
|
|
304
304
|
this plugin depends on it, since the barrel is a fact of the project that `ddd-ts-kit check`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type MessageId = 'undeclared' | 'wrongRole' | 'name' | '
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type MessageId = 'undeclared' | 'wrongRole' | 'name' | 'inDomain';
|
|
3
3
|
export declare const declarationsRoleDeclared: TSESLint.RuleModule<MessageId, [], import("../index.js").RuleDocs, TSESLint.RuleListener>;
|
|
4
4
|
export {};
|
|
5
5
|
//# sourceMappingURL=declarations-role-declared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations-role-declared.d.ts","sourceRoot":"","sources":["../../src/rules/declarations-role-declared.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"declarations-role-declared.d.ts","sourceRoot":"","sources":["../../src/rules/declarations-role-declared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAmBnE,KAAK,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAGlE,eAAO,MAAM,wBAAwB,2FA6CnC,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
1
|
import { className } from '../support/classes/class-name.js';
|
|
3
2
|
import { exportedClasses } from '../support/classes/exported-classes.js';
|
|
4
|
-
import { keyName } from '../support/classes/key-name.js';
|
|
5
3
|
import { topLevelClasses } from '../support/classes/top-level-classes.js';
|
|
6
4
|
import { ACCESS_DECORATORS } from '../support/declarations/access-decorators.js';
|
|
7
5
|
import { DECLARATIONS_ENTRY, declarationReader, } from '../support/declarations/declaration-reader.js';
|
|
@@ -9,11 +7,8 @@ import { WRITTEN_NAMES } from '../support/declarations/written-names.js';
|
|
|
9
7
|
import { declaredRoleOf } from '../support/declarations/declared-role-of.js';
|
|
10
8
|
import { isDeclaredStyle } from '../support/declarations/is-declared-style.js';
|
|
11
9
|
import { writtenName } from '../support/declarations/written-name.js';
|
|
12
|
-
import { propertyOf } from '../support/calls/property-of.js';
|
|
13
10
|
import { defineRule } from '../support/rule/define-rule.js';
|
|
14
11
|
import { inContext } from '../support/imports/in-context.js';
|
|
15
|
-
import { staticString } from '../support/imports/static-string.js';
|
|
16
|
-
import { classFinder } from '../support/classes/class-finder.js';
|
|
17
12
|
export const declarationsRoleDeclared = defineRule({
|
|
18
13
|
id: 'declarations/role-declared',
|
|
19
14
|
type: 'problem',
|
|
@@ -22,11 +17,10 @@ export const declarationsRoleDeclared = defineRule({
|
|
|
22
17
|
messages: {
|
|
23
18
|
undeclared: `This file is a role file of the declared style (\`*.{{suffix}}.ts\` under {{folder}}/) but exports no class carrying \`@{{expected}}\`. Put \`@{{expected}}(...)\` from "${DECLARATIONS_ENTRY}" on the exported class: a class that does not say what it is is in no assembly and is never registered.`,
|
|
24
19
|
wrongRole: '{{className}} carries `@{{actual}}` in a `*.{{suffix}}.ts` file under {{folder}}/, where a class is declared with `@{{expected}}`. Move the class to the file of its role, or declare it with `@{{expected}}(...)`: the file name, the folder and the decorator say the same thing.',
|
|
25
|
-
name: "`@{{decorator}}` of {{className}} has a `{{key}}` that is {{problem}}. Write `{ {{key}}: '{{context}}.<name>' }` as a string literal
|
|
26
|
-
eventName: '`@DomainEventHandler` of {{className}} names "{{declared}}", but {{event}} is named "{{actual}}". Write `{ name: \'{{actual}}\' }`: a handler names the domain event it reacts to by the name the event carries.',
|
|
20
|
+
name: "`@{{decorator}}` of {{className}} has a `{{key}}` that is {{problem}}. Write `{ {{key}}: '{{context}}.<name>' }` as a string literal: the name is written once and survives the renaming of the class.",
|
|
27
21
|
inDomain: '{{className}} carries `@{{decorator}}` under domain/: the domain declares nothing. Aggregates, entities, value objects, events, services and repository ports carry no decorator and no dependency list. Remove the decorator and declare the class of application/ or infrastructure/ that plays the role.',
|
|
28
22
|
},
|
|
29
|
-
create({ file, sourceCode,
|
|
23
|
+
create({ file, sourceCode, report }) {
|
|
30
24
|
const here = inContext(file);
|
|
31
25
|
if (here === undefined || file.isTest || !isDeclaredStyle(file)) {
|
|
32
26
|
return {};
|
|
@@ -35,11 +29,10 @@ export const declarationsRoleDeclared = defineRule({
|
|
|
35
29
|
if (here.layer === 'domain') {
|
|
36
30
|
return domain(declarationsOf, report);
|
|
37
31
|
}
|
|
38
|
-
const findClass = classFinder(file, sourceCode.ast, context.languageOptions.parser);
|
|
39
32
|
const role = declaredRoleOf(file);
|
|
40
33
|
const judgeClass = (node) => {
|
|
41
34
|
for (const declaration of declarationsOf(node)) {
|
|
42
|
-
const finding = unwrittenName(node, declaration, here.context)
|
|
35
|
+
const finding = unwrittenName(node, declaration, here.context);
|
|
43
36
|
if (finding !== undefined) {
|
|
44
37
|
report(finding);
|
|
45
38
|
}
|
|
@@ -95,7 +88,7 @@ function misdeclaredRole(program, role, declarationsOf) {
|
|
|
95
88
|
function unwrittenName(node, declaration, context) {
|
|
96
89
|
const key = WRITTEN_NAMES[declaration.name];
|
|
97
90
|
const written = key === undefined ? undefined : writtenName(declaration.arguments[1], key);
|
|
98
|
-
if (key === undefined || written === undefined || 'value' in written
|
|
91
|
+
if (key === undefined || written === undefined || 'value' in written) {
|
|
99
92
|
return undefined;
|
|
100
93
|
}
|
|
101
94
|
return {
|
|
@@ -104,61 +97,4 @@ function unwrittenName(node, declaration, context) {
|
|
|
104
97
|
data: { decorator: declaration.name, className: className(node), key, problem: written.problem, context },
|
|
105
98
|
};
|
|
106
99
|
}
|
|
107
|
-
/** Compared only when the event class is in view: declared in this file, or imported by name from a file read from disk. */
|
|
108
|
-
function renamedEvent(node, declaration, findClass) {
|
|
109
|
-
const [event, options] = declaration.arguments;
|
|
110
|
-
if (declaration.name !== 'DomainEventHandler' || event?.type !== AST_NODE_TYPES.Identifier) {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
const declared = writtenName(options, 'name');
|
|
114
|
-
const site = findClass(event.name);
|
|
115
|
-
const actual = site === undefined ? undefined : eventName(site.node);
|
|
116
|
-
if (!('value' in declared) || actual === undefined || actual === declared.value) {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
node: declaration.node,
|
|
121
|
-
messageId: 'eventName',
|
|
122
|
-
data: { className: className(node), declared: declared.value, event: event.name, actual },
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/** `@DomainEventHandler(InvoiceIssued, { name: InvoiceIssued.eventName })`: the name the event class declares, read where it is written. */
|
|
126
|
-
function readsEventName(declaration) {
|
|
127
|
-
const [event, options] = declaration.arguments;
|
|
128
|
-
const property = options?.type === AST_NODE_TYPES.ObjectExpression ? propertyOf(options, 'name') : undefined;
|
|
129
|
-
return (declaration.name === 'DomainEventHandler' &&
|
|
130
|
-
event?.type === AST_NODE_TYPES.Identifier &&
|
|
131
|
-
property !== undefined &&
|
|
132
|
-
memberName(property.value) === `${event.name}.eventName`);
|
|
133
|
-
}
|
|
134
|
-
/** `InvoiceIssued.eventName` for a member read on a name; undefined for anything else. */
|
|
135
|
-
function memberName(node) {
|
|
136
|
-
if (node.type !== AST_NODE_TYPES.MemberExpression || node.computed) {
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
const { object, property } = node;
|
|
140
|
-
return object.type === AST_NODE_TYPES.Identifier && property.type === AST_NODE_TYPES.Identifier
|
|
141
|
-
? `${object.name}.${property.name}`
|
|
142
|
-
: undefined;
|
|
143
|
-
}
|
|
144
|
-
/** `static readonly eventName = 'billing.invoice.issued';`, or `readonly name = '..'` as 0.5 wrote it, with or without `as const`. */
|
|
145
|
-
function eventName(event) {
|
|
146
|
-
for (const member of event.body.body) {
|
|
147
|
-
const written = member.type === AST_NODE_TYPES.PropertyDefinition &&
|
|
148
|
-
!member.computed &&
|
|
149
|
-
['name', 'eventName'].includes(keyName(member.key) ?? '')
|
|
150
|
-
? member.value
|
|
151
|
-
: null;
|
|
152
|
-
const value = written === null ? undefined : staticString(unwrapped(written));
|
|
153
|
-
if (value !== undefined) {
|
|
154
|
-
return value;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
function unwrapped(value) {
|
|
160
|
-
return value.type === AST_NODE_TYPES.TSAsExpression || value.type === AST_NODE_TYPES.TSSatisfiesExpression
|
|
161
|
-
? unwrapped(value.expression)
|
|
162
|
-
: value;
|
|
163
|
-
}
|
|
164
100
|
//# sourceMappingURL=declarations-role-declared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations-role-declared.js","sourceRoot":"","sources":["../../src/rules/declarations-role-declared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"declarations-role-declared.js","sourceRoot":"","sources":["../../src/rules/declarations-role-declared.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** The options keys that hold a name written once and never derived: the idempotency scope, the policy name
|
|
1
|
+
/** The options keys that hold a name written once and never derived: the idempotency scope, the policy name. */
|
|
2
2
|
export declare const WRITTEN_NAMES: Readonly<Record<string, string>>;
|
|
3
3
|
//# sourceMappingURL=written-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"written-names.d.ts","sourceRoot":"","sources":["../../../src/support/declarations/written-names.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"written-names.d.ts","sourceRoot":"","sources":["../../../src/support/declarations/written-names.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1D,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/** The options keys that hold a name written once and never derived: the idempotency scope, the policy name
|
|
1
|
+
/** The options keys that hold a name written once and never derived: the idempotency scope, the policy name. */
|
|
2
2
|
export const WRITTEN_NAMES = {
|
|
3
3
|
IntegrationEventHandler: 'consumer',
|
|
4
|
-
DomainEventHandler: 'name',
|
|
5
4
|
Policy: 'name',
|
|
6
5
|
};
|
|
7
6
|
//# sourceMappingURL=written-names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"written-names.js","sourceRoot":"","sources":["../../../src/support/declarations/written-names.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"written-names.js","sourceRoot":"","sources":["../../../src/support/declarations/written-names.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,uBAAuB,EAAE,UAAU;IACnC,MAAM,EAAE,MAAM;CACf,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.18.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.18.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](context-extractable.md) · **Français**
|
|
2
|
-
<!-- translation-of: context-extractable.md sha256:
|
|
2
|
+
<!-- translation-of: context-extractable.md sha256:9c8ef03d79be6af4 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/context-extractable
|
|
5
5
|
|
|
@@ -50,8 +50,10 @@ builder.query(GetPrice).public().handledBy(GetPriceHandler, [ProductReader]);
|
|
|
50
50
|
// style déclaré : billing/application/queries/get-price/get-price.handler.ts
|
|
51
51
|
import { ProductReader } from '@/contexts/catalog/application/ports/product-reader.port';
|
|
52
52
|
|
|
53
|
-
@QueryHandler(GetPriceQuery
|
|
54
|
-
export class GetPriceHandler {
|
|
53
|
+
@QueryHandler(GetPriceQuery)
|
|
54
|
+
export class GetPriceHandler {
|
|
55
|
+
constructor(private readonly productReader: ProductReader) {}
|
|
56
|
+
}
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
Correct :
|
|
@@ -67,8 +69,10 @@ builder.query(GetPrice).public().handledBy(GetPriceHandler, [PriceSource]);
|
|
|
67
69
|
// style déclaré : le port appartient à billing, sa gateway appelle catalog
|
|
68
70
|
import { PriceCatalog } from '@/contexts/billing/application/ports/price-catalog.port';
|
|
69
71
|
|
|
70
|
-
@QueryHandler(GetPriceQuery
|
|
71
|
-
export class GetPriceHandler {
|
|
72
|
+
@QueryHandler(GetPriceQuery)
|
|
73
|
+
export class GetPriceHandler {
|
|
74
|
+
constructor(private readonly priceCatalog: PriceCatalog) {}
|
|
75
|
+
}
|
|
72
76
|
```
|
|
73
77
|
|
|
74
78
|
## Détails
|
|
@@ -49,8 +49,10 @@ builder.query(GetPrice).public().handledBy(GetPriceHandler, [ProductReader]);
|
|
|
49
49
|
// declared style: billing/application/queries/get-price/get-price.handler.ts
|
|
50
50
|
import { ProductReader } from '@/contexts/catalog/application/ports/product-reader.port';
|
|
51
51
|
|
|
52
|
-
@QueryHandler(GetPriceQuery
|
|
53
|
-
export class GetPriceHandler {
|
|
52
|
+
@QueryHandler(GetPriceQuery)
|
|
53
|
+
export class GetPriceHandler {
|
|
54
|
+
constructor(private readonly productReader: ProductReader) {}
|
|
55
|
+
}
|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
Correct:
|
|
@@ -66,8 +68,10 @@ builder.query(GetPrice).public().handledBy(GetPriceHandler, [PriceSource]);
|
|
|
66
68
|
// declared style: the port is one of billing, its gateway calls catalog
|
|
67
69
|
import { PriceCatalog } from '@/contexts/billing/application/ports/price-catalog.port';
|
|
68
70
|
|
|
69
|
-
@QueryHandler(GetPriceQuery
|
|
70
|
-
export class GetPriceHandler {
|
|
71
|
+
@QueryHandler(GetPriceQuery)
|
|
72
|
+
export class GetPriceHandler {
|
|
73
|
+
constructor(private readonly priceCatalog: PriceCatalog) {}
|
|
74
|
+
}
|
|
71
75
|
```
|
|
72
76
|
|
|
73
77
|
## Details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](declarations-role-declared.md) · **Français**
|
|
2
|
-
<!-- translation-of: declarations-role-declared.md sha256:
|
|
2
|
+
<!-- translation-of: declarations-role-declared.md sha256:a325a3f29d8ff0b1 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/declarations-role-declared
|
|
5
5
|
|
|
@@ -20,8 +20,7 @@ Dans un fichier de rôle (le tableau ci-dessous), hors `*.command.ts` et `*.quer
|
|
|
20
20
|
|
|
21
21
|
Sur toute classe de `application/`, `infrastructure/`, `presentation/` ou de la racine du contexte :
|
|
22
22
|
|
|
23
|
-
- `@IntegrationEventHandler(definition, { consumer })
|
|
24
|
-
- `@DomainEventHandler(Event, { name })` dont le `name`, écrit en toutes lettres, diffère du nom que déclare la classe d'événement, quand cette classe est en vue
|
|
23
|
+
- `@IntegrationEventHandler(definition, { consumer })` ou `@Policy(permission, { name })` dont le nom n'est pas un littéral de chaîne non vide : absent, vide, une variable, un gabarit avec une substitution, des options contenues dans une variable ou seulement étalées. `@DomainEventHandler(Event)` n'écrit aucun nom : il est rattaché à celui que sa classe d'événement déclare une fois, `static readonly eventName`, que le compilateur exige
|
|
25
24
|
|
|
26
25
|
Sous `domain/` :
|
|
27
26
|
|
|
@@ -55,10 +54,6 @@ export class SearchInvoicesHandler {}
|
|
|
55
54
|
@Policy(billingPermissions['invoice.void'], { name: policyName })
|
|
56
55
|
export class OnlyIssuerVoidsPolicy {}
|
|
57
56
|
|
|
58
|
-
// application/event-handlers/invoice-issued.event-handler.ts, où InvoiceIssued s'appelle 'billing.invoice.issued'
|
|
59
|
-
@DomainEventHandler(InvoiceIssued, { name: 'billing.invoice.sent' })
|
|
60
|
-
export class InvoiceIssuedEventHandler {}
|
|
61
|
-
|
|
62
57
|
// domain/aggregates/invoice.aggregate.ts
|
|
63
58
|
@Repository(InvoiceRepository)
|
|
64
59
|
export class Invoice {}
|
|
@@ -85,7 +80,7 @@ export class IssueInvoiceHandler implements CommandHandler<IssueInvoiceCommand>
|
|
|
85
80
|
export class OnlyIssuerVoidsPolicy {}
|
|
86
81
|
|
|
87
82
|
// application/event-handlers/invoice-issued.event-handler.ts
|
|
88
|
-
@DomainEventHandler(InvoiceIssued
|
|
83
|
+
@DomainEventHandler(InvoiceIssued)
|
|
89
84
|
export class InvoiceIssuedEventHandler {}
|
|
90
85
|
```
|
|
91
86
|
|
|
@@ -95,8 +90,6 @@ Un décorateur compte quand son nom est l'un des douze décorateurs de déclarat
|
|
|
95
90
|
|
|
96
91
|
Le rôle d'un fichier se lit à son suffixe et à son dossier, tels que le générateur les écrit. Une classe est exportée en ligne, par `export { A }` ou par `export default A`. Quand une classe porte un autre décorateur de déclaration, seul celui-ci est signalé : le corriger répond aussi au décorateur manquant.
|
|
97
92
|
|
|
98
|
-
La classe d'événement de `@DomainEventHandler` est en vue quand elle est déclarée dans le même fichier, ou importée par son nom depuis une source du projet qui existe sur le disque ; ce fichier est alors analysé, syntaxe seulement, et son `static readonly eventName = '...'` (ou, comme l'écrivait la 0.5, son `readonly name = '...'`) est lu (`as const` et `satisfies` sont traversés). Quand la classe est introuvable, ou que son nom n'est pas un littéral, rien n'est comparé.
|
|
99
|
-
|
|
100
93
|
## Options
|
|
101
94
|
|
|
102
95
|
Aucune.
|
|
@@ -105,7 +98,6 @@ Aucune.
|
|
|
105
98
|
|
|
106
99
|
## Limites
|
|
107
100
|
|
|
108
|
-
- Une classe d'événement atteinte par un *barrel* (`@/contexts/billing/domain/events/index`), un export qui renomme, un import par défaut ou un espace de noms n'est pas suivie : son nom n'est pas comparé. `ddd-ts-kit check` résout le même import dans le projet.
|
|
109
101
|
- Un décorateur appliqué par une variable (`const declare = Repository(InvoiceRepository); @declare class ...`) n'est pas reconnu.
|
|
110
102
|
- Ce qu'une classe reçoit relève de `declarations/constructor-injection` ; qu'une liste corresponde au constructeur et qu'un gestionnaire traite son message est vérifié par le compilateur, pas ici ; qu'un adaptateur implémente son port relève de `ports/implements-never-extends`, et l'endroit où vit un *job* et son nom relèvent de `scheduling/job-triggers-use-case` et de `scheduling/job-name`.
|
|
111
103
|
- Que chaque fichier de rôle contienne une seule classe déclarée relève de `naming/one-concept-per-file` de `ddd-ts-kit check`.
|
|
@@ -19,8 +19,7 @@ In a role file (the table below), other than `*.command.ts` and `*.query.ts`, wh
|
|
|
19
19
|
|
|
20
20
|
On any class of `application/`, `infrastructure/`, `presentation/` or the context root:
|
|
21
21
|
|
|
22
|
-
- `@IntegrationEventHandler(definition, { consumer })
|
|
23
|
-
- `@DomainEventHandler(Event, { name })` whose `name`, written out, differs from the name the event class declares, when that class is in view
|
|
22
|
+
- `@IntegrationEventHandler(definition, { consumer })` or `@Policy(permission, { name })` whose name is not a non-empty string literal: missing, empty, a variable, a template with a substitution, options held in a variable or only spread. `@DomainEventHandler(Event)` writes no name: it is attached under the one its event class declares once, `static readonly eventName`, which the compiler requires
|
|
24
23
|
|
|
25
24
|
Under `domain/`:
|
|
26
25
|
|
|
@@ -54,10 +53,6 @@ export class SearchInvoicesHandler {}
|
|
|
54
53
|
@Policy(billingPermissions['invoice.void'], { name: policyName })
|
|
55
54
|
export class OnlyIssuerVoidsPolicy {}
|
|
56
55
|
|
|
57
|
-
// application/event-handlers/invoice-issued.event-handler.ts, where InvoiceIssued is named 'billing.invoice.issued'
|
|
58
|
-
@DomainEventHandler(InvoiceIssued, { name: 'billing.invoice.sent' })
|
|
59
|
-
export class InvoiceIssuedEventHandler {}
|
|
60
|
-
|
|
61
56
|
// domain/aggregates/invoice.aggregate.ts
|
|
62
57
|
@Repository(InvoiceRepository)
|
|
63
58
|
export class Invoice {}
|
|
@@ -84,7 +79,7 @@ export class IssueInvoiceHandler implements CommandHandler<IssueInvoiceCommand>
|
|
|
84
79
|
export class OnlyIssuerVoidsPolicy {}
|
|
85
80
|
|
|
86
81
|
// application/event-handlers/invoice-issued.event-handler.ts
|
|
87
|
-
@DomainEventHandler(InvoiceIssued
|
|
82
|
+
@DomainEventHandler(InvoiceIssued)
|
|
88
83
|
export class InvoiceIssuedEventHandler {}
|
|
89
84
|
```
|
|
90
85
|
|
|
@@ -94,8 +89,6 @@ A decorator counts when its name is one of the twelve declaration decorators and
|
|
|
94
89
|
|
|
95
90
|
The role of a file is read from its suffix and its folder, as the generator writes them. A class is exported inline, by `export { A }` or by `export default A`. When a class carries another declaration decorator, only that is reported: fixing it also answers the missing one.
|
|
96
91
|
|
|
97
|
-
The event class of `@DomainEventHandler` is in view when it is declared in the same file, or imported by name from a source of the project that exists on disk; that file is then parsed, syntax only, and its `static readonly eventName = '...'` (or, as 0.5 wrote it, its `readonly name = '...'`) is read (`as const` and `satisfies` are looked through). When the class cannot be found, or its name is not a literal, nothing is compared.
|
|
98
|
-
|
|
99
92
|
## Options
|
|
100
93
|
|
|
101
94
|
None.
|
|
@@ -104,7 +97,6 @@ None.
|
|
|
104
97
|
|
|
105
98
|
## Limits
|
|
106
99
|
|
|
107
|
-
- An event class reached through a barrel (`@/contexts/billing/domain/events/index`), a renaming export, a default import or a namespace is not followed: its name is not compared. `ddd-ts-kit check` resolves the same import in the project.
|
|
108
100
|
- A decorator applied through a variable (`const declare = Repository(InvoiceRepository); @declare class ...`) is not recognised.
|
|
109
101
|
- What a class is given is `declarations/constructor-injection`; that a list matches the constructor and that a handler handles its message is checked by the compiler, not here; that an adapter implements its port is `ports/implements-never-extends`, and where a job lives and what it is named are `scheduling/job-triggers-use-case` and `scheduling/job-name`.
|
|
110
102
|
- That each role file holds a single declared class is `naming/one-concept-per-file` of `ddd-ts-kit check`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](domain-events-dispatched-on-save.md) · **Français**
|
|
2
|
-
<!-- translation-of: domain-events-dispatched-on-save.md sha256:
|
|
2
|
+
<!-- translation-of: domain-events-dispatched-on-save.md sha256:815a6be7014d66ca -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/domain-events-dispatched-on-save
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ Incorrect :
|
|
|
22
22
|
// src/contexts/billing/application/commands/issue-invoice/issue-invoice.handler.ts
|
|
23
23
|
import { Clock, DomainEventDispatcher } from '@ddd-ts-kit/kernel';
|
|
24
24
|
|
|
25
|
-
@CommandHandler(IssueInvoice
|
|
25
|
+
@CommandHandler(IssueInvoice)
|
|
26
26
|
export class IssueInvoiceHandler {
|
|
27
27
|
constructor(
|
|
28
28
|
private readonly invoices: InvoiceRepository,
|
|
@@ -47,7 +47,7 @@ Correct :
|
|
|
47
47
|
// src/contexts/billing/application/commands/issue-invoice/issue-invoice.handler.ts
|
|
48
48
|
import { Clock } from '@ddd-ts-kit/kernel';
|
|
49
49
|
|
|
50
|
-
@CommandHandler(IssueInvoice
|
|
50
|
+
@CommandHandler(IssueInvoice)
|
|
51
51
|
export class IssueInvoiceHandler {
|
|
52
52
|
constructor(
|
|
53
53
|
private readonly invoices: InvoiceRepository,
|
|
@@ -21,7 +21,7 @@ Incorrect:
|
|
|
21
21
|
// src/contexts/billing/application/commands/issue-invoice/issue-invoice.handler.ts
|
|
22
22
|
import { Clock, DomainEventDispatcher } from '@ddd-ts-kit/kernel';
|
|
23
23
|
|
|
24
|
-
@CommandHandler(IssueInvoice
|
|
24
|
+
@CommandHandler(IssueInvoice)
|
|
25
25
|
export class IssueInvoiceHandler {
|
|
26
26
|
constructor(
|
|
27
27
|
private readonly invoices: InvoiceRepository,
|
|
@@ -46,7 +46,7 @@ Correct:
|
|
|
46
46
|
// src/contexts/billing/application/commands/issue-invoice/issue-invoice.handler.ts
|
|
47
47
|
import { Clock } from '@ddd-ts-kit/kernel';
|
|
48
48
|
|
|
49
|
-
@CommandHandler(IssueInvoice
|
|
49
|
+
@CommandHandler(IssueInvoice)
|
|
50
50
|
export class IssueInvoiceHandler {
|
|
51
51
|
constructor(
|
|
52
52
|
private readonly invoices: InvoiceRepository,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](domain-events-transactional-before-commit.md) · **Français**
|
|
2
|
-
<!-- translation-of: domain-events-transactional-before-commit.md sha256:
|
|
2
|
+
<!-- translation-of: domain-events-transactional-before-commit.md sha256:9a978f4c0a72e179 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/domain-events-transactional-before-commit
|
|
5
5
|
|
|
@@ -35,7 +35,7 @@ import { Cache } from '@ddd-ts-kit/kernel';
|
|
|
35
35
|
import { DomainEventHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
36
36
|
import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
|
|
37
37
|
|
|
38
|
-
@DomainEventHandler(InvoiceIssued
|
|
38
|
+
@DomainEventHandler(InvoiceIssued)
|
|
39
39
|
export class InvoiceIssuedEventHandler {
|
|
40
40
|
constructor(
|
|
41
41
|
private readonly invoices: InvoiceRepository,
|
|
@@ -45,28 +45,42 @@ export class InvoiceIssuedEventHandler {
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
|
-
@DomainEventHandler(InvoiceIssued, {
|
|
49
|
-
export class InvoiceIssuedEventHandler {
|
|
48
|
+
@DomainEventHandler(InvoiceIssued, { phase: 'after-commit' })
|
|
49
|
+
export class InvoiceIssuedEventHandler {
|
|
50
|
+
constructor(private readonly integrationEventPublisher: IntegrationEventPublisher) {}
|
|
51
|
+
}
|
|
50
52
|
```
|
|
51
53
|
|
|
52
54
|
Correct :
|
|
53
55
|
|
|
54
56
|
```ts
|
|
55
57
|
// l'état que change le gestionnaire est validé ou annulé avec la commande
|
|
56
|
-
@DomainEventHandler(InvoiceIssued
|
|
57
|
-
export class InvoiceIssuedEventHandler {
|
|
58
|
+
@DomainEventHandler(InvoiceIssued)
|
|
59
|
+
export class InvoiceIssuedEventHandler {
|
|
60
|
+
constructor(
|
|
61
|
+
private readonly invoiceRepository: InvoiceRepository,
|
|
62
|
+
private readonly commandBus: CommandBus,
|
|
63
|
+
) {}
|
|
64
|
+
}
|
|
58
65
|
```
|
|
59
66
|
|
|
60
67
|
```ts
|
|
61
68
|
// un effet qu'aucune transaction ne couvre s'exécute une fois la transaction validée, au plus une fois
|
|
62
|
-
@DomainEventHandler(InvoiceIssued, {
|
|
63
|
-
export class InvoiceIssuedEventHandler {
|
|
69
|
+
@DomainEventHandler(InvoiceIssued, { phase: 'after-commit' })
|
|
70
|
+
export class InvoiceIssuedEventHandler {
|
|
71
|
+
constructor(private readonly cache: Cache) {}
|
|
72
|
+
}
|
|
64
73
|
```
|
|
65
74
|
|
|
66
75
|
```ts
|
|
67
76
|
// un effet qui ne doit pas être perdu passe par l'outbox : le gestionnaire de l'événement d'intégration fait le travail
|
|
68
|
-
@DomainEventHandler(InvoiceIssued
|
|
69
|
-
export class InvoiceIssuedPublisher {
|
|
77
|
+
@DomainEventHandler(InvoiceIssued)
|
|
78
|
+
export class InvoiceIssuedPublisher {
|
|
79
|
+
constructor(
|
|
80
|
+
private readonly integrationEventPublisher: IntegrationEventPublisher,
|
|
81
|
+
private readonly idGenerator: IdGenerator,
|
|
82
|
+
) {}
|
|
83
|
+
}
|
|
70
84
|
```
|
|
71
85
|
|
|
72
86
|
## Détails
|
|
@@ -34,7 +34,7 @@ import { Cache } from '@ddd-ts-kit/kernel';
|
|
|
34
34
|
import { DomainEventHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
35
35
|
import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
|
|
36
36
|
|
|
37
|
-
@DomainEventHandler(InvoiceIssued
|
|
37
|
+
@DomainEventHandler(InvoiceIssued)
|
|
38
38
|
export class InvoiceIssuedEventHandler {
|
|
39
39
|
constructor(
|
|
40
40
|
private readonly invoices: InvoiceRepository,
|
|
@@ -44,28 +44,42 @@ export class InvoiceIssuedEventHandler {
|
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
```ts
|
|
47
|
-
@DomainEventHandler(InvoiceIssued, {
|
|
48
|
-
export class InvoiceIssuedEventHandler {
|
|
47
|
+
@DomainEventHandler(InvoiceIssued, { phase: 'after-commit' })
|
|
48
|
+
export class InvoiceIssuedEventHandler {
|
|
49
|
+
constructor(private readonly integrationEventPublisher: IntegrationEventPublisher) {}
|
|
50
|
+
}
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
Correct:
|
|
52
54
|
|
|
53
55
|
```ts
|
|
54
56
|
// the state the handler changes commits or rolls back with the command
|
|
55
|
-
@DomainEventHandler(InvoiceIssued
|
|
56
|
-
export class InvoiceIssuedEventHandler {
|
|
57
|
+
@DomainEventHandler(InvoiceIssued)
|
|
58
|
+
export class InvoiceIssuedEventHandler {
|
|
59
|
+
constructor(
|
|
60
|
+
private readonly invoiceRepository: InvoiceRepository,
|
|
61
|
+
private readonly commandBus: CommandBus,
|
|
62
|
+
) {}
|
|
63
|
+
}
|
|
57
64
|
```
|
|
58
65
|
|
|
59
66
|
```ts
|
|
60
67
|
// an effect no transaction covers runs once the transaction has committed, at most once
|
|
61
|
-
@DomainEventHandler(InvoiceIssued, {
|
|
62
|
-
export class InvoiceIssuedEventHandler {
|
|
68
|
+
@DomainEventHandler(InvoiceIssued, { phase: 'after-commit' })
|
|
69
|
+
export class InvoiceIssuedEventHandler {
|
|
70
|
+
constructor(private readonly cache: Cache) {}
|
|
71
|
+
}
|
|
63
72
|
```
|
|
64
73
|
|
|
65
74
|
```ts
|
|
66
75
|
// an effect that must not be lost goes through the outbox: the handler of the integration event does the work
|
|
67
|
-
@DomainEventHandler(InvoiceIssued
|
|
68
|
-
export class InvoiceIssuedPublisher {
|
|
76
|
+
@DomainEventHandler(InvoiceIssued)
|
|
77
|
+
export class InvoiceIssuedPublisher {
|
|
78
|
+
constructor(
|
|
79
|
+
private readonly integrationEventPublisher: IntegrationEventPublisher,
|
|
80
|
+
private readonly idGenerator: IdGenerator,
|
|
81
|
+
) {}
|
|
82
|
+
}
|
|
69
83
|
```
|
|
70
84
|
|
|
71
85
|
## Details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](events-consumer-idempotent.md) · **Français**
|
|
2
|
-
<!-- translation-of: events-consumer-idempotent.md sha256:
|
|
2
|
+
<!-- translation-of: events-consumer-idempotent.md sha256:03b7477d9bda7e88 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/events-consumer-idempotent
|
|
5
5
|
|
|
@@ -28,8 +28,10 @@ subscribeAll(platform.subscriber, [on(productListedV1, (event) => consumer.handl
|
|
|
28
28
|
resolve(IntegrationEventSubscriber).subscribe('catalog.product.listed', (event) => consumer.handle(event));
|
|
29
29
|
|
|
30
30
|
// style déclaré
|
|
31
|
-
@IntegrationEventHandler(productListedV1, { consumer: consumerName }
|
|
32
|
-
export class CatalogProductListedHandler {
|
|
31
|
+
@IntegrationEventHandler(productListedV1, { consumer: consumerName })
|
|
32
|
+
export class CatalogProductListedHandler {
|
|
33
|
+
constructor(private readonly commandBus: CommandBus) {}
|
|
34
|
+
}
|
|
33
35
|
```
|
|
34
36
|
|
|
35
37
|
Correct :
|
|
@@ -42,8 +44,10 @@ subscribeAll(platform.subscriber, [
|
|
|
42
44
|
]);
|
|
43
45
|
|
|
44
46
|
// style déclaré
|
|
45
|
-
@IntegrationEventHandler(productListedV1, { consumer: 'billing.catalog-product-listed' }
|
|
46
|
-
export class CatalogProductListedHandler {
|
|
47
|
+
@IntegrationEventHandler(productListedV1, { consumer: 'billing.catalog-product-listed' })
|
|
48
|
+
export class CatalogProductListedHandler {
|
|
49
|
+
constructor(private readonly commandBus: CommandBus) {}
|
|
50
|
+
}
|
|
47
51
|
```
|
|
48
52
|
|
|
49
53
|
## Détails
|
|
@@ -27,8 +27,10 @@ subscribeAll(platform.subscriber, [on(productListedV1, (event) => consumer.handl
|
|
|
27
27
|
resolve(IntegrationEventSubscriber).subscribe('catalog.product.listed', (event) => consumer.handle(event));
|
|
28
28
|
|
|
29
29
|
// declared style
|
|
30
|
-
@IntegrationEventHandler(productListedV1, { consumer: consumerName }
|
|
31
|
-
export class CatalogProductListedHandler {
|
|
30
|
+
@IntegrationEventHandler(productListedV1, { consumer: consumerName })
|
|
31
|
+
export class CatalogProductListedHandler {
|
|
32
|
+
constructor(private readonly commandBus: CommandBus) {}
|
|
33
|
+
}
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
Correct:
|
|
@@ -41,8 +43,10 @@ subscribeAll(platform.subscriber, [
|
|
|
41
43
|
]);
|
|
42
44
|
|
|
43
45
|
// declared style
|
|
44
|
-
@IntegrationEventHandler(productListedV1, { consumer: 'billing.catalog-product-listed' }
|
|
45
|
-
export class CatalogProductListedHandler {
|
|
46
|
+
@IntegrationEventHandler(productListedV1, { consumer: 'billing.catalog-product-listed' })
|
|
47
|
+
export class CatalogProductListedHandler {
|
|
48
|
+
constructor(private readonly commandBus: CommandBus) {}
|
|
49
|
+
}
|
|
46
50
|
```
|
|
47
51
|
|
|
48
52
|
## Details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](events-name-format.md) · **Français**
|
|
2
|
-
<!-- translation-of: events-name-format.md sha256:
|
|
2
|
+
<!-- translation-of: events-name-format.md sha256:282199502c3aaecf -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/events-name-format
|
|
5
5
|
|
|
@@ -38,7 +38,7 @@ export class InvoiceIssued implements DomainEvent {
|
|
|
38
38
|
|
|
39
39
|
## Détails
|
|
40
40
|
|
|
41
|
-
Les littéraux de gabarit (template literals) sans interpolation sont lus comme des chaînes. Le nom est déclaré une fois, dans `eventName`, que l'événement porte dans `name` et que ses réactions lisent (
|
|
41
|
+
Les littéraux de gabarit (template literals) sans interpolation sont lus comme des chaînes. Le nom est déclaré une fois, dans `eventName`, que l'événement porte dans `name` et que ses réactions lisent (`@DomainEventHandler(InvoiceIssued)`) ; un `readonly name = '..'` écrit en toutes lettres, comme avant la 0.6, est jugé de la même façon.
|
|
42
42
|
|
|
43
43
|
## Options
|
|
44
44
|
|
|
@@ -37,7 +37,7 @@ export class InvoiceIssued implements DomainEvent {
|
|
|
37
37
|
|
|
38
38
|
## Details
|
|
39
39
|
|
|
40
|
-
Template literals without interpolation are read like strings. The name is declared once, in `eventName`, which the event carries in `name` and its reactions read (
|
|
40
|
+
Template literals without interpolation are read like strings. The name is declared once, in `eventName`, which the event carries in `name` and its reactions read (`@DomainEventHandler(InvoiceIssued)`); a `readonly name = '..'` written out, as before 0.6, is judged the same way.
|
|
41
41
|
|
|
42
42
|
## Options
|
|
43
43
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](layer-application-inward.md) · **Français**
|
|
2
|
-
<!-- translation-of: layer-application-inward.md sha256:
|
|
2
|
+
<!-- translation-of: layer-application-inward.md sha256:6e16bc8f73e2aef0 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/layer-application-inward
|
|
5
5
|
|
|
@@ -40,8 +40,14 @@ import { PaymentGateway } from '@/contexts/billing/application/ports/payment-gat
|
|
|
40
40
|
// style déclaré
|
|
41
41
|
import { CommandHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
42
42
|
|
|
43
|
-
@CommandHandler(IssueInvoiceCommand
|
|
44
|
-
export class IssueInvoiceHandler implements CommandHandler<IssueInvoiceCommand> {
|
|
43
|
+
@CommandHandler(IssueInvoiceCommand)
|
|
44
|
+
export class IssueInvoiceHandler implements CommandHandler<IssueInvoiceCommand> {
|
|
45
|
+
constructor(
|
|
46
|
+
private readonly invoiceRepository: InvoiceRepository,
|
|
47
|
+
private readonly paymentGateway: PaymentGateway,
|
|
48
|
+
private readonly clock: Clock,
|
|
49
|
+
) {}
|
|
50
|
+
}
|
|
45
51
|
```
|
|
46
52
|
|
|
47
53
|
## Détails
|
|
@@ -39,8 +39,14 @@ import { PaymentGateway } from '@/contexts/billing/application/ports/payment-gat
|
|
|
39
39
|
// declared style
|
|
40
40
|
import { CommandHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
41
41
|
|
|
42
|
-
@CommandHandler(IssueInvoiceCommand
|
|
43
|
-
export class IssueInvoiceHandler implements CommandHandler<IssueInvoiceCommand> {
|
|
42
|
+
@CommandHandler(IssueInvoiceCommand)
|
|
43
|
+
export class IssueInvoiceHandler implements CommandHandler<IssueInvoiceCommand> {
|
|
44
|
+
constructor(
|
|
45
|
+
private readonly invoiceRepository: InvoiceRepository,
|
|
46
|
+
private readonly paymentGateway: PaymentGateway,
|
|
47
|
+
private readonly clock: Clock,
|
|
48
|
+
) {}
|
|
49
|
+
}
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
## Details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](ports-implements-never-extends.md) · **Français**
|
|
2
|
-
<!-- translation-of: ports-implements-never-extends.md sha256:
|
|
2
|
+
<!-- translation-of: ports-implements-never-extends.md sha256:00a3d609e321314e -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/ports-implements-never-extends
|
|
5
5
|
|
|
@@ -20,8 +20,10 @@ Un adaptateur honore un contrat ; il n'en hérite pas. `implements` laisse le co
|
|
|
20
20
|
Incorrect :
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
@Repository(InvoiceRepository
|
|
24
|
-
export class KnexInvoiceRepository extends InvoiceRepository {
|
|
23
|
+
@Repository(InvoiceRepository)
|
|
24
|
+
export class KnexInvoiceRepository extends InvoiceRepository {
|
|
25
|
+
constructor(private readonly database: Database) {}
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
builder.bind(PaymentGateway).toClass(StripePaymentGateway, [PaymentSettings]);
|
|
27
29
|
// où : export class StripePaymentGateway {}
|
|
@@ -30,8 +32,10 @@ builder.bind(PaymentGateway).toClass(StripePaymentGateway, [PaymentSettings]);
|
|
|
30
32
|
Correct :
|
|
31
33
|
|
|
32
34
|
```ts
|
|
33
|
-
@Repository(InvoiceRepository
|
|
34
|
-
export class KnexInvoiceRepository implements InvoiceRepository {
|
|
35
|
+
@Repository(InvoiceRepository)
|
|
36
|
+
export class KnexInvoiceRepository implements InvoiceRepository {
|
|
37
|
+
constructor(private readonly database: Database) {}
|
|
38
|
+
}
|
|
35
39
|
|
|
36
40
|
export class StripePaymentGateway implements PaymentGateway {}
|
|
37
41
|
```
|
|
@@ -19,8 +19,10 @@ An adapter honours a contract; it does not inherit from it. `implements` lets th
|
|
|
19
19
|
Incorrect:
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
@Repository(InvoiceRepository
|
|
23
|
-
export class KnexInvoiceRepository extends InvoiceRepository {
|
|
22
|
+
@Repository(InvoiceRepository)
|
|
23
|
+
export class KnexInvoiceRepository extends InvoiceRepository {
|
|
24
|
+
constructor(private readonly database: Database) {}
|
|
25
|
+
}
|
|
24
26
|
|
|
25
27
|
builder.bind(PaymentGateway).toClass(StripePaymentGateway, [PaymentSettings]);
|
|
26
28
|
// where: export class StripePaymentGateway {}
|
|
@@ -29,8 +31,10 @@ builder.bind(PaymentGateway).toClass(StripePaymentGateway, [PaymentSettings]);
|
|
|
29
31
|
Correct:
|
|
30
32
|
|
|
31
33
|
```ts
|
|
32
|
-
@Repository(InvoiceRepository
|
|
33
|
-
export class KnexInvoiceRepository implements InvoiceRepository {
|
|
34
|
+
@Repository(InvoiceRepository)
|
|
35
|
+
export class KnexInvoiceRepository implements InvoiceRepository {
|
|
36
|
+
constructor(private readonly database: Database) {}
|
|
37
|
+
}
|
|
34
38
|
|
|
35
39
|
export class StripePaymentGateway implements PaymentGateway {}
|
|
36
40
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](ports-no-concrete-dependency.md) · **Français**
|
|
2
|
-
<!-- translation-of: ports-no-concrete-dependency.md sha256:
|
|
2
|
+
<!-- translation-of: ports-no-concrete-dependency.md sha256:4743d3de0c74fb07 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/ports-no-concrete-dependency
|
|
5
5
|
|
|
@@ -22,8 +22,13 @@ Incorrect :
|
|
|
22
22
|
```ts
|
|
23
23
|
import { KnexInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/knex-invoice.repository';
|
|
24
24
|
|
|
25
|
-
@CommandHandler(IssueInvoiceCommand
|
|
26
|
-
export class IssueInvoiceHandler {
|
|
25
|
+
@CommandHandler(IssueInvoiceCommand)
|
|
26
|
+
export class IssueInvoiceHandler {
|
|
27
|
+
constructor(
|
|
28
|
+
private readonly knexInvoiceRepository: KnexInvoiceRepository,
|
|
29
|
+
private readonly clock: Clock,
|
|
30
|
+
) {}
|
|
31
|
+
}
|
|
27
32
|
```
|
|
28
33
|
|
|
29
34
|
Correct :
|
|
@@ -31,8 +36,13 @@ Correct :
|
|
|
31
36
|
```ts
|
|
32
37
|
import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
|
|
33
38
|
|
|
34
|
-
@CommandHandler(IssueInvoiceCommand
|
|
35
|
-
export class IssueInvoiceHandler {
|
|
39
|
+
@CommandHandler(IssueInvoiceCommand)
|
|
40
|
+
export class IssueInvoiceHandler {
|
|
41
|
+
constructor(
|
|
42
|
+
private readonly invoiceRepository: InvoiceRepository,
|
|
43
|
+
private readonly clock: Clock,
|
|
44
|
+
) {}
|
|
45
|
+
}
|
|
36
46
|
```
|
|
37
47
|
|
|
38
48
|
## Détails
|
|
@@ -21,8 +21,13 @@ Incorrect:
|
|
|
21
21
|
```ts
|
|
22
22
|
import { KnexInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/knex-invoice.repository';
|
|
23
23
|
|
|
24
|
-
@CommandHandler(IssueInvoiceCommand
|
|
25
|
-
export class IssueInvoiceHandler {
|
|
24
|
+
@CommandHandler(IssueInvoiceCommand)
|
|
25
|
+
export class IssueInvoiceHandler {
|
|
26
|
+
constructor(
|
|
27
|
+
private readonly knexInvoiceRepository: KnexInvoiceRepository,
|
|
28
|
+
private readonly clock: Clock,
|
|
29
|
+
) {}
|
|
30
|
+
}
|
|
26
31
|
```
|
|
27
32
|
|
|
28
33
|
Correct:
|
|
@@ -30,8 +35,13 @@ Correct:
|
|
|
30
35
|
```ts
|
|
31
36
|
import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
|
|
32
37
|
|
|
33
|
-
@CommandHandler(IssueInvoiceCommand
|
|
34
|
-
export class IssueInvoiceHandler {
|
|
38
|
+
@CommandHandler(IssueInvoiceCommand)
|
|
39
|
+
export class IssueInvoiceHandler {
|
|
40
|
+
constructor(
|
|
41
|
+
private readonly invoiceRepository: InvoiceRepository,
|
|
42
|
+
private readonly clock: Clock,
|
|
43
|
+
) {}
|
|
44
|
+
}
|
|
35
45
|
```
|
|
36
46
|
|
|
37
47
|
## Details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](ports-value-import.md) · **Français**
|
|
2
|
-
<!-- translation-of: ports-value-import.md sha256:
|
|
2
|
+
<!-- translation-of: ports-value-import.md sha256:56fe341111170bd1 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/ports-value-import
|
|
5
5
|
|
|
@@ -21,8 +21,8 @@ Incorrect :
|
|
|
21
21
|
```ts
|
|
22
22
|
import type { Clock } from '@ddd-ts-kit/kernel';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// billing.module.ts, style explicite
|
|
25
|
+
builder.command(IssueInvoiceCommand).handledBy(IssueInvoiceHandler, [Clock]);
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Correct :
|
|
@@ -30,8 +30,8 @@ Correct :
|
|
|
30
30
|
```ts
|
|
31
31
|
import { Clock } from '@ddd-ts-kit/kernel';
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// billing.module.ts, style explicite
|
|
34
|
+
builder.command(IssueInvoiceCommand).handledBy(IssueInvoiceHandler, [Clock]);
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## Détails
|
|
@@ -20,8 +20,8 @@ Incorrect:
|
|
|
20
20
|
```ts
|
|
21
21
|
import type { Clock } from '@ddd-ts-kit/kernel';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// billing.module.ts, explicit style
|
|
24
|
+
builder.command(IssueInvoiceCommand).handledBy(IssueInvoiceHandler, [Clock]);
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Correct:
|
|
@@ -29,8 +29,8 @@ Correct:
|
|
|
29
29
|
```ts
|
|
30
30
|
import { Clock } from '@ddd-ts-kit/kernel';
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// billing.module.ts, explicit style
|
|
33
|
+
builder.command(IssueInvoiceCommand).handledBy(IssueInvoiceHandler, [Clock]);
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](scheduling-job-name.md) · **Français**
|
|
2
|
-
<!-- translation-of: scheduling-job-name.md sha256:
|
|
2
|
+
<!-- translation-of: scheduling-job-name.md sha256:fcce14a1f2803f23 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/scheduling-job-name
|
|
5
5
|
|
|
@@ -21,8 +21,10 @@ Le nom d'un *job* est son identité : le verrou qui limite une occurrence à une
|
|
|
21
21
|
Incorrect :
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
|
-
@Scheduled('SendReminders', { every: '15m' }
|
|
24
|
+
@Scheduled('SendReminders', { every: '15m' })
|
|
25
25
|
export class SendRemindersJob implements ScheduledJob {
|
|
26
|
+
constructor(private readonly commands: CommandBus) {}
|
|
27
|
+
|
|
26
28
|
async run(execution: JobExecution): Promise<void> {
|
|
27
29
|
await this.commands.execute(new SendRemindersCommand(systemActor('reminders'), execution.scheduledAt));
|
|
28
30
|
}
|
|
@@ -32,8 +34,10 @@ export class SendRemindersJob implements ScheduledJob {
|
|
|
32
34
|
Correct :
|
|
33
35
|
|
|
34
36
|
```ts
|
|
35
|
-
@Scheduled('billing.send-reminders', { every: '15m' }
|
|
37
|
+
@Scheduled('billing.send-reminders', { every: '15m' })
|
|
36
38
|
export class SendRemindersJob implements ScheduledJob {
|
|
39
|
+
constructor(private readonly commands: CommandBus) {}
|
|
40
|
+
|
|
37
41
|
async run(execution: JobExecution): Promise<void> {
|
|
38
42
|
await this.commands.execute(new SendRemindersCommand(systemActor('billing.send-reminders'), execution.scheduledAt));
|
|
39
43
|
}
|
|
@@ -20,8 +20,10 @@ The name of a job is its identity: the lock that keeps an occurrence to one run,
|
|
|
20
20
|
Incorrect:
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
@Scheduled('SendReminders', { every: '15m' }
|
|
23
|
+
@Scheduled('SendReminders', { every: '15m' })
|
|
24
24
|
export class SendRemindersJob implements ScheduledJob {
|
|
25
|
+
constructor(private readonly commands: CommandBus) {}
|
|
26
|
+
|
|
25
27
|
async run(execution: JobExecution): Promise<void> {
|
|
26
28
|
await this.commands.execute(new SendRemindersCommand(systemActor('reminders'), execution.scheduledAt));
|
|
27
29
|
}
|
|
@@ -31,8 +33,10 @@ export class SendRemindersJob implements ScheduledJob {
|
|
|
31
33
|
Correct:
|
|
32
34
|
|
|
33
35
|
```ts
|
|
34
|
-
@Scheduled('billing.send-reminders', { every: '15m' }
|
|
36
|
+
@Scheduled('billing.send-reminders', { every: '15m' })
|
|
35
37
|
export class SendRemindersJob implements ScheduledJob {
|
|
38
|
+
constructor(private readonly commands: CommandBus) {}
|
|
39
|
+
|
|
36
40
|
async run(execution: JobExecution): Promise<void> {
|
|
37
41
|
await this.commands.execute(new SendRemindersCommand(systemActor('billing.send-reminders'), execution.scheduledAt));
|
|
38
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](scheduling-job-triggers-use-case.md) · **Français**
|
|
2
|
-
<!-- translation-of: scheduling-job-triggers-use-case.md sha256:
|
|
2
|
+
<!-- translation-of: scheduling-job-triggers-use-case.md sha256:cfb7f54359a91a6d -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit/scheduling-job-triggers-use-case
|
|
5
5
|
|
|
@@ -29,8 +29,13 @@ Incorrect :
|
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
31
|
// application/scheduling/send-reminders.job.ts
|
|
32
|
-
@Scheduled('billing.send-reminders', { every: '15m' }
|
|
32
|
+
@Scheduled('billing.send-reminders', { every: '15m' })
|
|
33
33
|
export class SendRemindersJob implements ScheduledJob {
|
|
34
|
+
constructor(
|
|
35
|
+
private readonly invoices: InvoiceRepository,
|
|
36
|
+
private readonly mailer: Mailer,
|
|
37
|
+
) {}
|
|
38
|
+
|
|
34
39
|
async run(): Promise<void> {
|
|
35
40
|
for (const invoice of await this.invoices.overdue()) {
|
|
36
41
|
await this.mailer.remind(invoice);
|
|
@@ -43,7 +48,7 @@ Correct :
|
|
|
43
48
|
|
|
44
49
|
```ts
|
|
45
50
|
// application/scheduling/send-reminders.job.ts
|
|
46
|
-
@Scheduled('billing.send-reminders', { every: '15m' }
|
|
51
|
+
@Scheduled('billing.send-reminders', { every: '15m' })
|
|
47
52
|
export class SendRemindersJob implements ScheduledJob {
|
|
48
53
|
constructor(private readonly commands: CommandBus) {}
|
|
49
54
|
|
|
@@ -28,8 +28,13 @@ Incorrect:
|
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
// application/scheduling/send-reminders.job.ts
|
|
31
|
-
@Scheduled('billing.send-reminders', { every: '15m' }
|
|
31
|
+
@Scheduled('billing.send-reminders', { every: '15m' })
|
|
32
32
|
export class SendRemindersJob implements ScheduledJob {
|
|
33
|
+
constructor(
|
|
34
|
+
private readonly invoices: InvoiceRepository,
|
|
35
|
+
private readonly mailer: Mailer,
|
|
36
|
+
) {}
|
|
37
|
+
|
|
33
38
|
async run(): Promise<void> {
|
|
34
39
|
for (const invoice of await this.invoices.overdue()) {
|
|
35
40
|
await this.mailer.remind(invoice);
|
|
@@ -42,7 +47,7 @@ Correct:
|
|
|
42
47
|
|
|
43
48
|
```ts
|
|
44
49
|
// application/scheduling/send-reminders.job.ts
|
|
45
|
-
@Scheduled('billing.send-reminders', { every: '15m' }
|
|
50
|
+
@Scheduled('billing.send-reminders', { every: '15m' })
|
|
46
51
|
export class SendRemindersJob implements ScheduledJob {
|
|
47
52
|
constructor(private readonly commands: CommandBus) {}
|
|
48
53
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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
|
+
"keywords": [
|
|
6
|
+
"ddd",
|
|
7
|
+
"domain-driven-design",
|
|
8
|
+
"clean-architecture",
|
|
9
|
+
"hexagonal-architecture",
|
|
10
|
+
"typescript",
|
|
11
|
+
"eslint",
|
|
12
|
+
"eslintplugin",
|
|
13
|
+
"eslint-plugin",
|
|
14
|
+
"architecture-testing",
|
|
15
|
+
"clean-code"
|
|
16
|
+
],
|
|
5
17
|
"license": "MIT",
|
|
6
18
|
"repository": {
|
|
7
19
|
"type": "git",
|
|
@@ -16,14 +28,6 @@
|
|
|
16
28
|
},
|
|
17
29
|
"type": "module",
|
|
18
30
|
"sideEffects": false,
|
|
19
|
-
"keywords": [
|
|
20
|
-
"eslint",
|
|
21
|
-
"eslintplugin",
|
|
22
|
-
"eslint-plugin",
|
|
23
|
-
"ddd",
|
|
24
|
-
"clean-architecture",
|
|
25
|
-
"typescript"
|
|
26
|
-
],
|
|
27
31
|
"engines": {
|
|
28
32
|
"node": ">=22.12.0"
|
|
29
33
|
},
|