@sasscore/database 0.0.1
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 +281 -0
- package/dist/connection/index.d.ts +7 -0
- package/dist/connection/index.d.ts.map +1 -0
- package/dist/connection/index.js +7 -0
- package/dist/connection/index.js.map +1 -0
- package/dist/connection/infrastructure/connection.module.d.ts +18 -0
- package/dist/connection/infrastructure/connection.module.d.ts.map +1 -0
- package/dist/connection/infrastructure/connection.module.js +75 -0
- package/dist/connection/infrastructure/connection.module.js.map +1 -0
- package/dist/connection/infrastructure/sequelize.service.d.ts +16 -0
- package/dist/connection/infrastructure/sequelize.service.d.ts.map +1 -0
- package/dist/connection/infrastructure/sequelize.service.js +56 -0
- package/dist/connection/infrastructure/sequelize.service.js.map +1 -0
- package/dist/database.module.d.ts +25 -0
- package/dist/database.module.d.ts.map +1 -0
- package/dist/database.module.js +71 -0
- package/dist/database.module.js.map +1 -0
- package/dist/health/database-health.service.d.ts +12 -0
- package/dist/health/database-health.service.d.ts.map +1 -0
- package/dist/health/database-health.service.js +48 -0
- package/dist/health/database-health.service.js.map +1 -0
- package/dist/health/database-health.types.d.ts +8 -0
- package/dist/health/database-health.types.d.ts.map +1 -0
- package/dist/health/database-health.types.js +2 -0
- package/dist/health/database-health.types.js.map +1 -0
- package/dist/health/health.module.d.ts +3 -0
- package/dist/health/health.module.d.ts.map +1 -0
- package/dist/health/health.module.js +20 -0
- package/dist/health/health.module.js.map +1 -0
- package/dist/health/index.d.ts +12 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +9 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/migration-health.service.d.ts +14 -0
- package/dist/health/migration-health.service.d.ts.map +1 -0
- package/dist/health/migration-health.service.js +43 -0
- package/dist/health/migration-health.service.js.map +1 -0
- package/dist/health/migration-health.types.d.ts +9 -0
- package/dist/health/migration-health.types.d.ts.map +1 -0
- package/dist/health/migration-health.types.js +2 -0
- package/dist/health/migration-health.types.js.map +1 -0
- package/dist/health/outbox-health.service.d.ts +14 -0
- package/dist/health/outbox-health.service.d.ts.map +1 -0
- package/dist/health/outbox-health.service.js +79 -0
- package/dist/health/outbox-health.service.js.map +1 -0
- package/dist/health/outbox-health.types.d.ts +15 -0
- package/dist/health/outbox-health.types.d.ts.map +1 -0
- package/dist/health/outbox-health.types.js +2 -0
- package/dist/health/outbox-health.types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/20260826173000-create-outbox-events.d.ts +5 -0
- package/dist/migrations/20260826173000-create-outbox-events.d.ts.map +1 -0
- package/dist/migrations/20260826173000-create-outbox-events.js +102 -0
- package/dist/migrations/20260826173000-create-outbox-events.js.map +1 -0
- package/dist/migrations/create-migration-registry.d.ts +9 -0
- package/dist/migrations/create-migration-registry.d.ts.map +1 -0
- package/dist/migrations/create-migration-registry.js +37 -0
- package/dist/migrations/create-migration-registry.js.map +1 -0
- package/dist/migrations/index.d.ts +7 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +6 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migration-registry.d.ts +4 -0
- package/dist/migrations/migration-registry.d.ts.map +1 -0
- package/dist/migrations/migration-registry.js +4 -0
- package/dist/migrations/migration-registry.js.map +1 -0
- package/dist/migrations/migration-runner.d.ts +27 -0
- package/dist/migrations/migration-runner.d.ts.map +1 -0
- package/dist/migrations/migration-runner.js +135 -0
- package/dist/migrations/migration-runner.js.map +1 -0
- package/dist/migrations/migration.helpers.d.ts +8 -0
- package/dist/migrations/migration.helpers.d.ts.map +1 -0
- package/dist/migrations/migration.helpers.js +9 -0
- package/dist/migrations/migration.helpers.js.map +1 -0
- package/dist/migrations/migration.types.d.ts +26 -0
- package/dist/migrations/migration.types.d.ts.map +1 -0
- package/dist/migrations/migration.types.js +2 -0
- package/dist/migrations/migration.types.js.map +1 -0
- package/dist/models/base.model.d.ts +17 -0
- package/dist/models/base.model.d.ts.map +1 -0
- package/dist/models/base.model.js +56 -0
- package/dist/models/base.model.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +2 -0
- package/dist/models/index.js.map +1 -0
- package/dist/outbox/application/outbox.processor.d.ts +20 -0
- package/dist/outbox/application/outbox.processor.d.ts.map +1 -0
- package/dist/outbox/application/outbox.processor.js +66 -0
- package/dist/outbox/application/outbox.processor.js.map +1 -0
- package/dist/outbox/application/outbox.publisher.d.ts +17 -0
- package/dist/outbox/application/outbox.publisher.d.ts.map +1 -0
- package/dist/outbox/application/outbox.publisher.js +33 -0
- package/dist/outbox/application/outbox.publisher.js.map +1 -0
- package/dist/outbox/application/ports/event-dispatcher.port.d.ts +7 -0
- package/dist/outbox/application/ports/event-dispatcher.port.d.ts.map +1 -0
- package/dist/outbox/application/ports/event-dispatcher.port.js +2 -0
- package/dist/outbox/application/ports/event-dispatcher.port.js.map +1 -0
- package/dist/outbox/domain/entities/domain-event.entity.d.ts +11 -0
- package/dist/outbox/domain/entities/domain-event.entity.d.ts.map +1 -0
- package/dist/outbox/domain/entities/domain-event.entity.js +15 -0
- package/dist/outbox/domain/entities/domain-event.entity.js.map +1 -0
- package/dist/outbox/domain/entities/outbox-event.types.d.ts +21 -0
- package/dist/outbox/domain/entities/outbox-event.types.d.ts.map +1 -0
- package/dist/outbox/domain/entities/outbox-event.types.js +2 -0
- package/dist/outbox/domain/entities/outbox-event.types.js.map +1 -0
- package/dist/outbox/domain/index.d.ts +5 -0
- package/dist/outbox/domain/index.d.ts.map +1 -0
- package/dist/outbox/domain/index.js +3 -0
- package/dist/outbox/domain/index.js.map +1 -0
- package/dist/outbox/domain/repositories/outbox.repository.interface.d.ts +13 -0
- package/dist/outbox/domain/repositories/outbox.repository.interface.d.ts.map +1 -0
- package/dist/outbox/domain/repositories/outbox.repository.interface.js +2 -0
- package/dist/outbox/domain/repositories/outbox.repository.interface.js.map +1 -0
- package/dist/outbox/domain/value-objects/event-types.d.ts +19 -0
- package/dist/outbox/domain/value-objects/event-types.d.ts.map +1 -0
- package/dist/outbox/domain/value-objects/event-types.js +18 -0
- package/dist/outbox/domain/value-objects/event-types.js.map +1 -0
- package/dist/outbox/event-dispatcher.d.ts +3 -0
- package/dist/outbox/event-dispatcher.d.ts.map +1 -0
- package/dist/outbox/event-dispatcher.js +3 -0
- package/dist/outbox/event-dispatcher.js.map +1 -0
- package/dist/outbox/event.entity.d.ts +4 -0
- package/dist/outbox/event.entity.d.ts.map +1 -0
- package/dist/outbox/event.entity.js +3 -0
- package/dist/outbox/event.entity.js.map +1 -0
- package/dist/outbox/index.d.ts +19 -0
- package/dist/outbox/index.d.ts.map +1 -0
- package/dist/outbox/index.js +17 -0
- package/dist/outbox/index.js.map +1 -0
- package/dist/outbox/infrastructure/dispatch/event-dispatcher.d.ts +21 -0
- package/dist/outbox/infrastructure/dispatch/event-dispatcher.d.ts.map +1 -0
- package/dist/outbox/infrastructure/dispatch/event-dispatcher.js +55 -0
- package/dist/outbox/infrastructure/dispatch/event-dispatcher.js.map +1 -0
- package/dist/outbox/infrastructure/dispatch/flat-handler.registry.d.ts +13 -0
- package/dist/outbox/infrastructure/dispatch/flat-handler.registry.d.ts.map +1 -0
- package/dist/outbox/infrastructure/dispatch/flat-handler.registry.js +46 -0
- package/dist/outbox/infrastructure/dispatch/flat-handler.registry.js.map +1 -0
- package/dist/outbox/infrastructure/outbox.module.d.ts +13 -0
- package/dist/outbox/infrastructure/outbox.module.d.ts.map +1 -0
- package/dist/outbox/infrastructure/outbox.module.js +53 -0
- package/dist/outbox/infrastructure/outbox.module.js.map +1 -0
- package/dist/outbox/infrastructure/persistence/outbox-event.model.d.ts +106 -0
- package/dist/outbox/infrastructure/persistence/outbox-event.model.d.ts.map +1 -0
- package/dist/outbox/infrastructure/persistence/outbox-event.model.js +186 -0
- package/dist/outbox/infrastructure/persistence/outbox-event.model.js.map +1 -0
- package/dist/outbox/infrastructure/persistence/outbox-persistence.module.d.ts +9 -0
- package/dist/outbox/infrastructure/persistence/outbox-persistence.module.d.ts.map +1 -0
- package/dist/outbox/infrastructure/persistence/outbox-persistence.module.js +25 -0
- package/dist/outbox/infrastructure/persistence/outbox-persistence.module.js.map +1 -0
- package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.d.ts +24 -0
- package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.d.ts.map +1 -0
- package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.js +191 -0
- package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.js.map +1 -0
- package/dist/outbox/outbox-flat-handler.registry.d.ts +4 -0
- package/dist/outbox/outbox-flat-handler.registry.d.ts.map +1 -0
- package/dist/outbox/outbox-flat-handler.registry.js +4 -0
- package/dist/outbox/outbox-flat-handler.registry.js.map +1 -0
- package/dist/outbox/outbox.constants.d.ts +3 -0
- package/dist/outbox/outbox.constants.d.ts.map +1 -0
- package/dist/outbox/outbox.constants.js +3 -0
- package/dist/outbox/outbox.constants.js.map +1 -0
- package/dist/outbox/outbox.module.d.ts +3 -0
- package/dist/outbox/outbox.module.d.ts.map +1 -0
- package/dist/outbox/outbox.module.js +3 -0
- package/dist/outbox/outbox.module.js.map +1 -0
- package/dist/outbox/outbox.processor.d.ts +4 -0
- package/dist/outbox/outbox.processor.d.ts.map +1 -0
- package/dist/outbox/outbox.processor.js +4 -0
- package/dist/outbox/outbox.processor.js.map +1 -0
- package/dist/outbox/outbox.publisher.d.ts +3 -0
- package/dist/outbox/outbox.publisher.d.ts.map +1 -0
- package/dist/outbox/outbox.publisher.js +3 -0
- package/dist/outbox/outbox.publisher.js.map +1 -0
- package/dist/outbox/outbox.repository.d.ts +3 -0
- package/dist/outbox/outbox.repository.d.ts.map +1 -0
- package/dist/outbox/outbox.repository.js +3 -0
- package/dist/outbox/outbox.repository.js.map +1 -0
- package/dist/providers/database.providers.d.ts +4 -0
- package/dist/providers/database.providers.d.ts.map +1 -0
- package/dist/providers/database.providers.js +25 -0
- package/dist/providers/database.providers.js.map +1 -0
- package/dist/providers/database.tokens.d.ts +43 -0
- package/dist/providers/database.tokens.d.ts.map +1 -0
- package/dist/providers/database.tokens.js +43 -0
- package/dist/providers/database.tokens.js.map +1 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/repositories/index.d.ts +5 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +4 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/main.repository.d.ts +163 -0
- package/dist/repositories/main.repository.d.ts.map +1 -0
- package/dist/repositories/main.repository.js +1120 -0
- package/dist/repositories/main.repository.js.map +1 -0
- package/dist/repositories/repository-execution-mode.enum.d.ts +11 -0
- package/dist/repositories/repository-execution-mode.enum.d.ts.map +1 -0
- package/dist/repositories/repository-execution-mode.enum.js +12 -0
- package/dist/repositories/repository-execution-mode.enum.js.map +1 -0
- package/dist/repositories/repository.types.d.ts +65 -0
- package/dist/repositories/repository.types.d.ts.map +1 -0
- package/dist/repositories/repository.types.js +2 -0
- package/dist/repositories/repository.types.js.map +1 -0
- package/dist/repositories/tenant-scope-mode.enum.d.ts +13 -0
- package/dist/repositories/tenant-scope-mode.enum.d.ts.map +1 -0
- package/dist/repositories/tenant-scope-mode.enum.js +14 -0
- package/dist/repositories/tenant-scope-mode.enum.js.map +1 -0
- package/dist/tenancy/domain/ports/tenant-context.port.d.ts +22 -0
- package/dist/tenancy/domain/ports/tenant-context.port.d.ts.map +1 -0
- package/dist/tenancy/domain/ports/tenant-context.port.js +2 -0
- package/dist/tenancy/domain/ports/tenant-context.port.js.map +1 -0
- package/dist/tenancy/index.d.ts +8 -0
- package/dist/tenancy/index.d.ts.map +1 -0
- package/dist/tenancy/index.js +7 -0
- package/dist/tenancy/index.js.map +1 -0
- package/dist/tenancy/infrastructure/cls-tenant-context.adapter.d.ts +26 -0
- package/dist/tenancy/infrastructure/cls-tenant-context.adapter.d.ts.map +1 -0
- package/dist/tenancy/infrastructure/cls-tenant-context.adapter.js +73 -0
- package/dist/tenancy/infrastructure/cls-tenant-context.adapter.js.map +1 -0
- package/dist/tenancy/infrastructure/tenant-context.module.d.ts +7 -0
- package/dist/tenancy/infrastructure/tenant-context.module.d.ts.map +1 -0
- package/dist/tenancy/infrastructure/tenant-context.module.js +32 -0
- package/dist/tenancy/infrastructure/tenant-context.module.js.map +1 -0
- package/dist/tokens.d.ts +6 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +6 -0
- package/dist/tokens.js.map +1 -0
- package/dist/transaction-manager/application/transaction-manager.service.d.ts +12 -0
- package/dist/transaction-manager/application/transaction-manager.service.d.ts.map +1 -0
- package/dist/transaction-manager/application/transaction-manager.service.js +29 -0
- package/dist/transaction-manager/application/transaction-manager.service.js.map +1 -0
- package/dist/transaction-manager/domain/ports/transaction-manager.port.d.ts +9 -0
- package/dist/transaction-manager/domain/ports/transaction-manager.port.d.ts.map +1 -0
- package/dist/transaction-manager/domain/ports/transaction-manager.port.js +2 -0
- package/dist/transaction-manager/domain/ports/transaction-manager.port.js.map +1 -0
- package/dist/transaction-manager/index.d.ts +7 -0
- package/dist/transaction-manager/index.d.ts.map +1 -0
- package/dist/transaction-manager/index.js +6 -0
- package/dist/transaction-manager/index.js.map +1 -0
- package/dist/types/database-module-options.d.ts +12 -0
- package/dist/types/database-module-options.d.ts.map +1 -0
- package/dist/types/database-module-options.js +2 -0
- package/dist/types/database-module-options.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.repository.interface.d.ts","sourceRoot":"","sources":["../../../../outbox/domain/repositories/outbox.repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CACF,KAAK,EAAE,WAAW,EAClB,WAAW,CAAC,EAAE,WAAW,EACzB,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAEjE,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.repository.interface.js","sourceRoot":"","sources":["../../../../outbox/domain/repositories/outbox.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable event type strings stored in `outbox_events.event_type`.
|
|
3
|
+
* Never rename after production use — use event_version for payload evolution.
|
|
4
|
+
*/
|
|
5
|
+
export declare const EVENT_TYPES: {
|
|
6
|
+
readonly INVITATION_CREATED: "invitation.created";
|
|
7
|
+
readonly INVITATION_APPROVED: "invitation.approved";
|
|
8
|
+
readonly INVITATION_REVOKED: "invitation.revoked";
|
|
9
|
+
readonly INVITATION_RESENT: "invitation.resent";
|
|
10
|
+
readonly PASSWORD_RESET_REQUESTED: "password_reset.requested";
|
|
11
|
+
readonly PASSWORD_RESET_COMPLETED: "password_reset.completed";
|
|
12
|
+
readonly INVOICE_PAID: "billing.invoice.paid";
|
|
13
|
+
readonly SUBSCRIPTION_ACTIVATED: "billing.subscription.activated";
|
|
14
|
+
readonly MARKETING_CAMPAIGN_STARTED: "marketing.campaign.started";
|
|
15
|
+
readonly MARKETING_RECIPIENT_SEND: "marketing.recipient.send";
|
|
16
|
+
readonly TENANT_PROVISIONED: "tenant.provisioned";
|
|
17
|
+
};
|
|
18
|
+
export type EventType = (typeof EVENT_TYPES)[keyof typeof EVENT_TYPES];
|
|
19
|
+
//# sourceMappingURL=event-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../../outbox/domain/value-objects/event-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;CAgBd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable event type strings stored in `outbox_events.event_type`.
|
|
3
|
+
* Never rename after production use — use event_version for payload evolution.
|
|
4
|
+
*/
|
|
5
|
+
export const EVENT_TYPES = {
|
|
6
|
+
INVITATION_CREATED: 'invitation.created',
|
|
7
|
+
INVITATION_APPROVED: 'invitation.approved',
|
|
8
|
+
INVITATION_REVOKED: 'invitation.revoked',
|
|
9
|
+
INVITATION_RESENT: 'invitation.resent',
|
|
10
|
+
PASSWORD_RESET_REQUESTED: 'password_reset.requested',
|
|
11
|
+
PASSWORD_RESET_COMPLETED: 'password_reset.completed',
|
|
12
|
+
INVOICE_PAID: 'billing.invoice.paid',
|
|
13
|
+
SUBSCRIPTION_ACTIVATED: 'billing.subscription.activated',
|
|
14
|
+
MARKETING_CAMPAIGN_STARTED: 'marketing.campaign.started',
|
|
15
|
+
MARKETING_RECIPIENT_SEND: 'marketing.recipient.send',
|
|
16
|
+
TENANT_PROVISIONED: 'tenant.provisioned',
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=event-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.js","sourceRoot":"","sources":["../../../../outbox/domain/value-objects/event-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,kBAAkB,EAAE,oBAAoB;IACxC,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;IAEtC,wBAAwB,EAAE,0BAA0B;IACpD,wBAAwB,EAAE,0BAA0B;IAEpD,YAAY,EAAE,sBAAsB;IACpC,sBAAsB,EAAE,gCAAgC;IAExD,0BAA0B,EAAE,4BAA4B;IACxD,wBAAwB,EAAE,0BAA0B;IAEpD,kBAAkB,EAAE,oBAAoB;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-dispatcher.d.ts","sourceRoot":"","sources":["../../outbox/event-dispatcher.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-dispatcher.js","sourceRoot":"","sources":["../../outbox/event-dispatcher.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** @deprecated Import from `domains/database/outbox/domain` instead. */
|
|
2
|
+
export { DomainEvent } from './domain/entities/domain-event.entity.js';
|
|
3
|
+
export type { OutboxEventRecord, OutboxEventStatus } from './domain/entities/outbox-event.types.js';
|
|
4
|
+
//# sourceMappingURL=event.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.entity.d.ts","sourceRoot":"","sources":["../../outbox/event.entity.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.entity.js","sourceRoot":"","sources":["../../outbox/event.entity.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sasscore/database/outbox — public API
|
|
3
|
+
*
|
|
4
|
+
* Do not import from `outbox/infrastructure/*` or `outbox/domain/*` directly.
|
|
5
|
+
*/
|
|
6
|
+
export { OUTBOX_TOKENS, DATABASE_TOKENS } from '../tokens.js';
|
|
7
|
+
export { DomainEvent } from './domain/entities/domain-event.entity.js';
|
|
8
|
+
export type { OutboxEventRecord, OutboxEventStatus } from './domain/entities/outbox-event.types.js';
|
|
9
|
+
export type { IOutboxRepository } from './domain/repositories/outbox.repository.interface.js';
|
|
10
|
+
export { EVENT_TYPES, type EventType } from './domain/value-objects/event-types.js';
|
|
11
|
+
export { OutboxPublisher, type OutboxPublishOptions } from './application/outbox.publisher.js';
|
|
12
|
+
export { OutboxProcessor, type OutboxBatchResult } from './application/outbox.processor.js';
|
|
13
|
+
export { DatabaseOutboxModule,
|
|
14
|
+
/** @deprecated */ OutboxModule, } from './infrastructure/outbox.module.js';
|
|
15
|
+
export { OutboxEventDispatcher, type OutboxEventMapper, } from './infrastructure/dispatch/event-dispatcher.js';
|
|
16
|
+
export { OutboxFlatHandlerRegistry, type OutboxFlatHandler, } from './infrastructure/dispatch/flat-handler.registry.js';
|
|
17
|
+
/** @deprecated Use {@link OutboxProcessor} */
|
|
18
|
+
export { OutboxProcessor as OutboxProcessorService } from './application/outbox.processor.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../outbox/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACpG,YAAY,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE5F,OAAO,EACL,oBAAoB;AACpB,kBAAkB,CAAC,YAAY,GAChC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,qBAAqB,EACrB,KAAK,iBAAiB,GACvB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,yBAAyB,EACzB,KAAK,iBAAiB,GACvB,MAAM,oDAAoD,CAAC;AAE5D,8CAA8C;AAC9C,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sasscore/database/outbox — public API
|
|
3
|
+
*
|
|
4
|
+
* Do not import from `outbox/infrastructure/*` or `outbox/domain/*` directly.
|
|
5
|
+
*/
|
|
6
|
+
export { OUTBOX_TOKENS, DATABASE_TOKENS } from '../tokens.js';
|
|
7
|
+
export { DomainEvent } from './domain/entities/domain-event.entity.js';
|
|
8
|
+
export { EVENT_TYPES } from './domain/value-objects/event-types.js';
|
|
9
|
+
export { OutboxPublisher } from './application/outbox.publisher.js';
|
|
10
|
+
export { OutboxProcessor } from './application/outbox.processor.js';
|
|
11
|
+
export { DatabaseOutboxModule,
|
|
12
|
+
/** @deprecated */ OutboxModule, } from './infrastructure/outbox.module.js';
|
|
13
|
+
export { OutboxEventDispatcher, } from './infrastructure/dispatch/event-dispatcher.js';
|
|
14
|
+
export { OutboxFlatHandlerRegistry, } from './infrastructure/dispatch/flat-handler.registry.js';
|
|
15
|
+
/** @deprecated Use {@link OutboxProcessor} */
|
|
16
|
+
export { OutboxProcessor as OutboxProcessorService } from './application/outbox.processor.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../outbox/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAkB,MAAM,uCAAuC,CAAC;AAEpF,OAAO,EAAE,eAAe,EAA6B,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,eAAe,EAA0B,MAAM,mCAAmC,CAAC;AAE5F,OAAO,EACL,oBAAoB;AACpB,kBAAkB,CAAC,YAAY,GAChC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,qBAAqB,GAEtB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,yBAAyB,GAE1B,MAAM,oDAAoD,CAAC;AAE5D,8CAA8C;AAC9C,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EventBus, type IEvent } from '@nestjs/cqrs';
|
|
2
|
+
import type { IOutboxEventDispatcher } from '../../application/ports/event-dispatcher.port.js';
|
|
3
|
+
import { OutboxFlatHandlerRegistry } from './flat-handler.registry.js';
|
|
4
|
+
/** Maps a persisted outbox payload to an application/integration event. */
|
|
5
|
+
export type OutboxEventMapper = (payload: Record<string, unknown>) => IEvent;
|
|
6
|
+
/**
|
|
7
|
+
* Delivers outbox payloads via flat handlers or registered mappers + EventBus.
|
|
8
|
+
*
|
|
9
|
+
* Business-specific mappers (invitation, companies, iam) must be registered by the
|
|
10
|
+
* host app — this package must not import business modules.
|
|
11
|
+
*/
|
|
12
|
+
export declare class OutboxEventDispatcher implements IOutboxEventDispatcher {
|
|
13
|
+
private readonly eventBus;
|
|
14
|
+
private readonly flatHandlers;
|
|
15
|
+
private readonly logger;
|
|
16
|
+
private readonly mappers;
|
|
17
|
+
constructor(eventBus: EventBus, flatHandlers: OutboxFlatHandlerRegistry);
|
|
18
|
+
registerMapper(eventType: string, mapper: OutboxEventMapper): void;
|
|
19
|
+
dispatch(eventType: string, payload: unknown): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=event-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-dispatcher.d.ts","sourceRoot":"","sources":["../../../../outbox/infrastructure/dispatch/event-dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;AAG7E;;;;;GAKG;AACH,qBACa,qBAAsB,YAAW,sBAAsB;IAKhE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAL/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;gBAG7C,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,yBAAyB;IAG1D,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAS5D,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAenE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var OutboxEventDispatcher_1;
|
|
11
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
12
|
+
import { EventBus } from '@nestjs/cqrs';
|
|
13
|
+
import { OutboxFlatHandlerRegistry } from './flat-handler.registry.js';
|
|
14
|
+
/**
|
|
15
|
+
* Delivers outbox payloads via flat handlers or registered mappers + EventBus.
|
|
16
|
+
*
|
|
17
|
+
* Business-specific mappers (invitation, companies, iam) must be registered by the
|
|
18
|
+
* host app — this package must not import business modules.
|
|
19
|
+
*/
|
|
20
|
+
let OutboxEventDispatcher = OutboxEventDispatcher_1 = class OutboxEventDispatcher {
|
|
21
|
+
eventBus;
|
|
22
|
+
flatHandlers;
|
|
23
|
+
logger = new Logger(OutboxEventDispatcher_1.name);
|
|
24
|
+
mappers = new Map();
|
|
25
|
+
constructor(eventBus, flatHandlers) {
|
|
26
|
+
this.eventBus = eventBus;
|
|
27
|
+
this.flatHandlers = flatHandlers;
|
|
28
|
+
}
|
|
29
|
+
registerMapper(eventType, mapper) {
|
|
30
|
+
if (this.mappers.has(eventType)) {
|
|
31
|
+
throw new Error(`OutboxEventDispatcher: duplicate mapper for event type "${eventType}".`);
|
|
32
|
+
}
|
|
33
|
+
this.mappers.set(eventType, mapper);
|
|
34
|
+
}
|
|
35
|
+
async dispatch(eventType, payload) {
|
|
36
|
+
if (this.flatHandlers.has(eventType)) {
|
|
37
|
+
await this.flatHandlers.dispatch(eventType, payload);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const mapper = this.mappers.get(eventType);
|
|
41
|
+
if (!mapper) {
|
|
42
|
+
throw new Error(`No outbox dispatcher registered for event type: ${eventType}`);
|
|
43
|
+
}
|
|
44
|
+
const applicationEvent = mapper(payload);
|
|
45
|
+
await this.eventBus.publish(applicationEvent);
|
|
46
|
+
this.logger.debug(`Dispatched outbox event via EventBus: ${eventType}`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
OutboxEventDispatcher = OutboxEventDispatcher_1 = __decorate([
|
|
50
|
+
Injectable(),
|
|
51
|
+
__metadata("design:paramtypes", [EventBus,
|
|
52
|
+
OutboxFlatHandlerRegistry])
|
|
53
|
+
], OutboxEventDispatcher);
|
|
54
|
+
export { OutboxEventDispatcher };
|
|
55
|
+
//# sourceMappingURL=event-dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-dispatcher.js","sourceRoot":"","sources":["../../../../outbox/infrastructure/dispatch/event-dispatcher.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAe,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAMvE;;;;;GAKG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAKb;IACA;IALF,MAAM,GAAG,IAAI,MAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEhE,YACmB,QAAkB,EAClB,YAAuC;QADvC,aAAQ,GAAR,QAAQ,CAAU;QAClB,iBAAY,GAAZ,YAAY,CAA2B;IACvD,CAAC;IAEJ,cAAc,CAAC,SAAiB,EAAE,MAAyB;QACzD,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,2DAA2D,SAAS,IAAI,CACzE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,SAAiB,EAAE,OAAgB;QAChD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mDAAmD,SAAS,EAAE,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAkC,CAAC,CAAC;QACpE,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,SAAS,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF,CAAA;AAjCY,qBAAqB;IADjC,UAAU,EAAE;qCAMkB,QAAQ;QACJ,yBAAyB;GAN/C,qBAAqB,CAiCjC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type OutboxFlatHandler = (payload: unknown) => Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* Optional direct handlers for outbox payloads (bypass EventBus mapping).
|
|
4
|
+
* Use when integration is queue/webhook-only and does not need CQRS application events.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OutboxFlatHandlerRegistry {
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private readonly handlers;
|
|
9
|
+
register(eventType: string, handler: OutboxFlatHandler): void;
|
|
10
|
+
has(eventType: string): boolean;
|
|
11
|
+
dispatch(eventType: string, payload: unknown): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=flat-handler.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-handler.registry.d.ts","sourceRoot":"","sources":["../../../../outbox/infrastructure/dispatch/flat-handler.registry.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpE;;;GAGG;AACH,qBACa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IAEjE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAS7D,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIzB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBnE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var OutboxFlatHandlerRegistry_1;
|
|
8
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
9
|
+
/**
|
|
10
|
+
* Optional direct handlers for outbox payloads (bypass EventBus mapping).
|
|
11
|
+
* Use when integration is queue/webhook-only and does not need CQRS application events.
|
|
12
|
+
*/
|
|
13
|
+
let OutboxFlatHandlerRegistry = OutboxFlatHandlerRegistry_1 = class OutboxFlatHandlerRegistry {
|
|
14
|
+
logger = new Logger(OutboxFlatHandlerRegistry_1.name);
|
|
15
|
+
handlers = new Map();
|
|
16
|
+
register(eventType, handler) {
|
|
17
|
+
if (this.handlers.has(eventType)) {
|
|
18
|
+
throw new Error(`OutboxFlatHandlerRegistry: duplicate handler for event type "${eventType}".`);
|
|
19
|
+
}
|
|
20
|
+
this.handlers.set(eventType, handler);
|
|
21
|
+
}
|
|
22
|
+
has(eventType) {
|
|
23
|
+
return this.handlers.has(eventType);
|
|
24
|
+
}
|
|
25
|
+
async dispatch(eventType, payload) {
|
|
26
|
+
const handler = this.handlers.get(eventType);
|
|
27
|
+
if (!handler) {
|
|
28
|
+
throw new Error(`No flat outbox handler registered for event type: ${eventType}`);
|
|
29
|
+
}
|
|
30
|
+
const start = Date.now();
|
|
31
|
+
try {
|
|
32
|
+
await handler(payload);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
this.logger.debug('Dispatched flat outbox event', {
|
|
36
|
+
eventType,
|
|
37
|
+
durationMs: Date.now() - start,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
OutboxFlatHandlerRegistry = OutboxFlatHandlerRegistry_1 = __decorate([
|
|
43
|
+
Injectable()
|
|
44
|
+
], OutboxFlatHandlerRegistry);
|
|
45
|
+
export { OutboxFlatHandlerRegistry };
|
|
46
|
+
//# sourceMappingURL=flat-handler.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-handler.registry.js","sourceRoot":"","sources":["../../../../outbox/infrastructure/dispatch/flat-handler.registry.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIpD;;;GAGG;AAEI,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IACnB,MAAM,GAAG,IAAI,MAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IACpD,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEjE,QAAQ,CAAC,SAAiB,EAAE,OAA0B;QACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,gEAAgE,SAAS,IAAI,CAC9E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,GAAG,CAAC,SAAiB;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,SAAiB,EAAE,OAAgB;QAChD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qDAAqD,SAAS,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE;gBAChD,SAAS;gBACT,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AAjCY,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CAiCrC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OutboxFlatHandlerRegistry } from './dispatch/flat-handler.registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Database Outbox — guaranteed delivery (Sequelize + PostgreSQL + transactional outbox table).
|
|
4
|
+
*
|
|
5
|
+
* Business contexts import this module once globally and inject {@link OutboxPublisher}.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DatabaseOutboxModule {
|
|
8
|
+
}
|
|
9
|
+
/** @deprecated Use {@link DatabaseOutboxModule} */
|
|
10
|
+
export { DatabaseOutboxModule as OutboxModule };
|
|
11
|
+
/** @deprecated Use {@link OutboxFlatHandlerRegistry} */
|
|
12
|
+
export { OutboxFlatHandlerRegistry as OutboxEventHandlerRegistry };
|
|
13
|
+
//# sourceMappingURL=outbox.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.module.d.ts","sourceRoot":"","sources":["../../../outbox/infrastructure/outbox.module.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAIhF;;;;GAIG;AACH,qBAuBa,oBAAoB;CAAG;AAEpC,mDAAmD;AACnD,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,yBAAyB,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Global, Module } from '@nestjs/common';
|
|
8
|
+
import { OutboxPublisher } from '../application/outbox.publisher.js';
|
|
9
|
+
import { OutboxProcessor } from '../application/outbox.processor.js';
|
|
10
|
+
import { outboxTokenProviders } from '../../providers/database.providers.js';
|
|
11
|
+
import { DATABASE_TOKENS } from '../../providers/database.tokens.js';
|
|
12
|
+
import { OutboxEventDispatcher } from './dispatch/event-dispatcher.js';
|
|
13
|
+
import { OutboxFlatHandlerRegistry } from './dispatch/flat-handler.registry.js';
|
|
14
|
+
import { OutboxPersistenceModule } from './persistence/outbox-persistence.module.js';
|
|
15
|
+
import { SequelizeOutboxRepository } from './persistence/sequelize-outbox.repository.js';
|
|
16
|
+
/**
|
|
17
|
+
* Database Outbox — guaranteed delivery (Sequelize + PostgreSQL + transactional outbox table).
|
|
18
|
+
*
|
|
19
|
+
* Business contexts import this module once globally and inject {@link OutboxPublisher}.
|
|
20
|
+
*/
|
|
21
|
+
let DatabaseOutboxModule = class DatabaseOutboxModule {
|
|
22
|
+
};
|
|
23
|
+
DatabaseOutboxModule = __decorate([
|
|
24
|
+
Global(),
|
|
25
|
+
Module({
|
|
26
|
+
imports: [OutboxPersistenceModule],
|
|
27
|
+
providers: [
|
|
28
|
+
...outboxTokenProviders,
|
|
29
|
+
SequelizeOutboxRepository,
|
|
30
|
+
OutboxPublisher,
|
|
31
|
+
OutboxFlatHandlerRegistry,
|
|
32
|
+
OutboxEventDispatcher,
|
|
33
|
+
OutboxProcessor,
|
|
34
|
+
],
|
|
35
|
+
exports: [
|
|
36
|
+
DATABASE_TOKENS.OUTBOX_REPOSITORY,
|
|
37
|
+
DATABASE_TOKENS.OUTBOX_DISPATCHER,
|
|
38
|
+
DATABASE_TOKENS.OUTBOX_PUBLISHER,
|
|
39
|
+
DATABASE_TOKENS.OUTBOX_PROCESSOR,
|
|
40
|
+
SequelizeOutboxRepository,
|
|
41
|
+
OutboxPublisher,
|
|
42
|
+
OutboxFlatHandlerRegistry,
|
|
43
|
+
OutboxEventDispatcher,
|
|
44
|
+
OutboxProcessor,
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
], DatabaseOutboxModule);
|
|
48
|
+
export { DatabaseOutboxModule };
|
|
49
|
+
/** @deprecated Use {@link DatabaseOutboxModule} */
|
|
50
|
+
export { DatabaseOutboxModule as OutboxModule };
|
|
51
|
+
/** @deprecated Use {@link OutboxFlatHandlerRegistry} */
|
|
52
|
+
export { OutboxFlatHandlerRegistry as OutboxEventHandlerRegistry };
|
|
53
|
+
//# sourceMappingURL=outbox.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.module.js","sourceRoot":"","sources":["../../../outbox/infrastructure/outbox.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAEzF;;;;GAIG;AAwBI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAvBhC,MAAM,EAAE;IACR,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,uBAAuB,CAAC;QAClC,SAAS,EAAE;YACT,GAAG,oBAAoB;YACvB,yBAAyB;YACzB,eAAe;YACf,yBAAyB;YACzB,qBAAqB;YACrB,eAAe;SAChB;QACD,OAAO,EAAE;YACP,eAAe,CAAC,iBAAiB;YACjC,eAAe,CAAC,iBAAiB;YACjC,eAAe,CAAC,gBAAgB;YAChC,eAAe,CAAC,gBAAgB;YAChC,yBAAyB;YACzB,eAAe;YACf,yBAAyB;YACzB,qBAAqB;YACrB,eAAe;SAChB;KACF,CAAC;GACW,oBAAoB,CAAG;;AAEpC,mDAAmD;AACnD,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,yBAAyB,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbox Event Model
|
|
3
|
+
*
|
|
4
|
+
* Transactional Outbox Pattern
|
|
5
|
+
* Stores domain events in DB for guaranteed delivery
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Save aggregate + events in same transaction
|
|
9
|
+
* 2. OutboxProcessor reads pending events
|
|
10
|
+
* 3. Publishes to EventBus
|
|
11
|
+
* 4. Marks as processed
|
|
12
|
+
*
|
|
13
|
+
* Benefits:
|
|
14
|
+
* - 100% consistency (atomic with aggregate)
|
|
15
|
+
* - Guaranteed delivery
|
|
16
|
+
* - Retry logic
|
|
17
|
+
* - Audit trail
|
|
18
|
+
*
|
|
19
|
+
* Note: Uses Model directly (not BaseModel) because:
|
|
20
|
+
* - INTEGER serial id (aligned with rest of SaaS Core schema)
|
|
21
|
+
* - No soft delete needed
|
|
22
|
+
*/
|
|
23
|
+
import { Model } from 'sequelize-typescript';
|
|
24
|
+
export declare class OutboxEventModel extends Model {
|
|
25
|
+
id: number;
|
|
26
|
+
aggregateType: string;
|
|
27
|
+
aggregateId: string;
|
|
28
|
+
eventType: string;
|
|
29
|
+
payload: any;
|
|
30
|
+
/**
|
|
31
|
+
* Event version for schema evolution
|
|
32
|
+
* Critical for:
|
|
33
|
+
* - Replaying old events
|
|
34
|
+
* - Handling payload structure changes
|
|
35
|
+
* - Long-term system evolution
|
|
36
|
+
*/
|
|
37
|
+
eventVersion: number;
|
|
38
|
+
/**
|
|
39
|
+
* Processing status
|
|
40
|
+
*
|
|
41
|
+
* States:
|
|
42
|
+
* - pending: Ready to process
|
|
43
|
+
* - processing: Currently being processed (prevents race conditions)
|
|
44
|
+
* - processed: Successfully completed
|
|
45
|
+
* - failed: Error occurred (will retry based on next_retry_at)
|
|
46
|
+
* - dead_letter: Permanently failed after max retries (requires manual intervention)
|
|
47
|
+
*
|
|
48
|
+
* Why STRING instead of ENUM:
|
|
49
|
+
* - ENUM in Postgres is hard to change (requires migration with locks)
|
|
50
|
+
* - ENUM blocks deployments
|
|
51
|
+
* - STRING is flexible and enterprise-friendly
|
|
52
|
+
* - Check constraint provides validation
|
|
53
|
+
*/
|
|
54
|
+
status: 'pending' | 'processing' | 'processed' | 'failed' | 'dead_letter';
|
|
55
|
+
retryCount: number;
|
|
56
|
+
/**
|
|
57
|
+
* Next retry timestamp for exponential backoff
|
|
58
|
+
*
|
|
59
|
+
* Critical for:
|
|
60
|
+
* - Exponential backoff control
|
|
61
|
+
* - Preventing infinite retry loops
|
|
62
|
+
* - Rate limiting failed events
|
|
63
|
+
*
|
|
64
|
+
* Polling query:
|
|
65
|
+
* WHERE status IN ('pending', 'failed')
|
|
66
|
+
* AND (next_retry_at IS NULL OR next_retry_at <= NOW())
|
|
67
|
+
*/
|
|
68
|
+
nextRetryAt: Date | null;
|
|
69
|
+
processedAt: Date | null;
|
|
70
|
+
processingStartedAt: Date | null;
|
|
71
|
+
/**
|
|
72
|
+
* Correlation ID for distributed tracing
|
|
73
|
+
*
|
|
74
|
+
* Critical for:
|
|
75
|
+
* - Tracing request flow across services
|
|
76
|
+
* - Debugging production issues
|
|
77
|
+
* - Observability
|
|
78
|
+
*
|
|
79
|
+
* Example: All events from same HTTP request share correlation_id
|
|
80
|
+
*/
|
|
81
|
+
correlationId: string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Causation ID - ID of event that caused this event
|
|
84
|
+
*
|
|
85
|
+
* Example:
|
|
86
|
+
* - InvitationCreated (causation: null)
|
|
87
|
+
* - InvitationApproved (causation: InvitationCreated.id)
|
|
88
|
+
*/
|
|
89
|
+
causationId: string | null;
|
|
90
|
+
error: string | null;
|
|
91
|
+
createdAt: Date;
|
|
92
|
+
/**
|
|
93
|
+
* Updated timestamp
|
|
94
|
+
*
|
|
95
|
+
* CRITICAL: NO @UpdatedAt decorator!
|
|
96
|
+
* We manage updated_at manually to prevent race conditions:
|
|
97
|
+
* - On INSERT: set same as created_at
|
|
98
|
+
* - On UPDATE (claim): set to NOW() explicitly in SQL
|
|
99
|
+
*
|
|
100
|
+
* @UpdatedAt would auto-update on every save(), causing:
|
|
101
|
+
* - created_at != updated_at even on fresh inserts
|
|
102
|
+
* - False positive "already claimed" detection
|
|
103
|
+
*/
|
|
104
|
+
updatedAt: Date;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=outbox-event.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-event.model.d.ts","sourceRoot":"","sources":["../../../../outbox/infrastructure/persistence/outbox-event.model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAIL,KAAK,EAGN,MAAM,sBAAsB,CAAC;AAE9B,qBAea,gBAAiB,SAAQ,KAAK;IAOjC,EAAE,EAAE,MAAM,CAAC;IAOX,aAAa,EAAE,MAAM,CAAC;IAOtB,WAAW,EAAE,MAAM,CAAC;IAOpB,SAAS,EAAE,MAAM,CAAC;IAOlB,OAAO,EAAE,GAAG,CAAC;IAErB;;;;;;OAMG;IAOK,YAAY,EAAE,MAAM,CAAC;IAE7B;;;;;;;;;;;;;;;OAeG;IAOK,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IAQ1E,UAAU,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;;OAWG;IAMK,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAOzB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAOzB,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC;IAEzC;;;;;;;;;OASG;IAMK,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC;;;;;;OAMG;IAMK,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAO3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAQrB,SAAS,EAAE,IAAI,CAAC;IAExB;;;;;;;;;;;OAWG;IAMK,SAAS,EAAE,IAAI,CAAC;CACzB"}
|