@prismicio/mock 0.0.6 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/api/index.cjs +242 -122
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +669 -0
- package/dist/api/index.js.map +1 -0
- package/dist/index.cjs +581 -571
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +155 -247
- package/dist/{index.mjs → index.js} +574 -561
- package/dist/index.js.map +1 -0
- package/dist/model/index.cjs +294 -257
- package/dist/model/index.cjs.map +1 -0
- package/dist/model/index.d.ts +72 -106
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +556 -0
- package/dist/model/index.js.map +1 -0
- package/dist/value/index.cjs +500 -647
- package/dist/value/index.cjs.map +1 -0
- package/dist/value/index.d.ts +71 -129
- package/dist/value/index.d.ts.map +1 -0
- package/dist/value/index.js +1461 -0
- package/dist/value/index.js.map +1 -0
- package/package.json +30 -27
- package/src/api/query.ts +2 -2
- package/src/api/ref.ts +3 -3
- package/src/api/repository.ts +5 -5
- package/src/lib/buildContentRelationshipField.ts +6 -1
- package/src/lib/buildEmbedField.ts +16 -27
- package/src/lib/buildImageFieldImage.ts +49 -0
- package/src/lib/createFaker.ts +98 -20
- package/src/lib/generateCustomTypeId.ts +1 -1
- package/src/lib/generateFieldId.ts +1 -3
- package/src/lib/generateTags.ts +4 -12
- package/src/lib/getMockEmbedData.ts +33 -12
- package/src/lib/getMockImageData.ts +1 -1
- package/src/lib/lorem.ts +112 -0
- package/src/model/boolean.ts +1 -1
- package/src/model/buildMockGroupFieldMap.ts +65 -0
- package/src/model/color.ts +2 -2
- package/src/model/contentRelationship.ts +16 -23
- package/src/model/customType.ts +49 -48
- package/src/model/date.ts +2 -2
- package/src/model/embed.ts +2 -2
- package/src/model/geoPoint.ts +1 -1
- package/src/model/group.ts +9 -16
- package/src/model/image.ts +16 -20
- package/src/model/index.ts +2 -0
- package/src/model/integrationFields.ts +5 -3
- package/src/model/keyText.ts +2 -2
- package/src/model/link.ts +3 -3
- package/src/model/linkToMedia.ts +2 -2
- package/src/model/number.ts +2 -2
- package/src/model/richText.ts +6 -6
- package/src/model/select.ts +13 -18
- package/src/model/sharedSlice.ts +15 -42
- package/src/model/sharedSliceVariation.ts +36 -24
- package/src/model/slice.ts +19 -23
- package/src/model/sliceZone.ts +23 -59
- package/src/model/timestamp.ts +2 -2
- package/src/model/title.ts +5 -5
- package/src/model/uid.ts +2 -2
- package/src/types.ts +130 -88
- package/src/value/boolean.ts +1 -1
- package/src/value/color.ts +16 -6
- package/src/value/contentRelationship.ts +54 -39
- package/src/value/customType.ts +5 -5
- package/src/value/date.ts +25 -9
- package/src/value/embed.ts +32 -7
- package/src/value/geoPoint.ts +21 -11
- package/src/value/group.ts +31 -45
- package/src/value/image.ts +22 -9
- package/src/value/integrationFields.ts +26 -14
- package/src/value/keyText.ts +16 -6
- package/src/value/link.ts +36 -37
- package/src/value/linkToMedia.ts +19 -23
- package/src/value/number.ts +16 -6
- package/src/value/richText/embed.ts +2 -2
- package/src/value/richText/heading.ts +10 -17
- package/src/value/richText/image.ts +8 -6
- package/src/value/richText/index.ts +4 -9
- package/src/value/richText/list.ts +4 -8
- package/src/value/richText/oList.ts +4 -8
- package/src/value/richText/paragraph.ts +8 -4
- package/src/value/richText/preformatted.ts +9 -5
- package/src/value/select.ts +23 -8
- package/src/value/sharedSlice.ts +3 -3
- package/src/value/sharedSliceVariation.ts +4 -36
- package/src/value/slice.ts +3 -32
- package/src/value/sliceZone.ts +54 -69
- package/src/value/timestamp.ts +42 -16
- package/src/value/title.ts +26 -13
- package/src/value/uid.ts +2 -2
- package/dist/api/index.mjs +0 -515
- package/dist/model/index.mjs +0 -465
- package/dist/value/index.mjs +0 -1554
- package/src/lib/buildImageField.ts +0 -34
- package/src/lib/buildMockGroupFieldMap.ts +0 -84
package/src/value/title.ts
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import * as prismicT from "@prismicio/types";
|
|
2
2
|
|
|
3
|
-
import { MockValueConfig } from "../types";
|
|
3
|
+
import { MockValueConfig, MockValueStateConfig } from "../types";
|
|
4
4
|
|
|
5
5
|
import { heading, MockRichTextHeadingValueConfig } from "./richText/heading";
|
|
6
6
|
|
|
7
7
|
export type MockTitleValueConfig<
|
|
8
8
|
Model extends prismicT.CustomTypeModelTitleField = prismicT.CustomTypeModelTitleField,
|
|
9
|
+
State extends prismicT.FieldState = prismicT.FieldState,
|
|
9
10
|
> = {
|
|
10
11
|
pattern?: MockRichTextHeadingValueConfig["pattern"];
|
|
11
|
-
} & MockValueConfig<Model
|
|
12
|
+
} & MockValueConfig<Model> &
|
|
13
|
+
MockValueStateConfig<State>;
|
|
12
14
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
export type MockTitleValue<
|
|
16
|
+
State extends prismicT.FieldState = prismicT.FieldState,
|
|
17
|
+
> = prismicT.TitleField<State>;
|
|
18
|
+
|
|
19
|
+
export const title = <
|
|
20
|
+
Model extends prismicT.CustomTypeModelTitleField = prismicT.CustomTypeModelTitleField,
|
|
21
|
+
State extends prismicT.FieldState = prismicT.FieldState,
|
|
22
|
+
>(
|
|
23
|
+
config: MockTitleValueConfig<Model, State> = {},
|
|
24
|
+
): MockTitleValue<State> => {
|
|
25
|
+
if (config.state === "empty") {
|
|
26
|
+
return [] as MockTitleValue<State>;
|
|
27
|
+
} else {
|
|
28
|
+
return [
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
30
|
+
heading({
|
|
31
|
+
seed: config.seed,
|
|
32
|
+
model: config.model,
|
|
33
|
+
pattern: config.pattern,
|
|
34
|
+
})!,
|
|
35
|
+
] as MockTitleValue<State>;
|
|
36
|
+
}
|
|
24
37
|
};
|
package/src/value/uid.ts
CHANGED
|
@@ -11,8 +11,8 @@ export type MockUIDValueConfig<
|
|
|
11
11
|
|
|
12
12
|
export const uid = (
|
|
13
13
|
config: MockUIDValueConfig = {},
|
|
14
|
-
): prismicT.PrismicDocument["uid"] => {
|
|
14
|
+
): NonNullable<prismicT.PrismicDocument["uid"]> => {
|
|
15
15
|
const faker = createFaker(config.seed);
|
|
16
16
|
|
|
17
|
-
return changeCase.snakeCase(faker.
|
|
17
|
+
return changeCase.snakeCase(faker.words(faker.range(1, 3)));
|
|
18
18
|
};
|
package/dist/api/index.mjs
DELETED
|
@@ -1,515 +0,0 @@
|
|
|
1
|
-
import * as changeCase from 'change-case';
|
|
2
|
-
import * as fakerLocaleEN from 'faker/lib/locales/en/index.js';
|
|
3
|
-
import Faker from 'faker/lib/index.js';
|
|
4
|
-
import * as prismicT from '@prismicio/types';
|
|
5
|
-
|
|
6
|
-
const FAKER_SEED = 1984;
|
|
7
|
-
|
|
8
|
-
const createFaker = (seed = FAKER_SEED) => {
|
|
9
|
-
let normalizedSeed;
|
|
10
|
-
if (typeof seed === "string") {
|
|
11
|
-
normalizedSeed = seed.split("").map((char) => char.charCodeAt(0));
|
|
12
|
-
} else {
|
|
13
|
-
normalizedSeed = seed;
|
|
14
|
-
}
|
|
15
|
-
const cacheKey = JSON.stringify(normalizedSeed);
|
|
16
|
-
if (createFaker.cache[cacheKey]) {
|
|
17
|
-
return createFaker.cache[cacheKey];
|
|
18
|
-
}
|
|
19
|
-
const fakerInstance = new Faker();
|
|
20
|
-
fakerInstance.locales["en"] = fakerLocaleEN;
|
|
21
|
-
fakerInstance.seed(normalizedSeed);
|
|
22
|
-
createFaker.cache[cacheKey] = fakerInstance;
|
|
23
|
-
return fakerInstance;
|
|
24
|
-
};
|
|
25
|
-
createFaker.cache = {};
|
|
26
|
-
|
|
27
|
-
const generateTags = (config) => {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
const faker = createFaker(config.seed);
|
|
30
|
-
return Array(faker.datatype.number({
|
|
31
|
-
min: (_a = config.min) != null ? _a : 0,
|
|
32
|
-
max: (_b = config.max) != null ? _b : 2
|
|
33
|
-
})).fill(void 0).map(() => changeCase.capitalCase(faker.lorem.words(faker.datatype.number({ min: 1, max: 3 }))));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const title = (config = {}) => {
|
|
37
|
-
const faker = createFaker(config.seed);
|
|
38
|
-
const single = faker.random.arrayElements([
|
|
39
|
-
"heading1",
|
|
40
|
-
"heading2",
|
|
41
|
-
"heading3",
|
|
42
|
-
"heading4",
|
|
43
|
-
"heading5",
|
|
44
|
-
"heading6"
|
|
45
|
-
]).join(",");
|
|
46
|
-
return {
|
|
47
|
-
type: prismicT.CustomTypeModelFieldType.StructuredText,
|
|
48
|
-
config: {
|
|
49
|
-
label: changeCase.capitalCase(faker.company.bsNoun()),
|
|
50
|
-
placeholder: changeCase.sentenceCase(faker.lorem.words(3)),
|
|
51
|
-
single,
|
|
52
|
-
allowTargetBlank: faker.datatype.boolean() ? true : void 0
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const timestamp = (config = {}) => {
|
|
58
|
-
const faker = createFaker(config.seed);
|
|
59
|
-
const after = config.after || faker.date.past(20, new Date("2021-03-07")).toISOString().split("T")[0];
|
|
60
|
-
const before = config.before || faker.date.future(20, new Date("2021-03-07")).toISOString().split("T")[0];
|
|
61
|
-
return faker.date.between(after, before).toISOString();
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const buildEmbedField = (config) => {
|
|
65
|
-
const faker = createFaker(config.seed);
|
|
66
|
-
return {
|
|
67
|
-
type: faker.datatype.boolean() ? prismicT.EmbedType.Link : prismicT.EmbedType.Rich,
|
|
68
|
-
url: config.embedData.url,
|
|
69
|
-
html: config.embedData.html,
|
|
70
|
-
title: changeCase.capitalCase(faker.lorem.words(3)),
|
|
71
|
-
version: faker.datatype.number({ min: 1, max: 3, precision: 10 }).toString(),
|
|
72
|
-
cache_age: faker.datatype.number(),
|
|
73
|
-
embed_url: config.embedData.embed_url,
|
|
74
|
-
author_url: faker.internet.url(),
|
|
75
|
-
author_name: faker.company.companyName(),
|
|
76
|
-
provider_name: faker.company.companyName(),
|
|
77
|
-
thumbnail_width: config.embedData.thumbnail_width,
|
|
78
|
-
thumbnail_height: config.embedData.thumbnail_height,
|
|
79
|
-
thumbnail_url: config.embedData.thumbnail_url,
|
|
80
|
-
width: faker.datatype.number({ min: 200, max: 500 }),
|
|
81
|
-
height: faker.datatype.number({ min: 200, max: 500 })
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const dataSet$1 = [
|
|
86
|
-
{
|
|
87
|
-
url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
|
|
88
|
-
embed_url: "https://www.youtube.com/embed/fiOwHYFkUz0",
|
|
89
|
-
thumbnail_url: "https://i.ytimg.com/vi/fiOwHYFkUz0/hqdefault.jpg",
|
|
90
|
-
thumbnail_height: 360,
|
|
91
|
-
thumbnail_width: 480,
|
|
92
|
-
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>'
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
url: "https://www.youtube.com/watch?v=c-ATzcy6VkI",
|
|
96
|
-
embed_url: "https://www.youtube.com/embed/c-ATzcy6VkI",
|
|
97
|
-
thumbnail_url: "https://i.ytimg.com/vi/c-ATzcy6VkI/hqdefault.jpg",
|
|
98
|
-
thumbnail_height: 360,
|
|
99
|
-
thumbnail_width: 480,
|
|
100
|
-
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>'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
url: "https://www.youtube.com/watch?v=iewZXv94XGY",
|
|
104
|
-
embed_url: "https://www.youtube.com/watch?v=fiOwHYFkUz0",
|
|
105
|
-
thumbnail_url: "https://i.ytimg.com/vi/iewZXv94XGY/hqdefault.jpg",
|
|
106
|
-
thumbnail_height: 360,
|
|
107
|
-
thumbnail_width: 480,
|
|
108
|
-
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>'
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
url: "https://twitter.com/prismicio/status/1356293316158095361",
|
|
112
|
-
embed_url: "https://www.youtube.com/watch?v=iewZXv94XGY",
|
|
113
|
-
thumbnail_url: null,
|
|
114
|
-
thumbnail_height: null,
|
|
115
|
-
thumbnail_width: null,
|
|
116
|
-
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'
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
url: "https://twitter.com/timbenniks/status/1304146886832594944",
|
|
120
|
-
thumbnail_url: null,
|
|
121
|
-
thumbnail_width: null,
|
|
122
|
-
thumbnail_height: null,
|
|
123
|
-
embed_url: "https://twitter.com/timbenniks/status/1304146886832594944",
|
|
124
|
-
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'
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
url: "https://twitter.com/prismicio/status/1354112310252630016",
|
|
128
|
-
thumbnail_url: null,
|
|
129
|
-
thumbnail_width: null,
|
|
130
|
-
thumbnail_height: null,
|
|
131
|
-
embed_url: "https://twitter.com/prismicio/status/1354112310252630016",
|
|
132
|
-
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'
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
url: "https://twitter.com/prismicio/status/1354835716430319617",
|
|
136
|
-
thumbnail_url: null,
|
|
137
|
-
thumbnail_width: null,
|
|
138
|
-
thumbnail_height: null,
|
|
139
|
-
embed_url: "https://twitter.com/prismicio/status/1354835716430319617",
|
|
140
|
-
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'
|
|
141
|
-
}
|
|
142
|
-
];
|
|
143
|
-
const getMockEmbedData = (config) => {
|
|
144
|
-
const faker = createFaker(config.seed);
|
|
145
|
-
return faker.random.arrayElement(dataSet$1);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const buildImageField = (config) => {
|
|
149
|
-
var _a, _b, _c, _d;
|
|
150
|
-
const faker = createFaker(config.seed);
|
|
151
|
-
const url = new URL(config.imageData.url);
|
|
152
|
-
const dimensions = {
|
|
153
|
-
width: (_b = (_a = config.constraint) == null ? void 0 : _a.width) != null ? _b : config.imageData.width,
|
|
154
|
-
height: (_d = (_c = config.constraint) == null ? void 0 : _c.height) != null ? _d : config.imageData.height
|
|
155
|
-
};
|
|
156
|
-
url.searchParams.set("w", dimensions.width.toString());
|
|
157
|
-
url.searchParams.set("h", dimensions.height.toString());
|
|
158
|
-
url.searchParams.set("fit", "crop");
|
|
159
|
-
return {
|
|
160
|
-
url: url.toString(),
|
|
161
|
-
dimensions,
|
|
162
|
-
alt: faker.lorem.sentence(),
|
|
163
|
-
copyright: faker.lorem.sentence()
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const dataSet = [
|
|
168
|
-
{
|
|
169
|
-
url: "https://images.unsplash.com/photo-1604537529428-15bcbeecfe4d",
|
|
170
|
-
width: 4240,
|
|
171
|
-
height: 2832
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05",
|
|
175
|
-
width: 7372,
|
|
176
|
-
height: 4392
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
url: "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
|
|
180
|
-
width: 2560,
|
|
181
|
-
height: 1705
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
url: "https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5",
|
|
185
|
-
width: 2200,
|
|
186
|
-
height: 1467
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
url: "https://images.unsplash.com/photo-1426604966848-d7adac402bff",
|
|
190
|
-
width: 5616,
|
|
191
|
-
height: 3744
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
url: "https://images.unsplash.com/photo-1604537466608-109fa2f16c3b",
|
|
195
|
-
width: 4240,
|
|
196
|
-
height: 2832
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
url: "https://images.unsplash.com/photo-1497436072909-60f360e1d4b1",
|
|
200
|
-
width: 2560,
|
|
201
|
-
height: 1440
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
url: "https://images.unsplash.com/reserve/HgZuGu3gSD6db21T3lxm_San%20Zenone.jpg",
|
|
205
|
-
width: 6373,
|
|
206
|
-
height: 4253
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
url: "https://images.unsplash.com/photo-1504198266287-1659872e6590",
|
|
210
|
-
width: 4272,
|
|
211
|
-
height: 2848
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
url: "https://images.unsplash.com/photo-1470770903676-69b98201ea1c",
|
|
215
|
-
width: 4554,
|
|
216
|
-
height: 3036
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
url: "https://images.unsplash.com/photo-1587502537745-84b86da1204f",
|
|
220
|
-
width: 6550,
|
|
221
|
-
height: 4367
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
url: "https://images.unsplash.com/photo-1431794062232-2a99a5431c6c",
|
|
225
|
-
width: 6e3,
|
|
226
|
-
height: 4e3
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
url: "https://images.unsplash.com/photo-1446329813274-7c9036bd9a1f",
|
|
230
|
-
width: 6e3,
|
|
231
|
-
height: 4e3
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
url: "https://images.unsplash.com/photo-1504567961542-e24d9439a724",
|
|
235
|
-
width: 4608,
|
|
236
|
-
height: 3456
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
url: "https://images.unsplash.com/photo-1444464666168-49d633b86797",
|
|
240
|
-
width: 4844,
|
|
241
|
-
height: 3234
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
url: "https://images.unsplash.com/photo-1553531384-397c80973a0b",
|
|
245
|
-
width: 4335,
|
|
246
|
-
height: 6502
|
|
247
|
-
}
|
|
248
|
-
];
|
|
249
|
-
const getMockImageData = (config) => {
|
|
250
|
-
const faker = createFaker(config.seed);
|
|
251
|
-
return faker.random.arrayElement(dataSet);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
const patterns$4 = {
|
|
255
|
-
short: {
|
|
256
|
-
minWords: 1,
|
|
257
|
-
maxWords: 3
|
|
258
|
-
},
|
|
259
|
-
medium: {
|
|
260
|
-
minWords: 3,
|
|
261
|
-
maxWords: 6
|
|
262
|
-
},
|
|
263
|
-
long: {
|
|
264
|
-
minWords: 6,
|
|
265
|
-
maxWords: 12
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
const heading = (config = {}) => {
|
|
269
|
-
const faker = createFaker(config.seed);
|
|
270
|
-
const model = config.model || title({ seed: config.seed });
|
|
271
|
-
const types = ("single" in model.config ? model.config.single : model.config.multi).split(",").filter((type2) => [
|
|
272
|
-
prismicT.RichTextNodeType.heading1,
|
|
273
|
-
prismicT.RichTextNodeType.heading2,
|
|
274
|
-
prismicT.RichTextNodeType.heading3,
|
|
275
|
-
prismicT.RichTextNodeType.heading4,
|
|
276
|
-
prismicT.RichTextNodeType.heading5,
|
|
277
|
-
prismicT.RichTextNodeType.heading6
|
|
278
|
-
].includes(type2));
|
|
279
|
-
const type = faker.random.arrayElement(types);
|
|
280
|
-
if (type) {
|
|
281
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$4));
|
|
282
|
-
const pattern = patterns$4[patternKey];
|
|
283
|
-
return {
|
|
284
|
-
type,
|
|
285
|
-
text: changeCase.capitalCase(faker.lorem.words(faker.datatype.number({
|
|
286
|
-
min: pattern.minWords,
|
|
287
|
-
max: pattern.maxWords
|
|
288
|
-
}))),
|
|
289
|
-
spans: []
|
|
290
|
-
};
|
|
291
|
-
} else {
|
|
292
|
-
return void 0;
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
const patterns$3 = {
|
|
297
|
-
short: {
|
|
298
|
-
sentenceCount: 2
|
|
299
|
-
},
|
|
300
|
-
medium: {
|
|
301
|
-
sentenceCount: 6
|
|
302
|
-
},
|
|
303
|
-
long: {
|
|
304
|
-
sentenceCount: 12
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
const paragraph = (config = {}) => {
|
|
308
|
-
const faker = createFaker(config.seed);
|
|
309
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$3));
|
|
310
|
-
const pattern = patterns$3[patternKey];
|
|
311
|
-
return {
|
|
312
|
-
type: prismicT.RichTextNodeType.paragraph,
|
|
313
|
-
text: faker.lorem.paragraph(pattern.sentenceCount),
|
|
314
|
-
spans: []
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const patterns$2 = {
|
|
319
|
-
short: {
|
|
320
|
-
sentenceCount: 2
|
|
321
|
-
},
|
|
322
|
-
medium: {
|
|
323
|
-
sentenceCount: 6
|
|
324
|
-
},
|
|
325
|
-
long: {
|
|
326
|
-
sentenceCount: 12
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
const preformatted = (config = {}) => {
|
|
330
|
-
const faker = createFaker(config.seed);
|
|
331
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$2));
|
|
332
|
-
const pattern = patterns$2[patternKey];
|
|
333
|
-
return {
|
|
334
|
-
type: prismicT.RichTextNodeType.preformatted,
|
|
335
|
-
text: faker.lorem.paragraph(pattern.sentenceCount),
|
|
336
|
-
spans: []
|
|
337
|
-
};
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
const patterns$1 = {
|
|
341
|
-
short: {
|
|
342
|
-
minItems: 1,
|
|
343
|
-
maxItems: 3
|
|
344
|
-
},
|
|
345
|
-
medium: {
|
|
346
|
-
minItems: 3,
|
|
347
|
-
maxItems: 6
|
|
348
|
-
},
|
|
349
|
-
long: {
|
|
350
|
-
minItems: 6,
|
|
351
|
-
maxItems: 12
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
const list = (config = {}) => {
|
|
355
|
-
const faker = createFaker(config.seed);
|
|
356
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns$1));
|
|
357
|
-
const pattern = patterns$1[patternKey];
|
|
358
|
-
const itemsCount = faker.datatype.number({
|
|
359
|
-
min: pattern.minItems,
|
|
360
|
-
max: pattern.maxItems
|
|
361
|
-
});
|
|
362
|
-
return Array(itemsCount).fill(void 0).map(() => {
|
|
363
|
-
return {
|
|
364
|
-
type: prismicT.RichTextNodeType.listItem,
|
|
365
|
-
text: faker.lorem.sentence(),
|
|
366
|
-
spans: []
|
|
367
|
-
};
|
|
368
|
-
});
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
const patterns = {
|
|
372
|
-
short: {
|
|
373
|
-
minItems: 1,
|
|
374
|
-
maxItems: 3
|
|
375
|
-
},
|
|
376
|
-
medium: {
|
|
377
|
-
minItems: 3,
|
|
378
|
-
maxItems: 6
|
|
379
|
-
},
|
|
380
|
-
long: {
|
|
381
|
-
minItems: 6,
|
|
382
|
-
maxItems: 12
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
const oList = (config = {}) => {
|
|
386
|
-
const faker = createFaker(config.seed);
|
|
387
|
-
const patternKey = config.pattern || faker.random.arrayElement(Object.keys(patterns));
|
|
388
|
-
const pattern = patterns[patternKey];
|
|
389
|
-
const itemsCount = faker.datatype.number({
|
|
390
|
-
min: pattern.minItems,
|
|
391
|
-
max: pattern.maxItems
|
|
392
|
-
});
|
|
393
|
-
return Array(itemsCount).fill(void 0).map(() => {
|
|
394
|
-
return {
|
|
395
|
-
type: prismicT.RichTextNodeType.oListItem,
|
|
396
|
-
text: faker.lorem.sentence(),
|
|
397
|
-
spans: []
|
|
398
|
-
};
|
|
399
|
-
});
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
const image = (config = {}) => {
|
|
403
|
-
const imageData = getMockImageData({ seed: config.seed });
|
|
404
|
-
const imageField = buildImageField({ seed: config.seed, imageData });
|
|
405
|
-
return {
|
|
406
|
-
type: prismicT.RichTextNodeType.image,
|
|
407
|
-
alt: imageField.alt,
|
|
408
|
-
url: imageField.url,
|
|
409
|
-
copyright: imageField.copyright,
|
|
410
|
-
dimensions: imageField.dimensions
|
|
411
|
-
};
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
const embed = (config = {}) => {
|
|
415
|
-
const embedData = getMockEmbedData({ seed: config.seed });
|
|
416
|
-
const embedField = buildEmbedField({ seed: config.seed, embedData });
|
|
417
|
-
return {
|
|
418
|
-
type: prismicT.RichTextNodeType.embed,
|
|
419
|
-
oembed: embedField
|
|
420
|
-
};
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
({
|
|
424
|
-
[prismicT.RichTextNodeType.heading1]: heading,
|
|
425
|
-
[prismicT.RichTextNodeType.heading2]: heading,
|
|
426
|
-
[prismicT.RichTextNodeType.heading3]: heading,
|
|
427
|
-
[prismicT.RichTextNodeType.heading4]: heading,
|
|
428
|
-
[prismicT.RichTextNodeType.heading5]: heading,
|
|
429
|
-
[prismicT.RichTextNodeType.heading6]: heading,
|
|
430
|
-
[prismicT.RichTextNodeType.paragraph]: paragraph,
|
|
431
|
-
[prismicT.RichTextNodeType.preformatted]: preformatted,
|
|
432
|
-
[prismicT.RichTextNodeType.listItem]: list,
|
|
433
|
-
[prismicT.RichTextNodeType.oListItem]: oList,
|
|
434
|
-
[prismicT.RichTextNodeType.image]: image,
|
|
435
|
-
[prismicT.RichTextNodeType.embed]: embed
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
const ref = (config = {}) => {
|
|
439
|
-
var _a;
|
|
440
|
-
const faker = createFaker(config.seed);
|
|
441
|
-
const value = {
|
|
442
|
-
id: faker.git.shortSha(),
|
|
443
|
-
ref: faker.git.shortSha(),
|
|
444
|
-
isMasterRef: (_a = config.isMasterRef) != null ? _a : false,
|
|
445
|
-
label: config.isMasterRef ? "Master" : changeCase.capitalCase(faker.company.bsNoun())
|
|
446
|
-
};
|
|
447
|
-
if (config.isScheduled) {
|
|
448
|
-
value.scheduledAt = timestamp({ seed: config.seed });
|
|
449
|
-
}
|
|
450
|
-
return value;
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
const repository = (config = {}) => {
|
|
454
|
-
const faker = createFaker(config.seed);
|
|
455
|
-
const types = (config.customTypeModels || []).reduce((acc, model) => {
|
|
456
|
-
acc[model.id] = model.label;
|
|
457
|
-
return acc;
|
|
458
|
-
}, {});
|
|
459
|
-
return {
|
|
460
|
-
refs: [
|
|
461
|
-
ref({ seed: config.seed, isMasterRef: true }),
|
|
462
|
-
...config.withReleases ? [ref({ seed: config.seed }), ref({ seed: config.seed })] : []
|
|
463
|
-
],
|
|
464
|
-
integrationFieldsRef: ref({ seed: config.seed }).ref,
|
|
465
|
-
types,
|
|
466
|
-
languages: [
|
|
467
|
-
{
|
|
468
|
-
id: faker.lorem.word(),
|
|
469
|
-
name: changeCase.capitalCase(faker.lorem.word())
|
|
470
|
-
}
|
|
471
|
-
],
|
|
472
|
-
tags: generateTags({
|
|
473
|
-
seed: config.seed,
|
|
474
|
-
min: 1,
|
|
475
|
-
max: 10
|
|
476
|
-
}),
|
|
477
|
-
forms: {},
|
|
478
|
-
license: "All Rights Reserved",
|
|
479
|
-
version: faker.git.shortSha(),
|
|
480
|
-
bookmarks: {},
|
|
481
|
-
experiments: {},
|
|
482
|
-
oauth_token: faker.internet.url(),
|
|
483
|
-
oauth_initiate: faker.internet.url()
|
|
484
|
-
};
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
const query = (config = {}) => {
|
|
488
|
-
var _a, _b;
|
|
489
|
-
const faker = createFaker(config.seed);
|
|
490
|
-
const documents = config.documents || [];
|
|
491
|
-
const page = Math.max(1, (_a = config.page) != null ? _a : 1);
|
|
492
|
-
const pageSize = Math.min(100, Math.max(1, (_b = config.pageSize) != null ? _b : 100));
|
|
493
|
-
const totalPages = Math.ceil(documents.length / pageSize);
|
|
494
|
-
const results = documents.slice((page - 1) * pageSize, page * pageSize);
|
|
495
|
-
return {
|
|
496
|
-
page,
|
|
497
|
-
next_page: page < totalPages ? faker.internet.url() : null,
|
|
498
|
-
prev_page: page > 1 ? faker.internet.url() : null,
|
|
499
|
-
total_pages: totalPages,
|
|
500
|
-
results_size: results.length,
|
|
501
|
-
results_per_page: pageSize,
|
|
502
|
-
total_results_size: documents.length,
|
|
503
|
-
results
|
|
504
|
-
};
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
const tags = (config = {}) => {
|
|
508
|
-
return generateTags({
|
|
509
|
-
seed: config.seed,
|
|
510
|
-
min: 1,
|
|
511
|
-
max: 10
|
|
512
|
-
});
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
export { query, ref, repository, tags };
|