From 40a8948f1b93c2deae49054b783a993d11b280b2 Mon Sep 17 00:00:00 2001 From: brennj Date: Tue, 22 Aug 2023 13:45:48 +0200 Subject: [PATCH 01/10] chore: current work --- package-lock.json | 448 ++++++++++++++-------------- src/createHeadlessForm.js | 19 +- src/helpers.js | 2 +- src/jsonLogic.js | 12 +- src/tests/const.test.js | 58 ++++ src/tests/jsonLogic.test.js | 343 +++++++++++++++++++++ src/tests/jsonLogicFixtures.js | 528 +++++++++++++++++++++++++++++++++ src/yupSchema.js | 40 ++- 8 files changed, 1204 insertions(+), 246 deletions(-) create mode 100644 src/tests/const.test.js diff --git a/package-lock.json b/package-lock.json index c0e99e7af..1a4e90cbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,42 +54,42 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", + "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", "dev": true, "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/compat-data": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.5.tgz", - "integrity": "sha512-M+XAiQ7GzQ3FDPf0KOLkugzptnIypt0X0ma0wmlTKPR3IchgNFdx2JXxZdvd18JY5s7QkaFD/qyX0dsMpog/Ug==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", + "integrity": "sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.5.tgz", - "integrity": "sha512-9M398B/QH5DlfCOTKDZT1ozXr0x8uBEeFd+dJraGUZGiaNpGCDVGCc14hZexsMblw3XxltJ+6kSvogp9J+5a9g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.5.tgz", + "integrity": "sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-compilation-targets": "^7.21.5", - "@babel/helper-module-transforms": "^7.21.5", - "@babel/helpers": "^7.21.5", - "@babel/parser": "^7.21.5", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5", + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.5", + "@babel/helper-compilation-targets": "^7.22.5", + "@babel/helper-module-transforms": "^7.22.5", + "@babel/helpers": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -120,12 +120,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.5.tgz", - "integrity": "sha512-SrKK/sRv8GesIW1bDagf9cCG38IOMYZusoe1dfg0D8aiUe3Amvoj1QtjTPAWcfrZFvIwlleLb0gxzQidL9w14w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.5.tgz", + "integrity": "sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA==", "dev": true, "dependencies": { - "@babel/types": "^7.21.5", + "@babel/types": "^7.22.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -174,13 +174,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.5.tgz", - "integrity": "sha512-1RkbFGUKex4lvsB9yhIfWltJM5cZKUftB2eNajaDv3dCMEp49iBG0K14uH8NnX9IPux2+mK7JGEOB0jn48/J6w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz", + "integrity": "sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.21.5", - "@babel/helper-validator-option": "^7.21.0", + "@babel/compat-data": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" @@ -266,9 +266,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", - "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", "dev": true, "engines": { "node": ">=6.9.0" @@ -287,25 +287,25 @@ } }, "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", "dev": true, "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -324,31 +324,31 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", - "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", + "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", "dev": true, "dependencies": { - "@babel/types": "^7.21.4" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.5.tgz", - "integrity": "sha512-bI2Z9zBGY2q5yMHoBvJ2a9iX3ZOAzJPm7Q8Yz6YeoUjU/Cvhmi2G4QyTNyPBqqXSgTjUxRg3L0xV45HvkNWWBw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz", + "integrity": "sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw==", "dev": true, "dependencies": { - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-simple-access": "^7.21.5", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -367,9 +367,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz", - "integrity": "sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", "dev": true, "engines": { "node": ">=6.9.0" @@ -411,12 +411,12 @@ } }, "node_modules/@babel/helper-simple-access": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", - "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", "dev": true, "dependencies": { - "@babel/types": "^7.21.5" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -435,39 +435,39 @@ } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz", + "integrity": "sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.21.5.tgz", - "integrity": "sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", + "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", "dev": true, "engines": { "node": ">=6.9.0" @@ -489,26 +489,26 @@ } }, "node_modules/@babel/helpers": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.5.tgz", - "integrity": "sha512-BSY+JSlHxOmGsPTydUkPf1MdMQ3M81x5xGCOVgWM3G8XH77sJ292Y2oqcp0CbbgxhqBuI46iUz1tT7hqP7EfgA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.5.tgz", + "integrity": "sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q==", "dev": true, "dependencies": { - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", + "@babel/helper-validator-identifier": "^7.22.5", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -588,9 +588,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.5.tgz", - "integrity": "sha512-J+IxH2IsxV4HbnTrSWgMAQj0UEo61hDA4Ny8h8PCX0MLXiibqHbqIOVneqdocemSBc22VpBKxt4J6FQzy9HarQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", + "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1766,33 +1766,33 @@ } }, "node_modules/@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.5.tgz", - "integrity": "sha512-AhQoI3YjWi6u/y/ntv7k48mcrCXmus0t79J9qPNlk/lAsFlCiJ047RmbfMOawySTHtywXhbXgpx/8nXMYd+oFw==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.5", - "@babel/types": "^7.21.5", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", + "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1801,13 +1801,13 @@ } }, "node_modules/@babel/types": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.5.tgz", - "integrity": "sha512-m4AfNvVF2mVC/F7fDEdH2El3HzUg9It/XsCxZiOTTA3m3qYfcSVSbTfM6Q9xG+hYDniZssYhlXKKUMD5m8tF4Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", + "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.21.5", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", "to-fast-properties": "^2.0.0" }, "engines": { @@ -8746,36 +8746,36 @@ } }, "@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", + "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", "dev": true, "requires": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.5" } }, "@babel/compat-data": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.5.tgz", - "integrity": "sha512-M+XAiQ7GzQ3FDPf0KOLkugzptnIypt0X0ma0wmlTKPR3IchgNFdx2JXxZdvd18JY5s7QkaFD/qyX0dsMpog/Ug==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", + "integrity": "sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA==", "dev": true }, "@babel/core": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.5.tgz", - "integrity": "sha512-9M398B/QH5DlfCOTKDZT1ozXr0x8uBEeFd+dJraGUZGiaNpGCDVGCc14hZexsMblw3XxltJ+6kSvogp9J+5a9g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.5.tgz", + "integrity": "sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg==", "dev": true, "requires": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-compilation-targets": "^7.21.5", - "@babel/helper-module-transforms": "^7.21.5", - "@babel/helpers": "^7.21.5", - "@babel/parser": "^7.21.5", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5", + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.5", + "@babel/helper-compilation-targets": "^7.22.5", + "@babel/helper-module-transforms": "^7.22.5", + "@babel/helpers": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -8798,12 +8798,12 @@ } }, "@babel/generator": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.5.tgz", - "integrity": "sha512-SrKK/sRv8GesIW1bDagf9cCG38IOMYZusoe1dfg0D8aiUe3Amvoj1QtjTPAWcfrZFvIwlleLb0gxzQidL9w14w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.5.tgz", + "integrity": "sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA==", "dev": true, "requires": { - "@babel/types": "^7.21.5", + "@babel/types": "^7.22.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -8842,13 +8842,13 @@ } }, "@babel/helper-compilation-targets": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.5.tgz", - "integrity": "sha512-1RkbFGUKex4lvsB9yhIfWltJM5cZKUftB2eNajaDv3dCMEp49iBG0K14uH8NnX9IPux2+mK7JGEOB0jn48/J6w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz", + "integrity": "sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw==", "dev": true, "requires": { - "@babel/compat-data": "^7.21.5", - "@babel/helper-validator-option": "^7.21.0", + "@babel/compat-data": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" @@ -8911,9 +8911,9 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", - "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", "dev": true }, "@babel/helper-explode-assignable-expression": { @@ -8926,22 +8926,22 @@ } }, "@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", "dev": true, "requires": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" } }, "@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-member-expression-to-functions": { @@ -8954,28 +8954,28 @@ } }, "@babel/helper-module-imports": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", - "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", + "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", "dev": true, "requires": { - "@babel/types": "^7.21.4" + "@babel/types": "^7.22.5" } }, "@babel/helper-module-transforms": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.5.tgz", - "integrity": "sha512-bI2Z9zBGY2q5yMHoBvJ2a9iX3ZOAzJPm7Q8Yz6YeoUjU/Cvhmi2G4QyTNyPBqqXSgTjUxRg3L0xV45HvkNWWBw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz", + "integrity": "sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw==", "dev": true, "requires": { - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-simple-access": "^7.21.5", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" } }, "@babel/helper-optimise-call-expression": { @@ -8988,9 +8988,9 @@ } }, "@babel/helper-plugin-utils": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz", - "integrity": "sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", "dev": true }, "@babel/helper-remap-async-to-generator": { @@ -9020,12 +9020,12 @@ } }, "@babel/helper-simple-access": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", - "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", "dev": true, "requires": { - "@babel/types": "^7.21.5" + "@babel/types": "^7.22.5" } }, "@babel/helper-skip-transparent-expression-wrappers": { @@ -9038,30 +9038,30 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz", + "integrity": "sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-string-parser": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.21.5.tgz", - "integrity": "sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", "dev": true }, "@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", + "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", "dev": true }, "@babel/helper-wrap-function": { @@ -9077,23 +9077,23 @@ } }, "@babel/helpers": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.5.tgz", - "integrity": "sha512-BSY+JSlHxOmGsPTydUkPf1MdMQ3M81x5xGCOVgWM3G8XH77sJ292Y2oqcp0CbbgxhqBuI46iUz1tT7hqP7EfgA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.5.tgz", + "integrity": "sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q==", "dev": true, "requires": { - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" } }, "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.18.6", + "@babel/helper-validator-identifier": "^7.22.5", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -9157,9 +9157,9 @@ } }, "@babel/parser": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.5.tgz", - "integrity": "sha512-J+IxH2IsxV4HbnTrSWgMAQj0UEo61hDA4Ny8h8PCX0MLXiibqHbqIOVneqdocemSBc22VpBKxt4J6FQzy9HarQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", + "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", "dev": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -9947,42 +9947,42 @@ } }, "@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", "dev": true, "requires": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" } }, "@babel/traverse": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.5.tgz", - "integrity": "sha512-AhQoI3YjWi6u/y/ntv7k48mcrCXmus0t79J9qPNlk/lAsFlCiJ047RmbfMOawySTHtywXhbXgpx/8nXMYd+oFw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.5", - "@babel/types": "^7.21.5", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", + "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5", "debug": "^4.1.0", "globals": "^11.1.0" } }, "@babel/types": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.5.tgz", - "integrity": "sha512-m4AfNvVF2mVC/F7fDEdH2El3HzUg9It/XsCxZiOTTA3m3qYfcSVSbTfM6Q9xG+hYDniZssYhlXKKUMD5m8tF4Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", + "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.21.5", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", "to-fast-properties": "^2.0.0" } }, diff --git a/src/createHeadlessForm.js b/src/createHeadlessForm.js index 48b5728a2..f979c3def 100644 --- a/src/createHeadlessForm.js +++ b/src/createHeadlessForm.js @@ -100,7 +100,7 @@ function removeInvalidAttributes(fields) { * * @returns {FieldParameters} */ -function buildFieldParameters(name, fieldProperties, required = [], config = {}) { +function buildFieldParameters(name, fieldProperties, required = [], config = {}, validations) { const { position } = pickXKey(fieldProperties, 'presentation') ?? {}; let fields; @@ -108,9 +108,14 @@ function buildFieldParameters(name, fieldProperties, required = [], config = {}) if (inputType === supportedTypes.FIELDSET) { // eslint-disable-next-line no-use-before-define - fields = getFieldsFromJSONSchema(fieldProperties, { - customProperties: get(config, `customProperties.${name}`, {}), - }); + fields = getFieldsFromJSONSchema( + fieldProperties, + { + customProperties: get(config, `customProperties.${name}`, {}), + parentID: name, + }, + validations + ); } const result = { @@ -285,7 +290,11 @@ function getFieldsFromJSONSchema(scopedJsonSchema, config, validations) { return []; } - const fieldParamsList = convertJSONSchemaPropertiesToFieldParameters(scopedJsonSchema, config); + const fieldParamsList = convertJSONSchemaPropertiesToFieldParameters( + scopedJsonSchema, + config, + validations + ); applyFieldsDependencies(fieldParamsList, scopedJsonSchema); diff --git a/src/helpers.js b/src/helpers.js index 15f336647..de9800c5d 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -42,7 +42,7 @@ export function getField(fieldName, fields) { * @returns */ export function validateFieldSchema(field, value, validations) { - const validator = buildYupSchema(field, {}, validations); + const validator = buildYupSchema(field, undefined, validations); return validator().isValidSync(value); } diff --git a/src/jsonLogic.js b/src/jsonLogic.js index 49d7470cc..57e900099 100644 --- a/src/jsonLogic.js +++ b/src/jsonLogic.js @@ -216,7 +216,7 @@ function handleComputedAttribute(validations, formValues, parentID, name) { if (key === 'x-jsf-errorMessage') { return [ 'errorMessage', - handleNestedObjectForComputedValues(value, formValues, parentID, validations, name), + handleComputedObjectValue(value, formValues, parentID, validations, name), ]; } @@ -230,13 +230,7 @@ function handleComputedAttribute(validations, formValues, parentID, name) { if (key === 'x-jsf-presentation' && value.statement) { return [ 'statement', - handleNestedObjectForComputedValues( - value.statement, - formValues, - parentID, - validations, - name - ), + handleComputedObjectValue(value.statement, formValues, parentID, validations, name), ]; } @@ -246,7 +240,7 @@ function handleComputedAttribute(validations, formValues, parentID, name) { }; } -function handleNestedObjectForComputedValues(values, formValues, parentID, validations, name) { +function handleComputedObjectValue(values, formValues, parentID, validations, name) { return Object.fromEntries( Object.entries(values).map(([key, value]) => { return [key, replaceHandlebarsTemplates({ value, validations, formValues, parentID, name })]; diff --git a/src/tests/const.test.js b/src/tests/const.test.js new file mode 100644 index 000000000..4438ea070 --- /dev/null +++ b/src/tests/const.test.js @@ -0,0 +1,58 @@ +import { createHeadlessForm } from '../createHeadlessForm'; + +it('Should work for number', () => { + const { handleValidation } = createHeadlessForm( + { + properties: { + ten_only: { type: 'number', const: 10 }, + }, + }, + { strictInputType: false } + ); + expect(handleValidation({}).formErrors).toEqual(undefined); + expect(handleValidation({ ten_only: 1 }).formErrors).toEqual({ + ten_only: 'The only accepted value is 10.', + }); + expect(handleValidation({ ten_only: 10 }).formErrors).toEqual(undefined); +}); + +it('Should work for text', () => { + const { handleValidation } = createHeadlessForm( + { + properties: { + hello_only: { type: 'string', const: 'hello' }, + }, + }, + { strictInputType: false } + ); + expect(handleValidation({}).formErrors).toEqual(undefined); + expect(handleValidation({ hello_only: 'what' }).formErrors).toEqual({ + hello_only: 'The only accepted value is hello.', + }); + expect(handleValidation({ hello_only: 'hello' }).formErrors).toEqual(undefined); +}); + +it('Should work for a conditionally applied const', () => { + const { handleValidation } = createHeadlessForm( + { + properties: { + answer: { type: 'string', oneOf: [{ const: 'yes' }, { const: 'no' }] }, + amount: { description: 'If you select yes, this needs to be exactly 10.', type: 'number' }, + }, + allOf: [ + { + if: { properties: { answer: { const: 'yes' } }, required: ['answer'] }, + then: { properties: { amount: { const: 10 } }, required: ['amount'] }, + }, + ], + }, + { strictInputType: false } + ); + expect(handleValidation({}).formErrors).toEqual(undefined); + expect(handleValidation({ answer: 'no' }).formErrors).toEqual(undefined); + expect(handleValidation({ answer: 'yes' }).formErrors).toEqual({ amount: 'Required field' }); + expect(handleValidation({ answer: 'yes', amount: 1 }).formErrors).toEqual({ + amount: 'The only accepted value is 10.', + }); + expect(handleValidation({ answer: 'yes', amount: 10 }).formErrors).toEqual(undefined); +}); diff --git a/src/tests/jsonLogic.test.js b/src/tests/jsonLogic.test.js index a57ca4dd1..5b94d9ebe 100644 --- a/src/tests/jsonLogic.test.js +++ b/src/tests/jsonLogic.test.js @@ -1,9 +1,16 @@ import { createHeadlessForm } from '../createHeadlessForm'; import { + aConditionallyAppliedComputedAttributeMinimumAndMaximum, + aConditionallyAppliedComputedAttributeValue, createSchemaWithRulesOnFieldA, createSchemaWithThreePropertiesWithRuleOnFieldA, + fieldsetWithAConditionalToApplyExtraValidations, + fieldsetWithComputedAttributes, + ifConditionWithMissingComputedValue, + ifConditionWithMissingValidation, multiRuleSchema, + nestedFieldsetWithValidationSchema, schemaSelfContainedValueForMaximumMinimumValues, schemaSelfContainedValueForTitleWithNoTemplate, schemaWhereValidationAndComputedValueIsAppliedOnNormalThenStatement, @@ -19,6 +26,7 @@ import { schemaWithGreaterThanChecksForThreeFields, schemaWithIfStatementWithComputedValuesAndValidationChecks, schemaWithInlineMultipleRulesForComputedAttributes, + schemaWithInlineRuleForComputedAttributeInConditionallyAppliedSchema, schemaWithInlineRuleForComputedAttributeWithCopy, schemaWithInlinedRuleOnComputedAttributeThatReferencesUnknownVar, schemaWithJSFLogicAndInlineRule, @@ -34,6 +42,10 @@ import { schemaWithTwoValidationsWhereOneOfThemIsAppliedConditionally, schemaWithValidationThatDoesNotExistOnProperty, schemaWithVarThatDoesNotExist, + simpleArrayValidationSchema, + twoLevelsOfJSONLogicSchema, + validatingASingleItemInTheArray, + validatingTwoNestedFieldsSchema, } from './jsonLogicFixtures'; describe('cross-value validations', () => { @@ -66,6 +78,146 @@ describe('cross-value validations', () => { }); }); + describe('Incorrectly written schemas', () => { + beforeEach(() => { + jest.spyOn(console, 'error').mockImplementation(() => {}); + }); + + afterEach(() => { + console.error.mockRestore(); + }); + + it('Should throw when theres a missing rule', () => { + createHeadlessForm(schemaWithMissingRule, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('Missing rule for validation with id of: "a_greater_than_ten".') + ); + }); + + it('Should throw when theres a missing computed value', () => { + createHeadlessForm(schemaWithMissingComputedValue, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('Missing rule for computedValue with id of: "a_plus_ten".') + ); + }); + + it('Should throw when theres an inline computed ruleset with no value.', () => { + createHeadlessForm(schemaWithMissingValueInlineRule, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('Cannot define multiple rules without a template string with key `value`.') + ); + }); + + it('Should throw when a var does not exist in a rule.', () => { + createHeadlessForm(schemaWithVarThatDoesNotExist, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('"field_b" in rule "a_greater_than_ten" does not exist as a JSON schema property.') + ); + }); + + it('Should throw when a var does not exist in a deeply nested rule', () => { + createHeadlessForm(schemaWithDeepVarThatDoesNotExist, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('"field_b" in rule "a_greater_than_ten" does not exist as a JSON schema property.') + ); + }); + + it('Should throw when a var does not exist in a fieldset.', () => { + createHeadlessForm(schemaWithDeepVarThatDoesNotExistOnFieldset, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('"field_a" in rule "a_greater_than_ten" does not exist as a JSON schema property.') + ); + }); + + it('On a property, it should throw an error for a requiredValidation that does not exist', () => { + createHeadlessForm(schemaWithValidationThatDoesNotExistOnProperty, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error(`Validation "iDontExist" required for "field_a" doesn't exist.`) + ); + }); + + it('A top level logic keyword will not be able to reference fieldset properties', () => { + createHeadlessForm(schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('"child" in rule "validation_parent" does not exist as a JSON schema property.') + ); + }); + + it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist.', () => { + createHeadlessForm(schemaWithComputedAttributeThatDoesntExist, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) + ); + }); + + it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a title.', () => { + createHeadlessForm(schemaWithComputedAttributeThatDoesntExistTitle, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) + ); + }); + + it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a description.', () => { + createHeadlessForm(schemaWithComputedAttributeThatDoesntExistDescription, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) + ); + }); + + it('Error for a missing computed value in an if', () => { + createHeadlessForm(ifConditionWithMissingComputedValue, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error(`"iDontExist" computedValue in if condition doesn't exist.`) + ); + }); + + it('Error for a missing validation in an if', () => { + createHeadlessForm(ifConditionWithMissingValidation, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error(`"iDontExist" validation in if condition doesn't exist.`) + ); + }); + + it('On an inline rule for a computedAttribute, error if theres a value referenced that does not exist', () => { + createHeadlessForm(schemaWithInlinedRuleOnComputedAttributeThatReferencesUnknownVar, { + strictInputType: false, + }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error( + '"IdontExist" in inline rule in property "field_a.x-jsf-logic-computedAttrs.title" does not exist as a JSON schema property.' + ) + ); + }); + }); + describe('Relative: <, >, =', () => { it('bigger: field_a > field_b', () => { const schema = createSchemaWithRulesOnFieldA({ @@ -524,6 +676,40 @@ describe('cross-value validations', () => { expect(fieldB.statement).toEqual({ description: 'Must be bigger than 4 and smaller than 8' }); }); + it('computedAttribute test that minimum, maximum, errorMessages.minimum, errorMessage.maximum is working', () => { + const { handleValidation } = createHeadlessForm( + aConditionallyAppliedComputedAttributeMinimumAndMaximum, + { + strictInputType: false, + } + ); + expect(handleValidation({ field_a: 20, field_b: 1 }).formErrors).toEqual({ + field_b: 'use 10 or more', + }); + expect(handleValidation({ field_a: 20, field_b: 60 }).formErrors).toEqual({ + field_b: 'use less than 40', + }); + expect(handleValidation({ field_a: 20, field_b: 30 }).formErrors).toEqual(undefined); + }); + + it('Apply a conditional computed attribute value', () => { + const { fields, handleValidation } = createHeadlessForm( + aConditionallyAppliedComputedAttributeValue, + { + strictInputType: false, + } + ); + + expect(handleValidation({ field_a: 20, field_b: 1 }).formErrors).toEqual({ + field_b: 'The only accepted value is 10.', + }); + + const [, fieldB] = fields; + expect(fieldB.value).toEqual(10); + expect(handleValidation({ field_a: 10, field_b: 1 }).formErrors).toEqual(); + expect(fieldB.value).toEqual(undefined); + }); + it('Use a self contained rule in a schema for a title attribute', () => { const { fields, handleValidation } = createHeadlessForm( schemaWithInlineRuleForComputedAttributeWithCopy, @@ -579,6 +765,19 @@ describe('cross-value validations', () => { expect(handleValidation({ field_a: 50, field_b: 50 }).formErrors).toEqual(undefined); }); + it('Use a self contained rule for a conditionally applied schema', () => { + const { fields, handleValidation } = createHeadlessForm( + schemaWithInlineRuleForComputedAttributeInConditionallyAppliedSchema, + { + strictInputType: false, + } + ); + const [, fieldB] = fields; + expect(fieldB.description).toEqual('Hello world'); + handleValidation({ field_a: 20, field_b: 0 }); + expect(fieldB.description).toEqual('Must be between 10 and 40.'); + }); + it('Mix use of multiple inline rules and an external rule', () => { const { fields, handleValidation } = createHeadlessForm(schemaWithJSFLogicAndInlineRule, { strictInputType: false, @@ -588,4 +787,148 @@ describe('cross-value validations', () => { expect(fieldB.label).toEqual('Going to use 20 and 4'); }); }); + + describe('Nested fieldsets', () => { + it('Basic nested validation works', () => { + const { handleValidation } = createHeadlessForm(nestedFieldsetWithValidationSchema, { + strictInputType: false, + }); + expect(handleValidation({}).formErrors).toEqual({ field_a: { child: 'Required field' } }); + expect(handleValidation({ field_a: { child: 0 } }).formErrors).toEqual({ + field_a: { child: 'Must be greater than 10!' }, + }); + expect(handleValidation({ field_a: { child: 11 } }).formErrors).toEqual(undefined); + }); + + it('Validating two nested fields together', () => { + const { handleValidation } = createHeadlessForm(validatingTwoNestedFieldsSchema, { + strictInputType: false, + }); + expect(handleValidation({}).formErrors).toEqual({ + field_a: { child: 'Required field', other_child: 'Required field' }, + }); + expect(handleValidation({ field_a: { child: 0, other_child: 0 } }).formErrors).toEqual({ + field_a: { child: 'Must be greater than 10!', other_child: 'Must be greater than child' }, + }); + expect(handleValidation({ field_a: { child: 11, other_child: 12 } }).formErrors).toEqual( + undefined + ); + }); + + it('Validate a field and a nested field together', () => { + const { handleValidation } = createHeadlessForm(twoLevelsOfJSONLogicSchema, { + strictInputType: false, + }); + expect(handleValidation({}).formErrors).toEqual({ + field_a: { child: 'Required field' }, + field_b: 'Required field', + }); + expect(handleValidation({ field_a: { child: 0 }, field_b: 0 }).formErrors).toEqual({ + field_a: { child: 'Must be greater than 10!' }, + field_b: 'Must be greater than 10!', + }); + expect(handleValidation({ field_a: { child: 11 }, field_b: 11 }).formErrors).toEqual({ + field_b: 'child must be greater than 15!', + }); + expect(handleValidation({ field_a: { child: 16 }, field_b: 11 }).formErrors).toEqual( + undefined + ); + }); + + it('compute a nested field attribute', () => { + const { fields, handleValidation } = createHeadlessForm(fieldsetWithComputedAttributes, { + strictInputType: false, + }); + const [fieldA] = fields; + const [, computedField] = fieldA.fields; + expect(handleValidation({}).formErrors).toEqual({ + field_a: { child: 'Required field' }, + }); + expect(computedField.value).toEqual(NaN); + + expect(handleValidation({ field_a: { child: 10 } }).formErrors).toEqual(undefined); + expect(computedField.value).toEqual(100); + expect(computedField.description).toEqual('this is 100'); + + expect(handleValidation({ field_a: { child: 11 } }).formErrors).toEqual(undefined); + expect(computedField.value).toEqual(110); + expect(computedField.description).toEqual('this is 110'); + }); + + it('Apply a conditional value in a nested field with a conditional extra validation.', () => { + const { fields, handleValidation } = createHeadlessForm( + fieldsetWithAConditionalToApplyExtraValidations, + { + strictInputType: false, + } + ); + const [fieldA] = fields; + const [, , thirdChild] = fieldA.fields; + expect(thirdChild.isVisible).toEqual(false); + expect(thirdChild.required).toEqual(false); + + expect(handleValidation({ field_a: {} }).formErrors).toEqual({ + field_a: { child: 'Required field', other_child: 'Required field' }, + }); + expect(handleValidation({ field_a: { child: 0, other_child: 0 } }).formErrors).toEqual( + undefined + ); + expect(handleValidation({ field_a: { child: 10, other_child: 0 } }).formErrors).toEqual( + undefined + ); + expect(handleValidation({ field_a: { child: 10, other_child: 20 } }).formErrors).toEqual({ + field_a: { third_child: 'Required field' }, + }); + expect(thirdChild.isVisible).toEqual(true); + expect(thirdChild.required).toEqual(true); + + expect( + handleValidation({ field_a: { child: 10, other_child: 20, third_child: 10 } }).formErrors + ).toEqual({ + field_a: { third_child: 'Must be greater than other child.' }, + }); + + expect( + handleValidation({ field_a: { child: 10, other_child: 20, third_child: 30 } }).formErrors + ).toEqual(undefined); + }); + }); + + describe('Array validation', () => { + it('Should apply the json logic on an individual array item', () => { + const { handleValidation } = createHeadlessForm(simpleArrayValidationSchema, { + strictInputType: false, + }); + expect(handleValidation({ field_array: [] }).formErrors).toEqual(undefined); + expect(handleValidation({ field_array: [{}] }).formErrors).toEqual({ + field_array: [{ array_item: 'Required field' }], + }); + expect(handleValidation({ field_array: [{ array_item: 1 }] }).formErrors).toEqual({ + field_array: [{ array_item: 'Must be divisible by two' }], + }); + expect(handleValidation({ field_array: [{ array_item: 2 }] }).formErrors).toEqual(undefined); + expect( + handleValidation({ field_array: [{ array_item: 2 }, { array_item: 1 }] }).formErrors + ).toEqual({ + field_array: [undefined, { array_item: 'Must be divisible by two' }], + }); + expect( + handleValidation({ field_array: [{ array_item: 2 }, { array_item: 2 }] }).formErrors + ).toEqual(undefined); + }); + + it('Validating a single item in an array should work', () => { + const { handleValidation } = createHeadlessForm(validatingASingleItemInTheArray, { + strictInputType: false, + }); + expect(handleValidation({ field_array: [] }).formErrors).toEqual(undefined); + expect(handleValidation({ field_array: [{ item: 0 }] }).formErrors).toEqual(undefined); + expect(handleValidation({ field_array: [{ item: 0 }, { item: 3 }] }).formErrors).toEqual({ + field_array: 'Second item in array must be divisible by 4', + }); + }); + + // FIXME: This doesn't work because conditionals in items are not supported. + it.todo('Should be able to use conditionals in items'); + }); }); diff --git a/src/tests/jsonLogicFixtures.js b/src/tests/jsonLogicFixtures.js index b501b67e3..a6428f6a6 100644 --- a/src/tests/jsonLogicFixtures.js +++ b/src/tests/jsonLogicFixtures.js @@ -246,6 +246,48 @@ export const schemaWithComputedAttributeThatDoesntExistDescription = { }, }; +export const ifConditionWithMissingComputedValue = { + properties: { + field_a: { + type: 'number', + }, + }, + 'x-jsf-logic': { + allOf: [ + { + if: { + computedValues: { + iDontExist: { + const: 10, + }, + }, + }, + }, + ], + }, +}; + +export const ifConditionWithMissingValidation = { + properties: { + field_a: { + type: 'number', + }, + }, + 'x-jsf-logic': { + allOf: [ + { + if: { + validations: { + iDontExist: { + const: true, + }, + }, + }, + }, + ], + }, +}; + export const schemaWithGreaterThanChecksForThreeFields = { properties: { field_a: { @@ -753,6 +795,239 @@ export const schemaWithComputedAttributes = { }, }; +export const nestedFieldsetWithValidationSchema = { + properties: { + field_a: { + type: 'object', + 'x-jsf-presentation': { + inputType: 'fieldset', + }, + properties: { + child: { + type: 'number', + 'x-jsf-logic-validations': ['child_greater_than_10'], + }, + }, + required: ['child'], + 'x-jsf-logic': { + validations: { + child_greater_than_10: { + errorMessage: 'Must be greater than 10!', + rule: { + '>': [{ var: 'child' }, 10], + }, + }, + }, + }, + }, + }, + required: ['field_a'], +}; + +export const validatingTwoNestedFieldsSchema = { + properties: { + field_a: { + type: 'object', + 'x-jsf-presentation': { + inputType: 'fieldset', + }, + properties: { + child: { + type: 'number', + 'x-jsf-logic-validations': ['child_greater_than_10'], + }, + other_child: { + type: 'number', + 'x-jsf-logic-validations': ['greater_than_child'], + }, + }, + required: ['child', 'other_child'], + 'x-jsf-logic': { + validations: { + child_greater_than_10: { + errorMessage: 'Must be greater than 10!', + rule: { + '>': [{ var: 'child' }, 10], + }, + }, + greater_than_child: { + errorMessage: 'Must be greater than child', + rule: { + '>': [{ var: 'other_child' }, { var: 'child' }], + }, + }, + }, + }, + }, + }, + required: ['field_a'], +}; + +export const twoLevelsOfJSONLogicSchema = { + properties: { + field_a: { + type: 'object', + 'x-jsf-presentation': { + inputType: 'fieldset', + }, + properties: { + child: { + type: 'number', + 'x-jsf-logic-validations': ['child_greater_than_10'], + }, + }, + required: ['child'], + 'x-jsf-logic': { + validations: { + child_greater_than_10: { + errorMessage: 'Must be greater than 10!', + rule: { + '>': [{ var: 'child' }, 10], + }, + }, + }, + }, + }, + field_b: { + type: 'number', + 'x-jsf-logic-validations': ['validation_parent', 'peek_to_nested'], + }, + }, + 'x-jsf-logic': { + validations: { + validation_parent: { + errorMessage: 'Must be greater than 10!', + rule: { + '>': [{ var: 'field_b' }, 10], + }, + }, + peek_to_nested: { + errorMessage: 'child must be greater than 15!', + rule: { + '>': [{ var: 'field_a.child' }, 15], + }, + }, + }, + }, + required: ['field_a', 'field_b'], +}; + +export const fieldsetWithComputedAttributes = { + properties: { + field_a: { + type: 'object', + 'x-jsf-presentation': { + inputType: 'fieldset', + }, + properties: { + child: { + type: 'number', + }, + other_child: { + type: 'number', + readOnly: true, + 'x-jsf-logic-computedAttrs': { + default: 'child_times_10', + const: 'child_times_10', + description: 'this is {{child_times_10}}', + }, + }, + }, + required: ['child'], + 'x-jsf-logic': { + computedValues: { + child_times_10: { + rule: { + '*': [{ var: 'child' }, 10], + }, + }, + }, + }, + }, + }, + required: ['field_a'], +}; + +export const fieldsetWithAConditionalToApplyExtraValidations = { + properties: { + field_a: { + type: 'object', + 'x-jsf-presentation': { + inputType: 'fieldset', + }, + properties: { + child: { + type: 'number', + }, + other_child: { + type: 'number', + }, + third_child: { + type: 'number', + }, + }, + required: ['child', 'other_child'], + 'x-jsf-logic': { + validations: { + child_is_greater_than_other_child: { + rule: { + '>': [{ var: 'child' }, { var: 'other_child' }], + }, + }, + third_child_is_greater_than_other_child: { + errorMessage: 'Must be greater than other child.', + rule: { + '>': [{ var: 'third_child' }, { var: 'other_child' }], + }, + }, + }, + computedValues: { + child_times_10: { + rule: { + '*': [{ var: 'child' }, 10], + }, + }, + }, + allOf: [ + { + if: { + computedValues: { + child_times_10: { + const: 100, + }, + }, + validations: { + child_is_greater_than_other_child: { + const: false, + }, + }, + properties: { + child: { + const: 10, + }, + }, + }, + then: { + required: ['third_child'], + properties: { + third_child: { + 'x-jsf-logic-validations': ['third_child_is_greater_than_other_child'], + }, + }, + }, + else: { + properties: { + third_child: false, + }, + }, + }, + ], + }, + }, + }, + required: ['field_a'], +}; + export const schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset = { properties: { field_a: { @@ -792,6 +1067,192 @@ export const schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset = { required: ['field_a'], }; +export const simpleArrayValidationSchema = { + properties: { + field_array: { + type: 'array', + items: { + properties: { + array_item: { + type: 'number', + 'x-jsf-logic-validations': ['divisible_by_two'], + }, + }, + required: ['array_item'], + 'x-jsf-logic': { + validations: { + divisible_by_two: { + errorMessage: 'Must be divisible by two', + rule: { + '===': [{ '%': [{ var: 'array_item' }, 2] }, 0], + }, + }, + }, + }, + }, + }, + }, +}; + +export const validatingASingleItemInTheArray = { + properties: { + field_array: { + type: 'array', + 'x-jsf-logic-validations': ['second_item_is_divisible_by_four'], + items: { + properties: { + item: { + type: 'number', + }, + }, + required: ['item'], + }, + }, + }, + 'x-jsf-logic': { + validations: { + second_item_is_divisible_by_four: { + errorMessage: 'Second item in array must be divisible by 4', + rule: { + '===': [{ '%': [{ var: 'field_array.1.item' }, 4] }, 0], + }, + }, + }, + }, +}; + +// FIXME: This doesn't work because conditionals in items are not supported. +export const conditionalAppliedInAnItem = { + properties: { + field_array: { + type: 'array', + items: { + properties: { + item: { + type: 'number', + }, + other_item: { + type: 'number', + }, + }, + required: ['item'], + 'x-jsf-logic': { + validations: { + divisible_by_three: { + rule: { + '===': [{ '%': [{ var: 'item' }, 3] }, 0], + }, + }, + other_item_divisible_by_three: { + errorMessage: 'Must be disivisble_by_three', + rule: { + '===': [{ '%': [{ var: 'other_item' }, 3] }, 0], + }, + }, + }, + allOf: [ + { + if: { validations: { divisible_by_three: { cosnt: true } } }, + then: { + required: ['other_item'], + other_item: { 'x-jsf-logic-validations': ['other_item_divisible_by_three'] }, + }, + else: { properties: { other_item: false } }, + }, + ], + }, + }, + }, + }, +}; + +export const aConditionallyAppliedComputedAttributeMinimumAndMaximum = { + properties: { + field_a: { + type: 'number', + }, + field_b: { + type: 'number', + }, + }, + allOf: [ + { + if: { properties: { field_a: { const: 20 } } }, + then: { + properties: { + field_b: { + 'x-jsf-logic-computedAttrs': { + minimum: 'a_divided_by_two', + maximum: 'a_multiplied_by_two', + 'x-jsf-errorMessage': { + minimum: 'use {{a_divided_by_two}} or more', + maximum: 'use less than {{a_multiplied_by_two}}', + }, + }, + }, + }, + }, + }, + ], + 'x-jsf-logic': { + computedValues: { + a_divided_by_two: { + rule: { + '/': [{ var: 'field_a' }, 2], + }, + }, + a_multiplied_by_two: { + rule: { + '*': [{ var: 'field_a' }, 2], + }, + }, + }, + }, +}; + +export const aConditionallyAppliedComputedAttributeValue = { + properties: { + field_a: { + type: 'number', + }, + field_b: { + type: 'number', + }, + }, + allOf: [ + { + if: { properties: { field_a: { const: 20 } } }, + then: { + properties: { + field_b: { + readOnly: true, + 'x-jsf-logic-computedAttrs': { + const: 'a_divided_by_two', + default: 'a_divided_by_two', + }, + }, + }, + }, + else: { + properties: { + field_b: { + readOnly: false, + }, + }, + }, + }, + ], + 'x-jsf-logic': { + computedValues: { + a_divided_by_two: { + rule: { + '/': [{ var: 'field_a' }, 2], + }, + }, + }, + }, +}; + export const schemaWithInlineRuleForComputedAttributeWithCopy = { properties: { field_a: { @@ -829,6 +1290,73 @@ export const schemaWithInlineRuleForComputedAttributeWithoutCopy = { }, }; +export const schemaWithInlineRuleForComputedAttributeWithOnlyTheRule = { + properties: { + field_a: { + type: 'number', + }, + field_b: { + type: 'number', + 'x-jsf-logic-computedAttrs': { + minimum: { + rule: { + '+': [{ var: 'field_a' }, 10], + }, + }, + 'x-jsf-errorMessage': { + minimum: { + value: 'This should be greater than {{rule}}.', + rule: { + '+': [{ var: 'field_a' }, 10], + }, + }, + }, + }, + }, + }, +}; + +export const schemaWithInlineRuleForComputedAttributeInConditionallyAppliedSchema = { + properties: { + field_a: { + type: 'number', + }, + field_b: { + description: 'Hello world', + type: 'number', + }, + }, + allOf: [ + { + if: { + properties: { + field_a: { + const: 20, + }, + }, + required: ['field_a'], + }, + then: { + properties: { + field_b: { + 'x-jsf-logic-computedAttrs': { + description: { + value: 'Must be between {{half_a}} and {{double_a}}.', + half_a: { + '/': [{ var: 'field_a' }, 2], + }, + double_a: { + '*': [{ var: 'field_a' }, 2], + }, + }, + }, + }, + }, + }, + }, + ], +}; + export const schemaWithInlineMultipleRulesForComputedAttributes = { properties: { field_a: { diff --git a/src/yupSchema.js b/src/yupSchema.js index 0c8bee152..33bb45025 100644 --- a/src/yupSchema.js +++ b/src/yupSchema.js @@ -305,6 +305,19 @@ export function buildYupSchema(field, config, validations) { ); } + function withConst(yupSchema) { + return yupSchema.test( + 'isConst', + errorMessage.const ?? + errorMessageFromConfig.const ?? + `The only accepted value is ${propertyFields.const}.`, + (value) => + (propertyFields.required === false && value === undefined) || + value === null || + value === propertyFields.const + ); + } + function withBaseSchema() { const customErrorMsg = errorMessage.type || errorMessageFromConfig.type; if (customErrorMsg) { @@ -326,7 +339,8 @@ export function buildYupSchema(field, config, validations) { ...fieldSetfield, inputType: fieldSetfield.type, }, - config + { ...config, parentID: field.name }, + validations )(); } }); @@ -338,7 +352,11 @@ export function buildYupSchema(field, config, validations) { propertyFields.nthFieldGroup.fields().reduce( (schema, groupArrayField) => ({ ...schema, - [groupArrayField.name]: buildYupSchema(groupArrayField, config)(), + [groupArrayField.name]: buildYupSchema( + groupArrayField, + { ...config, parentID: `${propertyFields.nthFieldGroup.name}[]` }, + validations + )(), }), {} ) @@ -390,6 +408,10 @@ export function buildYupSchema(field, config, validations) { validators.push(withFileFormat); } + if (propertyFields.const) { + validators.push(withConst); + } + if (propertyFields.requiredValidations) { propertyFields.requiredValidations.forEach((id) => validators.push(yupSchemaWithCustomJSONLogic({ field, id, validations, config })) @@ -412,7 +434,7 @@ export function getNoSortEdges(fields = []) { }, []); } -function getSchema(fields = [], config) { +function getSchema(fields = [], config, validations) { const newSchema = {}; fields.forEach((field) => { @@ -421,13 +443,17 @@ function getSchema(fields = [], config) { if (field.inputType === supportedTypes.FIELDSET) { // Fieldset validation schemas depend on the inner schemas of their fields, // so we need to rebuild it to take into account any of those updates. - const fieldsetSchema = buildYupSchema(field, config)(); + const fieldsetSchema = buildYupSchema( + field, + { ...config, parentID: field.name }, + validations + )(); newSchema[field.name] = fieldsetSchema; } else { newSchema[field.name] = field.schema; } } else { - Object.assign(newSchema, getSchema(field.fields, config)); + Object.assign(newSchema, getSchema(field.fields, config, validations)); } } }); @@ -443,6 +469,6 @@ function getSchema(fields = [], config) { * @param {JsfConfig} config - Config * @returns */ -export function buildCompleteYupSchema(fields, config) { - return object().shape(getSchema(fields, config), getNoSortEdges(fields)); +export function buildCompleteYupSchema(fields, config, validations) { + return object().shape(getSchema(fields, config, validations), getNoSortEdges(fields)); } From 63fc59fba2b29e4404cc0da8ae47ba148f5f25a1 Mon Sep 17 00:00:00 2001 From: brennj Date: Wed, 23 Aug 2023 17:04:33 +0200 Subject: [PATCH 02/10] chore: fix package-lock.json --- package-lock.json | 450 +++++++++++++++++++++++----------------------- 1 file changed, 225 insertions(+), 225 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1a4e90cbc..5569f4328 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,42 +54,42 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", - "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", + "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", "dev": true, "dependencies": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/compat-data": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", - "integrity": "sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.5.tgz", + "integrity": "sha512-M+XAiQ7GzQ3FDPf0KOLkugzptnIypt0X0ma0wmlTKPR3IchgNFdx2JXxZdvd18JY5s7QkaFD/qyX0dsMpog/Ug==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.5.tgz", - "integrity": "sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.5.tgz", + "integrity": "sha512-9M398B/QH5DlfCOTKDZT1ozXr0x8uBEeFd+dJraGUZGiaNpGCDVGCc14hZexsMblw3XxltJ+6kSvogp9J+5a9g==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-compilation-targets": "^7.22.5", - "@babel/helper-module-transforms": "^7.22.5", - "@babel/helpers": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.5", + "@babel/helper-compilation-targets": "^7.21.5", + "@babel/helper-module-transforms": "^7.21.5", + "@babel/helpers": "^7.21.5", + "@babel/parser": "^7.21.5", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.5", + "@babel/types": "^7.21.5", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -120,12 +120,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.5.tgz", - "integrity": "sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.5.tgz", + "integrity": "sha512-SrKK/sRv8GesIW1bDagf9cCG38IOMYZusoe1dfg0D8aiUe3Amvoj1QtjTPAWcfrZFvIwlleLb0gxzQidL9w14w==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.21.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -174,13 +174,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz", - "integrity": "sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.5.tgz", + "integrity": "sha512-1RkbFGUKex4lvsB9yhIfWltJM5cZKUftB2eNajaDv3dCMEp49iBG0K14uH8NnX9IPux2+mK7JGEOB0jn48/J6w==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.22.5", - "@babel/helper-validator-option": "^7.22.5", + "@babel/compat-data": "^7.21.5", + "@babel/helper-validator-option": "^7.21.0", "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" @@ -266,9 +266,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", + "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", "dev": true, "engines": { "node": ">=6.9.0" @@ -287,25 +287,25 @@ } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", + "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.20.7", + "@babel/types": "^7.21.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", - "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", + "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -324,31 +324,31 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", - "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", + "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.21.4" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz", - "integrity": "sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.5.tgz", + "integrity": "sha512-bI2Z9zBGY2q5yMHoBvJ2a9iX3ZOAzJPm7Q8Yz6YeoUjU/Cvhmi2G4QyTNyPBqqXSgTjUxRg3L0xV45HvkNWWBw==", "dev": true, "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-module-imports": "^7.22.5", - "@babel/helper-simple-access": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/helper-environment-visitor": "^7.21.5", + "@babel/helper-module-imports": "^7.21.4", + "@babel/helper-simple-access": "^7.21.5", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.19.1", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.5", + "@babel/types": "^7.21.5" }, "engines": { "node": ">=6.9.0" @@ -367,9 +367,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", - "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz", + "integrity": "sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==", "dev": true, "engines": { "node": ">=6.9.0" @@ -411,12 +411,12 @@ } }, "node_modules/@babel/helper-simple-access": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", - "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", + "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.21.5" }, "engines": { "node": ">=6.9.0" @@ -435,39 +435,39 @@ } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz", - "integrity": "sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", + "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.21.5.tgz", + "integrity": "sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", - "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", + "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", "dev": true, "engines": { "node": ">=6.9.0" @@ -489,26 +489,26 @@ } }, "node_modules/@babel/helpers": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.5.tgz", - "integrity": "sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.5.tgz", + "integrity": "sha512-BSY+JSlHxOmGsPTydUkPf1MdMQ3M81x5xGCOVgWM3G8XH77sJ292Y2oqcp0CbbgxhqBuI46iUz1tT7hqP7EfgA==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.5", + "@babel/types": "^7.21.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", - "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -588,9 +588,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", - "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.5.tgz", + "integrity": "sha512-J+IxH2IsxV4HbnTrSWgMAQj0UEo61hDA4Ny8h8PCX0MLXiibqHbqIOVneqdocemSBc22VpBKxt4J6FQzy9HarQ==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1766,33 +1766,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.20.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", + "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", - "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", - "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.5.tgz", + "integrity": "sha512-AhQoI3YjWi6u/y/ntv7k48mcrCXmus0t79J9qPNlk/lAsFlCiJ047RmbfMOawySTHtywXhbXgpx/8nXMYd+oFw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.5", + "@babel/helper-environment-visitor": "^7.21.5", + "@babel/helper-function-name": "^7.21.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.21.5", + "@babel/types": "^7.21.5", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1801,13 +1801,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", - "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.5.tgz", + "integrity": "sha512-m4AfNvVF2mVC/F7fDEdH2El3HzUg9It/XsCxZiOTTA3m3qYfcSVSbTfM6Q9xG+hYDniZssYhlXKKUMD5m8tF4Q==", "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-string-parser": "^7.21.5", + "@babel/helper-validator-identifier": "^7.19.1", "to-fast-properties": "^2.0.0" }, "engines": { @@ -8746,36 +8746,36 @@ } }, "@babel/code-frame": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", - "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", + "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", "dev": true, "requires": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.18.6" } }, "@babel/compat-data": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", - "integrity": "sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.5.tgz", + "integrity": "sha512-M+XAiQ7GzQ3FDPf0KOLkugzptnIypt0X0ma0wmlTKPR3IchgNFdx2JXxZdvd18JY5s7QkaFD/qyX0dsMpog/Ug==", "dev": true }, "@babel/core": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.5.tgz", - "integrity": "sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.5.tgz", + "integrity": "sha512-9M398B/QH5DlfCOTKDZT1ozXr0x8uBEeFd+dJraGUZGiaNpGCDVGCc14hZexsMblw3XxltJ+6kSvogp9J+5a9g==", "dev": true, "requires": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-compilation-targets": "^7.22.5", - "@babel/helper-module-transforms": "^7.22.5", - "@babel/helpers": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.5", + "@babel/helper-compilation-targets": "^7.21.5", + "@babel/helper-module-transforms": "^7.21.5", + "@babel/helpers": "^7.21.5", + "@babel/parser": "^7.21.5", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.5", + "@babel/types": "^7.21.5", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -8798,12 +8798,12 @@ } }, "@babel/generator": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.5.tgz", - "integrity": "sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.5.tgz", + "integrity": "sha512-SrKK/sRv8GesIW1bDagf9cCG38IOMYZusoe1dfg0D8aiUe3Amvoj1QtjTPAWcfrZFvIwlleLb0gxzQidL9w14w==", "dev": true, "requires": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.21.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -8842,13 +8842,13 @@ } }, "@babel/helper-compilation-targets": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz", - "integrity": "sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.5.tgz", + "integrity": "sha512-1RkbFGUKex4lvsB9yhIfWltJM5cZKUftB2eNajaDv3dCMEp49iBG0K14uH8NnX9IPux2+mK7JGEOB0jn48/J6w==", "dev": true, "requires": { - "@babel/compat-data": "^7.22.5", - "@babel/helper-validator-option": "^7.22.5", + "@babel/compat-data": "^7.21.5", + "@babel/helper-validator-option": "^7.21.0", "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" @@ -8911,9 +8911,9 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", + "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", "dev": true }, "@babel/helper-explode-assignable-expression": { @@ -8926,22 +8926,22 @@ } }, "@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", + "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", "dev": true, "requires": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.20.7", + "@babel/types": "^7.21.0" } }, "@babel/helper-hoist-variables": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", - "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", + "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", "dev": true, "requires": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.18.6" } }, "@babel/helper-member-expression-to-functions": { @@ -8954,28 +8954,28 @@ } }, "@babel/helper-module-imports": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", - "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", + "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", "dev": true, "requires": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.21.4" } }, "@babel/helper-module-transforms": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz", - "integrity": "sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.5.tgz", + "integrity": "sha512-bI2Z9zBGY2q5yMHoBvJ2a9iX3ZOAzJPm7Q8Yz6YeoUjU/Cvhmi2G4QyTNyPBqqXSgTjUxRg3L0xV45HvkNWWBw==", "dev": true, "requires": { - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-module-imports": "^7.22.5", - "@babel/helper-simple-access": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/helper-environment-visitor": "^7.21.5", + "@babel/helper-module-imports": "^7.21.4", + "@babel/helper-simple-access": "^7.21.5", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.19.1", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.5", + "@babel/types": "^7.21.5" } }, "@babel/helper-optimise-call-expression": { @@ -8988,9 +8988,9 @@ } }, "@babel/helper-plugin-utils": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", - "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz", + "integrity": "sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==", "dev": true }, "@babel/helper-remap-async-to-generator": { @@ -9020,12 +9020,12 @@ } }, "@babel/helper-simple-access": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", - "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", + "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", "dev": true, "requires": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.21.5" } }, "@babel/helper-skip-transparent-expression-wrappers": { @@ -9038,30 +9038,30 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz", - "integrity": "sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", + "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", "dev": true, "requires": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.18.6" } }, "@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.21.5.tgz", + "integrity": "sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true }, "@babel/helper-validator-option": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", - "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", + "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", "dev": true }, "@babel/helper-wrap-function": { @@ -9077,23 +9077,23 @@ } }, "@babel/helpers": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.5.tgz", - "integrity": "sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.5.tgz", + "integrity": "sha512-BSY+JSlHxOmGsPTydUkPf1MdMQ3M81x5xGCOVgWM3G8XH77sJ292Y2oqcp0CbbgxhqBuI46iUz1tT7hqP7EfgA==", "dev": true, "requires": { - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.5", + "@babel/types": "^7.21.5" } }, "@babel/highlight": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", - "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -9157,9 +9157,9 @@ } }, "@babel/parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", - "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.5.tgz", + "integrity": "sha512-J+IxH2IsxV4HbnTrSWgMAQj0UEo61hDA4Ny8h8PCX0MLXiibqHbqIOVneqdocemSBc22VpBKxt4J6FQzy9HarQ==", "dev": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -9947,42 +9947,42 @@ } }, "@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.20.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", + "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", "dev": true, "requires": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7" } }, "@babel/traverse": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", - "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", - "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.5.tgz", + "integrity": "sha512-AhQoI3YjWi6u/y/ntv7k48mcrCXmus0t79J9qPNlk/lAsFlCiJ047RmbfMOawySTHtywXhbXgpx/8nXMYd+oFw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.5", + "@babel/helper-environment-visitor": "^7.21.5", + "@babel/helper-function-name": "^7.21.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.21.5", + "@babel/types": "^7.21.5", "debug": "^4.1.0", "globals": "^11.1.0" } }, "@babel/types": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", - "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.5.tgz", + "integrity": "sha512-m4AfNvVF2mVC/F7fDEdH2El3HzUg9It/XsCxZiOTTA3m3qYfcSVSbTfM6Q9xG+hYDniZssYhlXKKUMD5m8tF4Q==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-string-parser": "^7.21.5", + "@babel/helper-validator-identifier": "^7.19.1", "to-fast-properties": "^2.0.0" } }, @@ -15007,4 +15007,4 @@ } } } -} +} \ No newline at end of file From f56b57ef7156c39272eab102e38e84b57ce40645 Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 08:59:30 +0200 Subject: [PATCH 03/10] chore: fix package-lock --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 5569f4328..c0e99e7af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15007,4 +15007,4 @@ } } } -} \ No newline at end of file +} From 7536a74bd6d5e53884efbc380867fd651f9ba48d Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 10:20:22 +0200 Subject: [PATCH 04/10] chore: fix blunder --- src/tests/jsonLogic.test.js | 128 ++---------------------------------- 1 file changed, 4 insertions(+), 124 deletions(-) diff --git a/src/tests/jsonLogic.test.js b/src/tests/jsonLogic.test.js index 5b94d9ebe..a7ebe812c 100644 --- a/src/tests/jsonLogic.test.js +++ b/src/tests/jsonLogic.test.js @@ -1,15 +1,17 @@ import { createHeadlessForm } from '../createHeadlessForm'; import { + createSchemaWithRulesOnFieldA, + multiRuleSchema, + schemaWithComputedAttributesAndErrorMessages, + schemaWithNonRequiredField, aConditionallyAppliedComputedAttributeMinimumAndMaximum, aConditionallyAppliedComputedAttributeValue, - createSchemaWithRulesOnFieldA, createSchemaWithThreePropertiesWithRuleOnFieldA, fieldsetWithAConditionalToApplyExtraValidations, fieldsetWithComputedAttributes, ifConditionWithMissingComputedValue, ifConditionWithMissingValidation, - multiRuleSchema, nestedFieldsetWithValidationSchema, schemaSelfContainedValueForMaximumMinimumValues, schemaSelfContainedValueForTitleWithNoTemplate, @@ -19,7 +21,6 @@ import { schemaWithComputedAttributeThatDoesntExistDescription, schemaWithComputedAttributeThatDoesntExistTitle, schemaWithComputedAttributes, - schemaWithComputedAttributesAndErrorMessages, schemaWithComputedValueChecksInIf, schemaWithDeepVarThatDoesNotExist, schemaWithDeepVarThatDoesNotExistOnFieldset, @@ -35,7 +36,6 @@ import { schemaWithMissingValueInlineRule, schemaWithMultipleComputedValueChecks, schemaWithNativeAndJSONLogicChecks, - schemaWithNonRequiredField, schemaWithPropertiesCheckAndValidationsInAIf, schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset, schemaWithTwoRules, @@ -259,126 +259,6 @@ describe('cross-value validations', () => { }); }); - describe('Incorrectly written schemas', () => { - beforeEach(() => { - jest.spyOn(console, 'error').mockImplementation(() => {}); - }); - - afterEach(() => { - console.error.mockRestore(); - }); - - it('Should throw when a var does not exist in a rule.', () => { - createHeadlessForm(schemaWithVarThatDoesNotExist, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('"field_b" in rule "a_greater_than_ten" does not exist as a JSON schema property.') - ); - }); - - it('Should throw when a var does not exist in a deeply nested rule', () => { - createHeadlessForm(schemaWithDeepVarThatDoesNotExist, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('"field_b" in rule "a_greater_than_ten" does not exist as a JSON schema property.') - ); - }); - - it('Should throw when a var does not exist in a fieldset.', () => { - createHeadlessForm(schemaWithDeepVarThatDoesNotExistOnFieldset, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('"field_a" in rule "a_greater_than_ten" does not exist as a JSON schema property.') - ); - }); - - it('On a property, it should throw an error for a requiredValidation that does not exist', () => { - createHeadlessForm(schemaWithValidationThatDoesNotExistOnProperty, { - strictInputType: false, - }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error(`Validation "iDontExist" required for "field_a" doesn't exist.`) - ); - }); - - it('A top level logic keyword will not be able to reference fieldset properties', () => { - createHeadlessForm(schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset, { - strictInputType: false, - }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('"child" in rule "validation_parent" does not exist as a JSON schema property.') - ); - }); - - it('Should throw when theres a missing rule', () => { - createHeadlessForm(schemaWithMissingRule, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('Missing rule for validation with id of: "a_greater_than_ten".') - ); - }); - - it('Should throw when theres a missing computed value', () => { - createHeadlessForm(schemaWithMissingComputedValue, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('Missing rule for computedValue with id of: "a_plus_ten".') - ); - }); - - it('Should throw when theres an inline computed ruleset with no value.', () => { - createHeadlessForm(schemaWithMissingValueInlineRule, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('Cannot define multiple rules without a template string with key `value`.') - ); - }); - - it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist.', () => { - createHeadlessForm(schemaWithComputedAttributeThatDoesntExist, { - strictInputType: false, - }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) - ); - }); - - it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a title.', () => { - createHeadlessForm(schemaWithComputedAttributeThatDoesntExistTitle, { - strictInputType: false, - }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) - ); - }); - - it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a description.', () => { - createHeadlessForm(schemaWithComputedAttributeThatDoesntExistDescription, { - strictInputType: false, - }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) - ); - }); - - it('On an inline rule for a computedAttribute, error if theres a value referenced that does not exist', () => { - createHeadlessForm(schemaWithInlinedRuleOnComputedAttributeThatReferencesUnknownVar, { - strictInputType: false, - }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error( - '"IdontExist" in inline rule in property "field_a.x-jsf-logic-computedAttrs.title" does not exist as a JSON schema property.' - ) - ); - }); - }); - describe('Arithmetic: +, -, *, /', () => { it('multiple: field_a > field_b * 2', () => { const schema = createSchemaWithRulesOnFieldA({ From 50fe4bbf3547c0e00597a7bd40127e22a6d87d5f Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 10:47:08 +0200 Subject: [PATCH 05/10] chore: match closer --- src/jsonLogic.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/jsonLogic.js b/src/jsonLogic.js index 57e900099..49d7470cc 100644 --- a/src/jsonLogic.js +++ b/src/jsonLogic.js @@ -216,7 +216,7 @@ function handleComputedAttribute(validations, formValues, parentID, name) { if (key === 'x-jsf-errorMessage') { return [ 'errorMessage', - handleComputedObjectValue(value, formValues, parentID, validations, name), + handleNestedObjectForComputedValues(value, formValues, parentID, validations, name), ]; } @@ -230,7 +230,13 @@ function handleComputedAttribute(validations, formValues, parentID, name) { if (key === 'x-jsf-presentation' && value.statement) { return [ 'statement', - handleComputedObjectValue(value.statement, formValues, parentID, validations, name), + handleNestedObjectForComputedValues( + value.statement, + formValues, + parentID, + validations, + name + ), ]; } @@ -240,7 +246,7 @@ function handleComputedAttribute(validations, formValues, parentID, name) { }; } -function handleComputedObjectValue(values, formValues, parentID, validations, name) { +function handleNestedObjectForComputedValues(values, formValues, parentID, validations, name) { return Object.fromEntries( Object.entries(values).map(([key, value]) => { return [key, replaceHandlebarsTemplates({ value, validations, formValues, parentID, name })]; From 9342fb9b56e1cc176446ec245ed485c64baf8044 Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 10:47:43 +0200 Subject: [PATCH 06/10] chore: match closer --- src/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers.js b/src/helpers.js index de9800c5d..15f336647 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -42,7 +42,7 @@ export function getField(fieldName, fields) { * @returns */ export function validateFieldSchema(field, value, validations) { - const validator = buildYupSchema(field, undefined, validations); + const validator = buildYupSchema(field, {}, validations); return validator().isValidSync(value); } From 173f5248ddfce2e58c9ad66ece7b4a38d7780051 Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 13:08:41 +0200 Subject: [PATCH 07/10] chore: move test --- src/tests/jsonLogic.test.js | 82 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/tests/jsonLogic.test.js b/src/tests/jsonLogic.test.js index a7ebe812c..3f4c8a08b 100644 --- a/src/tests/jsonLogic.test.js +++ b/src/tests/jsonLogic.test.js @@ -78,6 +78,47 @@ describe('cross-value validations', () => { }); }); + describe('Relative: <, >, =', () => { + it('bigger: field_a > field_b', () => { + const schema = createSchemaWithRulesOnFieldA({ + a_greater_than_b: { + errorMessage: 'Field A must be bigger than field B', + rule: { '>': [{ var: 'field_a' }, { var: 'field_b' }] }, + }, + }); + const { handleValidation } = createHeadlessForm(schema, { strictInputType: false }); + const { formErrors } = handleValidation({ field_a: 1, field_b: 2 }); + expect(formErrors.field_a).toEqual('Field A must be bigger than field B'); + expect(handleValidation({ field_a: 2, field_b: 0 }).formErrors).toEqual(undefined); + }); + + it('smaller: field_a < field_b', () => { + const schema = createSchemaWithRulesOnFieldA({ + a_less_than_b: { + errorMessage: 'Field A must be smaller than field B', + rule: { '<': [{ var: 'field_a' }, { var: 'field_b' }] }, + }, + }); + const { handleValidation } = createHeadlessForm(schema, { strictInputType: false }); + const { formErrors } = handleValidation({ field_a: 2, field_b: 2 }); + expect(formErrors.field_a).toEqual('Field A must be smaller than field B'); + expect(handleValidation({ field_a: 0, field_b: 2 }).formErrors).toEqual(undefined); + }); + + it('equal: field_a = field_b', () => { + const schema = createSchemaWithRulesOnFieldA({ + a_equals_b: { + errorMessage: 'Field A must equal field B', + rule: { '==': [{ var: 'field_a' }, { var: 'field_b' }] }, + }, + }); + const { handleValidation } = createHeadlessForm(schema, { strictInputType: false }); + const { formErrors } = handleValidation({ field_a: 3, field_b: 2 }); + expect(formErrors.field_a).toEqual('Field A must equal field B'); + expect(handleValidation({ field_a: 2, field_b: 2 }).formErrors).toEqual(undefined); + }); + }); + describe('Incorrectly written schemas', () => { beforeEach(() => { jest.spyOn(console, 'error').mockImplementation(() => {}); @@ -218,47 +259,6 @@ describe('cross-value validations', () => { }); }); - describe('Relative: <, >, =', () => { - it('bigger: field_a > field_b', () => { - const schema = createSchemaWithRulesOnFieldA({ - a_greater_than_b: { - errorMessage: 'Field A must be bigger than field B', - rule: { '>': [{ var: 'field_a' }, { var: 'field_b' }] }, - }, - }); - const { handleValidation } = createHeadlessForm(schema, { strictInputType: false }); - const { formErrors } = handleValidation({ field_a: 1, field_b: 2 }); - expect(formErrors.field_a).toEqual('Field A must be bigger than field B'); - expect(handleValidation({ field_a: 2, field_b: 0 }).formErrors).toEqual(undefined); - }); - - it('smaller: field_a < field_b', () => { - const schema = createSchemaWithRulesOnFieldA({ - a_less_than_b: { - errorMessage: 'Field A must be smaller than field B', - rule: { '<': [{ var: 'field_a' }, { var: 'field_b' }] }, - }, - }); - const { handleValidation } = createHeadlessForm(schema, { strictInputType: false }); - const { formErrors } = handleValidation({ field_a: 2, field_b: 2 }); - expect(formErrors.field_a).toEqual('Field A must be smaller than field B'); - expect(handleValidation({ field_a: 0, field_b: 2 }).formErrors).toEqual(undefined); - }); - - it('equal: field_a = field_b', () => { - const schema = createSchemaWithRulesOnFieldA({ - a_equals_b: { - errorMessage: 'Field A must equal field B', - rule: { '==': [{ var: 'field_a' }, { var: 'field_b' }] }, - }, - }); - const { handleValidation } = createHeadlessForm(schema, { strictInputType: false }); - const { formErrors } = handleValidation({ field_a: 3, field_b: 2 }); - expect(formErrors.field_a).toEqual('Field A must equal field B'); - expect(handleValidation({ field_a: 2, field_b: 2 }).formErrors).toEqual(undefined); - }); - }); - describe('Arithmetic: +, -, *, /', () => { it('multiple: field_a > field_b * 2', () => { const schema = createSchemaWithRulesOnFieldA({ From e16a5a672cb9aa00e30f10cb90051d0d3064ee6e Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 13:13:25 +0200 Subject: [PATCH 08/10] chore: move errors around --- src/tests/jsonLogic.test.js | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/tests/jsonLogic.test.js b/src/tests/jsonLogic.test.js index 3f4c8a08b..5715bce33 100644 --- a/src/tests/jsonLogic.test.js +++ b/src/tests/jsonLogic.test.js @@ -144,14 +144,6 @@ describe('cross-value validations', () => { ); }); - it('Should throw when theres an inline computed ruleset with no value.', () => { - createHeadlessForm(schemaWithMissingValueInlineRule, { strictInputType: false }); - expect(console.error).toHaveBeenCalledWith( - 'JSON Schema invalid!', - Error('Cannot define multiple rules without a template string with key `value`.') - ); - }); - it('Should throw when a var does not exist in a rule.', () => { createHeadlessForm(schemaWithVarThatDoesNotExist, { strictInputType: false }); expect(console.error).toHaveBeenCalledWith( @@ -160,69 +152,77 @@ describe('cross-value validations', () => { ); }); - it('Should throw when a var does not exist in a deeply nested rule', () => { - createHeadlessForm(schemaWithDeepVarThatDoesNotExist, { strictInputType: false }); + it('Should throw when theres an inline computed ruleset with no value.', () => { + createHeadlessForm(schemaWithMissingValueInlineRule, { strictInputType: false }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error('"field_b" in rule "a_greater_than_ten" does not exist as a JSON schema property.') + Error('Cannot define multiple rules without a template string with key `value`.') ); }); - it('Should throw when a var does not exist in a fieldset.', () => { - createHeadlessForm(schemaWithDeepVarThatDoesNotExistOnFieldset, { strictInputType: false }); + it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist.', () => { + createHeadlessForm(schemaWithComputedAttributeThatDoesntExist, { + strictInputType: false, + }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error('"field_a" in rule "a_greater_than_ten" does not exist as a JSON schema property.') + Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) ); }); - it('On a property, it should throw an error for a requiredValidation that does not exist', () => { - createHeadlessForm(schemaWithValidationThatDoesNotExistOnProperty, { + it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a title.', () => { + createHeadlessForm(schemaWithComputedAttributeThatDoesntExistTitle, { strictInputType: false, }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error(`Validation "iDontExist" required for "field_a" doesn't exist.`) + Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) ); }); - it('A top level logic keyword will not be able to reference fieldset properties', () => { - createHeadlessForm(schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset, { + it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a description.', () => { + createHeadlessForm(schemaWithComputedAttributeThatDoesntExistDescription, { strictInputType: false, }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error('"child" in rule "validation_parent" does not exist as a JSON schema property.') + Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) ); }); - it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist.', () => { - createHeadlessForm(schemaWithComputedAttributeThatDoesntExist, { - strictInputType: false, - }); + it('Should throw when a var does not exist in a deeply nested rule', () => { + createHeadlessForm(schemaWithDeepVarThatDoesNotExist, { strictInputType: false }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) + Error('"field_b" in rule "a_greater_than_ten" does not exist as a JSON schema property.') ); }); - it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a title.', () => { - createHeadlessForm(schemaWithComputedAttributeThatDoesntExistTitle, { + it('Should throw when a var does not exist in a fieldset.', () => { + createHeadlessForm(schemaWithDeepVarThatDoesNotExistOnFieldset, { strictInputType: false }); + expect(console.error).toHaveBeenCalledWith( + 'JSON Schema invalid!', + Error('"field_a" in rule "a_greater_than_ten" does not exist as a JSON schema property.') + ); + }); + + it('On a property, it should throw an error for a requiredValidation that does not exist', () => { + createHeadlessForm(schemaWithValidationThatDoesNotExistOnProperty, { strictInputType: false, }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) + Error(`Validation "iDontExist" required for "field_a" doesn't exist.`) ); }); - it('On x-jsf-logic-computedAttrs, error if theres a value that does not exist on a description.', () => { - createHeadlessForm(schemaWithComputedAttributeThatDoesntExistDescription, { + it('A top level logic keyword will not be able to reference fieldset properties', () => { + createHeadlessForm(schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset, { strictInputType: false, }); expect(console.error).toHaveBeenCalledWith( 'JSON Schema invalid!', - Error(`"iDontExist" computedValue in field "field_a" doesn't exist.`) + Error('"child" in rule "validation_parent" does not exist as a JSON schema property.') ); }); From 900973dab73e0aef9ef27ef23715de1fcabf83ac Mon Sep 17 00:00:00 2001 From: brennj Date: Thu, 24 Aug 2023 15:21:28 +0200 Subject: [PATCH 09/10] chore: remove const tests --- src/tests/const.test.js | 58 ----------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/tests/const.test.js diff --git a/src/tests/const.test.js b/src/tests/const.test.js deleted file mode 100644 index 4438ea070..000000000 --- a/src/tests/const.test.js +++ /dev/null @@ -1,58 +0,0 @@ -import { createHeadlessForm } from '../createHeadlessForm'; - -it('Should work for number', () => { - const { handleValidation } = createHeadlessForm( - { - properties: { - ten_only: { type: 'number', const: 10 }, - }, - }, - { strictInputType: false } - ); - expect(handleValidation({}).formErrors).toEqual(undefined); - expect(handleValidation({ ten_only: 1 }).formErrors).toEqual({ - ten_only: 'The only accepted value is 10.', - }); - expect(handleValidation({ ten_only: 10 }).formErrors).toEqual(undefined); -}); - -it('Should work for text', () => { - const { handleValidation } = createHeadlessForm( - { - properties: { - hello_only: { type: 'string', const: 'hello' }, - }, - }, - { strictInputType: false } - ); - expect(handleValidation({}).formErrors).toEqual(undefined); - expect(handleValidation({ hello_only: 'what' }).formErrors).toEqual({ - hello_only: 'The only accepted value is hello.', - }); - expect(handleValidation({ hello_only: 'hello' }).formErrors).toEqual(undefined); -}); - -it('Should work for a conditionally applied const', () => { - const { handleValidation } = createHeadlessForm( - { - properties: { - answer: { type: 'string', oneOf: [{ const: 'yes' }, { const: 'no' }] }, - amount: { description: 'If you select yes, this needs to be exactly 10.', type: 'number' }, - }, - allOf: [ - { - if: { properties: { answer: { const: 'yes' } }, required: ['answer'] }, - then: { properties: { amount: { const: 10 } }, required: ['amount'] }, - }, - ], - }, - { strictInputType: false } - ); - expect(handleValidation({}).formErrors).toEqual(undefined); - expect(handleValidation({ answer: 'no' }).formErrors).toEqual(undefined); - expect(handleValidation({ answer: 'yes' }).formErrors).toEqual({ amount: 'Required field' }); - expect(handleValidation({ answer: 'yes', amount: 1 }).formErrors).toEqual({ - amount: 'The only accepted value is 10.', - }); - expect(handleValidation({ answer: 'yes', amount: 10 }).formErrors).toEqual(undefined); -}); From 4aa9de15ffe8a2dc24dda3028cbb1400b1b1c835 Mon Sep 17 00:00:00 2001 From: brennj Date: Tue, 29 Aug 2023 12:14:14 +0200 Subject: [PATCH 10/10] Release 0.4.4-dev.20230829101351 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0e99e7af..0b7eebeb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@remoteoss/json-schema-form", - "version": "0.4.3-beta.0", + "version": "0.4.4-dev.20230829101351", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@remoteoss/json-schema-form", - "version": "0.4.3-beta.0", + "version": "0.4.4-dev.20230829101351", "license": "MIT", "dependencies": { "json-logic-js": "^2.0.2", diff --git a/package.json b/package.json index b1151cd36..5b595e6a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "0.4.3-beta.0", + "version": "0.4.4-dev.20230829101351", "description": "Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", "license": "MIT",