@prismicio/mock 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +348 -236
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.ts +52 -6
- package/dist/api/index.js +348 -236
- package/dist/api/index.js.map +1 -1
- package/dist/index.cjs +893 -543
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +247 -73
- package/dist/index.js +885 -542
- package/dist/index.js.map +1 -1
- package/dist/model/index.cjs +398 -134
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.ts +114 -28
- package/dist/model/index.js +398 -134
- package/dist/model/index.js.map +1 -1
- package/dist/value/index.cjs +598 -468
- package/dist/value/index.cjs.map +1 -1
- package/dist/value/index.d.ts +96 -40
- package/dist/value/index.js +598 -468
- package/dist/value/index.js.map +1 -1
- package/package.json +22 -20
- package/src/api/createAPIMockFactory.ts +56 -0
- package/src/api/query.ts +4 -4
- package/src/api/ref.ts +6 -6
- package/src/api/repository.ts +12 -14
- package/src/api/tags.ts +5 -2
- package/src/createMockFactory.ts +52 -0
- package/src/index.ts +15 -0
- package/src/lib/buildEmbedField.ts +28 -30
- package/src/lib/buildImageFieldImage.ts +19 -7
- package/src/lib/createFaker.ts +99 -22
- package/src/lib/generateCustomTypeId.ts +13 -5
- package/src/lib/generateFieldId.ts +13 -7
- package/src/lib/generateTags.ts +17 -16
- package/src/lib/getMockEmbedData.ts +45 -16
- package/src/lib/getMockImageData.ts +13 -5
- package/src/lib/lorem.ts +112 -0
- package/src/lib/valueForModel.ts +47 -30
- package/src/lib/valueForModelMap.ts +24 -4
- package/src/model/boolean.ts +6 -6
- package/src/model/buildMockGroupFieldMap.ts +5 -5
- package/src/model/color.ts +4 -4
- package/src/model/contentRelationship.ts +4 -4
- package/src/model/createModelMockFactory.ts +213 -0
- package/src/model/customType.ts +6 -6
- package/src/model/date.ts +4 -4
- package/src/model/embed.ts +4 -4
- package/src/model/geoPoint.ts +3 -3
- package/src/model/group.ts +7 -7
- package/src/model/image.ts +8 -12
- package/src/model/index.ts +2 -0
- package/src/model/integrationFields.ts +4 -4
- package/src/model/keyText.ts +4 -4
- package/src/model/link.ts +6 -6
- package/src/model/linkToMedia.ts +5 -5
- package/src/model/number.ts +4 -4
- package/src/model/richText.ts +8 -8
- package/src/model/select.ts +5 -5
- package/src/model/sharedSlice.ts +5 -5
- package/src/model/sharedSliceVariation.ts +10 -10
- package/src/model/slice.ts +7 -7
- package/src/model/sliceZone.ts +7 -4
- package/src/model/timestamp.ts +4 -4
- package/src/model/title.ts +7 -7
- package/src/model/uid.ts +4 -4
- package/src/types.ts +70 -31
- package/src/value/boolean.ts +4 -6
- package/src/value/color.ts +3 -3
- package/src/value/contentRelationship.ts +21 -18
- package/src/value/createValueMockFactory.ts +236 -0
- package/src/value/customType.ts +12 -12
- package/src/value/date.ts +6 -2
- package/src/value/embed.ts +23 -7
- package/src/value/geoPoint.ts +4 -6
- package/src/value/group.ts +6 -11
- package/src/value/image.ts +26 -18
- package/src/value/integrationFields.ts +12 -26
- package/src/value/keyText.ts +3 -5
- package/src/value/link.ts +11 -9
- package/src/value/linkToMedia.ts +9 -8
- package/src/value/number.ts +3 -3
- package/src/value/richText/embed.ts +6 -3
- package/src/value/richText/heading.ts +32 -27
- package/src/value/richText/image.ts +9 -8
- package/src/value/richText/index.ts +71 -48
- package/src/value/richText/list.ts +6 -10
- package/src/value/richText/oList.ts +6 -10
- package/src/value/richText/paragraph.ts +10 -6
- package/src/value/richText/preformatted.ts +11 -7
- package/src/value/select.ts +11 -7
- package/src/value/sharedSlice.ts +5 -5
- package/src/value/sharedSliceVariation.ts +11 -16
- package/src/value/slice.ts +11 -15
- package/src/value/sliceZone.ts +14 -18
- package/src/value/timestamp.ts +31 -18
- package/src/value/title.ts +7 -3
- package/src/value/uid.ts +6 -4
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,82 +26,169 @@ 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
|
-
const
|
|
33
|
+
const wordsString = "lorem ipsum dolor sit amet, consectetur adipiscing elit ut aliquam, purus sit amet luctus venenatis, lectus magna fringilla urna, porttitor rhoncus dolor purus non enim praesent elementum facilisis leo, vel fringilla est ullamcorper eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus in ornare quam viverra orci sagittis eu volutpat odio facilisis mauris sit amet massa vitae tortor condimentum lacinia quis vel eros donec ac odio tempor orci dapibus ultrices in iaculis nunc sed augue lacus, viverra vitae congue eu, consequat ac felis donec et odio pellentesque diam volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum arcu vitae elementum curabitur vitae nunc sed velit dignissim sodales ut eu sem integer vitae justo eget magna fermentum iaculis eu non diam phasellus vestibulum lorem sed risus ultricies tristique nulla aliquet enim tortor, at auctor urna nunc id cursus metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices sagittis orci, a scelerisque purus semper eget duis at tellus at urna condimentum mattis pellentesque id nibh tortor, id aliquet lectus proin nibh nisl, condimentum id venenatis a, condimentum vitae sapien pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas sed tempus, urna et pharetra pharetra, massa massa ultricies mi, quis hendrerit dolor magna eget est lorem ipsum dolor sit amet, consectetur adipiscing elit pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas integer eget aliquet nibh praesent tristique magna sit amet purus gravida quis blandit turpis cursus in hac habitasse platea dictumst quisque sagittis, purus sit amet volutpat consequat, mauris nunc congue nisi, vitae suscipit tellus mauris a diam maecenas sed enim ut sem viverra aliquet eget sit amet tellus cras adipiscing enim eu turpis egestas pretium aenean pharetra, magna ac placerat vestibulum, lectus mauris ultrices eros, in cursus turpis massa tincidunt dui ut ornare lectus sit amet est placerat in egestas erat imperdiet sed euismod nisi porta lorem mollis aliquam ut porttitor leo a diam sollicitudin tempor id eu nisl nunc mi ipsum, faucibus vitae aliquet nec, ullamcorper sit amet risus nullam eget felis eget nunc lobortis mattis aliquam faucibus purus in massa tempor nec feugiat nisl pretium fusce id velit ut tortor pretium viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi lacus, sed viverra tellus in hac habitasse platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius duis at consectetur lorem donec massa sapien, faucibus et molestie ac, feugiat sed lectus vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa, eget egestas purus viverra accumsan in nisl nisi, scelerisque eu ultrices vitae, auctor eu augue ut lectus arcu, bibendum at varius vel, pharetra vel turpis nunc eget lorem dolor, sed viverra ipsum nunc aliquet bibendum enim, facilisis gravida neque convallis a cras semper auctor neque, vitae tempus quam pellentesque nec nam aliquam sem et tortor consequat id porta nibh venenatis cras sed felis eget velit aliquet sagittis id consectetur purus ut faucibus pulvinar elementum integer enim neque, volutpat ac tincidunt vitae, semper quis lectus nulla at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum consectetur libero, id faucibus nisl tincidunt eget nullam non nisi est, sit amet facilisis magna etiam tempor, orci eu lobortis elementum, nibh tellus molestie nunc, non blandit massa enim nec dui nunc mattis enim ut tellus elementum sagittis vitae et leo duis ut diam quam nulla porttitor massa id neque aliquam vestibulum morbi blandit cursus risus, at ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget gravida cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus mauris vitae ultricies leo integer malesuada nunc vel risus commodo viverra maecenas accumsan, lacus vel facilisis volutpat, est velit egestas dui, id ornare arcu odio ut sem nulla pharetra diam sit amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc, consequat interdum varius sit amet, mattis vulputate enim nulla aliquet porttitor lacus, luctus accumsan tortor posuere ac ut consequat semper viverra nam libero justo, laoreet sit amet cursus sit amet, dictum sit amet justo donec enim diam, vulputate ut pharetra sit amet, aliquam id diam maecenas ultricies mi eget mauris pharetra et ultrices neque ornare aenean euismod elementum nisi, quis eleifend quam adipiscing vitae proin sagittis, nisl rhoncus mattis rhoncus, urna neque viverra justo, nec ultrices dui sapien eget mi proin sed libero enim, sed faucibus turpis in eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod quis viverra nibh cras pulvinar mattis nunc, sed blandit libero volutpat sed cras ornare arcu dui vivamus arcu felis, bibendum ut tristique et, egestas quis ipsum suspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque dignissim enim, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in pellentesque massa placerat duis ultricies lacus sed turpis tincidunt id aliquet risus feugiat in ante metus, dictum at tempor commodo, ullamcorper a lacus vestibulum sed arcu non odio euismod lacinia at quis risus sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit aliquam etiam erat velit, scelerisque in dictum non, consectetur a erat nam at lectus urna duis convallis convallis tellus, id interdum velit laoreet id donec ultrices tincidunt arcu, non sodales neque sodales ut etiam sit amet nisl purus, in mollis nunc sed id semper risus in hendrerit gravida rutrum quisque non tellus orci, ac auctor augue mauris augue neque, gravida in fermentum et, sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras fermentum, odio eu feugiat pretium, nibh ipsum consequat nisl, vel pretium lectus quam id leo in vitae turpis massa sed elementum tempus egestas sed sed risus pretium quam vulputate dignissim suspendisse in est ante in nibh mauris, cursus mattis molestie a, iaculis at erat pellentesque adipiscing commodo elit, at imperdiet dui accumsan sit amet nulla facilisi morbi tempus iaculis urna, id volutpat lacus laoreet non curabitur gravida arcu ac tortor dignissim convallis aenean et tortor at risus viverra adipiscing at in tellus integer feugiat scelerisque varius morbi enim nunc, faucibus a pellentesque sit amet, porttitor eget dolor morbi non arcu risus, quis varius quam quisque id diam vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit amet, consectetur adipiscing elit duis tristique sollicitudin nibh sit amet commodo nulla facilisi nullam vehicula ipsum a arcu cursus vitae congue mauris rhoncus aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas maecenas pharetra convallis posuere morbi leo urna, molestie at elementum eu, facilisis sed odio morbi quis commodo odio aenean sed adipiscing diam donec adipiscing tristique risus nec feugiat in fermentum posuere urna nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a molestie";
|
|
34
|
+
const loremWords = wordsString.split(" ");
|
|
35
|
+
const lorem = (length, wordOffset = 0) => {
|
|
36
|
+
const count = parseInt(length.substring(0, length.length - 1));
|
|
37
|
+
const countType = length.charAt(length.length - 1);
|
|
38
|
+
if (!isNaN(count) && (countType === "w" || countType === "c")) {
|
|
39
|
+
if (!lorem.spaceIndices.length) {
|
|
40
|
+
let startIndex = -1;
|
|
41
|
+
do {
|
|
42
|
+
const index = wordsString.indexOf(" ", startIndex + 1);
|
|
43
|
+
lorem.spaceIndices.push(index);
|
|
44
|
+
startIndex = index;
|
|
45
|
+
} while (startIndex !== -1);
|
|
46
|
+
}
|
|
47
|
+
if (countType === "c") {
|
|
48
|
+
return wordsString.substring(0, count);
|
|
49
|
+
} else {
|
|
50
|
+
let sentence = "";
|
|
51
|
+
const startSpaceIndex = lorem.spaceIndices[wordOffset % lorem.spaceIndices.length - 1];
|
|
52
|
+
const endSpaceIndex = lorem.spaceIndices[(wordOffset % lorem.spaceIndices.length + count) % lorem.spaceIndices.length - 1];
|
|
53
|
+
if (count + wordOffset % lorem.spaceIndices.length > lorem.spaceIndices.length) {
|
|
54
|
+
sentence += wordsString.substring(startSpaceIndex + 1) + " ";
|
|
55
|
+
const wraparoundCounts = Math.floor(count / lorem.spaceIndices.length) - 1;
|
|
56
|
+
for (let i = 0; i < wraparoundCounts; i++) {
|
|
57
|
+
sentence += wordsString + " ";
|
|
58
|
+
}
|
|
59
|
+
sentence += wordsString.substring(0, endSpaceIndex);
|
|
60
|
+
} else {
|
|
61
|
+
sentence = wordsString.substring(startSpaceIndex + 1, endSpaceIndex);
|
|
62
|
+
}
|
|
63
|
+
if (sentence.charAt(sentence.length - 1) === ",") {
|
|
64
|
+
return sentence.substring(0, sentence.length - 1);
|
|
65
|
+
} else {
|
|
66
|
+
return sentence.substring(0, sentence.length);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw new Error("Length must be of the form `${number}w` or `${number}c`");
|
|
71
|
+
};
|
|
72
|
+
lorem.spaceIndices = [];
|
|
36
73
|
|
|
37
|
-
const createFaker = (seed
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
74
|
+
const createFaker = (seed) => {
|
|
75
|
+
return new Faker(seed);
|
|
76
|
+
};
|
|
77
|
+
const DAY_MS = 1e3 * 60 * 60 * 24;
|
|
78
|
+
const YEAR_MS = DAY_MS * 365;
|
|
79
|
+
const YEAR_2022_MS = 52 * (YEAR_MS + DAY_MS / 4);
|
|
80
|
+
class Faker {
|
|
81
|
+
constructor(seed) {
|
|
82
|
+
this.seed = seed;
|
|
83
|
+
this.rand = new Rand__default["default"](seed.toString());
|
|
43
84
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return createFaker.cache[cacheKey];
|
|
85
|
+
boolean() {
|
|
86
|
+
return this.random() >= 0.5;
|
|
47
87
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
88
|
+
random() {
|
|
89
|
+
return this.rand.next();
|
|
90
|
+
}
|
|
91
|
+
randomElement(elements) {
|
|
92
|
+
return elements[this.range(0, elements.length)];
|
|
93
|
+
}
|
|
94
|
+
randomElements(elements) {
|
|
95
|
+
const alwaysInclude = this.randomElement(elements);
|
|
96
|
+
return elements.filter((element) => element === alwaysInclude || this.boolean());
|
|
97
|
+
}
|
|
98
|
+
range(min, max) {
|
|
99
|
+
return Math.floor(this.rangeFloat(Math.ceil(min), Math.floor(max)));
|
|
100
|
+
}
|
|
101
|
+
rangeFloat(min, max) {
|
|
102
|
+
return this.random() * (max - min) + min;
|
|
103
|
+
}
|
|
104
|
+
words(length, wordOffset = this.range(0, loremWords.length)) {
|
|
105
|
+
return lorem(`${length}w`, wordOffset);
|
|
106
|
+
}
|
|
107
|
+
word() {
|
|
108
|
+
return this.randomElement(loremWords);
|
|
109
|
+
}
|
|
110
|
+
lorem(length, wordOffset = this.range(0, loremWords.length)) {
|
|
111
|
+
return lorem(length, wordOffset);
|
|
112
|
+
}
|
|
113
|
+
url() {
|
|
114
|
+
return `https://${this.word()}.example`;
|
|
115
|
+
}
|
|
116
|
+
hexColor() {
|
|
117
|
+
return `#${this.hash(6)}`;
|
|
118
|
+
}
|
|
119
|
+
hash(length) {
|
|
120
|
+
let hash = "";
|
|
121
|
+
for (let i = 0; i < length; i++) {
|
|
122
|
+
const chars = this.boolean() ? "abcdef" : "0123456789";
|
|
123
|
+
hash += chars[this.range(0, chars.length)];
|
|
124
|
+
}
|
|
125
|
+
return hash;
|
|
126
|
+
}
|
|
127
|
+
date() {
|
|
128
|
+
return new Date(YEAR_2022_MS + this.range(-YEAR_MS * 3, YEAR_MS * 3));
|
|
129
|
+
}
|
|
130
|
+
dateAfter(date) {
|
|
131
|
+
const timestamp = date.getTime();
|
|
132
|
+
return new Date(this.range(timestamp, timestamp + YEAR_MS * 3));
|
|
133
|
+
}
|
|
134
|
+
dateBefore(date) {
|
|
135
|
+
const timestamp = date.getTime();
|
|
136
|
+
return new Date(this.range(timestamp - YEAR_MS * 3, timestamp));
|
|
137
|
+
}
|
|
138
|
+
dateBetween(min, max) {
|
|
139
|
+
return new Date(this.range(min.getTime(), max.getTime()));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
55
142
|
|
|
56
|
-
const boolean = (config
|
|
57
|
-
const faker = createFaker(config.seed);
|
|
58
|
-
return faker.
|
|
143
|
+
const boolean = (config) => {
|
|
144
|
+
const faker = config.faker || createFaker(config.seed);
|
|
145
|
+
return faker.boolean();
|
|
59
146
|
};
|
|
60
147
|
|
|
61
148
|
const generateTags = (config) => {
|
|
62
149
|
var _a, _b;
|
|
63
|
-
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 }))));
|
|
150
|
+
const faker = config.faker || createFaker(config.seed);
|
|
151
|
+
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
152
|
};
|
|
69
153
|
|
|
70
154
|
const valueForModel = (config) => {
|
|
155
|
+
var _a;
|
|
156
|
+
const faker = config.faker || createFaker(config.seed);
|
|
71
157
|
const model = config.model;
|
|
72
158
|
switch (model.type) {
|
|
73
159
|
case prismicT__namespace.CustomTypeModelFieldType.Boolean: {
|
|
74
160
|
return boolean({
|
|
75
|
-
|
|
161
|
+
faker,
|
|
76
162
|
model,
|
|
77
163
|
...config.config
|
|
78
164
|
});
|
|
79
165
|
}
|
|
80
166
|
case prismicT__namespace.CustomTypeModelFieldType.Color: {
|
|
81
167
|
return color({
|
|
82
|
-
|
|
168
|
+
faker,
|
|
83
169
|
model,
|
|
84
170
|
...config.config
|
|
85
171
|
});
|
|
86
172
|
}
|
|
87
173
|
case prismicT__namespace.CustomTypeModelFieldType.Link: {
|
|
88
|
-
switch (model.config.select) {
|
|
174
|
+
switch ((_a = model.config) == null ? void 0 : _a.select) {
|
|
89
175
|
case prismicT__namespace.CustomTypeModelLinkSelectType.Document: {
|
|
90
176
|
return contentRelationship({
|
|
91
|
-
|
|
177
|
+
faker,
|
|
92
178
|
model,
|
|
93
179
|
...config.config
|
|
94
180
|
});
|
|
95
181
|
}
|
|
96
182
|
case prismicT__namespace.CustomTypeModelLinkSelectType.Media: {
|
|
97
183
|
return linkToMedia({
|
|
98
|
-
|
|
184
|
+
faker,
|
|
99
185
|
model,
|
|
100
186
|
...config.config
|
|
101
187
|
});
|
|
102
188
|
}
|
|
103
189
|
default: {
|
|
104
190
|
return link({
|
|
105
|
-
|
|
191
|
+
faker,
|
|
106
192
|
model,
|
|
107
193
|
...config.config
|
|
108
194
|
});
|
|
@@ -111,70 +197,70 @@ const valueForModel = (config) => {
|
|
|
111
197
|
}
|
|
112
198
|
case prismicT__namespace.CustomTypeModelFieldType.Date: {
|
|
113
199
|
return date({
|
|
114
|
-
|
|
200
|
+
faker,
|
|
115
201
|
model,
|
|
116
202
|
...config.config
|
|
117
203
|
});
|
|
118
204
|
}
|
|
119
205
|
case prismicT__namespace.CustomTypeModelFieldType.Embed: {
|
|
120
206
|
return embed$1({
|
|
121
|
-
|
|
207
|
+
faker,
|
|
122
208
|
model,
|
|
123
209
|
...config.config
|
|
124
210
|
});
|
|
125
211
|
}
|
|
126
212
|
case prismicT__namespace.CustomTypeModelFieldType.GeoPoint: {
|
|
127
213
|
return geoPoint({
|
|
128
|
-
|
|
214
|
+
faker,
|
|
129
215
|
model,
|
|
130
216
|
...config.config
|
|
131
217
|
});
|
|
132
218
|
}
|
|
133
219
|
case prismicT__namespace.CustomTypeModelFieldType.Image: {
|
|
134
220
|
return image$1({
|
|
135
|
-
|
|
221
|
+
faker,
|
|
136
222
|
model,
|
|
137
223
|
...config.config
|
|
138
224
|
});
|
|
139
225
|
}
|
|
140
226
|
case prismicT__namespace.CustomTypeModelFieldType.Text: {
|
|
141
227
|
return keyText({
|
|
142
|
-
|
|
228
|
+
faker,
|
|
143
229
|
model,
|
|
144
230
|
...config.config
|
|
145
231
|
});
|
|
146
232
|
}
|
|
147
233
|
case prismicT__namespace.CustomTypeModelFieldType.Number: {
|
|
148
234
|
return number({
|
|
149
|
-
|
|
235
|
+
faker,
|
|
150
236
|
model,
|
|
151
237
|
...config.config
|
|
152
238
|
});
|
|
153
239
|
}
|
|
154
240
|
case prismicT__namespace.CustomTypeModelFieldType.Select: {
|
|
155
241
|
return select({
|
|
156
|
-
|
|
242
|
+
faker,
|
|
157
243
|
model,
|
|
158
244
|
...config.config
|
|
159
245
|
});
|
|
160
246
|
}
|
|
161
247
|
case prismicT__namespace.CustomTypeModelFieldType.Timestamp: {
|
|
162
248
|
return timestamp({
|
|
163
|
-
|
|
249
|
+
faker,
|
|
164
250
|
model,
|
|
165
251
|
...config.config
|
|
166
252
|
});
|
|
167
253
|
}
|
|
168
254
|
case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
|
|
169
|
-
if ("single" in model.config && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
|
|
255
|
+
if (model.config && "single" in model.config && model.config.single && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
|
|
170
256
|
return title({
|
|
171
|
-
|
|
257
|
+
faker,
|
|
172
258
|
model,
|
|
173
259
|
...config.config
|
|
174
260
|
});
|
|
175
261
|
} else {
|
|
176
262
|
return richText({
|
|
177
|
-
|
|
263
|
+
faker,
|
|
178
264
|
model,
|
|
179
265
|
...config.config
|
|
180
266
|
});
|
|
@@ -182,36 +268,41 @@ const valueForModel = (config) => {
|
|
|
182
268
|
}
|
|
183
269
|
case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields: {
|
|
184
270
|
return integrationFields({
|
|
185
|
-
|
|
271
|
+
faker,
|
|
186
272
|
model,
|
|
187
273
|
...config.config
|
|
188
274
|
});
|
|
189
275
|
}
|
|
190
276
|
case prismicT__namespace.CustomTypeModelFieldType.UID: {
|
|
191
277
|
return uid({
|
|
192
|
-
|
|
278
|
+
faker,
|
|
193
279
|
model,
|
|
194
280
|
...config.config
|
|
195
281
|
});
|
|
196
282
|
}
|
|
197
283
|
case prismicT__namespace.CustomTypeModelFieldType.Group: {
|
|
198
284
|
return group({
|
|
199
|
-
|
|
285
|
+
faker,
|
|
200
286
|
model,
|
|
201
287
|
...config.config
|
|
202
288
|
});
|
|
203
289
|
}
|
|
290
|
+
case prismicT__namespace.CustomTypeModelFieldType.LegacySlices:
|
|
204
291
|
case prismicT__namespace.CustomTypeModelFieldType.Slices: {
|
|
205
292
|
return sliceZone({
|
|
206
|
-
|
|
293
|
+
faker,
|
|
207
294
|
model,
|
|
208
295
|
...config.config
|
|
209
296
|
});
|
|
210
297
|
}
|
|
298
|
+
default: {
|
|
299
|
+
throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
|
|
300
|
+
}
|
|
211
301
|
}
|
|
212
302
|
};
|
|
213
303
|
|
|
214
304
|
const getValueConfigType = (model) => {
|
|
305
|
+
var _a;
|
|
215
306
|
switch (model.type) {
|
|
216
307
|
case prismicT__namespace.CustomTypeModelFieldType.Boolean:
|
|
217
308
|
return "boolean";
|
|
@@ -228,7 +319,7 @@ const getValueConfigType = (model) => {
|
|
|
228
319
|
case prismicT__namespace.CustomTypeModelFieldType.Image:
|
|
229
320
|
return "image";
|
|
230
321
|
case prismicT__namespace.CustomTypeModelFieldType.Link: {
|
|
231
|
-
switch (model.config.select) {
|
|
322
|
+
switch ((_a = model.config) == null ? void 0 : _a.select) {
|
|
232
323
|
case prismicT__namespace.CustomTypeModelLinkSelectType.Document:
|
|
233
324
|
return "contentRelationship";
|
|
234
325
|
case prismicT__namespace.CustomTypeModelLinkSelectType.Media:
|
|
@@ -242,7 +333,7 @@ const getValueConfigType = (model) => {
|
|
|
242
333
|
case prismicT__namespace.CustomTypeModelFieldType.Select:
|
|
243
334
|
return "select";
|
|
244
335
|
case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
|
|
245
|
-
if ("single" in model.config && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
|
|
336
|
+
if (model.config && "single" in model.config && model.config.single && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
|
|
246
337
|
return "title";
|
|
247
338
|
} else {
|
|
248
339
|
return "richText";
|
|
@@ -258,17 +349,21 @@ const getValueConfigType = (model) => {
|
|
|
258
349
|
return "integrationFields";
|
|
259
350
|
case prismicT__namespace.CustomTypeModelFieldType.Slices:
|
|
260
351
|
return "sliceZone";
|
|
352
|
+
default: {
|
|
353
|
+
throw new Error(`The "${model.type}" field type is not supported in @prismicio/mock.`);
|
|
354
|
+
}
|
|
261
355
|
}
|
|
262
356
|
};
|
|
263
357
|
const valueForModelMap = (config) => {
|
|
264
358
|
var _a;
|
|
359
|
+
const faker = config.faker || createFaker(config.seed);
|
|
265
360
|
const result = {};
|
|
266
361
|
for (const fieldId in config.map) {
|
|
267
362
|
const fieldModel = config.map[fieldId];
|
|
268
363
|
const fieldConfigType = getValueConfigType(fieldModel);
|
|
269
364
|
const fieldConfig = (_a = config.configs) == null ? void 0 : _a[fieldConfigType];
|
|
270
365
|
result[fieldId] = valueForModel({
|
|
271
|
-
|
|
366
|
+
faker,
|
|
272
367
|
model: fieldModel,
|
|
273
368
|
config: fieldConfig
|
|
274
369
|
});
|
|
@@ -276,13 +371,13 @@ const valueForModelMap = (config) => {
|
|
|
276
371
|
return result;
|
|
277
372
|
};
|
|
278
373
|
|
|
279
|
-
const contentRelationship$1 = (config
|
|
280
|
-
const faker = createFaker(config.seed);
|
|
374
|
+
const contentRelationship$1 = (config) => {
|
|
375
|
+
const faker = config.faker || createFaker(config.seed);
|
|
281
376
|
return {
|
|
282
377
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
283
378
|
config: {
|
|
284
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
285
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
379
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
380
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
286
381
|
select: prismicT__namespace.CustomTypeModelLinkSelectType.Document,
|
|
287
382
|
customtypes: config.customTypeIDs,
|
|
288
383
|
tags: config.tags
|
|
@@ -290,10 +385,10 @@ const contentRelationship$1 = (config = {}) => {
|
|
|
290
385
|
};
|
|
291
386
|
};
|
|
292
387
|
|
|
293
|
-
const customType$1 = (config
|
|
388
|
+
const customType$1 = (config) => {
|
|
294
389
|
var _a, _b;
|
|
295
|
-
const faker = createFaker(config.seed);
|
|
296
|
-
let label = config.label || changeCase__namespace.capitalCase(faker.
|
|
390
|
+
const faker = config.faker || createFaker(config.seed);
|
|
391
|
+
let label = config.label || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
297
392
|
let id = config.id || changeCase__namespace.snakeCase(label);
|
|
298
393
|
if (config.id && !config.label) {
|
|
299
394
|
label = changeCase__namespace.capitalCase(config.id);
|
|
@@ -309,62 +404,62 @@ const customType$1 = (config = {}) => {
|
|
|
309
404
|
return {
|
|
310
405
|
id,
|
|
311
406
|
label,
|
|
312
|
-
status: (_a = config.status) != null ? _a : faker.
|
|
313
|
-
repeatable: (_b = config.repeatable) != null ? _b : faker.
|
|
407
|
+
status: (_a = config.status) != null ? _a : faker.boolean(),
|
|
408
|
+
repeatable: (_b = config.repeatable) != null ? _b : faker.boolean(),
|
|
314
409
|
json
|
|
315
410
|
};
|
|
316
411
|
};
|
|
317
412
|
|
|
318
|
-
|
|
319
|
-
const faker = createFaker(config.seed);
|
|
413
|
+
function group$1(config) {
|
|
414
|
+
const faker = config.faker || createFaker(config.seed);
|
|
320
415
|
return {
|
|
321
416
|
type: prismicT__namespace.CustomTypeModelFieldType.Group,
|
|
322
417
|
config: {
|
|
323
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
418
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
324
419
|
fields: config.fields || {}
|
|
325
420
|
}
|
|
326
421
|
};
|
|
327
|
-
}
|
|
422
|
+
}
|
|
328
423
|
|
|
329
|
-
const image$2 = (config
|
|
330
|
-
const faker = createFaker(config.seed);
|
|
424
|
+
const image$2 = (config) => {
|
|
425
|
+
const faker = config.faker || createFaker(config.seed);
|
|
331
426
|
const thumbnails = (config.thumbnailNames || []).map((name) => {
|
|
332
427
|
return {
|
|
333
428
|
name,
|
|
334
|
-
width: faker.
|
|
335
|
-
height: faker.
|
|
429
|
+
width: faker.range(500, 2e3),
|
|
430
|
+
height: faker.range(500, 2e3)
|
|
336
431
|
};
|
|
337
432
|
});
|
|
338
433
|
return {
|
|
339
434
|
type: prismicT__namespace.CustomTypeModelFieldType.Image,
|
|
340
435
|
config: {
|
|
341
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
436
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
342
437
|
constraint: {
|
|
343
|
-
width: config.withConstraint ? faker.
|
|
344
|
-
height: config.withConstraint ? faker.
|
|
438
|
+
width: config.withConstraint ? faker.range(500, 2e3) : null,
|
|
439
|
+
height: config.withConstraint ? faker.range(500, 2e3) : null
|
|
345
440
|
},
|
|
346
441
|
thumbnails
|
|
347
442
|
}
|
|
348
443
|
};
|
|
349
444
|
};
|
|
350
445
|
|
|
351
|
-
const link$1 = (config
|
|
352
|
-
const faker = createFaker(config.seed);
|
|
446
|
+
const link$1 = (config) => {
|
|
447
|
+
const faker = config.faker || createFaker(config.seed);
|
|
353
448
|
return {
|
|
354
449
|
type: prismicT__namespace.CustomTypeModelFieldType.Link,
|
|
355
450
|
config: {
|
|
356
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
357
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
451
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
452
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
358
453
|
select: null,
|
|
359
|
-
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.
|
|
454
|
+
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
360
455
|
}
|
|
361
456
|
};
|
|
362
457
|
};
|
|
363
458
|
|
|
364
|
-
const richText$1 = (config
|
|
459
|
+
const richText$1 = (config) => {
|
|
365
460
|
var _a;
|
|
366
|
-
const faker = createFaker(config.seed);
|
|
367
|
-
const blockTypes = faker.
|
|
461
|
+
const faker = config.faker || createFaker(config.seed);
|
|
462
|
+
const blockTypes = faker.randomElements([
|
|
368
463
|
prismicT__namespace.RichTextNodeType.heading1,
|
|
369
464
|
prismicT__namespace.RichTextNodeType.heading2,
|
|
370
465
|
prismicT__namespace.RichTextNodeType.heading3,
|
|
@@ -381,34 +476,34 @@ const richText$1 = (config = {}) => {
|
|
|
381
476
|
prismicT__namespace.RichTextNodeType.embed,
|
|
382
477
|
prismicT__namespace.RichTextNodeType.hyperlink
|
|
383
478
|
]).join(",");
|
|
384
|
-
const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.
|
|
479
|
+
const blockTypeConfig = ((_a = config.withMultipleBlocks) != null ? _a : faker.boolean()) ? { multi: blockTypes } : { single: blockTypes };
|
|
385
480
|
return {
|
|
386
481
|
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
387
482
|
config: {
|
|
388
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
389
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
390
|
-
allowTargetBlank: faker.
|
|
483
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
484
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
485
|
+
allowTargetBlank: faker.boolean() ? true : void 0,
|
|
391
486
|
...blockTypeConfig
|
|
392
487
|
}
|
|
393
488
|
};
|
|
394
489
|
};
|
|
395
490
|
|
|
396
|
-
const select$1 = (config
|
|
397
|
-
const faker = createFaker(config.seed);
|
|
491
|
+
const select$1 = (config) => {
|
|
492
|
+
const faker = config.faker || createFaker(config.seed);
|
|
398
493
|
return {
|
|
399
494
|
type: prismicT__namespace.CustomTypeModelFieldType.Select,
|
|
400
495
|
config: {
|
|
401
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
402
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
496
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
497
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
403
498
|
options: config.options || [],
|
|
404
499
|
default_value: config.defaultValue || void 0
|
|
405
500
|
}
|
|
406
501
|
};
|
|
407
502
|
};
|
|
408
503
|
|
|
409
|
-
const sharedSlice$1 = (config
|
|
410
|
-
const faker = createFaker(config.seed);
|
|
411
|
-
let name = config.name || changeCase__namespace.capitalCase(faker.
|
|
504
|
+
const sharedSlice$1 = (config) => {
|
|
505
|
+
const faker = config.faker || createFaker(config.seed);
|
|
506
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
412
507
|
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
413
508
|
if (config.id && !config.name) {
|
|
414
509
|
name = changeCase__namespace.pascalCase(config.id);
|
|
@@ -419,45 +514,134 @@ const sharedSlice$1 = (config = {}) => {
|
|
|
419
514
|
type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice,
|
|
420
515
|
id,
|
|
421
516
|
name,
|
|
422
|
-
description: faker.
|
|
517
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
423
518
|
variations: config.variations || []
|
|
424
519
|
};
|
|
425
520
|
};
|
|
426
521
|
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
522
|
+
const dataSet$1 = [
|
|
523
|
+
{
|
|
524
|
+
url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
|
|
525
|
+
width: 4240,
|
|
526
|
+
height: 2832
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
|
|
530
|
+
width: 7372,
|
|
531
|
+
height: 4392
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
|
|
535
|
+
width: 2560,
|
|
536
|
+
height: 1705
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
|
|
540
|
+
width: 2200,
|
|
541
|
+
height: 1467
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
|
|
545
|
+
width: 5616,
|
|
546
|
+
height: 3744
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
|
|
550
|
+
width: 4240,
|
|
551
|
+
height: 2832
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
|
|
555
|
+
width: 2560,
|
|
556
|
+
height: 1440
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
|
|
560
|
+
width: 6373,
|
|
561
|
+
height: 4253
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
|
|
565
|
+
width: 4272,
|
|
566
|
+
height: 2848
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
|
|
570
|
+
width: 4554,
|
|
571
|
+
height: 3036
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
|
|
575
|
+
width: 6550,
|
|
576
|
+
height: 4367
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
|
|
580
|
+
width: 6e3,
|
|
581
|
+
height: 4e3
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
|
|
585
|
+
width: 6e3,
|
|
586
|
+
height: 4e3
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
|
|
590
|
+
width: 4608,
|
|
591
|
+
height: 3456
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
|
|
595
|
+
width: 4844,
|
|
596
|
+
height: 3234
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
|
|
600
|
+
width: 4335,
|
|
601
|
+
height: 6502
|
|
602
|
+
}
|
|
603
|
+
];
|
|
604
|
+
const getMockImageData = (config) => {
|
|
605
|
+
const faker = config.faker || createFaker(config.seed);
|
|
606
|
+
return faker.randomElement(dataSet$1);
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
const sharedSliceVariation$1 = (config) => {
|
|
610
|
+
const faker = config.faker || createFaker(config.seed);
|
|
611
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
430
612
|
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
431
613
|
if (config.id && !config.name) {
|
|
432
614
|
name = changeCase__namespace.pascalCase(config.id);
|
|
433
615
|
} else if (config.name && !config.name) {
|
|
434
616
|
id = changeCase__namespace.snakeCase(config.name);
|
|
435
617
|
}
|
|
618
|
+
const imageData = getMockImageData({ faker });
|
|
436
619
|
return {
|
|
437
620
|
id,
|
|
438
621
|
name,
|
|
439
|
-
description: faker.
|
|
440
|
-
docURL: faker.
|
|
441
|
-
version: faker.
|
|
622
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
623
|
+
docURL: faker.url(),
|
|
624
|
+
version: faker.hash(7),
|
|
442
625
|
primary: config.primaryFields || {},
|
|
443
|
-
items: config.itemsFields || {}
|
|
626
|
+
items: config.itemsFields || {},
|
|
627
|
+
imageUrl: imageData.url
|
|
444
628
|
};
|
|
445
629
|
};
|
|
446
630
|
|
|
447
|
-
const slice$1 = (config
|
|
448
|
-
const faker = createFaker(config.seed);
|
|
631
|
+
const slice$1 = (config) => {
|
|
632
|
+
const faker = config.faker || createFaker(config.seed);
|
|
449
633
|
return {
|
|
450
634
|
type: prismicT__namespace.CustomTypeModelSliceType.Slice,
|
|
451
|
-
icon: changeCase__namespace.snakeCase(faker.
|
|
452
|
-
display: faker.
|
|
453
|
-
fieldset: changeCase__namespace.capitalCase(faker.
|
|
454
|
-
description: faker.
|
|
635
|
+
icon: changeCase__namespace.snakeCase(faker.word()),
|
|
636
|
+
display: faker.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List,
|
|
637
|
+
fieldset: changeCase__namespace.capitalCase(faker.words(2)),
|
|
638
|
+
description: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 10))),
|
|
455
639
|
repeat: config.repeatFields || {},
|
|
456
640
|
"non-repeat": config.nonRepeatFields || {}
|
|
457
641
|
};
|
|
458
642
|
};
|
|
459
643
|
|
|
460
|
-
const sliceZone$1 = (config
|
|
644
|
+
const sliceZone$1 = (config) => {
|
|
461
645
|
const labels = {};
|
|
462
646
|
for (const choiceId in config.choices) {
|
|
463
647
|
const choice = config.choices[choiceId];
|
|
@@ -475,9 +659,9 @@ const sliceZone$1 = (config = {}) => {
|
|
|
475
659
|
};
|
|
476
660
|
};
|
|
477
661
|
|
|
478
|
-
const title$1 = (config
|
|
479
|
-
const faker = createFaker(config.seed);
|
|
480
|
-
const single = faker.
|
|
662
|
+
const title$1 = (config) => {
|
|
663
|
+
const faker = config.faker || createFaker(config.seed);
|
|
664
|
+
const single = faker.randomElements([
|
|
481
665
|
"heading1",
|
|
482
666
|
"heading2",
|
|
483
667
|
"heading3",
|
|
@@ -488,24 +672,38 @@ const title$1 = (config = {}) => {
|
|
|
488
672
|
return {
|
|
489
673
|
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
490
674
|
config: {
|
|
491
|
-
label: changeCase__namespace.capitalCase(faker.
|
|
492
|
-
placeholder: changeCase__namespace.sentenceCase(faker.
|
|
675
|
+
label: changeCase__namespace.capitalCase(faker.word()),
|
|
676
|
+
placeholder: changeCase__namespace.sentenceCase(faker.words(3)),
|
|
493
677
|
single,
|
|
494
|
-
allowTargetBlank: faker.
|
|
678
|
+
allowTargetBlank: faker.boolean() || void 0
|
|
495
679
|
}
|
|
496
680
|
};
|
|
497
681
|
};
|
|
498
682
|
|
|
499
683
|
const generateFieldId = (config) => {
|
|
500
|
-
const faker = createFaker(config.seed);
|
|
501
|
-
return changeCase__namespace.snakeCase(faker.
|
|
684
|
+
const faker = config.faker || createFaker(config.seed);
|
|
685
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
502
686
|
};
|
|
503
687
|
|
|
504
|
-
const timestamp = (config
|
|
505
|
-
const faker = createFaker(config.seed);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
688
|
+
const timestamp = (config) => {
|
|
689
|
+
const faker = config.faker || createFaker(config.seed);
|
|
690
|
+
if (config.state === "empty") {
|
|
691
|
+
return null;
|
|
692
|
+
} else {
|
|
693
|
+
let date;
|
|
694
|
+
const after = config.after ? new Date(config.after.toISOString().split("T")[0]) : void 0;
|
|
695
|
+
const before = config.before ? new Date(config.before.toISOString().split("T")[0]) : void 0;
|
|
696
|
+
if (after && before) {
|
|
697
|
+
date = faker.dateBetween(after, before);
|
|
698
|
+
} else if (after) {
|
|
699
|
+
date = faker.dateAfter(after);
|
|
700
|
+
} else if (before) {
|
|
701
|
+
date = faker.dateBefore(before);
|
|
702
|
+
} else {
|
|
703
|
+
date = faker.date();
|
|
704
|
+
}
|
|
705
|
+
return date.toISOString();
|
|
706
|
+
}
|
|
509
707
|
};
|
|
510
708
|
|
|
511
709
|
const buildAlternativeLanguage = (config) => {
|
|
@@ -517,10 +715,10 @@ const buildAlternativeLanguage = (config) => {
|
|
|
517
715
|
};
|
|
518
716
|
};
|
|
519
717
|
|
|
520
|
-
const customType = (config
|
|
718
|
+
const customType = (config) => {
|
|
521
719
|
var _a;
|
|
522
|
-
const faker = createFaker(config.seed);
|
|
523
|
-
const model = config.model || customType$1({
|
|
720
|
+
const faker = config.faker || createFaker(config.seed);
|
|
721
|
+
const model = config.model || customType$1({ faker });
|
|
524
722
|
const fieldModelsMap = Object.assign({}, ...Object.values(model.json));
|
|
525
723
|
const dataFieldModelsMap = {};
|
|
526
724
|
for (const key in fieldModelsMap) {
|
|
@@ -536,28 +734,28 @@ const customType = (config = {}) => {
|
|
|
536
734
|
}));
|
|
537
735
|
return {
|
|
538
736
|
type: model.id,
|
|
539
|
-
id: faker.
|
|
540
|
-
uid: hasUID ? changeCase__namespace.snakeCase(faker.
|
|
541
|
-
url: withURL ? faker.
|
|
542
|
-
href: faker.
|
|
543
|
-
lang: faker.
|
|
544
|
-
tags: generateTags({
|
|
737
|
+
id: faker.hash(7),
|
|
738
|
+
uid: hasUID ? changeCase__namespace.snakeCase(faker.words(faker.range(1, 3))) : null,
|
|
739
|
+
url: withURL ? faker.url() : null,
|
|
740
|
+
href: faker.url(),
|
|
741
|
+
lang: faker.word(),
|
|
742
|
+
tags: generateTags({ faker }),
|
|
545
743
|
slugs: [],
|
|
546
744
|
linked_documents: [],
|
|
547
745
|
alternate_languages: alternateLanguages,
|
|
548
|
-
first_publication_date: timestamp({
|
|
549
|
-
last_publication_date: timestamp({
|
|
746
|
+
first_publication_date: timestamp({ faker }),
|
|
747
|
+
last_publication_date: timestamp({ faker }),
|
|
550
748
|
data: valueForModelMap({
|
|
551
|
-
|
|
749
|
+
faker,
|
|
552
750
|
map: dataFieldModelsMap,
|
|
553
751
|
configs: config.configs
|
|
554
752
|
})
|
|
555
753
|
};
|
|
556
754
|
};
|
|
557
755
|
|
|
558
|
-
const color = (config
|
|
559
|
-
const faker = createFaker(config.seed);
|
|
560
|
-
return config.state === "empty" ? null : faker.
|
|
756
|
+
const color = (config) => {
|
|
757
|
+
const faker = config.faker || createFaker(config.seed);
|
|
758
|
+
return config.state === "empty" ? null : faker.hexColor().toUpperCase();
|
|
561
759
|
};
|
|
562
760
|
|
|
563
761
|
const buildContentRelationshipField = (config) => {
|
|
@@ -575,35 +773,37 @@ const buildContentRelationshipField = (config) => {
|
|
|
575
773
|
};
|
|
576
774
|
|
|
577
775
|
const generateCustomTypeId = (config) => {
|
|
578
|
-
const faker = createFaker(config.seed);
|
|
579
|
-
return changeCase__namespace.snakeCase(faker.
|
|
776
|
+
const faker = config.faker || createFaker(config.seed);
|
|
777
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
580
778
|
};
|
|
581
779
|
|
|
582
|
-
const contentRelationship = (config
|
|
583
|
-
|
|
780
|
+
const contentRelationship = (config) => {
|
|
781
|
+
var _a, _b;
|
|
782
|
+
const faker = config.faker || createFaker(config.seed);
|
|
584
783
|
if (config.state === "empty") {
|
|
585
784
|
return {
|
|
586
785
|
link_type: prismicT__namespace.LinkType.Document
|
|
587
786
|
};
|
|
588
787
|
} else {
|
|
589
|
-
const model = config.model || contentRelationship$1({
|
|
788
|
+
const model = config.model || contentRelationship$1({ faker });
|
|
590
789
|
const linkableDocuments = config.linkableDocuments ? config.linkableDocuments.filter((document2) => {
|
|
790
|
+
var _a2, _b2;
|
|
591
791
|
let shouldKeep = true;
|
|
592
|
-
if (model.config.customtypes) {
|
|
792
|
+
if ((_a2 = model.config) == null ? void 0 : _a2.customtypes) {
|
|
593
793
|
shouldKeep = shouldKeep && model.config.customtypes.includes(document2.type);
|
|
594
794
|
}
|
|
595
|
-
if (model.config.tags) {
|
|
795
|
+
if ((_b2 = model.config) == null ? void 0 : _b2.tags) {
|
|
596
796
|
shouldKeep = shouldKeep && model.config.tags.some((tag) => document2.tags.includes(tag));
|
|
597
797
|
}
|
|
598
798
|
return shouldKeep;
|
|
599
799
|
}) : [
|
|
600
800
|
{
|
|
601
|
-
...customType({
|
|
602
|
-
type: model.config.customtypes ? faker.
|
|
603
|
-
tags: model.config.tags ? faker.
|
|
801
|
+
...customType({ faker }),
|
|
802
|
+
type: ((_a = model.config) == null ? void 0 : _a.customtypes) ? faker.randomElement(model.config.customtypes) : generateCustomTypeId({ faker }),
|
|
803
|
+
tags: ((_b = model.config) == null ? void 0 : _b.tags) ? faker.randomElements(model.config.tags) : generateTags({ faker })
|
|
604
804
|
}
|
|
605
805
|
];
|
|
606
|
-
const document = faker.
|
|
806
|
+
const document = faker.randomElement(linkableDocuments);
|
|
607
807
|
if (!document) {
|
|
608
808
|
throw new Error("A linkable document could not be found.");
|
|
609
809
|
}
|
|
@@ -613,9 +813,10 @@ const contentRelationship = (config = {}) => {
|
|
|
613
813
|
}
|
|
614
814
|
};
|
|
615
815
|
|
|
616
|
-
const date = (config
|
|
816
|
+
const date = (config) => {
|
|
817
|
+
const faker = config.faker || createFaker(config.seed);
|
|
617
818
|
return config.state === "empty" ? null : timestamp({
|
|
618
|
-
|
|
819
|
+
faker,
|
|
619
820
|
after: config.after,
|
|
620
821
|
before: config.before,
|
|
621
822
|
state: "filled"
|
|
@@ -623,118 +824,132 @@ const date = (config = {}) => {
|
|
|
623
824
|
};
|
|
624
825
|
|
|
625
826
|
const buildEmbedField = (config) => {
|
|
626
|
-
|
|
827
|
+
var _a;
|
|
828
|
+
const faker = config.faker || createFaker(config.seed);
|
|
627
829
|
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 })
|
|
830
|
+
embed_url: (_a = config.url) != null ? _a : faker.url(),
|
|
831
|
+
html: `<div>embed html</div>`,
|
|
832
|
+
...config.data
|
|
643
833
|
};
|
|
644
834
|
};
|
|
645
835
|
|
|
646
|
-
const dataSet
|
|
836
|
+
const dataSet = [
|
|
647
837
|
{
|
|
648
|
-
|
|
838
|
+
version: "1.0",
|
|
839
|
+
type: "video",
|
|
649
840
|
embed_url: "https://www.youtube.com/embed/fiOwHYFkUz0",
|
|
650
841
|
thumbnail_url: "https://i.ytimg.com/vi/fiOwHYFkUz0/hqdefault.jpg",
|
|
651
842
|
thumbnail_height: 360,
|
|
652
843
|
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>'
|
|
844
|
+
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>',
|
|
845
|
+
width: 200,
|
|
846
|
+
height: 113
|
|
654
847
|
},
|
|
655
848
|
{
|
|
656
|
-
|
|
849
|
+
version: "1.0",
|
|
850
|
+
type: "video",
|
|
657
851
|
embed_url: "https://www.youtube.com/embed/c-ATzcy6VkI",
|
|
658
852
|
thumbnail_url: "https://i.ytimg.com/vi/c-ATzcy6VkI/hqdefault.jpg",
|
|
659
853
|
thumbnail_height: 360,
|
|
660
854
|
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>'
|
|
855
|
+
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>',
|
|
856
|
+
width: 200,
|
|
857
|
+
height: 113
|
|
662
858
|
},
|
|
663
859
|
{
|
|
664
|
-
|
|
860
|
+
version: "1.0",
|
|
861
|
+
type: "video",
|
|
665
862
|
embed_url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
|
|
666
863
|
thumbnail_url: "https://i.ytimg.com/vi/iewZXv94XGY/hqdefault.jpg",
|
|
667
864
|
thumbnail_height: 360,
|
|
668
865
|
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>'
|
|
866
|
+
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>',
|
|
867
|
+
width: 200,
|
|
868
|
+
height: 113
|
|
670
869
|
},
|
|
671
870
|
{
|
|
672
|
-
|
|
673
|
-
|
|
871
|
+
version: "1.0",
|
|
872
|
+
type: "rich",
|
|
873
|
+
embed_url: "https://twitter.com/prismicio/status/1356293316158095361",
|
|
674
874
|
thumbnail_url: null,
|
|
675
875
|
thumbnail_height: null,
|
|
676
876
|
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'
|
|
877
|
+
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',
|
|
878
|
+
width: 200,
|
|
879
|
+
height: 113
|
|
678
880
|
},
|
|
679
881
|
{
|
|
680
|
-
|
|
882
|
+
type: "rich",
|
|
883
|
+
version: "1.0",
|
|
884
|
+
embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
|
|
681
885
|
thumbnail_url: null,
|
|
682
886
|
thumbnail_width: null,
|
|
683
887
|
thumbnail_height: null,
|
|
684
|
-
|
|
685
|
-
|
|
888
|
+
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',
|
|
889
|
+
width: 200,
|
|
890
|
+
height: 113
|
|
686
891
|
},
|
|
687
892
|
{
|
|
688
|
-
|
|
893
|
+
version: "1.0",
|
|
894
|
+
type: "rich",
|
|
895
|
+
embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
|
|
689
896
|
thumbnail_url: null,
|
|
690
897
|
thumbnail_width: null,
|
|
691
898
|
thumbnail_height: null,
|
|
692
|
-
|
|
693
|
-
|
|
899
|
+
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',
|
|
900
|
+
width: 200,
|
|
901
|
+
height: 113
|
|
694
902
|
},
|
|
695
903
|
{
|
|
696
|
-
|
|
904
|
+
version: "1.0",
|
|
905
|
+
type: "rich",
|
|
906
|
+
embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
|
|
697
907
|
thumbnail_url: null,
|
|
698
908
|
thumbnail_width: null,
|
|
699
909
|
thumbnail_height: null,
|
|
700
|
-
|
|
701
|
-
|
|
910
|
+
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',
|
|
911
|
+
width: 200,
|
|
912
|
+
height: 113
|
|
702
913
|
}
|
|
703
914
|
];
|
|
704
915
|
const getMockEmbedData = (config) => {
|
|
705
|
-
const faker = createFaker(config.seed);
|
|
706
|
-
return faker.
|
|
916
|
+
const faker = config.faker || createFaker(config.seed);
|
|
917
|
+
return faker.randomElement(dataSet);
|
|
707
918
|
};
|
|
708
919
|
|
|
709
|
-
const embed$1 = (config
|
|
710
|
-
|
|
711
|
-
|
|
920
|
+
const embed$1 = (config) => {
|
|
921
|
+
var _a, _b, _c;
|
|
922
|
+
const faker = config.faker || createFaker(config.seed);
|
|
923
|
+
const data = (_a = config.data) != null ? _a : getMockEmbedData({ faker });
|
|
924
|
+
return config.state === "empty" ? {} : buildEmbedField({
|
|
925
|
+
faker,
|
|
926
|
+
url: (_b = config.url) != null ? _b : "embed_url" in data ? data.embed_url : void 0,
|
|
927
|
+
html: (_c = config.html) != null ? _c : "html" in data ? data.html : void 0,
|
|
928
|
+
data
|
|
929
|
+
});
|
|
712
930
|
};
|
|
713
931
|
|
|
714
|
-
const geoPoint = (config
|
|
715
|
-
const faker = createFaker(config.seed);
|
|
716
|
-
const coordinates = faker.address.nearbyGPSCoordinate();
|
|
932
|
+
const geoPoint = (config) => {
|
|
933
|
+
const faker = config.faker || createFaker(config.seed);
|
|
717
934
|
return config.state === "empty" ? {} : {
|
|
718
|
-
longitude:
|
|
719
|
-
latitude:
|
|
935
|
+
longitude: faker.rangeFloat(-180, 180),
|
|
936
|
+
latitude: faker.rangeFloat(-90, 90)
|
|
720
937
|
};
|
|
721
938
|
};
|
|
722
939
|
|
|
723
|
-
const group = (config
|
|
940
|
+
const group = (config) => {
|
|
724
941
|
var _a;
|
|
725
942
|
if (config.state === "empty") {
|
|
726
943
|
return [];
|
|
727
944
|
} else {
|
|
728
|
-
const faker = createFaker(config.seed);
|
|
729
|
-
const model = config.model || group$1({
|
|
730
|
-
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.
|
|
731
|
-
min: 1,
|
|
732
|
-
max: 6
|
|
733
|
-
});
|
|
945
|
+
const faker = config.faker || createFaker(config.seed);
|
|
946
|
+
const model = config.model || group$1({ faker });
|
|
947
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.range(1, 6);
|
|
734
948
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
949
|
+
var _a2;
|
|
735
950
|
return valueForModelMap({
|
|
736
|
-
|
|
737
|
-
map: model.config.fields,
|
|
951
|
+
faker,
|
|
952
|
+
map: ((_a2 = model.config) == null ? void 0 : _a2.fields) || {},
|
|
738
953
|
configs: config.configs
|
|
739
954
|
});
|
|
740
955
|
});
|
|
@@ -751,7 +966,7 @@ const buildImageFieldImage = (config) => {
|
|
|
751
966
|
copyright: null
|
|
752
967
|
};
|
|
753
968
|
} else {
|
|
754
|
-
const faker = createFaker(config.seed);
|
|
969
|
+
const faker = config.faker || createFaker(config.seed);
|
|
755
970
|
const url = new URL(config.imageData.url);
|
|
756
971
|
const dimensions = {
|
|
757
972
|
width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
|
|
@@ -763,142 +978,52 @@ const buildImageFieldImage = (config) => {
|
|
|
763
978
|
return {
|
|
764
979
|
url: url.toString(),
|
|
765
980
|
dimensions,
|
|
766
|
-
alt: faker.
|
|
767
|
-
copyright: faker.
|
|
981
|
+
alt: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
|
|
982
|
+
copyright: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15)))
|
|
768
983
|
};
|
|
769
984
|
}
|
|
770
985
|
};
|
|
771
986
|
|
|
772
|
-
const
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
|
|
780
|
-
width: 7372,
|
|
781
|
-
height: 4392
|
|
782
|
-
},
|
|
783
|
-
{
|
|
784
|
-
url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
|
|
785
|
-
width: 2560,
|
|
786
|
-
height: 1705
|
|
787
|
-
},
|
|
788
|
-
{
|
|
789
|
-
url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
|
|
790
|
-
width: 2200,
|
|
791
|
-
height: 1467
|
|
792
|
-
},
|
|
793
|
-
{
|
|
794
|
-
url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
|
|
795
|
-
width: 5616,
|
|
796
|
-
height: 3744
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
|
|
800
|
-
width: 4240,
|
|
801
|
-
height: 2832
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
|
|
805
|
-
width: 2560,
|
|
806
|
-
height: 1440
|
|
807
|
-
},
|
|
808
|
-
{
|
|
809
|
-
url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
|
|
810
|
-
width: 6373,
|
|
811
|
-
height: 4253
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
|
|
815
|
-
width: 4272,
|
|
816
|
-
height: 2848
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
|
|
820
|
-
width: 4554,
|
|
821
|
-
height: 3036
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
|
|
825
|
-
width: 6550,
|
|
826
|
-
height: 4367
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
|
|
830
|
-
width: 6e3,
|
|
831
|
-
height: 4e3
|
|
832
|
-
},
|
|
833
|
-
{
|
|
834
|
-
url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
|
|
835
|
-
width: 6e3,
|
|
836
|
-
height: 4e3
|
|
837
|
-
},
|
|
838
|
-
{
|
|
839
|
-
url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
|
|
840
|
-
width: 4608,
|
|
841
|
-
height: 3456
|
|
842
|
-
},
|
|
843
|
-
{
|
|
844
|
-
url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
|
|
845
|
-
width: 4844,
|
|
846
|
-
height: 3234
|
|
847
|
-
},
|
|
848
|
-
{
|
|
849
|
-
url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
|
|
850
|
-
width: 4335,
|
|
851
|
-
height: 6502
|
|
852
|
-
}
|
|
853
|
-
];
|
|
854
|
-
const getMockImageData = (config) => {
|
|
855
|
-
const faker = createFaker(config.seed);
|
|
856
|
-
return faker.random.arrayElement(dataSet);
|
|
857
|
-
};
|
|
858
|
-
|
|
859
|
-
const image$1 = (config = {}) => {
|
|
860
|
-
const model = config.model || image$2({ seed: config.seed });
|
|
861
|
-
const imageData = getMockImageData({ seed: config.seed });
|
|
987
|
+
const image$1 = (config) => {
|
|
988
|
+
var _a, _b;
|
|
989
|
+
const faker = config.faker || createFaker(config.seed);
|
|
990
|
+
const model = config.model || image$2({ faker });
|
|
991
|
+
const imageData = getMockImageData({ faker });
|
|
862
992
|
const value = buildImageFieldImage({
|
|
863
|
-
|
|
993
|
+
faker,
|
|
864
994
|
imageData,
|
|
865
|
-
constraint: model.config.constraint,
|
|
995
|
+
constraint: (_a = model.config) == null ? void 0 : _a.constraint,
|
|
866
996
|
state: config.state
|
|
867
997
|
});
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
998
|
+
if ((_b = model.config) == null ? void 0 : _b.thumbnails) {
|
|
999
|
+
for (const thumbnail of model.config.thumbnails) {
|
|
1000
|
+
value[thumbnail.name] = buildImageFieldImage({
|
|
1001
|
+
faker,
|
|
1002
|
+
imageData,
|
|
1003
|
+
constraint: {
|
|
1004
|
+
width: thumbnail.width,
|
|
1005
|
+
height: thumbnail.height
|
|
1006
|
+
},
|
|
1007
|
+
state: config.state
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
878
1010
|
}
|
|
879
1011
|
return value;
|
|
880
1012
|
};
|
|
881
1013
|
|
|
882
|
-
const integrationFields = (config
|
|
883
|
-
|
|
884
|
-
const
|
|
885
|
-
return config.state === "empty" ? null :
|
|
886
|
-
id: faker.git.shortSha(),
|
|
887
|
-
title: changeCase__namespace.capitalCase(faker.lorem.words(3)),
|
|
888
|
-
description: faker.lorem.sentence(),
|
|
889
|
-
image_url: imageData.url,
|
|
890
|
-
last_update: faker.date.past(20, new Date("2021-03-07")).getTime(),
|
|
891
|
-
blob: config.data
|
|
892
|
-
};
|
|
1014
|
+
const integrationFields = (config) => {
|
|
1015
|
+
var _a;
|
|
1016
|
+
const data = (_a = config.data) != null ? _a : {};
|
|
1017
|
+
return config.state === "empty" ? null : data;
|
|
893
1018
|
};
|
|
894
1019
|
|
|
895
|
-
const keyText = (config
|
|
896
|
-
const faker = createFaker(config.seed);
|
|
897
|
-
return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.
|
|
1020
|
+
const keyText = (config) => {
|
|
1021
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1022
|
+
return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.words(3));
|
|
898
1023
|
};
|
|
899
1024
|
|
|
900
|
-
const linkToMedia = (config
|
|
901
|
-
const faker = createFaker(config.seed);
|
|
1025
|
+
const linkToMedia = (config) => {
|
|
1026
|
+
const faker = config.faker || createFaker(config.seed);
|
|
902
1027
|
if (config.state === "empty") {
|
|
903
1028
|
return {
|
|
904
1029
|
link_type: prismicT__namespace.LinkType.Media
|
|
@@ -906,20 +1031,20 @@ const linkToMedia = (config = {}) => {
|
|
|
906
1031
|
} else {
|
|
907
1032
|
return {
|
|
908
1033
|
link_type: prismicT__namespace.LinkType.Media,
|
|
909
|
-
name: faker.
|
|
910
|
-
kind: faker.
|
|
911
|
-
url: faker.
|
|
912
|
-
size: faker.
|
|
913
|
-
height: faker.
|
|
914
|
-
width: faker.
|
|
1034
|
+
name: `${changeCase__namespace.snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
1035
|
+
kind: changeCase__namespace.snakeCase(faker.word()),
|
|
1036
|
+
url: faker.url(),
|
|
1037
|
+
size: faker.range(500, 3e3).toString(),
|
|
1038
|
+
height: faker.range(500, 3e3).toString(),
|
|
1039
|
+
width: faker.range(500, 3e3).toString()
|
|
915
1040
|
};
|
|
916
1041
|
}
|
|
917
1042
|
};
|
|
918
1043
|
|
|
919
|
-
const link = (config
|
|
920
|
-
var _a;
|
|
921
|
-
const faker = createFaker(config.seed);
|
|
922
|
-
const type = config.type || faker.
|
|
1044
|
+
const link = (config) => {
|
|
1045
|
+
var _a, _b;
|
|
1046
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1047
|
+
const type = config.type || faker.randomElement([
|
|
923
1048
|
prismicT__namespace.LinkType.Web,
|
|
924
1049
|
prismicT__namespace.LinkType.Document,
|
|
925
1050
|
prismicT__namespace.LinkType.Media
|
|
@@ -932,33 +1057,33 @@ const link = (config = {}) => {
|
|
|
932
1057
|
switch (type) {
|
|
933
1058
|
case prismicT__namespace.LinkType.Document: {
|
|
934
1059
|
return contentRelationship({
|
|
935
|
-
|
|
1060
|
+
faker,
|
|
936
1061
|
state: config.state,
|
|
937
1062
|
linkableDocuments: config.linkableDocuments
|
|
938
1063
|
});
|
|
939
1064
|
}
|
|
940
1065
|
case prismicT__namespace.LinkType.Media: {
|
|
941
1066
|
return linkToMedia({
|
|
942
|
-
|
|
1067
|
+
faker,
|
|
943
1068
|
state: config.state
|
|
944
1069
|
});
|
|
945
1070
|
}
|
|
946
1071
|
case prismicT__namespace.LinkType.Web:
|
|
947
1072
|
default: {
|
|
948
|
-
const model = config.model || link$1({
|
|
1073
|
+
const model = config.model || link$1({ faker });
|
|
949
1074
|
return {
|
|
950
1075
|
link_type: prismicT__namespace.LinkType.Web,
|
|
951
|
-
url: faker.
|
|
952
|
-
target: ((
|
|
1076
|
+
url: faker.url(),
|
|
1077
|
+
target: ((_b = config.withTargetBlank) != null ? _b : ((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
953
1078
|
};
|
|
954
1079
|
}
|
|
955
1080
|
}
|
|
956
1081
|
}
|
|
957
1082
|
};
|
|
958
1083
|
|
|
959
|
-
const number = (config
|
|
960
|
-
const faker = createFaker(config.seed);
|
|
961
|
-
return config.state === "empty" ? null : faker.
|
|
1084
|
+
const number = (config) => {
|
|
1085
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1086
|
+
return config.state === "empty" ? null : faker.range(1, 100);
|
|
962
1087
|
};
|
|
963
1088
|
|
|
964
1089
|
const patterns$5 = {
|
|
@@ -975,27 +1100,32 @@ const patterns$5 = {
|
|
|
975
1100
|
maxWords: 12
|
|
976
1101
|
}
|
|
977
1102
|
};
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1103
|
+
const headingNoteTypes = [
|
|
1104
|
+
prismicT__namespace.RichTextNodeType.heading1,
|
|
1105
|
+
prismicT__namespace.RichTextNodeType.heading2,
|
|
1106
|
+
prismicT__namespace.RichTextNodeType.heading3,
|
|
1107
|
+
prismicT__namespace.RichTextNodeType.heading4,
|
|
1108
|
+
prismicT__namespace.RichTextNodeType.heading5,
|
|
1109
|
+
prismicT__namespace.RichTextNodeType.heading6
|
|
1110
|
+
];
|
|
1111
|
+
const heading = (config) => {
|
|
1112
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1113
|
+
const model = config.model || title$1({ faker });
|
|
1114
|
+
let types = [];
|
|
1115
|
+
if (model.config) {
|
|
1116
|
+
if ("single" in model.config && model.config.single) {
|
|
1117
|
+
types = model.config.single.split(",").filter((type2) => headingNoteTypes.includes(type2));
|
|
1118
|
+
} else if ("multi" in model.config && model.config.multi) {
|
|
1119
|
+
types = model.config.multi.split(",").filter((type2) => headingNoteTypes.includes(type2));
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
const type = faker.randomElement(types);
|
|
990
1123
|
if (type) {
|
|
991
|
-
const patternKey = config.pattern || faker.
|
|
1124
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$5));
|
|
992
1125
|
const pattern = patterns$5[patternKey];
|
|
993
1126
|
return {
|
|
994
1127
|
type,
|
|
995
|
-
text: changeCase__namespace.capitalCase(faker.
|
|
996
|
-
min: pattern.minWords,
|
|
997
|
-
max: pattern.maxWords
|
|
998
|
-
}))),
|
|
1128
|
+
text: changeCase__namespace.capitalCase(faker.words(faker.range(pattern.minWords, pattern.maxWords))),
|
|
999
1129
|
spans: []
|
|
1000
1130
|
};
|
|
1001
1131
|
} else {
|
|
@@ -1014,13 +1144,14 @@ const patterns$4 = {
|
|
|
1014
1144
|
sentenceCount: 12
|
|
1015
1145
|
}
|
|
1016
1146
|
};
|
|
1017
|
-
const paragraph = (config
|
|
1018
|
-
const faker = createFaker(config.seed);
|
|
1019
|
-
const patternKey = config.pattern || faker.
|
|
1147
|
+
const paragraph = (config) => {
|
|
1148
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1149
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$4));
|
|
1020
1150
|
const pattern = patterns$4[patternKey];
|
|
1151
|
+
const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
|
|
1021
1152
|
return {
|
|
1022
1153
|
type: prismicT__namespace.RichTextNodeType.paragraph,
|
|
1023
|
-
text
|
|
1154
|
+
text,
|
|
1024
1155
|
spans: []
|
|
1025
1156
|
};
|
|
1026
1157
|
};
|
|
@@ -1036,13 +1167,14 @@ const patterns$3 = {
|
|
|
1036
1167
|
sentenceCount: 12
|
|
1037
1168
|
}
|
|
1038
1169
|
};
|
|
1039
|
-
const preformatted = (config
|
|
1040
|
-
const faker = createFaker(config.seed);
|
|
1041
|
-
const patternKey = config.pattern || faker.
|
|
1170
|
+
const preformatted = (config) => {
|
|
1171
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1172
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$3));
|
|
1042
1173
|
const pattern = patterns$3[patternKey];
|
|
1174
|
+
const text = Array.from({ length: pattern.sentenceCount }, () => changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))) + ".").join(" ");
|
|
1043
1175
|
return {
|
|
1044
1176
|
type: prismicT__namespace.RichTextNodeType.preformatted,
|
|
1045
|
-
text
|
|
1177
|
+
text,
|
|
1046
1178
|
spans: []
|
|
1047
1179
|
};
|
|
1048
1180
|
};
|
|
@@ -1061,18 +1193,15 @@ const patterns$2 = {
|
|
|
1061
1193
|
maxItems: 12
|
|
1062
1194
|
}
|
|
1063
1195
|
};
|
|
1064
|
-
const list = (config
|
|
1065
|
-
const faker = createFaker(config.seed);
|
|
1066
|
-
const patternKey = config.pattern || faker.
|
|
1196
|
+
const list = (config) => {
|
|
1197
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1198
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$2));
|
|
1067
1199
|
const pattern = patterns$2[patternKey];
|
|
1068
|
-
const itemsCount = faker.
|
|
1069
|
-
min: pattern.minItems,
|
|
1070
|
-
max: pattern.maxItems
|
|
1071
|
-
});
|
|
1200
|
+
const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
|
|
1072
1201
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
1073
1202
|
return {
|
|
1074
1203
|
type: prismicT__namespace.RichTextNodeType.listItem,
|
|
1075
|
-
text: faker.
|
|
1204
|
+
text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
|
|
1076
1205
|
spans: []
|
|
1077
1206
|
};
|
|
1078
1207
|
});
|
|
@@ -1092,29 +1221,27 @@ const patterns$1 = {
|
|
|
1092
1221
|
maxItems: 12
|
|
1093
1222
|
}
|
|
1094
1223
|
};
|
|
1095
|
-
const oList = (config
|
|
1096
|
-
const faker = createFaker(config.seed);
|
|
1097
|
-
const patternKey = config.pattern || faker.
|
|
1224
|
+
const oList = (config) => {
|
|
1225
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1226
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns$1));
|
|
1098
1227
|
const pattern = patterns$1[patternKey];
|
|
1099
|
-
const itemsCount = faker.
|
|
1100
|
-
min: pattern.minItems,
|
|
1101
|
-
max: pattern.maxItems
|
|
1102
|
-
});
|
|
1228
|
+
const itemsCount = faker.range(pattern.minItems, pattern.maxItems);
|
|
1103
1229
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
1104
1230
|
return {
|
|
1105
1231
|
type: prismicT__namespace.RichTextNodeType.oListItem,
|
|
1106
|
-
text: faker.
|
|
1232
|
+
text: changeCase__namespace.sentenceCase(faker.words(faker.range(5, 15))),
|
|
1107
1233
|
spans: []
|
|
1108
1234
|
};
|
|
1109
1235
|
});
|
|
1110
1236
|
};
|
|
1111
1237
|
|
|
1112
|
-
const image = (config
|
|
1113
|
-
const
|
|
1238
|
+
const image = (config) => {
|
|
1239
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1240
|
+
const imageData = getMockImageData({ faker });
|
|
1114
1241
|
const imageField = buildImageFieldImage({
|
|
1115
|
-
|
|
1242
|
+
faker,
|
|
1116
1243
|
imageData,
|
|
1117
|
-
state:
|
|
1244
|
+
state: "filled"
|
|
1118
1245
|
});
|
|
1119
1246
|
return {
|
|
1120
1247
|
type: prismicT__namespace.RichTextNodeType.image,
|
|
@@ -1125,9 +1252,10 @@ const image = (config = {}) => {
|
|
|
1125
1252
|
};
|
|
1126
1253
|
};
|
|
1127
1254
|
|
|
1128
|
-
const embed = (config
|
|
1129
|
-
const
|
|
1130
|
-
const
|
|
1255
|
+
const embed = (config) => {
|
|
1256
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1257
|
+
const data = getMockEmbedData({ faker });
|
|
1258
|
+
const embedField = buildEmbedField({ faker, data });
|
|
1131
1259
|
return {
|
|
1132
1260
|
type: prismicT__namespace.RichTextNodeType.embed,
|
|
1133
1261
|
oembed: embedField
|
|
@@ -1162,105 +1290,109 @@ const generators = {
|
|
|
1162
1290
|
[prismicT__namespace.RichTextNodeType.image]: image,
|
|
1163
1291
|
[prismicT__namespace.RichTextNodeType.embed]: embed
|
|
1164
1292
|
};
|
|
1165
|
-
const richText = (config
|
|
1166
|
-
const faker = createFaker(config.seed);
|
|
1167
|
-
|
|
1168
|
-
seed: config.seed,
|
|
1169
|
-
withMultipleBlocks: true
|
|
1170
|
-
});
|
|
1171
|
-
const supportsMultipleBlocks = "multi" in model.config;
|
|
1172
|
-
const types = ("multi" in model.config ? model.config.multi : model.config.single).split(",").filter((type) => Object.keys(generators).includes(type));
|
|
1173
|
-
if (types.length > 0) {
|
|
1174
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns));
|
|
1175
|
-
const pattern = patterns[patternKey];
|
|
1176
|
-
const blockCount = supportsMultipleBlocks ? faker.datatype.number({
|
|
1177
|
-
min: pattern.blockCountMin,
|
|
1178
|
-
max: pattern.blockCountMax
|
|
1179
|
-
}) : 1;
|
|
1180
|
-
return Array(blockCount).fill(void 0).map(() => {
|
|
1181
|
-
const type = faker.random.arrayElement(types);
|
|
1182
|
-
const generator = generators[type];
|
|
1183
|
-
return generator({ seed: config.seed, model });
|
|
1184
|
-
}).flat().filter((block) => block !== void 0).slice(0, blockCount);
|
|
1185
|
-
} else {
|
|
1293
|
+
const richText = (config) => {
|
|
1294
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1295
|
+
if (config.state === "empty") {
|
|
1186
1296
|
return [];
|
|
1297
|
+
} else {
|
|
1298
|
+
const model = config.model || richText$1({
|
|
1299
|
+
faker,
|
|
1300
|
+
withMultipleBlocks: true
|
|
1301
|
+
});
|
|
1302
|
+
const supportsMultipleBlocks = model.config && "multi" in model.config;
|
|
1303
|
+
let types = [];
|
|
1304
|
+
if (model.config) {
|
|
1305
|
+
if ("multi" in model.config && model.config.multi) {
|
|
1306
|
+
types = model.config.multi.split(",").filter((type) => Object.keys(generators).includes(type));
|
|
1307
|
+
} else if ("single" in model.config && model.config.single) {
|
|
1308
|
+
types = model.config.single.split(",").filter((type) => Object.keys(generators).includes(type));
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
if (types.length > 0) {
|
|
1312
|
+
const patternKey = config.pattern || faker.randomElement(Object.keys(patterns));
|
|
1313
|
+
const pattern = patterns[patternKey];
|
|
1314
|
+
const blockCount = supportsMultipleBlocks ? faker.range(pattern.blockCountMin, pattern.blockCountMax) : 1;
|
|
1315
|
+
return Array(blockCount).fill(void 0).map(() => {
|
|
1316
|
+
const type = faker.randomElement(types);
|
|
1317
|
+
const generator = generators[type];
|
|
1318
|
+
return generator({ faker, model });
|
|
1319
|
+
}).flat().filter((block) => block !== void 0).slice(0, blockCount);
|
|
1320
|
+
} else {
|
|
1321
|
+
return [];
|
|
1322
|
+
}
|
|
1187
1323
|
}
|
|
1188
1324
|
};
|
|
1189
1325
|
|
|
1190
|
-
const select = (config
|
|
1191
|
-
|
|
1192
|
-
const
|
|
1193
|
-
const
|
|
1326
|
+
const select = (config) => {
|
|
1327
|
+
var _a, _b;
|
|
1328
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1329
|
+
const model = config.model || select$1({ faker });
|
|
1330
|
+
const defaultValue = (_a = model.config) == null ? void 0 : _a.default_value;
|
|
1331
|
+
const options = ((_b = model.config) == null ? void 0 : _b.options) || [];
|
|
1194
1332
|
if (config.state === "empty") {
|
|
1195
1333
|
return null;
|
|
1196
1334
|
} else {
|
|
1197
|
-
return typeof defaultValue === "string" && faker.
|
|
1335
|
+
return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(options);
|
|
1198
1336
|
}
|
|
1199
1337
|
};
|
|
1200
1338
|
|
|
1201
|
-
const slice = (config
|
|
1339
|
+
const slice = (config) => {
|
|
1202
1340
|
var _a, _b;
|
|
1203
|
-
const faker = createFaker(config.seed);
|
|
1204
|
-
const model = config.model || slice$1({
|
|
1205
|
-
const sliceType = (_a = config.type) != null ? _a : generateFieldId({
|
|
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;
|
|
1341
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1342
|
+
const model = config.model || slice$1({ faker });
|
|
1343
|
+
const sliceType = (_a = config.type) != null ? _a : generateFieldId({ faker });
|
|
1344
|
+
const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.words(faker.range(1, 2)));
|
|
1345
|
+
const itemsCount = model.repeat && Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
|
|
1211
1346
|
return {
|
|
1212
1347
|
slice_type: sliceType,
|
|
1213
1348
|
slice_label: sliceLabel,
|
|
1214
1349
|
primary: valueForModelMap({
|
|
1215
|
-
|
|
1216
|
-
map: model["non-repeat"],
|
|
1350
|
+
faker,
|
|
1351
|
+
map: model["non-repeat"] || {},
|
|
1217
1352
|
configs: config.primaryFieldConfigs
|
|
1218
1353
|
}),
|
|
1219
1354
|
items: Array(itemsCount).fill(void 0).map(() => {
|
|
1220
1355
|
return valueForModelMap({
|
|
1221
|
-
|
|
1222
|
-
map: model.repeat,
|
|
1356
|
+
faker,
|
|
1357
|
+
map: model.repeat || {},
|
|
1223
1358
|
configs: config.itemsFieldConfigs
|
|
1224
1359
|
});
|
|
1225
1360
|
})
|
|
1226
1361
|
};
|
|
1227
1362
|
};
|
|
1228
1363
|
|
|
1229
|
-
const sharedSliceVariation = (config
|
|
1364
|
+
const sharedSliceVariation = (config) => {
|
|
1230
1365
|
var _a, _b;
|
|
1231
|
-
const faker = createFaker(config.seed);
|
|
1232
|
-
const model = config.model || sharedSliceVariation$1({
|
|
1233
|
-
const sliceType = (_a = config.type) != null ? _a : generateFieldId({
|
|
1234
|
-
const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.
|
|
1235
|
-
min: 1,
|
|
1236
|
-
max: 6
|
|
1237
|
-
}) : 0;
|
|
1366
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1367
|
+
const model = config.model || sharedSliceVariation$1({ faker });
|
|
1368
|
+
const sliceType = (_a = config.type) != null ? _a : generateFieldId({ faker });
|
|
1369
|
+
const itemsCount = model.items && Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.range(1, 6) : 0;
|
|
1238
1370
|
return {
|
|
1239
1371
|
slice_type: sliceType,
|
|
1240
1372
|
slice_label: null,
|
|
1241
1373
|
variation: model.id,
|
|
1242
|
-
version: faker.
|
|
1374
|
+
version: faker.hash(7),
|
|
1243
1375
|
primary: valueForModelMap({
|
|
1244
|
-
|
|
1245
|
-
map: model.primary,
|
|
1376
|
+
faker,
|
|
1377
|
+
map: model.primary || {},
|
|
1246
1378
|
configs: config.primaryFieldConfigs
|
|
1247
1379
|
}),
|
|
1248
1380
|
items: Array(itemsCount).fill(void 0).map(() => {
|
|
1249
1381
|
return valueForModelMap({
|
|
1250
|
-
|
|
1251
|
-
map: model.items,
|
|
1382
|
+
faker,
|
|
1383
|
+
map: model.items || {},
|
|
1252
1384
|
configs: config.itemsFieldConfigs
|
|
1253
1385
|
});
|
|
1254
1386
|
})
|
|
1255
1387
|
};
|
|
1256
1388
|
};
|
|
1257
1389
|
|
|
1258
|
-
const sharedSlice = (config
|
|
1259
|
-
const faker = createFaker(config.seed);
|
|
1260
|
-
const model = config.model || sharedSlice$1({
|
|
1261
|
-
const variationModel = faker.
|
|
1390
|
+
const sharedSlice = (config) => {
|
|
1391
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1392
|
+
const model = config.model || sharedSlice$1({ faker });
|
|
1393
|
+
const variationModel = faker.randomElement(model.variations);
|
|
1262
1394
|
return sharedSliceVariation({
|
|
1263
|
-
|
|
1395
|
+
faker,
|
|
1264
1396
|
model: variationModel,
|
|
1265
1397
|
itemsCount: config.itemsCount,
|
|
1266
1398
|
type: model.id,
|
|
@@ -1269,28 +1401,25 @@ const sharedSlice = (config = {}) => {
|
|
|
1269
1401
|
});
|
|
1270
1402
|
};
|
|
1271
1403
|
|
|
1272
|
-
const sliceZone = (config
|
|
1273
|
-
var _a;
|
|
1404
|
+
const sliceZone = (config) => {
|
|
1405
|
+
var _a, _b;
|
|
1274
1406
|
if (config.state === "empty") {
|
|
1275
1407
|
return [];
|
|
1276
1408
|
} else {
|
|
1277
|
-
const faker = createFaker(config.seed);
|
|
1278
|
-
const model = config.model || sliceZone$1({
|
|
1279
|
-
if (Object.keys(model.config.choices).length > 0) {
|
|
1280
|
-
const itemsCount = (
|
|
1281
|
-
min: 1,
|
|
1282
|
-
max: 6
|
|
1283
|
-
});
|
|
1409
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1410
|
+
const model = config.model || sliceZone$1({ faker });
|
|
1411
|
+
if (((_a = model.config) == null ? void 0 : _a.choices) && Object.keys(model.config.choices).length > 0) {
|
|
1412
|
+
const itemsCount = (_b = config.itemsCount) != null ? _b : faker.range(1, 6);
|
|
1284
1413
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
1285
|
-
var _a2;
|
|
1286
|
-
const choices = Object.entries(model.config.choices);
|
|
1287
|
-
const [choiceType, choiceModel] = faker.
|
|
1288
|
-
const choiceLabels = model.config.labels[choiceType] || [];
|
|
1289
|
-
const choiceLabel = faker.
|
|
1414
|
+
var _a2, _b2, _c, _d;
|
|
1415
|
+
const choices = ((_a2 = model.config) == null ? void 0 : _a2.choices) && Object.entries(model.config.choices) || [];
|
|
1416
|
+
const [choiceType, choiceModel] = faker.randomElement(choices);
|
|
1417
|
+
const choiceLabels = ((_c = (_b2 = model.config) == null ? void 0 : _b2.labels) == null ? void 0 : _c[choiceType]) || [];
|
|
1418
|
+
const choiceLabel = faker.randomElement(choiceLabels);
|
|
1290
1419
|
switch (choiceModel.type) {
|
|
1291
1420
|
case prismicT__namespace.CustomTypeModelSliceType.Slice: {
|
|
1292
1421
|
return slice({
|
|
1293
|
-
|
|
1422
|
+
faker,
|
|
1294
1423
|
model: choiceModel,
|
|
1295
1424
|
type: choiceType,
|
|
1296
1425
|
label: choiceLabel ? choiceLabel.name : null,
|
|
@@ -1299,10 +1428,10 @@ const sliceZone = (config = {}) => {
|
|
|
1299
1428
|
});
|
|
1300
1429
|
}
|
|
1301
1430
|
case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
|
|
1302
|
-
const sharedSliceModel = (
|
|
1431
|
+
const sharedSliceModel = (_d = config.sharedSliceModels) == null ? void 0 : _d.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
|
|
1303
1432
|
if (sharedSliceModel) {
|
|
1304
1433
|
return sharedSlice({
|
|
1305
|
-
|
|
1434
|
+
faker,
|
|
1306
1435
|
model: sharedSliceModel,
|
|
1307
1436
|
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1308
1437
|
itemsFieldConfigs: config.itemsFieldConfigs
|
|
@@ -1317,13 +1446,14 @@ const sliceZone = (config = {}) => {
|
|
|
1317
1446
|
}
|
|
1318
1447
|
};
|
|
1319
1448
|
|
|
1320
|
-
const title = (config
|
|
1449
|
+
const title = (config) => {
|
|
1450
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1321
1451
|
if (config.state === "empty") {
|
|
1322
1452
|
return [];
|
|
1323
1453
|
} else {
|
|
1324
1454
|
return [
|
|
1325
1455
|
heading({
|
|
1326
|
-
|
|
1456
|
+
faker,
|
|
1327
1457
|
model: config.model,
|
|
1328
1458
|
pattern: config.pattern
|
|
1329
1459
|
})
|
|
@@ -1331,9 +1461,9 @@ const title = (config = {}) => {
|
|
|
1331
1461
|
}
|
|
1332
1462
|
};
|
|
1333
1463
|
|
|
1334
|
-
const uid = (config
|
|
1335
|
-
const faker = createFaker(config.seed);
|
|
1336
|
-
return changeCase__namespace.snakeCase(faker.
|
|
1464
|
+
const uid = (config) => {
|
|
1465
|
+
const faker = config.faker || createFaker(config.seed);
|
|
1466
|
+
return changeCase__namespace.snakeCase(faker.words(faker.range(1, 3)));
|
|
1337
1467
|
};
|
|
1338
1468
|
|
|
1339
1469
|
exports.boolean = boolean;
|