@ddd-ts-kit/kernel 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -2
- package/dist/application/criteria/index.d.ts +33 -0
- package/dist/application/criteria/index.d.ts.map +1 -0
- package/dist/application/criteria/index.js +33 -0
- package/dist/application/criteria/index.js.map +1 -0
- package/dist/application/event-sourcing/appended.d.ts +8 -0
- package/dist/application/event-sourcing/appended.d.ts.map +1 -0
- package/dist/application/event-sourcing/appended.js +2 -0
- package/dist/application/event-sourcing/appended.js.map +1 -0
- package/dist/application/event-sourcing/define-stored-event.d.ts +10 -0
- package/dist/application/event-sourcing/define-stored-event.d.ts.map +1 -0
- package/dist/application/event-sourcing/define-stored-event.js +22 -0
- package/dist/application/event-sourcing/define-stored-event.js.map +1 -0
- package/dist/application/event-sourcing/erased-personal-data.d.ts +3 -0
- package/dist/application/event-sourcing/erased-personal-data.d.ts.map +1 -0
- package/dist/application/event-sourcing/erased-personal-data.js +3 -0
- package/dist/application/event-sourcing/erased-personal-data.js.map +1 -0
- package/dist/application/event-sourcing/event-envelope.d.ts +9 -0
- package/dist/application/event-sourcing/event-envelope.d.ts.map +1 -0
- package/dist/application/event-sourcing/event-envelope.js +2 -0
- package/dist/application/event-sourcing/event-envelope.js.map +1 -0
- package/dist/application/event-sourcing/event-to-append.d.ts +15 -0
- package/dist/application/event-sourcing/event-to-append.d.ts.map +1 -0
- package/dist/application/event-sourcing/event-to-append.js +2 -0
- package/dist/application/event-sourcing/event-to-append.js.map +1 -0
- package/dist/application/event-sourcing/index.d.ts +21 -0
- package/dist/application/event-sourcing/index.d.ts.map +1 -0
- package/dist/application/event-sourcing/index.js +21 -0
- package/dist/application/event-sourcing/index.js.map +1 -0
- package/dist/application/event-sourcing/is-stored-data.d.ts +5 -0
- package/dist/application/event-sourcing/is-stored-data.d.ts.map +1 -0
- package/dist/application/event-sourcing/is-stored-data.js +5 -0
- package/dist/application/event-sourcing/is-stored-data.js.map +1 -0
- package/dist/application/event-sourcing/is-stored-list.d.ts +4 -0
- package/dist/application/event-sourcing/is-stored-list.d.ts.map +1 -0
- package/dist/application/event-sourcing/is-stored-list.js +5 -0
- package/dist/application/event-sourcing/is-stored-list.js.map +1 -0
- package/dist/application/event-sourcing/personal-data.d.ts +14 -0
- package/dist/application/event-sourcing/personal-data.d.ts.map +1 -0
- package/dist/application/event-sourcing/personal-data.js +9 -0
- package/dist/application/event-sourcing/personal-data.js.map +1 -0
- package/dist/application/event-sourcing/stored-data-of.d.ts +9 -0
- package/dist/application/event-sourcing/stored-data-of.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-data-of.js +40 -0
- package/dist/application/event-sourcing/stored-data-of.js.map +1 -0
- package/dist/application/event-sourcing/stored-data.d.ts +6 -0
- package/dist/application/event-sourcing/stored-data.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-data.js +2 -0
- package/dist/application/event-sourcing/stored-data.js.map +1 -0
- package/dist/application/event-sourcing/stored-event-data.d.ts +25 -0
- package/dist/application/event-sourcing/stored-event-data.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-event-data.js +82 -0
- package/dist/application/event-sourcing/stored-event-data.js.map +1 -0
- package/dist/application/event-sourcing/stored-event-spec.d.ts +20 -0
- package/dist/application/event-sourcing/stored-event-spec.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-event-spec.js +2 -0
- package/dist/application/event-sourcing/stored-event-spec.js.map +1 -0
- package/dist/application/event-sourcing/stored-event-type.d.ts +14 -0
- package/dist/application/event-sourcing/stored-event-type.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-event-type.js +2 -0
- package/dist/application/event-sourcing/stored-event-type.js.map +1 -0
- package/dist/application/event-sourcing/stored-event-types.d.ts +9 -0
- package/dist/application/event-sourcing/stored-event-types.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-event-types.js +2 -0
- package/dist/application/event-sourcing/stored-event-types.js.map +1 -0
- package/dist/application/event-sourcing/stored-event.d.ts +12 -0
- package/dist/application/event-sourcing/stored-event.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-event.js +2 -0
- package/dist/application/event-sourcing/stored-event.js.map +1 -0
- package/dist/application/event-sourcing/stored-json.d.ts +5 -0
- package/dist/application/event-sourcing/stored-json.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-json.js +2 -0
- package/dist/application/event-sourcing/stored-json.js.map +1 -0
- package/dist/application/event-sourcing/stored-snapshot.d.ts +11 -0
- package/dist/application/event-sourcing/stored-snapshot.d.ts.map +1 -0
- package/dist/application/event-sourcing/stored-snapshot.js +2 -0
- package/dist/application/event-sourcing/stored-snapshot.js.map +1 -0
- package/dist/application/event-sourcing/subject-key.d.ts +10 -0
- package/dist/application/event-sourcing/subject-key.d.ts.map +1 -0
- package/dist/application/event-sourcing/subject-key.js +2 -0
- package/dist/application/event-sourcing/subject-key.js.map +1 -0
- package/dist/application/event-sourcing/unreadable-event-error.d.ts +5 -0
- package/dist/application/event-sourcing/unreadable-event-error.d.ts.map +1 -0
- package/dist/application/event-sourcing/unreadable-event-error.js +8 -0
- package/dist/application/event-sourcing/unreadable-event-error.js.map +1 -0
- package/dist/application/event-sourcing/upcaster.d.ts +4 -0
- package/dist/application/event-sourcing/upcaster.d.ts.map +1 -0
- package/dist/application/event-sourcing/upcaster.js +2 -0
- package/dist/application/event-sourcing/upcaster.js.map +1 -0
- package/dist/application/files/accepts-media-type.d.ts +3 -0
- package/dist/application/files/accepts-media-type.d.ts.map +1 -0
- package/dist/application/files/accepts-media-type.js +11 -0
- package/dist/application/files/accepts-media-type.js.map +1 -0
- package/dist/application/files/assert-expiry.d.ts +3 -0
- package/dist/application/files/assert-expiry.d.ts.map +1 -0
- package/dist/application/files/assert-expiry.js +10 -0
- package/dist/application/files/assert-expiry.js.map +1 -0
- package/dist/application/files/assert-file-key.d.ts +3 -0
- package/dist/application/files/assert-file-key.d.ts.map +1 -0
- package/dist/application/files/assert-file-key.js +10 -0
- package/dist/application/files/assert-file-key.js.map +1 -0
- package/dist/application/files/assert-final-key.d.ts +3 -0
- package/dist/application/files/assert-final-key.d.ts.map +1 -0
- package/dist/application/files/assert-final-key.js +11 -0
- package/dist/application/files/assert-final-key.js.map +1 -0
- package/dist/application/files/content-disposition.d.ts +3 -0
- package/dist/application/files/content-disposition.d.ts.map +1 -0
- package/dist/application/files/content-disposition.js +9 -0
- package/dist/application/files/content-disposition.js.map +1 -0
- package/dist/application/files/content-expectation.d.ts +6 -0
- package/dist/application/files/content-expectation.d.ts.map +1 -0
- package/dist/application/files/content-expectation.js +2 -0
- package/dist/application/files/content-expectation.js.map +1 -0
- package/dist/application/files/content-matches.d.ts +7 -0
- package/dist/application/files/content-matches.d.ts.map +1 -0
- package/dist/application/files/content-matches.js +39 -0
- package/dist/application/files/content-matches.js.map +1 -0
- package/dist/application/files/download-url-options.d.ts +7 -0
- package/dist/application/files/download-url-options.d.ts.map +1 -0
- package/dist/application/files/download-url-options.js +2 -0
- package/dist/application/files/download-url-options.js.map +1 -0
- package/dist/application/files/file-content.d.ts +8 -0
- package/dist/application/files/file-content.d.ts.map +1 -0
- package/dist/application/files/file-content.js +2 -0
- package/dist/application/files/file-content.js.map +1 -0
- package/dist/application/files/file-error.d.ts +28 -0
- package/dist/application/files/file-error.d.ts.map +1 -0
- package/dist/application/files/file-error.js +29 -0
- package/dist/application/files/file-error.js.map +1 -0
- package/dist/application/files/file-metadata.d.ts +10 -0
- package/dist/application/files/file-metadata.d.ts.map +1 -0
- package/dist/application/files/file-metadata.js +2 -0
- package/dist/application/files/file-metadata.js.map +1 -0
- package/dist/application/files/file-source.d.ts +4 -0
- package/dist/application/files/file-source.d.ts.map +1 -0
- package/dist/application/files/file-source.js +2 -0
- package/dist/application/files/file-source.js.map +1 -0
- package/dist/application/files/file-upload.d.ts +25 -0
- package/dist/application/files/file-upload.d.ts.map +1 -0
- package/dist/application/files/file-upload.js +36 -0
- package/dist/application/files/file-upload.js.map +1 -0
- package/dist/application/files/index.d.ts +31 -0
- package/dist/application/files/index.d.ts.map +1 -0
- package/dist/application/files/index.js +31 -0
- package/dist/application/files/index.js.map +1 -0
- package/dist/application/files/inspection-limits.d.ts +8 -0
- package/dist/application/files/inspection-limits.d.ts.map +1 -0
- package/dist/application/files/inspection-limits.js +2 -0
- package/dist/application/files/inspection-limits.js.map +1 -0
- package/dist/application/files/is-file-key.d.ts +7 -0
- package/dist/application/files/is-file-key.d.ts.map +1 -0
- package/dist/application/files/is-file-key.js +11 -0
- package/dist/application/files/is-file-key.js.map +1 -0
- package/dist/application/files/listed-file.d.ts +7 -0
- package/dist/application/files/listed-file.d.ts.map +1 -0
- package/dist/application/files/listed-file.js +2 -0
- package/dist/application/files/listed-file.js.map +1 -0
- package/dist/application/files/max-signed-url-seconds.d.ts +3 -0
- package/dist/application/files/max-signed-url-seconds.d.ts.map +1 -0
- package/dist/application/files/max-signed-url-seconds.js +3 -0
- package/dist/application/files/max-signed-url-seconds.js.map +1 -0
- package/dist/application/files/media-type-of.d.ts +3 -0
- package/dist/application/files/media-type-of.d.ts.map +1 -0
- package/dist/application/files/media-type-of.js +5 -0
- package/dist/application/files/media-type-of.js.map +1 -0
- package/dist/application/files/pending-upload-link.d.ts +10 -0
- package/dist/application/files/pending-upload-link.d.ts.map +1 -0
- package/dist/application/files/pending-upload-link.js +2 -0
- package/dist/application/files/pending-upload-link.js.map +1 -0
- package/dist/application/files/pending-upload.d.ts +15 -0
- package/dist/application/files/pending-upload.d.ts.map +1 -0
- package/dist/application/files/pending-upload.js +2 -0
- package/dist/application/files/pending-upload.js.map +1 -0
- package/dist/application/files/put-options.d.ts +7 -0
- package/dist/application/files/put-options.d.ts.map +1 -0
- package/dist/application/files/put-options.js +2 -0
- package/dist/application/files/put-options.js.map +1 -0
- package/dist/application/files/received-file.d.ts +15 -0
- package/dist/application/files/received-file.d.ts.map +1 -0
- package/dist/application/files/received-file.js +2 -0
- package/dist/application/files/received-file.js.map +1 -0
- package/dist/application/files/scan-verdict.d.ts +8 -0
- package/dist/application/files/scan-verdict.d.ts.map +1 -0
- package/dist/application/files/scan-verdict.js +2 -0
- package/dist/application/files/scan-verdict.js.map +1 -0
- package/dist/application/files/signature-of.d.ts +3 -0
- package/dist/application/files/signature-of.d.ts.map +1 -0
- package/dist/application/files/signature-of.js +28 -0
- package/dist/application/files/signature-of.js.map +1 -0
- package/dist/application/files/signed-download.d.ts +6 -0
- package/dist/application/files/signed-download.d.ts.map +1 -0
- package/dist/application/files/signed-download.js +2 -0
- package/dist/application/files/signed-download.js.map +1 -0
- package/dist/application/files/signed-upload.d.ts +9 -0
- package/dist/application/files/signed-upload.d.ts.map +1 -0
- package/dist/application/files/signed-upload.js +2 -0
- package/dist/application/files/signed-upload.js.map +1 -0
- package/dist/application/files/signed-url.d.ts +6 -0
- package/dist/application/files/signed-url.d.ts.map +1 -0
- package/dist/application/files/signed-url.js +2 -0
- package/dist/application/files/signed-url.js.map +1 -0
- package/dist/application/files/staged-key-of.d.ts +5 -0
- package/dist/application/files/staged-key-of.d.ts.map +1 -0
- package/dist/application/files/staged-key-of.js +7 -0
- package/dist/application/files/staged-key-of.js.map +1 -0
- package/dist/application/files/stored-file.d.ts +16 -0
- package/dist/application/files/stored-file.d.ts.map +1 -0
- package/dist/application/files/stored-file.js +2 -0
- package/dist/application/files/stored-file.js.map +1 -0
- package/dist/application/files/upload-url-options.d.ts +12 -0
- package/dist/application/files/upload-url-options.d.ts.map +1 -0
- package/dist/application/files/upload-url-options.js +2 -0
- package/dist/application/files/upload-url-options.js.map +1 -0
- package/dist/application/persistence/append-changes.d.ts +18 -0
- package/dist/application/persistence/append-changes.d.ts.map +1 -0
- package/dist/application/persistence/append-changes.js +17 -0
- package/dist/application/persistence/append-changes.js.map +1 -0
- package/dist/application/ports/checkpoint-store.d.ts +14 -0
- package/dist/application/ports/checkpoint-store.d.ts.map +1 -0
- package/dist/application/ports/checkpoint-store.js +10 -0
- package/dist/application/ports/checkpoint-store.js.map +1 -0
- package/dist/application/ports/event-store.d.ts +24 -0
- package/dist/application/ports/event-store.d.ts.map +1 -0
- package/dist/application/ports/event-store.js +12 -0
- package/dist/application/ports/event-store.js.map +1 -0
- package/dist/application/ports/file-keys.d.ts +9 -0
- package/dist/application/ports/file-keys.d.ts.map +1 -0
- package/dist/application/ports/file-keys.js +10 -0
- package/dist/application/ports/file-keys.js.map +1 -0
- package/dist/application/ports/file-scanner.d.ts +13 -0
- package/dist/application/ports/file-scanner.d.ts.map +1 -0
- package/dist/application/ports/file-scanner.js +12 -0
- package/dist/application/ports/file-scanner.js.map +1 -0
- package/dist/application/ports/file-storage.d.ts +40 -0
- package/dist/application/ports/file-storage.d.ts.map +1 -0
- package/dist/application/ports/file-storage.js +15 -0
- package/dist/application/ports/file-storage.js.map +1 -0
- package/dist/application/ports/served-file-storage.d.ts +16 -0
- package/dist/application/ports/served-file-storage.d.ts.map +1 -0
- package/dist/application/ports/served-file-storage.js +12 -0
- package/dist/application/ports/served-file-storage.js.map +1 -0
- package/dist/application/ports/snapshot-store.d.ts +8 -0
- package/dist/application/ports/snapshot-store.d.ts.map +1 -0
- package/dist/application/ports/snapshot-store.js +7 -0
- package/dist/application/ports/snapshot-store.js.map +1 -0
- package/dist/application/ports/subject-key-store.d.ts +17 -0
- package/dist/application/ports/subject-key-store.d.ts.map +1 -0
- package/dist/application/ports/subject-key-store.js +13 -0
- package/dist/application/ports/subject-key-store.js.map +1 -0
- package/dist/declarations/decorators/projection-options.d.ts +5 -0
- package/dist/declarations/decorators/projection-options.d.ts.map +1 -0
- package/dist/declarations/decorators/projection-options.js +2 -0
- package/dist/declarations/decorators/projection-options.js.map +1 -0
- package/dist/declarations/decorators/projection.d.ts +4 -0
- package/dist/declarations/decorators/projection.d.ts.map +1 -1
- package/dist/declarations/decorators/projection.js +16 -8
- package/dist/declarations/decorators/projection.js.map +1 -1
- package/dist/declarations/model/projection-declaration.d.ts +3 -0
- package/dist/declarations/model/projection-declaration.d.ts.map +1 -1
- package/dist/declarations/model/projection-feed.d.ts +8 -0
- package/dist/declarations/model/projection-feed.d.ts.map +1 -0
- package/dist/declarations/model/projection-feed.js +2 -0
- package/dist/declarations/model/projection-feed.js.map +1 -0
- package/dist/declarations/projection/applying-projection.d.ts +14 -0
- package/dist/declarations/projection/applying-projection.d.ts.map +1 -0
- package/dist/declarations/projection/applying-projection.js +32 -0
- package/dist/declarations/projection/applying-projection.js.map +1 -0
- package/dist/declarations.d.ts +3 -0
- package/dist/declarations.d.ts.map +1 -1
- package/dist/declarations.js +1 -0
- package/dist/declarations.js.map +1 -1
- package/dist/domain/event-sourcing/aggregate-history.d.ts +10 -0
- package/dist/domain/event-sourcing/aggregate-history.d.ts.map +1 -0
- package/dist/domain/event-sourcing/aggregate-history.js +2 -0
- package/dist/domain/event-sourcing/aggregate-history.js.map +1 -0
- package/dist/domain/event-sourcing/aggregate-snapshot.d.ts +6 -0
- package/dist/domain/event-sourcing/aggregate-snapshot.d.ts.map +1 -0
- package/dist/domain/event-sourcing/aggregate-snapshot.js +2 -0
- package/dist/domain/event-sourcing/aggregate-snapshot.js.map +1 -0
- package/dist/domain/event-sourcing/appliers.d.ts +12 -0
- package/dist/domain/event-sourcing/appliers.d.ts.map +1 -0
- package/dist/domain/event-sourcing/appliers.js +2 -0
- package/dist/domain/event-sourcing/appliers.js.map +1 -0
- package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts +28 -0
- package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts.map +1 -0
- package/dist/domain/event-sourcing/event-sourced-aggregate.js +51 -0
- package/dist/domain/event-sourcing/event-sourced-aggregate.js.map +1 -0
- package/dist/domain/event-sourcing/unstored-events.d.ts +8 -0
- package/dist/domain/event-sourcing/unstored-events.d.ts.map +1 -0
- package/dist/domain/event-sourcing/unstored-events.js +7 -0
- package/dist/domain/event-sourcing/unstored-events.js.map +1 -0
- package/dist/index.d.ts +52 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -32
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/domain-events/after-commit.d.ts +10 -0
- package/dist/infrastructure/domain-events/after-commit.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/after-commit.js +19 -0
- package/dist/infrastructure/domain-events/after-commit.js.map +1 -0
- package/dist/infrastructure/domain-events/at-commit.d.ts +11 -0
- package/dist/infrastructure/domain-events/at-commit.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/at-commit.js +19 -0
- package/dist/infrastructure/domain-events/at-commit.js.map +1 -0
- package/dist/infrastructure/domain-events/commit-step.d.ts +10 -0
- package/dist/infrastructure/domain-events/commit-step.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/commit-step.js +2 -0
- package/dist/infrastructure/domain-events/commit-step.js.map +1 -0
- package/dist/infrastructure/domain-events/unit-of-work-scope.d.ts +5 -0
- package/dist/infrastructure/domain-events/unit-of-work-scope.d.ts.map +1 -1
- package/dist/infrastructure/domain-events/unit-of-work-scope.js.map +1 -1
- package/dist/infrastructure/domain-events/within-unit-of-work.d.ts +3 -1
- package/dist/infrastructure/domain-events/within-unit-of-work.d.ts.map +1 -1
- package/dist/infrastructure/domain-events/within-unit-of-work.js +32 -5
- package/dist/infrastructure/domain-events/within-unit-of-work.js.map +1 -1
- package/dist/infrastructure/event-sourcing/catch-up-subscription.d.ts +33 -0
- package/dist/infrastructure/event-sourcing/catch-up-subscription.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/catch-up-subscription.js +39 -0
- package/dist/infrastructure/event-sourcing/catch-up-subscription.js.map +1 -0
- package/dist/infrastructure/event-sourcing/event-serializer.d.ts +35 -0
- package/dist/infrastructure/event-sourcing/event-serializer.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/event-serializer.js +104 -0
- package/dist/infrastructure/event-sourcing/event-serializer.js.map +1 -0
- package/dist/infrastructure/event-sourcing/event-sourced-repository.d.ts +32 -0
- package/dist/infrastructure/event-sourcing/event-sourced-repository.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/event-sourced-repository.js +68 -0
- package/dist/infrastructure/event-sourcing/event-sourced-repository.js.map +1 -0
- package/dist/infrastructure/event-sourcing/event-sourcing-stores.d.ts +12 -0
- package/dist/infrastructure/event-sourcing/event-sourcing-stores.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/event-sourcing-stores.js +2 -0
- package/dist/infrastructure/event-sourcing/event-sourcing-stores.js.map +1 -0
- package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.d.ts +34 -0
- package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.js +48 -0
- package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.js.map +1 -0
- package/dist/infrastructure/event-sourcing/personal-data-cipher.d.ts +19 -0
- package/dist/infrastructure/event-sourcing/personal-data-cipher.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/personal-data-cipher.js +84 -0
- package/dist/infrastructure/event-sourcing/personal-data-cipher.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.d.ts +6 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.js +2 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.d.ts +9 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.js +32 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables.d.ts +9 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables.js +9 -0
- package/dist/infrastructure/event-sourcing/postgres/event-store-tables.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.d.ts +3 -0
- package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.js +22 -0
- package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.d.ts +12 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.js +26 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.d.ts +6 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.js +14 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.d.ts +31 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.js +120 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.d.ts +13 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.js +28 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.d.ts +21 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.js +48 -0
- package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/qualified-table.d.ts +4 -0
- package/dist/infrastructure/event-sourcing/postgres/qualified-table.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/qualified-table.js +10 -0
- package/dist/infrastructure/event-sourcing/postgres/qualified-table.js.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/stored-data-from.d.ts +4 -0
- package/dist/infrastructure/event-sourcing/postgres/stored-data-from.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/postgres/stored-data-from.js +23 -0
- package/dist/infrastructure/event-sourcing/postgres/stored-data-from.js.map +1 -0
- package/dist/infrastructure/event-sourcing/rewrite-objects.d.ts +8 -0
- package/dist/infrastructure/event-sourcing/rewrite-objects.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/rewrite-objects.js +16 -0
- package/dist/infrastructure/event-sourcing/rewrite-objects.js.map +1 -0
- package/dist/infrastructure/event-sourcing/snapshot-policy.d.ts +14 -0
- package/dist/infrastructure/event-sourcing/snapshot-policy.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/snapshot-policy.js +2 -0
- package/dist/infrastructure/event-sourcing/snapshot-policy.js.map +1 -0
- package/dist/infrastructure/event-sourcing/stored-origins.d.ts +5 -0
- package/dist/infrastructure/event-sourcing/stored-origins.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/stored-origins.js +3 -0
- package/dist/infrastructure/event-sourcing/stored-origins.js.map +1 -0
- package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts +10 -0
- package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/stored-stamp-of.js +14 -0
- package/dist/infrastructure/event-sourcing/stored-stamp-of.js.map +1 -0
- package/dist/infrastructure/files/accept-every-file-scanner.d.ts +7 -0
- package/dist/infrastructure/files/accept-every-file-scanner.d.ts.map +1 -0
- package/dist/infrastructure/files/accept-every-file-scanner.js +7 -0
- package/dist/infrastructure/files/accept-every-file-scanner.js.map +1 -0
- package/dist/infrastructure/files/collect.d.ts +4 -0
- package/dist/infrastructure/files/collect.d.ts.map +1 -0
- package/dist/infrastructure/files/collect.js +11 -0
- package/dist/infrastructure/files/collect.js.map +1 -0
- package/dist/infrastructure/files/file-grant.d.ts +11 -0
- package/dist/infrastructure/files/file-grant.d.ts.map +1 -0
- package/dist/infrastructure/files/file-grant.js +2 -0
- package/dist/infrastructure/files/file-grant.js.map +1 -0
- package/dist/infrastructure/files/file-inspection.d.ts +22 -0
- package/dist/infrastructure/files/file-inspection.d.ts.map +1 -0
- package/dist/infrastructure/files/file-inspection.js +66 -0
- package/dist/infrastructure/files/file-inspection.js.map +1 -0
- package/dist/infrastructure/files/file-staging.d.ts +59 -0
- package/dist/infrastructure/files/file-staging.d.ts.map +1 -0
- package/dist/infrastructure/files/file-staging.js +142 -0
- package/dist/infrastructure/files/file-staging.js.map +1 -0
- package/dist/infrastructure/files/file-uploads-middleware.d.ts +11 -0
- package/dist/infrastructure/files/file-uploads-middleware.d.ts.map +1 -0
- package/dist/infrastructure/files/file-uploads-middleware.js +25 -0
- package/dist/infrastructure/files/file-uploads-middleware.js.map +1 -0
- package/dist/infrastructure/files/in-memory-file-storage.d.ts +25 -0
- package/dist/infrastructure/files/in-memory-file-storage.d.ts.map +1 -0
- package/dist/infrastructure/files/in-memory-file-storage.js +73 -0
- package/dist/infrastructure/files/in-memory-file-storage.js.map +1 -0
- package/dist/infrastructure/files/is-file-grant.d.ts +3 -0
- package/dist/infrastructure/files/is-file-grant.d.ts.map +1 -0
- package/dist/infrastructure/files/is-file-grant.js +16 -0
- package/dist/infrastructure/files/is-file-grant.js.map +1 -0
- package/dist/infrastructure/files/is-stored-metadata.d.ts +3 -0
- package/dist/infrastructure/files/is-stored-metadata.d.ts.map +1 -0
- package/dist/infrastructure/files/is-stored-metadata.js +8 -0
- package/dist/infrastructure/files/is-stored-metadata.js.map +1 -0
- package/dist/infrastructure/files/local-file-storage-options.d.ts +6 -0
- package/dist/infrastructure/files/local-file-storage-options.d.ts.map +1 -0
- package/dist/infrastructure/files/local-file-storage-options.js +2 -0
- package/dist/infrastructure/files/local-file-storage-options.js.map +1 -0
- package/dist/infrastructure/files/local-file-storage.d.ts +29 -0
- package/dist/infrastructure/files/local-file-storage.d.ts.map +1 -0
- package/dist/infrastructure/files/local-file-storage.js +103 -0
- package/dist/infrastructure/files/local-file-storage.js.map +1 -0
- package/dist/infrastructure/files/local-paths.d.ts +12 -0
- package/dist/infrastructure/files/local-paths.d.ts.map +1 -0
- package/dist/infrastructure/files/local-paths.js +33 -0
- package/dist/infrastructure/files/local-paths.js.map +1 -0
- package/dist/infrastructure/files/purge-staged-files.d.ts +16 -0
- package/dist/infrastructure/files/purge-staged-files.d.ts.map +1 -0
- package/dist/infrastructure/files/purge-staged-files.js +21 -0
- package/dist/infrastructure/files/purge-staged-files.js.map +1 -0
- package/dist/infrastructure/files/self-signed-file-storage.d.ts +23 -0
- package/dist/infrastructure/files/self-signed-file-storage.d.ts.map +1 -0
- package/dist/infrastructure/files/self-signed-file-storage.js +57 -0
- package/dist/infrastructure/files/self-signed-file-storage.js.map +1 -0
- package/dist/infrastructure/files/signed-file-tokens.d.ts +20 -0
- package/dist/infrastructure/files/signed-file-tokens.d.ts.map +1 -0
- package/dist/infrastructure/files/signed-file-tokens.js +45 -0
- package/dist/infrastructure/files/signed-file-tokens.js.map +1 -0
- package/dist/infrastructure/files/signed-link-options.d.ts +10 -0
- package/dist/infrastructure/files/signed-link-options.d.ts.map +1 -0
- package/dist/infrastructure/files/signed-link-options.js +2 -0
- package/dist/infrastructure/files/signed-link-options.js.map +1 -0
- package/dist/infrastructure/files/stored-metadata.d.ts +6 -0
- package/dist/infrastructure/files/stored-metadata.d.ts.map +1 -0
- package/dist/infrastructure/files/stored-metadata.js +2 -0
- package/dist/infrastructure/files/stored-metadata.js.map +1 -0
- package/dist/infrastructure/files/tenant-file-keys.d.ts +20 -0
- package/dist/infrastructure/files/tenant-file-keys.d.ts.map +1 -0
- package/dist/infrastructure/files/tenant-file-keys.js +27 -0
- package/dist/infrastructure/files/tenant-file-keys.js.map +1 -0
- package/dist/infrastructure/files/upload-desk.d.ts +8 -0
- package/dist/infrastructure/files/upload-desk.d.ts.map +1 -0
- package/dist/infrastructure/files/upload-desk.js +2 -0
- package/dist/infrastructure/files/upload-desk.js.map +1 -0
- package/dist/infrastructure/files/without-trailing-slashes.d.ts +3 -0
- package/dist/infrastructure/files/without-trailing-slashes.d.ts.map +1 -0
- package/dist/infrastructure/files/without-trailing-slashes.js +9 -0
- package/dist/infrastructure/files/without-trailing-slashes.js.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.d.ts +8 -0
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.js +15 -0
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.js.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-event-store.d.ts +14 -0
- package/dist/infrastructure/in-memory/in-memory-event-store.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-event-store.js +37 -0
- package/dist/infrastructure/in-memory/in-memory-event-store.js.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.d.ts +9 -0
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.js +15 -0
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.js.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-subject-key-store.d.ts +10 -0
- package/dist/infrastructure/in-memory/in-memory-subject-key-store.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-subject-key-store.js +21 -0
- package/dist/infrastructure/in-memory/in-memory-subject-key-store.js.map +1 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.d.ts +20 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.d.ts.map +1 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.js +25 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-checkpoint-store.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAEtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAG/E,uHAAuH;AACvH,qBAAa,uBAAwB,YAAW,eAAe;IAI3D,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B,YACmB,GAAG,EAAE,MAAM,EAC5B,OAAO,GAAE,uBAA4B,EAGtC;IAEK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIlD;IAEK,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBzE;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConcurrencyError } from '../../../domain/errors/concurrency-error.js';
|
|
2
|
+
import { qualifiedTable } from './qualified-table.js';
|
|
3
|
+
/** The checkpoints of the subscriptions on PostgreSQL, moved by a statement guarded by the position it starts from. */
|
|
4
|
+
export class PostgresCheckpointStore {
|
|
5
|
+
run;
|
|
6
|
+
table;
|
|
7
|
+
constructor(run, options = {}) {
|
|
8
|
+
this.run = run;
|
|
9
|
+
this.table = qualifiedTable(options.schema, 'checkpoints');
|
|
10
|
+
}
|
|
11
|
+
async position(subscriber) {
|
|
12
|
+
const [row] = await this.run(`select position from ${this.table} where subscriber = $1::text`, [subscriber]);
|
|
13
|
+
return Number(row?.['position'] ?? 0);
|
|
14
|
+
}
|
|
15
|
+
async advance(subscriber, from, to) {
|
|
16
|
+
const moved = from === 0
|
|
17
|
+
? await this.run(`insert into ${this.table} as c (subscriber, position) values ($1::text, $2::bigint)
|
|
18
|
+
on conflict (subscriber) do update set position = excluded.position, updated_at = now() where c.position = $3::bigint
|
|
19
|
+
returning subscriber`, [subscriber, to, from])
|
|
20
|
+
: await this.run(`update ${this.table} set position = $1::bigint, updated_at = now() where subscriber = $2::text and position = $3::bigint returning subscriber`, [to, subscriber, from]);
|
|
21
|
+
if (moved.length === 0) {
|
|
22
|
+
throw new ConcurrencyError(subscriber);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=postgres-checkpoint-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-checkpoint-store.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAG/E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,uHAAuH;AACvH,MAAM,OAAO,uBAAuB;IAIf,GAAG;IAHL,KAAK,CAAS;IAE/B,YACmB,GAAW,EAC5B,OAAO,GAA4B,EAAE;mBADpB,GAAG;QAGpB,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAAkB;QAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,KAAK,8BAA8B,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAE7G,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAkB,EAAE,IAAY,EAAE,EAAU;QACxD,MAAM,KAAK,GACT,IAAI,KAAK,CAAC;YACR,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CACZ,eAAe,IAAI,CAAC,KAAK;;qBAEhB,EACT,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,CACvB;YACH,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CACZ,UAAU,IAAI,CAAC,KAAK,2HAA2H,EAC/I,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,CACvB,CAAC;QAER,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SqlRun } from '../../read-model/sql-run.js';
|
|
2
|
+
import type { EventSourcingStores } from '../event-sourcing-stores.js';
|
|
3
|
+
import type { EventStoreTablesOptions } from './event-store-tables-options.js';
|
|
4
|
+
/** The stores of event sourcing on PostgreSQL over the statements of an ORM adapter: what each adapter package hands out. */
|
|
5
|
+
export declare function postgresEventSourcing(run: SqlRun, options?: EventStoreTablesOptions): EventSourcingStores;
|
|
6
|
+
//# sourceMappingURL=postgres-event-sourcing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-event-sourcing.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-event-sourcing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAM/E,6HAA6H;AAC7H,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,mBAAmB,CAO7G"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PostgresCheckpointStore } from './postgres-checkpoint-store.js';
|
|
2
|
+
import { PostgresEventStore } from './postgres-event-store.js';
|
|
3
|
+
import { PostgresSnapshotStore } from './postgres-snapshot-store.js';
|
|
4
|
+
import { PostgresSubjectKeyStore } from './postgres-subject-key-store.js';
|
|
5
|
+
/** The stores of event sourcing on PostgreSQL over the statements of an ORM adapter: what each adapter package hands out. */
|
|
6
|
+
export function postgresEventSourcing(run, options = {}) {
|
|
7
|
+
return {
|
|
8
|
+
events: new PostgresEventStore(run, options),
|
|
9
|
+
snapshots: new PostgresSnapshotStore(run, options),
|
|
10
|
+
checkpoints: new PostgresCheckpointStore(run, options),
|
|
11
|
+
subjectKeys: new PostgresSubjectKeyStore(run, options),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=postgres-event-sourcing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-event-sourcing.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-event-sourcing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,6HAA6H;AAC7H,MAAM,UAAU,qBAAqB,CAAC,GAAW,EAAE,OAAO,GAA4B,EAAE;IACtF,OAAO;QACL,MAAM,EAAE,IAAI,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC;QAC5C,SAAS,EAAE,IAAI,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC;QAClD,WAAW,EAAE,IAAI,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC;QACtD,WAAW,EAAE,IAAI,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Appended } from '../../../application/event-sourcing/appended.js';
|
|
2
|
+
import type { EventToAppend } from '../../../application/event-sourcing/event-to-append.js';
|
|
3
|
+
import type { StoredEvent } from '../../../application/event-sourcing/stored-event.js';
|
|
4
|
+
import type { EventStore } from '../../../application/ports/event-store.js';
|
|
5
|
+
import type { SqlRun } from '../../read-model/sql-run.js';
|
|
6
|
+
import type { EventStoreTablesOptions } from './event-store-tables-options.js';
|
|
7
|
+
/**
|
|
8
|
+
* The event store on PostgreSQL, shared by the ORM adapters, which differ only in how they run a
|
|
9
|
+
* statement. An append is one statement on the executor of the unit of work: it takes the head of
|
|
10
|
+
* the store, a row locked until the transaction ends, only when the stream still has the expected
|
|
11
|
+
* version, and inserts the events after it. Appends therefore commit in the order of their
|
|
12
|
+
* positions, and a subscription that read up to a position never meets a smaller one later; the
|
|
13
|
+
* price is that two appends never run side by side, whatever their streams. A conflict that slips
|
|
14
|
+
* between the check and the insert hits the unique (stream, version) and is a ConcurrencyError too,
|
|
15
|
+
* and so are a serialization failure (a unit of work at REPEATABLE READ or SERIALIZABLE) and a
|
|
16
|
+
* deadlock with row locks the same transaction took in another order: the caller retries.
|
|
17
|
+
*/
|
|
18
|
+
export declare class PostgresEventStore implements EventStore {
|
|
19
|
+
private readonly run;
|
|
20
|
+
private readonly events;
|
|
21
|
+
private readonly headRow;
|
|
22
|
+
constructor(run: SqlRun, options?: EventStoreTablesOptions);
|
|
23
|
+
append(stream: string, expectedVersion: number, events: readonly EventToAppend[]): Promise<Appended>;
|
|
24
|
+
readStream(stream: string, after?: number): Promise<readonly StoredEvent[]>;
|
|
25
|
+
readAll(after: number, limit: number): Promise<readonly StoredEvent[]>;
|
|
26
|
+
head(): Promise<number>;
|
|
27
|
+
private inserted;
|
|
28
|
+
private appendStatement;
|
|
29
|
+
private unchanged;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=postgres-event-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-event-store.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-event-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAa/E;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,UAAU;IAMjD,OAAO,CAAC,QAAQ,CAAC,GAAG;IALtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,YACmB,GAAG,EAAE,MAAM,EAC5B,OAAO,GAAE,uBAA4B,EAItC;IAEK,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiBzG;IAEK,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAO3E;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAO3E;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAI5B;YAEa,QAAQ;IAYtB,OAAO,CAAC,eAAe;YAmBT,SAAS;CAYxB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ConcurrencyError } from '../../../domain/errors/concurrency-error.js';
|
|
2
|
+
import { isAppendConflict } from './is-append-conflict.js';
|
|
3
|
+
import { qualifiedTable } from './qualified-table.js';
|
|
4
|
+
import { storedDataFrom } from './stored-data-from.js';
|
|
5
|
+
const COLUMNS = 'position, stream, version, event_id, type, schema_version, data, metadata, occurred_at';
|
|
6
|
+
// The instant as UTC text: drivers disagree on the zone they read a timestamptz in.
|
|
7
|
+
const SELECTED = `position, stream, version, event_id, type, schema_version, data, metadata,
|
|
8
|
+
to_char(occurred_at at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') as occurred_at`;
|
|
9
|
+
/**
|
|
10
|
+
* The event store on PostgreSQL, shared by the ORM adapters, which differ only in how they run a
|
|
11
|
+
* statement. An append is one statement on the executor of the unit of work: it takes the head of
|
|
12
|
+
* the store, a row locked until the transaction ends, only when the stream still has the expected
|
|
13
|
+
* version, and inserts the events after it. Appends therefore commit in the order of their
|
|
14
|
+
* positions, and a subscription that read up to a position never meets a smaller one later; the
|
|
15
|
+
* price is that two appends never run side by side, whatever their streams. A conflict that slips
|
|
16
|
+
* between the check and the insert hits the unique (stream, version) and is a ConcurrencyError too,
|
|
17
|
+
* and so are a serialization failure (a unit of work at REPEATABLE READ or SERIALIZABLE) and a
|
|
18
|
+
* deadlock with row locks the same transaction took in another order: the caller retries.
|
|
19
|
+
*/
|
|
20
|
+
export class PostgresEventStore {
|
|
21
|
+
run;
|
|
22
|
+
events;
|
|
23
|
+
headRow;
|
|
24
|
+
constructor(run, options = {}) {
|
|
25
|
+
this.run = run;
|
|
26
|
+
this.events = qualifiedTable(options.schema, 'events');
|
|
27
|
+
this.headRow = qualifiedTable(options.schema, 'head');
|
|
28
|
+
}
|
|
29
|
+
async append(stream, expectedVersion, events) {
|
|
30
|
+
if (events.length === 0) {
|
|
31
|
+
return this.unchanged(stream, expectedVersion);
|
|
32
|
+
}
|
|
33
|
+
await this.run(`insert into ${this.headRow} (id, position) values (1, 0) on conflict (id) do nothing`, []);
|
|
34
|
+
const inserted = await this.inserted(stream, expectedVersion, events);
|
|
35
|
+
if (inserted.length === 0) {
|
|
36
|
+
throw new ConcurrencyError(stream);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
version: Math.max(...inserted.map((row) => Number(row['version']))),
|
|
40
|
+
position: Math.max(...inserted.map((row) => Number(row['position']))),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async readStream(stream, after = 0) {
|
|
44
|
+
const rows = await this.run(`select ${SELECTED} from ${this.events} where stream = $1::text and version > $2::integer order by version`, [stream, after]);
|
|
45
|
+
return rows.map(storedEventOf);
|
|
46
|
+
}
|
|
47
|
+
async readAll(after, limit) {
|
|
48
|
+
const rows = await this.run(`select ${SELECTED} from ${this.events} where position > $1::bigint order by position limit $2::integer`, [after, limit]);
|
|
49
|
+
return rows.map(storedEventOf);
|
|
50
|
+
}
|
|
51
|
+
async head() {
|
|
52
|
+
const [row] = await this.run(`select position from ${this.headRow} where id = 1`, []);
|
|
53
|
+
return Number(row?.['position'] ?? 0);
|
|
54
|
+
}
|
|
55
|
+
async inserted(stream, expected, events) {
|
|
56
|
+
try {
|
|
57
|
+
return await this.run(this.appendStatement(), [stream, expected, JSON.stringify(events.map(recordOf))]);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (isAppendConflict(error)) {
|
|
61
|
+
throw new ConcurrencyError(stream);
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
appendStatement() {
|
|
67
|
+
return `with input as (
|
|
68
|
+
select $1::text as stream, $2::integer as expected, $3::jsonb as events
|
|
69
|
+
), held as (
|
|
70
|
+
select coalesce(max(e.version), 0) as version from ${this.events} e, input where e.stream = input.stream
|
|
71
|
+
), moved as (
|
|
72
|
+
update ${this.headRow} h set position = h.position + jsonb_array_length(input.events)
|
|
73
|
+
from input, held
|
|
74
|
+
where h.id = 1 and held.version = input.expected
|
|
75
|
+
returning h.position - jsonb_array_length(input.events) as base
|
|
76
|
+
)
|
|
77
|
+
insert into ${this.events} (${COLUMNS})
|
|
78
|
+
select moved.base + e.n, input.stream, input.expected + e.n, e.id, e.type, e.schema_version, e.data, e.metadata, e.occurred_at
|
|
79
|
+
from moved, input, jsonb_to_recordset(input.events)
|
|
80
|
+
as e(n integer, id text, type text, schema_version integer, data jsonb, metadata jsonb, occurred_at timestamptz)
|
|
81
|
+
order by e.n
|
|
82
|
+
returning position, version`;
|
|
83
|
+
}
|
|
84
|
+
async unchanged(stream, expected) {
|
|
85
|
+
const [row] = await this.run(`select coalesce(max(version), 0) as version from ${this.events} where stream = $1::text`, [stream]);
|
|
86
|
+
if (Number(row?.['version'] ?? 0) !== expected) {
|
|
87
|
+
throw new ConcurrencyError(stream);
|
|
88
|
+
}
|
|
89
|
+
return { version: expected, position: await this.head() };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function recordOf(event, index) {
|
|
93
|
+
return {
|
|
94
|
+
n: index + 1,
|
|
95
|
+
id: event.id,
|
|
96
|
+
type: event.type,
|
|
97
|
+
schema_version: event.schemaVersion,
|
|
98
|
+
data: event.data,
|
|
99
|
+
metadata: event.metadata ?? {},
|
|
100
|
+
occurred_at: event.occurredAt.toISOString(),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function storedEventOf(row) {
|
|
104
|
+
const id = String(row['event_id']);
|
|
105
|
+
return {
|
|
106
|
+
id,
|
|
107
|
+
stream: String(row['stream']),
|
|
108
|
+
version: Number(row['version']),
|
|
109
|
+
position: Number(row['position']),
|
|
110
|
+
type: String(row['type']),
|
|
111
|
+
schemaVersion: Number(row['schema_version']),
|
|
112
|
+
data: storedDataFrom(row['data'], `The data of stored event ${id}`),
|
|
113
|
+
metadata: storedDataFrom(row['metadata'], `The metadata of stored event ${id}`),
|
|
114
|
+
occurredAt: instantOf(row['occurred_at']),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function instantOf(value) {
|
|
118
|
+
return value instanceof Date ? value : new Date(String(value));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=postgres-event-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-event-store.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-event-store.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StoredSnapshot } from '../../../application/event-sourcing/stored-snapshot.js';
|
|
2
|
+
import type { SnapshotStore } from '../../../application/ports/snapshot-store.js';
|
|
3
|
+
import type { SqlRun } from '../../read-model/sql-run.js';
|
|
4
|
+
import type { EventStoreTablesOptions } from './event-store-tables-options.js';
|
|
5
|
+
/** The snapshots of the streams on PostgreSQL: one row per stream, never replaced by an older version. */
|
|
6
|
+
export declare class PostgresSnapshotStore implements SnapshotStore {
|
|
7
|
+
private readonly run;
|
|
8
|
+
private readonly table;
|
|
9
|
+
constructor(run: SqlRun, options?: EventStoreTablesOptions);
|
|
10
|
+
find(stream: string): Promise<StoredSnapshot | undefined>;
|
|
11
|
+
save(snapshot: StoredSnapshot): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=postgres-snapshot-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-snapshot-store.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-snapshot-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAI/E,0GAA0G;AAC1G,qBAAa,qBAAsB,YAAW,aAAa;IAIvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B,YACmB,GAAG,EAAE,MAAM,EAC5B,OAAO,GAAE,uBAA4B,EAGtC;IAEK,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAc9D;IAEK,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlD;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { qualifiedTable } from './qualified-table.js';
|
|
2
|
+
import { storedDataFrom } from './stored-data-from.js';
|
|
3
|
+
/** The snapshots of the streams on PostgreSQL: one row per stream, never replaced by an older version. */
|
|
4
|
+
export class PostgresSnapshotStore {
|
|
5
|
+
run;
|
|
6
|
+
table;
|
|
7
|
+
constructor(run, options = {}) {
|
|
8
|
+
this.run = run;
|
|
9
|
+
this.table = qualifiedTable(options.schema, 'snapshots');
|
|
10
|
+
}
|
|
11
|
+
async find(stream) {
|
|
12
|
+
const [row] = await this.run(`select stream, version, schema_version, data from ${this.table} where stream = $1::text`, [stream]);
|
|
13
|
+
return row === undefined
|
|
14
|
+
? undefined
|
|
15
|
+
: {
|
|
16
|
+
stream,
|
|
17
|
+
version: Number(row['version']),
|
|
18
|
+
schemaVersion: Number(row['schema_version']),
|
|
19
|
+
data: storedDataFrom(row['data'], `The snapshot of ${stream}`),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async save(snapshot) {
|
|
23
|
+
await this.run(`insert into ${this.table} as s (stream, version, schema_version, data) values ($1::text, $2::integer, $3::integer, $4::jsonb)
|
|
24
|
+
on conflict (stream) do update set version = excluded.version, schema_version = excluded.schema_version, data = excluded.data, taken_at = now()
|
|
25
|
+
where s.version < excluded.version`, [snapshot.stream, snapshot.version, snapshot.schemaVersion, JSON.stringify(snapshot.data)]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=postgres-snapshot-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-snapshot-store.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-snapshot-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,0GAA0G;AAC1G,MAAM,OAAO,qBAAqB;IAIb,GAAG;IAHL,KAAK,CAAS;IAE/B,YACmB,GAAW,EAC5B,OAAO,GAA4B,EAAE;mBADpB,GAAG;QAGpB,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAc;QACvB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAC1B,qDAAqD,IAAI,CAAC,KAAK,0BAA0B,EACzF,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,GAAG,KAAK,SAAS;YACtB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACE,MAAM;gBACN,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC/B,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBAC5C,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,mBAAmB,MAAM,EAAE,CAAC;aAC/D,CAAC;IACR,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAwB;QACjC,MAAM,IAAI,CAAC,GAAG,CACZ,eAAe,IAAI,CAAC,KAAK;;mCAEI,EAC7B,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAC3F,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SubjectKey } from '../../../application/event-sourcing/subject-key.js';
|
|
2
|
+
import type { SubjectKeyStore } from '../../../application/ports/subject-key-store.js';
|
|
3
|
+
import type { SqlRun } from '../../read-model/sql-run.js';
|
|
4
|
+
import type { EventStoreTablesOptions } from './event-store-tables-options.js';
|
|
5
|
+
/**
|
|
6
|
+
* The keys of the data subjects on PostgreSQL: one row per subject, deleted by an erasure. A
|
|
7
|
+
* deleted row is gone from the table at once, and from the backups as they expire. In the
|
|
8
|
+
* database of the events, a backup older than an erasure holds both the sealed values and their
|
|
9
|
+
* key: in production give this store a `SqlRun` of another database, backed up with a shorter
|
|
10
|
+
* retention than the events.
|
|
11
|
+
*/
|
|
12
|
+
export declare class PostgresSubjectKeyStore implements SubjectKeyStore {
|
|
13
|
+
private readonly run;
|
|
14
|
+
private readonly table;
|
|
15
|
+
constructor(run: SqlRun, options?: EventStoreTablesOptions);
|
|
16
|
+
keyFor(subject: string): Promise<SubjectKey>;
|
|
17
|
+
find(keyId: string): Promise<SubjectKey | undefined>;
|
|
18
|
+
erase(subject: string): Promise<boolean>;
|
|
19
|
+
private held;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=postgres-subject-key-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-subject-key-store.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-subject-key-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAK/E;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAI3D,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B,YACmB,GAAG,EAAE,MAAM,EAC5B,OAAO,GAAE,uBAA4B,EAGtC;IAEK,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAmBjD;IAEK,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAMzD;IAEK,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI7C;YAEa,IAAI;CAOnB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { randomBytes, randomUUID } from 'node:crypto';
|
|
2
|
+
import { qualifiedTable } from './qualified-table.js';
|
|
3
|
+
/**
|
|
4
|
+
* The keys of the data subjects on PostgreSQL: one row per subject, deleted by an erasure. A
|
|
5
|
+
* deleted row is gone from the table at once, and from the backups as they expire. In the
|
|
6
|
+
* database of the events, a backup older than an erasure holds both the sealed values and their
|
|
7
|
+
* key: in production give this store a `SqlRun` of another database, backed up with a shorter
|
|
8
|
+
* retention than the events.
|
|
9
|
+
*/
|
|
10
|
+
export class PostgresSubjectKeyStore {
|
|
11
|
+
run;
|
|
12
|
+
table;
|
|
13
|
+
constructor(run, options = {}) {
|
|
14
|
+
this.run = run;
|
|
15
|
+
this.table = qualifiedTable(options.schema, 'subjectKeys');
|
|
16
|
+
}
|
|
17
|
+
async keyFor(subject) {
|
|
18
|
+
const held = await this.held(subject);
|
|
19
|
+
if (held !== undefined) {
|
|
20
|
+
return held;
|
|
21
|
+
}
|
|
22
|
+
await this.run(`insert into ${this.table} (subject, key_id, material) values ($1::text, $2::text, $3::text) on conflict (subject) do nothing`, [subject, randomUUID(), randomBytes(32).toString('base64')]);
|
|
23
|
+
const created = await this.held(subject);
|
|
24
|
+
if (created === undefined) {
|
|
25
|
+
throw new TypeError(`The key of ${subject} was erased while it was being created`);
|
|
26
|
+
}
|
|
27
|
+
return created;
|
|
28
|
+
}
|
|
29
|
+
async find(keyId) {
|
|
30
|
+
const [row] = await this.run(`select subject, key_id, material from ${this.table} where key_id = $1::text`, [
|
|
31
|
+
keyId,
|
|
32
|
+
]);
|
|
33
|
+
return row === undefined ? undefined : keyOf(row);
|
|
34
|
+
}
|
|
35
|
+
async erase(subject) {
|
|
36
|
+
return ((await this.run(`delete from ${this.table} where subject = $1::text returning subject`, [subject])).length > 0);
|
|
37
|
+
}
|
|
38
|
+
async held(subject) {
|
|
39
|
+
const [row] = await this.run(`select subject, key_id, material from ${this.table} where subject = $1::text`, [
|
|
40
|
+
subject,
|
|
41
|
+
]);
|
|
42
|
+
return row === undefined ? undefined : keyOf(row);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function keyOf(row) {
|
|
46
|
+
return { id: String(row['key_id']), subject: String(row['subject']), material: String(row['material']) };
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=postgres-subject-key-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-subject-key-store.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-subject-key-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD;;;;;;GAMG;AACH,MAAM,OAAO,uBAAuB;IAIf,GAAG;IAHL,KAAK,CAAS;IAE/B,YACmB,GAAW,EAC5B,OAAO,GAA4B,EAAE;mBADpB,GAAG;QAGpB,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,CAAC,GAAG,CACZ,eAAe,IAAI,CAAC,KAAK,qGAAqG,EAC9H,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAC5D,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CAAC,cAAc,OAAO,wCAAwC,CAAC,CAAC;QACrF,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,yCAAyC,IAAI,CAAC,KAAK,0BAA0B,EAAE;YAC1G,KAAK;SACN,CAAC,CAAC;QAEH,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAe;QACzB,OAAO,CACL,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,KAAK,6CAA6C,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAC/G,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,OAAe;QAChC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,yCAAyC,IAAI,CAAC,KAAK,2BAA2B,EAAE;YAC3G,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;CACF;AAED,SAAS,KAAK,CAAC,GAAQ;IACrB,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;AAC3G,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EVENT_STORE_TABLES } from './event-store-tables.js';
|
|
2
|
+
/** A table of the event store, quoted and in its schema when it has one. */
|
|
3
|
+
export declare function qualifiedTable(schema: string | undefined, table: keyof typeof EVENT_STORE_TABLES): string;
|
|
4
|
+
//# sourceMappingURL=qualified-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualified-table.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/qualified-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,OAAO,kBAAkB,GAAG,MAAM,CAIzG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EVENT_STORE_TABLES } from './event-store-tables.js';
|
|
2
|
+
/** A table of the event store, quoted and in its schema when it has one. */
|
|
3
|
+
export function qualifiedTable(schema, table) {
|
|
4
|
+
const name = quoted(EVENT_STORE_TABLES[table]);
|
|
5
|
+
return schema === undefined ? name : `${quoted(schema)}.${name}`;
|
|
6
|
+
}
|
|
7
|
+
function quoted(identifier) {
|
|
8
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=qualified-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualified-table.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/qualified-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAAC,MAA0B,EAAE,KAAsC;IAC/F,MAAM,IAAI,GAAG,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;AACnE,CAAC;AAED,SAAS,MAAM,CAAC,UAAkB;IAChC,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StoredData } from '../../../application/event-sourcing/stored-data.js';
|
|
2
|
+
/** A `jsonb` column as the driver answered it, parsed when it came back as text, checked to be a JSON object. */
|
|
3
|
+
export declare function storedDataFrom(value: unknown, where: string): StoredData;
|
|
4
|
+
//# sourceMappingURL=stored-data-from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-data-from.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/stored-data-from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAIrF,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAQxE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UnreadableEventError } from '../../../application/event-sourcing/unreadable-event-error.js';
|
|
2
|
+
/** A `jsonb` column as the driver answered it, parsed when it came back as text, checked to be a JSON object. */
|
|
3
|
+
export function storedDataFrom(value, where) {
|
|
4
|
+
const parsed = typeof value === 'string' ? JSON.parse(value) : value;
|
|
5
|
+
if (!isJsonObject(parsed)) {
|
|
6
|
+
throw new UnreadableEventError(`${where} is not a JSON object`);
|
|
7
|
+
}
|
|
8
|
+
return parsed;
|
|
9
|
+
}
|
|
10
|
+
function isJsonObject(value) {
|
|
11
|
+
if (typeof value !== 'object' || value === null) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15
|
+
return (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJson);
|
|
16
|
+
}
|
|
17
|
+
function isJson(value) {
|
|
18
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number') {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return Array.isArray(value) ? value.every(isJson) : isJsonObject(value);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=stored-data-from.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-data-from.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/stored-data-from.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+DAA+D,CAAC;AAErG,iHAAiH;AACjH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,KAAa;IAC1D,MAAM,MAAM,GAAY,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAE9E,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,oBAAoB,CAAC,GAAG,KAAK,uBAAuB,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAExD,OAAO,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACtG,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3G,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StoredData } from '../../application/event-sourcing/stored-data.js';
|
|
2
|
+
import type { StoredJson } from '../../application/event-sourcing/stored-json.js';
|
|
3
|
+
/** Answers what replaces an object of the data, or `undefined` to keep it and look inside. */
|
|
4
|
+
type Rewrite = (object: StoredData) => Promise<StoredJson> | undefined;
|
|
5
|
+
/** A copy of the data where `rewrite` replaced the objects it recognised, at any depth. */
|
|
6
|
+
export declare function rewriteObjects(data: StoredData, rewrite: Rewrite): Promise<StoredData>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=rewrite-objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewrite-objects.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/rewrite-objects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAElF,8FAA8F;AAC9F,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAEvE,2FAA2F;AAC3F,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAM5F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isStoredData } from '../../application/event-sourcing/is-stored-data.js';
|
|
2
|
+
/** A copy of the data where `rewrite` replaced the objects it recognised, at any depth. */
|
|
3
|
+
export async function rewriteObjects(data, rewrite) {
|
|
4
|
+
const entries = await Promise.all(Object.entries(data).map(async ([key, value]) => [key, await rewritten(value, rewrite)]));
|
|
5
|
+
return Object.fromEntries(entries);
|
|
6
|
+
}
|
|
7
|
+
async function rewritten(value, rewrite) {
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
return Promise.all(value.map((item) => rewritten(item, rewrite)));
|
|
10
|
+
}
|
|
11
|
+
if (!isStoredData(value)) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
return (await rewrite(value)) ?? rewriteObjects(value, rewrite);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=rewrite-objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewrite-objects.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/rewrite-objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAOlF,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAgB,EAAE,OAAgB;IACrE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAU,CAAC,CAClG,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,KAAiB,EAAE,OAAgB;IAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StoredEventData } from '../../application/event-sourcing/stored-event-data.js';
|
|
2
|
+
import type { SnapshotStore } from '../../application/ports/snapshot-store.js';
|
|
3
|
+
/** When and how an event-sourced repository keeps snapshots of its aggregates: a choice per aggregate. */
|
|
4
|
+
export interface SnapshotPolicy<A, S> {
|
|
5
|
+
readonly store: SnapshotStore;
|
|
6
|
+
/** A snapshot is taken by the save that makes the stream reach a multiple of this many events. */
|
|
7
|
+
readonly every: number;
|
|
8
|
+
/** The version of the shape `encode` writes: a snapshot of another version is ignored, the stream replayed from its start. */
|
|
9
|
+
readonly version: number;
|
|
10
|
+
/** The state to keep, as plain data. */
|
|
11
|
+
encode(aggregate: A): object;
|
|
12
|
+
decode(data: StoredEventData): S;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=snapshot-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-policy.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/snapshot-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE/E,0GAA0G;AAC1G,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8HAA8H;IAC9H,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-policy.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/snapshot-policy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StoredEvent } from '../../application/event-sourcing/stored-event.js';
|
|
2
|
+
import type { DomainEvent } from '../../domain/domain-event.js';
|
|
3
|
+
/** The stored event each domain event was read from, for `storedStampOf`. */
|
|
4
|
+
export declare const storedOrigins: WeakMap<DomainEvent, StoredEvent>;
|
|
5
|
+
//# sourceMappingURL=stored-origins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-origins.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-origins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,6EAA6E;AAC7E,eAAO,MAAM,aAAa,mCAA0C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-origins.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-origins.ts"],"names":[],"mappings":"AAGA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,EAA4B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EventStamp } from '../../application/read-model/event-stamp.js';
|
|
2
|
+
import type { DomainEvent } from '../../domain/domain-event.js';
|
|
3
|
+
/**
|
|
4
|
+
* The stamp of a domain event read from an event store, for the row of a read model it changes:
|
|
5
|
+
* the id of the stored event, its instant and its version in its stream, so that the rows of one
|
|
6
|
+
* stream are ordered by the stream and not by clocks. `undefined` for an event that was not read
|
|
7
|
+
* from a store (dispatched by a save): a projection fed both ways falls back to `stampOf`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function storedStampOf(event: DomainEvent): EventStamp | undefined;
|
|
10
|
+
//# sourceMappingURL=stored-stamp-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-stamp-of.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-stamp-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAMxE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { storedOrigins } from './stored-origins.js';
|
|
2
|
+
/**
|
|
3
|
+
* The stamp of a domain event read from an event store, for the row of a read model it changes:
|
|
4
|
+
* the id of the stored event, its instant and its version in its stream, so that the rows of one
|
|
5
|
+
* stream are ordered by the stream and not by clocks. `undefined` for an event that was not read
|
|
6
|
+
* from a store (dispatched by a save): a projection fed both ways falls back to `stampOf`.
|
|
7
|
+
*/
|
|
8
|
+
export function storedStampOf(event) {
|
|
9
|
+
const stored = storedOrigins.get(event);
|
|
10
|
+
return stored === undefined
|
|
11
|
+
? undefined
|
|
12
|
+
: { eventId: stored.id, occurredAt: stored.occurredAt, version: stored.version };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=stored-stamp-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-stamp-of.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-stamp-of.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScanVerdict } from '../../application/files/scan-verdict.js';
|
|
2
|
+
import type { FileScanner } from '../../application/ports/file-scanner.js';
|
|
3
|
+
/** The scanner of a project that has none yet: accepts every file without reading it. Bind a real one before accepting files from strangers. */
|
|
4
|
+
export declare class AcceptEveryFileScanner implements FileScanner {
|
|
5
|
+
scan(): Promise<ScanVerdict>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=accept-every-file-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accept-every-file-scanner.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/files/accept-every-file-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAE3E,gJAAgJ;AAChJ,qBAAa,sBAAuB,YAAW,WAAW;IACxD,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAE3B;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The scanner of a project that has none yet: accepts every file without reading it. Bind a real one before accepting files from strangers. */
|
|
2
|
+
export class AcceptEveryFileScanner {
|
|
3
|
+
scan() {
|
|
4
|
+
return Promise.resolve({ accepted: true });
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=accept-every-file-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accept-every-file-scanner.js","sourceRoot":"","sources":["../../../src/infrastructure/files/accept-every-file-scanner.ts"],"names":[],"mappings":"AAGA,gJAAgJ;AAChJ,MAAM,OAAO,sBAAsB;IACjC,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/files/collect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAOlD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
/** The end of a pipeline that keeps every chunk: for the storage of the tests only. */
|
|
3
|
+
export function collect(chunks) {
|
|
4
|
+
return new Writable({
|
|
5
|
+
write(chunk, _encoding, done) {
|
|
6
|
+
chunks.push(chunk);
|
|
7
|
+
done();
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=collect.js.map
|