@prismicio/mock 0.0.9 → 0.1.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.
Files changed (96) hide show
  1. package/dist/api/index.cjs +153 -149
  2. package/dist/api/index.cjs.map +1 -1
  3. package/dist/api/index.d.ts +51 -5
  4. package/dist/api/index.js +153 -149
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/index.cjs +609 -357
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +240 -70
  9. package/dist/index.js +602 -358
  10. package/dist/index.js.map +1 -1
  11. package/dist/model/index.cjs +236 -66
  12. package/dist/model/index.cjs.map +1 -1
  13. package/dist/model/index.d.ts +113 -27
  14. package/dist/model/index.js +236 -66
  15. package/dist/model/index.js.map +1 -1
  16. package/dist/value/index.cjs +347 -315
  17. package/dist/value/index.cjs.map +1 -1
  18. package/dist/value/index.d.ts +90 -38
  19. package/dist/value/index.js +347 -315
  20. package/dist/value/index.js.map +1 -1
  21. package/package.json +14 -15
  22. package/src/api/createAPIMockFactory.ts +56 -0
  23. package/src/api/query.ts +2 -2
  24. package/src/api/ref.ts +3 -3
  25. package/src/api/repository.ts +7 -9
  26. package/src/api/tags.ts +5 -2
  27. package/src/createMockFactory.ts +52 -0
  28. package/src/index.ts +15 -0
  29. package/src/lib/buildEmbedField.ts +13 -4
  30. package/src/lib/buildImageFieldImage.ts +16 -5
  31. package/src/lib/createFaker.ts +14 -15
  32. package/src/lib/generateCustomTypeId.ts +12 -4
  33. package/src/lib/generateFieldId.ts +12 -4
  34. package/src/lib/generateTags.ts +13 -4
  35. package/src/lib/getMockEmbedData.ts +12 -4
  36. package/src/lib/getMockImageData.ts +12 -4
  37. package/src/lib/valueForModel.ts +47 -30
  38. package/src/lib/valueForModelMap.ts +24 -4
  39. package/src/model/boolean.ts +5 -5
  40. package/src/model/buildMockGroupFieldMap.ts +4 -4
  41. package/src/model/color.ts +2 -2
  42. package/src/model/contentRelationship.ts +2 -2
  43. package/src/model/createModelMockFactory.ts +213 -0
  44. package/src/model/customType.ts +3 -3
  45. package/src/model/date.ts +2 -2
  46. package/src/model/embed.ts +2 -2
  47. package/src/model/geoPoint.ts +2 -2
  48. package/src/model/group.ts +6 -6
  49. package/src/model/image.ts +3 -3
  50. package/src/model/index.ts +2 -0
  51. package/src/model/integrationFields.ts +2 -2
  52. package/src/model/keyText.ts +2 -2
  53. package/src/model/link.ts +3 -3
  54. package/src/model/linkToMedia.ts +3 -3
  55. package/src/model/number.ts +2 -2
  56. package/src/model/richText.ts +2 -2
  57. package/src/model/select.ts +3 -3
  58. package/src/model/sharedSlice.ts +3 -3
  59. package/src/model/sharedSliceVariation.ts +6 -6
  60. package/src/model/slice.ts +3 -3
  61. package/src/model/sliceZone.ts +7 -4
  62. package/src/model/timestamp.ts +2 -2
  63. package/src/model/title.ts +2 -2
  64. package/src/model/uid.ts +2 -2
  65. package/src/types.ts +67 -25
  66. package/src/value/boolean.ts +3 -5
  67. package/src/value/color.ts +2 -2
  68. package/src/value/contentRelationship.ts +18 -15
  69. package/src/value/createValueMockFactory.ts +236 -0
  70. package/src/value/customType.ts +7 -7
  71. package/src/value/date.ts +6 -2
  72. package/src/value/embed.ts +6 -3
  73. package/src/value/geoPoint.ts +2 -2
  74. package/src/value/group.ts +5 -5
  75. package/src/value/image.ts +26 -18
  76. package/src/value/integrationFields.ts +12 -26
  77. package/src/value/keyText.ts +2 -2
  78. package/src/value/link.ts +9 -7
  79. package/src/value/linkToMedia.ts +2 -2
  80. package/src/value/number.ts +2 -2
  81. package/src/value/richText/embed.ts +6 -3
  82. package/src/value/richText/heading.ts +29 -17
  83. package/src/value/richText/image.ts +6 -3
  84. package/src/value/richText/index.ts +71 -43
  85. package/src/value/richText/list.ts +2 -2
  86. package/src/value/richText/oList.ts +2 -2
  87. package/src/value/richText/paragraph.ts +2 -2
  88. package/src/value/richText/preformatted.ts +2 -2
  89. package/src/value/select.ts +10 -6
  90. package/src/value/sharedSlice.ts +4 -4
  91. package/src/value/sharedSliceVariation.ts +9 -10
  92. package/src/value/slice.ts +9 -9
  93. package/src/value/sliceZone.ts +10 -8
  94. package/src/value/timestamp.ts +2 -2
  95. package/src/value/title.ts +7 -3
  96. package/src/value/uid.ts +5 -3
package/dist/index.cjs CHANGED
@@ -30,8 +30,6 @@ const changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase);
30
30
  const Rand__default = /*#__PURE__*/_interopDefaultLegacy(Rand);
31
31
  const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
32
32
 
33
- const FAKER_SEED = 1984;
34
-
35
33
  const wordsString = "lorem ipsum dolor sit amet, consectetur adipiscing elit ut aliquam, purus sit amet luctus venenatis, lectus magna fringilla urna, porttitor rhoncus dolor purus non enim praesent elementum facilisis leo, vel fringilla est ullamcorper eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus in ornare quam viverra orci sagittis eu volutpat odio facilisis mauris sit amet massa vitae tortor condimentum lacinia quis vel eros donec ac odio tempor orci dapibus ultrices in iaculis nunc sed augue lacus, viverra vitae congue eu, consequat ac felis donec et odio pellentesque diam volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum arcu vitae elementum curabitur vitae nunc sed velit dignissim sodales ut eu sem integer vitae justo eget magna fermentum iaculis eu non diam phasellus vestibulum lorem sed risus ultricies tristique nulla aliquet enim tortor, at auctor urna nunc id cursus metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices sagittis orci, a scelerisque purus semper eget duis at tellus at urna condimentum mattis pellentesque id nibh tortor, id aliquet lectus proin nibh nisl, condimentum id venenatis a, condimentum vitae sapien pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas sed tempus, urna et pharetra pharetra, massa massa ultricies mi, quis hendrerit dolor magna eget est lorem ipsum dolor sit amet, consectetur adipiscing elit pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas integer eget aliquet nibh praesent tristique magna sit amet purus gravida quis blandit turpis cursus in hac habitasse platea dictumst quisque sagittis, purus sit amet volutpat consequat, mauris nunc congue nisi, vitae suscipit tellus mauris a diam maecenas sed enim ut sem viverra aliquet eget sit amet tellus cras adipiscing enim eu turpis egestas pretium aenean pharetra, magna ac placerat vestibulum, lectus mauris ultrices eros, in cursus turpis massa tincidunt dui ut ornare lectus sit amet est placerat in egestas erat imperdiet sed euismod nisi porta lorem mollis aliquam ut porttitor leo a diam sollicitudin tempor id eu nisl nunc mi ipsum, faucibus vitae aliquet nec, ullamcorper sit amet risus nullam eget felis eget nunc lobortis mattis aliquam faucibus purus in massa tempor nec feugiat nisl pretium fusce id velit ut tortor pretium viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi lacus, sed viverra tellus in hac habitasse platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius duis at consectetur lorem donec massa sapien, faucibus et molestie ac, feugiat sed lectus vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa, eget egestas purus viverra accumsan in nisl nisi, scelerisque eu ultrices vitae, auctor eu augue ut lectus arcu, bibendum at varius vel, pharetra vel turpis nunc eget lorem dolor, sed viverra ipsum nunc aliquet bibendum enim, facilisis gravida neque convallis a cras semper auctor neque, vitae tempus quam pellentesque nec nam aliquam sem et tortor consequat id porta nibh venenatis cras sed felis eget velit aliquet sagittis id consectetur purus ut faucibus pulvinar elementum integer enim neque, volutpat ac tincidunt vitae, semper quis lectus nulla at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum consectetur libero, id faucibus nisl tincidunt eget nullam non nisi est, sit amet facilisis magna etiam tempor, orci eu lobortis elementum, nibh tellus molestie nunc, non blandit massa enim nec dui nunc mattis enim ut tellus elementum sagittis vitae et leo duis ut diam quam nulla porttitor massa id neque aliquam vestibulum morbi blandit cursus risus, at ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget gravida cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus mauris vitae ultricies leo integer malesuada nunc vel risus commodo viverra maecenas accumsan, lacus vel facilisis volutpat, est velit egestas dui, id ornare arcu odio ut sem nulla pharetra diam sit amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc, consequat interdum varius sit amet, mattis vulputate enim nulla aliquet porttitor lacus, luctus accumsan tortor posuere ac ut consequat semper viverra nam libero justo, laoreet sit amet cursus sit amet, dictum sit amet justo donec enim diam, vulputate ut pharetra sit amet, aliquam id diam maecenas ultricies mi eget mauris pharetra et ultrices neque ornare aenean euismod elementum nisi, quis eleifend quam adipiscing vitae proin sagittis, nisl rhoncus mattis rhoncus, urna neque viverra justo, nec ultrices dui sapien eget mi proin sed libero enim, sed faucibus turpis in eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod quis viverra nibh cras pulvinar mattis nunc, sed blandit libero volutpat sed cras ornare arcu dui vivamus arcu felis, bibendum ut tristique et, egestas quis ipsum suspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque dignissim enim, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in pellentesque massa placerat duis ultricies lacus sed turpis tincidunt id aliquet risus feugiat in ante metus, dictum at tempor commodo, ullamcorper a lacus vestibulum sed arcu non odio euismod lacinia at quis risus sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit aliquam etiam erat velit, scelerisque in dictum non, consectetur a erat nam at lectus urna duis convallis convallis tellus, id interdum velit laoreet id donec ultrices tincidunt arcu, non sodales neque sodales ut etiam sit amet nisl purus, in mollis nunc sed id semper risus in hendrerit gravida rutrum quisque non tellus orci, ac auctor augue mauris augue neque, gravida in fermentum et, sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras fermentum, odio eu feugiat pretium, nibh ipsum consequat nisl, vel pretium lectus quam id leo in vitae turpis massa sed elementum tempus egestas sed sed risus pretium quam vulputate dignissim suspendisse in est ante in nibh mauris, cursus mattis molestie a, iaculis at erat pellentesque adipiscing commodo elit, at imperdiet dui accumsan sit amet nulla facilisi morbi tempus iaculis urna, id volutpat lacus laoreet non curabitur gravida arcu ac tortor dignissim convallis aenean et tortor at risus viverra adipiscing at in tellus integer feugiat scelerisque varius morbi enim nunc, faucibus a pellentesque sit amet, porttitor eget dolor morbi non arcu risus, quis varius quam quisque id diam vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit amet, consectetur adipiscing elit duis tristique sollicitudin nibh sit amet commodo nulla facilisi nullam vehicula ipsum a arcu cursus vitae congue mauris rhoncus aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas maecenas pharetra convallis posuere morbi leo urna, molestie at elementum eu, facilisis sed odio morbi quis commodo odio aenean sed adipiscing diam donec adipiscing tristique risus nec feugiat in fermentum posuere urna nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a molestie";
36
34
  const loremWords = wordsString.split(" ");
37
35
  const lorem = (length, wordOffset = 0) => {
@@ -73,22 +71,16 @@ const lorem = (length, wordOffset = 0) => {
73
71
  };
74
72
  lorem.spaceIndices = [];
75
73
 
76
- const createFaker = (seed = FAKER_SEED) => {
77
- const normalizedSeed = seed.toString();
78
- if (createFaker.cache[normalizedSeed]) {
79
- return createFaker.cache[normalizedSeed];
80
- } else {
81
- const faker = new Faker(normalizedSeed);
82
- return createFaker.cache[normalizedSeed] = faker;
83
- }
74
+ const createFaker = (seed) => {
75
+ return new Faker(seed);
84
76
  };
85
- createFaker.cache = {};
86
77
  const DAY_MS = 1e3 * 60 * 60 * 24;
87
78
  const YEAR_MS = DAY_MS * 365;
88
79
  const YEAR_2022_MS = 52 * (YEAR_MS + DAY_MS / 4);
89
80
  class Faker {
90
81
  constructor(seed) {
91
- this.rand = new Rand__default["default"](seed);
82
+ this.seed = seed;
83
+ this.rand = new Rand__default["default"](seed.toString());
92
84
  }
93
85
  boolean() {
94
86
  return this.random() >= 0.5;
@@ -100,7 +92,8 @@ class Faker {
100
92
  return elements[this.range(0, elements.length)];
101
93
  }
102
94
  randomElements(elements) {
103
- return elements.filter(() => this.boolean());
95
+ const alwaysInclude = this.randomElement(elements);
96
+ return elements.filter((element) => element === alwaysInclude || this.boolean());
104
97
  }
105
98
  range(min, max) {
106
99
  return Math.floor(this.rangeFloat(Math.ceil(min), Math.floor(max)));
@@ -149,51 +142,53 @@ class Faker {
149
142
 
150
143
  const generateTags = (config) => {
151
144
  var _a, _b;
152
- const faker = createFaker(config.seed);
145
+ const faker = config.faker || createFaker(config.seed);
153
146
  return Array.from({ length: faker.range((_a = config.min) != null ? _a : 0, (_b = config.max) != null ? _b : 2) }, () => changeCase__namespace.capitalCase(faker.words(faker.range(1, 3))));
154
147
  };
155
148
 
156
- const boolean$1 = (config = {}) => {
157
- const faker = createFaker(config.seed);
149
+ const boolean$1 = (config) => {
150
+ const faker = config.faker || createFaker(config.seed);
158
151
  return faker.boolean();
159
152
  };
160
153
 
161
154
  const valueForModel = (config) => {
155
+ var _a;
156
+ const faker = config.faker || createFaker(config.seed);
162
157
  const model = config.model;
163
158
  switch (model.type) {
164
159
  case prismicT__namespace.CustomTypeModelFieldType.Boolean: {
165
160
  return boolean$1({
166
- seed: config.seed,
161
+ faker,
167
162
  model,
168
163
  ...config.config
169
164
  });
170
165
  }
171
166
  case prismicT__namespace.CustomTypeModelFieldType.Color: {
172
167
  return color({
173
- seed: config.seed,
168
+ faker,
174
169
  model,
175
170
  ...config.config
176
171
  });
177
172
  }
178
173
  case prismicT__namespace.CustomTypeModelFieldType.Link: {
179
- switch (model.config.select) {
174
+ switch ((_a = model.config) == null ? void 0 : _a.select) {
180
175
  case prismicT__namespace.CustomTypeModelLinkSelectType.Document: {
181
176
  return contentRelationship({
182
- seed: config.seed,
177
+ faker,
183
178
  model,
184
179
  ...config.config
185
180
  });
186
181
  }
187
182
  case prismicT__namespace.CustomTypeModelLinkSelectType.Media: {
188
183
  return linkToMedia({
189
- seed: config.seed,
184
+ faker,
190
185
  model,
191
186
  ...config.config
192
187
  });
193
188
  }
194
189
  default: {
195
190
  return link({
196
- seed: config.seed,
191
+ faker,
197
192
  model,
198
193
  ...config.config
199
194
  });
@@ -202,70 +197,70 @@ const valueForModel = (config) => {
202
197
  }
203
198
  case prismicT__namespace.CustomTypeModelFieldType.Date: {
204
199
  return date({
205
- seed: config.seed,
200
+ faker,
206
201
  model,
207
202
  ...config.config
208
203
  });
209
204
  }
210
205
  case prismicT__namespace.CustomTypeModelFieldType.Embed: {
211
206
  return embed$1({
212
- seed: config.seed,
207
+ faker,
213
208
  model,
214
209
  ...config.config
215
210
  });
216
211
  }
217
212
  case prismicT__namespace.CustomTypeModelFieldType.GeoPoint: {
218
213
  return geoPoint({
219
- seed: config.seed,
214
+ faker,
220
215
  model,
221
216
  ...config.config
222
217
  });
223
218
  }
224
219
  case prismicT__namespace.CustomTypeModelFieldType.Image: {
225
220
  return image$1({
226
- seed: config.seed,
221
+ faker,
227
222
  model,
228
223
  ...config.config
229
224
  });
230
225
  }
231
226
  case prismicT__namespace.CustomTypeModelFieldType.Text: {
232
227
  return keyText({
233
- seed: config.seed,
228
+ faker,
234
229
  model,
235
230
  ...config.config
236
231
  });
237
232
  }
238
233
  case prismicT__namespace.CustomTypeModelFieldType.Number: {
239
234
  return number({
240
- seed: config.seed,
235
+ faker,
241
236
  model,
242
237
  ...config.config
243
238
  });
244
239
  }
245
240
  case prismicT__namespace.CustomTypeModelFieldType.Select: {
246
241
  return select({
247
- seed: config.seed,
242
+ faker,
248
243
  model,
249
244
  ...config.config
250
245
  });
251
246
  }
252
247
  case prismicT__namespace.CustomTypeModelFieldType.Timestamp: {
253
248
  return timestamp({
254
- seed: config.seed,
249
+ faker,
255
250
  model,
256
251
  ...config.config
257
252
  });
258
253
  }
259
254
  case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
260
- if ("single" in model.config && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
255
+ if (model.config && "single" in model.config && model.config.single && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
261
256
  return title({
262
- seed: config.seed,
257
+ faker,
263
258
  model,
264
259
  ...config.config
265
260
  });
266
261
  } else {
267
262
  return richText({
268
- seed: config.seed,
263
+ faker,
269
264
  model,
270
265
  ...config.config
271
266
  });
@@ -273,36 +268,41 @@ const valueForModel = (config) => {
273
268
  }
274
269
  case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields: {
275
270
  return integrationFields({
276
- seed: config.seed,
271
+ faker,
277
272
  model,
278
273
  ...config.config
279
274
  });
280
275
  }
281
276
  case prismicT__namespace.CustomTypeModelFieldType.UID: {
282
277
  return uid({
283
- seed: config.seed,
278
+ faker,
284
279
  model,
285
280
  ...config.config
286
281
  });
287
282
  }
288
283
  case prismicT__namespace.CustomTypeModelFieldType.Group: {
289
284
  return group({
290
- seed: config.seed,
285
+ faker,
291
286
  model,
292
287
  ...config.config
293
288
  });
294
289
  }
290
+ case prismicT__namespace.CustomTypeModelFieldType.LegacySlices:
295
291
  case prismicT__namespace.CustomTypeModelFieldType.Slices: {
296
292
  return sliceZone({
297
- seed: config.seed,
293
+ faker,
298
294
  model,
299
295
  ...config.config
300
296
  });
301
297
  }
298
+ default: {
299
+ throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
300
+ }
302
301
  }
303
302
  };
304
303
 
305
304
  const getValueConfigType = (model) => {
305
+ var _a;
306
306
  switch (model.type) {
307
307
  case prismicT__namespace.CustomTypeModelFieldType.Boolean:
308
308
  return "boolean";
@@ -319,7 +319,7 @@ const getValueConfigType = (model) => {
319
319
  case prismicT__namespace.CustomTypeModelFieldType.Image:
320
320
  return "image";
321
321
  case prismicT__namespace.CustomTypeModelFieldType.Link: {
322
- switch (model.config.select) {
322
+ switch ((_a = model.config) == null ? void 0 : _a.select) {
323
323
  case prismicT__namespace.CustomTypeModelLinkSelectType.Document:
324
324
  return "contentRelationship";
325
325
  case prismicT__namespace.CustomTypeModelLinkSelectType.Media:
@@ -333,7 +333,7 @@ const getValueConfigType = (model) => {
333
333
  case prismicT__namespace.CustomTypeModelFieldType.Select:
334
334
  return "select";
335
335
  case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
336
- if ("single" in model.config && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
336
+ if (model.config && "single" in model.config && model.config.single && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
337
337
  return "title";
338
338
  } else {
339
339
  return "richText";
@@ -349,17 +349,21 @@ const getValueConfigType = (model) => {
349
349
  return "integrationFields";
350
350
  case prismicT__namespace.CustomTypeModelFieldType.Slices:
351
351
  return "sliceZone";
352
+ default: {
353
+ throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
354
+ }
352
355
  }
353
356
  };
354
357
  const valueForModelMap = (config) => {
355
358
  var _a;
359
+ const faker = config.faker || createFaker(config.seed);
356
360
  const result = {};
357
361
  for (const fieldId in config.map) {
358
362
  const fieldModel = config.map[fieldId];
359
363
  const fieldConfigType = getValueConfigType(fieldModel);
360
364
  const fieldConfig = (_a = config.configs) == null ? void 0 : _a[fieldConfigType];
361
365
  result[fieldId] = valueForModel({
362
- seed: config.seed,
366
+ faker,
363
367
  model: fieldModel,
364
368
  config: fieldConfig
365
369
  });
@@ -367,18 +371,18 @@ const valueForModelMap = (config) => {
367
371
  return result;
368
372
  };
369
373
 
370
- const boolean = (config = {}) => {
371
- const faker = createFaker(config.seed);
374
+ function boolean(config) {
375
+ const faker = config.faker || createFaker(config.seed);
372
376
  return {
373
377
  type: prismicT__namespace.CustomTypeModelFieldType.Boolean,
374
378
  config: {
375
379
  label: changeCase__namespace.capitalCase(faker.word())
376
380
  }
377
381
  };
378
- };
382
+ }
379
383
 
380
- const color$1 = (config = {}) => {
381
- const faker = createFaker(config.seed);
384
+ const color$1 = (config) => {
385
+ const faker = config.faker || createFaker(config.seed);
382
386
  return {
383
387
  type: prismicT__namespace.CustomTypeModelFieldType.Color,
384
388
  config: {
@@ -388,8 +392,8 @@ const color$1 = (config = {}) => {
388
392
  };
389
393
  };
390
394
 
391
- const contentRelationship$1 = (config = {}) => {
392
- const faker = createFaker(config.seed);
395
+ const contentRelationship$1 = (config) => {
396
+ const faker = config.faker || createFaker(config.seed);
393
397
  return {
394
398
  type: prismicT__namespace.CustomTypeModelFieldType.Link,
395
399
  config: {
@@ -402,9 +406,9 @@ const contentRelationship$1 = (config = {}) => {
402
406
  };
403
407
  };
404
408
 
405
- const customType$1 = (config = {}) => {
409
+ const customType$1 = (config) => {
406
410
  var _a, _b;
407
- const faker = createFaker(config.seed);
411
+ const faker = config.faker || createFaker(config.seed);
408
412
  let label = config.label || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
409
413
  let id = config.id || changeCase__namespace.snakeCase(label);
410
414
  if (config.id && !config.label) {
@@ -427,8 +431,8 @@ const customType$1 = (config = {}) => {
427
431
  };
428
432
  };
429
433
 
430
- const date$1 = (config = {}) => {
431
- const faker = createFaker(config.seed);
434
+ const date$1 = (config) => {
435
+ const faker = config.faker || createFaker(config.seed);
432
436
  return {
433
437
  type: prismicT__namespace.CustomTypeModelFieldType.Date,
434
438
  config: {
@@ -438,8 +442,8 @@ const date$1 = (config = {}) => {
438
442
  };
439
443
  };
440
444
 
441
- const embed$2 = (config = {}) => {
442
- const faker = createFaker(config.seed);
445
+ const embed$2 = (config) => {
446
+ const faker = config.faker || createFaker(config.seed);
443
447
  return {
444
448
  type: prismicT__namespace.CustomTypeModelFieldType.Embed,
445
449
  config: {
@@ -449,8 +453,8 @@ const embed$2 = (config = {}) => {
449
453
  };
450
454
  };
451
455
 
452
- const geoPoint$1 = (config = {}) => {
453
- const faker = createFaker(config.seed);
456
+ const geoPoint$1 = (config) => {
457
+ const faker = config.faker || createFaker(config.seed);
454
458
  return {
455
459
  type: prismicT__namespace.CustomTypeModelFieldType.GeoPoint,
456
460
  config: {
@@ -459,8 +463,8 @@ const geoPoint$1 = (config = {}) => {
459
463
  };
460
464
  };
461
465
 
462
- const group$1 = (config = {}) => {
463
- const faker = createFaker(config.seed);
466
+ function group$1(config) {
467
+ const faker = config.faker || createFaker(config.seed);
464
468
  return {
465
469
  type: prismicT__namespace.CustomTypeModelFieldType.Group,
466
470
  config: {
@@ -468,10 +472,10 @@ const group$1 = (config = {}) => {
468
472
  fields: config.fields || {}
469
473
  }
470
474
  };
471
- };
475
+ }
472
476
 
473
- const image$2 = (config = {}) => {
474
- const faker = createFaker(config.seed);
477
+ const image$2 = (config) => {
478
+ const faker = config.faker || createFaker(config.seed);
475
479
  const thumbnails = (config.thumbnailNames || []).map((name) => {
476
480
  return {
477
481
  name,
@@ -492,8 +496,8 @@ const image$2 = (config = {}) => {
492
496
  };
493
497
  };
494
498
 
495
- const integrationFields$1 = (config = {}) => {
496
- const faker = createFaker(config.seed);
499
+ const integrationFields$1 = (config) => {
500
+ const faker = config.faker || createFaker(config.seed);
497
501
  return {
498
502
  type: prismicT__namespace.CustomTypeModelFieldType.IntegrationFields,
499
503
  config: {
@@ -503,8 +507,8 @@ const integrationFields$1 = (config = {}) => {
503
507
  };
504
508
  };
505
509
 
506
- const keyText$1 = (config = {}) => {
507
- const faker = createFaker(config.seed);
510
+ const keyText$1 = (config) => {
511
+ const faker = config.faker || createFaker(config.seed);
508
512
  return {
509
513
  type: prismicT__namespace.CustomTypeModelFieldType.Text,
510
514
  config: {
@@ -514,8 +518,8 @@ const keyText$1 = (config = {}) => {
514
518
  };
515
519
  };
516
520
 
517
- const link$1 = (config = {}) => {
518
- const faker = createFaker(config.seed);
521
+ const link$1 = (config) => {
522
+ const faker = config.faker || createFaker(config.seed);
519
523
  return {
520
524
  type: prismicT__namespace.CustomTypeModelFieldType.Link,
521
525
  config: {
@@ -527,8 +531,8 @@ const link$1 = (config = {}) => {
527
531
  };
528
532
  };
529
533
 
530
- const linkToMedia$1 = (config = {}) => {
531
- const faker = createFaker(config.seed);
534
+ const linkToMedia$1 = (config) => {
535
+ const faker = config.faker || createFaker(config.seed);
532
536
  return {
533
537
  type: prismicT__namespace.CustomTypeModelFieldType.Link,
534
538
  config: {
@@ -539,8 +543,8 @@ const linkToMedia$1 = (config = {}) => {
539
543
  };
540
544
  };
541
545
 
542
- const number$1 = (config = {}) => {
543
- const faker = createFaker(config.seed);
546
+ const number$1 = (config) => {
547
+ const faker = config.faker || createFaker(config.seed);
544
548
  return {
545
549
  type: prismicT__namespace.CustomTypeModelFieldType.Number,
546
550
  config: {
@@ -550,9 +554,9 @@ const number$1 = (config = {}) => {
550
554
  };
551
555
  };
552
556
 
553
- const richText$1 = (config = {}) => {
557
+ const richText$1 = (config) => {
554
558
  var _a;
555
- const faker = createFaker(config.seed);
559
+ const faker = config.faker || createFaker(config.seed);
556
560
  const blockTypes = faker.randomElements([
557
561
  prismicT__namespace.RichTextNodeType.heading1,
558
562
  prismicT__namespace.RichTextNodeType.heading2,
@@ -582,8 +586,8 @@ const richText$1 = (config = {}) => {
582
586
  };
583
587
  };
584
588
 
585
- const select$1 = (config = {}) => {
586
- const faker = createFaker(config.seed);
589
+ const select$1 = (config) => {
590
+ const faker = config.faker || createFaker(config.seed);
587
591
  return {
588
592
  type: prismicT__namespace.CustomTypeModelFieldType.Select,
589
593
  config: {
@@ -595,8 +599,8 @@ const select$1 = (config = {}) => {
595
599
  };
596
600
  };
597
601
 
598
- const sharedSlice$1 = (config = {}) => {
599
- const faker = createFaker(config.seed);
602
+ const sharedSlice$1 = (config) => {
603
+ const faker = config.faker || createFaker(config.seed);
600
604
  let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
601
605
  let id = config.id || changeCase__namespace.snakeCase(name);
602
606
  if (config.id && !config.name) {
@@ -619,8 +623,95 @@ const sharedSliceChoice = () => {
619
623
  };
620
624
  };
621
625
 
622
- const sharedSliceVariation$1 = (config = {}) => {
623
- const faker = createFaker(config.seed);
626
+ const dataSet$1 = [
627
+ {
628
+ url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
629
+ width: 4240,
630
+ height: 2832
631
+ },
632
+ {
633
+ url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
634
+ width: 7372,
635
+ height: 4392
636
+ },
637
+ {
638
+ url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
639
+ width: 2560,
640
+ height: 1705
641
+ },
642
+ {
643
+ url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
644
+ width: 2200,
645
+ height: 1467
646
+ },
647
+ {
648
+ url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
649
+ width: 5616,
650
+ height: 3744
651
+ },
652
+ {
653
+ url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
654
+ width: 4240,
655
+ height: 2832
656
+ },
657
+ {
658
+ url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
659
+ width: 2560,
660
+ height: 1440
661
+ },
662
+ {
663
+ url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
664
+ width: 6373,
665
+ height: 4253
666
+ },
667
+ {
668
+ url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
669
+ width: 4272,
670
+ height: 2848
671
+ },
672
+ {
673
+ url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
674
+ width: 4554,
675
+ height: 3036
676
+ },
677
+ {
678
+ url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
679
+ width: 6550,
680
+ height: 4367
681
+ },
682
+ {
683
+ url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
684
+ width: 6e3,
685
+ height: 4e3
686
+ },
687
+ {
688
+ url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
689
+ width: 6e3,
690
+ height: 4e3
691
+ },
692
+ {
693
+ url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
694
+ width: 4608,
695
+ height: 3456
696
+ },
697
+ {
698
+ url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
699
+ width: 4844,
700
+ height: 3234
701
+ },
702
+ {
703
+ url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
704
+ width: 4335,
705
+ height: 6502
706
+ }
707
+ ];
708
+ const getMockImageData = (config) => {
709
+ const faker = config.faker || createFaker(config.seed);
710
+ return faker.randomElement(dataSet$1);
711
+ };
712
+
713
+ const sharedSliceVariation$1 = (config) => {
714
+ const faker = config.faker || createFaker(config.seed);
624
715
  let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
625
716
  let id = config.id || changeCase__namespace.snakeCase(name);
626
717
  if (config.id && !config.name) {
@@ -628,6 +719,7 @@ const sharedSliceVariation$1 = (config = {}) => {
628
719
  } else if (config.name && !config.name) {
629
720
  id = changeCase__namespace.snakeCase(config.name);
630
721
  }
722
+ const imageData = getMockImageData({ faker });
631
723
  return {
632
724
  id,
633
725
  name,
@@ -635,12 +727,13 @@ const sharedSliceVariation$1 = (config = {}) => {
635
727
  docURL: faker.url(),
636
728
  version: faker.hash(7),
637
729
  primary: config.primaryFields || {},
638
- items: config.itemsFields || {}
730
+ items: config.itemsFields || {},
731
+ imageUrl: imageData.url
639
732
  };
640
733
  };
641
734
 
642
- const slice$1 = (config = {}) => {
643
- const faker = createFaker(config.seed);
735
+ const slice$1 = (config) => {
736
+ const faker = config.faker || createFaker(config.seed);
644
737
  return {
645
738
  type: prismicT__namespace.CustomTypeModelSliceType.Slice,
646
739
  icon: changeCase__namespace.snakeCase(faker.word()),
@@ -652,7 +745,7 @@ const slice$1 = (config = {}) => {
652
745
  };
653
746
  };
654
747
 
655
- const sliceZone$1 = (config = {}) => {
748
+ const sliceZone$1 = (config) => {
656
749
  const labels = {};
657
750
  for (const choiceId in config.choices) {
658
751
  const choice = config.choices[choiceId];
@@ -670,8 +763,8 @@ const sliceZone$1 = (config = {}) => {
670
763
  };
671
764
  };
672
765
 
673
- const timestamp$1 = (config = {}) => {
674
- const faker = createFaker(config.seed);
766
+ const timestamp$1 = (config) => {
767
+ const faker = config.faker || createFaker(config.seed);
675
768
  return {
676
769
  type: prismicT__namespace.CustomTypeModelFieldType.Timestamp,
677
770
  config: {
@@ -681,8 +774,8 @@ const timestamp$1 = (config = {}) => {
681
774
  };
682
775
  };
683
776
 
684
- const title$1 = (config = {}) => {
685
- const faker = createFaker(config.seed);
777
+ const title$1 = (config) => {
778
+ const faker = config.faker || createFaker(config.seed);
686
779
  const single = faker.randomElements([
687
780
  "heading1",
688
781
  "heading2",
@@ -702,8 +795,8 @@ const title$1 = (config = {}) => {
702
795
  };
703
796
  };
704
797
 
705
- const uid$1 = (config = {}) => {
706
- const faker = createFaker(config.seed);
798
+ const uid$1 = (config) => {
799
+ const faker = config.faker || createFaker(config.seed);
707
800
  return {
708
801
  type: prismicT__namespace.CustomTypeModelFieldType.UID,
709
802
  config: {
@@ -714,7 +807,7 @@ const uid$1 = (config = {}) => {
714
807
  };
715
808
 
716
809
  const generateFieldId = (config) => {
717
- const faker = createFaker(config.seed);
810
+ const faker = config.faker || createFaker(config.seed);
718
811
  return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
719
812
  };
720
813
 
@@ -736,18 +829,105 @@ const mockModelFns = {
736
829
  timestamp: timestamp$1,
737
830
  title: title$1
738
831
  };
739
- const buildMockGroupFieldMap = (config = {}) => {
740
- const faker = createFaker(config.seed);
832
+ const buildMockGroupFieldMap = (config) => {
833
+ const faker = config.faker || createFaker(config.seed);
741
834
  const fields = {};
742
835
  const fieldTypes = faker.randomElements(Object.keys(mockModelFns));
743
836
  for (const fieldType of fieldTypes) {
744
- const fieldId = generateFieldId({ seed: config.seed });
837
+ const fieldId = generateFieldId({ faker });
745
838
  const mockModelFn = mockModelFns[fieldType];
746
- fields[fieldId] = mockModelFn({ seed: config.seed });
839
+ fields[fieldId] = mockModelFn({ faker });
747
840
  }
748
841
  return fields;
749
842
  };
750
843
 
844
+ const createModelMockFactory = (...args) => {
845
+ return new ModelMockFactory(...args);
846
+ };
847
+ class ModelMockFactory {
848
+ constructor(config) {
849
+ this.faker = "faker" in config ? config.faker : createFaker(config.seed);
850
+ }
851
+ get seed() {
852
+ return this.faker.seed;
853
+ }
854
+ buildMockGroupFieldMap(config) {
855
+ return buildMockGroupFieldMap({ ...config, faker: this.faker });
856
+ }
857
+ boolean(config) {
858
+ return boolean({ ...config, faker: this.faker });
859
+ }
860
+ color(config) {
861
+ return color$1({ ...config, faker: this.faker });
862
+ }
863
+ contentRelationship(config) {
864
+ return contentRelationship$1({ ...config, faker: this.faker });
865
+ }
866
+ customType(config) {
867
+ return customType$1({ ...config, faker: this.faker });
868
+ }
869
+ date(config) {
870
+ return date$1({ ...config, faker: this.faker });
871
+ }
872
+ embed(config) {
873
+ return embed$2({ ...config, faker: this.faker });
874
+ }
875
+ geoPoint(config) {
876
+ return geoPoint$1({ ...config, faker: this.faker });
877
+ }
878
+ group(config) {
879
+ return group$1({ ...config, faker: this.faker });
880
+ }
881
+ image(config) {
882
+ return image$2({ ...config, faker: this.faker });
883
+ }
884
+ integrationFields(config) {
885
+ return integrationFields$1({ ...config, faker: this.faker });
886
+ }
887
+ keyText(config) {
888
+ return keyText$1({ ...config, faker: this.faker });
889
+ }
890
+ link(config) {
891
+ return link$1({ ...config, faker: this.faker });
892
+ }
893
+ linkToMedia(config) {
894
+ return linkToMedia$1({ ...config, faker: this.faker });
895
+ }
896
+ number(config) {
897
+ return number$1({ ...config, faker: this.faker });
898
+ }
899
+ richText(config) {
900
+ return richText$1({ ...config, faker: this.faker });
901
+ }
902
+ select(config) {
903
+ return select$1({ ...config, faker: this.faker });
904
+ }
905
+ sharedSlice(config) {
906
+ return sharedSlice$1({ ...config, faker: this.faker });
907
+ }
908
+ sharedSliceChoice() {
909
+ return sharedSliceChoice();
910
+ }
911
+ sharedSliceVariation(config) {
912
+ return sharedSliceVariation$1({ ...config, faker: this.faker });
913
+ }
914
+ slice(config) {
915
+ return slice$1({ ...config, faker: this.faker });
916
+ }
917
+ sliceZone(config) {
918
+ return sliceZone$1({ ...config, faker: this.faker });
919
+ }
920
+ timestamp(config) {
921
+ return timestamp$1({ ...config, faker: this.faker });
922
+ }
923
+ title(config) {
924
+ return title$1({ ...config, faker: this.faker });
925
+ }
926
+ uid(config) {
927
+ return uid$1({ ...config, faker: this.faker });
928
+ }
929
+ }
930
+
751
931
  const index$2 = /*#__PURE__*/Object.freeze({
752
932
  __proto__: null,
753
933
  boolean: boolean,
@@ -774,11 +954,12 @@ const index$2 = /*#__PURE__*/Object.freeze({
774
954
  timestamp: timestamp$1,
775
955
  title: title$1,
776
956
  uid: uid$1,
777
- buildMockGroupFieldMap: buildMockGroupFieldMap
957
+ buildMockGroupFieldMap: buildMockGroupFieldMap,
958
+ createModelFactory: createModelMockFactory
778
959
  });
779
960
 
780
- const timestamp = (config = {}) => {
781
- const faker = createFaker(config.seed);
961
+ const timestamp = (config) => {
962
+ const faker = config.faker || createFaker(config.seed);
782
963
  if (config.state === "empty") {
783
964
  return null;
784
965
  } else {
@@ -807,10 +988,10 @@ const buildAlternativeLanguage = (config) => {
807
988
  };
808
989
  };
809
990
 
810
- const customType = (config = {}) => {
991
+ const customType = (config) => {
811
992
  var _a;
812
- const faker = createFaker(config.seed);
813
- const model = config.model || customType$1({ seed: config.seed });
993
+ const faker = config.faker || createFaker(config.seed);
994
+ const model = config.model || customType$1({ faker });
814
995
  const fieldModelsMap = Object.assign({}, ...Object.values(model.json));
815
996
  const dataFieldModelsMap = {};
816
997
  for (const key in fieldModelsMap) {
@@ -831,22 +1012,22 @@ const customType = (config = {}) => {
831
1012
  url: withURL ? faker.url() : null,
832
1013
  href: faker.url(),
833
1014
  lang: faker.word(),
834
- tags: generateTags({ seed: config.seed }),
1015
+ tags: generateTags({ faker }),
835
1016
  slugs: [],
836
1017
  linked_documents: [],
837
1018
  alternate_languages: alternateLanguages,
838
- first_publication_date: timestamp({ seed: config.seed }),
839
- last_publication_date: timestamp({ seed: config.seed }),
1019
+ first_publication_date: timestamp({ faker }),
1020
+ last_publication_date: timestamp({ faker }),
840
1021
  data: valueForModelMap({
841
- seed: config.seed,
1022
+ faker,
842
1023
  map: dataFieldModelsMap,
843
1024
  configs: config.configs
844
1025
  })
845
1026
  };
846
1027
  };
847
1028
 
848
- const color = (config = {}) => {
849
- const faker = createFaker(config.seed);
1029
+ const color = (config) => {
1030
+ const faker = config.faker || createFaker(config.seed);
850
1031
  return config.state === "empty" ? null : faker.hexColor().toUpperCase();
851
1032
  };
852
1033
 
@@ -865,32 +1046,34 @@ const buildContentRelationshipField = (config) => {
865
1046
  };
866
1047
 
867
1048
  const generateCustomTypeId = (config) => {
868
- const faker = createFaker(config.seed);
1049
+ const faker = config.faker || createFaker(config.seed);
869
1050
  return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
870
1051
  };
871
1052
 
872
- const contentRelationship = (config = {}) => {
873
- const faker = createFaker(config.seed);
1053
+ const contentRelationship = (config) => {
1054
+ var _a, _b;
1055
+ const faker = config.faker || createFaker(config.seed);
874
1056
  if (config.state === "empty") {
875
1057
  return {
876
1058
  link_type: prismicT__namespace.LinkType.Document
877
1059
  };
878
1060
  } else {
879
- const model = config.model || contentRelationship$1({ seed: config.seed });
1061
+ const model = config.model || contentRelationship$1({ faker });
880
1062
  const linkableDocuments = config.linkableDocuments ? config.linkableDocuments.filter((document2) => {
1063
+ var _a2, _b2;
881
1064
  let shouldKeep = true;
882
- if (model.config.customtypes) {
1065
+ if ((_a2 = model.config) == null ? void 0 : _a2.customtypes) {
883
1066
  shouldKeep = shouldKeep && model.config.customtypes.includes(document2.type);
884
1067
  }
885
- if (model.config.tags) {
1068
+ if ((_b2 = model.config) == null ? void 0 : _b2.tags) {
886
1069
  shouldKeep = shouldKeep && model.config.tags.some((tag) => document2.tags.includes(tag));
887
1070
  }
888
1071
  return shouldKeep;
889
1072
  }) : [
890
1073
  {
891
- ...customType({ seed: config.seed }),
892
- type: model.config.customtypes ? faker.randomElement(model.config.customtypes) : generateCustomTypeId({ seed: config.seed }),
893
- tags: model.config.tags ? faker.randomElements(model.config.tags) : generateTags({ seed: config.seed })
1074
+ ...customType({ faker }),
1075
+ type: ((_a = model.config) == null ? void 0 : _a.customtypes) ? faker.randomElement(model.config.customtypes) : generateCustomTypeId({ faker }),
1076
+ tags: ((_b = model.config) == null ? void 0 : _b.tags) ? faker.randomElements(model.config.tags) : generateTags({ faker })
894
1077
  }
895
1078
  ];
896
1079
  const document = faker.randomElement(linkableDocuments);
@@ -903,9 +1086,10 @@ const contentRelationship = (config = {}) => {
903
1086
  }
904
1087
  };
905
1088
 
906
- const date = (config = {}) => {
1089
+ const date = (config) => {
1090
+ const faker = config.faker || createFaker(config.seed);
907
1091
  return config.state === "empty" ? null : timestamp({
908
- seed: config.seed,
1092
+ faker,
909
1093
  after: config.after,
910
1094
  before: config.before,
911
1095
  state: "filled"
@@ -914,7 +1098,7 @@ const date = (config = {}) => {
914
1098
 
915
1099
  const buildEmbedField = (config) => {
916
1100
  var _a;
917
- const faker = createFaker(config.seed);
1101
+ const faker = config.faker || createFaker(config.seed);
918
1102
  return {
919
1103
  embed_url: (_a = config.url) != null ? _a : faker.url(),
920
1104
  html: `<div>embed html</div>`,
@@ -922,7 +1106,7 @@ const buildEmbedField = (config) => {
922
1106
  };
923
1107
  };
924
1108
 
925
- const dataSet$1 = [
1109
+ const dataSet = [
926
1110
  {
927
1111
  version: "1.0",
928
1112
  type: "video",
@@ -1002,41 +1186,43 @@ const dataSet$1 = [
1002
1186
  }
1003
1187
  ];
1004
1188
  const getMockEmbedData = (config) => {
1005
- const faker = createFaker(config.seed);
1006
- return faker.randomElement(dataSet$1);
1189
+ const faker = config.faker || createFaker(config.seed);
1190
+ return faker.randomElement(dataSet);
1007
1191
  };
1008
1192
 
1009
- const embed$1 = (config = {}) => {
1193
+ const embed$1 = (config) => {
1010
1194
  var _a, _b, _c;
1011
- const data = (_a = config.data) != null ? _a : getMockEmbedData({ seed: config.seed });
1195
+ const faker = config.faker || createFaker(config.seed);
1196
+ const data = (_a = config.data) != null ? _a : getMockEmbedData({ faker });
1012
1197
  return config.state === "empty" ? {} : buildEmbedField({
1013
- seed: config.seed,
1198
+ faker,
1014
1199
  url: (_b = config.url) != null ? _b : "embed_url" in data ? data.embed_url : void 0,
1015
1200
  html: (_c = config.html) != null ? _c : "html" in data ? data.html : void 0,
1016
1201
  data
1017
1202
  });
1018
1203
  };
1019
1204
 
1020
- const geoPoint = (config = {}) => {
1021
- const faker = createFaker(config.seed);
1205
+ const geoPoint = (config) => {
1206
+ const faker = config.faker || createFaker(config.seed);
1022
1207
  return config.state === "empty" ? {} : {
1023
1208
  longitude: faker.rangeFloat(-180, 180),
1024
1209
  latitude: faker.rangeFloat(-90, 90)
1025
1210
  };
1026
1211
  };
1027
1212
 
1028
- const group = (config = {}) => {
1213
+ const group = (config) => {
1029
1214
  var _a;
1030
1215
  if (config.state === "empty") {
1031
1216
  return [];
1032
1217
  } else {
1033
- const faker = createFaker(config.seed);
1034
- const model = config.model || group$1({ seed: config.seed });
1218
+ const faker = config.faker || createFaker(config.seed);
1219
+ const model = config.model || group$1({ faker });
1035
1220
  const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
1036
1221
  return Array(itemsCount).fill(void 0).map(() => {
1222
+ var _a2;
1037
1223
  return valueForModelMap({
1038
- seed: config.seed,
1039
- map: model.config.fields,
1224
+ faker,
1225
+ map: ((_a2 = model.config) == null ? void 0 : _a2.fields) || {},
1040
1226
  configs: config.configs
1041
1227
  });
1042
1228
  });
@@ -1053,7 +1239,7 @@ const buildImageFieldImage = (config) => {
1053
1239
  copyright: null
1054
1240
  };
1055
1241
  } else {
1056
- const faker = createFaker(config.seed);
1242
+ const faker = config.faker || createFaker(config.seed);
1057
1243
  const url = new URL(config.imageData.url);
1058
1244
  const dimensions = {
1059
1245
  width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
@@ -1071,136 +1257,46 @@ const buildImageFieldImage = (config) => {
1071
1257
  }
1072
1258
  };
1073
1259
 
1074
- const dataSet = [
1075
- {
1076
- url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
1077
- width: 4240,
1078
- height: 2832
1079
- },
1080
- {
1081
- url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
1082
- width: 7372,
1083
- height: 4392
1084
- },
1085
- {
1086
- url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
1087
- width: 2560,
1088
- height: 1705
1089
- },
1090
- {
1091
- url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
1092
- width: 2200,
1093
- height: 1467
1094
- },
1095
- {
1096
- url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
1097
- width: 5616,
1098
- height: 3744
1099
- },
1100
- {
1101
- url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
1102
- width: 4240,
1103
- height: 2832
1104
- },
1105
- {
1106
- url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
1107
- width: 2560,
1108
- height: 1440
1109
- },
1110
- {
1111
- url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
1112
- width: 6373,
1113
- height: 4253
1114
- },
1115
- {
1116
- url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
1117
- width: 4272,
1118
- height: 2848
1119
- },
1120
- {
1121
- url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
1122
- width: 4554,
1123
- height: 3036
1124
- },
1125
- {
1126
- url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
1127
- width: 6550,
1128
- height: 4367
1129
- },
1130
- {
1131
- url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
1132
- width: 6e3,
1133
- height: 4e3
1134
- },
1135
- {
1136
- url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
1137
- width: 6e3,
1138
- height: 4e3
1139
- },
1140
- {
1141
- url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
1142
- width: 4608,
1143
- height: 3456
1144
- },
1145
- {
1146
- url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
1147
- width: 4844,
1148
- height: 3234
1149
- },
1150
- {
1151
- url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
1152
- width: 4335,
1153
- height: 6502
1154
- }
1155
- ];
1156
- const getMockImageData = (config) => {
1157
- const faker = createFaker(config.seed);
1158
- return faker.randomElement(dataSet);
1159
- };
1160
-
1161
- const image$1 = (config = {}) => {
1162
- const model = config.model || image$2({ seed: config.seed });
1163
- const imageData = getMockImageData({ seed: config.seed });
1260
+ const image$1 = (config) => {
1261
+ var _a, _b;
1262
+ const faker = config.faker || createFaker(config.seed);
1263
+ const model = config.model || image$2({ faker });
1264
+ const imageData = getMockImageData({ faker });
1164
1265
  const value = buildImageFieldImage({
1165
- seed: config.seed,
1266
+ faker,
1166
1267
  imageData,
1167
- constraint: model.config.constraint,
1268
+ constraint: (_a = model.config) == null ? void 0 : _a.constraint,
1168
1269
  state: config.state
1169
1270
  });
1170
- for (const thumbnail of model.config.thumbnails) {
1171
- value[thumbnail.name] = buildImageFieldImage({
1172
- seed: config.seed,
1173
- imageData,
1174
- constraint: {
1175
- width: thumbnail.width,
1176
- height: thumbnail.height
1177
- },
1178
- state: config.state
1179
- });
1271
+ if ((_b = model.config) == null ? void 0 : _b.thumbnails) {
1272
+ for (const thumbnail of model.config.thumbnails) {
1273
+ value[thumbnail.name] = buildImageFieldImage({
1274
+ faker,
1275
+ imageData,
1276
+ constraint: {
1277
+ width: thumbnail.width,
1278
+ height: thumbnail.height
1279
+ },
1280
+ state: config.state
1281
+ });
1282
+ }
1180
1283
  }
1181
1284
  return value;
1182
1285
  };
1183
1286
 
1184
- const integrationFields = (config = {}) => {
1185
- const faker = createFaker(config.seed);
1186
- const imageData = getMockImageData({ seed: config.seed });
1187
- return config.state === "empty" ? null : {
1188
- id: faker.hash(7),
1189
- title: changeCase__namespace.capitalCase(faker.words(faker.range(1, 3))),
1190
- description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
1191
- image_url: imageData.url,
1192
- last_update: faker.date().getTime(),
1193
- blob: config.data
1194
- };
1287
+ const integrationFields = (config) => {
1288
+ var _a;
1289
+ const data = (_a = config.data) != null ? _a : {};
1290
+ return config.state === "empty" ? null : data;
1195
1291
  };
1196
1292
 
1197
- const keyText = (config = {}) => {
1198
- const faker = createFaker(config.seed);
1293
+ const keyText = (config) => {
1294
+ const faker = config.faker || createFaker(config.seed);
1199
1295
  return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.words(3));
1200
1296
  };
1201
1297
 
1202
- const linkToMedia = (config = {}) => {
1203
- const faker = createFaker(config.seed);
1298
+ const linkToMedia = (config) => {
1299
+ const faker = config.faker || createFaker(config.seed);
1204
1300
  if (config.state === "empty") {
1205
1301
  return {
1206
1302
  link_type: prismicT__namespace.LinkType.Media
@@ -1218,9 +1314,9 @@ const linkToMedia = (config = {}) => {
1218
1314
  }
1219
1315
  };
1220
1316
 
1221
- const link = (config = {}) => {
1222
- var _a;
1223
- const faker = createFaker(config.seed);
1317
+ const link = (config) => {
1318
+ var _a, _b;
1319
+ const faker = config.faker || createFaker(config.seed);
1224
1320
  const type = config.type || faker.randomElement([
1225
1321
  prismicT__namespace.LinkType.Web,
1226
1322
  prismicT__namespace.LinkType.Document,
@@ -1234,32 +1330,32 @@ const link = (config = {}) => {
1234
1330
  switch (type) {
1235
1331
  case prismicT__namespace.LinkType.Document: {
1236
1332
  return contentRelationship({
1237
- seed: config.seed,
1333
+ faker,
1238
1334
  state: config.state,
1239
1335
  linkableDocuments: config.linkableDocuments
1240
1336
  });
1241
1337
  }
1242
1338
  case prismicT__namespace.LinkType.Media: {
1243
1339
  return linkToMedia({
1244
- seed: config.seed,
1340
+ faker,
1245
1341
  state: config.state
1246
1342
  });
1247
1343
  }
1248
1344
  case prismicT__namespace.LinkType.Web:
1249
1345
  default: {
1250
- const model = config.model || link$1({ seed: config.seed });
1346
+ const model = config.model || link$1({ faker });
1251
1347
  return {
1252
1348
  link_type: prismicT__namespace.LinkType.Web,
1253
1349
  url: faker.url(),
1254
- target: ((_a = config.withTargetBlank) != null ? _a : model.config.allowTargetBlank && faker.boolean()) ? "_blank" : void 0
1350
+ target: ((_b = config.withTargetBlank) != null ? _b : ((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
1255
1351
  };
1256
1352
  }
1257
1353
  }
1258
1354
  }
1259
1355
  };
1260
1356
 
1261
- const number = (config = {}) => {
1262
- const faker = createFaker(config.seed);
1357
+ const number = (config) => {
1358
+ const faker = config.faker || createFaker(config.seed);
1263
1359
  return config.state === "empty" ? null : faker.range(1, 100);
1264
1360
  };
1265
1361
 
@@ -1277,17 +1373,25 @@ const patterns$5 = {
1277
1373
  maxWords: 12
1278
1374
  }
1279
1375
  };
1280
- const heading = (config = {}) => {
1281
- const faker = createFaker(config.seed);
1282
- const model = config.model || title$1({ seed: config.seed });
1283
- const types = ("single" in model.config ? model.config.single : model.config.multi).split(",").filter((type2) => [
1284
- prismicT__namespace.RichTextNodeType.heading1,
1285
- prismicT__namespace.RichTextNodeType.heading2,
1286
- prismicT__namespace.RichTextNodeType.heading3,
1287
- prismicT__namespace.RichTextNodeType.heading4,
1288
- prismicT__namespace.RichTextNodeType.heading5,
1289
- prismicT__namespace.RichTextNodeType.heading6
1290
- ].includes(type2));
1376
+ const headingNoteTypes = [
1377
+ prismicT__namespace.RichTextNodeType.heading1,
1378
+ prismicT__namespace.RichTextNodeType.heading2,
1379
+ prismicT__namespace.RichTextNodeType.heading3,
1380
+ prismicT__namespace.RichTextNodeType.heading4,
1381
+ prismicT__namespace.RichTextNodeType.heading5,
1382
+ prismicT__namespace.RichTextNodeType.heading6
1383
+ ];
1384
+ const heading = (config) => {
1385
+ const faker = config.faker || createFaker(config.seed);
1386
+ const model = config.model || title$1({ faker });
1387
+ let types = [];
1388
+ if (model.config) {
1389
+ if ("single" in model.config && model.config.single) {
1390
+ types = model.config.single.split(",").filter((type2) => headingNoteTypes.includes(type2));
1391
+ } else if ("multi" in model.config && model.config.multi) {
1392
+ types = model.config.multi.split(",").filter((type2) => headingNoteTypes.includes(type2));
1393
+ }
1394
+ }
1291
1395
  const type = faker.randomElement(types);
1292
1396
  if (type) {
1293
1397
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$5));
@@ -1313,8 +1417,8 @@ const patterns$4 = {
1313
1417
  sentenceCount: 12
1314
1418
  }
1315
1419
  };
1316
- const paragraph = (config = {}) => {
1317
- const faker = createFaker(config.seed);
1420
+ const paragraph = (config) => {
1421
+ const faker = config.faker || createFaker(config.seed);
1318
1422
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$4));
1319
1423
  const pattern = patterns$4[patternKey];
1320
1424
  const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
@@ -1336,8 +1440,8 @@ const patterns$3 = {
1336
1440
  sentenceCount: 12
1337
1441
  }
1338
1442
  };
1339
- const preformatted = (config = {}) => {
1340
- const faker = createFaker(config.seed);
1443
+ const preformatted = (config) => {
1444
+ const faker = config.faker || createFaker(config.seed);
1341
1445
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$3));
1342
1446
  const pattern = patterns$3[patternKey];
1343
1447
  const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
@@ -1362,8 +1466,8 @@ const patterns$2 = {
1362
1466
  maxItems: 12
1363
1467
  }
1364
1468
  };
1365
- const list = (config = {}) => {
1366
- const faker = createFaker(config.seed);
1469
+ const list = (config) => {
1470
+ const faker = config.faker || createFaker(config.seed);
1367
1471
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$2));
1368
1472
  const pattern = patterns$2[patternKey];
1369
1473
  const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
@@ -1390,8 +1494,8 @@ const patterns$1 = {
1390
1494
  maxItems: 12
1391
1495
  }
1392
1496
  };
1393
- const oList = (config = {}) => {
1394
- const faker = createFaker(config.seed);
1497
+ const oList = (config) => {
1498
+ const faker = config.faker || createFaker(config.seed);
1395
1499
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$1));
1396
1500
  const pattern = patterns$1[patternKey];
1397
1501
  const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
@@ -1404,10 +1508,11 @@ const oList = (config = {}) => {
1404
1508
  });
1405
1509
  };
1406
1510
 
1407
- const image = (config = {}) => {
1408
- const imageData = getMockImageData({ seed: config.seed });
1511
+ const image = (config) => {
1512
+ const faker = config.faker || createFaker(config.seed);
1513
+ const imageData = getMockImageData({ faker });
1409
1514
  const imageField = buildImageFieldImage({
1410
- seed: config.seed,
1515
+ faker,
1411
1516
  imageData,
1412
1517
  state: "filled"
1413
1518
  });
@@ -1420,9 +1525,10 @@ const image = (config = {}) => {
1420
1525
  };
1421
1526
  };
1422
1527
 
1423
- const embed = (config = {}) => {
1424
- const data = getMockEmbedData({ seed: config.seed });
1425
- const embedField = buildEmbedField({ seed: config.seed, data });
1528
+ const embed = (config) => {
1529
+ const faker = config.faker || createFaker(config.seed);
1530
+ const data = getMockEmbedData({ faker });
1531
+ const embedField = buildEmbedField({ faker, data });
1426
1532
  return {
1427
1533
  type: prismicT__namespace.RichTextNodeType.embed,
1428
1534
  oembed: embedField
@@ -1457,96 +1563,109 @@ const generators = {
1457
1563
  [prismicT__namespace.RichTextNodeType.image]: image,
1458
1564
  [prismicT__namespace.RichTextNodeType.embed]: embed
1459
1565
  };
1460
- const richText = (config = {}) => {
1461
- const faker = createFaker(config.seed);
1462
- const model = config.model || richText$1({
1463
- seed: config.seed,
1464
- withMultipleBlocks: true
1465
- });
1466
- const supportsMultipleBlocks = "multi" in model.config;
1467
- const types = ("multi" in model.config ? model.config.multi : model.config.single).split(",").filter((type) => Object.keys(generators).includes(type));
1468
- if (types.length > 0) {
1469
- const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
1470
- const pattern = patterns[patternKey];
1471
- const blockCount = supportsMultipleBlocks ? faker.range(pattern.blockCountMin, pattern.blockCountMax) : 1;
1472
- return Array(blockCount).fill(void 0).map(() => {
1473
- const type = faker.randomElement(types);
1474
- const generator = generators[type];
1475
- return generator({ seed: config.seed, model });
1476
- }).flat().filter((block) => block !== void 0).slice(0, blockCount);
1477
- } else {
1566
+ const richText = (config) => {
1567
+ const faker = config.faker || createFaker(config.seed);
1568
+ if (config.state === "empty") {
1478
1569
  return [];
1570
+ } else {
1571
+ const model = config.model || richText$1({
1572
+ faker,
1573
+ withMultipleBlocks: true
1574
+ });
1575
+ const supportsMultipleBlocks = model.config && "multi" in model.config;
1576
+ let types = [];
1577
+ if (model.config) {
1578
+ if ("multi" in model.config && model.config.multi) {
1579
+ types = model.config.multi.split(",").filter((type) => Object.keys(generators).includes(type));
1580
+ } else if ("single" in model.config && model.config.single) {
1581
+ types = model.config.single.split(",").filter((type) => Object.keys(generators).includes(type));
1582
+ }
1583
+ }
1584
+ if (types.length > 0) {
1585
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
1586
+ const pattern = patterns[patternKey];
1587
+ const blockCount = supportsMultipleBlocks ? faker.range(pattern.blockCountMin, pattern.blockCountMax) : 1;
1588
+ return Array(blockCount).fill(void 0).map(() => {
1589
+ const type = faker.randomElement(types);
1590
+ const generator = generators[type];
1591
+ return generator({ faker, model });
1592
+ }).flat().filter((block) => block !== void 0).slice(0, blockCount);
1593
+ } else {
1594
+ return [];
1595
+ }
1479
1596
  }
1480
1597
  };
1481
1598
 
1482
- const select = (config = {}) => {
1483
- const faker = createFaker(config.seed);
1484
- const model = config.model || select$1({ seed: config.seed });
1485
- const defaultValue = model.config.default_value;
1599
+ const select = (config) => {
1600
+ var _a, _b;
1601
+ const faker = config.faker || createFaker(config.seed);
1602
+ const model = config.model || select$1({ faker });
1603
+ const defaultValue = (_a = model.config) == null ? void 0 : _a.default_value;
1604
+ const options = ((_b = model.config) == null ? void 0 : _b.options) || [];
1486
1605
  if (config.state === "empty") {
1487
1606
  return null;
1488
1607
  } else {
1489
- return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(model.config.options);
1608
+ return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(options);
1490
1609
  }
1491
1610
  };
1492
1611
 
1493
- const slice = (config = {}) => {
1612
+ const slice = (config) => {
1494
1613
  var _a, _b;
1495
- const faker = createFaker(config.seed);
1496
- const model = config.model || slice$1({ seed: config.seed });
1497
- const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
1614
+ const faker = config.faker || createFaker(config.seed);
1615
+ const model = config.model || slice$1({ faker });
1616
+ const sliceType = (_a = config.type) != null ? _a : generateFieldId({ faker });
1498
1617
  const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
1499
- const itemsCount = Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1618
+ const itemsCount = model.repeat && Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1500
1619
  return {
1501
1620
  slice_type: sliceType,
1502
1621
  slice_label: sliceLabel,
1503
1622
  primary: valueForModelMap({
1504
- seed: config.seed,
1505
- map: model["non-repeat"],
1623
+ faker,
1624
+ map: model["non-repeat"] || {},
1506
1625
  configs: config.primaryFieldConfigs
1507
1626
  }),
1508
1627
  items: Array(itemsCount).fill(void 0).map(() => {
1509
1628
  return valueForModelMap({
1510
- seed: config.seed,
1511
- map: model.repeat,
1629
+ faker,
1630
+ map: model.repeat || {},
1512
1631
  configs: config.itemsFieldConfigs
1513
1632
  });
1514
1633
  })
1515
1634
  };
1516
1635
  };
1517
1636
 
1518
- const sharedSliceVariation = (config = {}) => {
1637
+ const sharedSliceVariation = (config) => {
1519
1638
  var _a, _b;
1520
- const faker = createFaker(config.seed);
1521
- const model = config.model || sharedSliceVariation$1({ seed: config.seed });
1522
- const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
1523
- const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1639
+ const faker = config.faker || createFaker(config.seed);
1640
+ const model = config.model || sharedSliceVariation$1({ faker });
1641
+ const sliceType = (_a = config.type) != null ? _a : generateFieldId({ faker });
1642
+ const itemsCount = model.items && Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1524
1643
  return {
1525
1644
  slice_type: sliceType,
1526
1645
  slice_label: null,
1527
1646
  variation: model.id,
1528
1647
  version: faker.hash(7),
1529
1648
  primary: valueForModelMap({
1530
- seed: config.seed,
1531
- map: model.primary,
1649
+ faker,
1650
+ map: model.primary || {},
1532
1651
  configs: config.primaryFieldConfigs
1533
1652
  }),
1534
1653
  items: Array(itemsCount).fill(void 0).map(() => {
1535
1654
  return valueForModelMap({
1536
- seed: config.seed,
1537
- map: model.items,
1655
+ faker,
1656
+ map: model.items || {},
1538
1657
  configs: config.itemsFieldConfigs
1539
1658
  });
1540
1659
  })
1541
1660
  };
1542
1661
  };
1543
1662
 
1544
- const sharedSlice = (config = {}) => {
1545
- const faker = createFaker(config.seed);
1546
- const model = config.model || sharedSlice$1({ seed: config.seed });
1663
+ const sharedSlice = (config) => {
1664
+ const faker = config.faker || createFaker(config.seed);
1665
+ const model = config.model || sharedSlice$1({ faker });
1547
1666
  const variationModel = faker.randomElement(model.variations);
1548
1667
  return sharedSliceVariation({
1549
- seed: config.seed,
1668
+ faker,
1550
1669
  model: variationModel,
1551
1670
  itemsCount: config.itemsCount,
1552
1671
  type: model.id,
@@ -1555,25 +1674,25 @@ const sharedSlice = (config = {}) => {
1555
1674
  });
1556
1675
  };
1557
1676
 
1558
- const sliceZone = (config = {}) => {
1559
- var _a;
1677
+ const sliceZone = (config) => {
1678
+ var _a, _b;
1560
1679
  if (config.state === "empty") {
1561
1680
  return [];
1562
1681
  } else {
1563
- const faker = createFaker(config.seed);
1564
- const model = config.model || sliceZone$1({ seed: config.seed });
1565
- if (Object.keys(model.config.choices).length > 0) {
1566
- const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
1682
+ const faker = config.faker || createFaker(config.seed);
1683
+ const model = config.model || sliceZone$1({ faker });
1684
+ if (((_a = model.config) == null ? void 0 : _a.choices) && Object.keys(model.config.choices).length > 0) {
1685
+ const itemsCount = (_b = config.itemsCount) != null ? _b : faker.range(1, 6);
1567
1686
  return Array(itemsCount).fill(void 0).map(() => {
1568
- var _a2;
1569
- const choices = Object.entries(model.config.choices);
1687
+ var _a2, _b2, _c, _d;
1688
+ const choices = ((_a2 = model.config) == null ? void 0 : _a2.choices) && Object.entries(model.config.choices) || [];
1570
1689
  const [choiceType, choiceModel] = faker.randomElement(choices);
1571
- const choiceLabels = model.config.labels[choiceType] || [];
1690
+ const choiceLabels = ((_c = (_b2 = model.config) == null ? void 0 : _b2.labels) == null ? void 0 : _c[choiceType]) || [];
1572
1691
  const choiceLabel = faker.randomElement(choiceLabels);
1573
1692
  switch (choiceModel.type) {
1574
1693
  case prismicT__namespace.CustomTypeModelSliceType.Slice: {
1575
1694
  return slice({
1576
- seed: config.seed,
1695
+ faker,
1577
1696
  model: choiceModel,
1578
1697
  type: choiceType,
1579
1698
  label: choiceLabel ? choiceLabel.name : null,
@@ -1582,10 +1701,10 @@ const sliceZone = (config = {}) => {
1582
1701
  });
1583
1702
  }
1584
1703
  case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
1585
- const sharedSliceModel = (_a2 = config.sharedSliceModels) == null ? void 0 : _a2.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
1704
+ const sharedSliceModel = (_d = config.sharedSliceModels) == null ? void 0 : _d.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
1586
1705
  if (sharedSliceModel) {
1587
1706
  return sharedSlice({
1588
- seed: config.seed,
1707
+ faker,
1589
1708
  model: sharedSliceModel,
1590
1709
  primaryFieldConfigs: config.primaryFieldConfigs,
1591
1710
  itemsFieldConfigs: config.itemsFieldConfigs
@@ -1600,13 +1719,14 @@ const sliceZone = (config = {}) => {
1600
1719
  }
1601
1720
  };
1602
1721
 
1603
- const title = (config = {}) => {
1722
+ const title = (config) => {
1723
+ const faker = config.faker || createFaker(config.seed);
1604
1724
  if (config.state === "empty") {
1605
1725
  return [];
1606
1726
  } else {
1607
1727
  return [
1608
1728
  heading({
1609
- seed: config.seed,
1729
+ faker,
1610
1730
  model: config.model,
1611
1731
  pattern: config.pattern
1612
1732
  })
@@ -1614,8 +1734,8 @@ const title = (config = {}) => {
1614
1734
  }
1615
1735
  };
1616
1736
 
1617
- const uid = (config = {}) => {
1618
- const faker = createFaker(config.seed);
1737
+ const uid = (config) => {
1738
+ const faker = config.faker || createFaker(config.seed);
1619
1739
  return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
1620
1740
  };
1621
1741
 
@@ -1647,9 +1767,9 @@ const index$1 = /*#__PURE__*/Object.freeze({
1647
1767
  uid: uid
1648
1768
  });
1649
1769
 
1650
- const ref = (config = {}) => {
1770
+ const ref = (config) => {
1651
1771
  var _a;
1652
- const faker = createFaker(config.seed);
1772
+ const faker = config.faker || createFaker(config.seed);
1653
1773
  const value = {
1654
1774
  id: faker.hash(16),
1655
1775
  ref: faker.hash(16),
@@ -1657,23 +1777,23 @@ const ref = (config = {}) => {
1657
1777
  label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.words(faker.range(1, 3)))
1658
1778
  };
1659
1779
  if (config.isScheduled) {
1660
- value.scheduledAt = timestamp({ seed: config.seed });
1780
+ value.scheduledAt = timestamp({ faker });
1661
1781
  }
1662
1782
  return value;
1663
1783
  };
1664
1784
 
1665
- const repository = (config = {}) => {
1666
- const faker = createFaker(config.seed);
1785
+ const repository = (config) => {
1786
+ const faker = config.faker || createFaker(config.seed);
1667
1787
  const types = (config.customTypeModels || []).reduce((acc, model) => {
1668
- acc[model.id] = model.label;
1788
+ acc[model.id] = model.label || model.id;
1669
1789
  return acc;
1670
1790
  }, {});
1671
1791
  return {
1672
1792
  refs: [
1673
- ref({ seed: config.seed, isMasterRef: true }),
1674
- ...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
1793
+ ref({ faker, isMasterRef: true }),
1794
+ ...config.withReleases ? [ref({ faker }), ref({ faker })] : []
1675
1795
  ],
1676
- integrationFieldsRef: ref({ seed: config.seed }).ref,
1796
+ integrationFieldsRef: ref({ faker }).ref,
1677
1797
  types,
1678
1798
  languages: [
1679
1799
  {
@@ -1682,7 +1802,7 @@ const repository = (config = {}) => {
1682
1802
  }
1683
1803
  ],
1684
1804
  tags: generateTags({
1685
- seed: config.seed,
1805
+ faker,
1686
1806
  min: 1,
1687
1807
  max: 10
1688
1808
  }),
@@ -1696,9 +1816,9 @@ const repository = (config = {}) => {
1696
1816
  };
1697
1817
  };
1698
1818
 
1699
- const query = (config = {}) => {
1819
+ const query = (config) => {
1700
1820
  var _a, _b;
1701
- const faker = createFaker(config.seed);
1821
+ const faker = config.faker || createFaker(config.seed);
1702
1822
  const documents = config.documents || [];
1703
1823
  const page = Math.max(1, (_a = config.page) != null ? _a : 1);
1704
1824
  const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
@@ -1716,9 +1836,10 @@ const query = (config = {}) => {
1716
1836
  };
1717
1837
  };
1718
1838
 
1719
- const tags = (config = {}) => {
1839
+ const tags = (config) => {
1840
+ const faker = config.faker || createFaker(config.seed);
1720
1841
  return generateTags({
1721
- seed: config.seed,
1842
+ faker,
1722
1843
  min: 1,
1723
1844
  max: 10
1724
1845
  });
@@ -1732,7 +1853,138 @@ const index = /*#__PURE__*/Object.freeze({
1732
1853
  tags: tags
1733
1854
  });
1734
1855
 
1856
+ const createValueMockFactory = (...args) => {
1857
+ return new ValueMockFactory(...args);
1858
+ };
1859
+ class ValueMockFactory {
1860
+ constructor(config) {
1861
+ this.faker = "faker" in config ? config.faker : createFaker(config.seed);
1862
+ }
1863
+ get seed() {
1864
+ return this.faker.seed;
1865
+ }
1866
+ boolean(config) {
1867
+ return boolean$1({ ...config, faker: this.faker });
1868
+ }
1869
+ color(config) {
1870
+ return color({ ...config, faker: this.faker });
1871
+ }
1872
+ contentRelationship(config) {
1873
+ return contentRelationship({ ...config, faker: this.faker });
1874
+ }
1875
+ customType(config) {
1876
+ return customType({ ...config, faker: this.faker });
1877
+ }
1878
+ date(config) {
1879
+ return date({ ...config, faker: this.faker });
1880
+ }
1881
+ document(config) {
1882
+ return customType({ ...config, faker: this.faker });
1883
+ }
1884
+ embed(config) {
1885
+ return embed$1({ ...config, faker: this.faker });
1886
+ }
1887
+ geoPoint(config) {
1888
+ return geoPoint({ ...config, faker: this.faker });
1889
+ }
1890
+ group(config) {
1891
+ return group({ ...config, faker: this.faker });
1892
+ }
1893
+ image(config) {
1894
+ return image$1({ ...config, faker: this.faker });
1895
+ }
1896
+ integrationFields(config) {
1897
+ return integrationFields({ ...config, faker: this.faker });
1898
+ }
1899
+ keyText(config) {
1900
+ return keyText({ ...config, faker: this.faker });
1901
+ }
1902
+ link(config) {
1903
+ return link({ ...config, faker: this.faker });
1904
+ }
1905
+ linkToMedia(config) {
1906
+ return linkToMedia({ ...config, faker: this.faker });
1907
+ }
1908
+ number(config) {
1909
+ return number({ ...config, faker: this.faker });
1910
+ }
1911
+ select(config) {
1912
+ return select({ ...config, faker: this.faker });
1913
+ }
1914
+ sharedSlice(config) {
1915
+ return sharedSlice({ ...config, faker: this.faker });
1916
+ }
1917
+ sharedSliceVariation(config) {
1918
+ return sharedSliceVariation({ ...config, faker: this.faker });
1919
+ }
1920
+ slice(config) {
1921
+ return slice({ ...config, faker: this.faker });
1922
+ }
1923
+ sliceZone(config) {
1924
+ return sliceZone({ ...config, faker: this.faker });
1925
+ }
1926
+ timestamp(config) {
1927
+ return timestamp({ ...config, faker: this.faker });
1928
+ }
1929
+ title(config) {
1930
+ return title({ ...config, faker: this.faker });
1931
+ }
1932
+ uid(config) {
1933
+ return uid({ ...config, faker: this.faker });
1934
+ }
1935
+ richText(config) {
1936
+ return richText({ ...config, faker: this.faker });
1937
+ }
1938
+ }
1939
+
1940
+ const createAPIMockFactory = (...args) => {
1941
+ return new APIMockFactory(...args);
1942
+ };
1943
+ class APIMockFactory {
1944
+ constructor(config) {
1945
+ this.faker = "faker" in config ? config.faker : createFaker(config.seed);
1946
+ }
1947
+ get seed() {
1948
+ return this.faker.seed;
1949
+ }
1950
+ query(config) {
1951
+ return query({ ...config, faker: this.faker });
1952
+ }
1953
+ ref(config) {
1954
+ return ref({ ...config, faker: this.faker });
1955
+ }
1956
+ repository(config) {
1957
+ return repository({ ...config, faker: this.faker });
1958
+ }
1959
+ tags(config) {
1960
+ return tags({ ...config, faker: this.faker });
1961
+ }
1962
+ }
1963
+
1964
+ const createMockFactory = (...args) => {
1965
+ return new MockFactory(...args);
1966
+ };
1967
+ class MockFactory {
1968
+ constructor(config) {
1969
+ this.faker = config.faker || createFaker(config.seed);
1970
+ this.api = createAPIMockFactory({ faker: this.faker });
1971
+ this.model = createModelMockFactory({ faker: this.faker });
1972
+ this.value = createValueMockFactory({ faker: this.faker });
1973
+ }
1974
+ get seed() {
1975
+ return this.faker.seed;
1976
+ }
1977
+ }
1978
+
1979
+ exports.APIMockFactory = APIMockFactory;
1980
+ exports.MockFactory = MockFactory;
1981
+ exports.ModelMockFactory = ModelMockFactory;
1982
+ exports.ValueMockFactory = ValueMockFactory;
1735
1983
  exports.api = index;
1984
+ exports.createAPIMockFactory = createAPIMockFactory;
1985
+ exports.createMockFactory = createMockFactory;
1986
+ exports.createModelMockFactory = createModelMockFactory;
1987
+ exports.createValueMockFactory = createValueMockFactory;
1736
1988
  exports.model = index$2;
1737
1989
  exports.value = index$1;
1738
1990
  //# sourceMappingURL=index.cjs.map