ddd-ts-kit 0.2.0 → 0.3.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 +55 -2
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +4 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.d.ts.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.js +12 -0
- package/dist/check/catalogue/eslint-only-rules.js.map +1 -1
- package/dist/check/errors/builds-through-factories.d.ts +4 -0
- package/dist/check/errors/builds-through-factories.d.ts.map +1 -0
- package/dist/check/errors/builds-through-factories.js +5 -0
- package/dist/check/errors/builds-through-factories.js.map +1 -0
- package/dist/check/errors/error-code.d.ts +6 -0
- package/dist/check/errors/error-code.d.ts.map +1 -0
- package/dist/check/errors/error-code.js +2 -0
- package/dist/check/errors/error-code.js.map +1 -0
- package/dist/check/errors/error-codes.d.ts +8 -0
- package/dist/check/errors/error-codes.d.ts.map +1 -0
- package/dist/check/errors/error-codes.js +21 -0
- package/dist/check/errors/error-codes.js.map +1 -0
- package/dist/check/errors/kit-error-codes.d.ts +3 -0
- package/dist/check/errors/kit-error-codes.d.ts.map +1 -0
- package/dist/check/errors/kit-error-codes.js +17 -0
- package/dist/check/errors/kit-error-codes.js.map +1 -0
- package/dist/check/explain/errors-docs.d.ts +3 -0
- package/dist/check/explain/errors-docs.d.ts.map +1 -0
- package/dist/check/explain/errors-docs.js +30 -0
- package/dist/check/explain/errors-docs.js.map +1 -0
- package/dist/check/explain/rule-docs.d.ts.map +1 -1
- package/dist/check/explain/rule-docs.js +2 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/fixtures/errors-fixtures.d.ts +3 -0
- package/dist/check/fixtures/errors-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/errors-fixtures.js +126 -0
- package/dist/check/fixtures/errors-fixtures.js.map +1 -0
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +2 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/rules/errors-code-unique.d.ts +3 -0
- package/dist/check/rules/errors-code-unique.d.ts.map +1 -0
- package/dist/check/rules/errors-code-unique.js +34 -0
- package/dist/check/rules/errors-code-unique.js.map +1 -0
- package/dist/check/rules/errors-known-code.d.ts +3 -0
- package/dist/check/rules/errors-known-code.d.ts.map +1 -0
- package/dist/check/rules/errors-known-code.js +51 -0
- package/dist/check/rules/errors-known-code.js.map +1 -0
- package/dist/check/rules/language-glossary-term.d.ts.map +1 -1
- package/dist/check/rules/language-glossary-term.js +7 -5
- package/dist/check/rules/language-glossary-term.js.map +1 -1
- package/dist/commands/error-factories.d.ts +7 -0
- package/dist/commands/error-factories.d.ts.map +1 -0
- package/dist/commands/error-factories.js +65 -0
- package/dist/commands/error-factories.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-stack.d.ts.map +1 -1
- package/dist/config/parse-stack.js +2 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/stack.d.ts +9 -0
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +1 -0
- package/dist/config/stack.js.map +1 -1
- package/dist/describe/context-description.d.ts +12 -0
- package/dist/describe/context-description.d.ts.map +1 -1
- package/dist/describe/describe-context.d.ts.map +1 -1
- package/dist/describe/describe-context.js +2 -0
- package/dist/describe/describe-context.js.map +1 -1
- package/dist/describe/format-description.d.ts.map +1 -1
- package/dist/describe/format-description.js +5 -0
- package/dist/describe/format-description.js.map +1 -1
- package/dist/describe/read-errors.d.ts +8 -0
- package/dist/describe/read-errors.d.ts.map +1 -0
- package/dist/describe/read-errors.js +52 -0
- package/dist/describe/read-errors.js.map +1 -0
- package/dist/describe/reference-lines.js +14 -1
- package/dist/describe/reference-lines.js.map +1 -1
- package/dist/generate/errors/add-factory.d.ts +13 -0
- package/dist/generate/errors/add-factory.d.ts.map +1 -0
- package/dist/generate/errors/add-factory.js +30 -0
- package/dist/generate/errors/add-factory.js.map +1 -0
- package/dist/generate/errors/add-spec-case.d.ts +6 -0
- package/dist/generate/errors/add-spec-case.d.ts.map +1 -0
- package/dist/generate/errors/add-spec-case.js +26 -0
- package/dist/generate/errors/add-spec-case.js.map +1 -0
- package/dist/generate/errors/class-body.d.ts +8 -0
- package/dist/generate/errors/class-body.d.ts.map +1 -0
- package/dist/generate/errors/class-body.js +11 -0
- package/dist/generate/errors/class-body.js.map +1 -0
- package/dist/generate/errors/codes-of-context.d.ts +4 -0
- package/dist/generate/errors/codes-of-context.d.ts.map +1 -0
- package/dist/generate/errors/codes-of-context.js +17 -0
- package/dist/generate/errors/codes-of-context.js.map +1 -0
- package/dist/generate/errors/refusal-code.d.ts +13 -0
- package/dist/generate/errors/refusal-code.d.ts.map +1 -0
- package/dist/generate/errors/refusal-code.js +19 -0
- package/dist/generate/errors/refusal-code.js.map +1 -0
- package/dist/generate/errors/refusal-name.d.ts +4 -0
- package/dist/generate/errors/refusal-name.d.ts.map +1 -0
- package/dist/generate/errors/refusal-name.js +15 -0
- package/dist/generate/errors/refusal-name.js.map +1 -0
- package/dist/generate/errors/static-methods.d.ts +10 -0
- package/dist/generate/errors/static-methods.d.ts.map +1 -0
- package/dist/generate/errors/static-methods.js +13 -0
- package/dist/generate/errors/static-methods.js.map +1 -0
- package/dist/generate/errors/vague-refusal-names.d.ts +3 -0
- package/dist/generate/errors/vague-refusal-names.d.ts.map +1 -0
- package/dist/generate/errors/vague-refusal-names.js +15 -0
- package/dist/generate/errors/vague-refusal-names.js.map +1 -0
- package/dist/generate/kinds/domain-error-kind.d.ts.map +1 -1
- package/dist/generate/kinds/domain-error-kind.js +4 -1
- package/dist/generate/kinds/domain-error-kind.js.map +1 -1
- package/dist/generate/kinds/error-kind.d.ts +3 -0
- package/dist/generate/kinds/error-kind.d.ts.map +1 -0
- package/dist/generate/kinds/error-kind.js +75 -0
- package/dist/generate/kinds/error-kind.js.map +1 -0
- package/dist/generate/kinds.d.ts.map +1 -1
- package/dist/generate/kinds.js +2 -0
- package/dist/generate/kinds.js.map +1 -1
- package/dist/init/manifest/versions.js +23 -23
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +3 -1
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +1 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/refusals/apply-plan.d.ts +17 -0
- package/dist/refusals/apply-plan.d.ts.map +1 -0
- package/dist/refusals/apply-plan.js +118 -0
- package/dist/refusals/apply-plan.js.map +1 -0
- package/dist/refusals/factory-name-for.d.ts +7 -0
- package/dist/refusals/factory-name-for.d.ts.map +1 -0
- package/dist/refusals/factory-name-for.js +16 -0
- package/dist/refusals/factory-name-for.js.map +1 -0
- package/dist/refusals/legacy-error.d.ts +21 -0
- package/dist/refusals/legacy-error.d.ts.map +1 -0
- package/dist/refusals/legacy-error.js +2 -0
- package/dist/refusals/legacy-error.js.map +1 -0
- package/dist/refusals/legacy-errors.d.ts +6 -0
- package/dist/refusals/legacy-errors.d.ts.map +1 -0
- package/dist/refusals/legacy-errors.js +16 -0
- package/dist/refusals/legacy-errors.js.map +1 -0
- package/dist/refusals/migration-draft.d.ts +15 -0
- package/dist/refusals/migration-draft.d.ts.map +1 -0
- package/dist/refusals/migration-draft.js +41 -0
- package/dist/refusals/migration-draft.js.map +1 -0
- package/dist/refusals/migration-plan.d.ts +6 -0
- package/dist/refusals/migration-plan.d.ts.map +1 -0
- package/dist/refusals/migration-plan.js +2 -0
- package/dist/refusals/migration-plan.js.map +1 -0
- package/dist/refusals/move.d.ts +15 -0
- package/dist/refusals/move.d.ts.map +1 -0
- package/dist/refusals/move.js +2 -0
- package/dist/refusals/move.js.map +1 -0
- package/dist/refusals/nested-cases.d.ts +3 -0
- package/dist/refusals/nested-cases.d.ts.map +1 -0
- package/dist/refusals/nested-cases.js +9 -0
- package/dist/refusals/nested-cases.js.map +1 -0
- package/dist/refusals/plan-file.d.ts +3 -0
- package/dist/refusals/plan-file.d.ts.map +1 -0
- package/dist/refusals/plan-file.js +3 -0
- package/dist/refusals/plan-file.js.map +1 -0
- package/dist/refusals/planned-factory.d.ts +11 -0
- package/dist/refusals/planned-factory.d.ts.map +1 -0
- package/dist/refusals/planned-factory.js +2 -0
- package/dist/refusals/planned-factory.js.map +1 -0
- package/dist/refusals/planned-move.d.ts +8 -0
- package/dist/refusals/planned-move.d.ts.map +1 -0
- package/dist/refusals/planned-move.js +2 -0
- package/dist/refusals/planned-move.js.map +1 -0
- package/dist/refusals/project-sources.d.ts +5 -0
- package/dist/refusals/project-sources.d.ts.map +1 -0
- package/dist/refusals/project-sources.js +13 -0
- package/dist/refusals/project-sources.js.map +1 -0
- package/dist/refusals/propose-plan.d.ts +16 -0
- package/dist/refusals/propose-plan.d.ts.map +1 -0
- package/dist/refusals/propose-plan.js +39 -0
- package/dist/refusals/propose-plan.js.map +1 -0
- package/dist/refusals/read-legacy-error.d.ts +9 -0
- package/dist/refusals/read-legacy-error.d.ts.map +1 -0
- package/dist/refusals/read-legacy-error.js +75 -0
- package/dist/refusals/read-legacy-error.js.map +1 -0
- package/dist/refusals/read-plan.d.ts +4 -0
- package/dist/refusals/read-plan.d.ts.map +1 -0
- package/dist/refusals/read-plan.js +43 -0
- package/dist/refusals/read-plan.js.map +1 -0
- package/dist/refusals/render-factory.d.ts +5 -0
- package/dist/refusals/render-factory.d.ts.map +1 -0
- package/dist/refusals/render-factory.js +14 -0
- package/dist/refusals/render-factory.js.map +1 -0
- package/dist/refusals/replace-in-code.d.ts +16 -0
- package/dist/refusals/replace-in-code.d.ts.map +1 -0
- package/dist/refusals/replace-in-code.js +20 -0
- package/dist/refusals/replace-in-code.js.map +1 -0
- package/dist/refusals/rewrite-usages.d.ts +6 -0
- package/dist/refusals/rewrite-usages.d.ts.map +1 -0
- package/dist/refusals/rewrite-usages.js +80 -0
- package/dist/refusals/rewrite-usages.js.map +1 -0
- package/dist/refusals/spec-parts.d.ts +8 -0
- package/dist/refusals/spec-parts.d.ts.map +1 -0
- package/dist/refusals/spec-parts.js +14 -0
- package/dist/refusals/spec-parts.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +7 -1
- package/dist/run.js.map +1 -1
- package/dist/stack/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +2 -1
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/templates/aggregate/aggregate.ts.tpl +5 -0
- package/templates/command/handler.declared.ts.tpl +5 -0
- package/templates/command/handler.ts.tpl +5 -0
- package/templates/docs/openapi.json.tpl +5 -0
- package/templates/entity/entity.ts.tpl +5 -0
- package/templates/error/case.spec.ts.tpl +8 -0
- package/templates/error/concept-error.spec.ts.tpl +7 -0
- package/templates/error/concept-error.ts.tpl +5 -0
- package/templates/error/factory.ts.tpl +4 -0
- package/templates/init/jest.config.js.tpl +7 -0
- package/templates/init/rules/domain.md.tpl +11 -0
- package/templates/init/rules/presentation.md.tpl +5 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/route/route.class-validator.ts.tpl +1 -1
- package/templates/route/route.none.ts.tpl +1 -1
- package/templates/route/route.search.ts.tpl +1 -1
- package/templates/route/route.standard-schema.ts.tpl +1 -1
- package/templates/route/route.zod.ts.tpl +1 -1
- package/templates/value-object/value-object.ts.tpl +5 -0
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ ddd-ts-kit init [--http express|fastify|nest|none]
|
|
|
47
47
|
[--broker none|rabbitmq|kafka|nats|redis|custom] [--cache none|redis] [--audit on|off]
|
|
48
48
|
[--errors none|sentry] [--logger stdout|pino|winston]
|
|
49
49
|
[--style declared|explicit] [--assembly barrel|discovery]
|
|
50
|
+
[--dependencies signature|listed] [--refusals factories|classes]
|
|
50
51
|
[--package-manager npm|pnpm]
|
|
51
52
|
[--allow-no-outbox "<reason>"] [--import-alias '$<name>/']
|
|
52
53
|
[--import-extension none|js]
|
|
@@ -137,6 +138,13 @@ is absent with standard decorators and under `tsx`. `init` writes
|
|
|
137
138
|
what each class is given. Every generated file exports one class, interface or function and is named
|
|
138
139
|
after it.
|
|
139
140
|
|
|
141
|
+
**Domain errors are built by factories.** `init` writes `"stack.refusals": "factories"`: a
|
|
142
|
+
context has one error class per concept, extending `ConceptError` of the kernel, and
|
|
143
|
+
`generate error <context> <Concept> <refusal>` adds a static factory to it. The `errors/*`
|
|
144
|
+
rules hold that form. `--refusals classes`, or a config without the key, keeps one class per
|
|
145
|
+
error built with `new`, as 0.1 and 0.2 wrote them; `error-factories` moves a project from one
|
|
146
|
+
to the other.
|
|
147
|
+
|
|
140
148
|
**Domain events leave with the save.** A generated command handler builds or loads its aggregate,
|
|
141
149
|
calls one intention method, `await repository.save(aggregate)` and returns: no `pullEvents()`, and
|
|
142
150
|
no `DomainEventDispatcher` in a handler or in a repository adapter, which only persists. The events
|
|
@@ -231,7 +239,8 @@ ddd-ts-kit generate --help --json
|
|
|
231
239
|
| `entity` | `<context> <Name>` | entity, spec |
|
|
232
240
|
| `value-object` (`vo`) | `<context> <Name>` | value object, spec |
|
|
233
241
|
| `domain-event` | `<context> <Aggregate> <Fact>` | event named `<context>.<aggregate>.<fact>`, spec |
|
|
234
|
-
| `
|
|
242
|
+
| `error` (`refusal`) | `<context> <Concept> <refusal> [--code CODE] [--term ...]...` | a static factory `<refusal>` on `domain/errors/<concept>.error.ts`, the class of the errors of that concept (created when absent, extending `ConceptError`), and its case in `test/unit/<concept>.error.spec.ts`. The factory is added after the last one; run again, the command changes nothing. `<Concept>` is a term of the glossary (`--term` adds it). The code is the name of the refusal in constant case, with the concept before it when the name is one word or a code of the kit (`Appointment notFound` sets `APPOINTMENT_NOT_FOUND`); `--code` takes one of the forms `errors/factory-name` accepts. Refused: a name such as `create` or `error1`, and a code already set in the context |
|
|
243
|
+
| `domain-error` | `<context> <Name> [--code CODE]` | one class per error with a stable code, spec: the form of a project whose config says `"stack.refusals": "classes"` or nothing. Refused under `factories`, with the `generate error` command to run instead |
|
|
235
244
|
| `domain-service` | `<context> <Name>` | service, spec |
|
|
236
245
|
| `repository` | `<context> <Aggregate> [--tenant-scoped]` | the port `domain/repositories/<name>.repository.ts` (`abstract class <Name>Repository extends Repository<<Name>>`), the adapter of the project's ORM (`implements` the port) with its mapper and table (or model), a fake, one `repositoryContract` spec run on both, registration |
|
|
237
246
|
| `command` | `<context> <UseCaseName> (--permission <aggregate>.<action> \| --public) [--aggregate <Name>]` | `<use-case>.command.ts` on `AuthorizedCommand` (plain `Command` when public), `<use-case>.handler.ts` (it builds the aggregate, saves it and answers: the events leave with the save), spec through the bus with the refusal of an actor who lacks the permission, registration with `.requires(...)` or `.public()` (and the repository when missing). A generated command answers `void` or the identifier of its aggregate, so no `<use-case>.result.ts` is written |
|
|
@@ -413,6 +422,48 @@ published languages, declared upstreams, allowed packages, cycles and orphans. `
|
|
|
413
422
|
it as `.dependency-cruiser.cjs`; `--check` exits 1 when the file is missing or stale, which is
|
|
414
423
|
what `npm run depcruise` runs first. Edit the config, not the file.
|
|
415
424
|
|
|
425
|
+
## error-factories
|
|
426
|
+
|
|
427
|
+
```
|
|
428
|
+
ddd-ts-kit error-factories --plan
|
|
429
|
+
ddd-ts-kit error-factories --apply [--dry-run]
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
Moves a project from one class per error (`new SlotTakenError(..)`) to static factories on one
|
|
433
|
+
error class per concept (`AppointmentError.slotTaken(..)`), in two steps, because which concept
|
|
434
|
+
a refusal is about is a decision of the model.
|
|
435
|
+
|
|
436
|
+
`--plan` writes `error-factories.plan.json`: per context, one entry per class of
|
|
437
|
+
`domain/errors/` that extends `DomainError`, with its code, the concept proposed for it (the
|
|
438
|
+
aggregate its name starts or ends with, empty when none does) and the factory name that says
|
|
439
|
+
its code (`APPOINTMENT_NOT_FOUND` on `Appointment` gives `notFound`). Edit it: every entry
|
|
440
|
+
needs a `concept`, a term of the glossary.
|
|
441
|
+
|
|
442
|
+
`--apply` follows the plan and refuses an entry without a concept, a vague factory name or one
|
|
443
|
+
that does not say the code. It:
|
|
444
|
+
|
|
445
|
+
- writes `domain/errors/<concept>.error.ts`, a class extending `ConceptError` with one factory
|
|
446
|
+
per class moved there: the parameters of the constructor, the message it gave to `super`, and
|
|
447
|
+
as facts the parameters that are plain data (text, numbers, booleans, dates);
|
|
448
|
+
- removes each class and its spec, whose cases go under `describe('<factory>')` in
|
|
449
|
+
`test/unit/<concept>.error.spec.ts`;
|
|
450
|
+
- rewrites every file under the source root and `test/`: `new X(..)` becomes
|
|
451
|
+
`<Concept>Error.<factory>(..)`, `thenError(X)` and `thenError(X, code)` become
|
|
452
|
+
`thenError('<CODE>')`, `toThrow(X)` and `expect.any(X)` become an assertion on the code,
|
|
453
|
+
`toBeInstanceOf(X)` becomes `toMatchObject({ code })`, `e instanceof X` becomes
|
|
454
|
+
`<Concept>Error.is(e, '<CODE>')`, an import of the class becomes the import of its concept
|
|
455
|
+
class, and a type names the concept class. A class of the same name in two contexts goes to
|
|
456
|
+
the concept of its own. Comments and strings are left alone;
|
|
457
|
+
- sets `"stack.refusals": "factories"` in the config.
|
|
458
|
+
|
|
459
|
+
It leaves, and says: a class that has members of its own, reads `this` in its constructor or
|
|
460
|
+
gives options to `super` (written by hand); a place where a class stood as a value it cannot
|
|
461
|
+
translate; a property of the error that became a fact (`error.personId` is now
|
|
462
|
+
`error.facts.personId`); a factory with more than three parameters. And always: which facts a
|
|
463
|
+
client may read (none is exposed), the factories that still take a sentence as only parameter,
|
|
464
|
+
and the facts to assert in the specs. Run the formatter afterwards. Run again, it finds nothing
|
|
465
|
+
left to move. `--json` answers `{ dryRun, moved, written, removed, manual }`.
|
|
466
|
+
|
|
416
467
|
## build-aliases
|
|
417
468
|
|
|
418
469
|
```
|
|
@@ -591,7 +642,7 @@ saying what to do instead. Exit code 1 when there is at least one error.
|
|
|
591
642
|
| `test/builder-required` | an aggregate without `test/builders/<name>.builder.ts` |
|
|
592
643
|
| `events/name-format` | an event name that is not `<context>.<aggregate>.<fact>` in kebab-case with the right context |
|
|
593
644
|
| `events/defined-in-published-language` | `defineIntegrationEvent` outside a published language, without a payload, twice for one version; an event described by hand |
|
|
594
|
-
| `language/glossary-term` | a class of the model named with a word the glossary of its context does not define; an empty glossary |
|
|
645
|
+
| `language/glossary-term` | a class of the model named with a word the glossary of its context does not define; an empty glossary; under `"stack.refusals": "factories"`, an error class of `domain/errors/` too |
|
|
595
646
|
| `language/no-technical-name` | `Manager`, `Helper`, `Util`, `Utils`, `Data`, `Info`, `Processor`, `Wrapper`, `Impl`, `Base`, `Abstract`, `Dto`, `Entity`, `Model` in a type declared under `domain/` or in a use case folder |
|
|
596
647
|
| `purity/no-system-clock` | `new Date()` without argument, `Date.now()`, `performance.now()` in `domain/` or `application/` |
|
|
597
648
|
| `purity/no-ambient-randomness` | `Math.random`, the random source of `crypto`, an id library |
|
|
@@ -635,6 +686,8 @@ saying what to do instead. Exit code 1 when there is at least one error.
|
|
|
635
686
|
| `ports/value-import` | a class named in a dependency list, or given to `bind` or `rebind`, imported with `import type` or `import { type X }` |
|
|
636
687
|
| `scheduling/job-triggers-use-case` | in `application/scheduling/*.job.ts`: an exported class that does not implement `ScheduledJob`; a `run` that sends no command (no `.execute(` call); a repository in the dependency list or the constructor; an import from `domain/aggregates/`, `domain/entities/`, `domain/services/` or `infrastructure/`. A `builder.job(..)` registration of a class that lives elsewhere |
|
|
637
688
|
| `scheduling/job-name` | the first argument of `@Scheduled(..)` or `.job(..)` that is not a string literal `<context>.<job-name>` in lower-case kebab-case with the context of its file; a `systemActor(..)` of a job file passing another name; one job name used twice in the project |
|
|
689
|
+
| `errors/code-unique` | under `"stack.refusals": "factories"`, in the `domain/errors/` of a context: a code set a second time, by a factory (`refusal('CODE', ..)`) or by a class (`readonly code = 'CODE'`), with the file and line of the first. The same code in two contexts is not reported |
|
|
690
|
+
| `errors/known-code` | under `"stack.refusals": "factories"`, in a `*.route.ts`: a code of the `errors` list that no refusal of the context of the route sets, that no class outside the contexts sets, and that is not a code of the kit |
|
|
638
691
|
|
|
639
692
|
Five more ids belong to `@ddd-ts-kit/eslint-plugin`, which reads the syntax tree where this
|
|
640
693
|
checker reads text: `domain/aggregate-encapsulation`, `domain/value-object-immutability`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architecture-rules.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"architecture-rules.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAiE7C,gHAAgH;AAChH,eAAO,MAAM,kBAAkB,EAAE,SAAS,IAAI,EAgE7C,CAAC"}
|
|
@@ -24,6 +24,8 @@ import { declarationsConstructorInjection } from '../rules/declarations-construc
|
|
|
24
24
|
import { declarationsRoleDeclared } from '../rules/declarations-role-declared.js';
|
|
25
25
|
import { domainEventsDispatchedOnSave } from '../rules/domain-events-dispatched-on-save.js';
|
|
26
26
|
import { domainEventsTransactionalBeforeCommit } from '../rules/domain-events-transactional-before-commit.js';
|
|
27
|
+
import { errorsCodeUnique } from '../rules/errors-code-unique.js';
|
|
28
|
+
import { errorsKnownCode } from '../rules/errors-known-code.js';
|
|
27
29
|
import { eventsConsumerIdempotent } from '../rules/events-consumer-idempotent.js';
|
|
28
30
|
import { eventsDefinedInPublishedLanguage } from '../rules/events-defined-in-published-language.js';
|
|
29
31
|
import { eventsNameFormat } from '../rules/events-name-format.js';
|
|
@@ -122,5 +124,7 @@ export const ARCHITECTURE_RULES = [
|
|
|
122
124
|
importsAliasOnly,
|
|
123
125
|
importsExtension,
|
|
124
126
|
importsAliasDeclared,
|
|
127
|
+
errorsCodeUnique,
|
|
128
|
+
errorsKnownCode,
|
|
125
129
|
];
|
|
126
130
|
//# sourceMappingURL=architecture-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architecture-rules.js","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2C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BAA4B;IAC5B,2BAA2B;IAC3B,mCAAmC;IACnC,cAAc;IACd,UAAU;IACV,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,mBAAmB;IACnB,gBAAgB;IAChB,gBAAgB;IAChB,gCAAgC;IAChC,WAAW;IACX,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,mBAAmB;IACnB,yBAAyB;IACzB,mBAAmB;IACnB,aAAa;IACb,iBAAiB;IACjB,uBAAuB;IACvB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,qBAAqB;IACrB,aAAa;IACb,oBAAoB;IACpB,wBAAwB;IACxB,4BAA4B;IAC5B,qCAAqC;IACrC,kBAAkB;IAClB,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,mBAAmB;IACnB,2BAA2B;IAC3B,2BAA2B;IAC3B,uBAAuB;IACvB,wBAAwB;IACxB,yBAAyB;IACzB,gCAAgC;IAChC,kBAAkB;IAClB,2BAA2B;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,gBAAgB;IAChB,4BAA4B;IAC5B,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,oBAAoB;
|
|
1
|
+
{"version":3,"file":"architecture-rules.js","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BA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IACvB,wBAAwB;IACxB,yBAAyB;IACzB,gCAAgC;IAChC,kBAAkB;IAClB,2BAA2B;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,gBAAgB;IAChB,4BAA4B;IAC5B,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,oBAAoB;IACpB,gBAAgB;IAChB,eAAe;CAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-only-rules.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/eslint-only-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"eslint-only-rules.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/eslint-only-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAkC7F,CAAC"}
|
|
@@ -15,6 +15,18 @@ export const ESLINT_ONLY_RULES = [
|
|
|
15
15
|
id: 'domain/no-generic-error',
|
|
16
16
|
description: 'domain/ and application/ never `throw new Error(...)`: a business failure is a DomainError subclass.',
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
id: 'errors/through-factory',
|
|
20
|
+
description: 'Under "stack.refusals": "factories", a domain error is built by a static factory of its concept class: no `new` of a class of domain/errors/ outside that class.',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'errors/constructor-not-public',
|
|
24
|
+
description: 'Under "stack.refusals": "factories", the constructor of an error class of domain/errors/ is not public: the class extends ConceptError and declares none, or declares it private or protected.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'errors/factory-name',
|
|
28
|
+
description: 'Under "stack.refusals": "factories", a static factory of an error class is named after the refusal, never `create`, `make`, `of` or `error1`, and its code is that name in constant case, alone or with the name of the concept.',
|
|
29
|
+
},
|
|
18
30
|
{
|
|
19
31
|
id: 'application/handler-shape',
|
|
20
32
|
description: 'A *.handler.ts file exports one class with a single public method, execute.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-only-rules.js","sourceRoot":"","sources":["../../../src/check/catalogue/eslint-only-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqE;IACjG;QACE,EAAE,EAAE,gCAAgC;QACpC,WAAW,EACT,0GAA0G;KAC7G;IACD;QACE,EAAE,EAAE,kCAAkC;QACtC,WAAW,EAAE,kGAAkG;KAChH;IACD;QACE,EAAE,EAAE,yBAAyB;QAC7B,WAAW,EAAE,sGAAsG;KACpH;IACD;QACE,EAAE,EAAE,2BAA2B;QAC/B,WAAW,EAAE,6EAA6E;KAC3F;IACD,EAAE,EAAE,EAAE,sCAAsC,EAAE,WAAW,EAAE,oDAAoD,EAAE;CAClH,CAAC"}
|
|
1
|
+
{"version":3,"file":"eslint-only-rules.js","sourceRoot":"","sources":["../../../src/check/catalogue/eslint-only-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqE;IACjG;QACE,EAAE,EAAE,gCAAgC;QACpC,WAAW,EACT,0GAA0G;KAC7G;IACD;QACE,EAAE,EAAE,kCAAkC;QACtC,WAAW,EAAE,kGAAkG;KAChH;IACD;QACE,EAAE,EAAE,yBAAyB;QAC7B,WAAW,EAAE,sGAAsG;KACpH;IACD;QACE,EAAE,EAAE,wBAAwB;QAC5B,WAAW,EACT,kKAAkK;KACrK;IACD;QACE,EAAE,EAAE,+BAA+B;QACnC,WAAW,EACT,gMAAgM;KACnM;IACD;QACE,EAAE,EAAE,qBAAqB;QACzB,WAAW,EACT,kOAAkO;KACrO;IACD;QACE,EAAE,EAAE,2BAA2B;QAC/B,WAAW,EAAE,6EAA6E;KAC3F;IACD,EAAE,EAAE,EAAE,sCAAsC,EAAE,WAAW,EAAE,oDAAoD,EAAE;CAClH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Project } from '../model/project.js';
|
|
2
|
+
/** The `errors/*` rules judge a project that says it builds its refusals through factories; one that does not say keeps the form of 0.2. */
|
|
3
|
+
export declare function buildsThroughFactories(project: Project): boolean;
|
|
4
|
+
//# sourceMappingURL=builds-through-factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builds-through-factories.d.ts","sourceRoot":"","sources":["../../../src/check/errors/builds-through-factories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,4IAA4I;AAC5I,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEhE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The `errors/*` rules judge a project that says it builds its refusals through factories; one that does not say keeps the form of 0.2. */
|
|
2
|
+
export function buildsThroughFactories(project) {
|
|
3
|
+
return project.config.stack.refusals === 'factories';
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=builds-through-factories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builds-through-factories.js","sourceRoot":"","sources":["../../../src/check/errors/builds-through-factories.ts"],"names":[],"mappings":"AAEA,4IAA4I;AAC5I,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,WAAW,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-code.d.ts","sourceRoot":"","sources":["../../../src/check/errors/error-code.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-code.js","sourceRoot":"","sources":["../../../src/check/errors/error-code.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Scan } from '../scan/scan.js';
|
|
2
|
+
import type { ErrorCode } from './error-code.js';
|
|
3
|
+
/**
|
|
4
|
+
* The codes a source gives to its refusals, in both forms: the first argument of
|
|
5
|
+
* `.refusal('CODE', ..)` in a factory, and the `readonly code = 'CODE'` field of a class per error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function errorCodes(scan: Scan): ErrorCode[];
|
|
8
|
+
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../../src/check/errors/error-codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAKjD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,CAelD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { wholeLiteral } from '../declarations/whole-literal.js';
|
|
2
|
+
import { callArguments } from '../text/call-arguments.js';
|
|
3
|
+
const REFUSAL_CALL = /\.\s*refusal\s*\(/g;
|
|
4
|
+
const CODE_FIELD = /\breadonly\s+code\s*(?::[^=;]+)?=\s*/g;
|
|
5
|
+
/**
|
|
6
|
+
* The codes a source gives to its refusals, in both forms: the first argument of
|
|
7
|
+
* `.refusal('CODE', ..)` in a factory, and the `readonly code = 'CODE'` field of a class per error.
|
|
8
|
+
*/
|
|
9
|
+
export function errorCodes(scan) {
|
|
10
|
+
const built = [...scan.code.matchAll(REFUSAL_CALL)].flatMap((match) => {
|
|
11
|
+
const [code] = callArguments(scan.code, match.index + match[0].length - 1);
|
|
12
|
+
const literal = code === undefined ? undefined : wholeLiteral(scan, code);
|
|
13
|
+
return literal === undefined ? [] : [{ code: literal, line: scan.lineAt(match.index) }];
|
|
14
|
+
});
|
|
15
|
+
const fields = [...scan.code.matchAll(CODE_FIELD)].flatMap((match) => {
|
|
16
|
+
const literal = scan.strings.find((candidate) => candidate.start === match.index + match[0].length);
|
|
17
|
+
return literal === undefined ? [] : [{ code: literal.value, line: scan.lineAt(match.index) }];
|
|
18
|
+
});
|
|
19
|
+
return [...built, ...fields].sort((a, b) => a.line - b.line);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../../../src/check/errors/error-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAC1C,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACpE,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1E,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACnE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAEpG,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-error-codes.d.ts","sourceRoot":"","sources":["../../../src/check/errors/kit-error-codes.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAc5C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The codes of the refusals the packages of the kit raise, which a route may declare without a class of the project. */
|
|
2
|
+
export const KIT_ERROR_CODES = [
|
|
3
|
+
'VALIDATION_FAILED',
|
|
4
|
+
'NOT_FOUND',
|
|
5
|
+
'CONFLICT',
|
|
6
|
+
'INVARIANT_VIOLATION',
|
|
7
|
+
'UNAUTHORIZED',
|
|
8
|
+
'FORBIDDEN',
|
|
9
|
+
'CONCURRENCY_CONFLICT',
|
|
10
|
+
'INVALID_CRITERIA',
|
|
11
|
+
'INVALID_PAGE_REQUEST',
|
|
12
|
+
'TIMEOUT',
|
|
13
|
+
'CIRCUIT_OPEN',
|
|
14
|
+
'BULKHEAD_FULL',
|
|
15
|
+
'ATTEMPTS_EXHAUSTED',
|
|
16
|
+
];
|
|
17
|
+
//# sourceMappingURL=kit-error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-error-codes.js","sourceRoot":"","sources":["../../../src/check/errors/kit-error-codes.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,MAAM,CAAC,MAAM,eAAe,GAAsB;IAChD,mBAAmB;IACnB,WAAW;IACX,UAAU;IACV,qBAAqB;IACrB,cAAc;IACd,WAAW;IACX,sBAAsB;IACtB,kBAAkB;IAClB,sBAAsB;IACtB,SAAS;IACT,cAAc;IACd,eAAe;IACf,oBAAoB;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/errors-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4BzD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const ERRORS_DOCS = {
|
|
2
|
+
'errors/code-unique': {
|
|
3
|
+
why: 'The code is the identity of a refusal for everything outside the domain: the HTTP mapper gives it a status, the OpenAPI document lists it, the audit trail and the span record it as the reason, a client branches on it and a test asserts it. Nothing downstream knows the class or the factory. Two refusals of one context under one code are therefore one refusal for every reader, whatever their messages say. The code is checked per context, since each context owns its language: the same code in two contexts is allowed, and the error mapper of the application gives it one status. Both forms are read, the first argument of `refusal(..)` in a factory and the `readonly code` field of a class per error. Judged under "stack.refusals": "factories" only: a project whose config does not say was written when an error was a class, and keeps working untouched.',
|
|
4
|
+
bad: `export class AppointmentError extends ConceptError {
|
|
5
|
+
static slotTaken(calendarId: string) {
|
|
6
|
+
return AppointmentError.refusal('BOOKING_REFUSED', 'The slot is already held.', { calendarId });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static outsideAvailability(startsAt: Date) {
|
|
10
|
+
return AppointmentError.refusal('BOOKING_REFUSED', 'The calendar takes no appointment then.', { startsAt });
|
|
11
|
+
}
|
|
12
|
+
}`,
|
|
13
|
+
good: `export class AppointmentError extends ConceptError {
|
|
14
|
+
static slotTaken(calendarId: string) {
|
|
15
|
+
return AppointmentError.refusal('SLOT_TAKEN', 'The slot is already held.', { calendarId });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static outsideAvailability(startsAt: Date) {
|
|
19
|
+
return AppointmentError.refusal('OUTSIDE_AVAILABILITY', 'The calendar takes no appointment then.', { startsAt });
|
|
20
|
+
}
|
|
21
|
+
}`,
|
|
22
|
+
},
|
|
23
|
+
'errors/known-code': {
|
|
24
|
+
why: 'The `errors` list of a route is what the OpenAPI document promises: one problem response per status of the codes it names. A code written there that no refusal sets, misspelled or left behind by a renamed factory, is a response the contract documents and the API never gives, while the refusal really raised is missing from it. A code exists when a factory or an error class of the context of the route sets it, when a class outside the contexts (the platform, the shared kernel) does, or when it is a code of the kit: VALIDATION_FAILED, NOT_FOUND, CONFLICT, INVARIANT_VIOLATION, UNAUTHORIZED, FORBIDDEN, CONCURRENCY_CONFLICT, INVALID_CRITERIA, INVALID_PAGE_REQUEST, TIMEOUT, CIRCUIT_OPEN, BULKHEAD_FULL, ATTEMPTS_EXHAUSTED. A code another context sets does not count: a context answers with its own language. Judged under "stack.refusals": "factories" only.',
|
|
25
|
+
bad: `// domain/errors/appointment.error.ts sets 'SLOT_TAKEN'
|
|
26
|
+
defineRoute({ method: 'POST', path: '/appointments', errors: ['FORBIDDEN', 'SLOT_ALREADY_TAKEN'], security: ['bearer'] }, book);`,
|
|
27
|
+
good: `defineRoute({ method: 'POST', path: '/appointments', errors: ['FORBIDDEN', 'SLOT_TAKEN'], security: ['bearer'] }, book);`,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=errors-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-docs.js","sourceRoot":"","sources":["../../../src/check/explain/errors-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,oBAAoB,EAAE;QACpB,GAAG,EAAE,y1BAAy1B;QAC91B,GAAG,EAAE;;;;;;;;EAQP;QACE,IAAI,EAAE;;;;;;;;EAQR;KACC;IACD,mBAAmB,EAAE;QACnB,GAAG,EAAE,41BAA41B;QACj2B,GAAG,EAAE;iIACwH;QAC7H,IAAI,EAAE,0HAA0H;KACjI;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rule-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAgBpD,oGAAoG;AACpG,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAevD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AUTHZ_DOCS } from './authz-docs.js';
|
|
2
2
|
import { CLEAN_DOCS } from './clean-docs.js';
|
|
3
3
|
import { CONTEXT_DOCS } from './context-docs.js';
|
|
4
|
+
import { ERRORS_DOCS } from './errors-docs.js';
|
|
4
5
|
import { EVENTS_DOCS } from './events-docs.js';
|
|
5
6
|
import { IMPORTS_DOCS } from './imports-docs.js';
|
|
6
7
|
import { LANGUAGE_DOCS } from './language-docs.js';
|
|
@@ -16,6 +17,7 @@ export const RULE_DOCS = {
|
|
|
16
17
|
...AUTHZ_DOCS,
|
|
17
18
|
...CLEAN_DOCS,
|
|
18
19
|
...CONTEXT_DOCS,
|
|
20
|
+
...ERRORS_DOCS,
|
|
19
21
|
...EVENTS_DOCS,
|
|
20
22
|
...IMPORTS_DOCS,
|
|
21
23
|
...LANGUAGE_DOCS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-docs.js","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,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AG,UAAU;IACb,GAAG,YAAY;IACf,GAAG,WAAW;IACd,GAAG,WAAW;IACd,GAAG,YAAY;IACf,GAAG,aAAa;IAChB,GAAG,UAAU;IACb,GAAG,WAAW;IACd,GAAG,UAAU;IACb,GAAG,eAAe;IAClB,GAAG,aAAa;IAChB,GAAG,SAAS;IACZ,GAAG,WAAW;CACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/errors-fixtures.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuM5C,eAAO,MAAM,eAAe,EAAE,SAAS,OAAO,EAAuD,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { CONFIG_FILE } from '../../config/index.js';
|
|
2
|
+
import { config } from './config.js';
|
|
3
|
+
import { PATHS } from './paths.js';
|
|
4
|
+
import { project } from './project.js';
|
|
5
|
+
import { source } from './source.js';
|
|
6
|
+
const { BILLING, ROUTE } = PATHS;
|
|
7
|
+
const INVOICE_ERROR = `${BILLING}/domain/errors/invoice.error.ts`;
|
|
8
|
+
const REMINDER_ERROR = `${BILLING}/domain/errors/reminder.error.ts`;
|
|
9
|
+
const LEGACY_ERROR = `${BILLING}/domain/errors/issue.error.ts`;
|
|
10
|
+
const LEDGER_ERROR = `${BILLING}/domain/errors/ledger.error.ts`;
|
|
11
|
+
const FACTORIES = { [CONFIG_FILE]: config({ stack: { refusals: 'factories' } }) };
|
|
12
|
+
const concept = (name, ...factories) => source("import { ConceptError } from '@ddd-ts-kit/kernel';", '', `export class ${name}Error extends ConceptError {`, factories.join('\n\n'), '}');
|
|
13
|
+
const factory = (owner, name, code) => source(` static ${name}(id: string) {`, ` return ${owner}Error.refusal('${code}', \`Refused for \${id}.\`, { id });`, ' }').trimEnd();
|
|
14
|
+
const LEGACY = source("import { DomainError } from '@ddd-ts-kit/kernel';", '', 'export class IssueError extends DomainError {', " readonly code = 'INVOICE_ALREADY_ISSUED';", '}');
|
|
15
|
+
const route = (...codes) => source("import { defineRoute } from '@ddd-ts-kit/http';", '', 'export const issueInvoiceRoute = defineRoute(', ` { method: 'POST', path: '/invoices', errors: [${codes.map((code) => `'${code}'`).join(', ')}], security: false },`, ' issue,', ');');
|
|
16
|
+
const INVOICE = concept('Invoice', factory('Invoice', 'alreadyIssued', 'INVOICE_ALREADY_ISSUED'), factory('Invoice', 'notFound', 'INVOICE_NOT_FOUND'));
|
|
17
|
+
const CODE_UNIQUE = [
|
|
18
|
+
{
|
|
19
|
+
ruleId: 'errors/code-unique',
|
|
20
|
+
name: 'each refusal of a context has its own code, over two concept classes',
|
|
21
|
+
expect: 'pass',
|
|
22
|
+
files: project({
|
|
23
|
+
[INVOICE_ERROR]: INVOICE,
|
|
24
|
+
[REMINDER_ERROR]: concept('Reminder', factory('Reminder', 'notDue', 'REMINDER_NOT_DUE')),
|
|
25
|
+
}, FACTORIES),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
ruleId: 'errors/code-unique',
|
|
29
|
+
name: 'the same code in two contexts: each context owns its language',
|
|
30
|
+
expect: 'pass',
|
|
31
|
+
files: project({
|
|
32
|
+
[INVOICE_ERROR]: INVOICE,
|
|
33
|
+
[`${PATHS.CATALOG}/domain/errors/invoice.error.ts`]: concept('Invoice', factory('Invoice', 'notFound', 'INVOICE_NOT_FOUND')),
|
|
34
|
+
}, FACTORIES),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
ruleId: 'errors/code-unique',
|
|
38
|
+
name: 'a project that does not say how it builds its refusals is not judged',
|
|
39
|
+
expect: 'pass',
|
|
40
|
+
files: project({
|
|
41
|
+
[INVOICE_ERROR]: concept('Invoice', factory('Invoice', 'alreadyIssued', 'INVOICE_ALREADY_ISSUED')),
|
|
42
|
+
[LEGACY_ERROR]: LEGACY,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
ruleId: 'errors/code-unique',
|
|
47
|
+
name: 'two factories of one class set the same code',
|
|
48
|
+
expect: { file: INVOICE_ERROR },
|
|
49
|
+
files: project({
|
|
50
|
+
[INVOICE_ERROR]: concept('Invoice', factory('Invoice', 'alreadyIssued', 'INVOICE_ALREADY_ISSUED'), factory('Invoice', 'issuedTwice', 'INVOICE_ALREADY_ISSUED')),
|
|
51
|
+
}, FACTORIES),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
ruleId: 'errors/code-unique',
|
|
55
|
+
name: 'a factory sets the code of a class per error of the same context',
|
|
56
|
+
expect: { file: LEGACY_ERROR },
|
|
57
|
+
files: project({
|
|
58
|
+
[INVOICE_ERROR]: concept('Invoice', factory('Invoice', 'alreadyIssued', 'INVOICE_ALREADY_ISSUED')),
|
|
59
|
+
[LEGACY_ERROR]: LEGACY,
|
|
60
|
+
}, FACTORIES),
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
const KNOWN_CODE = [
|
|
64
|
+
{
|
|
65
|
+
ruleId: 'errors/known-code',
|
|
66
|
+
name: 'a route declaring codes its context sets, and codes of the kit',
|
|
67
|
+
expect: 'pass',
|
|
68
|
+
files: project({
|
|
69
|
+
[INVOICE_ERROR]: INVOICE,
|
|
70
|
+
[ROUTE]: route('UNAUTHORIZED', 'FORBIDDEN', 'INVOICE_ALREADY_ISSUED', 'INVOICE_NOT_FOUND'),
|
|
71
|
+
}, FACTORIES),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
ruleId: 'errors/known-code',
|
|
75
|
+
name: 'a code set by a class per error, and one set outside the contexts',
|
|
76
|
+
expect: 'pass',
|
|
77
|
+
files: project({
|
|
78
|
+
[LEGACY_ERROR]: LEGACY,
|
|
79
|
+
'src/platform/quota/quota-exceeded-error.ts': LEGACY.replaceAll('IssueError', 'QuotaExceededError').replace('INVOICE_ALREADY_ISSUED', 'QUOTA_EXCEEDED'),
|
|
80
|
+
[ROUTE]: route('INVOICE_ALREADY_ISSUED', 'QUOTA_EXCEEDED'),
|
|
81
|
+
}, FACTORIES),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
ruleId: 'errors/known-code',
|
|
85
|
+
name: 'a project that does not say how it builds its refusals is not judged',
|
|
86
|
+
expect: 'pass',
|
|
87
|
+
files: project({ [ROUTE]: route('INVOICE_VOIDED') }),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
ruleId: 'errors/known-code',
|
|
91
|
+
name: 'a route declaring a code nothing sets',
|
|
92
|
+
expect: { file: ROUTE },
|
|
93
|
+
files: project({ [INVOICE_ERROR]: INVOICE, [ROUTE]: route('FORBIDDEN', 'INVOICE_VOIDED') }, FACTORIES),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
ruleId: 'errors/known-code',
|
|
97
|
+
name: 'a route declaring a code only another context sets',
|
|
98
|
+
expect: { file: ROUTE },
|
|
99
|
+
files: project({
|
|
100
|
+
[`${PATHS.CATALOG}/domain/errors/reminder.error.ts`]: concept('Reminder', factory('Reminder', 'notDue', 'REMINDER_NOT_DUE')),
|
|
101
|
+
[ROUTE]: route('REMINDER_NOT_DUE'),
|
|
102
|
+
}, FACTORIES),
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
const ERROR_LANGUAGE = [
|
|
106
|
+
{
|
|
107
|
+
ruleId: 'language/glossary-term',
|
|
108
|
+
name: 'an error class named after a term of the glossary',
|
|
109
|
+
expect: 'pass',
|
|
110
|
+
files: project({ [INVOICE_ERROR]: INVOICE }, FACTORIES),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
ruleId: 'language/glossary-term',
|
|
114
|
+
name: 'an error class named after a word the glossary does not define',
|
|
115
|
+
expect: { file: LEDGER_ERROR },
|
|
116
|
+
files: project({ [LEDGER_ERROR]: concept('Ledger', factory('Ledger', 'closed', 'LEDGER_CLOSED')) }, FACTORIES),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
ruleId: 'language/glossary-term',
|
|
120
|
+
name: 'a class per error keeps its free name while the project does not build through factories',
|
|
121
|
+
expect: 'pass',
|
|
122
|
+
files: project({ [LEDGER_ERROR]: concept('Ledger', factory('Ledger', 'closed', 'LEDGER_CLOSED')) }),
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
export const ERRORS_FIXTURES = [...CODE_UNIQUE, ...KNOWN_CODE, ...ERROR_LANGUAGE];
|
|
126
|
+
//# sourceMappingURL=errors-fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-fixtures.js","sourceRoot":"","sources":["../../../src/check/fixtures/errors-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;AAEjC,MAAM,aAAa,GAAG,GAAG,OAAO,iCAAiC,CAAC;AAClE,MAAM,cAAc,GAAG,GAAG,OAAO,kCAAkC,CAAC;AACpE,MAAM,YAAY,GAAG,GAAG,OAAO,+BAA+B,CAAC;AAC/D,MAAM,YAAY,GAAG,GAAG,OAAO,gCAAgC,CAAC;AAEhE,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC;AAElF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,GAAG,SAAmB,EAAU,EAAE,CAC/D,MAAM,CACJ,oDAAoD,EACpD,EAAE,EACF,gBAAgB,IAAI,8BAA8B,EAClD,SAAS,CAAC,IAAI,CAAC,MA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AkB,CAAC,CAClD;YACD,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC;SACnC,EACD,SAAS,CACV;KACF;CACF,CAAC;AAEF,MAAM,cAAc,GAAuB;IACzC;QACE,MAAM,EAAE,wBAAwB;QAChC,IAAI,EAAE,mDAAmD;QACzD,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,CAAC;KACxD;IACD;QACE,MAAM,EAAE,wBAAwB;QAChC,IAAI,EAAE,gEAAgE;QACtE,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;QAC9B,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;KAC/G;IACD;QACE,MAAM,EAAE,wBAAwB;QAChC,IAAI,EAAE,0FAA0F;QAChG,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC;KACpG;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAuB,CAAC,GAAG,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/fixtures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/fixtures.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,OAAO,EA+BtC,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { CONTEXT_FIXTURES } from './context-fixtures.js';
|
|
|
10
10
|
import { COVERAGE_FIXTURES } from './coverage-fixtures.js';
|
|
11
11
|
import { DECLARATIONS_FIXTURES } from './declarations-fixtures.js';
|
|
12
12
|
import { DOMAIN_EVENTS_FIXTURES } from './domain-events-fixtures.js';
|
|
13
|
+
import { ERRORS_FIXTURES } from './errors-fixtures.js';
|
|
13
14
|
import { EVENTS_FIXTURES } from './events-fixtures.js';
|
|
14
15
|
import { EXTENSION_FIXTURES } from './extension-fixtures.js';
|
|
15
16
|
import { EXTRACTABLE_FIXTURES } from './extractable-fixtures.js';
|
|
@@ -45,6 +46,7 @@ export const FIXTURES = [
|
|
|
45
46
|
...COVERAGE_FIXTURES,
|
|
46
47
|
...DECLARATIONS_FIXTURES,
|
|
47
48
|
...DOMAIN_EVENTS_FIXTURES,
|
|
49
|
+
...ERRORS_FIXTURES,
|
|
48
50
|
...EVENTS_FIXTURES,
|
|
49
51
|
...EXTENSION_FIXTURES,
|
|
50
52
|
...EXTRACTABLE_FIXTURES,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/check/fixtures/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM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B;IACzB,GAAG,eAAe;IAClB,GAAG,eAAe;IAClB,GAAG,kBAAkB;IACrB,GAAG,oBAAoB;IACvB,GAAG,mBAAmB;IACtB,GAAG,gBAAgB;IACnB,GAAG,iBAAiB;IACpB,GAAG,cAAc;IACjB,GAAG,eAAe;IAClB,GAAG,eAAe;IAClB,GAAG,eAAe;IAClB,GAAG,cAAc;IACjB,GAAG,eAAe;IAClB,GAAG,mBAAmB;IACtB,GAAG,iBAAiB;IACpB,GAAG,aAAa;IAChB,GAAG,gBAAgB;IACnB,GAAG,aAAa;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-code-unique.d.ts","sourceRoot":"","sources":["../../../src/check/rules/errors-code-unique.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAO7C,eAAO,MAAM,gBAAgB,EAAE,IAe9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { buildsThroughFactories } from '../errors/builds-through-factories.js';
|
|
2
|
+
import { errorCodes } from '../errors/error-codes.js';
|
|
3
|
+
import { perFile } from '../support/per-file.js';
|
|
4
|
+
const FIX = 'Give each refusal of a context its own code, or call the factory that already sets this one: the HTTP mapping, the OpenAPI document, the audit trail and the tests know a refusal by its code alone.';
|
|
5
|
+
export const errorsCodeUnique = {
|
|
6
|
+
id: 'errors/code-unique',
|
|
7
|
+
description: 'Under "stack.refusals": "factories", a code is given to one refusal of a context: no two factories, and no two error classes, of the domain/errors/ of a context set the same code.',
|
|
8
|
+
scope: 'project',
|
|
9
|
+
run(project) {
|
|
10
|
+
if (!buildsThroughFactories(project)) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
// Remembers, across the error files of a context, where each code was first written.
|
|
14
|
+
const firstUse = new Map();
|
|
15
|
+
return perFile(project, this.id, (file) => codesTaken(file, firstUse));
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
function codesTaken(file, firstUse) {
|
|
19
|
+
const { location } = file;
|
|
20
|
+
if (location.area !== 'context' || location.layer !== 'domain' || location.inside[0] !== 'errors' || file.isTest) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return errorCodes(file.scan).flatMap(({ code, line }) => {
|
|
24
|
+
const key = `${location.context} ${code}`;
|
|
25
|
+
const first = firstUse.get(key);
|
|
26
|
+
if (first === undefined) {
|
|
27
|
+
firstUse.set(key, `${file.path}:${line}`);
|
|
28
|
+
}
|
|
29
|
+
return first === undefined
|
|
30
|
+
? []
|
|
31
|
+
: [{ line, message: `The code "${code}" is already set in ${first}, in the same context.`, fix: FIX }];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=errors-code-unique.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-code-unique.js","sourceRoot":"","sources":["../../../src/check/rules/errors-code-unique.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,GAAG,GACP,sMAAsM,CAAC;AAEzM,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,EAAE,EAAE,oBAAoB;IACxB,WAAW,EACT,qLAAqL;IACvL,KAAK,EAAE,SAAS;IAChB,GAAG,CAAC,OAAO;QACT,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;YACrC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,qFAAqF;QACrF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE3C,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;I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