@fourlights/strapi-plugin-deep-populate 1.11.1 → 1.12.0

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.
@@ -18467,11 +18467,11 @@ const register = async ({ strapi: strapi2 }) => {
18467
18467
  context.fields = ["documentId", "status", "locale"];
18468
18468
  const result = await next();
18469
18469
  if (!result) return result;
18470
- if (["create", "update"].includes(context.action)) {
18470
+ if (["create", "update", "publish"].includes(context.action)) {
18471
18471
  const { documentId, publishedAt, locale: locale2 } = result;
18472
18472
  const status = publishedAt !== null ? "published" : "draft";
18473
- if (useCache && context.action === "update")
18474
- await cacheService.clear({ ...context.params, contentType: context.uid });
18473
+ const refreshCache = useCache && ["update", "publish"].includes(context.action);
18474
+ if (refreshCache) await cacheService.clear({ ...context.params, status, contentType: context.uid });
18475
18475
  if (useCache || returnDeeplyPopulated) {
18476
18476
  const deepPopulate = await populateService.get({ contentType: context.uid, documentId, status, locale: locale2 });
18477
18477
  if (returnDeeplyPopulated)
@@ -18508,7 +18508,7 @@ const register = async ({ strapi: strapi2 }) => {
18508
18508
  return result;
18509
18509
  });
18510
18510
  };
18511
- const version = "1.11.1";
18511
+ const version = "1.12.0";
18512
18512
  const name = "@fourlights/strapi-plugin-deep-populate";
18513
18513
  const error = (msg, context = void 0) => strapi.log.error(`[${name}] ${msg}`, context);
18514
18514
  const warn = (msg, context = void 0) => strapi.log.warn(`[${name}] ${msg}`, context);
@@ -18615,8 +18615,9 @@ const cache = ({ strapi: strapi2 }) => ({
18615
18615
  await this.refreshDependents(params.documentId);
18616
18616
  return retval;
18617
18617
  },
18618
- async refreshDependents(documentId) {
18619
- const entries = await strapi2.documents("plugin::deep-populate.cache").findMany({ filters: { dependencies: { $contains: documentId } }, fields: ["documentId", "params"] });
18618
+ async refreshDependents(documentId, status) {
18619
+ let entries = await strapi2.documents("plugin::deep-populate.cache").findMany({ filters: { dependencies: { $contains: documentId } }, fields: ["documentId", "params"] });
18620
+ if (status !== void 0) entries = entries.filter((entry) => entry.params.status === status);
18620
18621
  const deleted = await strapi2.db.query("plugin::deep-populate.cache").deleteMany({
18621
18622
  where: {
18622
18623
  documentId: { $in: entries.map((x) => x.documentId) }
@@ -18900,7 +18901,8 @@ async function populate$1(params) {
18900
18901
  });
18901
18902
  populated.__deepPopulated = true;
18902
18903
  populated.__deepPopulateConfig = config2;
18903
- return { populate: populated, dependencies: [...resolvedRelations.keys()] };
18904
+ const dependencies = [...resolvedRelations.keys()].filter((r) => !r.startsWith("api::"));
18905
+ return { populate: populated, dependencies };
18904
18906
  }
18905
18907
  const populate = ({ strapi: strapi2 }) => ({
18906
18908
  async get(params) {
@@ -18439,11 +18439,11 @@ const register = async ({ strapi: strapi2 }) => {
18439
18439
  context.fields = ["documentId", "status", "locale"];
18440
18440
  const result = await next();
18441
18441
  if (!result) return result;
18442
- if (["create", "update"].includes(context.action)) {
18442
+ if (["create", "update", "publish"].includes(context.action)) {
18443
18443
  const { documentId, publishedAt, locale: locale2 } = result;
18444
18444
  const status = publishedAt !== null ? "published" : "draft";
18445
- if (useCache && context.action === "update")
18446
- await cacheService.clear({ ...context.params, contentType: context.uid });
18445
+ const refreshCache = useCache && ["update", "publish"].includes(context.action);
18446
+ if (refreshCache) await cacheService.clear({ ...context.params, status, contentType: context.uid });
18447
18447
  if (useCache || returnDeeplyPopulated) {
18448
18448
  const deepPopulate = await populateService.get({ contentType: context.uid, documentId, status, locale: locale2 });
18449
18449
  if (returnDeeplyPopulated)
@@ -18480,7 +18480,7 @@ const register = async ({ strapi: strapi2 }) => {
18480
18480
  return result;
18481
18481
  });
18482
18482
  };
18483
- const version = "1.11.1";
18483
+ const version = "1.12.0";
18484
18484
  const name = "@fourlights/strapi-plugin-deep-populate";
18485
18485
  const error = (msg, context = void 0) => strapi.log.error(`[${name}] ${msg}`, context);
18486
18486
  const warn = (msg, context = void 0) => strapi.log.warn(`[${name}] ${msg}`, context);
@@ -18587,8 +18587,9 @@ const cache = ({ strapi: strapi2 }) => ({
18587
18587
  await this.refreshDependents(params.documentId);
18588
18588
  return retval;
18589
18589
  },
18590
- async refreshDependents(documentId) {
18591
- const entries = await strapi2.documents("plugin::deep-populate.cache").findMany({ filters: { dependencies: { $contains: documentId } }, fields: ["documentId", "params"] });
18590
+ async refreshDependents(documentId, status) {
18591
+ let entries = await strapi2.documents("plugin::deep-populate.cache").findMany({ filters: { dependencies: { $contains: documentId } }, fields: ["documentId", "params"] });
18592
+ if (status !== void 0) entries = entries.filter((entry) => entry.params.status === status);
18592
18593
  const deleted = await strapi2.db.query("plugin::deep-populate.cache").deleteMany({
18593
18594
  where: {
18594
18595
  documentId: { $in: entries.map((x) => x.documentId) }
@@ -18872,7 +18873,8 @@ async function populate$1(params) {
18872
18873
  });
18873
18874
  populated.__deepPopulated = true;
18874
18875
  populated.__deepPopulateConfig = config2;
18875
- return { populate: populated, dependencies: [...resolvedRelations.keys()] };
18876
+ const dependencies = [...resolvedRelations.keys()].filter((r) => !r.startsWith("api::"));
18877
+ return { populate: populated, dependencies };
18876
18878
  }
18877
18879
  const populate = ({ strapi: strapi2 }) => ({
18878
18880
  async get(params) {
@@ -81,7 +81,7 @@ declare const _default: {
81
81
  dependencies: string[];
82
82
  }): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
83
83
  clear(params: import("./services/populate").PopulateParams): Promise<any>;
84
- refreshDependents(documentId: string): Promise<void>;
84
+ refreshDependents(documentId: string, status?: "published" | "draft"): Promise<void>;
85
85
  };
86
86
  };
87
87
  register: ({ strapi }: {
@@ -9,6 +9,6 @@ declare const _default: ({ strapi }: {
9
9
  get(params: PopulateParams): Promise<any>;
10
10
  set({ populate, dependencies, ...params }: SetPopulateParams): Promise<Modules.Documents.AnyDocument>;
11
11
  clear(params: PopulateParams): Promise<any>;
12
- refreshDependents(documentId: string): Promise<void>;
12
+ refreshDependents(documentId: string, status?: "draft" | "published" | undefined): Promise<void>;
13
13
  };
14
14
  export default _default;
@@ -22,7 +22,7 @@ declare const _default: {
22
22
  dependencies: string[];
23
23
  }): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
24
24
  clear(params: import("./populate").PopulateParams): Promise<any>;
25
- refreshDependents(documentId: string): Promise<void>;
25
+ refreshDependents(documentId: string, status?: "published" | "draft"): Promise<void>;
26
26
  };
27
27
  };
28
28
  export default _default;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.1",
2
+ "version": "1.12.0",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",