@event-driven-io/emmett-postgresql 0.42.0-rc.1 → 0.42.0-rc.2
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/dist/index.cjs +44 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -7
- package/dist/index.d.ts +14 -7
- package/dist/index.js +44 -27
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1589,7 +1589,7 @@ var pongoMultiStreamProjection = (options) => {
|
|
|
1589
1589
|
await pongo.db().collection(
|
|
1590
1590
|
collectionNameWithVersion,
|
|
1591
1591
|
options.collectionOptions
|
|
1592
|
-
).schema.migrate();
|
|
1592
|
+
).schema.migrate(context.migrationOptions);
|
|
1593
1593
|
} finally {
|
|
1594
1594
|
await pongo.close();
|
|
1595
1595
|
}
|
|
@@ -4166,8 +4166,8 @@ var eventStoreSchemaMigrations = [
|
|
|
4166
4166
|
migration_0_42_0_2_AddProcessorProjectionFunctions,
|
|
4167
4167
|
schemaMigration
|
|
4168
4168
|
];
|
|
4169
|
-
var createEventStoreSchema =
|
|
4170
|
-
|
|
4169
|
+
var createEventStoreSchema = (connectionString, pool, hooks, options) => {
|
|
4170
|
+
return pool.withTransaction(async (tx) => {
|
|
4171
4171
|
const client = await tx.connection.open();
|
|
4172
4172
|
const context = {
|
|
4173
4173
|
execute: tx.execute,
|
|
@@ -4183,10 +4183,15 @@ var createEventStoreSchema = async (connectionString, pool, hooks) => {
|
|
|
4183
4183
|
if (_optionalChain([hooks, 'optionalAccess', _65 => _65.onBeforeSchemaCreated])) {
|
|
4184
4184
|
await hooks.onBeforeSchemaCreated(context);
|
|
4185
4185
|
}
|
|
4186
|
-
await _dumbo.runPostgreSQLMigrations.call(void 0,
|
|
4186
|
+
const result = await _dumbo.runPostgreSQLMigrations.call(void 0,
|
|
4187
|
+
nestedPool,
|
|
4188
|
+
eventStoreSchemaMigrations,
|
|
4189
|
+
options
|
|
4190
|
+
);
|
|
4187
4191
|
if (_optionalChain([hooks, 'optionalAccess', _66 => _66.onAfterSchemaCreated])) {
|
|
4188
4192
|
await hooks.onAfterSchemaCreated(context);
|
|
4189
4193
|
}
|
|
4194
|
+
return result;
|
|
4190
4195
|
} finally {
|
|
4191
4196
|
await nestedPool.close();
|
|
4192
4197
|
}
|
|
@@ -4218,30 +4223,35 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
|
|
|
4218
4223
|
let migrateSchema = void 0;
|
|
4219
4224
|
const autoGenerateSchema = _optionalChain([options, 'access', _68 => _68.schema, 'optionalAccess', _69 => _69.autoMigration]) === void 0 || _optionalChain([options, 'access', _70 => _70.schema, 'optionalAccess', _71 => _71.autoMigration]) !== "None";
|
|
4220
4225
|
const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection: projection2 }) => projection2);
|
|
4221
|
-
const migrate = async () => {
|
|
4226
|
+
const migrate = async (migrationOptions) => {
|
|
4222
4227
|
if (!migrateSchema) {
|
|
4223
|
-
migrateSchema = createEventStoreSchema(
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4228
|
+
migrateSchema = createEventStoreSchema(
|
|
4229
|
+
connectionString,
|
|
4230
|
+
pool,
|
|
4231
|
+
{
|
|
4232
|
+
onBeforeSchemaCreated: async (context) => {
|
|
4233
|
+
if (_optionalChain([options, 'access', _72 => _72.hooks, 'optionalAccess', _73 => _73.onBeforeSchemaCreated])) {
|
|
4234
|
+
await options.hooks.onBeforeSchemaCreated(context);
|
|
4235
|
+
}
|
|
4236
|
+
},
|
|
4237
|
+
onAfterSchemaCreated: async (context) => {
|
|
4238
|
+
for (const projection2 of inlineProjections) {
|
|
4239
|
+
if (projection2.init) {
|
|
4240
|
+
await projection2.init({
|
|
4241
|
+
version: _nullishCoalesce(projection2.version, () => ( 1)),
|
|
4242
|
+
status: "active",
|
|
4243
|
+
registrationType: "inline",
|
|
4244
|
+
context: { ...context, migrationOptions }
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
if (_optionalChain([options, 'access', _74 => _74.hooks, 'optionalAccess', _75 => _75.onAfterSchemaCreated])) {
|
|
4249
|
+
await options.hooks.onAfterSchemaCreated(context);
|
|
4238
4250
|
}
|
|
4239
4251
|
}
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
}
|
|
4244
|
-
});
|
|
4252
|
+
},
|
|
4253
|
+
migrationOptions
|
|
4254
|
+
);
|
|
4245
4255
|
}
|
|
4246
4256
|
return migrateSchema;
|
|
4247
4257
|
};
|
|
@@ -4740,9 +4750,16 @@ var postgreSQLProjector = (options) => {
|
|
|
4740
4750
|
version: _nullishCoalesce(options.projection.version, () => ( version)),
|
|
4741
4751
|
status: "active",
|
|
4742
4752
|
registrationType: "async",
|
|
4743
|
-
context
|
|
4753
|
+
context: {
|
|
4754
|
+
...context,
|
|
4755
|
+
migrationOptions: options.migrationOptions
|
|
4756
|
+
}
|
|
4757
|
+
});
|
|
4758
|
+
if (_optionalChain([options, 'access', _100 => _100.hooks, 'optionalAccess', _101 => _101.onInit]))
|
|
4759
|
+
await options.hooks.onInit({
|
|
4760
|
+
...context,
|
|
4761
|
+
migrationOptions: options.migrationOptions
|
|
4744
4762
|
});
|
|
4745
|
-
if (_optionalChain([options, 'access', _100 => _100.hooks, 'optionalAccess', _101 => _101.onInit])) await options.hooks.onInit(context);
|
|
4746
4763
|
} : _optionalChain([options, 'access', _102 => _102.hooks, 'optionalAccess', _103 => _103.onInit]),
|
|
4747
4764
|
onClose: close ? async (context) => {
|
|
4748
4765
|
if (_optionalChain([options, 'access', _104 => _104.hooks, 'optionalAccess', _105 => _105.onClose])) await _optionalChain([options, 'access', _106 => _106.hooks, 'optionalAccess', _107 => _107.onClose, 'call', _108 => _108(context)]);
|