@webiny/app-headless-cms-common 6.3.0-beta.1 → 6.3.0-beta.3
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/createValidators.js +1 -1
- package/createValidators.js.map +1 -1
- package/package.json +15 -12
package/createValidators.js
CHANGED
|
@@ -33,7 +33,7 @@ export const createValidators = (field, validation) => {
|
|
|
33
33
|
validator: item
|
|
34
34
|
});
|
|
35
35
|
Object.keys(variables).forEach(key => {
|
|
36
|
-
const regex = new RegExp(
|
|
36
|
+
const regex = new RegExp(`{${key}}`, "g");
|
|
37
37
|
interpolated = interpolated.replace(regex, variables[key]);
|
|
38
38
|
});
|
|
39
39
|
}
|
package/createValidators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["plugins","camelCase","createValidators","field","validation","validatorPlugins","byType","reduce","collection","item","validatorPlugin","find","plugin","validator","name","validate","value","isInvalid","message","result","e","interpolated","getVariableValues","variables","Object","keys","forEach","key","regex","RegExp","replace","Error","validatorName","push"],"sources":["createValidators.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport type {\n CmsModelField,\n CmsModelFieldValidator,\n CmsModelFieldValidatorPlugin\n} from \"~/types/index.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nexport const createValidators = (\n field: CmsModelField,\n validation: (CmsModelFieldValidator | Validator)[]\n): Validator[] => {\n const validatorPlugins = plugins.byType<CmsModelFieldValidatorPlugin>(\n \"cms-model-field-validator\"\n );\n\n return validation.reduce<Validator[]>((collection, item) => {\n if (typeof item === \"function\") {\n return [...collection, item];\n }\n\n const validatorPlugin = validatorPlugins.find(\n plugin => plugin.validator.name === item.name\n );\n\n if (!validatorPlugin || typeof validatorPlugin.validator.validate !== \"function\") {\n return collection;\n }\n\n const validator = async (value: any | any[]) => {\n let isInvalid;\n let message = item.message;\n try {\n const result = await validatorPlugin.validator.validate(value, {\n validator: item,\n field\n });\n\n isInvalid = result === false;\n } catch (e) {\n isInvalid = true;\n if (e.message && !item.message) {\n message = e.message;\n }\n }\n\n if (isInvalid) {\n let interpolated = message || \"Invalid value.\";\n\n const getVariableValues = validatorPlugin.validator.getVariableValues;\n if (typeof getVariableValues === \"function\") {\n const variables = getVariableValues({ validator: item });\n\n Object.keys(variables).forEach(key => {\n const regex = new RegExp(
|
|
1
|
+
{"version":3,"names":["plugins","camelCase","createValidators","field","validation","validatorPlugins","byType","reduce","collection","item","validatorPlugin","find","plugin","validator","name","validate","value","isInvalid","message","result","e","interpolated","getVariableValues","variables","Object","keys","forEach","key","regex","RegExp","replace","Error","validatorName","push"],"sources":["createValidators.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport type {\n CmsModelField,\n CmsModelFieldValidator,\n CmsModelFieldValidatorPlugin\n} from \"~/types/index.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nexport const createValidators = (\n field: CmsModelField,\n validation: (CmsModelFieldValidator | Validator)[]\n): Validator[] => {\n const validatorPlugins = plugins.byType<CmsModelFieldValidatorPlugin>(\n \"cms-model-field-validator\"\n );\n\n return validation.reduce<Validator[]>((collection, item) => {\n if (typeof item === \"function\") {\n return [...collection, item];\n }\n\n const validatorPlugin = validatorPlugins.find(\n plugin => plugin.validator.name === item.name\n );\n\n if (!validatorPlugin || typeof validatorPlugin.validator.validate !== \"function\") {\n return collection;\n }\n\n const validator = async (value: any | any[]) => {\n let isInvalid;\n let message = item.message;\n try {\n const result = await validatorPlugin.validator.validate(value, {\n validator: item,\n field\n });\n\n isInvalid = result === false;\n } catch (e) {\n isInvalid = true;\n if (e.message && !item.message) {\n message = e.message;\n }\n }\n\n if (isInvalid) {\n let interpolated = message || \"Invalid value.\";\n\n const getVariableValues = validatorPlugin.validator.getVariableValues;\n if (typeof getVariableValues === \"function\") {\n const variables = getVariableValues({ validator: item });\n\n Object.keys(variables).forEach(key => {\n const regex = new RegExp(`{${key}}`, \"g\");\n interpolated = interpolated.replace(regex, variables[key]);\n });\n }\n\n throw new Error(interpolated);\n }\n };\n /**\n * We need to set the validator name because it will be used as the reference to skip, if necessary.\n */\n validator.validatorName = camelCase(validatorPlugin.validator.name);\n\n collection.push(validator);\n return collection;\n }, [] as Validator[]);\n};\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AAOzC,OAAOC,SAAS,MAAM,qBAAqB;AAE3C,OAAO,MAAMC,gBAAgB,GAAGA,CAC5BC,KAAoB,EACpBC,UAAkD,KACpC;EACd,MAAMC,gBAAgB,GAAGL,OAAO,CAACM,MAAM,CACnC,2BACJ,CAAC;EAED,OAAOF,UAAU,CAACG,MAAM,CAAc,CAACC,UAAU,EAAEC,IAAI,KAAK;IACxD,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;MAC5B,OAAO,CAAC,GAAGD,UAAU,EAAEC,IAAI,CAAC;IAChC;IAEA,MAAMC,eAAe,GAAGL,gBAAgB,CAACM,IAAI,CACzCC,MAAM,IAAIA,MAAM,CAACC,SAAS,CAACC,IAAI,KAAKL,IAAI,CAACK,IAC7C,CAAC;IAED,IAAI,CAACJ,eAAe,IAAI,OAAOA,eAAe,CAACG,SAAS,CAACE,QAAQ,KAAK,UAAU,EAAE;MAC9E,OAAOP,UAAU;IACrB;IAEA,MAAMK,SAAS,GAAG,MAAOG,KAAkB,IAAK;MAC5C,IAAIC,SAAS;MACb,IAAIC,OAAO,GAAGT,IAAI,CAACS,OAAO;MAC1B,IAAI;QACA,MAAMC,MAAM,GAAG,MAAMT,eAAe,CAACG,SAAS,CAACE,QAAQ,CAACC,KAAK,EAAE;UAC3DH,SAAS,EAAEJ,IAAI;UACfN;QACJ,CAAC,CAAC;QAEFc,SAAS,GAAGE,MAAM,KAAK,KAAK;MAChC,CAAC,CAAC,OAAOC,CAAC,EAAE;QACRH,SAAS,GAAG,IAAI;QAChB,IAAIG,CAAC,CAACF,OAAO,IAAI,CAACT,IAAI,CAACS,OAAO,EAAE;UAC5BA,OAAO,GAAGE,CAAC,CAACF,OAAO;QACvB;MACJ;MAEA,IAAID,SAAS,EAAE;QACX,IAAII,YAAY,GAAGH,OAAO,IAAI,gBAAgB;QAE9C,MAAMI,iBAAiB,GAAGZ,eAAe,CAACG,SAAS,CAACS,iBAAiB;QACrE,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;UACzC,MAAMC,SAAS,GAAGD,iBAAiB,CAAC;YAAET,SAAS,EAAEJ;UAAK,CAAC,CAAC;UAExDe,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC,CAACG,OAAO,CAACC,GAAG,IAAI;YAClC,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAAC,IAAIF,GAAG,GAAG,EAAE,GAAG,CAAC;YACzCN,YAAY,GAAGA,YAAY,CAACS,OAAO,CAACF,KAAK,EAAEL,SAAS,CAACI,GAAG,CAAC,CAAC;UAC9D,CAAC,CAAC;QACN;QAEA,MAAM,IAAII,KAAK,CAACV,YAAY,CAAC;MACjC;IACJ,CAAC;IACD;AACR;AACA;IACQR,SAAS,CAACmB,aAAa,GAAG/B,SAAS,CAACS,eAAe,CAACG,SAAS,CAACC,IAAI,CAAC;IAEnEN,UAAU,CAACyB,IAAI,CAACpB,SAAS,CAAC;IAC1B,OAAOL,UAAU;EACrB,CAAC,EAAE,EAAiB,CAAC;AACzB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms-common",
|
|
3
|
-
"version": "6.3.0-beta.
|
|
3
|
+
"version": "6.3.0-beta.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -17,14 +20,14 @@
|
|
|
17
20
|
"@emotion/react": "11.14.0",
|
|
18
21
|
"@emotion/styled": "11.14.1",
|
|
19
22
|
"@fortawesome/fontawesome-svg-core": "7.2.0",
|
|
20
|
-
"@fortawesome/react-fontawesome": "3.3.
|
|
21
|
-
"@webiny/admin-ui": "6.3.0-beta.
|
|
22
|
-
"@webiny/app": "6.3.0-beta.
|
|
23
|
-
"@webiny/app-admin": "6.3.0-beta.
|
|
24
|
-
"@webiny/form": "6.3.0-beta.
|
|
25
|
-
"@webiny/plugins": "6.3.0-beta.
|
|
26
|
-
"@webiny/react-composition": "6.3.0-beta.
|
|
27
|
-
"@webiny/validation": "6.3.0-beta.
|
|
23
|
+
"@fortawesome/react-fontawesome": "3.3.1",
|
|
24
|
+
"@webiny/admin-ui": "6.3.0-beta.3",
|
|
25
|
+
"@webiny/app": "6.3.0-beta.3",
|
|
26
|
+
"@webiny/app-admin": "6.3.0-beta.3",
|
|
27
|
+
"@webiny/form": "6.3.0-beta.3",
|
|
28
|
+
"@webiny/plugins": "6.3.0-beta.3",
|
|
29
|
+
"@webiny/react-composition": "6.3.0-beta.3",
|
|
30
|
+
"@webiny/validation": "6.3.0-beta.3",
|
|
28
31
|
"dnd-core": "16.0.1",
|
|
29
32
|
"graphql": "16.13.2",
|
|
30
33
|
"graphql-tag": "2.12.6",
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
"devDependencies": {
|
|
35
38
|
"@emotion/babel-plugin": "11.13.5",
|
|
36
39
|
"@types/react": "18.3.28",
|
|
37
|
-
"@webiny/build-tools": "6.3.0-beta.
|
|
40
|
+
"@webiny/build-tools": "6.3.0-beta.3",
|
|
38
41
|
"babel-plugin-module-resolver": "5.0.3",
|
|
39
42
|
"rimraf": "6.1.3",
|
|
40
43
|
"typescript": "6.0.3"
|
|
@@ -43,5 +46,5 @@
|
|
|
43
46
|
"access": "public",
|
|
44
47
|
"directory": "dist"
|
|
45
48
|
},
|
|
46
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e154ec3326903876c357d35422dc60d29e061419"
|
|
47
50
|
}
|