strapi-plugin-magic-mail 2.3.6 → 2.3.8

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.
@@ -5543,7 +5543,7 @@ function requireOauth() {
5543
5543
  });
5544
5544
  return oauth;
5545
5545
  }
5546
- const version = "2.3.5";
5546
+ const version = "2.3.7";
5547
5547
  const require$$2 = {
5548
5548
  version
5549
5549
  };
@@ -5971,27 +5971,35 @@ function requireEmailDesigner() {
5971
5971
  }
5972
5972
  return strapi2.documents(EMAIL_TEMPLATE_UID).findOne({
5973
5973
  documentId: String(idOrDocumentId),
5974
- populate: ["versions"]
5974
+ populate: { versions: true }
5975
5975
  });
5976
5976
  },
5977
5977
  /**
5978
- * Get template by numeric templateReferenceId
5979
- * The templateReferenceId is a unique integer field used to identify templates
5978
+ * Get template by numeric ID (supports both templateReferenceId and internal db id)
5979
+ * First tries templateReferenceId, then falls back to internal database id via entityService
5980
5980
  */
5981
5981
  async findById(id) {
5982
- strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by templateReferenceId: ${id}`);
5983
- const results = await strapi2.documents(EMAIL_TEMPLATE_UID).findMany({
5984
- filters: { templateReferenceId: Number(id) },
5982
+ const numericId = Number(id);
5983
+ strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by numeric ID: ${numericId}`);
5984
+ const byRefId = await strapi2.documents(EMAIL_TEMPLATE_UID).findMany({
5985
+ filters: { templateReferenceId: numericId },
5985
5986
  limit: 1,
5986
- populate: ["versions"]
5987
+ populate: { versions: true }
5987
5988
  });
5988
- const result = results.length > 0 ? results[0] : null;
5989
- if (result) {
5990
- strapi2.log.info(`[magic-mail] [SUCCESS] Found template by templateReferenceId ${id}: documentId=${result.documentId}, name="${result.name}"`);
5991
- } else {
5992
- strapi2.log.warn(`[magic-mail] [WARNING] Template with templateReferenceId ${id} not found`);
5989
+ if (byRefId.length > 0) {
5990
+ strapi2.log.info(`[magic-mail] [SUCCESS] Found template by templateReferenceId ${numericId}: documentId=${byRefId[0].documentId}, name="${byRefId[0].name}"`);
5991
+ return byRefId[0];
5993
5992
  }
5994
- return result;
5993
+ strapi2.log.info(`[magic-mail] [FALLBACK] templateReferenceId not found, trying internal db id: ${numericId}`);
5994
+ const byInternalId = await strapi2.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
5995
+ populate: { versions: true }
5996
+ });
5997
+ if (byInternalId) {
5998
+ strapi2.log.info(`[magic-mail] [SUCCESS] Found template by internal id ${numericId}: documentId=${byInternalId.documentId}, name="${byInternalId.name}"`);
5999
+ return byInternalId;
6000
+ }
6001
+ strapi2.log.warn(`[magic-mail] [WARNING] Template with ID ${numericId} not found (tried templateReferenceId and internal id)`);
6002
+ return null;
5995
6003
  },
5996
6004
  /**
5997
6005
  * Get template by reference ID
@@ -6222,7 +6230,7 @@ function requireEmailDesigner() {
6222
6230
  const actualDocumentId = template.documentId;
6223
6231
  const version2 = await strapi2.documents(EMAIL_TEMPLATE_VERSION_UID).findOne({
6224
6232
  documentId: versionDocumentId,
6225
- populate: ["template"]
6233
+ populate: { template: true }
6226
6234
  });
6227
6235
  if (!version2) {
6228
6236
  throw new Error("Version not found");
@@ -6255,7 +6263,7 @@ function requireEmailDesigner() {
6255
6263
  const actualDocumentId = template.documentId;
6256
6264
  const version2 = await strapi2.documents(EMAIL_TEMPLATE_VERSION_UID).findOne({
6257
6265
  documentId: versionDocumentId,
6258
- populate: ["template"]
6266
+ populate: { template: true }
6259
6267
  });
6260
6268
  if (!version2) {
6261
6269
  throw new Error("Version not found");
@@ -5533,7 +5533,7 @@ function requireOauth() {
5533
5533
  });
5534
5534
  return oauth;
5535
5535
  }
5536
- const version = "2.3.5";
5536
+ const version = "2.3.7";
5537
5537
  const require$$2 = {
5538
5538
  version
5539
5539
  };
@@ -5961,27 +5961,35 @@ function requireEmailDesigner() {
5961
5961
  }
5962
5962
  return strapi2.documents(EMAIL_TEMPLATE_UID).findOne({
5963
5963
  documentId: String(idOrDocumentId),
5964
- populate: ["versions"]
5964
+ populate: { versions: true }
5965
5965
  });
5966
5966
  },
5967
5967
  /**
5968
- * Get template by numeric templateReferenceId
5969
- * The templateReferenceId is a unique integer field used to identify templates
5968
+ * Get template by numeric ID (supports both templateReferenceId and internal db id)
5969
+ * First tries templateReferenceId, then falls back to internal database id via entityService
5970
5970
  */
5971
5971
  async findById(id) {
5972
- strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by templateReferenceId: ${id}`);
5973
- const results = await strapi2.documents(EMAIL_TEMPLATE_UID).findMany({
5974
- filters: { templateReferenceId: Number(id) },
5972
+ const numericId = Number(id);
5973
+ strapi2.log.info(`[magic-mail] [LOOKUP] Finding template by numeric ID: ${numericId}`);
5974
+ const byRefId = await strapi2.documents(EMAIL_TEMPLATE_UID).findMany({
5975
+ filters: { templateReferenceId: numericId },
5975
5976
  limit: 1,
5976
- populate: ["versions"]
5977
+ populate: { versions: true }
5977
5978
  });
5978
- const result = results.length > 0 ? results[0] : null;
5979
- if (result) {
5980
- strapi2.log.info(`[magic-mail] [SUCCESS] Found template by templateReferenceId ${id}: documentId=${result.documentId}, name="${result.name}"`);
5981
- } else {
5982
- strapi2.log.warn(`[magic-mail] [WARNING] Template with templateReferenceId ${id} not found`);
5979
+ if (byRefId.length > 0) {
5980
+ strapi2.log.info(`[magic-mail] [SUCCESS] Found template by templateReferenceId ${numericId}: documentId=${byRefId[0].documentId}, name="${byRefId[0].name}"`);
5981
+ return byRefId[0];
5983
5982
  }
5984
- return result;
5983
+ strapi2.log.info(`[magic-mail] [FALLBACK] templateReferenceId not found, trying internal db id: ${numericId}`);
5984
+ const byInternalId = await strapi2.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
5985
+ populate: { versions: true }
5986
+ });
5987
+ if (byInternalId) {
5988
+ strapi2.log.info(`[magic-mail] [SUCCESS] Found template by internal id ${numericId}: documentId=${byInternalId.documentId}, name="${byInternalId.name}"`);
5989
+ return byInternalId;
5990
+ }
5991
+ strapi2.log.warn(`[magic-mail] [WARNING] Template with ID ${numericId} not found (tried templateReferenceId and internal id)`);
5992
+ return null;
5985
5993
  },
5986
5994
  /**
5987
5995
  * Get template by reference ID
@@ -6212,7 +6220,7 @@ function requireEmailDesigner() {
6212
6220
  const actualDocumentId = template.documentId;
6213
6221
  const version2 = await strapi2.documents(EMAIL_TEMPLATE_VERSION_UID).findOne({
6214
6222
  documentId: versionDocumentId,
6215
- populate: ["template"]
6223
+ populate: { template: true }
6216
6224
  });
6217
6225
  if (!version2) {
6218
6226
  throw new Error("Version not found");
@@ -6245,7 +6253,7 @@ function requireEmailDesigner() {
6245
6253
  const actualDocumentId = template.documentId;
6246
6254
  const version2 = await strapi2.documents(EMAIL_TEMPLATE_VERSION_UID).findOne({
6247
6255
  documentId: versionDocumentId,
6248
- populate: ["template"]
6256
+ populate: { template: true }
6249
6257
  });
6250
6258
  if (!version2) {
6251
6259
  throw new Error("Version not found");
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.3.6",
2
+ "version": "2.3.8",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",