@perpetualsystems/cli 0.4.0-next-20261110214241 → 0.4.0
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/index.js +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -75,7 +75,7 @@ ${s}
|
|
|
75
75
|
`)}catch{}let e=t.split(`
|
|
76
76
|
`)[0].trim();if(!e)throw new I(`Password file "${A}" is empty`,"INVALID_INPUT",{field:"--password-file"});return e}async function gD(){if(process.stdin.isTTY)throw new I("--password-stdin requires piped input (e.g., echo 'pw' | perpetual ...)","MISSING_PASSWORD");let A=1024;return new Promise((t,e)=>{let j="",r=!1,n=(o)=>{if(r)return;r=!0,clearTimeout(p),process.stdin.removeListener("data",i),process.stdin.removeListener("end",s),process.stdin.removeListener("error",a),o()},i=(o)=>{if(j+=o,Buffer.byteLength(j)>A)n(()=>e(new I("Stdin input exceeds 1KB — not a valid password","INVALID_INPUT",{field:"--password-stdin"})))},s=()=>{n(()=>{let o=j.split(`
|
|
77
77
|
`)[0].trim();if(!o)e(new I("No password provided on stdin","MISSING_PASSWORD"));else t(o)})},a=(o)=>{n(()=>e(new I(`Failed to read stdin: ${o.message}`,"MISSING_PASSWORD")))},p=setTimeout(()=>{n(()=>e(new I("Timed out reading password from stdin","MISSING_PASSWORD")))},1e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",i),process.stdin.on("end",s),process.stdin.on("error",a),process.stdin.resume()})}async function $$(A,t){if(t)return;if(!Le())throw new I("Destructive action requires --force in non-interactive mode","CONFIRMATION_REQUIRED",{field:"--force",hint:"Pass --force to confirm the action."});let{default:e}=await Promise.resolve().then(() => (VtA(),_tA));if(!await e({message:A,default:!1},{output:process.stderr}).catch((r)=>{if(FZA(r))return!1;throw r}))throw new I("Aborted by user","ABORTED")}function FZA(A){return A instanceof Error&&A.name==="ExitPromptError"}async function xl(A,t,e){await $$(`Delete ${A} ${t}? This cannot be undone.`,e)}function TtA(A,t){let e=A.trim();if(e==="now()")return t.toISOString();let j=e.match(/^ts\((.+)\)$/);if(j){let n=j[1].trim(),i=new Date(n);if(Number.isNaN(i.getTime()))throw new I(`Invalid timestamp in ts(): "${n}"`,"INVALID_ARGUMENT");return i.toISOString()}let r=e.match(/^-(\d+)([smhdw])$/);if(r){let n=Number(r[1]),i=r[2];if(!Number.isSafeInteger(n))throw new I(`Duration too large in "${A}".`,"INVALID_ARGUMENT");let s=O$[i],a=t.getTime()-n*s,p=new Date(a);if(Number.isNaN(p.getTime()))throw new I(`Duration "${A}" yields an out-of-range timestamp.`,"INVALID_ARGUMENT");return p.toISOString()}if(B$.test(e)){let n=new Date(e);if(Number.isNaN(n.getTime()))throw new I(`Invalid ISO 8601 timestamp "${A}".`,"INVALID_ARGUMENT");return e}throw new I(`Invalid time expression "${A}". Use ISO 8601 with timezone (e.g. "2025-01-01T00:00:00Z"), "now()", a relative duration like "-1h" / "-7d" / "-1w", or "ts(<iso>)".`,"INVALID_ARGUMENT")}function Yk(A){if(!A)throw new I('Time range cannot be empty. Use a format like "-1h", "-1h..now()", or "ts(2025-01-01)..ts(2025-01-02)"',"INVALID_ARGUMENT");let t=new Date,e=A.indexOf(".."),j,r;if(e!==-1){if(j=A.slice(0,e),r=A.slice(e+2),!j||!r)throw new I(`Invalid time range "${A}": both start and end must be non-empty when using ".." separator`,"INVALID_ARGUMENT")}else j=A,r="now()";return{start:TtA(j,t),end:TtA(r,t)}}function ao(A,t){let e=A.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"untitled";if(t!==void 0&&t>0)e=e.slice(0,t).replace(/-+$/,"");return e}function Am(A,t){let e=new Map;for(let j of A){let r=t(j),n=e.get(r);if(n)n.push(j);else e.set(r,[j])}return e}function ot(A,t){if(A===t)return 0;return A<t?-1:1}var wk,QtA,hZA,$ZA,OZA,Vk=500,GZA,Jk="\uFEFF",JtA=10,Xk=`Warning: --password is insecure (visible in ps/history). Use --password-file or --password-stdin instead.
|
|
78
|
-
`,O$,B$;var Q=O(()=>{hp();L();wk=String.fromCharCode(27),QtA=String.fromCharCode(7),hZA=new RegExp(`${wk}\\[[0-9;]*[A-Za-z]`,"g"),$ZA=new RegExp(`${wk}\\][^${QtA}${wk}]*(?:${QtA}|${wk}\\\\)`,"g"),OZA=new RegExp(wk,"g");GZA=/[\p{Cf}\u{FE00}-\u{FE0F}\u{E0100}-\u{E01EF}]/u;O$={ms:1,s:1000,m:60000,h:3600000,d:86400000,w:604800000},B$=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/});function YtA(A){return A instanceof Error&&(A.name==="TimeoutError"||A.name==="AbortError")}function KZA(A){return A>=200&&A<300}function MZA(A){if(A.requestBuilt===!1)return{kind:"unbuilt"};if(A.status===void 0)return{kind:YtA(A.cause)?"timeout":"unreachable"};if(!KZA(A.status))return{kind:"errorResponse",status:A.status};return{kind:A.cause instanceof SyntaxError?"unparseable":"interrupted"}}function em(A){return A>=500&&!vZA.has(A)}function K$(A){if(!(A instanceof YA))return!1;switch(A.outcome.kind){case"timeout":case"unreachable":case"interrupted":return!0;case"errorResponse":return A.outcome.status===bZA||em(A.outcome.status);default:return!1}}function ID({outcome:A}){switch(A.kind){case"unbuilt":return!1;case"timeout":case"unreachable":case"interrupted":case"unparseable":return!0;case"errorResponse":return em(A.status)&&A.status!==DZA}}function XtA(A,t){let e=Date.parse(A);return Number.isNaN(e)?void 0:Math.max(0,Math.ceil((e-t.getTime())/1000))}function RZA(A,t){if(UZA.test(A))return Number(A);if(ZZA.test(A))return XtA(A,t);if(HZA.test(A))return XtA(`${A} GMT`,t);return}function NZA(A,t=new Date){let e=RZA(A?.trim()??"",t);return e!==void 0&&e<=xZA?e:void 0}async function Gj(A){try{return await A}catch(t){if(t instanceof YA&&t.status===404)return null;if(t instanceof im)return null;throw t}}function Nl(A,t,e){if(A instanceof YA)return A;let j=t!==void 0&&!t.ok&&!(A instanceof Error);return new YA({status:t?.status,body:j?A:void 0,cause:j?void 0:A,method:e?.method,url:e?.url,requestBuilt:e!==void 0,retryAfterSeconds:NZA(t?.headers.get("retry-after")??null)})}function oo(A){return typeof A==="object"&&A!==null&&!Array.isArray(A)}function Ou(A){return oo(A)&&typeof A.code==="string"?A.code:void 0}function hD(A){if(!oo(A)||!Array.isArray(A.errors))return[];return A.errors.filter((t)=>oo(t)&&typeof t.field==="string"&&typeof t.message==="string").map((t)=>({field:U(t.field),message:U(t.message)})).filter((t)=>t.field!=="")}function M$(A){if(!oo(A))return{};return oo(A.data)?A.data:A}function PZA(A){let{conflictDetails:t}=M$(A);if(!Array.isArray(t))return[];return t.filter((e)=>oo(e)&&typeof e.resourceId==="string"&&typeof e.reason==="string").map((e)=>({resourceId:U(e.resourceId),reason:U(e.reason)})).filter((e)=>e.resourceId!=="")}function LZA(A){let{conflictDetails:t}=M$(A);return Array.isArray(t)?t.length:0}function v$(A){return A instanceof YA&&A.outcome.kind==="errorResponse"&&A.outcome.status===zZA}function jm(A){if(!v$(A))return;let t=M$(A.body),{originKey:e,conflictingResourceId:j,conflictingResourceKind:r,resourceId:n}=t;if(t.code!=="origin_key_in_use")return;let i=G$(e),s=G$(j),a=G$(r);if(!i||!s||!a)return;let p=G$(n);return{originKey:i,holderId:s,holderKind:a,...p!==void 0&&{claimantId:p}}}function AeA(A){return A instanceof YA&&A.status===400&&hD(A.body).length===0}function teA(A){return v$(A)&&M$(A.body).code==="changeset_modified"}function G$(A){if(typeof A!=="string")return;let t=U(A);return t===""?void 0:t}function b$({holderKind:A,holderId:t}){return`Use a different originKey, or change the one on ${A} ${t}.`}function wZA(A){let t=hD(A);return Ou(A)==="already_exists"&&t.length>0&&t.every(({field:e})=>e==="originKey")}function eeA(A){return Ou(A.body)}function _ZA(A){let t;if(oo(A)){let j=oo(A.data)?A.data.message:void 0,r=typeof j==="string"&&j!==""?j:A.message;t=typeof r==="string"&&r!==""?r:Ou(A)}else if(typeof A==="string"&&!A.trim().startsWith("<"))t=A;let e=t===void 0?"":U(t);return e===""?void 0:e}function jeA(A){if(!A)return"the API";try{return new URL(A).origin}catch{return A}}function Rl(A){if(A===void 0)return"";return U(A instanceof Error?A.message:String(A))}function WtA(A){if(!(A instanceof Error))return Rl(A);let t=A.cause,e=Ou(A)??Ou(t);if(e)return`${Rl(A)} (${U(e)})`;return t instanceof Error?`${Rl(A)}: ${Rl(t)}`:Rl(A)}function F$(A,t){return t===""?A:`${A}: ${t}`}function VZA(A,t){let e=jeA(t.url),j=(r)=>({message:r,isFromBody:!1});switch(A){case"unbuilt":return j(`Could not build the request to ${e}`);case"timeout":return j(`Request to ${e} timed out`);case"unreachable":return j(F$(`Could not reach ${e}`,WtA(t.cause)));case"interrupted":return j(F$(`Could not read the response from ${e} (HTTP ${t.status})`,WtA(t.cause)));case"unparseable":return j(F$(`Could not read the response from ${e} (HTTP ${t.status})`,Rl(t.cause)));case"errorResponse":{if(t.body===void 0&&t.cause!==void 0)return j(F$(`Request to ${e} failed with HTTP ${t.status}, and its body could not be read`,Rl(t.cause)));let r=_ZA(t.body);return r===void 0?j(`Request to ${e} failed with HTTP ${t.status}`):{message:r,isFromBody:!0}}}}function JZA(A){return A===void 0?"Retry shortly.":`Retry after ${A} seconds.`}function tm(A,t,e=JZA(t.retryAfterSeconds)){let j=t.messageIsFromBody?`HTTP ${t.status}: ${t.message}`:t.message;return new I(j,A,{retryAfterSeconds:t.retryAfterSeconds,hint:e})}function StA(A,t){let e=`Check that ${jeA(A.url)} is reachable`;return new I(A.message,"NETWORK_ERROR",{hint:t?`${e}. If the request reached the server it may have been applied, so check the result before retrying.`:`${e}, then retry.`})}function TZA(A,t,e){let{body:j,message:r}=A;if(t===400){if(wZA(j))return new I(r,"ORIGIN_KEY_CONTENDED",{field:"originKey",hint:"Rerun the command; the server could not name the key's holder, which may since have gone. If it persists, use a different originKey."});let n=hD(j),i=Aj(n.map((s)=>`${s.field}: ${s.message}`),"; ");return new I(i?`${r} (${i})`:r,"API_ERROR",n.length>0?{field:n[0].field}:{})}if(t===401)return new I(r,"AUTH_REQUIRED",{hint:jn});if(t===403){let n=Ou(j);return n!==void 0&&QZA.has(n)?new I(r,"AUTH_REQUIRED",{hint:jn}):new I(r,"FORBIDDEN")}if(t===404)return new I(r,"NOT_FOUND");if(t===408)return tm("TIMEOUT",A);if(t===409){let n=jm(A);if(n)return new I(r,"CONFLICT",{field:"originKey",...n.claimantId!==void 0&&{resource:n.claimantId},hint:b$(n)});let i=PZA(j),s=Aj(i.map((a)=>`${a.resourceId} (${a.reason})`),", ");return new I(s?`${r}: ${s}`:r,"CONFLICT",{...i.length===1&&LZA(j)===1&&{resource:i[0].resourceId},hint:"Review the conflicting changes, update the changeset, then commit again."})}if(t===429)return tm("RATE_LIMITED",A);if(em(t))return tm("SERVICE_UNAVAILABLE",A,e?po:void 0);return new I(r,"API_ERROR")}function reA(A,t){return!(t.safeToRepeat===!0||rm.has(A.method??"GET"))&&ID(A)}function nm(A,t={}){let e=$u(A,YA);return e!==void 0&&reA(e,t)}function Bp(A,t={}){let e=reA(A,t),{outcome:j}=A;switch(j.kind){case"unbuilt":return new I(A.message,"CONFIG_ERROR",{hint:"Check the endpoint and the stored credentials for invalid characters."});case"timeout":return tm("TIMEOUT",A,e?po:void 0);case"unreachable":return StA(A,e);case"interrupted":if(e)return new I(A.message,"API_ERROR",{hint:po});return YtA(A.cause)?tm("TIMEOUT",A):StA(A,!1);case"unparseable":return new I(A.message,"API_ERROR",e?{hint:po}:{});case"errorResponse":return TZA(A,j.status,e)}}var YA,vZA,bZA=429,DZA=503,UZA,ZZA,HZA,xZA=86400,zZA=409,QZA,jn="Run `perpetual login` to authenticate again.",rm,po="The request reached the server, so it may have been applied. Check the result before retrying.";var ft=O(()=>{L();Q();YA=class YA extends Error{outcome;status;body;method;url;retryAfterSeconds;messageIsFromBody;#t;constructor(A){let t=MZA(A),e=VZA(t.kind,A);super(e.message,{cause:A.cause});this.name="ApiFailure",this.outcome=t,this.status=A.status,this.body=A.body,this.method=A.method,this.url=A.url,this.retryAfterSeconds=A.retryAfterSeconds,this.messageIsFromBody=e.isFromBody,this.#t=A}withBody(A){return new YA({...this.#t,body:A})}get kind(){return this.outcome.kind}};vZA=new Set([501,505]);UZA=/^\d+$/,ZZA=/^[A-Za-z]{3,9}, [\w -]+ \d\d:\d\d:\d\d GMT$/,HZA=/^[A-Za-z]{3} [A-Za-z]{3} [ \d]\d \d\d:\d\d:\d\d \d{4}$/;QZA=new Set(["step_up_required","password_auth_locked"]);rm=new Set(["GET","HEAD","OPTIONS"])});var D$;var $D=O(()=>{D$={name:"@perpetualsystems/cli",version:"0.4.0-next-20261110214241",description:"CLI for the Perpetual API",license:"MIT",type:"module",bin:{perpetual:"./dist/index.js"},scripts:{build:"tsc -p tsconfig.build.json",typecheck:"tsc","typecheck:prod":"tsc -p tsconfig.build.json --noEmit",clean:"rm -rf dist",test:"bun --bun x vitest run --project @perpetualsystems/cli --root ../..","test:watch":"bun --bun x vitest --project @perpetualsystems/cli --root ../..",dev:"bun run src/index.ts","dist:build":"bun scripts/build-binary.mjs","dist:local":"bun scripts/build-binary.mjs --local","install:local":"bun scripts/install-local.mjs","dist:test":"bun scripts/test-binary.mjs","smoke:node":"node scripts/node-smoke.mjs","dist:sign":"bun scripts/sign-macos.mjs",dist:"bun run dist:build && bun run dist:test","bundle:npm":"bun scripts/bundle-node.mjs"},dependencies:{"@clack/prompts":"^1.8.1","@inquirer/confirm":"^6.3.5","@perpetualsystems/typescript-sdk":"workspace:*","@resvg/resvg-wasm":"^2.6.2",ajv:"^8.20.0","ajv-formats":"^3.0.1",chalk:"^6.0.1",citty:"0.2.2",ora:"^10.0.0","p-limit":"^7.3.3","smol-toml":"^1.9.1",uuid:"14.0.3",vega:"^6.4.0","vega-lite":"^6.5.0",yaml:"^2.9.1"},devDependencies:{"@perpetualsystems/test-support":"workspace:*","@types/node":"^26.6.6","fast-check":"4.10.2",typescript:"^7.0.2",vitest:"5.0.5"},engines:{node:">=22.13.0"},publishConfig:{access:"public",directory:"dist/npm"},repository:{type:"git",url:"git+https://github.com/perpetualsystems/typescript-sdk.git",directory:"packages/cli"},homepage:"https://github.com/perpetualsystems/typescript-sdk/tree/main/packages/cli#readme"}});var U$;var OD=O(()=>{U$={name:"@perpetualsystems/typescript-sdk",version:"0.4.0-next-20261110214241",description:"TypeScript SDK for the Perpetual Systems API",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"},"./enum-values":{import:"./dist/generated/enum-values.gen.js",types:"./dist/generated/enum-values.gen.d.ts"},"./file-schemas":{import:"./dist/generated/file-schemas.gen.js",types:"./dist/generated/file-schemas.gen.d.ts"},"./openapi.json":"./openapi/openapi.json","./package.json":"./package.json"},scripts:{generate:"bun scripts/generate.ts","pin-spec":"bun scripts/pin-spec.ts",build:"tsc -p tsconfig.build.json",typecheck:"tsc && tsc -p scripts","typecheck:prod":"tsc -p tsconfig.build.json --noEmit",clean:"rm -rf dist",test:"bun --bun x vitest run --project @perpetualsystems/typescript-sdk --root ../..","test:watch":"bun --bun x vitest --project @perpetualsystems/typescript-sdk --root ../.."},devDependencies:{"@hey-api/openapi-ts":"^0.99.0","@perpetualsystems/test-support":"workspace:*","@types/bun":"1.4.4","@types/node":"^26.6.6","@typescript/typescript6":"6.0.2",typescript:"^7.0.2",vitest:"5.0.5"},engines:{node:">=20.3.0"},files:["dist","src","openapi/openapi.json"],keywords:["perpetual","api","sdk","typescript"],license:"MIT",dependencies:{open:"^11.0.4"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/perpetualsystems/typescript-sdk.git",directory:"packages/sdk"},homepage:"https://github.com/perpetualsystems/typescript-sdk/tree/main/packages/sdk#readme"}});var er,$zt;var Gp=O(()=>{$D();OD();er=D$.version,$zt=U$.version});function qt(A){if(A.json)return"json";if(A.text)return"text";if(A.format==="json"||A.format==="text")return A.format;return process.stdout.isTTY?"text":"json"}function Bu(A){let t=A.indexOf(SZA),e=t===-1?A:A.slice(0,t),j=e.indexOf("--format"),r=e.find((n)=>n.startsWith("--format="));return qt({json:e.includes("--json"),text:e.includes("--text"),format:r?.slice(9)??(j===-1?void 0:e[j+1])})}function Z$(A){if(A.json)return!0;if(A.text)return!1;return A.format==="json"}function T(A,t){if(t==="json")return JSON.stringify({ok:!0,data:A});return ieA(A)}function da(A){return JSON.stringify({ok:!1,data:A})}function ieA(A){if(typeof A==="string")return A;if(Array.isArray(A))return seA(A);if(typeof A==="object"&&A!==null)return tHA(A);return String(A)}function seA(A){if(A.length===0)return"(empty)";if(A.every((t)=>t&&typeof t==="object"&&("id"in t)))return YZA(A);return A.map(ieA).join(`
|
|
78
|
+
`,O$,B$;var Q=O(()=>{hp();L();wk=String.fromCharCode(27),QtA=String.fromCharCode(7),hZA=new RegExp(`${wk}\\[[0-9;]*[A-Za-z]`,"g"),$ZA=new RegExp(`${wk}\\][^${QtA}${wk}]*(?:${QtA}|${wk}\\\\)`,"g"),OZA=new RegExp(wk,"g");GZA=/[\p{Cf}\u{FE00}-\u{FE0F}\u{E0100}-\u{E01EF}]/u;O$={ms:1,s:1000,m:60000,h:3600000,d:86400000,w:604800000},B$=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/});function YtA(A){return A instanceof Error&&(A.name==="TimeoutError"||A.name==="AbortError")}function KZA(A){return A>=200&&A<300}function MZA(A){if(A.requestBuilt===!1)return{kind:"unbuilt"};if(A.status===void 0)return{kind:YtA(A.cause)?"timeout":"unreachable"};if(!KZA(A.status))return{kind:"errorResponse",status:A.status};return{kind:A.cause instanceof SyntaxError?"unparseable":"interrupted"}}function em(A){return A>=500&&!vZA.has(A)}function K$(A){if(!(A instanceof YA))return!1;switch(A.outcome.kind){case"timeout":case"unreachable":case"interrupted":return!0;case"errorResponse":return A.outcome.status===bZA||em(A.outcome.status);default:return!1}}function ID({outcome:A}){switch(A.kind){case"unbuilt":return!1;case"timeout":case"unreachable":case"interrupted":case"unparseable":return!0;case"errorResponse":return em(A.status)&&A.status!==DZA}}function XtA(A,t){let e=Date.parse(A);return Number.isNaN(e)?void 0:Math.max(0,Math.ceil((e-t.getTime())/1000))}function RZA(A,t){if(UZA.test(A))return Number(A);if(ZZA.test(A))return XtA(A,t);if(HZA.test(A))return XtA(`${A} GMT`,t);return}function NZA(A,t=new Date){let e=RZA(A?.trim()??"",t);return e!==void 0&&e<=xZA?e:void 0}async function Gj(A){try{return await A}catch(t){if(t instanceof YA&&t.status===404)return null;if(t instanceof im)return null;throw t}}function Nl(A,t,e){if(A instanceof YA)return A;let j=t!==void 0&&!t.ok&&!(A instanceof Error);return new YA({status:t?.status,body:j?A:void 0,cause:j?void 0:A,method:e?.method,url:e?.url,requestBuilt:e!==void 0,retryAfterSeconds:NZA(t?.headers.get("retry-after")??null)})}function oo(A){return typeof A==="object"&&A!==null&&!Array.isArray(A)}function Ou(A){return oo(A)&&typeof A.code==="string"?A.code:void 0}function hD(A){if(!oo(A)||!Array.isArray(A.errors))return[];return A.errors.filter((t)=>oo(t)&&typeof t.field==="string"&&typeof t.message==="string").map((t)=>({field:U(t.field),message:U(t.message)})).filter((t)=>t.field!=="")}function M$(A){if(!oo(A))return{};return oo(A.data)?A.data:A}function PZA(A){let{conflictDetails:t}=M$(A);if(!Array.isArray(t))return[];return t.filter((e)=>oo(e)&&typeof e.resourceId==="string"&&typeof e.reason==="string").map((e)=>({resourceId:U(e.resourceId),reason:U(e.reason)})).filter((e)=>e.resourceId!=="")}function LZA(A){let{conflictDetails:t}=M$(A);return Array.isArray(t)?t.length:0}function v$(A){return A instanceof YA&&A.outcome.kind==="errorResponse"&&A.outcome.status===zZA}function jm(A){if(!v$(A))return;let t=M$(A.body),{originKey:e,conflictingResourceId:j,conflictingResourceKind:r,resourceId:n}=t;if(t.code!=="origin_key_in_use")return;let i=G$(e),s=G$(j),a=G$(r);if(!i||!s||!a)return;let p=G$(n);return{originKey:i,holderId:s,holderKind:a,...p!==void 0&&{claimantId:p}}}function AeA(A){return A instanceof YA&&A.status===400&&hD(A.body).length===0}function teA(A){return v$(A)&&M$(A.body).code==="changeset_modified"}function G$(A){if(typeof A!=="string")return;let t=U(A);return t===""?void 0:t}function b$({holderKind:A,holderId:t}){return`Use a different originKey, or change the one on ${A} ${t}.`}function wZA(A){let t=hD(A);return Ou(A)==="already_exists"&&t.length>0&&t.every(({field:e})=>e==="originKey")}function eeA(A){return Ou(A.body)}function _ZA(A){let t;if(oo(A)){let j=oo(A.data)?A.data.message:void 0,r=typeof j==="string"&&j!==""?j:A.message;t=typeof r==="string"&&r!==""?r:Ou(A)}else if(typeof A==="string"&&!A.trim().startsWith("<"))t=A;let e=t===void 0?"":U(t);return e===""?void 0:e}function jeA(A){if(!A)return"the API";try{return new URL(A).origin}catch{return A}}function Rl(A){if(A===void 0)return"";return U(A instanceof Error?A.message:String(A))}function WtA(A){if(!(A instanceof Error))return Rl(A);let t=A.cause,e=Ou(A)??Ou(t);if(e)return`${Rl(A)} (${U(e)})`;return t instanceof Error?`${Rl(A)}: ${Rl(t)}`:Rl(A)}function F$(A,t){return t===""?A:`${A}: ${t}`}function VZA(A,t){let e=jeA(t.url),j=(r)=>({message:r,isFromBody:!1});switch(A){case"unbuilt":return j(`Could not build the request to ${e}`);case"timeout":return j(`Request to ${e} timed out`);case"unreachable":return j(F$(`Could not reach ${e}`,WtA(t.cause)));case"interrupted":return j(F$(`Could not read the response from ${e} (HTTP ${t.status})`,WtA(t.cause)));case"unparseable":return j(F$(`Could not read the response from ${e} (HTTP ${t.status})`,Rl(t.cause)));case"errorResponse":{if(t.body===void 0&&t.cause!==void 0)return j(F$(`Request to ${e} failed with HTTP ${t.status}, and its body could not be read`,Rl(t.cause)));let r=_ZA(t.body);return r===void 0?j(`Request to ${e} failed with HTTP ${t.status}`):{message:r,isFromBody:!0}}}}function JZA(A){return A===void 0?"Retry shortly.":`Retry after ${A} seconds.`}function tm(A,t,e=JZA(t.retryAfterSeconds)){let j=t.messageIsFromBody?`HTTP ${t.status}: ${t.message}`:t.message;return new I(j,A,{retryAfterSeconds:t.retryAfterSeconds,hint:e})}function StA(A,t){let e=`Check that ${jeA(A.url)} is reachable`;return new I(A.message,"NETWORK_ERROR",{hint:t?`${e}. If the request reached the server it may have been applied, so check the result before retrying.`:`${e}, then retry.`})}function TZA(A,t,e){let{body:j,message:r}=A;if(t===400){if(wZA(j))return new I(r,"ORIGIN_KEY_CONTENDED",{field:"originKey",hint:"Rerun the command; the server could not name the key's holder, which may since have gone. If it persists, use a different originKey."});let n=hD(j),i=Aj(n.map((s)=>`${s.field}: ${s.message}`),"; ");return new I(i?`${r} (${i})`:r,"API_ERROR",n.length>0?{field:n[0].field}:{})}if(t===401)return new I(r,"AUTH_REQUIRED",{hint:jn});if(t===403){let n=Ou(j);return n!==void 0&&QZA.has(n)?new I(r,"AUTH_REQUIRED",{hint:jn}):new I(r,"FORBIDDEN")}if(t===404)return new I(r,"NOT_FOUND");if(t===408)return tm("TIMEOUT",A);if(t===409){let n=jm(A);if(n)return new I(r,"CONFLICT",{field:"originKey",...n.claimantId!==void 0&&{resource:n.claimantId},hint:b$(n)});let i=PZA(j),s=Aj(i.map((a)=>`${a.resourceId} (${a.reason})`),", ");return new I(s?`${r}: ${s}`:r,"CONFLICT",{...i.length===1&&LZA(j)===1&&{resource:i[0].resourceId},hint:"Review the conflicting changes, update the changeset, then commit again."})}if(t===429)return tm("RATE_LIMITED",A);if(em(t))return tm("SERVICE_UNAVAILABLE",A,e?po:void 0);return new I(r,"API_ERROR")}function reA(A,t){return!(t.safeToRepeat===!0||rm.has(A.method??"GET"))&&ID(A)}function nm(A,t={}){let e=$u(A,YA);return e!==void 0&&reA(e,t)}function Bp(A,t={}){let e=reA(A,t),{outcome:j}=A;switch(j.kind){case"unbuilt":return new I(A.message,"CONFIG_ERROR",{hint:"Check the endpoint and the stored credentials for invalid characters."});case"timeout":return tm("TIMEOUT",A,e?po:void 0);case"unreachable":return StA(A,e);case"interrupted":if(e)return new I(A.message,"API_ERROR",{hint:po});return YtA(A.cause)?tm("TIMEOUT",A):StA(A,!1);case"unparseable":return new I(A.message,"API_ERROR",e?{hint:po}:{});case"errorResponse":return TZA(A,j.status,e)}}var YA,vZA,bZA=429,DZA=503,UZA,ZZA,HZA,xZA=86400,zZA=409,QZA,jn="Run `perpetual login` to authenticate again.",rm,po="The request reached the server, so it may have been applied. Check the result before retrying.";var ft=O(()=>{L();Q();YA=class YA extends Error{outcome;status;body;method;url;retryAfterSeconds;messageIsFromBody;#t;constructor(A){let t=MZA(A),e=VZA(t.kind,A);super(e.message,{cause:A.cause});this.name="ApiFailure",this.outcome=t,this.status=A.status,this.body=A.body,this.method=A.method,this.url=A.url,this.retryAfterSeconds=A.retryAfterSeconds,this.messageIsFromBody=e.isFromBody,this.#t=A}withBody(A){return new YA({...this.#t,body:A})}get kind(){return this.outcome.kind}};vZA=new Set([501,505]);UZA=/^\d+$/,ZZA=/^[A-Za-z]{3,9}, [\w -]+ \d\d:\d\d:\d\d GMT$/,HZA=/^[A-Za-z]{3} [A-Za-z]{3} [ \d]\d \d\d:\d\d:\d\d \d{4}$/;QZA=new Set(["step_up_required","password_auth_locked"]);rm=new Set(["GET","HEAD","OPTIONS"])});var D$;var $D=O(()=>{D$={name:"@perpetualsystems/cli",version:"0.4.0",description:"CLI for the Perpetual API",license:"MIT",type:"module",bin:{perpetual:"./dist/index.js"},scripts:{build:"tsc -p tsconfig.build.json",typecheck:"tsc","typecheck:prod":"tsc -p tsconfig.build.json --noEmit",clean:"rm -rf dist",test:"bun --bun x vitest run --project @perpetualsystems/cli --root ../..","test:watch":"bun --bun x vitest --project @perpetualsystems/cli --root ../..",dev:"bun run src/index.ts","dist:build":"bun scripts/build-binary.mjs","dist:local":"bun scripts/build-binary.mjs --local","install:local":"bun scripts/install-local.mjs","dist:test":"bun scripts/test-binary.mjs","smoke:node":"node scripts/node-smoke.mjs","dist:sign":"bun scripts/sign-macos.mjs",dist:"bun run dist:build && bun run dist:test","bundle:npm":"bun scripts/bundle-node.mjs"},dependencies:{"@clack/prompts":"^1.8.1","@inquirer/confirm":"^6.3.5","@perpetualsystems/typescript-sdk":"workspace:*","@resvg/resvg-wasm":"^2.6.2",ajv:"^8.20.0","ajv-formats":"^3.0.1",chalk:"^6.0.1",citty:"0.2.2",ora:"^10.0.0","p-limit":"^7.3.3","smol-toml":"^1.9.1",uuid:"14.0.3",vega:"^6.4.0","vega-lite":"^6.5.0",yaml:"^2.9.1"},devDependencies:{"@perpetualsystems/test-support":"workspace:*","@types/node":"^26.6.6","fast-check":"4.10.2",typescript:"^7.0.2",vitest:"5.0.5"},engines:{node:">=22.13.0"},publishConfig:{access:"public",directory:"dist/npm"},repository:{type:"git",url:"git+https://github.com/perpetualsystems/typescript-sdk.git",directory:"packages/cli"},homepage:"https://github.com/perpetualsystems/typescript-sdk/tree/main/packages/cli#readme"}});var U$;var OD=O(()=>{U$={name:"@perpetualsystems/typescript-sdk",version:"0.4.0",description:"TypeScript SDK for the Perpetual Systems API",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"},"./enum-values":{import:"./dist/generated/enum-values.gen.js",types:"./dist/generated/enum-values.gen.d.ts"},"./file-schemas":{import:"./dist/generated/file-schemas.gen.js",types:"./dist/generated/file-schemas.gen.d.ts"},"./openapi.json":"./openapi/openapi.json","./package.json":"./package.json"},scripts:{generate:"bun scripts/generate.ts","pin-spec":"bun scripts/pin-spec.ts",build:"tsc -p tsconfig.build.json",typecheck:"tsc && tsc -p scripts","typecheck:prod":"tsc -p tsconfig.build.json --noEmit",clean:"rm -rf dist",test:"bun --bun x vitest run --project @perpetualsystems/typescript-sdk --root ../..","test:watch":"bun --bun x vitest --project @perpetualsystems/typescript-sdk --root ../.."},devDependencies:{"@hey-api/openapi-ts":"^0.99.0","@perpetualsystems/test-support":"workspace:*","@types/bun":"1.4.4","@types/node":"^26.6.6","@typescript/typescript6":"6.0.2",typescript:"^7.0.2",vitest:"5.0.5"},engines:{node:">=20.3.0"},files:["dist","src","openapi/openapi.json"],keywords:["perpetual","api","sdk","typescript"],license:"MIT",dependencies:{open:"^11.0.4"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/perpetualsystems/typescript-sdk.git",directory:"packages/sdk"},homepage:"https://github.com/perpetualsystems/typescript-sdk/tree/main/packages/sdk#readme"}});var er,$zt;var Gp=O(()=>{$D();OD();er=D$.version,$zt=U$.version});function qt(A){if(A.json)return"json";if(A.text)return"text";if(A.format==="json"||A.format==="text")return A.format;return process.stdout.isTTY?"text":"json"}function Bu(A){let t=A.indexOf(SZA),e=t===-1?A:A.slice(0,t),j=e.indexOf("--format"),r=e.find((n)=>n.startsWith("--format="));return qt({json:e.includes("--json"),text:e.includes("--text"),format:r?.slice(9)??(j===-1?void 0:e[j+1])})}function Z$(A){if(A.json)return!0;if(A.text)return!1;return A.format==="json"}function T(A,t){if(t==="json")return JSON.stringify({ok:!0,data:A});return ieA(A)}function da(A){return JSON.stringify({ok:!1,data:A})}function ieA(A){if(typeof A==="string")return A;if(Array.isArray(A))return seA(A);if(typeof A==="object"&&A!==null)return tHA(A);return String(A)}function seA(A){if(A.length===0)return"(empty)";if(A.every((t)=>t&&typeof t==="object"&&("id"in t)))return YZA(A);return A.map(ieA).join(`
|
|
79
79
|
|
|
80
80
|
`)}function YZA(A){let t=A.some((i)=>("name"in i)),e=t?[...A].sort((i,s)=>sm(i.name).localeCompare(sm(s.name))):A,j=Math.max(2,...e.map((i)=>sm(i.id).length)),r=t?`${ae.bold("ID".padEnd(j))} ${ae.bold("Name")}`:ae.bold("ID"),n=e.map((i)=>{let s=ae.white(sm(i.id).padEnd(j));return t?`${s} ${ae.dim(sm(i.name))}`:s});return[r,...n].join(`
|
|
81
81
|
`)}function Pl(A){let t=A.map((j)=>j.map(Op)),e=t[0].map((j,r)=>Math.max(...t.map((n)=>n[r]?.length??0)));return t.map((j)=>j.map((r,n)=>n===j.length-1?r:r.padEnd(e[n])).join(AHA).trimEnd()).join(`
|
|
@@ -110,7 +110,7 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
110
110
|
`),{}}try{let e=JSON.parse(t);if(typeof e!=="object"||e===null)return{};let j={};for(let[r,n]of Object.entries(e))if(n&&typeof n==="object"&&typeof n.clientId==="string"&&typeof n.redirectUri==="string")j[r]=n;return j}catch{return process.stderr.write(`Warning: OAuth client cache at ${A} is corrupt; ignoring.
|
|
111
111
|
`),{}}}function dRA(A){let t=dm();if(!px(t))sRA(t,{recursive:!0,mode:448});let e=EjA(),j=`${e}.tmp`;try{yRA(j,JSON.stringify(A,null,2),{mode:384});try{CjA(j,384)}catch(r){process.stderr.write(`Warning: could not chmod ${j} to 0600: ${r instanceof Error?r.message:String(r)}
|
|
112
112
|
`)}pRA(j,e);try{CjA(gjA(e),448)}catch(r){process.stderr.write(`Warning: could not chmod ${gjA(e)} to 0700: ${r instanceof Error?r.message:String(r)}
|
|
113
|
-
`)}}catch(r){try{if(px(j))oRA(j)}catch{}throw r}}function Hm(A){let t=Fj(A);return IjA()[t]}function ox(A,t){let e=Fj(A),j=IjA();j[e]={clientId:t.clientId,clientSecret:t.clientSecret,redirectUri:t.redirectUri,registeredAt:t.registeredAt??new Date().toISOString()},dRA(j)}var hjA=O(()=>{T$();uo()});async function yx(A){let{endpoint:t,clientName:e,redirectUris:j,
|
|
113
|
+
`)}}catch(r){try{if(px(j))oRA(j)}catch{}throw r}}function Hm(A){let t=Fj(A);return IjA()[t]}function ox(A,t){let e=Fj(A),j=IjA();j[e]={clientId:t.clientId,clientSecret:t.clientSecret,redirectUri:t.redirectUri,registeredAt:t.registeredAt??new Date().toISOString()},dRA(j)}var hjA=O(()=>{T$();uo()});async function yx(A){let{endpoint:t,clientName:e,redirectUris:j,_fetch:r=fetch,requestTimeoutMs:n=fo}=A,i=`${Fj(t)}/api/oauth/register`,s;try{s=await r(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:e,redirect_uris:j,grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",application_type:"native"}),signal:AbortSignal.timeout(n)})}catch(o){throw Mp("Dynamic client registration",i,o)}let a=await co("Dynamic client registration",i,s);if(!s.ok)throw qo("Dynamic client registration",s,a);let p;try{p=JSON.parse(a)}catch(o){let y=o instanceof Error?o.message:String(o);throw Error(`Dynamic client registration response is not valid JSON (${s.status}): ${a.slice(0,200)||s.statusText} (${y})`)}if(typeof p.client_id!=="string"||!p.client_id)throw Error("Dynamic client registration response missing required client_id");if(!Array.isArray(p.redirect_uris)||p.redirect_uris.some((o)=>typeof o!=="string"))throw Error("Dynamic client registration response missing valid redirect_uris array");return{clientId:p.client_id,clientSecret:typeof p.client_secret==="string"&&p.client_secret?p.client_secret:void 0,redirectUris:p.redirect_uris}}var $jA=O(()=>{uo();vu()});var OjA=O(()=>{ax()});var BjA=()=>{};async function lx(A){let t=A._fetch??fetch,e=A.requestTimeoutMs??fo,j=A.log??(()=>{}),r=`${Fj(A.endpoint)}/api/oauth/token`,n=new URLSearchParams({grant_type:"refresh_token",refresh_token:A.refreshToken,client_id:A.clientId});if(A.clientSecret)n.set("client_secret",A.clientSecret);let i;try{i=await t(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString(),signal:AbortSignal.timeout(e)})}catch(y){throw Mp("Refresh token exchange",r,y)}let s=await co("Refresh token exchange",r,i);if(!i.ok)throw qo("Refresh token exchange",i,s);let a;try{a=JSON.parse(s)}catch(y){let l=y instanceof Error?y.message:String(y);throw Error(`Refresh token response is not valid JSON (${i.status}): ${s.slice(0,200)||i.statusText} (${l})`)}if(typeof a.access_token!=="string"||!a.access_token)throw Error("Refresh token response missing access_token");let p=typeof a.token_type==="string"?a.token_type:"Bearer";if(p.toLowerCase()!=="bearer")throw Error(`Unsupported token type: "${p}". Only Bearer tokens are supported.`);let o;if(a.expires_in!==void 0)if(typeof a.expires_in==="number"&&Number.isFinite(a.expires_in)&&a.expires_in>0)o=a.expires_in;else j(`Warning: refresh response contained invalid expires_in: ${JSON.stringify(a.expires_in)}, ignoring
|
|
114
114
|
`);return{token:a.access_token,refreshToken:typeof a.refresh_token==="string"?a.refresh_token:void 0,expiresIn:o,tokenType:p}}var GjA=O(()=>{uo();vu()});var XA=O(()=>{aU();mjA();oU();hjA();$jA();BjA();GjA();vu();T$();uo();OjA()});function Kj(A){return new RegExp(`^${A}_[A-Z0-9]+$`)}function fa(A){let t=me(A.space,"space"),e=t?.find((j)=>!ze.test(j));if(e!==void 0)throw new I(`Invalid value for --space: expected space ids such as SPC_ABC, got "${e}"`,"INVALID_ARGUMENT",{field:"--space"});return t}var ze,FjA;var Br=O(()=>{L();Q();ze=Kj("SPC"),FjA=Kj("[A-Z]+")});var r7=x((QrA)=>{Object.defineProperty(QrA,"__esModule",{value:!0});QrA.regexpCode=QrA.getEsmExportName=QrA.getProperty=QrA.safeStringify=QrA.stringify=QrA.strConcat=QrA.addCodeArg=QrA.str=QrA._=QrA.nil=QrA._Code=QrA.Name=QrA.IDENTIFIER=QrA._CodeOrName=void 0;class HO{}QrA._CodeOrName=HO;QrA.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class Wu extends HO{constructor(A){super();if(!QrA.IDENTIFIER.test(A))throw Error("CodeGen: name must be a valid identifier");this.str=A}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}QrA.Name=Wu;class es extends HO{constructor(A){super();this._items=typeof A==="string"?[A]:A}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let A=this._items[0];return A===""||A==='""'}get str(){var A;return(A=this._str)!==null&&A!==void 0?A:this._str=this._items.reduce((t,e)=>`${t}${e}`,"")}get names(){var A;return(A=this._names)!==null&&A!==void 0?A:this._names=this._items.reduce((t,e)=>{if(e instanceof Wu)t[e.str]=(t[e.str]||0)+1;return t},{})}}QrA._Code=es;QrA.nil=new es("");function _rA(A,...t){let e=[A[0]],j=0;while(j<t.length)Tx(e,t[j]),e.push(A[++j]);return new es(e)}QrA._=_rA;var Jx=new es("+");function VrA(A,...t){let e=[j7(A[0])],j=0;while(j<t.length)e.push(Jx),Tx(e,t[j]),e.push(Jx,j7(A[++j]));return lPA(e),new es(e)}QrA.str=VrA;function Tx(A,t){if(t instanceof es)A.push(...t._items);else if(t instanceof Wu)A.push(t);else A.push(fPA(t))}QrA.addCodeArg=Tx;function lPA(A){let t=1;while(t<A.length-1){if(A[t]===Jx){let e=dPA(A[t-1],A[t+1]);if(e!==void 0){A.splice(t-1,3,e);continue}A[t++]="+"}t++}}function dPA(A,t){if(t==='""')return A;if(A==='""')return t;if(typeof A=="string"){if(t instanceof Wu||A[A.length-1]!=='"')return;if(typeof t!="string")return`${A.slice(0,-1)}${t}"`;if(t[0]==='"')return A.slice(0,-1)+t.slice(1);return}if(typeof t=="string"&&t[0]==='"'&&!(A instanceof Wu))return`"${A}${t.slice(1)}`;return}function uPA(A,t){return t.emptyStr()?A:A.emptyStr()?t:VrA`${A}${t}`}QrA.strConcat=uPA;function fPA(A){return typeof A=="number"||typeof A=="boolean"||A===null?A:j7(Array.isArray(A)?A.join(","):A)}function qPA(A){return new es(j7(A))}QrA.stringify=qPA;function j7(A){return JSON.stringify(A).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}QrA.safeStringify=j7;function cPA(A){return typeof A=="string"&&QrA.IDENTIFIER.test(A)?new es(`.${A}`):_rA`[${A}]`}QrA.getProperty=cPA;function kPA(A){if(typeof A=="string"&&QrA.IDENTIFIER.test(A))return new es(`${A}`);throw Error(`CodeGen: invalid export name: ${A}, use explicit $id name mapping`)}QrA.getEsmExportName=kPA;function mPA(A){return new es(A.toString())}QrA.regexpCode=mPA});var Yx=x((WrA)=>{Object.defineProperty(WrA,"__esModule",{value:!0});WrA.ValueScope=WrA.ValueScopeName=WrA.Scope=WrA.varKinds=WrA.UsedValueState=void 0;var nn=r7();class TrA extends Error{constructor(A){super(`CodeGen: "code" for ${A} not defined`);this.value=A.value}}var RO;(function(A){A[A.Started=0]="Started",A[A.Completed=1]="Completed"})(RO||(WrA.UsedValueState=RO={}));WrA.varKinds={const:new nn.Name("const"),let:new nn.Name("let"),var:new nn.Name("var")};class Wx{constructor({prefixes:A,parent:t}={}){this._names={},this._prefixes=A,this._parent=t}toName(A){return A instanceof nn.Name?A:this.name(A)}name(A){return new nn.Name(this._newName(A))}_newName(A){let t=this._names[A]||this._nameGroup(A);return`${A}${t.index++}`}_nameGroup(A){var t,e;if(((e=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||e===void 0?void 0:e.has(A))||this._prefixes&&!this._prefixes.has(A))throw Error(`CodeGen: prefix "${A}" is not allowed in this scope`);return this._names[A]={prefix:A,index:0}}}WrA.Scope=Wx;class Sx extends nn.Name{constructor(A,t){super(t);this.prefix=A}setValue(A,{property:t,itemIndex:e}){this.value=A,this.scopePath=nn._`.${new nn.Name(t)}[${e}]`}}WrA.ValueScopeName=Sx;var vPA=nn._`\n`;class XrA extends Wx{constructor(A){super(A);this._values={},this._scope=A.scope,this.opts={...A,_n:A.lines?vPA:nn.nil}}get(){return this._scope}name(A){return new Sx(A,this._newName(A))}value(A,t){var e;if(t.ref===void 0)throw Error("CodeGen: ref must be passed in value");let j=this.toName(A),{prefix:r}=j,n=(e=t.key)!==null&&e!==void 0?e:t.ref,i=this._values[r];if(i){let p=i.get(n);if(p)return p}else i=this._values[r]=new Map;i.set(n,j);let s=this._scope[r]||(this._scope[r]=[]),a=s.length;return s[a]=t.ref,j.setValue(t,{property:r,itemIndex:a}),j}getValue(A,t){let e=this._values[A];if(!e)return;return e.get(t)}scopeRefs(A,t=this._values){return this._reduceValues(t,(e)=>{if(e.scopePath===void 0)throw Error(`CodeGen: name "${e}" has no value`);return nn._`${A}${e.scopePath}`})}scopeCode(A=this._values,t,e){return this._reduceValues(A,(j)=>{if(j.value===void 0)throw Error(`CodeGen: name "${j}" has no value`);return j.value.code},t,e)}_reduceValues(A,t,e={},j){let r=nn.nil;for(let n in A){let i=A[n];if(!i)continue;let s=e[n]=e[n]||new Map;i.forEach((a)=>{if(s.has(a))return;s.set(a,RO.Started);let p=t(a);if(p){let o=this.opts.es5?WrA.varKinds.var:WrA.varKinds.const;r=nn._`${r}${o} ${a} = ${p};${this.opts._n}`}else if(p=j===null||j===void 0?void 0:j(a))r=nn._`${r}${p}${this.opts._n}`;else throw new TrA(a);s.set(a,RO.Completed)})}return r}}WrA.ValueScope=XrA});var RA=x((sn)=>{Object.defineProperty(sn,"__esModule",{value:!0});sn.or=sn.and=sn.not=sn.CodeGen=sn.operators=sn.varKinds=sn.ValueScopeName=sn.ValueScope=sn.Scope=sn.Name=sn.regexpCode=sn.stringify=sn.getProperty=sn.nil=sn.strConcat=sn.str=sn._=void 0;var At=r7(),js=Yx(),Oo=r7();Object.defineProperty(sn,"_",{enumerable:!0,get:function(){return Oo._}});Object.defineProperty(sn,"str",{enumerable:!0,get:function(){return Oo.str}});Object.defineProperty(sn,"strConcat",{enumerable:!0,get:function(){return Oo.strConcat}});Object.defineProperty(sn,"nil",{enumerable:!0,get:function(){return Oo.nil}});Object.defineProperty(sn,"getProperty",{enumerable:!0,get:function(){return Oo.getProperty}});Object.defineProperty(sn,"stringify",{enumerable:!0,get:function(){return Oo.stringify}});Object.defineProperty(sn,"regexpCode",{enumerable:!0,get:function(){return Oo.regexpCode}});Object.defineProperty(sn,"Name",{enumerable:!0,get:function(){return Oo.Name}});var _O=Yx();Object.defineProperty(sn,"Scope",{enumerable:!0,get:function(){return _O.Scope}});Object.defineProperty(sn,"ValueScope",{enumerable:!0,get:function(){return _O.ValueScope}});Object.defineProperty(sn,"ValueScopeName",{enumerable:!0,get:function(){return _O.ValueScopeName}});Object.defineProperty(sn,"varKinds",{enumerable:!0,get:function(){return _O.varKinds}});sn.operators={GT:new At._Code(">"),GTE:new At._Code(">="),LT:new At._Code("<"),LTE:new At._Code("<="),EQ:new At._Code("==="),NEQ:new At._Code("!=="),NOT:new At._Code("!"),OR:new At._Code("||"),AND:new At._Code("&&"),ADD:new At._Code("+")};class Bo{optimizeNodes(){return this}optimizeNames(A,t){return this}}class YrA extends Bo{constructor(A,t,e){super();this.varKind=A,this.name=t,this.rhs=e}render({es5:A,_n:t}){let e=A?js.varKinds.var:this.varKind,j=this.rhs===void 0?"":` = ${this.rhs}`;return`${e} ${this.name}${j};`+t}optimizeNames(A,t){if(!A[this.name.str])return;if(this.rhs)this.rhs=Yu(this.rhs,A,t);return this}get names(){return this.rhs instanceof At._CodeOrName?this.rhs.names:{}}}class eR extends Bo{constructor(A,t,e){super();this.lhs=A,this.rhs=t,this.sideEffects=e}render({_n:A}){return`${this.lhs} = ${this.rhs};`+A}optimizeNames(A,t){if(this.lhs instanceof At.Name&&!A[this.lhs.str]&&!this.sideEffects)return;return this.rhs=Yu(this.rhs,A,t),this}get names(){let A=this.lhs instanceof At.Name?{}:{...this.lhs.names};return wO(A,this.rhs)}}class AnA extends eR{constructor(A,t,e,j){super(A,e,j);this.op=t}render({_n:A}){return`${this.lhs} ${this.op}= ${this.rhs};`+A}}class tnA extends Bo{constructor(A){super();this.label=A,this.names={}}render({_n:A}){return`${this.label}:`+A}}class enA extends Bo{constructor(A){super();this.label=A,this.names={}}render({_n:A}){return`break${this.label?` ${this.label}`:""};`+A}}class jnA extends Bo{constructor(A){super();this.error=A}render({_n:A}){return`throw ${this.error};`+A}get names(){return this.error.names}}class rnA extends Bo{constructor(A){super();this.code=A}render({_n:A}){return`${this.code};`+A}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(A,t){return this.code=Yu(this.code,A,t),this}get names(){return this.code instanceof At._CodeOrName?this.code.names:{}}}class VO extends Bo{constructor(A=[]){super();this.nodes=A}render(A){return this.nodes.reduce((t,e)=>t+e.render(A),"")}optimizeNodes(){let{nodes:A}=this,t=A.length;while(t--){let e=A[t].optimizeNodes();if(Array.isArray(e))A.splice(t,1,...e);else if(e)A[t]=e;else A.splice(t,1)}return A.length>0?this:void 0}optimizeNames(A,t){let{nodes:e}=this,j=e.length;while(j--){let r=e[j];if(r.optimizeNames(A,t))continue;ZPA(A,r.names),e.splice(j,1)}return e.length>0?this:void 0}get names(){return this.nodes.reduce((A,t)=>rd(A,t.names),{})}}class Go extends VO{render(A){return"{"+A._n+super.render(A)+"}"+A._n}}class nnA extends VO{}class n7 extends Go{}n7.kind="else";class xp extends Go{constructor(A,t){super(t);this.condition=A}render(A){let t=`if(${this.condition})`+super.render(A);if(this.else)t+="else "+this.else.render(A);return t}optimizeNodes(){super.optimizeNodes();let A=this.condition;if(A===!0)return this.nodes;let t=this.else;if(t){let e=t.optimizeNodes();t=this.else=Array.isArray(e)?new n7(e):e}if(t){if(A===!1)return t instanceof xp?t:t.nodes;if(this.nodes.length)return this;return new xp(onA(A),t instanceof xp?[t]:t.nodes)}if(A===!1||!this.nodes.length)return;return this}optimizeNames(A,t){var e;if(this.else=(e=this.else)===null||e===void 0?void 0:e.optimizeNames(A,t),!(super.optimizeNames(A,t)||this.else))return;return this.condition=Yu(this.condition,A,t),this}get names(){let A=super.names;if(wO(A,this.condition),this.else)rd(A,this.else.names);return A}}xp.kind="if";class Su extends Go{}Su.kind="for";class inA extends Su{constructor(A){super();this.iteration=A}render(A){return`for(${this.iteration})`+super.render(A)}optimizeNames(A,t){if(!super.optimizeNames(A,t))return;return this.iteration=Yu(this.iteration,A,t),this}get names(){return rd(super.names,this.iteration.names)}}class snA extends Su{constructor(A,t,e,j){super();this.varKind=A,this.name=t,this.from=e,this.to=j}render(A){let t=A.es5?js.varKinds.var:this.varKind,{name:e,from:j,to:r}=this;return`for(${t} ${e}=${j}; ${e}<${r}; ${e}++)`+super.render(A)}get names(){let A=wO(super.names,this.from);return wO(A,this.to)}}class AR extends Su{constructor(A,t,e,j){super();this.loop=A,this.varKind=t,this.name=e,this.iterable=j}render(A){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(A)}optimizeNames(A,t){if(!super.optimizeNames(A,t))return;return this.iterable=Yu(this.iterable,A,t),this}get names(){return rd(super.names,this.iterable.names)}}class NO extends Go{constructor(A,t,e){super();this.name=A,this.args=t,this.async=e}render(A){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(A)}}NO.kind="func";class PO extends VO{render(A){return"return "+super.render(A)}}PO.kind="return";class anA extends Go{render(A){let t="try"+super.render(A);if(this.catch)t+=this.catch.render(A);if(this.finally)t+=this.finally.render(A);return t}optimizeNodes(){var A,t;return super.optimizeNodes(),(A=this.catch)===null||A===void 0||A.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(A,t){var e,j;return super.optimizeNames(A,t),(e=this.catch)===null||e===void 0||e.optimizeNames(A,t),(j=this.finally)===null||j===void 0||j.optimizeNames(A,t),this}get names(){let A=super.names;if(this.catch)rd(A,this.catch.names);if(this.finally)rd(A,this.finally.names);return A}}class LO extends Go{constructor(A){super();this.error=A}render(A){return`catch(${this.error})`+super.render(A)}}LO.kind="catch";class zO extends Go{render(A){return"finally"+super.render(A)}}zO.kind="finally";class pnA{constructor(A,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
115
115
|
`:""},this._extScope=A,this._scope=new js.Scope({parent:A}),this._nodes=[new nnA]}toString(){return this._root.render(this.opts)}name(A){return this._scope.name(A)}scopeName(A){return this._extScope.name(A)}scopeValue(A,t){let e=this._extScope.value(A,t);return(this._values[e.prefix]||(this._values[e.prefix]=new Set)).add(e),e}getScopeValue(A,t){return this._extScope.getValue(A,t)}scopeRefs(A){return this._extScope.scopeRefs(A,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(A,t,e,j){let r=this._scope.toName(t);if(e!==void 0&&j)this._constants[r.str]=e;return this._leafNode(new YrA(A,r,e)),r}const(A,t,e){return this._def(js.varKinds.const,A,t,e)}let(A,t,e){return this._def(js.varKinds.let,A,t,e)}var(A,t,e){return this._def(js.varKinds.var,A,t,e)}assign(A,t,e){return this._leafNode(new eR(A,t,e))}add(A,t){return this._leafNode(new AnA(A,sn.operators.ADD,t))}code(A){if(typeof A=="function")A();else if(A!==At.nil)this._leafNode(new rnA(A));return this}object(...A){let t=["{"];for(let[e,j]of A){if(t.length>1)t.push(",");if(t.push(e),e!==j||this.opts.es5)t.push(":"),(0,At.addCodeArg)(t,j)}return t.push("}"),new At._Code(t)}if(A,t,e){if(this._blockNode(new xp(A)),t&&e)this.code(t).else().code(e).endIf();else if(t)this.code(t).endIf();else if(e)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(A){return this._elseNode(new xp(A))}else(){return this._elseNode(new n7)}endIf(){return this._endBlockNode(xp,n7)}_for(A,t){if(this._blockNode(A),t)this.code(t).endFor();return this}for(A,t){return this._for(new inA(A),t)}forRange(A,t,e,j,r=this.opts.es5?js.varKinds.var:js.varKinds.let){let n=this._scope.toName(A);return this._for(new snA(r,n,t,e),()=>j(n))}forOf(A,t,e,j=js.varKinds.const){let r=this._scope.toName(A);if(this.opts.es5){let n=t instanceof At.Name?t:this.var("_arr",t);return this.forRange("_i",0,At._`${n}.length`,(i)=>{this.var(r,At._`${n}[${i}]`),e(r)})}return this._for(new AR("of",j,r,t),()=>e(r))}forIn(A,t,e,j=this.opts.es5?js.varKinds.var:js.varKinds.const){if(this.opts.ownProperties)return this.forOf(A,At._`Object.keys(${t})`,e);let r=this._scope.toName(A);return this._for(new AR("in",j,r,t),()=>e(r))}endFor(){return this._endBlockNode(Su)}label(A){return this._leafNode(new tnA(A))}break(A){return this._leafNode(new enA(A))}return(A){let t=new PO;if(this._blockNode(t),this.code(A),t.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(PO)}try(A,t,e){if(!t&&!e)throw Error('CodeGen: "try" without "catch" and "finally"');let j=new anA;if(this._blockNode(j),this.code(A),t){let r=this.name("e");this._currNode=j.catch=new LO(r),t(r)}if(e)this._currNode=j.finally=new zO,this.code(e);return this._endBlockNode(LO,zO)}throw(A){return this._leafNode(new jnA(A))}block(A,t){if(this._blockStarts.push(this._nodes.length),A)this.code(A).endBlock(t);return this}endBlock(A){let t=this._blockStarts.pop();if(t===void 0)throw Error("CodeGen: not in self-balancing block");let e=this._nodes.length-t;if(e<0||A!==void 0&&e!==A)throw Error(`CodeGen: wrong number of nodes: ${e} vs ${A} expected`);return this._nodes.length=t,this}func(A,t=At.nil,e,j){if(this._blockNode(new NO(A,t,e)),j)this.code(j).endFunc();return this}endFunc(){return this._endBlockNode(NO)}optimize(A=1){while(A-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(A){return this._currNode.nodes.push(A),this}_blockNode(A){this._currNode.nodes.push(A),this._nodes.push(A)}_endBlockNode(A,t){let e=this._currNode;if(e instanceof A||t&&e instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${A.kind}/${t.kind}`:A.kind}"`)}_elseNode(A){let t=this._currNode;if(!(t instanceof xp))throw Error('CodeGen: "else" without "if"');return this._currNode=t.else=A,this}get _root(){return this._nodes[0]}get _currNode(){let A=this._nodes;return A[A.length-1]}set _currNode(A){let t=this._nodes;t[t.length-1]=A}}sn.CodeGen=pnA;function rd(A,t){for(let e in t)A[e]=(A[e]||0)+(t[e]||0);return A}function wO(A,t){return t instanceof At._CodeOrName?rd(A,t.names):A}function Yu(A,t,e){if(A instanceof At.Name)return j(A);if(!r(A))return A;return new At._Code(A._items.reduce((n,i)=>{if(i instanceof At.Name)i=j(i);if(i instanceof At._Code)n.push(...i._items);else n.push(i);return n},[]));function j(n){let i=e[n.str];if(i===void 0||t[n.str]!==1)return n;return delete t[n.str],i}function r(n){return n instanceof At._Code&&n._items.some((i)=>i instanceof At.Name&&t[i.str]===1&&e[i.str]!==void 0)}}function ZPA(A,t){for(let e in t)A[e]=(A[e]||0)-(t[e]||0)}function onA(A){return typeof A=="boolean"||typeof A=="number"||A===null?!A:At._`!${tR(A)}`}sn.not=onA;var HPA=ynA(sn.operators.AND);function xPA(...A){return A.reduce(HPA)}sn.and=xPA;var RPA=ynA(sn.operators.OR);function NPA(...A){return A.reduce(RPA)}sn.or=NPA;function ynA(A){return(t,e)=>t===At.nil?e:e===At.nil?t:At._`${tR(t)} ${A} ${tR(e)}`}function tR(A){return A instanceof At.Name?A:At._`(${A})`}});var VA=x((CnA)=>{Object.defineProperty(CnA,"__esModule",{value:!0});CnA.checkStrictMode=CnA.getErrorPath=CnA.Type=CnA.useFunc=CnA.setEvaluated=CnA.evaluatedPropsToName=CnA.mergeEvaluated=CnA.eachItem=CnA.unescapeJsonPointer=CnA.escapeJsonPointer=CnA.escapeFragment=CnA.unescapeFragment=CnA.schemaRefOrVal=CnA.schemaHasRulesButRef=CnA.schemaHasRules=CnA.checkUnknownRules=CnA.alwaysValidSchema=CnA.toHash=void 0;var xt=RA(),wPA=r7();function _PA(A){let t={};for(let e of A)t[e]=!0;return t}CnA.toHash=_PA;function VPA(A,t){if(typeof t=="boolean")return t;if(Object.keys(t).length===0)return!0;return fnA(A,t),!qnA(t,A.self.RULES.all)}CnA.alwaysValidSchema=VPA;function fnA(A,t=A.schema){let{opts:e,self:j}=A;if(!e.strictSchema)return;if(typeof t==="boolean")return;let r=j.RULES.keywords;for(let n in t)if(!r[n])mnA(A,`unknown keyword: "${n}"`)}CnA.checkUnknownRules=fnA;function qnA(A,t){if(typeof A=="boolean")return!A;for(let e in A)if(t[e])return!0;return!1}CnA.schemaHasRules=qnA;function QPA(A,t){if(typeof A=="boolean")return!A;for(let e in A)if(e!=="$ref"&&t.all[e])return!0;return!1}CnA.schemaHasRulesButRef=QPA;function JPA({topSchemaRef:A,schemaPath:t},e,j,r){if(!r){if(typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return xt._`${e}`}return xt._`${A}${t}${(0,xt.getProperty)(j)}`}CnA.schemaRefOrVal=JPA;function TPA(A){return cnA(decodeURIComponent(A))}CnA.unescapeFragment=TPA;function XPA(A){return encodeURIComponent(rR(A))}CnA.escapeFragment=XPA;function rR(A){if(typeof A=="number")return`${A}`;return A.replace(/~/g,"~0").replace(/\//g,"~1")}CnA.escapeJsonPointer=rR;function cnA(A){return A.replace(/~1/g,"/").replace(/~0/g,"~")}CnA.unescapeJsonPointer=cnA;function WPA(A,t){if(Array.isArray(A))for(let e of A)t(e);else t(A)}CnA.eachItem=WPA;function dnA({mergeNames:A,mergeToName:t,mergeValues:e,resultToName:j}){return(r,n,i,s)=>{let a=i===void 0?n:i instanceof xt.Name?(n instanceof xt.Name?A(r,n,i):t(r,n,i),i):n instanceof xt.Name?(t(r,i,n),n):e(n,i);return s===xt.Name&&!(a instanceof xt.Name)?j(r,a):a}}CnA.mergeEvaluated={props:dnA({mergeNames:(A,t,e)=>A.if(xt._`${e} !== true && ${t} !== undefined`,()=>{A.if(xt._`${t} === true`,()=>A.assign(e,!0),()=>A.assign(e,xt._`${e} || {}`).code(xt._`Object.assign(${e}, ${t})`))}),mergeToName:(A,t,e)=>A.if(xt._`${e} !== true`,()=>{if(t===!0)A.assign(e,!0);else A.assign(e,xt._`${e} || {}`),nR(A,e,t)}),mergeValues:(A,t)=>A===!0?!0:{...A,...t},resultToName:knA}),items:dnA({mergeNames:(A,t,e)=>A.if(xt._`${e} !== true && ${t} !== undefined`,()=>A.assign(e,xt._`${t} === true ? true : ${e} > ${t} ? ${e} : ${t}`)),mergeToName:(A,t,e)=>A.if(xt._`${e} !== true`,()=>A.assign(e,t===!0?!0:xt._`${e} > ${t} ? ${e} : ${t}`)),mergeValues:(A,t)=>A===!0?!0:Math.max(A,t),resultToName:(A,t)=>A.var("items",t)})};function knA(A,t){if(t===!0)return A.var("props",!0);let e=A.var("props",xt._`{}`);if(t!==void 0)nR(A,e,t);return e}CnA.evaluatedPropsToName=knA;function nR(A,t,e){Object.keys(e).forEach((j)=>A.assign(xt._`${t}${(0,xt.getProperty)(j)}`,!0))}CnA.setEvaluated=nR;var unA={};function SPA(A,t){return A.scopeValue("func",{ref:t,code:unA[t.code]||(unA[t.code]=new wPA._Code(t.code))})}CnA.useFunc=SPA;var jR;(function(A){A[A.Num=0]="Num",A[A.Str=1]="Str"})(jR||(CnA.Type=jR={}));function YPA(A,t,e){if(A instanceof xt.Name){let j=t===jR.Num;return e?j?xt._`"[" + ${A} + "]"`:xt._`"['" + ${A} + "']"`:j?xt._`"/" + ${A}`:xt._`"/" + ${A}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return e?(0,xt.getProperty)(A).toString():"/"+rR(A)}CnA.getErrorPath=YPA;function mnA(A,t,e=A.opts.strictSchema){if(!e)return;if(t=`strict mode: ${t}`,e===!0)throw Error(t);A.self.logger.warn(t)}CnA.checkStrictMode=mnA});var pi=x((EnA)=>{Object.defineProperty(EnA,"__esModule",{value:!0});var ir=RA(),cLA={data:new ir.Name("data"),valCxt:new ir.Name("valCxt"),instancePath:new ir.Name("instancePath"),parentData:new ir.Name("parentData"),parentDataProperty:new ir.Name("parentDataProperty"),rootData:new ir.Name("rootData"),dynamicAnchors:new ir.Name("dynamicAnchors"),vErrors:new ir.Name("vErrors"),errors:new ir.Name("errors"),this:new ir.Name("this"),self:new ir.Name("self"),scope:new ir.Name("scope"),json:new ir.Name("json"),jsonPos:new ir.Name("jsonPos"),jsonLen:new ir.Name("jsonLen"),jsonPart:new ir.Name("jsonPart")};EnA.default=cLA});var i7=x((OnA)=>{Object.defineProperty(OnA,"__esModule",{value:!0});OnA.extendErrors=OnA.resetErrorsCount=OnA.reportExtraError=OnA.reportError=OnA.keyword$DataError=OnA.keywordError=void 0;var jt=RA(),JO=VA(),Kr=pi();OnA.keywordError={message:({keyword:A})=>jt.str`must pass "${A}" keyword validation`};OnA.keyword$DataError={message:({keyword:A,schemaType:t})=>t?jt.str`"${A}" keyword must be ${t} ($data)`:jt.str`"${A}" keyword is invalid ($data)`};function mLA(A,t=OnA.keywordError,e,j){let{it:r}=A,{gen:n,compositeRule:i,allErrors:s}=r,a=$nA(A,t,e);if(j!==null&&j!==void 0?j:i||s)InA(n,a);else hnA(r,jt._`[${a}]`)}OnA.reportError=mLA;function CLA(A,t=OnA.keywordError,e){let{it:j}=A,{gen:r,compositeRule:n,allErrors:i}=j,s=$nA(A,t,e);if(InA(r,s),!(n||i))hnA(j,Kr.default.vErrors)}OnA.reportExtraError=CLA;function gLA(A,t){A.assign(Kr.default.errors,t),A.if(jt._`${Kr.default.vErrors} !== null`,()=>A.if(t,()=>A.assign(jt._`${Kr.default.vErrors}.length`,t),()=>A.assign(Kr.default.vErrors,null)))}OnA.resetErrorsCount=gLA;function ELA({gen:A,keyword:t,schemaValue:e,data:j,errsCount:r,it:n}){if(r===void 0)throw Error("ajv implementation error");let i=A.name("err");A.forRange("i",r,Kr.default.errors,(s)=>{if(A.const(i,jt._`${Kr.default.vErrors}[${s}]`),A.if(jt._`${i}.instancePath === undefined`,()=>A.assign(jt._`${i}.instancePath`,(0,jt.strConcat)(Kr.default.instancePath,n.errorPath))),A.assign(jt._`${i}.schemaPath`,jt.str`${n.errSchemaPath}/${t}`),n.opts.verbose)A.assign(jt._`${i}.schema`,e),A.assign(jt._`${i}.data`,j)})}OnA.extendErrors=ELA;function InA(A,t){let e=A.const("err",t);A.if(jt._`${Kr.default.vErrors} === null`,()=>A.assign(Kr.default.vErrors,jt._`[${e}]`),jt._`${Kr.default.vErrors}.push(${e})`),A.code(jt._`${Kr.default.errors}++`)}function hnA(A,t){let{gen:e,validateName:j,schemaEnv:r}=A;if(r.$async)e.throw(jt._`new ${A.ValidationError}(${t})`);else e.assign(jt._`${j}.errors`,t),e.return(!1)}var nd={keyword:new jt.Name("keyword"),schemaPath:new jt.Name("schemaPath"),params:new jt.Name("params"),propertyName:new jt.Name("propertyName"),message:new jt.Name("message"),schema:new jt.Name("schema"),parentSchema:new jt.Name("parentSchema")};function $nA(A,t,e){let{createErrors:j}=A.it;if(j===!1)return jt._`{}`;return ILA(A,t,e)}function ILA(A,t,e={}){let{gen:j,it:r}=A,n=[hLA(r,e),$LA(A,e)];return OLA(A,t,n),j.object(...n)}function hLA({errorPath:A},{instancePath:t}){let e=t?jt.str`${A}${(0,JO.getErrorPath)(t,JO.Type.Str)}`:A;return[Kr.default.instancePath,(0,jt.strConcat)(Kr.default.instancePath,e)]}function $LA({keyword:A,it:{errSchemaPath:t}},{schemaPath:e,parentSchema:j}){let r=j?t:jt.str`${t}/${A}`;if(e)r=jt.str`${r}${(0,JO.getErrorPath)(e,JO.Type.Str)}`;return[nd.schemaPath,r]}function OLA(A,{params:t,message:e},j){let{keyword:r,data:n,schemaValue:i,it:s}=A,{opts:a,propertyName:p,topSchemaRef:o,schemaPath:y}=s;if(j.push([nd.keyword,r],[nd.params,typeof t=="function"?t(A):t||jt._`{}`]),a.messages)j.push([nd.message,typeof e=="function"?e(A):e]);if(a.verbose)j.push([nd.schema,i],[nd.parentSchema,jt._`${o}${y}`],[Kr.default.data,n]);if(p)j.push([nd.propertyName,p])}});var MnA=x((FnA)=>{Object.defineProperty(FnA,"__esModule",{value:!0});FnA.boolOrEmptySchema=FnA.topBoolOrEmptySchema=void 0;var MLA=i7(),vLA=RA(),bLA=pi(),DLA={message:"boolean schema is false"};function ULA(A){let{gen:t,schema:e,validateName:j}=A;if(e===!1)GnA(A,!1);else if(typeof e=="object"&&e.$async===!0)t.return(bLA.default.data);else t.assign(vLA._`${j}.errors`,null),t.return(!0)}FnA.topBoolOrEmptySchema=ULA;function ZLA(A,t){let{gen:e,schema:j}=A;if(j===!1)e.var(t,!1),GnA(A);else e.var(t,!0)}FnA.boolOrEmptySchema=ZLA;function GnA(A,t){let{gen:e,data:j}=A,r={gen:e,keyword:"false schema",data:j,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:A};(0,MLA.reportError)(r,DLA,void 0,t)}});var sR=x((vnA)=>{Object.defineProperty(vnA,"__esModule",{value:!0});vnA.getRules=vnA.isJSONType=void 0;var xLA=["string","number","integer","boolean","null","object","array"],RLA=new Set(xLA);function NLA(A){return typeof A=="string"&&RLA.has(A)}vnA.isJSONType=NLA;function PLA(){let A={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...A,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},A.number,A.string,A.array,A.object],post:{rules:[]},all:{},keywords:{}}}vnA.getRules=PLA});var aR=x((ZnA)=>{Object.defineProperty(ZnA,"__esModule",{value:!0});ZnA.shouldUseRule=ZnA.shouldUseGroup=ZnA.schemaHasRulesForType=void 0;function zLA({schema:A,self:t},e){let j=t.RULES.types[e];return j&&j!==!0&&DnA(A,j)}ZnA.schemaHasRulesForType=zLA;function DnA(A,t){return t.rules.some((e)=>UnA(A,e))}ZnA.shouldUseGroup=DnA;function UnA(A,t){var e;return A[t.keyword]!==void 0||((e=t.definition.implements)===null||e===void 0?void 0:e.some((j)=>A[j]!==void 0))}ZnA.shouldUseRule=UnA});var s7=x((PnA)=>{Object.defineProperty(PnA,"__esModule",{value:!0});PnA.reportTypeError=PnA.checkDataTypes=PnA.checkDataType=PnA.coerceAndCheckDataType=PnA.getJSONTypes=PnA.getSchemaTypes=PnA.DataType=void 0;var VLA=sR(),QLA=aR(),JLA=i7(),LA=RA(),xnA=VA(),Af;(function(A){A[A.Correct=0]="Correct",A[A.Wrong=1]="Wrong"})(Af||(PnA.DataType=Af={}));function TLA(A){let t=RnA(A.type);if(t.includes("null")){if(A.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!t.length&&A.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(A.nullable===!0)t.push("null")}return t}PnA.getSchemaTypes=TLA;function RnA(A){let t=Array.isArray(A)?A:A?[A]:[];if(t.every(VLA.isJSONType))return t;throw Error("type must be JSONType or JSONType[]: "+t.join(","))}PnA.getJSONTypes=RnA;function XLA(A,t){let{gen:e,data:j,opts:r}=A,n=WLA(t,r.coerceTypes),i=t.length>0&&!(n.length===0&&t.length===1&&(0,QLA.schemaHasRulesForType)(A,t[0]));if(i){let s=oR(t,j,r.strictNumbers,Af.Wrong);e.if(s,()=>{if(n.length)SLA(A,t,n);else yR(A)})}return i}PnA.coerceAndCheckDataType=XLA;var NnA=new Set(["string","number","integer","boolean","null"]);function WLA(A,t){return t?A.filter((e)=>NnA.has(e)||t==="array"&&e==="array"):[]}function SLA(A,t,e){let{gen:j,data:r,opts:n}=A,i=j.let("dataType",LA._`typeof ${r}`),s=j.let("coerced",LA._`undefined`);if(n.coerceTypes==="array")j.if(LA._`${i} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>j.assign(r,LA._`${r}[0]`).assign(i,LA._`typeof ${r}`).if(oR(t,r,n.strictNumbers),()=>j.assign(s,r)));j.if(LA._`${s} !== undefined`);for(let p of e)if(NnA.has(p)||p==="array"&&n.coerceTypes==="array")a(p);j.else(),yR(A),j.endIf(),j.if(LA._`${s} !== undefined`,()=>{j.assign(r,s),YLA(A,s)});function a(p){switch(p){case"string":j.elseIf(LA._`${i} == "number" || ${i} == "boolean"`).assign(s,LA._`"" + ${r}`).elseIf(LA._`${r} === null`).assign(s,LA._`""`);return;case"number":j.elseIf(LA._`${i} == "boolean" || ${r} === null
|
|
116
116
|
|| (${i} == "string" && ${r} && ${r} == +${r})`).assign(s,LA._`+${r}`);return;case"integer":j.elseIf(LA._`${i} === "boolean" || ${r} === null
|