strapi-plugin-bulk-updater 1.2.7 → 1.2.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.
- package/dist/server/index.js +53 -12
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +53 -12
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -2205,6 +2205,33 @@ const auditService = ({ strapi: strapi2 }) => ({
|
|
|
2205
2205
|
isEnterpriseNativeAvailable: false
|
|
2206
2206
|
};
|
|
2207
2207
|
},
|
|
2208
|
+
/**
|
|
2209
|
+
* Checks whether audit logging is enabled.
|
|
2210
|
+
*/
|
|
2211
|
+
isAuditEnabled() {
|
|
2212
|
+
const config = this.getAuditConfig();
|
|
2213
|
+
return Boolean(config && config.enabled);
|
|
2214
|
+
},
|
|
2215
|
+
/**
|
|
2216
|
+
* Convenience alias to log an operation into the audit trail.
|
|
2217
|
+
*/
|
|
2218
|
+
async logOperation(data) {
|
|
2219
|
+
return this.recordBatch(
|
|
2220
|
+
{
|
|
2221
|
+
batchId: data.batchId,
|
|
2222
|
+
attribute: data.attribute,
|
|
2223
|
+
value: data.value,
|
|
2224
|
+
updatedCount: data.updatedCount,
|
|
2225
|
+
skippedCount: data.skippedCount,
|
|
2226
|
+
totalTargets: data.totalTargets
|
|
2227
|
+
},
|
|
2228
|
+
data.diffs || [],
|
|
2229
|
+
{
|
|
2230
|
+
email: data.userEmail,
|
|
2231
|
+
firstname: data.userName
|
|
2232
|
+
}
|
|
2233
|
+
);
|
|
2234
|
+
},
|
|
2208
2235
|
/**
|
|
2209
2236
|
* Optionally writes an audit event directly to Strapi Enterprise's native Audit Logs table.
|
|
2210
2237
|
*/
|
|
@@ -3363,18 +3390,32 @@ ${sampleRow.map(escapeCsvValue).join(",")}
|
|
|
3363
3390
|
if (stats.updated > 0 || stats.created > 0) {
|
|
3364
3391
|
try {
|
|
3365
3392
|
const auditService2 = strapi2.plugin("bulk-updater").service("audit");
|
|
3366
|
-
if (auditService2
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3393
|
+
if (auditService2) {
|
|
3394
|
+
const isEnabled = typeof auditService2.isAuditEnabled === "function" ? auditService2.isAuditEnabled() : Boolean(auditService2.getAuditConfig?.().enabled ?? true);
|
|
3395
|
+
if (isEnabled) {
|
|
3396
|
+
const batchSummary = {
|
|
3397
|
+
batchId,
|
|
3398
|
+
attribute: "CSV_IMPORT",
|
|
3399
|
+
value: `Mode: ${mode2} (${stats.created} created, ${stats.updated} updated)`,
|
|
3400
|
+
updatedCount: stats.updated + stats.created,
|
|
3401
|
+
skippedCount: stats.skipped,
|
|
3402
|
+
totalTargets: stats.total
|
|
3403
|
+
};
|
|
3404
|
+
const userObj = {
|
|
3405
|
+
email: userEmail || "admin@strapi.io",
|
|
3406
|
+
firstname: userName || "Admin"
|
|
3407
|
+
};
|
|
3408
|
+
if (typeof auditService2.recordBatch === "function") {
|
|
3409
|
+
await auditService2.recordBatch(batchSummary, stats.diffs, userObj);
|
|
3410
|
+
} else if (typeof auditService2.logOperation === "function") {
|
|
3411
|
+
await auditService2.logOperation({
|
|
3412
|
+
...batchSummary,
|
|
3413
|
+
userEmail,
|
|
3414
|
+
userName,
|
|
3415
|
+
diffs: stats.diffs
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3378
3419
|
}
|
|
3379
3420
|
} catch (auditErr) {
|
|
3380
3421
|
strapi2.log.warn("[bulk-updater] Failed logging CSV import audit:", auditErr);
|