@prismicio/mock 0.0.3 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/api/index.cjs +561 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.ts +36 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +561 -0
- package/dist/api/index.js.map +1 -0
- package/dist/index.cjs +672 -644
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +228 -262
- package/dist/{index.mjs → index.js} +663 -634
- package/dist/index.js.map +1 -0
- package/dist/model/index.cjs +163 -203
- package/dist/model/index.cjs.map +1 -0
- package/dist/model/index.d.ts +70 -96
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +462 -0
- package/dist/model/index.js.map +1 -0
- package/dist/value/index.cjs +284 -499
- package/dist/value/index.cjs.map +1 -0
- package/dist/value/index.d.ts +60 -120
- package/dist/value/index.d.ts.map +1 -0
- package/dist/value/{index.mjs → index.js} +447 -608
- package/dist/value/index.js.map +1 -0
- package/package.json +25 -20
- package/src/api/index.ts +11 -0
- package/src/api/query.ts +38 -0
- package/src/api/ref.ts +41 -0
- package/src/api/repository.ts +54 -0
- package/src/api/tags.ts +15 -0
- package/src/constants.ts +3 -1
- package/src/index.ts +1 -0
- package/src/lib/buildAlternativeLanguage.ts +18 -0
- package/src/lib/buildContentRelationshipField.ts +12 -5
- package/src/lib/buildEmbedField.ts +1 -1
- package/src/lib/buildImageFieldImage.ts +48 -0
- package/src/lib/createFaker.ts +19 -10
- package/src/lib/generateTags.ts +10 -2
- package/src/lib/valueForModelMap.ts +2 -2
- package/src/model/buildMockGroupFieldMap.ts +65 -0
- package/src/model/contentRelationship.ts +14 -21
- package/src/model/customType.ts +49 -48
- package/src/model/group.ts +8 -15
- package/src/model/image.ts +13 -13
- package/src/model/index.ts +2 -0
- package/src/model/select.ts +11 -16
- package/src/model/sharedSlice.ts +23 -30
- package/src/model/sharedSliceVariation.ts +33 -21
- package/src/model/slice.ts +15 -19
- package/src/model/sliceZone.ts +25 -42
- package/src/types.ts +50 -15
- package/src/value/color.ts +16 -6
- package/src/value/contentRelationship.ts +52 -36
- package/src/value/customType.ts +27 -4
- package/src/value/date.ts +25 -9
- package/src/value/embed.ts +18 -6
- package/src/value/geoPoint.ts +21 -9
- package/src/value/group.ts +7 -27
- package/src/value/image.ts +22 -9
- package/src/value/integrationFields.ts +26 -14
- package/src/value/keyText.ts +18 -6
- package/src/value/link.ts +33 -34
- package/src/value/linkToMedia.ts +15 -20
- package/src/value/number.ts +16 -6
- package/src/value/richText/heading.ts +7 -7
- package/src/value/richText/image.ts +6 -2
- package/src/value/richText/index.ts +1 -1
- package/src/value/select.ts +23 -8
- package/src/value/sharedSlice.ts +2 -2
- package/src/value/sharedSliceVariation.ts +6 -34
- package/src/value/slice.ts +5 -30
- package/src/value/sliceZone.ts +44 -60
- package/src/value/timestamp.ts +19 -6
- package/src/value/title.ts +1 -1
- package/src/value/uid.ts +1 -1
- package/dist/model/index.mjs +0 -448
- package/src/lib/buildImageField.ts +0 -34
- package/src/lib/buildMockGroupFieldMap.ts +0 -84
package/dist/index.cjs
CHANGED
|
@@ -2,53 +2,281 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const prismicT = require('@prismicio/types');
|
|
6
5
|
const changeCase = require('change-case');
|
|
7
|
-
const fakerLocaleEN = require('faker/lib/locales/en');
|
|
8
|
-
const Faker = require('faker/lib');
|
|
6
|
+
const fakerLocaleEN = require('faker/lib/locales/en/index.js');
|
|
7
|
+
const Faker = require('faker/lib/index.js');
|
|
8
|
+
const prismicT = require('@prismicio/types');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
13
13
|
if (e && e.__esModule) return e;
|
|
14
|
-
|
|
14
|
+
const n = Object.create(null);
|
|
15
15
|
if (e) {
|
|
16
|
-
|
|
16
|
+
for (const k in e) {
|
|
17
17
|
if (k !== 'default') {
|
|
18
|
-
|
|
18
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
19
|
Object.defineProperty(n, k, d.get ? d : {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return e[k];
|
|
23
|
-
}
|
|
21
|
+
get: function () { return e[k]; }
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
|
-
}
|
|
24
|
+
}
|
|
27
25
|
}
|
|
28
|
-
n[
|
|
26
|
+
n["default"] = e;
|
|
29
27
|
return Object.freeze(n);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
|
|
33
30
|
const changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase);
|
|
34
31
|
const fakerLocaleEN__namespace = /*#__PURE__*/_interopNamespace(fakerLocaleEN);
|
|
35
32
|
const Faker__default = /*#__PURE__*/_interopDefaultLegacy(Faker);
|
|
33
|
+
const prismicT__namespace = /*#__PURE__*/_interopNamespace(prismicT);
|
|
36
34
|
|
|
37
35
|
const FAKER_SEED = 1984;
|
|
38
36
|
|
|
39
37
|
const createFaker = (seed = FAKER_SEED) => {
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
let normalizedSeed;
|
|
39
|
+
if (typeof seed === "string") {
|
|
40
|
+
normalizedSeed = seed.split("").map((char) => char.charCodeAt(0));
|
|
41
|
+
} else {
|
|
42
|
+
normalizedSeed = seed;
|
|
43
|
+
}
|
|
44
|
+
const cacheKey = JSON.stringify(normalizedSeed);
|
|
45
|
+
if (createFaker.cache[cacheKey]) {
|
|
46
|
+
return createFaker.cache[cacheKey];
|
|
42
47
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
createFaker.cache[
|
|
47
|
-
return
|
|
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;
|
|
48
53
|
};
|
|
49
54
|
createFaker.cache = {};
|
|
50
55
|
|
|
56
|
+
const generateTags = (config) => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const faker = createFaker(config.seed);
|
|
59
|
+
return Array(faker.datatype.number({
|
|
60
|
+
min: (_a = config.min) != null ? _a : 0,
|
|
61
|
+
max: (_b = config.max) != null ? _b : 2
|
|
62
|
+
})).fill(void 0).map(() => changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 }))));
|
|
63
|
+
};
|
|
64
|
+
|
|
51
65
|
const boolean$1 = (config = {}) => {
|
|
66
|
+
const faker = createFaker(config.seed);
|
|
67
|
+
return faker.datatype.boolean();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const valueForModel = (config) => {
|
|
71
|
+
const model = config.model;
|
|
72
|
+
switch (model.type) {
|
|
73
|
+
case prismicT__namespace.CustomTypeModelFieldType.Boolean: {
|
|
74
|
+
return boolean$1({
|
|
75
|
+
seed: config.seed,
|
|
76
|
+
model,
|
|
77
|
+
...config.config
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
case prismicT__namespace.CustomTypeModelFieldType.Color: {
|
|
81
|
+
return color({
|
|
82
|
+
seed: config.seed,
|
|
83
|
+
model,
|
|
84
|
+
...config.config
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
case prismicT__namespace.CustomTypeModelFieldType.Link: {
|
|
88
|
+
switch (model.config.select) {
|
|
89
|
+
case prismicT__namespace.CustomTypeModelLinkSelectType.Document: {
|
|
90
|
+
return contentRelationship({
|
|
91
|
+
seed: config.seed,
|
|
92
|
+
model,
|
|
93
|
+
...config.config
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
case prismicT__namespace.CustomTypeModelLinkSelectType.Media: {
|
|
97
|
+
return linkToMedia({
|
|
98
|
+
seed: config.seed,
|
|
99
|
+
model,
|
|
100
|
+
...config.config
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
default: {
|
|
104
|
+
return link({
|
|
105
|
+
seed: config.seed,
|
|
106
|
+
model,
|
|
107
|
+
...config.config
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
case prismicT__namespace.CustomTypeModelFieldType.Date: {
|
|
113
|
+
return date({
|
|
114
|
+
seed: config.seed,
|
|
115
|
+
model,
|
|
116
|
+
...config.config
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
case prismicT__namespace.CustomTypeModelFieldType.Embed: {
|
|
120
|
+
return embed$1({
|
|
121
|
+
seed: config.seed,
|
|
122
|
+
model,
|
|
123
|
+
...config.config
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
case prismicT__namespace.CustomTypeModelFieldType.GeoPoint: {
|
|
127
|
+
return geoPoint({
|
|
128
|
+
seed: config.seed,
|
|
129
|
+
model,
|
|
130
|
+
...config.config
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
case prismicT__namespace.CustomTypeModelFieldType.Image: {
|
|
134
|
+
return image$1({
|
|
135
|
+
seed: config.seed,
|
|
136
|
+
model,
|
|
137
|
+
...config.config
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
case prismicT__namespace.CustomTypeModelFieldType.Text: {
|
|
141
|
+
return keyText({
|
|
142
|
+
seed: config.seed,
|
|
143
|
+
model,
|
|
144
|
+
...config.config
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
case prismicT__namespace.CustomTypeModelFieldType.Number: {
|
|
148
|
+
return number({
|
|
149
|
+
seed: config.seed,
|
|
150
|
+
model,
|
|
151
|
+
...config.config
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
case prismicT__namespace.CustomTypeModelFieldType.Select: {
|
|
155
|
+
return select({
|
|
156
|
+
seed: config.seed,
|
|
157
|
+
model,
|
|
158
|
+
...config.config
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
case prismicT__namespace.CustomTypeModelFieldType.Timestamp: {
|
|
162
|
+
return timestamp({
|
|
163
|
+
seed: config.seed,
|
|
164
|
+
model,
|
|
165
|
+
...config.config
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
|
|
169
|
+
if ("single" in model.config && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
|
|
170
|
+
return title({
|
|
171
|
+
seed: config.seed,
|
|
172
|
+
model,
|
|
173
|
+
...config.config
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
return richText({
|
|
177
|
+
seed: config.seed,
|
|
178
|
+
model,
|
|
179
|
+
...config.config
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields: {
|
|
184
|
+
return integrationFields({
|
|
185
|
+
seed: config.seed,
|
|
186
|
+
model,
|
|
187
|
+
...config.config
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
case prismicT__namespace.CustomTypeModelFieldType.UID: {
|
|
191
|
+
return uid({
|
|
192
|
+
seed: config.seed,
|
|
193
|
+
model,
|
|
194
|
+
...config.config
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
case prismicT__namespace.CustomTypeModelFieldType.Group: {
|
|
198
|
+
return group({
|
|
199
|
+
seed: config.seed,
|
|
200
|
+
model,
|
|
201
|
+
...config.config
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
case prismicT__namespace.CustomTypeModelFieldType.Slices: {
|
|
205
|
+
return sliceZone({
|
|
206
|
+
seed: config.seed,
|
|
207
|
+
model,
|
|
208
|
+
...config.config
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const getValueConfigType = (model) => {
|
|
215
|
+
switch (model.type) {
|
|
216
|
+
case prismicT__namespace.CustomTypeModelFieldType.Boolean:
|
|
217
|
+
return "boolean";
|
|
218
|
+
case prismicT__namespace.CustomTypeModelFieldType.Color:
|
|
219
|
+
return "color";
|
|
220
|
+
case prismicT__namespace.CustomTypeModelFieldType.Date:
|
|
221
|
+
return "date";
|
|
222
|
+
case prismicT__namespace.CustomTypeModelFieldType.Embed:
|
|
223
|
+
return "embed";
|
|
224
|
+
case prismicT__namespace.CustomTypeModelFieldType.GeoPoint:
|
|
225
|
+
return "geoPoint";
|
|
226
|
+
case prismicT__namespace.CustomTypeModelFieldType.Group:
|
|
227
|
+
return "group";
|
|
228
|
+
case prismicT__namespace.CustomTypeModelFieldType.Image:
|
|
229
|
+
return "image";
|
|
230
|
+
case prismicT__namespace.CustomTypeModelFieldType.Link: {
|
|
231
|
+
switch (model.config.select) {
|
|
232
|
+
case prismicT__namespace.CustomTypeModelLinkSelectType.Document:
|
|
233
|
+
return "contentRelationship";
|
|
234
|
+
case prismicT__namespace.CustomTypeModelLinkSelectType.Media:
|
|
235
|
+
return "linkToMedia";
|
|
236
|
+
default:
|
|
237
|
+
return "link";
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
case prismicT__namespace.CustomTypeModelFieldType.Number:
|
|
241
|
+
return "number";
|
|
242
|
+
case prismicT__namespace.CustomTypeModelFieldType.Select:
|
|
243
|
+
return "select";
|
|
244
|
+
case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
|
|
245
|
+
if ("single" in model.config && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
|
|
246
|
+
return "title";
|
|
247
|
+
} else {
|
|
248
|
+
return "richText";
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
case prismicT__namespace.CustomTypeModelFieldType.Text:
|
|
252
|
+
return "keyText";
|
|
253
|
+
case prismicT__namespace.CustomTypeModelFieldType.Timestamp:
|
|
254
|
+
return "timestamp";
|
|
255
|
+
case prismicT__namespace.CustomTypeModelFieldType.UID:
|
|
256
|
+
return "uid";
|
|
257
|
+
case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields:
|
|
258
|
+
return "integrationFields";
|
|
259
|
+
case prismicT__namespace.CustomTypeModelFieldType.Slices:
|
|
260
|
+
return "sliceZone";
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const valueForModelMap = (config) => {
|
|
264
|
+
var _a;
|
|
265
|
+
const result = {};
|
|
266
|
+
for (const fieldId in config.map) {
|
|
267
|
+
const fieldModel = config.map[fieldId];
|
|
268
|
+
const fieldConfigType = getValueConfigType(fieldModel);
|
|
269
|
+
const fieldConfig = (_a = config.configs) == null ? void 0 : _a[fieldConfigType];
|
|
270
|
+
result[fieldId] = valueForModel({
|
|
271
|
+
seed: config.seed,
|
|
272
|
+
model: fieldModel,
|
|
273
|
+
config: fieldConfig
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const boolean = (config = {}) => {
|
|
52
280
|
const faker = createFaker(config.seed);
|
|
53
281
|
return {
|
|
54
282
|
type: prismicT__namespace.CustomTypeModelFieldType.Boolean,
|
|
@@ -69,11 +297,6 @@ const color$1 = (config = {}) => {
|
|
|
69
297
|
};
|
|
70
298
|
};
|
|
71
299
|
|
|
72
|
-
const generateCustomTypeId = (config) => {
|
|
73
|
-
const faker = createFaker(config.seed);
|
|
74
|
-
return changeCase__namespace.snakeCase(faker.company.bsNoun());
|
|
75
|
-
};
|
|
76
|
-
|
|
77
300
|
const contentRelationship$1 = (config = {}) => {
|
|
78
301
|
const faker = createFaker(config.seed);
|
|
79
302
|
return {
|
|
@@ -82,12 +305,37 @@ const contentRelationship$1 = (config = {}) => {
|
|
|
82
305
|
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
83
306
|
placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
|
|
84
307
|
select: prismicT__namespace.CustomTypeModelLinkSelectType.Document,
|
|
85
|
-
customtypes: config.
|
|
86
|
-
tags: config.
|
|
308
|
+
customtypes: config.customTypeIDs,
|
|
309
|
+
tags: config.tags
|
|
87
310
|
}
|
|
88
311
|
};
|
|
89
312
|
};
|
|
90
313
|
|
|
314
|
+
const customType$1 = (config = {}) => {
|
|
315
|
+
var _a, _b;
|
|
316
|
+
const faker = createFaker(config.seed);
|
|
317
|
+
let label = config.label || changeCase__namespace.capitalCase(faker.company.bsNoun());
|
|
318
|
+
let id = config.id || changeCase__namespace.snakeCase(label);
|
|
319
|
+
if (config.id && !config.label) {
|
|
320
|
+
label = changeCase__namespace.capitalCase(config.id);
|
|
321
|
+
} else if (config.label && !config.label) {
|
|
322
|
+
id = changeCase__namespace.snakeCase(config.label);
|
|
323
|
+
}
|
|
324
|
+
let json = {};
|
|
325
|
+
if ("fields" in config && config.fields) {
|
|
326
|
+
json = { Main: config.fields };
|
|
327
|
+
} else if ("tabs" in config && config.tabs) {
|
|
328
|
+
json = config.tabs;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
id,
|
|
332
|
+
label,
|
|
333
|
+
status: (_a = config.status) != null ? _a : faker.datatype.boolean(),
|
|
334
|
+
repeatable: (_b = config.repeatable) != null ? _b : faker.datatype.boolean(),
|
|
335
|
+
json
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
91
339
|
const date$1 = (config = {}) => {
|
|
92
340
|
const faker = createFaker(config.seed);
|
|
93
341
|
return {
|
|
@@ -120,10 +368,26 @@ const geoPoint$1 = (config = {}) => {
|
|
|
120
368
|
};
|
|
121
369
|
};
|
|
122
370
|
|
|
371
|
+
const group$1 = (config = {}) => {
|
|
372
|
+
const faker = createFaker(config.seed);
|
|
373
|
+
return {
|
|
374
|
+
type: prismicT__namespace.CustomTypeModelFieldType.Group,
|
|
375
|
+
config: {
|
|
376
|
+
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
377
|
+
fields: config.fields || {}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
|
|
123
382
|
const image$2 = (config = {}) => {
|
|
124
|
-
var _a;
|
|
125
383
|
const faker = createFaker(config.seed);
|
|
126
|
-
const
|
|
384
|
+
const thumbnails = (config.thumbnailNames || []).map((name) => {
|
|
385
|
+
return {
|
|
386
|
+
name,
|
|
387
|
+
width: faker.datatype.number({ min: 500, max: 2e3 }),
|
|
388
|
+
height: faker.datatype.number({ min: 500, max: 2e3 })
|
|
389
|
+
};
|
|
390
|
+
});
|
|
127
391
|
return {
|
|
128
392
|
type: prismicT__namespace.CustomTypeModelFieldType.Image,
|
|
129
393
|
config: {
|
|
@@ -132,11 +396,7 @@ const image$2 = (config = {}) => {
|
|
|
132
396
|
width: config.withConstraint ? faker.datatype.number({ min: 500, max: 2e3 }) : null,
|
|
133
397
|
height: config.withConstraint ? faker.datatype.number({ min: 500, max: 2e3 }) : null
|
|
134
398
|
},
|
|
135
|
-
thumbnails
|
|
136
|
-
name: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
137
|
-
width: faker.datatype.number({ min: 500, max: 2e3 }),
|
|
138
|
-
height: faker.datatype.number({ min: 500, max: 2e3 })
|
|
139
|
-
}))
|
|
399
|
+
thumbnails
|
|
140
400
|
}
|
|
141
401
|
};
|
|
142
402
|
};
|
|
@@ -232,115 +492,63 @@ const richText$1 = (config = {}) => {
|
|
|
232
492
|
};
|
|
233
493
|
|
|
234
494
|
const select$1 = (config = {}) => {
|
|
235
|
-
var _a;
|
|
236
495
|
const faker = createFaker(config.seed);
|
|
237
|
-
const optionsCount = (_a = config.optionsCount) != null ? _a : faker.datatype.number({ min: 1, max: 5 });
|
|
238
|
-
const options = Array(optionsCount).fill(void 0).map(() => changeCase__namespace.capitalCase(faker.company.bsBuzz()));
|
|
239
496
|
return {
|
|
240
497
|
type: prismicT__namespace.CustomTypeModelFieldType.Select,
|
|
241
498
|
config: {
|
|
242
499
|
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
243
500
|
placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
|
|
244
|
-
options,
|
|
245
|
-
default_value: config.
|
|
501
|
+
options: config.options || [],
|
|
502
|
+
default_value: config.defaultValue || void 0
|
|
246
503
|
}
|
|
247
504
|
};
|
|
248
505
|
};
|
|
249
506
|
|
|
250
|
-
const
|
|
507
|
+
const sharedSlice$1 = (config = {}) => {
|
|
251
508
|
const faker = createFaker(config.seed);
|
|
509
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.company.bsNoun());
|
|
510
|
+
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
511
|
+
if (config.id && !config.name) {
|
|
512
|
+
name = changeCase__namespace.pascalCase(config.id);
|
|
513
|
+
} else if (config.name && !config.name) {
|
|
514
|
+
id = changeCase__namespace.snakeCase(config.name);
|
|
515
|
+
}
|
|
252
516
|
return {
|
|
253
|
-
type: prismicT__namespace.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
517
|
+
type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice,
|
|
518
|
+
id,
|
|
519
|
+
name,
|
|
520
|
+
description: faker.lorem.sentence(),
|
|
521
|
+
variations: config.variations || []
|
|
258
522
|
};
|
|
259
523
|
};
|
|
260
524
|
|
|
261
|
-
const
|
|
262
|
-
const faker = createFaker(config.seed);
|
|
263
|
-
const single = faker.random.arrayElements([
|
|
264
|
-
"heading1",
|
|
265
|
-
"heading2",
|
|
266
|
-
"heading3",
|
|
267
|
-
"heading4",
|
|
268
|
-
"heading5",
|
|
269
|
-
"heading6"
|
|
270
|
-
]).join(",");
|
|
525
|
+
const sharedSliceChoice = () => {
|
|
271
526
|
return {
|
|
272
|
-
type: prismicT__namespace.
|
|
273
|
-
config: {
|
|
274
|
-
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
275
|
-
placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
|
|
276
|
-
single,
|
|
277
|
-
allowTargetBlank: faker.datatype.boolean() ? true : void 0
|
|
278
|
-
}
|
|
527
|
+
type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice
|
|
279
528
|
};
|
|
280
529
|
};
|
|
281
530
|
|
|
282
|
-
const
|
|
283
|
-
const faker = createFaker(config.seed);
|
|
284
|
-
return changeCase__namespace.snakeCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 })));
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
const mockModelFns = {
|
|
288
|
-
boolean: boolean$1,
|
|
289
|
-
color: color$1,
|
|
290
|
-
contentRelationship: contentRelationship$1,
|
|
291
|
-
date: date$1,
|
|
292
|
-
embed: embed$2,
|
|
293
|
-
geoPoint: geoPoint$1,
|
|
294
|
-
image: image$2,
|
|
295
|
-
integrationFields: integrationFields$1,
|
|
296
|
-
keyText: keyText$1,
|
|
297
|
-
link: link$1,
|
|
298
|
-
linkToMedia: linkToMedia$1,
|
|
299
|
-
number: number$1,
|
|
300
|
-
richText: richText$1,
|
|
301
|
-
select: select$1,
|
|
302
|
-
timestamp: timestamp$1,
|
|
303
|
-
title: title$1
|
|
304
|
-
};
|
|
305
|
-
const buildMockGroupFieldMap = (config = {}) => {
|
|
306
|
-
var _a;
|
|
531
|
+
const sharedSliceVariation$1 = (config = {}) => {
|
|
307
532
|
const faker = createFaker(config.seed);
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
for (let i = 0; i < count; i++) {
|
|
315
|
-
const fieldId = generateFieldId({ seed: config.seed });
|
|
316
|
-
fields[fieldId] = mockModelFn({
|
|
317
|
-
seed: config.seed,
|
|
318
|
-
...mockModelMapConfig.config
|
|
319
|
-
});
|
|
320
|
-
}
|
|
533
|
+
let name = config.name || changeCase__namespace.capitalCase(faker.company.bsNoun());
|
|
534
|
+
let id = config.id || changeCase__namespace.snakeCase(name);
|
|
535
|
+
if (config.id && !config.name) {
|
|
536
|
+
name = changeCase__namespace.pascalCase(config.id);
|
|
537
|
+
} else if (config.name && !config.name) {
|
|
538
|
+
id = changeCase__namespace.snakeCase(config.name);
|
|
321
539
|
}
|
|
322
|
-
return fields;
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
const uid$1 = (config = {}) => {
|
|
326
|
-
const faker = createFaker(config.seed);
|
|
327
540
|
return {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const sharedSliceChoice = () => {
|
|
337
|
-
return {
|
|
338
|
-
type: prismicT__namespace.CustomTypeModelSliceType.SharedSlice
|
|
541
|
+
id,
|
|
542
|
+
name,
|
|
543
|
+
description: faker.lorem.sentence(),
|
|
544
|
+
docURL: faker.internet.url(),
|
|
545
|
+
version: faker.git.shortSha(),
|
|
546
|
+
primary: config.primaryFields || {},
|
|
547
|
+
items: config.itemsFields || {}
|
|
339
548
|
};
|
|
340
549
|
};
|
|
341
550
|
|
|
342
551
|
const slice$1 = (config = {}) => {
|
|
343
|
-
var _a, _b, _c, _d, _e, _f;
|
|
344
552
|
const faker = createFaker(config.seed);
|
|
345
553
|
return {
|
|
346
554
|
type: prismicT__namespace.CustomTypeModelSliceType.Slice,
|
|
@@ -348,34 +556,17 @@ const slice$1 = (config = {}) => {
|
|
|
348
556
|
display: faker.datatype.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List,
|
|
349
557
|
fieldset: changeCase__namespace.capitalCase(faker.lorem.words()),
|
|
350
558
|
description: faker.lorem.sentence(),
|
|
351
|
-
repeat:
|
|
352
|
-
|
|
353
|
-
configs: (_c = config.repeatFieldConfig) == null ? void 0 : _c.configs
|
|
354
|
-
}),
|
|
355
|
-
"non-repeat": buildMockGroupFieldMap({
|
|
356
|
-
seed: (_e = (_d = config.nonRepeatFieldConfig) == null ? void 0 : _d.seed) != null ? _e : config.seed,
|
|
357
|
-
configs: (_f = config.nonRepeatFieldConfig) == null ? void 0 : _f.configs
|
|
358
|
-
})
|
|
559
|
+
repeat: config.repeatFields || {},
|
|
560
|
+
"non-repeat": config.nonRepeatFields || {}
|
|
359
561
|
};
|
|
360
562
|
};
|
|
361
563
|
|
|
362
564
|
const sliceZone$1 = (config = {}) => {
|
|
363
|
-
var _a;
|
|
364
|
-
const faker = createFaker(config.seed);
|
|
365
|
-
const choicesCount = (_a = config.choicesCount) != null ? _a : faker.datatype.number({ min: 2, max: 6 });
|
|
366
|
-
const choices = {};
|
|
367
|
-
for (let i = 0; i < choicesCount; i++) {
|
|
368
|
-
const choiceId = generateFieldId({ seed: config.seed });
|
|
369
|
-
choices[choiceId] = config.withSharedSlices ? sharedSliceChoice() : slice$1({ seed: config.seed });
|
|
370
|
-
}
|
|
371
565
|
const labels = {};
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
labels[choiceId] =
|
|
376
|
-
name: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
377
|
-
display: faker.datatype.boolean() ? prismicT__namespace.CustomTypeModelSliceDisplay.Grid : prismicT__namespace.CustomTypeModelSliceDisplay.List
|
|
378
|
-
}));
|
|
566
|
+
for (const choiceId in config.choices) {
|
|
567
|
+
const choice = config.choices[choiceId];
|
|
568
|
+
if (choice.type === prismicT__namespace.CustomTypeModelSliceType.Slice) {
|
|
569
|
+
labels[choiceId] = [];
|
|
379
570
|
}
|
|
380
571
|
}
|
|
381
572
|
return {
|
|
@@ -383,374 +574,167 @@ const sliceZone$1 = (config = {}) => {
|
|
|
383
574
|
fieldset: "Slice zone",
|
|
384
575
|
config: {
|
|
385
576
|
labels,
|
|
386
|
-
choices
|
|
577
|
+
choices: config.choices || {}
|
|
387
578
|
}
|
|
388
579
|
};
|
|
389
580
|
};
|
|
390
581
|
|
|
391
|
-
const
|
|
392
|
-
var _a;
|
|
393
|
-
const faker = createFaker(config.seed);
|
|
394
|
-
const tabsCount = (_a = config.tabsCount) != null ? _a : faker.datatype.number({ min: 1, max: 3 });
|
|
395
|
-
const json = {};
|
|
396
|
-
for (let i = 0; i < tabsCount; i++) {
|
|
397
|
-
const tabName = changeCase__namespace.capitalCase(faker.company.bsNoun());
|
|
398
|
-
const tabFields = buildMockGroupFieldMap({
|
|
399
|
-
seed: config.seed,
|
|
400
|
-
configs: config.configs
|
|
401
|
-
});
|
|
402
|
-
if (i === 0 && config.withUID) {
|
|
403
|
-
const fieldId = generateFieldId({ seed: config.seed });
|
|
404
|
-
tabFields[fieldId] = uid$1();
|
|
405
|
-
}
|
|
406
|
-
if (config.withSliceZones) {
|
|
407
|
-
const sliceZoneId = generateFieldId({ seed: config.seed });
|
|
408
|
-
tabFields[sliceZoneId] = sliceZone$1({
|
|
409
|
-
withSharedSlices: config.withSharedSlices
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
json[tabName] = tabFields;
|
|
413
|
-
}
|
|
414
|
-
const id = generateCustomTypeId({ seed: config.seed });
|
|
415
|
-
return {
|
|
416
|
-
id,
|
|
417
|
-
label: changeCase__namespace.capitalCase(id),
|
|
418
|
-
status: faker.datatype.boolean(),
|
|
419
|
-
repeatable: faker.datatype.boolean(),
|
|
420
|
-
json
|
|
421
|
-
};
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
const group$1 = (config = {}) => {
|
|
582
|
+
const timestamp$1 = (config = {}) => {
|
|
425
583
|
const faker = createFaker(config.seed);
|
|
426
|
-
const fields = buildMockGroupFieldMap({
|
|
427
|
-
seed: config.seed,
|
|
428
|
-
configs: config.configs
|
|
429
|
-
});
|
|
430
584
|
return {
|
|
431
|
-
type: prismicT__namespace.CustomTypeModelFieldType.
|
|
585
|
+
type: prismicT__namespace.CustomTypeModelFieldType.Timestamp,
|
|
432
586
|
config: {
|
|
433
587
|
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
434
|
-
|
|
588
|
+
placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
|
|
435
589
|
}
|
|
436
590
|
};
|
|
437
591
|
};
|
|
438
592
|
|
|
439
|
-
const
|
|
440
|
-
var _a, _b, _c, _d, _e, _f;
|
|
593
|
+
const title$1 = (config = {}) => {
|
|
441
594
|
const faker = createFaker(config.seed);
|
|
442
|
-
const
|
|
595
|
+
const single = faker.random.arrayElements([
|
|
596
|
+
"heading1",
|
|
597
|
+
"heading2",
|
|
598
|
+
"heading3",
|
|
599
|
+
"heading4",
|
|
600
|
+
"heading5",
|
|
601
|
+
"heading6"
|
|
602
|
+
]).join(",");
|
|
443
603
|
return {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
configs: (_c = config.primaryFieldConfig) == null ? void 0 : _c.configs
|
|
452
|
-
}),
|
|
453
|
-
items: buildMockGroupFieldMap({
|
|
454
|
-
seed: (_e = (_d = config.itemsFieldConfig) == null ? void 0 : _d.seed) != null ? _e : config.seed,
|
|
455
|
-
configs: (_f = config.itemsFieldConfig) == null ? void 0 : _f.configs
|
|
456
|
-
})
|
|
604
|
+
type: prismicT__namespace.CustomTypeModelFieldType.StructuredText,
|
|
605
|
+
config: {
|
|
606
|
+
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
607
|
+
placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3)),
|
|
608
|
+
single,
|
|
609
|
+
allowTargetBlank: faker.datatype.boolean() ? true : void 0
|
|
610
|
+
}
|
|
457
611
|
};
|
|
458
612
|
};
|
|
459
613
|
|
|
460
|
-
const
|
|
461
|
-
var _a;
|
|
614
|
+
const uid$1 = (config = {}) => {
|
|
462
615
|
const faker = createFaker(config.seed);
|
|
463
|
-
const variationsCount = (_a = config.variationsCount) != null ? _a : faker.datatype.number({ min: 1, max: 3 });
|
|
464
|
-
const name = changeCase__namespace.capitalCase(faker.company.bsNoun());
|
|
465
|
-
const variations = Array(variationsCount).fill(void 0).map(() => sharedSliceVariation$1({
|
|
466
|
-
seed: config.seed,
|
|
467
|
-
itemsFieldConfig: config.itemsFieldConfig,
|
|
468
|
-
primaryFieldConfig: config.primaryFieldConfig
|
|
469
|
-
}));
|
|
470
616
|
return {
|
|
471
|
-
type: prismicT__namespace.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
617
|
+
type: prismicT__namespace.CustomTypeModelFieldType.UID,
|
|
618
|
+
config: {
|
|
619
|
+
label: changeCase__namespace.capitalCase(faker.company.bsNoun()),
|
|
620
|
+
placeholder: changeCase__namespace.sentenceCase(faker.lorem.words(3))
|
|
621
|
+
}
|
|
476
622
|
};
|
|
477
623
|
};
|
|
478
624
|
|
|
479
|
-
const
|
|
480
|
-
__proto__: null,
|
|
481
|
-
boolean: boolean$1,
|
|
482
|
-
color: color$1,
|
|
483
|
-
contentRelationship: contentRelationship$1,
|
|
484
|
-
customType: customType$1,
|
|
485
|
-
date: date$1,
|
|
486
|
-
embed: embed$2,
|
|
487
|
-
geoPoint: geoPoint$1,
|
|
488
|
-
group: group$1,
|
|
489
|
-
image: image$2,
|
|
490
|
-
integrationFields: integrationFields$1,
|
|
491
|
-
keyText: keyText$1,
|
|
492
|
-
link: link$1,
|
|
493
|
-
linkToMedia: linkToMedia$1,
|
|
494
|
-
number: number$1,
|
|
495
|
-
richText: richText$1,
|
|
496
|
-
select: select$1,
|
|
497
|
-
sharedSlice: sharedSlice$1,
|
|
498
|
-
sharedSliceChoice: sharedSliceChoice,
|
|
499
|
-
sharedSliceVariation: sharedSliceVariation$1,
|
|
500
|
-
slice: slice$1,
|
|
501
|
-
sliceZone: sliceZone$1,
|
|
502
|
-
timestamp: timestamp$1,
|
|
503
|
-
title: title$1,
|
|
504
|
-
uid: uid$1
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
const boolean = (config = {}) => {
|
|
508
|
-
const faker = createFaker(config.seed);
|
|
509
|
-
return faker.datatype.boolean();
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
const generateTags = (config) => {
|
|
625
|
+
const generateFieldId = (config) => {
|
|
513
626
|
const faker = createFaker(config.seed);
|
|
514
|
-
return
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
const valueForModel = (config) => {
|
|
518
|
-
const model = config.model;
|
|
519
|
-
switch (model.type) {
|
|
520
|
-
case prismicT__namespace.CustomTypeModelFieldType.Boolean: {
|
|
521
|
-
return boolean({
|
|
522
|
-
seed: config.seed,
|
|
523
|
-
model,
|
|
524
|
-
...config.config
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
case prismicT__namespace.CustomTypeModelFieldType.Color: {
|
|
528
|
-
return color({
|
|
529
|
-
seed: config.seed,
|
|
530
|
-
model,
|
|
531
|
-
...config.config
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
case prismicT__namespace.CustomTypeModelFieldType.Link: {
|
|
535
|
-
switch (model.config.select) {
|
|
536
|
-
case prismicT__namespace.CustomTypeModelLinkSelectType.Document: {
|
|
537
|
-
return contentRelationship({
|
|
538
|
-
seed: config.seed,
|
|
539
|
-
model,
|
|
540
|
-
...config.config
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
case prismicT__namespace.CustomTypeModelLinkSelectType.Media: {
|
|
544
|
-
return linkToMedia({
|
|
545
|
-
seed: config.seed,
|
|
546
|
-
model,
|
|
547
|
-
...config.config
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
default: {
|
|
551
|
-
return link({
|
|
552
|
-
seed: config.seed,
|
|
553
|
-
model,
|
|
554
|
-
...config.config
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
case prismicT__namespace.CustomTypeModelFieldType.Date: {
|
|
560
|
-
return date({
|
|
561
|
-
seed: config.seed,
|
|
562
|
-
model,
|
|
563
|
-
...config.config
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
case prismicT__namespace.CustomTypeModelFieldType.Embed: {
|
|
567
|
-
return embed$1({
|
|
568
|
-
seed: config.seed,
|
|
569
|
-
model,
|
|
570
|
-
...config.config
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
case prismicT__namespace.CustomTypeModelFieldType.GeoPoint: {
|
|
574
|
-
return geoPoint({
|
|
575
|
-
seed: config.seed,
|
|
576
|
-
model,
|
|
577
|
-
...config.config
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
case prismicT__namespace.CustomTypeModelFieldType.Image: {
|
|
581
|
-
return image$1({
|
|
582
|
-
seed: config.seed,
|
|
583
|
-
model,
|
|
584
|
-
...config.config
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
case prismicT__namespace.CustomTypeModelFieldType.Text: {
|
|
588
|
-
return keyText({
|
|
589
|
-
seed: config.seed,
|
|
590
|
-
model,
|
|
591
|
-
...config.config
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
case prismicT__namespace.CustomTypeModelFieldType.Number: {
|
|
595
|
-
return number({
|
|
596
|
-
seed: config.seed,
|
|
597
|
-
model,
|
|
598
|
-
...config.config
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
case prismicT__namespace.CustomTypeModelFieldType.Select: {
|
|
602
|
-
return select({
|
|
603
|
-
seed: config.seed,
|
|
604
|
-
model,
|
|
605
|
-
...config.config
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
case prismicT__namespace.CustomTypeModelFieldType.Timestamp: {
|
|
609
|
-
return timestamp({
|
|
610
|
-
seed: config.seed,
|
|
611
|
-
model,
|
|
612
|
-
...config.config
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
|
|
616
|
-
if ("single" in model.config && model.config.single.split(",").every((element) => /heading[1-6]/.test(element.trim()))) {
|
|
617
|
-
return title({
|
|
618
|
-
seed: config.seed,
|
|
619
|
-
model,
|
|
620
|
-
...config.config
|
|
621
|
-
});
|
|
622
|
-
} else {
|
|
623
|
-
return richText({
|
|
624
|
-
seed: config.seed,
|
|
625
|
-
model,
|
|
626
|
-
...config.config
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields: {
|
|
631
|
-
return integrationFields({
|
|
632
|
-
seed: config.seed,
|
|
633
|
-
model,
|
|
634
|
-
...config.config
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
case prismicT__namespace.CustomTypeModelFieldType.UID: {
|
|
638
|
-
return uid({
|
|
639
|
-
seed: config.seed,
|
|
640
|
-
model,
|
|
641
|
-
...config.config
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
case prismicT__namespace.CustomTypeModelFieldType.Group: {
|
|
645
|
-
return group({
|
|
646
|
-
seed: config.seed,
|
|
647
|
-
model,
|
|
648
|
-
...config.config
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
case prismicT__namespace.CustomTypeModelFieldType.Slices: {
|
|
652
|
-
return sliceZone({
|
|
653
|
-
seed: config.seed,
|
|
654
|
-
model,
|
|
655
|
-
...config.config
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
}
|
|
627
|
+
return changeCase__namespace.snakeCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 })));
|
|
659
628
|
};
|
|
660
629
|
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
switch (model.config.select) {
|
|
679
|
-
case prismicT__namespace.CustomTypeModelLinkSelectType.Document:
|
|
680
|
-
return "contentRelationship";
|
|
681
|
-
case prismicT__namespace.CustomTypeModelLinkSelectType.Media:
|
|
682
|
-
return "linkToMedia";
|
|
683
|
-
default:
|
|
684
|
-
return "link";
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
case prismicT__namespace.CustomTypeModelFieldType.Number:
|
|
688
|
-
return "number";
|
|
689
|
-
case prismicT__namespace.CustomTypeModelFieldType.Select:
|
|
690
|
-
return "select";
|
|
691
|
-
case prismicT__namespace.CustomTypeModelFieldType.StructuredText: {
|
|
692
|
-
if ("single" in model.config && model.config.single.split(",").every((element) => /heading{1,6}/.test(element.trim()))) {
|
|
693
|
-
return "title";
|
|
694
|
-
} else {
|
|
695
|
-
return "richText";
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
case prismicT__namespace.CustomTypeModelFieldType.Text:
|
|
699
|
-
return "keyText";
|
|
700
|
-
case prismicT__namespace.CustomTypeModelFieldType.Timestamp:
|
|
701
|
-
return "timestamp";
|
|
702
|
-
case prismicT__namespace.CustomTypeModelFieldType.UID:
|
|
703
|
-
return "uid";
|
|
704
|
-
case prismicT__namespace.CustomTypeModelFieldType.IntegrationFields:
|
|
705
|
-
return "integrationFields";
|
|
706
|
-
case prismicT__namespace.CustomTypeModelFieldType.Slices:
|
|
707
|
-
return "slices";
|
|
708
|
-
}
|
|
630
|
+
const mockModelFns = {
|
|
631
|
+
boolean,
|
|
632
|
+
color: color$1,
|
|
633
|
+
contentRelationship: contentRelationship$1,
|
|
634
|
+
date: date$1,
|
|
635
|
+
embed: embed$2,
|
|
636
|
+
geoPoint: geoPoint$1,
|
|
637
|
+
image: image$2,
|
|
638
|
+
integrationFields: integrationFields$1,
|
|
639
|
+
keyText: keyText$1,
|
|
640
|
+
link: link$1,
|
|
641
|
+
linkToMedia: linkToMedia$1,
|
|
642
|
+
number: number$1,
|
|
643
|
+
richText: richText$1,
|
|
644
|
+
select: select$1,
|
|
645
|
+
timestamp: timestamp$1,
|
|
646
|
+
title: title$1
|
|
709
647
|
};
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
seed: config.seed,
|
|
719
|
-
model: fieldModel,
|
|
720
|
-
config: fieldConfig
|
|
721
|
-
});
|
|
648
|
+
const buildMockGroupFieldMap = (config = {}) => {
|
|
649
|
+
const faker = createFaker(config.seed);
|
|
650
|
+
const fields = {};
|
|
651
|
+
const fieldTypes = faker.random.arrayElements(Object.keys(mockModelFns));
|
|
652
|
+
for (const fieldType of fieldTypes) {
|
|
653
|
+
const fieldId = generateFieldId({ seed: config.seed });
|
|
654
|
+
const mockModelFn = mockModelFns[fieldType];
|
|
655
|
+
fields[fieldId] = mockModelFn({ seed: config.seed });
|
|
722
656
|
}
|
|
723
|
-
return
|
|
657
|
+
return fields;
|
|
724
658
|
};
|
|
725
659
|
|
|
660
|
+
const index$2 = /*#__PURE__*/Object.freeze({
|
|
661
|
+
__proto__: null,
|
|
662
|
+
boolean: boolean,
|
|
663
|
+
color: color$1,
|
|
664
|
+
contentRelationship: contentRelationship$1,
|
|
665
|
+
customType: customType$1,
|
|
666
|
+
date: date$1,
|
|
667
|
+
embed: embed$2,
|
|
668
|
+
geoPoint: geoPoint$1,
|
|
669
|
+
group: group$1,
|
|
670
|
+
image: image$2,
|
|
671
|
+
integrationFields: integrationFields$1,
|
|
672
|
+
keyText: keyText$1,
|
|
673
|
+
link: link$1,
|
|
674
|
+
linkToMedia: linkToMedia$1,
|
|
675
|
+
number: number$1,
|
|
676
|
+
richText: richText$1,
|
|
677
|
+
select: select$1,
|
|
678
|
+
sharedSlice: sharedSlice$1,
|
|
679
|
+
sharedSliceChoice: sharedSliceChoice,
|
|
680
|
+
sharedSliceVariation: sharedSliceVariation$1,
|
|
681
|
+
slice: slice$1,
|
|
682
|
+
sliceZone: sliceZone$1,
|
|
683
|
+
timestamp: timestamp$1,
|
|
684
|
+
title: title$1,
|
|
685
|
+
uid: uid$1,
|
|
686
|
+
buildMockGroupFieldMap: buildMockGroupFieldMap
|
|
687
|
+
});
|
|
688
|
+
|
|
726
689
|
const timestamp = (config = {}) => {
|
|
727
690
|
const faker = createFaker(config.seed);
|
|
728
691
|
const after = config.after || faker.date.past(20, new Date("2021-03-07")).toISOString().split("T")[0];
|
|
729
692
|
const before = config.before || faker.date.future(20, new Date("2021-03-07")).toISOString().split("T")[0];
|
|
730
|
-
return faker.date.between(after, before).toISOString();
|
|
693
|
+
return config.state === "empty" ? null : faker.date.between(after, before).toISOString();
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
const buildAlternativeLanguage = (config) => {
|
|
697
|
+
return {
|
|
698
|
+
id: config.document.id,
|
|
699
|
+
type: config.document.type,
|
|
700
|
+
lang: config.document.lang,
|
|
701
|
+
uid: config.document.uid || void 0
|
|
702
|
+
};
|
|
731
703
|
};
|
|
732
704
|
|
|
733
705
|
const customType = (config = {}) => {
|
|
706
|
+
var _a;
|
|
734
707
|
const faker = createFaker(config.seed);
|
|
735
708
|
const model = config.model || customType$1({ seed: config.seed });
|
|
736
709
|
const fieldModelsMap = Object.assign({}, ...Object.values(model.json));
|
|
710
|
+
const dataFieldModelsMap = {};
|
|
711
|
+
for (const key in fieldModelsMap) {
|
|
712
|
+
const fieldModel = fieldModelsMap[key];
|
|
713
|
+
if (fieldModel.type !== prismicT__namespace.CustomTypeModelFieldType.UID) {
|
|
714
|
+
dataFieldModelsMap[key] = fieldModel;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
737
717
|
const hasUID = Object.values(fieldModelsMap).some((fieldModel) => fieldModel.type === prismicT__namespace.CustomTypeModelFieldType.UID);
|
|
718
|
+
const withURL = (_a = config.withURL) != null ? _a : true;
|
|
719
|
+
const alternateLanguages = (config.alternateLanguages || []).map((alternateLanguageDocument) => buildAlternativeLanguage({
|
|
720
|
+
document: alternateLanguageDocument
|
|
721
|
+
}));
|
|
738
722
|
return {
|
|
739
723
|
type: model.id,
|
|
740
724
|
id: faker.git.shortSha(),
|
|
741
725
|
uid: hasUID ? changeCase__namespace.snakeCase(faker.lorem.words(2)) : null,
|
|
742
|
-
url: faker.internet.url(),
|
|
726
|
+
url: withURL ? faker.internet.url() : null,
|
|
743
727
|
href: faker.internet.url(),
|
|
744
728
|
lang: faker.lorem.word(),
|
|
745
729
|
tags: generateTags({ seed: config.seed }),
|
|
746
730
|
slugs: [],
|
|
747
731
|
linked_documents: [],
|
|
748
|
-
alternate_languages:
|
|
732
|
+
alternate_languages: alternateLanguages,
|
|
749
733
|
first_publication_date: timestamp({ seed: config.seed }),
|
|
750
734
|
last_publication_date: timestamp({ seed: config.seed }),
|
|
751
735
|
data: valueForModelMap({
|
|
752
736
|
seed: config.seed,
|
|
753
|
-
map:
|
|
737
|
+
map: dataFieldModelsMap,
|
|
754
738
|
configs: config.configs
|
|
755
739
|
})
|
|
756
740
|
};
|
|
@@ -758,7 +742,7 @@ const customType = (config = {}) => {
|
|
|
758
742
|
|
|
759
743
|
const color = (config = {}) => {
|
|
760
744
|
const faker = createFaker(config.seed);
|
|
761
|
-
return faker.internet.color().toUpperCase();
|
|
745
|
+
return config.state === "empty" ? null : faker.internet.color().toUpperCase();
|
|
762
746
|
};
|
|
763
747
|
|
|
764
748
|
const buildContentRelationshipField = (config) => {
|
|
@@ -775,11 +759,18 @@ const buildContentRelationshipField = (config) => {
|
|
|
775
759
|
};
|
|
776
760
|
};
|
|
777
761
|
|
|
762
|
+
const generateCustomTypeId = (config) => {
|
|
763
|
+
const faker = createFaker(config.seed);
|
|
764
|
+
return changeCase__namespace.snakeCase(faker.company.bsNoun());
|
|
765
|
+
};
|
|
766
|
+
|
|
778
767
|
const contentRelationship = (config = {}) => {
|
|
779
|
-
var _a;
|
|
780
768
|
const faker = createFaker(config.seed);
|
|
781
|
-
|
|
782
|
-
|
|
769
|
+
if (config.state === "empty") {
|
|
770
|
+
return {
|
|
771
|
+
link_type: prismicT__namespace.LinkType.Document
|
|
772
|
+
};
|
|
773
|
+
} else {
|
|
783
774
|
const model = config.model || contentRelationship$1({ seed: config.seed });
|
|
784
775
|
const linkableDocuments = config.linkableDocuments ? config.linkableDocuments.filter((document2) => {
|
|
785
776
|
let shouldKeep = true;
|
|
@@ -801,19 +792,18 @@ const contentRelationship = (config = {}) => {
|
|
|
801
792
|
if (!document) {
|
|
802
793
|
throw new Error("A linkable document could not be found.");
|
|
803
794
|
}
|
|
804
|
-
return buildContentRelationshipField({
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
link_type: prismicT__namespace.LinkType.Document
|
|
808
|
-
};
|
|
795
|
+
return buildContentRelationshipField({
|
|
796
|
+
document
|
|
797
|
+
});
|
|
809
798
|
}
|
|
810
799
|
};
|
|
811
800
|
|
|
812
801
|
const date = (config = {}) => {
|
|
813
|
-
return timestamp({
|
|
802
|
+
return config.state === "empty" ? null : timestamp({
|
|
814
803
|
seed: config.seed,
|
|
815
804
|
after: config.after,
|
|
816
|
-
before: config.before
|
|
805
|
+
before: config.before,
|
|
806
|
+
state: "filled"
|
|
817
807
|
}).split("T")[0];
|
|
818
808
|
};
|
|
819
809
|
|
|
@@ -903,40 +893,25 @@ const getMockEmbedData = (config) => {
|
|
|
903
893
|
|
|
904
894
|
const embed$1 = (config = {}) => {
|
|
905
895
|
const embedData = getMockEmbedData({ seed: config.seed });
|
|
906
|
-
return buildEmbedField({ seed: config.seed, embedData });
|
|
896
|
+
return config.state === "empty" ? {} : buildEmbedField({ seed: config.seed, embedData });
|
|
907
897
|
};
|
|
908
898
|
|
|
909
899
|
const geoPoint = (config = {}) => {
|
|
910
900
|
const faker = createFaker(config.seed);
|
|
911
901
|
const coordinates = faker.address.nearbyGPSCoordinate();
|
|
912
|
-
return {
|
|
902
|
+
return config.state === "empty" ? {} : {
|
|
913
903
|
longitude: Number.parseFloat(coordinates[0]),
|
|
914
904
|
latitude: Number.parseFloat(coordinates[1])
|
|
915
905
|
};
|
|
916
906
|
};
|
|
917
907
|
|
|
918
|
-
const patterns$9 = {
|
|
919
|
-
short: {
|
|
920
|
-
minItems: 1,
|
|
921
|
-
maxItems: 3
|
|
922
|
-
},
|
|
923
|
-
medium: {
|
|
924
|
-
minItems: 3,
|
|
925
|
-
maxItems: 6
|
|
926
|
-
},
|
|
927
|
-
long: {
|
|
928
|
-
minItems: 6,
|
|
929
|
-
maxItems: 12
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
908
|
const group = (config = {}) => {
|
|
909
|
+
var _a;
|
|
933
910
|
const faker = createFaker(config.seed);
|
|
934
911
|
const model = config.model || group$1({ seed: config.seed });
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
min: pattern.minItems,
|
|
939
|
-
max: pattern.maxItems
|
|
912
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
|
|
913
|
+
min: 1,
|
|
914
|
+
max: 6
|
|
940
915
|
});
|
|
941
916
|
return Array(itemsCount).fill(void 0).map(() => {
|
|
942
917
|
return valueForModelMap({
|
|
@@ -947,23 +922,32 @@ const group = (config = {}) => {
|
|
|
947
922
|
});
|
|
948
923
|
};
|
|
949
924
|
|
|
950
|
-
const
|
|
925
|
+
const buildImageFieldImage = (config) => {
|
|
951
926
|
var _a, _b, _c, _d;
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
927
|
+
if (config.state === "empty") {
|
|
928
|
+
return {
|
|
929
|
+
url: null,
|
|
930
|
+
dimensions: null,
|
|
931
|
+
alt: null,
|
|
932
|
+
copyright: null
|
|
933
|
+
};
|
|
934
|
+
} else {
|
|
935
|
+
const faker = createFaker(config.seed);
|
|
936
|
+
const url = new URL(config.imageData.url);
|
|
937
|
+
const dimensions = {
|
|
938
|
+
width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
|
|
939
|
+
height: (_d = (_c = config.constraint) == null ? void 0 : _c.height) != null ? _d : config.imageData.height
|
|
940
|
+
};
|
|
941
|
+
url.searchParams.set("w", dimensions.width.toString());
|
|
942
|
+
url.searchParams.set("h", dimensions.height.toString());
|
|
943
|
+
url.searchParams.set("fit", "crop");
|
|
944
|
+
return {
|
|
945
|
+
url: url.toString(),
|
|
946
|
+
dimensions,
|
|
947
|
+
alt: faker.lorem.sentence(),
|
|
948
|
+
copyright: faker.lorem.sentence()
|
|
949
|
+
};
|
|
950
|
+
}
|
|
967
951
|
};
|
|
968
952
|
|
|
969
953
|
const dataSet = [
|
|
@@ -1056,19 +1040,21 @@ const getMockImageData = (config) => {
|
|
|
1056
1040
|
const image$1 = (config = {}) => {
|
|
1057
1041
|
const model = config.model || image$2({ seed: config.seed });
|
|
1058
1042
|
const imageData = getMockImageData({ seed: config.seed });
|
|
1059
|
-
const value =
|
|
1043
|
+
const value = buildImageFieldImage({
|
|
1060
1044
|
seed: config.seed,
|
|
1061
1045
|
imageData,
|
|
1062
|
-
constraint: model.config.constraint
|
|
1046
|
+
constraint: model.config.constraint,
|
|
1047
|
+
state: config.state
|
|
1063
1048
|
});
|
|
1064
1049
|
for (const thumbnail of model.config.thumbnails) {
|
|
1065
|
-
value[thumbnail.name] =
|
|
1050
|
+
value[thumbnail.name] = buildImageFieldImage({
|
|
1066
1051
|
seed: config.seed,
|
|
1067
1052
|
imageData,
|
|
1068
1053
|
constraint: {
|
|
1069
1054
|
width: thumbnail.width,
|
|
1070
1055
|
height: thumbnail.height
|
|
1071
|
-
}
|
|
1056
|
+
},
|
|
1057
|
+
state: config.state
|
|
1072
1058
|
});
|
|
1073
1059
|
}
|
|
1074
1060
|
return value;
|
|
@@ -1077,7 +1063,7 @@ const image$1 = (config = {}) => {
|
|
|
1077
1063
|
const integrationFields = (config = {}) => {
|
|
1078
1064
|
const faker = createFaker(config.seed);
|
|
1079
1065
|
const imageData = getMockImageData({ seed: config.seed });
|
|
1080
|
-
return {
|
|
1066
|
+
return config.state === "empty" ? null : {
|
|
1081
1067
|
id: faker.git.shortSha(),
|
|
1082
1068
|
title: changeCase__namespace.capitalCase(faker.lorem.words(3)),
|
|
1083
1069
|
description: faker.lorem.sentence(),
|
|
@@ -1089,14 +1075,16 @@ const integrationFields = (config = {}) => {
|
|
|
1089
1075
|
|
|
1090
1076
|
const keyText = (config = {}) => {
|
|
1091
1077
|
const faker = createFaker(config.seed);
|
|
1092
|
-
return changeCase__namespace.sentenceCase(faker.lorem.words(3));
|
|
1078
|
+
return config.state === "empty" ? null : changeCase__namespace.sentenceCase(faker.lorem.words(3));
|
|
1093
1079
|
};
|
|
1094
1080
|
|
|
1095
1081
|
const linkToMedia = (config = {}) => {
|
|
1096
|
-
var _a;
|
|
1097
1082
|
const faker = createFaker(config.seed);
|
|
1098
|
-
|
|
1099
|
-
|
|
1083
|
+
if (config.state === "empty") {
|
|
1084
|
+
return {
|
|
1085
|
+
link_type: prismicT__namespace.LinkType.Media
|
|
1086
|
+
};
|
|
1087
|
+
} else {
|
|
1100
1088
|
return {
|
|
1101
1089
|
link_type: prismicT__namespace.LinkType.Media,
|
|
1102
1090
|
name: faker.system.commonFileName(),
|
|
@@ -1106,58 +1094,55 @@ const linkToMedia = (config = {}) => {
|
|
|
1106
1094
|
height: faker.datatype.number().toString(),
|
|
1107
1095
|
width: faker.datatype.number().toString()
|
|
1108
1096
|
};
|
|
1109
|
-
} else {
|
|
1110
|
-
return {
|
|
1111
|
-
link_type: prismicT__namespace.LinkType.Media
|
|
1112
|
-
};
|
|
1113
1097
|
}
|
|
1114
1098
|
};
|
|
1115
1099
|
|
|
1116
1100
|
const link = (config = {}) => {
|
|
1117
|
-
var _a
|
|
1101
|
+
var _a;
|
|
1118
1102
|
const faker = createFaker(config.seed);
|
|
1119
|
-
const isFilled = (_a = config.isFilled) != null ? _a : true;
|
|
1120
1103
|
const type = config.type || faker.random.arrayElement([
|
|
1121
1104
|
prismicT__namespace.LinkType.Web,
|
|
1122
1105
|
prismicT__namespace.LinkType.Document,
|
|
1123
1106
|
prismicT__namespace.LinkType.Media
|
|
1124
1107
|
]);
|
|
1125
|
-
if (
|
|
1108
|
+
if (config.state === "empty") {
|
|
1109
|
+
return {
|
|
1110
|
+
link_type: type
|
|
1111
|
+
};
|
|
1112
|
+
} else {
|
|
1126
1113
|
switch (type) {
|
|
1127
1114
|
case prismicT__namespace.LinkType.Document: {
|
|
1128
1115
|
return contentRelationship({
|
|
1129
1116
|
seed: config.seed,
|
|
1130
|
-
|
|
1117
|
+
state: config.state,
|
|
1131
1118
|
linkableDocuments: config.linkableDocuments
|
|
1132
1119
|
});
|
|
1133
1120
|
}
|
|
1134
1121
|
case prismicT__namespace.LinkType.Media: {
|
|
1135
1122
|
return linkToMedia({
|
|
1136
1123
|
seed: config.seed,
|
|
1137
|
-
|
|
1124
|
+
state: config.state
|
|
1138
1125
|
});
|
|
1139
1126
|
}
|
|
1140
|
-
case prismicT__namespace.LinkType.Web:
|
|
1127
|
+
case prismicT__namespace.LinkType.Web:
|
|
1128
|
+
default: {
|
|
1141
1129
|
const model = config.model || link$1({ seed: config.seed });
|
|
1142
1130
|
return {
|
|
1143
1131
|
link_type: prismicT__namespace.LinkType.Web,
|
|
1144
1132
|
url: faker.internet.url(),
|
|
1145
|
-
target: ((
|
|
1133
|
+
target: ((_a = config.withTargetBlank) != null ? _a : model.config.allowTargetBlank && faker.datatype.boolean()) ? "_blank" : void 0
|
|
1146
1134
|
};
|
|
1147
1135
|
}
|
|
1148
1136
|
}
|
|
1149
1137
|
}
|
|
1150
|
-
return {
|
|
1151
|
-
link_type: type
|
|
1152
|
-
};
|
|
1153
1138
|
};
|
|
1154
1139
|
|
|
1155
1140
|
const number = (config = {}) => {
|
|
1156
1141
|
const faker = createFaker(config.seed);
|
|
1157
|
-
return faker.datatype.number();
|
|
1142
|
+
return config.state === "empty" ? null : faker.datatype.number();
|
|
1158
1143
|
};
|
|
1159
1144
|
|
|
1160
|
-
const patterns$
|
|
1145
|
+
const patterns$5 = {
|
|
1161
1146
|
short: {
|
|
1162
1147
|
minWords: 1,
|
|
1163
1148
|
maxWords: 3
|
|
@@ -1184,8 +1169,8 @@ const heading = (config = {}) => {
|
|
|
1184
1169
|
].includes(type2));
|
|
1185
1170
|
const type = faker.random.arrayElement(types);
|
|
1186
1171
|
if (type) {
|
|
1187
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$
|
|
1188
|
-
const pattern = patterns$
|
|
1172
|
+
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$5));
|
|
1173
|
+
const pattern = patterns$5[patternKey];
|
|
1189
1174
|
return {
|
|
1190
1175
|
type,
|
|
1191
1176
|
text: changeCase__namespace.capitalCase(faker.lorem.words(faker.datatype.number({
|
|
@@ -1199,7 +1184,7 @@ const heading = (config = {}) => {
|
|
|
1199
1184
|
}
|
|
1200
1185
|
};
|
|
1201
1186
|
|
|
1202
|
-
const patterns$
|
|
1187
|
+
const patterns$4 = {
|
|
1203
1188
|
short: {
|
|
1204
1189
|
sentenceCount: 2
|
|
1205
1190
|
},
|
|
@@ -1212,8 +1197,8 @@ const patterns$7 = {
|
|
|
1212
1197
|
};
|
|
1213
1198
|
const paragraph = (config = {}) => {
|
|
1214
1199
|
const faker = createFaker(config.seed);
|
|
1215
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$
|
|
1216
|
-
const pattern = patterns$
|
|
1200
|
+
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$4));
|
|
1201
|
+
const pattern = patterns$4[patternKey];
|
|
1217
1202
|
return {
|
|
1218
1203
|
type: prismicT__namespace.RichTextNodeType.paragraph,
|
|
1219
1204
|
text: faker.lorem.paragraph(pattern.sentenceCount),
|
|
@@ -1221,7 +1206,7 @@ const paragraph = (config = {}) => {
|
|
|
1221
1206
|
};
|
|
1222
1207
|
};
|
|
1223
1208
|
|
|
1224
|
-
const patterns$
|
|
1209
|
+
const patterns$3 = {
|
|
1225
1210
|
short: {
|
|
1226
1211
|
sentenceCount: 2
|
|
1227
1212
|
},
|
|
@@ -1234,8 +1219,8 @@ const patterns$6 = {
|
|
|
1234
1219
|
};
|
|
1235
1220
|
const preformatted = (config = {}) => {
|
|
1236
1221
|
const faker = createFaker(config.seed);
|
|
1237
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$
|
|
1238
|
-
const pattern = patterns$
|
|
1222
|
+
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$3));
|
|
1223
|
+
const pattern = patterns$3[patternKey];
|
|
1239
1224
|
return {
|
|
1240
1225
|
type: prismicT__namespace.RichTextNodeType.preformatted,
|
|
1241
1226
|
text: faker.lorem.paragraph(pattern.sentenceCount),
|
|
@@ -1243,7 +1228,7 @@ const preformatted = (config = {}) => {
|
|
|
1243
1228
|
};
|
|
1244
1229
|
};
|
|
1245
1230
|
|
|
1246
|
-
const patterns$
|
|
1231
|
+
const patterns$2 = {
|
|
1247
1232
|
short: {
|
|
1248
1233
|
minItems: 1,
|
|
1249
1234
|
maxItems: 3
|
|
@@ -1259,8 +1244,8 @@ const patterns$5 = {
|
|
|
1259
1244
|
};
|
|
1260
1245
|
const list = (config = {}) => {
|
|
1261
1246
|
const faker = createFaker(config.seed);
|
|
1262
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$
|
|
1263
|
-
const pattern = patterns$
|
|
1247
|
+
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$2));
|
|
1248
|
+
const pattern = patterns$2[patternKey];
|
|
1264
1249
|
const itemsCount = faker.datatype.number({
|
|
1265
1250
|
min: pattern.minItems,
|
|
1266
1251
|
max: pattern.maxItems
|
|
@@ -1274,7 +1259,7 @@ const list = (config = {}) => {
|
|
|
1274
1259
|
});
|
|
1275
1260
|
};
|
|
1276
1261
|
|
|
1277
|
-
const patterns$
|
|
1262
|
+
const patterns$1 = {
|
|
1278
1263
|
short: {
|
|
1279
1264
|
minItems: 1,
|
|
1280
1265
|
maxItems: 3
|
|
@@ -1290,8 +1275,8 @@ const patterns$4 = {
|
|
|
1290
1275
|
};
|
|
1291
1276
|
const oList = (config = {}) => {
|
|
1292
1277
|
const faker = createFaker(config.seed);
|
|
1293
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$
|
|
1294
|
-
const pattern = patterns$
|
|
1278
|
+
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$1));
|
|
1279
|
+
const pattern = patterns$1[patternKey];
|
|
1295
1280
|
const itemsCount = faker.datatype.number({
|
|
1296
1281
|
min: pattern.minItems,
|
|
1297
1282
|
max: pattern.maxItems
|
|
@@ -1307,7 +1292,11 @@ const oList = (config = {}) => {
|
|
|
1307
1292
|
|
|
1308
1293
|
const image = (config = {}) => {
|
|
1309
1294
|
const imageData = getMockImageData({ seed: config.seed });
|
|
1310
|
-
const imageField =
|
|
1295
|
+
const imageField = buildImageFieldImage({
|
|
1296
|
+
seed: config.seed,
|
|
1297
|
+
imageData,
|
|
1298
|
+
state: false
|
|
1299
|
+
});
|
|
1311
1300
|
return {
|
|
1312
1301
|
type: prismicT__namespace.RichTextNodeType.image,
|
|
1313
1302
|
alt: imageField.alt,
|
|
@@ -1326,7 +1315,7 @@ const embed = (config = {}) => {
|
|
|
1326
1315
|
};
|
|
1327
1316
|
};
|
|
1328
1317
|
|
|
1329
|
-
const patterns
|
|
1318
|
+
const patterns = {
|
|
1330
1319
|
short: {
|
|
1331
1320
|
blockCountMin: 1,
|
|
1332
1321
|
blockCountMax: 2
|
|
@@ -1363,8 +1352,8 @@ const richText = (config = {}) => {
|
|
|
1363
1352
|
const supportsMultipleBlocks = "multi" in model.config;
|
|
1364
1353
|
const types = ("multi" in model.config ? model.config.multi : model.config.single).split(",").filter((type) => Object.keys(generators).includes(type));
|
|
1365
1354
|
if (types.length > 0) {
|
|
1366
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns
|
|
1367
|
-
const pattern = patterns
|
|
1355
|
+
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns));
|
|
1356
|
+
const pattern = patterns[patternKey];
|
|
1368
1357
|
const blockCount = supportsMultipleBlocks ? faker.datatype.number({
|
|
1369
1358
|
min: pattern.blockCountMin,
|
|
1370
1359
|
max: pattern.blockCountMax
|
|
@@ -1383,38 +1372,22 @@ const select = (config = {}) => {
|
|
|
1383
1372
|
const faker = createFaker(config.seed);
|
|
1384
1373
|
const model = config.model || select$1({ seed: config.seed });
|
|
1385
1374
|
const defaultValue = model.config.default_value;
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
none: {
|
|
1391
|
-
minItems: 0,
|
|
1392
|
-
maxItems: 0
|
|
1393
|
-
},
|
|
1394
|
-
short: {
|
|
1395
|
-
minItems: 1,
|
|
1396
|
-
maxItems: 3
|
|
1397
|
-
},
|
|
1398
|
-
medium: {
|
|
1399
|
-
minItems: 3,
|
|
1400
|
-
maxItems: 6
|
|
1401
|
-
},
|
|
1402
|
-
long: {
|
|
1403
|
-
minItems: 6,
|
|
1404
|
-
maxItems: 12
|
|
1375
|
+
if (config.state === "empty") {
|
|
1376
|
+
return null;
|
|
1377
|
+
} else {
|
|
1378
|
+
return typeof defaultValue === "string" && faker.datatype.boolean() ? defaultValue : faker.random.arrayElement(model.config.options);
|
|
1405
1379
|
}
|
|
1406
1380
|
};
|
|
1381
|
+
|
|
1407
1382
|
const slice = (config = {}) => {
|
|
1408
|
-
var _a;
|
|
1383
|
+
var _a, _b;
|
|
1409
1384
|
const faker = createFaker(config.seed);
|
|
1410
1385
|
const model = config.model || slice$1({ seed: config.seed });
|
|
1411
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$2));
|
|
1412
|
-
const pattern = patterns$2[patternKey];
|
|
1413
1386
|
const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
|
|
1414
1387
|
const sliceLabel = config.label !== void 0 ? config.label : changeCase__namespace.capitalCase(faker.company.bsNoun());
|
|
1415
|
-
const itemsCount = Object.keys(model.repeat).length > 0 ? faker.datatype.number({
|
|
1416
|
-
min:
|
|
1417
|
-
max:
|
|
1388
|
+
const itemsCount = Object.keys(model.repeat).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.datatype.number({
|
|
1389
|
+
min: 1,
|
|
1390
|
+
max: 6
|
|
1418
1391
|
}) : 0;
|
|
1419
1392
|
return {
|
|
1420
1393
|
slice_type: sliceType,
|
|
@@ -1434,39 +1407,18 @@ const slice = (config = {}) => {
|
|
|
1434
1407
|
};
|
|
1435
1408
|
};
|
|
1436
1409
|
|
|
1437
|
-
const patterns$1 = {
|
|
1438
|
-
none: {
|
|
1439
|
-
minItems: 0,
|
|
1440
|
-
maxItems: 0
|
|
1441
|
-
},
|
|
1442
|
-
short: {
|
|
1443
|
-
minItems: 1,
|
|
1444
|
-
maxItems: 3
|
|
1445
|
-
},
|
|
1446
|
-
medium: {
|
|
1447
|
-
minItems: 3,
|
|
1448
|
-
maxItems: 6
|
|
1449
|
-
},
|
|
1450
|
-
long: {
|
|
1451
|
-
minItems: 6,
|
|
1452
|
-
maxItems: 12
|
|
1453
|
-
}
|
|
1454
|
-
};
|
|
1455
1410
|
const sharedSliceVariation = (config = {}) => {
|
|
1456
1411
|
var _a, _b;
|
|
1457
1412
|
const faker = createFaker(config.seed);
|
|
1458
1413
|
const model = config.model || sharedSliceVariation$1({ seed: config.seed });
|
|
1459
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$1));
|
|
1460
|
-
const pattern = patterns$1[patternKey];
|
|
1461
1414
|
const sliceType = (_a = config.type) != null ? _a : generateFieldId({ seed: config.seed });
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
max: pattern.maxItems
|
|
1415
|
+
const itemsCount = Object.keys(model.items).length > 0 ? (_b = config.itemsCount) != null ? _b : faker.datatype.number({
|
|
1416
|
+
min: 1,
|
|
1417
|
+
max: 6
|
|
1466
1418
|
}) : 0;
|
|
1467
1419
|
return {
|
|
1468
1420
|
slice_type: sliceType,
|
|
1469
|
-
slice_label:
|
|
1421
|
+
slice_label: null,
|
|
1470
1422
|
variation: model.id,
|
|
1471
1423
|
version: faker.git.shortSha(),
|
|
1472
1424
|
primary: valueForModelMap({
|
|
@@ -1491,66 +1443,55 @@ const sharedSlice = (config = {}) => {
|
|
|
1491
1443
|
return sharedSliceVariation({
|
|
1492
1444
|
seed: config.seed,
|
|
1493
1445
|
model: variationModel,
|
|
1494
|
-
|
|
1446
|
+
itemsCount: config.itemsCount,
|
|
1495
1447
|
type: model.id,
|
|
1496
1448
|
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1497
1449
|
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1498
1450
|
});
|
|
1499
1451
|
};
|
|
1500
1452
|
|
|
1501
|
-
const patterns = {
|
|
1502
|
-
short: {
|
|
1503
|
-
minItems: 1,
|
|
1504
|
-
maxItems: 3
|
|
1505
|
-
},
|
|
1506
|
-
medium: {
|
|
1507
|
-
minItems: 3,
|
|
1508
|
-
maxItems: 6
|
|
1509
|
-
},
|
|
1510
|
-
long: {
|
|
1511
|
-
minItems: 6,
|
|
1512
|
-
maxItems: 12
|
|
1513
|
-
}
|
|
1514
|
-
};
|
|
1515
1453
|
const sliceZone = (config = {}) => {
|
|
1454
|
+
var _a;
|
|
1516
1455
|
const faker = createFaker(config.seed);
|
|
1517
1456
|
const model = config.model || sliceZone$1({ seed: config.seed });
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
return slice({
|
|
1533
|
-
seed: config.seed,
|
|
1534
|
-
model: choiceModel,
|
|
1535
|
-
type: choiceType,
|
|
1536
|
-
label: choiceLabel ? choiceLabel.name : null,
|
|
1537
|
-
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1538
|
-
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1539
|
-
});
|
|
1540
|
-
}
|
|
1541
|
-
case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
|
|
1542
|
-
const sharedSliceModel = (_a = config.sharedSliceModels) == null ? void 0 : _a.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
|
|
1543
|
-
if (sharedSliceModel) {
|
|
1544
|
-
return sharedSlice({
|
|
1457
|
+
if (Object.keys(model.config.choices).length > 0) {
|
|
1458
|
+
const itemsCount = (_a = config.itemsCount) != null ? _a : faker.datatype.number({
|
|
1459
|
+
min: 1,
|
|
1460
|
+
max: 6
|
|
1461
|
+
});
|
|
1462
|
+
return Array(itemsCount).fill(void 0).map(() => {
|
|
1463
|
+
var _a2;
|
|
1464
|
+
const choices = Object.entries(model.config.choices);
|
|
1465
|
+
const [choiceType, choiceModel] = faker.random.arrayElement(choices);
|
|
1466
|
+
const choiceLabels = model.config.labels[choiceType] || [];
|
|
1467
|
+
const choiceLabel = faker.random.arrayElement(choiceLabels);
|
|
1468
|
+
switch (choiceModel.type) {
|
|
1469
|
+
case prismicT__namespace.CustomTypeModelSliceType.Slice: {
|
|
1470
|
+
return slice({
|
|
1545
1471
|
seed: config.seed,
|
|
1546
|
-
model:
|
|
1472
|
+
model: choiceModel,
|
|
1473
|
+
type: choiceType,
|
|
1474
|
+
label: choiceLabel ? choiceLabel.name : null,
|
|
1547
1475
|
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1548
1476
|
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1549
1477
|
});
|
|
1550
1478
|
}
|
|
1479
|
+
case prismicT__namespace.CustomTypeModelSliceType.SharedSlice: {
|
|
1480
|
+
const sharedSliceModel = (_a2 = config.sharedSliceModels) == null ? void 0 : _a2.find((sharedSliceModel2) => sharedSliceModel2.id === choiceType);
|
|
1481
|
+
if (sharedSliceModel) {
|
|
1482
|
+
return sharedSlice({
|
|
1483
|
+
seed: config.seed,
|
|
1484
|
+
model: sharedSliceModel,
|
|
1485
|
+
primaryFieldConfigs: config.primaryFieldConfigs,
|
|
1486
|
+
itemsFieldConfigs: config.itemsFieldConfigs
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1551
1490
|
}
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1491
|
+
}).filter((slice2) => slice2 !== void 0);
|
|
1492
|
+
} else {
|
|
1493
|
+
return [];
|
|
1494
|
+
}
|
|
1554
1495
|
};
|
|
1555
1496
|
|
|
1556
1497
|
const title = (config = {}) => {
|
|
@@ -1568,9 +1509,9 @@ const uid = (config = {}) => {
|
|
|
1568
1509
|
return changeCase__namespace.snakeCase(faker.lorem.words(2));
|
|
1569
1510
|
};
|
|
1570
1511
|
|
|
1571
|
-
const index = /*#__PURE__*/Object.freeze({
|
|
1512
|
+
const index$1 = /*#__PURE__*/Object.freeze({
|
|
1572
1513
|
__proto__: null,
|
|
1573
|
-
boolean: boolean,
|
|
1514
|
+
boolean: boolean$1,
|
|
1574
1515
|
customType: customType,
|
|
1575
1516
|
color: color,
|
|
1576
1517
|
contentRelationship: contentRelationship,
|
|
@@ -1596,5 +1537,92 @@ const index = /*#__PURE__*/Object.freeze({
|
|
|
1596
1537
|
uid: uid
|
|
1597
1538
|
});
|
|
1598
1539
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1540
|
+
const ref = (config = {}) => {
|
|
1541
|
+
var _a;
|
|
1542
|
+
const faker = createFaker(config.seed);
|
|
1543
|
+
const value = {
|
|
1544
|
+
id: faker.git.shortSha(),
|
|
1545
|
+
ref: faker.git.shortSha(),
|
|
1546
|
+
isMasterRef: (_a = config.isMasterRef) != null ? _a : false,
|
|
1547
|
+
label: config.isMasterRef ? "Master" : changeCase__namespace.capitalCase(faker.company.bsNoun())
|
|
1548
|
+
};
|
|
1549
|
+
if (config.isScheduled) {
|
|
1550
|
+
value.scheduledAt = timestamp({ seed: config.seed });
|
|
1551
|
+
}
|
|
1552
|
+
return value;
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1555
|
+
const repository = (config = {}) => {
|
|
1556
|
+
const faker = createFaker(config.seed);
|
|
1557
|
+
const types = (config.customTypeModels || []).reduce((acc, model) => {
|
|
1558
|
+
acc[model.id] = model.label;
|
|
1559
|
+
return acc;
|
|
1560
|
+
}, {});
|
|
1561
|
+
return {
|
|
1562
|
+
refs: [
|
|
1563
|
+
ref({ seed: config.seed, isMasterRef: true }),
|
|
1564
|
+
...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
|
|
1565
|
+
],
|
|
1566
|
+
integrationFieldsRef: ref({ seed: config.seed }).ref,
|
|
1567
|
+
types,
|
|
1568
|
+
languages: [
|
|
1569
|
+
{
|
|
1570
|
+
id: faker.lorem.word(),
|
|
1571
|
+
name: changeCase__namespace.capitalCase(faker.lorem.word())
|
|
1572
|
+
}
|
|
1573
|
+
],
|
|
1574
|
+
tags: generateTags({
|
|
1575
|
+
seed: config.seed,
|
|
1576
|
+
min: 1,
|
|
1577
|
+
max: 10
|
|
1578
|
+
}),
|
|
1579
|
+
forms: {},
|
|
1580
|
+
license: "All Rights Reserved",
|
|
1581
|
+
version: faker.git.shortSha(),
|
|
1582
|
+
bookmarks: {},
|
|
1583
|
+
experiments: {},
|
|
1584
|
+
oauth_token: faker.internet.url(),
|
|
1585
|
+
oauth_initiate: faker.internet.url()
|
|
1586
|
+
};
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
const query = (config = {}) => {
|
|
1590
|
+
var _a, _b;
|
|
1591
|
+
const faker = createFaker(config.seed);
|
|
1592
|
+
const documents = config.documents || [];
|
|
1593
|
+
const page = Math.max(1, (_a = config.page) != null ? _a : 1);
|
|
1594
|
+
const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
|
|
1595
|
+
const totalPages = Math.ceil(documents.length / pageSize);
|
|
1596
|
+
const results = documents.slice((page - 1) * pageSize, page * pageSize);
|
|
1597
|
+
return {
|
|
1598
|
+
page,
|
|
1599
|
+
next_page: page < totalPages ? faker.internet.url() : null,
|
|
1600
|
+
prev_page: page > 1 ? faker.internet.url() : null,
|
|
1601
|
+
total_pages: totalPages,
|
|
1602
|
+
results_size: results.length,
|
|
1603
|
+
results_per_page: pageSize,
|
|
1604
|
+
total_results_size: documents.length,
|
|
1605
|
+
results
|
|
1606
|
+
};
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
const tags = (config = {}) => {
|
|
1610
|
+
return generateTags({
|
|
1611
|
+
seed: config.seed,
|
|
1612
|
+
min: 1,
|
|
1613
|
+
max: 10
|
|
1614
|
+
});
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
const index = /*#__PURE__*/Object.freeze({
|
|
1618
|
+
__proto__: null,
|
|
1619
|
+
repository: repository,
|
|
1620
|
+
ref: ref,
|
|
1621
|
+
query: query,
|
|
1622
|
+
tags: tags
|
|
1623
|
+
});
|
|
1624
|
+
|
|
1625
|
+
exports.api = index;
|
|
1626
|
+
exports.model = index$2;
|
|
1627
|
+
exports.value = index$1;
|
|
1628
|
+
//# sourceMappingURL=index.cjs.map
|