@prismicio/mock 0.0.3 → 0.0.7

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 (78) hide show
  1. package/README.md +4 -1
  2. package/dist/api/index.cjs +561 -0
  3. package/dist/api/index.cjs.map +1 -0
  4. package/dist/api/index.d.ts +36 -0
  5. package/dist/api/index.d.ts.map +1 -0
  6. package/dist/api/index.js +561 -0
  7. package/dist/api/index.js.map +1 -0
  8. package/dist/index.cjs +672 -644
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +228 -262
  11. package/dist/{index.mjs → index.js} +663 -634
  12. package/dist/index.js.map +1 -0
  13. package/dist/model/index.cjs +163 -203
  14. package/dist/model/index.cjs.map +1 -0
  15. package/dist/model/index.d.ts +70 -96
  16. package/dist/model/index.d.ts.map +1 -0
  17. package/dist/model/index.js +462 -0
  18. package/dist/model/index.js.map +1 -0
  19. package/dist/value/index.cjs +284 -499
  20. package/dist/value/index.cjs.map +1 -0
  21. package/dist/value/index.d.ts +60 -120
  22. package/dist/value/index.d.ts.map +1 -0
  23. package/dist/value/{index.mjs → index.js} +447 -608
  24. package/dist/value/index.js.map +1 -0
  25. package/package.json +25 -20
  26. package/src/api/index.ts +11 -0
  27. package/src/api/query.ts +38 -0
  28. package/src/api/ref.ts +41 -0
  29. package/src/api/repository.ts +54 -0
  30. package/src/api/tags.ts +15 -0
  31. package/src/constants.ts +3 -1
  32. package/src/index.ts +1 -0
  33. package/src/lib/buildAlternativeLanguage.ts +18 -0
  34. package/src/lib/buildContentRelationshipField.ts +12 -5
  35. package/src/lib/buildEmbedField.ts +1 -1
  36. package/src/lib/buildImageFieldImage.ts +48 -0
  37. package/src/lib/createFaker.ts +19 -10
  38. package/src/lib/generateTags.ts +10 -2
  39. package/src/lib/valueForModelMap.ts +2 -2
  40. package/src/model/buildMockGroupFieldMap.ts +65 -0
  41. package/src/model/contentRelationship.ts +14 -21
  42. package/src/model/customType.ts +49 -48
  43. package/src/model/group.ts +8 -15
  44. package/src/model/image.ts +13 -13
  45. package/src/model/index.ts +2 -0
  46. package/src/model/select.ts +11 -16
  47. package/src/model/sharedSlice.ts +23 -30
  48. package/src/model/sharedSliceVariation.ts +33 -21
  49. package/src/model/slice.ts +15 -19
  50. package/src/model/sliceZone.ts +25 -42
  51. package/src/types.ts +50 -15
  52. package/src/value/color.ts +16 -6
  53. package/src/value/contentRelationship.ts +52 -36
  54. package/src/value/customType.ts +27 -4
  55. package/src/value/date.ts +25 -9
  56. package/src/value/embed.ts +18 -6
  57. package/src/value/geoPoint.ts +21 -9
  58. package/src/value/group.ts +7 -27
  59. package/src/value/image.ts +22 -9
  60. package/src/value/integrationFields.ts +26 -14
  61. package/src/value/keyText.ts +18 -6
  62. package/src/value/link.ts +33 -34
  63. package/src/value/linkToMedia.ts +15 -20
  64. package/src/value/number.ts +16 -6
  65. package/src/value/richText/heading.ts +7 -7
  66. package/src/value/richText/image.ts +6 -2
  67. package/src/value/richText/index.ts +1 -1
  68. package/src/value/select.ts +23 -8
  69. package/src/value/sharedSlice.ts +2 -2
  70. package/src/value/sharedSliceVariation.ts +6 -34
  71. package/src/value/slice.ts +5 -30
  72. package/src/value/sliceZone.ts +44 -60
  73. package/src/value/timestamp.ts +19 -6
  74. package/src/value/title.ts +1 -1
  75. package/src/value/uid.ts +1 -1
  76. package/dist/model/index.mjs +0 -448
  77. package/src/lib/buildImageField.ts +0 -34
  78. package/src/lib/buildMockGroupFieldMap.ts +0 -84
package/README.md CHANGED
@@ -36,7 +36,9 @@ Whether you're helping us fix bugs, improve the docs, or spread the word, we'd l
36
36
 
37
37
  **Suggesting an improvement**: [Open an issue][repo-feature-request] explaining your improvement or feature so we can discuss and learn more.
38
38
 
39
- **Submitting code changes**: For small fixes, feel free to [open a PR][repo-pull-requests] with a description of your changes. For large changes, please first [open an issue][repo-feature-request] so we can discuss if and how the changes should be implemented.
39
+ **Submitting code changes**: For small fixes, feel free to [open a pull request][repo-pull-requests] with a description of your changes. For large changes, please first [open an issue][repo-feature-request] so we can discuss if and how the changes should be implemented.
40
+
41
+ For more clarity on this project and its structure you can also check out the detailed [CONTRIBUTING.md][contributing] document.
40
42
 
41
43
  ## License
42
44
 
@@ -64,6 +66,7 @@ Whether you're helping us fix bugs, improve the docs, or spread the word, we'd l
64
66
 
65
67
  [prismic-docs]: https://prismic.io/docs
66
68
  [changelog]: /CHANGELOG.md
69
+ [contributing]: ./CONTRIBUTING.md
67
70
 
68
71
  <!-- TODO: Replace link with a more useful one if available -->
69
72
 
@@ -0,0 +1,561 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const changeCase = require('change-case');
6
+ const fakerLocaleEN = require('faker/lib/locales/en/index.js');
7
+ const Faker = require('faker/lib/index.js');
8
+ const prismicT = require('@prismicio/types');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ const n = Object.create(null);
15
+ if (e) {
16
+ for (const k in e) {
17
+ if (k !== 'default') {
18
+ const d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ }
25
+ }
26
+ n["default"] = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ const changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase);
31
+ const fakerLocaleEN__namespace = /*#__PURE__*/_interopNamespace(fakerLocaleEN);
32
+ const Faker__default = /*#__PURE__*/_interopDefaultLegacy(Faker);
33
+ const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
34
+
35
+ const FAKER_SEED = 1984;
36
+
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;
43
+ }
44
+ const cacheKey = JSON.stringify(normalizedSeed);
45
+ if (createFaker.cache[cacheKey]) {
46
+ return createFaker.cache[cacheKey];
47
+ }
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 = {};
55
+
56
+ const generateTags = (config) => {
57
+ 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 }))));
63
+ };
64
+
65
+ const title = (config = {}) => {
66
+ const faker = createFaker(config.seed);
67
+ const single = faker.random.arrayElements([
68
+ "heading1",
69
+ "heading2",
70
+ "heading3",
71
+ "heading4",
72
+ "heading5",
73
+ "heading6"
74
+ ]).join(",");
75
+ return {
76
+ type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
77
+ config: {
78
+ label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
79
+ placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
80
+ single,
81
+ allowTargetBlank: faker.datatype.boolean() ? true : void 0
82
+ }
83
+ };
84
+ };
85
+
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();
91
+ };
92
+
93
+ const buildEmbedField = (config) => {
94
+ const faker = createFaker(config.seed);
95
+ 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 })
111
+ };
112
+ };
113
+
114
+ const dataSet$1 = [
115
+ {
116
+ url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
117
+ embed_url: "https://www.youtube.com/embed/fiOwHYFkUz0",
118
+ thumbnail_url: "https://i.ytimg.com/vi/fiOwHYFkUz0/hqdefault.jpg",
119
+ thumbnail_height: 360,
120
+ 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>'
122
+ },
123
+ {
124
+ url: "https://www.youtube.com/watch?v=c-ATzcy6VkI",
125
+ embed_url: "https://www.youtube.com/embed/c-ATzcy6VkI",
126
+ thumbnail_url: "https://i.ytimg.com/vi/c-ATzcy6VkI/hqdefault.jpg",
127
+ thumbnail_height: 360,
128
+ 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>'
130
+ },
131
+ {
132
+ url: "https://www.youtube.com/watch?v=iewZXv94XGY",
133
+ embed_url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
134
+ thumbnail_url: "https://i.ytimg.com/vi/iewZXv94XGY/hqdefault.jpg",
135
+ thumbnail_height: 360,
136
+ 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>'
138
+ },
139
+ {
140
+ url: "https://twitter.com/prismicio/status/1356293316158095361",
141
+ embed_url: "https://www.youtube.com/watch?v=iewZXv94XGY",
142
+ thumbnail_url: null,
143
+ thumbnail_height: null,
144
+ 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'
146
+ },
147
+ {
148
+ url: "https://twitter.com/timbenniks/status/1304146886832594944",
149
+ thumbnail_url: null,
150
+ thumbnail_width: null,
151
+ 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'
154
+ },
155
+ {
156
+ url: "https://twitter.com/prismicio/status/1354112310252630016",
157
+ thumbnail_url: null,
158
+ thumbnail_width: null,
159
+ 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'
162
+ },
163
+ {
164
+ url: "https://twitter.com/prismicio/status/1354835716430319617",
165
+ thumbnail_url: null,
166
+ thumbnail_width: null,
167
+ 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'
170
+ }
171
+ ];
172
+ const getMockEmbedData = (config) => {
173
+ const faker = createFaker(config.seed);
174
+ return faker.random.arrayElement(dataSet$1);
175
+ };
176
+
177
+ const buildImageFieldImage = (config) => {
178
+ var _a, _b, _c, _d;
179
+ if (config.state === "empty") {
180
+ return {
181
+ url: null,
182
+ dimensions: null,
183
+ alt: null,
184
+ copyright: null
185
+ };
186
+ } else {
187
+ const faker = createFaker(config.seed);
188
+ const url = new URL(config.imageData.url);
189
+ const dimensions = {
190
+ width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
191
+ height: (_d = (_c = config.constraint) == null ? void 0 : _c.height) != null ? _d : config.imageData.height
192
+ };
193
+ url.searchParams.set("w", dimensions.width.toString());
194
+ url.searchParams.set("h", dimensions.height.toString());
195
+ url.searchParams.set("fit", "crop");
196
+ return {
197
+ url: url.toString(),
198
+ dimensions,
199
+ alt: faker.lorem.sentence(),
200
+ copyright: faker.lorem.sentence()
201
+ };
202
+ }
203
+ };
204
+
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
+ const patterns$4 = {
293
+ short: {
294
+ minWords: 1,
295
+ maxWords: 3
296
+ },
297
+ medium: {
298
+ minWords: 3,
299
+ maxWords: 6
300
+ },
301
+ long: {
302
+ minWords: 6,
303
+ maxWords: 12
304
+ }
305
+ };
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);
318
+ if (type) {
319
+ const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$4));
320
+ const pattern = patterns$4[patternKey];
321
+ return {
322
+ type,
323
+ text: changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({
324
+ min: pattern.minWords,
325
+ max: pattern.maxWords
326
+ }))),
327
+ spans: []
328
+ };
329
+ } else {
330
+ return void 0;
331
+ }
332
+ };
333
+
334
+ const patterns$3 = {
335
+ short: {
336
+ sentenceCount: 2
337
+ },
338
+ medium: {
339
+ sentenceCount: 6
340
+ },
341
+ long: {
342
+ sentenceCount: 12
343
+ }
344
+ };
345
+ const paragraph = (config = {}) => {
346
+ const faker = createFaker(config.seed);
347
+ const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$3));
348
+ const pattern = patterns$3[patternKey];
349
+ return {
350
+ type: prismicT__namespace.RichTextNodeType.paragraph,
351
+ text: faker.lorem.paragraph(pattern.sentenceCount),
352
+ spans: []
353
+ };
354
+ };
355
+
356
+ const patterns$2 = {
357
+ short: {
358
+ sentenceCount: 2
359
+ },
360
+ medium: {
361
+ sentenceCount: 6
362
+ },
363
+ long: {
364
+ sentenceCount: 12
365
+ }
366
+ };
367
+ const preformatted = (config = {}) => {
368
+ const faker = createFaker(config.seed);
369
+ const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$2));
370
+ const pattern = patterns$2[patternKey];
371
+ return {
372
+ type: prismicT__namespace.RichTextNodeType.preformatted,
373
+ text: faker.lorem.paragraph(pattern.sentenceCount),
374
+ spans: []
375
+ };
376
+ };
377
+
378
+ const patterns$1 = {
379
+ short: {
380
+ minItems: 1,
381
+ maxItems: 3
382
+ },
383
+ medium: {
384
+ minItems: 3,
385
+ maxItems: 6
386
+ },
387
+ long: {
388
+ minItems: 6,
389
+ maxItems: 12
390
+ }
391
+ };
392
+ const list = (config = {}) => {
393
+ const faker = createFaker(config.seed);
394
+ const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$1));
395
+ const pattern = patterns$1[patternKey];
396
+ const itemsCount = faker.datatype.number({
397
+ min: pattern.minItems,
398
+ max: pattern.maxItems
399
+ });
400
+ return Array(itemsCount).fill(void 0).map(() => {
401
+ return {
402
+ type: prismicT__namespace.RichTextNodeType.listItem,
403
+ text: faker.lorem.sentence(),
404
+ spans: []
405
+ };
406
+ });
407
+ };
408
+
409
+ const patterns = {
410
+ short: {
411
+ minItems: 1,
412
+ maxItems: 3
413
+ },
414
+ medium: {
415
+ minItems: 3,
416
+ maxItems: 6
417
+ },
418
+ long: {
419
+ minItems: 6,
420
+ maxItems: 12
421
+ }
422
+ };
423
+ const oList = (config = {}) => {
424
+ const faker = createFaker(config.seed);
425
+ const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns));
426
+ const pattern = patterns[patternKey];
427
+ const itemsCount = faker.datatype.number({
428
+ min: pattern.minItems,
429
+ max: pattern.maxItems
430
+ });
431
+ return Array(itemsCount).fill(void 0).map(() => {
432
+ return {
433
+ type: prismicT__namespace.RichTextNodeType.oListItem,
434
+ text: faker.lorem.sentence(),
435
+ spans: []
436
+ };
437
+ });
438
+ };
439
+
440
+ const image = (config = {}) => {
441
+ const imageData = getMockImageData({ seed: config.seed });
442
+ const imageField = buildImageFieldImage({
443
+ seed: config.seed,
444
+ imageData,
445
+ state: false
446
+ });
447
+ return {
448
+ type: prismicT__namespace.RichTextNodeType.image,
449
+ alt: imageField.alt,
450
+ url: imageField.url,
451
+ copyright: imageField.copyright,
452
+ dimensions: imageField.dimensions
453
+ };
454
+ };
455
+
456
+ const embed = (config = {}) => {
457
+ const embedData = getMockEmbedData({ seed: config.seed });
458
+ const embedField = buildEmbedField({ seed: config.seed, embedData });
459
+ return {
460
+ type: prismicT__namespace.RichTextNodeType.embed,
461
+ oembed: embedField
462
+ };
463
+ };
464
+
465
+ ({
466
+ [prismicT__namespace.RichTextNodeType.heading1]: heading,
467
+ [prismicT__namespace.RichTextNodeType.heading2]: heading,
468
+ [prismicT__namespace.RichTextNodeType.heading3]: heading,
469
+ [prismicT__namespace.RichTextNodeType.heading4]: heading,
470
+ [prismicT__namespace.RichTextNodeType.heading5]: heading,
471
+ [prismicT__namespace.RichTextNodeType.heading6]: heading,
472
+ [prismicT__namespace.RichTextNodeType.paragraph]: paragraph,
473
+ [prismicT__namespace.RichTextNodeType.preformatted]: preformatted,
474
+ [prismicT__namespace.RichTextNodeType.listItem]: list,
475
+ [prismicT__namespace.RichTextNodeType.oListItem]: oList,
476
+ [prismicT__namespace.RichTextNodeType.image]: image,
477
+ [prismicT__namespace.RichTextNodeType.embed]: embed
478
+ });
479
+
480
+ const ref = (config = {}) => {
481
+ var _a;
482
+ const faker = createFaker(config.seed);
483
+ const value = {
484
+ id: faker.git.shortSha(),
485
+ ref: faker.git.shortSha(),
486
+ isMasterRef: (_a = config.isMasterRef) != null ? _a : false,
487
+ label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.company.bsNoun())
488
+ };
489
+ if (config.isScheduled) {
490
+ value.scheduledAt = timestamp({ seed: config.seed });
491
+ }
492
+ return value;
493
+ };
494
+
495
+ const repository = (config = {}) => {
496
+ const faker = createFaker(config.seed);
497
+ const types = (config.customTypeModels || []).reduce((acc, model) => {
498
+ acc[model.id] = model.label;
499
+ return acc;
500
+ }, {});
501
+ return {
502
+ refs: [
503
+ ref({ seed: config.seed, isMasterRef: true }),
504
+ ...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
505
+ ],
506
+ integrationFieldsRef: ref({ seed: config.seed }).ref,
507
+ types,
508
+ languages: [
509
+ {
510
+ id: faker.lorem.word(),
511
+ name: changeCase__namespace.capitalCase(faker.lorem.word())
512
+ }
513
+ ],
514
+ tags: generateTags({
515
+ seed: config.seed,
516
+ min: 1,
517
+ max: 10
518
+ }),
519
+ forms: {},
520
+ license: "All Rights Reserved",
521
+ version: faker.git.shortSha(),
522
+ bookmarks: {},
523
+ experiments: {},
524
+ oauth_token: faker.internet.url(),
525
+ oauth_initiate: faker.internet.url()
526
+ };
527
+ };
528
+
529
+ const query = (config = {}) => {
530
+ var _a, _b;
531
+ const faker = createFaker(config.seed);
532
+ const documents = config.documents || [];
533
+ const page = Math.max(1, (_a = config.page) != null ? _a : 1);
534
+ const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
535
+ const totalPages = Math.ceil(documents.length / pageSize);
536
+ const results = documents.slice((page - 1) * pageSize, page * pageSize);
537
+ return {
538
+ page,
539
+ next_page: page < totalPages ? faker.internet.url() : null,
540
+ prev_page: page > 1 ? faker.internet.url() : null,
541
+ total_pages: totalPages,
542
+ results_size: results.length,
543
+ results_per_page: pageSize,
544
+ total_results_size: documents.length,
545
+ results
546
+ };
547
+ };
548
+
549
+ const tags = (config = {}) => {
550
+ return generateTags({
551
+ seed: config.seed,
552
+ min: 1,
553
+ max: 10
554
+ });
555
+ };
556
+
557
+ exports.query = query;
558
+ exports.ref = ref;
559
+ exports.repository = repository;
560
+ exports.tags = tags;
561
+ //# sourceMappingURL=index.cjs.map