@fourlights/strapi-plugin-deep-populate 1.9.2 → 1.10.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.
@@ -23,6 +23,7 @@ require("node:stream");
23
23
  const cloneDeep = require("lodash/cloneDeep");
24
24
  const unset = require("lodash/unset");
25
25
  const get = require("lodash/get");
26
+ const isEqual = require("lodash/isEqual");
26
27
  const merge$2 = require("lodash/merge");
27
28
  const mergeWith = require("lodash/mergeWith");
28
29
  const set$2 = require("lodash/set");
@@ -49,6 +50,7 @@ const require$$0__default$7 = /* @__PURE__ */ _interopDefault(require$$0$8);
49
50
  const cloneDeep__default = /* @__PURE__ */ _interopDefault(cloneDeep);
50
51
  const unset__default = /* @__PURE__ */ _interopDefault(unset);
51
52
  const get__default = /* @__PURE__ */ _interopDefault(get);
53
+ const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
52
54
  const merge__default = /* @__PURE__ */ _interopDefault(merge$2);
53
55
  const mergeWith__default = /* @__PURE__ */ _interopDefault(mergeWith);
54
56
  const set__default = /* @__PURE__ */ _interopDefault(set$2);
@@ -16064,7 +16066,7 @@ class Doc {
16064
16066
  return new F(...args, lines.join("\n"));
16065
16067
  }
16066
16068
  }
16067
- const version = {
16069
+ const version$1 = {
16068
16070
  major: 4,
16069
16071
  minor: 0,
16070
16072
  patch: 0
@@ -16075,7 +16077,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
16075
16077
  defineLazy(inst._zod, "id", () => def.type + "_" + randomString(10));
16076
16078
  inst._zod.def = def;
16077
16079
  inst._zod.bag = inst._zod.bag || {};
16078
- inst._zod.version = version;
16080
+ inst._zod.version = version$1;
16079
16081
  const checks = [...inst._zod.def.checks ?? []];
16080
16082
  if (inst._zod.traits.has("$ZodCheck")) {
16081
16083
  checks.unshift(inst);
@@ -18464,7 +18466,10 @@ const register = async ({ strapi: strapi2 }) => {
18464
18466
  const { populate: populate2 } = context.params;
18465
18467
  const bustCache = asBoolean(context.params.bustCache);
18466
18468
  const returnDeeplyPopulated = replaceWildcard && await populateIsWildcardEquivalent({ strapi: strapi2, schema: context.contentType, populate: populate2 });
18467
- if (has__default.default(populate2, "__deepPopulated")) unset__default.default(populate2, "__deepPopulated");
18469
+ if (has__default.default(populate2, "__deepPopulated")) {
18470
+ unset__default.default(populate2, "__deepPopulated");
18471
+ unset__default.default(populate2, "__deepPopulateConfig");
18472
+ }
18468
18473
  if (useCache && context.action === "delete")
18469
18474
  await cacheService.clear({ ...context.params, contentType: context.uid });
18470
18475
  const originalFields = cloneDeep__default.default(context.fields);
@@ -18513,16 +18518,83 @@ const register = async ({ strapi: strapi2 }) => {
18513
18518
  return result;
18514
18519
  });
18515
18520
  };
18521
+ const version = "1.10.0-rc.1";
18522
+ const sanitizeObject = (obj) => {
18523
+ if (obj === null || typeof obj !== "object") return obj;
18524
+ const dangerousProps = ["__proto__", "constructor", "prototype"];
18525
+ const sanitized = {};
18526
+ for (const key in obj) {
18527
+ if (dangerousProps.includes(key)) continue;
18528
+ if (typeof obj[key] === "object" && ___default.isNil(obj[key])) {
18529
+ sanitized[key] = sanitizeObject(obj[key]);
18530
+ } else {
18531
+ sanitized[key] = obj[key];
18532
+ }
18533
+ }
18534
+ return sanitized;
18535
+ };
18536
+ const getRelations = (model) => {
18537
+ const filteredAttributes = /* @__PURE__ */ new Set();
18538
+ const { populateCreatorFields } = getOptions(model);
18539
+ const { pluginOptions } = model;
18540
+ if (pluginOptions?.i18n?.localized !== true) {
18541
+ filteredAttributes.add("locale");
18542
+ filteredAttributes.add("localizations");
18543
+ }
18544
+ if (!populateCreatorFields) {
18545
+ filteredAttributes.add(constants$2.CREATED_BY_ATTRIBUTE);
18546
+ filteredAttributes.add(constants$2.UPDATED_BY_ATTRIBUTE);
18547
+ }
18548
+ const relationalAttributes = /* @__PURE__ */ new Set([
18549
+ ...getRelationalAttributes(model).filter((attr) => !filteredAttributes.has(attr)),
18550
+ ...getComponentAttributes(model).filter((attr) => !filteredAttributes.has(attr))
18551
+ ]);
18552
+ return Object.entries(model.attributes).filter(
18553
+ ([attrName, attr]) => relationalAttributes.has(attrName) || isMediaAttribute(attr)
18554
+ );
18555
+ };
18556
+ const isEmpty = (obj) => {
18557
+ return obj === void 0 || Object.keys(obj).length === 0;
18558
+ };
18559
+ const hasValue = (value) => {
18560
+ return !(value === null || value === void 0 || Array.isArray(value) && value.length === 0 || typeof value === "object" && isEmpty(value));
18561
+ };
18562
+ const getConfig = (params) => {
18563
+ const {
18564
+ omitEmpty: omitEmptyFallback,
18565
+ localizations: localizationsFallback,
18566
+ contentTypes: contentTypes2
18567
+ } = strapi.config.get("plugin::deep-populate");
18568
+ const contentTypeConfig = ___default.has(contentTypes2, "*") ? ___default.get(contentTypes2, "*") : {};
18569
+ if (___default.has(contentTypes2, params.contentType)) {
18570
+ ___default.mergeWith(contentTypeConfig, sanitizeObject(___default.get(contentTypes2, params.contentType)));
18571
+ }
18572
+ const { allow, deny } = contentTypeConfig;
18573
+ const omitEmpty = params.omitEmpty ?? contentTypeConfig.omitEmpty ?? omitEmptyFallback;
18574
+ const localizations = params.localizations ?? contentTypeConfig.localizations ?? localizationsFallback;
18575
+ return { allow, deny, omitEmpty, localizations };
18576
+ };
18577
+ const majorMinorVersion = version.split(".").slice(0, -1).join(".");
18578
+ const isEqualConfig = (lhs, rhs) => {
18579
+ const cleanedLhs = JSON.parse(JSON.stringify(lhs));
18580
+ const cleanedRhs = JSON.parse(JSON.stringify(rhs));
18581
+ return isEqual__default.default(cleanedLhs, cleanedRhs);
18582
+ };
18516
18583
  const getHash = (params) => {
18517
- return `${params.contentType}-${params.documentId}-${params.locale}-${params.status}-${params.omitEmpty ? "sparse" : "full"}-${params.localizations ? "all" : "single"}`;
18584
+ return `${majorMinorVersion}-${params.contentType}-${params.documentId}-${params.locale}-${params.status}`;
18518
18585
  };
18519
- const isValid = (entry) => {
18520
- return entry && !isEmpty__default.default(entry.populate) && has__default.default(entry.populate, "__deepPopulated");
18586
+ const isValid = (entry, params) => {
18587
+ if (entry && !isEmpty__default.default(entry.populate) && get__default.default(entry.populate, "__deepPopulated", false)) {
18588
+ const cachedConfig = entry.populate.__deepPopulateConfig;
18589
+ const currentConfig = getConfig(params);
18590
+ return isEqualConfig(cachedConfig, currentConfig);
18591
+ }
18592
+ return false;
18521
18593
  };
18522
18594
  const cache = ({ strapi: strapi2 }) => ({
18523
18595
  async get(params) {
18524
18596
  const entry = await strapi2.documents("plugin::deep-populate.cache").findFirst({ filters: { hash: { $eq: getHash(params) } } });
18525
- return isValid(entry) ? entry.populate : null;
18597
+ return isValid(entry, params) ? entry.populate : null;
18526
18598
  },
18527
18599
  async set({ populate: populate2, dependencies, ...params }) {
18528
18600
  const documentService = strapi2.documents("plugin::deep-populate.cache");
@@ -18558,46 +18630,6 @@ const cache = ({ strapi: strapi2 }) => ({
18558
18630
  }
18559
18631
  }
18560
18632
  });
18561
- const sanitizeObject = (obj) => {
18562
- if (obj === null || typeof obj !== "object") return obj;
18563
- const dangerousProps = ["__proto__", "constructor", "prototype"];
18564
- const sanitized = {};
18565
- for (const key in obj) {
18566
- if (dangerousProps.includes(key)) continue;
18567
- if (typeof obj[key] === "object" && ___default.isNil(obj[key])) {
18568
- sanitized[key] = sanitizeObject(obj[key]);
18569
- } else {
18570
- sanitized[key] = obj[key];
18571
- }
18572
- }
18573
- return sanitized;
18574
- };
18575
- const getRelations = (model) => {
18576
- const filteredAttributes = /* @__PURE__ */ new Set();
18577
- const { populateCreatorFields } = getOptions(model);
18578
- const { pluginOptions } = model;
18579
- if (pluginOptions?.i18n?.localized !== true) {
18580
- filteredAttributes.add("locale");
18581
- filteredAttributes.add("localizations");
18582
- }
18583
- if (!populateCreatorFields) {
18584
- filteredAttributes.add(constants$2.CREATED_BY_ATTRIBUTE);
18585
- filteredAttributes.add(constants$2.UPDATED_BY_ATTRIBUTE);
18586
- }
18587
- const relationalAttributes = /* @__PURE__ */ new Set([
18588
- ...getRelationalAttributes(model).filter((attr) => !filteredAttributes.has(attr)),
18589
- ...getComponentAttributes(model).filter((attr) => !filteredAttributes.has(attr))
18590
- ]);
18591
- return Object.entries(model.attributes).filter(
18592
- ([attrName, attr]) => relationalAttributes.has(attrName) || isMediaAttribute(attr)
18593
- );
18594
- };
18595
- const isEmpty = (obj) => {
18596
- return obj === void 0 || Object.keys(obj).length === 0;
18597
- };
18598
- const hasValue = (value) => {
18599
- return !(value === null || value === void 0 || Array.isArray(value) && value.length === 0 || typeof value === "object" && isEmpty(value));
18600
- };
18601
18633
  async function _populateComponent({
18602
18634
  schema: schema2,
18603
18635
  populate: populate2 = {},
@@ -18773,7 +18805,7 @@ async function _populate({
18773
18805
  continue;
18774
18806
  }
18775
18807
  if (__deny?.relations?.includes(attr.target)) {
18776
- newPopulate[attrName] = true;
18808
+ newPopulate[attrName] = false;
18777
18809
  continue;
18778
18810
  }
18779
18811
  }
@@ -18783,7 +18815,7 @@ async function _populate({
18783
18815
  continue;
18784
18816
  }
18785
18817
  if (__deny?.components?.includes(attr.component)) {
18786
- newPopulate[attrName] = true;
18818
+ newPopulate[attrName] = false;
18787
18819
  continue;
18788
18820
  }
18789
18821
  }
@@ -18841,23 +18873,19 @@ async function _populate({
18841
18873
  return newPopulate;
18842
18874
  }
18843
18875
  async function populate$1(params) {
18844
- const { omitEmpty, localizations, contentTypes: contentTypes2 } = strapi.config.get("plugin::deep-populate");
18845
- const contentTypeConfig = has__default.default(contentTypes2, "*") ? get__default.default(contentTypes2, "*") : {};
18846
- if (has__default.default(contentTypes2, params.contentType)) {
18847
- mergeWith__default.default(contentTypeConfig, sanitizeObject(get__default.default(contentTypes2, params.contentType)));
18848
- }
18849
- const { allow, deny } = contentTypeConfig;
18876
+ const config2 = getConfig(params);
18850
18877
  const resolvedRelations = /* @__PURE__ */ new Map();
18851
18878
  const populated = await _populate({
18852
- omitEmpty: contentTypeConfig.omitEmpty ?? omitEmpty,
18853
- localizations: contentTypeConfig.localizations ?? localizations,
18854
18879
  schema: params.contentType,
18855
18880
  resolvedRelations,
18856
- __deny: deny,
18857
- __allow: allow,
18881
+ omitEmpty: config2.omitEmpty,
18882
+ localizations: config2.localizations,
18883
+ __deny: config2.deny,
18884
+ __allow: config2.allow,
18858
18885
  ...params
18859
18886
  });
18860
18887
  populated.__deepPopulated = true;
18888
+ populated.__deepPopulateConfig = config2;
18861
18889
  return { populate: populated, dependencies: [...resolvedRelations.keys()] };
18862
18890
  }
18863
18891
  const populate = ({ strapi: strapi2 }) => ({
@@ -1,6 +1,6 @@
1
1
  import isEmpty$1 from "lodash/isEmpty";
2
2
  import isObject$2 from "lodash/isObject";
3
- import ___default, { isNil as isNil$1 } from "lodash";
3
+ import ___default, { isNil as isNil$1, has as has$1, get as get$1, mergeWith } from "lodash";
4
4
  import { union as union$1, getOr, curry, isObject as isObject$3, isNil, clone as clone$2, isArray, pick as pick$1, isEmpty as isEmpty$2, cloneDeep, omit as omit$1, isString, trim as trim$1, pipe as pipe$2, split, map as map$2, flatten, first, constant, identity, join, eq, get } from "lodash/fp";
5
5
  import require$$1 from "crypto";
6
6
  import require$$0$1 from "child_process";
@@ -21,9 +21,10 @@ import require$$0$8 from "constants";
21
21
  import "node:stream";
22
22
  import cloneDeep$1 from "lodash/cloneDeep";
23
23
  import unset from "lodash/unset";
24
- import get$1 from "lodash/get";
24
+ import get$2 from "lodash/get";
25
+ import isEqual from "lodash/isEqual";
25
26
  import merge$2 from "lodash/merge";
26
- import mergeWith from "lodash/mergeWith";
27
+ import mergeWith$1 from "lodash/mergeWith";
27
28
  import set$2 from "lodash/set";
28
29
  const config$1 = {
29
30
  default: ({ env: env2 }) => ({ useCache: true, replaceWildcard: true, contentTypes: {} }),
@@ -16037,7 +16038,7 @@ class Doc {
16037
16038
  return new F(...args, lines.join("\n"));
16038
16039
  }
16039
16040
  }
16040
- const version = {
16041
+ const version$1 = {
16041
16042
  major: 4,
16042
16043
  minor: 0,
16043
16044
  patch: 0
@@ -16048,7 +16049,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
16048
16049
  defineLazy(inst._zod, "id", () => def.type + "_" + randomString(10));
16049
16050
  inst._zod.def = def;
16050
16051
  inst._zod.bag = inst._zod.bag || {};
16051
- inst._zod.version = version;
16052
+ inst._zod.version = version$1;
16052
16053
  const checks = [...inst._zod.def.checks ?? []];
16053
16054
  if (inst._zod.traits.has("$ZodCheck")) {
16054
16055
  checks.unshift(inst);
@@ -18437,7 +18438,10 @@ const register = async ({ strapi: strapi2 }) => {
18437
18438
  const { populate: populate2 } = context.params;
18438
18439
  const bustCache = asBoolean(context.params.bustCache);
18439
18440
  const returnDeeplyPopulated = replaceWildcard && await populateIsWildcardEquivalent({ strapi: strapi2, schema: context.contentType, populate: populate2 });
18440
- if (has(populate2, "__deepPopulated")) unset(populate2, "__deepPopulated");
18441
+ if (has(populate2, "__deepPopulated")) {
18442
+ unset(populate2, "__deepPopulated");
18443
+ unset(populate2, "__deepPopulateConfig");
18444
+ }
18441
18445
  if (useCache && context.action === "delete")
18442
18446
  await cacheService.clear({ ...context.params, contentType: context.uid });
18443
18447
  const originalFields = cloneDeep$1(context.fields);
@@ -18486,16 +18490,83 @@ const register = async ({ strapi: strapi2 }) => {
18486
18490
  return result;
18487
18491
  });
18488
18492
  };
18493
+ const version = "1.10.0-rc.1";
18494
+ const sanitizeObject = (obj) => {
18495
+ if (obj === null || typeof obj !== "object") return obj;
18496
+ const dangerousProps = ["__proto__", "constructor", "prototype"];
18497
+ const sanitized = {};
18498
+ for (const key in obj) {
18499
+ if (dangerousProps.includes(key)) continue;
18500
+ if (typeof obj[key] === "object" && isNil$1(obj[key])) {
18501
+ sanitized[key] = sanitizeObject(obj[key]);
18502
+ } else {
18503
+ sanitized[key] = obj[key];
18504
+ }
18505
+ }
18506
+ return sanitized;
18507
+ };
18508
+ const getRelations = (model) => {
18509
+ const filteredAttributes = /* @__PURE__ */ new Set();
18510
+ const { populateCreatorFields } = getOptions(model);
18511
+ const { pluginOptions } = model;
18512
+ if (pluginOptions?.i18n?.localized !== true) {
18513
+ filteredAttributes.add("locale");
18514
+ filteredAttributes.add("localizations");
18515
+ }
18516
+ if (!populateCreatorFields) {
18517
+ filteredAttributes.add(constants$2.CREATED_BY_ATTRIBUTE);
18518
+ filteredAttributes.add(constants$2.UPDATED_BY_ATTRIBUTE);
18519
+ }
18520
+ const relationalAttributes = /* @__PURE__ */ new Set([
18521
+ ...getRelationalAttributes(model).filter((attr) => !filteredAttributes.has(attr)),
18522
+ ...getComponentAttributes(model).filter((attr) => !filteredAttributes.has(attr))
18523
+ ]);
18524
+ return Object.entries(model.attributes).filter(
18525
+ ([attrName, attr]) => relationalAttributes.has(attrName) || isMediaAttribute(attr)
18526
+ );
18527
+ };
18528
+ const isEmpty = (obj) => {
18529
+ return obj === void 0 || Object.keys(obj).length === 0;
18530
+ };
18531
+ const hasValue = (value) => {
18532
+ return !(value === null || value === void 0 || Array.isArray(value) && value.length === 0 || typeof value === "object" && isEmpty(value));
18533
+ };
18534
+ const getConfig = (params) => {
18535
+ const {
18536
+ omitEmpty: omitEmptyFallback,
18537
+ localizations: localizationsFallback,
18538
+ contentTypes: contentTypes2
18539
+ } = strapi.config.get("plugin::deep-populate");
18540
+ const contentTypeConfig = has$1(contentTypes2, "*") ? get$1(contentTypes2, "*") : {};
18541
+ if (has$1(contentTypes2, params.contentType)) {
18542
+ mergeWith(contentTypeConfig, sanitizeObject(get$1(contentTypes2, params.contentType)));
18543
+ }
18544
+ const { allow, deny } = contentTypeConfig;
18545
+ const omitEmpty = params.omitEmpty ?? contentTypeConfig.omitEmpty ?? omitEmptyFallback;
18546
+ const localizations = params.localizations ?? contentTypeConfig.localizations ?? localizationsFallback;
18547
+ return { allow, deny, omitEmpty, localizations };
18548
+ };
18549
+ const majorMinorVersion = version.split(".").slice(0, -1).join(".");
18550
+ const isEqualConfig = (lhs, rhs) => {
18551
+ const cleanedLhs = JSON.parse(JSON.stringify(lhs));
18552
+ const cleanedRhs = JSON.parse(JSON.stringify(rhs));
18553
+ return isEqual(cleanedLhs, cleanedRhs);
18554
+ };
18489
18555
  const getHash = (params) => {
18490
- return `${params.contentType}-${params.documentId}-${params.locale}-${params.status}-${params.omitEmpty ? "sparse" : "full"}-${params.localizations ? "all" : "single"}`;
18556
+ return `${majorMinorVersion}-${params.contentType}-${params.documentId}-${params.locale}-${params.status}`;
18491
18557
  };
18492
- const isValid = (entry) => {
18493
- return entry && !isEmpty$1(entry.populate) && has(entry.populate, "__deepPopulated");
18558
+ const isValid = (entry, params) => {
18559
+ if (entry && !isEmpty$1(entry.populate) && get$2(entry.populate, "__deepPopulated", false)) {
18560
+ const cachedConfig = entry.populate.__deepPopulateConfig;
18561
+ const currentConfig = getConfig(params);
18562
+ return isEqualConfig(cachedConfig, currentConfig);
18563
+ }
18564
+ return false;
18494
18565
  };
18495
18566
  const cache = ({ strapi: strapi2 }) => ({
18496
18567
  async get(params) {
18497
18568
  const entry = await strapi2.documents("plugin::deep-populate.cache").findFirst({ filters: { hash: { $eq: getHash(params) } } });
18498
- return isValid(entry) ? entry.populate : null;
18569
+ return isValid(entry, params) ? entry.populate : null;
18499
18570
  },
18500
18571
  async set({ populate: populate2, dependencies, ...params }) {
18501
18572
  const documentService = strapi2.documents("plugin::deep-populate.cache");
@@ -18531,46 +18602,6 @@ const cache = ({ strapi: strapi2 }) => ({
18531
18602
  }
18532
18603
  }
18533
18604
  });
18534
- const sanitizeObject = (obj) => {
18535
- if (obj === null || typeof obj !== "object") return obj;
18536
- const dangerousProps = ["__proto__", "constructor", "prototype"];
18537
- const sanitized = {};
18538
- for (const key in obj) {
18539
- if (dangerousProps.includes(key)) continue;
18540
- if (typeof obj[key] === "object" && isNil$1(obj[key])) {
18541
- sanitized[key] = sanitizeObject(obj[key]);
18542
- } else {
18543
- sanitized[key] = obj[key];
18544
- }
18545
- }
18546
- return sanitized;
18547
- };
18548
- const getRelations = (model) => {
18549
- const filteredAttributes = /* @__PURE__ */ new Set();
18550
- const { populateCreatorFields } = getOptions(model);
18551
- const { pluginOptions } = model;
18552
- if (pluginOptions?.i18n?.localized !== true) {
18553
- filteredAttributes.add("locale");
18554
- filteredAttributes.add("localizations");
18555
- }
18556
- if (!populateCreatorFields) {
18557
- filteredAttributes.add(constants$2.CREATED_BY_ATTRIBUTE);
18558
- filteredAttributes.add(constants$2.UPDATED_BY_ATTRIBUTE);
18559
- }
18560
- const relationalAttributes = /* @__PURE__ */ new Set([
18561
- ...getRelationalAttributes(model).filter((attr) => !filteredAttributes.has(attr)),
18562
- ...getComponentAttributes(model).filter((attr) => !filteredAttributes.has(attr))
18563
- ]);
18564
- return Object.entries(model.attributes).filter(
18565
- ([attrName, attr]) => relationalAttributes.has(attrName) || isMediaAttribute(attr)
18566
- );
18567
- };
18568
- const isEmpty = (obj) => {
18569
- return obj === void 0 || Object.keys(obj).length === 0;
18570
- };
18571
- const hasValue = (value) => {
18572
- return !(value === null || value === void 0 || Array.isArray(value) && value.length === 0 || typeof value === "object" && isEmpty(value));
18573
- };
18574
18605
  async function _populateComponent({
18575
18606
  schema: schema2,
18576
18607
  populate: populate2 = {},
@@ -18612,7 +18643,7 @@ async function _populateDynamicZone({
18612
18643
  inDynamicZone: true,
18613
18644
  ...params
18614
18645
  });
18615
- const currentPopulate = get$1(resolvedPopulate, [component]);
18646
+ const currentPopulate = get$2(resolvedPopulate, [component]);
18616
18647
  const mergedComponentPopulate = !currentPopulate && componentPopulate === true ? componentPopulate : merge$2({}, currentPopulate, sanitizeObject(componentPopulate));
18617
18648
  set$2(resolvedPopulate, [component], mergedComponentPopulate);
18618
18649
  }
@@ -18647,7 +18678,7 @@ async function _populateRelation({
18647
18678
  const newPopulate = {};
18648
18679
  for (const { documentId } of relations) {
18649
18680
  const relationPopulate = sanitizeObject(resolvedRelations.get(documentId));
18650
- mergeWith(newPopulate, relationPopulate, (existing, proposed) => {
18681
+ mergeWith$1(newPopulate, relationPopulate, (existing, proposed) => {
18651
18682
  if (proposed === true && existing) return existing;
18652
18683
  return void 0;
18653
18684
  });
@@ -18664,20 +18695,20 @@ const _resolveValue = ({ document: document2, lookup, attrName }) => {
18664
18695
  if (componentLookup.find((l) => l === "on")) {
18665
18696
  throw Error("Nested dynamic zones are not supported");
18666
18697
  }
18667
- const dynamicZoneValue = dynamicZoneLookup.length === 0 ? document2 : get$1(document2, dynamicZoneLookup, []);
18698
+ const dynamicZoneValue = dynamicZoneLookup.length === 0 ? document2 : get$2(document2, dynamicZoneLookup, []);
18668
18699
  const componentValue = dynamicZoneValue.filter((b) => b.__component === dynamicZoneComponent).flatMap((c) => _resolveValue({ document: c, lookup: componentLookup, attrName }));
18669
18700
  return (Array.isArray(componentValue) ? componentValue : [componentValue]).filter((v) => hasValue(v));
18670
18701
  }
18671
18702
  if (populateIdx !== -1) {
18672
18703
  const parentLookup = lookup.slice(0, populateIdx);
18673
18704
  const childLookup = lookup.slice(populateIdx + 1, lookup.length);
18674
- const parentValue2 = parentLookup.length === 0 ? document2 : get$1(document2, parentLookup);
18705
+ const parentValue2 = parentLookup.length === 0 ? document2 : get$2(document2, parentLookup);
18675
18706
  const childValue = (Array.isArray(parentValue2) ? parentValue2 : [parentValue2]).flatMap(
18676
18707
  (v) => _resolveValue({ document: v, lookup: childLookup, attrName })
18677
18708
  );
18678
18709
  return childValue.filter((v) => hasValue(v));
18679
18710
  }
18680
- const parentValue = lookup.length === 0 ? document2 : get$1(document2, lookup);
18711
+ const parentValue = lookup.length === 0 ? document2 : get$2(document2, lookup);
18681
18712
  if (Array.isArray(parentValue)) {
18682
18713
  return parentValue.map((v) => v[attrName]).filter((v) => hasValue(v));
18683
18714
  }
@@ -18706,7 +18737,7 @@ async function _populate({
18706
18737
  resolvedRelations.set(params.documentId, true);
18707
18738
  for (const [attrName, attr] of relations) {
18708
18739
  if (lookup.length > 0) {
18709
- const parent = get$1(currentPopulate, lookup);
18740
+ const parent = get$2(currentPopulate, lookup);
18710
18741
  if (parent === void 0 || parent !== "*" && "populate" in parent && parent.populate === "*")
18711
18742
  set$2(currentPopulate, [...lookup, "populate"], {});
18712
18743
  set$2(
@@ -18746,7 +18777,7 @@ async function _populate({
18746
18777
  continue;
18747
18778
  }
18748
18779
  if (__deny?.relations?.includes(attr.target)) {
18749
- newPopulate[attrName] = true;
18780
+ newPopulate[attrName] = false;
18750
18781
  continue;
18751
18782
  }
18752
18783
  }
@@ -18756,7 +18787,7 @@ async function _populate({
18756
18787
  continue;
18757
18788
  }
18758
18789
  if (__deny?.components?.includes(attr.component)) {
18759
- newPopulate[attrName] = true;
18790
+ newPopulate[attrName] = false;
18760
18791
  continue;
18761
18792
  }
18762
18793
  }
@@ -18814,23 +18845,19 @@ async function _populate({
18814
18845
  return newPopulate;
18815
18846
  }
18816
18847
  async function populate$1(params) {
18817
- const { omitEmpty, localizations, contentTypes: contentTypes2 } = strapi.config.get("plugin::deep-populate");
18818
- const contentTypeConfig = has(contentTypes2, "*") ? get$1(contentTypes2, "*") : {};
18819
- if (has(contentTypes2, params.contentType)) {
18820
- mergeWith(contentTypeConfig, sanitizeObject(get$1(contentTypes2, params.contentType)));
18821
- }
18822
- const { allow, deny } = contentTypeConfig;
18848
+ const config2 = getConfig(params);
18823
18849
  const resolvedRelations = /* @__PURE__ */ new Map();
18824
18850
  const populated = await _populate({
18825
- omitEmpty: contentTypeConfig.omitEmpty ?? omitEmpty,
18826
- localizations: contentTypeConfig.localizations ?? localizations,
18827
18851
  schema: params.contentType,
18828
18852
  resolvedRelations,
18829
- __deny: deny,
18830
- __allow: allow,
18853
+ omitEmpty: config2.omitEmpty,
18854
+ localizations: config2.localizations,
18855
+ __deny: config2.deny,
18856
+ __allow: config2.allow,
18831
18857
  ...params
18832
18858
  });
18833
18859
  populated.__deepPopulated = true;
18860
+ populated.__deepPopulateConfig = config2;
18834
18861
  return { populate: populated, dependencies: [...resolvedRelations.keys()] };
18835
18862
  }
18836
18863
  const populate = ({ strapi: strapi2 }) => ({
@@ -1,4 +1,11 @@
1
1
  import type { Schema, UID } from "@strapi/strapi";
2
+ import type { PopulateParams } from "../populate";
2
3
  export declare const getRelations: <TSchema extends UID.Schema>(model: Schema.Schema<TSchema>) => [string, Schema.Attribute.AnyAttribute][];
3
4
  export declare const isEmpty: (obj: object) => boolean;
4
5
  export declare const hasValue: (value: unknown) => boolean;
6
+ export declare const getConfig: (params: PopulateParams) => {
7
+ allow: import("../../config").ContentTypeConfigAllow;
8
+ deny: import("../../config").ContentTypeConfigDeny;
9
+ omitEmpty: boolean;
10
+ localizations: boolean;
11
+ };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.9.2",
2
+ "version": "1.10.0-rc.1",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",