@fourlights/strapi-plugin-deep-populate 1.15.0-rc.0 → 1.15.0-rc.1
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
CHANGED
|
@@ -18430,7 +18430,7 @@ function asBoolean(value) {
|
|
|
18430
18430
|
const normalized = value.toLowerCase().trim();
|
|
18431
18431
|
return normalized !== "false" && normalized !== "0";
|
|
18432
18432
|
}
|
|
18433
|
-
const version = "1.15.0-rc.
|
|
18433
|
+
const version = "1.15.0-rc.1";
|
|
18434
18434
|
const name = "@fourlights/strapi-plugin-deep-populate";
|
|
18435
18435
|
const f = (msg, context = void 0) => {
|
|
18436
18436
|
const prefix = `[${name}] `;
|
|
@@ -18465,7 +18465,7 @@ async function clearCacheForChangedSchemas(schemas) {
|
|
|
18465
18465
|
dependencies: { $contains: schema2 }
|
|
18466
18466
|
}
|
|
18467
18467
|
});
|
|
18468
|
-
log.
|
|
18468
|
+
log.debug(`Deleted ${deleted.count} cached entries due to out of date schema '${schema2}'`);
|
|
18469
18469
|
});
|
|
18470
18470
|
}
|
|
18471
18471
|
const register = async ({ strapi: strapi2 }) => {
|
|
@@ -18561,6 +18561,22 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
18561
18561
|
return result;
|
|
18562
18562
|
});
|
|
18563
18563
|
};
|
|
18564
|
+
const UniqueConstraintErrorCodes = {
|
|
18565
|
+
// PostgreSQL
|
|
18566
|
+
POSTGRES_UNIQUE_VIOLATION: "23505",
|
|
18567
|
+
// MySQL
|
|
18568
|
+
MYSQL_DUPLICATE_ENTRY: 1062,
|
|
18569
|
+
// SQLite
|
|
18570
|
+
SQLITE_CONSTRAINT: 19,
|
|
18571
|
+
SQLITE_CONSTRAINT_UNIQUE: 2067,
|
|
18572
|
+
// SQL Server
|
|
18573
|
+
SQLSERVER_DUPLICATE_KEY: 2601,
|
|
18574
|
+
SQLSERVER_UNIQUE_KEY_VIOLATION: 2627
|
|
18575
|
+
};
|
|
18576
|
+
const isUniqueConstraintError = (error2) => {
|
|
18577
|
+
const err = error2;
|
|
18578
|
+
return Object.keys(UniqueConstraintErrorCodes).includes(err.code) || err.code === UniqueConstraintErrorCodes.POSTGRES_UNIQUE_VIOLATION || err.errno === UniqueConstraintErrorCodes.MYSQL_DUPLICATE_ENTRY || err.errno === UniqueConstraintErrorCodes.SQLITE_CONSTRAINT || err.errno === UniqueConstraintErrorCodes.SQLITE_CONSTRAINT_UNIQUE || err.number === UniqueConstraintErrorCodes.SQLSERVER_DUPLICATE_KEY || err.number === UniqueConstraintErrorCodes.SQLSERVER_UNIQUE_KEY_VIOLATION;
|
|
18579
|
+
};
|
|
18564
18580
|
const majorMinorVersion = version.split(".").slice(0, -1).join(".");
|
|
18565
18581
|
const sanitizeObject = (obj) => {
|
|
18566
18582
|
if (obj === null || typeof obj !== "object") return obj;
|
|
@@ -18641,15 +18657,19 @@ const cache = ({ strapi: strapi2 }) => ({
|
|
|
18641
18657
|
async set({ populate: populate2, dependencies, ...params }) {
|
|
18642
18658
|
const documentService = strapi2.documents("plugin::deep-populate.cache");
|
|
18643
18659
|
const hash = getHash(params);
|
|
18644
|
-
const entry = await documentService.findFirst({ filters: { hash: { $eq: hash } } });
|
|
18645
18660
|
try {
|
|
18646
|
-
return
|
|
18647
|
-
documentId: entry.documentId,
|
|
18648
|
-
data: { populate: populate2, dependencies: dependencies.join(",") }
|
|
18649
|
-
}) : await documentService.create({ data: { hash, params, populate: populate2, dependencies: dependencies.join(",") } });
|
|
18661
|
+
return await documentService.create({ data: { hash, params, populate: populate2, dependencies: dependencies.join(",") } });
|
|
18650
18662
|
} catch (error2) {
|
|
18663
|
+
if (isUniqueConstraintError(error2)) {
|
|
18664
|
+
const entry = await documentService.findFirst({ filters: { hash: { $eq: hash } } });
|
|
18665
|
+
if (entry) {
|
|
18666
|
+
return await documentService.update({
|
|
18667
|
+
documentId: entry.documentId,
|
|
18668
|
+
data: { populate: populate2, dependencies: dependencies.join(",") }
|
|
18669
|
+
});
|
|
18670
|
+
}
|
|
18671
|
+
}
|
|
18651
18672
|
log.error("Failed to save cached entry", error2);
|
|
18652
|
-
return;
|
|
18653
18673
|
}
|
|
18654
18674
|
},
|
|
18655
18675
|
async clear(params) {
|
package/dist/server/index.mjs
CHANGED
|
@@ -18402,7 +18402,7 @@ function asBoolean(value) {
|
|
|
18402
18402
|
const normalized = value.toLowerCase().trim();
|
|
18403
18403
|
return normalized !== "false" && normalized !== "0";
|
|
18404
18404
|
}
|
|
18405
|
-
const version = "1.15.0-rc.
|
|
18405
|
+
const version = "1.15.0-rc.1";
|
|
18406
18406
|
const name = "@fourlights/strapi-plugin-deep-populate";
|
|
18407
18407
|
const f = (msg, context = void 0) => {
|
|
18408
18408
|
const prefix = `[${name}] `;
|
|
@@ -18437,7 +18437,7 @@ async function clearCacheForChangedSchemas(schemas) {
|
|
|
18437
18437
|
dependencies: { $contains: schema2 }
|
|
18438
18438
|
}
|
|
18439
18439
|
});
|
|
18440
|
-
log.
|
|
18440
|
+
log.debug(`Deleted ${deleted.count} cached entries due to out of date schema '${schema2}'`);
|
|
18441
18441
|
});
|
|
18442
18442
|
}
|
|
18443
18443
|
const register = async ({ strapi: strapi2 }) => {
|
|
@@ -18533,6 +18533,22 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
18533
18533
|
return result;
|
|
18534
18534
|
});
|
|
18535
18535
|
};
|
|
18536
|
+
const UniqueConstraintErrorCodes = {
|
|
18537
|
+
// PostgreSQL
|
|
18538
|
+
POSTGRES_UNIQUE_VIOLATION: "23505",
|
|
18539
|
+
// MySQL
|
|
18540
|
+
MYSQL_DUPLICATE_ENTRY: 1062,
|
|
18541
|
+
// SQLite
|
|
18542
|
+
SQLITE_CONSTRAINT: 19,
|
|
18543
|
+
SQLITE_CONSTRAINT_UNIQUE: 2067,
|
|
18544
|
+
// SQL Server
|
|
18545
|
+
SQLSERVER_DUPLICATE_KEY: 2601,
|
|
18546
|
+
SQLSERVER_UNIQUE_KEY_VIOLATION: 2627
|
|
18547
|
+
};
|
|
18548
|
+
const isUniqueConstraintError = (error2) => {
|
|
18549
|
+
const err = error2;
|
|
18550
|
+
return Object.keys(UniqueConstraintErrorCodes).includes(err.code) || err.code === UniqueConstraintErrorCodes.POSTGRES_UNIQUE_VIOLATION || err.errno === UniqueConstraintErrorCodes.MYSQL_DUPLICATE_ENTRY || err.errno === UniqueConstraintErrorCodes.SQLITE_CONSTRAINT || err.errno === UniqueConstraintErrorCodes.SQLITE_CONSTRAINT_UNIQUE || err.number === UniqueConstraintErrorCodes.SQLSERVER_DUPLICATE_KEY || err.number === UniqueConstraintErrorCodes.SQLSERVER_UNIQUE_KEY_VIOLATION;
|
|
18551
|
+
};
|
|
18536
18552
|
const majorMinorVersion = version.split(".").slice(0, -1).join(".");
|
|
18537
18553
|
const sanitizeObject = (obj) => {
|
|
18538
18554
|
if (obj === null || typeof obj !== "object") return obj;
|
|
@@ -18613,15 +18629,19 @@ const cache = ({ strapi: strapi2 }) => ({
|
|
|
18613
18629
|
async set({ populate: populate2, dependencies, ...params }) {
|
|
18614
18630
|
const documentService = strapi2.documents("plugin::deep-populate.cache");
|
|
18615
18631
|
const hash = getHash(params);
|
|
18616
|
-
const entry = await documentService.findFirst({ filters: { hash: { $eq: hash } } });
|
|
18617
18632
|
try {
|
|
18618
|
-
return
|
|
18619
|
-
documentId: entry.documentId,
|
|
18620
|
-
data: { populate: populate2, dependencies: dependencies.join(",") }
|
|
18621
|
-
}) : await documentService.create({ data: { hash, params, populate: populate2, dependencies: dependencies.join(",") } });
|
|
18633
|
+
return await documentService.create({ data: { hash, params, populate: populate2, dependencies: dependencies.join(",") } });
|
|
18622
18634
|
} catch (error2) {
|
|
18635
|
+
if (isUniqueConstraintError(error2)) {
|
|
18636
|
+
const entry = await documentService.findFirst({ filters: { hash: { $eq: hash } } });
|
|
18637
|
+
if (entry) {
|
|
18638
|
+
return await documentService.update({
|
|
18639
|
+
documentId: entry.documentId,
|
|
18640
|
+
data: { populate: populate2, dependencies: dependencies.join(",") }
|
|
18641
|
+
});
|
|
18642
|
+
}
|
|
18643
|
+
}
|
|
18623
18644
|
log.error("Failed to save cached entry", error2);
|
|
18624
|
-
return;
|
|
18625
18645
|
}
|
|
18626
18646
|
},
|
|
18627
18647
|
async clear(params) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isUniqueConstraintError: (error: unknown) => boolean;
|
package/package.json
CHANGED