ibm-cloud-sdk-core 4.3.2 → 4.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/es/lib/sdk-test-helpers.js +1 -2
- package/iamtest.env +3 -0
- package/lib/sdk-test-helpers.js +11 -9
- package/package.json +3 -2
- package/sdk-test-utilities/node_modules/.package-lock.json +508 -0
- package/sdk-test-utilities/node_modules/@babel/code-frame/LICENSE +22 -0
- package/sdk-test-utilities/node_modules/@babel/code-frame/README.md +19 -0
- package/sdk-test-utilities/node_modules/@babel/code-frame/lib/index.js +156 -0
- package/sdk-test-utilities/node_modules/@babel/code-frame/lib/index.js.map +1 -0
- package/sdk-test-utilities/node_modules/@babel/code-frame/package.json +30 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/LICENSE +22 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/README.md +19 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/identifier.js +70 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +1 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/index.js +57 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/index.js.map +1 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/keyword.js +35 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +1 -0
- package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/package.json +31 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/LICENSE +22 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/README.md +19 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/lib/index.js +119 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/lib/index.js.map +1 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/index.js +165 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/license +9 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/package.json +56 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/readme.md +147 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/index.js +228 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/index.js.flow +93 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/license +9 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/package.json +71 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/readme.md +314 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/templates.js +128 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/types/index.d.ts +97 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/CHANGELOG.md +54 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/README.md +68 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/conversions.js +868 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/index.js +78 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/package.json +46 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/route.js +97 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/.eslintrc.json +43 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/LICENSE +8 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/README.md +11 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/index.js +152 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/package.json +25 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/test.js +7 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/index.js +11 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/license +21 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/package.json +41 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/readme.md +27 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/index.js +8 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/license +9 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/package.json +44 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/readme.md +70 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/browser.js +5 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/index.js +131 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/license +9 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/package.json +53 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/readme.md +66 -0
- package/sdk-test-utilities/node_modules/@babel/highlight/package.json +30 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/README.md +5 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/build/immutableUtils.js +66 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/build/index.d.ts +94 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/build/index.js +34 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/build/jasmineUtils.js +218 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/build/types.js +1 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/build/utils.js +462 -0
- package/sdk-test-utilities/node_modules/@jest/expect-utils/package.json +35 -0
- package/sdk-test-utilities/node_modules/@jest/schemas/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@jest/schemas/README.md +3 -0
- package/sdk-test-utilities/node_modules/@jest/schemas/build/index.d.ts +63 -0
- package/sdk-test-utilities/node_modules/@jest/schemas/build/index.js +60 -0
- package/sdk-test-utilities/node_modules/@jest/schemas/package.json +29 -0
- package/sdk-test-utilities/node_modules/@jest/types/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@jest/types/README.md +30 -0
- package/sdk-test-utilities/node_modules/@jest/types/build/Circus.js +1 -0
- package/sdk-test-utilities/node_modules/@jest/types/build/Config.js +1 -0
- package/sdk-test-utilities/node_modules/@jest/types/build/Global.js +1 -0
- package/sdk-test-utilities/node_modules/@jest/types/build/TestResult.js +1 -0
- package/sdk-test-utilities/node_modules/@jest/types/build/index.d.ts +1204 -0
- package/sdk-test-utilities/node_modules/@jest/types/build/index.js +1 -0
- package/sdk-test-utilities/node_modules/@jest/types/package.json +38 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/compiler.d.ts +35 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/compiler.js +577 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/index.d.ts +2 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/index.js +47 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/errors.d.ts +88 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/errors.js +609 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/index.d.ts +1 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/index.js +44 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/license +23 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/package.json +47 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/readme.md +1424 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/system/index.d.ts +1 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/system/index.js +44 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/system/system.d.ts +26 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/system/system.js +90 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/typebox.d.ts +723 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/typebox.js +2220 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/cast.d.ts +30 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/cast.js +372 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/check.d.ts +12 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/check.js +484 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/clone.d.ts +3 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/clone.js +71 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/convert.d.ts +13 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/convert.js +372 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/create.d.ts +26 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/create.js +480 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/delta.d.ts +43 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/delta.js +204 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/equal.d.ts +3 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/equal.js +80 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/hash.d.ts +8 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/hash.js +208 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/index.d.ts +6 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/index.js +56 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/is.d.ts +11 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/is.js +53 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/mutate.d.ts +13 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/mutate.js +121 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/pointer.d.ts +24 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/pointer.js +142 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/value.d.ts +39 -0
- package/sdk-test-utilities/node_modules/@sinclair/typebox/value/value.js +99 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/README.md +15 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/index.d.ts +111 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/package.json +25 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/README.md +15 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/index.d.ts +184 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/package.json +32 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-reports/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-reports/README.md +86 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-reports/index.d.ts +67 -0
- package/sdk-test-utilities/node_modules/@types/istanbul-reports/package.json +32 -0
- package/sdk-test-utilities/node_modules/@types/node/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/node/README.md +15 -0
- package/sdk-test-utilities/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/sdk-test-utilities/node_modules/@types/node/assert.d.ts +1040 -0
- package/sdk-test-utilities/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/sdk-test-utilities/node_modules/@types/node/buffer.d.ts +2363 -0
- package/sdk-test-utilities/node_modules/@types/node/child_process.d.ts +1544 -0
- package/sdk-test-utilities/node_modules/@types/node/cluster.d.ts +578 -0
- package/sdk-test-utilities/node_modules/@types/node/console.d.ts +452 -0
- package/sdk-test-utilities/node_modules/@types/node/constants.d.ts +19 -0
- package/sdk-test-utilities/node_modules/@types/node/crypto.d.ts +4523 -0
- package/sdk-test-utilities/node_modules/@types/node/dgram.d.ts +596 -0
- package/sdk-test-utilities/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/sdk-test-utilities/node_modules/@types/node/dns/promises.d.ts +474 -0
- package/sdk-test-utilities/node_modules/@types/node/dns.d.ts +864 -0
- package/sdk-test-utilities/node_modules/@types/node/dom-events.d.ts +124 -0
- package/sdk-test-utilities/node_modules/@types/node/domain.d.ts +170 -0
- package/sdk-test-utilities/node_modules/@types/node/events.d.ts +909 -0
- package/sdk-test-utilities/node_modules/@types/node/fs/promises.d.ts +1245 -0
- package/sdk-test-utilities/node_modules/@types/node/fs.d.ts +4317 -0
- package/sdk-test-utilities/node_modules/@types/node/globals.d.ts +411 -0
- package/sdk-test-utilities/node_modules/@types/node/globals.global.d.ts +1 -0
- package/sdk-test-utilities/node_modules/@types/node/http.d.ts +1908 -0
- package/sdk-test-utilities/node_modules/@types/node/http2.d.ts +2418 -0
- package/sdk-test-utilities/node_modules/@types/node/https.d.ts +550 -0
- package/sdk-test-utilities/node_modules/@types/node/index.d.ts +89 -0
- package/sdk-test-utilities/node_modules/@types/node/inspector.d.ts +2746 -0
- package/sdk-test-utilities/node_modules/@types/node/module.d.ts +315 -0
- package/sdk-test-utilities/node_modules/@types/node/net.d.ts +999 -0
- package/sdk-test-utilities/node_modules/@types/node/os.d.ts +495 -0
- package/sdk-test-utilities/node_modules/@types/node/package.json +217 -0
- package/sdk-test-utilities/node_modules/@types/node/path.d.ts +191 -0
- package/sdk-test-utilities/node_modules/@types/node/perf_hooks.d.ts +905 -0
- package/sdk-test-utilities/node_modules/@types/node/process.d.ts +1754 -0
- package/sdk-test-utilities/node_modules/@types/node/punycode.d.ts +117 -0
- package/sdk-test-utilities/node_modules/@types/node/querystring.d.ts +153 -0
- package/sdk-test-utilities/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/sdk-test-utilities/node_modules/@types/node/readline.d.ts +540 -0
- package/sdk-test-utilities/node_modules/@types/node/repl.d.ts +430 -0
- package/sdk-test-utilities/node_modules/@types/node/sea.d.ts +153 -0
- package/sdk-test-utilities/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/sdk-test-utilities/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/sdk-test-utilities/node_modules/@types/node/stream/web.d.ts +367 -0
- package/sdk-test-utilities/node_modules/@types/node/stream.d.ts +1707 -0
- package/sdk-test-utilities/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/sdk-test-utilities/node_modules/@types/node/test.d.ts +1718 -0
- package/sdk-test-utilities/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/sdk-test-utilities/node_modules/@types/node/timers.d.ts +240 -0
- package/sdk-test-utilities/node_modules/@types/node/tls.d.ts +1217 -0
- package/sdk-test-utilities/node_modules/@types/node/trace_events.d.ts +197 -0
- package/sdk-test-utilities/node_modules/@types/node/tty.d.ts +208 -0
- package/sdk-test-utilities/node_modules/@types/node/url.d.ts +952 -0
- package/sdk-test-utilities/node_modules/@types/node/util.d.ts +2292 -0
- package/sdk-test-utilities/node_modules/@types/node/v8.d.ts +808 -0
- package/sdk-test-utilities/node_modules/@types/node/vm.d.ts +924 -0
- package/sdk-test-utilities/node_modules/@types/node/wasi.d.ts +181 -0
- package/sdk-test-utilities/node_modules/@types/node/worker_threads.d.ts +691 -0
- package/sdk-test-utilities/node_modules/@types/node/zlib.d.ts +530 -0
- package/sdk-test-utilities/node_modules/@types/stack-utils/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/stack-utils/README.md +78 -0
- package/sdk-test-utilities/node_modules/@types/stack-utils/index.d.ts +59 -0
- package/sdk-test-utilities/node_modules/@types/stack-utils/package.json +25 -0
- package/sdk-test-utilities/node_modules/@types/yargs/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/yargs/README.md +15 -0
- package/sdk-test-utilities/node_modules/@types/yargs/helpers.d.mts +1 -0
- package/sdk-test-utilities/node_modules/@types/yargs/helpers.d.ts +5 -0
- package/sdk-test-utilities/node_modules/@types/yargs/index.d.mts +46 -0
- package/sdk-test-utilities/node_modules/@types/yargs/index.d.ts +1031 -0
- package/sdk-test-utilities/node_modules/@types/yargs/package.json +87 -0
- package/sdk-test-utilities/node_modules/@types/yargs/yargs.d.ts +9 -0
- package/sdk-test-utilities/node_modules/@types/yargs-parser/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/@types/yargs-parser/README.md +15 -0
- package/sdk-test-utilities/node_modules/@types/yargs-parser/index.d.ts +112 -0
- package/sdk-test-utilities/node_modules/@types/yargs-parser/package.json +25 -0
- package/sdk-test-utilities/node_modules/ansi-styles/index.d.ts +345 -0
- package/sdk-test-utilities/node_modules/ansi-styles/index.js +163 -0
- package/sdk-test-utilities/node_modules/ansi-styles/license +9 -0
- package/sdk-test-utilities/node_modules/ansi-styles/package.json +56 -0
- package/sdk-test-utilities/node_modules/ansi-styles/readme.md +152 -0
- package/sdk-test-utilities/node_modules/braces/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/braces/README.md +586 -0
- package/sdk-test-utilities/node_modules/braces/index.js +170 -0
- package/sdk-test-utilities/node_modules/braces/lib/compile.js +60 -0
- package/sdk-test-utilities/node_modules/braces/lib/constants.js +57 -0
- package/sdk-test-utilities/node_modules/braces/lib/expand.js +113 -0
- package/sdk-test-utilities/node_modules/braces/lib/parse.js +331 -0
- package/sdk-test-utilities/node_modules/braces/lib/stringify.js +32 -0
- package/sdk-test-utilities/node_modules/braces/lib/utils.js +122 -0
- package/sdk-test-utilities/node_modules/braces/package.json +77 -0
- package/sdk-test-utilities/node_modules/chalk/index.d.ts +415 -0
- package/sdk-test-utilities/node_modules/chalk/license +9 -0
- package/sdk-test-utilities/node_modules/chalk/package.json +68 -0
- package/sdk-test-utilities/node_modules/chalk/readme.md +341 -0
- package/sdk-test-utilities/node_modules/chalk/source/index.js +229 -0
- package/sdk-test-utilities/node_modules/chalk/source/templates.js +134 -0
- package/sdk-test-utilities/node_modules/chalk/source/util.js +39 -0
- package/sdk-test-utilities/node_modules/ci-info/CHANGELOG.md +178 -0
- package/sdk-test-utilities/node_modules/ci-info/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/ci-info/README.md +135 -0
- package/sdk-test-utilities/node_modules/ci-info/index.d.ts +75 -0
- package/sdk-test-utilities/node_modules/ci-info/index.js +90 -0
- package/sdk-test-utilities/node_modules/ci-info/package.json +45 -0
- package/sdk-test-utilities/node_modules/ci-info/vendors.json +321 -0
- package/sdk-test-utilities/node_modules/color-convert/CHANGELOG.md +54 -0
- package/sdk-test-utilities/node_modules/color-convert/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/color-convert/README.md +68 -0
- package/sdk-test-utilities/node_modules/color-convert/conversions.js +839 -0
- package/sdk-test-utilities/node_modules/color-convert/index.js +81 -0
- package/sdk-test-utilities/node_modules/color-convert/package.json +48 -0
- package/sdk-test-utilities/node_modules/color-convert/route.js +97 -0
- package/sdk-test-utilities/node_modules/color-name/LICENSE +8 -0
- package/sdk-test-utilities/node_modules/color-name/README.md +11 -0
- package/sdk-test-utilities/node_modules/color-name/index.js +152 -0
- package/sdk-test-utilities/node_modules/color-name/package.json +28 -0
- package/sdk-test-utilities/node_modules/diff-sequences/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/diff-sequences/README.md +404 -0
- package/sdk-test-utilities/node_modules/diff-sequences/build/index.d.ts +38 -0
- package/sdk-test-utilities/node_modules/diff-sequences/build/index.js +798 -0
- package/sdk-test-utilities/node_modules/diff-sequences/package.json +39 -0
- package/sdk-test-utilities/node_modules/escape-string-regexp/index.d.ts +18 -0
- package/sdk-test-utilities/node_modules/escape-string-regexp/index.js +11 -0
- package/sdk-test-utilities/node_modules/escape-string-regexp/license +9 -0
- package/sdk-test-utilities/node_modules/escape-string-regexp/package.json +43 -0
- package/sdk-test-utilities/node_modules/escape-string-regexp/readme.md +29 -0
- package/sdk-test-utilities/node_modules/expect/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/expect/README.md +3 -0
- package/sdk-test-utilities/node_modules/expect/build/asymmetricMatchers.js +375 -0
- package/sdk-test-utilities/node_modules/expect/build/extractExpectedAssertionsErrors.js +86 -0
- package/sdk-test-utilities/node_modules/expect/build/index.d.ts +370 -0
- package/sdk-test-utilities/node_modules/expect/build/index.js +410 -0
- package/sdk-test-utilities/node_modules/expect/build/jestMatchersObject.js +123 -0
- package/sdk-test-utilities/node_modules/expect/build/matchers.js +1292 -0
- package/sdk-test-utilities/node_modules/expect/build/print.js +122 -0
- package/sdk-test-utilities/node_modules/expect/build/spyMatchers.js +1254 -0
- package/sdk-test-utilities/node_modules/expect/build/toThrowMatchers.js +481 -0
- package/sdk-test-utilities/node_modules/expect/build/types.js +3 -0
- package/sdk-test-utilities/node_modules/expect/package.json +43 -0
- package/sdk-test-utilities/node_modules/fill-range/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/fill-range/README.md +237 -0
- package/sdk-test-utilities/node_modules/fill-range/index.js +248 -0
- package/sdk-test-utilities/node_modules/fill-range/package.json +74 -0
- package/sdk-test-utilities/node_modules/graceful-fs/LICENSE +15 -0
- package/sdk-test-utilities/node_modules/graceful-fs/README.md +143 -0
- package/sdk-test-utilities/node_modules/graceful-fs/clone.js +23 -0
- package/sdk-test-utilities/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/sdk-test-utilities/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/sdk-test-utilities/node_modules/graceful-fs/package.json +53 -0
- package/sdk-test-utilities/node_modules/graceful-fs/polyfills.js +355 -0
- package/sdk-test-utilities/node_modules/has-flag/index.d.ts +39 -0
- package/sdk-test-utilities/node_modules/has-flag/index.js +8 -0
- package/sdk-test-utilities/node_modules/has-flag/license +9 -0
- package/sdk-test-utilities/node_modules/has-flag/package.json +46 -0
- package/sdk-test-utilities/node_modules/has-flag/readme.md +89 -0
- package/sdk-test-utilities/node_modules/is-number/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/is-number/README.md +187 -0
- package/sdk-test-utilities/node_modules/is-number/index.js +18 -0
- package/sdk-test-utilities/node_modules/is-number/package.json +82 -0
- package/sdk-test-utilities/node_modules/jest-diff/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/jest-diff/README.md +671 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/cleanupSemantic.js +599 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/constants.js +19 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/diffLines.js +193 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/diffStrings.js +66 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/getAlignedDiffs.js +223 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/index.d.ts +93 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/index.js +232 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/joinAlignedDiffs.js +271 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/normalizeDiffOptions.js +59 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/printDiffs.js +79 -0
- package/sdk-test-utilities/node_modules/jest-diff/build/types.js +1 -0
- package/sdk-test-utilities/node_modules/jest-diff/package.json +36 -0
- package/sdk-test-utilities/node_modules/jest-get-type/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/jest-get-type/build/index.d.ts +27 -0
- package/sdk-test-utilities/node_modules/jest-get-type/build/index.js +53 -0
- package/sdk-test-utilities/node_modules/jest-get-type/package.json +27 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/README.md +24 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/build/Replaceable.js +64 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/build/deepCyclicCopyReplaceable.js +111 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/build/index.d.ts +138 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/build/index.js +542 -0
- package/sdk-test-utilities/node_modules/jest-matcher-utils/package.json +37 -0
- package/sdk-test-utilities/node_modules/jest-message-util/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/jest-message-util/build/index.d.ts +68 -0
- package/sdk-test-utilities/node_modules/jest-message-util/build/index.js +518 -0
- package/sdk-test-utilities/node_modules/jest-message-util/build/types.js +1 -0
- package/sdk-test-utilities/node_modules/jest-message-util/package.json +43 -0
- package/sdk-test-utilities/node_modules/jest-util/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/jest-util/Readme.md +87 -0
- package/sdk-test-utilities/node_modules/jest-util/build/ErrorWithStack.js +28 -0
- package/sdk-test-utilities/node_modules/jest-util/build/clearLine.js +18 -0
- package/sdk-test-utilities/node_modules/jest-util/build/convertDescriptorToString.js +30 -0
- package/sdk-test-utilities/node_modules/jest-util/build/createDirectory.js +71 -0
- package/sdk-test-utilities/node_modules/jest-util/build/createProcessObject.js +109 -0
- package/sdk-test-utilities/node_modules/jest-util/build/deepCyclicCopy.js +76 -0
- package/sdk-test-utilities/node_modules/jest-util/build/formatTime.js +24 -0
- package/sdk-test-utilities/node_modules/jest-util/build/globsToMatcher.js +98 -0
- package/sdk-test-utilities/node_modules/jest-util/build/index.d.ts +136 -0
- package/sdk-test-utilities/node_modules/jest-util/build/index.js +199 -0
- package/sdk-test-utilities/node_modules/jest-util/build/installCommonGlobals.js +115 -0
- package/sdk-test-utilities/node_modules/jest-util/build/interopRequireDefault.js +22 -0
- package/sdk-test-utilities/node_modules/jest-util/build/invariant.js +18 -0
- package/sdk-test-utilities/node_modules/jest-util/build/isInteractive.js +22 -0
- package/sdk-test-utilities/node_modules/jest-util/build/isNonNullable.js +16 -0
- package/sdk-test-utilities/node_modules/jest-util/build/isPromise.js +20 -0
- package/sdk-test-utilities/node_modules/jest-util/build/pluralize.js +16 -0
- package/sdk-test-utilities/node_modules/jest-util/build/preRunMessage.js +38 -0
- package/sdk-test-utilities/node_modules/jest-util/build/replacePathSepForGlob.js +16 -0
- package/sdk-test-utilities/node_modules/jest-util/build/requireOrImportModule.js +77 -0
- package/sdk-test-utilities/node_modules/jest-util/build/setGlobal.js +17 -0
- package/sdk-test-utilities/node_modules/jest-util/build/specialChars.js +25 -0
- package/sdk-test-utilities/node_modules/jest-util/build/testPathPatternToRegExp.js +19 -0
- package/sdk-test-utilities/node_modules/jest-util/build/tryRealpath.js +30 -0
- package/sdk-test-utilities/node_modules/jest-util/package.json +38 -0
- package/sdk-test-utilities/node_modules/js-tokens/CHANGELOG.md +151 -0
- package/sdk-test-utilities/node_modules/js-tokens/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/js-tokens/README.md +240 -0
- package/sdk-test-utilities/node_modules/js-tokens/index.js +23 -0
- package/sdk-test-utilities/node_modules/js-tokens/package.json +30 -0
- package/sdk-test-utilities/node_modules/micromatch/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/micromatch/README.md +1017 -0
- package/sdk-test-utilities/node_modules/micromatch/index.js +467 -0
- package/sdk-test-utilities/node_modules/micromatch/package.json +101 -0
- package/sdk-test-utilities/node_modules/picocolors/LICENSE +15 -0
- package/sdk-test-utilities/node_modules/picocolors/README.md +21 -0
- package/sdk-test-utilities/node_modules/picocolors/package.json +25 -0
- package/sdk-test-utilities/node_modules/picocolors/picocolors.browser.js +4 -0
- package/sdk-test-utilities/node_modules/picocolors/picocolors.d.ts +5 -0
- package/sdk-test-utilities/node_modules/picocolors/picocolors.js +65 -0
- package/sdk-test-utilities/node_modules/picomatch/CHANGELOG.md +136 -0
- package/sdk-test-utilities/node_modules/picomatch/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/picomatch/README.md +708 -0
- package/sdk-test-utilities/node_modules/picomatch/index.js +3 -0
- package/sdk-test-utilities/node_modules/picomatch/lib/constants.js +179 -0
- package/sdk-test-utilities/node_modules/picomatch/lib/parse.js +1091 -0
- package/sdk-test-utilities/node_modules/picomatch/lib/picomatch.js +342 -0
- package/sdk-test-utilities/node_modules/picomatch/lib/scan.js +391 -0
- package/sdk-test-utilities/node_modules/picomatch/lib/utils.js +64 -0
- package/sdk-test-utilities/node_modules/picomatch/package.json +81 -0
- package/sdk-test-utilities/node_modules/pretty-format/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/pretty-format/README.md +463 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/collections.js +180 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/index.d.ts +163 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/index.js +478 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js +89 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/DOMCollection.js +67 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/DOMElement.js +101 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/Immutable.js +217 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/ReactElement.js +143 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/ReactTestComponent.js +66 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/lib/escapeHTML.js +16 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/plugins/lib/markup.js +113 -0
- package/sdk-test-utilities/node_modules/pretty-format/build/types.js +1 -0
- package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/index.d.ts +167 -0
- package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/index.js +164 -0
- package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/license +9 -0
- package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/package.json +52 -0
- package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/readme.md +144 -0
- package/sdk-test-utilities/node_modules/pretty-format/package.json +43 -0
- package/sdk-test-utilities/node_modules/react-is/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/react-is/README.md +104 -0
- package/sdk-test-utilities/node_modules/react-is/cjs/react-is.development.js +221 -0
- package/sdk-test-utilities/node_modules/react-is/cjs/react-is.production.min.js +14 -0
- package/sdk-test-utilities/node_modules/react-is/index.js +7 -0
- package/sdk-test-utilities/node_modules/react-is/package.json +26 -0
- package/sdk-test-utilities/node_modules/react-is/umd/react-is.development.js +220 -0
- package/sdk-test-utilities/node_modules/react-is/umd/react-is.production.min.js +15 -0
- package/sdk-test-utilities/node_modules/slash/index.d.ts +25 -0
- package/sdk-test-utilities/node_modules/slash/index.js +11 -0
- package/sdk-test-utilities/node_modules/slash/license +9 -0
- package/sdk-test-utilities/node_modules/slash/package.json +35 -0
- package/sdk-test-utilities/node_modules/slash/readme.md +44 -0
- package/sdk-test-utilities/node_modules/stack-utils/LICENSE.md +21 -0
- package/sdk-test-utilities/node_modules/stack-utils/index.js +344 -0
- package/sdk-test-utilities/node_modules/stack-utils/package.json +39 -0
- package/sdk-test-utilities/node_modules/stack-utils/readme.md +143 -0
- package/sdk-test-utilities/node_modules/supports-color/browser.js +5 -0
- package/sdk-test-utilities/node_modules/supports-color/index.js +135 -0
- package/sdk-test-utilities/node_modules/supports-color/license +9 -0
- package/sdk-test-utilities/node_modules/supports-color/package.json +53 -0
- package/sdk-test-utilities/node_modules/supports-color/readme.md +76 -0
- package/sdk-test-utilities/node_modules/to-regex-range/LICENSE +21 -0
- package/sdk-test-utilities/node_modules/to-regex-range/README.md +305 -0
- package/sdk-test-utilities/node_modules/to-regex-range/index.js +288 -0
- package/sdk-test-utilities/node_modules/to-regex-range/package.json +88 -0
- package/sdk-test-utilities/node_modules/undici-types/README.md +6 -0
- package/sdk-test-utilities/node_modules/undici-types/agent.d.ts +31 -0
- package/sdk-test-utilities/node_modules/undici-types/api.d.ts +43 -0
- package/sdk-test-utilities/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/sdk-test-utilities/node_modules/undici-types/cache.d.ts +36 -0
- package/sdk-test-utilities/node_modules/undici-types/client.d.ts +97 -0
- package/sdk-test-utilities/node_modules/undici-types/connector.d.ts +34 -0
- package/sdk-test-utilities/node_modules/undici-types/content-type.d.ts +21 -0
- package/sdk-test-utilities/node_modules/undici-types/cookies.d.ts +28 -0
- package/sdk-test-utilities/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/sdk-test-utilities/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/sdk-test-utilities/node_modules/undici-types/errors.d.ts +128 -0
- package/sdk-test-utilities/node_modules/undici-types/fetch.d.ts +209 -0
- package/sdk-test-utilities/node_modules/undici-types/file.d.ts +39 -0
- package/sdk-test-utilities/node_modules/undici-types/filereader.d.ts +54 -0
- package/sdk-test-utilities/node_modules/undici-types/formdata.d.ts +108 -0
- package/sdk-test-utilities/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/sdk-test-utilities/node_modules/undici-types/global-origin.d.ts +7 -0
- package/sdk-test-utilities/node_modules/undici-types/handlers.d.ts +9 -0
- package/sdk-test-utilities/node_modules/undici-types/header.d.ts +4 -0
- package/sdk-test-utilities/node_modules/undici-types/index.d.ts +63 -0
- package/sdk-test-utilities/node_modules/undici-types/interceptors.d.ts +5 -0
- package/sdk-test-utilities/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/sdk-test-utilities/node_modules/undici-types/mock-client.d.ts +25 -0
- package/sdk-test-utilities/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/sdk-test-utilities/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/sdk-test-utilities/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/sdk-test-utilities/node_modules/undici-types/package.json +55 -0
- package/sdk-test-utilities/node_modules/undici-types/patch.d.ts +71 -0
- package/sdk-test-utilities/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/sdk-test-utilities/node_modules/undici-types/pool.d.ts +28 -0
- package/sdk-test-utilities/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/sdk-test-utilities/node_modules/undici-types/readable.d.ts +61 -0
- package/sdk-test-utilities/node_modules/undici-types/webidl.d.ts +220 -0
- package/sdk-test-utilities/node_modules/undici-types/websocket.d.ts +131 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jest/types",
|
|
3
|
+
"version": "29.6.3",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/jestjs/jest.git",
|
|
7
|
+
"directory": "packages/jest-types"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"main": "./build/index.js",
|
|
14
|
+
"types": "./build/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./build/index.d.ts",
|
|
18
|
+
"default": "./build/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@jest/schemas": "^29.6.3",
|
|
24
|
+
"@types/istanbul-lib-coverage": "^2.0.0",
|
|
25
|
+
"@types/istanbul-reports": "^3.0.0",
|
|
26
|
+
"@types/node": "*",
|
|
27
|
+
"@types/yargs": "^17.0.8",
|
|
28
|
+
"chalk": "^4.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@tsd/typescript": "^5.0.4",
|
|
32
|
+
"tsd-lite": "^0.7.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "fb7d95c8af6e0d65a8b65348433d8a0ea0725b5b"
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Types from '../typebox';
|
|
2
|
+
import { ValueErrorIterator } from '../errors/index';
|
|
3
|
+
export type CheckFunction = (value: unknown) => boolean;
|
|
4
|
+
export declare class TypeCheck<T extends Types.TSchema> {
|
|
5
|
+
private readonly schema;
|
|
6
|
+
private readonly references;
|
|
7
|
+
private readonly checkFunc;
|
|
8
|
+
private readonly code;
|
|
9
|
+
constructor(schema: T, references: Types.TSchema[], checkFunc: CheckFunction, code: string);
|
|
10
|
+
/** Returns the generated assertion code used to validate this type. */
|
|
11
|
+
Code(): string;
|
|
12
|
+
/** Returns an iterator for each error in this value. */
|
|
13
|
+
Errors(value: unknown): ValueErrorIterator;
|
|
14
|
+
/** Returns true if the value matches the compiled type. */
|
|
15
|
+
Check(value: unknown): value is Types.Static<T>;
|
|
16
|
+
}
|
|
17
|
+
export declare class TypeCompilerUnknownTypeError extends Error {
|
|
18
|
+
readonly schema: Types.TSchema;
|
|
19
|
+
constructor(schema: Types.TSchema);
|
|
20
|
+
}
|
|
21
|
+
export declare class TypeCompilerDereferenceError extends Error {
|
|
22
|
+
readonly schema: Types.TRef;
|
|
23
|
+
constructor(schema: Types.TRef);
|
|
24
|
+
}
|
|
25
|
+
export declare class TypeCompilerTypeGuardError extends Error {
|
|
26
|
+
readonly schema: Types.TSchema;
|
|
27
|
+
constructor(schema: Types.TSchema);
|
|
28
|
+
}
|
|
29
|
+
/** Compiles Types for Runtime Type Checking */
|
|
30
|
+
export declare namespace TypeCompiler {
|
|
31
|
+
/** Returns the generated assertion code used to validate this type. */
|
|
32
|
+
function Code<T extends Types.TSchema>(schema: T, references?: Types.TSchema[]): string;
|
|
33
|
+
/** Compiles the given type for runtime type checking. This compiler only accepts known TypeBox types non-inclusive of unsafe types. */
|
|
34
|
+
function Compile<T extends Types.TSchema>(schema: T, references?: Types.TSchema[]): TypeCheck<T>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
|
|
4
|
+
@sinclair/typebox/compiler
|
|
5
|
+
|
|
6
|
+
The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
|
|
28
|
+
---------------------------------------------------------------------------*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.TypeCompiler = exports.TypeCompilerTypeGuardError = exports.TypeCompilerDereferenceError = exports.TypeCompilerUnknownTypeError = exports.TypeCheck = void 0;
|
|
31
|
+
const Types = require("../typebox");
|
|
32
|
+
const index_1 = require("../errors/index");
|
|
33
|
+
const index_2 = require("../system/index");
|
|
34
|
+
const hash_1 = require("../value/hash");
|
|
35
|
+
// -------------------------------------------------------------------
|
|
36
|
+
// TypeCheck
|
|
37
|
+
// -------------------------------------------------------------------
|
|
38
|
+
class TypeCheck {
|
|
39
|
+
constructor(schema, references, checkFunc, code) {
|
|
40
|
+
this.schema = schema;
|
|
41
|
+
this.references = references;
|
|
42
|
+
this.checkFunc = checkFunc;
|
|
43
|
+
this.code = code;
|
|
44
|
+
}
|
|
45
|
+
/** Returns the generated assertion code used to validate this type. */
|
|
46
|
+
Code() {
|
|
47
|
+
return this.code;
|
|
48
|
+
}
|
|
49
|
+
/** Returns an iterator for each error in this value. */
|
|
50
|
+
Errors(value) {
|
|
51
|
+
return index_1.ValueErrors.Errors(this.schema, this.references, value);
|
|
52
|
+
}
|
|
53
|
+
/** Returns true if the value matches the compiled type. */
|
|
54
|
+
Check(value) {
|
|
55
|
+
return this.checkFunc(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.TypeCheck = TypeCheck;
|
|
59
|
+
// -------------------------------------------------------------------
|
|
60
|
+
// Character
|
|
61
|
+
// -------------------------------------------------------------------
|
|
62
|
+
var Character;
|
|
63
|
+
(function (Character) {
|
|
64
|
+
function DollarSign(code) {
|
|
65
|
+
return code === 36;
|
|
66
|
+
}
|
|
67
|
+
Character.DollarSign = DollarSign;
|
|
68
|
+
function IsUnderscore(code) {
|
|
69
|
+
return code === 95;
|
|
70
|
+
}
|
|
71
|
+
Character.IsUnderscore = IsUnderscore;
|
|
72
|
+
function IsAlpha(code) {
|
|
73
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
74
|
+
}
|
|
75
|
+
Character.IsAlpha = IsAlpha;
|
|
76
|
+
function IsNumeric(code) {
|
|
77
|
+
return code >= 48 && code <= 57;
|
|
78
|
+
}
|
|
79
|
+
Character.IsNumeric = IsNumeric;
|
|
80
|
+
})(Character || (Character = {}));
|
|
81
|
+
// -------------------------------------------------------------------
|
|
82
|
+
// MemberExpression
|
|
83
|
+
// -------------------------------------------------------------------
|
|
84
|
+
var MemberExpression;
|
|
85
|
+
(function (MemberExpression) {
|
|
86
|
+
function IsFirstCharacterNumeric(value) {
|
|
87
|
+
if (value.length === 0)
|
|
88
|
+
return false;
|
|
89
|
+
return Character.IsNumeric(value.charCodeAt(0));
|
|
90
|
+
}
|
|
91
|
+
function IsAccessor(value) {
|
|
92
|
+
if (IsFirstCharacterNumeric(value))
|
|
93
|
+
return false;
|
|
94
|
+
for (let i = 0; i < value.length; i++) {
|
|
95
|
+
const code = value.charCodeAt(i);
|
|
96
|
+
const check = Character.IsAlpha(code) || Character.IsNumeric(code) || Character.DollarSign(code) || Character.IsUnderscore(code);
|
|
97
|
+
if (!check)
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function EscapeHyphen(key) {
|
|
103
|
+
return key.replace(/'/g, "\\'");
|
|
104
|
+
}
|
|
105
|
+
function Encode(object, key) {
|
|
106
|
+
return IsAccessor(key) ? `${object}.${key}` : `${object}['${EscapeHyphen(key)}']`;
|
|
107
|
+
}
|
|
108
|
+
MemberExpression.Encode = Encode;
|
|
109
|
+
})(MemberExpression || (MemberExpression = {}));
|
|
110
|
+
// -------------------------------------------------------------------
|
|
111
|
+
// Identifier
|
|
112
|
+
// -------------------------------------------------------------------
|
|
113
|
+
var Identifier;
|
|
114
|
+
(function (Identifier) {
|
|
115
|
+
function Encode($id) {
|
|
116
|
+
const buffer = [];
|
|
117
|
+
for (let i = 0; i < $id.length; i++) {
|
|
118
|
+
const code = $id.charCodeAt(i);
|
|
119
|
+
if (Character.IsNumeric(code) || Character.IsAlpha(code)) {
|
|
120
|
+
buffer.push($id.charAt(i));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
buffer.push(`_${code}_`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return buffer.join('').replace(/__/g, '_');
|
|
127
|
+
}
|
|
128
|
+
Identifier.Encode = Encode;
|
|
129
|
+
})(Identifier || (Identifier = {}));
|
|
130
|
+
// -------------------------------------------------------------------
|
|
131
|
+
// TypeCompiler
|
|
132
|
+
// -------------------------------------------------------------------
|
|
133
|
+
class TypeCompilerUnknownTypeError extends Error {
|
|
134
|
+
constructor(schema) {
|
|
135
|
+
super('TypeCompiler: Unknown type');
|
|
136
|
+
this.schema = schema;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.TypeCompilerUnknownTypeError = TypeCompilerUnknownTypeError;
|
|
140
|
+
class TypeCompilerDereferenceError extends Error {
|
|
141
|
+
constructor(schema) {
|
|
142
|
+
super(`TypeCompiler: Unable to dereference schema with $id '${schema.$ref}'`);
|
|
143
|
+
this.schema = schema;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.TypeCompilerDereferenceError = TypeCompilerDereferenceError;
|
|
147
|
+
class TypeCompilerTypeGuardError extends Error {
|
|
148
|
+
constructor(schema) {
|
|
149
|
+
super('TypeCompiler: Preflight validation check failed to guard for the given schema');
|
|
150
|
+
this.schema = schema;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.TypeCompilerTypeGuardError = TypeCompilerTypeGuardError;
|
|
154
|
+
/** Compiles Types for Runtime Type Checking */
|
|
155
|
+
var TypeCompiler;
|
|
156
|
+
(function (TypeCompiler) {
|
|
157
|
+
// -------------------------------------------------------------------
|
|
158
|
+
// Guards
|
|
159
|
+
// -------------------------------------------------------------------
|
|
160
|
+
function IsBigInt(value) {
|
|
161
|
+
return typeof value === 'bigint';
|
|
162
|
+
}
|
|
163
|
+
function IsNumber(value) {
|
|
164
|
+
return typeof value === 'number' && globalThis.Number.isFinite(value);
|
|
165
|
+
}
|
|
166
|
+
function IsString(value) {
|
|
167
|
+
return typeof value === 'string';
|
|
168
|
+
}
|
|
169
|
+
// -------------------------------------------------------------------
|
|
170
|
+
// Polices
|
|
171
|
+
// -------------------------------------------------------------------
|
|
172
|
+
function IsExactOptionalProperty(value, key, expression) {
|
|
173
|
+
return index_2.TypeSystem.ExactOptionalPropertyTypes ? `('${key}' in ${value} ? ${expression} : true)` : `(${MemberExpression.Encode(value, key)} !== undefined ? ${expression} : true)`;
|
|
174
|
+
}
|
|
175
|
+
function IsObjectCheck(value) {
|
|
176
|
+
return !index_2.TypeSystem.AllowArrayObjects ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}))` : `(typeof ${value} === 'object' && ${value} !== null)`;
|
|
177
|
+
}
|
|
178
|
+
function IsRecordCheck(value) {
|
|
179
|
+
return !index_2.TypeSystem.AllowArrayObjects
|
|
180
|
+
? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}) && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))`
|
|
181
|
+
: `(typeof ${value} === 'object' && ${value} !== null && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))`;
|
|
182
|
+
}
|
|
183
|
+
function IsNumberCheck(value) {
|
|
184
|
+
return !index_2.TypeSystem.AllowNaN ? `(typeof ${value} === 'number' && Number.isFinite(${value}))` : `typeof ${value} === 'number'`;
|
|
185
|
+
}
|
|
186
|
+
function IsVoidCheck(value) {
|
|
187
|
+
return index_2.TypeSystem.AllowVoidNull ? `(${value} === undefined || ${value} === null)` : `${value} === undefined`;
|
|
188
|
+
}
|
|
189
|
+
// -------------------------------------------------------------------
|
|
190
|
+
// Types
|
|
191
|
+
// -------------------------------------------------------------------
|
|
192
|
+
function* Any(schema, references, value) {
|
|
193
|
+
yield 'true';
|
|
194
|
+
}
|
|
195
|
+
function* Array(schema, references, value) {
|
|
196
|
+
const expression = CreateExpression(schema.items, references, 'value');
|
|
197
|
+
yield `Array.isArray(${value}) && ${value}.every(value => ${expression})`;
|
|
198
|
+
if (IsNumber(schema.minItems))
|
|
199
|
+
yield `${value}.length >= ${schema.minItems}`;
|
|
200
|
+
if (IsNumber(schema.maxItems))
|
|
201
|
+
yield `${value}.length <= ${schema.maxItems}`;
|
|
202
|
+
if (schema.uniqueItems === true)
|
|
203
|
+
yield `((function() { const set = new Set(); for(const element of ${value}) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true })())`;
|
|
204
|
+
}
|
|
205
|
+
function* BigInt(schema, references, value) {
|
|
206
|
+
yield `(typeof ${value} === 'bigint')`;
|
|
207
|
+
if (IsBigInt(schema.multipleOf))
|
|
208
|
+
yield `(${value} % BigInt(${schema.multipleOf})) === 0`;
|
|
209
|
+
if (IsBigInt(schema.exclusiveMinimum))
|
|
210
|
+
yield `${value} > BigInt(${schema.exclusiveMinimum})`;
|
|
211
|
+
if (IsBigInt(schema.exclusiveMaximum))
|
|
212
|
+
yield `${value} < BigInt(${schema.exclusiveMaximum})`;
|
|
213
|
+
if (IsBigInt(schema.minimum))
|
|
214
|
+
yield `${value} >= BigInt(${schema.minimum})`;
|
|
215
|
+
if (IsBigInt(schema.maximum))
|
|
216
|
+
yield `${value} <= BigInt(${schema.maximum})`;
|
|
217
|
+
}
|
|
218
|
+
function* Boolean(schema, references, value) {
|
|
219
|
+
yield `typeof ${value} === 'boolean'`;
|
|
220
|
+
}
|
|
221
|
+
function* Constructor(schema, references, value) {
|
|
222
|
+
yield* Visit(schema.returns, references, `${value}.prototype`);
|
|
223
|
+
}
|
|
224
|
+
function* Date(schema, references, value) {
|
|
225
|
+
yield `(${value} instanceof Date) && Number.isFinite(${value}.getTime())`;
|
|
226
|
+
if (IsNumber(schema.exclusiveMinimumTimestamp))
|
|
227
|
+
yield `${value}.getTime() > ${schema.exclusiveMinimumTimestamp}`;
|
|
228
|
+
if (IsNumber(schema.exclusiveMaximumTimestamp))
|
|
229
|
+
yield `${value}.getTime() < ${schema.exclusiveMaximumTimestamp}`;
|
|
230
|
+
if (IsNumber(schema.minimumTimestamp))
|
|
231
|
+
yield `${value}.getTime() >= ${schema.minimumTimestamp}`;
|
|
232
|
+
if (IsNumber(schema.maximumTimestamp))
|
|
233
|
+
yield `${value}.getTime() <= ${schema.maximumTimestamp}`;
|
|
234
|
+
}
|
|
235
|
+
function* Function(schema, references, value) {
|
|
236
|
+
yield `typeof ${value} === 'function'`;
|
|
237
|
+
}
|
|
238
|
+
function* Integer(schema, references, value) {
|
|
239
|
+
yield `(typeof ${value} === 'number' && Number.isInteger(${value}))`;
|
|
240
|
+
if (IsNumber(schema.multipleOf))
|
|
241
|
+
yield `(${value} % ${schema.multipleOf}) === 0`;
|
|
242
|
+
if (IsNumber(schema.exclusiveMinimum))
|
|
243
|
+
yield `${value} > ${schema.exclusiveMinimum}`;
|
|
244
|
+
if (IsNumber(schema.exclusiveMaximum))
|
|
245
|
+
yield `${value} < ${schema.exclusiveMaximum}`;
|
|
246
|
+
if (IsNumber(schema.minimum))
|
|
247
|
+
yield `${value} >= ${schema.minimum}`;
|
|
248
|
+
if (IsNumber(schema.maximum))
|
|
249
|
+
yield `${value} <= ${schema.maximum}`;
|
|
250
|
+
}
|
|
251
|
+
function* Intersect(schema, references, value) {
|
|
252
|
+
if (schema.unevaluatedProperties === undefined) {
|
|
253
|
+
const expressions = schema.allOf.map((schema) => CreateExpression(schema, references, value));
|
|
254
|
+
yield `${expressions.join(' && ')}`;
|
|
255
|
+
}
|
|
256
|
+
else if (schema.unevaluatedProperties === false) {
|
|
257
|
+
// prettier-ignore
|
|
258
|
+
const schemaKeys = Types.KeyResolver.Resolve(schema).map((key) => `'${key}'`).join(', ');
|
|
259
|
+
const expressions = schema.allOf.map((schema) => CreateExpression(schema, references, value));
|
|
260
|
+
const expression1 = `Object.getOwnPropertyNames(${value}).every(key => [${schemaKeys}].includes(key))`;
|
|
261
|
+
yield `${expressions.join(' && ')} && ${expression1}`;
|
|
262
|
+
}
|
|
263
|
+
else if (typeof schema.unevaluatedProperties === 'object') {
|
|
264
|
+
// prettier-ignore
|
|
265
|
+
const schemaKeys = Types.KeyResolver.Resolve(schema).map((key) => `'${key}'`).join(', ');
|
|
266
|
+
const expressions = schema.allOf.map((schema) => CreateExpression(schema, references, value));
|
|
267
|
+
const expression1 = CreateExpression(schema.unevaluatedProperties, references, 'value[key]');
|
|
268
|
+
const expression2 = `Object.getOwnPropertyNames(${value}).every(key => [${schemaKeys}].includes(key) || ${expression1})`;
|
|
269
|
+
yield `${expressions.join(' && ')} && ${expression2}`;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function* Literal(schema, references, value) {
|
|
273
|
+
if (typeof schema.const === 'number' || typeof schema.const === 'boolean') {
|
|
274
|
+
yield `${value} === ${schema.const}`;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
yield `${value} === '${schema.const}'`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function* Never(schema, references, value) {
|
|
281
|
+
yield `false`;
|
|
282
|
+
}
|
|
283
|
+
function* Not(schema, references, value) {
|
|
284
|
+
const left = CreateExpression(schema.allOf[0].not, references, value);
|
|
285
|
+
const right = CreateExpression(schema.allOf[1], references, value);
|
|
286
|
+
yield `!${left} && ${right}`;
|
|
287
|
+
}
|
|
288
|
+
function* Null(schema, references, value) {
|
|
289
|
+
yield `${value} === null`;
|
|
290
|
+
}
|
|
291
|
+
function* Number(schema, references, value) {
|
|
292
|
+
yield IsNumberCheck(value);
|
|
293
|
+
if (IsNumber(schema.multipleOf))
|
|
294
|
+
yield `(${value} % ${schema.multipleOf}) === 0`;
|
|
295
|
+
if (IsNumber(schema.exclusiveMinimum))
|
|
296
|
+
yield `${value} > ${schema.exclusiveMinimum}`;
|
|
297
|
+
if (IsNumber(schema.exclusiveMaximum))
|
|
298
|
+
yield `${value} < ${schema.exclusiveMaximum}`;
|
|
299
|
+
if (IsNumber(schema.minimum))
|
|
300
|
+
yield `${value} >= ${schema.minimum}`;
|
|
301
|
+
if (IsNumber(schema.maximum))
|
|
302
|
+
yield `${value} <= ${schema.maximum}`;
|
|
303
|
+
}
|
|
304
|
+
function* Object(schema, references, value) {
|
|
305
|
+
yield IsObjectCheck(value);
|
|
306
|
+
if (IsNumber(schema.minProperties))
|
|
307
|
+
yield `Object.getOwnPropertyNames(${value}).length >= ${schema.minProperties}`;
|
|
308
|
+
if (IsNumber(schema.maxProperties))
|
|
309
|
+
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
310
|
+
const knownKeys = globalThis.Object.getOwnPropertyNames(schema.properties);
|
|
311
|
+
for (const knownKey of knownKeys) {
|
|
312
|
+
const memberExpression = MemberExpression.Encode(value, knownKey);
|
|
313
|
+
const property = schema.properties[knownKey];
|
|
314
|
+
if (schema.required && schema.required.includes(knownKey)) {
|
|
315
|
+
yield* Visit(property, references, memberExpression);
|
|
316
|
+
if (Types.ExtendsUndefined.Check(property))
|
|
317
|
+
yield `('${knownKey}' in ${value})`;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
const expression = CreateExpression(property, references, memberExpression);
|
|
321
|
+
yield IsExactOptionalProperty(value, knownKey, expression);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (schema.additionalProperties === false) {
|
|
325
|
+
if (schema.required && schema.required.length === knownKeys.length) {
|
|
326
|
+
yield `Object.getOwnPropertyNames(${value}).length === ${knownKeys.length}`;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
const keys = `[${knownKeys.map((key) => `'${key}'`).join(', ')}]`;
|
|
330
|
+
yield `Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key))`;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (typeof schema.additionalProperties === 'object') {
|
|
334
|
+
const expression = CreateExpression(schema.additionalProperties, references, 'value[key]');
|
|
335
|
+
const keys = `[${knownKeys.map((key) => `'${key}'`).join(', ')}]`;
|
|
336
|
+
yield `(Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key) || ${expression}))`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function* Promise(schema, references, value) {
|
|
340
|
+
yield `(typeof value === 'object' && typeof ${value}.then === 'function')`;
|
|
341
|
+
}
|
|
342
|
+
function* Record(schema, references, value) {
|
|
343
|
+
yield IsRecordCheck(value);
|
|
344
|
+
if (IsNumber(schema.minProperties))
|
|
345
|
+
yield `Object.getOwnPropertyNames(${value}).length >= ${schema.minProperties}`;
|
|
346
|
+
if (IsNumber(schema.maxProperties))
|
|
347
|
+
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
348
|
+
const [keyPattern, valueSchema] = globalThis.Object.entries(schema.patternProperties)[0];
|
|
349
|
+
const local = PushLocal(`new RegExp(/${keyPattern}/)`);
|
|
350
|
+
yield `(Object.getOwnPropertyNames(${value}).every(key => ${local}.test(key)))`;
|
|
351
|
+
const expression = CreateExpression(valueSchema, references, 'value');
|
|
352
|
+
yield `Object.values(${value}).every(value => ${expression})`;
|
|
353
|
+
}
|
|
354
|
+
function* Ref(schema, references, value) {
|
|
355
|
+
const index = references.findIndex((foreign) => foreign.$id === schema.$ref);
|
|
356
|
+
if (index === -1)
|
|
357
|
+
throw new TypeCompilerDereferenceError(schema);
|
|
358
|
+
const target = references[index];
|
|
359
|
+
// Reference: If we have seen this reference before we can just yield and return
|
|
360
|
+
// the function call. If this isn't the case we defer to visit to generate and
|
|
361
|
+
// set the function for subsequent passes. Consider for refactor.
|
|
362
|
+
if (state_local_function_names.has(schema.$ref))
|
|
363
|
+
return yield `${CreateFunctionName(schema.$ref)}(${value})`;
|
|
364
|
+
yield* Visit(target, references, value);
|
|
365
|
+
}
|
|
366
|
+
function* String(schema, references, value) {
|
|
367
|
+
yield `(typeof ${value} === 'string')`;
|
|
368
|
+
if (IsNumber(schema.minLength))
|
|
369
|
+
yield `${value}.length >= ${schema.minLength}`;
|
|
370
|
+
if (IsNumber(schema.maxLength))
|
|
371
|
+
yield `${value}.length <= ${schema.maxLength}`;
|
|
372
|
+
if (schema.pattern !== undefined) {
|
|
373
|
+
const local = PushLocal(`${new RegExp(schema.pattern)};`);
|
|
374
|
+
yield `${local}.test(${value})`;
|
|
375
|
+
}
|
|
376
|
+
if (schema.format !== undefined) {
|
|
377
|
+
yield `format('${schema.format}', ${value})`;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function* Symbol(schema, references, value) {
|
|
381
|
+
yield `(typeof ${value} === 'symbol')`;
|
|
382
|
+
}
|
|
383
|
+
function* TemplateLiteral(schema, references, value) {
|
|
384
|
+
yield `(typeof ${value} === 'string')`;
|
|
385
|
+
const local = PushLocal(`${new RegExp(schema.pattern)};`);
|
|
386
|
+
yield `${local}.test(${value})`;
|
|
387
|
+
}
|
|
388
|
+
function* This(schema, references, value) {
|
|
389
|
+
const func = CreateFunctionName(schema.$ref);
|
|
390
|
+
yield `${func}(${value})`;
|
|
391
|
+
}
|
|
392
|
+
function* Tuple(schema, references, value) {
|
|
393
|
+
yield `(Array.isArray(${value}))`;
|
|
394
|
+
if (schema.items === undefined)
|
|
395
|
+
return yield `${value}.length === 0`;
|
|
396
|
+
yield `(${value}.length === ${schema.maxItems})`;
|
|
397
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
398
|
+
const expression = CreateExpression(schema.items[i], references, `${value}[${i}]`);
|
|
399
|
+
yield `${expression}`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function* Undefined(schema, references, value) {
|
|
403
|
+
yield `${value} === undefined`;
|
|
404
|
+
}
|
|
405
|
+
function* Union(schema, references, value) {
|
|
406
|
+
const expressions = schema.anyOf.map((schema) => CreateExpression(schema, references, value));
|
|
407
|
+
yield `(${expressions.join(' || ')})`;
|
|
408
|
+
}
|
|
409
|
+
function* Uint8Array(schema, references, value) {
|
|
410
|
+
yield `${value} instanceof Uint8Array`;
|
|
411
|
+
if (IsNumber(schema.maxByteLength))
|
|
412
|
+
yield `(${value}.length <= ${schema.maxByteLength})`;
|
|
413
|
+
if (IsNumber(schema.minByteLength))
|
|
414
|
+
yield `(${value}.length >= ${schema.minByteLength})`;
|
|
415
|
+
}
|
|
416
|
+
function* Unknown(schema, references, value) {
|
|
417
|
+
yield 'true';
|
|
418
|
+
}
|
|
419
|
+
function* Void(schema, references, value) {
|
|
420
|
+
yield IsVoidCheck(value);
|
|
421
|
+
}
|
|
422
|
+
function* UserDefined(schema, references, value) {
|
|
423
|
+
const schema_key = `schema_key_${state_remote_custom_types.size}`;
|
|
424
|
+
state_remote_custom_types.set(schema_key, schema);
|
|
425
|
+
yield `custom('${schema[Types.Kind]}', '${schema_key}', ${value})`;
|
|
426
|
+
}
|
|
427
|
+
function* Visit(schema, references, value) {
|
|
428
|
+
const references_ = IsString(schema.$id) ? [...references, schema] : references;
|
|
429
|
+
const schema_ = schema;
|
|
430
|
+
// Reference: Referenced schemas can originate from either additional schemas
|
|
431
|
+
// or inline in the schema itself. Ideally the recursive path should align to
|
|
432
|
+
// reference path. Consider for refactor.
|
|
433
|
+
if (IsString(schema.$id) && !state_local_function_names.has(schema.$id)) {
|
|
434
|
+
state_local_function_names.add(schema.$id);
|
|
435
|
+
const name = CreateFunctionName(schema.$id);
|
|
436
|
+
const body = CreateFunction(name, schema, references, 'value');
|
|
437
|
+
PushFunction(body);
|
|
438
|
+
yield `${name}(${value})`;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
switch (schema_[Types.Kind]) {
|
|
442
|
+
case 'Any':
|
|
443
|
+
return yield* Any(schema_, references_, value);
|
|
444
|
+
case 'Array':
|
|
445
|
+
return yield* Array(schema_, references_, value);
|
|
446
|
+
case 'BigInt':
|
|
447
|
+
return yield* BigInt(schema_, references_, value);
|
|
448
|
+
case 'Boolean':
|
|
449
|
+
return yield* Boolean(schema_, references_, value);
|
|
450
|
+
case 'Constructor':
|
|
451
|
+
return yield* Constructor(schema_, references_, value);
|
|
452
|
+
case 'Date':
|
|
453
|
+
return yield* Date(schema_, references_, value);
|
|
454
|
+
case 'Function':
|
|
455
|
+
return yield* Function(schema_, references_, value);
|
|
456
|
+
case 'Integer':
|
|
457
|
+
return yield* Integer(schema_, references_, value);
|
|
458
|
+
case 'Intersect':
|
|
459
|
+
return yield* Intersect(schema_, references_, value);
|
|
460
|
+
case 'Literal':
|
|
461
|
+
return yield* Literal(schema_, references_, value);
|
|
462
|
+
case 'Never':
|
|
463
|
+
return yield* Never(schema_, references_, value);
|
|
464
|
+
case 'Not':
|
|
465
|
+
return yield* Not(schema_, references_, value);
|
|
466
|
+
case 'Null':
|
|
467
|
+
return yield* Null(schema_, references_, value);
|
|
468
|
+
case 'Number':
|
|
469
|
+
return yield* Number(schema_, references_, value);
|
|
470
|
+
case 'Object':
|
|
471
|
+
return yield* Object(schema_, references_, value);
|
|
472
|
+
case 'Promise':
|
|
473
|
+
return yield* Promise(schema_, references_, value);
|
|
474
|
+
case 'Record':
|
|
475
|
+
return yield* Record(schema_, references_, value);
|
|
476
|
+
case 'Ref':
|
|
477
|
+
return yield* Ref(schema_, references_, value);
|
|
478
|
+
case 'String':
|
|
479
|
+
return yield* String(schema_, references_, value);
|
|
480
|
+
case 'Symbol':
|
|
481
|
+
return yield* Symbol(schema_, references_, value);
|
|
482
|
+
case 'TemplateLiteral':
|
|
483
|
+
return yield* TemplateLiteral(schema_, references_, value);
|
|
484
|
+
case 'This':
|
|
485
|
+
return yield* This(schema_, references_, value);
|
|
486
|
+
case 'Tuple':
|
|
487
|
+
return yield* Tuple(schema_, references_, value);
|
|
488
|
+
case 'Undefined':
|
|
489
|
+
return yield* Undefined(schema_, references_, value);
|
|
490
|
+
case 'Union':
|
|
491
|
+
return yield* Union(schema_, references_, value);
|
|
492
|
+
case 'Uint8Array':
|
|
493
|
+
return yield* Uint8Array(schema_, references_, value);
|
|
494
|
+
case 'Unknown':
|
|
495
|
+
return yield* Unknown(schema_, references_, value);
|
|
496
|
+
case 'Void':
|
|
497
|
+
return yield* Void(schema_, references_, value);
|
|
498
|
+
default:
|
|
499
|
+
if (!Types.TypeRegistry.Has(schema_[Types.Kind]))
|
|
500
|
+
throw new TypeCompilerUnknownTypeError(schema);
|
|
501
|
+
return yield* UserDefined(schema_, references_, value);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
// -------------------------------------------------------------------
|
|
505
|
+
// Compiler State
|
|
506
|
+
// -------------------------------------------------------------------
|
|
507
|
+
const state_local_variables = new Set(); // local variables and functions
|
|
508
|
+
const state_local_function_names = new Set(); // local function names used call ref validators
|
|
509
|
+
const state_remote_custom_types = new Map(); // remote custom types used during compilation
|
|
510
|
+
function ResetCompiler() {
|
|
511
|
+
state_local_variables.clear();
|
|
512
|
+
state_local_function_names.clear();
|
|
513
|
+
state_remote_custom_types.clear();
|
|
514
|
+
}
|
|
515
|
+
function CreateExpression(schema, references, value) {
|
|
516
|
+
return `(${[...Visit(schema, references, value)].join(' && ')})`;
|
|
517
|
+
}
|
|
518
|
+
function CreateFunctionName($id) {
|
|
519
|
+
return `check_${Identifier.Encode($id)}`;
|
|
520
|
+
}
|
|
521
|
+
function CreateFunction(name, schema, references, value) {
|
|
522
|
+
const expression = [...Visit(schema, references, value)].map((condition) => ` ${condition}`).join(' &&\n');
|
|
523
|
+
return `function ${name}(value) {\n return (\n${expression}\n )\n}`;
|
|
524
|
+
}
|
|
525
|
+
function PushFunction(functionBody) {
|
|
526
|
+
state_local_variables.add(functionBody);
|
|
527
|
+
}
|
|
528
|
+
function PushLocal(expression) {
|
|
529
|
+
const local = `local_${state_local_variables.size}`;
|
|
530
|
+
state_local_variables.add(`const ${local} = ${expression}`);
|
|
531
|
+
return local;
|
|
532
|
+
}
|
|
533
|
+
function GetLocals() {
|
|
534
|
+
return [...state_local_variables.values()];
|
|
535
|
+
}
|
|
536
|
+
// -------------------------------------------------------------------
|
|
537
|
+
// Compile
|
|
538
|
+
// -------------------------------------------------------------------
|
|
539
|
+
function Build(schema, references) {
|
|
540
|
+
ResetCompiler();
|
|
541
|
+
const check = CreateFunction('check', schema, references, 'value');
|
|
542
|
+
const locals = GetLocals();
|
|
543
|
+
return `${locals.join('\n')}\nreturn ${check}`;
|
|
544
|
+
}
|
|
545
|
+
/** Returns the generated assertion code used to validate this type. */
|
|
546
|
+
function Code(schema, references = []) {
|
|
547
|
+
if (!Types.TypeGuard.TSchema(schema))
|
|
548
|
+
throw new TypeCompilerTypeGuardError(schema);
|
|
549
|
+
for (const schema of references)
|
|
550
|
+
if (!Types.TypeGuard.TSchema(schema))
|
|
551
|
+
throw new TypeCompilerTypeGuardError(schema);
|
|
552
|
+
return Build(schema, references);
|
|
553
|
+
}
|
|
554
|
+
TypeCompiler.Code = Code;
|
|
555
|
+
/** Compiles the given type for runtime type checking. This compiler only accepts known TypeBox types non-inclusive of unsafe types. */
|
|
556
|
+
function Compile(schema, references = []) {
|
|
557
|
+
const code = Code(schema, references);
|
|
558
|
+
const custom_schemas = new Map(state_remote_custom_types);
|
|
559
|
+
const compiledFunction = globalThis.Function('custom', 'format', 'hash', code);
|
|
560
|
+
const checkFunction = compiledFunction((kind, schema_key, value) => {
|
|
561
|
+
if (!Types.TypeRegistry.Has(kind) || !custom_schemas.has(schema_key))
|
|
562
|
+
return false;
|
|
563
|
+
const schema = custom_schemas.get(schema_key);
|
|
564
|
+
const func = Types.TypeRegistry.Get(kind);
|
|
565
|
+
return func(schema, value);
|
|
566
|
+
}, (format, value) => {
|
|
567
|
+
if (!Types.FormatRegistry.Has(format))
|
|
568
|
+
return false;
|
|
569
|
+
const func = Types.FormatRegistry.Get(format);
|
|
570
|
+
return func(value);
|
|
571
|
+
}, (value) => {
|
|
572
|
+
return hash_1.ValueHash.Create(value);
|
|
573
|
+
});
|
|
574
|
+
return new TypeCheck(schema, references, checkFunction, code);
|
|
575
|
+
}
|
|
576
|
+
TypeCompiler.Compile = Compile;
|
|
577
|
+
})(TypeCompiler = exports.TypeCompiler || (exports.TypeCompiler = {}));
|