@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 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
- const faker = createFaker(config.seed);
911
- const model = config.model || group$1({ seed: config.seed });
912
- const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
913
- min: 1,
914
- max: 6
915
- });
916
- return Array(itemsCount).fill(void 0).map(() => {
917
- return valueForModelMap({
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
- const faker = createFaker(config.seed);
1456
- const model = config.model || sliceZone$1({ seed: config.seed });
1457
- if (Object.keys(model.config.choices).length > 0) {
1458
- const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
1459
- min: 1,
1460
- max: 6
1461
- });
1462
- return Array(itemsCount).fill(void 0).map(() => {
1463
- var _a2;
1464
- const choices = Object.entries(model.config.choices);
1465
- const [choiceType, choiceModel] = faker.random.arrayElement(choices);
1466
- const choiceLabels = model.config.labels[choiceType] || [];
1467
- const choiceLabel = faker.random.arrayElement(choiceLabels);
1468
- switch (choiceModel.type) {
1469
- case prismicT__namespace.CustomTypeModelSliceType.Slice: {
1470
- return slice({
1471
- seed: config.seed,
1472
- model: choiceModel,
1473
- type: choiceType,
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: sharedSliceModel,
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
- }).filter((slice2) => slice2 !== void 0);
1492
- } else {
1493
- return [];
1498
+ }).filter((slice2) => slice2 !== void 0);
1499
+ } else {
1500
+ return [];
1501
+ }
1494
1502
  }
1495
1503
  };
1496
1504
 
1497
1505
  const title = (config = {}) => {
1498
- return [
1499
- heading({
1500
- seed: config.seed,
1501
- model: config.model,
1502
- pattern: config.pattern
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 = {}) => {