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.
@@ -6174,12 +6174,6 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6174
6174
  });
6175
6175
  continue;
6176
6176
  }
6177
- const updateArgs = {
6178
- documentId: resolvedDocId,
6179
- data: mergedPayload
6180
- };
6181
- if (effectiveLocale) updateArgs.locale = effectiveLocale;
6182
- await strapi.documents(uid).update(updateArgs);
6183
6177
  let pubRecord = effectiveLocale && publishedCounterparts.get(`${resolvedDocId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(resolvedDocId));
6184
6178
  if (!pubRecord && isDraftAndPublish && resolvedDocId) {
6185
6179
  try {
@@ -6196,7 +6190,9 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6196
6190
  } catch {
6197
6191
  }
6198
6192
  }
6199
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
6193
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
6194
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
6195
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
6200
6196
  const { hadPublishedVersion } = resolveRecordPublicationStatus(
6201
6197
  inspectionExisting,
6202
6198
  pubRecord,
@@ -6210,6 +6206,12 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6210
6206
  publishStrategy,
6211
6207
  unreviewedConsent: options.unreviewedConsent
6212
6208
  });
6209
+ const updateArgs = {
6210
+ documentId: resolvedDocId,
6211
+ data: mergedPayload
6212
+ };
6213
+ if (effectiveLocale) updateArgs.locale = effectiveLocale;
6214
+ await strapi.documents(uid).update(updateArgs);
6213
6215
  if (shouldPublish) {
6214
6216
  try {
6215
6217
  const pubArgs = { documentId: resolvedDocId };
@@ -6257,12 +6259,6 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6257
6259
  mergedPayload[key] = deepMergeComponent(existing[key], payload[key]);
6258
6260
  }
6259
6261
  }
6260
- const updateArgs = {
6261
- documentId: resolvedDocId,
6262
- data: mergedPayload
6263
- };
6264
- if (effectiveLocale) updateArgs.locale = effectiveLocale;
6265
- await strapi.documents(uid).update(updateArgs);
6266
6262
  let pubRecord = effectiveLocale && publishedCounterparts.get(`${resolvedDocId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(resolvedDocId));
6267
6263
  if (!pubRecord && isDraftAndPublish && resolvedDocId) {
6268
6264
  try {
@@ -6279,7 +6275,9 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6279
6275
  } catch {
6280
6276
  }
6281
6277
  }
6282
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
6278
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
6279
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
6280
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
6283
6281
  const { hadPublishedVersion } = resolveRecordPublicationStatus(
6284
6282
  inspectionExisting,
6285
6283
  pubRecord,
@@ -6293,6 +6291,12 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6293
6291
  publishStrategy,
6294
6292
  unreviewedConsent: options.unreviewedConsent
6295
6293
  });
6294
+ const updateArgs = {
6295
+ documentId: resolvedDocId,
6296
+ data: mergedPayload
6297
+ };
6298
+ if (effectiveLocale) updateArgs.locale = effectiveLocale;
6299
+ await strapi.documents(uid).update(updateArgs);
6296
6300
  if (shouldPublish) {
6297
6301
  try {
6298
6302
  const pubArgs = { documentId: resolvedDocId };
@@ -6382,12 +6386,6 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6382
6386
  mergedPayload[key] = deepMergeComponent(existing[key], payload[key]);
6383
6387
  }
6384
6388
  }
6385
- const updateArgs = {
6386
- documentId: resolvedDocId,
6387
- data: mergedPayload
6388
- };
6389
- if (effectiveLocale) updateArgs.locale = effectiveLocale;
6390
- await strapi.documents(uid).update(updateArgs);
6391
6389
  let pubRecord = effectiveLocale && publishedCounterparts.get(`${resolvedDocId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(resolvedDocId));
6392
6390
  if (!pubRecord && isDraftAndPublish && resolvedDocId) {
6393
6391
  try {
@@ -6404,7 +6402,9 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6404
6402
  } catch {
6405
6403
  }
6406
6404
  }
6407
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
6405
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
6406
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
6407
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
6408
6408
  const { hadPublishedVersion } = resolveRecordPublicationStatus(
6409
6409
  inspectionExisting,
6410
6410
  pubRecord,
@@ -6418,6 +6418,12 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
6418
6418
  publishStrategy,
6419
6419
  unreviewedConsent: options.unreviewedConsent
6420
6420
  });
6421
+ const updateArgs = {
6422
+ documentId: resolvedDocId,
6423
+ data: mergedPayload
6424
+ };
6425
+ if (effectiveLocale) updateArgs.locale = effectiveLocale;
6426
+ await strapi.documents(uid).update(updateArgs);
6421
6427
  if (shouldPublish) {
6422
6428
  try {
6423
6429
  const pubArgs = { documentId: resolvedDocId };
@@ -6834,10 +6840,23 @@ const csvService = ({ strapi }) => ({
6834
6840
  filters: { documentId: { $in: docIds } },
6835
6841
  limit: docIds.length
6836
6842
  });
6843
+ let pubSet = /* @__PURE__ */ new Set();
6844
+ if (Boolean(ct.options?.draftAndPublish)) {
6845
+ try {
6846
+ const pubDocs = await strapi.documents(uid).findMany({
6847
+ status: "published",
6848
+ filters: { documentId: { $in: docIds } },
6849
+ fields: ["documentId"],
6850
+ limit: docIds.length
6851
+ });
6852
+ pubSet = new Set((pubDocs || []).map((p) => String(p.documentId)));
6853
+ } catch {
6854
+ }
6855
+ }
6837
6856
  for (const entry of entries || []) {
6838
6857
  const titleOrName = entry.title || entry.name || entry.subject || entry.email || `Entry #${entry.documentId}`;
6839
6858
  const identifier = entry.slug || entry.email || entry.username || entry.documentId;
6840
- const isPublished = Boolean(entry.publishedAt);
6859
+ const isPublished = Boolean(entry.publishedAt) || pubSet.has(String(entry.documentId));
6841
6860
  const row = [
6842
6861
  uid,
6843
6862
  displayName,
@@ -7052,6 +7071,27 @@ const csvService = ({ strapi }) => ({
7052
7071
  };
7053
7072
  const errors2 = [];
7054
7073
  const warnings = [];
7074
+ const docIdsInPreflight = rows.map((r) => extractDocId(r)).filter(Boolean);
7075
+ const publishedCounterparts = /* @__PURE__ */ new Map();
7076
+ if (isDraftAndPublish && docIdsInPreflight.length > 0) {
7077
+ try {
7078
+ const pubDocs = await strapi.documents(uid).findMany({
7079
+ status: "published",
7080
+ filters: { documentId: { $in: docIdsInPreflight } },
7081
+ fields: ["documentId", "updatedAt", "publishedAt", "locale"],
7082
+ limit: Math.max(docIdsInPreflight.length, 100)
7083
+ });
7084
+ for (const pub of pubDocs || []) {
7085
+ if (pub?.documentId) {
7086
+ publishedCounterparts.set(String(pub.documentId), pub);
7087
+ if (pub.locale) {
7088
+ publishedCounterparts.set(`${pub.documentId}@@@${pub.locale}`, pub);
7089
+ }
7090
+ }
7091
+ }
7092
+ } catch {
7093
+ }
7094
+ }
7055
7095
  for (let i = 0; i < rows.length; i++) {
7056
7096
  const rowNumber = i + 2;
7057
7097
  const row = rows[i];
@@ -7066,14 +7106,16 @@ const csvService = ({ strapi }) => ({
7066
7106
  }
7067
7107
  if (existing && isDraftAndPublish) {
7068
7108
  lifecycleStats.totalChecked++;
7069
- const inspectionExisting = row.status || row.publishedAt ? { ...existing, status: row.status, publishedAt: row.publishedAt } : existing;
7109
+ const pubRecord = effectiveLocale && publishedCounterparts.get(`${docId}@@@${effectiveLocale}`) || publishedCounterparts.get(String(docId));
7110
+ const rowStatus = row.status || row.Status || row.STATUS || row["Published Status"] || row["published_status"] || row["strapi_status"];
7111
+ const rowPubAt = row.publishedAt || row.published_at || row.PublishedAt;
7112
+ const inspectionExisting = rowStatus || rowPubAt ? { ...existing, ...rowStatus ? { status: rowStatus } : {}, ...rowPubAt ? { publishedAt: rowPubAt } : {} } : existing;
7070
7113
  const { status: preStatus, hadPublishedVersion } = resolveRecordPublicationStatus(
7071
7114
  inspectionExisting,
7072
- void 0,
7115
+ pubRecord,
7073
7116
  isDraftAndPublish
7074
7117
  );
7075
- const isApproved = !isEditing && hadPublishedVersion;
7076
- if (isApproved) {
7118
+ if (!isEditing && preStatus === "published") {
7077
7119
  lifecycleStats.published++;
7078
7120
  } else if (preStatus === "modified" || hadPublishedVersion && isEditing) {
7079
7121
  lifecycleStats.modified++;