@fourlights/strapi-plugin-deep-populate 1.0.0-beta.0 → 1.0.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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @fourlights/strapi-plugin-deep-populate
2
2
 
3
+ [![npm version](https://badge.fury.io/js/@fourlights%2Fstrapi-plugin-deep-populate.svg)](https://badge.fury.io/js/@fourlights%2Fstrapi-plugin-deep-populate)
4
+
3
5
  This Strapi v5 plugin provides a simple way of retrieving all nested objects in a single request.
4
6
  It does this by traversing the schema and comparing that to the actual retrieved document(s).
5
7
  Only relations that are actually set will be populated.
@@ -8,17 +10,25 @@ Only relations that are actually set will be populated.
8
10
 
9
11
  ```ts
10
12
  // Option 1: get the populate object and use where you see fit
11
- const populate = await strapi.plugin("deep-populate").service("populate").getPopulate({ documentId: 'xyz', contentType: 'api::page.page' })
13
+ const populate = await strapi.plugin("deep-populate").service("populate").get({ documentId: 'xyz', contentType: 'api::page.page' })
12
14
  const document = strapi.documents('api::page.page').findOne({ documentId: 'xyz', populate })
13
15
  ```
14
16
  ```ts
15
- // Option 2: use the wrapped `findOne` method around documentService
17
+ // Option 2: use the `findOne` method that wraps around documentService.findOne
16
18
  const { findOne } = strapi.plugin("deep-populate").service("populate").documents("api::page.page")
17
19
  const document = await findOne({ documentId: 'xyz' })
20
+ ```
18
21
 
19
- // You can also override the populate this way:
22
+ ```ts
23
+ // Using the wrapped FindOne provides some handy features:
24
+
25
+ // Allow you to override the populate this way:
20
26
  const documentWithCreatedBy = findOne({ documentId: 'xyz', populate: ['createdBy']})
21
27
  const documentWithoutSection = findOne({ documentId: 'xyz', populate: { section: false }})
28
+
29
+ // And if you supply a `*` as populate, it will return a fully populated document (i.e. non-sparse)
30
+ const sparseDocument = findOne({ documentId: 'xyz' }) // sparse, so only attributes are returned that have a value
31
+ const fullDocument = findOne({ documentId: 'xyz', populate: '*' }) // fully populated, so all attributes are returned
22
32
  ```
23
33
 
24
34
  ### populateCreatorFields
@@ -24584,7 +24584,7 @@ const isPopulateString = (value) => {
24584
24584
  };
24585
24585
  const isStringArray$1 = (value) => fp.isArray(value) && value.every(fp.isString);
24586
24586
  const isObj = (value) => fp.isObject(value);
24587
- const populate = traverseFactory().intercept(isPopulateString, async (visitor2, options, populate2, { recurse }) => {
24587
+ const populate$1 = traverseFactory().intercept(isPopulateString, async (visitor2, options, populate2, { recurse }) => {
24588
24588
  const populateObject = pathsToObjectPopulate([populate2]);
24589
24589
  const traversedPopulate = await recurse(visitor2, options, populateObject);
24590
24590
  const [result] = objectPopulateToPaths(traversedPopulate);
@@ -24752,7 +24752,7 @@ const populate = traverseFactory().intercept(isPopulateString, async (visitor2,
24752
24752
  }
24753
24753
  }
24754
24754
  );
24755
- const traverseQueryPopulate = fp.curry(populate.traverse);
24755
+ const traverseQueryPopulate = fp.curry(populate$1.traverse);
24756
24756
  const objectPopulateToPaths = (input) => {
24757
24757
  const paths = [];
24758
24758
  function traverse(currentObj, parentPath) {
@@ -25073,31 +25073,42 @@ async function _populateComponent({
25073
25073
  mainUid,
25074
25074
  mainDocumentId,
25075
25075
  schema: schema2,
25076
- populate: populate2,
25077
- lookup
25076
+ populate: populate2 = {},
25077
+ lookup,
25078
+ inDynamicZone = false,
25079
+ omitEmpty
25078
25080
  }) {
25079
- const nestedPopulate = await _populate({ mainUid, mainDocumentId, schema: schema2, populate: populate2, lookup });
25080
- return { populate: nestedPopulate ? nestedPopulate : "*" };
25081
+ const attrName = lookup.pop();
25082
+ const componentLookup = lookup.length === 0 ? [attrName] : [...lookup, inDynamicZone ? "on" : "populate", attrName];
25083
+ const componentPopulate = json$1.klona(populate2);
25084
+ merge$1.dset(componentPopulate, componentLookup, { populate: "*" });
25085
+ const nestedPopulate = await _populate({
25086
+ mainUid,
25087
+ mainDocumentId,
25088
+ schema: schema2,
25089
+ populate: componentPopulate,
25090
+ lookup: componentLookup,
25091
+ omitEmpty
25092
+ });
25093
+ return isEmpty(nestedPopulate) ? true : { populate: nestedPopulate };
25081
25094
  }
25082
25095
  async function _populateDynamicZone({
25083
25096
  mainUid,
25084
25097
  mainDocumentId,
25085
25098
  components,
25086
25099
  populate: populate2,
25087
- lookup
25100
+ lookup,
25101
+ omitEmpty
25088
25102
  }) {
25089
- const dzLookup = [...lookup, "on"];
25090
- const dzPopulate = json$1.klona(populate2);
25091
- merge$1.dset(dzPopulate, dzLookup, {});
25092
25103
  const resolvedPopulate = await components.reduce(async (prev, cur) => {
25093
- const componentPopulate = json$1.klona(dzPopulate);
25094
- delve__default.default(componentPopulate, dzLookup)[cur] = { populate: "*" };
25095
25104
  const curPopulate = await _populateComponent({
25096
25105
  mainUid,
25097
25106
  mainDocumentId,
25098
25107
  schema: cur,
25099
- populate: componentPopulate,
25100
- lookup: [...dzLookup, cur]
25108
+ populate: populate2,
25109
+ lookup: [...lookup, cur],
25110
+ inDynamicZone: true,
25111
+ omitEmpty
25101
25112
  });
25102
25113
  const newPop = await prev;
25103
25114
  merge$1.dset(newPop, [cur], curPopulate);
@@ -25107,12 +25118,13 @@ async function _populateDynamicZone({
25107
25118
  return { on: resolvedPopulate };
25108
25119
  }
25109
25120
  function _populateMedia() {
25110
- return { populate: "*" };
25121
+ return true;
25111
25122
  }
25112
25123
  async function _populateRelation({
25113
25124
  contentType,
25114
25125
  relation,
25115
- resolvedRelations
25126
+ resolvedRelations,
25127
+ omitEmpty
25116
25128
  }) {
25117
25129
  const isSingleRelation = !Array.isArray(relation);
25118
25130
  const relations = isSingleRelation ? [relation] : relation;
@@ -25122,7 +25134,8 @@ async function _populateRelation({
25122
25134
  mainUid: contentType,
25123
25135
  mainDocumentId: relation2.documentId,
25124
25136
  schema: contentType,
25125
- resolvedRelations
25137
+ resolvedRelations,
25138
+ omitEmpty
25126
25139
  });
25127
25140
  resolvedRelations.set(relation2.documentId, relationPopulate);
25128
25141
  }
@@ -25131,15 +25144,34 @@ async function _populateRelation({
25131
25144
  const relationPopulate = resolvedRelations.get(documentId);
25132
25145
  Object.keys(relationPopulate).map((r) => merge$1.dset(newPopulate, r, relationPopulate[r]));
25133
25146
  }
25134
- return { populate: newPopulate };
25147
+ return isEmpty(newPopulate) ? true : { populate: newPopulate };
25135
25148
  }
25149
+ const _resolveValue = ({ document: document2, lookup, attrName }) => {
25150
+ if (lookup.find((l) => l === "on")) {
25151
+ const attrLookup = lookup.filter((l) => l !== "on");
25152
+ const parentAttr = attrLookup.pop();
25153
+ const parentValue2 = (delve__default.default(document2, attrLookup) ?? []).filter((b) => b.__component === parentAttr) ?? [];
25154
+ return (Array.isArray(parentValue2) ? parentValue2 : [parentValue2]).find((v) => hasValue(v[attrName]))?.[attrName];
25155
+ }
25156
+ if (lookup.find((l) => l === "populate")) {
25157
+ const attrLookup = lookup.filter((l) => l !== "populate");
25158
+ const parentValue2 = delve__default.default(document2, attrLookup) ?? [];
25159
+ return (Array.isArray(parentValue2) ? parentValue2 : [parentValue2]).find((v) => hasValue(v[attrName]))?.[attrName];
25160
+ }
25161
+ const parentValue = delve__default.default(document2, lookup);
25162
+ if (Array.isArray(parentValue)) {
25163
+ return parentValue.map((v) => v[attrName]);
25164
+ }
25165
+ return parentValue?.[attrName];
25166
+ };
25136
25167
  async function _populate({
25137
25168
  mainUid,
25138
25169
  mainDocumentId,
25139
25170
  schema: schema2,
25140
25171
  populate: populate2 = {},
25141
25172
  lookup = [],
25142
- resolvedRelations = /* @__PURE__ */ new Map()
25173
+ resolvedRelations = /* @__PURE__ */ new Map(),
25174
+ omitEmpty = true
25143
25175
  }) {
25144
25176
  const newPopulate = {};
25145
25177
  const model = strapi.getModel(schema2);
@@ -25160,10 +25192,9 @@ async function _populate({
25160
25192
  populate: currentPopulate ? currentPopulate : "*"
25161
25193
  });
25162
25194
  for (const [attrName, attr] of relations) {
25163
- const attrLookup = [...lookup, attrName];
25164
- const value = delve__default.default(document2, attrLookup);
25195
+ const value = _resolveValue({ document: document2, attrName, lookup });
25165
25196
  if (!hasValue(value)) {
25166
- newPopulate[attrName] = true;
25197
+ if (!omitEmpty) newPopulate[attrName] = true;
25167
25198
  continue;
25168
25199
  }
25169
25200
  if (contentTypes.isDynamicZoneAttribute(attr)) {
@@ -25174,8 +25205,8 @@ async function _populate({
25174
25205
  mainUid,
25175
25206
  mainDocumentId,
25176
25207
  components: relComponents,
25177
- populate: newPopulate,
25178
- lookup: [...lookup, attrName]
25208
+ lookup: [...lookup, attrName],
25209
+ omitEmpty
25179
25210
  });
25180
25211
  }
25181
25212
  if (contentTypes.isRelationalAttribute(attr)) {
@@ -25183,7 +25214,8 @@ async function _populate({
25183
25214
  newPopulate[attrName] = await _populateRelation({
25184
25215
  contentType: relContentType,
25185
25216
  relation: value,
25186
- resolvedRelations
25217
+ resolvedRelations,
25218
+ omitEmpty
25187
25219
  });
25188
25220
  }
25189
25221
  if (contentTypes.isComponentAttribute(attr) && !contentTypes.isDynamicZoneAttribute(attr)) {
@@ -25191,26 +25223,35 @@ async function _populate({
25191
25223
  mainUid,
25192
25224
  mainDocumentId,
25193
25225
  schema: attr.component,
25194
- populate: newPopulate,
25195
- lookup: [...lookup, attrName]
25226
+ lookup: [...lookup, attrName],
25227
+ omitEmpty
25196
25228
  });
25197
25229
  }
25198
25230
  if (contentTypes.isMediaAttribute(attr)) {
25199
25231
  newPopulate[attrName] = _populateMedia();
25200
25232
  }
25201
25233
  }
25202
- return isEmpty(newPopulate) ? "*" : newPopulate;
25234
+ return newPopulate;
25203
25235
  }
25204
- const deepPopulateService = ({ strapi: strapi2 }) => ({
25205
- async getPopulate({ contentType, documentId }) {
25206
- return await _populate({ mainUid: contentType, mainDocumentId: documentId, schema: contentType });
25236
+ const populate = ({ strapi: strapi2 }) => ({
25237
+ async get({
25238
+ contentType,
25239
+ documentId,
25240
+ omitEmpty = false
25241
+ }) {
25242
+ return await _populate({ mainUid: contentType, mainDocumentId: documentId, schema: contentType, omitEmpty });
25207
25243
  },
25208
25244
  documents(contentType) {
25209
25245
  strapi2.documents(contentType);
25210
25246
  const { findOne, ...wrapped } = strapi2.documents(contentType);
25211
25247
  const wrappedFindOne = async (params) => {
25212
25248
  const { documentId, populate: originalPopulate } = params;
25213
- const deepPopulate = await _populate({ mainUid: contentType, mainDocumentId: documentId, schema: contentType });
25249
+ const deepPopulate = await _populate({
25250
+ mainUid: contentType,
25251
+ mainDocumentId: documentId,
25252
+ schema: contentType,
25253
+ omitEmpty: originalPopulate !== "*"
25254
+ });
25214
25255
  if (originalPopulate && originalPopulate !== "*") {
25215
25256
  strapi2.log.warn(
25216
25257
  `passed "populate" will be merged with deepPopulate, which could result in unexpected behavior.`
@@ -25225,7 +25266,7 @@ const deepPopulateService = ({ strapi: strapi2 }) => ({
25225
25266
  }
25226
25267
  });
25227
25268
  const services = {
25228
- populate: deepPopulateService
25269
+ populate
25229
25270
  };
25230
25271
  const index = {
25231
25272
  services
@@ -24570,7 +24570,7 @@ const isPopulateString = (value) => {
24570
24570
  };
24571
24571
  const isStringArray$1 = (value) => fp.isArray(value) && value.every(fp.isString);
24572
24572
  const isObj = (value) => fp.isObject(value);
24573
- const populate = traverseFactory().intercept(isPopulateString, async (visitor2, options, populate2, { recurse }) => {
24573
+ const populate$1 = traverseFactory().intercept(isPopulateString, async (visitor2, options, populate2, { recurse }) => {
24574
24574
  const populateObject = pathsToObjectPopulate([populate2]);
24575
24575
  const traversedPopulate = await recurse(visitor2, options, populateObject);
24576
24576
  const [result] = objectPopulateToPaths(traversedPopulate);
@@ -24738,7 +24738,7 @@ const populate = traverseFactory().intercept(isPopulateString, async (visitor2,
24738
24738
  }
24739
24739
  }
24740
24740
  );
24741
- const traverseQueryPopulate = fp.curry(populate.traverse);
24741
+ const traverseQueryPopulate = fp.curry(populate$1.traverse);
24742
24742
  const objectPopulateToPaths = (input) => {
24743
24743
  const paths = [];
24744
24744
  function traverse(currentObj, parentPath) {
@@ -25059,31 +25059,42 @@ async function _populateComponent({
25059
25059
  mainUid,
25060
25060
  mainDocumentId,
25061
25061
  schema: schema2,
25062
- populate: populate2,
25063
- lookup
25062
+ populate: populate2 = {},
25063
+ lookup,
25064
+ inDynamicZone = false,
25065
+ omitEmpty
25064
25066
  }) {
25065
- const nestedPopulate = await _populate({ mainUid, mainDocumentId, schema: schema2, populate: populate2, lookup });
25066
- return { populate: nestedPopulate ? nestedPopulate : "*" };
25067
+ const attrName = lookup.pop();
25068
+ const componentLookup = lookup.length === 0 ? [attrName] : [...lookup, inDynamicZone ? "on" : "populate", attrName];
25069
+ const componentPopulate = klona(populate2);
25070
+ dset(componentPopulate, componentLookup, { populate: "*" });
25071
+ const nestedPopulate = await _populate({
25072
+ mainUid,
25073
+ mainDocumentId,
25074
+ schema: schema2,
25075
+ populate: componentPopulate,
25076
+ lookup: componentLookup,
25077
+ omitEmpty
25078
+ });
25079
+ return isEmpty(nestedPopulate) ? true : { populate: nestedPopulate };
25067
25080
  }
25068
25081
  async function _populateDynamicZone({
25069
25082
  mainUid,
25070
25083
  mainDocumentId,
25071
25084
  components,
25072
25085
  populate: populate2,
25073
- lookup
25086
+ lookup,
25087
+ omitEmpty
25074
25088
  }) {
25075
- const dzLookup = [...lookup, "on"];
25076
- const dzPopulate = klona(populate2);
25077
- dset(dzPopulate, dzLookup, {});
25078
25089
  const resolvedPopulate = await components.reduce(async (prev, cur) => {
25079
- const componentPopulate = klona(dzPopulate);
25080
- delve(componentPopulate, dzLookup)[cur] = { populate: "*" };
25081
25090
  const curPopulate = await _populateComponent({
25082
25091
  mainUid,
25083
25092
  mainDocumentId,
25084
25093
  schema: cur,
25085
- populate: componentPopulate,
25086
- lookup: [...dzLookup, cur]
25094
+ populate: populate2,
25095
+ lookup: [...lookup, cur],
25096
+ inDynamicZone: true,
25097
+ omitEmpty
25087
25098
  });
25088
25099
  const newPop = await prev;
25089
25100
  dset(newPop, [cur], curPopulate);
@@ -25093,12 +25104,13 @@ async function _populateDynamicZone({
25093
25104
  return { on: resolvedPopulate };
25094
25105
  }
25095
25106
  function _populateMedia() {
25096
- return { populate: "*" };
25107
+ return true;
25097
25108
  }
25098
25109
  async function _populateRelation({
25099
25110
  contentType,
25100
25111
  relation,
25101
- resolvedRelations
25112
+ resolvedRelations,
25113
+ omitEmpty
25102
25114
  }) {
25103
25115
  const isSingleRelation = !Array.isArray(relation);
25104
25116
  const relations = isSingleRelation ? [relation] : relation;
@@ -25108,7 +25120,8 @@ async function _populateRelation({
25108
25120
  mainUid: contentType,
25109
25121
  mainDocumentId: relation2.documentId,
25110
25122
  schema: contentType,
25111
- resolvedRelations
25123
+ resolvedRelations,
25124
+ omitEmpty
25112
25125
  });
25113
25126
  resolvedRelations.set(relation2.documentId, relationPopulate);
25114
25127
  }
@@ -25117,15 +25130,34 @@ async function _populateRelation({
25117
25130
  const relationPopulate = resolvedRelations.get(documentId);
25118
25131
  Object.keys(relationPopulate).map((r) => dset(newPopulate, r, relationPopulate[r]));
25119
25132
  }
25120
- return { populate: newPopulate };
25133
+ return isEmpty(newPopulate) ? true : { populate: newPopulate };
25121
25134
  }
25135
+ const _resolveValue = ({ document: document2, lookup, attrName }) => {
25136
+ if (lookup.find((l) => l === "on")) {
25137
+ const attrLookup = lookup.filter((l) => l !== "on");
25138
+ const parentAttr = attrLookup.pop();
25139
+ const parentValue2 = (delve(document2, attrLookup) ?? []).filter((b) => b.__component === parentAttr) ?? [];
25140
+ return (Array.isArray(parentValue2) ? parentValue2 : [parentValue2]).find((v) => hasValue(v[attrName]))?.[attrName];
25141
+ }
25142
+ if (lookup.find((l) => l === "populate")) {
25143
+ const attrLookup = lookup.filter((l) => l !== "populate");
25144
+ const parentValue2 = delve(document2, attrLookup) ?? [];
25145
+ return (Array.isArray(parentValue2) ? parentValue2 : [parentValue2]).find((v) => hasValue(v[attrName]))?.[attrName];
25146
+ }
25147
+ const parentValue = delve(document2, lookup);
25148
+ if (Array.isArray(parentValue)) {
25149
+ return parentValue.map((v) => v[attrName]);
25150
+ }
25151
+ return parentValue?.[attrName];
25152
+ };
25122
25153
  async function _populate({
25123
25154
  mainUid,
25124
25155
  mainDocumentId,
25125
25156
  schema: schema2,
25126
25157
  populate: populate2 = {},
25127
25158
  lookup = [],
25128
- resolvedRelations = /* @__PURE__ */ new Map()
25159
+ resolvedRelations = /* @__PURE__ */ new Map(),
25160
+ omitEmpty = true
25129
25161
  }) {
25130
25162
  const newPopulate = {};
25131
25163
  const model = strapi.getModel(schema2);
@@ -25146,10 +25178,9 @@ async function _populate({
25146
25178
  populate: currentPopulate ? currentPopulate : "*"
25147
25179
  });
25148
25180
  for (const [attrName, attr] of relations) {
25149
- const attrLookup = [...lookup, attrName];
25150
- const value = delve(document2, attrLookup);
25181
+ const value = _resolveValue({ document: document2, attrName, lookup });
25151
25182
  if (!hasValue(value)) {
25152
- newPopulate[attrName] = true;
25183
+ if (!omitEmpty) newPopulate[attrName] = true;
25153
25184
  continue;
25154
25185
  }
25155
25186
  if (contentTypes.isDynamicZoneAttribute(attr)) {
@@ -25160,8 +25191,8 @@ async function _populate({
25160
25191
  mainUid,
25161
25192
  mainDocumentId,
25162
25193
  components: relComponents,
25163
- populate: newPopulate,
25164
- lookup: [...lookup, attrName]
25194
+ lookup: [...lookup, attrName],
25195
+ omitEmpty
25165
25196
  });
25166
25197
  }
25167
25198
  if (contentTypes.isRelationalAttribute(attr)) {
@@ -25169,7 +25200,8 @@ async function _populate({
25169
25200
  newPopulate[attrName] = await _populateRelation({
25170
25201
  contentType: relContentType,
25171
25202
  relation: value,
25172
- resolvedRelations
25203
+ resolvedRelations,
25204
+ omitEmpty
25173
25205
  });
25174
25206
  }
25175
25207
  if (contentTypes.isComponentAttribute(attr) && !contentTypes.isDynamicZoneAttribute(attr)) {
@@ -25177,26 +25209,35 @@ async function _populate({
25177
25209
  mainUid,
25178
25210
  mainDocumentId,
25179
25211
  schema: attr.component,
25180
- populate: newPopulate,
25181
- lookup: [...lookup, attrName]
25212
+ lookup: [...lookup, attrName],
25213
+ omitEmpty
25182
25214
  });
25183
25215
  }
25184
25216
  if (contentTypes.isMediaAttribute(attr)) {
25185
25217
  newPopulate[attrName] = _populateMedia();
25186
25218
  }
25187
25219
  }
25188
- return isEmpty(newPopulate) ? "*" : newPopulate;
25220
+ return newPopulate;
25189
25221
  }
25190
- const deepPopulateService = ({ strapi: strapi2 }) => ({
25191
- async getPopulate({ contentType, documentId }) {
25192
- return await _populate({ mainUid: contentType, mainDocumentId: documentId, schema: contentType });
25222
+ const populate = ({ strapi: strapi2 }) => ({
25223
+ async get({
25224
+ contentType,
25225
+ documentId,
25226
+ omitEmpty = false
25227
+ }) {
25228
+ return await _populate({ mainUid: contentType, mainDocumentId: documentId, schema: contentType, omitEmpty });
25193
25229
  },
25194
25230
  documents(contentType) {
25195
25231
  strapi2.documents(contentType);
25196
25232
  const { findOne, ...wrapped } = strapi2.documents(contentType);
25197
25233
  const wrappedFindOne = async (params) => {
25198
25234
  const { documentId, populate: originalPopulate } = params;
25199
- const deepPopulate = await _populate({ mainUid: contentType, mainDocumentId: documentId, schema: contentType });
25235
+ const deepPopulate = await _populate({
25236
+ mainUid: contentType,
25237
+ mainDocumentId: documentId,
25238
+ schema: contentType,
25239
+ omitEmpty: originalPopulate !== "*"
25240
+ });
25200
25241
  if (originalPopulate && originalPopulate !== "*") {
25201
25242
  strapi2.log.warn(
25202
25243
  `passed "populate" will be merged with deepPopulate, which could result in unexpected behavior.`
@@ -25211,7 +25252,7 @@ const deepPopulateService = ({ strapi: strapi2 }) => ({
25211
25252
  }
25212
25253
  });
25213
25254
  const services = {
25214
- populate: deepPopulateService
25255
+ populate
25215
25256
  };
25216
25257
  const index = {
25217
25258
  services
@@ -3,9 +3,10 @@ declare const _default: {
3
3
  populate: ({ strapi }: {
4
4
  strapi: import("@strapi/types/dist/core").Strapi;
5
5
  }) => {
6
- getPopulate({ contentType, documentId }: {
6
+ get({ contentType, documentId, omitEmpty, }: {
7
7
  contentType: import("@strapi/types/dist/uid").ContentType;
8
8
  documentId: string;
9
+ omitEmpty?: boolean;
9
10
  }): Promise<{}>;
10
11
  documents(contentType: import("@strapi/types/dist/uid").ContentType): {
11
12
  findMany<const TParams extends import("@strapi/types/dist/modules/documents/params/document-engine").FindMany<import("@strapi/types/dist/uid").ContentType>>(params?: TParams): import("@strapi/types/dist/modules/documents/result/document-engine").FindMany<import("@strapi/types/dist/uid").ContentType, TParams>;
@@ -1,3 +1,3 @@
1
1
  import type { UID } from "@strapi/strapi";
2
2
  import type { PopulateProps } from "./types";
3
- export default function _populate<TContentType extends UID.ContentType, TSchema extends UID.Schema>({ mainUid, mainDocumentId, schema, populate, lookup, resolvedRelations, }: PopulateProps<TContentType, TSchema>): Promise<{}>;
3
+ export default function _populate<TContentType extends UID.ContentType, TSchema extends UID.Schema>({ mainUid, mainDocumentId, schema, populate, lookup, resolvedRelations, omitEmpty, }: PopulateProps<TContentType, TSchema>): Promise<{}>;
@@ -2,9 +2,10 @@ declare const _default: {
2
2
  populate: ({ strapi }: {
3
3
  strapi: import("@strapi/types/dist/core").Strapi;
4
4
  }) => {
5
- getPopulate({ contentType, documentId }: {
5
+ get({ contentType, documentId, omitEmpty, }: {
6
6
  contentType: import("@strapi/types/dist/uid").ContentType;
7
7
  documentId: string;
8
+ omitEmpty?: boolean;
8
9
  }): Promise<{}>;
9
10
  documents(contentType: import("@strapi/types/dist/uid").ContentType): {
10
11
  findMany<const TParams extends import("@strapi/types/dist/modules/documents/params/document-engine").FindMany<import("@strapi/types/dist/uid").ContentType>>(params?: TParams): import("@strapi/types/dist/modules/documents/result/document-engine").FindMany<import("@strapi/types/dist/uid").ContentType, TParams>;
@@ -1,10 +1,11 @@
1
1
  import type { Core, UID } from "@strapi/strapi";
2
- declare const deepPopulateService: ({ strapi }: {
2
+ declare const _default: ({ strapi }: {
3
3
  strapi: Core.Strapi;
4
4
  }) => {
5
- getPopulate({ contentType, documentId }: {
5
+ get({ contentType, documentId, omitEmpty, }: {
6
6
  contentType: UID.ContentType;
7
7
  documentId: string;
8
+ omitEmpty?: boolean;
8
9
  }): Promise<{}>;
9
10
  documents(contentType: UID.ContentType): {
10
11
  findMany<const TParams extends import("@strapi/types/dist/modules/documents/params/document-engine").FindMany<UID.ContentType>>(params?: TParams): import("@strapi/types/dist/modules/documents/result/document-engine").FindMany<UID.ContentType, TParams>;
@@ -17,4 +18,4 @@ declare const deepPopulateService: ({ strapi }: {
17
18
  clone<const TParams_7 extends import("@strapi/types/dist/modules/documents/params/document-engine").Clone<UID.ContentType>>(params: TParams_7): import("@strapi/types/dist/modules/documents/result/document-engine").Clone<UID.ContentType, TParams_7>;
18
19
  } & import("@strapi/types/dist/modules/documents").DraftAndPublishExtension<UID.ContentType> & import("@strapi/types/dist/modules/documents/component-extension").ComponentExtension<UID.ContentType>;
19
20
  };
20
- export default deepPopulateService;
21
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
- "version": "1.0.0-beta.0",
3
- "keywords": [],
2
+ "version": "1.0.1",
3
+ "keywords": [
4
+ "strapi",
5
+ "strapi-plugin",
6
+ "populate",
7
+ "strapi-v5"
8
+ ],
4
9
  "type": "commonjs",
5
10
  "exports": {
6
11
  "./package.json": "./package.json",
@@ -25,7 +30,7 @@
25
30
  "test:integration": "jest --verbose --forceExit --detectOpenHandles",
26
31
  "ci": "biome ci server",
27
32
  "release": "release-it",
28
- "playground:install": "$npm_execpath run playground:yalc-add && cd playground && $npm_execpath install",
33
+ "playground:install": "$npm_execpath run playground:yalc-add && cd playground && $npm_execpath install --loglevel error",
29
34
  "playground:yalc-add": "cd playground && yalc add @fourlights/strapi-plugin-deep-populate",
30
35
  "playground:yalc-add-link": "cd playground && yalc add --link @fourlights/strapi-plugin-deep-populate"
31
36
  },
@@ -36,7 +41,6 @@
36
41
  },
37
42
  "devDependencies": {
38
43
  "@biomejs/biome": "^1.9.4",
39
- "@release-it/conventional-changelog": "^10.0.0",
40
44
  "@strapi/sdk-plugin": "^5.3.0",
41
45
  "@strapi/strapi": "^5.8.0",
42
46
  "@strapi/typescript-utils": "^5.8.0",
@@ -53,8 +57,8 @@
53
57
  "yalc": "^1.0.0-pre.53"
54
58
  },
55
59
  "peerDependencies": {
56
- "@strapi/sdk-plugin": "^5.3.0",
57
- "@strapi/strapi": "^5.8.0"
60
+ "@strapi/sdk-plugin": "^5",
61
+ "@strapi/strapi": "^5"
58
62
  },
59
63
  "strapi": {
60
64
  "kind": "plugin",