1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.nodeSchema = exports.pageSchema = exports.gatsbyConfigSchema = void 0;
|
5 |
|
6 | const Joi = require(`@hapi/joi`);
|
7 |
|
8 | const stripTrailingSlash = chain => chain.replace(/(\w)\/+$/, `$1`);
|
9 |
|
10 |
|
11 | const addLeadingSlash = chain => chain.when(Joi.string().uri({
|
12 | relativeOnly: true
|
13 | }), {
|
14 | then: chain.replace(/^([^/])/, `/$1`)
|
15 | });
|
16 |
|
17 | const gatsbyConfigSchema = Joi.object().keys({
|
18 | __experimentalThemes: Joi.array(),
|
19 | polyfill: Joi.boolean().default(true),
|
20 | assetPrefix: stripTrailingSlash(Joi.string().uri({
|
21 | allowRelative: true
|
22 | })),
|
23 | pathPrefix: addLeadingSlash(stripTrailingSlash(Joi.string().uri({
|
24 | allowRelative: true,
|
25 | relativeOnly: true
|
26 | }).default(``)
|
27 | .allow(``).replace(/^\/$/, ``))),
|
28 | siteMetadata: Joi.object({
|
29 | siteUrl: stripTrailingSlash(Joi.string()).uri()
|
30 | }).unknown(),
|
31 | mapping: Joi.object(),
|
32 | plugins: Joi.array(),
|
33 | proxy: Joi.array().items(Joi.object().keys({
|
34 | prefix: Joi.string().required(),
|
35 | url: Joi.string().required()
|
36 | })).single(),
|
37 | developMiddleware: Joi.func()
|
38 | })
|
39 | .when(Joi.object({
|
40 | assetPrefix: Joi.string().uri({
|
41 | allowRelative: true,
|
42 | relativeOnly: true
|
43 | }),
|
44 | pathPrefix: Joi.string().uri({
|
45 | allowRelative: true,
|
46 | relativeOnly: true
|
47 | }).default(``)
|
48 | }), {
|
49 | then: Joi.object({
|
50 | assetPrefix: Joi.string().uri({
|
51 | allowRelative: false
|
52 | }).error(new Error(`assetPrefix must be an absolute URI when used with pathPrefix`))
|
53 | })
|
54 | });
|
55 | exports.gatsbyConfigSchema = gatsbyConfigSchema;
|
56 | const pageSchema = Joi.object().keys({
|
57 | path: Joi.string().required(),
|
58 | matchPath: Joi.string(),
|
59 | component: Joi.string().required(),
|
60 | componentChunkName: Joi.string().required(),
|
61 | context: Joi.object(),
|
62 | pluginCreator___NODE: Joi.string(),
|
63 | pluginCreatorId: Joi.string()
|
64 | }).unknown();
|
65 | exports.pageSchema = pageSchema;
|
66 | const nodeSchema = Joi.object().keys({
|
67 | id: Joi.string().required(),
|
68 | children: Joi.array().items(Joi.string(), Joi.object().forbidden()),
|
69 | parent: Joi.string().allow(null),
|
70 | fields: Joi.object(),
|
71 | internal: Joi.object().keys({
|
72 | contentDigest: Joi.string().required(),
|
73 | mediaType: Joi.string(),
|
74 | type: Joi.string().required(),
|
75 | owner: Joi.string().required(),
|
76 | fieldOwners: Joi.object(),
|
77 | content: Joi.string().allow(``),
|
78 | description: Joi.string(),
|
79 | ignoreType: Joi.boolean(),
|
80 | counter: Joi.number()
|
81 | }).unknown(false)
|
82 |
|
83 | }).unknown();
|
84 | exports.nodeSchema = nodeSchema;
|
85 |
|
\ | No newline at end of file |