@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.js CHANGED
@@ -2,8 +2,6 @@ import * as changeCase from 'change-case';
2
2
  import Rand from 'rand-seed';
3
3
  import * as prismicT from '@prismicio/types';
4
4
 
5
- const FAKER_SEED = 1984;
6
-
7
5
  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";
8
6
  const loremWords = wordsString.split(" ");
9
7
  const lorem = (length, wordOffset = 0) => {
@@ -45,22 +43,16 @@ const lorem = (length, wordOffset = 0) => {
45
43
  };
46
44
  lorem.spaceIndices = [];
47
45
 
48
- const createFaker = (seed = FAKER_SEED) => {
49
- const normalizedSeed = seed.toString();
50
- if (createFaker.cache[normalizedSeed]) {
51
- return createFaker.cache[normalizedSeed];
52
- } else {
53
- const faker = new Faker(normalizedSeed);
54
- return createFaker.cache[normalizedSeed] = faker;
55
- }
46
+ const createFaker = (seed) => {
47
+ return new Faker(seed);
56
48
  };
57
- createFaker.cache = {};
58
49
  const DAY_MS = 1e3 * 60 * 60 * 24;
59
50
  const YEAR_MS = DAY_MS * 365;
60
51
  const YEAR_2022_MS = 52 * (YEAR_MS + DAY_MS / 4);
61
52
  class Faker {
62
53
  constructor(seed) {
63
- this.rand = new Rand(seed);
54
+ this.seed = seed;
55
+ this.rand = new Rand(seed.toString());
64
56
  }
65
57
  boolean() {
66
58
  return this.random() >= 0.5;
@@ -72,7 +64,8 @@ class Faker {
72
64
  return elements[this.range(0, elements.length)];
73
65
  }
74
66
  randomElements(elements) {
75
- return elements.filter(() => this.boolean());
67
+ const alwaysInclude = this.randomElement(elements);
68
+ return elements.filter((element) => element === alwaysInclude || this.boolean());
76
69
  }
77
70
  range(min, max) {
78
71
  return Math.floor(this.rangeFloat(Math.ceil(min), Math.floor(max)));
@@ -121,51 +114,53 @@ class Faker {
121
114
 
122
115
  const generateTags = (config) => {
123
116
  var _a, _b;
124
- const faker = createFaker(config.seed);
117
+ const faker = config.faker || createFaker(config.seed);
125
118
  return Array.from({ length: faker.range((_a = config.min) != null ? _a : 0, (_b = config.max) != null ? _b : 2) }, () => changeCase.capitalCase(faker.words(faker.range(1, 3))));
126
119
  };
127
120
 
128
- const boolean$1 = (config = {}) => {
129
- const faker = createFaker(config.seed);
121
+ const boolean$1 = (config) => {
122
+ const faker = config.faker || createFaker(config.seed);
130
123
  return faker.boolean();
131
124
  };
132
125
 
133
126
  const valueForModel = (config) => {
127
+ var _a;
128
+ const faker = config.faker || createFaker(config.seed);
134
129
  const model = config.model;
135
130
  switch (model.type) {
136
131
  case prismicT.CustomTypeModelFieldType.Boolean: {
137
132
  return boolean$1({
138
- seed: config.seed,
133
+ faker,
139
134
  model,
140
135
  ...config.config
141
136
  });
142
137
  }
143
138
  case prismicT.CustomTypeModelFieldType.Color: {
144
139
  return color({
145
- seed: config.seed,
140
+ faker,
146
141
  model,
147
142
  ...config.config
148
143
  });
149
144
  }
150
145
  case prismicT.CustomTypeModelFieldType.Link: {
151
- switch (model.config.select) {
146
+ switch ((_a = model.config) == null ? void 0 : _a.select) {
152
147
  case prismicT.CustomTypeModelLinkSelectType.Document: {
153
148
  return contentRelationship({
154
- seed: config.seed,
149
+ faker,
155
150
  model,
156
151
  ...config.config
157
152
  });
158
153
  }
159
154
  case prismicT.CustomTypeModelLinkSelectType.Media: {
160
155
  return linkToMedia({
161
- seed: config.seed,
156
+ faker,
162
157
  model,
163
158
  ...config.config
164
159
  });
165
160
  }
166
161
  default: {
167
162
  return link({
168
- seed: config.seed,
163
+ faker,
169
164
  model,
170
165
  ...config.config
171
166
  });
@@ -174,70 +169,70 @@ const valueForModel = (config) => {
174
169
  }
175
170
  case prismicT.CustomTypeModelFieldType.Date: {
176
171
  return date({
177
- seed: config.seed,
172
+ faker,
178
173
  model,
179
174
  ...config.config
180
175
  });
181
176
  }
182
177
  case prismicT.CustomTypeModelFieldType.Embed: {
183
178
  return embed$1({
184
- seed: config.seed,
179
+ faker,
185
180
  model,
186
181
  ...config.config
187
182
  });
188
183
  }
189
184
  case prismicT.CustomTypeModelFieldType.GeoPoint: {
190
185
  return geoPoint({
191
- seed: config.seed,
186
+ faker,
192
187
  model,
193
188
  ...config.config
194
189
  });
195
190
  }
196
191
  case prismicT.CustomTypeModelFieldType.Image: {
197
192
  return image$1({
198
- seed: config.seed,
193
+ faker,
199
194
  model,
200
195
  ...config.config
201
196
  });
202
197
  }
203
198
  case prismicT.CustomTypeModelFieldType.Text: {
204
199
  return keyText({
205
- seed: config.seed,
200
+ faker,
206
201
  model,
207
202
  ...config.config
208
203
  });
209
204
  }
210
205
  case prismicT.CustomTypeModelFieldType.Number: {
211
206
  return number({
212
- seed: config.seed,
207
+ faker,
213
208
  model,
214
209
  ...config.config
215
210
  });
216
211
  }
217
212
  case prismicT.CustomTypeModelFieldType.Select: {
218
213
  return select({
219
- seed: config.seed,
214
+ faker,
220
215
  model,
221
216
  ...config.config
222
217
  });
223
218
  }
224
219
  case prismicT.CustomTypeModelFieldType.Timestamp: {
225
220
  return timestamp({
226
- seed: config.seed,
221
+ faker,
227
222
  model,
228
223
  ...config.config
229
224
  });
230
225
  }
231
226
  case prismicT.CustomTypeModelFieldType.StructuredText: {
232
- if ("single" in model.config && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
227
+ if (model.config && "single" in model.config && model.config.single && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
233
228
  return title({
234
- seed: config.seed,
229
+ faker,
235
230
  model,
236
231
  ...config.config
237
232
  });
238
233
  } else {
239
234
  return richText({
240
- seed: config.seed,
235
+ faker,
241
236
  model,
242
237
  ...config.config
243
238
  });
@@ -245,36 +240,41 @@ const valueForModel = (config) => {
245
240
  }
246
241
  case prismicT.CustomTypeModelFieldType.IntegrationFields: {
247
242
  return integrationFields({
248
- seed: config.seed,
243
+ faker,
249
244
  model,
250
245
  ...config.config
251
246
  });
252
247
  }
253
248
  case prismicT.CustomTypeModelFieldType.UID: {
254
249
  return uid({
255
- seed: config.seed,
250
+ faker,
256
251
  model,
257
252
  ...config.config
258
253
  });
259
254
  }
260
255
  case prismicT.CustomTypeModelFieldType.Group: {
261
256
  return group({
262
- seed: config.seed,
257
+ faker,
263
258
  model,
264
259
  ...config.config
265
260
  });
266
261
  }
262
+ case prismicT.CustomTypeModelFieldType.LegacySlices:
267
263
  case prismicT.CustomTypeModelFieldType.Slices: {
268
264
  return sliceZone({
269
- seed: config.seed,
265
+ faker,
270
266
  model,
271
267
  ...config.config
272
268
  });
273
269
  }
270
+ default: {
271
+ throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
272
+ }
274
273
  }
275
274
  };
276
275
 
277
276
  const getValueConfigType = (model) => {
277
+ var _a;
278
278
  switch (model.type) {
279
279
  case prismicT.CustomTypeModelFieldType.Boolean:
280
280
  return "boolean";
@@ -291,7 +291,7 @@ const getValueConfigType = (model) => {
291
291
  case prismicT.CustomTypeModelFieldType.Image:
292
292
  return "image";
293
293
  case prismicT.CustomTypeModelFieldType.Link: {
294
- switch (model.config.select) {
294
+ switch ((_a = model.config) == null ? void 0 : _a.select) {
295
295
  case prismicT.CustomTypeModelLinkSelectType.Document:
296
296
  return "contentRelationship";
297
297
  case prismicT.CustomTypeModelLinkSelectType.Media:
@@ -305,7 +305,7 @@ const getValueConfigType = (model) => {
305
305
  case prismicT.CustomTypeModelFieldType.Select:
306
306
  return "select";
307
307
  case prismicT.CustomTypeModelFieldType.StructuredText: {
308
- if ("single" in model.config && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
308
+ if (model.config && "single" in model.config && model.config.single && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
309
309
  return "title";
310
310
  } else {
311
311
  return "richText";
@@ -321,17 +321,21 @@ const getValueConfigType = (model) => {
321
321
  return "integrationFields";
322
322
  case prismicT.CustomTypeModelFieldType.Slices:
323
323
  return "sliceZone";
324
+ default: {
325
+ throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
326
+ }
324
327
  }
325
328
  };
326
329
  const valueForModelMap = (config) => {
327
330
  var _a;
331
+ const faker = config.faker || createFaker(config.seed);
328
332
  const result = {};
329
333
  for (const fieldId in config.map) {
330
334
  const fieldModel = config.map[fieldId];
331
335
  const fieldConfigType = getValueConfigType(fieldModel);
332
336
  const fieldConfig = (_a = config.configs) == null ? void 0 : _a[fieldConfigType];
333
337
  result[fieldId] = valueForModel({
334
- seed: config.seed,
338
+ faker,
335
339
  model: fieldModel,
336
340
  config: fieldConfig
337
341
  });
@@ -339,18 +343,18 @@ const valueForModelMap = (config) => {
339
343
  return result;
340
344
  };
341
345
 
342
- const boolean = (config = {}) => {
343
- const faker = createFaker(config.seed);
346
+ function boolean(config) {
347
+ const faker = config.faker || createFaker(config.seed);
344
348
  return {
345
349
  type: prismicT.CustomTypeModelFieldType.Boolean,
346
350
  config: {
347
351
  label: changeCase.capitalCase(faker.word())
348
352
  }
349
353
  };
350
- };
354
+ }
351
355
 
352
- const color$1 = (config = {}) => {
353
- const faker = createFaker(config.seed);
356
+ const color$1 = (config) => {
357
+ const faker = config.faker || createFaker(config.seed);
354
358
  return {
355
359
  type: prismicT.CustomTypeModelFieldType.Color,
356
360
  config: {
@@ -360,8 +364,8 @@ const color$1 = (config = {}) => {
360
364
  };
361
365
  };
362
366
 
363
- const contentRelationship$1 = (config = {}) => {
364
- const faker = createFaker(config.seed);
367
+ const contentRelationship$1 = (config) => {
368
+ const faker = config.faker || createFaker(config.seed);
365
369
  return {
366
370
  type: prismicT.CustomTypeModelFieldType.Link,
367
371
  config: {
@@ -374,9 +378,9 @@ const contentRelationship$1 = (config = {}) => {
374
378
  };
375
379
  };
376
380
 
377
- const customType$1 = (config = {}) => {
381
+ const customType$1 = (config) => {
378
382
  var _a, _b;
379
- const faker = createFaker(config.seed);
383
+ const faker = config.faker || createFaker(config.seed);
380
384
  let label = config.label || changeCase.capitalCase(faker.words(faker.range(1, 2)));
381
385
  let id = config.id || changeCase.snakeCase(label);
382
386
  if (config.id && !config.label) {
@@ -399,8 +403,8 @@ const customType$1 = (config = {}) => {
399
403
  };
400
404
  };
401
405
 
402
- const date$1 = (config = {}) => {
403
- const faker = createFaker(config.seed);
406
+ const date$1 = (config) => {
407
+ const faker = config.faker || createFaker(config.seed);
404
408
  return {
405
409
  type: prismicT.CustomTypeModelFieldType.Date,
406
410
  config: {
@@ -410,8 +414,8 @@ const date$1 = (config = {}) => {
410
414
  };
411
415
  };
412
416
 
413
- const embed$2 = (config = {}) => {
414
- const faker = createFaker(config.seed);
417
+ const embed$2 = (config) => {
418
+ const faker = config.faker || createFaker(config.seed);
415
419
  return {
416
420
  type: prismicT.CustomTypeModelFieldType.Embed,
417
421
  config: {
@@ -421,8 +425,8 @@ const embed$2 = (config = {}) => {
421
425
  };
422
426
  };
423
427
 
424
- const geoPoint$1 = (config = {}) => {
425
- const faker = createFaker(config.seed);
428
+ const geoPoint$1 = (config) => {
429
+ const faker = config.faker || createFaker(config.seed);
426
430
  return {
427
431
  type: prismicT.CustomTypeModelFieldType.GeoPoint,
428
432
  config: {
@@ -431,8 +435,8 @@ const geoPoint$1 = (config = {}) => {
431
435
  };
432
436
  };
433
437
 
434
- const group$1 = (config = {}) => {
435
- const faker = createFaker(config.seed);
438
+ function group$1(config) {
439
+ const faker = config.faker || createFaker(config.seed);
436
440
  return {
437
441
  type: prismicT.CustomTypeModelFieldType.Group,
438
442
  config: {
@@ -440,10 +444,10 @@ const group$1 = (config = {}) => {
440
444
  fields: config.fields || {}
441
445
  }
442
446
  };
443
- };
447
+ }
444
448
 
445
- const image$2 = (config = {}) => {
446
- const faker = createFaker(config.seed);
449
+ const image$2 = (config) => {
450
+ const faker = config.faker || createFaker(config.seed);
447
451
  const thumbnails = (config.thumbnailNames || []).map((name) => {
448
452
  return {
449
453
  name,
@@ -464,8 +468,8 @@ const image$2 = (config = {}) => {
464
468
  };
465
469
  };
466
470
 
467
- const integrationFields$1 = (config = {}) => {
468
- const faker = createFaker(config.seed);
471
+ const integrationFields$1 = (config) => {
472
+ const faker = config.faker || createFaker(config.seed);
469
473
  return {
470
474
  type: prismicT.CustomTypeModelFieldType.IntegrationFields,
471
475
  config: {
@@ -475,8 +479,8 @@ const integrationFields$1 = (config = {}) => {
475
479
  };
476
480
  };
477
481
 
478
- const keyText$1 = (config = {}) => {
479
- const faker = createFaker(config.seed);
482
+ const keyText$1 = (config) => {
483
+ const faker = config.faker || createFaker(config.seed);
480
484
  return {
481
485
  type: prismicT.CustomTypeModelFieldType.Text,
482
486
  config: {
@@ -486,8 +490,8 @@ const keyText$1 = (config = {}) => {
486
490
  };
487
491
  };
488
492
 
489
- const link$1 = (config = {}) => {
490
- const faker = createFaker(config.seed);
493
+ const link$1 = (config) => {
494
+ const faker = config.faker || createFaker(config.seed);
491
495
  return {
492
496
  type: prismicT.CustomTypeModelFieldType.Link,
493
497
  config: {
@@ -499,8 +503,8 @@ const link$1 = (config = {}) => {
499
503
  };
500
504
  };
501
505
 
502
- const linkToMedia$1 = (config = {}) => {
503
- const faker = createFaker(config.seed);
506
+ const linkToMedia$1 = (config) => {
507
+ const faker = config.faker || createFaker(config.seed);
504
508
  return {
505
509
  type: prismicT.CustomTypeModelFieldType.Link,
506
510
  config: {
@@ -511,8 +515,8 @@ const linkToMedia$1 = (config = {}) => {
511
515
  };
512
516
  };
513
517
 
514
- const number$1 = (config = {}) => {
515
- const faker = createFaker(config.seed);
518
+ const number$1 = (config) => {
519
+ const faker = config.faker || createFaker(config.seed);
516
520
  return {
517
521
  type: prismicT.CustomTypeModelFieldType.Number,
518
522
  config: {
@@ -522,9 +526,9 @@ const number$1 = (config = {}) => {
522
526
  };
523
527
  };
524
528
 
525
- const richText$1 = (config = {}) => {
529
+ const richText$1 = (config) => {
526
530
  var _a;
527
- const faker = createFaker(config.seed);
531
+ const faker = config.faker || createFaker(config.seed);
528
532
  const blockTypes = faker.randomElements([
529
533
  prismicT.RichTextNodeType.heading1,
530
534
  prismicT.RichTextNodeType.heading2,
@@ -554,8 +558,8 @@ const richText$1 = (config = {}) => {
554
558
  };
555
559
  };
556
560
 
557
- const select$1 = (config = {}) => {
558
- const faker = createFaker(config.seed);
561
+ const select$1 = (config) => {
562
+ const faker = config.faker || createFaker(config.seed);
559
563
  return {
560
564
  type: prismicT.CustomTypeModelFieldType.Select,
561
565
  config: {
@@ -567,8 +571,8 @@ const select$1 = (config = {}) => {
567
571
  };
568
572
  };
569
573
 
570
- const sharedSlice$1 = (config = {}) => {
571
- const faker = createFaker(config.seed);
574
+ const sharedSlice$1 = (config) => {
575
+ const faker = config.faker || createFaker(config.seed);
572
576
  let name = config.name || changeCase.capitalCase(faker.words(faker.range(1, 2)));
573
577
  let id = config.id || changeCase.snakeCase(name);
574
578
  if (config.id && !config.name) {
@@ -591,8 +595,95 @@ const sharedSliceChoice = () => {
591
595
  };
592
596
  };
593
597
 
594
- const sharedSliceVariation$1 = (config = {}) => {
595
- const faker = createFaker(config.seed);
598
+ const dataSet$1 = [
599
+ {
600
+ url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
601
+ width: 4240,
602
+ height: 2832
603
+ },
604
+ {
605
+ url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
606
+ width: 7372,
607
+ height: 4392
608
+ },
609
+ {
610
+ url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
611
+ width: 2560,
612
+ height: 1705
613
+ },
614
+ {
615
+ url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
616
+ width: 2200,
617
+ height: 1467
618
+ },
619
+ {
620
+ url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
621
+ width: 5616,
622
+ height: 3744
623
+ },
624
+ {
625
+ url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
626
+ width: 4240,
627
+ height: 2832
628
+ },
629
+ {
630
+ url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
631
+ width: 2560,
632
+ height: 1440
633
+ },
634
+ {
635
+ url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
636
+ width: 6373,
637
+ height: 4253
638
+ },
639
+ {
640
+ url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
641
+ width: 4272,
642
+ height: 2848
643
+ },
644
+ {
645
+ url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
646
+ width: 4554,
647
+ height: 3036
648
+ },
649
+ {
650
+ url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
651
+ width: 6550,
652
+ height: 4367
653
+ },
654
+ {
655
+ url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
656
+ width: 6e3,
657
+ height: 4e3
658
+ },
659
+ {
660
+ url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
661
+ width: 6e3,
662
+ height: 4e3
663
+ },
664
+ {
665
+ url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
666
+ width: 4608,
667
+ height: 3456
668
+ },
669
+ {
670
+ url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
671
+ width: 4844,
672
+ height: 3234
673
+ },
674
+ {
675
+ url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
676
+ width: 4335,
677
+ height: 6502
678
+ }
679
+ ];
680
+ const getMockImageData = (config) => {
681
+ const faker = config.faker || createFaker(config.seed);
682
+ return faker.randomElement(dataSet$1);
683
+ };
684
+
685
+ const sharedSliceVariation$1 = (config) => {
686
+ const faker = config.faker || createFaker(config.seed);
596
687
  let name = config.name || changeCase.capitalCase(faker.words(faker.range(1, 2)));
597
688
  let id = config.id || changeCase.snakeCase(name);
598
689
  if (config.id && !config.name) {
@@ -600,6 +691,7 @@ const sharedSliceVariation$1 = (config = {}) => {
600
691
  } else if (config.name && !config.name) {
601
692
  id = changeCase.snakeCase(config.name);
602
693
  }
694
+ const imageData = getMockImageData({ faker });
603
695
  return {
604
696
  id,
605
697
  name,
@@ -607,12 +699,13 @@ const sharedSliceVariation$1 = (config = {}) => {
607
699
  docURL: faker.url(),
608
700
  version: faker.hash(7),
609
701
  primary: config.primaryFields || {},
610
- items: config.itemsFields || {}
702
+ items: config.itemsFields || {},
703
+ imageUrl: imageData.url
611
704
  };
612
705
  };
613
706
 
614
- const slice$1 = (config = {}) => {
615
- const faker = createFaker(config.seed);
707
+ const slice$1 = (config) => {
708
+ const faker = config.faker || createFaker(config.seed);
616
709
  return {
617
710
  type: prismicT.CustomTypeModelSliceType.Slice,
618
711
  icon: changeCase.snakeCase(faker.word()),
@@ -624,7 +717,7 @@ const slice$1 = (config = {}) => {
624
717
  };
625
718
  };
626
719
 
627
- const sliceZone$1 = (config = {}) => {
720
+ const sliceZone$1 = (config) => {
628
721
  const labels = {};
629
722
  for (const choiceId in config.choices) {
630
723
  const choice = config.choices[choiceId];
@@ -642,8 +735,8 @@ const sliceZone$1 = (config = {}) => {
642
735
  };
643
736
  };
644
737
 
645
- const timestamp$1 = (config = {}) => {
646
- const faker = createFaker(config.seed);
738
+ const timestamp$1 = (config) => {
739
+ const faker = config.faker || createFaker(config.seed);
647
740
  return {
648
741
  type: prismicT.CustomTypeModelFieldType.Timestamp,
649
742
  config: {
@@ -653,8 +746,8 @@ const timestamp$1 = (config = {}) => {
653
746
  };
654
747
  };
655
748
 
656
- const title$1 = (config = {}) => {
657
- const faker = createFaker(config.seed);
749
+ const title$1 = (config) => {
750
+ const faker = config.faker || createFaker(config.seed);
658
751
  const single = faker.randomElements([
659
752
  "heading1",
660
753
  "heading2",
@@ -674,8 +767,8 @@ const title$1 = (config = {}) => {
674
767
  };
675
768
  };
676
769
 
677
- const uid$1 = (config = {}) => {
678
- const faker = createFaker(config.seed);
770
+ const uid$1 = (config) => {
771
+ const faker = config.faker || createFaker(config.seed);
679
772
  return {
680
773
  type: prismicT.CustomTypeModelFieldType.UID,
681
774
  config: {
@@ -686,7 +779,7 @@ const uid$1 = (config = {}) => {
686
779
  };
687
780
 
688
781
  const generateFieldId = (config) => {
689
- const faker = createFaker(config.seed);
782
+ const faker = config.faker || createFaker(config.seed);
690
783
  return changeCase.snakeCase(faker.words(faker.range(1, 3)));
691
784
  };
692
785
 
@@ -708,18 +801,105 @@ const mockModelFns = {
708
801
  timestamp: timestamp$1,
709
802
  title: title$1
710
803
  };
711
- const buildMockGroupFieldMap = (config = {}) => {
712
- const faker = createFaker(config.seed);
804
+ const buildMockGroupFieldMap = (config) => {
805
+ const faker = config.faker || createFaker(config.seed);
713
806
  const fields = {};
714
807
  const fieldTypes = faker.randomElements(Object.keys(mockModelFns));
715
808
  for (const fieldType of fieldTypes) {
716
- const fieldId = generateFieldId({ seed: config.seed });
809
+ const fieldId = generateFieldId({ faker });
717
810
  const mockModelFn = mockModelFns[fieldType];
718
- fields[fieldId] = mockModelFn({ seed: config.seed });
811
+ fields[fieldId] = mockModelFn({ faker });
719
812
  }
720
813
  return fields;
721
814
  };
722
815
 
816
+ const createModelMockFactory = (...args) => {
817
+ return new ModelMockFactory(...args);
818
+ };
819
+ class ModelMockFactory {
820
+ constructor(config) {
821
+ this.faker = "faker" in config ? config.faker : createFaker(config.seed);
822
+ }
823
+ get seed() {
824
+ return this.faker.seed;
825
+ }
826
+ buildMockGroupFieldMap(config) {
827
+ return buildMockGroupFieldMap({ ...config, faker: this.faker });
828
+ }
829
+ boolean(config) {
830
+ return boolean({ ...config, faker: this.faker });
831
+ }
832
+ color(config) {
833
+ return color$1({ ...config, faker: this.faker });
834
+ }
835
+ contentRelationship(config) {
836
+ return contentRelationship$1({ ...config, faker: this.faker });
837
+ }
838
+ customType(config) {
839
+ return customType$1({ ...config, faker: this.faker });
840
+ }
841
+ date(config) {
842
+ return date$1({ ...config, faker: this.faker });
843
+ }
844
+ embed(config) {
845
+ return embed$2({ ...config, faker: this.faker });
846
+ }
847
+ geoPoint(config) {
848
+ return geoPoint$1({ ...config, faker: this.faker });
849
+ }
850
+ group(config) {
851
+ return group$1({ ...config, faker: this.faker });
852
+ }
853
+ image(config) {
854
+ return image$2({ ...config, faker: this.faker });
855
+ }
856
+ integrationFields(config) {
857
+ return integrationFields$1({ ...config, faker: this.faker });
858
+ }
859
+ keyText(config) {
860
+ return keyText$1({ ...config, faker: this.faker });
861
+ }
862
+ link(config) {
863
+ return link$1({ ...config, faker: this.faker });
864
+ }
865
+ linkToMedia(config) {
866
+ return linkToMedia$1({ ...config, faker: this.faker });
867
+ }
868
+ number(config) {
869
+ return number$1({ ...config, faker: this.faker });
870
+ }
871
+ richText(config) {
872
+ return richText$1({ ...config, faker: this.faker });
873
+ }
874
+ select(config) {
875
+ return select$1({ ...config, faker: this.faker });
876
+ }
877
+ sharedSlice(config) {
878
+ return sharedSlice$1({ ...config, faker: this.faker });
879
+ }
880
+ sharedSliceChoice() {
881
+ return sharedSliceChoice();
882
+ }
883
+ sharedSliceVariation(config) {
884
+ return sharedSliceVariation$1({ ...config, faker: this.faker });
885
+ }
886
+ slice(config) {
887
+ return slice$1({ ...config, faker: this.faker });
888
+ }
889
+ sliceZone(config) {
890
+ return sliceZone$1({ ...config, faker: this.faker });
891
+ }
892
+ timestamp(config) {
893
+ return timestamp$1({ ...config, faker: this.faker });
894
+ }
895
+ title(config) {
896
+ return title$1({ ...config, faker: this.faker });
897
+ }
898
+ uid(config) {
899
+ return uid$1({ ...config, faker: this.faker });
900
+ }
901
+ }
902
+
723
903
  var index$2 = /*#__PURE__*/Object.freeze({
724
904
  __proto__: null,
725
905
  boolean: boolean,
@@ -746,11 +926,12 @@ var index$2 = /*#__PURE__*/Object.freeze({
746
926
  timestamp: timestamp$1,
747
927
  title: title$1,
748
928
  uid: uid$1,
749
- buildMockGroupFieldMap: buildMockGroupFieldMap
929
+ buildMockGroupFieldMap: buildMockGroupFieldMap,
930
+ createModelFactory: createModelMockFactory
750
931
  });
751
932
 
752
- const timestamp = (config = {}) => {
753
- const faker = createFaker(config.seed);
933
+ const timestamp = (config) => {
934
+ const faker = config.faker || createFaker(config.seed);
754
935
  if (config.state === "empty") {
755
936
  return null;
756
937
  } else {
@@ -779,10 +960,10 @@ const buildAlternativeLanguage = (config) => {
779
960
  };
780
961
  };
781
962
 
782
- const customType = (config = {}) => {
963
+ const customType = (config) => {
783
964
  var _a;
784
- const faker = createFaker(config.seed);
785
- const model = config.model || customType$1({ seed: config.seed });
965
+ const faker = config.faker || createFaker(config.seed);
966
+ const model = config.model || customType$1({ faker });
786
967
  const fieldModelsMap = Object.assign({}, ...Object.values(model.json));
787
968
  const dataFieldModelsMap = {};
788
969
  for (const key in fieldModelsMap) {
@@ -803,22 +984,22 @@ const customType = (config = {}) => {
803
984
  url: withURL ? faker.url() : null,
804
985
  href: faker.url(),
805
986
  lang: faker.word(),
806
- tags: generateTags({ seed: config.seed }),
987
+ tags: generateTags({ faker }),
807
988
  slugs: [],
808
989
  linked_documents: [],
809
990
  alternate_languages: alternateLanguages,
810
- first_publication_date: timestamp({ seed: config.seed }),
811
- last_publication_date: timestamp({ seed: config.seed }),
991
+ first_publication_date: timestamp({ faker }),
992
+ last_publication_date: timestamp({ faker }),
812
993
  data: valueForModelMap({
813
- seed: config.seed,
994
+ faker,
814
995
  map: dataFieldModelsMap,
815
996
  configs: config.configs
816
997
  })
817
998
  };
818
999
  };
819
1000
 
820
- const color = (config = {}) => {
821
- const faker = createFaker(config.seed);
1001
+ const color = (config) => {
1002
+ const faker = config.faker || createFaker(config.seed);
822
1003
  return config.state === "empty" ? null : faker.hexColor().toUpperCase();
823
1004
  };
824
1005
 
@@ -837,32 +1018,34 @@ const buildContentRelationshipField = (config) => {
837
1018
  };
838
1019
 
839
1020
  const generateCustomTypeId = (config) => {
840
- const faker = createFaker(config.seed);
1021
+ const faker = config.faker || createFaker(config.seed);
841
1022
  return changeCase.snakeCase(faker.words(faker.range(1, 3)));
842
1023
  };
843
1024
 
844
- const contentRelationship = (config = {}) => {
845
- const faker = createFaker(config.seed);
1025
+ const contentRelationship = (config) => {
1026
+ var _a, _b;
1027
+ const faker = config.faker || createFaker(config.seed);
846
1028
  if (config.state === "empty") {
847
1029
  return {
848
1030
  link_type: prismicT.LinkType.Document
849
1031
  };
850
1032
  } else {
851
- const model = config.model || contentRelationship$1({ seed: config.seed });
1033
+ const model = config.model || contentRelationship$1({ faker });
852
1034
  const linkableDocuments = config.linkableDocuments ? config.linkableDocuments.filter((document2) => {
1035
+ var _a2, _b2;
853
1036
  let shouldKeep = true;
854
- if (model.config.customtypes) {
1037
+ if ((_a2 = model.config) == null ? void 0 : _a2.customtypes) {
855
1038
  shouldKeep = shouldKeep && model.config.customtypes.includes(document2.type);
856
1039
  }
857
- if (model.config.tags) {
1040
+ if ((_b2 = model.config) == null ? void 0 : _b2.tags) {
858
1041
  shouldKeep = shouldKeep && model.config.tags.some((tag) => document2.tags.includes(tag));
859
1042
  }
860
1043
  return shouldKeep;
861
1044
  }) : [
862
1045
  {
863
- ...customType({ seed: config.seed }),
864
- type: model.config.customtypes ? faker.randomElement(model.config.customtypes) : generateCustomTypeId({ seed: config.seed }),
865
- tags: model.config.tags ? faker.randomElements(model.config.tags) : generateTags({ seed: config.seed })
1046
+ ...customType({ faker }),
1047
+ type: ((_a = model.config) == null ? void 0 : _a.customtypes) ? faker.randomElement(model.config.customtypes) : generateCustomTypeId({ faker }),
1048
+ tags: ((_b = model.config) == null ? void 0 : _b.tags) ? faker.randomElements(model.config.tags) : generateTags({ faker })
866
1049
  }
867
1050
  ];
868
1051
  const document = faker.randomElement(linkableDocuments);
@@ -875,9 +1058,10 @@ const contentRelationship = (config = {}) => {
875
1058
  }
876
1059
  };
877
1060
 
878
- const date = (config = {}) => {
1061
+ const date = (config) => {
1062
+ const faker = config.faker || createFaker(config.seed);
879
1063
  return config.state === "empty" ? null : timestamp({
880
- seed: config.seed,
1064
+ faker,
881
1065
  after: config.after,
882
1066
  before: config.before,
883
1067
  state: "filled"
@@ -886,7 +1070,7 @@ const date = (config = {}) => {
886
1070
 
887
1071
  const buildEmbedField = (config) => {
888
1072
  var _a;
889
- const faker = createFaker(config.seed);
1073
+ const faker = config.faker || createFaker(config.seed);
890
1074
  return {
891
1075
  embed_url: (_a = config.url) != null ? _a : faker.url(),
892
1076
  html: `<div>embed html</div>`,
@@ -894,7 +1078,7 @@ const buildEmbedField = (config) => {
894
1078
  };
895
1079
  };
896
1080
 
897
- const dataSet$1 = [
1081
+ const dataSet = [
898
1082
  {
899
1083
  version: "1.0",
900
1084
  type: "video",
@@ -974,41 +1158,43 @@ const dataSet$1 = [
974
1158
  }
975
1159
  ];
976
1160
  const getMockEmbedData = (config) => {
977
- const faker = createFaker(config.seed);
978
- return faker.randomElement(dataSet$1);
1161
+ const faker = config.faker || createFaker(config.seed);
1162
+ return faker.randomElement(dataSet);
979
1163
  };
980
1164
 
981
- const embed$1 = (config = {}) => {
1165
+ const embed$1 = (config) => {
982
1166
  var _a, _b, _c;
983
- const data = (_a = config.data) != null ? _a : getMockEmbedData({ seed: config.seed });
1167
+ const faker = config.faker || createFaker(config.seed);
1168
+ const data = (_a = config.data) != null ? _a : getMockEmbedData({ faker });
984
1169
  return config.state === "empty" ? {} : buildEmbedField({
985
- seed: config.seed,
1170
+ faker,
986
1171
  url: (_b = config.url) != null ? _b : "embed_url" in data ? data.embed_url : void 0,
987
1172
  html: (_c = config.html) != null ? _c : "html" in data ? data.html : void 0,
988
1173
  data
989
1174
  });
990
1175
  };
991
1176
 
992
- const geoPoint = (config = {}) => {
993
- const faker = createFaker(config.seed);
1177
+ const geoPoint = (config) => {
1178
+ const faker = config.faker || createFaker(config.seed);
994
1179
  return config.state === "empty" ? {} : {
995
1180
  longitude: faker.rangeFloat(-180, 180),
996
1181
  latitude: faker.rangeFloat(-90, 90)
997
1182
  };
998
1183
  };
999
1184
 
1000
- const group = (config = {}) => {
1185
+ const group = (config) => {
1001
1186
  var _a;
1002
1187
  if (config.state === "empty") {
1003
1188
  return [];
1004
1189
  } else {
1005
- const faker = createFaker(config.seed);
1006
- const model = config.model || group$1({ seed: config.seed });
1190
+ const faker = config.faker || createFaker(config.seed);
1191
+ const model = config.model || group$1({ faker });
1007
1192
  const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
1008
1193
  return Array(itemsCount).fill(void 0).map(() => {
1194
+ var _a2;
1009
1195
  return valueForModelMap({
1010
- seed: config.seed,
1011
- map: model.config.fields,
1196
+ faker,
1197
+ map: ((_a2 = model.config) == null ? void 0 : _a2.fields) || {},
1012
1198
  configs: config.configs
1013
1199
  });
1014
1200
  });
@@ -1025,7 +1211,7 @@ const buildImageFieldImage = (config) => {
1025
1211
  copyright: null
1026
1212
  };
1027
1213
  } else {
1028
- const faker = createFaker(config.seed);
1214
+ const faker = config.faker || createFaker(config.seed);
1029
1215
  const url = new URL(config.imageData.url);
1030
1216
  const dimensions = {
1031
1217
  width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
@@ -1043,136 +1229,46 @@ const buildImageFieldImage = (config) => {
1043
1229
  }
1044
1230
  };
1045
1231
 
1046
- const dataSet = [
1047
- {
1048
- url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
1049
- width: 4240,
1050
- height: 2832
1051
- },
1052
- {
1053
- url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
1054
- width: 7372,
1055
- height: 4392
1056
- },
1057
- {
1058
- url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
1059
- width: 2560,
1060
- height: 1705
1061
- },
1062
- {
1063
- url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
1064
- width: 2200,
1065
- height: 1467
1066
- },
1067
- {
1068
- url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
1069
- width: 5616,
1070
- height: 3744
1071
- },
1072
- {
1073
- url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
1074
- width: 4240,
1075
- height: 2832
1076
- },
1077
- {
1078
- url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
1079
- width: 2560,
1080
- height: 1440
1081
- },
1082
- {
1083
- url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
1084
- width: 6373,
1085
- height: 4253
1086
- },
1087
- {
1088
- url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
1089
- width: 4272,
1090
- height: 2848
1091
- },
1092
- {
1093
- url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
1094
- width: 4554,
1095
- height: 3036
1096
- },
1097
- {
1098
- url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
1099
- width: 6550,
1100
- height: 4367
1101
- },
1102
- {
1103
- url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
1104
- width: 6e3,
1105
- height: 4e3
1106
- },
1107
- {
1108
- url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
1109
- width: 6e3,
1110
- height: 4e3
1111
- },
1112
- {
1113
- url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
1114
- width: 4608,
1115
- height: 3456
1116
- },
1117
- {
1118
- url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
1119
- width: 4844,
1120
- height: 3234
1121
- },
1122
- {
1123
- url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
1124
- width: 4335,
1125
- height: 6502
1126
- }
1127
- ];
1128
- const getMockImageData = (config) => {
1129
- const faker = createFaker(config.seed);
1130
- return faker.randomElement(dataSet);
1131
- };
1132
-
1133
- const image$1 = (config = {}) => {
1134
- const model = config.model || image$2({ seed: config.seed });
1135
- const imageData = getMockImageData({ seed: config.seed });
1232
+ const image$1 = (config) => {
1233
+ var _a, _b;
1234
+ const faker = config.faker || createFaker(config.seed);
1235
+ const model = config.model || image$2({ faker });
1236
+ const imageData = getMockImageData({ faker });
1136
1237
  const value = buildImageFieldImage({
1137
- seed: config.seed,
1238
+ faker,
1138
1239
  imageData,
1139
- constraint: model.config.constraint,
1240
+ constraint: (_a = model.config) == null ? void 0 : _a.constraint,
1140
1241
  state: config.state
1141
1242
  });
1142
- for (const thumbnail of model.config.thumbnails) {
1143
- value[thumbnail.name] = buildImageFieldImage({
1144
- seed: config.seed,
1145
- imageData,
1146
- constraint: {
1147
- width: thumbnail.width,
1148
- height: thumbnail.height
1149
- },
1150
- state: config.state
1151
- });
1243
+ if ((_b = model.config) == null ? void 0 : _b.thumbnails) {
1244
+ for (const thumbnail of model.config.thumbnails) {
1245
+ value[thumbnail.name] = buildImageFieldImage({
1246
+ faker,
1247
+ imageData,
1248
+ constraint: {
1249
+ width: thumbnail.width,
1250
+ height: thumbnail.height
1251
+ },
1252
+ state: config.state
1253
+ });
1254
+ }
1152
1255
  }
1153
1256
  return value;
1154
1257
  };
1155
1258
 
1156
- const integrationFields = (config = {}) => {
1157
- const faker = createFaker(config.seed);
1158
- const imageData = getMockImageData({ seed: config.seed });
1159
- return config.state === "empty" ? null : {
1160
- id: faker.hash(7),
1161
- title: changeCase.capitalCase(faker.words(faker.range(1, 3))),
1162
- description: changeCase.sentenceCase(faker.words(faker.range(5, 10))),
1163
- image_url: imageData.url,
1164
- last_update: faker.date().getTime(),
1165
- blob: config.data
1166
- };
1259
+ const integrationFields = (config) => {
1260
+ var _a;
1261
+ const data = (_a = config.data) != null ? _a : {};
1262
+ return config.state === "empty" ? null : data;
1167
1263
  };
1168
1264
 
1169
- const keyText = (config = {}) => {
1170
- const faker = createFaker(config.seed);
1265
+ const keyText = (config) => {
1266
+ const faker = config.faker || createFaker(config.seed);
1171
1267
  return config.state === "empty" ? null : changeCase.sentenceCase(faker.words(3));
1172
1268
  };
1173
1269
 
1174
- const linkToMedia = (config = {}) => {
1175
- const faker = createFaker(config.seed);
1270
+ const linkToMedia = (config) => {
1271
+ const faker = config.faker || createFaker(config.seed);
1176
1272
  if (config.state === "empty") {
1177
1273
  return {
1178
1274
  link_type: prismicT.LinkType.Media
@@ -1190,9 +1286,9 @@ const linkToMedia = (config = {}) => {
1190
1286
  }
1191
1287
  };
1192
1288
 
1193
- const link = (config = {}) => {
1194
- var _a;
1195
- const faker = createFaker(config.seed);
1289
+ const link = (config) => {
1290
+ var _a, _b;
1291
+ const faker = config.faker || createFaker(config.seed);
1196
1292
  const type = config.type || faker.randomElement([
1197
1293
  prismicT.LinkType.Web,
1198
1294
  prismicT.LinkType.Document,
@@ -1206,32 +1302,32 @@ const link = (config = {}) => {
1206
1302
  switch (type) {
1207
1303
  case prismicT.LinkType.Document: {
1208
1304
  return contentRelationship({
1209
- seed: config.seed,
1305
+ faker,
1210
1306
  state: config.state,
1211
1307
  linkableDocuments: config.linkableDocuments
1212
1308
  });
1213
1309
  }
1214
1310
  case prismicT.LinkType.Media: {
1215
1311
  return linkToMedia({
1216
- seed: config.seed,
1312
+ faker,
1217
1313
  state: config.state
1218
1314
  });
1219
1315
  }
1220
1316
  case prismicT.LinkType.Web:
1221
1317
  default: {
1222
- const model = config.model || link$1({ seed: config.seed });
1318
+ const model = config.model || link$1({ faker });
1223
1319
  return {
1224
1320
  link_type: prismicT.LinkType.Web,
1225
1321
  url: faker.url(),
1226
- target: ((_a = config.withTargetBlank) != null ? _a : model.config.allowTargetBlank && faker.boolean()) ? "_blank" : void 0
1322
+ target: ((_b = config.withTargetBlank) != null ? _b : ((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
1227
1323
  };
1228
1324
  }
1229
1325
  }
1230
1326
  }
1231
1327
  };
1232
1328
 
1233
- const number = (config = {}) => {
1234
- const faker = createFaker(config.seed);
1329
+ const number = (config) => {
1330
+ const faker = config.faker || createFaker(config.seed);
1235
1331
  return config.state === "empty" ? null : faker.range(1, 100);
1236
1332
  };
1237
1333
 
@@ -1249,17 +1345,25 @@ const patterns$5 = {
1249
1345
  maxWords: 12
1250
1346
  }
1251
1347
  };
1252
- const heading = (config = {}) => {
1253
- const faker = createFaker(config.seed);
1254
- const model = config.model || title$1({ seed: config.seed });
1255
- const types = ("single" in model.config ? model.config.single : model.config.multi).split(",").filter((type2) => [
1256
- prismicT.RichTextNodeType.heading1,
1257
- prismicT.RichTextNodeType.heading2,
1258
- prismicT.RichTextNodeType.heading3,
1259
- prismicT.RichTextNodeType.heading4,
1260
- prismicT.RichTextNodeType.heading5,
1261
- prismicT.RichTextNodeType.heading6
1262
- ].includes(type2));
1348
+ const headingNoteTypes = [
1349
+ prismicT.RichTextNodeType.heading1,
1350
+ prismicT.RichTextNodeType.heading2,
1351
+ prismicT.RichTextNodeType.heading3,
1352
+ prismicT.RichTextNodeType.heading4,
1353
+ prismicT.RichTextNodeType.heading5,
1354
+ prismicT.RichTextNodeType.heading6
1355
+ ];
1356
+ const heading = (config) => {
1357
+ const faker = config.faker || createFaker(config.seed);
1358
+ const model = config.model || title$1({ faker });
1359
+ let types = [];
1360
+ if (model.config) {
1361
+ if ("single" in model.config && model.config.single) {
1362
+ types = model.config.single.split(",").filter((type2) => headingNoteTypes.includes(type2));
1363
+ } else if ("multi" in model.config && model.config.multi) {
1364
+ types = model.config.multi.split(",").filter((type2) => headingNoteTypes.includes(type2));
1365
+ }
1366
+ }
1263
1367
  const type = faker.randomElement(types);
1264
1368
  if (type) {
1265
1369
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$5));
@@ -1285,8 +1389,8 @@ const patterns$4 = {
1285
1389
  sentenceCount: 12
1286
1390
  }
1287
1391
  };
1288
- const paragraph = (config = {}) => {
1289
- const faker = createFaker(config.seed);
1392
+ const paragraph = (config) => {
1393
+ const faker = config.faker || createFaker(config.seed);
1290
1394
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$4));
1291
1395
  const pattern = patterns$4[patternKey];
1292
1396
  const text = Array.from({ length: pattern.sentenceCount }, () => changeCase.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
@@ -1308,8 +1412,8 @@ const patterns$3 = {
1308
1412
  sentenceCount: 12
1309
1413
  }
1310
1414
  };
1311
- const preformatted = (config = {}) => {
1312
- const faker = createFaker(config.seed);
1415
+ const preformatted = (config) => {
1416
+ const faker = config.faker || createFaker(config.seed);
1313
1417
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$3));
1314
1418
  const pattern = patterns$3[patternKey];
1315
1419
  const text = Array.from({ length: pattern.sentenceCount }, () => changeCase.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
@@ -1334,8 +1438,8 @@ const patterns$2 = {
1334
1438
  maxItems: 12
1335
1439
  }
1336
1440
  };
1337
- const list = (config = {}) => {
1338
- const faker = createFaker(config.seed);
1441
+ const list = (config) => {
1442
+ const faker = config.faker || createFaker(config.seed);
1339
1443
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$2));
1340
1444
  const pattern = patterns$2[patternKey];
1341
1445
  const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
@@ -1362,8 +1466,8 @@ const patterns$1 = {
1362
1466
  maxItems: 12
1363
1467
  }
1364
1468
  };
1365
- const oList = (config = {}) => {
1366
- const faker = createFaker(config.seed);
1469
+ const oList = (config) => {
1470
+ const faker = config.faker || createFaker(config.seed);
1367
1471
  const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$1));
1368
1472
  const pattern = patterns$1[patternKey];
1369
1473
  const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
@@ -1376,10 +1480,11 @@ const oList = (config = {}) => {
1376
1480
  });
1377
1481
  };
1378
1482
 
1379
- const image = (config = {}) => {
1380
- const imageData = getMockImageData({ seed: config.seed });
1483
+ const image = (config) => {
1484
+ const faker = config.faker || createFaker(config.seed);
1485
+ const imageData = getMockImageData({ faker });
1381
1486
  const imageField = buildImageFieldImage({
1382
- seed: config.seed,
1487
+ faker,
1383
1488
  imageData,
1384
1489
  state: "filled"
1385
1490
  });
@@ -1392,9 +1497,10 @@ const image = (config = {}) => {
1392
1497
  };
1393
1498
  };
1394
1499
 
1395
- const embed = (config = {}) => {
1396
- const data = getMockEmbedData({ seed: config.seed });
1397
- const embedField = buildEmbedField({ seed: config.seed, data });
1500
+ const embed = (config) => {
1501
+ const faker = config.faker || createFaker(config.seed);
1502
+ const data = getMockEmbedData({ faker });
1503
+ const embedField = buildEmbedField({ faker, data });
1398
1504
  return {
1399
1505
  type: prismicT.RichTextNodeType.embed,
1400
1506
  oembed: embedField
@@ -1429,96 +1535,109 @@ const generators = {
1429
1535
  [prismicT.RichTextNodeType.image]: image,
1430
1536
  [prismicT.RichTextNodeType.embed]: embed
1431
1537
  };
1432
- const richText = (config = {}) => {
1433
- const faker = createFaker(config.seed);
1434
- const model = config.model || richText$1({
1435
- seed: config.seed,
1436
- withMultipleBlocks: true
1437
- });
1438
- const supportsMultipleBlocks = "multi" in model.config;
1439
- const types = ("multi" in model.config ? model.config.multi : model.config.single).split(",").filter((type) => Object.keys(generators).includes(type));
1440
- if (types.length > 0) {
1441
- const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
1442
- const pattern = patterns[patternKey];
1443
- const blockCount = supportsMultipleBlocks ? faker.range(pattern.blockCountMin, pattern.blockCountMax) : 1;
1444
- return Array(blockCount).fill(void 0).map(() => {
1445
- const type = faker.randomElement(types);
1446
- const generator = generators[type];
1447
- return generator({ seed: config.seed, model });
1448
- }).flat().filter((block) => block !== void 0).slice(0, blockCount);
1449
- } else {
1538
+ const richText = (config) => {
1539
+ const faker = config.faker || createFaker(config.seed);
1540
+ if (config.state === "empty") {
1450
1541
  return [];
1542
+ } else {
1543
+ const model = config.model || richText$1({
1544
+ faker,
1545
+ withMultipleBlocks: true
1546
+ });
1547
+ const supportsMultipleBlocks = model.config && "multi" in model.config;
1548
+ let types = [];
1549
+ if (model.config) {
1550
+ if ("multi" in model.config && model.config.multi) {
1551
+ types = model.config.multi.split(",").filter((type) => Object.keys(generators).includes(type));
1552
+ } else if ("single" in model.config && model.config.single) {
1553
+ types = model.config.single.split(",").filter((type) => Object.keys(generators).includes(type));
1554
+ }
1555
+ }
1556
+ if (types.length > 0) {
1557
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
1558
+ const pattern = patterns[patternKey];
1559
+ const blockCount = supportsMultipleBlocks ? faker.range(pattern.blockCountMin, pattern.blockCountMax) : 1;
1560
+ return Array(blockCount).fill(void 0).map(() => {
1561
+ const type = faker.randomElement(types);
1562
+ const generator = generators[type];
1563
+ return generator({ faker, model });
1564
+ }).flat().filter((block) => block !== void 0).slice(0, blockCount);
1565
+ } else {
1566
+ return [];
1567
+ }
1451
1568
  }
1452
1569
  };
1453
1570
 
1454
- const select = (config = {}) => {
1455
- const faker = createFaker(config.seed);
1456
- const model = config.model || select$1({ seed: config.seed });
1457
- const defaultValue = model.config.default_value;
1571
+ const select = (config) => {
1572
+ var _a, _b;
1573
+ const faker = config.faker || createFaker(config.seed);
1574
+ const model = config.model || select$1({ faker });
1575
+ const defaultValue = (_a = model.config) == null ? void 0 : _a.default_value;
1576
+ const options = ((_b = model.config) == null ? void 0 : _b.options) || [];
1458
1577
  if (config.state === "empty") {
1459
1578
  return null;
1460
1579
  } else {
1461
- return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(model.config.options);
1580
+ return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(options);
1462
1581
  }
1463
1582
  };
1464
1583
 
1465
- const slice = (config = {}) => {
1584
+ const slice = (config) => {
1466
1585
  var _a, _b;
1467
- const faker = createFaker(config.seed);
1468
- const model = config.model || slice$1({ seed: config.seed });
1469
- const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
1586
+ const faker = config.faker || createFaker(config.seed);
1587
+ const model = config.model || slice$1({ faker });
1588
+ const sliceType = (_a = config.type) != null ? _a : generateFieldId({ faker });
1470
1589
  const sliceLabel = config.label !== void 0 ? config.label : changeCase.capitalCase(faker.words(faker.range(1, 2)));
1471
- const itemsCount = Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1590
+ const itemsCount = model.repeat && Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1472
1591
  return {
1473
1592
  slice_type: sliceType,
1474
1593
  slice_label: sliceLabel,
1475
1594
  primary: valueForModelMap({
1476
- seed: config.seed,
1477
- map: model["non-repeat"],
1595
+ faker,
1596
+ map: model["non-repeat"] || {},
1478
1597
  configs: config.primaryFieldConfigs
1479
1598
  }),
1480
1599
  items: Array(itemsCount).fill(void 0).map(() => {
1481
1600
  return valueForModelMap({
1482
- seed: config.seed,
1483
- map: model.repeat,
1601
+ faker,
1602
+ map: model.repeat || {},
1484
1603
  configs: config.itemsFieldConfigs
1485
1604
  });
1486
1605
  })
1487
1606
  };
1488
1607
  };
1489
1608
 
1490
- const sharedSliceVariation = (config = {}) => {
1609
+ const sharedSliceVariation = (config) => {
1491
1610
  var _a, _b;
1492
- const faker = createFaker(config.seed);
1493
- const model = config.model || sharedSliceVariation$1({ seed: config.seed });
1494
- const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
1495
- const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1611
+ const faker = config.faker || createFaker(config.seed);
1612
+ const model = config.model || sharedSliceVariation$1({ faker });
1613
+ const sliceType = (_a = config.type) != null ? _a : generateFieldId({ faker });
1614
+ const itemsCount = model.items && Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1496
1615
  return {
1497
1616
  slice_type: sliceType,
1498
1617
  slice_label: null,
1499
1618
  variation: model.id,
1500
1619
  version: faker.hash(7),
1501
1620
  primary: valueForModelMap({
1502
- seed: config.seed,
1503
- map: model.primary,
1621
+ faker,
1622
+ map: model.primary || {},
1504
1623
  configs: config.primaryFieldConfigs
1505
1624
  }),
1506
1625
  items: Array(itemsCount).fill(void 0).map(() => {
1507
1626
  return valueForModelMap({
1508
- seed: config.seed,
1509
- map: model.items,
1627
+ faker,
1628
+ map: model.items || {},
1510
1629
  configs: config.itemsFieldConfigs
1511
1630
  });
1512
1631
  })
1513
1632
  };
1514
1633
  };
1515
1634
 
1516
- const sharedSlice = (config = {}) => {
1517
- const faker = createFaker(config.seed);
1518
- const model = config.model || sharedSlice$1({ seed: config.seed });
1635
+ const sharedSlice = (config) => {
1636
+ const faker = config.faker || createFaker(config.seed);
1637
+ const model = config.model || sharedSlice$1({ faker });
1519
1638
  const variationModel = faker.randomElement(model.variations);
1520
1639
  return sharedSliceVariation({
1521
- seed: config.seed,
1640
+ faker,
1522
1641
  model: variationModel,
1523
1642
  itemsCount: config.itemsCount,
1524
1643
  type: model.id,
@@ -1527,25 +1646,25 @@ const sharedSlice = (config = {}) => {
1527
1646
  });
1528
1647
  };
1529
1648
 
1530
- const sliceZone = (config = {}) => {
1531
- var _a;
1649
+ const sliceZone = (config) => {
1650
+ var _a, _b;
1532
1651
  if (config.state === "empty") {
1533
1652
  return [];
1534
1653
  } else {
1535
- const faker = createFaker(config.seed);
1536
- const model = config.model || sliceZone$1({ seed: config.seed });
1537
- if (Object.keys(model.config.choices).length > 0) {
1538
- const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
1654
+ const faker = config.faker || createFaker(config.seed);
1655
+ const model = config.model || sliceZone$1({ faker });
1656
+ if (((_a = model.config) == null ? void 0 : _a.choices) && Object.keys(model.config.choices).length > 0) {
1657
+ const itemsCount = (_b = config.itemsCount) != null ? _b : faker.range(1, 6);
1539
1658
  return Array(itemsCount).fill(void 0).map(() => {
1540
- var _a2;
1541
- const choices = Object.entries(model.config.choices);
1659
+ var _a2, _b2, _c, _d;
1660
+ const choices = ((_a2 = model.config) == null ? void 0 : _a2.choices) && Object.entries(model.config.choices) || [];
1542
1661
  const [choiceType, choiceModel] = faker.randomElement(choices);
1543
- const choiceLabels = model.config.labels[choiceType] || [];
1662
+ const choiceLabels = ((_c = (_b2 = model.config) == null ? void 0 : _b2.labels) == null ? void 0 : _c[choiceType]) || [];
1544
1663
  const choiceLabel = faker.randomElement(choiceLabels);
1545
1664
  switch (choiceModel.type) {
1546
1665
  case prismicT.CustomTypeModelSliceType.Slice: {
1547
1666
  return slice({
1548
- seed: config.seed,
1667
+ faker,
1549
1668
  model: choiceModel,
1550
1669
  type: choiceType,
1551
1670
  label: choiceLabel ? choiceLabel.name : null,
@@ -1554,10 +1673,10 @@ const sliceZone = (config = {}) => {
1554
1673
  });
1555
1674
  }
1556
1675
  case prismicT.CustomTypeModelSliceType.SharedSlice: {
1557
- const sharedSliceModel = (_a2 = config.sharedSliceModels) == null ? void 0 : _a2.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
1676
+ const sharedSliceModel = (_d = config.sharedSliceModels) == null ? void 0 : _d.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
1558
1677
  if (sharedSliceModel) {
1559
1678
  return sharedSlice({
1560
- seed: config.seed,
1679
+ faker,
1561
1680
  model: sharedSliceModel,
1562
1681
  primaryFieldConfigs: config.primaryFieldConfigs,
1563
1682
  itemsFieldConfigs: config.itemsFieldConfigs
@@ -1572,13 +1691,14 @@ const sliceZone = (config = {}) => {
1572
1691
  }
1573
1692
  };
1574
1693
 
1575
- const title = (config = {}) => {
1694
+ const title = (config) => {
1695
+ const faker = config.faker || createFaker(config.seed);
1576
1696
  if (config.state === "empty") {
1577
1697
  return [];
1578
1698
  } else {
1579
1699
  return [
1580
1700
  heading({
1581
- seed: config.seed,
1701
+ faker,
1582
1702
  model: config.model,
1583
1703
  pattern: config.pattern
1584
1704
  })
@@ -1586,8 +1706,8 @@ const title = (config = {}) => {
1586
1706
  }
1587
1707
  };
1588
1708
 
1589
- const uid = (config = {}) => {
1590
- const faker = createFaker(config.seed);
1709
+ const uid = (config) => {
1710
+ const faker = config.faker || createFaker(config.seed);
1591
1711
  return changeCase.snakeCase(faker.words(faker.range(1, 3)));
1592
1712
  };
1593
1713
 
@@ -1619,9 +1739,9 @@ var index$1 = /*#__PURE__*/Object.freeze({
1619
1739
  uid: uid
1620
1740
  });
1621
1741
 
1622
- const ref = (config = {}) => {
1742
+ const ref = (config) => {
1623
1743
  var _a;
1624
- const faker = createFaker(config.seed);
1744
+ const faker = config.faker || createFaker(config.seed);
1625
1745
  const value = {
1626
1746
  id: faker.hash(16),
1627
1747
  ref: faker.hash(16),
@@ -1629,23 +1749,23 @@ const ref = (config = {}) => {
1629
1749
  label: config.isMasterRef ? "Master" : changeCase.capitalCase(faker.words(faker.range(1, 3)))
1630
1750
  };
1631
1751
  if (config.isScheduled) {
1632
- value.scheduledAt = timestamp({ seed: config.seed });
1752
+ value.scheduledAt = timestamp({ faker });
1633
1753
  }
1634
1754
  return value;
1635
1755
  };
1636
1756
 
1637
- const repository = (config = {}) => {
1638
- const faker = createFaker(config.seed);
1757
+ const repository = (config) => {
1758
+ const faker = config.faker || createFaker(config.seed);
1639
1759
  const types = (config.customTypeModels || []).reduce((acc, model) => {
1640
- acc[model.id] = model.label;
1760
+ acc[model.id] = model.label || model.id;
1641
1761
  return acc;
1642
1762
  }, {});
1643
1763
  return {
1644
1764
  refs: [
1645
- ref({ seed: config.seed, isMasterRef: true }),
1646
- ...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
1765
+ ref({ faker, isMasterRef: true }),
1766
+ ...config.withReleases ? [ref({ faker }), ref({ faker })] : []
1647
1767
  ],
1648
- integrationFieldsRef: ref({ seed: config.seed }).ref,
1768
+ integrationFieldsRef: ref({ faker }).ref,
1649
1769
  types,
1650
1770
  languages: [
1651
1771
  {
@@ -1654,7 +1774,7 @@ const repository = (config = {}) => {
1654
1774
  }
1655
1775
  ],
1656
1776
  tags: generateTags({
1657
- seed: config.seed,
1777
+ faker,
1658
1778
  min: 1,
1659
1779
  max: 10
1660
1780
  }),
@@ -1668,9 +1788,9 @@ const repository = (config = {}) => {
1668
1788
  };
1669
1789
  };
1670
1790
 
1671
- const query = (config = {}) => {
1791
+ const query = (config) => {
1672
1792
  var _a, _b;
1673
- const faker = createFaker(config.seed);
1793
+ const faker = config.faker || createFaker(config.seed);
1674
1794
  const documents = config.documents || [];
1675
1795
  const page = Math.max(1, (_a = config.page) != null ? _a : 1);
1676
1796
  const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
@@ -1688,9 +1808,10 @@ const query = (config = {}) => {
1688
1808
  };
1689
1809
  };
1690
1810
 
1691
- const tags = (config = {}) => {
1811
+ const tags = (config) => {
1812
+ const faker = config.faker || createFaker(config.seed);
1692
1813
  return generateTags({
1693
- seed: config.seed,
1814
+ faker,
1694
1815
  min: 1,
1695
1816
  max: 10
1696
1817
  });
@@ -1704,5 +1825,128 @@ var index = /*#__PURE__*/Object.freeze({
1704
1825
  tags: tags
1705
1826
  });
1706
1827
 
1707
- export { index as api, index$2 as model, index$1 as value };
1828
+ const createValueMockFactory = (...args) => {
1829
+ return new ValueMockFactory(...args);
1830
+ };
1831
+ class ValueMockFactory {
1832
+ constructor(config) {
1833
+ this.faker = "faker" in config ? config.faker : createFaker(config.seed);
1834
+ }
1835
+ get seed() {
1836
+ return this.faker.seed;
1837
+ }
1838
+ boolean(config) {
1839
+ return boolean$1({ ...config, faker: this.faker });
1840
+ }
1841
+ color(config) {
1842
+ return color({ ...config, faker: this.faker });
1843
+ }
1844
+ contentRelationship(config) {
1845
+ return contentRelationship({ ...config, faker: this.faker });
1846
+ }
1847
+ customType(config) {
1848
+ return customType({ ...config, faker: this.faker });
1849
+ }
1850
+ date(config) {
1851
+ return date({ ...config, faker: this.faker });
1852
+ }
1853
+ document(config) {
1854
+ return customType({ ...config, faker: this.faker });
1855
+ }
1856
+ embed(config) {
1857
+ return embed$1({ ...config, faker: this.faker });
1858
+ }
1859
+ geoPoint(config) {
1860
+ return geoPoint({ ...config, faker: this.faker });
1861
+ }
1862
+ group(config) {
1863
+ return group({ ...config, faker: this.faker });
1864
+ }
1865
+ image(config) {
1866
+ return image$1({ ...config, faker: this.faker });
1867
+ }
1868
+ integrationFields(config) {
1869
+ return integrationFields({ ...config, faker: this.faker });
1870
+ }
1871
+ keyText(config) {
1872
+ return keyText({ ...config, faker: this.faker });
1873
+ }
1874
+ link(config) {
1875
+ return link({ ...config, faker: this.faker });
1876
+ }
1877
+ linkToMedia(config) {
1878
+ return linkToMedia({ ...config, faker: this.faker });
1879
+ }
1880
+ number(config) {
1881
+ return number({ ...config, faker: this.faker });
1882
+ }
1883
+ select(config) {
1884
+ return select({ ...config, faker: this.faker });
1885
+ }
1886
+ sharedSlice(config) {
1887
+ return sharedSlice({ ...config, faker: this.faker });
1888
+ }
1889
+ sharedSliceVariation(config) {
1890
+ return sharedSliceVariation({ ...config, faker: this.faker });
1891
+ }
1892
+ slice(config) {
1893
+ return slice({ ...config, faker: this.faker });
1894
+ }
1895
+ sliceZone(config) {
1896
+ return sliceZone({ ...config, faker: this.faker });
1897
+ }
1898
+ timestamp(config) {
1899
+ return timestamp({ ...config, faker: this.faker });
1900
+ }
1901
+ title(config) {
1902
+ return title({ ...config, faker: this.faker });
1903
+ }
1904
+ uid(config) {
1905
+ return uid({ ...config, faker: this.faker });
1906
+ }
1907
+ richText(config) {
1908
+ return richText({ ...config, faker: this.faker });
1909
+ }
1910
+ }
1911
+
1912
+ const createAPIMockFactory = (...args) => {
1913
+ return new APIMockFactory(...args);
1914
+ };
1915
+ class APIMockFactory {
1916
+ constructor(config) {
1917
+ this.faker = "faker" in config ? config.faker : createFaker(config.seed);
1918
+ }
1919
+ get seed() {
1920
+ return this.faker.seed;
1921
+ }
1922
+ query(config) {
1923
+ return query({ ...config, faker: this.faker });
1924
+ }
1925
+ ref(config) {
1926
+ return ref({ ...config, faker: this.faker });
1927
+ }
1928
+ repository(config) {
1929
+ return repository({ ...config, faker: this.faker });
1930
+ }
1931
+ tags(config) {
1932
+ return tags({ ...config, faker: this.faker });
1933
+ }
1934
+ }
1935
+
1936
+ const createMockFactory = (...args) => {
1937
+ return new MockFactory(...args);
1938
+ };
1939
+ class MockFactory {
1940
+ constructor(config) {
1941
+ this.faker = config.faker || createFaker(config.seed);
1942
+ this.api = createAPIMockFactory({ faker: this.faker });
1943
+ this.model = createModelMockFactory({ faker: this.faker });
1944
+ this.value = createValueMockFactory({ faker: this.faker });
1945
+ }
1946
+ get seed() {
1947
+ return this.faker.seed;
1948
+ }
1949
+ }
1950
+
1951
+ export { APIMockFactory, MockFactory, ModelMockFactory, ValueMockFactory, index as api, createAPIMockFactory, createMockFactory, createModelMockFactory, createValueMockFactory, index$2 as model, index$1 as value };
1708
1952
  //# sourceMappingURL=index.js.map