@medusajs/link-modules 0.2.12-snapshot-20240827104434 → 0.2.12-snapshot-20240829144419

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAkB,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAQxE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,sBAAsB;;IAoBvE;;;OAGG;IACH,SAAS,CAAC,SAAS,SAA2B;gBAG5C,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,CAAC,EAAE,8BAA8B;IAyB1C;;;OAGG;cACa,SAAS,CAAC,QAAQ,GAAE,YAAY,EAAO;IAIvD;;;;;OAKG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;OAKG;cACa,6BAA6B,CAC3C,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAmDjC;;;;;;OAMG;cACa,eAAe,CAC7B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,MAAM,EAAE,2BAA2B,GAAG;QACpC,cAAc,EAAE,2BAA2B,CAAA;QAC3C,GAAG,EAAE,MAAM,CAAA;KACZ;IAgBH;;;OAGG;cACa,aAAa,CAC3B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,SAAS,EAAE,MAAM;IAQnB;;;;;;OAMG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CACR;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,E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cACa,aAAa,CAC3B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,SAAS,EAAE,MAAM;IAQnB;;;;;;OAMG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CACR;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,2BAA2B,CAAA;KAAE,EAAE,CACvE;IAgBD;;OAEG;cACa,sBAAsB,CACpC,cAAc,EAAE,2BAA2B,EAC3C,MAAM,EAAE,YAAY,EACpB,kBAAkB,EAAE,MAAM,EAAE,GAC3B,OAAO,CAAC,2BAA2B,CAAC;IAyEvC;;;;;;OAMG;IACG,UAAU;IAwDhB;;;;;;;OAOG;IACG,WAAW,CAAC,UAAU,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB5E"}
@@ -172,58 +172,58 @@ class MigrationsExecutionPlanner {
172
172
  async getEntityMigrationPlan(linkDescriptor, entity, trackedLinksTables) {
173
173
  const tableName = entity.meta.collection;
174
174
  const orm = await this.createORM([entity]);
175
- const generator = orm.getSchemaGenerator();
176
- const platform = orm.em.getPlatform();
177
- const connection = orm.em.getConnection();
178
- const schemaName = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_dbConfig, "f").schema || "public";
179
- /**
180
- * If the table name for the entity has not been
181
- * managed by us earlier, then we should create
182
- * it.
183
- */
184
- if (!trackedLinksTables.includes(tableName)) {
185
- return {
186
- action: "create",
187
- linkDescriptor,
188
- tableName,
189
- sql: await generator.getCreateSchemaSQL(),
190
- };
191
- }
192
- /**
193
- * Pre-fetching information schema from the database and using that
194
- * as the way to compute the update diff.
195
- *
196
- * @note
197
- * The "loadInformationSchema" mutates the "dbSchema" argument provided
198
- * to it as the first argument.
199
- */
200
- const dbSchema = new postgresql_1.DatabaseSchema(platform, schemaName);
201
- await platform
202
- .getSchemaHelper?.()
203
- ?.loadInformationSchema(dbSchema, connection, [
204
- {
205
- table_name: tableName,
206
- schema_name: schemaName,
207
- },
208
- ]);
209
- const updateSQL = await generator.getUpdateSchemaSQL({
210
- fromSchema: dbSchema,
211
- });
212
- /**
213
- * Entity is upto-date and hence we do not have to perform
214
- * any updates on it.
215
- */
216
- if (!updateSQL.length) {
217
- return {
218
- action: "noop",
219
- linkDescriptor,
220
- tableName,
221
- };
222
- }
223
- const usesUnsafeCommands = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_unsafeSQLCommands, "f").some((fragment) => {
224
- return updateSQL.match(new RegExp(`${fragment}`, "ig"));
225
- });
226
175
  try {
176
+ const generator = orm.getSchemaGenerator();
177
+ const platform = orm.em.getPlatform();
178
+ const connection = orm.em.getConnection();
179
+ const schemaName = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_dbConfig, "f").schema || "public";
180
+ /**
181
+ * If the table name for the entity has not been
182
+ * managed by us earlier, then we should create
183
+ * it.
184
+ */
185
+ if (!trackedLinksTables.includes(tableName)) {
186
+ return {
187
+ action: "create",
188
+ linkDescriptor,
189
+ tableName,
190
+ sql: await generator.getCreateSchemaSQL(),
191
+ };
192
+ }
193
+ /**
194
+ * Pre-fetching information schema from the database and using that
195
+ * as the way to compute the update diff.
196
+ *
197
+ * @note
198
+ * The "loadInformationSchema" mutates the "dbSchema" argument provided
199
+ * to it as the first argument.
200
+ */
201
+ const dbSchema = new postgresql_1.DatabaseSchema(platform, schemaName);
202
+ await platform
203
+ .getSchemaHelper?.()
204
+ ?.loadInformationSchema(dbSchema, connection, [
205
+ {
206
+ table_name: tableName,
207
+ schema_name: schemaName,
208
+ },
209
+ ]);
210
+ const updateSQL = await generator.getUpdateSchemaSQL({
211
+ fromSchema: dbSchema,
212
+ });
213
+ /**
214
+ * Entity is upto-date and hence we do not have to perform
215
+ * any updates on it.
216
+ */
217
+ if (!updateSQL.length) {
218
+ return {
219
+ action: "noop",
220
+ linkDescriptor,
221
+ tableName,
222
+ };
223
+ }
224
+ const usesUnsafeCommands = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_unsafeSQLCommands, "f").some((fragment) => {
225
+ return updateSQL.match(new RegExp(`${fragment}`, "ig"));
226
+ });
227
227
  return {
228
228
  action: usesUnsafeCommands ? "notify" : "update",
229
229
  linkDescriptor,
@@ -244,31 +244,31 @@ class MigrationsExecutionPlanner {
244
244
  */
245
245
  async createPlan() {
246
246
  const orm = await this.createORM();
247
- await this.ensureMigrationsTable(orm);
248
- const executionActions = [];
249
- await this.ensureMigrationsTableUpToDate(orm);
250
- const trackedTables = await this.getTrackedLinksTables(orm);
251
- const trackedTablesNames = trackedTables.map(({ table_name }) => table_name);
252
- /**
253
- * Looping through the new set of entities and generating
254
- * execution plan for them
255
- */
256
- for (let { entity, linkDescriptor } of __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f")) {
257
- executionActions.push(await this.getEntityMigrationPlan(linkDescriptor, entity, trackedTablesNames));
258
- }
259
- const linksTableNames = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f").map(({ entity }) => entity.meta.collection);
260
- /**
261
- * Finding the tables to be removed
262
- */
263
- const tablesToRemove = (0, utils_2.arrayDifference)(trackedTablesNames, linksTableNames);
264
- tablesToRemove.forEach((tableToRemove) => {
265
- executionActions.push({
266
- action: "delete",
267
- tableName: tableToRemove,
268
- linkDescriptor: trackedTables.find(({ table_name }) => tableToRemove === table_name).link_descriptor,
269
- });
270
- });
271
247
  try {
248
+ await this.ensureMigrationsTable(orm);
249
+ const executionActions = [];
250
+ await this.ensureMigrationsTableUpToDate(orm);
251
+ const trackedTables = await this.getTrackedLinksTables(orm);
252
+ const trackedTablesNames = trackedTables.map(({ table_name }) => table_name);
253
+ /**
254
+ * Looping through the new set of entities and generating
255
+ * execution plan for them
256
+ */
257
+ for (let { entity, linkDescriptor } of __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f")) {
258
+ executionActions.push(await this.getEntityMigrationPlan(linkDescriptor, entity, trackedTablesNames));
259
+ }
260
+ const linksTableNames = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f").map(({ entity }) => entity.meta.collection);
261
+ /**
262
+ * Finding the tables to be removed
263
+ */
264
+ const tablesToRemove = (0, utils_2.arrayDifference)(trackedTablesNames, linksTableNames);
265
+ tablesToRemove.forEach((tableToRemove) => {
266
+ executionActions.push({
267
+ action: "delete",
268
+ tableName: tableToRemove,
269
+ linkDescriptor: trackedTables.find(({ table_name }) => tableToRemove === table_name).link_descriptor,
270
+ });
271
+ });
272
272
  return executionActions;
273
273
  }
274
274
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/link-modules",
3
- "version": "0.2.12-snapshot-20240827104434",
3
+ "version": "0.2.12-snapshot-20240829144419",
4
4
  "description": "Medusa Default Link Modules Package and Definitions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,10 +29,10 @@
29
29
  "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts"
30
30
  },
31
31
  "devDependencies": {
32
- "@medusajs/types": "1.12.0-snapshot-20240827104434",
32
+ "@medusajs/types": "1.12.0-snapshot-20240829144419",
33
33
  "cross-env": "^5.2.1",
34
34
  "jest": "^29.7.0",
35
- "medusa-test-utils": "1.1.45-snapshot-20240827104434",
35
+ "medusa-test-utils": "1.1.45-snapshot-20240829144419",
36
36
  "pg-god": "^1.0.12",
37
37
  "rimraf": "^5.0.1",
38
38
  "ts-node": "^10.9.1",
@@ -40,8 +40,8 @@
40
40
  "typescript": "^5.5.0"
41
41
  },
42
42
  "dependencies": {
43
- "@medusajs/modules-sdk": "1.13.0-snapshot-20240827104434",
44
- "@medusajs/utils": "1.12.0-snapshot-20240827104434"
43
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240829144419",
44
+ "@medusajs/utils": "1.12.0-snapshot-20240829144419"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@mikro-orm/core": "5.9.7",