strapi-plugin-magic-mail 2.10.5 → 2.10.7

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.10.7](https://github.com/Schero94/Magic-Mail/compare/v2.10.6...v2.10.7) (2026-04-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **email-designer:** prioritize templateReferenceId in findById() to match actual admin UI usage ([bcd7a4b](https://github.com/Schero94/Magic-Mail/commit/bcd7a4bd3b9640f8bc58694ec7a81fddb262245f))
7
+
8
+ ## [2.10.6](https://github.com/Schero94/Magic-Mail/compare/v2.10.5...v2.10.6) (2026-04-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **designer:** correct template lookup order so 'Send Test' hits the actual template ([c62c0e4](https://github.com/Schero94/Magic-Mail/commit/c62c0e461d39275dca2a176276d2797c9743a8fd))
14
+
1
15
  ## [2.10.5](https://github.com/Schero94/Magic-Mail/compare/v2.10.4...v2.10.5) (2026-04-21)
2
16
 
3
17
 
@@ -4830,7 +4830,8 @@ const TemplateList = () => {
4830
4830
  return;
4831
4831
  }
4832
4832
  try {
4833
- const response = await post(`/magic-mail/designer/templates/${selectedTemplate.id}/test-send`, {
4833
+ const templateIdForLookup = selectedTemplate.templateReferenceId ?? selectedTemplate.id;
4834
+ const response = await post(`/magic-mail/designer/templates/${templateIdForLookup}/test-send`, {
4834
4835
  to: testEmail,
4835
4836
  accountName: testAccount || null
4836
4837
  });
@@ -4807,7 +4807,8 @@ const TemplateList = () => {
4807
4807
  return;
4808
4808
  }
4809
4809
  try {
4810
- const response = await post(`/magic-mail/designer/templates/${selectedTemplate.id}/test-send`, {
4810
+ const templateIdForLookup = selectedTemplate.templateReferenceId ?? selectedTemplate.id;
4811
+ const response = await post(`/magic-mail/designer/templates/${templateIdForLookup}/test-send`, {
4811
4812
  to: testEmail,
4812
4813
  accountName: testAccount || null
4813
4814
  });
@@ -68,7 +68,7 @@ const index = {
68
68
  id: `${pluginId}.plugin.name`,
69
69
  defaultMessage: "MagicMail"
70
70
  },
71
- Component: () => Promise.resolve().then(() => require("../_chunks/App-2Bg4LxwL.js")),
71
+ Component: () => Promise.resolve().then(() => require("../_chunks/App-BJBweFJi.js")),
72
72
  permissions: pluginPermissions
73
73
  });
74
74
  app.createSettingSection(
@@ -67,7 +67,7 @@ const index = {
67
67
  id: `${pluginId}.plugin.name`,
68
68
  defaultMessage: "MagicMail"
69
69
  },
70
- Component: () => import("../_chunks/App-CAtJIwNW.mjs"),
70
+ Component: () => import("../_chunks/App-PxOT9hIQ.mjs"),
71
71
  permissions: pluginPermissions
72
72
  });
73
73
  app.createSettingSection(
@@ -15851,7 +15851,7 @@ var oauth$1 = ({ strapi: strapi2 }) => ({
15851
15851
  return account;
15852
15852
  }
15853
15853
  });
15854
- const version = "2.10.4";
15854
+ const version = "2.10.6";
15855
15855
  const require$$2 = {
15856
15856
  version
15857
15857
  };
@@ -16277,8 +16277,11 @@ var emailDesigner$1 = ({ strapi: strapi2 }) => ({
16277
16277
  });
16278
16278
  },
16279
16279
  /**
16280
- * Get template by ID (documentId or numeric id) with populated versions
16281
- * Supports both documentId (string) and numeric id for backward compatibility
16280
+ * Get template by ID (numeric id or documentId) with populated versions.
16281
+ *
16282
+ * Numeric IDs are interpreted as `templateReferenceId` first (this is the
16283
+ * app-wide convention — see findById() below), then as legacy DB id.
16284
+ * Non-numeric strings are treated as Strapi v5 `documentId`s.
16282
16285
  */
16283
16286
  async findOne(idOrDocumentId) {
16284
16287
  const isNumericId = /^\d+$/.test(String(idOrDocumentId));
@@ -16292,30 +16295,52 @@ var emailDesigner$1 = ({ strapi: strapi2 }) => ({
16292
16295
  });
16293
16296
  },
16294
16297
  /**
16295
- * Get template by numeric ID (supports both templateReferenceId and internal db id)
16296
- * First tries templateReferenceId, then falls back to internal database id via entityService
16298
+ * Get template by numeric ID.
16299
+ *
16300
+ * CONTRACT — every HTTP route that carries `:id` (admin UI, REST callers,
16301
+ * magic-link's `magic_mail_template_id`, Strapi's own test-send) refers to
16302
+ * the user-visible `templateReferenceId`. That is what `TemplateList`
16303
+ * navigates with, what `EditorPage` reads from `useParams()`, and what the
16304
+ * `findAll()` response surfaces as `templateReferenceId` (alongside `.id`).
16305
+ *
16306
+ * So: we resolve the reference id FIRST. The DB id is only kept as a
16307
+ * best-effort fallback for very old installs that might have persisted
16308
+ * the Strapi primary key as their template key before the reference id
16309
+ * was introduced. Collisions between the two ID spaces are prevented on
16310
+ * create() (refId uniqueness is enforced there).
16311
+ *
16312
+ * We intentionally do NOT spam warn-logs in the success path: the
16313
+ * reference-id lookup IS the primary path.
16297
16314
  */
16298
16315
  async findById(id) {
16299
16316
  const numericId = Number(id);
16300
- strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by numeric ID: ${numericId}`);
16317
+ strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by ID: ${numericId}`);
16301
16318
  const byRefId = await strapi2.documents(EMAIL_TEMPLATE_UID).findMany({
16302
16319
  filters: { templateReferenceId: numericId },
16303
16320
  limit: 1,
16304
16321
  populate: { versions: true }
16305
16322
  });
16306
16323
  if (byRefId.length > 0) {
16307
- strapi2.log.info(`[magic-mail] [SUCCESS] Found template by templateReferenceId ${numericId}: documentId=${byRefId[0].documentId}, name="${byRefId[0].name}"`);
16324
+ strapi2.log.info(
16325
+ `[magic-mail] [SUCCESS] Found template by templateReferenceId ${numericId}: documentId=${byRefId[0].documentId}, name="${byRefId[0].name}"`
16326
+ );
16308
16327
  return byRefId[0];
16309
16328
  }
16310
- strapi2.log.info(`[magic-mail] [FALLBACK] templateReferenceId not found, trying internal db id: ${numericId}`);
16311
- const byInternalId = await strapi2.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
16312
- populate: { versions: true }
16313
- });
16329
+ let byInternalId = null;
16330
+ try {
16331
+ byInternalId = await strapi2.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
16332
+ populate: { versions: true }
16333
+ });
16334
+ } catch (err) {
16335
+ strapi2.log.debug(`[magic-mail] [LOOKUP] entityService.findOne(${numericId}) threw: ${err.message}`);
16336
+ }
16314
16337
  if (byInternalId) {
16315
- strapi2.log.info(`[magic-mail] [SUCCESS] Found template by internal id ${numericId}: documentId=${byInternalId.documentId}, name="${byInternalId.name}"`);
16338
+ strapi2.log.info(
16339
+ `[magic-mail] [LEGACY-LOOKUP] No templateReferenceId=${numericId}; resolved via internal DB id=${numericId} → "${byInternalId.name}" (documentId=${byInternalId.documentId}). Consider storing the template's templateReferenceId (${byInternalId.templateReferenceId ?? "none set"}) instead of its DB id to keep callers stable across migrations.`
16340
+ );
16316
16341
  return byInternalId;
16317
16342
  }
16318
- strapi2.log.warn(`[magic-mail] [WARNING] Template with ID ${numericId} not found (tried templateReferenceId and internal id)`);
16343
+ strapi2.log.warn(`[magic-mail] [WARNING] Template with ID ${numericId} not found (tried templateReferenceId and internal DB id)`);
16319
16344
  return null;
16320
16345
  },
16321
16346
  /**
@@ -15838,7 +15838,7 @@ var oauth$1 = ({ strapi: strapi2 }) => ({
15838
15838
  return account;
15839
15839
  }
15840
15840
  });
15841
- const version = "2.10.4";
15841
+ const version = "2.10.6";
15842
15842
  const require$$2 = {
15843
15843
  version
15844
15844
  };
@@ -16264,8 +16264,11 @@ var emailDesigner$1 = ({ strapi: strapi2 }) => ({
16264
16264
  });
16265
16265
  },
16266
16266
  /**
16267
- * Get template by ID (documentId or numeric id) with populated versions
16268
- * Supports both documentId (string) and numeric id for backward compatibility
16267
+ * Get template by ID (numeric id or documentId) with populated versions.
16268
+ *
16269
+ * Numeric IDs are interpreted as `templateReferenceId` first (this is the
16270
+ * app-wide convention — see findById() below), then as legacy DB id.
16271
+ * Non-numeric strings are treated as Strapi v5 `documentId`s.
16269
16272
  */
16270
16273
  async findOne(idOrDocumentId) {
16271
16274
  const isNumericId = /^\d+$/.test(String(idOrDocumentId));
@@ -16279,30 +16282,52 @@ var emailDesigner$1 = ({ strapi: strapi2 }) => ({
16279
16282
  });
16280
16283
  },
16281
16284
  /**
16282
- * Get template by numeric ID (supports both templateReferenceId and internal db id)
16283
- * First tries templateReferenceId, then falls back to internal database id via entityService
16285
+ * Get template by numeric ID.
16286
+ *
16287
+ * CONTRACT — every HTTP route that carries `:id` (admin UI, REST callers,
16288
+ * magic-link's `magic_mail_template_id`, Strapi's own test-send) refers to
16289
+ * the user-visible `templateReferenceId`. That is what `TemplateList`
16290
+ * navigates with, what `EditorPage` reads from `useParams()`, and what the
16291
+ * `findAll()` response surfaces as `templateReferenceId` (alongside `.id`).
16292
+ *
16293
+ * So: we resolve the reference id FIRST. The DB id is only kept as a
16294
+ * best-effort fallback for very old installs that might have persisted
16295
+ * the Strapi primary key as their template key before the reference id
16296
+ * was introduced. Collisions between the two ID spaces are prevented on
16297
+ * create() (refId uniqueness is enforced there).
16298
+ *
16299
+ * We intentionally do NOT spam warn-logs in the success path: the
16300
+ * reference-id lookup IS the primary path.
16284
16301
  */
16285
16302
  async findById(id) {
16286
16303
  const numericId = Number(id);
16287
- strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by numeric ID: ${numericId}`);
16304
+ strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by ID: ${numericId}`);
16288
16305
  const byRefId = await strapi2.documents(EMAIL_TEMPLATE_UID).findMany({
16289
16306
  filters: { templateReferenceId: numericId },
16290
16307
  limit: 1,
16291
16308
  populate: { versions: true }
16292
16309
  });
16293
16310
  if (byRefId.length > 0) {
16294
- strapi2.log.info(`[magic-mail] [SUCCESS] Found template by templateReferenceId ${numericId}: documentId=${byRefId[0].documentId}, name="${byRefId[0].name}"`);
16311
+ strapi2.log.info(
16312
+ `[magic-mail] [SUCCESS] Found template by templateReferenceId ${numericId}: documentId=${byRefId[0].documentId}, name="${byRefId[0].name}"`
16313
+ );
16295
16314
  return byRefId[0];
16296
16315
  }
16297
- strapi2.log.info(`[magic-mail] [FALLBACK] templateReferenceId not found, trying internal db id: ${numericId}`);
16298
- const byInternalId = await strapi2.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
16299
- populate: { versions: true }
16300
- });
16316
+ let byInternalId = null;
16317
+ try {
16318
+ byInternalId = await strapi2.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
16319
+ populate: { versions: true }
16320
+ });
16321
+ } catch (err) {
16322
+ strapi2.log.debug(`[magic-mail] [LOOKUP] entityService.findOne(${numericId}) threw: ${err.message}`);
16323
+ }
16301
16324
  if (byInternalId) {
16302
- strapi2.log.info(`[magic-mail] [SUCCESS] Found template by internal id ${numericId}: documentId=${byInternalId.documentId}, name="${byInternalId.name}"`);
16325
+ strapi2.log.info(
16326
+ `[magic-mail] [LEGACY-LOOKUP] No templateReferenceId=${numericId}; resolved via internal DB id=${numericId} → "${byInternalId.name}" (documentId=${byInternalId.documentId}). Consider storing the template's templateReferenceId (${byInternalId.templateReferenceId ?? "none set"}) instead of its DB id to keep callers stable across migrations.`
16327
+ );
16303
16328
  return byInternalId;
16304
16329
  }
16305
- strapi2.log.warn(`[magic-mail] [WARNING] Template with ID ${numericId} not found (tried templateReferenceId and internal id)`);
16330
+ strapi2.log.warn(`[magic-mail] [WARNING] Template with ID ${numericId} not found (tried templateReferenceId and internal DB id)`);
16306
16331
  return null;
16307
16332
  },
16308
16333
  /**
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.10.5",
2
+ "version": "2.10.7",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",