@fourlights/strapi-plugin-deep-populate 1.13.0 → 1.15.0-rc.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.
package/README.md CHANGED
@@ -149,7 +149,26 @@ Settings are applied in the following priority order (highest to lowest):
149
149
 
150
150
  ### Caching
151
151
 
152
- The plugin caches populate objects to improve performance. Cache can be disabled via the `useCache` setting.
152
+ The plugin caches populate objects to improve performance. Cache can be disabled
153
+ via the `useCache` setting. Cache entires are persisted in the database and can
154
+ become stale after content-type updates. You can use the `cacheOptions > clearCacheOnStartup` to force cache purging on server start.
155
+
156
+ #### Cache Configuration
157
+
158
+ ```js
159
+ // config/plugins.js
160
+ module.exports = ({ env }) => ({
161
+ 'deep-populate': {
162
+ enabled: true,
163
+ config: {
164
+ useCache: true, // Enable caching (default: true)
165
+ cacheOptions: {
166
+ clearCacheOnStartup: false, // Clear cache on server startup (default: false)
167
+ }
168
+ }
169
+ }
170
+ });
171
+ ```
153
172
 
154
173
  ### Creator Fields
155
174
 
@@ -194,3 +213,30 @@ The plugin recursively:
194
213
  4. Returns a complete populate object
195
214
 
196
215
  This process handles all relation types including dynamic zones and circular references.
216
+
217
+ ----
218
+
219
+ ## Troubleshooting
220
+
221
+ Due to the dynamic nature of Strapi, stuff becomes complex pretty quickly and it can sometimes become tricky to see the proverbial forest through the trees.
222
+ In that case, feel free to open up an issue and I'll try to help you out.
223
+
224
+ But first, make sure you:
225
+
226
+ 1. use the latest version of the plugin
227
+ 2. use the latest version of Strapi
228
+ 3. see if disabling the cache fixes the problem
229
+ 4. check if your content-types are still valid, e.g. no dynamic zones who reference deleted components etc.
230
+ 5. check you don't have attributes/relations marked as private if you expect them in the API response
231
+
232
+ If that didn't fix it, open up that issue! Make sure you report the used versions (plugin & strapi) and preferably share the affected content-type definitions. Or even better, a reproduction of the problem.
233
+
234
+ ----
235
+
236
+ ## Star History
237
+
238
+ [![Star History Chart](https://api.star-history.com/svg?repos=Four-Lights-NL/strapi-plugin-deep-populate&type=date&legend=top-left)](https://www.star-history.com/#Four-Lights-NL/strapi-plugin-deep-populate&type=date&legend=top-left)
239
+
240
+ Thanks for reading and using the plugin. If you like it, consider starring it to give me a nice little dopamine hit next time I'm working on it.
241
+
242
+ ### Built with ☕ in [Deventer, NL](https://en.wikipedia.org/wiki/Deventer).
@@ -54,6 +54,20 @@ const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
54
54
  const merge__default = /* @__PURE__ */ _interopDefault(merge$2);
55
55
  const mergeWith__default = /* @__PURE__ */ _interopDefault(mergeWith);
56
56
  const set__default = /* @__PURE__ */ _interopDefault(set$2);
57
+ const bootstrap = async ({ strapi: strapi2 }) => {
58
+ const { cacheOptions } = strapi2.config.get("plugin::deep-populate");
59
+ if (cacheOptions?.clearCacheOnStartup === true) {
60
+ try {
61
+ await strapi2.db.query("plugin::deep-populate.cache").deleteMany({
62
+ where: {
63
+ id: { $gt: 0 }
64
+ }
65
+ });
66
+ } catch (error2) {
67
+ strapi2.log.error("❌ Error during startup cache deletion:", error2);
68
+ }
69
+ }
70
+ };
57
71
  const config$1 = {
58
72
  default: ({ env: env2 }) => ({ useCache: true, replaceWildcard: true, contentTypes: {} }),
59
73
  validator: (config2) => {
@@ -618,9 +632,9 @@ function requireDist() {
618
632
  t2.exports = "constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",");
619
633
  }, function(t2, n2, r) {
620
634
  var e = r(2), o = r(6), i = r(7), c = r(5), u = "prototype", s = function(t3, n3, r2) {
621
- var f, a, p, l = t3 & s.F, v = t3 & s.G, h = t3 & s.S, d = t3 & s.P, y = t3 & s.B, _ = t3 & s.W, x = v ? o : o[n3] || (o[n3] = {}), m = x[u], w = v ? e : h ? e[n3] : (e[n3] || {})[u];
635
+ var f2, a, p, l = t3 & s.F, v = t3 & s.G, h = t3 & s.S, d = t3 & s.P, y = t3 & s.B, _ = t3 & s.W, x = v ? o : o[n3] || (o[n3] = {}), m = x[u], w = v ? e : h ? e[n3] : (e[n3] || {})[u];
622
636
  v && (r2 = n3);
623
- for (f in r2) a = !l && w && void 0 !== w[f], a && f in x || (p = a ? w[f] : r2[f], x[f] = v && "function" != typeof w[f] ? r2[f] : y && a ? i(p, e) : _ && w[f] == p ? (function(t4) {
637
+ for (f2 in r2) a = !l && w && void 0 !== w[f2], a && f2 in x || (p = a ? w[f2] : r2[f2], x[f2] = v && "function" != typeof w[f2] ? r2[f2] : y && a ? i(p, e) : _ && w[f2] == p ? (function(t4) {
624
638
  var n4 = function(n5, r3, e2) {
625
639
  if (this instanceof t4) {
626
640
  switch (arguments.length) {
@@ -636,7 +650,7 @@ function requireDist() {
636
650
  return t4.apply(this, arguments);
637
651
  };
638
652
  return n4[u] = t4[u], n4;
639
- })(p) : d && "function" == typeof p ? i(Function.call, p) : p, d && ((x.virtual || (x.virtual = {}))[f] = p, t3 & s.R && m && !m[f] && c(m, f, p)));
653
+ })(p) : d && "function" == typeof p ? i(Function.call, p) : p, d && ((x.virtual || (x.virtual = {}))[f2] = p, t3 & s.R && m && !m[f2] && c(m, f2, p)));
640
654
  };
641
655
  s.F = 1, s.G = 2, s.S = 4, s.P = 8, s.B = 16, s.W = 32, s.U = 64, s.R = 128, t2.exports = s;
642
656
  }, function(t2, n2) {
@@ -656,11 +670,11 @@ function requireDist() {
656
670
  } }).a;
657
671
  });
658
672
  }, function(t2, n2, r) {
659
- var e = r(28), o = r(23), i = r(57), c = r(5), u = r(8), s = r(10), f = r(45), a = r(18), p = r(52), l = r(1)("iterator"), v = !([].keys && "next" in [].keys()), h = "@@iterator", d = "keys", y = "values", _ = function() {
673
+ var e = r(28), o = r(23), i = r(57), c = r(5), u = r(8), s = r(10), f2 = r(45), a = r(18), p = r(52), l = r(1)("iterator"), v = !([].keys && "next" in [].keys()), h = "@@iterator", d = "keys", y = "values", _ = function() {
660
674
  return this;
661
675
  };
662
676
  t2.exports = function(t3, n3, r2, x, m, w, g) {
663
- f(r2, n3, x);
677
+ f2(r2, n3, x);
664
678
  var b, O, j, S = function(t4) {
665
679
  if (!v && t4 in T) return T[t4];
666
680
  switch (t4) {
@@ -691,7 +705,7 @@ function requireDist() {
691
705
  return i[t3] || (i[t3] = {});
692
706
  };
693
707
  }, function(t2, n2, r) {
694
- var e, o, i, c = r(7), u = r(41), s = r(25), f = r(16), a = r(2), p = a.process, l = a.setImmediate, v = a.clearImmediate, h = a.MessageChannel, d = 0, y = {}, _ = "onreadystatechange", x = function() {
708
+ var e, o, i, c = r(7), u = r(41), s = r(25), f2 = r(16), a = r(2), p = a.process, l = a.setImmediate, v = a.clearImmediate, h = a.MessageChannel, d = 0, y = {}, _ = "onreadystatechange", x = function() {
695
709
  var t3 = +this;
696
710
  if (y.hasOwnProperty(t3)) {
697
711
  var n3 = y[t3];
@@ -711,8 +725,8 @@ function requireDist() {
711
725
  p.nextTick(c(x, t3, 1));
712
726
  } : h ? (o = new h(), i = o.port2, o.port1.onmessage = m, e = c(i.postMessage, i, 1)) : a.addEventListener && "function" == typeof postMessage && !a.importScripts ? (e = function(t3) {
713
727
  a.postMessage(t3 + "", "*");
714
- }, a.addEventListener("message", m, false)) : e = _ in f("script") ? function(t3) {
715
- s.appendChild(f("script"))[_] = function() {
728
+ }, a.addEventListener("message", m, false)) : e = _ in f2("script") ? function(t3) {
729
+ s.appendChild(f2("script"))[_] = function() {
716
730
  s.removeChild(this), x.call(t3);
717
731
  };
718
732
  } : function(t3) {
@@ -776,7 +790,7 @@ function requireDist() {
776
790
  });
777
791
  }
778
792
  Object.defineProperty(n2, "__esModule", { value: true });
779
- var f = r(35), a = e(f);
793
+ var f2 = r(35), a = e(f2);
780
794
  n2.machineIdSync = u, n2.machineId = s;
781
795
  var p = r(70), l = r(71), v = process, h = v.platform, d = { native: "%windir%\\System32", mixed: "%windir%\\sysnative\\cmd.exe /c %windir%\\System32" }, y = { darwin: "ioreg -rd1 -c IOPlatformExpertDevice", win32: d[o()] + "\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid", linux: "( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :", freebsd: "kenv -q smbios.system.uuid || sysctl -n kern.hostuuid" };
782
796
  }, function(t2, n2, r) {
@@ -795,24 +809,24 @@ function requireDist() {
795
809
  var e = r(13), o = r(31), i = r(62);
796
810
  t2.exports = function(t3) {
797
811
  return function(n3, r2, c) {
798
- var u, s = e(n3), f = o(s.length), a = i(c, f);
812
+ var u, s = e(n3), f2 = o(s.length), a = i(c, f2);
799
813
  if (t3 && r2 != r2) {
800
- for (; f > a; ) if (u = s[a++], u != u) return true;
801
- } else for (; f > a; a++) if ((t3 || a in s) && s[a] === r2) return t3 || a || 0;
814
+ for (; f2 > a; ) if (u = s[a++], u != u) return true;
815
+ } else for (; f2 > a; a++) if ((t3 || a in s) && s[a] === r2) return t3 || a || 0;
802
816
  return !t3 && -1;
803
817
  };
804
818
  };
805
819
  }, function(t2, n2, r) {
806
- var e = r(7), o = r(44), i = r(43), c = r(3), u = r(31), s = r(64), f = {}, a = {}, n2 = t2.exports = function(t3, n3, r2, p, l) {
820
+ var e = r(7), o = r(44), i = r(43), c = r(3), u = r(31), s = r(64), f2 = {}, a = {}, n2 = t2.exports = function(t3, n3, r2, p, l) {
807
821
  var v, h, d, y, _ = l ? function() {
808
822
  return t3;
809
823
  } : s(t3), x = e(r2, p, n3 ? 2 : 1), m = 0;
810
824
  if ("function" != typeof _) throw TypeError(t3 + " is not iterable!");
811
825
  if (i(_)) {
812
- for (v = u(t3.length); v > m; m++) if (y = n3 ? x(c(h = t3[m])[0], h[1]) : x(t3[m]), y === f || y === a) return y;
813
- } else for (d = _.call(t3); !(h = d.next()).done; ) if (y = o(d, x, h.value, n3), y === f || y === a) return y;
826
+ for (v = u(t3.length); v > m; m++) if (y = n3 ? x(c(h = t3[m])[0], h[1]) : x(t3[m]), y === f2 || y === a) return y;
827
+ } else for (d = _.call(t3); !(h = d.next()).done; ) if (y = o(d, x, h.value, n3), y === f2 || y === a) return y;
814
828
  };
815
- n2.BREAK = f, n2.RETURN = a;
829
+ n2.BREAK = f2, n2.RETURN = a;
816
830
  }, function(t2, n2) {
817
831
  t2.exports = function(t3, n3, r) {
818
832
  var e = void 0 === r;
@@ -889,7 +903,7 @@ function requireDist() {
889
903
  }, function(t2, n2, r) {
890
904
  var e = r(2), o = r(30).set, i = e.MutationObserver || e.WebKitMutationObserver, c = e.process, u = e.Promise, s = "process" == r(11)(c);
891
905
  t2.exports = function() {
892
- var t3, n3, r2, f = function() {
906
+ var t3, n3, r2, f2 = function() {
893
907
  var e2, o2;
894
908
  for (s && (e2 = c.domain) && e2.exit(); t3; ) {
895
909
  o2 = t3.fn, t3 = t3.next;
@@ -902,20 +916,20 @@ function requireDist() {
902
916
  n3 = void 0, e2 && e2.enter();
903
917
  };
904
918
  if (s) r2 = function() {
905
- c.nextTick(f);
919
+ c.nextTick(f2);
906
920
  };
907
921
  else if (i) {
908
922
  var a = true, p = document.createTextNode("");
909
- new i(f).observe(p, { characterData: true }), r2 = function() {
923
+ new i(f2).observe(p, { characterData: true }), r2 = function() {
910
924
  p.data = a = !a;
911
925
  };
912
926
  } else if (u && u.resolve) {
913
927
  var l = u.resolve();
914
928
  r2 = function() {
915
- l.then(f);
929
+ l.then(f2);
916
930
  };
917
931
  } else r2 = function() {
918
- o.call(e, f);
932
+ o.call(e, f2);
919
933
  };
920
934
  return function(e2) {
921
935
  var o2 = { fn: e2, next: void 0 };
@@ -924,14 +938,14 @@ function requireDist() {
924
938
  };
925
939
  }, function(t2, n2, r) {
926
940
  var e = r(3), o = r(50), i = r(22), c = r(19)("IE_PROTO"), u = function() {
927
- }, s = "prototype", f = function() {
941
+ }, s = "prototype", f2 = function() {
928
942
  var t3, n3 = r(16)("iframe"), e2 = i.length, o2 = ">";
929
- for (n3.style.display = "none", r(25).appendChild(n3), n3.src = "javascript:", t3 = n3.contentWindow.document, t3.open(), t3.write("<script>document.F=Object<\/script" + o2), t3.close(), f = t3.F; e2--; ) delete f[s][i[e2]];
930
- return f();
943
+ for (n3.style.display = "none", r(25).appendChild(n3), n3.src = "javascript:", t3 = n3.contentWindow.document, t3.open(), t3.write("<script>document.F=Object<\/script" + o2), t3.close(), f2 = t3.F; e2--; ) delete f2[s][i[e2]];
944
+ return f2();
931
945
  };
932
946
  t2.exports = Object.create || function(t3, n3) {
933
947
  var r2;
934
- return null !== t3 ? (u[s] = e(t3), r2 = new u(), u[s] = null, r2[c] = t3) : r2 = f(), void 0 === n3 ? r2 : o(r2, n3);
948
+ return null !== t3 ? (u[s] = e(t3), r2 = new u(), u[s] = null, r2[c] = t3) : r2 = f2(), void 0 === n3 ? r2 : o(r2, n3);
935
949
  };
936
950
  }, function(t2, n2, r) {
937
951
  var e = r(12), o = r(3), i = r(54);
@@ -941,10 +955,10 @@ function requireDist() {
941
955
  return t3;
942
956
  };
943
957
  }, function(t2, n2, r) {
944
- var e = r(55), o = r(17), i = r(13), c = r(32), u = r(8), s = r(26), f = Object.getOwnPropertyDescriptor;
945
- n2.f = r(4) ? f : function(t3, n3) {
958
+ var e = r(55), o = r(17), i = r(13), c = r(32), u = r(8), s = r(26), f2 = Object.getOwnPropertyDescriptor;
959
+ n2.f = r(4) ? f2 : function(t3, n3) {
946
960
  if (t3 = i(t3), n3 = c(n3, true), s) try {
947
- return f(t3, n3);
961
+ return f2(t3, n3);
948
962
  } catch (t4) {
949
963
  }
950
964
  if (u(t3, n3)) return o(!e.f.call(t3, n3), t3[n3]);
@@ -957,10 +971,10 @@ function requireDist() {
957
971
  }, function(t2, n2, r) {
958
972
  var e = r(8), o = r(13), i = r(39)(false), c = r(19)("IE_PROTO");
959
973
  t2.exports = function(t3, n3) {
960
- var r2, u = o(t3), s = 0, f = [];
961
- for (r2 in u) r2 != c && e(u, r2) && f.push(r2);
962
- for (; n3.length > s; ) e(u, r2 = n3[s++]) && (~i(f, r2) || f.push(r2));
963
- return f;
974
+ var r2, u = o(t3), s = 0, f2 = [];
975
+ for (r2 in u) r2 != c && e(u, r2) && f2.push(r2);
976
+ for (; n3.length > s; ) e(u, r2 = n3[s++]) && (~i(f2, r2) || f2.push(r2));
977
+ return f2;
964
978
  };
965
979
  }, function(t2, n2, r) {
966
980
  var e = r(53), o = r(22);
@@ -1009,8 +1023,8 @@ function requireDist() {
1009
1023
  var e = r(20), o = r(15);
1010
1024
  t2.exports = function(t3) {
1011
1025
  return function(n3, r2) {
1012
- var i, c, u = String(o(n3)), s = e(r2), f = u.length;
1013
- return s < 0 || s >= f ? t3 ? "" : void 0 : (i = u.charCodeAt(s), i < 55296 || i > 56319 || s + 1 === f || (c = u.charCodeAt(s + 1)) < 56320 || c > 57343 ? t3 ? u.charAt(s) : i : t3 ? u.slice(s, s + 2) : (i - 55296 << 10) + (c - 56320) + 65536);
1026
+ var i, c, u = String(o(n3)), s = e(r2), f2 = u.length;
1027
+ return s < 0 || s >= f2 ? t3 ? "" : void 0 : (i = u.charCodeAt(s), i < 55296 || i > 56319 || s + 1 === f2 || (c = u.charCodeAt(s + 1)) < 56320 || c > 57343 ? t3 ? u.charAt(s) : i : t3 ? u.slice(s, s + 2) : (i - 55296 << 10) + (c - 56320) + 65536);
1014
1028
  };
1015
1029
  };
1016
1030
  }, function(t2, n2, r) {
@@ -1038,7 +1052,7 @@ function requireDist() {
1038
1052
  }, "values"), i.Arguments = i.Array, e("keys"), e("values"), e("entries");
1039
1053
  }, function(t2, n2) {
1040
1054
  }, function(t2, n2, r) {
1041
- var e, o, i, c = r(28), u = r(2), s = r(7), f = r(21), a = r(23), p = r(9), l = (r(3), r(14)), v = r(38), h = r(40), d = (r(58).set, r(60)), y = r(30).set, _ = r(48)(), x = "Promise", m = u.TypeError, w = u.process, g = u[x], w = u.process, b = "process" == f(w), O = function() {
1055
+ var e, o, i, c = r(28), u = r(2), s = r(7), f2 = r(21), a = r(23), p = r(9), l = (r(3), r(14)), v = r(38), h = r(40), d = (r(58).set, r(60)), y = r(30).set, _ = r(48)(), x = "Promise", m = u.TypeError, w = u.process, g = u[x], w = u.process, b = "process" == f2(w), O = function() {
1042
1056
  }, j = !!(function() {
1043
1057
  try {
1044
1058
  var t3 = g.resolve(1), n3 = (t3.constructor = {})[r(1)("species")] = function(t4) {
@@ -1072,9 +1086,9 @@ function requireDist() {
1072
1086
  var r2 = t3._c;
1073
1087
  _(function() {
1074
1088
  for (var e2 = t3._v, o2 = 1 == t3._s, i2 = 0, c2 = function(n4) {
1075
- var r3, i3, c3 = o2 ? n4.ok : n4.fail, u2 = n4.resolve, s2 = n4.reject, f2 = n4.domain;
1089
+ var r3, i3, c3 = o2 ? n4.ok : n4.fail, u2 = n4.resolve, s2 = n4.reject, f3 = n4.domain;
1076
1090
  try {
1077
- c3 ? (o2 || (2 == t3._h && I(t3), t3._h = 1), c3 === true ? r3 = e2 : (f2 && f2.enter(), r3 = c3(e2), f2 && f2.exit()), r3 === n4.promise ? s2(m("Promise-chain cycle")) : (i3 = E(r3)) ? i3.call(r3, u2, s2) : u2(r3)) : s2(e2);
1091
+ c3 ? (o2 || (2 == t3._h && I(t3), t3._h = 1), c3 === true ? r3 = e2 : (f3 && f3.enter(), r3 = c3(e2), f3 && f3.exit()), r3 === n4.promise ? s2(m("Promise-chain cycle")) : (i3 = E(r3)) ? i3.call(r3, u2, s2) : u2(r3)) : s2(e2);
1078
1092
  } catch (t4) {
1079
1093
  s2(t4);
1080
1094
  }
@@ -1176,8 +1190,8 @@ function requireDist() {
1176
1190
  }, function(t2, n2, r) {
1177
1191
  r(65);
1178
1192
  for (var e = r(2), o = r(5), i = r(10), c = r(1)("toStringTag"), u = ["NodeList", "DOMTokenList", "MediaList", "StyleSheetList", "CSSRuleList"], s = 0; s < 5; s++) {
1179
- var f = u[s], a = e[f], p = a && a.prototype;
1180
- p && !p[c] && o(p, c, f), i[f] = i.Array;
1193
+ var f2 = u[s], a = e[f2], p = a && a.prototype;
1194
+ p && !p[c] && o(p, c, f2), i[f2] = i.Array;
1181
1195
  }
1182
1196
  }, function(t2, n2) {
1183
1197
  t2.exports = require$$0__default.default;
@@ -1189,9 +1203,9 @@ function requireDist() {
1189
1203
  return dist$1.exports;
1190
1204
  }
1191
1205
  requireDist();
1192
- var map$1;
1206
+ var map$2;
1193
1207
  try {
1194
- map$1 = Map;
1208
+ map$2 = Map;
1195
1209
  } catch (_) {
1196
1210
  }
1197
1211
  var set$1;
@@ -1215,7 +1229,7 @@ function baseClone(src, circulars, clones) {
1215
1229
  if (Array.isArray(src)) {
1216
1230
  return src.map(clone$1);
1217
1231
  }
1218
- if (map$1 && src instanceof map$1) {
1232
+ if (map$2 && src instanceof map$2) {
1219
1233
  return new Map(Array.from(src.entries()));
1220
1234
  }
1221
1235
  if (set$1 && src instanceof set$1) {
@@ -3765,7 +3779,7 @@ function pipe$1(...fns) {
3765
3779
  return res;
3766
3780
  };
3767
3781
  }
3768
- fp.curry(pMap);
3782
+ const map$1 = fp.curry(pMap);
3769
3783
  const visitor$4 = ({ key, attribute }, { remove }) => {
3770
3784
  if (attribute?.type === "password") {
3771
3785
  remove(key);
@@ -18416,6 +18430,19 @@ function asBoolean(value) {
18416
18430
  const normalized = value.toLowerCase().trim();
18417
18431
  return normalized !== "false" && normalized !== "0";
18418
18432
  }
18433
+ const version = "1.15.0-rc.0";
18434
+ const name = "@fourlights/strapi-plugin-deep-populate";
18435
+ const f = (msg, context = void 0) => {
18436
+ const prefix = `[${name}] `;
18437
+ const suffix = context !== void 0 ? `
18438
+ ${prefix}${context}` : "";
18439
+ return `${prefix}${msg}${suffix}`;
18440
+ };
18441
+ const error = (msg, context = void 0) => strapi.log.error(f(msg, context));
18442
+ const warn = (msg, context = void 0) => strapi.log.warn(f(msg, context));
18443
+ const info = (msg, context = void 0) => strapi.log.info(f(msg, context));
18444
+ const debug = (msg, context = void 0) => strapi.log.debug(f(msg, context));
18445
+ const log = { error, warn, info, debug };
18419
18446
  const populateIsWildcardEquivalent = async ({
18420
18447
  strapi: strapi2,
18421
18448
  schema: schema2,
@@ -18431,9 +18458,35 @@ const populateIsWildcardEquivalent = async ({
18431
18458
  );
18432
18459
  return populate2 === "*" || populate2 === true || JSON.stringify(expandedWildcardQuery) === JSON.stringify(populate2);
18433
18460
  };
18461
+ async function clearCacheForChangedSchemas(schemas) {
18462
+ await map$1(schemas, async (schema2) => {
18463
+ const deleted = await strapi.db.query("plugin::deep-populate.cache").deleteMany({
18464
+ where: {
18465
+ dependencies: { $contains: schema2 }
18466
+ }
18467
+ });
18468
+ log.info(`Deleted ${deleted.count} cached entries due to out of date schema '${schema2}'`);
18469
+ });
18470
+ }
18434
18471
  const register = async ({ strapi: strapi2 }) => {
18472
+ strapi2.hook("strapi::content-types.beforeSync").register(async () => {
18473
+ const databaseSchema = await strapi2.db.dialect.schemaInspector.getSchema();
18474
+ const storedSchema = await strapi2.db.schema.schemaStorage.read();
18475
+ const { status, diff } = await strapi2.db.schema.schemaDiff.diff({
18476
+ previousSchema: storedSchema?.schema,
18477
+ databaseSchema,
18478
+ userSchema: strapi2.db.schema.schema
18479
+ });
18480
+ if (status === "CHANGED") {
18481
+ const updatedTables = (diff.tables.updated ?? []).map((t) => t.name);
18482
+ const updatedSchemas = [...strapi2.db.metadata.values()].filter((m) => updatedTables.includes(m.tableName)).map((m) => m.uid);
18483
+ const tableName = strapi2.db.metadata.get("plugin::deep-populate.cache").tableName;
18484
+ const hasTable = await strapi2.db.connection.schema.hasTable(tableName);
18485
+ if (hasTable) await clearCacheForChangedSchemas(updatedSchemas);
18486
+ }
18487
+ });
18435
18488
  strapi2.hook("strapi::content-types.afterSync").register(async () => {
18436
- const tableName = "populate_cache";
18489
+ const tableName = strapi2.db.metadata.get("plugin::deep-populate.cache").tableName;
18437
18490
  const columnName = "dependencies";
18438
18491
  const hasIndex = await hasDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
18439
18492
  const hasTable = await strapi2.db.connection.schema.hasTable(tableName);
@@ -18508,13 +18561,7 @@ const register = async ({ strapi: strapi2 }) => {
18508
18561
  return result;
18509
18562
  });
18510
18563
  };
18511
- const version = "1.13.0";
18512
- const name = "@fourlights/strapi-plugin-deep-populate";
18513
- const error = (msg, context = void 0) => strapi.log.error(`[${name}] ${msg}`, context);
18514
- const warn = (msg, context = void 0) => strapi.log.warn(`[${name}] ${msg}`, context);
18515
- const info = (msg, context = void 0) => strapi.log.info(`[${name}] ${msg}`, context);
18516
- const debug = (msg, context = void 0) => strapi.log.debug(`[${name}] ${msg}`, context);
18517
- const log = { error, warn, info, debug };
18564
+ const majorMinorVersion = version.split(".").slice(0, -1).join(".");
18518
18565
  const sanitizeObject = (obj) => {
18519
18566
  if (obj === null || typeof obj !== "object") return obj;
18520
18567
  const dangerousProps = ["__proto__", "constructor", "prototype"];
@@ -18570,7 +18617,6 @@ const getConfig = (params) => {
18570
18617
  const localizations = params.localizations ?? contentTypeConfig.localizations ?? localizationsFallback;
18571
18618
  return { allow, deny, omitEmpty, localizations };
18572
18619
  };
18573
- const majorMinorVersion = version.split(".").slice(0, -1).join(".");
18574
18620
  const isEqualConfig = (lhs, rhs) => {
18575
18621
  const cleanedLhs = JSON.parse(JSON.stringify(lhs));
18576
18622
  const cleanedRhs = JSON.parse(JSON.stringify(rhs));
@@ -18602,7 +18648,7 @@ const cache = ({ strapi: strapi2 }) => ({
18602
18648
  data: { populate: populate2, dependencies: dependencies.join(",") }
18603
18649
  }) : await documentService.create({ data: { hash, params, populate: populate2, dependencies: dependencies.join(",") } });
18604
18650
  } catch (error2) {
18605
- log.error("[Plugin: Deep Populate] Failed to save cached entry", { error: error2 });
18651
+ log.error("Failed to save cached entry", error2);
18606
18652
  return;
18607
18653
  }
18608
18654
  },
@@ -18770,6 +18816,7 @@ async function _populate({
18770
18816
  populate: populate2 = {},
18771
18817
  lookup = [],
18772
18818
  resolvedRelations,
18819
+ resolvedSchemas,
18773
18820
  omitEmpty,
18774
18821
  __deny,
18775
18822
  __allow,
@@ -18785,6 +18832,7 @@ async function _populate({
18785
18832
  let relations = getRelations(model);
18786
18833
  let currentPopulate = cloneDeep__default.default(populate2);
18787
18834
  resolvedRelations.set(params.documentId, true);
18835
+ resolvedSchemas.add(schema2);
18788
18836
  for (const [attrName, attr] of relations) {
18789
18837
  if (lookup.length > 0) {
18790
18838
  const parent = get__default.default(currentPopulate, lookup);
@@ -18856,6 +18904,7 @@ async function _populate({
18856
18904
  lookup,
18857
18905
  attrName,
18858
18906
  resolvedRelations,
18907
+ resolvedSchemas,
18859
18908
  omitEmpty,
18860
18909
  __deny,
18861
18910
  __allow,
@@ -18867,6 +18916,7 @@ async function _populate({
18867
18916
  contentType: attr.target,
18868
18917
  relation: value,
18869
18918
  resolvedRelations,
18919
+ resolvedSchemas,
18870
18920
  omitEmpty,
18871
18921
  locale: params.locale,
18872
18922
  status: params.status,
@@ -18882,6 +18932,7 @@ async function _populate({
18882
18932
  lookup,
18883
18933
  attrName,
18884
18934
  resolvedRelations,
18935
+ resolvedSchemas,
18885
18936
  omitEmpty,
18886
18937
  __deny,
18887
18938
  __allow,
@@ -18897,9 +18948,11 @@ async function _populate({
18897
18948
  async function populate$1(params) {
18898
18949
  const config2 = getConfig(params);
18899
18950
  const resolvedRelations = /* @__PURE__ */ new Map();
18951
+ const resolvedSchemas = /* @__PURE__ */ new Set();
18900
18952
  const populated = await _populate({
18901
18953
  schema: params.contentType,
18902
18954
  resolvedRelations,
18955
+ resolvedSchemas,
18903
18956
  omitEmpty: config2.omitEmpty,
18904
18957
  localizations: config2.localizations,
18905
18958
  __deny: config2.deny,
@@ -18908,7 +18961,11 @@ async function populate$1(params) {
18908
18961
  });
18909
18962
  populated.__deepPopulated = true;
18910
18963
  populated.__deepPopulateConfig = config2;
18911
- const dependencies = [...resolvedRelations.keys()].filter((r) => !r.startsWith("api::"));
18964
+ const dependencies = [
18965
+ ...[...resolvedRelations.keys()].filter((r) => !r.startsWith("api::")),
18966
+ // Remove content-types from resolved relations
18967
+ ...resolvedSchemas.values()
18968
+ ];
18912
18969
  return { populate: populated, dependencies };
18913
18970
  }
18914
18971
  const populate = ({ strapi: strapi2 }) => ({
@@ -18927,6 +18984,7 @@ const services = {
18927
18984
  cache
18928
18985
  };
18929
18986
  const index = {
18987
+ bootstrap,
18930
18988
  config: config$1,
18931
18989
  contentTypes,
18932
18990
  services,
@@ -1,7 +1,7 @@
1
1
  import isEmpty$1 from "lodash/isEmpty";
2
2
  import isObject$2 from "lodash/isObject";
3
3
  import ___default, { isNil as isNil$1, has as has$1, get as get$1, mergeWith } from "lodash";
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";
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$3, 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";
7
7
  import has from "lodash/has";
@@ -26,6 +26,20 @@ import isEqual from "lodash/isEqual";
26
26
  import merge$2 from "lodash/merge";
27
27
  import mergeWith$1 from "lodash/mergeWith";
28
28
  import set$2 from "lodash/set";
29
+ const bootstrap = async ({ strapi: strapi2 }) => {
30
+ const { cacheOptions } = strapi2.config.get("plugin::deep-populate");
31
+ if (cacheOptions?.clearCacheOnStartup === true) {
32
+ try {
33
+ await strapi2.db.query("plugin::deep-populate.cache").deleteMany({
34
+ where: {
35
+ id: { $gt: 0 }
36
+ }
37
+ });
38
+ } catch (error2) {
39
+ strapi2.log.error("❌ Error during startup cache deletion:", error2);
40
+ }
41
+ }
42
+ };
29
43
  const config$1 = {
30
44
  default: ({ env: env2 }) => ({ useCache: true, replaceWildcard: true, contentTypes: {} }),
31
45
  validator: (config2) => {
@@ -590,9 +604,9 @@ function requireDist() {
590
604
  t2.exports = "constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",");
591
605
  }, function(t2, n2, r) {
592
606
  var e = r(2), o = r(6), i = r(7), c = r(5), u = "prototype", s = function(t3, n3, r2) {
593
- var f, a, p, l = t3 & s.F, v = t3 & s.G, h = t3 & s.S, d = t3 & s.P, y = t3 & s.B, _ = t3 & s.W, x = v ? o : o[n3] || (o[n3] = {}), m = x[u], w = v ? e : h ? e[n3] : (e[n3] || {})[u];
607
+ var f2, a, p, l = t3 & s.F, v = t3 & s.G, h = t3 & s.S, d = t3 & s.P, y = t3 & s.B, _ = t3 & s.W, x = v ? o : o[n3] || (o[n3] = {}), m = x[u], w = v ? e : h ? e[n3] : (e[n3] || {})[u];
594
608
  v && (r2 = n3);
595
- for (f in r2) a = !l && w && void 0 !== w[f], a && f in x || (p = a ? w[f] : r2[f], x[f] = v && "function" != typeof w[f] ? r2[f] : y && a ? i(p, e) : _ && w[f] == p ? (function(t4) {
609
+ for (f2 in r2) a = !l && w && void 0 !== w[f2], a && f2 in x || (p = a ? w[f2] : r2[f2], x[f2] = v && "function" != typeof w[f2] ? r2[f2] : y && a ? i(p, e) : _ && w[f2] == p ? (function(t4) {
596
610
  var n4 = function(n5, r3, e2) {
597
611
  if (this instanceof t4) {
598
612
  switch (arguments.length) {
@@ -608,7 +622,7 @@ function requireDist() {
608
622
  return t4.apply(this, arguments);
609
623
  };
610
624
  return n4[u] = t4[u], n4;
611
- })(p) : d && "function" == typeof p ? i(Function.call, p) : p, d && ((x.virtual || (x.virtual = {}))[f] = p, t3 & s.R && m && !m[f] && c(m, f, p)));
625
+ })(p) : d && "function" == typeof p ? i(Function.call, p) : p, d && ((x.virtual || (x.virtual = {}))[f2] = p, t3 & s.R && m && !m[f2] && c(m, f2, p)));
612
626
  };
613
627
  s.F = 1, s.G = 2, s.S = 4, s.P = 8, s.B = 16, s.W = 32, s.U = 64, s.R = 128, t2.exports = s;
614
628
  }, function(t2, n2) {
@@ -628,11 +642,11 @@ function requireDist() {
628
642
  } }).a;
629
643
  });
630
644
  }, function(t2, n2, r) {
631
- var e = r(28), o = r(23), i = r(57), c = r(5), u = r(8), s = r(10), f = r(45), a = r(18), p = r(52), l = r(1)("iterator"), v = !([].keys && "next" in [].keys()), h = "@@iterator", d = "keys", y = "values", _ = function() {
645
+ var e = r(28), o = r(23), i = r(57), c = r(5), u = r(8), s = r(10), f2 = r(45), a = r(18), p = r(52), l = r(1)("iterator"), v = !([].keys && "next" in [].keys()), h = "@@iterator", d = "keys", y = "values", _ = function() {
632
646
  return this;
633
647
  };
634
648
  t2.exports = function(t3, n3, r2, x, m, w, g) {
635
- f(r2, n3, x);
649
+ f2(r2, n3, x);
636
650
  var b, O, j, S = function(t4) {
637
651
  if (!v && t4 in T) return T[t4];
638
652
  switch (t4) {
@@ -663,7 +677,7 @@ function requireDist() {
663
677
  return i[t3] || (i[t3] = {});
664
678
  };
665
679
  }, function(t2, n2, r) {
666
- var e, o, i, c = r(7), u = r(41), s = r(25), f = r(16), a = r(2), p = a.process, l = a.setImmediate, v = a.clearImmediate, h = a.MessageChannel, d = 0, y = {}, _ = "onreadystatechange", x = function() {
680
+ var e, o, i, c = r(7), u = r(41), s = r(25), f2 = r(16), a = r(2), p = a.process, l = a.setImmediate, v = a.clearImmediate, h = a.MessageChannel, d = 0, y = {}, _ = "onreadystatechange", x = function() {
667
681
  var t3 = +this;
668
682
  if (y.hasOwnProperty(t3)) {
669
683
  var n3 = y[t3];
@@ -683,8 +697,8 @@ function requireDist() {
683
697
  p.nextTick(c(x, t3, 1));
684
698
  } : h ? (o = new h(), i = o.port2, o.port1.onmessage = m, e = c(i.postMessage, i, 1)) : a.addEventListener && "function" == typeof postMessage && !a.importScripts ? (e = function(t3) {
685
699
  a.postMessage(t3 + "", "*");
686
- }, a.addEventListener("message", m, false)) : e = _ in f("script") ? function(t3) {
687
- s.appendChild(f("script"))[_] = function() {
700
+ }, a.addEventListener("message", m, false)) : e = _ in f2("script") ? function(t3) {
701
+ s.appendChild(f2("script"))[_] = function() {
688
702
  s.removeChild(this), x.call(t3);
689
703
  };
690
704
  } : function(t3) {
@@ -748,7 +762,7 @@ function requireDist() {
748
762
  });
749
763
  }
750
764
  Object.defineProperty(n2, "__esModule", { value: true });
751
- var f = r(35), a = e(f);
765
+ var f2 = r(35), a = e(f2);
752
766
  n2.machineIdSync = u, n2.machineId = s;
753
767
  var p = r(70), l = r(71), v = process, h = v.platform, d = { native: "%windir%\\System32", mixed: "%windir%\\sysnative\\cmd.exe /c %windir%\\System32" }, y = { darwin: "ioreg -rd1 -c IOPlatformExpertDevice", win32: d[o()] + "\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid", linux: "( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :", freebsd: "kenv -q smbios.system.uuid || sysctl -n kern.hostuuid" };
754
768
  }, function(t2, n2, r) {
@@ -767,24 +781,24 @@ function requireDist() {
767
781
  var e = r(13), o = r(31), i = r(62);
768
782
  t2.exports = function(t3) {
769
783
  return function(n3, r2, c) {
770
- var u, s = e(n3), f = o(s.length), a = i(c, f);
784
+ var u, s = e(n3), f2 = o(s.length), a = i(c, f2);
771
785
  if (t3 && r2 != r2) {
772
- for (; f > a; ) if (u = s[a++], u != u) return true;
773
- } else for (; f > a; a++) if ((t3 || a in s) && s[a] === r2) return t3 || a || 0;
786
+ for (; f2 > a; ) if (u = s[a++], u != u) return true;
787
+ } else for (; f2 > a; a++) if ((t3 || a in s) && s[a] === r2) return t3 || a || 0;
774
788
  return !t3 && -1;
775
789
  };
776
790
  };
777
791
  }, function(t2, n2, r) {
778
- var e = r(7), o = r(44), i = r(43), c = r(3), u = r(31), s = r(64), f = {}, a = {}, n2 = t2.exports = function(t3, n3, r2, p, l) {
792
+ var e = r(7), o = r(44), i = r(43), c = r(3), u = r(31), s = r(64), f2 = {}, a = {}, n2 = t2.exports = function(t3, n3, r2, p, l) {
779
793
  var v, h, d, y, _ = l ? function() {
780
794
  return t3;
781
795
  } : s(t3), x = e(r2, p, n3 ? 2 : 1), m = 0;
782
796
  if ("function" != typeof _) throw TypeError(t3 + " is not iterable!");
783
797
  if (i(_)) {
784
- for (v = u(t3.length); v > m; m++) if (y = n3 ? x(c(h = t3[m])[0], h[1]) : x(t3[m]), y === f || y === a) return y;
785
- } else for (d = _.call(t3); !(h = d.next()).done; ) if (y = o(d, x, h.value, n3), y === f || y === a) return y;
798
+ for (v = u(t3.length); v > m; m++) if (y = n3 ? x(c(h = t3[m])[0], h[1]) : x(t3[m]), y === f2 || y === a) return y;
799
+ } else for (d = _.call(t3); !(h = d.next()).done; ) if (y = o(d, x, h.value, n3), y === f2 || y === a) return y;
786
800
  };
787
- n2.BREAK = f, n2.RETURN = a;
801
+ n2.BREAK = f2, n2.RETURN = a;
788
802
  }, function(t2, n2) {
789
803
  t2.exports = function(t3, n3, r) {
790
804
  var e = void 0 === r;
@@ -861,7 +875,7 @@ function requireDist() {
861
875
  }, function(t2, n2, r) {
862
876
  var e = r(2), o = r(30).set, i = e.MutationObserver || e.WebKitMutationObserver, c = e.process, u = e.Promise, s = "process" == r(11)(c);
863
877
  t2.exports = function() {
864
- var t3, n3, r2, f = function() {
878
+ var t3, n3, r2, f2 = function() {
865
879
  var e2, o2;
866
880
  for (s && (e2 = c.domain) && e2.exit(); t3; ) {
867
881
  o2 = t3.fn, t3 = t3.next;
@@ -874,20 +888,20 @@ function requireDist() {
874
888
  n3 = void 0, e2 && e2.enter();
875
889
  };
876
890
  if (s) r2 = function() {
877
- c.nextTick(f);
891
+ c.nextTick(f2);
878
892
  };
879
893
  else if (i) {
880
894
  var a = true, p = document.createTextNode("");
881
- new i(f).observe(p, { characterData: true }), r2 = function() {
895
+ new i(f2).observe(p, { characterData: true }), r2 = function() {
882
896
  p.data = a = !a;
883
897
  };
884
898
  } else if (u && u.resolve) {
885
899
  var l = u.resolve();
886
900
  r2 = function() {
887
- l.then(f);
901
+ l.then(f2);
888
902
  };
889
903
  } else r2 = function() {
890
- o.call(e, f);
904
+ o.call(e, f2);
891
905
  };
892
906
  return function(e2) {
893
907
  var o2 = { fn: e2, next: void 0 };
@@ -896,14 +910,14 @@ function requireDist() {
896
910
  };
897
911
  }, function(t2, n2, r) {
898
912
  var e = r(3), o = r(50), i = r(22), c = r(19)("IE_PROTO"), u = function() {
899
- }, s = "prototype", f = function() {
913
+ }, s = "prototype", f2 = function() {
900
914
  var t3, n3 = r(16)("iframe"), e2 = i.length, o2 = ">";
901
- for (n3.style.display = "none", r(25).appendChild(n3), n3.src = "javascript:", t3 = n3.contentWindow.document, t3.open(), t3.write("<script>document.F=Object<\/script" + o2), t3.close(), f = t3.F; e2--; ) delete f[s][i[e2]];
902
- return f();
915
+ for (n3.style.display = "none", r(25).appendChild(n3), n3.src = "javascript:", t3 = n3.contentWindow.document, t3.open(), t3.write("<script>document.F=Object<\/script" + o2), t3.close(), f2 = t3.F; e2--; ) delete f2[s][i[e2]];
916
+ return f2();
903
917
  };
904
918
  t2.exports = Object.create || function(t3, n3) {
905
919
  var r2;
906
- return null !== t3 ? (u[s] = e(t3), r2 = new u(), u[s] = null, r2[c] = t3) : r2 = f(), void 0 === n3 ? r2 : o(r2, n3);
920
+ return null !== t3 ? (u[s] = e(t3), r2 = new u(), u[s] = null, r2[c] = t3) : r2 = f2(), void 0 === n3 ? r2 : o(r2, n3);
907
921
  };
908
922
  }, function(t2, n2, r) {
909
923
  var e = r(12), o = r(3), i = r(54);
@@ -913,10 +927,10 @@ function requireDist() {
913
927
  return t3;
914
928
  };
915
929
  }, function(t2, n2, r) {
916
- var e = r(55), o = r(17), i = r(13), c = r(32), u = r(8), s = r(26), f = Object.getOwnPropertyDescriptor;
917
- n2.f = r(4) ? f : function(t3, n3) {
930
+ var e = r(55), o = r(17), i = r(13), c = r(32), u = r(8), s = r(26), f2 = Object.getOwnPropertyDescriptor;
931
+ n2.f = r(4) ? f2 : function(t3, n3) {
918
932
  if (t3 = i(t3), n3 = c(n3, true), s) try {
919
- return f(t3, n3);
933
+ return f2(t3, n3);
920
934
  } catch (t4) {
921
935
  }
922
936
  if (u(t3, n3)) return o(!e.f.call(t3, n3), t3[n3]);
@@ -929,10 +943,10 @@ function requireDist() {
929
943
  }, function(t2, n2, r) {
930
944
  var e = r(8), o = r(13), i = r(39)(false), c = r(19)("IE_PROTO");
931
945
  t2.exports = function(t3, n3) {
932
- var r2, u = o(t3), s = 0, f = [];
933
- for (r2 in u) r2 != c && e(u, r2) && f.push(r2);
934
- for (; n3.length > s; ) e(u, r2 = n3[s++]) && (~i(f, r2) || f.push(r2));
935
- return f;
946
+ var r2, u = o(t3), s = 0, f2 = [];
947
+ for (r2 in u) r2 != c && e(u, r2) && f2.push(r2);
948
+ for (; n3.length > s; ) e(u, r2 = n3[s++]) && (~i(f2, r2) || f2.push(r2));
949
+ return f2;
936
950
  };
937
951
  }, function(t2, n2, r) {
938
952
  var e = r(53), o = r(22);
@@ -981,8 +995,8 @@ function requireDist() {
981
995
  var e = r(20), o = r(15);
982
996
  t2.exports = function(t3) {
983
997
  return function(n3, r2) {
984
- var i, c, u = String(o(n3)), s = e(r2), f = u.length;
985
- return s < 0 || s >= f ? t3 ? "" : void 0 : (i = u.charCodeAt(s), i < 55296 || i > 56319 || s + 1 === f || (c = u.charCodeAt(s + 1)) < 56320 || c > 57343 ? t3 ? u.charAt(s) : i : t3 ? u.slice(s, s + 2) : (i - 55296 << 10) + (c - 56320) + 65536);
998
+ var i, c, u = String(o(n3)), s = e(r2), f2 = u.length;
999
+ return s < 0 || s >= f2 ? t3 ? "" : void 0 : (i = u.charCodeAt(s), i < 55296 || i > 56319 || s + 1 === f2 || (c = u.charCodeAt(s + 1)) < 56320 || c > 57343 ? t3 ? u.charAt(s) : i : t3 ? u.slice(s, s + 2) : (i - 55296 << 10) + (c - 56320) + 65536);
986
1000
  };
987
1001
  };
988
1002
  }, function(t2, n2, r) {
@@ -1010,7 +1024,7 @@ function requireDist() {
1010
1024
  }, "values"), i.Arguments = i.Array, e("keys"), e("values"), e("entries");
1011
1025
  }, function(t2, n2) {
1012
1026
  }, function(t2, n2, r) {
1013
- var e, o, i, c = r(28), u = r(2), s = r(7), f = r(21), a = r(23), p = r(9), l = (r(3), r(14)), v = r(38), h = r(40), d = (r(58).set, r(60)), y = r(30).set, _ = r(48)(), x = "Promise", m = u.TypeError, w = u.process, g = u[x], w = u.process, b = "process" == f(w), O = function() {
1027
+ var e, o, i, c = r(28), u = r(2), s = r(7), f2 = r(21), a = r(23), p = r(9), l = (r(3), r(14)), v = r(38), h = r(40), d = (r(58).set, r(60)), y = r(30).set, _ = r(48)(), x = "Promise", m = u.TypeError, w = u.process, g = u[x], w = u.process, b = "process" == f2(w), O = function() {
1014
1028
  }, j = !!(function() {
1015
1029
  try {
1016
1030
  var t3 = g.resolve(1), n3 = (t3.constructor = {})[r(1)("species")] = function(t4) {
@@ -1044,9 +1058,9 @@ function requireDist() {
1044
1058
  var r2 = t3._c;
1045
1059
  _(function() {
1046
1060
  for (var e2 = t3._v, o2 = 1 == t3._s, i2 = 0, c2 = function(n4) {
1047
- var r3, i3, c3 = o2 ? n4.ok : n4.fail, u2 = n4.resolve, s2 = n4.reject, f2 = n4.domain;
1061
+ var r3, i3, c3 = o2 ? n4.ok : n4.fail, u2 = n4.resolve, s2 = n4.reject, f3 = n4.domain;
1048
1062
  try {
1049
- c3 ? (o2 || (2 == t3._h && I(t3), t3._h = 1), c3 === true ? r3 = e2 : (f2 && f2.enter(), r3 = c3(e2), f2 && f2.exit()), r3 === n4.promise ? s2(m("Promise-chain cycle")) : (i3 = E(r3)) ? i3.call(r3, u2, s2) : u2(r3)) : s2(e2);
1063
+ c3 ? (o2 || (2 == t3._h && I(t3), t3._h = 1), c3 === true ? r3 = e2 : (f3 && f3.enter(), r3 = c3(e2), f3 && f3.exit()), r3 === n4.promise ? s2(m("Promise-chain cycle")) : (i3 = E(r3)) ? i3.call(r3, u2, s2) : u2(r3)) : s2(e2);
1050
1064
  } catch (t4) {
1051
1065
  s2(t4);
1052
1066
  }
@@ -1148,8 +1162,8 @@ function requireDist() {
1148
1162
  }, function(t2, n2, r) {
1149
1163
  r(65);
1150
1164
  for (var e = r(2), o = r(5), i = r(10), c = r(1)("toStringTag"), u = ["NodeList", "DOMTokenList", "MediaList", "StyleSheetList", "CSSRuleList"], s = 0; s < 5; s++) {
1151
- var f = u[s], a = e[f], p = a && a.prototype;
1152
- p && !p[c] && o(p, c, f), i[f] = i.Array;
1165
+ var f2 = u[s], a = e[f2], p = a && a.prototype;
1166
+ p && !p[c] && o(p, c, f2), i[f2] = i.Array;
1153
1167
  }
1154
1168
  }, function(t2, n2) {
1155
1169
  t2.exports = require$$0$1;
@@ -1161,9 +1175,9 @@ function requireDist() {
1161
1175
  return dist$1.exports;
1162
1176
  }
1163
1177
  requireDist();
1164
- var map$1;
1178
+ var map$2;
1165
1179
  try {
1166
- map$1 = Map;
1180
+ map$2 = Map;
1167
1181
  } catch (_) {
1168
1182
  }
1169
1183
  var set$1;
@@ -1187,7 +1201,7 @@ function baseClone(src, circulars, clones) {
1187
1201
  if (Array.isArray(src)) {
1188
1202
  return src.map(clone$1);
1189
1203
  }
1190
- if (map$1 && src instanceof map$1) {
1204
+ if (map$2 && src instanceof map$2) {
1191
1205
  return new Map(Array.from(src.entries()));
1192
1206
  }
1193
1207
  if (set$1 && src instanceof set$1) {
@@ -3737,7 +3751,7 @@ function pipe$1(...fns) {
3737
3751
  return res;
3738
3752
  };
3739
3753
  }
3740
- curry(pMap);
3754
+ const map$1 = curry(pMap);
3741
3755
  const visitor$4 = ({ key, attribute }, { remove }) => {
3742
3756
  if (attribute?.type === "password") {
3743
3757
  remove(key);
@@ -4055,7 +4069,7 @@ const sort = traverseFactory().intercept(
4055
4069
  return Promise.all(sort2.map((nestedSort) => recurse(visitor2, options, nestedSort))).then((res) => res.filter((nestedSort) => !isEmpty$2(nestedSort)));
4056
4070
  }
4057
4071
  ).parse(isString, () => {
4058
- const tokenize = pipe$2(split("."), map$2(split(":")), flatten);
4072
+ const tokenize = pipe$2(split("."), map$3(split(":")), flatten);
4059
4073
  const recompose = (parts) => {
4060
4074
  if (parts.length === 0) {
4061
4075
  return void 0;
@@ -18388,6 +18402,19 @@ function asBoolean(value) {
18388
18402
  const normalized = value.toLowerCase().trim();
18389
18403
  return normalized !== "false" && normalized !== "0";
18390
18404
  }
18405
+ const version = "1.15.0-rc.0";
18406
+ const name = "@fourlights/strapi-plugin-deep-populate";
18407
+ const f = (msg, context = void 0) => {
18408
+ const prefix = `[${name}] `;
18409
+ const suffix = context !== void 0 ? `
18410
+ ${prefix}${context}` : "";
18411
+ return `${prefix}${msg}${suffix}`;
18412
+ };
18413
+ const error = (msg, context = void 0) => strapi.log.error(f(msg, context));
18414
+ const warn = (msg, context = void 0) => strapi.log.warn(f(msg, context));
18415
+ const info = (msg, context = void 0) => strapi.log.info(f(msg, context));
18416
+ const debug = (msg, context = void 0) => strapi.log.debug(f(msg, context));
18417
+ const log = { error, warn, info, debug };
18391
18418
  const populateIsWildcardEquivalent = async ({
18392
18419
  strapi: strapi2,
18393
18420
  schema: schema2,
@@ -18403,9 +18430,35 @@ const populateIsWildcardEquivalent = async ({
18403
18430
  );
18404
18431
  return populate2 === "*" || populate2 === true || JSON.stringify(expandedWildcardQuery) === JSON.stringify(populate2);
18405
18432
  };
18433
+ async function clearCacheForChangedSchemas(schemas) {
18434
+ await map$1(schemas, async (schema2) => {
18435
+ const deleted = await strapi.db.query("plugin::deep-populate.cache").deleteMany({
18436
+ where: {
18437
+ dependencies: { $contains: schema2 }
18438
+ }
18439
+ });
18440
+ log.info(`Deleted ${deleted.count} cached entries due to out of date schema '${schema2}'`);
18441
+ });
18442
+ }
18406
18443
  const register = async ({ strapi: strapi2 }) => {
18444
+ strapi2.hook("strapi::content-types.beforeSync").register(async () => {
18445
+ const databaseSchema = await strapi2.db.dialect.schemaInspector.getSchema();
18446
+ const storedSchema = await strapi2.db.schema.schemaStorage.read();
18447
+ const { status, diff } = await strapi2.db.schema.schemaDiff.diff({
18448
+ previousSchema: storedSchema?.schema,
18449
+ databaseSchema,
18450
+ userSchema: strapi2.db.schema.schema
18451
+ });
18452
+ if (status === "CHANGED") {
18453
+ const updatedTables = (diff.tables.updated ?? []).map((t) => t.name);
18454
+ const updatedSchemas = [...strapi2.db.metadata.values()].filter((m) => updatedTables.includes(m.tableName)).map((m) => m.uid);
18455
+ const tableName = strapi2.db.metadata.get("plugin::deep-populate.cache").tableName;
18456
+ const hasTable = await strapi2.db.connection.schema.hasTable(tableName);
18457
+ if (hasTable) await clearCacheForChangedSchemas(updatedSchemas);
18458
+ }
18459
+ });
18407
18460
  strapi2.hook("strapi::content-types.afterSync").register(async () => {
18408
- const tableName = "populate_cache";
18461
+ const tableName = strapi2.db.metadata.get("plugin::deep-populate.cache").tableName;
18409
18462
  const columnName = "dependencies";
18410
18463
  const hasIndex = await hasDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
18411
18464
  const hasTable = await strapi2.db.connection.schema.hasTable(tableName);
@@ -18480,13 +18533,7 @@ const register = async ({ strapi: strapi2 }) => {
18480
18533
  return result;
18481
18534
  });
18482
18535
  };
18483
- const version = "1.13.0";
18484
- const name = "@fourlights/strapi-plugin-deep-populate";
18485
- const error = (msg, context = void 0) => strapi.log.error(`[${name}] ${msg}`, context);
18486
- const warn = (msg, context = void 0) => strapi.log.warn(`[${name}] ${msg}`, context);
18487
- const info = (msg, context = void 0) => strapi.log.info(`[${name}] ${msg}`, context);
18488
- const debug = (msg, context = void 0) => strapi.log.debug(`[${name}] ${msg}`, context);
18489
- const log = { error, warn, info, debug };
18536
+ const majorMinorVersion = version.split(".").slice(0, -1).join(".");
18490
18537
  const sanitizeObject = (obj) => {
18491
18538
  if (obj === null || typeof obj !== "object") return obj;
18492
18539
  const dangerousProps = ["__proto__", "constructor", "prototype"];
@@ -18542,7 +18589,6 @@ const getConfig = (params) => {
18542
18589
  const localizations = params.localizations ?? contentTypeConfig.localizations ?? localizationsFallback;
18543
18590
  return { allow, deny, omitEmpty, localizations };
18544
18591
  };
18545
- const majorMinorVersion = version.split(".").slice(0, -1).join(".");
18546
18592
  const isEqualConfig = (lhs, rhs) => {
18547
18593
  const cleanedLhs = JSON.parse(JSON.stringify(lhs));
18548
18594
  const cleanedRhs = JSON.parse(JSON.stringify(rhs));
@@ -18574,7 +18620,7 @@ const cache = ({ strapi: strapi2 }) => ({
18574
18620
  data: { populate: populate2, dependencies: dependencies.join(",") }
18575
18621
  }) : await documentService.create({ data: { hash, params, populate: populate2, dependencies: dependencies.join(",") } });
18576
18622
  } catch (error2) {
18577
- log.error("[Plugin: Deep Populate] Failed to save cached entry", { error: error2 });
18623
+ log.error("Failed to save cached entry", error2);
18578
18624
  return;
18579
18625
  }
18580
18626
  },
@@ -18742,6 +18788,7 @@ async function _populate({
18742
18788
  populate: populate2 = {},
18743
18789
  lookup = [],
18744
18790
  resolvedRelations,
18791
+ resolvedSchemas,
18745
18792
  omitEmpty,
18746
18793
  __deny,
18747
18794
  __allow,
@@ -18757,6 +18804,7 @@ async function _populate({
18757
18804
  let relations = getRelations(model);
18758
18805
  let currentPopulate = cloneDeep$1(populate2);
18759
18806
  resolvedRelations.set(params.documentId, true);
18807
+ resolvedSchemas.add(schema2);
18760
18808
  for (const [attrName, attr] of relations) {
18761
18809
  if (lookup.length > 0) {
18762
18810
  const parent = get$2(currentPopulate, lookup);
@@ -18828,6 +18876,7 @@ async function _populate({
18828
18876
  lookup,
18829
18877
  attrName,
18830
18878
  resolvedRelations,
18879
+ resolvedSchemas,
18831
18880
  omitEmpty,
18832
18881
  __deny,
18833
18882
  __allow,
@@ -18839,6 +18888,7 @@ async function _populate({
18839
18888
  contentType: attr.target,
18840
18889
  relation: value,
18841
18890
  resolvedRelations,
18891
+ resolvedSchemas,
18842
18892
  omitEmpty,
18843
18893
  locale: params.locale,
18844
18894
  status: params.status,
@@ -18854,6 +18904,7 @@ async function _populate({
18854
18904
  lookup,
18855
18905
  attrName,
18856
18906
  resolvedRelations,
18907
+ resolvedSchemas,
18857
18908
  omitEmpty,
18858
18909
  __deny,
18859
18910
  __allow,
@@ -18869,9 +18920,11 @@ async function _populate({
18869
18920
  async function populate$1(params) {
18870
18921
  const config2 = getConfig(params);
18871
18922
  const resolvedRelations = /* @__PURE__ */ new Map();
18923
+ const resolvedSchemas = /* @__PURE__ */ new Set();
18872
18924
  const populated = await _populate({
18873
18925
  schema: params.contentType,
18874
18926
  resolvedRelations,
18927
+ resolvedSchemas,
18875
18928
  omitEmpty: config2.omitEmpty,
18876
18929
  localizations: config2.localizations,
18877
18930
  __deny: config2.deny,
@@ -18880,7 +18933,11 @@ async function populate$1(params) {
18880
18933
  });
18881
18934
  populated.__deepPopulated = true;
18882
18935
  populated.__deepPopulateConfig = config2;
18883
- const dependencies = [...resolvedRelations.keys()].filter((r) => !r.startsWith("api::"));
18936
+ const dependencies = [
18937
+ ...[...resolvedRelations.keys()].filter((r) => !r.startsWith("api::")),
18938
+ // Remove content-types from resolved relations
18939
+ ...resolvedSchemas.values()
18940
+ ];
18884
18941
  return { populate: populated, dependencies };
18885
18942
  }
18886
18943
  const populate = ({ strapi: strapi2 }) => ({
@@ -18899,6 +18956,7 @@ const services = {
18899
18956
  cache
18900
18957
  };
18901
18958
  const index = {
18959
+ bootstrap,
18902
18960
  config: config$1,
18903
18961
  contentTypes,
18904
18962
  services,
@@ -0,0 +1,5 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ declare const bootstrap: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => Promise<void>;
5
+ export default bootstrap;
@@ -13,8 +13,12 @@ export type ContentTypeConfig = {
13
13
  allow?: ContentTypeConfigAllow;
14
14
  deny?: ContentTypeConfigDeny;
15
15
  };
16
+ export type CacheOptions = {
17
+ clearCacheOnStartup?: boolean;
18
+ };
16
19
  export type Config = {
17
20
  useCache: boolean;
21
+ cacheOptions?: CacheOptions;
18
22
  replaceWildcard: boolean;
19
23
  omitEmpty?: boolean;
20
24
  localizations?: boolean;
@@ -1,4 +1,7 @@
1
1
  declare const _default: {
2
+ bootstrap: ({ strapi }: {
3
+ strapi: import("@strapi/types/dist/core").Strapi;
4
+ }) => Promise<void>;
2
5
  config: {
3
6
  default: ({ env }: {
4
7
  env: any;
@@ -1,3 +1,5 @@
1
+ import type { UID } from "@strapi/strapi";
2
+ export declare function clearCacheForChangedSchemas(schemas: UID.Schema[]): Promise<void>;
1
3
  declare const _default: ({ strapi }: {
2
4
  strapi: any;
3
5
  }) => Promise<void>;
@@ -1,11 +1,11 @@
1
- export declare const error: (msg: any, context?: any) => import("winston").Logger;
2
- export declare const warn: (msg: any, context?: any) => import("winston").Logger;
3
- export declare const info: (msg: any, context?: any) => import("winston").Logger;
4
- export declare const debug: (msg: any, context?: any) => import("winston").Logger;
1
+ export declare const error: (msg: string, context?: any) => import("winston").Logger;
2
+ export declare const warn: (msg: string, context?: any) => import("winston").Logger;
3
+ export declare const info: (msg: string, context?: any) => import("winston").Logger;
4
+ export declare const debug: (msg: string, context?: any) => import("winston").Logger;
5
5
  declare const _default: {
6
- error: (msg: any, context?: any) => import("winston").Logger;
7
- warn: (msg: any, context?: any) => import("winston").Logger;
8
- info: (msg: any, context?: any) => import("winston").Logger;
9
- debug: (msg: any, context?: any) => import("winston").Logger;
6
+ error: (msg: string, context?: any) => import("winston").Logger;
7
+ warn: (msg: string, context?: any) => import("winston").Logger;
8
+ info: (msg: string, context?: any) => import("winston").Logger;
9
+ debug: (msg: string, context?: any) => import("winston").Logger;
10
10
  };
11
11
  export default _default;
@@ -0,0 +1 @@
1
+ export declare const majorMinorVersion: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.13.0",
2
+ "version": "1.15.0-rc.0",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",