@fourlights/strapi-plugin-deep-populate 1.15.0 → 1.16.0-beta.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/dist/server/index.js +155 -137
- package/dist/server/index.mjs +155 -138
- package/dist/server/src/services/deep-populate/utils.d.ts +4 -4
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const cloneDeep = require("lodash/cloneDeep");
|
|
|
24
24
|
const unset = require("lodash/unset");
|
|
25
25
|
const get = require("lodash/get");
|
|
26
26
|
const isEqual = require("lodash/isEqual");
|
|
27
|
+
const clone$2 = require("lodash/clone");
|
|
27
28
|
const merge$2 = require("lodash/merge");
|
|
28
29
|
const mergeWith = require("lodash/mergeWith");
|
|
29
30
|
const set$2 = require("lodash/set");
|
|
@@ -51,6 +52,7 @@ const cloneDeep__default = /* @__PURE__ */ _interopDefault(cloneDeep);
|
|
|
51
52
|
const unset__default = /* @__PURE__ */ _interopDefault(unset);
|
|
52
53
|
const get__default = /* @__PURE__ */ _interopDefault(get);
|
|
53
54
|
const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
|
|
55
|
+
const clone__default = /* @__PURE__ */ _interopDefault(clone$2);
|
|
54
56
|
const merge__default = /* @__PURE__ */ _interopDefault(merge$2);
|
|
55
57
|
const mergeWith__default = /* @__PURE__ */ _interopDefault(mergeWith);
|
|
56
58
|
const set__default = /* @__PURE__ */ _interopDefault(set$2);
|
|
@@ -160,73 +162,76 @@ function envFn(key, defaultValue) {
|
|
|
160
162
|
function getKey(key) {
|
|
161
163
|
return process.env[key] ?? "";
|
|
162
164
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
throw new Error(`Invalid json environment variable ${key}: ${error2.message}`);
|
|
191
|
-
}
|
|
192
|
-
throw error2;
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
array(key, defaultValue) {
|
|
196
|
-
if (!___default__default.default.has(process.env, key)) {
|
|
197
|
-
return defaultValue;
|
|
198
|
-
}
|
|
199
|
-
let value = getKey(key);
|
|
200
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
201
|
-
value = value.substring(1, value.length - 1);
|
|
202
|
-
}
|
|
203
|
-
return value.split(",").map((v) => {
|
|
204
|
-
return ___default__default.default.trim(___default__default.default.trim(v, " "), '"');
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
date(key, defaultValue) {
|
|
208
|
-
if (!___default__default.default.has(process.env, key)) {
|
|
209
|
-
return defaultValue;
|
|
210
|
-
}
|
|
211
|
-
return new Date(getKey(key));
|
|
212
|
-
},
|
|
213
|
-
/**
|
|
214
|
-
* Gets a value from env that matches oneOf provided values
|
|
215
|
-
* @param {string} key
|
|
216
|
-
* @param {string[]} expectedValues
|
|
217
|
-
* @param {string|undefined} defaultValue
|
|
218
|
-
* @returns {string|undefined}
|
|
219
|
-
*/
|
|
220
|
-
oneOf(key, expectedValues, defaultValue) {
|
|
221
|
-
if (!expectedValues) {
|
|
222
|
-
throw new Error(`env.oneOf requires expectedValues`);
|
|
223
|
-
}
|
|
224
|
-
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
225
|
-
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
165
|
+
function int$2(key, defaultValue) {
|
|
166
|
+
if (!___default__default.default.has(process.env, key)) {
|
|
167
|
+
return defaultValue;
|
|
168
|
+
}
|
|
169
|
+
return parseInt(getKey(key), 10);
|
|
170
|
+
}
|
|
171
|
+
function float$1(key, defaultValue) {
|
|
172
|
+
if (!___default__default.default.has(process.env, key)) {
|
|
173
|
+
return defaultValue;
|
|
174
|
+
}
|
|
175
|
+
return parseFloat(getKey(key));
|
|
176
|
+
}
|
|
177
|
+
function bool$1(key, defaultValue) {
|
|
178
|
+
if (!___default__default.default.has(process.env, key)) {
|
|
179
|
+
return defaultValue;
|
|
180
|
+
}
|
|
181
|
+
return getKey(key) === "true";
|
|
182
|
+
}
|
|
183
|
+
function json$1(key, defaultValue) {
|
|
184
|
+
if (!___default__default.default.has(process.env, key)) {
|
|
185
|
+
return defaultValue;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
return JSON.parse(getKey(key));
|
|
189
|
+
} catch (error2) {
|
|
190
|
+
if (error2 instanceof Error) {
|
|
191
|
+
throw new Error(`Invalid json environment variable ${key}: ${error2.message}`);
|
|
226
192
|
}
|
|
227
|
-
|
|
228
|
-
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
|
|
193
|
+
throw error2;
|
|
229
194
|
}
|
|
195
|
+
}
|
|
196
|
+
function array$2(key, defaultValue) {
|
|
197
|
+
if (!___default__default.default.has(process.env, key)) {
|
|
198
|
+
return defaultValue;
|
|
199
|
+
}
|
|
200
|
+
let value = getKey(key);
|
|
201
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
202
|
+
value = value.substring(1, value.length - 1);
|
|
203
|
+
}
|
|
204
|
+
return value.split(",").map((v) => {
|
|
205
|
+
return ___default__default.default.trim(___default__default.default.trim(v, " "), '"');
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function date$3(key, defaultValue) {
|
|
209
|
+
if (!___default__default.default.has(process.env, key)) {
|
|
210
|
+
return defaultValue;
|
|
211
|
+
}
|
|
212
|
+
return new Date(getKey(key));
|
|
213
|
+
}
|
|
214
|
+
function oneOf(key, expectedValues, defaultValue) {
|
|
215
|
+
if (!expectedValues) {
|
|
216
|
+
throw new Error(`env.oneOf requires expectedValues`);
|
|
217
|
+
}
|
|
218
|
+
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
219
|
+
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
220
|
+
}
|
|
221
|
+
const rawValue = env(key, defaultValue);
|
|
222
|
+
if (rawValue !== void 0 && expectedValues.includes(rawValue)) {
|
|
223
|
+
return rawValue;
|
|
224
|
+
}
|
|
225
|
+
return defaultValue;
|
|
226
|
+
}
|
|
227
|
+
const utils$2 = {
|
|
228
|
+
int: int$2,
|
|
229
|
+
float: float$1,
|
|
230
|
+
bool: bool$1,
|
|
231
|
+
json: json$1,
|
|
232
|
+
array: array$2,
|
|
233
|
+
date: date$3,
|
|
234
|
+
oneOf
|
|
230
235
|
};
|
|
231
236
|
const env = Object.assign(envFn, utils$2);
|
|
232
237
|
const ID_ATTRIBUTE$1 = "id";
|
|
@@ -265,10 +270,10 @@ const HAS_RELATION_REORDERING = [
|
|
|
265
270
|
"oneToMany"
|
|
266
271
|
];
|
|
267
272
|
const hasRelationReordering = (attribute) => isRelationalAttribute(attribute) && HAS_RELATION_REORDERING.includes(attribute.relation);
|
|
268
|
-
const isComponentAttribute = (attribute) => [
|
|
273
|
+
const isComponentAttribute = (attribute) => !!attribute && [
|
|
269
274
|
"component",
|
|
270
275
|
"dynamiczone"
|
|
271
|
-
].includes(attribute
|
|
276
|
+
].includes(attribute.type);
|
|
272
277
|
const isDynamicZoneAttribute = (attribute) => !!attribute && attribute.type === "dynamiczone";
|
|
273
278
|
const isMorphToRelationalAttribute = (attribute) => {
|
|
274
279
|
return !!attribute && isRelationalAttribute(attribute) && attribute.relation?.startsWith?.("morphTo");
|
|
@@ -285,12 +290,22 @@ const getRelationalAttributes = (schema2) => {
|
|
|
285
290
|
return acc;
|
|
286
291
|
}, []);
|
|
287
292
|
};
|
|
288
|
-
const
|
|
293
|
+
const parallelWithOrderedErrors = async (promises) => {
|
|
294
|
+
const results = await Promise.allSettled(promises);
|
|
295
|
+
for (let i = 0; i < results.length; i += 1) {
|
|
296
|
+
const result = results[i];
|
|
297
|
+
if (result.status === "rejected") {
|
|
298
|
+
throw result.reason;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return results.map((r) => r.value);
|
|
302
|
+
};
|
|
303
|
+
const traverseEntity$1 = async (visitor2, options, entity) => {
|
|
289
304
|
const { path = {
|
|
290
305
|
raw: null,
|
|
291
306
|
attribute: null,
|
|
292
307
|
rawWithIndices: null
|
|
293
|
-
}, schema: schema2, getModel } = options;
|
|
308
|
+
}, schema: schema2, getModel, allowedExtraRootKeys } = options;
|
|
294
309
|
let parent = options.parent;
|
|
295
310
|
const traverseMorphRelationTarget = async (visitor3, path2, entry) => {
|
|
296
311
|
const targetSchema = getModel(entry.__type);
|
|
@@ -298,18 +313,20 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
298
313
|
schema: targetSchema,
|
|
299
314
|
path: path2,
|
|
300
315
|
getModel,
|
|
301
|
-
parent
|
|
316
|
+
parent,
|
|
317
|
+
allowedExtraRootKeys
|
|
302
318
|
};
|
|
303
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
319
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
304
320
|
};
|
|
305
321
|
const traverseRelationTarget = (schema3) => async (visitor3, path2, entry) => {
|
|
306
322
|
const traverseOptions = {
|
|
307
323
|
schema: schema3,
|
|
308
324
|
path: path2,
|
|
309
325
|
getModel,
|
|
310
|
-
parent
|
|
326
|
+
parent,
|
|
327
|
+
allowedExtraRootKeys
|
|
311
328
|
};
|
|
312
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
329
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
313
330
|
};
|
|
314
331
|
const traverseMediaTarget = async (visitor3, path2, entry) => {
|
|
315
332
|
const targetSchemaUID = "plugin::upload.file";
|
|
@@ -318,18 +335,20 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
318
335
|
schema: targetSchema,
|
|
319
336
|
path: path2,
|
|
320
337
|
getModel,
|
|
321
|
-
parent
|
|
338
|
+
parent,
|
|
339
|
+
allowedExtraRootKeys
|
|
322
340
|
};
|
|
323
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
341
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
324
342
|
};
|
|
325
343
|
const traverseComponent = async (visitor3, path2, schema3, entry) => {
|
|
326
344
|
const traverseOptions = {
|
|
327
345
|
schema: schema3,
|
|
328
346
|
path: path2,
|
|
329
347
|
getModel,
|
|
330
|
-
parent
|
|
348
|
+
parent,
|
|
349
|
+
allowedExtraRootKeys
|
|
331
350
|
};
|
|
332
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
351
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
333
352
|
};
|
|
334
353
|
const visitDynamicZoneEntry = async (visitor3, path2, entry) => {
|
|
335
354
|
const targetSchema = getModel(entry.__component);
|
|
@@ -337,9 +356,10 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
337
356
|
schema: targetSchema,
|
|
338
357
|
path: path2,
|
|
339
358
|
getModel,
|
|
340
|
-
parent
|
|
359
|
+
parent,
|
|
360
|
+
allowedExtraRootKeys
|
|
341
361
|
};
|
|
342
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
362
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
343
363
|
};
|
|
344
364
|
if (!fp.isObject(entity) || fp.isNil(schema2)) {
|
|
345
365
|
return entity;
|
|
@@ -368,7 +388,8 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
368
388
|
attribute,
|
|
369
389
|
path: newPath,
|
|
370
390
|
getModel,
|
|
371
|
-
parent
|
|
391
|
+
parent,
|
|
392
|
+
allowedExtraRootKeys
|
|
372
393
|
};
|
|
373
394
|
await visitor2(visitorOptions, visitorUtils);
|
|
374
395
|
const value = copy[key];
|
|
@@ -385,15 +406,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
385
406
|
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
|
386
407
|
const method = isMorphRelation ? traverseMorphRelationTarget : traverseRelationTarget(getModel(attribute.target));
|
|
387
408
|
if (fp.isArray(value)) {
|
|
388
|
-
|
|
389
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
409
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
390
410
|
const arrayPath = {
|
|
391
411
|
...newPath,
|
|
392
412
|
rawWithIndices: fp.isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
393
413
|
};
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
copy[key] = res;
|
|
414
|
+
return method(visitor2, arrayPath, item);
|
|
415
|
+
}));
|
|
397
416
|
} else {
|
|
398
417
|
copy[key] = await method(visitor2, newPath, value);
|
|
399
418
|
}
|
|
@@ -407,15 +426,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
407
426
|
path: newPath
|
|
408
427
|
};
|
|
409
428
|
if (fp.isArray(value)) {
|
|
410
|
-
|
|
411
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
429
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
412
430
|
const arrayPath = {
|
|
413
431
|
...newPath,
|
|
414
432
|
rawWithIndices: fp.isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
415
433
|
};
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
copy[key] = res;
|
|
434
|
+
return traverseMediaTarget(visitor2, arrayPath, item);
|
|
435
|
+
}));
|
|
419
436
|
} else {
|
|
420
437
|
copy[key] = await traverseMediaTarget(visitor2, newPath, value);
|
|
421
438
|
}
|
|
@@ -430,15 +447,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
430
447
|
};
|
|
431
448
|
const targetSchema = getModel(attribute.component);
|
|
432
449
|
if (fp.isArray(value)) {
|
|
433
|
-
|
|
434
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
450
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
435
451
|
const arrayPath = {
|
|
436
452
|
...newPath,
|
|
437
453
|
rawWithIndices: fp.isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
438
454
|
};
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
copy[key] = res;
|
|
455
|
+
return traverseComponent(visitor2, arrayPath, targetSchema, item);
|
|
456
|
+
}));
|
|
442
457
|
} else {
|
|
443
458
|
copy[key] = await traverseComponent(visitor2, newPath, targetSchema, value);
|
|
444
459
|
}
|
|
@@ -451,15 +466,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
451
466
|
attribute,
|
|
452
467
|
path: newPath
|
|
453
468
|
};
|
|
454
|
-
|
|
455
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
469
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
456
470
|
const arrayPath = {
|
|
457
471
|
...newPath,
|
|
458
472
|
rawWithIndices: fp.isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
459
473
|
};
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
copy[key] = res;
|
|
474
|
+
return visitDynamicZoneEntry(visitor2, arrayPath, item);
|
|
475
|
+
}));
|
|
463
476
|
continue;
|
|
464
477
|
}
|
|
465
478
|
}
|
|
@@ -473,7 +486,7 @@ const createVisitorUtils = ({ data }) => ({
|
|
|
473
486
|
data[key] = value;
|
|
474
487
|
}
|
|
475
488
|
});
|
|
476
|
-
fp.curry(traverseEntity);
|
|
489
|
+
fp.curry(traverseEntity$1);
|
|
477
490
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
478
491
|
function getDefaultExportFromCjs(x) {
|
|
479
492
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -484,7 +497,7 @@ var hasRequiredDist;
|
|
|
484
497
|
function requireDist() {
|
|
485
498
|
if (hasRequiredDist) return dist$1.exports;
|
|
486
499
|
hasRequiredDist = 1;
|
|
487
|
-
(function(module2,
|
|
500
|
+
(function(module2, exports$1) {
|
|
488
501
|
!(function(t, n) {
|
|
489
502
|
module2.exports = n(require$$0__default.default, require$$1__default.default);
|
|
490
503
|
})(dist, function(t, n) {
|
|
@@ -3496,7 +3509,7 @@ function requireHttpErrors() {
|
|
|
3496
3509
|
Object.defineProperty(func, "name", desc);
|
|
3497
3510
|
}
|
|
3498
3511
|
}
|
|
3499
|
-
function populateConstructorExports(
|
|
3512
|
+
function populateConstructorExports(exports$1, codes, HttpError) {
|
|
3500
3513
|
codes.forEach(function forEachCode(code) {
|
|
3501
3514
|
var CodeError;
|
|
3502
3515
|
var name2 = toIdentifier(statuses2.message[code]);
|
|
@@ -3509,8 +3522,8 @@ function requireHttpErrors() {
|
|
|
3509
3522
|
break;
|
|
3510
3523
|
}
|
|
3511
3524
|
if (CodeError) {
|
|
3512
|
-
|
|
3513
|
-
|
|
3525
|
+
exports$1[code] = CodeError;
|
|
3526
|
+
exports$1[name2] = CodeError;
|
|
3514
3527
|
}
|
|
3515
3528
|
});
|
|
3516
3529
|
}
|
|
@@ -6885,8 +6898,8 @@ var hasRequiredUtils$1;
|
|
|
6885
6898
|
function requireUtils$1() {
|
|
6886
6899
|
if (hasRequiredUtils$1) return utils$1;
|
|
6887
6900
|
hasRequiredUtils$1 = 1;
|
|
6888
|
-
(function(
|
|
6889
|
-
|
|
6901
|
+
(function(exports$1) {
|
|
6902
|
+
exports$1.isInteger = (num) => {
|
|
6890
6903
|
if (typeof num === "number") {
|
|
6891
6904
|
return Number.isInteger(num);
|
|
6892
6905
|
}
|
|
@@ -6895,13 +6908,13 @@ function requireUtils$1() {
|
|
|
6895
6908
|
}
|
|
6896
6909
|
return false;
|
|
6897
6910
|
};
|
|
6898
|
-
|
|
6899
|
-
|
|
6911
|
+
exports$1.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
|
|
6912
|
+
exports$1.exceedsLimit = (min, max, step = 1, limit) => {
|
|
6900
6913
|
if (limit === false) return false;
|
|
6901
|
-
if (!
|
|
6914
|
+
if (!exports$1.isInteger(min) || !exports$1.isInteger(max)) return false;
|
|
6902
6915
|
return (Number(max) - Number(min)) / Number(step) >= limit;
|
|
6903
6916
|
};
|
|
6904
|
-
|
|
6917
|
+
exports$1.escapeNode = (block, n = 0, type2) => {
|
|
6905
6918
|
const node = block.nodes[n];
|
|
6906
6919
|
if (!node) return;
|
|
6907
6920
|
if (type2 && node.type === type2 || node.type === "open" || node.type === "close") {
|
|
@@ -6911,7 +6924,7 @@ function requireUtils$1() {
|
|
|
6911
6924
|
}
|
|
6912
6925
|
}
|
|
6913
6926
|
};
|
|
6914
|
-
|
|
6927
|
+
exports$1.encloseBrace = (node) => {
|
|
6915
6928
|
if (node.type !== "brace") return false;
|
|
6916
6929
|
if (node.commas >> 0 + node.ranges >> 0 === 0) {
|
|
6917
6930
|
node.invalid = true;
|
|
@@ -6919,7 +6932,7 @@ function requireUtils$1() {
|
|
|
6919
6932
|
}
|
|
6920
6933
|
return false;
|
|
6921
6934
|
};
|
|
6922
|
-
|
|
6935
|
+
exports$1.isInvalidBrace = (block) => {
|
|
6923
6936
|
if (block.type !== "brace") return false;
|
|
6924
6937
|
if (block.invalid === true || block.dollar) return true;
|
|
6925
6938
|
if (block.commas >> 0 + block.ranges >> 0 === 0) {
|
|
@@ -6932,18 +6945,18 @@ function requireUtils$1() {
|
|
|
6932
6945
|
}
|
|
6933
6946
|
return false;
|
|
6934
6947
|
};
|
|
6935
|
-
|
|
6948
|
+
exports$1.isOpenOrClose = (node) => {
|
|
6936
6949
|
if (node.type === "open" || node.type === "close") {
|
|
6937
6950
|
return true;
|
|
6938
6951
|
}
|
|
6939
6952
|
return node.open === true || node.close === true;
|
|
6940
6953
|
};
|
|
6941
|
-
|
|
6954
|
+
exports$1.reduce = (nodes) => nodes.reduce((acc, node) => {
|
|
6942
6955
|
if (node.type === "text") acc.push(node.value);
|
|
6943
6956
|
if (node.type === "range") node.type = "text";
|
|
6944
6957
|
return acc;
|
|
6945
6958
|
}, []);
|
|
6946
|
-
|
|
6959
|
+
exports$1.flatten = (...args) => {
|
|
6947
6960
|
const result = [];
|
|
6948
6961
|
const flat = (arr) => {
|
|
6949
6962
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -8166,7 +8179,7 @@ var hasRequiredUtils;
|
|
|
8166
8179
|
function requireUtils() {
|
|
8167
8180
|
if (hasRequiredUtils) return utils;
|
|
8168
8181
|
hasRequiredUtils = 1;
|
|
8169
|
-
(function(
|
|
8182
|
+
(function(exports$1) {
|
|
8170
8183
|
const path = require$$0__default$3.default;
|
|
8171
8184
|
const win32 = process.platform === "win32";
|
|
8172
8185
|
const {
|
|
@@ -8175,36 +8188,36 @@ function requireUtils() {
|
|
|
8175
8188
|
REGEX_SPECIAL_CHARS,
|
|
8176
8189
|
REGEX_SPECIAL_CHARS_GLOBAL
|
|
8177
8190
|
} = requireConstants();
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8191
|
+
exports$1.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
8192
|
+
exports$1.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
|
|
8193
|
+
exports$1.isRegexChar = (str2) => str2.length === 1 && exports$1.hasRegexChars(str2);
|
|
8194
|
+
exports$1.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
8195
|
+
exports$1.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
|
|
8196
|
+
exports$1.removeBackslashes = (str2) => {
|
|
8184
8197
|
return str2.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
8185
8198
|
return match === "\\" ? "" : match;
|
|
8186
8199
|
});
|
|
8187
8200
|
};
|
|
8188
|
-
|
|
8201
|
+
exports$1.supportsLookbehinds = () => {
|
|
8189
8202
|
const segs = process.version.slice(1).split(".").map(Number);
|
|
8190
8203
|
if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
|
|
8191
8204
|
return true;
|
|
8192
8205
|
}
|
|
8193
8206
|
return false;
|
|
8194
8207
|
};
|
|
8195
|
-
|
|
8208
|
+
exports$1.isWindows = (options) => {
|
|
8196
8209
|
if (options && typeof options.windows === "boolean") {
|
|
8197
8210
|
return options.windows;
|
|
8198
8211
|
}
|
|
8199
8212
|
return win32 === true || path.sep === "\\";
|
|
8200
8213
|
};
|
|
8201
|
-
|
|
8214
|
+
exports$1.escapeLast = (input, char, lastIdx) => {
|
|
8202
8215
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
8203
8216
|
if (idx === -1) return input;
|
|
8204
|
-
if (input[idx - 1] === "\\") return
|
|
8217
|
+
if (input[idx - 1] === "\\") return exports$1.escapeLast(input, char, idx - 1);
|
|
8205
8218
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
8206
8219
|
};
|
|
8207
|
-
|
|
8220
|
+
exports$1.removePrefix = (input, state = {}) => {
|
|
8208
8221
|
let output = input;
|
|
8209
8222
|
if (output.startsWith("./")) {
|
|
8210
8223
|
output = output.slice(2);
|
|
@@ -8212,7 +8225,7 @@ function requireUtils() {
|
|
|
8212
8225
|
}
|
|
8213
8226
|
return output;
|
|
8214
8227
|
};
|
|
8215
|
-
|
|
8228
|
+
exports$1.wrapOutput = (input, state = {}, options = {}) => {
|
|
8216
8229
|
const prepend = options.contains ? "" : "^";
|
|
8217
8230
|
const append = options.contains ? "" : "$";
|
|
8218
8231
|
let output = `${prepend}(?:${input})${append}`;
|
|
@@ -13856,7 +13869,14 @@ function requirePreferredPm() {
|
|
|
13856
13869
|
};
|
|
13857
13870
|
}
|
|
13858
13871
|
try {
|
|
13859
|
-
|
|
13872
|
+
const workspaceRoot = findYarnWorkspaceRoot(pkgPath);
|
|
13873
|
+
if (typeof workspaceRoot === "string") {
|
|
13874
|
+
if (await pathExists2(path.join(workspaceRoot, "package-lock.json"))) {
|
|
13875
|
+
return {
|
|
13876
|
+
name: "npm",
|
|
13877
|
+
version: ">=7"
|
|
13878
|
+
};
|
|
13879
|
+
}
|
|
13860
13880
|
return {
|
|
13861
13881
|
name: "yarn",
|
|
13862
13882
|
version: "*"
|
|
@@ -18430,7 +18450,7 @@ function asBoolean(value) {
|
|
|
18430
18450
|
const normalized = value.toLowerCase().trim();
|
|
18431
18451
|
return normalized !== "false" && normalized !== "0";
|
|
18432
18452
|
}
|
|
18433
|
-
const version = "1.
|
|
18453
|
+
const version = "1.16.0-beta.0";
|
|
18434
18454
|
const name = "@fourlights/strapi-plugin-deep-populate";
|
|
18435
18455
|
const f = (msg, context = void 0) => {
|
|
18436
18456
|
const prefix = `[${name}] `;
|
|
@@ -18624,10 +18644,8 @@ const getConfig = (params) => {
|
|
|
18624
18644
|
localizations: localizationsFallback,
|
|
18625
18645
|
contentTypes: contentTypes2
|
|
18626
18646
|
} = strapi.config.get("plugin::deep-populate");
|
|
18627
|
-
const
|
|
18628
|
-
|
|
18629
|
-
___default.mergeWith(contentTypeConfig, sanitizeObject(___default.get(contentTypes2, params.contentType)));
|
|
18630
|
-
}
|
|
18647
|
+
const baseConfig = ___default.has(contentTypes2, "*") ? ___default.get(contentTypes2, "*") : {};
|
|
18648
|
+
const contentTypeConfig = ___default.has(contentTypes2, params.contentType) ? ___default.mergeWith({}, baseConfig, sanitizeObject(___default.get(contentTypes2, params.contentType))) : baseConfig;
|
|
18631
18649
|
const { allow, deny } = contentTypeConfig;
|
|
18632
18650
|
const omitEmpty = params.omitEmpty ?? contentTypeConfig.omitEmpty ?? omitEmptyFallback;
|
|
18633
18651
|
const localizations = params.localizations ?? contentTypeConfig.localizations ?? localizationsFallback;
|
|
@@ -18975,8 +18993,8 @@ async function populate$1(params) {
|
|
|
18975
18993
|
resolvedSchemas,
|
|
18976
18994
|
omitEmpty: config2.omitEmpty,
|
|
18977
18995
|
localizations: config2.localizations,
|
|
18978
|
-
__deny: config2.deny,
|
|
18979
|
-
__allow: config2.allow,
|
|
18996
|
+
__deny: clone__default.default(config2.deny),
|
|
18997
|
+
__allow: clone__default.default(config2.allow),
|
|
18980
18998
|
...params
|
|
18981
18999
|
});
|
|
18982
19000
|
populated.__deepPopulated = true;
|
package/dist/server/index.mjs
CHANGED
|
@@ -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,
|
|
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, trim as trim$1, isString, pipe as pipe$2, split, map as map$3, flatten, first, identity, constant, 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";
|
|
@@ -23,6 +23,7 @@ import cloneDeep$1 from "lodash/cloneDeep";
|
|
|
23
23
|
import unset from "lodash/unset";
|
|
24
24
|
import get$2 from "lodash/get";
|
|
25
25
|
import isEqual from "lodash/isEqual";
|
|
26
|
+
import clone$3 from "lodash/clone";
|
|
26
27
|
import merge$2 from "lodash/merge";
|
|
27
28
|
import mergeWith$1 from "lodash/mergeWith";
|
|
28
29
|
import set$2 from "lodash/set";
|
|
@@ -132,73 +133,76 @@ function envFn(key, defaultValue) {
|
|
|
132
133
|
function getKey(key) {
|
|
133
134
|
return process.env[key] ?? "";
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
throw new Error(`Invalid json environment variable ${key}: ${error2.message}`);
|
|
163
|
-
}
|
|
164
|
-
throw error2;
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
array(key, defaultValue) {
|
|
168
|
-
if (!___default.has(process.env, key)) {
|
|
169
|
-
return defaultValue;
|
|
170
|
-
}
|
|
171
|
-
let value = getKey(key);
|
|
172
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
173
|
-
value = value.substring(1, value.length - 1);
|
|
174
|
-
}
|
|
175
|
-
return value.split(",").map((v) => {
|
|
176
|
-
return ___default.trim(___default.trim(v, " "), '"');
|
|
177
|
-
});
|
|
178
|
-
},
|
|
179
|
-
date(key, defaultValue) {
|
|
180
|
-
if (!___default.has(process.env, key)) {
|
|
181
|
-
return defaultValue;
|
|
182
|
-
}
|
|
183
|
-
return new Date(getKey(key));
|
|
184
|
-
},
|
|
185
|
-
/**
|
|
186
|
-
* Gets a value from env that matches oneOf provided values
|
|
187
|
-
* @param {string} key
|
|
188
|
-
* @param {string[]} expectedValues
|
|
189
|
-
* @param {string|undefined} defaultValue
|
|
190
|
-
* @returns {string|undefined}
|
|
191
|
-
*/
|
|
192
|
-
oneOf(key, expectedValues, defaultValue) {
|
|
193
|
-
if (!expectedValues) {
|
|
194
|
-
throw new Error(`env.oneOf requires expectedValues`);
|
|
195
|
-
}
|
|
196
|
-
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
197
|
-
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
136
|
+
function int$2(key, defaultValue) {
|
|
137
|
+
if (!___default.has(process.env, key)) {
|
|
138
|
+
return defaultValue;
|
|
139
|
+
}
|
|
140
|
+
return parseInt(getKey(key), 10);
|
|
141
|
+
}
|
|
142
|
+
function float$1(key, defaultValue) {
|
|
143
|
+
if (!___default.has(process.env, key)) {
|
|
144
|
+
return defaultValue;
|
|
145
|
+
}
|
|
146
|
+
return parseFloat(getKey(key));
|
|
147
|
+
}
|
|
148
|
+
function bool$1(key, defaultValue) {
|
|
149
|
+
if (!___default.has(process.env, key)) {
|
|
150
|
+
return defaultValue;
|
|
151
|
+
}
|
|
152
|
+
return getKey(key) === "true";
|
|
153
|
+
}
|
|
154
|
+
function json$1(key, defaultValue) {
|
|
155
|
+
if (!___default.has(process.env, key)) {
|
|
156
|
+
return defaultValue;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
return JSON.parse(getKey(key));
|
|
160
|
+
} catch (error2) {
|
|
161
|
+
if (error2 instanceof Error) {
|
|
162
|
+
throw new Error(`Invalid json environment variable ${key}: ${error2.message}`);
|
|
198
163
|
}
|
|
199
|
-
|
|
200
|
-
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
|
|
164
|
+
throw error2;
|
|
201
165
|
}
|
|
166
|
+
}
|
|
167
|
+
function array$2(key, defaultValue) {
|
|
168
|
+
if (!___default.has(process.env, key)) {
|
|
169
|
+
return defaultValue;
|
|
170
|
+
}
|
|
171
|
+
let value = getKey(key);
|
|
172
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
173
|
+
value = value.substring(1, value.length - 1);
|
|
174
|
+
}
|
|
175
|
+
return value.split(",").map((v) => {
|
|
176
|
+
return ___default.trim(___default.trim(v, " "), '"');
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function date$3(key, defaultValue) {
|
|
180
|
+
if (!___default.has(process.env, key)) {
|
|
181
|
+
return defaultValue;
|
|
182
|
+
}
|
|
183
|
+
return new Date(getKey(key));
|
|
184
|
+
}
|
|
185
|
+
function oneOf(key, expectedValues, defaultValue) {
|
|
186
|
+
if (!expectedValues) {
|
|
187
|
+
throw new Error(`env.oneOf requires expectedValues`);
|
|
188
|
+
}
|
|
189
|
+
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
190
|
+
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
191
|
+
}
|
|
192
|
+
const rawValue = env(key, defaultValue);
|
|
193
|
+
if (rawValue !== void 0 && expectedValues.includes(rawValue)) {
|
|
194
|
+
return rawValue;
|
|
195
|
+
}
|
|
196
|
+
return defaultValue;
|
|
197
|
+
}
|
|
198
|
+
const utils$2 = {
|
|
199
|
+
int: int$2,
|
|
200
|
+
float: float$1,
|
|
201
|
+
bool: bool$1,
|
|
202
|
+
json: json$1,
|
|
203
|
+
array: array$2,
|
|
204
|
+
date: date$3,
|
|
205
|
+
oneOf
|
|
202
206
|
};
|
|
203
207
|
const env = Object.assign(envFn, utils$2);
|
|
204
208
|
const ID_ATTRIBUTE$1 = "id";
|
|
@@ -237,10 +241,10 @@ const HAS_RELATION_REORDERING = [
|
|
|
237
241
|
"oneToMany"
|
|
238
242
|
];
|
|
239
243
|
const hasRelationReordering = (attribute) => isRelationalAttribute(attribute) && HAS_RELATION_REORDERING.includes(attribute.relation);
|
|
240
|
-
const isComponentAttribute = (attribute) => [
|
|
244
|
+
const isComponentAttribute = (attribute) => !!attribute && [
|
|
241
245
|
"component",
|
|
242
246
|
"dynamiczone"
|
|
243
|
-
].includes(attribute
|
|
247
|
+
].includes(attribute.type);
|
|
244
248
|
const isDynamicZoneAttribute = (attribute) => !!attribute && attribute.type === "dynamiczone";
|
|
245
249
|
const isMorphToRelationalAttribute = (attribute) => {
|
|
246
250
|
return !!attribute && isRelationalAttribute(attribute) && attribute.relation?.startsWith?.("morphTo");
|
|
@@ -257,12 +261,22 @@ const getRelationalAttributes = (schema2) => {
|
|
|
257
261
|
return acc;
|
|
258
262
|
}, []);
|
|
259
263
|
};
|
|
260
|
-
const
|
|
264
|
+
const parallelWithOrderedErrors = async (promises) => {
|
|
265
|
+
const results = await Promise.allSettled(promises);
|
|
266
|
+
for (let i = 0; i < results.length; i += 1) {
|
|
267
|
+
const result = results[i];
|
|
268
|
+
if (result.status === "rejected") {
|
|
269
|
+
throw result.reason;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return results.map((r) => r.value);
|
|
273
|
+
};
|
|
274
|
+
const traverseEntity$1 = async (visitor2, options, entity) => {
|
|
261
275
|
const { path = {
|
|
262
276
|
raw: null,
|
|
263
277
|
attribute: null,
|
|
264
278
|
rawWithIndices: null
|
|
265
|
-
}, schema: schema2, getModel } = options;
|
|
279
|
+
}, schema: schema2, getModel, allowedExtraRootKeys } = options;
|
|
266
280
|
let parent = options.parent;
|
|
267
281
|
const traverseMorphRelationTarget = async (visitor3, path2, entry) => {
|
|
268
282
|
const targetSchema = getModel(entry.__type);
|
|
@@ -270,18 +284,20 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
270
284
|
schema: targetSchema,
|
|
271
285
|
path: path2,
|
|
272
286
|
getModel,
|
|
273
|
-
parent
|
|
287
|
+
parent,
|
|
288
|
+
allowedExtraRootKeys
|
|
274
289
|
};
|
|
275
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
290
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
276
291
|
};
|
|
277
292
|
const traverseRelationTarget = (schema3) => async (visitor3, path2, entry) => {
|
|
278
293
|
const traverseOptions = {
|
|
279
294
|
schema: schema3,
|
|
280
295
|
path: path2,
|
|
281
296
|
getModel,
|
|
282
|
-
parent
|
|
297
|
+
parent,
|
|
298
|
+
allowedExtraRootKeys
|
|
283
299
|
};
|
|
284
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
300
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
285
301
|
};
|
|
286
302
|
const traverseMediaTarget = async (visitor3, path2, entry) => {
|
|
287
303
|
const targetSchemaUID = "plugin::upload.file";
|
|
@@ -290,18 +306,20 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
290
306
|
schema: targetSchema,
|
|
291
307
|
path: path2,
|
|
292
308
|
getModel,
|
|
293
|
-
parent
|
|
309
|
+
parent,
|
|
310
|
+
allowedExtraRootKeys
|
|
294
311
|
};
|
|
295
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
312
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
296
313
|
};
|
|
297
314
|
const traverseComponent = async (visitor3, path2, schema3, entry) => {
|
|
298
315
|
const traverseOptions = {
|
|
299
316
|
schema: schema3,
|
|
300
317
|
path: path2,
|
|
301
318
|
getModel,
|
|
302
|
-
parent
|
|
319
|
+
parent,
|
|
320
|
+
allowedExtraRootKeys
|
|
303
321
|
};
|
|
304
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
322
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
305
323
|
};
|
|
306
324
|
const visitDynamicZoneEntry = async (visitor3, path2, entry) => {
|
|
307
325
|
const targetSchema = getModel(entry.__component);
|
|
@@ -309,9 +327,10 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
309
327
|
schema: targetSchema,
|
|
310
328
|
path: path2,
|
|
311
329
|
getModel,
|
|
312
|
-
parent
|
|
330
|
+
parent,
|
|
331
|
+
allowedExtraRootKeys
|
|
313
332
|
};
|
|
314
|
-
return traverseEntity(visitor3, traverseOptions, entry);
|
|
333
|
+
return traverseEntity$1(visitor3, traverseOptions, entry);
|
|
315
334
|
};
|
|
316
335
|
if (!isObject$3(entity) || isNil(schema2)) {
|
|
317
336
|
return entity;
|
|
@@ -340,7 +359,8 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
340
359
|
attribute,
|
|
341
360
|
path: newPath,
|
|
342
361
|
getModel,
|
|
343
|
-
parent
|
|
362
|
+
parent,
|
|
363
|
+
allowedExtraRootKeys
|
|
344
364
|
};
|
|
345
365
|
await visitor2(visitorOptions, visitorUtils);
|
|
346
366
|
const value = copy[key];
|
|
@@ -357,15 +377,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
357
377
|
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
|
358
378
|
const method = isMorphRelation ? traverseMorphRelationTarget : traverseRelationTarget(getModel(attribute.target));
|
|
359
379
|
if (isArray(value)) {
|
|
360
|
-
|
|
361
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
380
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
362
381
|
const arrayPath = {
|
|
363
382
|
...newPath,
|
|
364
383
|
rawWithIndices: isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
365
384
|
};
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
copy[key] = res;
|
|
385
|
+
return method(visitor2, arrayPath, item);
|
|
386
|
+
}));
|
|
369
387
|
} else {
|
|
370
388
|
copy[key] = await method(visitor2, newPath, value);
|
|
371
389
|
}
|
|
@@ -379,15 +397,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
379
397
|
path: newPath
|
|
380
398
|
};
|
|
381
399
|
if (isArray(value)) {
|
|
382
|
-
|
|
383
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
400
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
384
401
|
const arrayPath = {
|
|
385
402
|
...newPath,
|
|
386
403
|
rawWithIndices: isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
387
404
|
};
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
copy[key] = res;
|
|
405
|
+
return traverseMediaTarget(visitor2, arrayPath, item);
|
|
406
|
+
}));
|
|
391
407
|
} else {
|
|
392
408
|
copy[key] = await traverseMediaTarget(visitor2, newPath, value);
|
|
393
409
|
}
|
|
@@ -402,15 +418,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
402
418
|
};
|
|
403
419
|
const targetSchema = getModel(attribute.component);
|
|
404
420
|
if (isArray(value)) {
|
|
405
|
-
|
|
406
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
421
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
407
422
|
const arrayPath = {
|
|
408
423
|
...newPath,
|
|
409
424
|
rawWithIndices: isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
410
425
|
};
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
copy[key] = res;
|
|
426
|
+
return traverseComponent(visitor2, arrayPath, targetSchema, item);
|
|
427
|
+
}));
|
|
414
428
|
} else {
|
|
415
429
|
copy[key] = await traverseComponent(visitor2, newPath, targetSchema, value);
|
|
416
430
|
}
|
|
@@ -423,15 +437,13 @@ const traverseEntity = async (visitor2, options, entity) => {
|
|
|
423
437
|
attribute,
|
|
424
438
|
path: newPath
|
|
425
439
|
};
|
|
426
|
-
|
|
427
|
-
for (let i2 = 0; i2 < value.length; i2 += 1) {
|
|
440
|
+
copy[key] = await parallelWithOrderedErrors(value.map((item, i2) => {
|
|
428
441
|
const arrayPath = {
|
|
429
442
|
...newPath,
|
|
430
443
|
rawWithIndices: isNil(newPath.rawWithIndices) ? `${i2}` : `${newPath.rawWithIndices}.${i2}`
|
|
431
444
|
};
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
copy[key] = res;
|
|
445
|
+
return visitDynamicZoneEntry(visitor2, arrayPath, item);
|
|
446
|
+
}));
|
|
435
447
|
continue;
|
|
436
448
|
}
|
|
437
449
|
}
|
|
@@ -445,7 +457,7 @@ const createVisitorUtils = ({ data }) => ({
|
|
|
445
457
|
data[key] = value;
|
|
446
458
|
}
|
|
447
459
|
});
|
|
448
|
-
curry(traverseEntity);
|
|
460
|
+
curry(traverseEntity$1);
|
|
449
461
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
450
462
|
function getDefaultExportFromCjs(x) {
|
|
451
463
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -456,7 +468,7 @@ var hasRequiredDist;
|
|
|
456
468
|
function requireDist() {
|
|
457
469
|
if (hasRequiredDist) return dist$1.exports;
|
|
458
470
|
hasRequiredDist = 1;
|
|
459
|
-
(function(module, exports) {
|
|
471
|
+
(function(module, exports$1) {
|
|
460
472
|
!(function(t, n) {
|
|
461
473
|
module.exports = n(require$$0$1, require$$1);
|
|
462
474
|
})(dist, function(t, n) {
|
|
@@ -3468,7 +3480,7 @@ function requireHttpErrors() {
|
|
|
3468
3480
|
Object.defineProperty(func, "name", desc);
|
|
3469
3481
|
}
|
|
3470
3482
|
}
|
|
3471
|
-
function populateConstructorExports(exports, codes, HttpError) {
|
|
3483
|
+
function populateConstructorExports(exports$1, codes, HttpError) {
|
|
3472
3484
|
codes.forEach(function forEachCode(code) {
|
|
3473
3485
|
var CodeError;
|
|
3474
3486
|
var name2 = toIdentifier(statuses2.message[code]);
|
|
@@ -3481,8 +3493,8 @@ function requireHttpErrors() {
|
|
|
3481
3493
|
break;
|
|
3482
3494
|
}
|
|
3483
3495
|
if (CodeError) {
|
|
3484
|
-
exports[code] = CodeError;
|
|
3485
|
-
exports[name2] = CodeError;
|
|
3496
|
+
exports$1[code] = CodeError;
|
|
3497
|
+
exports$1[name2] = CodeError;
|
|
3486
3498
|
}
|
|
3487
3499
|
});
|
|
3488
3500
|
}
|
|
@@ -6857,8 +6869,8 @@ var hasRequiredUtils$1;
|
|
|
6857
6869
|
function requireUtils$1() {
|
|
6858
6870
|
if (hasRequiredUtils$1) return utils$1;
|
|
6859
6871
|
hasRequiredUtils$1 = 1;
|
|
6860
|
-
(function(exports) {
|
|
6861
|
-
exports.isInteger = (num) => {
|
|
6872
|
+
(function(exports$1) {
|
|
6873
|
+
exports$1.isInteger = (num) => {
|
|
6862
6874
|
if (typeof num === "number") {
|
|
6863
6875
|
return Number.isInteger(num);
|
|
6864
6876
|
}
|
|
@@ -6867,13 +6879,13 @@ function requireUtils$1() {
|
|
|
6867
6879
|
}
|
|
6868
6880
|
return false;
|
|
6869
6881
|
};
|
|
6870
|
-
exports.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
|
|
6871
|
-
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
|
6882
|
+
exports$1.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
|
|
6883
|
+
exports$1.exceedsLimit = (min, max, step = 1, limit) => {
|
|
6872
6884
|
if (limit === false) return false;
|
|
6873
|
-
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
6885
|
+
if (!exports$1.isInteger(min) || !exports$1.isInteger(max)) return false;
|
|
6874
6886
|
return (Number(max) - Number(min)) / Number(step) >= limit;
|
|
6875
6887
|
};
|
|
6876
|
-
exports.escapeNode = (block, n = 0, type2) => {
|
|
6888
|
+
exports$1.escapeNode = (block, n = 0, type2) => {
|
|
6877
6889
|
const node = block.nodes[n];
|
|
6878
6890
|
if (!node) return;
|
|
6879
6891
|
if (type2 && node.type === type2 || node.type === "open" || node.type === "close") {
|
|
@@ -6883,7 +6895,7 @@ function requireUtils$1() {
|
|
|
6883
6895
|
}
|
|
6884
6896
|
}
|
|
6885
6897
|
};
|
|
6886
|
-
exports.encloseBrace = (node) => {
|
|
6898
|
+
exports$1.encloseBrace = (node) => {
|
|
6887
6899
|
if (node.type !== "brace") return false;
|
|
6888
6900
|
if (node.commas >> 0 + node.ranges >> 0 === 0) {
|
|
6889
6901
|
node.invalid = true;
|
|
@@ -6891,7 +6903,7 @@ function requireUtils$1() {
|
|
|
6891
6903
|
}
|
|
6892
6904
|
return false;
|
|
6893
6905
|
};
|
|
6894
|
-
exports.isInvalidBrace = (block) => {
|
|
6906
|
+
exports$1.isInvalidBrace = (block) => {
|
|
6895
6907
|
if (block.type !== "brace") return false;
|
|
6896
6908
|
if (block.invalid === true || block.dollar) return true;
|
|
6897
6909
|
if (block.commas >> 0 + block.ranges >> 0 === 0) {
|
|
@@ -6904,18 +6916,18 @@ function requireUtils$1() {
|
|
|
6904
6916
|
}
|
|
6905
6917
|
return false;
|
|
6906
6918
|
};
|
|
6907
|
-
exports.isOpenOrClose = (node) => {
|
|
6919
|
+
exports$1.isOpenOrClose = (node) => {
|
|
6908
6920
|
if (node.type === "open" || node.type === "close") {
|
|
6909
6921
|
return true;
|
|
6910
6922
|
}
|
|
6911
6923
|
return node.open === true || node.close === true;
|
|
6912
6924
|
};
|
|
6913
|
-
exports.reduce = (nodes) => nodes.reduce((acc, node) => {
|
|
6925
|
+
exports$1.reduce = (nodes) => nodes.reduce((acc, node) => {
|
|
6914
6926
|
if (node.type === "text") acc.push(node.value);
|
|
6915
6927
|
if (node.type === "range") node.type = "text";
|
|
6916
6928
|
return acc;
|
|
6917
6929
|
}, []);
|
|
6918
|
-
exports.flatten = (...args) => {
|
|
6930
|
+
exports$1.flatten = (...args) => {
|
|
6919
6931
|
const result = [];
|
|
6920
6932
|
const flat = (arr) => {
|
|
6921
6933
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -8138,7 +8150,7 @@ var hasRequiredUtils;
|
|
|
8138
8150
|
function requireUtils() {
|
|
8139
8151
|
if (hasRequiredUtils) return utils;
|
|
8140
8152
|
hasRequiredUtils = 1;
|
|
8141
|
-
(function(exports) {
|
|
8153
|
+
(function(exports$1) {
|
|
8142
8154
|
const path = require$$0$4;
|
|
8143
8155
|
const win32 = process.platform === "win32";
|
|
8144
8156
|
const {
|
|
@@ -8147,36 +8159,36 @@ function requireUtils() {
|
|
|
8147
8159
|
REGEX_SPECIAL_CHARS,
|
|
8148
8160
|
REGEX_SPECIAL_CHARS_GLOBAL
|
|
8149
8161
|
} = requireConstants();
|
|
8150
|
-
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
8151
|
-
exports.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
|
|
8152
|
-
exports.isRegexChar = (str2) => str2.length === 1 && exports.hasRegexChars(str2);
|
|
8153
|
-
exports.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
8154
|
-
exports.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
|
|
8155
|
-
exports.removeBackslashes = (str2) => {
|
|
8162
|
+
exports$1.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
8163
|
+
exports$1.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
|
|
8164
|
+
exports$1.isRegexChar = (str2) => str2.length === 1 && exports$1.hasRegexChars(str2);
|
|
8165
|
+
exports$1.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
8166
|
+
exports$1.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
|
|
8167
|
+
exports$1.removeBackslashes = (str2) => {
|
|
8156
8168
|
return str2.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
8157
8169
|
return match === "\\" ? "" : match;
|
|
8158
8170
|
});
|
|
8159
8171
|
};
|
|
8160
|
-
exports.supportsLookbehinds = () => {
|
|
8172
|
+
exports$1.supportsLookbehinds = () => {
|
|
8161
8173
|
const segs = process.version.slice(1).split(".").map(Number);
|
|
8162
8174
|
if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
|
|
8163
8175
|
return true;
|
|
8164
8176
|
}
|
|
8165
8177
|
return false;
|
|
8166
8178
|
};
|
|
8167
|
-
exports.isWindows = (options) => {
|
|
8179
|
+
exports$1.isWindows = (options) => {
|
|
8168
8180
|
if (options && typeof options.windows === "boolean") {
|
|
8169
8181
|
return options.windows;
|
|
8170
8182
|
}
|
|
8171
8183
|
return win32 === true || path.sep === "\\";
|
|
8172
8184
|
};
|
|
8173
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
8185
|
+
exports$1.escapeLast = (input, char, lastIdx) => {
|
|
8174
8186
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
8175
8187
|
if (idx === -1) return input;
|
|
8176
|
-
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
8188
|
+
if (input[idx - 1] === "\\") return exports$1.escapeLast(input, char, idx - 1);
|
|
8177
8189
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
8178
8190
|
};
|
|
8179
|
-
exports.removePrefix = (input, state = {}) => {
|
|
8191
|
+
exports$1.removePrefix = (input, state = {}) => {
|
|
8180
8192
|
let output = input;
|
|
8181
8193
|
if (output.startsWith("./")) {
|
|
8182
8194
|
output = output.slice(2);
|
|
@@ -8184,7 +8196,7 @@ function requireUtils() {
|
|
|
8184
8196
|
}
|
|
8185
8197
|
return output;
|
|
8186
8198
|
};
|
|
8187
|
-
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
8199
|
+
exports$1.wrapOutput = (input, state = {}, options = {}) => {
|
|
8188
8200
|
const prepend = options.contains ? "" : "^";
|
|
8189
8201
|
const append = options.contains ? "" : "$";
|
|
8190
8202
|
let output = `${prepend}(?:${input})${append}`;
|
|
@@ -13828,7 +13840,14 @@ function requirePreferredPm() {
|
|
|
13828
13840
|
};
|
|
13829
13841
|
}
|
|
13830
13842
|
try {
|
|
13831
|
-
|
|
13843
|
+
const workspaceRoot = findYarnWorkspaceRoot(pkgPath);
|
|
13844
|
+
if (typeof workspaceRoot === "string") {
|
|
13845
|
+
if (await pathExists2(path.join(workspaceRoot, "package-lock.json"))) {
|
|
13846
|
+
return {
|
|
13847
|
+
name: "npm",
|
|
13848
|
+
version: ">=7"
|
|
13849
|
+
};
|
|
13850
|
+
}
|
|
13832
13851
|
return {
|
|
13833
13852
|
name: "yarn",
|
|
13834
13853
|
version: "*"
|
|
@@ -18402,7 +18421,7 @@ function asBoolean(value) {
|
|
|
18402
18421
|
const normalized = value.toLowerCase().trim();
|
|
18403
18422
|
return normalized !== "false" && normalized !== "0";
|
|
18404
18423
|
}
|
|
18405
|
-
const version = "1.
|
|
18424
|
+
const version = "1.16.0-beta.0";
|
|
18406
18425
|
const name = "@fourlights/strapi-plugin-deep-populate";
|
|
18407
18426
|
const f = (msg, context = void 0) => {
|
|
18408
18427
|
const prefix = `[${name}] `;
|
|
@@ -18596,10 +18615,8 @@ const getConfig = (params) => {
|
|
|
18596
18615
|
localizations: localizationsFallback,
|
|
18597
18616
|
contentTypes: contentTypes2
|
|
18598
18617
|
} = strapi.config.get("plugin::deep-populate");
|
|
18599
|
-
const
|
|
18600
|
-
|
|
18601
|
-
mergeWith(contentTypeConfig, sanitizeObject(get$1(contentTypes2, params.contentType)));
|
|
18602
|
-
}
|
|
18618
|
+
const baseConfig = has$1(contentTypes2, "*") ? get$1(contentTypes2, "*") : {};
|
|
18619
|
+
const contentTypeConfig = has$1(contentTypes2, params.contentType) ? mergeWith({}, baseConfig, sanitizeObject(get$1(contentTypes2, params.contentType))) : baseConfig;
|
|
18603
18620
|
const { allow, deny } = contentTypeConfig;
|
|
18604
18621
|
const omitEmpty = params.omitEmpty ?? contentTypeConfig.omitEmpty ?? omitEmptyFallback;
|
|
18605
18622
|
const localizations = params.localizations ?? contentTypeConfig.localizations ?? localizationsFallback;
|
|
@@ -18947,8 +18964,8 @@ async function populate$1(params) {
|
|
|
18947
18964
|
resolvedSchemas,
|
|
18948
18965
|
omitEmpty: config2.omitEmpty,
|
|
18949
18966
|
localizations: config2.localizations,
|
|
18950
|
-
__deny: config2.deny,
|
|
18951
|
-
__allow: config2.allow,
|
|
18967
|
+
__deny: clone$3(config2.deny),
|
|
18968
|
+
__allow: clone$3(config2.allow),
|
|
18952
18969
|
...params
|
|
18953
18970
|
});
|
|
18954
18971
|
populated.__deepPopulated = true;
|
|
@@ -4,8 +4,8 @@ export declare const getRelations: <TSchema extends UID.Schema>(model: Schema.Sc
|
|
|
4
4
|
export declare const isEmpty: (obj: object) => boolean;
|
|
5
5
|
export declare const hasValue: (value: unknown) => boolean;
|
|
6
6
|
export declare const getConfig: (params: PopulateParams) => {
|
|
7
|
-
allow:
|
|
8
|
-
deny:
|
|
9
|
-
omitEmpty:
|
|
10
|
-
localizations:
|
|
7
|
+
allow: any;
|
|
8
|
+
deny: any;
|
|
9
|
+
omitEmpty: any;
|
|
10
|
+
localizations: any;
|
|
11
11
|
};
|
package/package.json
CHANGED