@fourlights/strapi-plugin-deep-populate 1.4.0 → 1.4.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
|
@@ -14612,7 +14612,7 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
14612
14612
|
});
|
|
14613
14613
|
};
|
|
14614
14614
|
const getHash = (params) => {
|
|
14615
|
-
return `${params.contentType}-${params.documentId}-${params.locale}-${params.status}-${params.omitEmpty ? "sparse" : "full"}`;
|
|
14615
|
+
return `${params.contentType}-${params.documentId}-${params.locale}-${params.status}-${params.omitEmpty ? "sparse" : "full"}-${params.localizations ? "all" : "single"}`;
|
|
14616
14616
|
};
|
|
14617
14617
|
const cache = ({ strapi: strapi2 }) => ({
|
|
14618
14618
|
async get(params) {
|
|
@@ -14727,11 +14727,7 @@ async function _populateRelation({
|
|
|
14727
14727
|
contentType,
|
|
14728
14728
|
relation,
|
|
14729
14729
|
resolvedRelations,
|
|
14730
|
-
|
|
14731
|
-
locale: locale2,
|
|
14732
|
-
status: status2,
|
|
14733
|
-
__deny,
|
|
14734
|
-
__allow
|
|
14730
|
+
...params
|
|
14735
14731
|
}) {
|
|
14736
14732
|
const isSingleRelation = !Array.isArray(relation);
|
|
14737
14733
|
const relations = isSingleRelation ? [relation] : relation;
|
|
@@ -14743,11 +14739,7 @@ async function _populateRelation({
|
|
|
14743
14739
|
documentId: relation2.documentId,
|
|
14744
14740
|
schema: contentType,
|
|
14745
14741
|
resolvedRelations,
|
|
14746
|
-
|
|
14747
|
-
locale: locale2,
|
|
14748
|
-
status: status2,
|
|
14749
|
-
__deny,
|
|
14750
|
-
__allow
|
|
14742
|
+
...params
|
|
14751
14743
|
});
|
|
14752
14744
|
resolvedRelations.set(relation2.documentId, relationPopulate);
|
|
14753
14745
|
}
|
|
@@ -14824,7 +14816,11 @@ async function _populate({
|
|
|
14824
14816
|
for (const [attrName, attr] of relations) {
|
|
14825
14817
|
const value = _resolveValue({ document: document2, attrName, lookup });
|
|
14826
14818
|
if (!hasValue(value)) {
|
|
14827
|
-
if (
|
|
14819
|
+
if (omitEmpty !== true) newPopulate[attrName] = true;
|
|
14820
|
+
continue;
|
|
14821
|
+
}
|
|
14822
|
+
if (params.localizations !== true && attrName === "localizations" && hasValue(value)) {
|
|
14823
|
+
newPopulate[attrName] = true;
|
|
14828
14824
|
continue;
|
|
14829
14825
|
}
|
|
14830
14826
|
if (contentTypes.isRelationalAttribute(attr)) {
|
|
@@ -14876,6 +14872,7 @@ async function _populate({
|
|
|
14876
14872
|
omitEmpty,
|
|
14877
14873
|
locale: params.locale,
|
|
14878
14874
|
status: params.status,
|
|
14875
|
+
localizations: params.localizations,
|
|
14879
14876
|
__deny,
|
|
14880
14877
|
__allow
|
|
14881
14878
|
});
|
|
@@ -14901,7 +14898,10 @@ async function _populate({
|
|
|
14901
14898
|
}
|
|
14902
14899
|
async function populate$1(params) {
|
|
14903
14900
|
const { contentTypes: contentTypes2 } = strapi.config.get("plugin::deep-populate");
|
|
14904
|
-
const contentTypeConfig =
|
|
14901
|
+
const contentTypeConfig = has__default.default(contentTypes2, "*") ? get__default.default(contentTypes2, "*") : {};
|
|
14902
|
+
if (has__default.default(contentTypes2, params.contentType)) {
|
|
14903
|
+
mergeWith__default.default(contentTypeConfig, get__default.default(contentTypes2, params.contentType));
|
|
14904
|
+
}
|
|
14905
14905
|
const { allow, deny } = contentTypeConfig;
|
|
14906
14906
|
const resolvedRelations = /* @__PURE__ */ new Map();
|
|
14907
14907
|
const populated = await _populate({
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isEmpty$1 from "lodash/isEmpty";
|
|
2
2
|
import isObject$4 from "lodash/isObject";
|
|
3
|
-
import ___default
|
|
3
|
+
import ___default from "lodash";
|
|
4
4
|
import { curry, isArray, isObject as isObject$5, isEmpty as isEmpty$2, cloneDeep, omit, isNil, trim as trim$1, isString, pipe as pipe$1, split as split$1, map as map$2, flatten, first, identity, constant, join, eq, clone as clone$3, get, pick, has as has$1, union, getOr, toPath, isBoolean as isBoolean$1 } from "lodash/fp";
|
|
5
5
|
import require$$1 from "crypto";
|
|
6
6
|
import require$$0$1 from "child_process";
|
|
@@ -14587,7 +14587,7 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
14587
14587
|
});
|
|
14588
14588
|
};
|
|
14589
14589
|
const getHash = (params) => {
|
|
14590
|
-
return `${params.contentType}-${params.documentId}-${params.locale}-${params.status}-${params.omitEmpty ? "sparse" : "full"}`;
|
|
14590
|
+
return `${params.contentType}-${params.documentId}-${params.locale}-${params.status}-${params.omitEmpty ? "sparse" : "full"}-${params.localizations ? "all" : "single"}`;
|
|
14591
14591
|
};
|
|
14592
14592
|
const cache = ({ strapi: strapi2 }) => ({
|
|
14593
14593
|
async get(params) {
|
|
@@ -14702,11 +14702,7 @@ async function _populateRelation({
|
|
|
14702
14702
|
contentType,
|
|
14703
14703
|
relation,
|
|
14704
14704
|
resolvedRelations,
|
|
14705
|
-
|
|
14706
|
-
locale: locale2,
|
|
14707
|
-
status: status2,
|
|
14708
|
-
__deny,
|
|
14709
|
-
__allow
|
|
14705
|
+
...params
|
|
14710
14706
|
}) {
|
|
14711
14707
|
const isSingleRelation = !Array.isArray(relation);
|
|
14712
14708
|
const relations = isSingleRelation ? [relation] : relation;
|
|
@@ -14718,11 +14714,7 @@ async function _populateRelation({
|
|
|
14718
14714
|
documentId: relation2.documentId,
|
|
14719
14715
|
schema: contentType,
|
|
14720
14716
|
resolvedRelations,
|
|
14721
|
-
|
|
14722
|
-
locale: locale2,
|
|
14723
|
-
status: status2,
|
|
14724
|
-
__deny,
|
|
14725
|
-
__allow
|
|
14717
|
+
...params
|
|
14726
14718
|
});
|
|
14727
14719
|
resolvedRelations.set(relation2.documentId, relationPopulate);
|
|
14728
14720
|
}
|
|
@@ -14799,7 +14791,11 @@ async function _populate({
|
|
|
14799
14791
|
for (const [attrName, attr] of relations) {
|
|
14800
14792
|
const value = _resolveValue({ document: document2, attrName, lookup });
|
|
14801
14793
|
if (!hasValue(value)) {
|
|
14802
|
-
if (
|
|
14794
|
+
if (omitEmpty !== true) newPopulate[attrName] = true;
|
|
14795
|
+
continue;
|
|
14796
|
+
}
|
|
14797
|
+
if (params.localizations !== true && attrName === "localizations" && hasValue(value)) {
|
|
14798
|
+
newPopulate[attrName] = true;
|
|
14803
14799
|
continue;
|
|
14804
14800
|
}
|
|
14805
14801
|
if (contentTypes.isRelationalAttribute(attr)) {
|
|
@@ -14851,6 +14847,7 @@ async function _populate({
|
|
|
14851
14847
|
omitEmpty,
|
|
14852
14848
|
locale: params.locale,
|
|
14853
14849
|
status: params.status,
|
|
14850
|
+
localizations: params.localizations,
|
|
14854
14851
|
__deny,
|
|
14855
14852
|
__allow
|
|
14856
14853
|
});
|
|
@@ -14876,7 +14873,10 @@ async function _populate({
|
|
|
14876
14873
|
}
|
|
14877
14874
|
async function populate$1(params) {
|
|
14878
14875
|
const { contentTypes: contentTypes2 } = strapi.config.get("plugin::deep-populate");
|
|
14879
|
-
const contentTypeConfig = has
|
|
14876
|
+
const contentTypeConfig = has(contentTypes2, "*") ? get$1(contentTypes2, "*") : {};
|
|
14877
|
+
if (has(contentTypes2, params.contentType)) {
|
|
14878
|
+
mergeWith(contentTypeConfig, get$1(contentTypes2, params.contentType));
|
|
14879
|
+
}
|
|
14880
14880
|
const { allow, deny } = contentTypeConfig;
|
|
14881
14881
|
const resolvedRelations = /* @__PURE__ */ new Map();
|
|
14882
14882
|
const populated = await _populate({
|
|
@@ -14,7 +14,7 @@ type ContentTypeConfig = {
|
|
|
14
14
|
export type Config = {
|
|
15
15
|
useCache: boolean;
|
|
16
16
|
replaceWildcard: boolean;
|
|
17
|
-
contentTypes: Record<UID.ContentType, ContentTypeConfig>;
|
|
17
|
+
contentTypes: Record<UID.ContentType | "*", ContentTypeConfig>;
|
|
18
18
|
};
|
|
19
19
|
declare const _default: {
|
|
20
20
|
default: ({ env }: {
|
|
@@ -73,6 +73,7 @@ declare const _default: {
|
|
|
73
73
|
contentType: import("@strapi/types/dist/uid").ContentType;
|
|
74
74
|
documentId: string;
|
|
75
75
|
omitEmpty?: boolean;
|
|
76
|
+
localizations?: boolean;
|
|
76
77
|
} & {
|
|
77
78
|
populate?: import("@strapi/types/dist/modules/documents/params/populate").Any<import("@strapi/types/dist/uid").ContentType>;
|
|
78
79
|
} & {
|
|
@@ -14,6 +14,7 @@ declare const _default: {
|
|
|
14
14
|
contentType: import("@strapi/types/dist/uid").ContentType;
|
|
15
15
|
documentId: string;
|
|
16
16
|
omitEmpty?: boolean;
|
|
17
|
+
localizations?: boolean;
|
|
17
18
|
} & {
|
|
18
19
|
populate?: import("@strapi/types/dist/modules/documents/params/populate").Any<import("@strapi/types/dist/uid").ContentType>;
|
|
19
20
|
} & {
|
package/package.json
CHANGED