@quadnix/octo 0.0.30 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +117 -8
- package/dist/app.type.d.ts +277 -19
- package/dist/app.type.js +80 -9
- package/dist/app.type.js.map +1 -1
- package/dist/decorators/action.decorator.d.ts +10 -6
- package/dist/decorators/action.decorator.js +19 -6
- package/dist/decorators/action.decorator.js.map +1 -1
- package/dist/decorators/anchor.decorator.d.ts +12 -5
- package/dist/decorators/anchor.decorator.js +12 -5
- package/dist/decorators/anchor.decorator.js.map +1 -1
- package/dist/decorators/enable-hook.decorator.d.ts +1 -1
- package/dist/decorators/enable-hook.decorator.js +1 -1
- package/dist/decorators/factory.decorator.d.ts +18 -34
- package/dist/decorators/factory.decorator.js +18 -34
- package/dist/decorators/factory.decorator.js.map +1 -1
- package/dist/decorators/model.decorator.d.ts +4 -6
- package/dist/decorators/model.decorator.js +2 -7
- package/dist/decorators/model.decorator.js.map +1 -1
- package/dist/decorators/module.decorator.d.ts +16 -10
- package/dist/decorators/module.decorator.js +16 -10
- package/dist/decorators/module.decorator.js.map +1 -1
- package/dist/decorators/on-event.decorator.d.ts +7 -2
- package/dist/decorators/on-event.decorator.js +5 -0
- package/dist/decorators/on-event.decorator.js.map +1 -1
- package/dist/decorators/resource.decorator.d.ts +50 -1
- package/dist/decorators/resource.decorator.js +38 -1
- package/dist/decorators/resource.decorator.js.map +1 -1
- package/dist/decorators/validate.decorator.d.ts +15 -1
- package/dist/decorators/validate.decorator.js +15 -1
- package/dist/decorators/validate.decorator.js.map +1 -1
- package/dist/errors/container.error.d.ts +18 -0
- package/dist/errors/container.error.js +18 -0
- package/dist/errors/container.error.js.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/module.error.d.ts +6 -0
- package/dist/errors/module.error.js +6 -0
- package/dist/errors/module.error.js.map +1 -1
- package/dist/errors/node.error.d.ts +56 -0
- package/dist/errors/node.error.js +56 -0
- package/dist/errors/node.error.js.map +1 -1
- package/dist/errors/schema.error.d.ts +14 -1
- package/dist/errors/schema.error.js +11 -1
- package/dist/errors/schema.error.js.map +1 -1
- package/dist/errors/terraform.error.d.ts +20 -0
- package/dist/errors/terraform.error.js +24 -0
- package/dist/errors/terraform.error.js.map +1 -0
- package/dist/errors/transaction.error.d.ts +93 -2
- package/dist/errors/transaction.error.js +83 -0
- package/dist/errors/transaction.error.js.map +1 -1
- package/dist/events/action.event.d.ts +8 -4
- package/dist/events/action.event.js +2 -4
- package/dist/events/action.event.js.map +1 -1
- package/dist/events/command.event.d.ts +43 -0
- package/dist/events/command.event.js +33 -0
- package/dist/events/command.event.js.map +1 -0
- package/dist/events/event.model.d.ts +26 -8
- package/dist/events/event.model.js +15 -7
- package/dist/events/event.model.js.map +1 -1
- package/dist/events/hook/commit.hook.event.d.ts +1 -7
- package/dist/events/hook/commit.hook.event.js +0 -6
- package/dist/events/hook/commit.hook.event.js.map +1 -1
- package/dist/events/hook/hook.event.d.ts +1 -3
- package/dist/events/hook/hook.event.js +0 -2
- package/dist/events/hook/hook.event.js.map +1 -1
- package/dist/events/hook/model.hook.event.d.ts +1 -7
- package/dist/events/hook/model.hook.event.js +0 -6
- package/dist/events/hook/model.hook.event.js.map +1 -1
- package/dist/events/hook/resource.hook.event.d.ts +1 -7
- package/dist/events/hook/resource.hook.event.js +0 -6
- package/dist/events/hook/resource.hook.event.js.map +1 -1
- package/dist/events/index.d.ts +5 -0
- package/dist/events/index.js +5 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/mode-result.event.d.ts +57 -0
- package/dist/events/mode-result.event.js +24 -0
- package/dist/events/mode-result.event.js.map +1 -0
- package/dist/events/mode.event.d.ts +61 -0
- package/dist/events/mode.event.js +32 -0
- package/dist/events/mode.event.js.map +1 -0
- package/dist/events/module.event.d.ts +7 -5
- package/dist/events/module.event.js +3 -4
- package/dist/events/module.event.js.map +1 -1
- package/dist/events/registration.event.d.ts +19 -15
- package/dist/events/registration.event.js +18 -14
- package/dist/events/registration.event.js.map +1 -1
- package/dist/events/serialization.event.d.ts +16 -13
- package/dist/events/serialization.event.js +15 -12
- package/dist/events/serialization.event.js.map +1 -1
- package/dist/events/state.event.d.ts +102 -0
- package/dist/events/state.event.js +69 -0
- package/dist/events/state.event.js.map +1 -0
- package/dist/events/terraform.event.d.ts +78 -0
- package/dist/events/terraform.event.js +55 -0
- package/dist/events/terraform.event.js.map +1 -0
- package/dist/events/transaction.event.d.ts +3 -40
- package/dist/events/transaction.event.js +1 -29
- package/dist/events/transaction.event.js.map +1 -1
- package/dist/functions/container/container.d.ts +54 -13
- package/dist/functions/container/container.js +64 -19
- package/dist/functions/container/container.js.map +1 -1
- package/dist/functions/container/test-container.d.ts +43 -29
- package/dist/functions/container/test-container.js +71 -43
- package/dist/functions/container/test-container.js.map +1 -1
- package/dist/functions/dependency/dependency.d.ts +84 -23
- package/dist/functions/dependency/dependency.js +84 -14
- package/dist/functions/dependency/dependency.js.map +1 -1
- package/dist/functions/diff/aggregate-resource-actions.d.ts +19 -0
- package/dist/functions/diff/aggregate-resource-actions.js +41 -0
- package/dist/functions/diff/aggregate-resource-actions.js.map +1 -0
- package/dist/functions/diff/diff-metadata.d.ts +21 -3
- package/dist/functions/diff/diff-metadata.js +18 -0
- package/dist/functions/diff/diff-metadata.js.map +1 -1
- package/dist/functions/diff/diff.d.ts +68 -7
- package/dist/functions/diff/diff.js +44 -3
- package/dist/functions/diff/diff.js.map +1 -1
- package/dist/functions/hook/commit.hook.d.ts +16 -1
- package/dist/functions/hook/commit.hook.js +21 -6
- package/dist/functions/hook/commit.hook.js.map +1 -1
- package/dist/functions/hook/model-action.hook.d.ts +16 -1
- package/dist/functions/hook/model-action.hook.js +21 -6
- package/dist/functions/hook/model-action.hook.js.map +1 -1
- package/dist/functions/hook/resource-action.hook.d.ts +16 -1
- package/dist/functions/hook/resource-action.hook.js +21 -6
- package/dist/functions/hook/resource-action.hook.js.map +1 -1
- package/dist/functions/node/node-action.abstract.d.ts +23 -2
- package/dist/functions/node/node-action.abstract.js +22 -8
- package/dist/functions/node/node-action.abstract.js.map +1 -1
- package/dist/functions/node/node.abstract.d.ts +56 -5
- package/dist/functions/node/node.abstract.js +106 -22
- package/dist/functions/node/node.abstract.js.map +1 -1
- package/dist/functions/node/node.interface.d.ts +3 -1
- package/dist/functions/schema/schema.d.ts +7 -0
- package/dist/functions/schema/schema.js +10 -1
- package/dist/functions/schema/schema.js.map +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.type.d.ts +5 -0
- package/dist/index.type.js +2 -0
- package/dist/index.type.js.map +1 -0
- package/dist/main.d.ts +245 -14
- package/dist/main.js +377 -72
- package/dist/main.js.map +1 -1
- package/dist/models/account/account.model.d.ts +43 -7
- package/dist/models/account/account.model.js +56 -8
- package/dist/models/account/account.model.js.map +1 -1
- package/dist/models/account/account.schema.d.ts +13 -1
- package/dist/models/account/account.schema.js +12 -0
- package/dist/models/account/account.schema.js.map +1 -1
- package/dist/models/app/app.model.d.ts +13 -8
- package/dist/models/app/app.model.js +17 -32
- package/dist/models/app/app.model.js.map +1 -1
- package/dist/models/app/app.schema.d.ts +6 -0
- package/dist/models/app/app.schema.js +6 -0
- package/dist/models/app/app.schema.js.map +1 -1
- package/dist/models/deployment/deployment.model.d.ts +13 -1
- package/dist/models/deployment/deployment.model.js +16 -4
- package/dist/models/deployment/deployment.model.js.map +1 -1
- package/dist/models/deployment/deployment.schema.d.ts +6 -0
- package/dist/models/deployment/deployment.schema.js +6 -0
- package/dist/models/deployment/deployment.schema.js.map +1 -1
- package/dist/models/environment/environment.model.d.ts +15 -3
- package/dist/models/environment/environment.model.js +22 -10
- package/dist/models/environment/environment.model.js.map +1 -1
- package/dist/models/environment/environment.schema.d.ts +2 -0
- package/dist/models/environment/environment.schema.js +2 -0
- package/dist/models/environment/environment.schema.js.map +1 -1
- package/dist/models/execution/execution.model.d.ts +21 -3
- package/dist/models/execution/execution.model.js +47 -29
- package/dist/models/execution/execution.model.js.map +1 -1
- package/dist/models/execution/execution.schema.d.ts +11 -0
- package/dist/models/execution/execution.schema.js +11 -0
- package/dist/models/execution/execution.schema.js.map +1 -1
- package/dist/models/filesystem/filesystem.model.d.ts +27 -1
- package/dist/models/filesystem/filesystem.model.js +30 -4
- package/dist/models/filesystem/filesystem.model.js.map +1 -1
- package/dist/models/filesystem/filesystem.schema.d.ts +5 -0
- package/dist/models/filesystem/filesystem.schema.js +5 -0
- package/dist/models/filesystem/filesystem.schema.js.map +1 -1
- package/dist/models/image/image.model.d.ts +19 -5
- package/dist/models/image/image.model.js +25 -11
- package/dist/models/image/image.model.js.map +1 -1
- package/dist/models/image/image.schema.d.ts +8 -0
- package/dist/models/image/image.schema.js +8 -0
- package/dist/models/image/image.schema.js.map +1 -1
- package/dist/models/model-action.interface.d.ts +17 -4
- package/dist/models/model.abstract.d.ts +96 -1
- package/dist/models/model.abstract.js +107 -8
- package/dist/models/model.abstract.js.map +1 -1
- package/dist/models/model.interface.d.ts +3 -0
- package/dist/models/pipeline/pipeline.model.d.ts +14 -2
- package/dist/models/pipeline/pipeline.model.js +19 -7
- package/dist/models/pipeline/pipeline.model.js.map +1 -1
- package/dist/models/pipeline/pipeline.schema.d.ts +8 -0
- package/dist/models/pipeline/pipeline.schema.js +8 -0
- package/dist/models/pipeline/pipeline.schema.js.map +1 -1
- package/dist/models/region/region.model.d.ts +16 -1
- package/dist/models/region/region.model.js +19 -4
- package/dist/models/region/region.model.js.map +1 -1
- package/dist/models/region/region.schema.d.ts +6 -0
- package/dist/models/region/region.schema.js +6 -0
- package/dist/models/region/region.schema.js.map +1 -1
- package/dist/models/server/server.model.d.ts +15 -3
- package/dist/models/server/server.model.js +18 -6
- package/dist/models/server/server.model.js.map +1 -1
- package/dist/models/server/server.schema.d.ts +3 -1
- package/dist/models/server/server.schema.js +3 -1
- package/dist/models/server/server.schema.js.map +1 -1
- package/dist/models/service/service.model.d.ts +37 -6
- package/dist/models/service/service.model.js +65 -11
- package/dist/models/service/service.model.js.map +1 -1
- package/dist/models/service/service.schema.d.ts +48 -1
- package/dist/models/service/service.schema.js +56 -1
- package/dist/models/service/service.schema.js.map +1 -1
- package/dist/models/subnet/subnet.model.d.ts +27 -3
- package/dist/models/subnet/subnet.model.js +40 -16
- package/dist/models/subnet/subnet.model.js.map +1 -1
- package/dist/models/subnet/subnet.schema.d.ts +9 -0
- package/dist/models/subnet/subnet.schema.js +9 -0
- package/dist/models/subnet/subnet.schema.js.map +1 -1
- package/dist/modes/apply-transaction.d.ts +23 -0
- package/dist/modes/apply-transaction.js +25 -0
- package/dist/modes/apply-transaction.js.map +1 -0
- package/dist/modes/commit.mode.d.ts +54 -0
- package/dist/modes/commit.mode.js +235 -0
- package/dist/modes/commit.mode.js.map +1 -0
- package/dist/modes/generate.mode.d.ts +30 -0
- package/dist/modes/generate.mode.js +50 -0
- package/dist/modes/generate.mode.js.map +1 -0
- package/dist/modes/run-action.mode.d.ts +30 -0
- package/dist/modes/run-action.mode.js +140 -0
- package/dist/modes/run-action.mode.js.map +1 -0
- package/dist/modes/validate.mode.d.ts +186 -0
- package/dist/modes/validate.mode.js +558 -0
- package/dist/modes/validate.mode.js.map +1 -0
- package/dist/modules/module.abstract.d.ts +51 -0
- package/dist/modules/module.abstract.js +36 -0
- package/dist/modules/module.abstract.js.map +1 -1
- package/dist/modules/module.container.d.ts +43 -1
- package/dist/modules/module.container.js +77 -5
- package/dist/modules/module.container.js.map +1 -1
- package/dist/modules/test-module.container.d.ts +139 -25
- package/dist/modules/test-module.container.js +383 -199
- package/dist/modules/test-module.container.js.map +1 -1
- package/dist/overlays/anchor.abstract.d.ts +32 -1
- package/dist/overlays/anchor.abstract.js +42 -11
- package/dist/overlays/anchor.abstract.js.map +1 -1
- package/dist/overlays/anchor.schema.d.ts +21 -0
- package/dist/overlays/anchor.schema.js +21 -0
- package/dist/overlays/anchor.schema.js.map +1 -1
- package/dist/overlays/overlay-data.repository.d.ts +18 -0
- package/dist/overlays/overlay-data.repository.js +18 -0
- package/dist/overlays/overlay-data.repository.js.map +1 -1
- package/dist/overlays/overlay.abstract.d.ts +56 -1
- package/dist/overlays/overlay.abstract.js +79 -20
- package/dist/overlays/overlay.abstract.js.map +1 -1
- package/dist/overlays/overlay.schema.d.ts +20 -0
- package/dist/overlays/overlay.schema.js +20 -0
- package/dist/overlays/overlay.schema.js.map +1 -1
- package/dist/resources/resource-action.interface.d.ts +29 -3
- package/dist/resources/resource-data.repository.d.ts +63 -1
- package/dist/resources/resource-data.repository.js +94 -4
- package/dist/resources/resource-data.repository.js.map +1 -1
- package/dist/resources/resource.abstract.d.ts +163 -6
- package/dist/resources/resource.abstract.js +223 -59
- package/dist/resources/resource.abstract.js.map +1 -1
- package/dist/resources/resource.interface.d.ts +0 -2
- package/dist/resources/resource.schema.d.ts +39 -1
- package/dist/resources/resource.schema.js +38 -0
- package/dist/resources/resource.schema.js.map +1 -1
- package/dist/resources/terraform-resource.abstract.d.ts +44 -0
- package/dist/resources/terraform-resource.abstract.js +45 -0
- package/dist/resources/terraform-resource.abstract.js.map +1 -0
- package/dist/services/event/event.service.d.ts +32 -5
- package/dist/services/event/event.service.js +58 -16
- package/dist/services/event/event.service.js.map +1 -1
- package/dist/services/input/input.service.d.ts +82 -5
- package/dist/services/input/input.service.js +143 -12
- package/dist/services/input/input.service.js.map +1 -1
- package/dist/services/schema-translation/schema-translation.service.d.ts +9 -0
- package/dist/services/schema-translation/schema-translation.service.js +9 -0
- package/dist/services/schema-translation/schema-translation.service.js.map +1 -1
- package/dist/services/serialization/model/model-serialization.service.d.ts +25 -3
- package/dist/services/serialization/model/model-serialization.service.js +113 -62
- package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
- package/dist/services/serialization/resource/resource-serialization.service.d.ts +36 -6
- package/dist/services/serialization/resource/resource-serialization.service.js +77 -28
- package/dist/services/serialization/resource/resource-serialization.service.js.map +1 -1
- package/dist/services/state-management/local.state-provider.d.ts +67 -4
- package/dist/services/state-management/local.state-provider.js +168 -41
- package/dist/services/state-management/local.state-provider.js.map +1 -1
- package/dist/services/state-management/remote.state-provider.d.ts +216 -0
- package/dist/services/state-management/remote.state-provider.js +645 -0
- package/dist/services/state-management/remote.state-provider.js.map +1 -0
- package/dist/services/state-management/state-management.service.d.ts +195 -17
- package/dist/services/state-management/state-management.service.js +259 -10
- package/dist/services/state-management/state-management.service.js.map +1 -1
- package/dist/services/state-management/state-provider.interface.d.ts +98 -3
- package/dist/services/state-management/state-provider.interface.js +14 -1
- package/dist/services/state-management/state-provider.interface.js.map +1 -1
- package/dist/services/state-management/terraform-state.service.d.ts +99 -0
- package/dist/services/state-management/terraform-state.service.js +197 -0
- package/dist/services/state-management/terraform-state.service.js.map +1 -0
- package/dist/services/state-management/test.state-provider.d.ts +42 -4
- package/dist/services/state-management/test.state-provider.js +77 -25
- package/dist/services/state-management/test.state-provider.js.map +1 -1
- package/dist/services/terraform/terraform.service.d.ts +480 -0
- package/dist/services/terraform/terraform.service.js +1082 -0
- package/dist/services/terraform/terraform.service.js.map +1 -0
- package/dist/services/terraform/terraform.type.d.ts +387 -0
- package/dist/services/terraform/terraform.type.js +579 -0
- package/dist/services/terraform/terraform.type.js.map +1 -0
- package/dist/services/transaction/transaction.service.d.ts +110 -10
- package/dist/services/transaction/transaction.service.js +570 -251
- package/dist/services/transaction/transaction.service.js.map +1 -1
- package/dist/services/validation/validation.service.d.ts +15 -3
- package/dist/services/validation/validation.service.js +12 -0
- package/dist/services/validation/validation.service.js.map +1 -1
- package/dist/utilities/array/array.utility.d.ts +3 -0
- package/dist/utilities/array/array.utility.js +3 -0
- package/dist/utilities/array/array.utility.js.map +1 -1
- package/dist/{functions → utilities}/diff/diff.utility.d.ts +19 -3
- package/dist/{functions → utilities}/diff/diff.utility.js +57 -41
- package/dist/utilities/diff/diff.utility.js.map +1 -0
- package/dist/utilities/file/file.utility.d.ts +16 -2
- package/dist/utilities/file/file.utility.js +23 -61
- package/dist/utilities/file/file.utility.js.map +1 -1
- package/dist/utilities/hcl/hcl.utility.d.ts +128 -0
- package/dist/utilities/hcl/hcl.utility.js +402 -0
- package/dist/utilities/hcl/hcl.utility.js.map +1 -0
- package/dist/utilities/http/http.utility.d.ts +57 -0
- package/dist/utilities/http/http.utility.js +98 -0
- package/dist/utilities/http/http.utility.js.map +1 -0
- package/dist/utilities/node/node.utility.d.ts +3 -0
- package/dist/utilities/node/node.utility.js +3 -0
- package/dist/utilities/node/node.utility.js.map +1 -1
- package/dist/utilities/object/object.utility.d.ts +12 -0
- package/dist/utilities/object/object.utility.js +12 -0
- package/dist/utilities/object/object.utility.js.map +1 -1
- package/dist/utilities/project/project.utility.d.ts +28 -0
- package/dist/utilities/project/project.utility.js +35 -0
- package/dist/utilities/project/project.utility.js.map +1 -0
- package/dist/utilities/string/string.utility.d.ts +41 -0
- package/dist/utilities/string/string.utility.js +65 -0
- package/dist/utilities/string/string.utility.js.map +1 -0
- package/dist/utilities/terraform/terraform.utility.d.ts +276 -0
- package/dist/utilities/terraform/terraform.utility.js +623 -0
- package/dist/utilities/terraform/terraform.utility.js.map +1 -0
- package/dist/utilities/test-helpers/test-classes.d.ts +36 -30
- package/dist/utilities/test-helpers/test-classes.js +38 -39
- package/dist/utilities/test-helpers/test-classes.js.map +1 -1
- package/dist/utilities/test-helpers/test-models.d.ts +8 -1
- package/dist/utilities/test-helpers/test-models.js +37 -12
- package/dist/utilities/test-helpers/test-models.js.map +1 -1
- package/dist/utilities/test-helpers/test-modes.d.ts +315 -0
- package/dist/utilities/test-helpers/test-modes.js +486 -0
- package/dist/utilities/test-helpers/test-modes.js.map +1 -0
- package/dist/utilities/test-helpers/test-modules.d.ts +47 -0
- package/dist/utilities/test-helpers/test-modules.js +85 -0
- package/dist/utilities/test-helpers/test-modules.js.map +1 -0
- package/dist/utilities/test-helpers/test-overlays.d.ts +20 -2
- package/dist/utilities/test-helpers/test-overlays.js +56 -6
- package/dist/utilities/test-helpers/test-overlays.js.map +1 -1
- package/dist/utilities/test-helpers/test-resources.d.ts +23 -3
- package/dist/utilities/test-helpers/test-resources.js +83 -23
- package/dist/utilities/test-helpers/test-resources.js.map +1 -1
- package/dist/utilities/validation/validation.utility.d.ts +24 -0
- package/dist/utilities/validation/validation.utility.js +24 -0
- package/dist/utilities/validation/validation.utility.js.map +1 -1
- package/package.json +12 -6
- package/dist/functions/diff/diff.utility.js.map +0 -1
- package/dist/services/capture/capture.service.d.ts +0 -19
- package/dist/services/capture/capture.service.js +0 -43
- package/dist/services/capture/capture.service.js.map +0 -1
- package/dist/services/state-management/local-encryption.state-provider.d.ts +0 -20
- package/dist/services/state-management/local-encryption.state-provider.js +0 -90
- package/dist/services/state-management/local-encryption.state-provider.js.map +0 -1
- package/dist/utilities/cidr/cidr.utility.d.ts +0 -10
- package/dist/utilities/cidr/cidr.utility.js +0 -51
- package/dist/utilities/cidr/cidr.utility.js.map +0 -1
|
@@ -12,40 +12,46 @@ type TestContainerSubjects = {
|
|
|
12
12
|
};
|
|
13
13
|
type TestContainerOptions = {
|
|
14
14
|
factoryTimeoutInMs?: number;
|
|
15
|
+
force?: boolean;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* An isolated {@link Container} for tests.
|
|
19
|
+
*
|
|
20
|
+
* The Container is a process-wide singleton, which makes it awkward to mock. TestContainer solves
|
|
21
|
+
* that: create one in `beforeEach()` and it takes over the Container for that test, letting you
|
|
22
|
+
* replace any factory with a stub. `reset()` in `afterEach()` puts it back.
|
|
18
23
|
*
|
|
19
24
|
* :::info Info
|
|
20
|
-
* A test framework like Jest
|
|
21
|
-
*
|
|
25
|
+
* A test framework like Jest runs test *files* in parallel across cores, and the `it()` blocks
|
|
26
|
+
* within a file serially. So a TestContainer never leaks into a test running in parallel.
|
|
22
27
|
* :::
|
|
23
28
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* beforeEach(async () => {
|
|
32
|
+
* container = await TestContainer.create({ mocks: [] }, { factoryTimeoutInMs: 500 });
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* afterEach(async () => {
|
|
36
|
+
* await TestContainer.reset();
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
29
39
|
*
|
|
30
40
|
* @group Functions/Container
|
|
31
41
|
*/
|
|
32
42
|
export declare class TestContainer {
|
|
33
43
|
private static originalFactories;
|
|
34
|
-
private static bootstrap;
|
|
35
44
|
/**
|
|
36
|
-
*
|
|
45
|
+
* To take over the Container for one test, replacing the factories you name.
|
|
37
46
|
*
|
|
38
47
|
* @example
|
|
39
48
|
* ```ts
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* }, { factoryTimeoutInMs: 500 });
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
+
* await TestContainer.create({
|
|
50
|
+
* mocks: [
|
|
51
|
+
* { type: MyClass, value: jest.fn() },
|
|
52
|
+
* { metadata: { key: 'value' }, type: AnotherClass, value: new AnotherClass() },
|
|
53
|
+
* ],
|
|
54
|
+
* }, { factoryTimeoutInMs: 500 });
|
|
49
55
|
* ```
|
|
50
56
|
* @param subjects The subjects being mocked.
|
|
51
57
|
* - `mocks` is an array of objects, to override the default factories.
|
|
@@ -54,20 +60,28 @@ export declare class TestContainer {
|
|
|
54
60
|
* - Use `value: T` to provide the mocked value.
|
|
55
61
|
* @param options Options to configure TestContainer.
|
|
56
62
|
* - `factoryTimeoutInMs?: number` is to override the default container timeout.
|
|
63
|
+
* - `force?: boolean` performs a complete container reset.
|
|
57
64
|
*/
|
|
58
65
|
static create(subjects: TestContainerSubjects, options?: TestContainerOptions): Promise<Container>;
|
|
59
66
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```ts
|
|
66
|
-
* afterAll(async () => {
|
|
67
|
-
* await TestContainer.reset();
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
67
|
+
* To destroy every factory in the Container. Because it destroys the whole Container and not only
|
|
68
|
+
* the mocks, it must always be called in your teardown block - otherwise the next test starts
|
|
69
|
+
* against a Container this test left behind.
|
|
70
70
|
*/
|
|
71
71
|
static reset(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Bootstrap the Container with the necessary factories internal to Octo.
|
|
74
|
+
* Between test runs, when the container is reset, many of Octo's internal classes must be reset as well.
|
|
75
|
+
* Since these classes are not exposed outside of Octo, we must bootstrap them.
|
|
76
|
+
*
|
|
77
|
+
* Some factories defined in Octo using `@Factory` must be placed here,
|
|
78
|
+
* the exact criteria being any factory that needs to reset its state.
|
|
79
|
+
*
|
|
80
|
+
* Exceptions:
|
|
81
|
+
* - {@link ModelSerializationService}: We do not want to loose class mapping already instantiated via decorators.
|
|
82
|
+
* - {@link ResourceSerializationService}: We do not want to loose class mapping already instantiated via decorators.
|
|
83
|
+
* - {@link TransactionService}: We do not want to loose action mapping already instantiated via decorators.
|
|
84
|
+
*/
|
|
85
|
+
private static bootstrap;
|
|
72
86
|
}
|
|
73
87
|
export {};
|
|
@@ -1,51 +1,50 @@
|
|
|
1
1
|
import { ModuleContainer } from '../../modules/module.container.js';
|
|
2
2
|
import { OverlayDataRepository } from '../../overlays/overlay-data.repository.js';
|
|
3
3
|
import { ResourceDataRepository, } from '../../resources/resource-data.repository.js';
|
|
4
|
-
import {
|
|
4
|
+
import { EventService } from '../../services/event/event.service.js';
|
|
5
5
|
import { InputService } from '../../services/input/input.service.js';
|
|
6
|
+
import { ModelSerializationService } from '../../services/serialization/model/model-serialization.service.js';
|
|
7
|
+
import { ResourceSerializationService } from '../../services/serialization/resource/resource-serialization.service.js';
|
|
8
|
+
import { TerraformService } from '../../services/terraform/terraform.service.js';
|
|
9
|
+
import { TransactionService } from '../../services/transaction/transaction.service.js';
|
|
6
10
|
import { Container } from './container.js';
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* An isolated {@link Container} for tests.
|
|
13
|
+
*
|
|
14
|
+
* The Container is a process-wide singleton, which makes it awkward to mock. TestContainer solves
|
|
15
|
+
* that: create one in `beforeEach()` and it takes over the Container for that test, letting you
|
|
16
|
+
* replace any factory with a stub. `reset()` in `afterEach()` puts it back.
|
|
9
17
|
*
|
|
10
18
|
* :::info Info
|
|
11
|
-
* A test framework like Jest
|
|
12
|
-
*
|
|
19
|
+
* A test framework like Jest runs test *files* in parallel across cores, and the `it()` blocks
|
|
20
|
+
* within a file serially. So a TestContainer never leaks into a test running in parallel.
|
|
13
21
|
* :::
|
|
14
22
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* beforeEach(async () => {
|
|
26
|
+
* container = await TestContainer.create({ mocks: [] }, { factoryTimeoutInMs: 500 });
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* afterEach(async () => {
|
|
30
|
+
* await TestContainer.reset();
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
20
33
|
*
|
|
21
34
|
* @group Functions/Container
|
|
22
35
|
*/
|
|
23
36
|
export class TestContainer {
|
|
24
|
-
static async bootstrap(container) {
|
|
25
|
-
await container.get(OverlayDataRepository, {
|
|
26
|
-
args: [true, []],
|
|
27
|
-
});
|
|
28
|
-
await container.get(ResourceDataRepository, {
|
|
29
|
-
args: [true, [], [], []],
|
|
30
|
-
});
|
|
31
|
-
await container.get(CaptureService, { args: [true] });
|
|
32
|
-
await container.get(InputService, { args: [true] });
|
|
33
|
-
await container.get(ModuleContainer, { args: [true] });
|
|
34
|
-
}
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* To take over the Container for one test, replacing the factories you name.
|
|
37
39
|
*
|
|
38
40
|
* @example
|
|
39
41
|
* ```ts
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* }, { factoryTimeoutInMs: 500 });
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
42
|
+
* await TestContainer.create({
|
|
43
|
+
* mocks: [
|
|
44
|
+
* { type: MyClass, value: jest.fn() },
|
|
45
|
+
* { metadata: { key: 'value' }, type: AnotherClass, value: new AnotherClass() },
|
|
46
|
+
* ],
|
|
47
|
+
* }, { factoryTimeoutInMs: 500 });
|
|
49
48
|
* ```
|
|
50
49
|
* @param subjects The subjects being mocked.
|
|
51
50
|
* - `mocks` is an array of objects, to override the default factories.
|
|
@@ -54,6 +53,7 @@ export class TestContainer {
|
|
|
54
53
|
* - Use `value: T` to provide the mocked value.
|
|
55
54
|
* @param options Options to configure TestContainer.
|
|
56
55
|
* - `factoryTimeoutInMs?: number` is to override the default container timeout.
|
|
56
|
+
* - `force?: boolean` performs a complete container reset.
|
|
57
57
|
*/
|
|
58
58
|
static async create(subjects, options) {
|
|
59
59
|
if (!TestContainer.originalFactories) {
|
|
@@ -64,31 +64,59 @@ export class TestContainer {
|
|
|
64
64
|
container.setFactories(this.originalFactories);
|
|
65
65
|
// Reset state of eligible factories.
|
|
66
66
|
// A factory is eligible if it has an internal structure and should be reset on every test.
|
|
67
|
-
await this.bootstrap(container);
|
|
67
|
+
await this.bootstrap(container, options?.force ?? false);
|
|
68
68
|
if (options?.factoryTimeoutInMs) {
|
|
69
69
|
container.setFactoryTimeout(options.factoryTimeoutInMs);
|
|
70
70
|
}
|
|
71
71
|
// Override new container with mock factories as instructed.
|
|
72
72
|
for (const mock of subjects.mocks || []) {
|
|
73
|
-
container.
|
|
74
|
-
container.registerValue(mock.type, mock.value, { metadata: mock.metadata });
|
|
73
|
+
container.replaceValue(mock.type, mock.value, { metadata: mock.metadata });
|
|
75
74
|
}
|
|
76
75
|
return container;
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* afterAll(async () => {
|
|
86
|
-
* await TestContainer.reset();
|
|
87
|
-
* });
|
|
88
|
-
* ```
|
|
78
|
+
* To destroy every factory in the Container. Because it destroys the whole Container and not only
|
|
79
|
+
* the mocks, it must always be called in your teardown block - otherwise the next test starts
|
|
80
|
+
* against a Container this test left behind.
|
|
89
81
|
*/
|
|
90
82
|
static async reset() {
|
|
91
83
|
Container.getInstance().reset();
|
|
92
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Bootstrap the Container with the necessary factories internal to Octo.
|
|
87
|
+
* Between test runs, when the container is reset, many of Octo's internal classes must be reset as well.
|
|
88
|
+
* Since these classes are not exposed outside of Octo, we must bootstrap them.
|
|
89
|
+
*
|
|
90
|
+
* Some factories defined in Octo using `@Factory` must be placed here,
|
|
91
|
+
* the exact criteria being any factory that needs to reset its state.
|
|
92
|
+
*
|
|
93
|
+
* Exceptions:
|
|
94
|
+
* - {@link ModelSerializationService}: We do not want to loose class mapping already instantiated via decorators.
|
|
95
|
+
* - {@link ResourceSerializationService}: We do not want to loose class mapping already instantiated via decorators.
|
|
96
|
+
* - {@link TransactionService}: We do not want to loose action mapping already instantiated via decorators.
|
|
97
|
+
*/
|
|
98
|
+
static async bootstrap(container, force = false) {
|
|
99
|
+
const overlayDataRepository = await container.get(OverlayDataRepository, { args: [true, []] });
|
|
100
|
+
const resourceDataRepository = await container.get(ResourceDataRepository, { args: [true, [], [], []] });
|
|
101
|
+
const inputService = await container.get(InputService, { args: [true] });
|
|
102
|
+
const moduleContainer = await container.get(ModuleContainer, {
|
|
103
|
+
args: [true],
|
|
104
|
+
});
|
|
105
|
+
const terraformService = await container.get(TerraformService, {
|
|
106
|
+
args: [{}, true],
|
|
107
|
+
});
|
|
108
|
+
if (force) {
|
|
109
|
+
const eventService = await container.get(EventService);
|
|
110
|
+
const modelSerializationService = new ModelSerializationService(inputService, moduleContainer);
|
|
111
|
+
container.unRegisterFactory(ModelSerializationService);
|
|
112
|
+
container.registerValue(ModelSerializationService, modelSerializationService);
|
|
113
|
+
const resourceSerializationService = new ResourceSerializationService(resourceDataRepository, inputService);
|
|
114
|
+
container.unRegisterFactory(ResourceSerializationService);
|
|
115
|
+
container.registerValue(ResourceSerializationService, resourceSerializationService);
|
|
116
|
+
const transactionService = new TransactionService(eventService, inputService, moduleContainer, overlayDataRepository, resourceDataRepository, resourceSerializationService, terraformService);
|
|
117
|
+
container.unRegisterFactory(TransactionService);
|
|
118
|
+
container.registerValue(TransactionService, transactionService);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
93
121
|
}
|
|
94
122
|
//# sourceMappingURL=test-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-container.js","sourceRoot":"","sources":["../../../src/functions/container/test-container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA+B,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAqC,MAAM,2CAA2C,CAAC;AACrH,OAAO,EACL,sBAAsB,GAEvB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"test-container.js","sourceRoot":"","sources":["../../../src/functions/container/test-container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA+B,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAqC,MAAM,2CAA2C,CAAC;AACrH,OAAO,EACL,sBAAsB,GAEvB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,YAAY,EAA4B,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM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AAS,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;YAC1D,SAAS,CAAC,aAAa,CAAC,4BAA4B,EAAE,4BAA4B,CAAC,CAAC;YAEpF,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,CAC/C,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,CACjB,CAAC;YACF,SAAS,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;YAChD,SAAS,CAAC,aAAa,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import type { UnknownNode } from '../../app.type.js';
|
|
2
2
|
import type { DiffAction } from '../diff/diff.js';
|
|
3
|
-
declare class DependencyBehavior {
|
|
4
|
-
forAction: DiffAction;
|
|
5
|
-
onAction: DiffAction;
|
|
6
|
-
onField: string;
|
|
7
|
-
toField: string;
|
|
8
|
-
constructor(onField: string, onAction: DiffAction, toField: string, forAction: DiffAction);
|
|
9
|
-
}
|
|
10
3
|
/**
|
|
4
|
+
* How two nodes are related. A parent exists before its child, and outlives it.
|
|
5
|
+
*
|
|
11
6
|
* @group Functions/Dependency
|
|
12
7
|
*/
|
|
13
8
|
export declare enum DependencyRelationship {
|
|
@@ -15,47 +10,113 @@ export declare enum DependencyRelationship {
|
|
|
15
10
|
PARENT = "parent"
|
|
16
11
|
}
|
|
17
12
|
/**
|
|
13
|
+
* The serialized form of a {@link Dependency}, as it is written to state. A behavior says that the
|
|
14
|
+
* `forAction` diff of `to`'s `toField` waits for the `onAction` diff of `from`'s `onField`.
|
|
15
|
+
*
|
|
18
16
|
* @group Functions/Dependency
|
|
19
17
|
*/
|
|
20
18
|
export interface IDependency {
|
|
21
19
|
behaviors: {
|
|
22
|
-
forAction:
|
|
23
|
-
onAction:
|
|
24
|
-
onField:
|
|
25
|
-
toField:
|
|
20
|
+
forAction: `${DiffAction}`;
|
|
21
|
+
onAction: `${DiffAction}`;
|
|
22
|
+
onField: string;
|
|
23
|
+
toField: string;
|
|
26
24
|
}[];
|
|
27
25
|
from: string;
|
|
28
26
|
relationship?: {
|
|
29
|
-
onField:
|
|
30
|
-
toField:
|
|
31
|
-
type: DependencyRelationship
|
|
27
|
+
onField: string;
|
|
28
|
+
toField: string;
|
|
29
|
+
type: `${DependencyRelationship}`;
|
|
32
30
|
};
|
|
33
31
|
to: string;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
34
|
+
* The edge between two nodes in Octo's graph.
|
|
35
|
+
*
|
|
36
|
+
* A dependency is directed, and carries two things: an optional parent/child relationship, and a set
|
|
37
|
+
* of *behaviors*. A behavior states an ordering rule - "when this field of `from` is added, the
|
|
38
|
+
* matching action on `to` must have run first" - and it is those rules that let Octo order a
|
|
39
|
+
* transaction correctly instead of guessing.
|
|
40
|
+
*
|
|
41
|
+
* Models create dependencies through `addChild()` and `addRelationship()`; you rarely construct one.
|
|
42
|
+
*
|
|
36
43
|
* @group Functions/Dependency
|
|
44
|
+
*
|
|
45
|
+
* @see Definition of [Dependencies](/docs/fundamentals/dependencies).
|
|
37
46
|
*/
|
|
38
47
|
export declare class Dependency {
|
|
39
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The node this dependency points from.
|
|
50
|
+
*/
|
|
40
51
|
readonly from: UnknownNode;
|
|
41
|
-
|
|
52
|
+
/**
|
|
53
|
+
* The node this dependency points to.
|
|
54
|
+
*/
|
|
42
55
|
readonly to: UnknownNode;
|
|
56
|
+
private readonly behaviors;
|
|
57
|
+
private relationship;
|
|
58
|
+
/**
|
|
59
|
+
* @param from The node this dependency points from.
|
|
60
|
+
* @param to The node this dependency points to.
|
|
61
|
+
*/
|
|
43
62
|
constructor(from: UnknownNode, to: UnknownNode);
|
|
44
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
static unSynth(from: UnknownNode, to: UnknownNode, dependency: IDependency): Dependency;
|
|
67
|
+
/**
|
|
68
|
+
* To declare an ordering rule: when `onAction` happens to `onField` of `from`, then `forAction`
|
|
69
|
+
* on `toField` of `to` must have been applied first. Adding the same behavior twice is a no-op.
|
|
70
|
+
*/
|
|
45
71
|
addBehavior(onField: string, onAction: DiffAction, toField: string, forAction: DiffAction): void;
|
|
72
|
+
/**
|
|
73
|
+
* To mark `to` as the child of `from`.
|
|
74
|
+
*
|
|
75
|
+
* @throws {@link DependencyError} If this dependency already has a relationship.
|
|
76
|
+
*/
|
|
46
77
|
addChildRelationship(onField: string, toField: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* To mark `to` as the parent of `from`.
|
|
80
|
+
*
|
|
81
|
+
* @throws {@link DependencyError} If this dependency already has a relationship.
|
|
82
|
+
*/
|
|
47
83
|
addParentRelationship(onField: string, toField: string): void;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
isParentRelationship(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The relationship between the two nodes, if one was declared.
|
|
86
|
+
*/
|
|
52
87
|
getRelationship(): {
|
|
53
88
|
onField: string;
|
|
54
89
|
toField: string;
|
|
55
90
|
type: DependencyRelationship;
|
|
56
91
|
} | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Whether any behavior matches every argument given. Arguments left out match anything.
|
|
94
|
+
*/
|
|
95
|
+
hasMatchingBehavior(onField?: string, onAction?: DiffAction, toField?: string, forAction?: DiffAction): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether `to` is a child of `from`.
|
|
98
|
+
*/
|
|
99
|
+
isChildRelationship(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Whether both dependencies connect the same two nodes, in the same direction.
|
|
102
|
+
*/
|
|
103
|
+
isEqual(dependency: Dependency): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether `to` is a parent of `from`.
|
|
106
|
+
*/
|
|
107
|
+
isParentRelationship(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* To drop an ordering rule.
|
|
110
|
+
*
|
|
111
|
+
* @throws {@link DependencyError} If no such behavior exists.
|
|
112
|
+
*/
|
|
57
113
|
removeBehavior(onField: string, onAction: DiffAction, toField: string, forAction: DiffAction): void;
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
58
117
|
synth(): IDependency;
|
|
59
|
-
|
|
118
|
+
/**
|
|
119
|
+
* The position of a matching behavior, or `-1`.
|
|
120
|
+
*/
|
|
121
|
+
private getBehaviorIndex;
|
|
60
122
|
}
|
|
61
|
-
export {};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { DependencyError } from '../../errors/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
2
5
|
class DependencyBehavior {
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
3
9
|
constructor(onField, onAction, toField, forAction) {
|
|
4
10
|
this.onField = onField;
|
|
5
11
|
this.onAction = onAction;
|
|
@@ -8,6 +14,8 @@ class DependencyBehavior {
|
|
|
8
14
|
}
|
|
9
15
|
}
|
|
10
16
|
/**
|
|
17
|
+
* How two nodes are related. A parent exists before its child, and outlives it.
|
|
18
|
+
*
|
|
11
19
|
* @group Functions/Dependency
|
|
12
20
|
*/
|
|
13
21
|
export var DependencyRelationship;
|
|
@@ -16,34 +24,86 @@ export var DependencyRelationship;
|
|
|
16
24
|
DependencyRelationship["PARENT"] = "parent";
|
|
17
25
|
})(DependencyRelationship || (DependencyRelationship = {}));
|
|
18
26
|
/**
|
|
27
|
+
* The edge between two nodes in Octo's graph.
|
|
28
|
+
*
|
|
29
|
+
* A dependency is directed, and carries two things: an optional parent/child relationship, and a set
|
|
30
|
+
* of *behaviors*. A behavior states an ordering rule - "when this field of `from` is added, the
|
|
31
|
+
* matching action on `to` must have run first" - and it is those rules that let Octo order a
|
|
32
|
+
* transaction correctly instead of guessing.
|
|
33
|
+
*
|
|
34
|
+
* Models create dependencies through `addChild()` and `addRelationship()`; you rarely construct one.
|
|
35
|
+
*
|
|
19
36
|
* @group Functions/Dependency
|
|
37
|
+
*
|
|
38
|
+
* @see Definition of [Dependencies](/docs/fundamentals/dependencies).
|
|
20
39
|
*/
|
|
21
40
|
export class Dependency {
|
|
41
|
+
/**
|
|
42
|
+
* @param from The node this dependency points from.
|
|
43
|
+
* @param to The node this dependency points to.
|
|
44
|
+
*/
|
|
22
45
|
constructor(from, to) {
|
|
23
46
|
this.behaviors = [];
|
|
24
47
|
this.from = from;
|
|
25
48
|
this.to = to;
|
|
26
49
|
}
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
static unSynth(from, to, dependency) {
|
|
54
|
+
const newDependency = new Dependency(from, to);
|
|
55
|
+
// Read the actions and the relationship back as the values they were written from.
|
|
56
|
+
dependency.behaviors.forEach((b) => {
|
|
57
|
+
newDependency.addBehavior(b.onField, b.onAction, b.toField, b.forAction);
|
|
58
|
+
});
|
|
59
|
+
if (dependency.relationship) {
|
|
60
|
+
newDependency.relationship = {
|
|
61
|
+
...dependency.relationship,
|
|
62
|
+
type: dependency.relationship.type,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return newDependency;
|
|
29
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* To declare an ordering rule: when `onAction` happens to `onField` of `from`, then `forAction`
|
|
69
|
+
* on `toField` of `to` must have been applied first. Adding the same behavior twice is a no-op.
|
|
70
|
+
*/
|
|
30
71
|
addBehavior(onField, onAction, toField, forAction) {
|
|
31
72
|
if (this.getBehaviorIndex(onField, onAction, toField, forAction) === -1) {
|
|
32
73
|
this.behaviors.push(new DependencyBehavior(onField, onAction, toField, forAction));
|
|
33
74
|
}
|
|
34
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* To mark `to` as the child of `from`.
|
|
78
|
+
*
|
|
79
|
+
* @throws {@link DependencyError} If this dependency already has a relationship.
|
|
80
|
+
*/
|
|
35
81
|
addChildRelationship(onField, toField) {
|
|
36
82
|
if (this.relationship) {
|
|
37
83
|
throw new DependencyError('Dependency relationship already exists!', this);
|
|
38
84
|
}
|
|
39
85
|
this.relationship = { onField, toField, type: DependencyRelationship.CHILD };
|
|
40
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* To mark `to` as the parent of `from`.
|
|
89
|
+
*
|
|
90
|
+
* @throws {@link DependencyError} If this dependency already has a relationship.
|
|
91
|
+
*/
|
|
41
92
|
addParentRelationship(onField, toField) {
|
|
42
93
|
if (this.relationship) {
|
|
43
94
|
throw new DependencyError('Dependency relationship already exists!', this);
|
|
44
95
|
}
|
|
45
96
|
this.relationship = { onField, toField, type: DependencyRelationship.PARENT };
|
|
46
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* The relationship between the two nodes, if one was declared.
|
|
100
|
+
*/
|
|
101
|
+
getRelationship() {
|
|
102
|
+
return this.relationship;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether any behavior matches every argument given. Arguments left out match anything.
|
|
106
|
+
*/
|
|
47
107
|
hasMatchingBehavior(onField, onAction, toField, forAction) {
|
|
48
108
|
return this.behaviors.some((b) => {
|
|
49
109
|
const onFieldCondition = onField ? b.onField === onField : true;
|
|
@@ -53,18 +113,29 @@ export class Dependency {
|
|
|
53
113
|
return onFieldCondition && onActionCondition && toFieldCondition && forActionCondition;
|
|
54
114
|
});
|
|
55
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Whether `to` is a child of `from`.
|
|
118
|
+
*/
|
|
56
119
|
isChildRelationship() {
|
|
57
120
|
return this.relationship && this.relationship.type === DependencyRelationship.CHILD;
|
|
58
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether both dependencies connect the same two nodes, in the same direction.
|
|
124
|
+
*/
|
|
59
125
|
isEqual(dependency) {
|
|
60
126
|
return (this.from.getContext() === dependency.from.getContext() && this.to.getContext() === dependency.to.getContext());
|
|
61
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Whether `to` is a parent of `from`.
|
|
130
|
+
*/
|
|
62
131
|
isParentRelationship() {
|
|
63
132
|
return this.relationship && this.relationship.type === DependencyRelationship.PARENT;
|
|
64
133
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
134
|
+
/**
|
|
135
|
+
* To drop an ordering rule.
|
|
136
|
+
*
|
|
137
|
+
* @throws {@link DependencyError} If no such behavior exists.
|
|
138
|
+
*/
|
|
68
139
|
removeBehavior(onField, onAction, toField, forAction) {
|
|
69
140
|
const index = this.getBehaviorIndex(onField, onAction, toField, forAction);
|
|
70
141
|
if (index === -1) {
|
|
@@ -72,6 +143,9 @@ export class Dependency {
|
|
|
72
143
|
}
|
|
73
144
|
this.behaviors.splice(index, 1);
|
|
74
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
75
149
|
synth() {
|
|
76
150
|
const behaviors = [];
|
|
77
151
|
this.behaviors.forEach((b) => {
|
|
@@ -95,15 +169,11 @@ export class Dependency {
|
|
|
95
169
|
to: this.to.getContext(),
|
|
96
170
|
};
|
|
97
171
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (dependency.relationship) {
|
|
104
|
-
newDependency.relationship = { ...dependency.relationship };
|
|
105
|
-
}
|
|
106
|
-
return newDependency;
|
|
172
|
+
/**
|
|
173
|
+
* The position of a matching behavior, or `-1`.
|
|
174
|
+
*/
|
|
175
|
+
getBehaviorIndex(onField, onAction, toField, forAction) {
|
|
176
|
+
return this.behaviors.findIndex((b) => b.onField === onField && b.onAction === onAction && b.toField === toField && b.forAction === forAction);
|
|
107
177
|
}
|
|
108
178
|
}
|
|
109
179
|
//# sourceMappingURL=dependency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency.js","sourceRoot":"","sources":["../../../src/functions/dependency/dependency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,kBAAkB;IAStB,YAAY,OAAe,EAAE,QAAoB,EAAE,OAAe,EAAE,SAAqB;QACvF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED
|
|
1
|
+
{"version":3,"file":"dependency.js","sourceRoot":"","sources":["../../../src/functions/dependency/dependency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;GAEG;AACH,MAAM,kBAAkB;IAStB;;OAEG;IACH,YAAY,OAAe,EAAE,QAAoB,EAAE,OAAe,EAAE,SAAqB;QACvF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAeD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,UAAU;IAerB;;;OAGG;IACH,YAAY,IAAiB,EAAE,EAAe;QAR7B,cAAS,GAAyB,EAAE,CAAC;QASpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,IAAiB,EAAE,EAAe,EAAE,UAAuB;QACxE,MAAM,aAAa,GAAG,IAAI,UAA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YAAY,CAAC,IAAI;iBAC7B;gBACH,CAAC,CAAC,SAAS;YACb,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE;SACzB,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,OAAe,EAAE,QAAoB,EAAE,OAAe,EAAE,SAAqB;QACpG,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,CAC9G,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DiffMetadata } from './diff-metadata.js';
|
|
2
|
+
import { DiffAction } from './diff.js';
|
|
3
|
+
/**
|
|
4
|
+
* One octo resource's diffs, collapsed to a single action.
|
|
5
|
+
*/
|
|
6
|
+
export interface AggregatedResourceAction {
|
|
7
|
+
action: DiffAction.ADD | DiffAction.DELETE | DiffAction.REPLACE | DiffAction.UPDATE;
|
|
8
|
+
reason?: string;
|
|
9
|
+
resourceId: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Collapses a resource's field-level diffs into one action per resource, keyed by resource context.
|
|
13
|
+
*
|
|
14
|
+
* Precedence: an add/delete of `resourceId` wins; a REPLACE beats an UPDATE; otherwise UPDATE.
|
|
15
|
+
* `reason` is taken from the winning diff.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function aggregateResourceActions(diffs: DiffMetadata[]): Map<string, AggregatedResourceAction>;
|