@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,27 @@
|
|
|
1
|
+
import { type Sequelize } from 'sequelize';
|
|
2
|
+
import type { MigrationDefinition, MigrationRunStatus } from './migration.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stable advisory lock key for @sasscore/database MigrationRunner.
|
|
5
|
+
* Must not change across releases. Independent of DB name / process id.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MIGRATION_ADVISORY_LOCK_KEY = 99324354550529;
|
|
8
|
+
export declare const SCHEMA_MIGRATIONS_TABLE = "schema_migrations";
|
|
9
|
+
export declare class MigrationRunner {
|
|
10
|
+
private readonly sequelize;
|
|
11
|
+
private readonly migrations;
|
|
12
|
+
constructor(sequelize: Sequelize, migrations: MigrationDefinition[]);
|
|
13
|
+
/**
|
|
14
|
+
* Apply pending migrations in deterministic order (transaction per migration).
|
|
15
|
+
* On failure: STOP, TX rollback, DB stays at last committed migration — no auto rollback.
|
|
16
|
+
*/
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
/** Compare registered migrations vs ledger without applying changes. */
|
|
19
|
+
getStatus(): Promise<MigrationRunStatus>;
|
|
20
|
+
private acquireLock;
|
|
21
|
+
private releaseLock;
|
|
22
|
+
private ensureMigrationsTable;
|
|
23
|
+
/** Adds `source` column for databases created before V1 namespace support. */
|
|
24
|
+
private upgradeMigrationsTableIfNeeded;
|
|
25
|
+
private loadAppliedRecords;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=migration-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-runner.d.ts","sourceRoot":"","sources":["../../migrations/migration-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAEV,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,mBAAmB,EAAE;IAGpD;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAiD1B,wEAAwE;IAClE,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC;YAehC,WAAW;YAMX,WAAW;YAMX,qBAAqB;IAiCnC,8EAA8E;YAChE,8BAA8B;YA2B9B,kBAAkB;CAwBjC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
/**
|
|
3
|
+
* Stable advisory lock key for @sasscore/database MigrationRunner.
|
|
4
|
+
* Must not change across releases. Independent of DB name / process id.
|
|
5
|
+
*/
|
|
6
|
+
export const MIGRATION_ADVISORY_LOCK_KEY = 0x5a55c0dedb01;
|
|
7
|
+
export const SCHEMA_MIGRATIONS_TABLE = 'schema_migrations';
|
|
8
|
+
export class MigrationRunner {
|
|
9
|
+
sequelize;
|
|
10
|
+
migrations;
|
|
11
|
+
constructor(sequelize, migrations) {
|
|
12
|
+
this.sequelize = sequelize;
|
|
13
|
+
this.migrations = migrations;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Apply pending migrations in deterministic order (transaction per migration).
|
|
17
|
+
* On failure: STOP, TX rollback, DB stays at last committed migration — no auto rollback.
|
|
18
|
+
*/
|
|
19
|
+
async run() {
|
|
20
|
+
try {
|
|
21
|
+
await this.acquireLock();
|
|
22
|
+
await this.ensureMigrationsTable();
|
|
23
|
+
const executed = await this.loadAppliedRecords();
|
|
24
|
+
for (const migration of this.migrations) {
|
|
25
|
+
if (executed.has(migration.name)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
console.log(`[migrate] Running ${migration.source}/${migration.name}`);
|
|
29
|
+
try {
|
|
30
|
+
await this.sequelize.transaction(async (transaction) => {
|
|
31
|
+
const queryInterface = this.sequelize.getQueryInterface();
|
|
32
|
+
await migration.up(queryInterface, transaction);
|
|
33
|
+
await this.sequelize.query(`INSERT INTO ${SCHEMA_MIGRATIONS_TABLE} (name, source, executed_at) VALUES (:name, :source, NOW())`, {
|
|
34
|
+
replacements: {
|
|
35
|
+
name: migration.name,
|
|
36
|
+
source: migration.source,
|
|
37
|
+
},
|
|
38
|
+
transaction,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
44
|
+
console.error(`[migrate] FAILED ${migration.source}/${migration.name}: ${message}`);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
console.log(`[migrate] Completed ${migration.source}/${migration.name}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
await this.releaseLock();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Compare registered migrations vs ledger without applying changes. */
|
|
55
|
+
async getStatus() {
|
|
56
|
+
await this.ensureMigrationsTable();
|
|
57
|
+
const appliedMap = await this.loadAppliedRecords();
|
|
58
|
+
const applied = [...appliedMap.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
59
|
+
const pending = this.migrations.filter((m) => !appliedMap.has(m.name));
|
|
60
|
+
return {
|
|
61
|
+
applied,
|
|
62
|
+
pending,
|
|
63
|
+
upToDate: pending.length === 0,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async acquireLock() {
|
|
67
|
+
await this.sequelize.query('SELECT pg_advisory_lock(:key)', {
|
|
68
|
+
replacements: { key: MIGRATION_ADVISORY_LOCK_KEY },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async releaseLock() {
|
|
72
|
+
await this.sequelize.query('SELECT pg_advisory_unlock(:key)', {
|
|
73
|
+
replacements: { key: MIGRATION_ADVISORY_LOCK_KEY },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async ensureMigrationsTable() {
|
|
77
|
+
const queryInterface = this.sequelize.getQueryInterface();
|
|
78
|
+
const tables = await queryInterface.showAllTables();
|
|
79
|
+
const normalized = tables.map((t) => typeof t === 'string'
|
|
80
|
+
? t
|
|
81
|
+
: (t.tableName ??
|
|
82
|
+
t.name ??
|
|
83
|
+
String(t)));
|
|
84
|
+
if (!normalized.includes(SCHEMA_MIGRATIONS_TABLE)) {
|
|
85
|
+
await queryInterface.createTable(SCHEMA_MIGRATIONS_TABLE, {
|
|
86
|
+
name: {
|
|
87
|
+
type: DataTypes.TEXT,
|
|
88
|
+
primaryKey: true,
|
|
89
|
+
allowNull: false,
|
|
90
|
+
},
|
|
91
|
+
source: {
|
|
92
|
+
type: DataTypes.TEXT,
|
|
93
|
+
allowNull: false,
|
|
94
|
+
},
|
|
95
|
+
executed_at: {
|
|
96
|
+
type: DataTypes.DATE,
|
|
97
|
+
allowNull: false,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
await this.upgradeMigrationsTableIfNeeded();
|
|
103
|
+
}
|
|
104
|
+
/** Adds `source` column for databases created before V1 namespace support. */
|
|
105
|
+
async upgradeMigrationsTableIfNeeded() {
|
|
106
|
+
const [columns] = await this.sequelize.query(`
|
|
107
|
+
SELECT column_name
|
|
108
|
+
FROM information_schema.columns
|
|
109
|
+
WHERE table_schema = current_schema()
|
|
110
|
+
AND table_name = :table
|
|
111
|
+
`, { replacements: { table: SCHEMA_MIGRATIONS_TABLE } });
|
|
112
|
+
const names = columns.map((c) => c.column_name);
|
|
113
|
+
if (names.includes('source')) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await this.sequelize.query(`
|
|
117
|
+
ALTER TABLE ${SCHEMA_MIGRATIONS_TABLE}
|
|
118
|
+
ADD COLUMN source TEXT NOT NULL DEFAULT 'core'
|
|
119
|
+
`);
|
|
120
|
+
}
|
|
121
|
+
async loadAppliedRecords() {
|
|
122
|
+
const [rows] = await this.sequelize.query(`SELECT name, source, executed_at FROM ${SCHEMA_MIGRATIONS_TABLE} ORDER BY name`);
|
|
123
|
+
const map = new Map();
|
|
124
|
+
for (const row of rows) {
|
|
125
|
+
const source = (row.source ?? 'core');
|
|
126
|
+
map.set(row.name, {
|
|
127
|
+
name: row.name,
|
|
128
|
+
source,
|
|
129
|
+
executedAt: new Date(row.executed_at),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return map;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=migration-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-runner.js","sourceRoot":"","sources":["../../migrations/migration-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAQtD;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAE3D,MAAM,OAAO,eAAe;IAEP;IACA;IAFnB,YACmB,SAAoB,EACpB,UAAiC;QADjC,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAuB;IACjD,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YAEzB,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAEjD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACxC,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;oBACjC,SAAS;gBACX,CAAC;gBAED,OAAO,CAAC,GAAG,CACT,qBAAqB,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,EAAE,CAC1D,CAAC;gBAEF,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,SAAS,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ACN,UAAU,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;aACtC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MigrationDefinition } from './migration.types.js';
|
|
2
|
+
type MigrationBody = Omit<MigrationDefinition, 'source'>;
|
|
3
|
+
/** Migration owned by a @sasscore/* package — immutable for consumers. */
|
|
4
|
+
export declare function defineCoreMigration(def: MigrationBody): MigrationDefinition;
|
|
5
|
+
/** Migration owned by the host application (business domain extension). */
|
|
6
|
+
export declare function defineClientMigration(def: MigrationBody): MigrationDefinition;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=migration.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.helpers.d.ts","sourceRoot":"","sources":["../../migrations/migration.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,KAAK,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AAEzD,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,mBAAmB,CAE3E;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,aAAa,GAAG,mBAAmB,CAE7E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Migration owned by a @sasscore/* package — immutable for consumers. */
|
|
2
|
+
export function defineCoreMigration(def) {
|
|
3
|
+
return { ...def, source: 'core' };
|
|
4
|
+
}
|
|
5
|
+
/** Migration owned by the host application (business domain extension). */
|
|
6
|
+
export function defineClientMigration(def) {
|
|
7
|
+
return { ...def, source: 'client' };
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=migration.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.helpers.js","sourceRoot":"","sources":["../../migrations/migration.helpers.ts"],"names":[],"mappings":"AAIA,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAAC,GAAkB;IACpD,OAAO,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,qBAAqB,CAAC,GAAkB;IACtD,OAAO,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { QueryInterface, Transaction } from 'sequelize';
|
|
2
|
+
/** Ledger namespace: SaaS Core packages vs host application. */
|
|
3
|
+
export type MigrationSource = 'core' | 'client';
|
|
4
|
+
/**
|
|
5
|
+
* Infrastructure-neutral migration contract.
|
|
6
|
+
* Domain packages export `MigrationDefinition[]`; they do not import Nest or the runner.
|
|
7
|
+
*/
|
|
8
|
+
export interface MigrationDefinition {
|
|
9
|
+
/** Globally unique migration id (timestamp prefix recommended). */
|
|
10
|
+
name: string;
|
|
11
|
+
/** `core` = @sasscore/* packages; `client` = host-owned migrations. */
|
|
12
|
+
source: MigrationSource;
|
|
13
|
+
up(queryInterface: QueryInterface, transaction: Transaction): Promise<void>;
|
|
14
|
+
down(queryInterface: QueryInterface, transaction: Transaction): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export interface AppliedMigrationRecord {
|
|
17
|
+
name: string;
|
|
18
|
+
source: MigrationSource;
|
|
19
|
+
executedAt: Date;
|
|
20
|
+
}
|
|
21
|
+
export interface MigrationRunStatus {
|
|
22
|
+
applied: AppliedMigrationRecord[];
|
|
23
|
+
pending: MigrationDefinition[];
|
|
24
|
+
upToDate: boolean;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=migration.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.types.d.ts","sourceRoot":"","sources":["../../migrations/migration.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7D,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,MAAM,EAAE,eAAe,CAAC;IACxB,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAClC,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.types.js","sourceRoot":"","sources":["../../migrations/migration.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
2
|
+
export declare const BASE_MODEL_OPTIONS: {
|
|
3
|
+
paranoid: boolean;
|
|
4
|
+
timestamps: boolean;
|
|
5
|
+
underscored: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Shared Sequelize base for package + application models.
|
|
9
|
+
* Part of `@sasscore/database` public surface (`./models`).
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class BaseModel extends Model {
|
|
12
|
+
id: number;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
deletedAt: Date;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=base.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.model.d.ts","sourceRoot":"","sources":["../../models/base.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqD,MAAM,sBAAsB,CAAC;AAEhG,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAC;AAEF;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,KAAK;IAMnC,EAAE,EAAE,MAAM,CAAC;IAQX,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;IAOhB,SAAS,EAAE,IAAI,CAAC;CACzB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
import { Model, DataType, Column, CreatedAt, UpdatedAt, DeletedAt } from 'sequelize-typescript';
|
|
11
|
+
export const BASE_MODEL_OPTIONS = {
|
|
12
|
+
paranoid: true, // Enables soft delete with deletedAt
|
|
13
|
+
timestamps: true,
|
|
14
|
+
underscored: true,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Shared Sequelize base for package + application models.
|
|
18
|
+
* Part of `@sasscore/database` public surface (`./models`).
|
|
19
|
+
*/
|
|
20
|
+
export class BaseModel extends Model {
|
|
21
|
+
}
|
|
22
|
+
__decorate([
|
|
23
|
+
Column({
|
|
24
|
+
type: DataType.INTEGER,
|
|
25
|
+
primaryKey: true,
|
|
26
|
+
autoIncrement: true,
|
|
27
|
+
}),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], BaseModel.prototype, "id", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
CreatedAt,
|
|
32
|
+
Column({
|
|
33
|
+
type: DataType.DATE,
|
|
34
|
+
allowNull: false,
|
|
35
|
+
field: 'created_at',
|
|
36
|
+
}),
|
|
37
|
+
__metadata("design:type", Date)
|
|
38
|
+
], BaseModel.prototype, "createdAt", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
UpdatedAt,
|
|
41
|
+
Column({
|
|
42
|
+
type: DataType.DATE,
|
|
43
|
+
allowNull: false,
|
|
44
|
+
field: 'updated_at',
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", Date)
|
|
47
|
+
], BaseModel.prototype, "updatedAt", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
DeletedAt,
|
|
50
|
+
Column({
|
|
51
|
+
type: DataType.DATE,
|
|
52
|
+
field: 'deleted_at',
|
|
53
|
+
}),
|
|
54
|
+
__metadata("design:type", Date)
|
|
55
|
+
], BaseModel.prototype, "deletedAt", void 0);
|
|
56
|
+
//# sourceMappingURL=base.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.model.js","sourceRoot":"","sources":["../../models/base.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEhG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,IAAI,EAAE,qCAAqC;IACrD,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAgB,SAAU,SAAQ,KAAK;CA8B5C;AAxBS;IALP,MAAM,CAAC;QACN,IAAI,EAAE,QAAQ,CAAC,OAAO;QACtB,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;KACpB,CAAC;;qCACiB;AAQX;IANP,SAAS;IACT,MAAM,CAAC;QACN,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,YAAY;KACpB,CAAC;8BACiB,IAAI;4CAAC;AAQhB;IANP,SAAS;IACT,MAAM,CAAC;QACN,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,YAAY;KACpB,CAAC;8BACiB,IAAI;4CAAC;AAOhB;IALP,SAAS;IACT,MAAM,CAAC;QACN,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,YAAY;KACpB,CAAC;8BACiB,IAAI;4CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IOutboxRepository } from '../domain/repositories/outbox.repository.interface.js';
|
|
2
|
+
import type { IOutboxEventDispatcher } from './ports/event-dispatcher.port.js';
|
|
3
|
+
export interface OutboxBatchResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
total: number;
|
|
6
|
+
processed: number;
|
|
7
|
+
failed: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Application use case: claim pending outbox rows and deliver them.
|
|
11
|
+
*/
|
|
12
|
+
export declare class OutboxProcessor {
|
|
13
|
+
private readonly outboxRepository;
|
|
14
|
+
private readonly dispatcher;
|
|
15
|
+
constructor(outboxRepository: IOutboxRepository, dispatcher: IOutboxEventDispatcher);
|
|
16
|
+
processBatch(limit?: number): Promise<OutboxBatchResult>;
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Use {@link OutboxProcessor} */
|
|
19
|
+
export { OutboxProcessor as OutboxProcessorService };
|
|
20
|
+
//# sourceMappingURL=outbox.processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.processor.d.ts","sourceRoot":"","sources":["../../../outbox/application/outbox.processor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG/E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBACa,eAAe;IAGxB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAEjC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAFV,gBAAgB,EAAE,iBAAiB,EAEnC,UAAU,EAAE,sBAAsB;IAG/C,YAAY,CAAC,KAAK,SAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAiC5D;AAED,8CAA8C;AAC9C,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Inject, Injectable, Scope } from '@nestjs/common';
|
|
14
|
+
import { DATABASE_TOKENS } from '../../providers/database.tokens.js';
|
|
15
|
+
/**
|
|
16
|
+
* Application use case: claim pending outbox rows and deliver them.
|
|
17
|
+
*/
|
|
18
|
+
let OutboxProcessor = class OutboxProcessor {
|
|
19
|
+
outboxRepository;
|
|
20
|
+
dispatcher;
|
|
21
|
+
constructor(outboxRepository, dispatcher) {
|
|
22
|
+
this.outboxRepository = outboxRepository;
|
|
23
|
+
this.dispatcher = dispatcher;
|
|
24
|
+
}
|
|
25
|
+
async processBatch(limit = 100) {
|
|
26
|
+
try {
|
|
27
|
+
const claimedEvents = await this.outboxRepository.claimPendingEvents(limit);
|
|
28
|
+
if (claimedEvents.length === 0) {
|
|
29
|
+
return { success: true, total: 0, processed: 0, failed: 0 };
|
|
30
|
+
}
|
|
31
|
+
let processed = 0;
|
|
32
|
+
let failed = 0;
|
|
33
|
+
for (const outboxEvent of claimedEvents) {
|
|
34
|
+
try {
|
|
35
|
+
await this.dispatcher.dispatch(outboxEvent.eventType, outboxEvent.payload);
|
|
36
|
+
await this.outboxRepository.markAsProcessed(outboxEvent.id);
|
|
37
|
+
processed++;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
41
|
+
await this.outboxRepository.markAsFailed(outboxEvent.id, message);
|
|
42
|
+
failed++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
total: claimedEvents.length,
|
|
48
|
+
processed,
|
|
49
|
+
failed,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { success: false, total: 0, processed: 0, failed: 0 };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
OutboxProcessor = __decorate([
|
|
58
|
+
Injectable({ scope: Scope.DEFAULT }),
|
|
59
|
+
__param(0, Inject(DATABASE_TOKENS.OUTBOX_REPOSITORY)),
|
|
60
|
+
__param(1, Inject(DATABASE_TOKENS.OUTBOX_DISPATCHER)),
|
|
61
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
62
|
+
], OutboxProcessor);
|
|
63
|
+
export { OutboxProcessor };
|
|
64
|
+
/** @deprecated Use {@link OutboxProcessor} */
|
|
65
|
+
export { OutboxProcessor as OutboxProcessorService };
|
|
66
|
+
//# sourceMappingURL=outbox.processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.processor.js","sourceRoot":"","sources":["../../../outbox/application/outbox.processor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG3D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AASrE;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAGP;IAEA;IAJnB,YAEmB,gBAAmC,EAEnC,UAAkC;QAFlC,qBAAgB,GAAhB,gBAAgB,CAAmB;QAEnC,eAAU,GAAV,UAAU,CAAwB;IAClD,CAAC;IAEJ,K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AM,EAAE,CAAC,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;CACF,CAAA;AAzCY,eAAe;IAD3B,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAGhC,WAAA,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;IAEzC,WAAA,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;;GAJjC,eAAe,CAyC3B;;AAED,8CAA8C;AAC9C,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Transaction } from 'sequelize';
|
|
2
|
+
import type { DomainEvent } from '../domain/entities/domain-event.entity.js';
|
|
3
|
+
import type { IOutboxRepository } from '../domain/repositories/outbox.repository.interface.js';
|
|
4
|
+
export interface OutboxPublishOptions {
|
|
5
|
+
transaction?: Transaction;
|
|
6
|
+
correlationId?: string;
|
|
7
|
+
causationId?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Application use case: persist domain event in the same DB transaction as aggregate write.
|
|
11
|
+
*/
|
|
12
|
+
export declare class OutboxPublisher {
|
|
13
|
+
private readonly outboxRepository;
|
|
14
|
+
constructor(outboxRepository: IOutboxRepository);
|
|
15
|
+
publish(event: DomainEvent, options?: OutboxPublishOptions): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=outbox.publisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.publisher.d.ts","sourceRoot":"","sources":["../../../outbox/application/outbox.publisher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAG/F,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBACa,eAAe;IAGxB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,iBAAiB;IAGhD,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQrF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
14
|
+
import { DATABASE_TOKENS } from '../../providers/database.tokens.js';
|
|
15
|
+
/**
|
|
16
|
+
* Application use case: persist domain event in the same DB transaction as aggregate write.
|
|
17
|
+
*/
|
|
18
|
+
let OutboxPublisher = class OutboxPublisher {
|
|
19
|
+
outboxRepository;
|
|
20
|
+
constructor(outboxRepository) {
|
|
21
|
+
this.outboxRepository = outboxRepository;
|
|
22
|
+
}
|
|
23
|
+
async publish(event, options = {}) {
|
|
24
|
+
await this.outboxRepository.save(event, options.transaction, options.correlationId, options.causationId);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
OutboxPublisher = __decorate([
|
|
28
|
+
Injectable(),
|
|
29
|
+
__param(0, Inject(DATABASE_TOKENS.OUTBOX_REPOSITORY)),
|
|
30
|
+
__metadata("design:paramtypes", [Object])
|
|
31
|
+
], OutboxPublisher);
|
|
32
|
+
export { OutboxPublisher };
|
|
33
|
+
//# sourceMappingURL=outbox.publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.publisher.js","sourceRoot":"","sources":["../../../outbox/application/outbox.publisher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIpD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAQrE;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAGP;IAFnB,YAEmB,gBAAmC;QAAnC,qBAAgB,GAAhB,gBAAgB,CAAmB;IACnD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,KAAkB,EAAE,UAAgC,EAAE;QAClE,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAC9B,KAAK,EACL,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,WAAW,CACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAdY,eAAe;IAD3B,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;;GAFjC,eAAe,CAc3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-dispatcher.port.d.ts","sourceRoot":"","sources":["../../../../outbox/application/ports/event-dispatcher.port.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-dispatcher.port.js","sourceRoot":"","sources":["../../../../outbox/application/ports/event-dispatcher.port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for domain events persisted via transactional outbox.
|
|
3
|
+
* Pure domain — no ORM, no NestJS.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class DomainEvent {
|
|
6
|
+
readonly occurredAt: Date;
|
|
7
|
+
readonly aggregateType: string;
|
|
8
|
+
readonly aggregateId: string;
|
|
9
|
+
constructor(aggregateType: string, aggregateId: string);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=domain-event.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-event.entity.d.ts","sourceRoot":"","sources":["../../../../outbox/domain/entities/domain-event.entity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,WAAW;IAC/B,SAAgB,UAAU,EAAE,IAAI,CAAC;IACjC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAKvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for domain events persisted via transactional outbox.
|
|
3
|
+
* Pure domain — no ORM, no NestJS.
|
|
4
|
+
*/
|
|
5
|
+
export class DomainEvent {
|
|
6
|
+
occurredAt;
|
|
7
|
+
aggregateType;
|
|
8
|
+
aggregateId;
|
|
9
|
+
constructor(aggregateType, aggregateId) {
|
|
10
|
+
this.aggregateType = aggregateType;
|
|
11
|
+
this.aggregateId = aggregateId;
|
|
12
|
+
this.occurredAt = new Date();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=domain-event.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-event.entity.js","sourceRoot":"","sources":["../../../../outbox/domain/entities/domain-event.entity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAgB,WAAW;IACf,UAAU,CAAO;IACjB,aAAa,CAAS;IACtB,WAAW,CAAS;IAEpC,YAAY,aAAqB,EAAE,WAAmB;QACpD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type OutboxEventStatus = 'pending' | 'processing' | 'processed' | 'failed' | 'dead_letter';
|
|
2
|
+
/** Persistence read model for `outbox_events` table. */
|
|
3
|
+
export interface OutboxEventRecord {
|
|
4
|
+
id: number;
|
|
5
|
+
aggregateType: string;
|
|
6
|
+
aggregateId: string;
|
|
7
|
+
eventType: string;
|
|
8
|
+
payload: unknown;
|
|
9
|
+
eventVersion: number;
|
|
10
|
+
status: OutboxEventStatus;
|
|
11
|
+
retryCount: number;
|
|
12
|
+
nextRetryAt: Date | null;
|
|
13
|
+
processedAt: Date | null;
|
|
14
|
+
processingStartedAt: Date | null;
|
|
15
|
+
correlationId: string | null;
|
|
16
|
+
causationId: string | null;
|
|
17
|
+
error: string | null;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
updatedAt: Date;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=outbox-event.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-event.types.d.ts","sourceRoot":"","sources":["../../../../outbox/domain/entities/outbox-event.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,aAAa,CAAC;AAElB,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-event.types.js","sourceRoot":"","sources":["../../../../outbox/domain/entities/outbox-event.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DomainEvent } from './entities/domain-event.entity.js';
|
|
2
|
+
export type { OutboxEventRecord, OutboxEventStatus } from './entities/outbox-event.types.js';
|
|
3
|
+
export type { IOutboxRepository } from './repositories/outbox.repository.interface.js';
|
|
4
|
+
export { EVENT_TYPES, type EventType } from './value-objects/event-types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../outbox/domain/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC7F,YAAY,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../outbox/domain/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAkB,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Transaction } from 'sequelize';
|
|
2
|
+
import type { DomainEvent } from '../entities/domain-event.entity.js';
|
|
3
|
+
import type { OutboxEventRecord } from '../entities/outbox-event.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Outbox persistence port — implemented in infrastructure (Sequelize).
|
|
6
|
+
*/
|
|
7
|
+
export interface IOutboxRepository {
|
|
8
|
+
save(event: DomainEvent, transaction?: Transaction, correlationId?: string, causationId?: string): Promise<void>;
|
|
9
|
+
claimPendingEvents(limit?: number): Promise<OutboxEventRecord[]>;
|
|
10
|
+
markAsProcessed(id: number): Promise<void>;
|
|
11
|
+
markAsFailed(id: number, error: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=outbox.repository.interface.d.ts.map
|