@prismicio/mock 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/api/index.cjs +348 -236
  2. package/dist/api/index.cjs.map +1 -1
  3. package/dist/api/index.d.ts +52 -6
  4. package/dist/api/index.js +348 -236
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/index.cjs +893 -543
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +247 -73
  9. package/dist/index.js +885 -542
  10. package/dist/index.js.map +1 -1
  11. package/dist/model/index.cjs +398 -134
  12. package/dist/model/index.cjs.map +1 -1
  13. package/dist/model/index.d.ts +114 -28
  14. package/dist/model/index.js +398 -134
  15. package/dist/model/index.js.map +1 -1
  16. package/dist/value/index.cjs +598 -468
  17. package/dist/value/index.cjs.map +1 -1
  18. package/dist/value/index.d.ts +96 -40
  19. package/dist/value/index.js +598 -468
  20. package/dist/value/index.js.map +1 -1
  21. package/package.json +22 -20
  22. package/src/api/createAPIMockFactory.ts +56 -0
  23. package/src/api/query.ts +4 -4
  24. package/src/api/ref.ts +6 -6
  25. package/src/api/repository.ts +12 -14
  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 +28 -30
  30. package/src/lib/buildImageFieldImage.ts +19 -7
  31. package/src/lib/createFaker.ts +99 -22
  32. package/src/lib/generateCustomTypeId.ts +13 -5
  33. package/src/lib/generateFieldId.ts +13 -7
  34. package/src/lib/generateTags.ts +17 -16
  35. package/src/lib/getMockEmbedData.ts +45 -16
  36. package/src/lib/getMockImageData.ts +13 -5
  37. package/src/lib/lorem.ts +112 -0
  38. package/src/lib/valueForModel.ts +47 -30
  39. package/src/lib/valueForModelMap.ts +24 -4
  40. package/src/model/boolean.ts +6 -6
  41. package/src/model/buildMockGroupFieldMap.ts +5 -5
  42. package/src/model/color.ts +4 -4
  43. package/src/model/contentRelationship.ts +4 -4
  44. package/src/model/createModelMockFactory.ts +213 -0
  45. package/src/model/customType.ts +6 -6
  46. package/src/model/date.ts +4 -4
  47. package/src/model/embed.ts +4 -4
  48. package/src/model/geoPoint.ts +3 -3
  49. package/src/model/group.ts +7 -7
  50. package/src/model/image.ts +8 -12
  51. package/src/model/index.ts +2 -0
  52. package/src/model/integrationFields.ts +4 -4
  53. package/src/model/keyText.ts +4 -4
  54. package/src/model/link.ts +6 -6
  55. package/src/model/linkToMedia.ts +5 -5
  56. package/src/model/number.ts +4 -4
  57. package/src/model/richText.ts +8 -8
  58. package/src/model/select.ts +5 -5
  59. package/src/model/sharedSlice.ts +5 -5
  60. package/src/model/sharedSliceVariation.ts +10 -10
  61. package/src/model/slice.ts +7 -7
  62. package/src/model/sliceZone.ts +7 -4
  63. package/src/model/timestamp.ts +4 -4
  64. package/src/model/title.ts +7 -7
  65. package/src/model/uid.ts +4 -4
  66. package/src/types.ts +70 -31
  67. package/src/value/boolean.ts +4 -6
  68. package/src/value/color.ts +3 -3
  69. package/src/value/contentRelationship.ts +21 -18
  70. package/src/value/createValueMockFactory.ts +236 -0
  71. package/src/value/customType.ts +12 -12
  72. package/src/value/date.ts +6 -2
  73. package/src/value/embed.ts +23 -7
  74. package/src/value/geoPoint.ts +4 -6
  75. package/src/value/group.ts +6 -11
  76. package/src/value/image.ts +26 -18
  77. package/src/value/integrationFields.ts +12 -26
  78. package/src/value/keyText.ts +3 -5
  79. package/src/value/link.ts +11 -9
  80. package/src/value/linkToMedia.ts +9 -8
  81. package/src/value/number.ts +3 -3
  82. package/src/value/richText/embed.ts +6 -3
  83. package/src/value/richText/heading.ts +32 -27
  84. package/src/value/richText/image.ts +9 -8
  85. package/src/value/richText/index.ts +71 -48
  86. package/src/value/richText/list.ts +6 -10
  87. package/src/value/richText/oList.ts +6 -10
  88. package/src/value/richText/paragraph.ts +10 -6
  89. package/src/value/richText/preformatted.ts +11 -7
  90. package/src/value/select.ts +11 -7
  91. package/src/value/sharedSlice.ts +5 -5
  92. package/src/value/sharedSliceVariation.ts +11 -16
  93. package/src/value/slice.ts +11 -15
  94. package/src/value/sliceZone.ts +14 -18
  95. package/src/value/timestamp.ts +31 -18
  96. package/src/value/title.ts +7 -3
  97. package/src/value/uid.ts +6 -4
package/dist/index.cjs CHANGED
@@ -3,8 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const changeCase = require('change-case');
6
- const fakerLocaleEN = require('faker/lib/locales/en/index.js');
7
- const Faker = require('faker/lib/index.js');
6
+ const Rand = require('rand-seed');
8
7
  const prismicT = require('@prismicio/types');
9
8
 
10
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -28,81 +27,168 @@ function _interopNamespace(e) {
28
27
  }
29
28
 
30
29
  const changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase);
31
- const fakerLocaleEN__namespace = /*#__PURE__*/_interopNamespace(fakerLocaleEN);
32
- const Faker__default = /*#__PURE__*/_interopDefaultLegacy(Faker);
30
+ const Rand__default = /*#__PURE__*/_interopDefaultLegacy(Rand);
33
31
  const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
34
32
 
35
- const FAKER_SEED = 1984;
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";
34
+ const loremWords = wordsString.split(" ");
35
+ const lorem = (length, wordOffset = 0) => {
36
+ const count = parseInt(length.substring(0, length.length - 1));
37
+ const countType = length.charAt(length.length - 1);
38
+ if (!isNaN(count) && (countType === "w" || countType === "c")) {
39
+ if (!lorem.spaceIndices.length) {
40
+ let startIndex = -1;
41
+ do {
42
+ const index = wordsString.indexOf(" ", startIndex + 1);
43
+ lorem.spaceIndices.push(index);
44
+ startIndex = index;
45
+ } while (startIndex !== -1);
46
+ }
47
+ if (countType === "c") {
48
+ return wordsString.substring(0, count);
49
+ } else {
50
+ let sentence = "";
51
+ const startSpaceIndex = lorem.spaceIndices[wordOffset % lorem.spaceIndices.length - 1];
52
+ const endSpaceIndex = lorem.spaceIndices[(wordOffset % lorem.spaceIndices.length + count) % lorem.spaceIndices.length - 1];
53
+ if (count + wordOffset % lorem.spaceIndices.length > lorem.spaceIndices.length) {
54
+ sentence += wordsString.substring(startSpaceIndex + 1) + " ";
55
+ const wraparoundCounts = Math.floor(count / lorem.spaceIndices.length) - 1;
56
+ for (let i = 0; i < wraparoundCounts; i++) {
57
+ sentence += wordsString + " ";
58
+ }
59
+ sentence += wordsString.substring(0, endSpaceIndex);
60
+ } else {
61
+ sentence = wordsString.substring(startSpaceIndex + 1, endSpaceIndex);
62
+ }
63
+ if (sentence.charAt(sentence.length - 1) === ",") {
64
+ return sentence.substring(0, sentence.length - 1);
65
+ } else {
66
+ return sentence.substring(0, sentence.length);
67
+ }
68
+ }
69
+ }
70
+ throw new Error("Length must be of the form `${number}w` or `${number}c`");
71
+ };
72
+ lorem.spaceIndices = [];
36
73
 
37
- const createFaker = (seed = FAKER_SEED) => {
38
- let normalizedSeed;
39
- if (typeof seed === "string") {
40
- normalizedSeed = seed.split("").map((char) => char.charCodeAt(0));
41
- } else {
42
- normalizedSeed = seed;
74
+ const createFaker = (seed) => {
75
+ return new Faker(seed);
76
+ };
77
+ const DAY_MS = 1e3 * 60 * 60 * 24;
78
+ const YEAR_MS = DAY_MS * 365;
79
+ const YEAR_2022_MS = 52 * (YEAR_MS + DAY_MS / 4);
80
+ class Faker {
81
+ constructor(seed) {
82
+ this.seed = seed;
83
+ this.rand = new Rand__default["default"](seed.toString());
43
84
  }
44
- const cacheKey = JSON.stringify(normalizedSeed);
45
- if (createFaker.cache[cacheKey]) {
46
- return createFaker.cache[cacheKey];
85
+ boolean() {
86
+ return this.random() >= 0.5;
47
87
  }
48
- const fakerInstance = new Faker__default["default"]();
49
- fakerInstance.locales["en"] = fakerLocaleEN__namespace;
50
- fakerInstance.seed(normalizedSeed);
51
- createFaker.cache[cacheKey] = fakerInstance;
52
- return fakerInstance;
53
- };
54
- createFaker.cache = {};
88
+ random() {
89
+ return this.rand.next();
90
+ }
91
+ randomElement(elements) {
92
+ return elements[this.range(0, elements.length)];
93
+ }
94
+ randomElements(elements) {
95
+ const alwaysInclude = this.randomElement(elements);
96
+ return elements.filter((element) => element === alwaysInclude || this.boolean());
97
+ }
98
+ range(min, max) {
99
+ return Math.floor(this.rangeFloat(Math.ceil(min), Math.floor(max)));
100
+ }
101
+ rangeFloat(min, max) {
102
+ return this.random() * (max - min) + min;
103
+ }
104
+ words(length, wordOffset = this.range(0, loremWords.length)) {
105
+ return lorem(`${length}w`, wordOffset);
106
+ }
107
+ word() {
108
+ return this.randomElement(loremWords);
109
+ }
110
+ lorem(length, wordOffset = this.range(0, loremWords.length)) {
111
+ return lorem(length, wordOffset);
112
+ }
113
+ url() {
114
+ return `https://${this.word()}.example`;
115
+ }
116
+ hexColor() {
117
+ return `#${this.hash(6)}`;
118
+ }
119
+ hash(length) {
120
+ let hash = "";
121
+ for (let i = 0; i < length; i++) {
122
+ const chars = this.boolean() ? "abcdef" : "0123456789";
123
+ hash += chars[this.range(0, chars.length)];
124
+ }
125
+ return hash;
126
+ }
127
+ date() {
128
+ return new Date(YEAR_2022_MS + this.range(-YEAR_MS * 3, YEAR_MS * 3));
129
+ }
130
+ dateAfter(date) {
131
+ const timestamp = date.getTime();
132
+ return new Date(this.range(timestamp, timestamp + YEAR_MS * 3));
133
+ }
134
+ dateBefore(date) {
135
+ const timestamp = date.getTime();
136
+ return new Date(this.range(timestamp - YEAR_MS * 3, timestamp));
137
+ }
138
+ dateBetween(min, max) {
139
+ return new Date(this.range(min.getTime(), max.getTime()));
140
+ }
141
+ }
55
142
 
56
143
  const generateTags = (config) => {
57
144
  var _a, _b;
58
- const faker = createFaker(config.seed);
59
- return Array(faker.datatype.number({
60
- min: (_a = config.min) != null ? _a : 0,
61
- max: (_b = config.max) != null ? _b : 2
62
- })).fill(void 0).map(() => changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 }))));
145
+ const faker = config.faker || createFaker(config.seed);
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))));
63
147
  };
64
148
 
65
- const boolean$1 = (config = {}) => {
66
- const faker = createFaker(config.seed);
67
- return faker.datatype.boolean();
149
+ const boolean$1 = (config) => {
150
+ const faker = config.faker || createFaker(config.seed);
151
+ return faker.boolean();
68
152
  };
69
153
 
70
154
  const valueForModel = (config) => {
155
+ var _a;
156
+ const faker = config.faker || createFaker(config.seed);
71
157
  const model = config.model;
72
158
  switch (model.type) {
73
159
  case prismicT__namespace.CustomTypeModelFieldType.Boolean: {
74
160
  return boolean$1({
75
- seed: config.seed,
161
+ faker,
76
162
  model,
77
163
  ...config.config
78
164
  });
79
165
  }
80
166
  case prismicT__namespace.CustomTypeModelFieldType.Color: {
81
167
  return color({
82
- seed: config.seed,
168
+ faker,
83
169
  model,
84
170
  ...config.config
85
171
  });
86
172
  }
87
173
  case prismicT__namespace.CustomTypeModelFieldType.Link: {
88
- switch (model.config.select) {
174
+ switch ((_a = model.config) == null ? void 0 : _a.select) {
89
175
  case prismicT__namespace.CustomTypeModelLinkSelectType.Document: {
90
176
  return contentRelationship({
91
- seed: config.seed,
177
+ faker,
92
178
  model,
93
179
  ...config.config
94
180
  });
95
181
  }
96
182
  case prismicT__namespace.CustomTypeModelLinkSelectType.Media: {
97
183
  return linkToMedia({
98
- seed: config.seed,
184
+ faker,
99
185
  model,
100
186
  ...config.config
101
187
  });
102
188
  }
103
189
  default: {
104
190
  return link({
105
- seed: config.seed,
191
+ faker,
106
192
  model,
107
193
  ...config.config
108
194
  });
@@ -111,70 +197,70 @@ const valueForModel = (config) => {
111
197
  }
112
198
  case prismicT__namespace.CustomTypeModelFieldType.Date: {
113
199
  return date({
114
- seed: config.seed,
200
+ faker,
115
201
  model,
116
202
  ...config.config
117
203
  });
118
204
  }
119
205
  case prismicT__namespace.CustomTypeModelFieldType.Embed: {
120
206
  return embed$1({
121
- seed: config.seed,
207
+ faker,
122
208
  model,
123
209
  ...config.config
124
210
  });
125
211
  }
126
212
  case prismicT__namespace.CustomTypeModelFieldType.GeoPoint: {
127
213
  return geoPoint({
128
- seed: config.seed,
214
+ faker,
129
215
  model,
130
216
  ...config.config
131
217
  });
132
218
  }
133
219
  case prismicT__namespace.CustomTypeModelFieldType.Image: {
134
220
  return image$1({
135
- seed: config.seed,
221
+ faker,
136
222
  model,
137
223
  ...config.config
138
224
  });
139
225
  }
140
226
  case prismicT__namespace.CustomTypeModelFieldType.Text: {
141
227
  return keyText({
142
- seed: config.seed,
228
+ faker,
143
229
  model,
144
230
  ...config.config
145
231
  });
146
232
  }
147
233
  case prismicT__namespace.CustomTypeModelFieldType.Number: {
148
234
  return number({
149
- seed: config.seed,
235
+ faker,
150
236
  model,
151
237
  ...config.config
152
238
  });
153
239
  }
154
240
  case prismicT__namespace.CustomTypeModelFieldType.Select: {
155
241
  return select({
156
- seed: config.seed,
242
+ faker,
157
243
  model,
158
244
  ...config.config
159
245
  });
160
246
  }
161
247
  case prismicT__namespace.CustomTypeModelFieldType.Timestamp: {
162
248
  return timestamp({
163
- seed: config.seed,
249
+ faker,
164
250
  model,
165
251
  ...config.config
166
252
  });
167
253
  }
168
254
  case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
169
- 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()))) {
170
256
  return title({
171
- seed: config.seed,
257
+ faker,
172
258
  model,
173
259
  ...config.config
174
260
  });
175
261
  } else {
176
262
  return richText({
177
- seed: config.seed,
263
+ faker,
178
264
  model,
179
265
  ...config.config
180
266
  });
@@ -182,36 +268,41 @@ const valueForModel = (config) => {
182
268
  }
183
269
  case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields: {
184
270
  return integrationFields({
185
- seed: config.seed,
271
+ faker,
186
272
  model,
187
273
  ...config.config
188
274
  });
189
275
  }
190
276
  case prismicT__namespace.CustomTypeModelFieldType.UID: {
191
277
  return uid({
192
- seed: config.seed,
278
+ faker,
193
279
  model,
194
280
  ...config.config
195
281
  });
196
282
  }
197
283
  case prismicT__namespace.CustomTypeModelFieldType.Group: {
198
284
  return group({
199
- seed: config.seed,
285
+ faker,
200
286
  model,
201
287
  ...config.config
202
288
  });
203
289
  }
290
+ case prismicT__namespace.CustomTypeModelFieldType.LegacySlices:
204
291
  case prismicT__namespace.CustomTypeModelFieldType.Slices: {
205
292
  return sliceZone({
206
- seed: config.seed,
293
+ faker,
207
294
  model,
208
295
  ...config.config
209
296
  });
210
297
  }
298
+ default: {
299
+ throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
300
+ }
211
301
  }
212
302
  };
213
303
 
214
304
  const getValueConfigType = (model) => {
305
+ var _a;
215
306
  switch (model.type) {
216
307
  case prismicT__namespace.CustomTypeModelFieldType.Boolean:
217
308
  return "boolean";
@@ -228,7 +319,7 @@ const getValueConfigType = (model) => {
228
319
  case prismicT__namespace.CustomTypeModelFieldType.Image:
229
320
  return "image";
230
321
  case prismicT__namespace.CustomTypeModelFieldType.Link: {
231
- switch (model.config.select) {
322
+ switch ((_a = model.config) == null ? void 0 : _a.select) {
232
323
  case prismicT__namespace.CustomTypeModelLinkSelectType.Document:
233
324
  return "contentRelationship";
234
325
  case prismicT__namespace.CustomTypeModelLinkSelectType.Media:
@@ -242,7 +333,7 @@ const getValueConfigType = (model) => {
242
333
  case prismicT__namespace.CustomTypeModelFieldType.Select:
243
334
  return "select";
244
335
  case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
245
- 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()))) {
246
337
  return "title";
247
338
  } else {
248
339
  return "richText";
@@ -258,17 +349,21 @@ const getValueConfigType = (model) => {
258
349
  return "integrationFields";
259
350
  case prismicT__namespace.CustomTypeModelFieldType.Slices:
260
351
  return "sliceZone";
352
+ default: {
353
+ throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
354
+ }
261
355
  }
262
356
  };
263
357
  const valueForModelMap = (config) => {
264
358
  var _a;
359
+ const faker = config.faker || createFaker(config.seed);
265
360
  const result = {};
266
361
  for (const fieldId in config.map) {
267
362
  const fieldModel = config.map[fieldId];
268
363
  const fieldConfigType = getValueConfigType(fieldModel);
269
364
  const fieldConfig = (_a = config.configs) == null ? void 0 : _a[fieldConfigType];
270
365
  result[fieldId] = valueForModel({
271
- seed: config.seed,
366
+ faker,
272
367
  model: fieldModel,
273
368
  config: fieldConfig
274
369
  });
@@ -276,34 +371,34 @@ const valueForModelMap = (config) => {
276
371
  return result;
277
372
  };
278
373
 
279
- const boolean = (config = {}) => {
280
- const faker = createFaker(config.seed);
374
+ function boolean(config) {
375
+ const faker = config.faker || createFaker(config.seed);
281
376
  return {
282
377
  type: prismicT__namespace.CustomTypeModelFieldType.Boolean,
283
378
  config: {
284
- label: changeCase__namespace.capitalCase(faker.company.bsNoun())
379
+ label: changeCase__namespace.capitalCase(faker.word())
285
380
  }
286
381
  };
287
- };
382
+ }
288
383
 
289
- const color$1 = (config = {}) => {
290
- const faker = createFaker(config.seed);
384
+ const color$1 = (config) => {
385
+ const faker = config.faker || createFaker(config.seed);
291
386
  return {
292
387
  type: prismicT__namespace.CustomTypeModelFieldType.Color,
293
388
  config: {
294
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
295
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
389
+ label: changeCase__namespace.capitalCase(faker.word()),
390
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
296
391
  }
297
392
  };
298
393
  };
299
394
 
300
- const contentRelationship$1 = (config = {}) => {
301
- const faker = createFaker(config.seed);
395
+ const contentRelationship$1 = (config) => {
396
+ const faker = config.faker || createFaker(config.seed);
302
397
  return {
303
398
  type: prismicT__namespace.CustomTypeModelFieldType.Link,
304
399
  config: {
305
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
306
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
400
+ label: changeCase__namespace.capitalCase(faker.word()),
401
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
307
402
  select: prismicT__namespace.CustomTypeModelLinkSelectType.Document,
308
403
  customtypes: config.customTypeIDs,
309
404
  tags: config.tags
@@ -311,10 +406,10 @@ const contentRelationship$1 = (config = {}) => {
311
406
  };
312
407
  };
313
408
 
314
- const customType$1 = (config = {}) => {
409
+ const customType$1 = (config) => {
315
410
  var _a, _b;
316
- const faker = createFaker(config.seed);
317
- let label = config.label || changeCase__namespace.capitalCase(faker.company.bsNoun());
411
+ const faker = config.faker || createFaker(config.seed);
412
+ let label = config.label || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
318
413
  let id = config.id || changeCase__namespace.snakeCase(label);
319
414
  if (config.id && !config.label) {
320
415
  label = changeCase__namespace.capitalCase(config.id);
@@ -330,139 +425,139 @@ const customType$1 = (config = {}) => {
330
425
  return {
331
426
  id,
332
427
  label,
333
- status: (_a = config.status) != null ? _a : faker.datatype.boolean(),
334
- repeatable: (_b = config.repeatable) != null ? _b : faker.datatype.boolean(),
428
+ status: (_a = config.status) != null ? _a : faker.boolean(),
429
+ repeatable: (_b = config.repeatable) != null ? _b : faker.boolean(),
335
430
  json
336
431
  };
337
432
  };
338
433
 
339
- const date$1 = (config = {}) => {
340
- const faker = createFaker(config.seed);
434
+ const date$1 = (config) => {
435
+ const faker = config.faker || createFaker(config.seed);
341
436
  return {
342
437
  type: prismicT__namespace.CustomTypeModelFieldType.Date,
343
438
  config: {
344
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
345
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
439
+ label: changeCase__namespace.capitalCase(faker.word()),
440
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
346
441
  }
347
442
  };
348
443
  };
349
444
 
350
- const embed$2 = (config = {}) => {
351
- const faker = createFaker(config.seed);
445
+ const embed$2 = (config) => {
446
+ const faker = config.faker || createFaker(config.seed);
352
447
  return {
353
448
  type: prismicT__namespace.CustomTypeModelFieldType.Embed,
354
449
  config: {
355
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
356
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
450
+ label: changeCase__namespace.capitalCase(faker.word()),
451
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
357
452
  }
358
453
  };
359
454
  };
360
455
 
361
- const geoPoint$1 = (config = {}) => {
362
- const faker = createFaker(config.seed);
456
+ const geoPoint$1 = (config) => {
457
+ const faker = config.faker || createFaker(config.seed);
363
458
  return {
364
459
  type: prismicT__namespace.CustomTypeModelFieldType.GeoPoint,
365
460
  config: {
366
- label: changeCase__namespace.capitalCase(faker.company.bsNoun())
461
+ label: changeCase__namespace.capitalCase(faker.word())
367
462
  }
368
463
  };
369
464
  };
370
465
 
371
- const group$1 = (config = {}) => {
372
- const faker = createFaker(config.seed);
466
+ function group$1(config) {
467
+ const faker = config.faker || createFaker(config.seed);
373
468
  return {
374
469
  type: prismicT__namespace.CustomTypeModelFieldType.Group,
375
470
  config: {
376
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
471
+ label: changeCase__namespace.capitalCase(faker.word()),
377
472
  fields: config.fields || {}
378
473
  }
379
474
  };
380
- };
475
+ }
381
476
 
382
- const image$2 = (config = {}) => {
383
- const faker = createFaker(config.seed);
477
+ const image$2 = (config) => {
478
+ const faker = config.faker || createFaker(config.seed);
384
479
  const thumbnails = (config.thumbnailNames || []).map((name) => {
385
480
  return {
386
481
  name,
387
- width: faker.datatype.number({ min: 500, max: 2e3 }),
388
- height: faker.datatype.number({ min: 500, max: 2e3 })
482
+ width: faker.range(500, 2e3),
483
+ height: faker.range(500, 2e3)
389
484
  };
390
485
  });
391
486
  return {
392
487
  type: prismicT__namespace.CustomTypeModelFieldType.Image,
393
488
  config: {
394
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
489
+ label: changeCase__namespace.capitalCase(faker.word()),
395
490
  constraint: {
396
- width: config.withConstraint ? faker.datatype.number({ min: 500, max: 2e3 }) : null,
397
- height: config.withConstraint ? faker.datatype.number({ min: 500, max: 2e3 }) : null
491
+ width: config.withConstraint ? faker.range(500, 2e3) : null,
492
+ height: config.withConstraint ? faker.range(500, 2e3) : null
398
493
  },
399
494
  thumbnails
400
495
  }
401
496
  };
402
497
  };
403
498
 
404
- const integrationFields$1 = (config = {}) => {
405
- const faker = createFaker(config.seed);
499
+ const integrationFields$1 = (config) => {
500
+ const faker = config.faker || createFaker(config.seed);
406
501
  return {
407
502
  type: prismicT__namespace.CustomTypeModelFieldType.IntegrationFields,
408
503
  config: {
409
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
410
- catalog: config.catalog || changeCase__namespace.snakeCase(faker.lorem.words(4))
504
+ label: changeCase__namespace.capitalCase(faker.word()),
505
+ catalog: config.catalog || changeCase__namespace.snakeCase(faker.words(2))
411
506
  }
412
507
  };
413
508
  };
414
509
 
415
- const keyText$1 = (config = {}) => {
416
- const faker = createFaker(config.seed);
510
+ const keyText$1 = (config) => {
511
+ const faker = config.faker || createFaker(config.seed);
417
512
  return {
418
513
  type: prismicT__namespace.CustomTypeModelFieldType.Text,
419
514
  config: {
420
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
421
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
515
+ label: changeCase__namespace.capitalCase(faker.word()),
516
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
422
517
  }
423
518
  };
424
519
  };
425
520
 
426
- const link$1 = (config = {}) => {
427
- const faker = createFaker(config.seed);
521
+ const link$1 = (config) => {
522
+ const faker = config.faker || createFaker(config.seed);
428
523
  return {
429
524
  type: prismicT__namespace.CustomTypeModelFieldType.Link,
430
525
  config: {
431
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
432
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
526
+ label: changeCase__namespace.capitalCase(faker.word()),
527
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
433
528
  select: null,
434
- allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.datatype.boolean()) || void 0
529
+ allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
435
530
  }
436
531
  };
437
532
  };
438
533
 
439
- const linkToMedia$1 = (config = {}) => {
440
- const faker = createFaker(config.seed);
534
+ const linkToMedia$1 = (config) => {
535
+ const faker = config.faker || createFaker(config.seed);
441
536
  return {
442
537
  type: prismicT__namespace.CustomTypeModelFieldType.Link,
443
538
  config: {
444
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
445
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
539
+ label: changeCase__namespace.capitalCase(faker.word()),
540
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
446
541
  select: prismicT__namespace.CustomTypeModelLinkSelectType.Media
447
542
  }
448
543
  };
449
544
  };
450
545
 
451
- const number$1 = (config = {}) => {
452
- const faker = createFaker(config.seed);
546
+ const number$1 = (config) => {
547
+ const faker = config.faker || createFaker(config.seed);
453
548
  return {
454
549
  type: prismicT__namespace.CustomTypeModelFieldType.Number,
455
550
  config: {
456
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
457
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
551
+ label: changeCase__namespace.capitalCase(faker.word()),
552
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
458
553
  }
459
554
  };
460
555
  };
461
556
 
462
- const richText$1 = (config = {}) => {
557
+ const richText$1 = (config) => {
463
558
  var _a;
464
- const faker = createFaker(config.seed);
465
- const blockTypes = faker.random.arrayElements([
559
+ const faker = config.faker || createFaker(config.seed);
560
+ const blockTypes = faker.randomElements([
466
561
  prismicT__namespace.RichTextNodeType.heading1,
467
562
  prismicT__namespace.RichTextNodeType.heading2,
468
563
  prismicT__namespace.RichTextNodeType.heading3,
@@ -479,34 +574,34 @@ const richText$1 = (config = {}) => {
479
574
  prismicT__namespace.RichTextNodeType.embed,
480
575
  prismicT__namespace.RichTextNodeType.hyperlink
481
576
  ]).join(",");
482
- const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.datatype.boolean()) ? { multi: blockTypes } : { single: blockTypes };
577
+ const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.boolean()) ? { multi: blockTypes } : { single: blockTypes };
483
578
  return {
484
579
  type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
485
580
  config: {
486
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
487
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
488
- allowTargetBlank: faker.datatype.boolean() ? true : void 0,
581
+ label: changeCase__namespace.capitalCase(faker.word()),
582
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
583
+ allowTargetBlank: faker.boolean() ? true : void 0,
489
584
  ...blockTypeConfig
490
585
  }
491
586
  };
492
587
  };
493
588
 
494
- const select$1 = (config = {}) => {
495
- const faker = createFaker(config.seed);
589
+ const select$1 = (config) => {
590
+ const faker = config.faker || createFaker(config.seed);
496
591
  return {
497
592
  type: prismicT__namespace.CustomTypeModelFieldType.Select,
498
593
  config: {
499
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
500
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
594
+ label: changeCase__namespace.capitalCase(faker.word()),
595
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
501
596
  options: config.options || [],
502
597
  default_value: config.defaultValue || void 0
503
598
  }
504
599
  };
505
600
  };
506
601
 
507
- const sharedSlice$1 = (config = {}) => {
508
- const faker = createFaker(config.seed);
509
- let name = config.name || changeCase__namespace.capitalCase(faker.company.bsNoun());
602
+ const sharedSlice$1 = (config) => {
603
+ const faker = config.faker || createFaker(config.seed);
604
+ let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
510
605
  let id = config.id || changeCase__namespace.snakeCase(name);
511
606
  if (config.id && !config.name) {
512
607
  name = changeCase__namespace.pascalCase(config.id);
@@ -517,7 +612,7 @@ const sharedSlice$1 = (config = {}) => {
517
612
  type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice,
518
613
  id,
519
614
  name,
520
- description: faker.lorem.sentence(),
615
+ description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
521
616
  variations: config.variations || []
522
617
  };
523
618
  };
@@ -528,40 +623,129 @@ const sharedSliceChoice = () => {
528
623
  };
529
624
  };
530
625
 
531
- const sharedSliceVariation$1 = (config = {}) => {
532
- const faker = createFaker(config.seed);
533
- let name = config.name || changeCase__namespace.capitalCase(faker.company.bsNoun());
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);
715
+ let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
534
716
  let id = config.id || changeCase__namespace.snakeCase(name);
535
717
  if (config.id && !config.name) {
536
718
  name = changeCase__namespace.pascalCase(config.id);
537
719
  } else if (config.name && !config.name) {
538
720
  id = changeCase__namespace.snakeCase(config.name);
539
721
  }
722
+ const imageData = getMockImageData({ faker });
540
723
  return {
541
724
  id,
542
725
  name,
543
- description: faker.lorem.sentence(),
544
- docURL: faker.internet.url(),
545
- version: faker.git.shortSha(),
726
+ description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
727
+ docURL: faker.url(),
728
+ version: faker.hash(7),
546
729
  primary: config.primaryFields || {},
547
- items: config.itemsFields || {}
730
+ items: config.itemsFields || {},
731
+ imageUrl: imageData.url
548
732
  };
549
733
  };
550
734
 
551
- const slice$1 = (config = {}) => {
552
- const faker = createFaker(config.seed);
735
+ const slice$1 = (config) => {
736
+ const faker = config.faker || createFaker(config.seed);
553
737
  return {
554
738
  type: prismicT__namespace.CustomTypeModelSliceType.Slice,
555
- icon: changeCase__namespace.snakeCase(faker.company.bsNoun()),
556
- display: faker.datatype.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List,
557
- fieldset: changeCase__namespace.capitalCase(faker.lorem.words()),
558
- description: faker.lorem.sentence(),
739
+ icon: changeCase__namespace.snakeCase(faker.word()),
740
+ display: faker.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List,
741
+ fieldset: changeCase__namespace.capitalCase(faker.words(2)),
742
+ description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
559
743
  repeat: config.repeatFields || {},
560
744
  "non-repeat": config.nonRepeatFields || {}
561
745
  };
562
746
  };
563
747
 
564
- const sliceZone$1 = (config = {}) => {
748
+ const sliceZone$1 = (config) => {
565
749
  const labels = {};
566
750
  for (const choiceId in config.choices) {
567
751
  const choice = config.choices[choiceId];
@@ -579,20 +763,20 @@ const sliceZone$1 = (config = {}) => {
579
763
  };
580
764
  };
581
765
 
582
- const timestamp$1 = (config = {}) => {
583
- const faker = createFaker(config.seed);
766
+ const timestamp$1 = (config) => {
767
+ const faker = config.faker || createFaker(config.seed);
584
768
  return {
585
769
  type: prismicT__namespace.CustomTypeModelFieldType.Timestamp,
586
770
  config: {
587
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
588
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
771
+ label: changeCase__namespace.capitalCase(faker.word()),
772
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
589
773
  }
590
774
  };
591
775
  };
592
776
 
593
- const title$1 = (config = {}) => {
594
- const faker = createFaker(config.seed);
595
- const single = faker.random.arrayElements([
777
+ const title$1 = (config) => {
778
+ const faker = config.faker || createFaker(config.seed);
779
+ const single = faker.randomElements([
596
780
  "heading1",
597
781
  "heading2",
598
782
  "heading3",
@@ -603,28 +787,28 @@ const title$1 = (config = {}) => {
603
787
  return {
604
788
  type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
605
789
  config: {
606
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
607
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
790
+ label: changeCase__namespace.capitalCase(faker.word()),
791
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
608
792
  single,
609
- allowTargetBlank: faker.datatype.boolean() ? true : void 0
793
+ allowTargetBlank: faker.boolean() || void 0
610
794
  }
611
795
  };
612
796
  };
613
797
 
614
- const uid$1 = (config = {}) => {
615
- const faker = createFaker(config.seed);
798
+ const uid$1 = (config) => {
799
+ const faker = config.faker || createFaker(config.seed);
616
800
  return {
617
801
  type: prismicT__namespace.CustomTypeModelFieldType.UID,
618
802
  config: {
619
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
620
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
803
+ label: changeCase__namespace.capitalCase(faker.word()),
804
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3))
621
805
  }
622
806
  };
623
807
  };
624
808
 
625
809
  const generateFieldId = (config) => {
626
- const faker = createFaker(config.seed);
627
- return changeCase__namespace.snakeCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 })));
810
+ const faker = config.faker || createFaker(config.seed);
811
+ return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
628
812
  };
629
813
 
630
814
  const mockModelFns = {
@@ -645,18 +829,105 @@ const mockModelFns = {
645
829
  timestamp: timestamp$1,
646
830
  title: title$1
647
831
  };
648
- const buildMockGroupFieldMap = (config = {}) => {
649
- const faker = createFaker(config.seed);
832
+ const buildMockGroupFieldMap = (config) => {
833
+ const faker = config.faker || createFaker(config.seed);
650
834
  const fields = {};
651
- const fieldTypes = faker.random.arrayElements(Object.keys(mockModelFns));
835
+ const fieldTypes = faker.randomElements(Object.keys(mockModelFns));
652
836
  for (const fieldType of fieldTypes) {
653
- const fieldId = generateFieldId({ seed: config.seed });
837
+ const fieldId = generateFieldId({ faker });
654
838
  const mockModelFn = mockModelFns[fieldType];
655
- fields[fieldId] = mockModelFn({ seed: config.seed });
839
+ fields[fieldId] = mockModelFn({ faker });
656
840
  }
657
841
  return fields;
658
842
  };
659
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
+
660
931
  const index$2 = /*#__PURE__*/Object.freeze({
661
932
  __proto__: null,
662
933
  boolean: boolean,
@@ -683,14 +954,29 @@ const index$2 = /*#__PURE__*/Object.freeze({
683
954
  timestamp: timestamp$1,
684
955
  title: title$1,
685
956
  uid: uid$1,
686
- buildMockGroupFieldMap: buildMockGroupFieldMap
957
+ buildMockGroupFieldMap: buildMockGroupFieldMap,
958
+ createModelFactory: createModelMockFactory
687
959
  });
688
960
 
689
- const timestamp = (config = {}) => {
690
- const faker = createFaker(config.seed);
691
- const after = config.after || faker.date.past(20, new Date("2021-03-07")).toISOString().split("T")[0];
692
- const before = config.before || faker.date.future(20, new Date("2021-03-07")).toISOString().split("T")[0];
693
- return config.state === "empty" ? null : faker.date.between(after, before).toISOString();
961
+ const timestamp = (config) => {
962
+ const faker = config.faker || createFaker(config.seed);
963
+ if (config.state === "empty") {
964
+ return null;
965
+ } else {
966
+ let date;
967
+ const after = config.after ? new Date(config.after.toISOString().split("T")[0]) : void 0;
968
+ const before = config.before ? new Date(config.before.toISOString().split("T")[0]) : void 0;
969
+ if (after && before) {
970
+ date = faker.dateBetween(after, before);
971
+ } else if (after) {
972
+ date = faker.dateAfter(after);
973
+ } else if (before) {
974
+ date = faker.dateBefore(before);
975
+ } else {
976
+ date = faker.date();
977
+ }
978
+ return date.toISOString();
979
+ }
694
980
  };
695
981
 
696
982
  const buildAlternativeLanguage = (config) => {
@@ -702,10 +988,10 @@ const buildAlternativeLanguage = (config) => {
702
988
  };
703
989
  };
704
990
 
705
- const customType = (config = {}) => {
991
+ const customType = (config) => {
706
992
  var _a;
707
- const faker = createFaker(config.seed);
708
- 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 });
709
995
  const fieldModelsMap = Object.assign({}, ...Object.values(model.json));
710
996
  const dataFieldModelsMap = {};
711
997
  for (const key in fieldModelsMap) {
@@ -721,28 +1007,28 @@ const customType = (config = {}) => {
721
1007
  }));
722
1008
  return {
723
1009
  type: model.id,
724
- id: faker.git.shortSha(),
725
- uid: hasUID ? changeCase__namespace.snakeCase(faker.lorem.words(2)) : null,
726
- url: withURL ? faker.internet.url() : null,
727
- href: faker.internet.url(),
728
- lang: faker.lorem.word(),
729
- tags: generateTags({ seed: config.seed }),
1010
+ id: faker.hash(7),
1011
+ uid: hasUID ? changeCase__namespace.snakeCase(faker.words(faker.range(1, 3))) : null,
1012
+ url: withURL ? faker.url() : null,
1013
+ href: faker.url(),
1014
+ lang: faker.word(),
1015
+ tags: generateTags({ faker }),
730
1016
  slugs: [],
731
1017
  linked_documents: [],
732
1018
  alternate_languages: alternateLanguages,
733
- first_publication_date: timestamp({ seed: config.seed }),
734
- last_publication_date: timestamp({ seed: config.seed }),
1019
+ first_publication_date: timestamp({ faker }),
1020
+ last_publication_date: timestamp({ faker }),
735
1021
  data: valueForModelMap({
736
- seed: config.seed,
1022
+ faker,
737
1023
  map: dataFieldModelsMap,
738
1024
  configs: config.configs
739
1025
  })
740
1026
  };
741
1027
  };
742
1028
 
743
- const color = (config = {}) => {
744
- const faker = createFaker(config.seed);
745
- return config.state === "empty" ? null : faker.internet.color().toUpperCase();
1029
+ const color = (config) => {
1030
+ const faker = config.faker || createFaker(config.seed);
1031
+ return config.state === "empty" ? null : faker.hexColor().toUpperCase();
746
1032
  };
747
1033
 
748
1034
  const buildContentRelationshipField = (config) => {
@@ -760,35 +1046,37 @@ const buildContentRelationshipField = (config) => {
760
1046
  };
761
1047
 
762
1048
  const generateCustomTypeId = (config) => {
763
- const faker = createFaker(config.seed);
764
- return changeCase__namespace.snakeCase(faker.company.bsNoun());
1049
+ const faker = config.faker || createFaker(config.seed);
1050
+ return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
765
1051
  };
766
1052
 
767
- const contentRelationship = (config = {}) => {
768
- const faker = createFaker(config.seed);
1053
+ const contentRelationship = (config) => {
1054
+ var _a, _b;
1055
+ const faker = config.faker || createFaker(config.seed);
769
1056
  if (config.state === "empty") {
770
1057
  return {
771
1058
  link_type: prismicT__namespace.LinkType.Document
772
1059
  };
773
1060
  } else {
774
- const model = config.model || contentRelationship$1({ seed: config.seed });
1061
+ const model = config.model || contentRelationship$1({ faker });
775
1062
  const linkableDocuments = config.linkableDocuments ? config.linkableDocuments.filter((document2) => {
1063
+ var _a2, _b2;
776
1064
  let shouldKeep = true;
777
- if (model.config.customtypes) {
1065
+ if ((_a2 = model.config) == null ? void 0 : _a2.customtypes) {
778
1066
  shouldKeep = shouldKeep && model.config.customtypes.includes(document2.type);
779
1067
  }
780
- if (model.config.tags) {
1068
+ if ((_b2 = model.config) == null ? void 0 : _b2.tags) {
781
1069
  shouldKeep = shouldKeep && model.config.tags.some((tag) => document2.tags.includes(tag));
782
1070
  }
783
1071
  return shouldKeep;
784
1072
  }) : [
785
1073
  {
786
- ...customType({ seed: config.seed }),
787
- type: model.config.customtypes ? faker.random.arrayElement(model.config.customtypes) : generateCustomTypeId({ seed: config.seed }),
788
- tags: model.config.tags ? faker.random.arrayElements(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 })
789
1077
  }
790
1078
  ];
791
- const document = faker.random.arrayElement(linkableDocuments);
1079
+ const document = faker.randomElement(linkableDocuments);
792
1080
  if (!document) {
793
1081
  throw new Error("A linkable document could not be found.");
794
1082
  }
@@ -798,9 +1086,10 @@ const contentRelationship = (config = {}) => {
798
1086
  }
799
1087
  };
800
1088
 
801
- const date = (config = {}) => {
1089
+ const date = (config) => {
1090
+ const faker = config.faker || createFaker(config.seed);
802
1091
  return config.state === "empty" ? null : timestamp({
803
- seed: config.seed,
1092
+ faker,
804
1093
  after: config.after,
805
1094
  before: config.before,
806
1095
  state: "filled"
@@ -808,118 +1097,132 @@ const date = (config = {}) => {
808
1097
  };
809
1098
 
810
1099
  const buildEmbedField = (config) => {
811
- const faker = createFaker(config.seed);
1100
+ var _a;
1101
+ const faker = config.faker || createFaker(config.seed);
812
1102
  return {
813
- type: faker.datatype.boolean() ? prismicT__namespace.EmbedType.Link : prismicT__namespace.EmbedType.Rich,
814
- url: config.embedData.url,
815
- html: config.embedData.html,
816
- title: changeCase__namespace.capitalCase(faker.lorem.words(3)),
817
- version: faker.datatype.number({ min: 1, max: 3, precision: 10 }).toString(),
818
- cache_age: faker.datatype.number(),
819
- embed_url: config.embedData.embed_url,
820
- author_url: faker.internet.url(),
821
- author_name: faker.company.companyName(),
822
- provider_name: faker.company.companyName(),
823
- thumbnail_width: config.embedData.thumbnail_width,
824
- thumbnail_height: config.embedData.thumbnail_height,
825
- thumbnail_url: config.embedData.thumbnail_url,
826
- width: faker.datatype.number({ min: 200, max: 500 }),
827
- height: faker.datatype.number({ min: 200, max: 500 })
1103
+ embed_url: (_a = config.url) != null ? _a : faker.url(),
1104
+ html: `<div>embed html</div>`,
1105
+ ...config.data
828
1106
  };
829
1107
  };
830
1108
 
831
- const dataSet$1 = [
1109
+ const dataSet = [
832
1110
  {
833
- url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
1111
+ version: "1.0",
1112
+ type: "video",
834
1113
  embed_url: "https://www.youtube.com/embed/fiOwHYFkUz0",
835
1114
  thumbnail_url: "https://i.ytimg.com/vi/fiOwHYFkUz0/hqdefault.jpg",
836
1115
  thumbnail_height: 360,
837
1116
  thumbnail_width: 480,
838
- html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/fiOwHYFkUz0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
1117
+ html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/fiOwHYFkUz0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
1118
+ width: 200,
1119
+ height: 113
839
1120
  },
840
1121
  {
841
- url: "https://www.youtube.com/watch?v=c-ATzcy6VkI",
1122
+ version: "1.0",
1123
+ type: "video",
842
1124
  embed_url: "https://www.youtube.com/embed/c-ATzcy6VkI",
843
1125
  thumbnail_url: "https://i.ytimg.com/vi/c-ATzcy6VkI/hqdefault.jpg",
844
1126
  thumbnail_height: 360,
845
1127
  thumbnail_width: 480,
846
- html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/c-ATzcy6VkI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
1128
+ html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/c-ATzcy6VkI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
1129
+ width: 200,
1130
+ height: 113
847
1131
  },
848
1132
  {
849
- url: "https://www.youtube.com/watch?v=iewZXv94XGY",
1133
+ version: "1.0",
1134
+ type: "video",
850
1135
  embed_url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
851
1136
  thumbnail_url: "https://i.ytimg.com/vi/iewZXv94XGY/hqdefault.jpg",
852
1137
  thumbnail_height: 360,
853
1138
  thumbnail_width: 480,
854
- html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/iewZXv94XGY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
1139
+ html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/iewZXv94XGY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
1140
+ width: 200,
1141
+ height: 113
855
1142
  },
856
1143
  {
857
- url: "https://twitter.com/prismicio/status/1356293316158095361",
858
- embed_url: "https://www.youtube.com/watch?v=iewZXv94XGY",
1144
+ version: "1.0",
1145
+ type: "rich",
1146
+ embed_url: "https://twitter.com/prismicio/status/1356293316158095361",
859
1147
  thumbnail_url: null,
860
1148
  thumbnail_height: null,
861
1149
  thumbnail_width: null,
862
- html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Gatsby is a popular choice for Prismic users and we work hard on delivering a CMS that plays to its strengths.<br><br>But, what makes <a href="https://twitter.com/GatsbyJS?ref_src=twsrc%5Etfw">@GatsbyJS</a> so popular?<br><br>Here are some of <a href="https://twitter.com/mxstbr?ref_src=twsrc%5Etfw">@mxstbr</a>&#39;s thoughts on Gatsby&#39;s success and how they&#39;re improving developer experience.<a href="https://t.co/ZjCPvsWWUD">https://t.co/ZjCPvsWWUD</a> <a href="https://t.co/EQqzJpeNKl">pic.twitter.com/EQqzJpeNKl</a></p>&mdash; Prismic (@prismicio) <a href="https://twitter.com/prismicio/status/1356293316158095361?ref_src=twsrc%5Etfw">February 1, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n'
1150
+ html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Gatsby is a popular choice for Prismic users and we work hard on delivering a CMS that plays to its strengths.<br><br>But, what makes <a href="https://twitter.com/GatsbyJS?ref_src=twsrc%5Etfw">@GatsbyJS</a> so popular?<br><br>Here are some of <a href="https://twitter.com/mxstbr?ref_src=twsrc%5Etfw">@mxstbr</a>&#39;s thoughts on Gatsby&#39;s success and how they&#39;re improving developer experience.<a href="https://t.co/ZjCPvsWWUD">https://t.co/ZjCPvsWWUD</a> <a href="https://t.co/EQqzJpeNKl">pic.twitter.com/EQqzJpeNKl</a></p>&mdash; Prismic (@prismicio) <a href="https://twitter.com/prismicio/status/1356293316158095361?ref_src=twsrc%5Etfw">February 1, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n',
1151
+ width: 200,
1152
+ height: 113
863
1153
  },
864
1154
  {
865
- url: "https://twitter.com/timbenniks/status/1304146886832594944",
1155
+ type: "rich",
1156
+ version: "1.0",
1157
+ embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
866
1158
  thumbnail_url: null,
867
1159
  thumbnail_width: null,
868
1160
  thumbnail_height: null,
869
- embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
870
- html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">I\u2019ve been diving deep on <a href="https://twitter.com/prismicio?ref_src=twsrc%5Etfw">@prismicio</a> <a href="https://twitter.com/hashtag/slicemachine?src=hash&amp;ref_src=twsrc%5Etfw">#slicemachine</a> today. I made all my own components and I used custom slices. It works like a charm with <a href="https://twitter.com/nuxt_js?ref_src=twsrc%5Etfw">@nuxt_js</a>. Also: I\u2019m coding with this view. <a href="https://t.co/F0I8X9gz39">pic.twitter.com/F0I8X9gz39</a></p>&mdash; Tim Benniks (@timbenniks) <a href="https://twitter.com/timbenniks/status/1304146886832594944?ref_src=twsrc%5Etfw">September 10, 2020</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n'
1161
+ html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">I\u2019ve been diving deep on <a href="https://twitter.com/prismicio?ref_src=twsrc%5Etfw">@prismicio</a> <a href="https://twitter.com/hashtag/slicemachine?src=hash&amp;ref_src=twsrc%5Etfw">#slicemachine</a> today. I made all my own components and I used custom slices. It works like a charm with <a href="https://twitter.com/nuxt_js?ref_src=twsrc%5Etfw">@nuxt_js</a>. Also: I\u2019m coding with this view. <a href="https://t.co/F0I8X9gz39">pic.twitter.com/F0I8X9gz39</a></p>&mdash; Tim Benniks (@timbenniks) <a href="https://twitter.com/timbenniks/status/1304146886832594944?ref_src=twsrc%5Etfw">September 10, 2020</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n',
1162
+ width: 200,
1163
+ height: 113
871
1164
  },
872
1165
  {
873
- url: "https://twitter.com/prismicio/status/1354112310252630016",
1166
+ version: "1.0",
1167
+ type: "rich",
1168
+ embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
874
1169
  thumbnail_url: null,
875
1170
  thumbnail_width: null,
876
1171
  thumbnail_height: null,
877
- embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
878
- html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">We&#39;re launching a new <a href="https://twitter.com/hashtag/SliceContest?src=hash&amp;ref_src=twsrc%5Etfw">#SliceContest</a> tomorrow along with Slice Machine upgrades.<br><br>Want to know more? Join us at tomorrow&#39;s Product Meet-up\u{1F447}<a href="https://t.co/prYSypiAvB">https://t.co/prYSypiAvB</a><br><br>We can&#39;t tell you any further details for now, but here&#39;s a sneak peek at the prizes\u{1F440} <a href="https://t.co/fV1eoGlEBh">pic.twitter.com/fV1eoGlEBh</a></p>&mdash; Prismic (@prismicio) <a href="https://twitter.com/prismicio/status/1354112310252630016?ref_src=twsrc%5Etfw">January 26, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n'
1172
+ html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">We&#39;re launching a new <a href="https://twitter.com/hashtag/SliceContest?src=hash&amp;ref_src=twsrc%5Etfw">#SliceContest</a> tomorrow along with Slice Machine upgrades.<br><br>Want to know more? Join us at tomorrow&#39;s Product Meet-up\u{1F447}<a href="https://t.co/prYSypiAvB">https://t.co/prYSypiAvB</a><br><br>We can&#39;t tell you any further details for now, but here&#39;s a sneak peek at the prizes\u{1F440} <a href="https://t.co/fV1eoGlEBh">pic.twitter.com/fV1eoGlEBh</a></p>&mdash; Prismic (@prismicio) <a href="https://twitter.com/prismicio/status/1354112310252630016?ref_src=twsrc%5Etfw">January 26, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n',
1173
+ width: 200,
1174
+ height: 113
879
1175
  },
880
1176
  {
881
- url: "https://twitter.com/prismicio/status/1354835716430319617",
1177
+ version: "1.0",
1178
+ type: "rich",
1179
+ embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
882
1180
  thumbnail_url: null,
883
1181
  thumbnail_width: null,
884
1182
  thumbnail_height: null,
885
- embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
886
- html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Does anyone want to create a wildly popular website for discussing &#39;Wall Street Bets&#39; using Prismic?<br><br>It may or may not have to look a lot like <a href="https://twitter.com/hashtag/reddit?src=hash&amp;ref_src=twsrc%5Etfw">#reddit</a> and we won&#39;t make it private.<br><br>Just asking for some friends...</p>&mdash; Prismic (@prismicio) <a href="https://twitter.com/prismicio/status/1354835716430319617?ref_src=twsrc%5Etfw">January 28, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n'
1183
+ html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Does anyone want to create a wildly popular website for discussing &#39;Wall Street Bets&#39; using Prismic?<br><br>It may or may not have to look a lot like <a href="https://twitter.com/hashtag/reddit?src=hash&amp;ref_src=twsrc%5Etfw">#reddit</a> and we won&#39;t make it private.<br><br>Just asking for some friends...</p>&mdash; Prismic (@prismicio) <a href="https://twitter.com/prismicio/status/1354835716430319617?ref_src=twsrc%5Etfw">January 28, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>\n',
1184
+ width: 200,
1185
+ height: 113
887
1186
  }
888
1187
  ];
889
1188
  const getMockEmbedData = (config) => {
890
- const faker = createFaker(config.seed);
891
- return faker.random.arrayElement(dataSet$1);
892
- };
893
-
894
- const embed$1 = (config = {}) => {
895
- const embedData = getMockEmbedData({ seed: config.seed });
896
- return config.state === "empty" ? {} : buildEmbedField({ seed: config.seed, embedData });
1189
+ const faker = config.faker || createFaker(config.seed);
1190
+ return faker.randomElement(dataSet);
1191
+ };
1192
+
1193
+ const embed$1 = (config) => {
1194
+ var _a, _b, _c;
1195
+ const faker = config.faker || createFaker(config.seed);
1196
+ const data = (_a = config.data) != null ? _a : getMockEmbedData({ faker });
1197
+ return config.state === "empty" ? {} : buildEmbedField({
1198
+ faker,
1199
+ url: (_b = config.url) != null ? _b : "embed_url" in data ? data.embed_url : void 0,
1200
+ html: (_c = config.html) != null ? _c : "html" in data ? data.html : void 0,
1201
+ data
1202
+ });
897
1203
  };
898
1204
 
899
- const geoPoint = (config = {}) => {
900
- const faker = createFaker(config.seed);
901
- const coordinates = faker.address.nearbyGPSCoordinate();
1205
+ const geoPoint = (config) => {
1206
+ const faker = config.faker || createFaker(config.seed);
902
1207
  return config.state === "empty" ? {} : {
903
- longitude: Number.parseFloat(coordinates[0]),
904
- latitude: Number.parseFloat(coordinates[1])
1208
+ longitude: faker.rangeFloat(-180, 180),
1209
+ latitude: faker.rangeFloat(-90, 90)
905
1210
  };
906
1211
  };
907
1212
 
908
- const group = (config = {}) => {
1213
+ const group = (config) => {
909
1214
  var _a;
910
1215
  if (config.state === "empty") {
911
1216
  return [];
912
1217
  } else {
913
- const faker = createFaker(config.seed);
914
- const model = config.model || group$1({ seed: config.seed });
915
- const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
916
- min: 1,
917
- max: 6
918
- });
1218
+ const faker = config.faker || createFaker(config.seed);
1219
+ const model = config.model || group$1({ faker });
1220
+ const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
919
1221
  return Array(itemsCount).fill(void 0).map(() => {
1222
+ var _a2;
920
1223
  return valueForModelMap({
921
- seed: config.seed,
922
- map: model.config.fields,
1224
+ faker,
1225
+ map: ((_a2 = model.config) == null ? void 0 : _a2.fields) || {},
923
1226
  configs: config.configs
924
1227
  });
925
1228
  });
@@ -936,7 +1239,7 @@ const buildImageFieldImage = (config) => {
936
1239
  copyright: null
937
1240
  };
938
1241
  } else {
939
- const faker = createFaker(config.seed);
1242
+ const faker = config.faker || createFaker(config.seed);
940
1243
  const url = new URL(config.imageData.url);
941
1244
  const dimensions = {
942
1245
  width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
@@ -948,142 +1251,52 @@ const buildImageFieldImage = (config) => {
948
1251
  return {
949
1252
  url: url.toString(),
950
1253
  dimensions,
951
- alt: faker.lorem.sentence(),
952
- copyright: faker.lorem.sentence()
1254
+ alt: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
1255
+ copyright: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15)))
953
1256
  };
954
1257
  }
955
1258
  };
956
1259
 
957
- const dataSet = [
958
- {
959
- url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
960
- width: 4240,
961
- height: 2832
962
- },
963
- {
964
- url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
965
- width: 7372,
966
- height: 4392
967
- },
968
- {
969
- url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
970
- width: 2560,
971
- height: 1705
972
- },
973
- {
974
- url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
975
- width: 2200,
976
- height: 1467
977
- },
978
- {
979
- url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
980
- width: 5616,
981
- height: 3744
982
- },
983
- {
984
- url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
985
- width: 4240,
986
- height: 2832
987
- },
988
- {
989
- url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
990
- width: 2560,
991
- height: 1440
992
- },
993
- {
994
- url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
995
- width: 6373,
996
- height: 4253
997
- },
998
- {
999
- url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
1000
- width: 4272,
1001
- height: 2848
1002
- },
1003
- {
1004
- url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
1005
- width: 4554,
1006
- height: 3036
1007
- },
1008
- {
1009
- url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
1010
- width: 6550,
1011
- height: 4367
1012
- },
1013
- {
1014
- url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
1015
- width: 6e3,
1016
- height: 4e3
1017
- },
1018
- {
1019
- url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
1020
- width: 6e3,
1021
- height: 4e3
1022
- },
1023
- {
1024
- url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
1025
- width: 4608,
1026
- height: 3456
1027
- },
1028
- {
1029
- url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
1030
- width: 4844,
1031
- height: 3234
1032
- },
1033
- {
1034
- url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
1035
- width: 4335,
1036
- height: 6502
1037
- }
1038
- ];
1039
- const getMockImageData = (config) => {
1040
- const faker = createFaker(config.seed);
1041
- return faker.random.arrayElement(dataSet);
1042
- };
1043
-
1044
- const image$1 = (config = {}) => {
1045
- const model = config.model || image$2({ seed: config.seed });
1046
- 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 });
1047
1265
  const value = buildImageFieldImage({
1048
- seed: config.seed,
1266
+ faker,
1049
1267
  imageData,
1050
- constraint: model.config.constraint,
1268
+ constraint: (_a = model.config) == null ? void 0 : _a.constraint,
1051
1269
  state: config.state
1052
1270
  });
1053
- for (const thumbnail of model.config.thumbnails) {
1054
- value[thumbnail.name] = buildImageFieldImage({
1055
- seed: config.seed,
1056
- imageData,
1057
- constraint: {
1058
- width: thumbnail.width,
1059
- height: thumbnail.height
1060
- },
1061
- state: config.state
1062
- });
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
+ }
1063
1283
  }
1064
1284
  return value;
1065
1285
  };
1066
1286
 
1067
- const integrationFields = (config = {}) => {
1068
- const faker = createFaker(config.seed);
1069
- const imageData = getMockImageData({ seed: config.seed });
1070
- return config.state === "empty" ? null : {
1071
- id: faker.git.shortSha(),
1072
- title: changeCase__namespace.capitalCase(faker.lorem.words(3)),
1073
- description: faker.lorem.sentence(),
1074
- image_url: imageData.url,
1075
- last_update: faker.date.past(20, new Date("2021-03-07")).getTime(),
1076
- blob: config.data
1077
- };
1287
+ const integrationFields = (config) => {
1288
+ var _a;
1289
+ const data = (_a = config.data) != null ? _a : {};
1290
+ return config.state === "empty" ? null : data;
1078
1291
  };
1079
1292
 
1080
- const keyText = (config = {}) => {
1081
- const faker = createFaker(config.seed);
1082
- return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.lorem.words(3));
1293
+ const keyText = (config) => {
1294
+ const faker = config.faker || createFaker(config.seed);
1295
+ return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.words(3));
1083
1296
  };
1084
1297
 
1085
- const linkToMedia = (config = {}) => {
1086
- const faker = createFaker(config.seed);
1298
+ const linkToMedia = (config) => {
1299
+ const faker = config.faker || createFaker(config.seed);
1087
1300
  if (config.state === "empty") {
1088
1301
  return {
1089
1302
  link_type: prismicT__namespace.LinkType.Media
@@ -1091,20 +1304,20 @@ const linkToMedia = (config = {}) => {
1091
1304
  } else {
1092
1305
  return {
1093
1306
  link_type: prismicT__namespace.LinkType.Media,
1094
- name: faker.system.commonFileName(),
1095
- kind: faker.system.commonFileType(),
1096
- url: faker.internet.url(),
1097
- size: faker.datatype.number().toString(),
1098
- height: faker.datatype.number().toString(),
1099
- width: faker.datatype.number().toString()
1307
+ name: `${changeCase__namespace.snakeCase(faker.words(faker.range(1, 2)))}.example`,
1308
+ kind: changeCase__namespace.snakeCase(faker.word()),
1309
+ url: faker.url(),
1310
+ size: faker.range(500, 3e3).toString(),
1311
+ height: faker.range(500, 3e3).toString(),
1312
+ width: faker.range(500, 3e3).toString()
1100
1313
  };
1101
1314
  }
1102
1315
  };
1103
1316
 
1104
- const link = (config = {}) => {
1105
- var _a;
1106
- const faker = createFaker(config.seed);
1107
- const type = config.type || faker.random.arrayElement([
1317
+ const link = (config) => {
1318
+ var _a, _b;
1319
+ const faker = config.faker || createFaker(config.seed);
1320
+ const type = config.type || faker.randomElement([
1108
1321
  prismicT__namespace.LinkType.Web,
1109
1322
  prismicT__namespace.LinkType.Document,
1110
1323
  prismicT__namespace.LinkType.Media
@@ -1117,33 +1330,33 @@ const link = (config = {}) => {
1117
1330
  switch (type) {
1118
1331
  case prismicT__namespace.LinkType.Document: {
1119
1332
  return contentRelationship({
1120
- seed: config.seed,
1333
+ faker,
1121
1334
  state: config.state,
1122
1335
  linkableDocuments: config.linkableDocuments
1123
1336
  });
1124
1337
  }
1125
1338
  case prismicT__namespace.LinkType.Media: {
1126
1339
  return linkToMedia({
1127
- seed: config.seed,
1340
+ faker,
1128
1341
  state: config.state
1129
1342
  });
1130
1343
  }
1131
1344
  case prismicT__namespace.LinkType.Web:
1132
1345
  default: {
1133
- const model = config.model || link$1({ seed: config.seed });
1346
+ const model = config.model || link$1({ faker });
1134
1347
  return {
1135
1348
  link_type: prismicT__namespace.LinkType.Web,
1136
- url: faker.internet.url(),
1137
- target: ((_a = config.withTargetBlank) != null ? _a : model.config.allowTargetBlank && faker.datatype.boolean()) ? "_blank" : void 0
1349
+ url: faker.url(),
1350
+ target: ((_b = config.withTargetBlank) != null ? _b : ((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
1138
1351
  };
1139
1352
  }
1140
1353
  }
1141
1354
  }
1142
1355
  };
1143
1356
 
1144
- const number = (config = {}) => {
1145
- const faker = createFaker(config.seed);
1146
- return config.state === "empty" ? null : faker.datatype.number();
1357
+ const number = (config) => {
1358
+ const faker = config.faker || createFaker(config.seed);
1359
+ return config.state === "empty" ? null : faker.range(1, 100);
1147
1360
  };
1148
1361
 
1149
1362
  const patterns$5 = {
@@ -1160,27 +1373,32 @@ const patterns$5 = {
1160
1373
  maxWords: 12
1161
1374
  }
1162
1375
  };
1163
- const heading = (config = {}) => {
1164
- const faker = createFaker(config.seed);
1165
- const model = config.model || title$1({ seed: config.seed });
1166
- const types = ("single" in model.config ? model.config.single : model.config.multi).split(",").filter((type2) => [
1167
- prismicT__namespace.RichTextNodeType.heading1,
1168
- prismicT__namespace.RichTextNodeType.heading2,
1169
- prismicT__namespace.RichTextNodeType.heading3,
1170
- prismicT__namespace.RichTextNodeType.heading4,
1171
- prismicT__namespace.RichTextNodeType.heading5,
1172
- prismicT__namespace.RichTextNodeType.heading6
1173
- ].includes(type2));
1174
- const type = faker.random.arrayElement(types);
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
+ }
1395
+ const type = faker.randomElement(types);
1175
1396
  if (type) {
1176
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$5));
1397
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$5));
1177
1398
  const pattern = patterns$5[patternKey];
1178
1399
  return {
1179
1400
  type,
1180
- text: changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({
1181
- min: pattern.minWords,
1182
- max: pattern.maxWords
1183
- }))),
1401
+ text: changeCase__namespace.capitalCase(faker.words(faker.range(pattern.minWords, pattern.maxWords))),
1184
1402
  spans: []
1185
1403
  };
1186
1404
  } else {
@@ -1199,13 +1417,14 @@ const patterns$4 = {
1199
1417
  sentenceCount: 12
1200
1418
  }
1201
1419
  };
1202
- const paragraph = (config = {}) => {
1203
- const faker = createFaker(config.seed);
1204
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$4));
1420
+ const paragraph = (config) => {
1421
+ const faker = config.faker || createFaker(config.seed);
1422
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$4));
1205
1423
  const pattern = patterns$4[patternKey];
1424
+ const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
1206
1425
  return {
1207
1426
  type: prismicT__namespace.RichTextNodeType.paragraph,
1208
- text: faker.lorem.paragraph(pattern.sentenceCount),
1427
+ text,
1209
1428
  spans: []
1210
1429
  };
1211
1430
  };
@@ -1221,13 +1440,14 @@ const patterns$3 = {
1221
1440
  sentenceCount: 12
1222
1441
  }
1223
1442
  };
1224
- const preformatted = (config = {}) => {
1225
- const faker = createFaker(config.seed);
1226
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$3));
1443
+ const preformatted = (config) => {
1444
+ const faker = config.faker || createFaker(config.seed);
1445
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$3));
1227
1446
  const pattern = patterns$3[patternKey];
1447
+ const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
1228
1448
  return {
1229
1449
  type: prismicT__namespace.RichTextNodeType.preformatted,
1230
- text: faker.lorem.paragraph(pattern.sentenceCount),
1450
+ text,
1231
1451
  spans: []
1232
1452
  };
1233
1453
  };
@@ -1246,18 +1466,15 @@ const patterns$2 = {
1246
1466
  maxItems: 12
1247
1467
  }
1248
1468
  };
1249
- const list = (config = {}) => {
1250
- const faker = createFaker(config.seed);
1251
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$2));
1469
+ const list = (config) => {
1470
+ const faker = config.faker || createFaker(config.seed);
1471
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$2));
1252
1472
  const pattern = patterns$2[patternKey];
1253
- const itemsCount = faker.datatype.number({
1254
- min: pattern.minItems,
1255
- max: pattern.maxItems
1256
- });
1473
+ const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
1257
1474
  return Array(itemsCount).fill(void 0).map(() => {
1258
1475
  return {
1259
1476
  type: prismicT__namespace.RichTextNodeType.listItem,
1260
- text: faker.lorem.sentence(),
1477
+ text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
1261
1478
  spans: []
1262
1479
  };
1263
1480
  });
@@ -1277,29 +1494,27 @@ const patterns$1 = {
1277
1494
  maxItems: 12
1278
1495
  }
1279
1496
  };
1280
- const oList = (config = {}) => {
1281
- const faker = createFaker(config.seed);
1282
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$1));
1497
+ const oList = (config) => {
1498
+ const faker = config.faker || createFaker(config.seed);
1499
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$1));
1283
1500
  const pattern = patterns$1[patternKey];
1284
- const itemsCount = faker.datatype.number({
1285
- min: pattern.minItems,
1286
- max: pattern.maxItems
1287
- });
1501
+ const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
1288
1502
  return Array(itemsCount).fill(void 0).map(() => {
1289
1503
  return {
1290
1504
  type: prismicT__namespace.RichTextNodeType.oListItem,
1291
- text: faker.lorem.sentence(),
1505
+ text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
1292
1506
  spans: []
1293
1507
  };
1294
1508
  });
1295
1509
  };
1296
1510
 
1297
- const image = (config = {}) => {
1298
- const imageData = getMockImageData({ seed: config.seed });
1511
+ const image = (config) => {
1512
+ const faker = config.faker || createFaker(config.seed);
1513
+ const imageData = getMockImageData({ faker });
1299
1514
  const imageField = buildImageFieldImage({
1300
- seed: config.seed,
1515
+ faker,
1301
1516
  imageData,
1302
- state: false
1517
+ state: "filled"
1303
1518
  });
1304
1519
  return {
1305
1520
  type: prismicT__namespace.RichTextNodeType.image,
@@ -1310,9 +1525,10 @@ const image = (config = {}) => {
1310
1525
  };
1311
1526
  };
1312
1527
 
1313
- const embed = (config = {}) => {
1314
- const embedData = getMockEmbedData({ seed: config.seed });
1315
- const embedField = buildEmbedField({ seed: config.seed, embedData });
1528
+ const embed = (config) => {
1529
+ const faker = config.faker || createFaker(config.seed);
1530
+ const data = getMockEmbedData({ faker });
1531
+ const embedField = buildEmbedField({ faker, data });
1316
1532
  return {
1317
1533
  type: prismicT__namespace.RichTextNodeType.embed,
1318
1534
  oembed: embedField
@@ -1347,105 +1563,109 @@ const generators = {
1347
1563
  [prismicT__namespace.RichTextNodeType.image]: image,
1348
1564
  [prismicT__namespace.RichTextNodeType.embed]: embed
1349
1565
  };
1350
- const richText = (config = {}) => {
1351
- const faker = createFaker(config.seed);
1352
- const model = config.model || richText$1({
1353
- seed: config.seed,
1354
- withMultipleBlocks: true
1355
- });
1356
- const supportsMultipleBlocks = "multi" in model.config;
1357
- const types = ("multi" in model.config ? model.config.multi : model.config.single).split(",").filter((type) => Object.keys(generators).includes(type));
1358
- if (types.length > 0) {
1359
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns));
1360
- const pattern = patterns[patternKey];
1361
- const blockCount = supportsMultipleBlocks ? faker.datatype.number({
1362
- min: pattern.blockCountMin,
1363
- max: pattern.blockCountMax
1364
- }) : 1;
1365
- return Array(blockCount).fill(void 0).map(() => {
1366
- const type = faker.random.arrayElement(types);
1367
- const generator = generators[type];
1368
- return generator({ seed: config.seed, model });
1369
- }).flat().filter((block) => block !== void 0).slice(0, blockCount);
1370
- } else {
1566
+ const richText = (config) => {
1567
+ const faker = config.faker || createFaker(config.seed);
1568
+ if (config.state === "empty") {
1371
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
+ }
1372
1596
  }
1373
1597
  };
1374
1598
 
1375
- const select = (config = {}) => {
1376
- const faker = createFaker(config.seed);
1377
- const model = config.model || select$1({ seed: config.seed });
1378
- 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) || [];
1379
1605
  if (config.state === "empty") {
1380
1606
  return null;
1381
1607
  } else {
1382
- return typeof defaultValue === "string" && faker.datatype.boolean() ? defaultValue : faker.random.arrayElement(model.config.options);
1608
+ return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(options);
1383
1609
  }
1384
1610
  };
1385
1611
 
1386
- const slice = (config = {}) => {
1612
+ const slice = (config) => {
1387
1613
  var _a, _b;
1388
- const faker = createFaker(config.seed);
1389
- const model = config.model || slice$1({ seed: config.seed });
1390
- const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
1391
- const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.company.bsNoun());
1392
- const itemsCount = Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.datatype.number({
1393
- min: 1,
1394
- max: 6
1395
- }) : 0;
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 });
1617
+ const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
1618
+ const itemsCount = model.repeat && Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
1396
1619
  return {
1397
1620
  slice_type: sliceType,
1398
1621
  slice_label: sliceLabel,
1399
1622
  primary: valueForModelMap({
1400
- seed: config.seed,
1401
- map: model["non-repeat"],
1623
+ faker,
1624
+ map: model["non-repeat"] || {},
1402
1625
  configs: config.primaryFieldConfigs
1403
1626
  }),
1404
1627
  items: Array(itemsCount).fill(void 0).map(() => {
1405
1628
  return valueForModelMap({
1406
- seed: config.seed,
1407
- map: model.repeat,
1629
+ faker,
1630
+ map: model.repeat || {},
1408
1631
  configs: config.itemsFieldConfigs
1409
1632
  });
1410
1633
  })
1411
1634
  };
1412
1635
  };
1413
1636
 
1414
- const sharedSliceVariation = (config = {}) => {
1637
+ const sharedSliceVariation = (config) => {
1415
1638
  var _a, _b;
1416
- const faker = createFaker(config.seed);
1417
- const model = config.model || sharedSliceVariation$1({ seed: config.seed });
1418
- const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
1419
- const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.datatype.number({
1420
- min: 1,
1421
- max: 6
1422
- }) : 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;
1423
1643
  return {
1424
1644
  slice_type: sliceType,
1425
1645
  slice_label: null,
1426
1646
  variation: model.id,
1427
- version: faker.git.shortSha(),
1647
+ version: faker.hash(7),
1428
1648
  primary: valueForModelMap({
1429
- seed: config.seed,
1430
- map: model.primary,
1649
+ faker,
1650
+ map: model.primary || {},
1431
1651
  configs: config.primaryFieldConfigs
1432
1652
  }),
1433
1653
  items: Array(itemsCount).fill(void 0).map(() => {
1434
1654
  return valueForModelMap({
1435
- seed: config.seed,
1436
- map: model.items,
1655
+ faker,
1656
+ map: model.items || {},
1437
1657
  configs: config.itemsFieldConfigs
1438
1658
  });
1439
1659
  })
1440
1660
  };
1441
1661
  };
1442
1662
 
1443
- const sharedSlice = (config = {}) => {
1444
- const faker = createFaker(config.seed);
1445
- const model = config.model || sharedSlice$1({ seed: config.seed });
1446
- const variationModel = faker.random.arrayElement(model.variations);
1663
+ const sharedSlice = (config) => {
1664
+ const faker = config.faker || createFaker(config.seed);
1665
+ const model = config.model || sharedSlice$1({ faker });
1666
+ const variationModel = faker.randomElement(model.variations);
1447
1667
  return sharedSliceVariation({
1448
- seed: config.seed,
1668
+ faker,
1449
1669
  model: variationModel,
1450
1670
  itemsCount: config.itemsCount,
1451
1671
  type: model.id,
@@ -1454,28 +1674,25 @@ const sharedSlice = (config = {}) => {
1454
1674
  });
1455
1675
  };
1456
1676
 
1457
- const sliceZone = (config = {}) => {
1458
- var _a;
1677
+ const sliceZone = (config) => {
1678
+ var _a, _b;
1459
1679
  if (config.state === "empty") {
1460
1680
  return [];
1461
1681
  } else {
1462
- const faker = createFaker(config.seed);
1463
- const model = config.model || sliceZone$1({ seed: config.seed });
1464
- if (Object.keys(model.config.choices).length > 0) {
1465
- const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
1466
- min: 1,
1467
- max: 6
1468
- });
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);
1469
1686
  return Array(itemsCount).fill(void 0).map(() => {
1470
- var _a2;
1471
- const choices = Object.entries(model.config.choices);
1472
- const [choiceType, choiceModel] = faker.random.arrayElement(choices);
1473
- const choiceLabels = model.config.labels[choiceType] || [];
1474
- const choiceLabel = faker.random.arrayElement(choiceLabels);
1687
+ var _a2, _b2, _c, _d;
1688
+ const choices = ((_a2 = model.config) == null ? void 0 : _a2.choices) && Object.entries(model.config.choices) || [];
1689
+ const [choiceType, choiceModel] = faker.randomElement(choices);
1690
+ const choiceLabels = ((_c = (_b2 = model.config) == null ? void 0 : _b2.labels) == null ? void 0 : _c[choiceType]) || [];
1691
+ const choiceLabel = faker.randomElement(choiceLabels);
1475
1692
  switch (choiceModel.type) {
1476
1693
  case prismicT__namespace.CustomTypeModelSliceType.Slice: {
1477
1694
  return slice({
1478
- seed: config.seed,
1695
+ faker,
1479
1696
  model: choiceModel,
1480
1697
  type: choiceType,
1481
1698
  label: choiceLabel ? choiceLabel.name : null,
@@ -1484,10 +1701,10 @@ const sliceZone = (config = {}) => {
1484
1701
  });
1485
1702
  }
1486
1703
  case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
1487
- 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);
1488
1705
  if (sharedSliceModel) {
1489
1706
  return sharedSlice({
1490
- seed: config.seed,
1707
+ faker,
1491
1708
  model: sharedSliceModel,
1492
1709
  primaryFieldConfigs: config.primaryFieldConfigs,
1493
1710
  itemsFieldConfigs: config.itemsFieldConfigs
@@ -1502,13 +1719,14 @@ const sliceZone = (config = {}) => {
1502
1719
  }
1503
1720
  };
1504
1721
 
1505
- const title = (config = {}) => {
1722
+ const title = (config) => {
1723
+ const faker = config.faker || createFaker(config.seed);
1506
1724
  if (config.state === "empty") {
1507
1725
  return [];
1508
1726
  } else {
1509
1727
  return [
1510
1728
  heading({
1511
- seed: config.seed,
1729
+ faker,
1512
1730
  model: config.model,
1513
1731
  pattern: config.pattern
1514
1732
  })
@@ -1516,9 +1734,9 @@ const title = (config = {}) => {
1516
1734
  }
1517
1735
  };
1518
1736
 
1519
- const uid = (config = {}) => {
1520
- const faker = createFaker(config.seed);
1521
- return changeCase__namespace.snakeCase(faker.lorem.words(2));
1737
+ const uid = (config) => {
1738
+ const faker = config.faker || createFaker(config.seed);
1739
+ return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
1522
1740
  };
1523
1741
 
1524
1742
  const index$1 = /*#__PURE__*/Object.freeze({
@@ -1549,58 +1767,58 @@ const index$1 = /*#__PURE__*/Object.freeze({
1549
1767
  uid: uid
1550
1768
  });
1551
1769
 
1552
- const ref = (config = {}) => {
1770
+ const ref = (config) => {
1553
1771
  var _a;
1554
- const faker = createFaker(config.seed);
1772
+ const faker = config.faker || createFaker(config.seed);
1555
1773
  const value = {
1556
- id: faker.git.shortSha(),
1557
- ref: faker.git.shortSha(),
1774
+ id: faker.hash(16),
1775
+ ref: faker.hash(16),
1558
1776
  isMasterRef: (_a = config.isMasterRef) != null ? _a : false,
1559
- label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.company.bsNoun())
1777
+ label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.words(faker.range(1, 3)))
1560
1778
  };
1561
1779
  if (config.isScheduled) {
1562
- value.scheduledAt = timestamp({ seed: config.seed });
1780
+ value.scheduledAt = timestamp({ faker });
1563
1781
  }
1564
1782
  return value;
1565
1783
  };
1566
1784
 
1567
- const repository = (config = {}) => {
1568
- const faker = createFaker(config.seed);
1785
+ const repository = (config) => {
1786
+ const faker = config.faker || createFaker(config.seed);
1569
1787
  const types = (config.customTypeModels || []).reduce((acc, model) => {
1570
- acc[model.id] = model.label;
1788
+ acc[model.id] = model.label || model.id;
1571
1789
  return acc;
1572
1790
  }, {});
1573
1791
  return {
1574
1792
  refs: [
1575
- ref({ seed: config.seed, isMasterRef: true }),
1576
- ...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
1793
+ ref({ faker, isMasterRef: true }),
1794
+ ...config.withReleases ? [ref({ faker }), ref({ faker })] : []
1577
1795
  ],
1578
- integrationFieldsRef: ref({ seed: config.seed }).ref,
1796
+ integrationFieldsRef: ref({ faker }).ref,
1579
1797
  types,
1580
1798
  languages: [
1581
1799
  {
1582
- id: faker.lorem.word(),
1583
- name: changeCase__namespace.capitalCase(faker.lorem.word())
1800
+ id: faker.word(),
1801
+ name: changeCase__namespace.capitalCase(faker.word())
1584
1802
  }
1585
1803
  ],
1586
1804
  tags: generateTags({
1587
- seed: config.seed,
1805
+ faker,
1588
1806
  min: 1,
1589
1807
  max: 10
1590
1808
  }),
1591
1809
  forms: {},
1592
1810
  license: "All Rights Reserved",
1593
- version: faker.git.shortSha(),
1811
+ version: faker.hash(7),
1594
1812
  bookmarks: {},
1595
1813
  experiments: {},
1596
- oauth_token: faker.internet.url(),
1597
- oauth_initiate: faker.internet.url()
1814
+ oauth_token: faker.url(),
1815
+ oauth_initiate: faker.url()
1598
1816
  };
1599
1817
  };
1600
1818
 
1601
- const query = (config = {}) => {
1819
+ const query = (config) => {
1602
1820
  var _a, _b;
1603
- const faker = createFaker(config.seed);
1821
+ const faker = config.faker || createFaker(config.seed);
1604
1822
  const documents = config.documents || [];
1605
1823
  const page = Math.max(1, (_a = config.page) != null ? _a : 1);
1606
1824
  const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
@@ -1608,8 +1826,8 @@ const query = (config = {}) => {
1608
1826
  const results = documents.slice((page - 1) * pageSize, page * pageSize);
1609
1827
  return {
1610
1828
  page,
1611
- next_page: page < totalPages ? faker.internet.url() : null,
1612
- prev_page: page > 1 ? faker.internet.url() : null,
1829
+ next_page: page < totalPages ? faker.url() : null,
1830
+ prev_page: page > 1 ? faker.url() : null,
1613
1831
  total_pages: totalPages,
1614
1832
  results_size: results.length,
1615
1833
  results_per_page: pageSize,
@@ -1618,9 +1836,10 @@ const query = (config = {}) => {
1618
1836
  };
1619
1837
  };
1620
1838
 
1621
- const tags = (config = {}) => {
1839
+ const tags = (config) => {
1840
+ const faker = config.faker || createFaker(config.seed);
1622
1841
  return generateTags({
1623
- seed: config.seed,
1842
+ faker,
1624
1843
  min: 1,
1625
1844
  max: 10
1626
1845
  });
@@ -1634,7 +1853,138 @@ const index = /*#__PURE__*/Object.freeze({
1634
1853
  tags: tags
1635
1854
  });
1636
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;
1637
1983
  exports.api = index;
1984
+ exports.createAPIMockFactory = createAPIMockFactory;
1985
+ exports.createMockFactory = createMockFactory;
1986
+ exports.createModelMockFactory = createModelMockFactory;
1987
+ exports.createValueMockFactory = createValueMockFactory;
1638
1988
  exports.model = index$2;
1639
1989
  exports.value = index$1;
1640
1990
  //# sourceMappingURL=index.cjs.map