@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
@@ -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,43 +27,215 @@ 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))));
147
+ };
148
+
149
+ const dataSet$1 = [
150
+ {
151
+ url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
152
+ width: 4240,
153
+ height: 2832
154
+ },
155
+ {
156
+ url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
157
+ width: 7372,
158
+ height: 4392
159
+ },
160
+ {
161
+ url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
162
+ width: 2560,
163
+ height: 1705
164
+ },
165
+ {
166
+ url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
167
+ width: 2200,
168
+ height: 1467
169
+ },
170
+ {
171
+ url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
172
+ width: 5616,
173
+ height: 3744
174
+ },
175
+ {
176
+ url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
177
+ width: 4240,
178
+ height: 2832
179
+ },
180
+ {
181
+ url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
182
+ width: 2560,
183
+ height: 1440
184
+ },
185
+ {
186
+ url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
187
+ width: 6373,
188
+ height: 4253
189
+ },
190
+ {
191
+ url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
192
+ width: 4272,
193
+ height: 2848
194
+ },
195
+ {
196
+ url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
197
+ width: 4554,
198
+ height: 3036
199
+ },
200
+ {
201
+ url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
202
+ width: 6550,
203
+ height: 4367
204
+ },
205
+ {
206
+ url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
207
+ width: 6e3,
208
+ height: 4e3
209
+ },
210
+ {
211
+ url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
212
+ width: 6e3,
213
+ height: 4e3
214
+ },
215
+ {
216
+ url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
217
+ width: 4608,
218
+ height: 3456
219
+ },
220
+ {
221
+ url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
222
+ width: 4844,
223
+ height: 3234
224
+ },
225
+ {
226
+ url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
227
+ width: 4335,
228
+ height: 6502
229
+ }
230
+ ];
231
+ const getMockImageData = (config) => {
232
+ const faker = config.faker || createFaker(config.seed);
233
+ return faker.randomElement(dataSet$1);
63
234
  };
64
235
 
65
- const title = (config = {}) => {
66
- const faker = createFaker(config.seed);
67
- const single = faker.random.arrayElements([
236
+ const title = (config) => {
237
+ const faker = config.faker || createFaker(config.seed);
238
+ const single = faker.randomElements([
68
239
  "heading1",
69
240
  "heading2",
70
241
  "heading3",
@@ -75,103 +246,127 @@ const title = (config = {}) => {
75
246
  return {
76
247
  type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
77
248
  config: {
78
- label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
79
- placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
249
+ label: changeCase__namespace.capitalCase(faker.word()),
250
+ placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
80
251
  single,
81
- allowTargetBlank: faker.datatype.boolean() ? true : void 0
252
+ allowTargetBlank: faker.boolean() || void 0
82
253
  }
83
254
  };
84
255
  };
85
256
 
86
- const timestamp = (config = {}) => {
87
- const faker = createFaker(config.seed);
88
- const after = config.after || faker.date.past(20, new Date("2021-03-07")).toISOString().split("T")[0];
89
- const before = config.before || faker.date.future(20, new Date("2021-03-07")).toISOString().split("T")[0];
90
- return config.state === "empty" ? null : faker.date.between(after, before).toISOString();
257
+ const timestamp = (config) => {
258
+ const faker = config.faker || createFaker(config.seed);
259
+ if (config.state === "empty") {
260
+ return null;
261
+ } else {
262
+ let date;
263
+ const after = config.after ? new Date(config.after.toISOString().split("T")[0]) : void 0;
264
+ const before = config.before ? new Date(config.before.toISOString().split("T")[0]) : void 0;
265
+ if (after && before) {
266
+ date = faker.dateBetween(after, before);
267
+ } else if (after) {
268
+ date = faker.dateAfter(after);
269
+ } else if (before) {
270
+ date = faker.dateBefore(before);
271
+ } else {
272
+ date = faker.date();
273
+ }
274
+ return date.toISOString();
275
+ }
91
276
  };
92
277
 
93
278
  const buildEmbedField = (config) => {
94
- const faker = createFaker(config.seed);
279
+ var _a;
280
+ const faker = config.faker || createFaker(config.seed);
95
281
  return {
96
- type: faker.datatype.boolean() ? prismicT__namespace.EmbedType.Link : prismicT__namespace.EmbedType.Rich,
97
- url: config.embedData.url,
98
- html: config.embedData.html,
99
- title: changeCase__namespace.capitalCase(faker.lorem.words(3)),
100
- version: faker.datatype.number({ min: 1, max: 3, precision: 10 }).toString(),
101
- cache_age: faker.datatype.number(),
102
- embed_url: config.embedData.embed_url,
103
- author_url: faker.internet.url(),
104
- author_name: faker.company.companyName(),
105
- provider_name: faker.company.companyName(),
106
- thumbnail_width: config.embedData.thumbnail_width,
107
- thumbnail_height: config.embedData.thumbnail_height,
108
- thumbnail_url: config.embedData.thumbnail_url,
109
- width: faker.datatype.number({ min: 200, max: 500 }),
110
- height: faker.datatype.number({ min: 200, max: 500 })
282
+ embed_url: (_a = config.url) != null ? _a : faker.url(),
283
+ html: `<div>embed html</div>`,
284
+ ...config.data
111
285
  };
112
286
  };
113
287
 
114
- const dataSet$1 = [
288
+ const dataSet = [
115
289
  {
116
- url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
290
+ version: "1.0",
291
+ type: "video",
117
292
  embed_url: "https://www.youtube.com/embed/fiOwHYFkUz0",
118
293
  thumbnail_url: "https://i.ytimg.com/vi/fiOwHYFkUz0/hqdefault.jpg",
119
294
  thumbnail_height: 360,
120
295
  thumbnail_width: 480,
121
- 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>'
296
+ 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>',
297
+ width: 200,
298
+ height: 113
122
299
  },
123
300
  {
124
- url: "https://www.youtube.com/watch?v=c-ATzcy6VkI",
301
+ version: "1.0",
302
+ type: "video",
125
303
  embed_url: "https://www.youtube.com/embed/c-ATzcy6VkI",
126
304
  thumbnail_url: "https://i.ytimg.com/vi/c-ATzcy6VkI/hqdefault.jpg",
127
305
  thumbnail_height: 360,
128
306
  thumbnail_width: 480,
129
- 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>'
307
+ 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>',
308
+ width: 200,
309
+ height: 113
130
310
  },
131
311
  {
132
- url: "https://www.youtube.com/watch?v=iewZXv94XGY",
312
+ version: "1.0",
313
+ type: "video",
133
314
  embed_url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
134
315
  thumbnail_url: "https://i.ytimg.com/vi/iewZXv94XGY/hqdefault.jpg",
135
316
  thumbnail_height: 360,
136
317
  thumbnail_width: 480,
137
- 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>'
318
+ 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>',
319
+ width: 200,
320
+ height: 113
138
321
  },
139
322
  {
140
- url: "https://twitter.com/prismicio/status/1356293316158095361",
141
- embed_url: "https://www.youtube.com/watch?v=iewZXv94XGY",
323
+ version: "1.0",
324
+ type: "rich",
325
+ embed_url: "https://twitter.com/prismicio/status/1356293316158095361",
142
326
  thumbnail_url: null,
143
327
  thumbnail_height: null,
144
328
  thumbnail_width: null,
145
- 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'
329
+ 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',
330
+ width: 200,
331
+ height: 113
146
332
  },
147
333
  {
148
- url: "https://twitter.com/timbenniks/status/1304146886832594944",
334
+ type: "rich",
335
+ version: "1.0",
336
+ embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
149
337
  thumbnail_url: null,
150
338
  thumbnail_width: null,
151
339
  thumbnail_height: null,
152
- embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
153
- 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'
340
+ 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',
341
+ width: 200,
342
+ height: 113
154
343
  },
155
344
  {
156
- url: "https://twitter.com/prismicio/status/1354112310252630016",
345
+ version: "1.0",
346
+ type: "rich",
347
+ embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
157
348
  thumbnail_url: null,
158
349
  thumbnail_width: null,
159
350
  thumbnail_height: null,
160
- embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
161
- 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'
351
+ 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',
352
+ width: 200,
353
+ height: 113
162
354
  },
163
355
  {
164
- url: "https://twitter.com/prismicio/status/1354835716430319617",
356
+ version: "1.0",
357
+ type: "rich",
358
+ embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
165
359
  thumbnail_url: null,
166
360
  thumbnail_width: null,
167
361
  thumbnail_height: null,
168
- embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
169
- 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'
362
+ 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',
363
+ width: 200,
364
+ height: 113
170
365
  }
171
366
  ];
172
367
  const getMockEmbedData = (config) => {
173
- const faker = createFaker(config.seed);
174
- return faker.random.arrayElement(dataSet$1);
368
+ const faker = config.faker || createFaker(config.seed);
369
+ return faker.randomElement(dataSet);
175
370
  };
176
371
 
177
372
  const buildImageFieldImage = (config) => {
@@ -184,7 +379,7 @@ const buildImageFieldImage = (config) => {
184
379
  copyright: null
185
380
  };
186
381
  } else {
187
- const faker = createFaker(config.seed);
382
+ const faker = config.faker || createFaker(config.seed);
188
383
  const url = new URL(config.imageData.url);
189
384
  const dimensions = {
190
385
  width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
@@ -196,99 +391,12 @@ const buildImageFieldImage = (config) => {
196
391
  return {
197
392
  url: url.toString(),
198
393
  dimensions,
199
- alt: faker.lorem.sentence(),
200
- copyright: faker.lorem.sentence()
394
+ alt: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
395
+ copyright: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15)))
201
396
  };
202
397
  }
203
398
  };
204
399
 
205
- const dataSet = [
206
- {
207
- url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
208
- width: 4240,
209
- height: 2832
210
- },
211
- {
212
- url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
213
- width: 7372,
214
- height: 4392
215
- },
216
- {
217
- url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
218
- width: 2560,
219
- height: 1705
220
- },
221
- {
222
- url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
223
- width: 2200,
224
- height: 1467
225
- },
226
- {
227
- url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
228
- width: 5616,
229
- height: 3744
230
- },
231
- {
232
- url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
233
- width: 4240,
234
- height: 2832
235
- },
236
- {
237
- url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
238
- width: 2560,
239
- height: 1440
240
- },
241
- {
242
- url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
243
- width: 6373,
244
- height: 4253
245
- },
246
- {
247
- url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
248
- width: 4272,
249
- height: 2848
250
- },
251
- {
252
- url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
253
- width: 4554,
254
- height: 3036
255
- },
256
- {
257
- url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
258
- width: 6550,
259
- height: 4367
260
- },
261
- {
262
- url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
263
- width: 6e3,
264
- height: 4e3
265
- },
266
- {
267
- url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
268
- width: 6e3,
269
- height: 4e3
270
- },
271
- {
272
- url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
273
- width: 4608,
274
- height: 3456
275
- },
276
- {
277
- url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
278
- width: 4844,
279
- height: 3234
280
- },
281
- {
282
- url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
283
- width: 4335,
284
- height: 6502
285
- }
286
- ];
287
- const getMockImageData = (config) => {
288
- const faker = createFaker(config.seed);
289
- return faker.random.arrayElement(dataSet);
290
- };
291
-
292
400
  const patterns$4 = {
293
401
  short: {
294
402
  minWords: 1,
@@ -303,27 +411,32 @@ const patterns$4 = {
303
411
  maxWords: 12
304
412
  }
305
413
  };
306
- const heading = (config = {}) => {
307
- const faker = createFaker(config.seed);
308
- const model = config.model || title({ seed: config.seed });
309
- const types = ("single" in model.config ? model.config.single : model.config.multi).split(",").filter((type2) => [
310
- prismicT__namespace.RichTextNodeType.heading1,
311
- prismicT__namespace.RichTextNodeType.heading2,
312
- prismicT__namespace.RichTextNodeType.heading3,
313
- prismicT__namespace.RichTextNodeType.heading4,
314
- prismicT__namespace.RichTextNodeType.heading5,
315
- prismicT__namespace.RichTextNodeType.heading6
316
- ].includes(type2));
317
- const type = faker.random.arrayElement(types);
414
+ const headingNoteTypes = [
415
+ prismicT__namespace.RichTextNodeType.heading1,
416
+ prismicT__namespace.RichTextNodeType.heading2,
417
+ prismicT__namespace.RichTextNodeType.heading3,
418
+ prismicT__namespace.RichTextNodeType.heading4,
419
+ prismicT__namespace.RichTextNodeType.heading5,
420
+ prismicT__namespace.RichTextNodeType.heading6
421
+ ];
422
+ const heading = (config) => {
423
+ const faker = config.faker || createFaker(config.seed);
424
+ const model = config.model || title({ faker });
425
+ let types = [];
426
+ if (model.config) {
427
+ if ("single" in model.config && model.config.single) {
428
+ types = model.config.single.split(",").filter((type2) => headingNoteTypes.includes(type2));
429
+ } else if ("multi" in model.config && model.config.multi) {
430
+ types = model.config.multi.split(",").filter((type2) => headingNoteTypes.includes(type2));
431
+ }
432
+ }
433
+ const type = faker.randomElement(types);
318
434
  if (type) {
319
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$4));
435
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$4));
320
436
  const pattern = patterns$4[patternKey];
321
437
  return {
322
438
  type,
323
- text: changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({
324
- min: pattern.minWords,
325
- max: pattern.maxWords
326
- }))),
439
+ text: changeCase__namespace.capitalCase(faker.words(faker.range(pattern.minWords, pattern.maxWords))),
327
440
  spans: []
328
441
  };
329
442
  } else {
@@ -342,13 +455,14 @@ const patterns$3 = {
342
455
  sentenceCount: 12
343
456
  }
344
457
  };
345
- const paragraph = (config = {}) => {
346
- const faker = createFaker(config.seed);
347
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$3));
458
+ const paragraph = (config) => {
459
+ const faker = config.faker || createFaker(config.seed);
460
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$3));
348
461
  const pattern = patterns$3[patternKey];
462
+ const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
349
463
  return {
350
464
  type: prismicT__namespace.RichTextNodeType.paragraph,
351
- text: faker.lorem.paragraph(pattern.sentenceCount),
465
+ text,
352
466
  spans: []
353
467
  };
354
468
  };
@@ -364,13 +478,14 @@ const patterns$2 = {
364
478
  sentenceCount: 12
365
479
  }
366
480
  };
367
- const preformatted = (config = {}) => {
368
- const faker = createFaker(config.seed);
369
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$2));
481
+ const preformatted = (config) => {
482
+ const faker = config.faker || createFaker(config.seed);
483
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$2));
370
484
  const pattern = patterns$2[patternKey];
485
+ const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
371
486
  return {
372
487
  type: prismicT__namespace.RichTextNodeType.preformatted,
373
- text: faker.lorem.paragraph(pattern.sentenceCount),
488
+ text,
374
489
  spans: []
375
490
  };
376
491
  };
@@ -389,18 +504,15 @@ const patterns$1 = {
389
504
  maxItems: 12
390
505
  }
391
506
  };
392
- const list = (config = {}) => {
393
- const faker = createFaker(config.seed);
394
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$1));
507
+ const list = (config) => {
508
+ const faker = config.faker || createFaker(config.seed);
509
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$1));
395
510
  const pattern = patterns$1[patternKey];
396
- const itemsCount = faker.datatype.number({
397
- min: pattern.minItems,
398
- max: pattern.maxItems
399
- });
511
+ const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
400
512
  return Array(itemsCount).fill(void 0).map(() => {
401
513
  return {
402
514
  type: prismicT__namespace.RichTextNodeType.listItem,
403
- text: faker.lorem.sentence(),
515
+ text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
404
516
  spans: []
405
517
  };
406
518
  });
@@ -420,29 +532,27 @@ const patterns = {
420
532
  maxItems: 12
421
533
  }
422
534
  };
423
- const oList = (config = {}) => {
424
- const faker = createFaker(config.seed);
425
- const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns));
535
+ const oList = (config) => {
536
+ const faker = config.faker || createFaker(config.seed);
537
+ const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
426
538
  const pattern = patterns[patternKey];
427
- const itemsCount = faker.datatype.number({
428
- min: pattern.minItems,
429
- max: pattern.maxItems
430
- });
539
+ const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
431
540
  return Array(itemsCount).fill(void 0).map(() => {
432
541
  return {
433
542
  type: prismicT__namespace.RichTextNodeType.oListItem,
434
- text: faker.lorem.sentence(),
543
+ text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
435
544
  spans: []
436
545
  };
437
546
  });
438
547
  };
439
548
 
440
- const image = (config = {}) => {
441
- const imageData = getMockImageData({ seed: config.seed });
549
+ const image = (config) => {
550
+ const faker = config.faker || createFaker(config.seed);
551
+ const imageData = getMockImageData({ faker });
442
552
  const imageField = buildImageFieldImage({
443
- seed: config.seed,
553
+ faker,
444
554
  imageData,
445
- state: false
555
+ state: "filled"
446
556
  });
447
557
  return {
448
558
  type: prismicT__namespace.RichTextNodeType.image,
@@ -453,9 +563,10 @@ const image = (config = {}) => {
453
563
  };
454
564
  };
455
565
 
456
- const embed = (config = {}) => {
457
- const embedData = getMockEmbedData({ seed: config.seed });
458
- const embedField = buildEmbedField({ seed: config.seed, embedData });
566
+ const embed = (config) => {
567
+ const faker = config.faker || createFaker(config.seed);
568
+ const data = getMockEmbedData({ faker });
569
+ const embedField = buildEmbedField({ faker, data });
459
570
  return {
460
571
  type: prismicT__namespace.RichTextNodeType.embed,
461
572
  oembed: embedField
@@ -477,58 +588,58 @@ const embed = (config = {}) => {
477
588
  [prismicT__namespace.RichTextNodeType.embed]: embed
478
589
  });
479
590
 
480
- const ref = (config = {}) => {
591
+ const ref = (config) => {
481
592
  var _a;
482
- const faker = createFaker(config.seed);
593
+ const faker = config.faker || createFaker(config.seed);
483
594
  const value = {
484
- id: faker.git.shortSha(),
485
- ref: faker.git.shortSha(),
595
+ id: faker.hash(16),
596
+ ref: faker.hash(16),
486
597
  isMasterRef: (_a = config.isMasterRef) != null ? _a : false,
487
- label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.company.bsNoun())
598
+ label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.words(faker.range(1, 3)))
488
599
  };
489
600
  if (config.isScheduled) {
490
- value.scheduledAt = timestamp({ seed: config.seed });
601
+ value.scheduledAt = timestamp({ faker });
491
602
  }
492
603
  return value;
493
604
  };
494
605
 
495
- const repository = (config = {}) => {
496
- const faker = createFaker(config.seed);
606
+ const repository = (config) => {
607
+ const faker = config.faker || createFaker(config.seed);
497
608
  const types = (config.customTypeModels || []).reduce((acc, model) => {
498
- acc[model.id] = model.label;
609
+ acc[model.id] = model.label || model.id;
499
610
  return acc;
500
611
  }, {});
501
612
  return {
502
613
  refs: [
503
- ref({ seed: config.seed, isMasterRef: true }),
504
- ...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
614
+ ref({ faker, isMasterRef: true }),
615
+ ...config.withReleases ? [ref({ faker }), ref({ faker })] : []
505
616
  ],
506
- integrationFieldsRef: ref({ seed: config.seed }).ref,
617
+ integrationFieldsRef: ref({ faker }).ref,
507
618
  types,
508
619
  languages: [
509
620
  {
510
- id: faker.lorem.word(),
511
- name: changeCase__namespace.capitalCase(faker.lorem.word())
621
+ id: faker.word(),
622
+ name: changeCase__namespace.capitalCase(faker.word())
512
623
  }
513
624
  ],
514
625
  tags: generateTags({
515
- seed: config.seed,
626
+ faker,
516
627
  min: 1,
517
628
  max: 10
518
629
  }),
519
630
  forms: {},
520
631
  license: "All Rights Reserved",
521
- version: faker.git.shortSha(),
632
+ version: faker.hash(7),
522
633
  bookmarks: {},
523
634
  experiments: {},
524
- oauth_token: faker.internet.url(),
525
- oauth_initiate: faker.internet.url()
635
+ oauth_token: faker.url(),
636
+ oauth_initiate: faker.url()
526
637
  };
527
638
  };
528
639
 
529
- const query = (config = {}) => {
640
+ const query = (config) => {
530
641
  var _a, _b;
531
- const faker = createFaker(config.seed);
642
+ const faker = config.faker || createFaker(config.seed);
532
643
  const documents = config.documents || [];
533
644
  const page = Math.max(1, (_a = config.page) != null ? _a : 1);
534
645
  const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
@@ -536,8 +647,8 @@ const query = (config = {}) => {
536
647
  const results = documents.slice((page - 1) * pageSize, page * pageSize);
537
648
  return {
538
649
  page,
539
- next_page: page < totalPages ? faker.internet.url() : null,
540
- prev_page: page > 1 ? faker.internet.url() : null,
650
+ next_page: page < totalPages ? faker.url() : null,
651
+ prev_page: page > 1 ? faker.url() : null,
541
652
  total_pages: totalPages,
542
653
  results_size: results.length,
543
654
  results_per_page: pageSize,
@@ -546,9 +657,10 @@ const query = (config = {}) => {
546
657
  };
547
658
  };
548
659
 
549
- const tags = (config = {}) => {
660
+ const tags = (config) => {
661
+ const faker = config.faker || createFaker(config.seed);
550
662
  return generateTags({
551
- seed: config.seed,
663
+ faker,
552
664
  min: 1,
553
665
  max: 10
554
666
  });