@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/model/index.js
CHANGED
|
@@ -4,8 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const prismicT = require('@prismicio/types');
|
|
6
6
|
const changeCase = require('change-case');
|
|
7
|
-
const
|
|
8
|
-
const Faker = require('faker/lib/index.js');
|
|
7
|
+
const Rand = require('rand-seed');
|
|
9
8
|
|
|
10
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
10
|
|
|
@@ -29,36 +28,131 @@ function _interopNamespace(e) {
|
|
|
29
28
|
|
|
30
29
|
const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
|
|
31
30
|
const changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase);
|
|
32
|
-
const
|
|
33
|
-
const Faker__default = /*#__PURE__*/_interopDefaultLegacy(Faker);
|
|
31
|
+
const Rand__default = /*#__PURE__*/_interopDefaultLegacy(Rand);
|
|
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
152
|
return {
|
|
59
153
|
type: prismicT__namespace.CustomTypeModelFieldType.Boolean,
|
|
60
154
|
config: {
|
|
61
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
155
|
+
label: changeCase__namespace.capitalCase(faker.word())
|
|
62
156
|
}
|
|
63
157
|
};
|
|
64
158
|
};
|
|
@@ -68,8 +162,8 @@ const color = (config = {}) => {
|
|
|
68
162
|
return {
|
|
69
163
|
type: prismicT__namespace.CustomTypeModelFieldType.Color,
|
|
70
164
|
config: {
|
|
71
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
72
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
165
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
166
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
73
167
|
}
|
|
74
168
|
};
|
|
75
169
|
};
|
|
@@ -79,8 +173,8 @@ const contentRelationship = (config = {}) => {
|
|
|
79
173
|
return {
|
|
80
174
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
81
175
|
config: {
|
|
82
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
83
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
176
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
177
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
84
178
|
select: prismicT__namespace.CustomTypeModelLinkSelectType.Document,
|
|
85
179
|
customtypes: config.customTypeIDs,
|
|
86
180
|
tags: config.tags
|
|
@@ -91,7 +185,7 @@ const contentRelationship = (config = {}) => {
|
|
|
91
185
|
const customType = (config = {}) => {
|
|
92
186
|
var _a, _b;
|
|
93
187
|
const faker = createFaker(config.seed);
|
|
94
|
-
let label = config.label || changeCase__namespace.capitalCase(faker.
|
|
188
|
+
let label = config.label || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
95
189
|
let id = config.id || changeCase__namespace.snakeCase(label);
|
|
96
190
|
if (config.id && !config.label) {
|
|
97
191
|
label = changeCase__namespace.capitalCase(config.id);
|
|
@@ -107,8 +201,8 @@ const customType = (config = {}) => {
|
|
|
107
201
|
return {
|
|
108
202
|
id,
|
|
109
203
|
label,
|
|
110
|
-
status: (_a = config.status) != null ? _a : faker.
|
|
111
|
-
repeatable: (_b = config.repeatable) != null ? _b : faker.
|
|
204
|
+
status: (_a = config.status) != null ? _a : faker.boolean(),
|
|
205
|
+
repeatable: (_b = config.repeatable) != null ? _b : faker.boolean(),
|
|
112
206
|
json
|
|
113
207
|
};
|
|
114
208
|
};
|
|
@@ -118,8 +212,8 @@ const date = (config = {}) => {
|
|
|
118
212
|
return {
|
|
119
213
|
type: prismicT__namespace.CustomTypeModelFieldType.Date,
|
|
120
214
|
config: {
|
|
121
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
122
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
215
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
216
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
123
217
|
}
|
|
124
218
|
};
|
|
125
219
|
};
|
|
@@ -129,8 +223,8 @@ const embed = (config = {}) => {
|
|
|
129
223
|
return {
|
|
130
224
|
type: prismicT__namespace.CustomTypeModelFieldType.Embed,
|
|
131
225
|
config: {
|
|
132
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
133
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
226
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
227
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
134
228
|
}
|
|
135
229
|
};
|
|
136
230
|
};
|
|
@@ -140,7 +234,7 @@ const geoPoint = (config = {}) => {
|
|
|
140
234
|
return {
|
|
141
235
|
type: prismicT__namespace.CustomTypeModelFieldType.GeoPoint,
|
|
142
236
|
config: {
|
|
143
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
237
|
+
label: changeCase__namespace.capitalCase(faker.word())
|
|
144
238
|
}
|
|
145
239
|
};
|
|
146
240
|
};
|
|
@@ -150,7 +244,7 @@ const group = (config = {}) => {
|
|
|
150
244
|
return {
|
|
151
245
|
type: prismicT__namespace.CustomTypeModelFieldType.Group,
|
|
152
246
|
config: {
|
|
153
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
247
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
154
248
|
fields: config.fields || {}
|
|
155
249
|
}
|
|
156
250
|
};
|
|
@@ -161,17 +255,17 @@ const image = (config = {}) => {
|
|
|
161
255
|
const thumbnails = (config.thumbnailNames || []).map((name) => {
|
|
162
256
|
return {
|
|
163
257
|
name,
|
|
164
|
-
width: faker.
|
|
165
|
-
height: faker.
|
|
258
|
+
width: faker.range(500, 2e3),
|
|
259
|
+
height: faker.range(500, 2e3)
|
|
166
260
|
};
|
|
167
261
|
});
|
|
168
262
|
return {
|
|
169
263
|
type: prismicT__namespace.CustomTypeModelFieldType.Image,
|
|
170
264
|
config: {
|
|
171
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
265
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
172
266
|
constraint: {
|
|
173
|
-
width: config.withConstraint ? faker.
|
|
174
|
-
height: config.withConstraint ? faker.
|
|
267
|
+
width: config.withConstraint ? faker.range(500, 2e3) : null,
|
|
268
|
+
height: config.withConstraint ? faker.range(500, 2e3) : null
|
|
175
269
|
},
|
|
176
270
|
thumbnails
|
|
177
271
|
}
|
|
@@ -183,8 +277,8 @@ const integrationFields = (config = {}) => {
|
|
|
183
277
|
return {
|
|
184
278
|
type: prismicT__namespace.CustomTypeModelFieldType.IntegrationFields,
|
|
185
279
|
config: {
|
|
186
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
187
|
-
catalog: config.catalog || changeCase__namespace.snakeCase(faker.
|
|
280
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
281
|
+
catalog: config.catalog || changeCase__namespace.snakeCase(faker.words(2))
|
|
188
282
|
}
|
|
189
283
|
};
|
|
190
284
|
};
|
|
@@ -194,8 +288,8 @@ const keyText = (config = {}) => {
|
|
|
194
288
|
return {
|
|
195
289
|
type: prismicT__namespace.CustomTypeModelFieldType.Text,
|
|
196
290
|
config: {
|
|
197
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
198
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
291
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
292
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
199
293
|
}
|
|
200
294
|
};
|
|
201
295
|
};
|
|
@@ -205,10 +299,10 @@ const link = (config = {}) => {
|
|
|
205
299
|
return {
|
|
206
300
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
207
301
|
config: {
|
|
208
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
209
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
302
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
303
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
210
304
|
select: null,
|
|
211
|
-
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.
|
|
305
|
+
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
212
306
|
}
|
|
213
307
|
};
|
|
214
308
|
};
|
|
@@ -218,8 +312,8 @@ const linkToMedia = (config = {}) => {
|
|
|
218
312
|
return {
|
|
219
313
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
220
314
|
config: {
|
|
221
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
222
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
315
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
316
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
223
317
|
select: prismicT__namespace.CustomTypeModelLinkSelectType.Media
|
|
224
318
|
}
|
|
225
319
|
};
|
|
@@ -230,8 +324,8 @@ const number = (config = {}) => {
|
|
|
230
324
|
return {
|
|
231
325
|
type: prismicT__namespace.CustomTypeModelFieldType.Number,
|
|
232
326
|
config: {
|
|
233
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
234
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
327
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
328
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
235
329
|
}
|
|
236
330
|
};
|
|
237
331
|
};
|
|
@@ -239,7 +333,7 @@ const number = (config = {}) => {
|
|
|
239
333
|
const richText = (config = {}) => {
|
|
240
334
|
var _a;
|
|
241
335
|
const faker = createFaker(config.seed);
|
|
242
|
-
const blockTypes = faker.
|
|
336
|
+
const blockTypes = faker.randomElements([
|
|
243
337
|
prismicT__namespace.RichTextNodeType.heading1,
|
|
244
338
|
prismicT__namespace.RichTextNodeType.heading2,
|
|
245
339
|
prismicT__namespace.RichTextNodeType.heading3,
|
|
@@ -256,13 +350,13 @@ const richText = (config = {}) => {
|
|
|
256
350
|
prismicT__namespace.RichTextNodeType.embed,
|
|
257
351
|
prismicT__namespace.RichTextNodeType.hyperlink
|
|
258
352
|
]).join(",");
|
|
259
|
-
const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.
|
|
353
|
+
const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.boolean()) ? { multi: blockTypes } : { single: blockTypes };
|
|
260
354
|
return {
|
|
261
355
|
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
262
356
|
config: {
|
|
263
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
264
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
265
|
-
allowTargetBlank: faker.
|
|
357
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
358
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
359
|
+
allowTargetBlank: faker.boolean() ? true : void 0,
|
|
266
360
|
...blockTypeConfig
|
|
267
361
|
}
|
|
268
362
|
};
|
|
@@ -273,8 +367,8 @@ const select = (config = {}) => {
|
|
|
273
367
|
return {
|
|
274
368
|
type: prismicT__namespace.CustomTypeModelFieldType.Select,
|
|
275
369
|
config: {
|
|
276
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
277
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
370
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
371
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
278
372
|
options: config.options || [],
|
|
279
373
|
default_value: config.defaultValue || void 0
|
|
280
374
|
}
|
|
@@ -283,7 +377,7 @@ const select = (config = {}) => {
|
|
|
283
377
|
|
|
284
378
|
const sharedSlice = (config = {}) => {
|
|
285
379
|
const faker = createFaker(config.seed);
|
|
286
|
-
let name = config.name || changeCase__namespace.capitalCase(faker.
|
|
380
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
287
381
|
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
288
382
|
if (config.id && !config.name) {
|
|
289
383
|
name = changeCase__namespace.pascalCase(config.id);
|
|
@@ -294,7 +388,7 @@ const sharedSlice = (config = {}) => {
|
|
|
294
388
|
type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice,
|
|
295
389
|
id,
|
|
296
390
|
name,
|
|
297
|
-
description: faker.
|
|
391
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
298
392
|
variations: config.variations || []
|
|
299
393
|
};
|
|
300
394
|
};
|
|
@@ -307,7 +401,7 @@ const sharedSliceChoice = () => {
|
|
|
307
401
|
|
|
308
402
|
const sharedSliceVariation = (config = {}) => {
|
|
309
403
|
const faker = createFaker(config.seed);
|
|
310
|
-
let name = config.name || changeCase__namespace.capitalCase(faker.
|
|
404
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
311
405
|
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
312
406
|
if (config.id && !config.name) {
|
|
313
407
|
name = changeCase__namespace.pascalCase(config.id);
|
|
@@ -317,9 +411,9 @@ const sharedSliceVariation = (config = {}) => {
|
|
|
317
411
|
return {
|
|
318
412
|
id,
|
|
319
413
|
name,
|
|
320
|
-
description: faker.
|
|
321
|
-
docURL: faker.
|
|
322
|
-
version: faker.
|
|
414
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
415
|
+
docURL: faker.url(),
|
|
416
|
+
version: faker.hash(7),
|
|
323
417
|
primary: config.primaryFields || {},
|
|
324
418
|
items: config.itemsFields || {}
|
|
325
419
|
};
|
|
@@ -329,10 +423,10 @@ const slice = (config = {}) => {
|
|
|
329
423
|
const faker = createFaker(config.seed);
|
|
330
424
|
return {
|
|
331
425
|
type: prismicT__namespace.CustomTypeModelSliceType.Slice,
|
|
332
|
-
icon: changeCase__namespace.snakeCase(faker.
|
|
333
|
-
display: faker.
|
|
334
|
-
fieldset: changeCase__namespace.capitalCase(faker.
|
|
335
|
-
description: faker.
|
|
426
|
+
icon: changeCase__namespace.snakeCase(faker.word()),
|
|
427
|
+
display: faker.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List,
|
|
428
|
+
fieldset: changeCase__namespace.capitalCase(faker.words(2)),
|
|
429
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
336
430
|
repeat: config.repeatFields || {},
|
|
337
431
|
"non-repeat": config.nonRepeatFields || {}
|
|
338
432
|
};
|
|
@@ -361,15 +455,15 @@ const timestamp = (config = {}) => {
|
|
|
361
455
|
return {
|
|
362
456
|
type: prismicT__namespace.CustomTypeModelFieldType.Timestamp,
|
|
363
457
|
config: {
|
|
364
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
365
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
458
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
459
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
366
460
|
}
|
|
367
461
|
};
|
|
368
462
|
};
|
|
369
463
|
|
|
370
464
|
const title = (config = {}) => {
|
|
371
465
|
const faker = createFaker(config.seed);
|
|
372
|
-
const single = faker.
|
|
466
|
+
const single = faker.randomElements([
|
|
373
467
|
"heading1",
|
|
374
468
|
"heading2",
|
|
375
469
|
"heading3",
|
|
@@ -380,10 +474,10 @@ const title = (config = {}) => {
|
|
|
380
474
|
return {
|
|
381
475
|
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
382
476
|
config: {
|
|
383
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
384
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
477
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
478
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
385
479
|
single,
|
|
386
|
-
allowTargetBlank: faker.
|
|
480
|
+
allowTargetBlank: faker.boolean() || void 0
|
|
387
481
|
}
|
|
388
482
|
};
|
|
389
483
|
};
|
|
@@ -393,15 +487,15 @@ const uid = (config = {}) => {
|
|
|
393
487
|
return {
|
|
394
488
|
type: prismicT__namespace.CustomTypeModelFieldType.UID,
|
|
395
489
|
config: {
|
|
396
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
397
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
490
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
491
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3))
|
|
398
492
|
}
|
|
399
493
|
};
|
|
400
494
|
};
|
|
401
495
|
|
|
402
496
|
const generateFieldId = (config) => {
|
|
403
497
|
const faker = createFaker(config.seed);
|
|
404
|
-
return changeCase__namespace.snakeCase(faker.
|
|
498
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
405
499
|
};
|
|
406
500
|
|
|
407
501
|
const mockModelFns = {
|
|
@@ -425,7 +519,7 @@ const mockModelFns = {
|
|
|
425
519
|
const buildMockGroupFieldMap = (config = {}) => {
|
|
426
520
|
const faker = createFaker(config.seed);
|
|
427
521
|
const fields = {};
|
|
428
|
-
const fieldTypes = faker.
|
|
522
|
+
const fieldTypes = faker.randomElements(Object.keys(mockModelFns));
|
|
429
523
|
for (const fieldType of fieldTypes) {
|
|
430
524
|
const fieldId = generateFieldId({ seed: config.seed });
|
|
431
525
|
const mockModelFn = mockModelFns[fieldType];
|