ddd-ts-kit 0.82.0 → 0.83.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.fr.md +128 -60
- package/README.md +124 -59
- package/dist/check/canonical/role.d.ts +2 -0
- package/dist/check/canonical/role.d.ts.map +1 -1
- package/dist/check/canonical/roles.js +1 -1
- package/dist/check/canonical/roles.js.map +1 -1
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.js +3 -3
- package/dist/check/catalogue/eslint-only-rules.js.map +1 -1
- package/dist/check/errors/builds-through-factories.d.ts +4 -1
- package/dist/check/errors/builds-through-factories.d.ts.map +1 -1
- package/dist/check/errors/builds-through-factories.js +6 -2
- package/dist/check/errors/builds-through-factories.js.map +1 -1
- package/dist/check/errors/code-entry.d.ts +8 -0
- package/dist/check/errors/code-entry.d.ts.map +1 -0
- package/dist/check/errors/code-entry.js +2 -0
- package/dist/check/errors/code-entry.js.map +1 -0
- package/dist/check/errors/code-list-name.d.ts +3 -0
- package/dist/check/errors/code-list-name.d.ts.map +1 -0
- package/dist/check/errors/code-list-name.js +6 -0
- package/dist/check/errors/code-list-name.js.map +1 -0
- package/dist/check/errors/code-list.d.ts +10 -0
- package/dist/check/errors/code-list.d.ts.map +1 -0
- package/dist/check/errors/code-list.js +2 -0
- package/dist/check/errors/code-list.js.map +1 -0
- package/dist/check/errors/codes-set-in.d.ts +9 -0
- package/dist/check/errors/codes-set-in.d.ts.map +1 -0
- package/dist/check/errors/codes-set-in.js +15 -0
- package/dist/check/errors/codes-set-in.js.map +1 -0
- package/dist/check/errors/error-codes.d.ts +2 -0
- package/dist/check/errors/error-codes.d.ts.map +1 -1
- package/dist/check/errors/error-codes.js +8 -0
- package/dist/check/errors/error-codes.js.map +1 -1
- package/dist/check/errors/is-codes-file.d.ts +4 -0
- package/dist/check/errors/is-codes-file.d.ts.map +1 -0
- package/dist/check/errors/is-codes-file.js +11 -0
- package/dist/check/errors/is-codes-file.js.map +1 -0
- package/dist/check/errors/is-error-file.d.ts +4 -0
- package/dist/check/errors/is-error-file.d.ts.map +1 -0
- package/dist/check/errors/is-error-file.js +6 -0
- package/dist/check/errors/is-error-file.js.map +1 -0
- package/dist/check/errors/listed-codes.d.ts +5 -0
- package/dist/check/errors/listed-codes.d.ts.map +1 -0
- package/dist/check/errors/listed-codes.js +12 -0
- package/dist/check/errors/listed-codes.js.map +1 -0
- package/dist/check/errors/names-refusals.d.ts +4 -0
- package/dist/check/errors/names-refusals.d.ts.map +1 -0
- package/dist/check/errors/names-refusals.js +5 -0
- package/dist/check/errors/names-refusals.js.map +1 -0
- package/dist/check/errors/read-code-list.d.ts +5 -0
- package/dist/check/errors/read-code-list.d.ts.map +1 -0
- package/dist/check/errors/read-code-list.js +32 -0
- package/dist/check/errors/read-code-list.js.map +1 -0
- package/dist/check/errors/refusal-classes.d.ts +8 -0
- package/dist/check/errors/refusal-classes.d.ts.map +1 -0
- package/dist/check/errors/refusal-classes.js +9 -0
- package/dist/check/errors/refusal-classes.js.map +1 -0
- package/dist/check/event-sourcing/declared-shape.d.ts +7 -1
- package/dist/check/event-sourcing/declared-shape.d.ts.map +1 -1
- package/dist/check/event-sourcing/declared-shape.js +12 -4
- package/dist/check/event-sourcing/declared-shape.js.map +1 -1
- package/dist/check/event-sourcing/read-stored-shape.d.ts.map +1 -1
- package/dist/check/event-sourcing/read-stored-shape.js +10 -2
- package/dist/check/event-sourcing/read-stored-shape.js.map +1 -1
- package/dist/check/event-sourcing/stored-event-declaration.d.ts +2 -0
- package/dist/check/event-sourcing/stored-event-declaration.d.ts.map +1 -1
- package/dist/check/event-sourcing/stored-event-declarations.js +1 -0
- package/dist/check/event-sourcing/stored-event-declarations.js.map +1 -1
- package/dist/check/event-sourcing/stored-shape.d.ts +2 -0
- package/dist/check/event-sourcing/stored-shape.d.ts.map +1 -1
- package/dist/check/explain/errors-docs.d.ts.map +1 -1
- package/dist/check/explain/errors-docs.js +30 -2
- package/dist/check/explain/errors-docs.js.map +1 -1
- package/dist/check/explain/language-docs.js +1 -1
- package/dist/check/explain/language-docs.js.map +1 -1
- package/dist/check/fixtures/authz-policy-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/authz-policy-fixtures.js +11 -0
- package/dist/check/fixtures/authz-policy-fixtures.js.map +1 -1
- package/dist/check/fixtures/errors-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/errors-fixtures.js +1 -1
- package/dist/check/fixtures/errors-fixtures.js.map +1 -1
- package/dist/check/fixtures/errors-route.d.ts +3 -0
- package/dist/check/fixtures/errors-route.d.ts.map +1 -0
- package/dist/check/fixtures/errors-route.js +6 -0
- package/dist/check/fixtures/errors-route.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/fixtures/named-refusal-fixtures.d.ts +4 -0
- package/dist/check/fixtures/named-refusal-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/named-refusal-fixtures.js +210 -0
- package/dist/check/fixtures/named-refusal-fixtures.js.map +1 -0
- package/dist/check/language/refusal-qualifiers.d.ts +8 -0
- package/dist/check/language/refusal-qualifiers.d.ts.map +1 -0
- package/dist/check/language/refusal-qualifiers.js +16 -0
- package/dist/check/language/refusal-qualifiers.js.map +1 -0
- package/dist/check/language/unknown-words.d.ts +2 -2
- package/dist/check/language/unknown-words.d.ts.map +1 -1
- package/dist/check/language/unknown-words.js +3 -2
- package/dist/check/language/unknown-words.js.map +1 -1
- package/dist/check/rules/authz-policy-asked.js +5 -2
- package/dist/check/rules/authz-policy-asked.js.map +1 -1
- package/dist/check/rules/errors-code-listed.d.ts +3 -0
- package/dist/check/rules/errors-code-listed.d.ts.map +1 -0
- package/dist/check/rules/errors-code-listed.js +160 -0
- package/dist/check/rules/errors-code-listed.js.map +1 -0
- package/dist/check/rules/errors-code-unique.d.ts.map +1 -1
- package/dist/check/rules/errors-code-unique.js +13 -8
- package/dist/check/rules/errors-code-unique.js.map +1 -1
- package/dist/check/rules/errors-known-code.d.ts.map +1 -1
- package/dist/check/rules/errors-known-code.js +17 -7
- package/dist/check/rules/errors-known-code.js.map +1 -1
- package/dist/check/rules/event-sourcing-upcaster-required.js +14 -4
- package/dist/check/rules/event-sourcing-upcaster-required.js.map +1 -1
- package/dist/check/rules/language-glossary-term.d.ts.map +1 -1
- package/dist/check/rules/language-glossary-term.js +10 -3
- package/dist/check/rules/language-glossary-term.js.map +1 -1
- package/dist/check/rules/naming-suffix.js +1 -1
- package/dist/check/rules/naming-suffix.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +16 -7
- package/dist/commands/docs.js.map +1 -1
- package/dist/commands/error-factories.d.ts +4 -2
- package/dist/commands/error-factories.d.ts.map +1 -1
- package/dist/commands/error-factories.js +74 -17
- package/dist/commands/error-factories.js.map +1 -1
- package/dist/config/open-api-problems.js +7 -6
- package/dist/config/open-api-problems.js.map +1 -1
- package/dist/config/stack.d.ts +9 -6
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +1 -1
- package/dist/config/stack.js.map +1 -1
- package/dist/describe/context-description.d.ts +7 -2
- package/dist/describe/context-description.d.ts.map +1 -1
- package/dist/describe/exposed-by.d.ts +7 -0
- package/dist/describe/exposed-by.d.ts.map +1 -0
- package/dist/describe/exposed-by.js +11 -0
- package/dist/describe/exposed-by.js.map +1 -0
- package/dist/describe/read-errors.d.ts +3 -1
- package/dist/describe/read-errors.d.ts.map +1 -1
- package/dist/describe/read-errors.js +18 -11
- package/dist/describe/read-errors.js.map +1 -1
- package/dist/describe/read-refusals.d.ts +11 -0
- package/dist/describe/read-refusals.d.ts.map +1 -0
- package/dist/describe/read-refusals.js +41 -0
- package/dist/describe/read-refusals.js.map +1 -0
- package/dist/describe/reference-lines.d.ts.map +1 -1
- package/dist/describe/reference-lines.js +18 -2
- package/dist/describe/reference-lines.js.map +1 -1
- package/dist/docs/formerly-recorded-stored-events.d.ts +9 -0
- package/dist/docs/formerly-recorded-stored-events.d.ts.map +1 -0
- package/dist/docs/formerly-recorded-stored-events.js +17 -0
- package/dist/docs/formerly-recorded-stored-events.js.map +1 -0
- package/dist/docs/write-stored-events-lock.d.ts +3 -2
- package/dist/docs/write-stored-events-lock.d.ts.map +1 -1
- package/dist/docs/write-stored-events-lock.js +10 -4
- package/dist/docs/write-stored-events-lock.js.map +1 -1
- package/dist/generate/concept.d.ts.map +1 -1
- package/dist/generate/concept.js +3 -29
- package/dist/generate/concept.js.map +1 -1
- package/dist/generate/errors/add-code.d.ts +13 -0
- package/dist/generate/errors/add-code.d.ts.map +1 -0
- package/dist/generate/errors/add-code.js +18 -0
- package/dist/generate/errors/add-code.js.map +1 -0
- package/dist/generate/errors/codes-list.d.ts +10 -0
- package/dist/generate/errors/codes-list.d.ts.map +1 -0
- package/dist/generate/errors/codes-list.js +25 -0
- package/dist/generate/errors/codes-list.js.map +1 -0
- package/dist/generate/errors/error-code-pattern.d.ts +3 -0
- package/dist/generate/errors/error-code-pattern.d.ts.map +1 -0
- package/dist/generate/errors/error-code-pattern.js +3 -0
- package/dist/generate/errors/error-code-pattern.js.map +1 -0
- package/dist/generate/errors/factory-prefix.d.ts +3 -0
- package/dist/generate/errors/factory-prefix.d.ts.map +1 -0
- package/dist/generate/errors/factory-prefix.js +3 -0
- package/dist/generate/errors/factory-prefix.js.map +1 -0
- package/dist/generate/errors/named-refusal-code.d.ts +17 -0
- package/dist/generate/errors/named-refusal-code.d.ts.map +1 -0
- package/dist/generate/errors/named-refusal-code.js +42 -0
- package/dist/generate/errors/named-refusal-code.js.map +1 -0
- package/dist/generate/errors/refusal-class-name.d.ts +8 -0
- package/dist/generate/errors/refusal-class-name.d.ts.map +1 -0
- package/dist/generate/errors/refusal-class-name.js +16 -0
- package/dist/generate/errors/refusal-class-name.js.map +1 -0
- package/dist/generate/errors/refusal-factory-name.d.ts +4 -0
- package/dist/generate/errors/refusal-factory-name.d.ts.map +1 -0
- package/dist/generate/errors/refusal-factory-name.js +15 -0
- package/dist/generate/errors/refusal-factory-name.js.map +1 -0
- package/dist/generate/errors/write-named-refusal.d.ts +18 -0
- package/dist/generate/errors/write-named-refusal.d.ts.map +1 -0
- package/dist/generate/errors/write-named-refusal.js +89 -0
- package/dist/generate/errors/write-named-refusal.js.map +1 -0
- package/dist/generate/kinds/domain-error-kind.d.ts.map +1 -1
- package/dist/generate/kinds/domain-error-kind.js +12 -5
- package/dist/generate/kinds/domain-error-kind.js.map +1 -1
- package/dist/generate/kinds/error-kind.d.ts.map +1 -1
- package/dist/generate/kinds/error-kind.js +27 -12
- package/dist/generate/kinds/error-kind.js.map +1 -1
- package/dist/generate/spoken-in-language.d.ts +9 -0
- package/dist/generate/spoken-in-language.d.ts.map +1 -0
- package/dist/generate/spoken-in-language.js +39 -0
- package/dist/generate/spoken-in-language.js.map +1 -0
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +11 -5
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +2 -2
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/run-init.js +1 -1
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/stack/resolve-stack.js +2 -2
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/write-contracts.d.ts +9 -2
- package/dist/init/write-contracts.d.ts.map +1 -1
- package/dist/init/write-contracts.js +14 -4
- package/dist/init/write-contracts.js.map +1 -1
- package/dist/presets/identity-refusal.js +1 -1
- package/dist/presets/identity-refusal.js.map +1 -1
- package/dist/presets/identity-terms.d.ts.map +1 -1
- package/dist/presets/identity-terms.js +30 -0
- package/dist/presets/identity-terms.js.map +1 -1
- package/dist/presets/preset-files.d.ts.map +1 -1
- package/dist/presets/preset-files.js +4 -1
- package/dist/presets/preset-files.js.map +1 -1
- package/dist/refusals/aggregates-of.d.ts +10 -0
- package/dist/refusals/aggregates-of.d.ts.map +1 -0
- package/dist/refusals/aggregates-of.js +9 -0
- package/dist/refusals/aggregates-of.js.map +1 -0
- package/dist/refusals/applied-moves.d.ts +7 -0
- package/dist/refusals/applied-moves.d.ts.map +1 -0
- package/dist/refusals/applied-moves.js +2 -0
- package/dist/refusals/applied-moves.js.map +1 -0
- package/dist/refusals/apply-named-plan.d.ts +19 -0
- package/dist/refusals/apply-named-plan.d.ts.map +1 -0
- package/dist/refusals/apply-named-plan.js +46 -0
- package/dist/refusals/apply-named-plan.js.map +1 -0
- package/dist/refusals/apply-plan.d.ts.map +1 -1
- package/dist/refusals/apply-plan.js +21 -25
- package/dist/refusals/apply-plan.js.map +1 -1
- package/dist/refusals/code-without-imports.d.ts +3 -0
- package/dist/refusals/code-without-imports.d.ts.map +1 -0
- package/dist/refusals/code-without-imports.js +9 -0
- package/dist/refusals/code-without-imports.js.map +1 -0
- package/dist/refusals/concept-error-class.d.ts +26 -0
- package/dist/refusals/concept-error-class.d.ts.map +1 -0
- package/dist/refusals/concept-error-class.js +2 -0
- package/dist/refusals/concept-error-class.js.map +1 -0
- package/dist/refusals/concept-errors.d.ts +6 -0
- package/dist/refusals/concept-errors.d.ts.map +1 -0
- package/dist/refusals/concept-errors.js +16 -0
- package/dist/refusals/concept-errors.js.map +1 -0
- package/dist/refusals/concept-imports.d.ts +8 -0
- package/dist/refusals/concept-imports.d.ts.map +1 -0
- package/dist/refusals/concept-imports.js +33 -0
- package/dist/refusals/concept-imports.js.map +1 -0
- package/dist/refusals/concept-leftovers.d.ts +5 -0
- package/dist/refusals/concept-leftovers.d.ts.map +1 -0
- package/dist/refusals/concept-leftovers.js +26 -0
- package/dist/refusals/concept-leftovers.js.map +1 -0
- package/dist/refusals/concept-named.d.ts +3 -0
- package/dist/refusals/concept-named.d.ts.map +1 -0
- package/dist/refusals/concept-named.js +13 -0
- package/dist/refusals/concept-named.js.map +1 -0
- package/dist/refusals/concerns.d.ts +16 -0
- package/dist/refusals/concerns.d.ts.map +1 -0
- package/dist/refusals/concerns.js +9 -0
- package/dist/refusals/concerns.js.map +1 -0
- package/dist/refusals/cut-factories.d.ts +7 -0
- package/dist/refusals/cut-factories.d.ts.map +1 -0
- package/dist/refusals/cut-factories.js +30 -0
- package/dist/refusals/cut-factories.js.map +1 -0
- package/dist/refusals/earlier-guidance.d.ts +8 -0
- package/dist/refusals/earlier-guidance.d.ts.map +1 -0
- package/dist/refusals/earlier-guidance.js +21 -0
- package/dist/refusals/earlier-guidance.js.map +1 -0
- package/dist/refusals/factory-for-parameter.d.ts +7 -0
- package/dist/refusals/factory-for-parameter.d.ts.map +1 -0
- package/dist/refusals/factory-for-parameter.js +17 -0
- package/dist/refusals/factory-for-parameter.js.map +1 -0
- package/dist/refusals/first-parameter.d.ts +6 -0
- package/dist/refusals/first-parameter.d.ts.map +1 -0
- package/dist/refusals/first-parameter.js +12 -0
- package/dist/refusals/first-parameter.js.map +1 -0
- package/dist/refusals/ignore-code-types.d.ts +10 -0
- package/dist/refusals/ignore-code-types.d.ts.map +1 -0
- package/dist/refusals/ignore-code-types.js +53 -0
- package/dist/refusals/ignore-code-types.js.map +1 -0
- package/dist/refusals/imports-used-by.d.ts +6 -0
- package/dist/refusals/imports-used-by.d.ts.map +1 -0
- package/dist/refusals/imports-used-by.js +32 -0
- package/dist/refusals/imports-used-by.js.map +1 -0
- package/dist/refusals/leave-origins.d.ts +10 -0
- package/dist/refusals/leave-origins.d.ts.map +1 -0
- package/dist/refusals/leave-origins.js +35 -0
- package/dist/refusals/leave-origins.js.map +1 -0
- package/dist/refusals/legacy-move.d.ts +5 -0
- package/dist/refusals/legacy-move.d.ts.map +1 -0
- package/dist/refusals/legacy-move.js +14 -0
- package/dist/refusals/legacy-move.js.map +1 -0
- package/dist/refusals/markdown-files.d.ts +4 -0
- package/dist/refusals/markdown-files.d.ts.map +1 -0
- package/dist/refusals/markdown-files.js +13 -0
- package/dist/refusals/markdown-files.js.map +1 -0
- package/dist/refusals/member-start.d.ts +3 -0
- package/dist/refusals/member-start.d.ts.map +1 -0
- package/dist/refusals/member-start.js +14 -0
- package/dist/refusals/member-start.js.map +1 -0
- package/dist/refusals/migration-targets.d.ts +3 -0
- package/dist/refusals/migration-targets.d.ts.map +1 -0
- package/dist/refusals/migration-targets.js +3 -0
- package/dist/refusals/migration-targets.js.map +1 -0
- package/dist/refusals/move-named-specs.d.ts +16 -0
- package/dist/refusals/move-named-specs.d.ts.map +1 -0
- package/dist/refusals/move-named-specs.js +119 -0
- package/dist/refusals/move-named-specs.js.map +1 -0
- package/dist/refusals/move.d.ts +6 -1
- package/dist/refusals/move.d.ts.map +1 -1
- package/dist/refusals/named-move.d.ts +23 -0
- package/dist/refusals/named-move.d.ts.map +1 -0
- package/dist/refusals/named-move.js +2 -0
- package/dist/refusals/named-move.js.map +1 -0
- package/dist/refusals/named-moves.d.ts +10 -0
- package/dist/refusals/named-moves.d.ts.map +1 -0
- package/dist/refusals/named-moves.js +64 -0
- package/dist/refusals/named-moves.js.map +1 -0
- package/dist/refusals/named-plan.d.ts +7 -0
- package/dist/refusals/named-plan.d.ts.map +1 -0
- package/dist/refusals/named-plan.js +2 -0
- package/dist/refusals/named-plan.js.map +1 -0
- package/dist/refusals/own-factory.d.ts +14 -0
- package/dist/refusals/own-factory.d.ts.map +1 -0
- package/dist/refusals/own-factory.js +38 -0
- package/dist/refusals/own-factory.js.map +1 -0
- package/dist/refusals/plan-target.d.ts +7 -0
- package/dist/refusals/plan-target.d.ts.map +1 -0
- package/dist/refusals/plan-target.js +13 -0
- package/dist/refusals/plan-target.js.map +1 -0
- package/dist/refusals/planned-refusal.d.ts +13 -0
- package/dist/refusals/planned-refusal.d.ts.map +1 -0
- package/dist/refusals/planned-refusal.js +2 -0
- package/dist/refusals/planned-refusal.js.map +1 -0
- package/dist/refusals/propose-named-plan.d.ts +25 -0
- package/dist/refusals/propose-named-plan.d.ts.map +1 -0
- package/dist/refusals/propose-named-plan.js +67 -0
- package/dist/refusals/propose-named-plan.js.map +1 -0
- package/dist/refusals/propose-plan.d.ts.map +1 -1
- package/dist/refusals/propose-plan.js +3 -19
- package/dist/refusals/propose-plan.js.map +1 -1
- package/dist/refusals/read-concept-error.d.ts +9 -0
- package/dist/refusals/read-concept-error.d.ts.map +1 -0
- package/dist/refusals/read-concept-error.js +51 -0
- package/dist/refusals/read-concept-error.js.map +1 -0
- package/dist/refusals/read-named-plan.d.ts +4 -0
- package/dist/refusals/read-named-plan.d.ts.map +1 -0
- package/dist/refusals/read-named-plan.js +57 -0
- package/dist/refusals/read-named-plan.js.map +1 -0
- package/dist/refusals/refusal-class-file.d.ts +15 -0
- package/dist/refusals/refusal-class-file.d.ts.map +1 -0
- package/dist/refusals/refusal-class-file.js +38 -0
- package/dist/refusals/refusal-class-file.js.map +1 -0
- package/dist/refusals/rename-concept.d.ts +7 -0
- package/dist/refusals/rename-concept.d.ts.map +1 -0
- package/dist/refusals/rename-concept.js +15 -0
- package/dist/refusals/rename-concept.js.map +1 -0
- package/dist/refusals/render-factory.d.ts +1 -1
- package/dist/refusals/render-factory.d.ts.map +1 -1
- package/dist/refusals/render-factory.js +3 -2
- package/dist/refusals/render-factory.js.map +1 -1
- package/dist/refusals/rewrite-concept-usages.d.ts +11 -0
- package/dist/refusals/rewrite-concept-usages.d.ts.map +1 -0
- package/dist/refusals/rewrite-concept-usages.js +61 -0
- package/dist/refusals/rewrite-concept-usages.js.map +1 -0
- package/dist/refusals/rewrite-named-usages.d.ts +9 -0
- package/dist/refusals/rewrite-named-usages.d.ts.map +1 -0
- package/dist/refusals/rewrite-named-usages.js +14 -0
- package/dist/refusals/rewrite-named-usages.js.map +1 -0
- package/dist/refusals/rewrite-usages.d.ts.map +1 -1
- package/dist/refusals/rewrite-usages.js +10 -6
- package/dist/refusals/rewrite-usages.js.map +1 -1
- package/dist/refusals/say-refusals.d.ts +3 -0
- package/dist/refusals/say-refusals.d.ts.map +1 -0
- package/dist/refusals/say-refusals.js +8 -0
- package/dist/refusals/say-refusals.js.map +1 -0
- package/dist/refusals/split-concept-spec.d.ts +19 -0
- package/dist/refusals/split-concept-spec.d.ts.map +1 -0
- package/dist/refusals/split-concept-spec.js +74 -0
- package/dist/refusals/split-concept-spec.js.map +1 -0
- package/dist/refusals/stale-mentions.d.ts +10 -0
- package/dist/refusals/stale-mentions.d.ts.map +1 -0
- package/dist/refusals/stale-mentions.js +41 -0
- package/dist/refusals/stale-mentions.js.map +1 -0
- package/dist/refusals/undefined-words.d.ts +15 -0
- package/dist/refusals/undefined-words.d.ts.map +1 -0
- package/dist/refusals/undefined-words.js +26 -0
- package/dist/refusals/undefined-words.js.map +1 -0
- package/dist/refusals/with-codes.d.ts +11 -0
- package/dist/refusals/with-codes.d.ts.map +1 -0
- package/dist/refusals/with-codes.js +46 -0
- package/dist/refusals/with-codes.js.map +1 -0
- package/dist/refusals/with-imports.d.ts +3 -0
- package/dist/refusals/with-imports.d.ts.map +1 -0
- package/dist/refusals/with-imports.js +8 -0
- package/dist/refusals/with-imports.js.map +1 -0
- package/dist/refusals/write-refusal-classes.d.ts +9 -0
- package/dist/refusals/write-refusal-classes.d.ts.map +1 -0
- package/dist/refusals/write-refusal-classes.js +23 -0
- package/dist/refusals/write-refusal-classes.js.map +1 -0
- package/dist/stack/stack-vars.js +1 -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 +3 -0
- package/templates/aggregate/event-sourced.aggregate.ts.tpl +3 -0
- package/templates/command/handler.declared.ts.tpl +3 -0
- package/templates/command/handler.ts.tpl +3 -0
- package/templates/entity/entity.ts.tpl +3 -0
- package/templates/error/codes.ts.tpl +5 -0
- package/templates/error/refusal-case.spec.ts.tpl +8 -0
- package/templates/error/refusal-factory.ts.tpl +4 -0
- package/templates/error/refusal.spec.ts.tpl +7 -0
- package/templates/error/refusal.ts.tpl +8 -0
- package/templates/init/rules/domain.md.tpl +9 -2
- package/templates/init/rules/presentation.md.tpl +3 -0
- package/templates/init/scripts/events.ts.tpl +19 -1
- package/templates/init/scripts/openapi.ts.tpl +19 -1
- package/templates/pipeline/knip.json.tpl +5 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +22 -0
- package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.handler.ts.tpl +16 -0
- package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.handler.ts.tpl +16 -0
- package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.handler.ts.tpl +16 -0
- package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.handler.ts.tpl +10 -0
- package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.handler.ts.tpl +16 -0
- package/templates/presets/identity/context/application/commands/provision-account/provision-account.handler.ts.tpl +10 -0
- package/templates/presets/identity/context/application/commands/remove-member/remove-member.handler.ts.tpl +16 -0
- package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.handler.ts.tpl +10 -0
- package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.handler.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/aggregates/account.aggregate.ts.tpl +16 -0
- package/templates/presets/identity/context/domain/aggregates/delegation.aggregate.ts.tpl +28 -0
- package/templates/presets/identity/context/domain/aggregates/invitation.aggregate.ts.tpl +27 -0
- package/templates/presets/identity/context/domain/aggregates/member.aggregate.ts.tpl +31 -0
- package/templates/presets/identity/context/domain/errors/above-own-role.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/account-already-deactivated.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/already-member.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/codes.named.ts.tpl +33 -0
- package/templates/presets/identity/context/domain/errors/deactivated-account.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/delegation-not-active.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/delegation-period-inverted.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/delegation-to-oneself.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/delegation-too-long.error.named.ts.tpl +12 -0
- package/templates/presets/identity/context/domain/errors/delegation-with-no-right.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/email-not-verified.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/invalid-display-name.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/invalid-email-address.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/invalid-organisation-name.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/invalid-organisation-slug.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/invitation-expired.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/invitation-not-addressed-to-account.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/invitation-not-pending.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/last-owner.error.named.ts.tpl +12 -0
- package/templates/presets/identity/context/domain/errors/not-an-owner.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/organisation-slug-taken.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/own-role.error.named.ts.tpl +12 -0
- package/templates/presets/identity/context/domain/errors/right-not-in-role.error.named.ts.tpl +12 -0
- package/templates/presets/identity/context/domain/errors/unknown-account.error.named.ts.tpl +12 -0
- package/templates/presets/identity/context/domain/errors/unknown-delegation.error.named.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/errors/unknown-invitation.error.named.ts.tpl +11 -0
- package/templates/presets/identity/context/domain/errors/unknown-member.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/unknown-organisation.error.named.ts.tpl +12 -0
- package/templates/presets/identity/context/domain/value-objects/delegation-period.vo.ts.tpl +16 -0
- package/templates/presets/identity/context/domain/value-objects/display-name.vo.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/value-objects/email-address.vo.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/value-objects/organisation-name.vo.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/value-objects/organisation-slug.vo.ts.tpl +10 -0
- package/templates/presets/identity/context/test/unit/provision-account.controller.spec.ts.tpl +13 -0
- package/templates/state-machine/state-machine.ts.tpl +5 -0
- package/templates/value-object/value-object.ts.tpl +6 -0
- /package/templates/presets/identity/context/domain/errors/{account.error.ts.tpl → account.error.factories.ts.tpl} +0 -0
- /package/templates/presets/identity/context/domain/errors/{delegation.error.ts.tpl → delegation.error.factories.ts.tpl} +0 -0
- /package/templates/presets/identity/context/domain/errors/{invitation.error.ts.tpl → invitation.error.factories.ts.tpl} +0 -0
- /package/templates/presets/identity/context/domain/errors/{member.error.ts.tpl → member.error.factories.ts.tpl} +0 -0
- /package/templates/presets/identity/context/domain/errors/{organisation.error.ts.tpl → organisation.error.factories.ts.tpl} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { toName } from '../naming/index.js';
|
|
2
|
+
import { legacyMove } from './legacy-move.js';
|
|
3
|
+
import { ownFactory } from './own-factory.js';
|
|
4
|
+
import { renderFactory } from './render-factory.js';
|
|
5
|
+
const IMPORT = /^import [^;]+;\n/gm;
|
|
6
|
+
/**
|
|
7
|
+
* The refusals still there whose plan entry names their class: each one with the factory it gets.
|
|
8
|
+
* One that cannot move mechanically is said, and left.
|
|
9
|
+
*/
|
|
10
|
+
export function namedMoves(plan, sources, draft) {
|
|
11
|
+
return Object.entries(plan.contexts).flatMap(([context, entries]) => entries.flatMap((entry) => {
|
|
12
|
+
const concept = sources.concepts.find((candidate) => candidate.context === context && candidate.file === entry.file);
|
|
13
|
+
const legacy = sources.legacy.find((candidate) => candidate.context === context && candidate.file === entry.file && candidate.className === entry.from);
|
|
14
|
+
if (legacy !== undefined) {
|
|
15
|
+
return fromLegacy({ entry, error: legacy }, draft);
|
|
16
|
+
}
|
|
17
|
+
return concept === undefined ? [] : fromConcept({ entry, concept }, draft);
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function fromConcept({ entry, concept }, draft) {
|
|
21
|
+
const factory = concept.factories.find((candidate) => `${concept.className}.${candidate.name}` === entry.from);
|
|
22
|
+
if (factory === undefined || factory.code === undefined) {
|
|
23
|
+
draft.manual.push(...(factory?.manual === undefined ? [] : [`${concept.file}: ${entry.from} is left as it is, ${factory.manual}.`]));
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const target = { oldClass: concept.className, className: entry.class, factory: entry.factory };
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
...movedFrom(concept, entry),
|
|
30
|
+
oldClass: concept.className,
|
|
31
|
+
oldFactory: factory.name,
|
|
32
|
+
code: factory.code,
|
|
33
|
+
text: ownFactory(factory, target),
|
|
34
|
+
imports: concept.imports,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function fromLegacy({ entry, error }, draft) {
|
|
39
|
+
if (error.manual !== undefined) {
|
|
40
|
+
draft.manual.push(`${error.file}: ${error.className} is left as it is, ${error.manual}.`);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const head = { ...movedFrom(error, entry), oldClass: error.className, oldFactory: undefined, code: error.code };
|
|
44
|
+
const text = renderFactory(error, legacyMove({ ...head, text: '', imports: [] }));
|
|
45
|
+
for (const property of error.properties) {
|
|
46
|
+
draft.manual.push(`${error.className}.${property} was a property of the error: read \`error.facts.${property}\` where it was read.`);
|
|
47
|
+
}
|
|
48
|
+
if (error.parameters.length > 3) {
|
|
49
|
+
draft.manual.push(`${entry.class}.${entry.factory} takes more than three parameters, give it one typed object.`);
|
|
50
|
+
}
|
|
51
|
+
return [{ ...head, text, imports: draft.read(error.file)?.match(IMPORT) ?? [] }];
|
|
52
|
+
}
|
|
53
|
+
function movedFrom(origin, entry) {
|
|
54
|
+
return {
|
|
55
|
+
context: origin.context,
|
|
56
|
+
from: entry.from,
|
|
57
|
+
oldFile: origin.file,
|
|
58
|
+
oldPath: `${origin.context}/domain/errors/${origin.file.slice(origin.file.lastIndexOf('/') + 1).replace(/\.ts$/, '')}`,
|
|
59
|
+
className: entry.class,
|
|
60
|
+
classFile: `${toName(entry.class).kebab}.error`,
|
|
61
|
+
factory: entry.factory,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=named-moves.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"named-moves.js","sourceRoot":"","sources":["../../src/refusals/named-moves.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,GAAG,oBAAoB,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAe,EAAE,OAAuB,EAAE,KAAqB;IACxF,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,CAClE,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CACnC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAAK,OAAO,IAAI,SAAS,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAC9E,CAAC;QAEF,MAAM,M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KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,8DAA8D,CAAC,CAAC;IACnH,CAAC;IAED,OAAO,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACnF,CAAC;AAID,SAAS,SAAS,CAAC,MAAyC,EAAE,KAAqB;IACjF,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,MAAM,CAAC,IAAI;QACpB,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,kBAAkB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;QACtH,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,QAAQ;QAC/C,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PlannedRefusal } from './planned-refusal.js';
|
|
2
|
+
/** What `error-factories --plan` proposes and `--apply` follows under `--to named`: per context, the class of each refusal. */
|
|
3
|
+
export interface NamedPlan {
|
|
4
|
+
readonly to: 'named';
|
|
5
|
+
readonly contexts: Readonly<Record<string, readonly PlannedRefusal[]>>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=named-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"named-plan.d.ts","sourceRoot":"","sources":["../../src/refusals/named-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,+HAA+H;AAC/H,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"named-plan.js","sourceRoot":"","sources":["../../src/refusals/named-plan.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConceptFactory } from './concept-error-class.js';
|
|
2
|
+
interface Target {
|
|
3
|
+
readonly oldClass: string;
|
|
4
|
+
readonly className: string;
|
|
5
|
+
readonly factory: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The factory of a class of its own, from a factory of a concept class: renamed, and building its
|
|
9
|
+
* refusal without the code, which the class holds now. Its parameters, its message, its facts and
|
|
10
|
+
* what it chains (`.exposing(..)`, `.causedBy(..)`) are kept as written.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ownFactory(factory: ConceptFactory, target: Target): string;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=own-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-factory.d.ts","sourceRoot":"","sources":["../../src/refusals/own-factory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/D,UAAU,MAAM;IACd,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAQD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsB1E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { scan } from '../check/scan/scan.js';
|
|
2
|
+
import { callArguments } from '../check/text/call-arguments.js';
|
|
3
|
+
import { escapeRegExp } from '../check/text/escape-reg-exp.js';
|
|
4
|
+
const REFUSAL_CALL = /(?<![\w$])([A-Za-z_$][\w$]*)(\s*\.\s*refusal\s*\()/;
|
|
5
|
+
/**
|
|
6
|
+
* The factory of a class of its own, from a factory of a concept class: renamed, and building its
|
|
7
|
+
* refusal without the code, which the class holds now. Its parameters, its message, its facts and
|
|
8
|
+
* what it chains (`.exposing(..)`, `.causedBy(..)`) are kept as written.
|
|
9
|
+
*/
|
|
10
|
+
export function ownFactory(factory, target) {
|
|
11
|
+
const { code } = scan(factory.text);
|
|
12
|
+
const declared = new RegExp(`(static\\s+(?:async\\s+)?)${escapeRegExp(factory.name)}(?![\\w$])`).exec(code);
|
|
13
|
+
const called = REFUSAL_CALL.exec(code);
|
|
14
|
+
if (declared === null || called === null) {
|
|
15
|
+
return factory.text;
|
|
16
|
+
}
|
|
17
|
+
const name = declared.index + (declared[1] ?? '').length;
|
|
18
|
+
const receiver = called[1] ?? '';
|
|
19
|
+
const [first, message] = callArguments(code, called.index + called[0].length - 1);
|
|
20
|
+
const edits = [
|
|
21
|
+
{ start: name, end: name + factory.name.length, text: target.factory },
|
|
22
|
+
...(receiver === target.oldClass
|
|
23
|
+
? [{ start: called.index, end: called.index + receiver.length, text: target.className }]
|
|
24
|
+
: []),
|
|
25
|
+
...(first === undefined || message === undefined ? [] : [{ start: first.start, end: message.start, text: '' }]),
|
|
26
|
+
];
|
|
27
|
+
return withSecondArgument(applied(factory.text, edits));
|
|
28
|
+
}
|
|
29
|
+
function applied(text, edits) {
|
|
30
|
+
return [...edits]
|
|
31
|
+
.sort((a, b) => b.start - a.start)
|
|
32
|
+
.reduce((current, edit) => current.slice(0, edit.start) + edit.text + current.slice(edit.end), text);
|
|
33
|
+
}
|
|
34
|
+
/** The note the generator wrote in a factory of a concept class counts the code as the first argument: it is gone. */
|
|
35
|
+
function withSecondArgument(text) {
|
|
36
|
+
return text.replace('give them as the third argument', 'give them as the second argument');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=own-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-factory.js","sourceRoot":"","sources":["../../src/refusals/own-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D,MAAM,YAAY,GAAG,oDAAoD,CAAC;AAc1E;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,OAAuB,EAAE,MAAc;IAChE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,6BAA6B,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5G,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,QAAQ,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACzC,OAAO,OAAO,CAAC,IAAI,CAAC;IACtB,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,C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AC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,iCAAiC,EAAE,kCAAkC,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MIGRATION_TARGETS } from './migration-targets.js';
|
|
2
|
+
/**
|
|
3
|
+
* The form a plan file moves the project to: its `to`. A plan without one was written before the
|
|
4
|
+
* named form existed, for the move to factories; no plan at all is read as the default move.
|
|
5
|
+
*/
|
|
6
|
+
export declare function planTarget(text: string | undefined): (typeof MIGRATION_TARGETS)[number];
|
|
7
|
+
//# sourceMappingURL=plan-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-target.d.ts","sourceRoot":"","sources":["../../src/refusals/plan-target.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAQvF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isRecord } from '../check/support/is-record.js';
|
|
2
|
+
/**
|
|
3
|
+
* The form a plan file moves the project to: its `to`. A plan without one was written before the
|
|
4
|
+
* named form existed, for the move to factories; no plan at all is read as the default move.
|
|
5
|
+
*/
|
|
6
|
+
export function planTarget(text) {
|
|
7
|
+
if (text === undefined) {
|
|
8
|
+
return 'named';
|
|
9
|
+
}
|
|
10
|
+
const raw = JSON.parse(text);
|
|
11
|
+
return isRecord(raw) && raw['to'] === 'named' ? 'named' : 'factories';
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=plan-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-target.js","sourceRoot":"","sources":["../../src/refusals/plan-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAwB;IACjD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,GAAG,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The decision about one refusal on its way to a class of its own: the name of that class and of its factory. */
|
|
2
|
+
export interface PlannedRefusal {
|
|
3
|
+
/** What builds it today: `SlotTakenError` (a class per error) or `AppointmentError.ended` (a factory of a concept class). */
|
|
4
|
+
readonly from: string;
|
|
5
|
+
readonly file: string;
|
|
6
|
+
/** Kept as it is: the code is the contract. */
|
|
7
|
+
readonly code: string;
|
|
8
|
+
/** The class of its own, named after the refusal: the PascalCase of its code, so that the code says it. */
|
|
9
|
+
readonly class: string;
|
|
10
|
+
/** Its factory, named after what the refusal is about: `forAppointment`, `withNotice`, `becauseOf`. */
|
|
11
|
+
readonly factory: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=planned-refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planned-refusal.d.ts","sourceRoot":"","sources":["../../src/refusals/planned-refusal.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,MAAM,WAAW,cAAc;IAC7B,6HAA6H;IAC7H,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2GAA2G;IAC3G,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uGAAuG;IACvG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planned-refusal.js","sourceRoot":"","sources":["../../src/refusals/planned-refusal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { Workspace } from '../workspace/index.js';
|
|
3
|
+
import type { ConceptErrorClass } from './concept-error-class.js';
|
|
4
|
+
import type { LegacyError } from './legacy-error.js';
|
|
5
|
+
import type { NamedPlan } from './named-plan.js';
|
|
6
|
+
interface Tree {
|
|
7
|
+
readonly ws: Workspace;
|
|
8
|
+
readonly config: Config;
|
|
9
|
+
}
|
|
10
|
+
/** What builds the refusals of a project today: classes per error, and factories of error classes per concept. */
|
|
11
|
+
export interface RefusalSources {
|
|
12
|
+
readonly legacy: readonly LegacyError[];
|
|
13
|
+
readonly concepts: readonly ConceptErrorClass[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A proposal: each refusal becomes a class named after its code (a thing not found is unknown),
|
|
17
|
+
* which it keeps, with one factory named after what it is refused on, its first parameter
|
|
18
|
+
* (`AppointmentError.bookingTooFar(horizon)` becomes `BookingTooFar.forHorizon`, `ended(appointmentId)`
|
|
19
|
+
* becomes `AppointmentEnded.forAppointment`), or the concept when the factory has no parameter to say it. The names are decisions of the model:
|
|
20
|
+
* the proposal is edited before it is applied. A factory whose code is not a literal is left out:
|
|
21
|
+
* it moves by hand.
|
|
22
|
+
*/
|
|
23
|
+
export declare function proposeNamedPlan(sources: RefusalSources, tree: Tree): NamedPlan;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=propose-named-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose-named-plan.d.ts","sourceRoot":"","sources":["../../src/refusals/propose-named-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAKjD,UAAU,IAAI;IACZ,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,kHAAkH;AAClH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACjD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,GAAG,SAAS,CAsC/E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { toName } from '../naming/index.js';
|
|
2
|
+
import { aggregatesOf } from './aggregates-of.js';
|
|
3
|
+
import { conceptNamed } from './concept-named.js';
|
|
4
|
+
import { factoryForParameter } from './factory-for-parameter.js';
|
|
5
|
+
const NOT_FOUND = /^(?:([A-Z0-9_]+?)_NOT_FOUND|NOT_FOUND_([A-Z0-9_]+))$/;
|
|
6
|
+
/**
|
|
7
|
+
* A proposal: each refusal becomes a class named after its code (a thing not found is unknown),
|
|
8
|
+
* which it keeps, with one factory named after what it is refused on, its first parameter
|
|
9
|
+
* (`AppointmentError.bookingTooFar(horizon)` becomes `BookingTooFar.forHorizon`, `ended(appointmentId)`
|
|
10
|
+
* becomes `AppointmentEnded.forAppointment`), or the concept when the factory has no parameter to say it. The names are decisions of the model:
|
|
11
|
+
* the proposal is edited before it is applied. A factory whose code is not a literal is left out:
|
|
12
|
+
* it moves by hand.
|
|
13
|
+
*/
|
|
14
|
+
export function proposeNamedPlan(sources, tree) {
|
|
15
|
+
const contexts = {};
|
|
16
|
+
const add = (context, entry, fallback) => {
|
|
17
|
+
const planned = (contexts[context] ??= []);
|
|
18
|
+
const taken = planned.some((other) => other.class === entry.class && other.factory === entry.factory);
|
|
19
|
+
planned.push(taken ? { ...entry, factory: `for${toName(fallback).pascal}` } : entry);
|
|
20
|
+
};
|
|
21
|
+
for (const concept of sources.concepts) {
|
|
22
|
+
const subject = concept.className.replace(/Error$/, '');
|
|
23
|
+
for (const { name, code, parameter } of concept.factories) {
|
|
24
|
+
if (code !== undefined) {
|
|
25
|
+
const from = `${concept.className}.${name}`;
|
|
26
|
+
const factory = factoryForParameter(parameter) ?? `for${subject}`;
|
|
27
|
+
add(concept.context, { from, file: concept.file, code, class: classNameOf(code), factory }, name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const error of sources.legacy) {
|
|
32
|
+
const factory = legacyFactory(error, conceptNamed(error.className, aggregatesOf(tree, error.context)));
|
|
33
|
+
const entry = {
|
|
34
|
+
from: error.className,
|
|
35
|
+
file: error.file,
|
|
36
|
+
code: error.code,
|
|
37
|
+
class: classNameOf(error.code),
|
|
38
|
+
factory,
|
|
39
|
+
};
|
|
40
|
+
add(error.context, entry, error.className.replace(/Error$/, ''));
|
|
41
|
+
}
|
|
42
|
+
return { to: 'named', contexts };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The PascalCase of the code, never ending in `Error`: `APPOINTMENT_ENDED` gives `AppointmentEnded`.
|
|
46
|
+
* A thing not found is unknown to the business, which has no word "found": `INVOICE_NOT_FOUND` and
|
|
47
|
+
* `NOT_FOUND_INVOICE` give `UnknownInvoice`, the code kept.
|
|
48
|
+
*/
|
|
49
|
+
function classNameOf(code) {
|
|
50
|
+
const missing = NOT_FOUND.exec(code);
|
|
51
|
+
const subject = missing?.[1] ?? missing?.[2];
|
|
52
|
+
const pascal = subject === undefined ? toName(code).pascal : `Unknown${toName(subject).pascal}`;
|
|
53
|
+
const bare = pascal.replace(/Error$/, '');
|
|
54
|
+
return bare === '' ? pascal : bare;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* As for a factory of a concept class: its first parameter, else the concept the class is named
|
|
58
|
+
* after, else the context. A constructor that takes only the message (a class without one does)
|
|
59
|
+
* says nothing about the refusal: the concept, when the class is named after one, says more.
|
|
60
|
+
*/
|
|
61
|
+
function legacyFactory(error, concept) {
|
|
62
|
+
const [first] = error.parameters;
|
|
63
|
+
const told = first?.name === 'message' && concept !== '';
|
|
64
|
+
const named = told ? undefined : factoryForParameter(first?.name);
|
|
65
|
+
return named ?? `for${concept === '' ? toName(error.context).pascal : concept}`;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=propose-named-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose-named-plan.js","sourceRoot":"","sources":["../../src/refusals/propose-named-plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,MAAM,SAAS,GAAG,sDAAsD,CAAC;AAazE;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAuB,EAAE,IAAU;IAClE,MAAM,QAAQ,GAAqC,EAAE,CAAC;IAEtD,MAAM,GAAG,GAAG,CAAC,OAAe,EAAE,KAAqB,EAAE,QAAgB,EAAQ,EAAE;QAC7E,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,K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IAElE,OAAO,KAAK,IAAI,MAAM,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAClF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose-plan.d.ts","sourceRoot":"","sources":["../../src/refusals/propose-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"propose-plan.d.ts","sourceRoot":"","sources":["../../src/refusals/propose-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,UAAU,IAAI;IACZ,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,aAAa,CAgBrF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aggregatesOf } from './aggregates-of.js';
|
|
2
|
+
import { conceptNamed } from './concept-named.js';
|
|
2
3
|
import { factoryNameFor } from './factory-name-for.js';
|
|
3
4
|
/**
|
|
4
5
|
* A proposal: each class per error goes to the aggregate its name or its code starts or ends
|
|
@@ -8,7 +9,7 @@ import { factoryNameFor } from './factory-name-for.js';
|
|
|
8
9
|
export function proposePlan(errors, tree) {
|
|
9
10
|
const contexts = {};
|
|
10
11
|
for (const error of errors) {
|
|
11
|
-
const concept =
|
|
12
|
+
const concept = conceptNamed(error.className, aggregatesOf(tree, error.context));
|
|
12
13
|
(contexts[error.context] ??= []).push({
|
|
13
14
|
class: error.className,
|
|
14
15
|
file: error.file,
|
|
@@ -19,21 +20,4 @@ export function proposePlan(errors, tree) {
|
|
|
19
20
|
}
|
|
20
21
|
return { contexts };
|
|
21
22
|
}
|
|
22
|
-
function aggregatesOf({ ws, config }, context) {
|
|
23
|
-
return ws
|
|
24
|
-
.list(`${config.contextsDir}/${context}/domain/aggregates`)
|
|
25
|
-
.filter((name) => name.endsWith('.aggregate.ts'))
|
|
26
|
-
.map((name) => toName(name.replace(/\.aggregate\.ts$/, '')).pascal);
|
|
27
|
-
}
|
|
28
|
-
/** The longest aggregate name the words of the class start or end with. */
|
|
29
|
-
function conceptOf(error, aggregates) {
|
|
30
|
-
const words = splitWords(error.className.replace(/Error$/, '')).join(' ');
|
|
31
|
-
const named = aggregates
|
|
32
|
-
.filter((aggregate) => {
|
|
33
|
-
const subject = splitWords(aggregate).join(' ');
|
|
34
|
-
return words === subject || words.startsWith(`${subject} `) || words.endsWith(` ${subject}`);
|
|
35
|
-
})
|
|
36
|
-
.sort((a, b) => b.length - a.length);
|
|
37
|
-
return named[0] ?? '';
|
|
38
|
-
}
|
|
39
23
|
//# sourceMappingURL=propose-plan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose-plan.js","sourceRoot":"","sources":["../../src/refusals/propose-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"propose-plan.js","sourceRoot":"","sources":["../../src/refusals/propose-plan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAUvD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAA8B,EAAE,IAAU;IACpE,MAAM,QAAQ,GAAqC,EAAE,CAAC;IAEtD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAEjF,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC;YACpC,KAAK,EAAE,KAAK,CAAC,SAAS;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO;YACP,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConceptErrorClass } from './concept-error-class.js';
|
|
2
|
+
interface Origin {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly context: string;
|
|
5
|
+
}
|
|
6
|
+
/** Reads an error class per concept: each of its static factories, with the code it sets. Undefined when the file holds none. */
|
|
7
|
+
export declare function readConceptError(source: string, origin: Origin): ConceptErrorClass | undefined;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=read-concept-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-concept-error.d.ts","sourceRoot":"","sources":["../../src/refusals/read-concept-error.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,0BAA0B,CAAC;AAQlF,UAAU,MAAM;IACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAQD,iIAAiI;AACjI,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAgB9F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { wholeLiteral } from '../check/declarations/whole-literal.js';
|
|
2
|
+
import { scan } from '../check/scan/scan.js';
|
|
3
|
+
import { callArguments } from '../check/text/call-arguments.js';
|
|
4
|
+
import { classBody } from '../generate/errors/class-body.js';
|
|
5
|
+
import { staticMethods } from '../generate/errors/static-methods.js';
|
|
6
|
+
import { firstParameter } from './first-parameter.js';
|
|
7
|
+
import { memberStart } from './member-start.js';
|
|
8
|
+
const CLASS = /export\s+class\s+([A-Za-z_$][\w$]*)\s+extends\s+ConceptError\b/;
|
|
9
|
+
const REFUSAL_CALL = /(?<![\w$])([A-Za-z_$][\w$]*)\s*\.\s*refusal\s*\(/g;
|
|
10
|
+
const IMPORT = /^import [^;]+;\n/gm;
|
|
11
|
+
/** Reads an error class per concept: each of its static factories, with the code it sets. Undefined when the file holds none. */
|
|
12
|
+
export function readConceptError(source, origin) {
|
|
13
|
+
const scanned = scan(source);
|
|
14
|
+
const declared = CLASS.exec(scanned.code);
|
|
15
|
+
const className = declared?.[1] ?? '';
|
|
16
|
+
const body = classBody(scanned, className);
|
|
17
|
+
if (declared === null || body === undefined) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...origin,
|
|
22
|
+
className,
|
|
23
|
+
factories: staticMethods(scanned.code, body).map((method) => factoryOf({ source, scanned, className }, method)),
|
|
24
|
+
imports: source.match(IMPORT) ?? [],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function factoryOf(read, method) {
|
|
28
|
+
const declared = read.scanned.code.lastIndexOf('static', method.open);
|
|
29
|
+
const start = memberStart(read.source, declared);
|
|
30
|
+
const text = read.source.slice(start, method.end + 1);
|
|
31
|
+
const parameter = firstParameter(read.scanned.code, read.scanned.code.indexOf('(', declared));
|
|
32
|
+
return { name: method.name, parameter, start, end: method.end, text, ...codeOf(read, method) };
|
|
33
|
+
}
|
|
34
|
+
/** A factory moves alone when it builds one refusal of its class, whose code is one string literal. */
|
|
35
|
+
function codeOf({ scanned, className }, method) {
|
|
36
|
+
const calls = [...scanned.code.slice(method.open, method.end).matchAll(REFUSAL_CALL)];
|
|
37
|
+
const [call] = calls;
|
|
38
|
+
if (call === undefined || calls.length > 1) {
|
|
39
|
+
return { code: undefined, manual: 'it does not build exactly one refusal with refusal(..)' };
|
|
40
|
+
}
|
|
41
|
+
if (call[1] !== className && call[1] !== 'this') {
|
|
42
|
+
return { code: undefined, manual: `it builds the refusal of ${call[1] ?? ''}, not of its own class` };
|
|
43
|
+
}
|
|
44
|
+
const [first, message] = callArguments(scanned.code, method.open + call.index + call[0].length - 1);
|
|
45
|
+
const code = first === undefined ? undefined : wholeLiteral(scanned, first);
|
|
46
|
+
if (code === undefined || message === undefined) {
|
|
47
|
+
return { code: undefined, manual: 'its code is not one string literal followed by a message' };
|
|
48
|
+
}
|
|
49
|
+
return { code };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=read-concept-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-concept-error.js","sourceRoot":"","sources":["../../src/refusals/read-concept-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,IAAI,EAAa,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAqB,MAAM,sCAAsC,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,KAAK,GAAG,gEAAgE,CAAC;AAC/E,MAAM,YAAY,GAAG,mDAAmD,CAAC;AACzE,MAAM,M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C,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAE5E,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,0DAA0D,EAAE,CAAC;IACjG,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NamedPlan } from './named-plan.js';
|
|
2
|
+
/** The decisions of a plan to the named form, each one checked: a class named after the refusal, a factory with its prefix. */
|
|
3
|
+
export declare function readNamedPlan(text: string | undefined): NamedPlan;
|
|
4
|
+
//# sourceMappingURL=read-named-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-named-plan.d.ts","sourceRoot":"","sources":["../../src/refusals/read-named-plan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQjD,+HAA+H;AAC/H,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAiBjE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isRecord } from '../check/support/is-record.js';
|
|
2
|
+
import { CliError } from '../cli-error.js';
|
|
3
|
+
import { FACTORY_PREFIX } from '../generate/errors/factory-prefix.js';
|
|
4
|
+
import { toName } from '../naming/index.js';
|
|
5
|
+
import { PLAN_FILE } from './plan-file.js';
|
|
6
|
+
const FIX = `Run \`ddd-ts-kit error-factories --plan\` to write ${PLAN_FILE} again, then edit the names of each entry.`;
|
|
7
|
+
const CLASS = /^[A-Z][A-Za-z0-9]*$/;
|
|
8
|
+
const LETTERS = /^[A-Za-z]+$/;
|
|
9
|
+
/** The decisions of a plan to the named form, each one checked: a class named after the refusal, a factory with its prefix. */
|
|
10
|
+
export function readNamedPlan(text) {
|
|
11
|
+
const raw = text === undefined ? undefined : JSON.parse(text);
|
|
12
|
+
const contexts = isRecord(raw) && isRecord(raw['contexts']) ? raw['contexts'] : undefined;
|
|
13
|
+
if (contexts === undefined) {
|
|
14
|
+
throw new CliError(`${PLAN_FILE} holds no plan.`, FIX);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
to: 'named',
|
|
18
|
+
contexts: Object.fromEntries(Object.entries(contexts).map(([context, entries]) => [
|
|
19
|
+
context,
|
|
20
|
+
distinct((Array.isArray(entries) ? entries : []).map(entryOf)),
|
|
21
|
+
])),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function entryOf(raw) {
|
|
25
|
+
const text = (key) => (isRecord(raw) && typeof raw[key] === 'string' ? raw[key].trim() : '');
|
|
26
|
+
const entry = {
|
|
27
|
+
from: text('from'),
|
|
28
|
+
file: text('file'),
|
|
29
|
+
code: text('code'),
|
|
30
|
+
class: text('class'),
|
|
31
|
+
factory: text('factory'),
|
|
32
|
+
};
|
|
33
|
+
if (entry.from === '' || entry.file === '' || entry.code === '') {
|
|
34
|
+
throw new CliError(`${PLAN_FILE} has an entry without what it moves from, its file or its code.`, FIX);
|
|
35
|
+
}
|
|
36
|
+
if (!CLASS.test(entry.class) || entry.class.endsWith('Error')) {
|
|
37
|
+
throw new CliError(`${PLAN_FILE}: "${entry.class}" is not the name of the refusal ${entry.from} builds.`, `Name it after the refusal, in PascalCase, never ending in Error: ${toName(entry.code).pascal.replace(/Error$/, '')} (rule errors/factory-name).`);
|
|
38
|
+
}
|
|
39
|
+
if (!FACTORY_PREFIX.test(entry.factory) || !LETTERS.test(entry.factory)) {
|
|
40
|
+
throw new CliError(`${PLAN_FILE}: "${entry.factory}" is not the name of a factory of ${entry.class}.`, `Start it with for, with, because, on or at, then an upper-case letter, letters only: for${toName(entry.factory).pascal.replace(/\d/g, '')} (rule errors/factory-name).`);
|
|
41
|
+
}
|
|
42
|
+
return entry;
|
|
43
|
+
}
|
|
44
|
+
/** Within a context a class has one code, and each of its factories one name. */
|
|
45
|
+
function distinct(entries) {
|
|
46
|
+
for (const [index, entry] of entries.entries()) {
|
|
47
|
+
const earlier = entries.slice(0, index).filter((other) => other.class === entry.class);
|
|
48
|
+
if (earlier.some((other) => other.code !== entry.code)) {
|
|
49
|
+
throw new CliError(`${PLAN_FILE}: ${entry.class} is given two codes.`, 'A refusal class has one code: give the other refusal a class of its own.');
|
|
50
|
+
}
|
|
51
|
+
if (earlier.some((other) => other.factory === entry.factory)) {
|
|
52
|
+
throw new CliError(`${PLAN_FILE}: ${entry.class}.${entry.factory} is planned twice.`, `Give each factory of ${entry.class} a name of its own.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return [...entries];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=read-named-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-named-plan.js","sourceRoot":"","sources":["../../src/refusals/read-named-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,GAAG,GAAG,sDAAsD,SAAS,4CAA4C,CAAC;AACxH,MAAM,KAAK,GAAG,qBAAqB,CAAC;AACpC,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B,+HAA+H;AAC/H,MAAM,UAAU,aAAa,CAAC,IAAwB;IACpD,MAAM,GAAG,GAAY,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CA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CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,MAAM,IAAI,QAAQ,CAChB,GAAG,SAAS,KAAK,KAAK,CAAC,KAAK,sBAAsB,EAClD,0EAA0E,CAC3E,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,QAAQ,CAChB,GAAG,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,oBAAoB,EACjE,wBAAwB,KAAK,CAAC,KAAK,qBAAqB,CACzD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NamedMove } from './named-move.js';
|
|
2
|
+
/** The refusal class of a context, the moves that give it its factories, and how its file imports the codes. */
|
|
3
|
+
export interface RefusalClass {
|
|
4
|
+
readonly file: string;
|
|
5
|
+
readonly className: string;
|
|
6
|
+
readonly context: string;
|
|
7
|
+
readonly codesSpecifier: string;
|
|
8
|
+
readonly moves: readonly NamedMove[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The file of a refusal class: its code read from the list of the context, its factories, and the
|
|
12
|
+
* imports they read. A file that already declares the class only gains the factories it lacks.
|
|
13
|
+
*/
|
|
14
|
+
export declare function refusalClassFile(existing: string | undefined, refusal: RefusalClass): string;
|
|
15
|
+
//# sourceMappingURL=refusal-class-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal-class-file.d.ts","sourceRoot":"","sources":["../../src/refusals/refusal-class-file.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,gHAAgH;AAChH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAqB5F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CliError } from '../cli-error.js';
|
|
2
|
+
import { addFactory } from '../generate/errors/add-factory.js';
|
|
3
|
+
import { fitSource } from '../layout/index.js';
|
|
4
|
+
import { toName } from '../naming/index.js';
|
|
5
|
+
import { importsUsedBy } from './imports-used-by.js';
|
|
6
|
+
/**
|
|
7
|
+
* The file of a refusal class: its code read from the list of the context, its factories, and the
|
|
8
|
+
* imports they read. A file that already declares the class only gains the factories it lacks.
|
|
9
|
+
*/
|
|
10
|
+
export function refusalClassFile(existing, refusal) {
|
|
11
|
+
if (existing === undefined) {
|
|
12
|
+
return fitSource(fresh(refusal));
|
|
13
|
+
}
|
|
14
|
+
const added = refusal.moves.reduce((source, move) => source === undefined
|
|
15
|
+
? undefined
|
|
16
|
+
: addFactory(source, { className: refusal.className, name: move.factory, text: move.text }), existing);
|
|
17
|
+
if (added === undefined) {
|
|
18
|
+
throw new CliError(`${refusal.file} holds another class than ${refusal.className}.`, `Give ${refusal.className} another name in the plan, then run \`ddd-ts-kit error-factories --apply\` again.`);
|
|
19
|
+
}
|
|
20
|
+
return fitSource(added);
|
|
21
|
+
}
|
|
22
|
+
function fresh({ className, context, codesSpecifier, moves }) {
|
|
23
|
+
const list = `${toName(context).pascal}Codes`;
|
|
24
|
+
const factories = moves.map((move) => move.text);
|
|
25
|
+
const carried = [...new Set(moves.flatMap((move) => move.imports))];
|
|
26
|
+
return [
|
|
27
|
+
"import { DomainRefusal } from '@ddd-ts-kit/kernel';\n",
|
|
28
|
+
...importsUsedBy(carried, factories.join('\n')),
|
|
29
|
+
`import { ${list} } from '${codesSpecifier}';\n`,
|
|
30
|
+
'\n',
|
|
31
|
+
`export class ${className} extends DomainRefusal {\n`,
|
|
32
|
+
` readonly code = ${list}.${className};\n`,
|
|
33
|
+
'\n',
|
|
34
|
+
`${factories.join('\n\n')}\n`,
|
|
35
|
+
'}\n',
|
|
36
|
+
].join('');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=refusal-class-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal-class-file.js","sourceRoot":"","sources":["../../src/refusals/refusal-class-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAYrD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA4B,EAAE,OAAqB;IAClF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAChC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACf,MAAM,KAAK,SAAS;QAClB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAC/F,QAAQ,CACT,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,QAAQ,CAChB,GAAG,OAAO,CAAC,IAAI,6BAA6B,OAAO,CAAC,SAAS,GAAG,EAChE,QAAQ,OAAO,CAAC,SAAS,mFAAmF,CAC7G,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAgB;IACxE,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC;IAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEpE,OAAO;QACL,uDAAuD;QACvD,GAAG,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,YAAY,IAAI,YAAY,cAAc,MAAM;QAChD,IAAI;QACJ,gBAAgB,SAAS,4BAA4B;QACrD,qBAAqB,IAAI,IAAI,SAAS,KAAK;QAC3C,IAAI;QACJ,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;QAC7B,KAAK;KACN,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A case moved to the spec of one class of its own: what still names the concept class there,
|
|
3
|
+
* an assertion `toBeInstanceOf(AppointmentError)` for instance, means that class. Import lines
|
|
4
|
+
* are left: the imports are sorted out after.
|
|
5
|
+
*/
|
|
6
|
+
export declare function renameConcept(source: string, concept: string, className: string): string;
|
|
7
|
+
//# sourceMappingURL=rename-concept.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-concept.d.ts","sourceRoot":"","sources":["../../src/refusals/rename-concept.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAUxF"}
|