@prismicio/mock 0.0.7 → 0.0.8
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/index.cjs +65 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +27 -25
- package/dist/index.js +65 -53
- package/dist/index.js.map +1 -1
- package/dist/model/index.cjs +1 -1
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.ts +3 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/value/index.cjs +64 -52
- package/dist/value/index.cjs.map +1 -1
- package/dist/value/index.d.ts +21 -21
- package/dist/value/index.js +64 -52
- package/dist/value/index.js.map +1 -1
- package/package.json +1 -1
- package/src/model/integrationFields.ts +4 -2
- package/src/types.ts +99 -83
- package/src/value/group.ts +35 -24
- package/src/value/sliceZone.ts +56 -49
- package/src/value/title.ts +26 -13
package/dist/index.cjs
CHANGED
|
@@ -407,7 +407,7 @@ const integrationFields$1 = (config = {}) => {
|
|
|
407
407
|
type: prismicT__namespace.CustomTypeModelFieldType.IntegrationFields,
|
|
408
408
|
config: {
|
|
409
409
|
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
410
|
-
catalog: changeCase__namespace.snakeCase(faker.lorem.words(4))
|
|
410
|
+
catalog: config.catalog || changeCase__namespace.snakeCase(faker.lorem.words(4))
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
413
|
};
|
|
@@ -907,19 +907,23 @@ const geoPoint = (config = {}) => {
|
|
|
907
907
|
|
|
908
908
|
const group = (config = {}) => {
|
|
909
909
|
var _a;
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
seed: config.seed,
|
|
919
|
-
map: model.config.fields,
|
|
920
|
-
configs: config.configs
|
|
910
|
+
if (config.state === "empty") {
|
|
911
|
+
return [];
|
|
912
|
+
} else {
|
|
913
|
+
const faker = createFaker(config.seed);
|
|
914
|
+
const model = config.model || group$1({ seed: config.seed });
|
|
915
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
|
|
916
|
+
min: 1,
|
|
917
|
+
max: 6
|
|
921
918
|
});
|
|
922
|
-
|
|
919
|
+
return Array(itemsCount).fill(void 0).map(() => {
|
|
920
|
+
return valueForModelMap({
|
|
921
|
+
seed: config.seed,
|
|
922
|
+
map: model.config.fields,
|
|
923
|
+
configs: config.configs
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
}
|
|
923
927
|
};
|
|
924
928
|
|
|
925
929
|
const buildImageFieldImage = (config) => {
|
|
@@ -1452,56 +1456,64 @@ const sharedSlice = (config = {}) => {
|
|
|
1452
1456
|
|
|
1453
1457
|
const sliceZone = (config = {}) => {
|
|
1454
1458
|
var _a;
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
label: choiceLabel ? choiceLabel.name : null,
|
|
1475
|
-
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1476
|
-
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
|
|
1480
|
-
const sharedSliceModel = (_a2 = config.sharedSliceModels) == null ? void 0 : _a2.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
|
|
1481
|
-
if (sharedSliceModel) {
|
|
1482
|
-
return sharedSlice({
|
|
1459
|
+
if (config.state === "empty") {
|
|
1460
|
+
return [];
|
|
1461
|
+
} else {
|
|
1462
|
+
const faker = createFaker(config.seed);
|
|
1463
|
+
const model = config.model || sliceZone$1({ seed: config.seed });
|
|
1464
|
+
if (Object.keys(model.config.choices).length > 0) {
|
|
1465
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
|
|
1466
|
+
min: 1,
|
|
1467
|
+
max: 6
|
|
1468
|
+
});
|
|
1469
|
+
return Array(itemsCount).fill(void 0).map(() => {
|
|
1470
|
+
var _a2;
|
|
1471
|
+
const choices = Object.entries(model.config.choices);
|
|
1472
|
+
const [choiceType, choiceModel] = faker.random.arrayElement(choices);
|
|
1473
|
+
const choiceLabels = model.config.labels[choiceType] || [];
|
|
1474
|
+
const choiceLabel = faker.random.arrayElement(choiceLabels);
|
|
1475
|
+
switch (choiceModel.type) {
|
|
1476
|
+
case prismicT__namespace.CustomTypeModelSliceType.Slice: {
|
|
1477
|
+
return slice({
|
|
1483
1478
|
seed: config.seed,
|
|
1484
|
-
model:
|
|
1479
|
+
model: choiceModel,
|
|
1480
|
+
type: choiceType,
|
|
1481
|
+
label: choiceLabel ? choiceLabel.name : null,
|
|
1485
1482
|
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1486
1483
|
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1487
1484
|
});
|
|
1488
1485
|
}
|
|
1486
|
+
case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
|
|
1487
|
+
const sharedSliceModel = (_a2 = config.sharedSliceModels) == null ? void 0 : _a2.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
|
|
1488
|
+
if (sharedSliceModel) {
|
|
1489
|
+
return sharedSlice({
|
|
1490
|
+
seed: config.seed,
|
|
1491
|
+
model: sharedSliceModel,
|
|
1492
|
+
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1493
|
+
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1489
1497
|
}
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1498
|
+
}).filter((slice2) => slice2 !== void 0);
|
|
1499
|
+
} else {
|
|
1500
|
+
return [];
|
|
1501
|
+
}
|
|
1494
1502
|
}
|
|
1495
1503
|
};
|
|
1496
1504
|
|
|
1497
1505
|
const title = (config = {}) => {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1506
|
+
if (config.state === "empty") {
|
|
1507
|
+
return [];
|
|
1508
|
+
} else {
|
|
1509
|
+
return [
|
|
1510
|
+
heading({
|
|
1511
|
+
seed: config.seed,
|
|
1512
|
+
model: config.model,
|
|
1513
|
+
pattern: config.pattern
|
|
1514
|
+
})
|
|
1515
|
+
];
|
|
1516
|
+
}
|
|
1505
1517
|
};
|
|
1506
1518
|
|
|
1507
1519
|
const uid = (config = {}) => {
|