fix(deps): update dependency ajv to v7 (#4748)
This commit is contained in:
parent
a18e4286f0
commit
a3f95b0d24
@ -26,9 +26,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iarna/toml": "2.2.5",
|
"@iarna/toml": "2.2.5",
|
||||||
"ajv": "^6.10.0",
|
"ajv": "^7.0.0",
|
||||||
"ajv-errors": "^1.0.1",
|
"ajv-errors": "^2.0.0",
|
||||||
"ajv-keywords": "^3.4.1",
|
"ajv-keywords": "^4.0.0",
|
||||||
"connected-react-router": "^6.8.0",
|
"connected-react-router": "^6.8.0",
|
||||||
"copy-text-to-clipboard": "^2.0.0",
|
"copy-text-to-clipboard": "^2.0.0",
|
||||||
"diacritics": "^1.3.0",
|
"diacritics": "^1.3.0",
|
||||||
|
@ -334,7 +334,9 @@ describe('config', () => {
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}).toThrowError("'search_fields' should be array\n'display_fields' should be array");
|
}).toThrowError(
|
||||||
|
"'collections[0].fields[1].fields[1].search_fields' should be array\n'collections[0].fields[1].fields[1].display_fields' should be array",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw if nested relation display_fields and search_fields are arrays', () => {
|
it('should not throw if nested relation display_fields and search_fields are arrays', () => {
|
||||||
@ -378,7 +380,7 @@ describe('config', () => {
|
|||||||
it('should throw if collection meta is an empty object', () => {
|
it('should throw if collection meta is an empty object', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
validateConfig(merge({}, validConfig, { collections: [{ meta: {} }] }));
|
validateConfig(merge({}, validConfig, { collections: [{ meta: {} }] }));
|
||||||
}).toThrowError("'collections[0].meta' should NOT have fewer than 1 properties");
|
}).toThrowError("'collections[0].meta' should NOT have fewer than 1 items");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if collection meta is an empty object', () => {
|
it('should throw if collection meta is an empty object', () => {
|
||||||
@ -475,7 +477,7 @@ describe('config', () => {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}).toThrowError(`'i18n.locales[1]' should NOT be shorter than 2 characters`);
|
}).toThrowError(`'i18n.locales[1]' should NOT have fewer than 2 characters`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error when locale is more than 10 characters', () => {
|
it('should throw error when locale is more than 10 characters', () => {
|
||||||
@ -488,7 +490,7 @@ describe('config', () => {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}).toThrowError(`'i18n.locales[1]' should NOT be longer than 10 characters`);
|
}).toThrowError(`'i18n.locales[1]' should NOT have more than 10 characters`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow valid locales strings', () => {
|
it('should allow valid locales strings', () => {
|
||||||
|
@ -4,10 +4,11 @@ import {
|
|||||||
uniqueItemProperties,
|
uniqueItemProperties,
|
||||||
instanceof as instanceOf,
|
instanceof as instanceOf,
|
||||||
prohibited,
|
prohibited,
|
||||||
} from 'ajv-keywords/keywords';
|
} from 'ajv-keywords/dist/keywords';
|
||||||
import ajvErrors from 'ajv-errors';
|
import ajvErrors from 'ajv-errors';
|
||||||
import { formatExtensions, frontmatterFormats, extensionFormatters } from 'Formats/formats';
|
import { formatExtensions, frontmatterFormats, extensionFormatters } from 'Formats/formats';
|
||||||
import { getWidgets } from 'Lib/registry';
|
import { getWidgets } from 'Lib/registry';
|
||||||
|
import uuid from 'uuid/v4';
|
||||||
import { I18N_STRUCTURE, I18N_FIELD } from '../lib/i18n';
|
import { I18N_STRUCTURE, I18N_FIELD } from '../lib/i18n';
|
||||||
|
|
||||||
const localeType = { type: 'string', minLength: 2, maxLength: 10, pattern: '^[a-zA-Z-_]+$' };
|
const localeType = { type: 'string', minLength: 2, maxLength: 10, pattern: '^[a-zA-Z-_]+$' };
|
||||||
@ -42,38 +43,41 @@ const i18nField = {
|
|||||||
/**
|
/**
|
||||||
* Config for fields in both file and folder collections.
|
* Config for fields in both file and folder collections.
|
||||||
*/
|
*/
|
||||||
const fieldsConfig = () => ({
|
const fieldsConfig = () => {
|
||||||
$id: 'fields',
|
const id = uuid();
|
||||||
type: 'array',
|
return {
|
||||||
minItems: 1,
|
$id: `fields_${id}`,
|
||||||
items: {
|
type: 'array',
|
||||||
// ------- Each field: -------
|
minItems: 1,
|
||||||
$id: 'field',
|
items: {
|
||||||
type: 'object',
|
// ------- Each field: -------
|
||||||
properties: {
|
$id: `field_${id}`,
|
||||||
name: { type: 'string' },
|
type: 'object',
|
||||||
label: { type: 'string' },
|
properties: {
|
||||||
widget: { type: 'string' },
|
name: { type: 'string' },
|
||||||
required: { type: 'boolean' },
|
label: { type: 'string' },
|
||||||
i18n: i18nField,
|
widget: { type: 'string' },
|
||||||
hint: { type: 'string' },
|
required: { type: 'boolean' },
|
||||||
pattern: {
|
i18n: i18nField,
|
||||||
type: 'array',
|
hint: { type: 'string' },
|
||||||
minItems: 2,
|
pattern: {
|
||||||
items: [{ oneOf: [{ type: 'string' }, { instanceof: 'RegExp' }] }, { type: 'string' }],
|
type: 'array',
|
||||||
|
minItems: 2,
|
||||||
|
items: [{ oneOf: [{ type: 'string' }, { instanceof: 'RegExp' }] }, { type: 'string' }],
|
||||||
|
},
|
||||||
|
field: { $ref: `field_${id}` },
|
||||||
|
fields: { $ref: `fields_${id}` },
|
||||||
|
types: { $ref: `fields_${id}` },
|
||||||
},
|
},
|
||||||
field: { $ref: 'field' },
|
select: { $data: '0/widget' },
|
||||||
fields: { $ref: 'fields' },
|
selectCases: {
|
||||||
types: { $ref: 'fields' },
|
...getWidgetSchemas(),
|
||||||
|
},
|
||||||
|
required: ['name'],
|
||||||
},
|
},
|
||||||
select: { $data: '0/widget' },
|
uniqueItemProperties: ['name'],
|
||||||
selectCases: {
|
};
|
||||||
...getWidgetSchemas(),
|
};
|
||||||
},
|
|
||||||
required: ['name'],
|
|
||||||
},
|
|
||||||
uniqueItemProperties: ['name'],
|
|
||||||
});
|
|
||||||
|
|
||||||
const viewFilters = {
|
const viewFilters = {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
@ -347,7 +351,7 @@ class ConfigError extends Error {
|
|||||||
* the config that is passed in.
|
* the config that is passed in.
|
||||||
*/
|
*/
|
||||||
export function validateConfig(config) {
|
export function validateConfig(config) {
|
||||||
const ajv = new AJV({ allErrors: true, jsonPointers: true, $data: true });
|
const ajv = new AJV({ allErrors: true, jsonPointers: true, $data: true, strict: false });
|
||||||
uniqueItemProperties(ajv);
|
uniqueItemProperties(ajv);
|
||||||
select(ajv);
|
select(ajv);
|
||||||
instanceOf(ajv);
|
instanceOf(ajv);
|
||||||
|
32
yarn.lock
32
yarn.lock
@ -3971,16 +3971,26 @@ airbnb-js-shims@^2.2.1:
|
|||||||
string.prototype.padstart "^3.0.0"
|
string.prototype.padstart "^3.0.0"
|
||||||
symbol.prototype.description "^1.0.0"
|
symbol.prototype.description "^1.0.0"
|
||||||
|
|
||||||
ajv-errors@^1.0.0, ajv-errors@^1.0.1:
|
ajv-errors@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
|
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
|
||||||
integrity sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==
|
integrity sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==
|
||||||
|
|
||||||
|
ajv-errors@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-2.0.0.tgz#d48231d8de44bf52c517bbfcb298bb628ead4f89"
|
||||||
|
integrity sha512-Qi+I07e2Kc7Tgza7cZMvROyWuWmandN0BLbAiQUGLAMN/IfwIyg5kjg1qz/+q7p+uJ/x3THplnuGmihg/+WnXg==
|
||||||
|
|
||||||
ajv-keywords@^3.1.0, ajv-keywords@^3.4.1, ajv-keywords@^3.5.2:
|
ajv-keywords@^3.1.0, ajv-keywords@^3.4.1, ajv-keywords@^3.5.2:
|
||||||
version "3.5.2"
|
version "3.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
|
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
|
||||||
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==
|
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==
|
||||||
|
|
||||||
|
ajv-keywords@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-4.0.0.tgz#d0ffb23189d5002b234ad54c1a1b620a5398db58"
|
||||||
|
integrity sha512-baL4pEYniCF5E/5Cj28f1DmPXGGASQIeCFfntY94vJPtrq0fei3iNt/TP5f2IwEH4opCzcOOvL6hKsi2IHaecg==
|
||||||
|
|
||||||
ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
|
ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
|
||||||
version "6.12.6"
|
version "6.12.6"
|
||||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
|
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
|
||||||
@ -3991,6 +4001,16 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
|
|||||||
json-schema-traverse "^0.4.1"
|
json-schema-traverse "^0.4.1"
|
||||||
uri-js "^4.2.2"
|
uri-js "^4.2.2"
|
||||||
|
|
||||||
|
ajv@^7.0.0:
|
||||||
|
version "7.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/ajv/-/ajv-7.0.2.tgz#04ccc89a93449c64382fe0846d45a7135d986dbc"
|
||||||
|
integrity sha512-qIaxO9RXjaXyO21tJr0EvwPcZa49m64GcXCU8ZrLjCAlFyMuOcPpI560So4A11M1WsKslJYIXn6jSyG5P0xIeg==
|
||||||
|
dependencies:
|
||||||
|
fast-deep-equal "^3.1.1"
|
||||||
|
json-schema-traverse "^1.0.0"
|
||||||
|
require-from-string "^2.0.2"
|
||||||
|
uri-js "^4.2.2"
|
||||||
|
|
||||||
all-contributors-cli@^6.0.0:
|
all-contributors-cli@^6.0.0:
|
||||||
version "6.19.0"
|
version "6.19.0"
|
||||||
resolved "https://registry.yarnpkg.com/all-contributors-cli/-/all-contributors-cli-6.19.0.tgz#7e4550973afede2476b62bd159fee6d72a1ad802"
|
resolved "https://registry.yarnpkg.com/all-contributors-cli/-/all-contributors-cli-6.19.0.tgz#7e4550973afede2476b62bd159fee6d72a1ad802"
|
||||||
@ -11293,6 +11313,11 @@ json-schema-traverse@^0.4.1:
|
|||||||
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
|
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
|
||||||
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
|
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
|
||||||
|
|
||||||
|
json-schema-traverse@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
|
||||||
|
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
|
||||||
|
|
||||||
json-schema@0.2.3:
|
json-schema@0.2.3:
|
||||||
version "0.2.3"
|
version "0.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
|
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
|
||||||
@ -15469,6 +15494,11 @@ require-directory@^2.1.1:
|
|||||||
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
|
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
|
||||||
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
|
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
|
||||||
|
|
||||||
|
require-from-string@^2.0.2:
|
||||||
|
version "2.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
|
||||||
|
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==
|
||||||
|
|
||||||
require-main-filename@^2.0.0:
|
require-main-filename@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
|
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user