strapi-plugin-bulk-updater 1.5.8 → 1.5.9

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.
@@ -68,7 +68,7 @@ const index = {
68
68
  id: `${PLUGIN_ID}.plugin.name`,
69
69
  defaultMessage: "Bulk Attribute Updater"
70
70
  },
71
- Component: () => Promise.resolve().then(() => require("../_chunks/BulkUpdater-ezjrkUaf.js")),
71
+ Component: () => Promise.resolve().then(() => require("../_chunks/BulkUpdater-C0uR_ORS.js")),
72
72
  permissions: [],
73
73
  position: 3
74
74
  });
@@ -65,7 +65,7 @@ const index = {
65
65
  id: `${PLUGIN_ID}.plugin.name`,
66
66
  defaultMessage: "Bulk Attribute Updater"
67
67
  },
68
- Component: () => import("../_chunks/BulkUpdater-B58N9HHk.mjs"),
68
+ Component: () => import("../_chunks/BulkUpdater-RWXTJOa6.mjs"),
69
69
  permissions: [],
70
70
  position: 3
71
71
  });
@@ -6177,12 +6177,6 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6177
6177
  });
6178
6178
  continue;
6179
6179
  }
6180
- const updateArgs = {
6181
- documentId: resolvedDocId,
6182
- data: mergedPayload
6183
- };
6184
- if (effectiveLocale) updateArgs.locale = effectiveLocale;
6185
- await strapi.documents(uid).update(updateArgs);
6186
6180
  let pubRecord = effectiveLocale && publishedCounterparts.get(`${resolvedDocId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(resolvedDocId));
6187
6181
  if (!pubRecord && isDraftAndPublish && resolvedDocId) {
6188
6182
  try {
@@ -6199,7 +6193,9 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6199
6193
  } catch {
6200
6194
  }
6201
6195
  }
6202
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
6196
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
6197
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
6198
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
6203
6199
  const { hadPublishedVersion } = resolveRecordPublicationStatus(
6204
6200
  inspectionExisting,
6205
6201
  pubRecord,
@@ -6213,6 +6209,12 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6213
6209
  publishStrategy,
6214
6210
  unreviewedConsent: options.unreviewedConsent
6215
6211
  });
6212
+ const updateArgs = {
6213
+ documentId: resolvedDocId,
6214
+ data: mergedPayload
6215
+ };
6216
+ if (effectiveLocale) updateArgs.locale = effectiveLocale;
6217
+ await strapi.documents(uid).update(updateArgs);
6216
6218
  if (shouldPublish) {
6217
6219
  try {
6218
6220
  const pubArgs = { documentId: resolvedDocId };
@@ -6260,12 +6262,6 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6260
6262
  mergedPayload[key] = deepMergeComponent(existing[key], payload[key]);
6261
6263
  }
6262
6264
  }
6263
- const updateArgs = {
6264
- documentId: resolvedDocId,
6265
- data: mergedPayload
6266
- };
6267
- if (effectiveLocale) updateArgs.locale = effectiveLocale;
6268
- await strapi.documents(uid).update(updateArgs);
6269
6265
  let pubRecord = effectiveLocale && publishedCounterparts.get(`${resolvedDocId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(resolvedDocId));
6270
6266
  if (!pubRecord && isDraftAndPublish && resolvedDocId) {
6271
6267
  try {
@@ -6282,7 +6278,9 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6282
6278
  } catch {
6283
6279
  }
6284
6280
  }
6285
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
6281
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
6282
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
6283
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
6286
6284
  const { hadPublishedVersion } = resolveRecordPublicationStatus(
6287
6285
  inspectionExisting,
6288
6286
  pubRecord,
@@ -6296,6 +6294,12 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6296
6294
  publishStrategy,
6297
6295
  unreviewedConsent: options.unreviewedConsent
6298
6296
  });
6297
+ const updateArgs = {
6298
+ documentId: resolvedDocId,
6299
+ data: mergedPayload
6300
+ };
6301
+ if (effectiveLocale) updateArgs.locale = effectiveLocale;
6302
+ await strapi.documents(uid).update(updateArgs);
6299
6303
  if (shouldPublish) {
6300
6304
  try {
6301
6305
  const pubArgs = { documentId: resolvedDocId };
@@ -6385,12 +6389,6 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6385
6389
  mergedPayload[key] = deepMergeComponent(existing[key], payload[key]);
6386
6390
  }
6387
6391
  }
6388
- const updateArgs = {
6389
- documentId: resolvedDocId,
6390
- data: mergedPayload
6391
- };
6392
- if (effectiveLocale) updateArgs.locale = effectiveLocale;
6393
- await strapi.documents(uid).update(updateArgs);
6394
6392
  let pubRecord = effectiveLocale && publishedCounterparts.get(`${resolvedDocId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(resolvedDocId));
6395
6393
  if (!pubRecord && isDraftAndPublish && resolvedDocId) {
6396
6394
  try {
@@ -6407,7 +6405,9 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6407
6405
  } catch {
6408
6406
  }
6409
6407
  }
6410
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
6408
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
6409
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
6410
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
6411
6411
  const { hadPublishedVersion } = resolveRecordPublicationStatus(
6412
6412
  inspectionExisting,
6413
6413
  pubRecord,
@@ -6421,6 +6421,12 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6421
6421
  publishStrategy,
6422
6422
  unreviewedConsent: options.unreviewedConsent
6423
6423
  });
6424
+ const updateArgs = {
6425
+ documentId: resolvedDocId,
6426
+ data: mergedPayload
6427
+ };
6428
+ if (effectiveLocale) updateArgs.locale = effectiveLocale;
6429
+ await strapi.documents(uid).update(updateArgs);
6424
6430
  if (shouldPublish) {
6425
6431
  try {
6426
6432
  const pubArgs = { documentId: resolvedDocId };
@@ -6837,10 +6843,23 @@ const csvService = ({ strapi }) => ({
6837
6843
  filters: { documentId: { $in: docIds } },
6838
6844
  limit: docIds.length
6839
6845
  });
6846
+ let pubSet = /* @__PURE__ */ new Set();
6847
+ if (Boolean(ct.options?.draftAndPublish)) {
6848
+ try {
6849
+ const pubDocs = await strapi.documents(uid).findMany({
6850
+ status: "published",
6851
+ filters: { documentId: { $in: docIds } },
6852
+ fields: ["documentId"],
6853
+ limit: docIds.length
6854
+ });
6855
+ pubSet = new Set((pubDocs || []).map((p) => String(p.documentId)));
6856
+ } catch {
6857
+ }
6858
+ }
6840
6859
  for (const entry of entries || []) {
6841
6860
  const titleOrName = entry.title || entry.name || entry.subject || entry.email || `Entry #${entry.documentId}`;
6842
6861
  const identifier = entry.slug || entry.email || entry.username || entry.documentId;
6843
- const isPublished = Boolean(entry.publishedAt);
6862
+ const isPublished = Boolean(entry.publishedAt) || pubSet.has(String(entry.documentId));
6844
6863
  const row = [
6845
6864
  uid,
6846
6865
  displayName,
@@ -7055,6 +7074,27 @@ const csvService = ({ strapi }) => ({
7055
7074
  };
7056
7075
  const errors = [];
7057
7076
  const warnings = [];
7077
+ const docIdsInPreflight = rows.map((r) => extractDocId(r)).filter(Boolean);
7078
+ const publishedCounterparts = /* @__PURE__ */ new Map();
7079
+ if (isDraftAndPublish && docIdsInPreflight.length > 0) {
7080
+ try {
7081
+ const pubDocs = await strapi.documents(uid).findMany({
7082
+ status: "published",
7083
+ filters: { documentId: { $in: docIdsInPreflight } },
7084
+ fields: ["documentId", "updatedAt", "publishedAt", "locale"],
7085
+ limit: Math.max(docIdsInPreflight.length, 100)
7086
+ });
7087
+ for (const pub of pubDocs || []) {
7088
+ if (pub?.documentId) {
7089
+ publishedCounterparts.set(String(pub.documentId), pub);
7090
+ if (pub.locale) {
7091
+ publishedCounterparts.set(`${pub.documentId}@@@${pub.locale}`, pub);
7092
+ }
7093
+ }
7094
+ }
7095
+ } catch {
7096
+ }
7097
+ }
7058
7098
  for (let i = 0; i < rows.length; i++) {
7059
7099
  const rowNumber = i + 2;
7060
7100
  const row = rows[i];
@@ -7069,14 +7109,16 @@ const csvService = ({ strapi }) => ({
7069
7109
  }
7070
7110
  if (existing && isDraftAndPublish) {
7071
7111
  lifecycleStats.totalChecked++;
7072
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
7112
+ const pubRecord = effectiveLocale && publishedCounterparts.get(`${docId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(docId));
7113
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
7114
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
7115
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
7073
7116
  const { status: preStatus, hadPublishedVersion } = resolveRecordPublicationStatus(
7074
7117
  inspectionExisting,
7075
- void 0,
7118
+ pubRecord,
7076
7119
  isDraftAndPublish
7077
7120
  );
7078
- const isApproved = !isEditing && hadPublishedVersion;
7079
- if (isApproved) {
7121
+ if (!isEditing && preStatus === "published") {
7080
7122
  lifecycleStats.published++;
7081
7123
  } else if (preStatus === "modified" || hadPublishedVersion && isEditing) {
7082
7124
  lifecycleStats.modified++;