@prismicio/mock 0.0.8 → 0.0.9
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.
- package/dist/api/index.cjs +208 -100
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +208 -100
- package/dist/api/index.js.map +1 -1
- package/dist/index.cjs +311 -213
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.js +310 -211
- package/dist/index.js.map +1 -1
- package/dist/model/index.cjs +168 -74
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.js +168 -74
- package/dist/model/index.js.map +1 -1
- package/dist/value/index.cjs +280 -182
- package/dist/value/index.cjs.map +1 -1
- package/dist/value/index.d.ts +8 -4
- package/dist/value/index.js +280 -182
- package/dist/value/index.js.map +1 -1
- package/package.json +19 -16
- package/src/api/query.ts +2 -2
- package/src/api/ref.ts +3 -3
- package/src/api/repository.ts +5 -5
- package/src/lib/buildEmbedField.ts +16 -27
- package/src/lib/buildImageFieldImage.ts +3 -2
- package/src/lib/createFaker.ts +98 -20
- package/src/lib/generateCustomTypeId.ts +1 -1
- package/src/lib/generateFieldId.ts +1 -3
- package/src/lib/generateTags.ts +4 -12
- package/src/lib/getMockEmbedData.ts +33 -12
- package/src/lib/getMockImageData.ts +1 -1
- package/src/lib/lorem.ts +112 -0
- package/src/model/boolean.ts +1 -1
- package/src/model/buildMockGroupFieldMap.ts +1 -1
- package/src/model/color.ts +2 -2
- package/src/model/contentRelationship.ts +2 -2
- package/src/model/customType.ts +3 -3
- package/src/model/date.ts +2 -2
- package/src/model/embed.ts +2 -2
- package/src/model/geoPoint.ts +1 -1
- package/src/model/group.ts +1 -1
- package/src/model/image.ts +5 -9
- package/src/model/integrationFields.ts +2 -2
- package/src/model/keyText.ts +2 -2
- package/src/model/link.ts +3 -3
- package/src/model/linkToMedia.ts +2 -2
- package/src/model/number.ts +2 -2
- package/src/model/richText.ts +6 -6
- package/src/model/select.ts +2 -2
- package/src/model/sharedSlice.ts +2 -2
- package/src/model/sharedSliceVariation.ts +4 -4
- package/src/model/slice.ts +4 -4
- package/src/model/timestamp.ts +2 -2
- package/src/model/title.ts +5 -5
- package/src/model/uid.ts +2 -2
- package/src/types.ts +7 -10
- package/src/value/boolean.ts +1 -1
- package/src/value/color.ts +1 -1
- package/src/value/contentRelationship.ts +3 -3
- package/src/value/customType.ts +5 -5
- package/src/value/embed.ts +20 -7
- package/src/value/geoPoint.ts +2 -4
- package/src/value/group.ts +1 -6
- package/src/value/integrationFields.ts +4 -4
- package/src/value/keyText.ts +1 -3
- package/src/value/link.ts +3 -3
- package/src/value/linkToMedia.ts +7 -6
- package/src/value/number.ts +1 -1
- package/src/value/richText/embed.ts +2 -2
- package/src/value/richText/heading.ts +3 -10
- package/src/value/richText/image.ts +3 -5
- package/src/value/richText/index.ts +3 -8
- package/src/value/richText/list.ts +4 -8
- package/src/value/richText/oList.ts +4 -8
- package/src/value/richText/paragraph.ts +8 -4
- package/src/value/richText/preformatted.ts +9 -5
- package/src/value/select.ts +2 -2
- package/src/value/sharedSlice.ts +1 -1
- package/src/value/sharedSliceVariation.ts +2 -6
- package/src/value/slice.ts +2 -6
- package/src/value/sliceZone.ts +4 -10
- package/src/value/timestamp.ts +28 -15
- package/src/value/uid.ts +1 -1
package/dist/value/index.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const Faker = require('faker/lib/index.js');
|
|
5
|
+
const Rand = require('rand-seed');
|
|
7
6
|
const prismicT = require('@prismicio/types');
|
|
8
7
|
const changeCase = require('change-case');
|
|
9
8
|
|
|
@@ -27,44 +26,136 @@ function _interopNamespace(e) {
|
|
|
27
26
|
return Object.freeze(n);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
const
|
|
31
|
-
const Faker__default = /*#__PURE__*/_interopDefaultLegacy(Faker);
|
|
29
|
+
const Rand__default = /*#__PURE__*/_interopDefaultLegacy(Rand);
|
|
32
30
|
const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
|
|
33
31
|
const changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase);
|
|
34
32
|
|
|
35
33
|
const FAKER_SEED = 1984;
|
|
36
34
|
|
|
35
|
+
const wordsString = "lorem ipsum dolor sit amet, consectetur adipiscing elit ut aliquam, purus sit amet luctus venenatis, lectus magna fringilla urna, porttitor rhoncus dolor purus non enim praesent elementum facilisis leo, vel fringilla est ullamcorper eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus in ornare quam viverra orci sagittis eu volutpat odio facilisis mauris sit amet massa vitae tortor condimentum lacinia quis vel eros donec ac odio tempor orci dapibus ultrices in iaculis nunc sed augue lacus, viverra vitae congue eu, consequat ac felis donec et odio pellentesque diam volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum arcu vitae elementum curabitur vitae nunc sed velit dignissim sodales ut eu sem integer vitae justo eget magna fermentum iaculis eu non diam phasellus vestibulum lorem sed risus ultricies tristique nulla aliquet enim tortor, at auctor urna nunc id cursus metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices sagittis orci, a scelerisque purus semper eget duis at tellus at urna condimentum mattis pellentesque id nibh tortor, id aliquet lectus proin nibh nisl, condimentum id venenatis a, condimentum vitae sapien pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas sed tempus, urna et pharetra pharetra, massa massa ultricies mi, quis hendrerit dolor magna eget est lorem ipsum dolor sit amet, consectetur adipiscing elit pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas integer eget aliquet nibh praesent tristique magna sit amet purus gravida quis blandit turpis cursus in hac habitasse platea dictumst quisque sagittis, purus sit amet volutpat consequat, mauris nunc congue nisi, vitae suscipit tellus mauris a diam maecenas sed enim ut sem viverra aliquet eget sit amet tellus cras adipiscing enim eu turpis egestas pretium aenean pharetra, magna ac placerat vestibulum, lectus mauris ultrices eros, in cursus turpis massa tincidunt dui ut ornare lectus sit amet est placerat in egestas erat imperdiet sed euismod nisi porta lorem mollis aliquam ut porttitor leo a diam sollicitudin tempor id eu nisl nunc mi ipsum, faucibus vitae aliquet nec, ullamcorper sit amet risus nullam eget felis eget nunc lobortis mattis aliquam faucibus purus in massa tempor nec feugiat nisl pretium fusce id velit ut tortor pretium viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi lacus, sed viverra tellus in hac habitasse platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius duis at consectetur lorem donec massa sapien, faucibus et molestie ac, feugiat sed lectus vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa, eget egestas purus viverra accumsan in nisl nisi, scelerisque eu ultrices vitae, auctor eu augue ut lectus arcu, bibendum at varius vel, pharetra vel turpis nunc eget lorem dolor, sed viverra ipsum nunc aliquet bibendum enim, facilisis gravida neque convallis a cras semper auctor neque, vitae tempus quam pellentesque nec nam aliquam sem et tortor consequat id porta nibh venenatis cras sed felis eget velit aliquet sagittis id consectetur purus ut faucibus pulvinar elementum integer enim neque, volutpat ac tincidunt vitae, semper quis lectus nulla at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum consectetur libero, id faucibus nisl tincidunt eget nullam non nisi est, sit amet facilisis magna etiam tempor, orci eu lobortis elementum, nibh tellus molestie nunc, non blandit massa enim nec dui nunc mattis enim ut tellus elementum sagittis vitae et leo duis ut diam quam nulla porttitor massa id neque aliquam vestibulum morbi blandit cursus risus, at ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget gravida cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus mauris vitae ultricies leo integer malesuada nunc vel risus commodo viverra maecenas accumsan, lacus vel facilisis volutpat, est velit egestas dui, id ornare arcu odio ut sem nulla pharetra diam sit amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc, consequat interdum varius sit amet, mattis vulputate enim nulla aliquet porttitor lacus, luctus accumsan tortor posuere ac ut consequat semper viverra nam libero justo, laoreet sit amet cursus sit amet, dictum sit amet justo donec enim diam, vulputate ut pharetra sit amet, aliquam id diam maecenas ultricies mi eget mauris pharetra et ultrices neque ornare aenean euismod elementum nisi, quis eleifend quam adipiscing vitae proin sagittis, nisl rhoncus mattis rhoncus, urna neque viverra justo, nec ultrices dui sapien eget mi proin sed libero enim, sed faucibus turpis in eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod quis viverra nibh cras pulvinar mattis nunc, sed blandit libero volutpat sed cras ornare arcu dui vivamus arcu felis, bibendum ut tristique et, egestas quis ipsum suspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque dignissim enim, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in pellentesque massa placerat duis ultricies lacus sed turpis tincidunt id aliquet risus feugiat in ante metus, dictum at tempor commodo, ullamcorper a lacus vestibulum sed arcu non odio euismod lacinia at quis risus sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit aliquam etiam erat velit, scelerisque in dictum non, consectetur a erat nam at lectus urna duis convallis convallis tellus, id interdum velit laoreet id donec ultrices tincidunt arcu, non sodales neque sodales ut etiam sit amet nisl purus, in mollis nunc sed id semper risus in hendrerit gravida rutrum quisque non tellus orci, ac auctor augue mauris augue neque, gravida in fermentum et, sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras fermentum, odio eu feugiat pretium, nibh ipsum consequat nisl, vel pretium lectus quam id leo in vitae turpis massa sed elementum tempus egestas sed sed risus pretium quam vulputate dignissim suspendisse in est ante in nibh mauris, cursus mattis molestie a, iaculis at erat pellentesque adipiscing commodo elit, at imperdiet dui accumsan sit amet nulla facilisi morbi tempus iaculis urna, id volutpat lacus laoreet non curabitur gravida arcu ac tortor dignissim convallis aenean et tortor at risus viverra adipiscing at in tellus integer feugiat scelerisque varius morbi enim nunc, faucibus a pellentesque sit amet, porttitor eget dolor morbi non arcu risus, quis varius quam quisque id diam vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit amet, consectetur adipiscing elit duis tristique sollicitudin nibh sit amet commodo nulla facilisi nullam vehicula ipsum a arcu cursus vitae congue mauris rhoncus aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas maecenas pharetra convallis posuere morbi leo urna, molestie at elementum eu, facilisis sed odio morbi quis commodo odio aenean sed adipiscing diam donec adipiscing tristique risus nec feugiat in fermentum posuere urna nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a molestie";
|
|
36
|
+
const loremWords = wordsString.split(" ");
|
|
37
|
+
const lorem = (length, wordOffset = 0) => {
|
|
38
|
+
const count = parseInt(length.substring(0, length.length - 1));
|
|
39
|
+
const countType = length.charAt(length.length - 1);
|
|
40
|
+
if (!isNaN(count) && (countType === "w" || countType === "c")) {
|
|
41
|
+
if (!lorem.spaceIndices.length) {
|
|
42
|
+
let startIndex = -1;
|
|
43
|
+
do {
|
|
44
|
+
const index = wordsString.indexOf(" ", startIndex + 1);
|
|
45
|
+
lorem.spaceIndices.push(index);
|
|
46
|
+
startIndex = index;
|
|
47
|
+
} while (startIndex !== -1);
|
|
48
|
+
}
|
|
49
|
+
if (countType === "c") {
|
|
50
|
+
return wordsString.substring(0, count);
|
|
51
|
+
} else {
|
|
52
|
+
let sentence = "";
|
|
53
|
+
const startSpaceIndex = lorem.spaceIndices[wordOffset % lorem.spaceIndices.length - 1];
|
|
54
|
+
const endSpaceIndex = lorem.spaceIndices[(wordOffset % lorem.spaceIndices.length + count) % lorem.spaceIndices.length - 1];
|
|
55
|
+
if (count + wordOffset % lorem.spaceIndices.length > lorem.spaceIndices.length) {
|
|
56
|
+
sentence += wordsString.substring(startSpaceIndex + 1) + " ";
|
|
57
|
+
const wraparoundCounts = Math.floor(count / lorem.spaceIndices.length) - 1;
|
|
58
|
+
for (let i = 0; i < wraparoundCounts; i++) {
|
|
59
|
+
sentence += wordsString + " ";
|
|
60
|
+
}
|
|
61
|
+
sentence += wordsString.substring(0, endSpaceIndex);
|
|
62
|
+
} else {
|
|
63
|
+
sentence = wordsString.substring(startSpaceIndex + 1, endSpaceIndex);
|
|
64
|
+
}
|
|
65
|
+
if (sentence.charAt(sentence.length - 1) === ",") {
|
|
66
|
+
return sentence.substring(0, sentence.length - 1);
|
|
67
|
+
} else {
|
|
68
|
+
return sentence.substring(0, sentence.length);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw new Error("Length must be of the form `${number}w` or `${number}c`");
|
|
73
|
+
};
|
|
74
|
+
lorem.spaceIndices = [];
|
|
75
|
+
|
|
37
76
|
const createFaker = (seed = FAKER_SEED) => {
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
77
|
+
const normalizedSeed = seed.toString();
|
|
78
|
+
if (createFaker.cache[normalizedSeed]) {
|
|
79
|
+
return createFaker.cache[normalizedSeed];
|
|
41
80
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const cacheKey = JSON.stringify(normalizedSeed);
|
|
45
|
-
if (createFaker.cache[cacheKey]) {
|
|
46
|
-
return createFaker.cache[cacheKey];
|
|
81
|
+
const faker = new Faker(normalizedSeed);
|
|
82
|
+
return createFaker.cache[normalizedSeed] = faker;
|
|
47
83
|
}
|
|
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
84
|
};
|
|
54
85
|
createFaker.cache = {};
|
|
86
|
+
const DAY_MS = 1e3 * 60 * 60 * 24;
|
|
87
|
+
const YEAR_MS = DAY_MS * 365;
|
|
88
|
+
const YEAR_2022_MS = 52 * (YEAR_MS + DAY_MS / 4);
|
|
89
|
+
class Faker {
|
|
90
|
+
constructor(seed) {
|
|
91
|
+
this.rand = new Rand__default["default"](seed);
|
|
92
|
+
}
|
|
93
|
+
boolean() {
|
|
94
|
+
return this.random() >= 0.5;
|
|
95
|
+
}
|
|
96
|
+
random() {
|
|
97
|
+
return this.rand.next();
|
|
98
|
+
}
|
|
99
|
+
randomElement(elements) {
|
|
100
|
+
return elements[this.range(0, elements.length)];
|
|
101
|
+
}
|
|
102
|
+
randomElements(elements) {
|
|
103
|
+
return elements.filter(() => this.boolean());
|
|
104
|
+
}
|
|
105
|
+
range(min, max) {
|
|
106
|
+
return Math.floor(this.rangeFloat(Math.ceil(min), Math.floor(max)));
|
|
107
|
+
}
|
|
108
|
+
rangeFloat(min, max) {
|
|
109
|
+
return this.random() * (max - min) + min;
|
|
110
|
+
}
|
|
111
|
+
words(length, wordOffset = this.range(0, loremWords.length)) {
|
|
112
|
+
return lorem(`${length}w`, wordOffset);
|
|
113
|
+
}
|
|
114
|
+
word() {
|
|
115
|
+
return this.randomElement(loremWords);
|
|
116
|
+
}
|
|
117
|
+
lorem(length, wordOffset = this.range(0, loremWords.length)) {
|
|
118
|
+
return lorem(length, wordOffset);
|
|
119
|
+
}
|
|
120
|
+
url() {
|
|
121
|
+
return `https://${this.word()}.example`;
|
|
122
|
+
}
|
|
123
|
+
hexColor() {
|
|
124
|
+
return `#${this.hash(6)}`;
|
|
125
|
+
}
|
|
126
|
+
hash(length) {
|
|
127
|
+
let hash = "";
|
|
128
|
+
for (let i = 0; i < length; i++) {
|
|
129
|
+
const chars = this.boolean() ? "abcdef" : "0123456789";
|
|
130
|
+
hash += chars[this.range(0, chars.length)];
|
|
131
|
+
}
|
|
132
|
+
return hash;
|
|
133
|
+
}
|
|
134
|
+
date() {
|
|
135
|
+
return new Date(YEAR_2022_MS + this.range(-YEAR_MS * 3, YEAR_MS * 3));
|
|
136
|
+
}
|
|
137
|
+
dateAfter(date) {
|
|
138
|
+
const timestamp = date.getTime();
|
|
139
|
+
return new Date(this.range(timestamp, timestamp + YEAR_MS * 3));
|
|
140
|
+
}
|
|
141
|
+
dateBefore(date) {
|
|
142
|
+
const timestamp = date.getTime();
|
|
143
|
+
return new Date(this.range(timestamp - YEAR_MS * 3, timestamp));
|
|
144
|
+
}
|
|
145
|
+
dateBetween(min, max) {
|
|
146
|
+
return new Date(this.range(min.getTime(), max.getTime()));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
55
149
|
|
|
56
150
|
const boolean = (config = {}) => {
|
|
57
151
|
const faker = createFaker(config.seed);
|
|
58
|
-
return faker.
|
|
152
|
+
return faker.boolean();
|
|
59
153
|
};
|
|
60
154
|
|
|
61
155
|
const generateTags = (config) => {
|
|
62
156
|
var _a, _b;
|
|
63
157
|
const faker = createFaker(config.seed);
|
|
64
|
-
return Array(faker.
|
|
65
|
-
min: (_a = config.min) != null ? _a : 0,
|
|
66
|
-
max: (_b = config.max) != null ? _b : 2
|
|
67
|
-
})).fill(void 0).map(() => changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 }))));
|
|
158
|
+
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))));
|
|
68
159
|
};
|
|
69
160
|
|
|
70
161
|
const valueForModel = (config) => {
|
|
@@ -281,8 +372,8 @@ const contentRelationship$1 = (config = {}) => {
|
|
|
281
372
|
return {
|
|
282
373
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
283
374
|
config: {
|
|
284
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
285
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
375
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
376
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
286
377
|
select: prismicT__namespace.CustomTypeModelLinkSelectType.Document,
|
|
287
378
|
customtypes: config.customTypeIDs,
|
|
288
379
|
tags: config.tags
|
|
@@ -293,7 +384,7 @@ const contentRelationship$1 = (config = {}) => {
|
|
|
293
384
|
const customType$1 = (config = {}) => {
|
|
294
385
|
var _a, _b;
|
|
295
386
|
const faker = createFaker(config.seed);
|
|
296
|
-
let label = config.label || changeCase__namespace.capitalCase(faker.
|
|
387
|
+
let label = config.label || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
297
388
|
let id = config.id || changeCase__namespace.snakeCase(label);
|
|
298
389
|
if (config.id && !config.label) {
|
|
299
390
|
label = changeCase__namespace.capitalCase(config.id);
|
|
@@ -309,8 +400,8 @@ const customType$1 = (config = {}) => {
|
|
|
309
400
|
return {
|
|
310
401
|
id,
|
|
311
402
|
label,
|
|
312
|
-
status: (_a = config.status) != null ? _a : faker.
|
|
313
|
-
repeatable: (_b = config.repeatable) != null ? _b : faker.
|
|
403
|
+
status: (_a = config.status) != null ? _a : faker.boolean(),
|
|
404
|
+
repeatable: (_b = config.repeatable) != null ? _b : faker.boolean(),
|
|
314
405
|
json
|
|
315
406
|
};
|
|
316
407
|
};
|
|
@@ -320,7 +411,7 @@ const group$1 = (config = {}) => {
|
|
|
320
411
|
return {
|
|
321
412
|
type: prismicT__namespace.CustomTypeModelFieldType.Group,
|
|
322
413
|
config: {
|
|
323
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
414
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
324
415
|
fields: config.fields || {}
|
|
325
416
|
}
|
|
326
417
|
};
|
|
@@ -331,17 +422,17 @@ const image$2 = (config = {}) => {
|
|
|
331
422
|
const thumbnails = (config.thumbnailNames || []).map((name) => {
|
|
332
423
|
return {
|
|
333
424
|
name,
|
|
334
|
-
width: faker.
|
|
335
|
-
height: faker.
|
|
425
|
+
width: faker.range(500, 2e3),
|
|
426
|
+
height: faker.range(500, 2e3)
|
|
336
427
|
};
|
|
337
428
|
});
|
|
338
429
|
return {
|
|
339
430
|
type: prismicT__namespace.CustomTypeModelFieldType.Image,
|
|
340
431
|
config: {
|
|
341
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
432
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
342
433
|
constraint: {
|
|
343
|
-
width: config.withConstraint ? faker.
|
|
344
|
-
height: config.withConstraint ? faker.
|
|
434
|
+
width: config.withConstraint ? faker.range(500, 2e3) : null,
|
|
435
|
+
height: config.withConstraint ? faker.range(500, 2e3) : null
|
|
345
436
|
},
|
|
346
437
|
thumbnails
|
|
347
438
|
}
|
|
@@ -353,10 +444,10 @@ const link$1 = (config = {}) => {
|
|
|
353
444
|
return {
|
|
354
445
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
355
446
|
config: {
|
|
356
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
357
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
447
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
448
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
358
449
|
select: null,
|
|
359
|
-
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.
|
|
450
|
+
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
360
451
|
}
|
|
361
452
|
};
|
|
362
453
|
};
|
|
@@ -364,7 +455,7 @@ const link$1 = (config = {}) => {
|
|
|
364
455
|
const richText$1 = (config = {}) => {
|
|
365
456
|
var _a;
|
|
366
457
|
const faker = createFaker(config.seed);
|
|
367
|
-
const blockTypes = faker.
|
|
458
|
+
const blockTypes = faker.randomElements([
|
|
368
459
|
prismicT__namespace.RichTextNodeType.heading1,
|
|
369
460
|
prismicT__namespace.RichTextNodeType.heading2,
|
|
370
461
|
prismicT__namespace.RichTextNodeType.heading3,
|
|
@@ -381,13 +472,13 @@ const richText$1 = (config = {}) => {
|
|
|
381
472
|
prismicT__namespace.RichTextNodeType.embed,
|
|
382
473
|
prismicT__namespace.RichTextNodeType.hyperlink
|
|
383
474
|
]).join(",");
|
|
384
|
-
const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.
|
|
475
|
+
const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.boolean()) ? { multi: blockTypes } : { single: blockTypes };
|
|
385
476
|
return {
|
|
386
477
|
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
387
478
|
config: {
|
|
388
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
389
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
390
|
-
allowTargetBlank: faker.
|
|
479
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
480
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
481
|
+
allowTargetBlank: faker.boolean() ? true : void 0,
|
|
391
482
|
...blockTypeConfig
|
|
392
483
|
}
|
|
393
484
|
};
|
|
@@ -398,8 +489,8 @@ const select$1 = (config = {}) => {
|
|
|
398
489
|
return {
|
|
399
490
|
type: prismicT__namespace.CustomTypeModelFieldType.Select,
|
|
400
491
|
config: {
|
|
401
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
402
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
492
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
493
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
403
494
|
options: config.options || [],
|
|
404
495
|
default_value: config.defaultValue || void 0
|
|
405
496
|
}
|
|
@@ -408,7 +499,7 @@ const select$1 = (config = {}) => {
|
|
|
408
499
|
|
|
409
500
|
const sharedSlice$1 = (config = {}) => {
|
|
410
501
|
const faker = createFaker(config.seed);
|
|
411
|
-
let name = config.name || changeCase__namespace.capitalCase(faker.
|
|
502
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
412
503
|
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
413
504
|
if (config.id && !config.name) {
|
|
414
505
|
name = changeCase__namespace.pascalCase(config.id);
|
|
@@ -419,14 +510,14 @@ const sharedSlice$1 = (config = {}) => {
|
|
|
419
510
|
type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice,
|
|
420
511
|
id,
|
|
421
512
|
name,
|
|
422
|
-
description: faker.
|
|
513
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
423
514
|
variations: config.variations || []
|
|
424
515
|
};
|
|
425
516
|
};
|
|
426
517
|
|
|
427
518
|
const sharedSliceVariation$1 = (config = {}) => {
|
|
428
519
|
const faker = createFaker(config.seed);
|
|
429
|
-
let name = config.name || changeCase__namespace.capitalCase(faker.
|
|
520
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
430
521
|
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
431
522
|
if (config.id && !config.name) {
|
|
432
523
|
name = changeCase__namespace.pascalCase(config.id);
|
|
@@ -436,9 +527,9 @@ const sharedSliceVariation$1 = (config = {}) => {
|
|
|
436
527
|
return {
|
|
437
528
|
id,
|
|
438
529
|
name,
|
|
439
|
-
description: faker.
|
|
440
|
-
docURL: faker.
|
|
441
|
-
version: faker.
|
|
530
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
531
|
+
docURL: faker.url(),
|
|
532
|
+
version: faker.hash(7),
|
|
442
533
|
primary: config.primaryFields || {},
|
|
443
534
|
items: config.itemsFields || {}
|
|
444
535
|
};
|
|
@@ -448,10 +539,10 @@ const slice$1 = (config = {}) => {
|
|
|
448
539
|
const faker = createFaker(config.seed);
|
|
449
540
|
return {
|
|
450
541
|
type: prismicT__namespace.CustomTypeModelSliceType.Slice,
|
|
451
|
-
icon: changeCase__namespace.snakeCase(faker.
|
|
452
|
-
display: faker.
|
|
453
|
-
fieldset: changeCase__namespace.capitalCase(faker.
|
|
454
|
-
description: faker.
|
|
542
|
+
icon: changeCase__namespace.snakeCase(faker.word()),
|
|
543
|
+
display: faker.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List,
|
|
544
|
+
fieldset: changeCase__namespace.capitalCase(faker.words(2)),
|
|
545
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
455
546
|
repeat: config.repeatFields || {},
|
|
456
547
|
"non-repeat": config.nonRepeatFields || {}
|
|
457
548
|
};
|
|
@@ -477,7 +568,7 @@ const sliceZone$1 = (config = {}) => {
|
|
|
477
568
|
|
|
478
569
|
const title$1 = (config = {}) => {
|
|
479
570
|
const faker = createFaker(config.seed);
|
|
480
|
-
const single = faker.
|
|
571
|
+
const single = faker.randomElements([
|
|
481
572
|
"heading1",
|
|
482
573
|
"heading2",
|
|
483
574
|
"heading3",
|
|
@@ -488,24 +579,38 @@ const title$1 = (config = {}) => {
|
|
|
488
579
|
return {
|
|
489
580
|
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
490
581
|
config: {
|
|
491
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
492
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
582
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
583
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
493
584
|
single,
|
|
494
|
-
allowTargetBlank: faker.
|
|
585
|
+
allowTargetBlank: faker.boolean() || void 0
|
|
495
586
|
}
|
|
496
587
|
};
|
|
497
588
|
};
|
|
498
589
|
|
|
499
590
|
const generateFieldId = (config) => {
|
|
500
591
|
const faker = createFaker(config.seed);
|
|
501
|
-
return changeCase__namespace.snakeCase(faker.
|
|
592
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
502
593
|
};
|
|
503
594
|
|
|
504
595
|
const timestamp = (config = {}) => {
|
|
505
596
|
const faker = createFaker(config.seed);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
597
|
+
if (config.state === "empty") {
|
|
598
|
+
return null;
|
|
599
|
+
} else {
|
|
600
|
+
let date;
|
|
601
|
+
const after = config.after ? new Date(config.after.toISOString().split("T")[0]) : void 0;
|
|
602
|
+
const before = config.before ? new Date(config.before.toISOString().split("T")[0]) : void 0;
|
|
603
|
+
if (after && before) {
|
|
604
|
+
date = faker.dateBetween(after, before);
|
|
605
|
+
} else if (after) {
|
|
606
|
+
date = faker.dateAfter(after);
|
|
607
|
+
} else if (before) {
|
|
608
|
+
date = faker.dateBefore(before);
|
|
609
|
+
} else {
|
|
610
|
+
date = faker.date();
|
|
611
|
+
}
|
|
612
|
+
return date.toISOString();
|
|
613
|
+
}
|
|
509
614
|
};
|
|
510
615
|
|
|
511
616
|
const buildAlternativeLanguage = (config) => {
|
|
@@ -536,11 +641,11 @@ const customType = (config = {}) => {
|
|
|
536
641
|
}));
|
|
537
642
|
return {
|
|
538
643
|
type: model.id,
|
|
539
|
-
id: faker.
|
|
540
|
-
uid: hasUID ? changeCase__namespace.snakeCase(faker.
|
|
541
|
-
url: withURL ? faker.
|
|
542
|
-
href: faker.
|
|
543
|
-
lang: faker.
|
|
644
|
+
id: faker.hash(7),
|
|
645
|
+
uid: hasUID ? changeCase__namespace.snakeCase(faker.words(faker.range(1, 3))) : null,
|
|
646
|
+
url: withURL ? faker.url() : null,
|
|
647
|
+
href: faker.url(),
|
|
648
|
+
lang: faker.word(),
|
|
544
649
|
tags: generateTags({ seed: config.seed }),
|
|
545
650
|
slugs: [],
|
|
546
651
|
linked_documents: [],
|
|
@@ -557,7 +662,7 @@ const customType = (config = {}) => {
|
|
|
557
662
|
|
|
558
663
|
const color = (config = {}) => {
|
|
559
664
|
const faker = createFaker(config.seed);
|
|
560
|
-
return config.state === "empty" ? null : faker.
|
|
665
|
+
return config.state === "empty" ? null : faker.hexColor().toUpperCase();
|
|
561
666
|
};
|
|
562
667
|
|
|
563
668
|
const buildContentRelationshipField = (config) => {
|
|
@@ -576,7 +681,7 @@ const buildContentRelationshipField = (config) => {
|
|
|
576
681
|
|
|
577
682
|
const generateCustomTypeId = (config) => {
|
|
578
683
|
const faker = createFaker(config.seed);
|
|
579
|
-
return changeCase__namespace.snakeCase(faker.
|
|
684
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
580
685
|
};
|
|
581
686
|
|
|
582
687
|
const contentRelationship = (config = {}) => {
|
|
@@ -599,11 +704,11 @@ const contentRelationship = (config = {}) => {
|
|
|
599
704
|
}) : [
|
|
600
705
|
{
|
|
601
706
|
...customType({ seed: config.seed }),
|
|
602
|
-
type: model.config.customtypes ? faker.
|
|
603
|
-
tags: model.config.tags ? faker.
|
|
707
|
+
type: model.config.customtypes ? faker.randomElement(model.config.customtypes) : generateCustomTypeId({ seed: config.seed }),
|
|
708
|
+
tags: model.config.tags ? faker.randomElements(model.config.tags) : generateTags({ seed: config.seed })
|
|
604
709
|
}
|
|
605
710
|
];
|
|
606
|
-
const document = faker.
|
|
711
|
+
const document = faker.randomElement(linkableDocuments);
|
|
607
712
|
if (!document) {
|
|
608
713
|
throw new Error("A linkable document could not be found.");
|
|
609
714
|
}
|
|
@@ -623,100 +728,115 @@ const date = (config = {}) => {
|
|
|
623
728
|
};
|
|
624
729
|
|
|
625
730
|
const buildEmbedField = (config) => {
|
|
731
|
+
var _a;
|
|
626
732
|
const faker = createFaker(config.seed);
|
|
627
733
|
return {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
title: changeCase__namespace.capitalCase(faker.lorem.words(3)),
|
|
632
|
-
version: faker.datatype.number({ min: 1, max: 3, precision: 10 }).toString(),
|
|
633
|
-
cache_age: faker.datatype.number(),
|
|
634
|
-
embed_url: config.embedData.embed_url,
|
|
635
|
-
author_url: faker.internet.url(),
|
|
636
|
-
author_name: faker.company.companyName(),
|
|
637
|
-
provider_name: faker.company.companyName(),
|
|
638
|
-
thumbnail_width: config.embedData.thumbnail_width,
|
|
639
|
-
thumbnail_height: config.embedData.thumbnail_height,
|
|
640
|
-
thumbnail_url: config.embedData.thumbnail_url,
|
|
641
|
-
width: faker.datatype.number({ min: 200, max: 500 }),
|
|
642
|
-
height: faker.datatype.number({ min: 200, max: 500 })
|
|
734
|
+
embed_url: (_a = config.url) != null ? _a : faker.url(),
|
|
735
|
+
html: `<div>embed html</div>`,
|
|
736
|
+
...config.data
|
|
643
737
|
};
|
|
644
738
|
};
|
|
645
739
|
|
|
646
740
|
const dataSet$1 = [
|
|
647
741
|
{
|
|
648
|
-
|
|
742
|
+
version: "1.0",
|
|
743
|
+
type: "video",
|
|
649
744
|
embed_url: "https://www.youtube.com/embed/fiOwHYFkUz0",
|
|
650
745
|
thumbnail_url: "https://i.ytimg.com/vi/fiOwHYFkUz0/hqdefault.jpg",
|
|
651
746
|
thumbnail_height: 360,
|
|
652
747
|
thumbnail_width: 480,
|
|
653
|
-
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>'
|
|
748
|
+
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>',
|
|
749
|
+
width: 200,
|
|
750
|
+
height: 113
|
|
654
751
|
},
|
|
655
752
|
{
|
|
656
|
-
|
|
753
|
+
version: "1.0",
|
|
754
|
+
type: "video",
|
|
657
755
|
embed_url: "https://www.youtube.com/embed/c-ATzcy6VkI",
|
|
658
756
|
thumbnail_url: "https://i.ytimg.com/vi/c-ATzcy6VkI/hqdefault.jpg",
|
|
659
757
|
thumbnail_height: 360,
|
|
660
758
|
thumbnail_width: 480,
|
|
661
|
-
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>'
|
|
759
|
+
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>',
|
|
760
|
+
width: 200,
|
|
761
|
+
height: 113
|
|
662
762
|
},
|
|
663
763
|
{
|
|
664
|
-
|
|
764
|
+
version: "1.0",
|
|
765
|
+
type: "video",
|
|
665
766
|
embed_url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
|
|
666
767
|
thumbnail_url: "https://i.ytimg.com/vi/iewZXv94XGY/hqdefault.jpg",
|
|
667
768
|
thumbnail_height: 360,
|
|
668
769
|
thumbnail_width: 480,
|
|
669
|
-
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>'
|
|
770
|
+
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>',
|
|
771
|
+
width: 200,
|
|
772
|
+
height: 113
|
|
670
773
|
},
|
|
671
774
|
{
|
|
672
|
-
|
|
673
|
-
|
|
775
|
+
version: "1.0",
|
|
776
|
+
type: "rich",
|
|
777
|
+
embed_url: "https://twitter.com/prismicio/status/1356293316158095361",
|
|
674
778
|
thumbnail_url: null,
|
|
675
779
|
thumbnail_height: null,
|
|
676
780
|
thumbnail_width: null,
|
|
677
|
-
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>'s thoughts on Gatsby's success and how they'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>— 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'
|
|
781
|
+
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>'s thoughts on Gatsby's success and how they'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>— 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',
|
|
782
|
+
width: 200,
|
|
783
|
+
height: 113
|
|
678
784
|
},
|
|
679
785
|
{
|
|
680
|
-
|
|
786
|
+
type: "rich",
|
|
787
|
+
version: "1.0",
|
|
788
|
+
embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
|
|
681
789
|
thumbnail_url: null,
|
|
682
790
|
thumbnail_width: null,
|
|
683
791
|
thumbnail_height: null,
|
|
684
|
-
|
|
685
|
-
|
|
792
|
+
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&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>— 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',
|
|
793
|
+
width: 200,
|
|
794
|
+
height: 113
|
|
686
795
|
},
|
|
687
796
|
{
|
|
688
|
-
|
|
797
|
+
version: "1.0",
|
|
798
|
+
type: "rich",
|
|
799
|
+
embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
|
|
689
800
|
thumbnail_url: null,
|
|
690
801
|
thumbnail_width: null,
|
|
691
802
|
thumbnail_height: null,
|
|
692
|
-
|
|
693
|
-
|
|
803
|
+
html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">We're launching a new <a href="https://twitter.com/hashtag/SliceContest?src=hash&ref_src=twsrc%5Etfw">#SliceContest</a> tomorrow along with Slice Machine upgrades.<br><br>Want to know more? Join us at tomorrow's Product Meet-up\u{1F447}<a href="https://t.co/prYSypiAvB">https://t.co/prYSypiAvB</a><br><br>We can't tell you any further details for now, but here's a sneak peek at the prizes\u{1F440} <a href="https://t.co/fV1eoGlEBh">pic.twitter.com/fV1eoGlEBh</a></p>— 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',
|
|
804
|
+
width: 200,
|
|
805
|
+
height: 113
|
|
694
806
|
},
|
|
695
807
|
{
|
|
696
|
-
|
|
808
|
+
version: "1.0",
|
|
809
|
+
type: "rich",
|
|
810
|
+
embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
|
|
697
811
|
thumbnail_url: null,
|
|
698
812
|
thumbnail_width: null,
|
|
699
813
|
thumbnail_height: null,
|
|
700
|
-
|
|
701
|
-
|
|
814
|
+
html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Does anyone want to create a wildly popular website for discussing 'Wall Street Bets' using Prismic?<br><br>It may or may not have to look a lot like <a href="https://twitter.com/hashtag/reddit?src=hash&ref_src=twsrc%5Etfw">#reddit</a> and we won't make it private.<br><br>Just asking for some friends...</p>— 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',
|
|
815
|
+
width: 200,
|
|
816
|
+
height: 113
|
|
702
817
|
}
|
|
703
818
|
];
|
|
704
819
|
const getMockEmbedData = (config) => {
|
|
705
820
|
const faker = createFaker(config.seed);
|
|
706
|
-
return faker.
|
|
821
|
+
return faker.randomElement(dataSet$1);
|
|
707
822
|
};
|
|
708
823
|
|
|
709
824
|
const embed$1 = (config = {}) => {
|
|
710
|
-
|
|
711
|
-
|
|
825
|
+
var _a, _b, _c;
|
|
826
|
+
const data = (_a = config.data) != null ? _a : getMockEmbedData({ seed: config.seed });
|
|
827
|
+
return config.state === "empty" ? {} : buildEmbedField({
|
|
828
|
+
seed: config.seed,
|
|
829
|
+
url: (_b = config.url) != null ? _b : "embed_url" in data ? data.embed_url : void 0,
|
|
830
|
+
html: (_c = config.html) != null ? _c : "html" in data ? data.html : void 0,
|
|
831
|
+
data
|
|
832
|
+
});
|
|
712
833
|
};
|
|
713
834
|
|
|
714
835
|
const geoPoint = (config = {}) => {
|
|
715
836
|
const faker = createFaker(config.seed);
|
|
716
|
-
const coordinates = faker.address.nearbyGPSCoordinate();
|
|
717
837
|
return config.state === "empty" ? {} : {
|
|
718
|
-
longitude:
|
|
719
|
-
latitude:
|
|
838
|
+
longitude: faker.rangeFloat(-180, 180),
|
|
839
|
+
latitude: faker.rangeFloat(-90, 90)
|
|
720
840
|
};
|
|
721
841
|
};
|
|
722
842
|
|
|
@@ -727,10 +847,7 @@ const group = (config = {}) => {
|
|
|
727
847
|
} else {
|
|
728
848
|
const faker = createFaker(config.seed);
|
|
729
849
|
const model = config.model || group$1({ seed: config.seed });
|
|
730
|
-
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.
|
|
731
|
-
min: 1,
|
|
732
|
-
max: 6
|
|
733
|
-
});
|
|
850
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
|
|
734
851
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
735
852
|
return valueForModelMap({
|
|
736
853
|
seed: config.seed,
|
|
@@ -763,8 +880,8 @@ const buildImageFieldImage = (config) => {
|
|
|
763
880
|
return {
|
|
764
881
|
url: url.toString(),
|
|
765
882
|
dimensions,
|
|
766
|
-
alt: faker.
|
|
767
|
-
copyright: faker.
|
|
883
|
+
alt: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
|
|
884
|
+
copyright: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15)))
|
|
768
885
|
};
|
|
769
886
|
}
|
|
770
887
|
};
|
|
@@ -853,7 +970,7 @@ const dataSet = [
|
|
|
853
970
|
];
|
|
854
971
|
const getMockImageData = (config) => {
|
|
855
972
|
const faker = createFaker(config.seed);
|
|
856
|
-
return faker.
|
|
973
|
+
return faker.randomElement(dataSet);
|
|
857
974
|
};
|
|
858
975
|
|
|
859
976
|
const image$1 = (config = {}) => {
|
|
@@ -883,18 +1000,18 @@ const integrationFields = (config = {}) => {
|
|
|
883
1000
|
const faker = createFaker(config.seed);
|
|
884
1001
|
const imageData = getMockImageData({ seed: config.seed });
|
|
885
1002
|
return config.state === "empty" ? null : {
|
|
886
|
-
id: faker.
|
|
887
|
-
title: changeCase__namespace.capitalCase(faker.
|
|
888
|
-
description: faker.
|
|
1003
|
+
id: faker.hash(7),
|
|
1004
|
+
title: changeCase__namespace.capitalCase(faker.words(faker.range(1, 3))),
|
|
1005
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
889
1006
|
image_url: imageData.url,
|
|
890
|
-
last_update: faker.date
|
|
1007
|
+
last_update: faker.date().getTime(),
|
|
891
1008
|
blob: config.data
|
|
892
1009
|
};
|
|
893
1010
|
};
|
|
894
1011
|
|
|
895
1012
|
const keyText = (config = {}) => {
|
|
896
1013
|
const faker = createFaker(config.seed);
|
|
897
|
-
return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.
|
|
1014
|
+
return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.words(3));
|
|
898
1015
|
};
|
|
899
1016
|
|
|
900
1017
|
const linkToMedia = (config = {}) => {
|
|
@@ -906,12 +1023,12 @@ const linkToMedia = (config = {}) => {
|
|
|
906
1023
|
} else {
|
|
907
1024
|
return {
|
|
908
1025
|
link_type: prismicT__namespace.LinkType.Media,
|
|
909
|
-
name: faker.
|
|
910
|
-
kind: faker.
|
|
911
|
-
url: faker.
|
|
912
|
-
size: faker.
|
|
913
|
-
height: faker.
|
|
914
|
-
width: faker.
|
|
1026
|
+
name: `${changeCase__namespace.snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
1027
|
+
kind: changeCase__namespace.snakeCase(faker.word()),
|
|
1028
|
+
url: faker.url(),
|
|
1029
|
+
size: faker.range(500, 3e3).toString(),
|
|
1030
|
+
height: faker.range(500, 3e3).toString(),
|
|
1031
|
+
width: faker.range(500, 3e3).toString()
|
|
915
1032
|
};
|
|
916
1033
|
}
|
|
917
1034
|
};
|
|
@@ -919,7 +1036,7 @@ const linkToMedia = (config = {}) => {
|
|
|
919
1036
|
const link = (config = {}) => {
|
|
920
1037
|
var _a;
|
|
921
1038
|
const faker = createFaker(config.seed);
|
|
922
|
-
const type = config.type || faker.
|
|
1039
|
+
const type = config.type || faker.randomElement([
|
|
923
1040
|
prismicT__namespace.LinkType.Web,
|
|
924
1041
|
prismicT__namespace.LinkType.Document,
|
|
925
1042
|
prismicT__namespace.LinkType.Media
|
|
@@ -948,8 +1065,8 @@ const link = (config = {}) => {
|
|
|
948
1065
|
const model = config.model || link$1({ seed: config.seed });
|
|
949
1066
|
return {
|
|
950
1067
|
link_type: prismicT__namespace.LinkType.Web,
|
|
951
|
-
url: faker.
|
|
952
|
-
target: ((_a = config.withTargetBlank) != null ? _a : model.config.allowTargetBlank && faker.
|
|
1068
|
+
url: faker.url(),
|
|
1069
|
+
target: ((_a = config.withTargetBlank) != null ? _a : model.config.allowTargetBlank && faker.boolean()) ? "_blank" : void 0
|
|
953
1070
|
};
|
|
954
1071
|
}
|
|
955
1072
|
}
|
|
@@ -958,7 +1075,7 @@ const link = (config = {}) => {
|
|
|
958
1075
|
|
|
959
1076
|
const number = (config = {}) => {
|
|
960
1077
|
const faker = createFaker(config.seed);
|
|
961
|
-
return config.state === "empty" ? null : faker.
|
|
1078
|
+
return config.state === "empty" ? null : faker.range(1, 100);
|
|
962
1079
|
};
|
|
963
1080
|
|
|
964
1081
|
const patterns$5 = {
|
|
@@ -986,16 +1103,13 @@ const heading = (config = {}) => {
|
|
|
986
1103
|
prismicT__namespace.RichTextNodeType.heading5,
|
|
987
1104
|
prismicT__namespace.RichTextNodeType.heading6
|
|
988
1105
|
].includes(type2));
|
|
989
|
-
const type = faker.
|
|
1106
|
+
const type = faker.randomElement(types);
|
|
990
1107
|
if (type) {
|
|
991
|
-
const patternKey = config.pattern || faker.
|
|
1108
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$5));
|
|
992
1109
|
const pattern = patterns$5[patternKey];
|
|
993
1110
|
return {
|
|
994
1111
|
type,
|
|
995
|
-
text: changeCase__namespace.capitalCase(faker.
|
|
996
|
-
min: pattern.minWords,
|
|
997
|
-
max: pattern.maxWords
|
|
998
|
-
}))),
|
|
1112
|
+
text: changeCase__namespace.capitalCase(faker.words(faker.range(pattern.minWords, pattern.maxWords))),
|
|
999
1113
|
spans: []
|
|
1000
1114
|
};
|
|
1001
1115
|
} else {
|
|
@@ -1016,11 +1130,12 @@ const patterns$4 = {
|
|
|
1016
1130
|
};
|
|
1017
1131
|
const paragraph = (config = {}) => {
|
|
1018
1132
|
const faker = createFaker(config.seed);
|
|
1019
|
-
const patternKey = config.pattern || faker.
|
|
1133
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$4));
|
|
1020
1134
|
const pattern = patterns$4[patternKey];
|
|
1135
|
+
const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
|
|
1021
1136
|
return {
|
|
1022
1137
|
type: prismicT__namespace.RichTextNodeType.paragraph,
|
|
1023
|
-
text
|
|
1138
|
+
text,
|
|
1024
1139
|
spans: []
|
|
1025
1140
|
};
|
|
1026
1141
|
};
|
|
@@ -1038,11 +1153,12 @@ const patterns$3 = {
|
|
|
1038
1153
|
};
|
|
1039
1154
|
const preformatted = (config = {}) => {
|
|
1040
1155
|
const faker = createFaker(config.seed);
|
|
1041
|
-
const patternKey = config.pattern || faker.
|
|
1156
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$3));
|
|
1042
1157
|
const pattern = patterns$3[patternKey];
|
|
1158
|
+
const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
|
|
1043
1159
|
return {
|
|
1044
1160
|
type: prismicT__namespace.RichTextNodeType.preformatted,
|
|
1045
|
-
text
|
|
1161
|
+
text,
|
|
1046
1162
|
spans: []
|
|
1047
1163
|
};
|
|
1048
1164
|
};
|
|
@@ -1063,16 +1179,13 @@ const patterns$2 = {
|
|
|
1063
1179
|
};
|
|
1064
1180
|
const list = (config = {}) => {
|
|
1065
1181
|
const faker = createFaker(config.seed);
|
|
1066
|
-
const patternKey = config.pattern || faker.
|
|
1182
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$2));
|
|
1067
1183
|
const pattern = patterns$2[patternKey];
|
|
1068
|
-
const itemsCount = faker.
|
|
1069
|
-
min: pattern.minItems,
|
|
1070
|
-
max: pattern.maxItems
|
|
1071
|
-
});
|
|
1184
|
+
const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
|
|
1072
1185
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
1073
1186
|
return {
|
|
1074
1187
|
type: prismicT__namespace.RichTextNodeType.listItem,
|
|
1075
|
-
text: faker.
|
|
1188
|
+
text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
|
|
1076
1189
|
spans: []
|
|
1077
1190
|
};
|
|
1078
1191
|
});
|
|
@@ -1094,16 +1207,13 @@ const patterns$1 = {
|
|
|
1094
1207
|
};
|
|
1095
1208
|
const oList = (config = {}) => {
|
|
1096
1209
|
const faker = createFaker(config.seed);
|
|
1097
|
-
const patternKey = config.pattern || faker.
|
|
1210
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$1));
|
|
1098
1211
|
const pattern = patterns$1[patternKey];
|
|
1099
|
-
const itemsCount = faker.
|
|
1100
|
-
min: pattern.minItems,
|
|
1101
|
-
max: pattern.maxItems
|
|
1102
|
-
});
|
|
1212
|
+
const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
|
|
1103
1213
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
1104
1214
|
return {
|
|
1105
1215
|
type: prismicT__namespace.RichTextNodeType.oListItem,
|
|
1106
|
-
text: faker.
|
|
1216
|
+
text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
|
|
1107
1217
|
spans: []
|
|
1108
1218
|
};
|
|
1109
1219
|
});
|
|
@@ -1114,7 +1224,7 @@ const image = (config = {}) => {
|
|
|
1114
1224
|
const imageField = buildImageFieldImage({
|
|
1115
1225
|
seed: config.seed,
|
|
1116
1226
|
imageData,
|
|
1117
|
-
state:
|
|
1227
|
+
state: "filled"
|
|
1118
1228
|
});
|
|
1119
1229
|
return {
|
|
1120
1230
|
type: prismicT__namespace.RichTextNodeType.image,
|
|
@@ -1126,8 +1236,8 @@ const image = (config = {}) => {
|
|
|
1126
1236
|
};
|
|
1127
1237
|
|
|
1128
1238
|
const embed = (config = {}) => {
|
|
1129
|
-
const
|
|
1130
|
-
const embedField = buildEmbedField({ seed: config.seed,
|
|
1239
|
+
const data = getMockEmbedData({ seed: config.seed });
|
|
1240
|
+
const embedField = buildEmbedField({ seed: config.seed, data });
|
|
1131
1241
|
return {
|
|
1132
1242
|
type: prismicT__namespace.RichTextNodeType.embed,
|
|
1133
1243
|
oembed: embedField
|
|
@@ -1171,14 +1281,11 @@ const richText = (config = {}) => {
|
|
|
1171
1281
|
const supportsMultipleBlocks = "multi" in model.config;
|
|
1172
1282
|
const types = ("multi" in model.config ? model.config.multi : model.config.single).split(",").filter((type) => Object.keys(generators).includes(type));
|
|
1173
1283
|
if (types.length > 0) {
|
|
1174
|
-
const patternKey = config.pattern || faker.
|
|
1284
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
|
|
1175
1285
|
const pattern = patterns[patternKey];
|
|
1176
|
-
const blockCount = supportsMultipleBlocks ? faker.
|
|
1177
|
-
min: pattern.blockCountMin,
|
|
1178
|
-
max: pattern.blockCountMax
|
|
1179
|
-
}) : 1;
|
|
1286
|
+
const blockCount = supportsMultipleBlocks ? faker.range(pattern.blockCountMin, pattern.blockCountMax) : 1;
|
|
1180
1287
|
return Array(blockCount).fill(void 0).map(() => {
|
|
1181
|
-
const type = faker.
|
|
1288
|
+
const type = faker.randomElement(types);
|
|
1182
1289
|
const generator = generators[type];
|
|
1183
1290
|
return generator({ seed: config.seed, model });
|
|
1184
1291
|
}).flat().filter((block) => block !== void 0).slice(0, blockCount);
|
|
@@ -1194,7 +1301,7 @@ const select = (config = {}) => {
|
|
|
1194
1301
|
if (config.state === "empty") {
|
|
1195
1302
|
return null;
|
|
1196
1303
|
} else {
|
|
1197
|
-
return typeof defaultValue === "string" && faker.
|
|
1304
|
+
return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(model.config.options);
|
|
1198
1305
|
}
|
|
1199
1306
|
};
|
|
1200
1307
|
|
|
@@ -1203,11 +1310,8 @@ const slice = (config = {}) => {
|
|
|
1203
1310
|
const faker = createFaker(config.seed);
|
|
1204
1311
|
const model = config.model || slice$1({ seed: config.seed });
|
|
1205
1312
|
const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
|
|
1206
|
-
const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.
|
|
1207
|
-
const itemsCount = Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.
|
|
1208
|
-
min: 1,
|
|
1209
|
-
max: 6
|
|
1210
|
-
}) : 0;
|
|
1313
|
+
const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
1314
|
+
const itemsCount = Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
|
|
1211
1315
|
return {
|
|
1212
1316
|
slice_type: sliceType,
|
|
1213
1317
|
slice_label: sliceLabel,
|
|
@@ -1231,15 +1335,12 @@ const sharedSliceVariation = (config = {}) => {
|
|
|
1231
1335
|
const faker = createFaker(config.seed);
|
|
1232
1336
|
const model = config.model || sharedSliceVariation$1({ seed: config.seed });
|
|
1233
1337
|
const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
|
|
1234
|
-
const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.
|
|
1235
|
-
min: 1,
|
|
1236
|
-
max: 6
|
|
1237
|
-
}) : 0;
|
|
1338
|
+
const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
|
|
1238
1339
|
return {
|
|
1239
1340
|
slice_type: sliceType,
|
|
1240
1341
|
slice_label: null,
|
|
1241
1342
|
variation: model.id,
|
|
1242
|
-
version: faker.
|
|
1343
|
+
version: faker.hash(7),
|
|
1243
1344
|
primary: valueForModelMap({
|
|
1244
1345
|
seed: config.seed,
|
|
1245
1346
|
map: model.primary,
|
|
@@ -1258,7 +1359,7 @@ const sharedSliceVariation = (config = {}) => {
|
|
|
1258
1359
|
const sharedSlice = (config = {}) => {
|
|
1259
1360
|
const faker = createFaker(config.seed);
|
|
1260
1361
|
const model = config.model || sharedSlice$1({ seed: config.seed });
|
|
1261
|
-
const variationModel = faker.
|
|
1362
|
+
const variationModel = faker.randomElement(model.variations);
|
|
1262
1363
|
return sharedSliceVariation({
|
|
1263
1364
|
seed: config.seed,
|
|
1264
1365
|
model: variationModel,
|
|
@@ -1277,16 +1378,13 @@ const sliceZone = (config = {}) => {
|
|
|
1277
1378
|
const faker = createFaker(config.seed);
|
|
1278
1379
|
const model = config.model || sliceZone$1({ seed: config.seed });
|
|
1279
1380
|
if (Object.keys(model.config.choices).length > 0) {
|
|
1280
|
-
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.
|
|
1281
|
-
min: 1,
|
|
1282
|
-
max: 6
|
|
1283
|
-
});
|
|
1381
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
|
|
1284
1382
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
1285
1383
|
var _a2;
|
|
1286
1384
|
const choices = Object.entries(model.config.choices);
|
|
1287
|
-
const [choiceType, choiceModel] = faker.
|
|
1385
|
+
const [choiceType, choiceModel] = faker.randomElement(choices);
|
|
1288
1386
|
const choiceLabels = model.config.labels[choiceType] || [];
|
|
1289
|
-
const choiceLabel = faker.
|
|
1387
|
+
const choiceLabel = faker.randomElement(choiceLabels);
|
|
1290
1388
|
switch (choiceModel.type) {
|
|
1291
1389
|
case prismicT__namespace.CustomTypeModelSliceType.Slice: {
|
|
1292
1390
|
return slice({
|
|
@@ -1333,7 +1431,7 @@ const title = (config = {}) => {
|
|
|
1333
1431
|
|
|
1334
1432
|
const uid = (config = {}) => {
|
|
1335
1433
|
const faker = createFaker(config.seed);
|
|
1336
|
-
return changeCase__namespace.snakeCase(faker.
|
|
1434
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
1337
1435
|
};
|
|
1338
1436
|
|
|
1339
1437
|
exports.boolean = boolean;
|