@nestjslatam/ddd-lib 1.0.50 → 1.0.52
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/LICENSE +21 -21
- package/README.md +30 -30
- package/dist/aggregate-root.d.ts +63 -0
- package/dist/aggregate-root.js +154 -0
- package/dist/broken-rules.manager.d.ts +21 -0
- package/dist/broken-rules.manager.js +95 -0
- package/dist/core/aggregate/aggregate-equality.d.ts +16 -0
- package/dist/core/aggregate/aggregate-equality.js +33 -0
- package/dist/core/aggregate/aggregate-identity.d.ts +11 -0
- package/dist/core/aggregate/aggregate-identity.js +40 -0
- package/dist/core/aggregate/aggregate-serializer.d.ts +28 -0
- package/dist/core/aggregate/aggregate-serializer.js +38 -0
- package/dist/core/aggregate/aggregate-validation-orchestrator.d.ts +14 -0
- package/dist/core/aggregate/aggregate-validation-orchestrator.js +36 -0
- package/dist/core/aggregate/index.d.ts +5 -0
- package/dist/core/aggregate/index.js +12 -0
- package/dist/core/business-rules/impl/broken-rule.d.ts +7 -0
- package/dist/core/business-rules/impl/broken-rule.js +15 -0
- package/dist/core/business-rules/impl/broken-rules-extension.d.ts +6 -0
- package/dist/core/business-rules/impl/broken-rules-extension.js +32 -0
- package/dist/core/business-rules/impl/index.d.ts +4 -0
- package/{ddd-core/broken-rules → dist/core/business-rules/impl}/index.js +2 -1
- package/dist/core/business-rules/impl/property-change/index.d.ts +5 -0
- package/dist/core/business-rules/impl/property-change/index.js +21 -0
- package/dist/core/business-rules/impl/property-change/notify-property-changed.base.d.ts +16 -0
- package/dist/core/business-rules/impl/property-change/notify-property-changed.base.js +64 -0
- package/dist/core/business-rules/impl/property-change/notify-property-changed.context-args.d.ts +7 -0
- package/dist/core/business-rules/impl/property-change/notify-property-changed.context-args.js +12 -0
- package/dist/core/business-rules/impl/property-change/notify-property-changed.context.d.ts +11 -0
- package/dist/core/business-rules/impl/property-change/notify-property-changed.context.js +21 -0
- package/dist/core/business-rules/impl/property-change/reflection-type-extensions.d.ts +5 -0
- package/dist/core/business-rules/impl/property-change/reflection-type-extensions.js +23 -0
- package/dist/core/business-rules/index.d.ts +2 -0
- package/dist/core/index.d.ts +6 -0
- package/{ddd-core → dist/core}/index.js +5 -5
- package/dist/core/repositories/index.d.ts +3 -0
- package/dist/core/repositories/index.js +19 -0
- package/dist/core/repositories/repository-read.interface.d.ts +7 -0
- package/{ddd-commands/interfaces/command-handler.interface.js → dist/core/repositories/repository-read.interface.js} +1 -1
- package/{ddd-ports/interfaces/domain-repository-write.interface.d.ts → dist/core/repositories/repository-write.interface.d.ts} +4 -3
- package/{ddd-commands/interfaces/command-metadata.interface.js → dist/core/repositories/repository-write.interface.js} +1 -1
- package/dist/core/tracking-state/impl/index.d.ts +4 -0
- package/{ddd-core → dist/core/tracking-state}/impl/index.js +2 -2
- package/dist/core/tracking-state/impl/nested-property-change-detector.d.ts +8 -0
- package/dist/core/tracking-state/impl/nested-property-change-detector.js +38 -0
- package/{ddd-core → dist/core/tracking-state}/impl/tracking-props.d.ts +3 -0
- package/{ddd-core → dist/core/tracking-state}/impl/tracking-props.js +11 -0
- package/dist/core/tracking-state/impl/tracking-state-transition.d.ts +9 -0
- package/dist/core/tracking-state/impl/tracking-state-transition.js +34 -0
- package/{ddd-commands → dist/core/tracking-state}/index.d.ts +1 -0
- package/dist/core/tracking-state/interfaces/ichange-detector.d.ts +8 -0
- package/{ddd-commands/interfaces/command.interface.js → dist/core/tracking-state/interfaces/ichange-detector.js} +1 -1
- package/dist/core/tracking-state/interfaces/idomain-primitive.d.ts +5 -0
- package/dist/core/tracking-state/interfaces/idomain-primitive.js +3 -0
- package/dist/core/tracking-state/interfaces/index.d.ts +6 -0
- package/dist/core/tracking-state/interfaces/index.js +22 -0
- package/{ddd-core/interfaces/tracking.interface.d.ts → dist/core/tracking-state/interfaces/itracking-props.d.ts} +2 -0
- package/{ddd-core/interfaces/saga.interface.js → dist/core/tracking-state/interfaces/itracking-props.js} +1 -1
- package/dist/core/tracking-state/interfaces/itracking-state-manager.d.ts +12 -0
- package/{ddd-commands/interfaces/command-bus.interface.js → dist/core/tracking-state/interfaces/itracking-state-manager.js} +1 -1
- package/dist/core/tracking-state/interfaces/itracking-state-transitions.d.ts +7 -0
- package/dist/core/tracking-state/interfaces/itracking-state-transitions.js +3 -0
- package/dist/core/validator-rules/impl/abstract-rule-validator.d.ts +13 -0
- package/dist/core/validator-rules/impl/abstract-rule-validator.js +34 -0
- package/dist/core/validator-rules/impl/abstract-validator.d.ts +4 -0
- package/dist/core/validator-rules/impl/abstract-validator.js +7 -0
- package/dist/core/validator-rules/impl/entity-validator.d.ts +5 -0
- package/dist/core/validator-rules/impl/entity-validator.js +12 -0
- package/dist/core/validator-rules/impl/index.d.ts +5 -0
- package/{ddd-core/interfaces → dist/core/validator-rules/impl}/index.js +4 -4
- package/dist/core/validator-rules/impl/value-object-validator.d.ts +7 -0
- package/dist/core/validator-rules/impl/value-object-validator.js +15 -0
- package/{ddd-events → dist/core/validator-rules}/index.d.ts +2 -1
- package/{ddd-events → dist/core/validator-rules}/index.js +1 -1
- package/dist/core/validator-rules/interfaces/index.d.ts +3 -0
- package/{ddd-ports → dist/core/validator-rules/interfaces}/index.js +2 -1
- package/dist/core/validator-rules/interfaces/irule-context.d.ts +5 -0
- package/{ddd-commands/impl/command-types.js → dist/core/validator-rules/interfaces/irule-context.js} +1 -1
- package/dist/core/validator-rules/interfaces/irule-validator.d.ts +8 -0
- package/{ddd-core/interfaces/ddd.options.js → dist/core/validator-rules/interfaces/irule-validator.js} +1 -1
- package/dist/ddd.module.d.ts +6 -0
- package/{ddd.module.js → dist/ddd.module.js} +4 -32
- package/dist/ddd.service.d.ts +7 -0
- package/{ddd.service.js → dist/ddd.service.js} +1 -16
- package/dist/domain-event.d.ts +56 -0
- package/dist/domain-event.js +175 -0
- package/dist/enum.d.ts +28 -0
- package/dist/enum.js +129 -0
- package/dist/exceptions/domain.exception.d.ts +19 -0
- package/dist/exceptions/domain.exception.js +45 -0
- package/{ddd-helpers → dist/helpers}/datetime.helper.d.ts +1 -0
- package/{ddd-helpers → dist/helpers}/datetime.helper.js +1 -1
- package/dist/helpers/domain-object.helper.d.ts +20 -0
- package/{ddd-helpers → dist/helpers}/domain-object.helper.js +14 -19
- package/{ddd-helpers → dist/helpers}/index.d.ts +1 -0
- package/dist/index.d.ts +13 -0
- package/{ddd-events/impl → dist}/index.js +11 -7
- package/dist/state-transition.manager.d.ts +23 -0
- package/dist/state-transition.manager.js +163 -0
- package/dist/tracking-state-manager.d.ts +25 -0
- package/dist/tracking-state-manager.js +70 -0
- package/dist/validator-rule.manager.d.ts +17 -0
- package/dist/validator-rule.manager.js +80 -0
- package/dist/valueobject.d.ts +23 -0
- package/dist/valueobject.js +93 -0
- package/dist/valueobjects/id.valueobject.d.ts +16 -0
- package/dist/valueobjects/id.valueobject.js +52 -0
- package/dist/valueobjects/index.d.ts +7 -0
- package/{ddd-commands/impl → dist/valueobjects}/index.js +6 -5
- package/dist/valueobjects/number-notnull.validator.d.ts +13 -0
- package/dist/valueobjects/number-notnull.validator.js +31 -0
- package/dist/valueobjects/number-positive.validator.d.ts +13 -0
- package/dist/valueobjects/number-positive.validator.js +43 -0
- package/dist/valueobjects/number.valueobject.d.ts +25 -0
- package/dist/valueobjects/number.valueobject.js +67 -0
- package/dist/valueobjects/string-notnullorempty.validator.d.ts +14 -0
- package/dist/valueobjects/string-notnullorempty.validator.js +36 -0
- package/dist/valueobjects/string.valueobject.d.ts +27 -0
- package/dist/valueobjects/string.valueobject.js +86 -0
- package/package.json +51 -25
- package/src/types.d.ts +7 -0
- package/ddd-aggregate-root.d.ts +0 -34
- package/ddd-aggregate-root.js +0 -85
- package/ddd-aggregate-root.js.map +0 -1
- package/ddd-commands/impl/command-types.d.ts +0 -3
- package/ddd-commands/impl/command-types.js.map +0 -1
- package/ddd-commands/impl/command.base.d.ts +0 -7
- package/ddd-commands/impl/command.base.js +0 -15
- package/ddd-commands/impl/command.base.js.map +0 -1
- package/ddd-commands/impl/default-command-publisher.d.ts +0 -7
- package/ddd-commands/impl/default-command-publisher.js +0 -13
- package/ddd-commands/impl/default-command-publisher.js.map +0 -1
- package/ddd-commands/impl/domain-command-bus.d.ts +0 -18
- package/ddd-commands/impl/domain-command-bus.js +0 -71
- package/ddd-commands/impl/domain-command-bus.js.map +0 -1
- package/ddd-commands/impl/index.d.ts +0 -5
- package/ddd-commands/impl/index.js.map +0 -1
- package/ddd-commands/index.js.map +0 -1
- package/ddd-commands/interfaces/command-bus.interface.d.ts +0 -4
- package/ddd-commands/interfaces/command-bus.interface.js.map +0 -1
- package/ddd-commands/interfaces/command-handler.interface.d.ts +0 -4
- package/ddd-commands/interfaces/command-handler.interface.js.map +0 -1
- package/ddd-commands/interfaces/command-metadata.interface.d.ts +0 -4
- package/ddd-commands/interfaces/command-metadata.interface.js.map +0 -1
- package/ddd-commands/interfaces/command-publisher.interface.d.ts +0 -4
- package/ddd-commands/interfaces/command-publisher.interface.js +0 -3
- package/ddd-commands/interfaces/command-publisher.interface.js.map +0 -1
- package/ddd-commands/interfaces/command.interface.d.ts +0 -4
- package/ddd-commands/interfaces/command.interface.js.map +0 -1
- package/ddd-commands/interfaces/index.d.ts +0 -5
- package/ddd-commands/interfaces/index.js +0 -22
- package/ddd-commands/interfaces/index.js.map +0 -1
- package/ddd-core/broken-rules/broken-rule-collection.d.ts +0 -13
- package/ddd-core/broken-rules/broken-rule-collection.js +0 -54
- package/ddd-core/broken-rules/broken-rule-collection.js.map +0 -1
- package/ddd-core/broken-rules/broken-rule.d.ts +0 -5
- package/ddd-core/broken-rules/broken-rule.js +0 -13
- package/ddd-core/broken-rules/broken-rule.js.map +0 -1
- package/ddd-core/broken-rules/index.d.ts +0 -2
- package/ddd-core/broken-rules/index.js.map +0 -1
- package/ddd-core/ddd-base-classes.d.ts +0 -52
- package/ddd-core/ddd-base-classes.js +0 -173
- package/ddd-core/ddd-base-classes.js.map +0 -1
- package/ddd-core/ddd-validators.d.ts +0 -15
- package/ddd-core/ddd-validators.js +0 -70
- package/ddd-core/ddd-validators.js.map +0 -1
- package/ddd-core/impl/index.d.ts +0 -3
- package/ddd-core/impl/index.js.map +0 -1
- package/ddd-core/impl/observable-bus.d.ts +0 -6
- package/ddd-core/impl/observable-bus.js +0 -16
- package/ddd-core/impl/observable-bus.js.map +0 -1
- package/ddd-core/impl/of-type.d.ts +0 -4
- package/ddd-core/impl/of-type.js +0 -9
- package/ddd-core/impl/of-type.js.map +0 -1
- package/ddd-core/impl/tracking-props.js.map +0 -1
- package/ddd-core/index.d.ts +0 -5
- package/ddd-core/index.js.map +0 -1
- package/ddd-core/interfaces/ddd.options.d.ts +0 -7
- package/ddd-core/interfaces/ddd.options.js.map +0 -1
- package/ddd-core/interfaces/index.d.ts +0 -4
- package/ddd-core/interfaces/index.js.map +0 -1
- package/ddd-core/interfaces/message-source.interface.d.ts +0 -5
- package/ddd-core/interfaces/message-source.interface.js +0 -3
- package/ddd-core/interfaces/message-source.interface.js.map +0 -1
- package/ddd-core/interfaces/saga.interface.d.ts +0 -4
- package/ddd-core/interfaces/saga.interface.js.map +0 -1
- package/ddd-core/interfaces/tracking.interface.js +0 -3
- package/ddd-core/interfaces/tracking.interface.js.map +0 -1
- package/ddd-decorators/command-handler.decorator.d.ts +0 -3
- package/ddd-decorators/command-handler.decorator.js +0 -16
- package/ddd-decorators/command-handler.decorator.js.map +0 -1
- package/ddd-decorators/constants.d.ts +0 -5
- package/ddd-decorators/constants.js +0 -9
- package/ddd-decorators/constants.js.map +0 -1
- package/ddd-decorators/events-handler.decorator.d.ts +0 -3
- package/ddd-decorators/events-handler.decorator.js +0 -18
- package/ddd-decorators/events-handler.decorator.js.map +0 -1
- package/ddd-decorators/index.d.ts +0 -6
- package/ddd-decorators/index.js +0 -23
- package/ddd-decorators/index.js.map +0 -1
- package/ddd-decorators/reflect-command.helper.d.ts +0 -6
- package/ddd-decorators/reflect-command.helper.js +0 -25
- package/ddd-decorators/reflect-command.helper.js.map +0 -1
- package/ddd-decorators/reflect-event.helper.d.ts +0 -7
- package/ddd-decorators/reflect-event.helper.js +0 -18
- package/ddd-decorators/reflect-event.helper.js.map +0 -1
- package/ddd-decorators/saga.decorator.d.ts +0 -2
- package/ddd-decorators/saga.decorator.js +0 -13
- package/ddd-decorators/saga.decorator.js.map +0 -1
- package/ddd-events/impl/default-event-publisher.d.ts +0 -9
- package/ddd-events/impl/default-event-publisher.js +0 -16
- package/ddd-events/impl/default-event-publisher.js.map +0 -1
- package/ddd-events/impl/domain-event-bus.d.ts +0 -32
- package/ddd-events/impl/domain-event-bus.js +0 -140
- package/ddd-events/impl/domain-event-bus.js.map +0 -1
- package/ddd-events/impl/domain-event-cli.registry.d.ts +0 -6
- package/ddd-events/impl/domain-event-cli.registry.js +0 -18
- package/ddd-events/impl/domain-event-cli.registry.js.map +0 -1
- package/ddd-events/impl/domain-event-collection.d.ts +0 -11
- package/ddd-events/impl/domain-event-collection.js +0 -33
- package/ddd-events/impl/domain-event-collection.js.map +0 -1
- package/ddd-events/impl/domain-event-publisher.d.ts +0 -12
- package/ddd-events/impl/domain-event-publisher.js +0 -48
- package/ddd-events/impl/domain-event-publisher.js.map +0 -1
- package/ddd-events/impl/domain-event-types.d.ts +0 -3
- package/ddd-events/impl/domain-event-types.js +0 -3
- package/ddd-events/impl/domain-event-types.js.map +0 -1
- package/ddd-events/impl/domain-event.d.ts +0 -19
- package/ddd-events/impl/domain-event.deserializer.d.ts +0 -8
- package/ddd-events/impl/domain-event.deserializer.js +0 -31
- package/ddd-events/impl/domain-event.deserializer.js.map +0 -1
- package/ddd-events/impl/domain-event.js +0 -29
- package/ddd-events/impl/domain-event.js.map +0 -1
- package/ddd-events/impl/domain-event.serializer.d.ts +0 -6
- package/ddd-events/impl/domain-event.serializer.js +0 -45
- package/ddd-events/impl/domain-event.serializer.js.map +0 -1
- package/ddd-events/impl/index.d.ts +0 -8
- package/ddd-events/impl/index.js.map +0 -1
- package/ddd-events/index.js.map +0 -1
- package/ddd-events/interfaces/domain-event-bus.interface.d.ts +0 -5
- package/ddd-events/interfaces/domain-event-bus.interface.js +0 -3
- package/ddd-events/interfaces/domain-event-bus.interface.js.map +0 -1
- package/ddd-events/interfaces/domain-event-handler.interface.d.ts +0 -4
- package/ddd-events/interfaces/domain-event-handler.interface.js +0 -3
- package/ddd-events/interfaces/domain-event-handler.interface.js.map +0 -1
- package/ddd-events/interfaces/domain-event-metadata.interface.d.ts +0 -7
- package/ddd-events/interfaces/domain-event-metadata.interface.js +0 -3
- package/ddd-events/interfaces/domain-event-metadata.interface.js.map +0 -1
- package/ddd-events/interfaces/domain-event-publisher.interface.d.ts +0 -5
- package/ddd-events/interfaces/domain-event-publisher.interface.js +0 -3
- package/ddd-events/interfaces/domain-event-publisher.interface.js.map +0 -1
- package/ddd-events/interfaces/domain-event-serializable.interface.d.ts +0 -11
- package/ddd-events/interfaces/domain-event-serializable.interface.js +0 -3
- package/ddd-events/interfaces/domain-event-serializable.interface.js.map +0 -1
- package/ddd-events/interfaces/domain-event.interface.d.ts +0 -2
- package/ddd-events/interfaces/domain-event.interface.js +0 -3
- package/ddd-events/interfaces/domain-event.interface.js.map +0 -1
- package/ddd-events/interfaces/index.d.ts +0 -6
- package/ddd-events/interfaces/index.js +0 -23
- package/ddd-events/interfaces/index.js.map +0 -1
- package/ddd-exceptions/constants.d.ts +0 -14
- package/ddd-exceptions/constants.js +0 -18
- package/ddd-exceptions/constants.js.map +0 -1
- package/ddd-exceptions/impl/arguments-exception.d.ts +0 -10
- package/ddd-exceptions/impl/arguments-exception.js +0 -27
- package/ddd-exceptions/impl/arguments-exception.js.map +0 -1
- package/ddd-exceptions/impl/broken-rules.exeption.d.ts +0 -6
- package/ddd-exceptions/impl/broken-rules.exeption.js +0 -14
- package/ddd-exceptions/impl/broken-rules.exeption.js.map +0 -1
- package/ddd-exceptions/impl/command-exception.d.ts +0 -7
- package/ddd-exceptions/impl/command-exception.js +0 -20
- package/ddd-exceptions/impl/command-exception.js.map +0 -1
- package/ddd-exceptions/impl/common.exception.d.ts +0 -14
- package/ddd-exceptions/impl/common.exception.js +0 -29
- package/ddd-exceptions/impl/common.exception.js.map +0 -1
- package/ddd-exceptions/impl/domain-bus.exception.d.ts +0 -7
- package/ddd-exceptions/impl/domain-bus.exception.js +0 -20
- package/ddd-exceptions/impl/domain-bus.exception.js.map +0 -1
- package/ddd-exceptions/impl/domain-publisher.exception.d.ts +0 -9
- package/ddd-exceptions/impl/domain-publisher.exception.js +0 -13
- package/ddd-exceptions/impl/domain-publisher.exception.js.map +0 -1
- package/ddd-exceptions/impl/domain-unhandled-bus.exeption.d.ts +0 -16
- package/ddd-exceptions/impl/domain-unhandled-bus.exeption.js +0 -45
- package/ddd-exceptions/impl/domain-unhandled-bus.exeption.js.map +0 -1
- package/ddd-exceptions/impl/index.d.ts +0 -8
- package/ddd-exceptions/impl/index.js +0 -25
- package/ddd-exceptions/impl/index.js.map +0 -1
- package/ddd-exceptions/impl/sagas.exception.d.ts +0 -4
- package/ddd-exceptions/impl/sagas.exception.js +0 -13
- package/ddd-exceptions/impl/sagas.exception.js.map +0 -1
- package/ddd-exceptions/index.d.ts +0 -3
- package/ddd-exceptions/index.js +0 -20
- package/ddd-exceptions/index.js.map +0 -1
- package/ddd-exceptions/interfaces/exception.base.d.ts +0 -17
- package/ddd-exceptions/interfaces/exception.base.js +0 -24
- package/ddd-exceptions/interfaces/exception.base.js.map +0 -1
- package/ddd-exceptions/interfaces/index.d.ts +0 -3
- package/ddd-exceptions/interfaces/index.js +0 -20
- package/ddd-exceptions/interfaces/index.js.map +0 -1
- package/ddd-exceptions/interfaces/unhandled-exception-info.interface.d.ts +0 -6
- package/ddd-exceptions/interfaces/unhandled-exception-info.interface.js +0 -3
- package/ddd-exceptions/interfaces/unhandled-exception-info.interface.js.map +0 -1
- package/ddd-exceptions/interfaces/unhandled-exception-publisher.interface.d.ts +0 -6
- package/ddd-exceptions/interfaces/unhandled-exception-publisher.interface.js +0 -3
- package/ddd-exceptions/interfaces/unhandled-exception-publisher.interface.js.map +0 -1
- package/ddd-helpers/datetime.helper.js.map +0 -1
- package/ddd-helpers/domain-object.helper.d.ts +0 -18
- package/ddd-helpers/domain-object.helper.js.map +0 -1
- package/ddd-helpers/index.js.map +0 -1
- package/ddd-ports/index.d.ts +0 -1
- package/ddd-ports/index.js.map +0 -1
- package/ddd-ports/interfaces/domain-repository-read.interface.d.ts +0 -6
- package/ddd-ports/interfaces/domain-repository-read.interface.js +0 -3
- package/ddd-ports/interfaces/domain-repository-read.interface.js.map +0 -1
- package/ddd-ports/interfaces/domain-repository-write.interface.js +0 -3
- package/ddd-ports/interfaces/domain-repository-write.interface.js.map +0 -1
- package/ddd-ports/interfaces/index.d.ts +0 -2
- package/ddd-ports/interfaces/index.js +0 -19
- package/ddd-ports/interfaces/index.js.map +0 -1
- package/ddd-validators/impl/domain-abstract.validator.d.ts +0 -5
- package/ddd-validators/impl/domain-abstract.validator.js +0 -34
- package/ddd-validators/impl/domain-abstract.validator.js.map +0 -1
- package/ddd-validators/impl/domain-entity.validator.d.ts +0 -5
- package/ddd-validators/impl/domain-entity.validator.js +0 -12
- package/ddd-validators/impl/domain-entity.validator.js.map +0 -1
- package/ddd-validators/impl/domain-value-object.validator.d.ts +0 -11
- package/ddd-validators/impl/domain-value-object.validator.js +0 -41
- package/ddd-validators/impl/domain-value-object.validator.js.map +0 -1
- package/ddd-validators/impl/index.d.ts +0 -3
- package/ddd-validators/impl/index.js +0 -20
- package/ddd-validators/impl/index.js.map +0 -1
- package/ddd-validators/index.d.ts +0 -1
- package/ddd-validators/index.js.map +0 -1
- package/ddd-valueobjects/domain-audit.valueobject.d.ts +0 -21
- package/ddd-valueobjects/domain-audit.valueobject.js +0 -63
- package/ddd-valueobjects/domain-audit.valueobject.js.map +0 -1
- package/ddd-valueobjects/domain-date.valueobject.d.ts +0 -6
- package/ddd-valueobjects/domain-date.valueobject.js +0 -20
- package/ddd-valueobjects/domain-date.valueobject.js.map +0 -1
- package/ddd-valueobjects/domain-enum-base.valueobject.d.ts +0 -5
- package/ddd-valueobjects/domain-enum-base.valueobject.js +0 -11
- package/ddd-valueobjects/domain-enum-base.valueobject.js.map +0 -1
- package/ddd-valueobjects/domain-number-base.valueobject.d.ts +0 -6
- package/ddd-valueobjects/domain-number-base.valueobject.js +0 -22
- package/ddd-valueobjects/domain-number-base.valueobject.js.map +0 -1
- package/ddd-valueobjects/domain-string-base.valueobject.d.ts +0 -6
- package/ddd-valueobjects/domain-string-base.valueobject.js +0 -22
- package/ddd-valueobjects/domain-string-base.valueobject.js.map +0 -1
- package/ddd-valueobjects/domain-uid.valueobject.d.ts +0 -7
- package/ddd-valueobjects/domain-uid.valueobject.js +0 -29
- package/ddd-valueobjects/domain-uid.valueobject.js.map +0 -1
- package/ddd-valueobjects/index.d.ts +0 -6
- package/ddd-valueobjects/index.js +0 -23
- package/ddd-valueobjects/index.js.map +0 -1
- package/ddd.module.d.ts +0 -11
- package/ddd.module.js.map +0 -1
- package/ddd.service.d.ts +0 -14
- package/ddd.service.js.map +0 -1
- package/index.d.ts +0 -14
- package/index.js +0 -31
- package/index.js.map +0 -1
- package/tsconfig.lib.tsbuildinfo +0 -1
- /package/{ddd-validators → dist/core/business-rules}/index.js +0 -0
- /package/{ddd-commands → dist/core/tracking-state}/index.js +0 -0
- /package/{ddd-helpers → dist/helpers}/index.js +0 -0
package/dist/enum.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DddEnum = void 0;
|
|
4
|
+
const domain_exception_1 = require("./exceptions/domain.exception");
|
|
5
|
+
class DddEnum {
|
|
6
|
+
constructor(id, name) {
|
|
7
|
+
this.id = id;
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.validateId(id);
|
|
10
|
+
this.validateName(name);
|
|
11
|
+
}
|
|
12
|
+
validateId(id) {
|
|
13
|
+
if (typeof id !== 'number' || !Number.isInteger(id)) {
|
|
14
|
+
throw new Error('Enum id must be an integer');
|
|
15
|
+
}
|
|
16
|
+
if (id < 0) {
|
|
17
|
+
throw new Error('Enum id must be non-negative');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
validateName(name) {
|
|
21
|
+
if (typeof name !== 'string' || name.trim().length === 0) {
|
|
22
|
+
throw new Error('Enum name must be a non-empty string');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
return this.name;
|
|
27
|
+
}
|
|
28
|
+
static getAll() {
|
|
29
|
+
const constructor = this;
|
|
30
|
+
if (DddEnum._cache.has(constructor)) {
|
|
31
|
+
return DddEnum._cache.get(constructor);
|
|
32
|
+
}
|
|
33
|
+
const values = Object.getOwnPropertyNames(constructor)
|
|
34
|
+
.map((name) => constructor[name])
|
|
35
|
+
.filter((value) => value instanceof constructor);
|
|
36
|
+
DddEnum._cache.set(constructor, values);
|
|
37
|
+
return values;
|
|
38
|
+
}
|
|
39
|
+
equals(other) {
|
|
40
|
+
if (!(other instanceof DddEnum)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const typeMatches = Object.getPrototypeOf(this) === Object.getPrototypeOf(other);
|
|
44
|
+
const valueMatches = this.id === other.id;
|
|
45
|
+
return typeMatches && valueMatches;
|
|
46
|
+
}
|
|
47
|
+
static absoluteDifference(firstValue, secondValue) {
|
|
48
|
+
if (!firstValue) {
|
|
49
|
+
throw new domain_exception_1.ArgumentNullException('firstValue');
|
|
50
|
+
}
|
|
51
|
+
if (!secondValue) {
|
|
52
|
+
throw new domain_exception_1.ArgumentNullException('secondValue');
|
|
53
|
+
}
|
|
54
|
+
return Math.abs(firstValue.id - secondValue.id);
|
|
55
|
+
}
|
|
56
|
+
static fromValue(value) {
|
|
57
|
+
if (typeof value !== 'number') {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const allItems = this.getAll();
|
|
61
|
+
return allItems.find((item) => item.id === value);
|
|
62
|
+
}
|
|
63
|
+
static fromName(name) {
|
|
64
|
+
if (typeof name !== 'string' || name.trim().length === 0) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const allItems = this.getAll();
|
|
68
|
+
return allItems.find((item) => item.name === name);
|
|
69
|
+
}
|
|
70
|
+
static fromNameIgnoreCase(name) {
|
|
71
|
+
if (typeof name !== 'string' || name.trim().length === 0) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const allItems = this.getAll();
|
|
75
|
+
const lowerName = name.toLowerCase();
|
|
76
|
+
return allItems.find((item) => item.name.toLowerCase() === lowerName);
|
|
77
|
+
}
|
|
78
|
+
static fromDisplayName(displayName) {
|
|
79
|
+
return this.fromName(displayName);
|
|
80
|
+
}
|
|
81
|
+
compareTo(other) {
|
|
82
|
+
if (!other) {
|
|
83
|
+
throw new domain_exception_1.ArgumentNullException('other');
|
|
84
|
+
}
|
|
85
|
+
return this.id - other.id;
|
|
86
|
+
}
|
|
87
|
+
isLessThan(other) {
|
|
88
|
+
return this.compareTo(other) < 0;
|
|
89
|
+
}
|
|
90
|
+
isLessThanOrEqual(other) {
|
|
91
|
+
return this.compareTo(other) <= 0;
|
|
92
|
+
}
|
|
93
|
+
isGreaterThan(other) {
|
|
94
|
+
return this.compareTo(other) > 0;
|
|
95
|
+
}
|
|
96
|
+
isGreaterThanOrEqual(other) {
|
|
97
|
+
return this.compareTo(other) >= 0;
|
|
98
|
+
}
|
|
99
|
+
static isDefined(value) {
|
|
100
|
+
return this.fromValue(value) !== undefined;
|
|
101
|
+
}
|
|
102
|
+
static getMinValue() {
|
|
103
|
+
const allItems = this.getAll();
|
|
104
|
+
if (allItems.length === 0)
|
|
105
|
+
return undefined;
|
|
106
|
+
return allItems.reduce((min, item) => (item.id < min.id ? item : min));
|
|
107
|
+
}
|
|
108
|
+
static getMaxValue() {
|
|
109
|
+
const allItems = this.getAll();
|
|
110
|
+
if (allItems.length === 0)
|
|
111
|
+
return undefined;
|
|
112
|
+
return allItems.reduce((max, item) => (item.id > max.id ? item : max));
|
|
113
|
+
}
|
|
114
|
+
isBetween(min, max) {
|
|
115
|
+
return this.isGreaterThanOrEqual(min) && this.isLessThanOrEqual(max);
|
|
116
|
+
}
|
|
117
|
+
static areEqual(left, right) {
|
|
118
|
+
if (left === null || left === undefined) {
|
|
119
|
+
return right === null || right === undefined;
|
|
120
|
+
}
|
|
121
|
+
return left.equals(right);
|
|
122
|
+
}
|
|
123
|
+
static areNotEqual(left, right) {
|
|
124
|
+
return !this.areEqual(left, right);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.DddEnum = DddEnum;
|
|
128
|
+
DddEnum._cache = new Map();
|
|
129
|
+
//# sourceMappingURL=enum.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare abstract class DomainException extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class ArgumentNullException extends DomainException {
|
|
5
|
+
constructor(parameterName: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class InvalidOperationException extends DomainException {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class InvalidStateTransitionException extends DomainException {
|
|
11
|
+
constructor(fromState: string, toState: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class NoTransitionsDefinedException extends DomainException {
|
|
14
|
+
constructor(stateName: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class InvalidFormatException extends DomainException {
|
|
17
|
+
constructor(parameterName: string, expectedFormat: string, value?: string);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=domain.exception.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidFormatException = exports.NoTransitionsDefinedException = exports.InvalidStateTransitionException = exports.InvalidOperationException = exports.ArgumentNullException = exports.DomainException = void 0;
|
|
4
|
+
class DomainException extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = this.constructor.name;
|
|
8
|
+
Error.captureStackTrace(this, this.constructor);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.DomainException = DomainException;
|
|
12
|
+
class ArgumentNullException extends DomainException {
|
|
13
|
+
constructor(parameterName) {
|
|
14
|
+
super(`${parameterName} cannot be null or undefined`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ArgumentNullException = ArgumentNullException;
|
|
18
|
+
class InvalidOperationException extends DomainException {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.InvalidOperationException = InvalidOperationException;
|
|
24
|
+
class InvalidStateTransitionException extends DomainException {
|
|
25
|
+
constructor(fromState, toState) {
|
|
26
|
+
super(`Invalid state transition from '${fromState}' to '${toState}'. ` +
|
|
27
|
+
`This transition is not defined in the valid transitions map.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.InvalidStateTransitionException = InvalidStateTransitionException;
|
|
31
|
+
class NoTransitionsDefinedException extends DomainException {
|
|
32
|
+
constructor(stateName) {
|
|
33
|
+
super(`No transitions defined for state '${stateName}'. ` +
|
|
34
|
+
`Define transitions first using defineTransitions().`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.NoTransitionsDefinedException = NoTransitionsDefinedException;
|
|
38
|
+
class InvalidFormatException extends DomainException {
|
|
39
|
+
constructor(parameterName, expectedFormat, value) {
|
|
40
|
+
const valueInfo = value ? ` Provided value: '${value}'` : '';
|
|
41
|
+
super(`${parameterName} has an invalid format. Expected: ${expectedFormat}.${valueInfo}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.InvalidFormatException = InvalidFormatException;
|
|
45
|
+
//# sourceMappingURL=domain.exception.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
2
|
+
import { Module } from '@nestjs/core/injector/module';
|
|
3
|
+
import { DddAggregateRoot } from '../aggregate-root';
|
|
4
|
+
import { IDddPrimitive, Primitives } from '../core';
|
|
5
|
+
import { Type } from '../types';
|
|
6
|
+
export declare class DddObjectHelper {
|
|
7
|
+
static isEntity(obj: unknown): obj is DddAggregateRoot<any, any>;
|
|
8
|
+
static convertToPlainObject(item: any): any;
|
|
9
|
+
static isDomainEntity(entity: unknown): entity is DddAggregateRoot<any, any>;
|
|
10
|
+
static isDomainPrimitive<T>(obj: unknown): obj is IDddPrimitive<T & (Primitives | Date)>;
|
|
11
|
+
static convertPropsToObject(props: any): any;
|
|
12
|
+
static flatMap<T>(options: {
|
|
13
|
+
modules: Module[];
|
|
14
|
+
callback: (instance: InstanceWrapper) => Type<any> | undefined;
|
|
15
|
+
}): Type<T>[];
|
|
16
|
+
static filterProvider(wrapper: InstanceWrapper, metadataKey: string): Type<any> | undefined;
|
|
17
|
+
static extractMetadata(instance: Record<string, any>, metadataKey: string): Type<any>;
|
|
18
|
+
static getEventName(event: any): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=domain-object.helper.d.ts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
class
|
|
3
|
+
exports.DddObjectHelper = void 0;
|
|
4
|
+
const aggregate_root_1 = require("../aggregate-root");
|
|
5
|
+
const core_1 = require("../core");
|
|
6
|
+
class DddObjectHelper {
|
|
7
7
|
static isEntity(obj) {
|
|
8
|
-
return obj instanceof
|
|
8
|
+
return obj instanceof aggregate_root_1.DddAggregateRoot;
|
|
9
9
|
}
|
|
10
10
|
static convertToPlainObject(item) {
|
|
11
|
-
if (
|
|
12
|
-
return item.unpack();
|
|
11
|
+
if (core_1.ValueObjectValidator.isValueObject(item)) {
|
|
12
|
+
return item.getValue ? item.getValue() : item.unpack?.() || item;
|
|
13
13
|
}
|
|
14
14
|
if (this.isEntity(item)) {
|
|
15
15
|
return item.toObject();
|
|
@@ -17,12 +17,12 @@ class DomainObjectHelper {
|
|
|
17
17
|
return item;
|
|
18
18
|
}
|
|
19
19
|
static isDomainEntity(entity) {
|
|
20
|
-
return entity instanceof
|
|
20
|
+
return entity instanceof aggregate_root_1.DddAggregateRoot;
|
|
21
21
|
}
|
|
22
22
|
static isDomainPrimitive(obj) {
|
|
23
|
-
if (!obj)
|
|
23
|
+
if (!obj || typeof obj !== 'object')
|
|
24
24
|
return false;
|
|
25
|
-
return Object.
|
|
25
|
+
return Object.hasOwn(obj, 'value');
|
|
26
26
|
}
|
|
27
27
|
static convertPropsToObject(props) {
|
|
28
28
|
if (!props)
|
|
@@ -40,10 +40,9 @@ class DomainObjectHelper {
|
|
|
40
40
|
}
|
|
41
41
|
return propsCopy;
|
|
42
42
|
}
|
|
43
|
-
static flatMap(
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
.reduce((a, b) => a.concat(b), []);
|
|
43
|
+
static flatMap(options) {
|
|
44
|
+
const { modules, callback } = options;
|
|
45
|
+
const items = modules.flatMap((module) => [...module.providers.values()].map(callback));
|
|
47
46
|
return items.filter((element) => !!element);
|
|
48
47
|
}
|
|
49
48
|
static filterProvider(wrapper, metadataKey) {
|
|
@@ -60,14 +59,10 @@ class DomainObjectHelper {
|
|
|
60
59
|
const metadata = Reflect.getMetadata(metadataKey, instance.constructor);
|
|
61
60
|
return metadata ? instance.constructor : undefined;
|
|
62
61
|
}
|
|
63
|
-
static getEventHandler(event) {
|
|
64
|
-
const handler = `on${this.getEventName(event)}`;
|
|
65
|
-
return this[handler];
|
|
66
|
-
}
|
|
67
62
|
static getEventName(event) {
|
|
68
63
|
const { constructor } = Object.getPrototypeOf(event);
|
|
69
64
|
return constructor.name;
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
|
-
exports.
|
|
67
|
+
exports.DddObjectHelper = DddObjectHelper;
|
|
73
68
|
//# sourceMappingURL=domain-object.helper.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './enum';
|
|
3
|
+
export * from './exceptions/domain.exception';
|
|
4
|
+
export * from './valueobject';
|
|
5
|
+
export * from './validator-rule.manager';
|
|
6
|
+
export * from './broken-rules.manager';
|
|
7
|
+
export * from './tracking-state-manager';
|
|
8
|
+
export * from './state-transition.manager';
|
|
9
|
+
export * from './domain-event';
|
|
10
|
+
export * from './aggregate-root';
|
|
11
|
+
export * from './helpers';
|
|
12
|
+
export * from './valueobjects';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -14,12 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./core"), exports);
|
|
18
|
+
__exportStar(require("./enum"), exports);
|
|
19
|
+
__exportStar(require("./exceptions/domain.exception"), exports);
|
|
20
|
+
__exportStar(require("./valueobject"), exports);
|
|
21
|
+
__exportStar(require("./validator-rule.manager"), exports);
|
|
22
|
+
__exportStar(require("./broken-rules.manager"), exports);
|
|
23
|
+
__exportStar(require("./tracking-state-manager"), exports);
|
|
24
|
+
__exportStar(require("./state-transition.manager"), exports);
|
|
19
25
|
__exportStar(require("./domain-event"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./
|
|
23
|
-
__exportStar(require("./domain-event.serializer"), exports);
|
|
24
|
-
__exportStar(require("./domain-event-cli.registry"), exports);
|
|
26
|
+
__exportStar(require("./aggregate-root"), exports);
|
|
27
|
+
__exportStar(require("./helpers"), exports);
|
|
28
|
+
__exportStar(require("./valueobjects"), exports);
|
|
25
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type StateEqualityComparator<TState> = (state1: TState, state2: TState) => boolean;
|
|
2
|
+
export declare class StateTransitionManager<TState extends object> {
|
|
3
|
+
private readonly _validTransitions;
|
|
4
|
+
private readonly _stateComparator;
|
|
5
|
+
constructor(stateComparator?: StateEqualityComparator<TState>);
|
|
6
|
+
private getStateName;
|
|
7
|
+
private findState;
|
|
8
|
+
defineTransitions(transitions: Map<TState, TState[]>): void;
|
|
9
|
+
canTransitionTo(currentState: TState, newState: TState): boolean;
|
|
10
|
+
getValidTransitions(state: TState): readonly TState[];
|
|
11
|
+
hasTransitions(): boolean;
|
|
12
|
+
hasTransitionsDefined(state: TState): boolean;
|
|
13
|
+
getAllStates(): readonly TState[];
|
|
14
|
+
getTransitionGraph(): Record<string, string[]>;
|
|
15
|
+
validateTransitionGraph(): {
|
|
16
|
+
isValid: boolean;
|
|
17
|
+
warnings: string[];
|
|
18
|
+
orphanedStates: TState[];
|
|
19
|
+
};
|
|
20
|
+
clear(): void;
|
|
21
|
+
validateTransition(currentState: TState, newState: TState): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=state-transition.manager.d.ts.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StateTransitionManager = void 0;
|
|
4
|
+
const domain_exception_1 = require("./exceptions/domain.exception");
|
|
5
|
+
class StateTransitionManager {
|
|
6
|
+
constructor(stateComparator) {
|
|
7
|
+
this._validTransitions = new Map();
|
|
8
|
+
this._stateComparator = stateComparator || ((s1, s2) => s1 === s2);
|
|
9
|
+
}
|
|
10
|
+
getStateName(state) {
|
|
11
|
+
if (!state)
|
|
12
|
+
return 'null/undefined';
|
|
13
|
+
if (typeof state.toString === 'function') {
|
|
14
|
+
const str = state.toString();
|
|
15
|
+
if (str !== '[object Object]')
|
|
16
|
+
return str;
|
|
17
|
+
}
|
|
18
|
+
if ('name' in state && typeof state.name === 'string') {
|
|
19
|
+
return state.name;
|
|
20
|
+
}
|
|
21
|
+
if ('value' in state) {
|
|
22
|
+
return String(state.value);
|
|
23
|
+
}
|
|
24
|
+
return state.constructor?.name || 'Unknown State';
|
|
25
|
+
}
|
|
26
|
+
findState(state, states) {
|
|
27
|
+
return states.some((s) => this._stateComparator(state, s));
|
|
28
|
+
}
|
|
29
|
+
defineTransitions(transitions) {
|
|
30
|
+
if (!transitions) {
|
|
31
|
+
throw new domain_exception_1.ArgumentNullException('transitions');
|
|
32
|
+
}
|
|
33
|
+
if (transitions.size === 0) {
|
|
34
|
+
throw new Error('Transitions map cannot be empty. Provide at least one state transition.');
|
|
35
|
+
}
|
|
36
|
+
transitions.forEach((targetStates, sourceState) => {
|
|
37
|
+
if (!sourceState) {
|
|
38
|
+
throw new domain_exception_1.ArgumentNullException('sourceState in transitions map');
|
|
39
|
+
}
|
|
40
|
+
if (!targetStates) {
|
|
41
|
+
throw new domain_exception_1.ArgumentNullException(`targetStates for state '${this.getStateName(sourceState)}'`);
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(targetStates)) {
|
|
44
|
+
throw new Error(`Target states for '${this.getStateName(sourceState)}' must be an array`);
|
|
45
|
+
}
|
|
46
|
+
if (targetStates.length === 0) {
|
|
47
|
+
throw new Error(`Target states array for '${this.getStateName(sourceState)}' cannot be empty. ` +
|
|
48
|
+
`Remove the entry if no transitions are allowed from this state.`);
|
|
49
|
+
}
|
|
50
|
+
targetStates.forEach((targetState, index) => {
|
|
51
|
+
if (!targetState) {
|
|
52
|
+
throw new domain_exception_1.ArgumentNullException(`targetState at index ${index} for source state '${this.getStateName(sourceState)}'`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
this._validTransitions.clear();
|
|
57
|
+
transitions.forEach((value, key) => {
|
|
58
|
+
this._validTransitions.set(key, [...value]);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
canTransitionTo(currentState, newState) {
|
|
62
|
+
if (!currentState) {
|
|
63
|
+
throw new domain_exception_1.ArgumentNullException('currentState');
|
|
64
|
+
}
|
|
65
|
+
if (!newState) {
|
|
66
|
+
throw new domain_exception_1.ArgumentNullException('newState');
|
|
67
|
+
}
|
|
68
|
+
let foundKey;
|
|
69
|
+
for (const key of this._validTransitions.keys()) {
|
|
70
|
+
if (this._stateComparator(key, currentState)) {
|
|
71
|
+
foundKey = key;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!foundKey) {
|
|
76
|
+
throw new domain_exception_1.NoTransitionsDefinedException(this.getStateName(currentState));
|
|
77
|
+
}
|
|
78
|
+
const possibleTransitions = this._validTransitions.get(foundKey);
|
|
79
|
+
return possibleTransitions
|
|
80
|
+
? this.findState(newState, possibleTransitions)
|
|
81
|
+
: false;
|
|
82
|
+
}
|
|
83
|
+
getValidTransitions(state) {
|
|
84
|
+
if (!state) {
|
|
85
|
+
throw new domain_exception_1.ArgumentNullException('state');
|
|
86
|
+
}
|
|
87
|
+
for (const [key, value] of this._validTransitions.entries()) {
|
|
88
|
+
if (this._stateComparator(key, state)) {
|
|
89
|
+
return [...value];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
hasTransitions() {
|
|
95
|
+
return this._validTransitions.size > 0;
|
|
96
|
+
}
|
|
97
|
+
hasTransitionsDefined(state) {
|
|
98
|
+
if (!state) {
|
|
99
|
+
throw new domain_exception_1.ArgumentNullException('state');
|
|
100
|
+
}
|
|
101
|
+
for (const key of this._validTransitions.keys()) {
|
|
102
|
+
if (this._stateComparator(key, state)) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
getAllStates() {
|
|
109
|
+
return Array.from(this._validTransitions.keys());
|
|
110
|
+
}
|
|
111
|
+
getTransitionGraph() {
|
|
112
|
+
const graph = {};
|
|
113
|
+
this._validTransitions.forEach((targets, source) => {
|
|
114
|
+
const sourceName = this.getStateName(source);
|
|
115
|
+
graph[sourceName] = targets.map((t) => this.getStateName(t));
|
|
116
|
+
});
|
|
117
|
+
return graph;
|
|
118
|
+
}
|
|
119
|
+
validateTransitionGraph() {
|
|
120
|
+
const warnings = [];
|
|
121
|
+
const orphanedStates = [];
|
|
122
|
+
const allSourceStates = new Set(this._validTransitions.keys());
|
|
123
|
+
const allTargetStates = new Set();
|
|
124
|
+
this._validTransitions.forEach((targets) => {
|
|
125
|
+
targets.forEach((target) => allTargetStates.add(target));
|
|
126
|
+
});
|
|
127
|
+
allTargetStates.forEach((targetState) => {
|
|
128
|
+
let isOrphaned = true;
|
|
129
|
+
for (const sourceState of allSourceStates) {
|
|
130
|
+
if (this._stateComparator(targetState, sourceState)) {
|
|
131
|
+
isOrphaned = false;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (isOrphaned) {
|
|
136
|
+
orphanedStates.push(targetState);
|
|
137
|
+
warnings.push(`State '${this.getStateName(targetState)}' is a transition target but has no outgoing transitions defined. ` +
|
|
138
|
+
`This might be intentional for terminal states.`);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
isValid: true,
|
|
143
|
+
warnings,
|
|
144
|
+
orphanedStates,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
clear() {
|
|
148
|
+
this._validTransitions.clear();
|
|
149
|
+
}
|
|
150
|
+
validateTransition(currentState, newState) {
|
|
151
|
+
if (!currentState) {
|
|
152
|
+
throw new domain_exception_1.ArgumentNullException('currentState');
|
|
153
|
+
}
|
|
154
|
+
if (!newState) {
|
|
155
|
+
throw new domain_exception_1.ArgumentNullException('newState');
|
|
156
|
+
}
|
|
157
|
+
if (!this.canTransitionTo(currentState, newState)) {
|
|
158
|
+
throw new domain_exception_1.InvalidStateTransitionException(this.getStateName(currentState), this.getStateName(newState));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.StateTransitionManager = StateTransitionManager;
|
|
163
|
+
//# sourceMappingURL=state-transition.manager.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IChangeDetector, IProps, ITrackingProps, ITrackingStateManager, ITrackingStateTransitions } from './core';
|
|
2
|
+
export declare class TrackingStateManager implements ITrackingStateManager, ITrackingStateTransitions {
|
|
3
|
+
private _isNew;
|
|
4
|
+
private _isDirty;
|
|
5
|
+
private _isSelfDeleted;
|
|
6
|
+
private _isDeleted;
|
|
7
|
+
private readonly changeDetector;
|
|
8
|
+
get isNew(): boolean;
|
|
9
|
+
get isDirty(): boolean;
|
|
10
|
+
get isSelfDeleted(): boolean;
|
|
11
|
+
get isDeleted(): boolean;
|
|
12
|
+
constructor(changeDetector?: IChangeDetector);
|
|
13
|
+
get trackingProps(): ITrackingProps;
|
|
14
|
+
getTracking<TProp extends IProps>(props: TProp): this;
|
|
15
|
+
markAsDirty(): void;
|
|
16
|
+
markAsNew(): void;
|
|
17
|
+
markAsSelfDeleted(): void;
|
|
18
|
+
markAsDeleted(): void;
|
|
19
|
+
markAsClean(): void;
|
|
20
|
+
setDirty(value: boolean): void;
|
|
21
|
+
setNew(value: boolean): void;
|
|
22
|
+
setSelfDeleted(value: boolean): void;
|
|
23
|
+
setDeleted(value: boolean): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=tracking-state-manager.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrackingStateManager = void 0;
|
|
4
|
+
const core_1 = require("./core");
|
|
5
|
+
class TrackingStateManager {
|
|
6
|
+
get isNew() {
|
|
7
|
+
return this._isNew;
|
|
8
|
+
}
|
|
9
|
+
get isDirty() {
|
|
10
|
+
return this._isDirty;
|
|
11
|
+
}
|
|
12
|
+
get isSelfDeleted() {
|
|
13
|
+
return this._isSelfDeleted;
|
|
14
|
+
}
|
|
15
|
+
get isDeleted() {
|
|
16
|
+
return this._isDeleted;
|
|
17
|
+
}
|
|
18
|
+
constructor(changeDetector) {
|
|
19
|
+
this._isNew = false;
|
|
20
|
+
this._isDirty = false;
|
|
21
|
+
this._isSelfDeleted = false;
|
|
22
|
+
this._isDeleted = false;
|
|
23
|
+
this.changeDetector = changeDetector || new core_1.NestedPropertyChangeDetector();
|
|
24
|
+
this.markAsClean();
|
|
25
|
+
}
|
|
26
|
+
get trackingProps() {
|
|
27
|
+
return {
|
|
28
|
+
isDirty: this._isDirty,
|
|
29
|
+
isNew: this._isNew,
|
|
30
|
+
isDeleted: this._isDeleted,
|
|
31
|
+
isSelfDeleted: this._isSelfDeleted,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
getTracking(props) {
|
|
35
|
+
this.changeDetector.detectChanges(props, this);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
markAsDirty() {
|
|
39
|
+
core_1.TrackingStateTransition.toDirty(this);
|
|
40
|
+
}
|
|
41
|
+
markAsNew() {
|
|
42
|
+
core_1.TrackingStateTransition.toNew(this);
|
|
43
|
+
}
|
|
44
|
+
markAsSelfDeleted() {
|
|
45
|
+
core_1.TrackingStateTransition.toSelfDeleted(this);
|
|
46
|
+
}
|
|
47
|
+
markAsDeleted() {
|
|
48
|
+
core_1.TrackingStateTransition.toDeleted(this);
|
|
49
|
+
}
|
|
50
|
+
markAsClean() {
|
|
51
|
+
this._isDirty = false;
|
|
52
|
+
this._isNew = false;
|
|
53
|
+
this._isSelfDeleted = false;
|
|
54
|
+
this._isDeleted = false;
|
|
55
|
+
}
|
|
56
|
+
setDirty(value) {
|
|
57
|
+
this._isDirty = value;
|
|
58
|
+
}
|
|
59
|
+
setNew(value) {
|
|
60
|
+
this._isNew = value;
|
|
61
|
+
}
|
|
62
|
+
setSelfDeleted(value) {
|
|
63
|
+
this._isSelfDeleted = value;
|
|
64
|
+
}
|
|
65
|
+
setDeleted(value) {
|
|
66
|
+
this._isDeleted = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.TrackingStateManager = TrackingStateManager;
|
|
70
|
+
//# sourceMappingURL=tracking-state-manager.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BrokenRule, ClassType, IRuleValidator } from './core';
|
|
2
|
+
export declare class ValidatorRuleManager<TValidator extends IRuleValidator> {
|
|
3
|
+
private readonly _validators;
|
|
4
|
+
add(rule: TValidator): void;
|
|
5
|
+
addRange(rules: TValidator[]): void;
|
|
6
|
+
remove(rule: TValidator): void;
|
|
7
|
+
clear(): void;
|
|
8
|
+
getValidators(): ReadonlyArray<TValidator>;
|
|
9
|
+
getBrokenRules(): ReadonlyArray<BrokenRule>;
|
|
10
|
+
isEmpty(): boolean;
|
|
11
|
+
count(): number;
|
|
12
|
+
has(validatorType: ClassType<TValidator>): boolean;
|
|
13
|
+
findByType(validatorType: ClassType<TValidator>): TValidator | undefined;
|
|
14
|
+
private hasValidatorOfType;
|
|
15
|
+
private getBrokenRuleKey;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=validator-rule.manager.d.ts.map
|