@zuplo/cli 6.70.16 → 6.70.21
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/dist/cli.js +0 -6
- package/dist/cli.js.map +1 -1
- package/node_modules/@cfworker/json-schema/README.md +75 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/deep-compare-strict.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/deep-compare-strict.js +42 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/dereference.d.ts +7 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/dereference.js +147 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/format.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/format.js +111 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/index.d.ts +8 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/index.js +24 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/package.json +3 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/pointer.d.ts +2 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/pointer.js +10 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/types.d.ts +72 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/types.js +9 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/ucs2-length.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/ucs2-length.js +20 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/validate.d.ts +3 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/validate.js +805 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/validator.d.ts +10 -0
- package/node_modules/@cfworker/json-schema/dist/commonjs/validator.js +27 -0
- package/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js +39 -0
- package/node_modules/@cfworker/json-schema/dist/esm/dereference.d.ts +7 -0
- package/node_modules/@cfworker/json-schema/dist/esm/dereference.js +143 -0
- package/node_modules/@cfworker/json-schema/dist/esm/format.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/dist/esm/format.js +108 -0
- package/node_modules/@cfworker/json-schema/dist/esm/index.d.ts +8 -0
- package/node_modules/@cfworker/json-schema/dist/esm/index.js +8 -0
- package/node_modules/@cfworker/json-schema/dist/esm/package.json +3 -0
- package/node_modules/@cfworker/json-schema/dist/esm/pointer.d.ts +2 -0
- package/node_modules/@cfworker/json-schema/dist/esm/pointer.js +6 -0
- package/node_modules/@cfworker/json-schema/dist/esm/types.d.ts +72 -0
- package/node_modules/@cfworker/json-schema/dist/esm/types.js +6 -0
- package/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js +17 -0
- package/node_modules/@cfworker/json-schema/dist/esm/validate.d.ts +3 -0
- package/node_modules/@cfworker/json-schema/dist/esm/validate.js +802 -0
- package/node_modules/@cfworker/json-schema/dist/esm/validator.d.ts +10 -0
- package/node_modules/@cfworker/json-schema/dist/esm/validator.js +23 -0
- package/node_modules/@cfworker/json-schema/package.json +68 -0
- package/node_modules/@cfworker/json-schema/src/deep-compare-strict.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/src/deep-compare-strict.ts +39 -0
- package/node_modules/@cfworker/json-schema/src/dereference.d.ts +12 -0
- package/node_modules/@cfworker/json-schema/src/dereference.ts +188 -0
- package/node_modules/@cfworker/json-schema/src/format.d.ts +2 -0
- package/node_modules/@cfworker/json-schema/src/format.ts +164 -0
- package/node_modules/@cfworker/json-schema/src/index.d.ts +8 -0
- package/node_modules/@cfworker/json-schema/src/index.ts +8 -0
- package/node_modules/@cfworker/json-schema/src/pointer.d.ts +2 -0
- package/node_modules/@cfworker/json-schema/src/pointer.ts +7 -0
- package/node_modules/@cfworker/json-schema/src/types.d.ts +79 -0
- package/node_modules/@cfworker/json-schema/src/types.ts +92 -0
- package/node_modules/@cfworker/json-schema/src/ucs2-length.d.ts +1 -0
- package/node_modules/@cfworker/json-schema/src/ucs2-length.ts +24 -0
- package/node_modules/@cfworker/json-schema/src/validate.d.ts +13 -0
- package/node_modules/@cfworker/json-schema/src/validate.ts +1168 -0
- package/node_modules/@cfworker/json-schema/src/validator.d.ts +14 -0
- package/node_modules/@cfworker/json-schema/src/validator.ts +32 -0
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-YJ3VHQXF.js → chunk-2ZQVIVZ3.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-STBDRSX7.js → chunk-UMZORQLU.js} +67 -66
- package/node_modules/@zuplo/runtime/out/esm/chunk-UMZORQLU.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-KWR5BV7H.js → chunk-YGYFQCBA.js} +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-YGYFQCBA.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-NJNTFB34.js → chunk-ZS34EO4B.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-NJNTFB34.js.map → chunk-ZS34EO4B.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +208 -72
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +61 -12
- package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +8 -17
- package/node_modules/@zuplo/runtime/out/types/mocks/index.d.ts +3 -12
- package/node_modules/@zuplo/runtime/package.json +3 -2
- package/node_modules/agent-base/README.md +145 -0
- package/node_modules/agent-base/dist/src/index.d.ts +78 -0
- package/node_modules/agent-base/dist/src/index.js +203 -0
- package/node_modules/agent-base/dist/src/index.js.map +1 -0
- package/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
- package/node_modules/agent-base/dist/src/promisify.js +18 -0
- package/node_modules/agent-base/dist/src/promisify.js.map +1 -0
- package/node_modules/agent-base/package.json +64 -0
- package/node_modules/agent-base/src/index.ts +345 -0
- package/node_modules/agent-base/src/promisify.ts +33 -0
- package/node_modules/axios/CHANGELOG.md +71 -0
- package/node_modules/axios/README.md +46 -11
- package/node_modules/axios/dist/axios.js +81 -53
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +2 -2
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +96 -64
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +96 -64
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +206 -85
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +1 -1
- package/node_modules/axios/index.d.ts +1 -1
- package/node_modules/axios/lib/adapters/fetch.js +6 -2
- package/node_modules/axios/lib/adapters/http.js +139 -29
- package/node_modules/axios/lib/adapters/xhr.js +2 -1
- package/node_modules/axios/lib/core/AxiosHeaders.js +1 -33
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/composeSignals.js +48 -47
- package/node_modules/axios/lib/helpers/formDataToJSON.js +1 -1
- package/node_modules/axios/lib/helpers/fromDataURI.js +18 -5
- package/node_modules/axios/lib/helpers/progressEventReducer.js +3 -0
- package/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/node_modules/axios/lib/utils.js +8 -7
- package/node_modules/axios/package.json +3 -1
- package/node_modules/https-proxy-agent/README.md +137 -0
- package/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
- package/node_modules/https-proxy-agent/dist/agent.js +177 -0
- package/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
- package/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
- package/node_modules/https-proxy-agent/dist/index.js +14 -0
- package/node_modules/https-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
- package/node_modules/https-proxy-agent/package.json +56 -0
- package/node_modules/type-is/index.js +8 -18
- package/node_modules/type-is/node_modules/content-type/LICENSE +22 -0
- package/node_modules/type-is/node_modules/content-type/README.md +69 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +26 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js +170 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/type-is/node_modules/content-type/package.json +52 -0
- package/node_modules/type-is/package.json +9 -5
- package/package.json +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-KWR5BV7H.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-STBDRSX7.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-YJ3VHQXF.js.map → chunk-2ZQVIVZ3.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-STBDRSX7.js.LEGAL.txt → chunk-UMZORQLU.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-KWR5BV7H.js.LEGAL.txt → chunk-YGYFQCBA.js.LEGAL.txt} +0 -0
package/dist/cli.js
CHANGED
|
@@ -118,12 +118,6 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
118
118
|
.command(bucket)
|
|
119
119
|
.command(proxies)
|
|
120
120
|
.command(whoami)
|
|
121
|
-
.command({
|
|
122
|
-
command: "hello",
|
|
123
|
-
handler: async () => {
|
|
124
|
-
await fetch("https://393b4699ced44cc2ae87e4ad86184a29.api.mockbin.io/");
|
|
125
|
-
},
|
|
126
|
-
})
|
|
127
121
|
.demandCommand()
|
|
128
122
|
.strictCommands()
|
|
129
123
|
.version(cliVersion)
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAG7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,YAAY,MAAM,+BAA+B,CAAC;AACzD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAClC,OAAO,MA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AC;AACJ,CAAC","sourcesContent":["import * as dotenv from \"dotenv\";\n\ndotenv.config();\n\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { confirm } from \"@inquirer/prompts\";\nimport * as Sentry from \"@sentry/node\";\nimport { gte } from \"semver\";\n// Undici must be imported first to set the global dispatcher\n// If fetch is used before undici, the process will crash\nimport undici from \"undici\";\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs/yargs\";\nimport bucket from \"./cmds/bucket/index.js\";\nimport build from \"./cmds/build.js\";\nimport caCertificate from \"./cmds/ca-certificate/index.js\";\nimport compile from \"./cmds/compile.js\";\nimport customDomain from \"./cmds/custom-domain/index.js\";\nimport deleteZup from \"./cmds/delete.js\";\nimport deploy from \"./cmds/deploy.js\";\nimport dev from \"./cmds/dev.js\";\nimport docs from \"./cmds/docs.js\";\nimport editor from \"./cmds/editor.js\";\nimport info from \"./cmds/info.js\";\nimport init from \"./cmds/init.js\";\nimport link from \"./cmds/link.js\";\nimport list from \"./cmds/list.js\";\nimport login from \"./cmds/login.js\";\nimport logout from \"./cmds/logout.js\";\nimport mtlsCertificates from \"./cmds/mtls-certificates/index.js\";\nimport oas from \"./cmds/open-api/index.js\";\nimport project from \"./cmds/project/index.js\";\nimport proxies from \"./cmds/proxies/index.js\";\nimport source from \"./cmds/source/index.js\";\nimport test from \"./cmds/test.js\";\nimport tunnel from \"./cmds/tunnel/index.js\";\nimport variable from \"./cmds/variable/index.js\";\nimport whoami from \"./cmds/whoami.js\";\nimport { captureCliInvocationEvent } from \"./common/analytics/cli-invocation.js\";\nimport { shutdownAnalytics } from \"./common/analytics/lib.js\";\nimport { ApiError } from \"./common/api/client.js\";\nimport { MAX_WAIT_PENDING_TIME_MS, SENTRY_DSN } from \"./common/constants.js\";\nimport { logger } from \"./common/logger.js\";\nimport { checkPnpmLifecycle } from \"./common/middleware/check-pnpm-lifecycle.js\";\nimport { logLevel } from \"./common/middleware/logging.js\";\nimport { warnIfOutdatedVersion, warnNodeVersion } from \"./common/outdated.js\";\nimport setBlocking, {\n printCriticalFailureToConsole,\n printCriticalFailureToConsoleAndExit,\n} from \"./common/output.js\";\n\n// This allows us to stop the CLI from executing so we can connect the profiler\n\n// biome-ignore lint/style/noProcessEnv: Migrated from ESLint\nif (process.env.ZUPLO_CLI_PROFILING) {\n await confirm({ message: \"Continue executing CLI?\", default: true });\n}\n\n// Note: We cannot set this to be higher than 18.0.0 because of the way\n// our documentation works -- we tell them to use npx @zuplo/cli@latest (even in CI/CD jobs)\n// If we set this to be higher than 18.0.0, then we will break them.\n// Instead we set the value in package.json to be engine.node >= 20.0.0, so it will warn\nconst MIN_NODE_VERSION = \"18.0.0\";\nconst RECOMMENDED_NODE_VERSION = \"20.0.0\";\n\nif (gte(process.versions.node, MIN_NODE_VERSION)) {\n let cliVersion: string;\n try {\n const packageJson = JSON.parse(\n readFileSync(\n fileURLToPath(new URL(\"../package.json\", import.meta.url)),\n \"utf-8\"\n )\n );\n cliVersion = packageJson.version;\n } catch (e) {\n cliVersion = \"0.0.0\";\n logger.error(e);\n await printCriticalFailureToConsoleAndExit(\n `Unable to load @zuplo/cli. The package.json is missing or malformed.`\n );\n }\n\n await warnNodeVersion(cliVersion, RECOMMENDED_NODE_VERSION);\n\n undici.setGlobalDispatcher(\n undici.getGlobalDispatcher().compose((dispatch) => {\n return (opts, handler) => {\n opts.headers = {\n ...opts.headers,\n \"user-agent\": `ZuploCLI/${cliVersion}`,\n\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n ...(process.env.ZUPLO_CANARY ? { \"zp-canary\": \"true\" } : {}),\n };\n return dispatch(opts, handler);\n };\n })\n );\n\n Sentry.init({\n dsn: SENTRY_DSN,\n release: cliVersion,\n });\n\n const cli = yargs(hideBin(process.argv))\n // This means that all env vars will have to be prefixed with ZUPLO_\n .env(\"ZUPLO\")\n .option(\"prompt\", {\n type: \"boolean\",\n describe: \"Bypass confirmation prompts\",\n default: true,\n hidden: true,\n })\n .option(\"verbose\", {\n alias: \"v\",\n type: \"count\",\n describe: \"Increase verbosity level (-v, -vv, -vvv)\",\n default: 0,\n })\n // setBlocking forces synchronous TTY writes so error messages flush before\n // process.exit. Runs first so subsequent middleware (including the\n // preflight, which can exit) benefit from it.\n .middleware(setBlocking)\n .middleware(logLevel)\n .middleware(checkPnpmLifecycle)\n .middleware((argv) => {\n void captureCliInvocationEvent(argv, cliVersion);\n })\n .command(caCertificate)\n .command(compile)\n .command(customDomain)\n .command(deleteZup) // delete is a reserved keyword in JavaScript, so we call this function deleteZup\n .command(deploy)\n .command(dev)\n .command(docs)\n .command(editor)\n .command(info)\n .command(init)\n .command(list)\n .command(link)\n .command(login)\n .command(logout)\n .command(test)\n .command(oas)\n .command(mtlsCertificates)\n .command(project)\n .command(source)\n .command(tunnel)\n .command(variable)\n .command(build)\n .command(bucket)\n .command(proxies)\n .command(whoami)\n .command({\n command: \"hello\",\n handler: async () => {\n await fetch(\"https://393b4699ced44cc2ae87e4ad86184a29.api.mockbin.io/\");\n },\n })\n .demandCommand()\n .strictCommands()\n .version(cliVersion)\n .fail(false)\n .help();\n\n let exitCode = 0;\n try {\n await cli.argv;\n\n // Don't block\n void warnIfOutdatedVersion(cliVersion);\n } catch (err) {\n exitCode = 1;\n if (err instanceof Error) {\n Sentry.captureException(err);\n }\n if (err instanceof ApiError) {\n // The API client has already logged the structured error and printed\n // a user-facing diagnostic. Nothing more to display here.\n } else {\n printCriticalFailureToConsole(err.message ?? err);\n cli.showHelp();\n }\n } finally {\n await shutdownAnalytics();\n await Sentry.close(MAX_WAIT_PENDING_TIME_MS);\n process.exit(exitCode);\n }\n} else {\n await printCriticalFailureToConsoleAndExit(\n `The Zuplo CLI requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.\n\n Consider using a Node.js version manager such as https://github.com/nvm-sh/nvm.`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"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AAU,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,QAAQ,GAAG,CAAC,CAAC;QACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAG9B,CAAC;aAAM,CAAC;YACN,6BAA6B,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YAClD,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,iBAAiB,EAAE,CAAC;QAC1B,MAAM,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;KAAM,CAAC;IACN,MAAM,oCAAoC,CACxC,4CAA4C,gBAAgB,oBAAoB,OAAO,CAAC,QAAQ,CAAC,IAAI;;oFAErB,CACjF,CAAC;AACJ,CAAC","sourcesContent":["import * as dotenv from \"dotenv\";\n\ndotenv.config();\n\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { confirm } from \"@inquirer/prompts\";\nimport * as Sentry from \"@sentry/node\";\nimport { gte } from \"semver\";\n// Undici must be imported first to set the global dispatcher\n// If fetch is used before undici, the process will crash\nimport undici from \"undici\";\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs/yargs\";\nimport bucket from \"./cmds/bucket/index.js\";\nimport build from \"./cmds/build.js\";\nimport caCertificate from \"./cmds/ca-certificate/index.js\";\nimport compile from \"./cmds/compile.js\";\nimport customDomain from \"./cmds/custom-domain/index.js\";\nimport deleteZup from \"./cmds/delete.js\";\nimport deploy from \"./cmds/deploy.js\";\nimport dev from \"./cmds/dev.js\";\nimport docs from \"./cmds/docs.js\";\nimport editor from \"./cmds/editor.js\";\nimport info from \"./cmds/info.js\";\nimport init from \"./cmds/init.js\";\nimport link from \"./cmds/link.js\";\nimport list from \"./cmds/list.js\";\nimport login from \"./cmds/login.js\";\nimport logout from \"./cmds/logout.js\";\nimport mtlsCertificates from \"./cmds/mtls-certificates/index.js\";\nimport oas from \"./cmds/open-api/index.js\";\nimport project from \"./cmds/project/index.js\";\nimport proxies from \"./cmds/proxies/index.js\";\nimport source from \"./cmds/source/index.js\";\nimport test from \"./cmds/test.js\";\nimport tunnel from \"./cmds/tunnel/index.js\";\nimport variable from \"./cmds/variable/index.js\";\nimport whoami from \"./cmds/whoami.js\";\nimport { captureCliInvocationEvent } from \"./common/analytics/cli-invocation.js\";\nimport { shutdownAnalytics } from \"./common/analytics/lib.js\";\nimport { ApiError } from \"./common/api/client.js\";\nimport { MAX_WAIT_PENDING_TIME_MS, SENTRY_DSN } from \"./common/constants.js\";\nimport { logger } from \"./common/logger.js\";\nimport { checkPnpmLifecycle } from \"./common/middleware/check-pnpm-lifecycle.js\";\nimport { logLevel } from \"./common/middleware/logging.js\";\nimport { warnIfOutdatedVersion, warnNodeVersion } from \"./common/outdated.js\";\nimport setBlocking, {\n printCriticalFailureToConsole,\n printCriticalFailureToConsoleAndExit,\n} from \"./common/output.js\";\n\n// This allows us to stop the CLI from executing so we can connect the profiler\n\n// biome-ignore lint/style/noProcessEnv: Migrated from ESLint\nif (process.env.ZUPLO_CLI_PROFILING) {\n await confirm({ message: \"Continue executing CLI?\", default: true });\n}\n\n// Note: We cannot set this to be higher than 18.0.0 because of the way\n// our documentation works -- we tell them to use npx @zuplo/cli@latest (even in CI/CD jobs)\n// If we set this to be higher than 18.0.0, then we will break them.\n// Instead we set the value in package.json to be engine.node >= 20.0.0, so it will warn\nconst MIN_NODE_VERSION = \"18.0.0\";\nconst RECOMMENDED_NODE_VERSION = \"20.0.0\";\n\nif (gte(process.versions.node, MIN_NODE_VERSION)) {\n let cliVersion: string;\n try {\n const packageJson = JSON.parse(\n readFileSync(\n fileURLToPath(new URL(\"../package.json\", import.meta.url)),\n \"utf-8\"\n )\n );\n cliVersion = packageJson.version;\n } catch (e) {\n cliVersion = \"0.0.0\";\n logger.error(e);\n await printCriticalFailureToConsoleAndExit(\n `Unable to load @zuplo/cli. The package.json is missing or malformed.`\n );\n }\n\n await warnNodeVersion(cliVersion, RECOMMENDED_NODE_VERSION);\n\n undici.setGlobalDispatcher(\n undici.getGlobalDispatcher().compose((dispatch) => {\n return (opts, handler) => {\n opts.headers = {\n ...opts.headers,\n \"user-agent\": `ZuploCLI/${cliVersion}`,\n\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n ...(process.env.ZUPLO_CANARY ? { \"zp-canary\": \"true\" } : {}),\n };\n return dispatch(opts, handler);\n };\n })\n );\n\n Sentry.init({\n dsn: SENTRY_DSN,\n release: cliVersion,\n });\n\n const cli = yargs(hideBin(process.argv))\n // This means that all env vars will have to be prefixed with ZUPLO_\n .env(\"ZUPLO\")\n .option(\"prompt\", {\n type: \"boolean\",\n describe: \"Bypass confirmation prompts\",\n default: true,\n hidden: true,\n })\n .option(\"verbose\", {\n alias: \"v\",\n type: \"count\",\n describe: \"Increase verbosity level (-v, -vv, -vvv)\",\n default: 0,\n })\n // setBlocking forces synchronous TTY writes so error messages flush before\n // process.exit. Runs first so subsequent middleware (including the\n // preflight, which can exit) benefit from it.\n .middleware(setBlocking)\n .middleware(logLevel)\n .middleware(checkPnpmLifecycle)\n .middleware((argv) => {\n void captureCliInvocationEvent(argv, cliVersion);\n })\n .command(caCertificate)\n .command(compile)\n .command(customDomain)\n .command(deleteZup) // delete is a reserved keyword in JavaScript, so we call this function deleteZup\n .command(deploy)\n .command(dev)\n .command(docs)\n .command(editor)\n .command(info)\n .command(init)\n .command(list)\n .command(link)\n .command(login)\n .command(logout)\n .command(test)\n .command(oas)\n .command(mtlsCertificates)\n .command(project)\n .command(source)\n .command(tunnel)\n .command(variable)\n .command(build)\n .command(bucket)\n .command(proxies)\n .command(whoami)\n .demandCommand()\n .strictCommands()\n .version(cliVersion)\n .fail(false)\n .help();\n\n let exitCode = 0;\n try {\n await cli.argv;\n\n // Don't block\n void warnIfOutdatedVersion(cliVersion);\n } catch (err) {\n exitCode = 1;\n if (err instanceof Error) {\n Sentry.captureException(err);\n }\n if (err instanceof ApiError) {\n // The API client has already logged the structured error and printed\n // a user-facing diagnostic. Nothing more to display here.\n } else {\n printCriticalFailureToConsole(err.message ?? err);\n cli.showHelp();\n }\n } finally {\n await shutdownAnalytics();\n await Sentry.close(MAX_WAIT_PENDING_TIME_MS);\n process.exit(exitCode);\n }\n} else {\n await printCriticalFailureToConsoleAndExit(\n `The Zuplo CLI requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.\n\n Consider using a Node.js version manager such as https://github.com/nvm-sh/nvm.`\n );\n}\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @cfworker/json-schema
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.
|
|
10
|
+
|
|
11
|
+
This library is validated against the [json-schema-test-suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite), a series of approximately 4,500 assertions maintained along with the json-schema specification. A small set of test cases are intentionally not supported due to performance constraints or lack of feature use. These list of unsupported features are maintained in [test/unsupported.ts](./test/unsupported.ts). While this library is not the fastest due to lack of code generation, it's consistently among the [most spec compliant](https://json-schema.org/implementations.html#benchmarks).
|
|
12
|
+
|
|
13
|
+
## Background
|
|
14
|
+
|
|
15
|
+
_Why another JSON schema validator?_
|
|
16
|
+
|
|
17
|
+
Cloudflare workers do not have APIs required by [Ajv](https://ajv.js.org/) schema compilation (`eval` or `new Function(code)`).
|
|
18
|
+
If possible use Ajv in a build step to precompile your schema. Otherwise this library could work for you.
|
|
19
|
+
|
|
20
|
+
## Basic usage
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { Validator } from '@cfworker/json-schema';
|
|
24
|
+
|
|
25
|
+
const validator = new Validator({ type: 'number' });
|
|
26
|
+
|
|
27
|
+
const result = validator.validate(7);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Specify meta schema draft
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const validator = new Validator({ type: 'number' }, '4'); // draft-4
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Add schemas
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
const validator = new Validator({
|
|
40
|
+
$id: 'https://foo.bar/baz',
|
|
41
|
+
$ref: '/beep'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
validator.addSchema({ $id: 'https://foo.bar/beep', type: 'boolean' });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Include all errors
|
|
48
|
+
|
|
49
|
+
By default the validator stops processing after the first error. Set the `shortCircuit` parameter to `false` to emit all errors.
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const shortCircuit = false;
|
|
53
|
+
|
|
54
|
+
const draft = '2019-09';
|
|
55
|
+
|
|
56
|
+
const schema = {
|
|
57
|
+
type: 'object',
|
|
58
|
+
required: ['name', 'email', 'number', 'bool'],
|
|
59
|
+
properties: {
|
|
60
|
+
name: { type: 'string' },
|
|
61
|
+
email: { type: 'string', format: 'email' },
|
|
62
|
+
number: { type: 'number' },
|
|
63
|
+
bool: { type: 'boolean' }
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const validator = new Validator(schema, draft, shortCircuit);
|
|
68
|
+
|
|
69
|
+
const result = validator.validate({
|
|
70
|
+
name: 'hello',
|
|
71
|
+
email: 5, // invalid type
|
|
72
|
+
number: 'Hello' // invalid type
|
|
73
|
+
bool: 'false' // invalid type
|
|
74
|
+
});
|
|
75
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepCompareStrict(a: any, b: any): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepCompareStrict = deepCompareStrict;
|
|
4
|
+
function deepCompareStrict(a, b) {
|
|
5
|
+
const typeofa = typeof a;
|
|
6
|
+
if (typeofa !== typeof b) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(a)) {
|
|
10
|
+
if (!Array.isArray(b)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const length = a.length;
|
|
14
|
+
if (length !== b.length) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < length; i++) {
|
|
18
|
+
if (!deepCompareStrict(a[i], b[i])) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (typeofa === 'object') {
|
|
25
|
+
if (!a || !b) {
|
|
26
|
+
return a === b;
|
|
27
|
+
}
|
|
28
|
+
const aKeys = Object.keys(a);
|
|
29
|
+
const bKeys = Object.keys(b);
|
|
30
|
+
const length = aKeys.length;
|
|
31
|
+
if (length !== bKeys.length) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
for (const k of aKeys) {
|
|
35
|
+
if (!deepCompareStrict(a[k], b[k])) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return a === b;
|
|
42
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from './types.js';
|
|
2
|
+
export declare const schemaKeyword: Record<string, boolean>;
|
|
3
|
+
export declare const schemaArrayKeyword: Record<string, boolean>;
|
|
4
|
+
export declare const schemaMapKeyword: Record<string, boolean>;
|
|
5
|
+
export declare const ignoredKeyword: Record<string, boolean>;
|
|
6
|
+
export declare let initialBaseURI: URL;
|
|
7
|
+
export declare function dereference(schema: Schema | boolean, lookup?: Record<string, Schema | boolean>, baseURI?: URL, basePointer?: string): Record<string, Schema | boolean>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialBaseURI = exports.ignoredKeyword = exports.schemaMapKeyword = exports.schemaArrayKeyword = exports.schemaKeyword = void 0;
|
|
4
|
+
exports.dereference = dereference;
|
|
5
|
+
const pointer_js_1 = require("./pointer.js");
|
|
6
|
+
exports.schemaKeyword = {
|
|
7
|
+
additionalItems: true,
|
|
8
|
+
unevaluatedItems: true,
|
|
9
|
+
items: true,
|
|
10
|
+
contains: true,
|
|
11
|
+
additionalProperties: true,
|
|
12
|
+
unevaluatedProperties: true,
|
|
13
|
+
propertyNames: true,
|
|
14
|
+
not: true,
|
|
15
|
+
if: true,
|
|
16
|
+
then: true,
|
|
17
|
+
else: true
|
|
18
|
+
};
|
|
19
|
+
exports.schemaArrayKeyword = {
|
|
20
|
+
prefixItems: true,
|
|
21
|
+
items: true,
|
|
22
|
+
allOf: true,
|
|
23
|
+
anyOf: true,
|
|
24
|
+
oneOf: true
|
|
25
|
+
};
|
|
26
|
+
exports.schemaMapKeyword = {
|
|
27
|
+
$defs: true,
|
|
28
|
+
definitions: true,
|
|
29
|
+
properties: true,
|
|
30
|
+
patternProperties: true,
|
|
31
|
+
dependentSchemas: true
|
|
32
|
+
};
|
|
33
|
+
exports.ignoredKeyword = {
|
|
34
|
+
id: true,
|
|
35
|
+
$id: true,
|
|
36
|
+
$ref: true,
|
|
37
|
+
$schema: true,
|
|
38
|
+
$anchor: true,
|
|
39
|
+
$vocabulary: true,
|
|
40
|
+
$comment: true,
|
|
41
|
+
default: true,
|
|
42
|
+
enum: true,
|
|
43
|
+
const: true,
|
|
44
|
+
required: true,
|
|
45
|
+
type: true,
|
|
46
|
+
maximum: true,
|
|
47
|
+
minimum: true,
|
|
48
|
+
exclusiveMaximum: true,
|
|
49
|
+
exclusiveMinimum: true,
|
|
50
|
+
multipleOf: true,
|
|
51
|
+
maxLength: true,
|
|
52
|
+
minLength: true,
|
|
53
|
+
pattern: true,
|
|
54
|
+
format: true,
|
|
55
|
+
maxItems: true,
|
|
56
|
+
minItems: true,
|
|
57
|
+
uniqueItems: true,
|
|
58
|
+
maxProperties: true,
|
|
59
|
+
minProperties: true
|
|
60
|
+
};
|
|
61
|
+
exports.initialBaseURI = typeof self !== 'undefined' &&
|
|
62
|
+
self.location &&
|
|
63
|
+
self.location.origin !== 'null'
|
|
64
|
+
?
|
|
65
|
+
new URL(self.location.origin + self.location.pathname + location.search)
|
|
66
|
+
: new URL('https://github.com/cfworker');
|
|
67
|
+
function dereference(schema, lookup = Object.create(null), baseURI = exports.initialBaseURI, basePointer = '') {
|
|
68
|
+
if (schema && typeof schema === 'object' && !Array.isArray(schema)) {
|
|
69
|
+
const id = schema.$id || schema.id;
|
|
70
|
+
if (id) {
|
|
71
|
+
const url = new URL(id, baseURI.href);
|
|
72
|
+
if (url.hash.length > 1) {
|
|
73
|
+
lookup[url.href] = schema;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
url.hash = '';
|
|
77
|
+
if (basePointer === '') {
|
|
78
|
+
baseURI = url;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
dereference(schema, lookup, baseURI);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (schema !== true && schema !== false) {
|
|
87
|
+
return lookup;
|
|
88
|
+
}
|
|
89
|
+
const schemaURI = baseURI.href + (basePointer ? '#' + basePointer : '');
|
|
90
|
+
if (lookup[schemaURI] !== undefined) {
|
|
91
|
+
throw new Error(`Duplicate schema URI "${schemaURI}".`);
|
|
92
|
+
}
|
|
93
|
+
lookup[schemaURI] = schema;
|
|
94
|
+
if (schema === true || schema === false) {
|
|
95
|
+
return lookup;
|
|
96
|
+
}
|
|
97
|
+
if (schema.__absolute_uri__ === undefined) {
|
|
98
|
+
Object.defineProperty(schema, '__absolute_uri__', {
|
|
99
|
+
enumerable: false,
|
|
100
|
+
value: schemaURI
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (schema.$ref && schema.__absolute_ref__ === undefined) {
|
|
104
|
+
const url = new URL(schema.$ref, baseURI.href);
|
|
105
|
+
url.hash = url.hash;
|
|
106
|
+
Object.defineProperty(schema, '__absolute_ref__', {
|
|
107
|
+
enumerable: false,
|
|
108
|
+
value: url.href
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
|
|
112
|
+
const url = new URL(schema.$recursiveRef, baseURI.href);
|
|
113
|
+
url.hash = url.hash;
|
|
114
|
+
Object.defineProperty(schema, '__absolute_recursive_ref__', {
|
|
115
|
+
enumerable: false,
|
|
116
|
+
value: url.href
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (schema.$anchor) {
|
|
120
|
+
const url = new URL('#' + schema.$anchor, baseURI.href);
|
|
121
|
+
lookup[url.href] = schema;
|
|
122
|
+
}
|
|
123
|
+
for (let key in schema) {
|
|
124
|
+
if (exports.ignoredKeyword[key]) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const keyBase = `${basePointer}/${(0, pointer_js_1.encodePointer)(key)}`;
|
|
128
|
+
const subSchema = schema[key];
|
|
129
|
+
if (Array.isArray(subSchema)) {
|
|
130
|
+
if (exports.schemaArrayKeyword[key]) {
|
|
131
|
+
const length = subSchema.length;
|
|
132
|
+
for (let i = 0; i < length; i++) {
|
|
133
|
+
dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (exports.schemaMapKeyword[key]) {
|
|
138
|
+
for (let subKey in subSchema) {
|
|
139
|
+
dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${(0, pointer_js_1.encodePointer)(subKey)}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
dereference(subSchema, lookup, baseURI, keyBase);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return lookup;
|
|
147
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const format: Record<string, (s: string) => boolean>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.format = void 0;
|
|
4
|
+
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
5
|
+
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
6
|
+
const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
7
|
+
const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
|
8
|
+
const URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25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{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
|
11
|
+
const UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
12
|
+
const JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
13
|
+
const JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
14
|
+
const RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
15
|
+
const EMAIL = (input) => {
|
|
16
|
+
if (input[0] === '"')
|
|
17
|
+
return false;
|
|
18
|
+
const [name, host, ...rest] = input.split('@');
|
|
19
|
+
if (!name ||
|
|
20
|
+
!host ||
|
|
21
|
+
rest.length !== 0 ||
|
|
22
|
+
name.length > 64 ||
|
|
23
|
+
host.length > 253)
|
|
24
|
+
return false;
|
|
25
|
+
if (name[0] === '.' || name.endsWith('.') || name.includes('..'))
|
|
26
|
+
return false;
|
|
27
|
+
if (!/^[a-z0-9.-]+$/i.test(host) ||
|
|
28
|
+
!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name))
|
|
29
|
+
return false;
|
|
30
|
+
return host
|
|
31
|
+
.split('.')
|
|
32
|
+
.every(part => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
|
|
33
|
+
};
|
|
34
|
+
const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
|
|
35
|
+
const IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
|
|
36
|
+
const DURATION = (input) => input.length > 1 &&
|
|
37
|
+
input.length < 80 &&
|
|
38
|
+
(/^P\d+([.,]\d+)?W$/.test(input) ||
|
|
39
|
+
(/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) &&
|
|
40
|
+
/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input)));
|
|
41
|
+
function bind(r) {
|
|
42
|
+
return r.test.bind(r);
|
|
43
|
+
}
|
|
44
|
+
exports.format = {
|
|
45
|
+
date,
|
|
46
|
+
time: time.bind(undefined, false),
|
|
47
|
+
'date-time': date_time,
|
|
48
|
+
duration: DURATION,
|
|
49
|
+
uri,
|
|
50
|
+
'uri-reference': bind(URIREF),
|
|
51
|
+
'uri-template': bind(URITEMPLATE),
|
|
52
|
+
url: bind(URL_),
|
|
53
|
+
email: EMAIL,
|
|
54
|
+
hostname: bind(HOSTNAME),
|
|
55
|
+
ipv4: bind(IPV4),
|
|
56
|
+
ipv6: bind(IPV6),
|
|
57
|
+
regex: regex,
|
|
58
|
+
uuid: bind(UUID),
|
|
59
|
+
'json-pointer': bind(JSON_POINTER),
|
|
60
|
+
'json-pointer-uri-fragment': bind(JSON_POINTER_URI_FRAGMENT),
|
|
61
|
+
'relative-json-pointer': bind(RELATIVE_JSON_POINTER)
|
|
62
|
+
};
|
|
63
|
+
function isLeapYear(year) {
|
|
64
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
65
|
+
}
|
|
66
|
+
function date(str) {
|
|
67
|
+
const matches = str.match(DATE);
|
|
68
|
+
if (!matches)
|
|
69
|
+
return false;
|
|
70
|
+
const year = +matches[1];
|
|
71
|
+
const month = +matches[2];
|
|
72
|
+
const day = +matches[3];
|
|
73
|
+
return (month >= 1 &&
|
|
74
|
+
month <= 12 &&
|
|
75
|
+
day >= 1 &&
|
|
76
|
+
day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]));
|
|
77
|
+
}
|
|
78
|
+
function time(full, str) {
|
|
79
|
+
const matches = str.match(TIME);
|
|
80
|
+
if (!matches)
|
|
81
|
+
return false;
|
|
82
|
+
const hour = +matches[1];
|
|
83
|
+
const minute = +matches[2];
|
|
84
|
+
const second = +matches[3];
|
|
85
|
+
const timeZone = !!matches[5];
|
|
86
|
+
return (((hour <= 23 && minute <= 59 && second <= 59) ||
|
|
87
|
+
(hour == 23 && minute == 59 && second == 60)) &&
|
|
88
|
+
(!full || timeZone));
|
|
89
|
+
}
|
|
90
|
+
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
91
|
+
function date_time(str) {
|
|
92
|
+
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
93
|
+
return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
|
|
94
|
+
}
|
|
95
|
+
const NOT_URI_FRAGMENT = /\/|:/;
|
|
96
|
+
const URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
97
|
+
function uri(str) {
|
|
98
|
+
return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
|
|
99
|
+
}
|
|
100
|
+
const Z_ANCHOR = /[^\\]\\Z/;
|
|
101
|
+
function regex(str) {
|
|
102
|
+
if (Z_ANCHOR.test(str))
|
|
103
|
+
return false;
|
|
104
|
+
try {
|
|
105
|
+
new RegExp(str, 'u');
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './deep-compare-strict.js';
|
|
2
|
+
export * from './dereference.js';
|
|
3
|
+
export * from './format.js';
|
|
4
|
+
export * from './pointer.js';
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export * from './ucs2-length.js';
|
|
7
|
+
export * from './validate.js';
|
|
8
|
+
export * from './validator.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./deep-compare-strict.js"), exports);
|
|
18
|
+
__exportStar(require("./dereference.js"), exports);
|
|
19
|
+
__exportStar(require("./format.js"), exports);
|
|
20
|
+
__exportStar(require("./pointer.js"), exports);
|
|
21
|
+
__exportStar(require("./types.js"), exports);
|
|
22
|
+
__exportStar(require("./ucs2-length.js"), exports);
|
|
23
|
+
__exportStar(require("./validate.js"), exports);
|
|
24
|
+
__exportStar(require("./validator.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodePointer = encodePointer;
|
|
4
|
+
exports.escapePointer = escapePointer;
|
|
5
|
+
function encodePointer(p) {
|
|
6
|
+
return encodeURI(escapePointer(p));
|
|
7
|
+
}
|
|
8
|
+
function escapePointer(p) {
|
|
9
|
+
return p.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
10
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type SchemaDraft = '4' | '7' | '2019-09' | '2020-12';
|
|
2
|
+
export declare const enum OutputFormat {
|
|
3
|
+
Flag = 1,
|
|
4
|
+
Basic = 2,
|
|
5
|
+
Detailed = 4
|
|
6
|
+
}
|
|
7
|
+
export type InstanceType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
|
|
8
|
+
export interface Schema {
|
|
9
|
+
$id?: string;
|
|
10
|
+
$anchor?: string;
|
|
11
|
+
$recursiveAnchor?: boolean;
|
|
12
|
+
$ref?: string;
|
|
13
|
+
$recursiveRef?: '#';
|
|
14
|
+
$schema?: string;
|
|
15
|
+
$comment?: string;
|
|
16
|
+
$defs?: any;
|
|
17
|
+
$vocabulary?: Record<string, boolean>;
|
|
18
|
+
type?: InstanceType | InstanceType[];
|
|
19
|
+
const?: any;
|
|
20
|
+
enum?: any[];
|
|
21
|
+
required?: string[];
|
|
22
|
+
not?: Schema;
|
|
23
|
+
anyOf?: Schema[];
|
|
24
|
+
allOf?: Schema[];
|
|
25
|
+
oneOf?: Schema[];
|
|
26
|
+
if?: Schema;
|
|
27
|
+
then?: Schema;
|
|
28
|
+
else?: Schema;
|
|
29
|
+
format?: string;
|
|
30
|
+
properties?: Record<string | number, Schema | boolean>;
|
|
31
|
+
patternProperties?: Record<string, Schema | boolean>;
|
|
32
|
+
additionalProperties?: Schema | boolean;
|
|
33
|
+
unevaluatedProperties?: Schema | boolean;
|
|
34
|
+
minProperties?: number;
|
|
35
|
+
maxProperties?: number;
|
|
36
|
+
propertyNames?: Schema;
|
|
37
|
+
dependentRequired?: Record<string, string[]>;
|
|
38
|
+
dependentSchemas?: Record<string, Schema>;
|
|
39
|
+
dependencies?: Record<string, Schema | string[]>;
|
|
40
|
+
prefixItems?: Array<Schema | boolean>;
|
|
41
|
+
items?: Schema | boolean | Array<Schema | boolean>;
|
|
42
|
+
additionalItems?: Schema | boolean;
|
|
43
|
+
unevaluatedItems?: Schema | boolean;
|
|
44
|
+
contains?: Schema | boolean;
|
|
45
|
+
minContains?: number;
|
|
46
|
+
maxContains?: number;
|
|
47
|
+
minItems?: number;
|
|
48
|
+
maxItems?: number;
|
|
49
|
+
uniqueItems?: boolean;
|
|
50
|
+
minimum?: number;
|
|
51
|
+
maximum?: number;
|
|
52
|
+
exclusiveMinimum?: number | boolean;
|
|
53
|
+
exclusiveMaximum?: number | boolean;
|
|
54
|
+
multipleOf?: number;
|
|
55
|
+
minLength?: number;
|
|
56
|
+
maxLength?: number;
|
|
57
|
+
pattern?: string;
|
|
58
|
+
__absolute_ref__?: string;
|
|
59
|
+
__absolute_recursive_ref__?: string;
|
|
60
|
+
__absolute_uri__?: string;
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}
|
|
63
|
+
export interface OutputUnit {
|
|
64
|
+
keyword: string;
|
|
65
|
+
keywordLocation: string;
|
|
66
|
+
instanceLocation: string;
|
|
67
|
+
error: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ValidationResult {
|
|
70
|
+
valid: boolean;
|
|
71
|
+
errors: OutputUnit[];
|
|
72
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutputFormat = void 0;
|
|
4
|
+
var OutputFormat;
|
|
5
|
+
(function (OutputFormat) {
|
|
6
|
+
OutputFormat[OutputFormat["Flag"] = 1] = "Flag";
|
|
7
|
+
OutputFormat[OutputFormat["Basic"] = 2] = "Basic";
|
|
8
|
+
OutputFormat[OutputFormat["Detailed"] = 4] = "Detailed";
|
|
9
|
+
})(OutputFormat || (exports.OutputFormat = OutputFormat = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ucs2length(s: string): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ucs2length = ucs2length;
|
|
4
|
+
function ucs2length(s) {
|
|
5
|
+
let result = 0;
|
|
6
|
+
let length = s.length;
|
|
7
|
+
let index = 0;
|
|
8
|
+
let charCode;
|
|
9
|
+
while (index < length) {
|
|
10
|
+
result++;
|
|
11
|
+
charCode = s.charCodeAt(index++);
|
|
12
|
+
if (charCode >= 0xd800 && charCode <= 0xdbff && index < length) {
|
|
13
|
+
charCode = s.charCodeAt(index);
|
|
14
|
+
if ((charCode & 0xfc00) == 0xdc00) {
|
|
15
|
+
index++;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Schema, SchemaDraft, ValidationResult } from './types.js';
|
|
2
|
+
export type Evaluated = Record<string | number, boolean>;
|
|
3
|
+
export declare function validate(instance: any, schema: Schema | boolean, draft?: SchemaDraft, lookup?: Record<string, Schema | boolean>, shortCircuit?: boolean, recursiveAnchor?: Schema | null, instanceLocation?: string, schemaLocation?: string, evaluated?: Evaluated): ValidationResult;
|