complete-cli 1.0.5-dev.1 → 1.0.5-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.cjs +65139 -2
- package/dist/main.cjs.map +1 -1
- package/dist/vendors-node_modules_prettier_plugins_acorn_mjs.main.cjs +38 -0
- package/dist/vendors-node_modules_prettier_plugins_acorn_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_angular_mjs.main.cjs +25 -0
- package/dist/vendors-node_modules_prettier_plugins_angular_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_babel_mjs.main.cjs +38 -0
- package/dist/vendors-node_modules_prettier_plugins_babel_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_estree_mjs.main.cjs +61 -0
- package/dist/vendors-node_modules_prettier_plugins_estree_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_flow_mjs.main.cjs +42 -0
- package/dist/vendors-node_modules_prettier_plugins_flow_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_glimmer_mjs.main.cjs +55 -0
- package/dist/vendors-node_modules_prettier_plugins_glimmer_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_graphql_mjs.main.cjs +55 -0
- package/dist/vendors-node_modules_prettier_plugins_graphql_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_html_mjs.main.cjs +48 -0
- package/dist/vendors-node_modules_prettier_plugins_html_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_markdown_mjs.main.cjs +89 -0
- package/dist/vendors-node_modules_prettier_plugins_markdown_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_meriyah_mjs.main.cjs +27 -0
- package/dist/vendors-node_modules_prettier_plugins_meriyah_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_postcss_mjs.main.cjs +80 -0
- package/dist/vendors-node_modules_prettier_plugins_postcss_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_typescript_mjs.main.cjs +43 -0
- package/dist/vendors-node_modules_prettier_plugins_typescript_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_prettier_plugins_yaml_mjs.main.cjs +187 -0
- package/dist/vendors-node_modules_prettier_plugins_yaml_mjs.main.cjs.map +1 -0
- package/dist/vendors-node_modules_typanion_lib_index_js.main.cjs +1323 -0
- package/dist/vendors-node_modules_typanion_lib_index_js.main.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/107.main.cjs +0 -2
- package/dist/107.main.cjs.map +0 -1
- package/dist/140.main.cjs +0 -2
- package/dist/140.main.cjs.map +0 -1
- package/dist/242.main.cjs +0 -2
- package/dist/242.main.cjs.map +0 -1
- package/dist/269.main.cjs +0 -2
- package/dist/269.main.cjs.map +0 -1
- package/dist/309.main.cjs +0 -2
- package/dist/309.main.cjs.map +0 -1
- package/dist/367.main.cjs +0 -2
- package/dist/367.main.cjs.map +0 -1
- package/dist/541.main.cjs +0 -2
- package/dist/541.main.cjs.map +0 -1
- package/dist/55.main.cjs +0 -2
- package/dist/55.main.cjs.map +0 -1
- package/dist/717.main.cjs +0 -2
- package/dist/717.main.cjs.map +0 -1
- package/dist/742.main.cjs +0 -2
- package/dist/742.main.cjs.map +0 -1
- package/dist/769.main.cjs +0 -2
- package/dist/769.main.cjs.map +0 -1
- package/dist/770.main.cjs +0 -2
- package/dist/770.main.cjs.map +0 -1
- package/dist/914.main.cjs +0 -2
- package/dist/914.main.cjs.map +0 -1
- package/dist/951.main.cjs +0 -2
- package/dist/951.main.cjs.map +0 -1
- package/dist/main.cjs.LICENSE.txt +0 -78
package/dist/770.main.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";exports.id=770,exports.ids=[770],exports.modules={770:(n,o)=>{const r=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function e(n){return null===n?"null":void 0===n?"undefined":""===n?"an empty string":"symbol"==typeof n?`<${n.toString()}>`:Array.isArray(n)?"an array":JSON.stringify(n)}function i(n,o){var e,i,t;return"number"==typeof o?`${null!==(e=null==n?void 0:n.p)&&void 0!==e?e:"."}[${o}]`:r.test(o)?`${null!==(i=null==n?void 0:n.p)&&void 0!==i?i:""}.${o}`:`${null!==(t=null==n?void 0:n.p)&&void 0!==t?t:"."}[${JSON.stringify(o)}]`}function t({errors:n,p:o}={},r){return null==n||n.push(`${null!=o?o:"."}: ${r}`),!1}function l(n,o){return r=>{const e=n[o];return n[o]=r,l(n,o).bind(null,e)}}new Map([["true",!0],["True",!0],["1",!0],[1,!0],["false",!1],["False",!1],["0",!1],[0,!1]]);function s(n,{delimiter:o}={}){const r=(s=n.length,u({test:(n,o)=>n.length===s||t(o,`Expected to have a length of exactly ${s} elements (got ${n.length})`)}));var s;return u({test:(s,c)=>{var u;if("string"==typeof s&&void 0!==o&&void 0!==(null==c?void 0:c.coercions)){if(void 0===(null==c?void 0:c.coercion))return t(c,"Unbound coercion result");s=s.split(o),c.coercions.push([null!==(u=c.p)&&void 0!==u?u:".",c.coercion.bind(null,s)])}if(!Array.isArray(s))return t(c,`Expected a tuple (got ${e(s)})`);let d=r(s,Object.assign({},c));for(let o=0,r=s.length;o<r&&o<n.length&&(d=n[o](s[o],Object.assign(Object.assign({},c),{p:i(c,o),coercion:l(s,o)}))&&d,d||null!=(null==c?void 0:c.errors));++o);return d}})}function c(n,{keys:o=null}={}){const r=function(n,{delimiter:o}={}){return u({test:(r,s)=>{var c;const u=r;if("string"==typeof r&&void 0!==o&&void 0!==(null==s?void 0:s.coercions)){if(void 0===(null==s?void 0:s.coercion))return t(s,"Unbound coercion result");r=r.split(o)}if(!Array.isArray(r))return t(s,`Expected an array (got ${e(r)})`);let d=!0;for(let o=0,e=r.length;o<e&&(d=n(r[o],Object.assign(Object.assign({},s),{p:i(s,o),coercion:l(r,o)}))&&d,d||null!=(null==s?void 0:s.errors));++o);return r!==u&&s.coercions.push([null!==(c=s.p)&&void 0!==c?c:".",s.coercion.bind(null,r)]),d}})}(s([null!=o?o:u({test:(n,o)=>"string"==typeof n||t(o,`Expected a string (got ${e(n)})`)}),n]));return u({test:(s,c)=>{var u;if(Array.isArray(s)&&void 0!==(null==c?void 0:c.coercions))return void 0===(null==c?void 0:c.coercion)?t(c,"Unbound coercion result"):!!r(s,Object.assign(Object.assign({},c),{coercion:void 0}))&&(s=Object.fromEntries(s),c.coercions.push([null!==(u=c.p)&&void 0!==u?u:".",c.coercion.bind(null,s)]),!0);if("object"!=typeof s||null===s)return t(c,`Expected an object (got ${e(s)})`);const d=Object.keys(s);let a=!0;for(let r=0,e=d.length;r<e&&(a||null!=(null==c?void 0:c.errors));++r){const e=d[r],u=s[e];"__proto__"!==e&&"constructor"!==e?(null===o||o(e,c))&&n(u,Object.assign(Object.assign({},c),{p:i(c,e),coercion:l(s,e)}))||(a=!1):a=t(Object.assign(Object.assign({},c),{p:i(c,e)}),"Unsafe property name")}return a}})}function u({test:n}){return(o=n,()=>o)();var o}Error;var d;(d=o.s2||(o.s2={})).Forbids="Forbids",d.Requires="Requires";o.s2.Forbids,o.s2.Requires;o.applyCascade=function(n,...o){return function(n,...o){const r=Array.isArray(o[0])?o[0]:o;return u({test:(o,e)=>{var i,s;const c={value:o},u=void 0!==(null==e?void 0:e.coercions)?l(c,"value"):void 0,d=void 0!==(null==e?void 0:e.coercions)?[]:void 0;if(!n(o,Object.assign(Object.assign({},e),{coercion:u,coercions:d})))return!1;const a=[];if(void 0!==d)for(const[,n]of d)a.push(n());try{if(void 0!==(null==e?void 0:e.coercions)){if(c.value!==o){if(void 0===(null==e?void 0:e.coercion))return t(e,"Unbound coercion result");e.coercions.push([null!==(i=e.p)&&void 0!==i?i:".",e.coercion.bind(null,c.value)])}null===(s=null==e?void 0:e.coercions)||void 0===s||s.push(...d)}return r.every((n=>n(c.value,e)))}finally{for(const n of a)n()}}})}(n,Array.isArray(o[0])?o[0]:o)},o.isDict=function(n,o={}){return c(n,o)},o.isUnknown=function(){return u({test:(n,o)=>!0})}}};
|
|
2
|
-
//# sourceMappingURL=770.main.cjs.map
|
package/dist/770.main.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"770.main.cjs","mappings":"2EAIA,MAAMA,EAAkB,2BACxB,SAASC,EAAaC,GAClB,OAAc,OAAVA,EACO,YACGC,IAAVD,EACO,YACG,KAAVA,EACO,kBACU,iBAAVA,EACA,IAAIA,EAAME,cACjBC,MAAMC,QAAQJ,GACP,WACJK,KAAKC,UAAUN,EAC1B,CAaA,SAASO,EAAWC,EAAOC,GACvB,IAAIC,EAAIC,EAAIC,EACZ,MAAmB,iBAARH,EACA,GAAoE,QAAhEC,EAAKF,aAAqC,EAASA,EAAMK,SAAsB,IAAPH,EAAgBA,EAAK,OAAOD,KAE1GX,EAAgBgB,KAAKL,GACnB,GAAoE,QAAhEE,EAAKH,aAAqC,EAASA,EAAMK,SAAsB,IAAPF,EAAgBA,EAAK,MAAMF,IAGvG,GAAoE,QAAhEG,EAAKJ,aAAqC,EAASA,EAAMK,SAAsB,IAAPD,EAAgBA,EAAK,OAAOP,KAAKC,UAAUG,KAEtI,CAcA,SAASM,GAAU,OAAEC,EAAM,EAAEH,GAAM,CAAC,EAAGI,GAEnC,OADAD,SAAgDA,EAAOE,KAAK,GAAGL,QAA6BA,EAAI,QAAQI,MACjG,CACX,CAMA,SAASE,EAAeC,EAAQX,GAC5B,OAAQY,IACJ,MAAMC,EAAWF,EAAOX,GAExB,OADAW,EAAOX,GAAOY,EACPF,EAAeC,EAAQX,GAAKc,KAAK,KAAMD,EAAS,CAE/D,CAiE0B,IAAIE,IAAI,CAC9B,CAAC,QAAQ,GACT,CAAC,QAAQ,GACT,CAAC,KAAK,GACN,CAAC,GAAG,GACJ,CAAC,SAAS,GACV,CAAC,SAAS,GACV,CAAC,KAAK,GACN,CAAC,GAAG,KAiUR,SAASC,EAAQC,GAAM,UAA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EpD,MAAOA,GACnBqD,OAAyF,KAAnE7C,aAAqC,EAASA,EAAMuB,WAC1EZ,EAAeiC,EAAS,cAAWnD,EACnCqD,OAA0F,KAAnE9C,aAAqC,EAASA,EAAMuB,WAC3E,QAAK9B,EACX,IAAKyB,EAAK1B,EAAOmC,OAAOC,OAAOD,OAAOC,OAAO,CAAC,EAAG5B,GAAQ,CAAEwB,SAAUqB,EAAatB,UAAWuB,KACzF,OAAO,EACX,MAAMC,EAAU,GAChB,QAA4B,IAAjBD,EACP,IAAK,MAAO,CAAEtB,KAAasB,EACvBC,EAAQrC,KAAKc,KACrB,IACI,QAA+E,KAAnExB,aAAqC,EAASA,EAAMuB,WAA4B,CACxF,GAAIqB,EAAQpD,QAAUA,EAAO,CACzB,QAA8E,KAAlEQ,aAAqC,EAASA,EAAMwB,UAC5D,OAAOjB,EAAUP,EAAO,2BAC5BA,EAAMuB,UAAUb,KAAK,CAAoB,QAAlBR,EAAKF,EAAMK,SAAsB,IAAPH,EAAgBA,EAAK,IAAKF,EAAMwB,SAAST,KAAK,KAAM6B,EAAQpD,QACjH,CACyE,QAAxEW,EAAKH,aAAqC,EAASA,EAAMuB,iBAA8B,IAAPpB,GAAyBA,EAAGO,QAAQoC,EACzH,CACA,OAAOH,EAAkBK,OAAM9B,GACpBA,EAAK0B,EAAQpD,MAAOQ,IAEnC,CACA,QACI,IAAK,MAAMiD,KAAUF,EACjBE,GAER,IAGZ,CAKWC,CAAQhC,EAHWvB,MAAMC,QAAQ8C,EAAU,IAC5CA,EAAU,GACVA,EAEV,EAiLAF,EAAQW,OA3tBR,SAAgBjC,EAAMkC,EAAO,CAAC,GAC1B,OAAOrB,EAASb,EAAMkC,EAC1B,EAmvBAZ,EAAQa,UA7rCR,WACI,OAAO/B,EAAc,CACjBhB,KAAM,CAACd,EAAOQ,KACH,GAGnB,C","sources":["webpack://complete-cli/../../node_modules/typanion/lib/index.js"],"sourcesContent":["'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst simpleKeyRegExp = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\nfunction getPrintable(value) {\n if (value === null)\n return `null`;\n if (value === undefined)\n return `undefined`;\n if (value === ``)\n return `an empty string`;\n if (typeof value === 'symbol')\n return `<${value.toString()}>`;\n if (Array.isArray(value))\n return `an array`;\n return JSON.stringify(value);\n}\nfunction getPrintableArray(value, conjunction) {\n if (value.length === 0)\n return `nothing`;\n if (value.length === 1)\n return getPrintable(value[0]);\n const rest = value.slice(0, -1);\n const trailing = value[value.length - 1];\n const separator = value.length > 2\n ? `, ${conjunction} `\n : ` ${conjunction} `;\n return `${rest.map(value => getPrintable(value)).join(`, `)}${separator}${getPrintable(trailing)}`;\n}\nfunction computeKey(state, key) {\n var _a, _b, _c;\n if (typeof key === `number`) {\n return `${(_a = state === null || state === void 0 ? void 0 : state.p) !== null && _a !== void 0 ? _a : `.`}[${key}]`;\n }\n else if (simpleKeyRegExp.test(key)) {\n return `${(_b = state === null || state === void 0 ? void 0 : state.p) !== null && _b !== void 0 ? _b : ``}.${key}`;\n }\n else {\n return `${(_c = state === null || state === void 0 ? void 0 : state.p) !== null && _c !== void 0 ? _c : `.`}[${JSON.stringify(key)}]`;\n }\n}\nfunction plural(n, singular, plural) {\n return n === 1 ? singular : plural;\n}\n\nconst colorStringRegExp = /^#[0-9a-f]{6}$/i;\nconst colorStringAlphaRegExp = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;\n// https://stackoverflow.com/a/475217/880703\nconst base64RegExp = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;\n// https://stackoverflow.com/a/14166194/880703\nconst uuid4RegExp = /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}$/i;\n// https://stackoverflow.com/a/28022901/880703 + https://www.debuggex.com/r/bl8J35wMKk48a7u_\nconst iso8601RegExp = /^(?:[1-9]\\d{3}(-?)(?:(?:0[1-9]|1[0-2])\\1(?:0[1-9]|1\\d|2[0-8])|(?:0[13-9]|1[0-2])\\1(?:29|30)|(?:0[13578]|1[02])(?:\\1)31|00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[0-5]))|(?:[1-9]\\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)(?:(-?)02(?:\\2)29|-?366))T(?:[01]\\d|2[0-3])(:?)[0-5]\\d(?:\\3[0-5]\\d)?(?:Z|[+-][01]\\d(?:\\3[0-5]\\d)?)$/;\n\nfunction pushError({ errors, p } = {}, message) {\n errors === null || errors === void 0 ? void 0 : errors.push(`${p !== null && p !== void 0 ? p : `.`}: ${message}`);\n return false;\n}\nfunction makeSetter(target, key) {\n return (v) => {\n target[key] = v;\n };\n}\nfunction makeCoercionFn(target, key) {\n return (v) => {\n const previous = target[key];\n target[key] = v;\n return makeCoercionFn(target, key).bind(null, previous);\n };\n}\nfunction makeLazyCoercionFn(fn, orig, generator) {\n const commit = () => {\n fn(generator());\n return revert;\n };\n const revert = () => {\n fn(orig);\n return commit;\n };\n return commit;\n}\n\n/**\n * Create a validator that always returns true and never refines the type.\n */\nfunction isUnknown() {\n return makeValidator({\n test: (value, state) => {\n return true;\n },\n });\n}\nfunction isLiteral(expected) {\n return makeValidator({\n test: (value, state) => {\n if (value !== expected)\n return pushError(state, `Expected ${getPrintable(expected)} (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that only returns true when the tested value is a string.\n * Refines the type to `string`.\n */\nfunction isString() {\n return makeValidator({\n test: (value, state) => {\n if (typeof value !== `string`)\n return pushError(state, `Expected a string (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\nfunction isEnum(enumSpec) {\n const valuesArray = Array.isArray(enumSpec) ? enumSpec : Object.values(enumSpec);\n const isAlphaNum = valuesArray.every(item => typeof item === 'string' || typeof item === 'number');\n const values = new Set(valuesArray);\n if (values.size === 1)\n return isLiteral([...values][0]);\n return makeValidator({\n test: (value, state) => {\n if (!values.has(value)) {\n if (isAlphaNum) {\n return pushError(state, `Expected one of ${getPrintableArray(valuesArray, `or`)} (got ${getPrintable(value)})`);\n }\n else {\n return pushError(state, `Expected a valid enumeration value (got ${getPrintable(value)})`);\n }\n }\n return true;\n },\n });\n}\nconst BOOLEAN_COERCIONS = new Map([\n [`true`, true],\n [`True`, true],\n [`1`, true],\n [1, true],\n [`false`, false],\n [`False`, false],\n [`0`, false],\n [0, false],\n]);\n/**\n * Create a validator that only returns true when the tested value is a\n * boolean. Refines the type to `boolean`.\n *\n * Supports coercion:\n * - 'true' / 'True' / '1' / 1 will turn to `true`\n * - 'false' / 'False' / '0' / 0 will turn to `false`\n */\nfunction isBoolean() {\n return makeValidator({\n test: (value, state) => {\n var _a;\n if (typeof value !== `boolean`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n const coercion = BOOLEAN_COERCIONS.get(value);\n if (typeof coercion !== `undefined`) {\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, coercion)]);\n return true;\n }\n }\n return pushError(state, `Expected a boolean (got ${getPrintable(value)})`);\n }\n return true;\n },\n });\n}\n/**\n * Create a validator that only returns true when the tested value is a\n * number (including floating numbers; use `cascade` and `isInteger` to\n * restrict the range further). Refines the type to `number`.\n *\n * Supports coercion.\n */\nfunction isNumber() {\n return makeValidator({\n test: (value, state) => {\n var _a;\n if (typeof value !== `number`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n let coercion;\n if (typeof value === `string`) {\n let val;\n try {\n val = JSON.parse(value);\n }\n catch (_b) { }\n // We check against JSON.stringify that the output is the same to ensure that the number can be safely represented in JS\n if (typeof val === `number`) {\n if (JSON.stringify(val) === value) {\n coercion = val;\n }\n else {\n return pushError(state, `Received a number that can't be safely represented by the runtime (${value})`);\n }\n }\n }\n if (typeof coercion !== `undefined`) {\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, coercion)]);\n return true;\n }\n }\n return pushError(state, `Expected a number (got ${getPrintable(value)})`);\n }\n return true;\n },\n });\n}\n/**\n * Important: This validator only makes sense when used in conjunction with\n * coercion! It will always error when used without.\n *\n * Create a validator that only returns true when the tested value is a\n * JSON representation of the expected type. Refines the type to the\n * expected type, and casts the value into its inner value.\n */\nfunction isPayload(spec) {\n return makeValidator({\n test: (value, state) => {\n var _a;\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) === `undefined`)\n return pushError(state, `The isPayload predicate can only be used with coercion enabled`);\n if (typeof state.coercion === `undefined`)\n return pushError(state, `Unbound coercion result`);\n if (typeof value !== `string`)\n return pushError(state, `Expected a string (got ${getPrintable(value)})`);\n let inner;\n try {\n inner = JSON.parse(value);\n }\n catch (_b) {\n return pushError(state, `Expected a JSON string (got ${getPrintable(value)})`);\n }\n const wrapper = { value: inner };\n if (!spec(inner, Object.assign(Object.assign({}, state), { coercion: makeCoercionFn(wrapper, `value`) })))\n return false;\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, wrapper.value)]);\n return true;\n },\n });\n}\n/**\n * Create a validator that only returns true when the tested value is a\n * valid date. Refines the type to `Date`.\n *\n * Supports coercion via one of the following formats:\n * - ISO86001 strings\n * - Unix timestamps\n */\nfunction isDate() {\n return makeValidator({\n test: (value, state) => {\n var _a;\n if (!(value instanceof Date)) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n let coercion;\n if (typeof value === `string` && iso8601RegExp.test(value)) {\n coercion = new Date(value);\n }\n else {\n let timestamp;\n if (typeof value === `string`) {\n let val;\n try {\n val = JSON.parse(value);\n }\n catch (_b) { }\n if (typeof val === `number`) {\n timestamp = val;\n }\n }\n else if (typeof value === `number`) {\n timestamp = value;\n }\n if (typeof timestamp !== `undefined`) {\n if (Number.isSafeInteger(timestamp) || !Number.isSafeInteger(timestamp * 1000)) {\n coercion = new Date(timestamp * 1000);\n }\n else {\n return pushError(state, `Received a timestamp that can't be safely represented by the runtime (${value})`);\n }\n }\n }\n if (typeof coercion !== `undefined`) {\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, coercion)]);\n return true;\n }\n }\n return pushError(state, `Expected a date (got ${getPrintable(value)})`);\n }\n return true;\n },\n });\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * array whose all values match the provided subspec. Refines the type to\n * `Array<T>`, with `T` being the subspec inferred type.\n *\n * Supports coercion if the `delimiter` option is set, in which case strings\n * will be split accordingly.\n */\nfunction isArray(spec, { delimiter } = {}) {\n return makeValidator({\n test: (value, state) => {\n var _a;\n const originalValue = value;\n if (typeof value === `string` && typeof delimiter !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n value = value.split(delimiter);\n }\n }\n if (!Array.isArray(value))\n return pushError(state, `Expected an array (got ${getPrintable(value)})`);\n let valid = true;\n for (let t = 0, T = value.length; t < T; ++t) {\n valid = spec(value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid;\n if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {\n break;\n }\n }\n if (value !== originalValue)\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);\n return valid;\n },\n });\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * set whose all values match the provided subspec. Refines the type to\n * `Set<T>`, with `T` being the subspec inferred type.\n *\n * Supports coercion from arrays (or anything that can be coerced into an\n * array).\n */\nfunction isSet(spec, { delimiter } = {}) {\n const isArrayValidator = isArray(spec, { delimiter });\n return makeValidator({\n test: (value, state) => {\n var _a, _b;\n if (Object.getPrototypeOf(value).toString() === `[object Set]`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n const originalValues = [...value];\n const coercedValues = [...value];\n if (!isArrayValidator(coercedValues, Object.assign(Object.assign({}, state), { coercion: undefined })))\n return false;\n const updateValue = () => coercedValues.some((val, t) => val !== originalValues[t])\n ? new Set(coercedValues)\n : value;\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, makeLazyCoercionFn(state.coercion, value, updateValue)]);\n return true;\n }\n else {\n let valid = true;\n for (const subValue of value) {\n valid = spec(subValue, Object.assign({}, state)) && valid;\n if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {\n break;\n }\n }\n return valid;\n }\n }\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n const store = { value };\n if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: makeCoercionFn(store, `value`) })))\n return false;\n state.coercions.push([(_b = state.p) !== null && _b !== void 0 ? _b : `.`, makeLazyCoercionFn(state.coercion, value, () => new Set(store.value))]);\n return true;\n }\n return pushError(state, `Expected a set (got ${getPrintable(value)})`);\n }\n });\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * map whose all values match the provided subspecs. Refines the type to\n * `Map<U, V>`, with `U` being the key subspec inferred type and `V` being\n * the value subspec inferred type.\n *\n * Supports coercion from array of tuples (or anything that can be coerced into\n * an array of tuples).\n */\nfunction isMap(keySpec, valueSpec) {\n const isArrayValidator = isArray(isTuple([keySpec, valueSpec]));\n const isRecordValidator = isRecord(valueSpec, { keys: keySpec });\n return makeValidator({\n test: (value, state) => {\n var _a, _b, _c;\n if (Object.getPrototypeOf(value).toString() === `[object Map]`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n const originalValues = [...value];\n const coercedValues = [...value];\n if (!isArrayValidator(coercedValues, Object.assign(Object.assign({}, state), { coercion: undefined })))\n return false;\n const updateValue = () => coercedValues.some((val, t) => val[0] !== originalValues[t][0] || val[1] !== originalValues[t][1])\n ? new Map(coercedValues)\n : value;\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, makeLazyCoercionFn(state.coercion, value, updateValue)]);\n return true;\n }\n else {\n let valid = true;\n for (const [key, subValue] of value) {\n valid = keySpec(key, Object.assign({}, state)) && valid;\n if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {\n break;\n }\n valid = valueSpec(subValue, Object.assign(Object.assign({}, state), { p: computeKey(state, key) })) && valid;\n if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {\n break;\n }\n }\n return valid;\n }\n }\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n const store = { value };\n if (Array.isArray(value)) {\n if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: undefined })))\n return false;\n state.coercions.push([(_b = state.p) !== null && _b !== void 0 ? _b : `.`, makeLazyCoercionFn(state.coercion, value, () => new Map(store.value))]);\n return true;\n }\n else {\n if (!isRecordValidator(value, Object.assign(Object.assign({}, state), { coercion: makeCoercionFn(store, `value`) })))\n return false;\n state.coercions.push([(_c = state.p) !== null && _c !== void 0 ? _c : `.`, makeLazyCoercionFn(state.coercion, value, () => new Map(Object.entries(store.value)))]);\n return true;\n }\n }\n return pushError(state, `Expected a map (got ${getPrintable(value)})`);\n }\n });\n}\n/**\n * Create a validator that only returns true when the tested value is a\n * tuple whose each value matches the corresponding subspec. Refines the type\n * into a tuple whose each item has the type inferred by the corresponding\n * tuple.\n *\n * Supports coercion if the `delimiter` option is set, in which case strings\n * will be split accordingly.\n */\nfunction isTuple(spec, { delimiter } = {}) {\n const lengthValidator = hasExactLength(spec.length);\n return makeValidator({\n test: (value, state) => {\n var _a;\n if (typeof value === `string` && typeof delimiter !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n value = value.split(delimiter);\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);\n }\n }\n if (!Array.isArray(value))\n return pushError(state, `Expected a tuple (got ${getPrintable(value)})`);\n let valid = lengthValidator(value, Object.assign({}, state));\n for (let t = 0, T = value.length; t < T && t < spec.length; ++t) {\n valid = spec[t](value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid;\n if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {\n break;\n }\n }\n return valid;\n },\n });\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * object with any amount of properties that must all match the provided\n * subspec. Refines the type to `Record<string, T>`, with `T` being the\n * subspec inferred type.\n *\n * Keys can be optionally validated as well by using the `keys` optional\n * subspec parameter.\n */\nfunction isRecord(spec, { keys: keySpec = null, } = {}) {\n const isArrayValidator = isArray(isTuple([keySpec !== null && keySpec !== void 0 ? keySpec : isString(), spec]));\n return makeValidator({\n test: (value, state) => {\n var _a;\n if (Array.isArray(value)) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: undefined })))\n return false;\n value = Object.fromEntries(value);\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);\n return true;\n }\n }\n if (typeof value !== `object` || value === null)\n return pushError(state, `Expected an object (got ${getPrintable(value)})`);\n const keys = Object.keys(value);\n let valid = true;\n for (let t = 0, T = keys.length; t < T && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null); ++t) {\n const key = keys[t];\n const sub = value[key];\n if (key === `__proto__` || key === `constructor`) {\n valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Unsafe property name`);\n continue;\n }\n if (keySpec !== null && !keySpec(key, state)) {\n valid = false;\n continue;\n }\n if (!spec(sub, Object.assign(Object.assign({}, state), { p: computeKey(state, key), coercion: makeCoercionFn(value, key) }))) {\n valid = false;\n continue;\n }\n }\n return valid;\n },\n });\n}\n/**\n * @deprecated Replace `isDict` by `isRecord`\n */\nfunction isDict(spec, opts = {}) {\n return isRecord(spec, opts);\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * object whose all properties match their corresponding subspec. Refines\n * the type into an object whose each property has the type inferred by the\n * corresponding subspec.\n *\n * Unlike `t.isPartial`, `t.isObject` doesn't allow extraneous properties by\n * default. This behaviour can be altered by using the `extra` optional\n * subspec parameter, which will be called to validate an object only\n * containing the extraneous properties.\n *\n * Calling `t.isObject(..., {extra: t.isRecord(t.isUnknown())})` is\n * essentially the same as calling `t.isPartial(...)`.\n */\nfunction isObject(props, { extra: extraSpec = null, } = {}) {\n const specKeys = Object.keys(props);\n const validator = makeValidator({\n test: (value, state) => {\n if (typeof value !== `object` || value === null)\n return pushError(state, `Expected an object (got ${getPrintable(value)})`);\n const keys = new Set([...specKeys, ...Object.keys(value)]);\n const extra = {};\n let valid = true;\n for (const key of keys) {\n if (key === `constructor` || key === `__proto__`) {\n valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Unsafe property name`);\n }\n else {\n const spec = Object.prototype.hasOwnProperty.call(props, key)\n ? props[key]\n : undefined;\n const sub = Object.prototype.hasOwnProperty.call(value, key)\n ? value[key]\n : undefined;\n if (typeof spec !== `undefined`) {\n valid = spec(sub, Object.assign(Object.assign({}, state), { p: computeKey(state, key), coercion: makeCoercionFn(value, key) })) && valid;\n }\n else if (extraSpec === null) {\n valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Extraneous property (got ${getPrintable(sub)})`);\n }\n else {\n Object.defineProperty(extra, key, {\n enumerable: true,\n get: () => sub,\n set: makeSetter(value, key)\n });\n }\n }\n if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {\n break;\n }\n }\n if (extraSpec !== null && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null))\n valid = extraSpec(extra, state) && valid;\n return valid;\n },\n });\n return Object.assign(validator, {\n properties: props,\n });\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * object whose all properties match their corresponding subspec. Refines\n * the type into an object whose each property has the type inferred by the\n * corresponding subspec.\n *\n * Unlike `t.isObject`, `t.isPartial` allows extraneous properties. The\n * resulting type will reflect this behaviour by including an index\n * signature (each extraneous property being typed `unknown`).\n *\n * Calling `t.isPartial(...)` is essentially the same as calling\n * `t.isObject(..., {extra: t.isRecord(t.isUnknown())})`.\n */\nfunction isPartial(props) {\n return isObject(props, { extra: isRecord(isUnknown()) });\n}\n/**\n * Create a validator that only returns true when the tested value is an\n * object whose prototype is derived from the given class. Refines the type\n * into a class instance.\n */\nconst isInstanceOf = (constructor) => makeValidator({\n test: (value, state) => {\n if (!(value instanceof constructor))\n return pushError(state, `Expected an instance of ${constructor.name} (got ${getPrintable(value)})`);\n return true;\n },\n});\n/**\n * Create a validator that only returns true when the tested value is an\n * object matching any of the provided subspecs. If the optional `exclusive`\n * parameter is set to `true`, the behaviour changes so that the validator\n * only returns true when exactly one subspec matches.\n */\nconst isOneOf = (specs, { exclusive = false, } = {}) => makeValidator({\n test: (value, state) => {\n var _a, _b, _c;\n const matches = [];\n const errorBuffer = typeof (state === null || state === void 0 ? void 0 : state.errors) !== `undefined`\n ? [] : undefined;\n for (let t = 0, T = specs.length; t < T; ++t) {\n const subErrors = typeof (state === null || state === void 0 ? void 0 : state.errors) !== `undefined`\n ? [] : undefined;\n const subCoercions = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`\n ? [] : undefined;\n if (specs[t](value, Object.assign(Object.assign({}, state), { errors: subErrors, coercions: subCoercions, p: `${(_a = state === null || state === void 0 ? void 0 : state.p) !== null && _a !== void 0 ? _a : `.`}#${t + 1}` }))) {\n matches.push([`#${t + 1}`, subCoercions]);\n if (!exclusive) {\n break;\n }\n }\n else {\n errorBuffer === null || errorBuffer === void 0 ? void 0 : errorBuffer.push(subErrors[0]);\n }\n }\n if (matches.length === 1) {\n const [, subCoercions] = matches[0];\n if (typeof subCoercions !== `undefined`)\n (_b = state === null || state === void 0 ? void 0 : state.coercions) === null || _b === void 0 ? void 0 : _b.push(...subCoercions);\n return true;\n }\n if (matches.length > 1)\n pushError(state, `Expected to match exactly a single predicate (matched ${matches.join(`, `)})`);\n else\n (_c = state === null || state === void 0 ? void 0 : state.errors) === null || _c === void 0 ? void 0 : _c.push(...errorBuffer);\n return false;\n },\n});\n\nfunction makeTrait(value) {\n return () => {\n return value;\n };\n}\nfunction makeValidator({ test }) {\n return makeTrait(test)();\n}\nclass TypeAssertionError extends Error {\n constructor({ errors } = {}) {\n let errorMessage = `Type mismatch`;\n if (errors && errors.length > 0) {\n errorMessage += `\\n`;\n for (const error of errors) {\n errorMessage += `\\n- ${error}`;\n }\n }\n super(errorMessage);\n }\n}\n/**\n * Check that the specified value matches the given validator, and throws an\n * exception if it doesn't. Refine the type if it passes.\n */\nfunction assert(val, validator) {\n if (!validator(val)) {\n throw new TypeAssertionError();\n }\n}\n/**\n * Check that the specified value matches the given validator, and throws an\n * exception if it doesn't. Refine the type if it passes.\n *\n * Thrown exceptions include details about what exactly looks invalid in the\n * tested value.\n */\nfunction assertWithErrors(val, validator) {\n const errors = [];\n if (!validator(val, { errors })) {\n throw new TypeAssertionError({ errors });\n }\n}\n/**\n * Compile-time only. Refine the type as if the validator was matching the\n * tested value, but doesn't actually run it. Similar to the classic `as`\n * operator in TypeScript.\n */\nfunction softAssert(val, validator) {\n // It's a soft assert; we tell TypeScript about the type, but we don't need to check it\n}\nfunction as(value, validator, { coerce = false, errors: storeErrors, throw: throws } = {}) {\n const errors = storeErrors ? [] : undefined;\n if (!coerce) {\n if (validator(value, { errors })) {\n return throws ? value : { value, errors: undefined };\n }\n else if (!throws) {\n return { value: undefined, errors: errors !== null && errors !== void 0 ? errors : true };\n }\n else {\n throw new TypeAssertionError({ errors });\n }\n }\n const state = { value };\n const coercion = makeCoercionFn(state, `value`);\n const coercions = [];\n if (!validator(value, { errors, coercion, coercions })) {\n if (!throws) {\n return { value: undefined, errors: errors !== null && errors !== void 0 ? errors : true };\n }\n else {\n throw new TypeAssertionError({ errors });\n }\n }\n for (const [, apply] of coercions)\n apply();\n if (throws) {\n return state.value;\n }\n else {\n return { value: state.value, errors: undefined };\n }\n}\n/**\n * Create and return a new function that apply the given validators to each\n * corresponding argument passed to the function and throws an exception in\n * case of a mismatch.\n */\nfunction fn(validators, fn) {\n const isValidArgList = isTuple(validators);\n return ((...args) => {\n const check = isValidArgList(args);\n if (!check)\n throw new TypeAssertionError();\n return fn(...args);\n });\n}\n\n/**\n * Create a validator that checks that the tested array or string has at least\n * the specified length.\n */\nfunction hasMinLength(length) {\n return makeValidator({\n test: (value, state) => {\n if (!(value.length >= length))\n return pushError(state, `Expected to have a length of at least ${length} elements (got ${value.length})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested array or string has at most\n * the specified length.\n */\nfunction hasMaxLength(length) {\n return makeValidator({\n test: (value, state) => {\n if (!(value.length <= length))\n return pushError(state, `Expected to have a length of at most ${length} elements (got ${value.length})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested array or string has exactly\n * the specified length.\n */\nfunction hasExactLength(length) {\n return makeValidator({\n test: (value, state) => {\n if (!(value.length === length))\n return pushError(state, `Expected to have a length of exactly ${length} elements (got ${value.length})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested array only contains unique\n * elements. The optional `map` parameter lets you define a transform to\n * apply before making the check (the result of this transform will be\n * discarded afterwards).\n */\nfunction hasUniqueItems({ map, } = {}) {\n return makeValidator({\n test: (value, state) => {\n const set = new Set();\n const dup = new Set();\n for (let t = 0, T = value.length; t < T; ++t) {\n const sub = value[t];\n const key = typeof map !== `undefined`\n ? map(sub)\n : sub;\n if (set.has(key)) {\n if (dup.has(key))\n continue;\n pushError(state, `Expected to contain unique elements; got a duplicate with ${getPrintable(value)}`);\n dup.add(key);\n }\n else {\n set.add(key);\n }\n }\n return dup.size === 0;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is strictly less than 0.\n */\nfunction isNegative() {\n return makeValidator({\n test: (value, state) => {\n if (!(value <= 0))\n return pushError(state, `Expected to be negative (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is equal or greater\n * than 0.\n */\nfunction isPositive() {\n return makeValidator({\n test: (value, state) => {\n if (!(value >= 0))\n return pushError(state, `Expected to be positive (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is equal or greater\n * than the specified reference.\n */\nfunction isAtLeast(n) {\n return makeValidator({\n test: (value, state) => {\n if (!(value >= n))\n return pushError(state, `Expected to be at least ${n} (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is equal or smaller\n * than the specified reference.\n */\nfunction isAtMost(n) {\n return makeValidator({\n test: (value, state) => {\n if (!(value <= n))\n return pushError(state, `Expected to be at most ${n} (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is between the\n * specified references (including the upper boundary).\n */\nfunction isInInclusiveRange(a, b) {\n return makeValidator({\n test: (value, state) => {\n if (!(value >= a && value <= b))\n return pushError(state, `Expected to be in the [${a}; ${b}] range (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is between the\n * specified references (excluding the upper boundary).\n */\nfunction isInExclusiveRange(a, b) {\n return makeValidator({\n test: (value, state) => {\n if (!(value >= a && value < b))\n return pushError(state, `Expected to be in the [${a}; ${b}[ range (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested number is an integer.\n *\n * By default Typanion will also check that it's a *safe* integer. For example,\n * 2^53 wouldn't be a safe integer because 2^53+1 would be rounded to 2^53,\n * which could put your applications at risk when used in loops.\n */\nfunction isInteger({ unsafe = false, } = {}) {\n return makeValidator({\n test: (value, state) => {\n if (value !== Math.round(value))\n return pushError(state, `Expected to be an integer (got ${value})`);\n if (!unsafe && !Number.isSafeInteger(value))\n return pushError(state, `Expected to be a safe integer (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string matches the given\n * regular expression.\n */\nfunction matchesRegExp(regExp) {\n return makeValidator({\n test: (value, state) => {\n if (!regExp.test(value))\n return pushError(state, `Expected to match the pattern ${regExp.toString()} (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string only contain lowercase\n * characters.\n */\nfunction isLowerCase() {\n return makeValidator({\n test: (value, state) => {\n if (value !== value.toLowerCase())\n return pushError(state, `Expected to be all-lowercase (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string only contain uppercase\n * characters.\n */\nfunction isUpperCase() {\n return makeValidator({\n test: (value, state) => {\n if (value !== value.toUpperCase())\n return pushError(state, `Expected to be all-uppercase (got ${value})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string is a valid UUID v4.\n */\nfunction isUUID4() {\n return makeValidator({\n test: (value, state) => {\n if (!uuid4RegExp.test(value))\n return pushError(state, `Expected to be a valid UUID v4 (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string is a valid ISO8601\n * date.\n */\nfunction isISO8601() {\n return makeValidator({\n test: (value, state) => {\n if (!iso8601RegExp.test(value))\n return pushError(state, `Expected to be a valid ISO 8601 date string (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string is a valid hexadecimal\n * color. Setting the optional `alpha` parameter to `true` allows an additional\n * transparency channel to be included.\n */\nfunction isHexColor({ alpha = false, }) {\n return makeValidator({\n test: (value, state) => {\n const res = alpha\n ? colorStringRegExp.test(value)\n : colorStringAlphaRegExp.test(value);\n if (!res)\n return pushError(state, `Expected to be a valid hexadecimal color string (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string is valid base64.\n */\nfunction isBase64() {\n return makeValidator({\n test: (value, state) => {\n if (!base64RegExp.test(value))\n return pushError(state, `Expected to be a valid base 64 string (got ${getPrintable(value)})`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested string is valid JSON. A\n * optional spec can be passed as parameter, in which case the data will be\n * deserialized and validated against the spec (coercion will be disabled\n * for this check, and even if successful the returned value will still be\n * the original string).\n */\nfunction isJSON(spec = isUnknown()) {\n return makeValidator({\n test: (value, state) => {\n let data;\n try {\n data = JSON.parse(value);\n }\n catch (_a) {\n return pushError(state, `Expected to be a valid JSON string (got ${getPrintable(value)})`);\n }\n return spec(data, state);\n },\n });\n}\n\nfunction cascade(spec, ...followups) {\n const resolvedFollowups = Array.isArray(followups[0])\n ? followups[0]\n : followups;\n return makeValidator({\n test: (value, state) => {\n var _a, _b;\n const context = { value: value };\n const subCoercion = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`\n ? makeCoercionFn(context, `value`) : undefined;\n const subCoercions = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`\n ? [] : undefined;\n if (!spec(value, Object.assign(Object.assign({}, state), { coercion: subCoercion, coercions: subCoercions })))\n return false;\n const reverts = [];\n if (typeof subCoercions !== `undefined`)\n for (const [, coercion] of subCoercions)\n reverts.push(coercion());\n try {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {\n if (context.value !== value) {\n if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)\n return pushError(state, `Unbound coercion result`);\n state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, context.value)]);\n }\n (_b = state === null || state === void 0 ? void 0 : state.coercions) === null || _b === void 0 ? void 0 : _b.push(...subCoercions);\n }\n return resolvedFollowups.every(spec => {\n return spec(context.value, state);\n });\n }\n finally {\n for (const revert of reverts) {\n revert();\n }\n }\n },\n });\n}\nfunction applyCascade(spec, ...followups) {\n const resolvedFollowups = Array.isArray(followups[0])\n ? followups[0]\n : followups;\n return cascade(spec, resolvedFollowups);\n}\n/**\n * Wraps the given spec to also allow `undefined`.\n */\nfunction isOptional(spec) {\n return makeValidator({\n test: (value, state) => {\n if (typeof value === `undefined`)\n return true;\n return spec(value, state);\n },\n });\n}\n/**\n * Wraps the given spec to also allow `null`.\n */\nfunction isNullable(spec) {\n return makeValidator({\n test: (value, state) => {\n if (value === null)\n return true;\n return spec(value, state);\n },\n });\n}\nconst checks = {\n missing: (keys, key) => keys.has(key),\n undefined: (keys, key, value) => keys.has(key) && typeof value[key] !== `undefined`,\n nil: (keys, key, value) => keys.has(key) && value[key] != null,\n falsy: (keys, key, value) => keys.has(key) && !!value[key],\n};\n/**\n * Create a validator that checks that the tested object contains the specified\n * keys.\n*/\nfunction hasRequiredKeys(requiredKeys, options) {\n var _a;\n const requiredSet = new Set(requiredKeys);\n const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : 'missing'];\n return makeValidator({\n test: (value, state) => {\n const keys = new Set(Object.keys(value));\n const problems = [];\n for (const key of requiredSet)\n if (!check(keys, key, value))\n problems.push(key);\n if (problems.length > 0)\n return pushError(state, `Missing required ${plural(problems.length, `property`, `properties`)} ${getPrintableArray(problems, `and`)}`);\n return true;\n },\n });\n}\n/**\n* Create a validator that checks that the tested object contains at least one\n* of the specified keys.\n*/\nfunction hasAtLeastOneKey(requiredKeys, options) {\n var _a;\n const requiredSet = new Set(requiredKeys);\n const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : 'missing'];\n return makeValidator({\n test: (value, state) => {\n const keys = Object.keys(value);\n const valid = keys.some(key => check(requiredSet, key, value));\n if (!valid)\n return pushError(state, `Missing at least one property from ${getPrintableArray(Array.from(requiredSet), `or`)}`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested object contains none of the\n * specified keys.\n*/\nfunction hasForbiddenKeys(forbiddenKeys, options) {\n var _a;\n const forbiddenSet = new Set(forbiddenKeys);\n const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : 'missing'];\n return makeValidator({\n test: (value, state) => {\n const keys = new Set(Object.keys(value));\n const problems = [];\n for (const key of forbiddenSet)\n if (check(keys, key, value))\n problems.push(key);\n if (problems.length > 0)\n return pushError(state, `Forbidden ${plural(problems.length, `property`, `properties`)} ${getPrintableArray(problems, `and`)}`);\n return true;\n },\n });\n}\n/**\n * Create a validator that checks that the tested object contains at most one\n * of the specified keys.\n */\nfunction hasMutuallyExclusiveKeys(exclusiveKeys, options) {\n var _a;\n const exclusiveSet = new Set(exclusiveKeys);\n const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : 'missing'];\n return makeValidator({\n test: (value, state) => {\n const keys = new Set(Object.keys(value));\n const used = [];\n for (const key of exclusiveSet)\n if (check(keys, key, value))\n used.push(key);\n if (used.length > 1)\n return pushError(state, `Mutually exclusive properties ${getPrintableArray(used, `and`)}`);\n return true;\n },\n });\n}\n(function (KeyRelationship) {\n KeyRelationship[\"Forbids\"] = \"Forbids\";\n KeyRelationship[\"Requires\"] = \"Requires\";\n})(exports.KeyRelationship || (exports.KeyRelationship = {}));\nconst keyRelationships = {\n [exports.KeyRelationship.Forbids]: {\n expect: false,\n message: `forbids using`,\n },\n [exports.KeyRelationship.Requires]: {\n expect: true,\n message: `requires using`,\n },\n};\n/**\n * Create a validator that checks that, when the specified subject property is\n * set, the relationship is satisfied.\n */\nfunction hasKeyRelationship(subject, relationship, others, options) {\n var _a, _b;\n const skipped = new Set((_a = options === null || options === void 0 ? void 0 : options.ignore) !== null && _a !== void 0 ? _a : []);\n const check = checks[(_b = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _b !== void 0 ? _b : 'missing'];\n const otherSet = new Set(others);\n const spec = keyRelationships[relationship];\n const conjunction = relationship === exports.KeyRelationship.Forbids\n ? `or`\n : `and`;\n return makeValidator({\n test: (value, state) => {\n const keys = new Set(Object.keys(value));\n if (!check(keys, subject, value) || skipped.has(value[subject]))\n return true;\n const problems = [];\n for (const key of otherSet)\n if ((check(keys, key, value) && !skipped.has(value[key])) !== spec.expect)\n problems.push(key);\n if (problems.length >= 1)\n return pushError(state, `Property \"${subject}\" ${spec.message} ${plural(problems.length, `property`, `properties`)} ${getPrintableArray(problems, conjunction)}`);\n return true;\n },\n });\n}\n\nexports.TypeAssertionError = TypeAssertionError;\nexports.applyCascade = applyCascade;\nexports.as = as;\nexports.assert = assert;\nexports.assertWithErrors = assertWithErrors;\nexports.cascade = cascade;\nexports.fn = fn;\nexports.hasAtLeastOneKey = hasAtLeastOneKey;\nexports.hasExactLength = hasExactLength;\nexports.hasForbiddenKeys = hasForbiddenKeys;\nexports.hasKeyRelationship = hasKeyRelationship;\nexports.hasMaxLength = hasMaxLength;\nexports.hasMinLength = hasMinLength;\nexports.hasMutuallyExclusiveKeys = hasMutuallyExclusiveKeys;\nexports.hasRequiredKeys = hasRequiredKeys;\nexports.hasUniqueItems = hasUniqueItems;\nexports.isArray = isArray;\nexports.isAtLeast = isAtLeast;\nexports.isAtMost = isAtMost;\nexports.isBase64 = isBase64;\nexports.isBoolean = isBoolean;\nexports.isDate = isDate;\nexports.isDict = isDict;\nexports.isEnum = isEnum;\nexports.isHexColor = isHexColor;\nexports.isISO8601 = isISO8601;\nexports.isInExclusiveRange = isInExclusiveRange;\nexports.isInInclusiveRange = isInInclusiveRange;\nexports.isInstanceOf = isInstanceOf;\nexports.isInteger = isInteger;\nexports.isJSON = isJSON;\nexports.isLiteral = isLiteral;\nexports.isLowerCase = isLowerCase;\nexports.isMap = isMap;\nexports.isNegative = isNegative;\nexports.isNullable = isNullable;\nexports.isNumber = isNumber;\nexports.isObject = isObject;\nexports.isOneOf = isOneOf;\nexports.isOptional = isOptional;\nexports.isPartial = isPartial;\nexports.isPayload = isPayload;\nexports.isPositive = isPositive;\nexports.isRecord = isRecord;\nexports.isSet = isSet;\nexports.isString = isString;\nexports.isTuple = isTuple;\nexports.isUUID4 = isUUID4;\nexports.isUnknown = isUnknown;\nexports.isUpperCase = isUpperCase;\nexports.makeTrait = makeTrait;\nexports.makeValidator = makeValidator;\nexports.matchesRegExp = matchesRegExp;\nexports.softAssert = softAssert;\n"],"names":["simpleKeyRegExp","getPrintable","value","undefined","toString","Array","isArray","JSON","stringify","computeKey","state","key","_a","_b","_c","p","test","pushError","errors","message","push","makeCoercionFn","target","v","previous","bind","Map","isTuple","spec","delimiter","lengthValidator","length","makeValidator","coercions","coercion","split","valid","Object","assign","t","T","isRecord","keys","keySpec","isArrayValidator","originalValue","fromEntries","sub","Error","KeyRelationship","exports","applyCascade","followups","resolvedFollowups","context","subCoercion","subCoercions","reverts","every","revert","cascade","isDict","opts","isUnknown"],"sourceRoot":""}
|