@allscale/cli 1.0.2 → 1.0.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/README.md +58 -5
- package/dist/commands/build-info.js +9 -9
- package/dist/commands/claim-link/claim.js +10 -10
- package/dist/commands/claim-link/create.js +30 -30
- package/dist/commands/claim-link/get.js +13 -13
- package/dist/commands/claim-link/list.js +11 -11
- package/dist/commands/claim-link/status.js +10 -10
- package/dist/commands/describe.js +8 -8
- package/dist/commands/device-login.js +24 -24
- package/dist/commands/invoice/get.js +10 -10
- package/dist/commands/invoice/list.js +8 -8
- package/dist/commands/invoice/pay.js +28 -28
- package/dist/commands/invoice/received.js +8 -8
- package/dist/commands/invoice/send.js +22 -22
- package/dist/commands/invoice/sent.js +4 -4
- package/dist/commands/invoice/update.js +11 -11
- package/dist/commands/logout.js +12 -12
- package/dist/commands/operations.js +7 -7
- package/dist/commands/otp-login.js +19 -19
- package/dist/commands/otp-send.js +7 -7
- package/dist/commands/payout/send.js +12 -12
- package/dist/commands/payout/status.js +12 -12
- package/dist/commands/scope.js +12 -12
- package/dist/commands/store/create.js +15 -15
- package/dist/commands/transaction/get.js +11 -11
- package/dist/commands/transaction/list.js +5 -5
- package/dist/commands/wallet/list.js +9 -9
- package/dist/commands/wallet/send.js +27 -27
- package/dist/commands/whoami.js +12 -12
- package/dist/index.js +9 -9
- package/dist/lib/help.js +10 -7
- package/oclif.manifest.json +5 -5
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var nr=Object.create;var Te=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,or=Object.prototype.hasOwnProperty;var ar=(e,n)=>{for(var t in n)Te(e,t,{get:n[t],enumerable:!0})},pt=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ir(n))!or.call(e,r)&&r!==t&&Te(e,r,{get:()=>n[r],enumerable:!(i=tr(n,r))||i.enumerable});return e};var
|
|
1
|
+
"use strict";var nr=Object.create;var Te=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,or=Object.prototype.hasOwnProperty;var ar=(e,n)=>{for(var t in n)Te(e,t,{get:n[t],enumerable:!0})},pt=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ir(n))!or.call(e,r)&&r!==t&&Te(e,r,{get:()=>n[r],enumerable:!(i=tr(n,r))||i.enumerable});return e};var b=(e,n,t)=>(t=e!=null?nr(rr(e)):{},pt(n||!e||!e.__esModule?Te(t,"default",{value:e,enumerable:!0}):t,e)),sr=e=>pt(Te({},"__esModule",{value:!0}),e);var es={};ar(es,{default:()=>en});module.exports=sr(es);var I=require("@oclif/core");var ft="public",mt="https://app.allscale.io";var yt=["https://app.allscale.io"];var rn="Override the API base URL (public builds accept only https://app.allscale.io)";var on="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function ht(e){try{let n=new URL(e);return n.username.length>0||n.password.length>0?null:n.protocol==="https:"?n:null}catch{return null}}function gt(e){return ht(e)!==null}function an(e){let n=ht(e);return n!==null&&yt.includes(n.origin)}function de(){return"".trim()||void 0}function X(){return"public"}function F(e){try{let{hostname:n}=new URL(e);return n==="127.0.0.1"||n==="localhost"||n==="[::1]"}catch{return!1}}function ln(e){try{return new URL(e).origin}catch{return null}}function ue(){{let e="[]".trim();if(e.length===0)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}return sn()}function sn(){let e=process.env.ALLSCALE_BUILD_PAIRS?.trim()??"";if(e.length>0)try{let i=JSON.parse(e);if(!Array.isArray(i))return[];let r=[];for(let o of i){if(typeof o!="object"||o===null)continue;let{base:a,key:l,keyId:s}=o;if(typeof a!="string"||a.trim().length===0||typeof l!="string"||l.trim().length===0)continue;let u=typeof s=="string"?s.trim():"";r.push({base:a.trim(),key:l,keyId:u.length>0?u:"cli-1"})}return r}catch{return[]}let n=process.env.ALLSCALE_SIGNING_KEY??"",t=process.env.ALLSCALE_BUILD_API_BASE?.trim()??"";if(n.trim().length>0&&t.length>0){let i=process.env.ALLSCALE_SIGNING_KEY_ID?.trim();return[{base:t,key:n,keyId:i&&i.length>0?i:"cli-1"}]}return[]}var St="device-login",lr=/^[A-Za-z0-9._-]{1,64}$/;function un(e){return lr.test(e)?e:"<profile>"}function Q(e){return"allscale otp-login --profile "+(e===void 0?"<profile>":un(e))+" --email <you@example.com> --scopes <scope> --otp-stdin"}function Le(){return"`allscale device-login` (or `allscale otp-login` \u2014 requires `--email` and `--scopes` \u2014 for headless automation)"}function At(e){let n=un(e);return`No tokens stored for profile '${e}'. Run \`allscale device-login --profile ${n}\` (recommended), or use \`${Q(e)}\` for headless automation.`}function kt(e){return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. Check the spelling first; to deliberately create '${e}', run \`allscale ${St} --profile ${un(e)}\`.`}var cr={"input.invalid":2,"storage.unavailable":2,"transport.network":3,"transport.timeout":3,"transport.response_too_large":2,"auth.no_token":4,"auth.unknown_profile":2,"auth.token_invalid":5,"auth.token_expired":5,"auth.device_pairing_timeout":3,"auth.credential_changed":3,"auth.permission_denied":6,"auth.signature_rejected":11,"claim.not_claimable":12,"claim.expired":12,"claim.payout_ambiguous":9,"claim_link.funding_ambiguous":9,"claim_link.intent_conflict":2,"claim_link.browser_cancelled":12,"user.cancelled":12,"signing.key_unavailable":2,not_found:7,rate_limited:8,"backend.internal":9,"wallet.requires_browser_auth":6,"wallet.bridge_timeout":3,"wallet.bridge_op_expired":3,"wallet.bridge_invalid_response":9,"wallet.transaction_reverted":12,"wallet.transaction_status_unknown":9,"raw.disabled":10,internal:1};var dr=new RegExp(["\\u001b\\[[0-9;:<=>?]*[ -/]*[@-~]","\\u009b[0-9;:<=>?]*[ -/]*[@-~]","\\u001b\\][^\\u0007\\u001b\\u009c]*(?:\\u0007|\\u001b\\\\|\\u009c)","\\u009d[^\\u0007\\u001b\\u009c]*(?:\\u0007|\\u001b\\\\|\\u009c)","\\u001b[ -/]+[0-~]","\\u001b[0-Z\\x5c-~]","\\u001b\\[[0-9;:<=>?]*[ -/]*","\\u009b[0-9;:<=>?]*[ -/]*","[\\u0007\\u001b\\u0090\\u0098\\u009b\\u009c\\u009d\\u009e\\u009f]"].join("|"),"g");function pn(e){return(typeof e=="string"?e:String(e??"")).replace(dr,"")}var ur=64;function cn(e,n=new Map,t=0){if(typeof e=="string")return pn(e);if(e===null||typeof e!="object")return e;let i=n.get(e);if(i!==void 0)return i;if(t>=ur)return e;if(Array.isArray(e)){let a=[];n.set(e,a);for(let l of e)a.push(cn(l,n,t+1));return a}let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return e;let o={};n.set(e,o);for(let[a,l]of Object.entries(e))Object.defineProperty(o,a,{value:cn(l,n,t+1),writable:!0,enumerable:!0,configurable:!0});return o}var c=class extends Error{code;details;constructor(n,t,i){super(pn(t)),this.code=n,this.details=i&&cn(i),this.name="AllscaleError"}get exitCode(){return cr[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function Tt(e){if(e instanceof c)return e;if(e instanceof Error){if(mr(e)){let n=hr(e),t={};return e.name&&e.name!=="Error"&&(t.name=e.name),Object.keys(n).length>0&&(t.oclif=n),new c("input.invalid",e.message,Object.keys(t).length>0?t:void 0)}return new c("internal",e.message,{name:e.name})}return new c("internal","Unknown error",{value:String(e)})}var pr=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),fr=[/^Missing \d+ required arg/i,/^Missing required flag/i,/^Unexpected argument/i,/^Nonexistent flag/i,/^Unexpected arguments?/i,/^Failed parsing/i,/^Parsing --[A-Za-z0-9][A-Za-z0-9-]*(?:\s|$)/i,/^Expected (?:--|-).*/i,/^Flag --[A-Za-z0-9][A-Za-z0-9-]* can only be specified once\.?$/i,/^Flag --[A-Za-z0-9][A-Za-z0-9-]* expects a value$/i,/^Flag --[A-Za-z0-9][A-Za-z0-9-]* expects one of these values: /i,/to be one of: /];function mr(e){if(yr(e))return!0;let n=e.name??"";return pr.has(n)?n==="CLIError"?dn(e,"parse")||_t(e.message):!0:_t(e.message)}function yr(e){if(!dn(e,"oclif"))return!1;let n=e.oclif;return typeof n=="object"&&n!==null&&n.exit===2&&dn(e,"parse")}function _t(e){return e?pn(e).split(`
|
|
2
2
|
`).some(n=>fr.some(t=>t.test(n.trim()))):!1}function dn(e,n){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,n)}function hr(e){let n=e,t={};for(let i of["code","exitCode","suggestions","ref"])n[i]!==void 0&&(t[i]=n[i]);return t}function Lt(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
-
`)}var h=
|
|
3
|
+
`)}var h=b(require("fs")),Ce=b(require("path")),Rt=b(require("crypto"));var gr="...<truncated>",_r=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,Sr=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,gn=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,fn=String.raw`(?:proxy[_-]?)?authorization`,Ar=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${fn}"|'${fn}'|${fn})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${gn}`,"gi"),kr=/\b(https?:\/\/)[^\s/?#]+@/gi,Tr=String.raw`(?:[A-Za-z0-9]+[_-])*`,Lr=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,wt=e=>String.raw`(?:password|passwd|passphrase|otp(?:[_-]?code)?|signature|hmac|sig|session[_-]?id|mnemonic|seed|cookie|bearer|${e}(?:token|secret)|(?:api|access|private|signing)[_-]?key|credential|claim[_-]?url)`,bt=wt(Tr),br=wt(Lr),wr=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${bt}"|'${bt}'|${br})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${gn}`,"gi"),mn=String.raw`(?:[A-Za-z0-9]+(?:Token|Secret)|[Oo][Tt][Pp]Code|[Ss]essionId|(?:api|API|access|Access|private|Private|signing|Signing)Key|[Cc]laimUrl)`,Er=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${mn}"|'${mn}'|${mn})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${gn}`,"g");function be(e){return e.replace(kr,"$1<redacted>@").replace(_r,"<redacted-jwt>").replace(Ar,"$1$2$3<redacted>").replace(wr,"$1$2<redacted>").replace(Er,"$1$2<redacted>").replace(Sr,"Bearer <redacted>")}var Nr=/(token|secret|password|passwd|passphrase|cookie|authorization|bearer|credential|mnemonic|seed|api[_-]?key|apikey|private[_-]?key|privkey|otp|signature|hmac|(?:^|[_-])sig(?:[_-]|$)|session[_-]?id|^input$)/i;function we(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Nr.test(n)}function Et(e){let n="";for(let t of e){let i=t.codePointAt(0),r=i<=8||i>=11&&i<=12||i>=14&&i<=31||i>=127&&i<=159;n+=r?`\\u${i.toString(16).padStart(4,"0")}`:t}return n}function Ee(e,n,t=gr){if(n<=0)return"";if(Buffer.byteLength(e,"utf8")<=n)return e;let i=Buffer.byteLength(t,"utf8");if(i>=n){let l="",s=0;for(let u of t){let f=Buffer.byteLength(u,"utf8");if(s+f>n)break;l+=u,s+=f}return l}let r=n-i,o="",a=0;for(let l of e){let s=Buffer.byteLength(l,"utf8");if(a+s>r)break;o+=l,a+=s}return`${o}${t}`}function L(e,n=16384){return Ee(Et(be(e)),n)}var yn=100,Cr=8,Or=8*1024;function Ne(){return{remaining:Or}}function hn(e,n){let t=Math.min(16384,n.remaining),i=Ee(e,t);return n.remaining-=Buffer.byteLength(i,"utf8"),i}function Z(e,n,t=0,i={}){if(t>Cr)return hn("<truncated>",n);if(typeof e=="string"){let r=be(e);return hn(i.escapeControls?Et(r):r,n)}if(Array.isArray(e)){let r=e.slice(0,yn),o=r.map(a=>Z(a,n,t+1,i));return e.length>r.length&&o.push(hn(`<${e.length-r.length} more items truncated>`,n)),o}if(e!==null&&typeof e=="object"){let r=Object.create(null),o=Object.entries(e);for(let[a,l]of o.slice(0,yn))r[a]=Z(l,n,t+1,i);return o.length>yn&&(r.output_truncated=!0),r}return e}var _n=require("process");var Sn=!1;function An(e){Sn=e}function Ct(){return Sn}var Nt="1";function ne(e,n){if(Sn){let t={...e};delete t.version;let i=Ne(),r={event:t.event,...t},o=Z(r,i,0,{escapeControls:!0}),a=JSON.stringify({version:Nt,...o});Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:Nt,event:o.event,output_truncated:!0})),_n.stderr.write(`${a}
|
|
4
4
|
`)}else _n.stderr.write(n)}var Ot="2",te=null,E=null,ie=!1,pe=!1;function Rr(){let e=process.env.ALLSCALE_OUTPUT_FILE_PATH;if(e)return e;let n=process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY;if(n){let t=new Date().toISOString().replace(/[:.]/g,"-"),i=Rt.randomBytes(4).toString("hex");return Ce.join(n,`allscale-output-${t}-${i}.ndjson`)}return null}var kn=64*1024*1024,Ir=null;function Tn(e={}){if(e.quiet&&(pe=!0),ie)return;let n=Rr();if(!n)return;te=null;let t=null;try{if((Ir??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let i=Ce.dirname(n);if(h.mkdirSync(i,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let s=h.statSync(i),u=s.mode&511;if(!s.isDirectory()||(u&63)!==0)throw new Error(`output directory must be owner-only (no group/other permissions); current mode is ${u.toString(8).padStart(3,"0")}`)}let r=h.constants.O_NOFOLLOW??0;t=h.openSync(n,h.constants.O_APPEND|h.constants.O_CREAT|h.constants.O_WRONLY|(h.constants.O_NONBLOCK??0)|r,384);let o=h.fstatSync(t),a=h.lstatSync(n);if(!o.isFile()||a.isSymbolicLink()||a.dev!==o.dev||a.ino!==o.ino)throw new Error("target changed while it was being opened or is not a regular file");if(typeof process.geteuid=="function"&&o.uid!==process.geteuid())throw new Error("existing sidecar file is not owned by the current effective user");let l=o.mode&511;if((l&63)!==0)throw new Error(`existing sidecar file must already be owner-only; current mode is ${l.toString(8).padStart(3,"0")}. Rotate or remove it before retrying`);h.fchmodSync(t,384)}catch(i){if(t!==null)try{h.closeSync(t)}catch{}pe||ne({event:"sidecar_disabled",reason:"open_failed",detail:L(`sidecar path '${n}' could not be opened safely (${i.message})`)},`${L(`[allscale] sidecar path '${n}' could not be opened safely (${i.message}); refusing to write. Sidecar disabled for this run.`)}
|
|
5
5
|
`);return}te=n,E=t,ie=!0}var vr=[/password/i,/secret/i,/token/i,/api[_-]?key/i,/signing[_-]?key/i,/private[_-]?key/i,/credential/i,/otp/i,/signature/i,/(?:^|[_-])sig(?:[_-]|$)/i,/hmac/i,/session[_-]?id/i,/nonce/i,/bearer/i,/authorization/i,/^code$/i,/^auth$/i,/^state$/i];function xr(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return vr.some(t=>t.test(n))}function It(e){try{let n=new URL(e),t=n.username.length>0||n.password.length>0;t&&(n.username="",n.password="");let i=n.pathname;n.pathname=Pr(n.pathname);let r=t;n.pathname!==i&&(r=!0);for(let[o]of n.searchParams)xr(o)&&(n.searchParams.set(o,"<redacted>"),r=!0);return r?n.toString():e}catch{return e}}function Pr(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function Ur(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:It(e.url)}:e}function Br(e){let n=new Date().toISOString(),t=e,{type:i,...r}=t,o=Z(r,Ne()),a=JSON.stringify({version:Ot,timestamp:n,type:i,...o});return Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:Ot,timestamp:n,type:i,output_truncated:!0})),a}function k(e){if(!ie||!te||E===null)return;let n=Ur(e),t=Br(n);try{if(h.fstatSync(E).size+Buffer.byteLength(t,"utf8")+1>kn){ie=!1;try{h.closeSync(E)}catch{}E=null,pe||ne({event:"sidecar_disabled",reason:"size_limit",...te===null?{}:{path:L(te)},max_bytes:kn},`${L(`[allscale] sidecar exceeded ${kn} bytes; disabling it for the rest of this run. Rotate or remove ${te}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
6
|
`);return}h.appendFileSync(E,`${t}
|
|
7
7
|
`)}catch(i){if(ie=!1,E!==null){try{h.closeSync(E)}catch{}E=null}try{pe||ne({event:"sidecar_disabled",reason:"write_failed",detail:L(i.message)},`${L(`[allscale] sidecar write failed (${i.message}); disabling sidecar for the rest of this run.`)}
|
|
8
|
-
`)}catch{}}}var D=It;function vt(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function fe(){if(pe=!1,ie=!1,E!==null){try{h.closeSync(E)}catch{}E=null}}function xt(e=!1){let n=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||vt()||!n}var me=new Set(["--password","-p","--token","-t","--otp","--otp-id","--api-base","--payout-api-base","--browser-base","--input","-i","--claim-token","--claim-url","--api-key","--api-secret"]),Dr=new Set(Array.from(me).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),$r=Array.from(me).filter(e=>e.startsWith("--")).sort((e,n)=>n.length-e.length),Fr=new Set(["--otp-stdin","--password-stdin"]);function Ln(e){let n=[];for(let t=0;t<e.length;t+=1){let i=e[t];if(i.startsWith("-")){let o=i.indexOf("=");if(o!==-1){let a=i.slice(0,o);if(me.has(a)){n.push(`${a}=<redacted>`);continue}}}if(me.has(i)){n.push(i),t+1<e.length&&(me.has(e[t+1])||(n.push("<redacted>"),t+=1));continue}if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2&&i[1]!=="="){let o=i.slice(0,2);if(Dr.has(o)){n.push(`${o}<redacted>`);continue}}let r=Fr.has(i)?void 0:$r.find(o=>i.length>o.length&&i.startsWith(o));if(r){n.push(`${r}<redacted>`);continue}n.push(i)}return n}function Pt(e){k({type:"error",code:e.code,message:L(e.message)}),k({type:"command-end",ok:!1,exitCode:e.exitCode}),fe()}var ye=de()??mt,oe={TOKEN:"ALLSCALE_TOKEN",PROFILE:"ALLSCALE_PROFILE",API_BASE:"ALLSCALE_API_BASE",PAYOUT_API_BASE:"ALLSCALE_PAYOUT_API_BASE",PRETTY:"ALLSCALE_PRETTY",LOG_LEVEL:"ALLSCALE_LOG_LEVEL",INSECURE_STORAGE:"ALLSCALE_INSECURE_STORAGE",NO_KEYCHAIN:"ALLSCALE_NO_KEYCHAIN",ALLOW_RAW:"ALLSCALE_ALLOW_RAW",OUTPUT_FILE_PATH:"ALLSCALE_OUTPUT_FILE_PATH",OUTPUT_FILE_DIRECTORY:"ALLSCALE_OUTPUT_FILE_DIRECTORY",STORE_API_KEY:"ALLSCALE_STORE_API_KEY",STORE_API_SECRET:"ALLSCALE_STORE_API_SECRET"};function M(e){return gt(e)?new URL(e).origin:null}function R(e){try{let n=new URL(e);return`${n.protocol}//${n.host}`}catch{return"<unparseable URL>"}}function Ut(){let e=process.env[oe.TOKEN]?.trim();return e&&e.length>0?e:void 0}function
|
|
8
|
+
`)}catch{}}}var D=It;function vt(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function fe(){if(pe=!1,ie=!1,E!==null){try{h.closeSync(E)}catch{}E=null}}function xt(e=!1){let n=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||vt()||!n}var me=new Set(["--password","-p","--token","-t","--otp","--otp-id","--api-base","--payout-api-base","--browser-base","--input","-i","--claim-token","--claim-url","--api-key","--api-secret"]),Dr=new Set(Array.from(me).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),$r=Array.from(me).filter(e=>e.startsWith("--")).sort((e,n)=>n.length-e.length),Fr=new Set(["--otp-stdin","--password-stdin"]);function Ln(e){let n=[];for(let t=0;t<e.length;t+=1){let i=e[t];if(i.startsWith("-")){let o=i.indexOf("=");if(o!==-1){let a=i.slice(0,o);if(me.has(a)){n.push(`${a}=<redacted>`);continue}}}if(me.has(i)){n.push(i),t+1<e.length&&(me.has(e[t+1])||(n.push("<redacted>"),t+=1));continue}if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2&&i[1]!=="="){let o=i.slice(0,2);if(Dr.has(o)){n.push(`${o}<redacted>`);continue}}let r=Fr.has(i)?void 0:$r.find(o=>i.length>o.length&&i.startsWith(o));if(r){n.push(`${r}<redacted>`);continue}n.push(i)}return n}function Pt(e){k({type:"error",code:e.code,message:L(e.message)}),k({type:"command-end",ok:!1,exitCode:e.exitCode}),fe()}var ye=de()??mt,oe={TOKEN:"ALLSCALE_TOKEN",PROFILE:"ALLSCALE_PROFILE",API_BASE:"ALLSCALE_API_BASE",PAYOUT_API_BASE:"ALLSCALE_PAYOUT_API_BASE",PRETTY:"ALLSCALE_PRETTY",LOG_LEVEL:"ALLSCALE_LOG_LEVEL",INSECURE_STORAGE:"ALLSCALE_INSECURE_STORAGE",NO_KEYCHAIN:"ALLSCALE_NO_KEYCHAIN",ALLOW_RAW:"ALLSCALE_ALLOW_RAW",OUTPUT_FILE_PATH:"ALLSCALE_OUTPUT_FILE_PATH",OUTPUT_FILE_DIRECTORY:"ALLSCALE_OUTPUT_FILE_DIRECTORY",STORE_API_KEY:"ALLSCALE_STORE_API_KEY",STORE_API_SECRET:"ALLSCALE_STORE_API_SECRET"};function M(e){return gt(e)?new URL(e).origin:null}function R(e){try{let n=new URL(e);return`${n.protocol}//${n.host}`}catch{return"<unparseable URL>"}}function Ut(){let e=process.env[oe.TOKEN]?.trim();return e&&e.length>0?e:void 0}function bn(){let e=process.env[oe.PROFILE]?.trim();return e&&e.length>0?e:void 0}function he(){let e=process.env[oe.API_BASE]?.trim();return e&&e.length>0?e:void 0}function Bt(){let e=process.env[oe.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Dt(){let e=process.env[oe.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function $t(){let e=process.env[oe.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Ft(e){let{resolvedApiBase:n,fromExplicitOverride:t,profileApiBase:i,profileApiBaseSource:r}=e;if(de()===void 0&&ye!==""&&"".length!==0&&!t&&r!=="explicit"&&i===""&&n==="")return`Notice: this profile is pinned to ${""} (staging) in ~/.allscale/config.toml.
|
|
9
9
|
The CLI default is now ${ye} (production), but a saved profile wins over the default,
|
|
10
10
|
so this session still uses staging. That pin was written before the default changed, so it may just be
|
|
11
11
|
the old default rather than a deliberate choice.
|
|
12
12
|
To keep staging, re-run \`allscale device-login\` with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
13
|
To move to production, run: allscale device-login --api-base ${ye}
|
|
14
|
-
`}var G=
|
|
15
|
-
`)}};var Zr=/_(removed|cleared|count|total)$/i;function eo(e,n){return typeof n=="number"&&Zr.test(e)}var no=new Set(Vt);function to(e,n){return e==="token_symbol"&&typeof n=="string"&&no.has(n)}var io=new Set(Wt);function ro(e,n){return e==="otp_reason"&&typeof n=="string"&&io.has(n)}var xe=100;function Pe(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,xe),i=t.map(r=>Pe(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null),i=Object.entries(e);for(let[r,o]of i.slice(0,xe))t[r]=be(r)&&!eo(r,o)&&!to(r,o)&&!ro(r,o)?"<redacted>":Pe(o,n+1);if(i.length>xe){let r="<truncated>";for(;r in t;)r=`<${r}>`;t[r]=`${i.length-xe} more keys`}return t}if(typeof e=="string"){let t=oo(e);return t!==void 0?L(JSON.stringify(Pe(t,n+1))):L(e)}return e}function oo(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function ao(e){let n=Ct()?void 0:2,t=Pe(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:L(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function so(e){if(e.requiresInput===!0)return!0;let n=r=>typeof r=="object"&&r!==null&&r.required===!0,t=e.flags??{},i=e.args??{};return Object.values(t).some(r=>n(r))||Object.values(i).some(r=>n(r))}var li=w(require("path"));var Rn=require("crypto"),d=w(require("fs")),S=w(require("path"));var Ue=1024*1024,lo=5e3,co=20,uo=3e4,Cn=4096,po=new Int32Array(new SharedArrayBuffer(4)),_e=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function Be(e){return e instanceof _e}var b=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},fo=null;function q(){return new c("storage.unavailable","Owner-only plaintext credential ACLs cannot be enforced on Windows; --insecure-storage is disabled on this platform. Use Windows Credential Manager instead. `allscale logout` can still remove a legacy plaintext file when the requested profile is its only remaining profile.")}function De(){return(fo??process.platform)!=="win32"}function ii(){if(!De())throw q()}function ri(e){try{return d.default.lstatSync(e),!1}catch(n){if(!_(n,"ENOENT"))throw n}try{let n=d.default.lstatSync(S.dirname(e));return!n.isSymbolicLink()&&n.isDirectory()}catch(n){if(_(n,"ENOENT"))return!0;throw n}}function _(e,n){return typeof e=="object"&&e!==null&&e.code===n}function Se(e,n){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${n} is not owned by the current effective user`)}function Ae(e,n){return e.dev===n.dev&&e.ino===n.ino}function mo(e){Atomics.wait(po,0,0,e)}function oi(e){try{return process.kill(e,0),!0}catch(n){return!_(n,"ESRCH")}}function yo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zt(e,n){let t=S.dirname(e);n&&d.default.mkdirSync(t,{recursive:!0,mode:448});let i;try{i=d.default.lstatSync(t)}catch(o){if(!n&&_(o,"ENOENT"))return!1;throw o}if(i.isSymbolicLink()||!i.isDirectory())throw new Error("credential-store parent must be a real directory");if(process.platform==="win32")return!0;let r=null;try{r=d.default.openSync(t,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0));let o=d.default.fstatSync(r),a=d.default.lstatSync(t);if(!o.isDirectory()||a.isSymbolicLink()||!a.isDirectory()||!Ae(o,a))throw new Error("credential-store parent changed while it was being inspected");Se(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&S.basename(t)===".allscale"&&(d.default.fchmodSync(r,448),l=d.default.fstatSync(r)),(l.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{r!==null&&d.default.closeSync(r)}return!0}function v(e,n,t,i={}){if(!t.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");let r;try{r=d.default.lstatSync(e)}catch(o){throw i.retryOnPathChange&&_(o,"ENOENT")?new b:o}if(!Ae(t,r))throw i.retryOnPathChange?new b:new Error("credential-store target changed while it was being opened or is not a regular file");if(r.isSymbolicLink()||!r.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");if(!i.allowMultipleLinks&&(t.nlink!==1||r.nlink!==1))throw new _e;if(Se(t,"credential-store file"),process.platform!=="win32"){d.default.fchmodSync(n,384);let o=d.default.fstatSync(n);if((o.mode&63)!==0)throw new Error("credential-store file could not be made owner-only");return o}return t}function ho(e,n){if(n.size>Ue)throw new Error("credential-store file exceeds the maximum supported size");let t=Buffer.alloc(Ue+1),i=0;for(;i<t.length;){let r=d.default.readSync(e,t,i,t.length-i,null);if(r===0)break;i+=r}if(i>Ue)throw new Error("credential-store file exceeds the maximum supported size");return t.subarray(0,i).toString("utf8")}function Xt(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT"))try{if(d.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(_(o,"ENOENT"))return null;throw o}throw r}let t=d.default.fstatSync(n),i=v(e,n,t);return ho(n,i)}finally{n!==null&&d.default.closeSync(n)}}function Qt(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT")&&ri(e))return;throw r}let t=d.default.fstatSync(n),i=v(e,n,t);j(e,i)}finally{n!==null&&d.default.closeSync(n)}si(S.dirname(e))}function go(e){let n;try{n=d.default.lstatSync(e)}catch(t){if(_(t,"ENOENT"))return;throw t}if(n.isSymbolicLink()||!n.isFile())throw new Error("credential-store replacement target must be a regular file");if(n.nlink!==1)throw new _e;Se(n,"credential-store replacement target")}function _o(e,n){for(let t=0;t<8;t+=1){let i=(0,Rn.randomBytes)(12).toString("hex"),r=S.join(e,`.${n}.${process.pid}.${i}.tmp`);try{return{fd:d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384),tempPath:r}}catch(o){if(_(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function ai(e,n){let t=0;for(;t<n.length;){let i=d.default.writeSync(e,n,t,n.length-t,null);if(!Number.isSafeInteger(i)||i<=0)throw new Error("credential-store temp file write made no progress");t+=i}}function si(e){if(process.platform==="win32")return;let n=null;try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)),d.default.fsyncSync(n)}catch{}finally{if(n!==null)try{d.default.closeSync(n)}catch{}}}function So(e,n){let t=Buffer.from(n,"utf8");if(t.length>Ue)throw new Error("credential-store file exceeds the maximum supported size");let i=S.dirname(e),r=S.basename(e),o=null,a=null,l=!1;try{let s=_o(i,r);o=s.fd,a=s.tempPath;let u=d.default.fstatSync(o);if((v(a,o,u).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");ai(o,t),d.default.fsyncSync(o),v(a,o,d.default.fstatSync(o));let p=o;o=null,d.default.closeSync(p),go(e),d.default.renameSync(a,e),l=!0}finally{if(o!==null)try{d.default.closeSync(o)}catch{}if(!l&&a!==null)try{d.default.unlinkSync(a)}catch{}}si(i)}function Ao(e){return S.join(S.dirname(e),`.${S.basename(e)}.lock`)}function ko(e){return S.join(S.dirname(e),`.${S.basename(e)}.lock-recovery`)}function To(e,n){if(n.size>Cn)return null;let t=Buffer.alloc(Cn+1),i=0;for(;i<t.length;){let o=d.default.readSync(e,t,i,t.length-i,null);if(o===0)break;i+=o}if(i>Cn)return null;let r;try{r=JSON.parse(t.subarray(0,i).toString("utf8"))}catch{return null}return typeof r!="object"||r===null||!Number.isSafeInteger(r.pid)||(r.pid??0)<=0||typeof r.nonce!="string"||!/^[a-f0-9]{24}$/.test(r.nonce??"")||typeof r.target!="string"?null:r}function j(e,n){let t=d.default.lstatSync(e);if(t.isSymbolicLink()||!t.isFile()||!Ae(t,n))throw new Error("credential-store lock changed while it was being inspected");Se(t,"credential-store lock"),d.default.unlinkSync(e)}function Zt(e,n){let t=null;try{try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(s){if(_(s,"ENOENT"))try{let u=d.default.lstatSync(e);throw u.isSymbolicLink()||!u.isFile()?new Error("credential-store lock must be a real regular file"):new b}catch(u){if(_(u,"ENOENT"))return{state:"absent"};throw u}throw s}let i=d.default.fstatSync(t),r=v(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=To(t,r);return{state:(o?.target===n&&o?!oi(o.pid):Date.now()-r.mtimeMs>=uo)?"stale":"active",stats:r}}finally{t!==null&&d.default.closeSync(t)}}function Lo(e,n){for(let t=0;t<8;t+=1){let i=(0,Rn.randomBytes)(12).toString("hex"),r=S.join(e,`.${n}.${process.pid}.${i}.lock-claim`),o={pid:process.pid,nonce:i,target:n},a=null;try{a=d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384);let l=d.default.fstatSync(a),s=v(r,a,l,{allowMultipleLinks:!0});return ai(a,Buffer.from(JSON.stringify(o),"utf8")),d.default.fsyncSync(a),{claimPath:r,metadata:o,stats:s}}catch(l){if(_(l,"EEXIST"))continue;try{d.default.unlinkSync(r)}catch{}throw l}finally{a!==null&&d.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function wo(e,n){let t;try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(i){throw _(i,"ENOENT")?new b:i}try{let i=d.default.fstatSync(t),r=v(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!Ae(r,n))throw new b;return{fd:t,lockPath:e,stats:r}}catch(i){throw d.default.closeSync(t),i}}function ei(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(t){if(_(t,"ENOENT"))try{let i=d.default.lstatSync(e);throw i.isSymbolicLink()||!i.isFile()?new Error("credential-store recovery gate must be a real regular file"):new b}catch(i){if(_(i,"ENOENT"))return!1;throw i}throw t}return v(e,n,d.default.fstatSync(n),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{n!==null&&d.default.closeSync(n)}}function bo(e){let n;try{n=d.default.openSync(e,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_RDWR|(d.default.constants.O_NOFOLLOW??0),384)}catch(i){if(_(i,"EEXIST"))return null;throw i}let t=null;try{t=d.default.fstatSync(n);let i=v(e,n,t,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:n,lockPath:e,stats:i}}catch(i){if(t!==null)try{j(e,t)}catch{}throw d.default.closeSync(n),i}}function K(e,n){if(Date.now()>=e)throw n?new Error("credential-store recovery gate remained present past the bounded wait; a previous lock reclaimer may have crashed, so automatic recovery is intentionally disabled and manual inspection/removal is required"):new Error("credential-store lock remained busy past the bounded wait");mo(co)}function ni(e){let n=S.dirname(e),t=S.basename(e),i=Ao(e),r=ko(e),o=Lo(n,t),a=Date.now()+lo,l=!1,s=!1,u=null,f;try{for(;u===null;)try{if(ei(r)){K(a,!0);continue}d.default.linkSync(o.claimPath,i),s=!0,u=wo(i,o.stats),l=!0}catch(p){if(s&&!l){try{j(i,o.stats)}catch{}s=!1}if(p instanceof b){K(a,!1);continue}if(!_(p,"EEXIST"))throw p;let y;try{y=Zt(i,t)}catch(g){if(g instanceof b){K(a,!1);continue}throw g}if(y.state==="absent")continue;if(y.state==="stale"){let g;try{g=bo(r)}catch(A){if(A instanceof b){K(a,!1);continue}throw A}if(g!==null){try{let A;try{A=Zt(i,t)}catch(C){if(C instanceof b){K(a,!1);continue}throw C}A.state==="stale"&&j(i,A.stats)}finally{On(g)}continue}}let m;try{m=ei(r)}catch(g){if(g instanceof b){K(a,!1);continue}throw g}K(a,m)}}catch(p){f=p}try{j(o.claimPath,o.stats)}catch(p){!_(p,"ENOENT")&&!l&&f===void 0&&(f=p)}if(f!==void 0)throw f;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function On(e){try{j(e.lockPath,e.stats)}finally{d.default.closeSync(e.fd)}}function Eo(e,n){let t=yo(n),i=new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.tmp$`).exec(e)??new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.lock-claim$`).exec(e);if(!i)return null;let r=Number(i[1]);return Number.isSafeInteger(r)&&r>0?r:null}function ti(e){let n=S.dirname(e),t=S.basename(e);for(let i of d.default.readdirSync(n)){let r=Eo(i,t);if(r===null||oi(r))continue;let o=S.join(n,i),a=null;try{try{a=d.default.openSync(o,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(u){if(_(u,"ENOENT")||_(u,"ELOOP"))continue;throw u}let l=d.default.fstatSync(a),s=d.default.lstatSync(o);if(!l.isFile()||s.isSymbolicLink()||!s.isFile()||!Ae(l,s))continue;try{Se(l,"credential-store orphan")}catch{continue}j(o,l)}catch(l){if(!_(l,"ENOENT"))throw l}finally{a!==null&&d.default.closeSync(a)}}}function ke(e,n,t){if(!De()){if(n.allowUnsupportedPlatformCleanup){if(n.createParent)throw q();if(!zt(e,!1))return t({read:()=>null,remove:()=>{},write:()=>{throw q()}});let a=ni(e);try{return ti(e),t({read:()=>Xt(e),remove:()=>Qt(e),write:()=>{throw q()}})}finally{On(a)}}if(!n.createParent){let o=!1;try{o=ri(e)}catch{throw q()}if(o)return t({read:()=>null,remove:()=>{},write:()=>{throw q()}})}throw q()}if(!zt(e,n.createParent))return t({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let r=ni(e);try{return ti(e),t({read:()=>Xt(e),remove:()=>Qt(e),write:o=>So(e,o)})}finally{On(r)}}var In="allscale-cli";function Un(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ci(e){return Un(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function Y(e){return new c("internal",`The session credential store in the ${e} exists but could not be read as valid credential data. Refusing to treat it as empty or overwrite it; session credentials may still remain on this machine.`)}function vn(){return new c("internal","The session credential store in the plaintext file has multiple hard links. Refusing to read, modify, or delete it because another directory entry may retain session credentials. Remove every extra hard link, then re-run the command. If you intentionally keep a deduplicated backup, revoke or rotate its credentials before treating logout as complete.")}function $e(){return new c("internal","The session credential store in the plaintext file could not be written safely. Any previous credential file was left unchanged.")}var V,xn=!1;function No(){return Dt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Co(e){if(typeof e!="object"||e===null||e.code!=="MODULE_NOT_FOUND")return!1;let n=e.message;return typeof n=="string"&&n.split(`
|
|
16
|
-
`,1)[0]==="Cannot find module 'keytar'"}function Oo(){if(V!==void 0)return V;if(No())return xn=!1,V=null,V;try{V=require("keytar"),xn=!1}catch(e){xn=!Co(e),V=null}return V}function di(){let e=De()?"Re-run with --insecure-storage (or set ALLSCALE_INSECURE_STORAGE=1) to use the owner-only plaintext credential file.":"Plaintext credential fallback is unavailable on Windows because owner-only ACLs cannot be verified; use Windows Credential Manager.";return new c("storage.unavailable","OS keychain could not be accessed on this system (keytar / libsecret may be unavailable, locked, or unusable). "+e+" Never silently downgrade in production.")}async function Pn(e){try{return await e()}catch{throw di()}}var Bn=class{constructor(n){this.keytar=n}keytar;kind="keychain";async read(n){let t=await Pn(()=>this.keytar.getPassword(In,n));if(t===null)return null;let i;try{i=JSON.parse(t)}catch{throw Y("OS keychain")}if(!ci(i))throw Y("OS keychain");return i}async get(n){return this.read(n)}async set(n,t){await this.read(n),await Pn(()=>this.keytar.setPassword(In,n,JSON.stringify(t)))}async delete(n){await this.read(n),await Pn(()=>this.keytar.deletePassword(In,n))}},Ro="credentials.json",Dn=class{kind="insecure-file";filePath;constructor(n){this.filePath=n??li.join(Nn(),Ro)}read(n){let t;try{t=n.read()}catch(r){throw Be(r)?vn():Y("plaintext file")}if(t===null)return{profiles:{}};let i;try{i=JSON.parse(t)}catch{throw Y("plaintext file")}if(!Un(i)||!Un(i.profiles))throw Y("plaintext file");return i}write(n,t){try{n.write(JSON.stringify(t,null,2))}catch(i){throw Be(i)?vn():$e()}}profileTokens(n,t){let i=n.profiles[t];if(i!==void 0){if(!ci(i))throw Y("plaintext file");return i}}async get(n){try{return ke(this.filePath,{createParent:!1},t=>this.profileTokens(this.read(t),n)??null)}catch(t){throw t instanceof c?t:Y("plaintext file")}}async set(n,t){try{ke(this.filePath,{createParent:!0},i=>{let r=this.read(i);this.profileTokens(r,n),r.profiles[n]=t,this.write(i,r)})}catch(i){throw i instanceof c?i:$e()}}async delete(n){try{ke(this.filePath,{createParent:!1},t=>{let i=this.read(t);this.profileTokens(i,n)!==void 0&&(delete i.profiles[n],this.write(t,i))})}catch(t){throw t instanceof c?t:$e()}}async clearProfile(n){try{return ke(this.filePath,{createParent:!1,allowUnsupportedPlatformCleanup:!0},t=>{let i=this.read(t);return this.profileTokens(i,n)===void 0?!1:(delete i.profiles[n],Object.keys(i.profiles).length===0?t.remove():this.write(t,i),!0)})}catch(t){throw t instanceof c?t:Be(t)?vn():$e()}}};function Fe(e){if(e.insecureStorage)return ii(),new Dn(e.insecureFilePath);let n=Oo();if(n)return new Bn(n);throw di()}var $n=class{kind="insecure-file";async get(n){return null}async set(n,t){throw new c("internal","NoopTokenStore: refusing to persist tokens \u2014 caller used --token override path.")}async delete(n){}};function Me(){return new $n}var Ge="allscale_access_token",Fn="allscale_refresh_token";function ui(e){return(typeof e.getSetCookie=="function"?e.getSetCookie():e.get("set-cookie")?[e.get("set-cookie")]:[]).map(t=>{let i=t.indexOf(";"),r=i===-1?t:t.slice(0,i),o=r.indexOf("=");return o===-1?null:{name:r.slice(0,o).trim(),value:r.slice(o+1).trim()}}).filter(t=>t!==null)}function Mn(e){return e.map(n=>`${n.name}=${n.value}`).join("; ")}function Gn(e,n){return e.find(t=>t.name===n)?.value??null}var pi=w(require("crypto")),fi=w(require("fs")),mi=w(require("path"));var Io="key-id",vo="x-allscale-cli-version",Kn="cli-1",xo="aScaLe_cli_obf_v1",Po="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function Uo(e,n){let t=Buffer.from(e,"base64"),i=Buffer.from(n,"utf8"),r=Buffer.alloc(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^i[o%i.length];return r.toString("utf8")}var Bo=Uo(Po,xo),yi=`Bearer ${Bo}`;function hi(e,n){let t=ln(e);if(t!==null)return n.find(i=>ln(i.base)===t)}function Do(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let n=ue();if(n.length>0){let i=hi(e,n);if(i)return i.key;if(F(e)){let r=process.env.ALLSCALE_SIGNING_KEY;return r&&r.trim().length>0?r:F(n[0].base)?n[0].key:void 0}return}let t=process.env.ALLSCALE_SIGNING_KEY;return t&&t.trim().length>0?t:void 0}function $o(e){{let i="cli-1".trim();if(i.length>0)return i}let n=ue();if(n.length>0){let i=e!==void 0?hi(e,n):void 0;if(i)return i.keyId;if(e!==void 0&&F(e)){let r=process.env.ALLSCALE_SIGNING_KEY;if(r&&r.trim().length>0){let o=process.env.ALLSCALE_SIGNING_KEY_ID;return o!==void 0?o.trim():Kn}if(!F(n[0].base))return Kn}return n[0].keyId}let t=process.env.ALLSCALE_SIGNING_KEY_ID;return t!==void 0?t.trim():Kn}function Fo(){return"1.0.2"}function Mo(){return new c("signing.key_unavailable","No request-signing key is available for this destination in this build. Published builds embed one at publish time; when running from source or an internal build, set ALLSCALE_SIGNING_KEY + ALLSCALE_BUILD_API_BASE (or ALLSCALE_BUILD_PAIRS for more than one environment) in the environment.")}function qn(e,n){let t=Do(n);if(!t)throw Mo();let i=$o(n),r=Math.floor(Date.now()/1e3).toString(),o=pi.createHash("sha256").update(`${t}${r}${e}`).digest("hex"),a={timestamp:r,"secret-key":o,[vo]:Fo()};return i.length>0&&(a[Io]=i),a}function gi(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function Go(e,n={}){let t;try{t=Gt(Oe())}catch{return}if(!(t.length===0||t.includes(e)))return new c("auth.unknown_profile",kt(e)+(n.messageSuffix??""),{profile:e})}function Ke(e){if(e.profileExplicit){let n=Go(e.profile);if(n)return n}return new c("auth.no_token",At(e.profile))}var Ko=500,qo=8,_i=100;function jn(e,n=0){if(n>qo)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,_i),i=t.map(r=>jn(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null);for(let[i,r]of Object.entries(e).slice(0,_i))t[i]=be(i)?"<redacted>":jn(r,n+1);return t}return e}function jo(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function Si(e,n=Ko){let t=jo(e),i=t===void 0?we(e):JSON.stringify(jn(t));return Ee(i,n)}var Vn=256*1024,qe=class extends c{constructor(n,t,i="backend-envelope"){let r=i==="successful-query",o=i==="successful-mutation";super(r?"transport.response_too_large":"backend.internal",r?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so it was not parsed. For list commands, request fewer rows by removing --all or using --input/--limit pagination, and reduce --select when possible; for other commands, contact support.`:o?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so its result was not parsed. The operation may already have completed; inspect authoritative state before retrying.`:`API response body exceeded the ${t}-byte safety limit and was not parsed.`,{status:n,max_body_bytes:t,...o?{outcome_ambiguous:!0}:{}}),this.name="ResponseBodyTooLargeError"}},je=class extends Error{status;timeoutMs;constructor(n,t){super(`API response body read exceeded its ${t}ms deadline.`),this.name="ResponseBodyReadTimeoutError",this.status=n,this.timeoutMs=t}};async function Yn(e,n,t={}){if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maxBytes must be a positive safe integer");if(t.timeoutMs!==void 0&&(!Number.isSafeInteger(t.timeoutMs)||t.timeoutMs<=0))throw new RangeError("timeoutMs must be a positive safe integer");let i=e.headers.get("content-length"),r=i!==null&&/^\d+$/.test(i.trim())?Number(i):void 0;if(r!==void 0&&r>n)throw e.body?.cancel().catch(()=>{}),new qe(e.status,n,t.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),a=[],l=0,s,u=t.timeoutMs,f=u===void 0?void 0:new Promise((p,y)=>{s=setTimeout(()=>{y(new je(e.status,u))},u),s.unref?.()});try{for(;;){let p=o.read(),{done:y,value:m}=f?await Promise.race([p,f]):await p;if(y)break;if(l+=m.byteLength,l>n)throw o.cancel().catch(()=>{}),new qe(e.status,n,t.oversizeKind);a.push(Buffer.from(m))}}catch(p){throw p instanceof je&&o.cancel(p).catch(()=>{}),p}finally{s!==void 0&&clearTimeout(s);try{o.releaseLock()}catch{}}return Buffer.concat(a,l).toString("utf8")}var Vo="X-AllScale-Api-Key",Yo=3e4,Jo=32*1024*1024,Ho=4*1024*1024;function Wo(e,n){let t=new AbortController,i=!1,r=()=>{t.abort(e?.reason)};e?.aborted?r():e?.addEventListener("abort",r,{once:!0});let o=setTimeout(()=>{i=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>i,dispose:()=>{clearTimeout(o),e?.removeEventListener("abort",r)}}}function zo(e,n){return n?n.aborted?Promise.reject(Object.assign(new Error("The operation was aborted"),{name:"AbortError"})):new Promise((t,i)=>{let r=()=>{i(Object.assign(new Error("The operation was aborted"),{name:"AbortError"}))};n.addEventListener("abort",r,{once:!0}),e.then(t,i).finally(()=>{n.removeEventListener("abort",r)})}):e}function Xo(e,n){if(!(e<300||e>=400))throw new c("transport.network",`API returned HTTP ${e} (a redirect) for ${D(n||"the request")}. The CLI does NOT follow redirects on credential-bearing requests \u2014 a cross-origin hop could re-send credentials and the request body to the new host. Check that --api-base / ALLSCALE_API_BASE points at the API origin directly and that no proxy is rewriting it.`,{status:e})}async function wi(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Xo(e.status,e.url)}}var Ai="--dns-result-order=ipv4first";async function Ve(e,n){if(e.status!==403)return;let t=e.headers.get("content-type")?.toLowerCase()??"",i=e.headers.get("cf-ray")??"",r=e.headers.get("cf-mitigated")?.trim().toLowerCase()==="challenge",o=t.includes("text/html"),a=n?.slice(0,4096)??"",l=/^\s*(?:<!doctype\s+html|<html\b)/i.test(a),s=/cf-error-details|\/cdn-cgi\/(?:challenge-platform|styles\/cf\.errors)|sorry,\s*you have been blocked|attention required[^<]{0,160}cloudflare|cloudflare ray id|error\s*(?:code\s*)?1020/i.test(a);if(!((o||l)&&(r||n!==void 0&&s)))return;if(n===void 0)try{e.body?.cancel().catch(()=>{})}catch{}let f=/^[A-Za-z0-9-]{1,128}$/.test(i)?i:void 0;throw new c("transport.network",`Cloudflare blocked this request before it reached the AllScale API (HTTP 403). This can happen when the release edge accepts IPv4 but rejects IPv6. Retry with NODE_OPTIONS=${Ai} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...f?{cf_ray:f}:{},ipv4_workaround:`NODE_OPTIONS=${Ai}`})}var J=class{constructor(n){this.opts=n}opts;refreshInFlight=null;async requestWithMetadata(n){return this.requestInternal(n,{withMetadata:!0})}async request(n){return this.requestInternal(n,{withMetadata:!1})}async requestInternal(n,t){let i=n.timeoutMs??this.opts.requestTimeoutMs??Yo;if(!Number.isFinite(i)||i<1)throw new c("input.invalid","HTTP request timeout must be a positive number of milliseconds.");ae(this.opts.apiBase),Ie(this.opts.apiBase);let r=this.opts.override?{access_token:this.opts.override.access_token,refresh_token:this.opts.override.refresh_token??""}:await this.opts.tokenStore.get(this.opts.profile),o=Wo(n.signal,i);try{return await this.requestWithinDeadline({...n,signal:o.signal},t,r)}catch(a){throw o.timedOut()?new c("transport.timeout",`Request to ${D(new URL(n.path,this.opts.apiBase).toString())} timed out after ${i}ms.`,{timeout_ms:i}):n.signal?.aborted&&!(a instanceof c)?new c("transport.network",`Request to ${D(new URL(n.path,this.opts.apiBase).toString())} was aborted by the caller.`):a}finally{o.dispose()}}async requestWithinDeadline(n,t,i){let r=new URL(n.path,this.opts.apiBase).toString();jt(this.opts.apiBase,r);let o=i?.agent_key,a=n.auth??"auto",l=bi(n.path),s=a==="required"?!0:a==="none"?!1:ea(n.path);if((l||a==="required")&&!n._isRefresh&&!this.opts.override&&!i?.access_token&&!o)throw Ke({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let u=gi(n.body),f=!!o||!!i?.access_token;s&&f&&!this.opts.override&&Re(this.opts.apiBase,i?.api_base);let p=this.buildHeaders({attachAuth:s&&f,bodyForSig:u,tokens:i,extra:n.headers}),y=Date.now();k({type:"request",method:n.method??"GET",url:r,...n._isRefresh?{refresh:!0}:{}});let m;try{m=await fetch(r,{method:n.method??"GET",headers:p,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(A){throw new c("transport.network",`Network error contacting ${D(r)}: ${A instanceof Error?A.message:String(A)}`)}if(k({type:"response",status:m.status,durationMs:Date.now()-y}),s&&!!i?.access_token&&!o&&m.status===401&&!n._isRefresh&&!this.opts.override){let A=await zo(this.refreshSingleFlight(),n.signal),C=this.buildHeaders({attachAuth:s&&!!A.access_token,bodyForSig:u,tokens:A,extra:n.headers}),O=Date.now();k({type:"request",method:n.method??"GET",url:r});let P;try{P=await fetch(r,{method:n.method??"GET",headers:C,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(U){throw new c("transport.network",`Network error contacting ${D(r)} on refresh-retry: ${U instanceof Error?U.message:String(U)}`)}return k({type:"response",status:P.status,durationMs:Date.now()-O}),ki(P,{withMetadata:t.withMetadata,authBearing:s,responseKind:Ti(n)})}return ki(m,{withMetadata:t.withMetadata,authBearing:s&&f,agentKeyAuth:s&&!!o,responseKind:Ti(n)})}buildHeaders(n){let i={Accept:"application/json","Content-Type":"application/json",...qn(n.bodyForSig,this.opts.apiBase),...n.extra};if(n.attachAuth){i.Authorization=yi;let r=n.tokens;if(r?.agent_key)return i[Vo]=r.agent_key,i;let o=r?.access_token;o&&(i.Cookie=Mn([{name:Ge,value:o}]))}return i}async refreshSingleFlight(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.doRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}async adoptConcurrentlyRotatedTokens(n){let t;try{t=await this.opts.tokenStore.get(this.opts.profile)}catch{return null}if(!t?.access_token||!t?.refresh_token||t.refresh_token===n.refresh_token)return null;if(Re(this.opts.apiBase,t.api_base),t.agent_key)throw new c("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than use it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");return t}async doRefresh(){let n=await this.opts.tokenStore.get(this.opts.profile);if(!n?.access_token||!n?.refresh_token)throw new c("auth.token_expired",`No refresh token available; log in again \u2014 ${Le()}.`);if(Re(this.opts.apiBase,n.api_base),n.agent_key)throw new c("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than overwrite it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");let t=new URL("/api/public/auth/refresh_token",this.opts.apiBase).toString(),i=Mn([{name:Ge,value:n.access_token},{name:Fn,value:n.refresh_token}]),r=qn("",this.opts.apiBase);k({type:"request",method:"POST",url:t,refresh:!0});let o=new AbortController,a=!1,l=setTimeout(()=>{a=!0,o.abort()},1e4),s;try{s=await fetch(t,{method:"POST",headers:{Accept:"application/json",Cookie:i,...r},signal:o.signal,redirect:"manual"})}catch(m){throw k({type:"refresh",ok:!1}),new c("transport.network",a&&m instanceof Error&&m.name==="AbortError"?`Token refresh against ${D(t)} timed out after 10s with no response.`:`Network error during token refresh against ${D(t)}: ${m instanceof Error?m.message:String(m)}`)}finally{clearTimeout(l)}k({type:"response",status:s.status,durationMs:0});try{await wi(s)}catch(m){throw k({type:"refresh",ok:!1}),m}if(s.status!==200){let m=null;try{await Ve(s);let g=await oa(s);await Ve(s,g),Ni(s.status,g),s.status===401&&(m=await this.adoptConcurrentlyRotatedTokens(n))}catch(g){throw k({type:"refresh",ok:!1}),g}if(m)return k({type:"refresh",ok:!0,adopted:!0}),m;throw k({type:"refresh",ok:!1}),new c("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${Le()}.`,{status:s.status})}let u=ui(s.headers),f=Gn(u,Ge),p=Gn(u,Fn);if(!f||!p)throw k({type:"refresh",ok:!1}),new c("auth.token_expired","Refresh response did not include new access/refresh cookies.");let y={...n,access_token:f,refresh_token:p};return await this.opts.tokenStore.set(this.opts.profile,y),k({type:"refresh",ok:!0}),y}},Qo=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function bi(e){let n=e.split(/[?#]/,1)[0];return Qo.some(t=>n===t||n.startsWith(`${t}/`))}var Zo=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function Jn(e){let n=e.split(/[?#]/,1)[0];return Zo.some(t=>t.test(n))}function ea(e){return bi(e)||Jn(e)}async function ki(e,n={}){await wi(e);let t=e.status>=200&&e.status<300;t||await Ve(e);let i=n.responseKind??"mutation",o=await Yn(e,t?i==="query"?Jo:Ho:Vn,{oversizeKind:t?i==="query"?"successful-query":"successful-mutation":"backend-envelope"});t||await Ve(e,o);let a=null;if(o.length>0)try{a=JSON.parse(o)}catch{a={raw:o}}if(e.status>=200&&e.status<300){if(n.withMetadata){let s={};return e.headers.forEach((u,f)=>{s[f]=u}),{status:e.status,headers:s,body:a}}return a}let l=aa(a)??`HTTP ${e.status}`;if(Ni(e.status,a),ia(e.status,a,n),e.status===401){if(n.agentKeyAuth)throw new c("auth.token_expired","Agent key was rejected (expired or revoked). Re-run `allscale device-login` to mint a new scoped key.",{status:401,body:a});let s=n.authBearing?"auth.token_expired":"input.invalid";throw new c(s,l,{status:401,body:a})}throw e.status===403?new c("auth.permission_denied",l,{status:403,body:a}):e.status===404?new c("not_found",l,{status:404,body:a}):e.status===429?new c("rate_limited",l,{status:429,body:a}):e.status>=500?new c("backend.internal",l,{status:e.status,body:a}):new c("input.invalid",l,{status:e.status,body:a})}function Ti(e){if(e.responseKind)return e.responseKind;let n=(e.method??"GET").toUpperCase();return n==="GET"||n==="HEAD"?"query":"mutation"}var na=2014,Li=2004;function Ei(e,n){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;let i=t.code;return i===n||i===String(n)}function ta(e){return Ei(e,na)}function ia(e,n,t){if(!(e>=200&&e<300)&&t.authBearing&&!(e===401&&t.agentKeyAuth)&&Ei(n,Li))throw new c("auth.token_expired",`The API rejected this credential as invalid. Re-authenticate with ${Le()} and retry. If that does not help, upgrade the CLI \u2014 the API may have rotated the client credential this build carries.`,{status:e,backend_code:Li})}var ra=1e4;async function oa(e,n=ra){if(e.status>=200&&e.status<300)return"";try{return await Yn(e,Vn,{timeoutMs:n})}catch{return""}}function Ni(e,n){if(!(e>=200&&e<300)&&ta(n))throw new c("auth.signature_rejected","The AllScale API rejected this CLI build's request signing key. Download the latest version \u2014 `npm install -g @allscale/cli@latest` \u2014 and retry: retiring an old signing key is how a release is made mandatory. If you are already on the latest version, this build's key row is missing or misprovisioned on the backend \u2014 contact AllScale support. Re-logging in will not help either way; the key ships inside the CLI build itself.",{status:e,body:typeof n=="string"?Si(n):n})}function aa(e){if(!e||typeof e!="object")return;let n=e;if(typeof n.message=="string")return n.message;if(typeof n.detail=="string")return n.detail;if(Array.isArray(n.detail))return JSON.stringify(n.detail)}var sa=/^\/(api\/)?(v1\/)?public\//;function Ci(e,n={}){let t=typeof n.pathHint=="string"?n.pathHint:"",i=t&&sa.test(t),r=t&&Jn(t),o=i&&!r&&!n.forceAuth;if(e.token)return new J({apiBase:e.apiBase,tokenStore:Me(),profile:e.profile,profileExplicit:e.profileExplicit,override:{access_token:e.token}});if(o)return new J({apiBase:e.apiBase,tokenStore:Me(),profile:e.profile,profileExplicit:e.profileExplicit});try{return new J({apiBase:e.apiBase,tokenStore:Fe({insecureStorage:e.insecureStorage}),profile:e.profile,profileExplicit:e.profileExplicit})}catch(a){if(r)return new J({apiBase:e.apiBase,tokenStore:Me(),profile:e.profile,profileExplicit:e.profileExplicit});throw a}}var Ye=[{name:"create_claim_link",kind:"mutation",description:"Create a single App claim link. Returns the pending link, funding address, exact deposit total, and bearer claim URL. The link becomes available after the sender's deposit is confirmed. No claim-back.",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateClaimLinkInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"CreateClaimLinkResult",ofType:null}},deprecated:null},{name:"create_contact",kind:"mutation",description:"create a new contact",args:[{name:"create_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateContactInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"create_payment",kind:"mutation",description:"create a new payment",args:[{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreatePaymentInput",ofType:null}},defaultValue:null},{name:"wallet_ids",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"create_store",kind:"mutation",description:"create store",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateStoreInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"StoreCreateResult",ofType:null}},deprecated:null},{name:"update_payment",kind:"mutation",description:"update an existing payment status by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"UpdatePaymentInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"activities",kind:"query",description:"Get current user's activity list with multi-dimensional filters (type, status, contact, wallet, time range, amount range)",args:[{name:"filter_input",description:null,type:{kind:"INPUT_OBJECT",name:"ActivityFilterInput",ofType:null},defaultValue:"null"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"20"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItemPaginatedResponse",ofType:null}},deprecated:null},{name:"auto_payout_session_status",kind:"query",description:"Return the current merchant auto-payout status, expiry, total/used/remaining USD cap, per-transaction limit, and authorized chain/token pairs. Merchants without an active setup receive provisioned=false with null money/expiry fields and no pairs.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AutoPayoutSessionStatus",ofType:null}},deprecated:null},{name:"business",kind:"query",description:"get one business by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Business",ofType:null}},deprecated:null},{name:"business_contact_by_email",kind:"query",description:"Look up the contact card of the business whose login email is given. Used to fill the invoice header's From: block with the same name/email/phone the web editor shows.",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"BusinessContact",ofType:null}},deprecated:null},{name:"business_transaction_records",kind:"query",description:"get transaction records for business",args:[{name:"direction",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_type",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"business_wallets",kind:"query",description:"List the CALLER'S OWN non-custodial wallets (id, chain, address, coin balances). Takes no business id \u2014 the owner is derived from the authenticated identity, so there is no caller-supplied id to mismatch and no way to read another merchant's wallets. Returns [] when the account has no wallet yet.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"WalletEmbedded",ofType:null}}}},deprecated:null},{name:"claim_link",kind:"query",description:"Get one of the caller's own claim links by id (sender surface). A non-owned or unknown id returns CLAIM_LINK_NOT_AVAILABLE \u2014 no existence leak.",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},deprecated:null},{name:"contact",kind:"query",description:"get one contact by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contact_by_email",kind:"query",description:"get one contact by it's email",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contacts",kind:"query",description:"get multi contacts by owner business id",args:[{name:"owner_business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ContactPaginatedResponse",ofType:null}},deprecated:null},{name:"my_claim_links",kind:"query",description:"List the caller's claim links, newest first. Optional status and link_source filters narrow the results; query_input controls pagination, ordering, and the created_at time range.",args:[{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"link_source",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkPaginatedResponse",ofType:null}},deprecated:null},{name:"my_transactions",kind:"query",description:"get one user's successful transactions by query",args:[{name:"query_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"payment",kind:"query",description:"get one payment by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"payments",kind:"query",description:"All payments by business ID as sender or recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"recipient_payments",kind:"query",description:"Get multiple payments by business ID as recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"sender_payments",kind:"query",description:"Get multiple payments by business ID as sender",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"transaction",kind:"query",description:"get one transaction by id_str",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}},deprecated:null}],$=[{name:"ActivityFilterInput",kind:"INPUT",description:null,inputFields:[{name:"transaction_types",description:"Filter by transaction types (OR): 1=PAYMENT, 2=REWARD, 3=WITHDRAWAL, 8=CHECKOUT_INTENT_EPHEMERAL, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 11=CHECKOUT_INTENT_EPHEMERAL_REFUND, 13=CHECKOUT_INTENT_EPHEMERAL_NET_INCOME, 14=CLAIM_LINK",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"transaction_statuses",description:"Filter by transaction statuses (OR): 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"payment_statuses",description:"Filter by payment statuses (OR): -4=OVERDUE, -1=FAILED, 0=DRAFT, 1=SENT, 2=ACKNOWLEDGED, 3=PROCESSING, 10=PAID",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"withdraw_statuses",description:"Filter by withdraw statuses (OR): -4=CANCELED, -1=FAILED, 1=CREATED, 20=CONFIRMED",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"directions",description:"Filter by transaction direction (OR): 1=INFLOW, -1=OUTFLOW",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"contact_keyword",description:"Fuzzy search by contact name/email or store name. OR relationship with wallet_address.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"wallet_address",description:"Fuzzy search by counterparty wallet address (tx_from/tx_to). OR relationship with contact_keyword.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"start_time",description:"Filter transactions after this time, ISO8601 format (e.g. 2024-01-01T00:00:00.000Z)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"end_time",description:"Filter transactions before this time, ISO8601 format",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"min_amount",description:"Filter transactions with amount >= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"max_amount",description:"Filter transactions with amount <= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"is_claim_link",description:"When true, return only claim-link activity: a receiver's claim (an ON_CHAIN_TX tagged with claim_link_id) OR a sender's CLAIM_LINK row (single claim_link_id / batch claim_link_batch_id). Matched by claim-link linkage presence, NOT transaction_types \u2014 a receiver's claim shares transaction_type=ON_CHAIN_TX(10) with a plain deposit, so it cannot be selected by type alone (bug 6935616).",type:{kind:"SCALAR",name:"Boolean",ofType:null},defaultValue:"null"}]},{name:"ActivityItem",kind:"OBJECT",description:null,fields:[{name:"transaction_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Transaction record ID"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Transaction amount in cryptocurrency"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Transaction amount in fiat cents"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"When the transaction occurred on-chain"},{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Record creation time in UTC"},{name:"transaction_status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Status: 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked payment ID for PAYMENT type transactions"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Type: 1=PAYMENT, 2=REWARD, 3=SEND, 4=SERVICE_FEE, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 14=CLAIM_LINK"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Direction: 1=INFLOW (received), -1=OUTFLOW (sent)"},{name:"wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Counterparty wallet address (sender if INFLOW, recipient if OUTFLOW)"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"On-chain transaction hash"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Blockchain network type"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Block number of the on-chain transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"User-provided memo or notes"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Cryptocurrency type (e.g. USDT)"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Fiat currency type (e.g. USD, CNY)"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee = network_fee + service_fee"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"On-chain gas/network fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"AllScale platform service fee"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Counterparty's business ID if they are an AllScale user"},{name:"claim_link_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked claim link ID for CLAIM_LINK type transactions"}]},{name:"ActivityItemPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItem",ofType:null}}}},description:null}]},{name:"AuthorizedPolicyPair",kind:"OBJECT",description:null,fields:[{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain identified by its BlockChainType value (for example BASE = 5) \u2014 not the EIP-155 chain id."},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Stablecoin symbol: USDT or USDC"}]},{name:"AutoPayoutSessionStatus",kind:"OBJECT",description:null,fields:[{name:"provisioned",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether auto-payout setup has been completed for this merchant."},{name:"active",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"True iff provisioned AND the session has not expired (the runtime auto-pay gate)"},{name:"session_expires_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"Session expiry (drives the countdown); null when not provisioned"},{name:"total_cap_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified session total cap in USD (decimal string); null when not provisioned"},{name:"used_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Cumulative USD spent (reserved + committed) this session (decimal string); populated only for an ACTIVE session, else null"},{name:"remaining_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"max(0, total_cap - used) in USD (decimal string); populated only for an ACTIVE session, else null"},{name:"per_transaction_limit",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified single-transaction limit (token-unit decimal string, stablecoin $ 1:1) recorded when auto-payout is enabled; null when not provisioned or when recorded entries have different limits. Retained after a session expires, so it still reports what was recorded."},{name:"authorized_pairs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AuthorizedPolicyPair",ofType:null}}}},description:"The (chain, stable-coin) pairs the merchant authorized when enabling auto-payout; empty when auto-payout was never provisioned. Retained after a session expires, so it still reports what was authorized."},{name:"sponsor_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Lowercased sponsor address used to validate authorized payouts. Populated whether or not auto-payout is provisioned, so it is readable while enabling; null when unavailable."}]},{name:"Business",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"user name"},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"email of the user"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"description of the user"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the business"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address field for business"},{name:"country",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"country code of business"},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"contact name of business"},{name:"contact_avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact avatar url of business"},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact phone of business"},{name:"avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"avatar url of business"},{name:"default_currency",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"default currency for business"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the business"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax id of the business"},{name:"about",type:{kind:"SCALAR",name:"String",ofType:null},description:"about of the business, can be changed by business"},{name:"business_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"business type"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of accepted stablecoins for invoices (StableCoinFlag)"},{name:"employee_count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"total active employees in the business"}]},{name:"BusinessContact",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Display name of the business's user account."},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Login email of the business's user account."},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Contact person the business presents on its invoices. Preferred over `name` when both are set."},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"Contact phone the business presents on its invoices. Null when the business has not set one."}]},{name:"ClaimLink",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim link id"},{name:"business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"sender business that owns the link"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"ClaimLinkStatus lifecycle state"},{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount, decimal string in token units"},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"stablecoin symbol, e.g. USDT / USDC"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"BlockChainType the link is locked to"},{name:"sender_display_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name shown to the receiver (person or Store name)"},{name:"sender_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional message shown on the claim page"},{name:"receiver_email",type:{kind:"SCALAR",name:"String",ofType:null},description:"receiver email, if the sender supplied one"},{name:"reference_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"Optional merchant-supplied reference identifier."},{name:"expected_deposit_total",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the expected POOL balance (principal). The sender's gross outlay is the fee breakdown's total"},{name:"service_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"AllScale service fee fixed when the claim link is created; null when not applicable."},{name:"network_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"Network fee fixed when the claim link is created; null when not applicable."},{name:"funded_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the deposit actually received at the pool wallet"},{name:"funded_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the confirming sender deposit"},{name:"expiry_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC; the resolved claim-window deadline (funded_at + the chosen window, default 14d); None until link_sent"},{name:"claimed_via",type:{kind:"SCALAR",name:"String",ofType:null},description:"how it was claimed: masked receiver email or 0x address"},{name:"claim_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the successful claim"},{name:"refund_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the expiry refund back to the sender"},{name:"refunded_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC when the expiry refund proved on-chain"},{name:"cancel_requested_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC timestamp set when the sender requests cancellation while a claim is in progress. The request stays pending until the in-flight payout resolves: it is cleared if that payout completes (the cancellation is moot and the link is claimed), and retained if the payout did not go through and the link is cancelled and refunded. Null therefore means either no mid-claim cancellation was requested, or one that was resolved by a completed payout."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL returned by create and single-link detail operations. The sender distributes this URL themselves; it is never emailed to the receiver. Null when unavailable, and always null on list operations \u2014 selecting it there returns the field as null rather than omitting it."}]},{name:"ClaimLinkFeeBreakdown",kind:"OBJECT",description:null,fields:[{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount the receiver gets, decimal string"},{name:"network_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"gas reserve = gas_shares \xD7 per_transfer_gas, decimal string"},{name:"service_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"AllScale service fee for the chain, decimal string"},{name:"total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"amount + network_fee + service_fee \u2014 what the sender pays"},{name:"per_transfer_gas",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"one transfer's gas in token units (echoed for audit)"},{name:"gas_shares",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Number of per_transfer_gas shares reserved; currently 2 for a single claim link."}]},{name:"ClaimLinkPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}}}},description:null}]},{name:"CoinBalanceEmbedded",kind:"OBJECT",description:null,fields:[{name:"coin_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Stablecoin held, as the numeric StableCoin value (1 = USDT, 2 = USDC). `wallet list` decorates each balance with the derived `coin_name`."},{name:"balance",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Decimal",ofType:null}},description:"Balance of the coin"}]},{name:"Contact",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"id of the contact"},{name:"owner_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"owner id of the contact"},{name:"contact_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"contact id if contact is allscale business"},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name of the contact"},{name:"binding_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"the way of binding an allscale business id to the contact, by email matching(1) or scan qrcode(2), etc."},{name:"email",type:{kind:"SCALAR",name:"String",ofType:null},description:"email of the contact"},{name:"evm_wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"evm wallet address of the contact"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax number of the contact"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address of the contact"},{name:"phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"phone number of the contact"},{name:"last_payment_created_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last payment date of the contact"},{name:"last_paid_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last successful pay date"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"Free-form description of the contact."},{name:"is_favourite",type:{kind:"SCALAR",name:"Boolean",ofType:null},description:"is favourite or not"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the contact"}]},{name:"ContactPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}}}},description:null}]},{name:"CreateClaimLinkInput",kind:"INPUT",description:null,inputFields:[{name:"amount",description:"claim amount, decimal string in token units (e.g. '10.5')",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"token_symbol",description:"stablecoin symbol: 'USDT' or 'USDC'",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"BlockChainType value the link is locked to (EVM only)",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"per_transfer_gas",description:"one ERC-20 transfer's gas in TOKEN units (decimal string); from the App's withdraw estimate",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"receiver_email",description:"optional receiver email \u2014 a SENDER-SIDE LABEL ONLY, recording who the link is meant for. AllScale does NOT email the receiver (no invite, no expiry reminder, no resend); the sender must distribute `claim_url` themselves.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_display_name",description:"name shown to the receiver (person or Store name)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_message",description:"optional message shown on the claim page (<= 200 chars)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"idempotency_key",description:"optional client retry-safety token; a retried create with the same key returns the existing link instead of a duplicate",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_window_seconds",description:"Optional positive claim-window duration in seconds. Defaults to 14 days. The window starts when funding is confirmed; after it expires, unclaimed funds are returned to the sender.",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreateClaimLinkResult",kind:"OBJECT",description:null,fields:[{name:"claim_link",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},description:"the newly created link (pending_deposit)"},{name:"claim_token",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Bearer claim token returned only when the claim link is created and never available again. Capture and store it securely immediately; it preserves claim authority when claim_url is unavailable."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL; null when no claim-page URL is configured."},{name:"pool_wallet_address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"ERC-4337 address the sender funds"},{name:"expected_deposit_total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"the expected POOL balance (principal), decimal string; the sender's gross outlay is the fee breakdown's total"},{name:"fees",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkFeeBreakdown",ofType:null}},description:"the frozen fee breakdown"}]},{name:"CreateContactInput",kind:"INPUT",description:null,inputFields:[{name:"owner_business_id",description:"owner id of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"name",description:"name of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"email",description:"email of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"evm_wallet_address",description:"evm wallet address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"address",description:"address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"phone",description:"phone number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_number",description:"tax number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"description",description:"Free-form description of the contact.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"binding_type",description:"binding type of the contact",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"sender_contact_id",description:"contact id of the payer/sender",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"payment_type",description:"payment type of the payment",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"accepted_stable_coins",description:"optional per-invoice bitflag (StableCoinFlag) overriding the recipient business's accepted_stable_coins setting",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"payment_extra_info",description:"payment extra info of the payment, JSON object string",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"currency",description:"currency of the payment, only if the payment_type is CURRENCY",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_cents",description:"amount of the payment in cents",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_coins",description:"amount of the payment in coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"html_template",description:"HTML template for the invoice",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_id",description:"optional taxpayer identification for the invoice",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"datetime the payment is due",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"},{name:"wallets",description:"list of wallets address",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"PlainWalletEmbeddedInput",ofType:null}}}},defaultValue:null}]},{name:"CreateStoreInput",kind:"INPUT",description:null,inputFields:[{name:"name",description:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"logo_url",description:"logo url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:null},{name:"business_id",description:"pay account business id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"type",description:"type of the store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"default_timeout_seconds",description:"default timeout seconds for checkout intents",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"3600"},{name:"swidge_enabled",description:"whether Swidge cross-chain checkout is enabled for this store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"claim_link_claim_notify_enabled",description:"Whether AllScale sends merchant claim-notification emails for this store; defaults to false.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"false"},{name:"description",description:"description",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"scopes",description:"permission scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:'["*"]'},{name:"ip_allowlist",description:"allowed IPs/CIDRs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:"[]"},{name:"is_sandbox",description:"Whether to create the store in sandbox mode.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"rate_limit_per_minute",description:"Optional request-per-minute limit; defaults to 300, and 0 uses the platform default.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"300"},{name:"replay_window_seconds",description:"override replay window seconds",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_webhook",description:"transaction webhook url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_link_webhook_url",description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"redirect_url",description:"Redirect URL used after payment completes.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"fee_rate",description:"fee rate",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"accepted_stable_coins",description:"bitflag of accepted stablecoins for checkout (StableCoinFlag); null inherits from business",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"Payment",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the payment"},{name:"recipient_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"business id of the payee/recipient"},{name:"sender_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the payer/sender"},{name:"sender_contact_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"contact id of the payer/sender"},{name:"payment_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"payment type of the payment"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of stablecoins accepted for this payment (StableCoinFlag). None on payments created before the multi-coin rollout."},{name:"payment_extra_info",type:{kind:"SCALAR",name:"String",ofType:null},description:"payment extra info of the payment, JSON object string"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the payment, only if the payment_type is CURRENCY"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the payment"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount of the payment in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount of the payment in coins"},{name:"invoice_url",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice url of the payment"},{name:"invoice_visible_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice visible id of the pdf"},{name:"tax_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional taxpayer identification for the invoice"},{name:"error_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"error message of the payment if status is failed"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the payment"},{name:"due_datetime",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"datetime the payment is due"},{name:"display_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"display amount of the payment"},{name:"encrypted_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Opaque payment identifier used in public payment links."}]},{name:"PaymentPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}}}},description:null}]},{name:"PlainWalletEmbeddedInput",kind:"INPUT",description:null,inputFields:[{name:"id_str",description:"Unique identifier for the wallet",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"Blockchain type of the address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"address",description:"Blockchain address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}]},{name:"QueryInput",kind:"INPUT",description:null,inputFields:[{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"order_by",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"},{name:"raw_filter_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:'"{}"'},{name:"created_at_lte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"created_at_gte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"}]},{name:"Store",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Unique store identifier."},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name"},{name:"type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the store"},{name:"scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},description:"permission scopes"},{name:"is_sandbox",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether this store uses sandbox mode."},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the store"},{name:"transaction_webhook",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction webhook url"},{name:"claim_link_webhook_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook."},{name:"redirect_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Redirect URL used after payment completes."}]},{name:"StoreCreateResult",kind:"OBJECT",description:null,fields:[{name:"store",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Store",ofType:null}},description:"store"},{name:"api_secret",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Store API secret returned only when the store is created and never available again. Capture and store it securely immediately."}]},{name:"Transaction",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the transaction record"},{name:"owner_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"owner user type of the record"},{name:"owner_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id that owns this transaction record"},{name:"owner_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id that owns this transaction record"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the transaction"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"direction of the transaction"},{name:"reference_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"reference type of the related record"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"payment id when reference_type is PAYMENT"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the counterparty"},{name:"counterparty_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id of the counterparty"},{name:"counterparty_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name of the counterparty"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"payment type if this is a payment transaction"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the transaction"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount in coins"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the transaction"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"actual transaction time"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"hash of the transaction"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block chain of the transaction"},{name:"tx_from",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction sender address"},{name:"tx_to",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction receiver address"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block number of the transaction"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee (network_fee + service_fee)"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Network/gas fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Allscale service fee (0.03%)"}]},{name:"TransactionPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}}}},description:null}]},{name:"UpdatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_business_id",description:"sender business id of the payer",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"new payment deadline for an OVERDUE invoice. Only an overdue invoice may be extended, and only FORWARD. Extending past now also revives the invoice (back to SENT/ACKNOWLEDGED) so buyers can pay again.",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"}]},{name:"WalletEmbedded",kind:"OBJECT",description:null,fields:[{name:"id_str",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet id"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain the wallet lives on, as the numeric BlockChainType value (NOT a name). `wallet list` decorates each wallet with the derived `chain_name` and `eip155_chain_id`."},{name:"address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet address"},{name:"coin_balances",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"OBJECT",name:"CoinBalanceEmbedded",ofType:null}}},description:"wallet balance"}]}];var Je=new Set(["SCALAR","ENUM"]),la=new Set(["password","password_hash","totp_secret","credential","credentials","private_key","encryption_key"]),ca=[/(^|_)password(_|$)/i,/(^|_)secret(_|$)/i,/(^|_)token(_|$)/i,/(^|_)api[_-]?key(_|$)/i,/(^|_)signing[_-]?key(_|$)/i,/(^|_)private[_-]?key(_|$)/i,/(^|_)credential(_|$)/i],da=new Set(["CreateClaimLinkResult.claim_token","StoreCreateResult.api_secret"]),ua=new Map([["StoreCreateResult.store",["id","name"]],["CreateClaimLinkResult.claim_link",["id","token_symbol","status"]]]),pa=new Set(["token_symbol"]),fa=new Set;function Hn(e,n){return fa.has(`${e}.${n}`)}function x(e){return pa.has(e.toLowerCase())?!1:la.has(e)?!0:ca.some(n=>n.test(e))}function ma(e,n){return da.has(`${e}.${n}`)}function Wn(e){return e.kind==="NON_NULL"&&e.ofType?`${Wn(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${Wn(e.ofType)}]`:e.name??"Unknown"}function N(e){let n=e;for(;n&&n.ofType;)n=n.ofType;return!n||!n.name?null:{kind:n.kind,name:n.name}}function zn(e,n){let t=n.find(a=>a.name===e);if(!t||t.kind==="SCALAR"||t.kind==="ENUM")return"";if(t.kind==="UNION")return"__typename";let i=t.fields??[];if(i.length===0)return"";let r=[],o=!1;for(let a of i){let l=N(a.type);if(!l)continue;if(Je.has(l.kind)){if(x(a.name)&&!ma(e,a.name)||Hn(e,a.name))continue;r.push(a.name);continue}let s=ua.get(`${e}.${a.name}`);if(s){let u=n.find(m=>m.name===l.name),f=new Set((u?.fields??[]).filter(m=>{let g=N(m.type);return g!==null&&Je.has(g.kind)&&!x(m.name)}).map(m=>m.name)),p=s.filter(m=>!f.has(m));if(p.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${p.join(", ")}] that are not selectable scalars on ${l.name}; fix the entry or the public registry.`);let y=s.filter(m=>Hn(l.name,m));if(y.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${y.join(", ")}] that DEFAULT_SELECTION_EXCLUSIONS keeps out of default selections on ${l.name}; drop the field from the nested entry, or remove the exclusion if it is no longer true.`);r.push(`${a.name} { ${s.join(" ")} }`);continue}if(!o&&a.name==="items"&&a.type.kind==="NON_NULL"&&a.type.ofType?.kind==="LIST"){let u=ya(a.type)?.name;if(u){let f=ha(u,n);f&&r.push(`items { ${f} }`),o=!0}}}return r.length>0?r.join(" "):"__typename"}function ya(e){return N(e)}function ha(e,n){let t=n.find(o=>o.name===e);if(!t||t.kind==="UNION")return"__typename";let i=t.fields??[],r=[];for(let o of i){let a=N(o.type);if(a&&Je.has(a.kind)){if(x(o.name)||Hn(e,o.name))continue;r.push(o.name)}}return r.length>0?r.join(" "):"__typename"}function Oi(e,n,t){let i=ga(e.name),r=e.args.map(f=>{let p=Wn(f.type);return f.defaultValue!==null&&f.defaultValue!==void 0?`$${f.name}: ${p} = ${f.defaultValue}`:`$${f.name}: ${p}`}).join(", "),o=e.args.map(f=>`${f.name}: $${f.name}`).join(", "),a=r.length>0?`${e.kind} ${i}(${r})`:`${e.kind} ${i}`,l=o.length>0?`${e.name}(${o})`:e.name,s=N(e.returnType),u;if(s&&Je.has(s.kind))u=l;else{let f=t&&t.trim().length>0?t.trim():s&&zn(s.name,n)||"__typename";u=`${l} { ${f} }`}return`${a} { ${u} }`}function Ri(e,n){let i=e.args.filter(r=>r.type.kind==="NON_NULL"&&r.defaultValue===null).map(r=>r.name).filter(r=>!(r in n));return i.length===0?{ok:!0}:{ok:!1,missing:i}}function He(e,n,t){return e.find(i=>i.kind===n&&i.name===t)??null}function Ii(e){if(!e||typeof e!="object")return!1;let n=e.errors;return Array.isArray(n)&&n.length>0}function vi(e,n=3){let t=e.errors;return!Array.isArray(t)||t.length===0?"":t.slice(0,n).map(i=>typeof i=="object"&&i!==null&&typeof i.message=="string"?i.message:JSON.stringify(i)).join("; ")}function ga(e){return e.replace(/[^_0-9A-Za-z]/g,"_")}var _a=new Set;var Sa=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","claim_link:read_only","claim_link:all","transaction:read_only","transaction:all","store:read_only","store:all","wallet:read_only","wallet:all"]),Xn=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","transaction:read_only","wallet:read_only","wallet:all","claim_link:read_only","claim_link:all","store:read_only","store:all"]),Qn=new Set(["payroll","admin:user","admin:org","admin:audit"]);function We(e){let n=e.lastIndexOf(":");return n===-1?e:e.slice(0,n)}function Zn(e,n){if(e===n)return!0;let t=":read_only";return n.endsWith(t)&&e===`${n.slice(0,-t.length)}:all`}var Aa=new Set(["cli_op:all"]),ka=new Set([...Aa].map(We));var Ml=new Set([...[...Sa,...Xn,..._a].map(We),...Qn,...ka]);var Ta={payments:"invoice:read_only",payment:"invoice:read_only",sender_payments:"invoice:read_only",recipient_payments:"invoice:read_only",business_contact_by_email:"invoice:read_only",create_payment:"invoice:all",update_payment:"invoice:all",contact_by_email:"contact:read_only",contact:"contact:read_only",contacts:"contact:read_only",create_contact:"contact:all",transaction:"transaction:read_only",my_transactions:"transaction:read_only",business_transaction_records:"transaction:read_only",activities:"transaction:read_only",business_wallets:"wallet:read_only",business_invoice:"payroll:read_only",auto_payout_session_status:"store:read_only",create_store:"store:all",my_claim_links:"claim_link:read_only",claim_link:"claim_link:read_only",claim_link_fee_preview:"claim_link:read_only",claim_link_limits:"claim_link:read_only",create_claim_link:"claim_link:all",claim_link_funding_by_idempotency_key:"claim_link:all"},La={business:"the broad `business` query is default-denied for agent keys by design \u2014 no scope grants it, because allowing the entry point would expose every nested field of the Business type"},wa=/API key scope not granted:\s*requires\s+(.+?),\s*key has\s+(.+?)\.?\s*$/i,ba=/is not available to API keys/i,xi=/^[a-z_]+(?::[a-z_]+)*:[a-z_]+$/;function Pi(e){if(typeof e!="string")return;let n=wa.exec(e);if(!n)return;let t=n[1].trim(),i=n[2].trim(),r=ba.test(t),o=!r&&xi.test(t)?t:void 0,a;if(i.toLowerCase()==="none")a=[];else{let l=i.split(",").map(s=>s.trim()).filter(s=>xi.test(s));a=l.length>0?l:void 0}if(!(o===void 0&&!r))return{required:o,granted:a,notAvailableToKeys:r}}function Ui(e){let n=La[e];if(n!==void 0)return{ungrantableReason:n};let t=Ta[e];if(t!==void 0)return{scope:t}}function Bi(e){if(Qn.has(We(e)))return{kind:"ungrantable"};for(let n of Xn)if(Zn(n,e))return{kind:"approval_screen"};return{kind:"otp_login_only"}}var Ea=new Set([8100]),Na=new Set([...Ea,3e3,3200,3300,3400,3500,3600,4e3,4100,4200,4300,4400,4600,4700,4800,4900,4901,5e3,5200,5300,5400,5500,5600,6050,8300,8301,8302,8306]);function $i(e,n){let t=Fi(e),i={graphql_error_count:Ca(e.errors),...t===void 0?{}:{backend_code:t}};if(t===2102)throw Oa(e,n,i);if(t===429)throw new c("rate_limited",`GraphQL ${n.kind} '${n.operationName}' was rate limited. Retry after a backoff.`,i);if(t===1002)throw new c("auth.permission_denied",`The signed-in account is not permitted to perform GraphQL ${n.kind} '${n.operationName}'. This is a role or ownership restriction, not a missing agent-key scope \u2014 re-authorizing will not grant it.`,i);if(t!==void 0&&Na.has(t))throw new c("not_found",`GraphQL ${n.kind} '${n.operationName}' could not find the requested resource.`,i);if(Ii(e))throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' returned errors: ${vi(e)}`,i);if(t!==void 0)throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' failed with backend code ${t}.`,i)}function Fi(e){let n=Di(e.code);if(n!==void 0)return n;if(Array.isArray(e.errors))for(let t of e.errors){if(!t||typeof t!="object")continue;let i=t.extensions;if(!i||typeof i!="object")continue;let r=Di(i.code);if(r!==void 0)return r}}function Di(e){if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d+$/.test(e)){let n=Number(e);if(Number.isSafeInteger(n)&&n>0)return n}}function Ca(e){return Array.isArray(e)?e.length:e==null?0:1}function Oa(e,n,t){let i=`GraphQL ${n.kind} '${n.operationName}'`,r={...t,operation:n.operationName},o=Pi(Ra(e,Fi(e))),a=Ui(n.operationName),l=o?.notAvailableToKeys===!0,s=o?.required??a?.scope,u=o?.granted,f=u===void 0?"":` This key holds ${u.length>0?u.join(", "):"no scopes"}.`;if(l||a?.ungrantableReason!==void 0){let p=a?.ungrantableReason!==void 0?`: ${a.ungrantableReason}`:"";return new c("auth.permission_denied",`${i} is not available to agent keys${p}. Re-authorizing will NOT help \u2014 no scope grants it.${f} Use a command that does not need it, or perform this action in the AllScale dashboard.`,{...r,missing_scopes:[],...u===void 0?{}:{granted_scopes:u},ungrantable:!0})}if(s!==void 0){let p=Bi(s),y=p.kind==="ungrantable"?`\`${s}\` cannot be granted to any key (the backend clips this category to nothing), so re-authorizing will NOT help.`:p.kind==="approval_screen"?`Re-run \`allscale device-login\` and enable it on the approval screen, or \`${Q()}\` with \`--scopes ${s}\`.`:`The browser approval screen does not offer \`${s}\`, so \`device-login\` cannot grant it \u2014 use \`${Q()}\` with \`--scopes ${s}\`.`;return new c("auth.permission_denied",`The current agent key lacks \`${s}\`, required by ${i}.${f} ${y}`,{...r,missing_scopes:[s],...u===void 0?{}:{granted_scopes:u},...p.kind==="ungrantable"?{ungrantable:!0}:{}})}return new c("auth.permission_denied",`The current agent key does not have the scope required by ${i}.${f} Re-run \`allscale device-login\` (or \`${Q()}\`) and grant the required scope.`,r)}function Ra(e,n){let t=e.errors;if(typeof t=="string")return t;if(!Array.isArray(t))return"";let i=r=>{if(r===null||typeof r!="object")return;let o=r.message;return typeof o=="string"?o:void 0};if(n!==void 0)for(let r of t){if(r===null||typeof r!="object")continue;let o=r.extensions;if(!o||typeof o!="object")continue;let a=o.code;if(a===n||typeof a=="string"&&Number(a)===n){let s=i(r);if(s!==void 0)return s}}for(let r of t){let o=i(r);if(o!==void 0)return o}return""}async function ze(e,n,t,i,r={}){let o=He(Ye,n,t);if(!o)throw new c("input.invalid",`No ${n} named '${t}' in the schema. Run \`allscale operations --kind ${n}\` to list options.`);let a=Ri(o,i);if(!a.ok)throw new c("input.invalid",`Missing required variables for ${t}: ${a.missing.join(", ")}`,{required:a.missing});let l=Oi(o,$,r.selection);return Ia(e,{...r,kind:n,operationName:o.name,document:l,variables:i})}async function Ia(e,n){n.showDoc&&process.stderr.write(`${n.document}
|
|
17
|
-
`);let t=Ci(e),i=n.path??"/api/secure/graphql",r=await t.request({method:"POST",path:i,responseKind:n.kind,body:{query:n.document,...Object.keys(n.variables).length>0?{variables:n.variables}:{},operationName:n.operationName}});$i(r,{kind:n.kind,operationName:n.operationName});let o=r.data?.[n.operationName];return o===void 0?null:o}function va(e,n){try{return JSON.parse(e)}catch(t){throw new c("input.invalid",`${n} is not valid JSON: ${t.message}`)}}var xa=50;function Pa(e,n){if("raw_filter_str"in e)throw new c("input.invalid","--input must not contain 'raw_filter_str': it is a raw Mongo query document and the CLI refuses to pass one through. Use the typed QueryInput fields instead \u2014 created_at_gte / created_at_lte for creation-time bounds"+(n?`, or ${n}`:"")+".")}function Mi(e){if(typeof e.input=="string"&&e.input.length>0){let n=va(e.input,"--input");if(n===null||typeof n!="object"||Array.isArray(n))throw new c("input.invalid","--input must be a JSON object (the QueryInput shape).");let t=n;return Pa(t,e.typedAlternatives),t}return e.all?{limit:0}:{limit:xa}}var Gi="Override the default selection set with a GraphQL fragment.",Ki="Pass --show-doc to print the exact GraphQL document that gets sent.";function ji(...e){let n=Ua(...e);if(n.length===0)return`${Gi} ${Ki}`;let t=[];for(let a of n){let l=t.find(s=>s.typeName===a.typeName);l?l.labels.push(...a.labels):t.push({...a,labels:[...a.labels]})}let i=[Gi],r=n.length<e.length,o=t.length>1||r;for(let a of t){let l=o&&a.labels.length>0?`Default (${a.labels.join(", ")})`:"Default";a.preset&&i.push(`${l}: '${a.preset}'.`);for(let s of a.others){let u=s.example?` Object and list fields among them need their own sub-selection, e.g. --select '${s.example}'.`:"",f=s.hasSuppressedFields?" This list is not exhaustive \u2014 a deliberately broad credential-name filter withholds some fields from it.":"";if(s.fields.length===0){i.push(`Beyond the default, ${s.typeName} has further selectable fields, all withheld by a deliberately broad credential-name filter.`);continue}i.push(`Other selectable fields on ${s.typeName}: ${s.fields.join(", ")}.${u}${f}`)}}return i.push(Ki),i.join(" ")}function Ua(...e){return e.map(n=>{try{return Ba(n)}catch{return null}}).filter(n=>n!==null)}function Ba(e){let n=He(Ye,e.kind,e.name);if(!n)return null;let t=N(n.returnType);if(!t)return null;let i=e.preset?.trim();if(e.preset!==void 0&&!i)return null;let r=i??zn(t.name,$),o=$.find(y=>y.name===t.name),a=new Set(nt(r)),l=(o?.fields??[]).filter(y=>!a.has(y.name)),s=l.filter(y=>!x(y.name)),u=[],f=l.length-s.length;(s.length>0||f>0)&&u.push({typeName:t.name,fields:s.map(y=>y.name),example:qi(s,et(nt(r),t.name)),hasSuppressedFields:f>0});let p=Da(o,a,r);return p&&u.push({typeName:`${t.name}.${p.fieldName} (${p.typeName})`,fields:p.others.map(y=>y.name),example:qi(p.others,p.anchorField,p.fieldName,p.wrapperScalars),hasSuppressedFields:p.hasSuppressedFields}),{labels:e.label?[e.label]:[],typeName:t.name,preset:r,others:u}}function Da(e,n,t){let i=null;for(let r of e?.fields??[]){if(!n.has(r.name))continue;let o=N(r.type);if(!o||Xe.has(o.kind))continue;let a=$.find(p=>p.name===o.name);if(!a)continue;let l=nt($a(t,r.name)??""),s=new Set(l),u=(a.fields??[]).filter(p=>!s.has(p.name)),f=u.filter(p=>!x(p.name));if(f.length===0){u.length>0&&i===null&&(i={fieldName:r.name,typeName:o.name,others:[],hasSuppressedFields:!0,anchorField:et(l,o.name),wrapperScalars:[]});continue}return{fieldName:r.name,typeName:o.name,others:f,hasSuppressedFields:u.length>f.length,anchorField:et(l,o.name),wrapperScalars:(e?.fields??[]).filter(p=>{if(p.name===r.name||!n.has(p.name)||x(p.name))return!1;let y=N(p.type);return y!==null&&Xe.has(y.kind)}).map(p=>p.name)}}return i}function et(e,n){let t=$.find(r=>r.name===n),i=r=>{if(x(r))return!1;let o=(t?.fields??[]).find(l=>l.name===r),a=o?N(o.type):null;return a!==null&&Xe.has(a.kind)};return e.includes("id")&&i("id")?"id":e.find(i)??null}function qi(e,n,t,i=[]){for(let r of e){let o=N(r.type);if(!o)continue;let l=($.find(s=>s.name===o.name)?.fields??[]).filter(s=>{let u=N(s.type);return u!==null&&Xe.has(u.kind)}).map(s=>s.name).filter(s=>!x(s)).slice(0,2);if(l.length>0){let s=`${r.name} { ${l.join(" ")} }`,u=n?`${n} ${s}`:s;return t?[...i,`${t} { ${u} }`].join(" "):u}}return null}var Xe=new Set(["SCALAR","ENUM"]);function nt(e){let n=[],t=0;for(let i of Vi(e))i==="{"?t+=1:i==="}"?t=Math.max(0,t-1):t===0&&n.push(i);return n}function $a(e,n){let t=Vi(e),i=0;for(let r=0;r<t.length;r+=1){let o=t[r];if(o==="{"){i+=1;continue}if(o==="}"){i=Math.max(0,i-1);continue}if(i!==0||o!==n||t[r+1]!=="{")continue;let a=[],l=0;for(let s=r+1;s<t.length;s+=1){let u=t[s];if(u==="{"){if(l+=1,l===1)continue}else if(u==="}"&&(l-=1,l===0))return a.join(" ");a.push(u)}return a.join(" ")}return null}function Vi(e){return e.split(/([{}])/).flatMap(n=>n==="{"||n==="}"?[n]:n.split(/\s+/)).filter(n=>n.length>0)}async function Qe(e){if(e.token)return{kind:"override",accessToken:e.token};let t=await Fe({insecureStorage:e.insecureStorage}).get(e.profile),i=t?.api_base;return t?.agent_key?{kind:"agent",storedApiBase:i,businessId:tt(t.business_id),userEmail:tt(t.user_email),scopes:Fa(t.scopes)}:t?.access_token?{kind:"human",storedApiBase:i,accessToken:t.access_token,userEmail:tt(t.user_email)}:{kind:"none"}}function tt(e){return typeof e=="string"&&e.length>0?e:void 0}function Fa(e){if(!Array.isArray(e))return;let n=e.filter(t=>typeof t=="string"&&t.length>0);return n.length>0?n:void 0}function Ji(e){let n=e.split(".");if(n.length!==3)throw new c("auth.token_invalid","This token is not a JWT session. Agent API keys are not JWTs \u2014 this path needs a human session token.");let t;try{let i=Buffer.from(n[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");t=JSON.parse(i)}catch{throw Yi()}if(typeof t!="object"||t===null||Array.isArray(t))throw Yi();return t}function Yi(){return new c("auth.token_invalid","The provided token is not a valid JWT credential \u2014 its payload could not be decoded. Check the --token / ALLSCALE_TOKEN value, or re-authenticate to obtain a fresh session.")}async function it(e,n){if(typeof n=="string"&&n.length>0)return n;let t=await Qe(e);switch(t.kind){case"override":case"human":return Ga(t.accessToken);case"agent":if(t.businessId!==void 0)return t.businessId;throw new c("input.invalid","Agent-key sessions carry no JWT to derive the business id from \u2014 pass --business-id explicitly. (Re-run `allscale device-login` to store your business id automatically.)");case"none":throw Ke({profile:e.profile,profileExplicit:e.profileExplicit});default:return Ma(t)}}function Ma(e){throw new c("internal",`Unhandled credential kind: ${JSON.stringify(e.kind)}`)}function Ga(e){let n=Ji(e),t=typeof n.user_id=="string"?n.user_id:void 0;if(!t)throw new c("input.invalid","Could not infer --business-id from the cached JWT (no user_id claim). Pass --business-id explicitly.");return t}var Ka=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,9}))?\s*(Z|[+-]\d{2}:?\d{2})?)?$/i,rt="YYYY-MM-DDTHH:MM:SS.ffffffZ",Ze=`Accepts a date (2026-08-05), a naive datetime (2026-08-05T12:30:00, read as UTC), or an offset datetime (2026-08-05T20:30:00+08:00); the CLI converts to UTC and pads it to the backend's required ${rt}.`;function H(e,n){return new c("input.invalid",`${n} is not a datetime the CLI can read: '${e}'. ${Ze}`)}var qa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z$/,ja=/^(\d{4})-(\d{1,2})-( ?[1-9]|\d{1,2})T(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,6})Z$/;function Hi(e,n,t={}){let i=e.trim(),r=Ka.exec(i);if(!r)throw H(e,n);let[,o,a,l,s,u,f,p,y]=r,m=s===void 0,g=Number(o),A=Number(a),C=Number(l),O=m?0:Number(s),P=m?0:Number(u),U=m||f===void 0?0:Number(f);if(A<1||A>12||C<1||C>31||O>23||P>59||U>59)throw H(e,n);let st=m?"":p??"",se=st.padEnd(6,"0").slice(0,6),lt=/[1-9]/.test(st.slice(6)),nn=0;if(y!==void 0&&y.toUpperCase()!=="Z"){let ce=y.startsWith("-")?-1:1,B=y.slice(1).replace(":",""),dt=Number(B.slice(0,2)),ut=Number(B.slice(2,4));if(dt>23||ut>59)throw H(e,n);nn=ce*(dt*60+ut)}let le=Date.UTC(g,A-1,C,O,P,U)-nn*6e4;if(Number.isNaN(le))throw H(e,n);let tn=new Date(le+nn*6e4);if(tn.getUTCFullYear()!==g||tn.getUTCMonth()!==A-1||tn.getUTCDate()!==C)throw H(e,n);let ct=ce=>{let B=Number(se)+ce;B<0?(se="999999",le-=1e3):B>999999?(se="000000",le+=1e3):se=String(B).padStart(6,"0")};t.exclusive?lt||ct(-1):lt&&ct(1);let W=new Date(le),z=(ce,B=2)=>String(ce).padStart(B,"0");return`${z(W.getUTCFullYear(),4)}-${z(W.getUTCMonth()+1)}-${z(W.getUTCDate())}T${z(W.getUTCHours())}:${z(W.getUTCMinutes())}:${z(W.getUTCSeconds())}.${se}Z`}function Wi(e,n,t){let i={...e},r=[["from",t.lowerKey,!1],["to",t.upperKey,!0]];for(let[s,u,f]of r){let p=n[s];if(!(typeof p!="string"||p.length===0)){if(i[u]!==void 0&&i[u]!==null)throw new c("input.invalid",`--${s} conflicts with '${u}' already set in --input. Pass one or the other, not both.`);i[u]=Hi(p,`--${s}`,{exclusive:f})}}let o=s=>{if(typeof s!="string"||s.length===0)return;if(qa.test(s))return s;let u=ja.exec(s);if(u){let[,f,p,y,m,g,A,C]=u,O=(P,U=2)=>P.trim().padStart(U,"0");return`${f}-${O(p)}-${O(y)}T${O(m)}:${O(g)}:${O(A)}.${(C??"").padEnd(6,"0")}Z`}try{return Hi(s,"--input",{exclusive:!1})}catch{return}},a=o(i[t.lowerKey]),l=o(i[t.upperKey]);if(a!==void 0&&l!==void 0&&a>l)throw new c("input.invalid",`The ${t.rangeNoun} range is empty: the lower bound (${a}) is after the upper bound (${l}). Remember --to is EXCLUSIVE, so --from and --to may not name the same instant.`);return i}var Xi=new Map([["OVERDUE",-4],["FAILED",-1],["DRAFT",0],["SENT",1],["ACKNOWLEDGED",2],["PROCESSING",3],["PAID",10]]),Va=new Set(["CURRENCY","FIAT"]);function ot(){return[...Xi.keys()]}function Ya(e){let n=e.trim(),t=Xi.get(n.toUpperCase());if(t!==void 0)return t;if(/^-?\d+$/.test(n))return Number(n);throw new c("input.invalid",`--status '${e}' is not a known invoice status. Accepted: ${ot().join(", ")} (case-insensitive), or a raw integer.`)}function Ja(e){let n=e.trim();if(Va.has(n.toUpperCase()))return 0;let t=Jt(n);if(t!==null)return t;if(/^-?\d+$/.test(n))return Number(n);throw new c("input.invalid",`--payment-type '${e}' is not a known invoice currency. Accepted: CURRENCY (fiat), ${ve().join(", ")} (case-insensitive), or a raw integer.`)}function zi(e){let n=[...new Set(e)];return n.length===1?n[0]:{$in:n}}function Qi(e,n){let t=Wi(e,n,{lowerKey:"created_at_gte",upperKey:"created_at_lte",rangeNoun:"creation-date"}),i={};if(Array.isArray(n.status)&&n.status.length>0&&(i.status=zi(n.status.map(Ya))),Array.isArray(n["payment-type"])&&n["payment-type"].length>0&&(i.payment_type=zi(n["payment-type"].map(Ja))),typeof n.toContactId=="string"&&n.toContactId.length>0){if(!/^[0-9a-f]{24}$/i.test(n.toContactId))throw new c("backend.internal","contact_by_email returned a contact id that is not a plain ObjectId; refusing to build the --to-email filter from it.",{received:n.toContactId});i.sender_contact_id=n.toContactId}return Object.keys(i).length===0||(t.raw_filter_str=JSON.stringify(i)),t}var Ha="id email name address phone";function Wa(e){return e.startsWith("transport.")||e.startsWith("auth.")||e.startsWith("backend.")||e==="internal"||e==="rate_limited"}async function za(e,n,t={}){let i;try{i=await ze(e,"query","contact_by_email",{email:n},{selection:Ha,showDoc:!1})}catch(o){if(o instanceof c&&Wa(o.code))throw o;let a=o instanceof Error?o.message:String(o),l=t.notFoundMessage??`No contact found for "${n}". Re-run with \`--auto-create-contact\` (optionally \`--contact-name "<name>"\`) to create one, or pass the contact_id directly via --to-contact-id.`;throw new c("input.invalid",`${l}
|
|
18
|
-
Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.internal",`contact_by_email returned an unexpected shape for "${n}".`,{received:i});return r}async function Zi(e,n){let t=n.trim();if(t.length===0)throw new c("input.invalid","--to-email requires a non-empty email address.");return(await
|
|
14
|
+
`}var G=b(require("fs")),Mt=b(require("os")),wn=b(require("path")),En=b(require("@iarna/toml"));var qr=".allscale",Kr="config.toml";function Nn(){return wn.join(Mt.homedir(),qr)}function jr(){return wn.join(Nn(),Kr)}function Oe(){let e=jr();if(!G.existsSync(e))return{};let n=G.readFileSync(e,"utf-8");try{return En.parse(n)}catch(t){throw new c("internal",`Failed to parse ${e}: ${t.message}`)}}function Gt(e){return Object.keys(e.profile??{}).sort()}function qt(e,n){return e.profile?.[n]}function Kt(e,n,t){let i=n??t??e.default??"default";if(i.includes(":"))throw new c("input.invalid",`Invalid profile name '${i}': ':' is reserved as the keychain namespace separator \u2014 pick a name without ':'.`);return i}function ae(e){if(!an(e))throw new c("input.invalid",`Refusing to send credentials to API base ${R(e)}. `+on)}function Re(e,n){ae(e);let t=M(e),i=typeof n=="string"?M(n):null;if(t&&i===t)return;let r=typeof n=="string"?R(n):"<missing origin binding>";throw new c("input.invalid",`Refusing to send stored credentials: API base ${R(e)} does not match their bound origin ${r}. Re-login against the intended API base before retrying.`)}function jt(e,n){let t=M(e),i=M(n);if(!(t&&i===t))throw new c("input.invalid",`Refusing API request to ${R(n)} because it is outside the configured API origin ${R(e)}.`)}function Ie(e){let n=Yr(e);if(n)throw new c("input.invalid",n.message)}function Vr(){let e=de();if(e===void 0)return;let n=ue();return n.length>0?{endpoints:n.map(t=>t.base),fromPairs:!0}:{endpoints:[e],fromPairs:!1}}function Yr(e){let n=Vr();if(n===void 0||F(e))return;let{endpoints:t,fromPairs:i}=n,r=M(e),o=t.map(l=>M(l)).filter(l=>l!==null);if(r!==null&&o.includes(r))return;let a=t.map(l=>R(l)).join(", ");return{message:i?`Refusing to send to ${R(e)} \u2014 this build only signs for: ${a}. Re-login against one of this build's environments, or use a build that includes the one you need.`:`Refusing to send to ${R(e)} \u2014 this build only signs for ${a}. Re-login against this build's environment, or use a build for that one.`}}var Jr=require("@noble/hashes/sha3");var Vt=["USDT","USDC"];var Gs=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var Yt=new Map([[1,"USDT"],[2,"USDC"],[3,"BUSD"],[4,"DAI"],[5,"TUSD"],[6,"PAX"],[7,"GUSD"],[8,"USTC"],[9,"FRAX"],[10,"EURS"]]);function ve(){return[...Yt.values()]}function Jt(e){let n=e.trim().toUpperCase();for(let[t,i]of Yt)if(i===n)return t;return null}var Hr="unknown_otp_id",Wr="invalid_code",zr="expired_code";function Xr(e){return`'${e.replace(/'/g,"'\\''")}'`}function Ht(e){return`Run \`allscale otp-send --email ${Xr(e)}\` first \u2014 that command does report a missing account \u2014 then retry with the otp_id it returns and a fresh code.`}var Qr=new Map([[Hr,(e,n)=>`${e}: this environment never issued the --otp-id you passed for '${n}', so the verification code was never the problem. The backend decides this by comparing the otp_id against that address alone, so it says nothing about whether the account exists. ${Ht(n)}`],[Wr,e=>`${e}: the --otp-id is one this environment issued and a live code stands behind it \u2014 the verification code you passed is what does not match. Check for a typo \u2014 the backend invalidates the code after a few wrong answers, so if you are unsure, request a fresh code instead of guessing.`],[zr,(e,n,t)=>t?`${e}: this run's send request was accepted moments ago, but this attempt could not claim a live code for the --otp-id. Delivery is asynchronous and the code is stored only after the email goes out, so it may still be in flight \u2014 or the send may have failed outright, in which case no code is coming. The code you submitted may also have expired, been used, run out of attempts, or been replaced by a newer send. Check the inbox, including spam, and retry with whatever code arrived. If nothing arrives, confirm the address and wait at least three minutes before requesting one fresh code \u2014 sends are rate-limited per address, and retrying in a tight loop spends that budget even when the send is rejected.`:`${e}: this attempt could not claim a live code for the --otp-id. The code you submitted may have expired, been used, run out of attempts, been replaced by a later send, or never have been requested for this address; the backend does not distinguish those. If a newer code was delivered after the one you entered, use that one. ${Ht(n)}`]]);var Wt=[...Qr.keys()];var T=require("@oclif/core"),ge=class e extends I.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:I.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:I.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:X()==="public"}),"api-base":I.Flags.string({description:rn,helpGroup:"GLOBAL",hidden:X()==="public"}),"insecure-storage":I.Flags.boolean({description:"Force POSIX plaintext token storage at ~/.allscale/credentials.json (mode 0600) instead of the OS keychain \u2014 for headless / CI / agent use. Unavailable on Windows because Node cannot verify owner-only ACL/link safety. Also via ALLSCALE_INSECURE_STORAGE=1.",default:!1,helpGroup:"GLOBAL"})};async run(){try{An(this.jsonEnabled()),Tn(),k({type:"session-start",command:this.id??"",argv:Ln(this.argv)});let n=this.constructor;if(X()==="public"){if(this.argv.some(o=>o==="--token"||o.startsWith("--token=")))throw new c("input.invalid","--token is not supported in this build. Set the ALLSCALE_TOKEN environment variable instead (it does not leak into shell history or process listings).");if(this.argv.some(o=>o==="--api-base"||o.startsWith("--api-base=")))throw new c("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!n.isLocalOnly&&he()!==void 0)throw new c("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let t=xt(this.jsonEnabled()),i=this.argv.length===0&&!t&&so(n)?this.config.findCommand(this.id??""):void 0;if(i){fe();let o=await(0,I.loadHelpClass)(this.config),a=this.config.pjson.oclif?.helpOptions??this.config.pjson.helpOptions;await new o(this.config,a).showCommandHelp(i,this.config.topics);return}if(n.requiresEscapeHatch&&!$t())throw this.argv.length>0&&await this.parse(),new c("raw.disabled","This command is an opt-in escape hatch and is disabled by default. Set ALLSCALE_ALLOW_RAW=1 to enable raw GraphQL/REST passthroughs and schema introspection. Access remains governed by the key's granted scopes, which the backend checks on each request.");let r=await this.runCommand();return k({type:"command-end",ok:!0}),fe(),n.emitsOwnOutput?void 0:(this.jsonEnabled()||Lt(r),{data:r})}catch(n){let t=Tt(n);Pt({code:t.code,message:t.message,exitCode:t.exitCode}),this.emitError(t),process.exitCode=t.exitCode;return}finally{An(!1)}}resolveSessionApiBaseChain(n){let t=Oe(),i=n.profile??void 0,r=n["api-base"]??void 0,o=i!==void 0||bn()!==void 0,a=Kt(t,i,bn()),l=qt(t,a),s=X()==="public"&&he()!==void 0,u=r??(s?void 0:he()),f=u??l?.api_base??ye,p=Ft({resolvedApiBase:f,fromExplicitOverride:u!==void 0,profileApiBase:l?.api_base,profileApiBaseSource:l?.api_base_source});return p&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,ne({event:"legacy_staging_profile",api_base:f,profile:a},p)),{apiBase:f,explicitApiBase:u,envApiBaseIgnored:s,profileApiBase:l?.api_base,profile:a,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(n){let{apiBase:t}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||ae(t),t}resolveContext(n){if(X()==="public"){if(n.token!==void 0)throw new c("input.invalid","--token is not supported in this build. Set the ALLSCALE_TOKEN environment variable instead (it does not leak into shell history or process listings).");if(n["api-base"]!==void 0)throw new c("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!this.constructor.isLocalOnly&&he()!==void 0)throw new c("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let t=n.token??void 0,i=!!n["insecure-storage"],{apiBase:r,explicitApiBase:o,envApiBaseIgnored:a,profile:l,profileApiBase:s,profileExplicit:u}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||(ae(r),Ie(r)),{apiBase:r,profile:l,token:t??Ut(),insecureStorage:i||Bt(),apiBaseSource:o!==void 0?"explicit":s!==void 0?"profile":"default",profileExplicit:u,envApiBaseIgnored:a}}emitError(n){process.stderr.write(`${ao(n)}
|
|
15
|
+
`)}};var Zr=/_(removed|cleared|count|total)$/i;function eo(e,n){return typeof n=="number"&&Zr.test(e)}var no=new Set(Vt);function to(e,n){return e==="token_symbol"&&typeof n=="string"&&no.has(n)}var io=new Set(Wt);function ro(e,n){return e==="otp_reason"&&typeof n=="string"&&io.has(n)}var xe=100;function Pe(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,xe),i=t.map(r=>Pe(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null),i=Object.entries(e);for(let[r,o]of i.slice(0,xe))t[r]=we(r)&&!eo(r,o)&&!to(r,o)&&!ro(r,o)?"<redacted>":Pe(o,n+1);if(i.length>xe){let r="<truncated>";for(;r in t;)r=`<${r}>`;t[r]=`${i.length-xe} more keys`}return t}if(typeof e=="string"){let t=oo(e);return t!==void 0?L(JSON.stringify(Pe(t,n+1))):L(e)}return e}function oo(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function ao(e){let n=Ct()?void 0:2,t=Pe(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:L(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function so(e){if(e.requiresInput===!0)return!0;let n=r=>typeof r=="object"&&r!==null&&r.required===!0,t=e.flags??{},i=e.args??{};return Object.values(t).some(r=>n(r))||Object.values(i).some(r=>n(r))}var li=b(require("path"));var Rn=require("crypto"),d=b(require("fs")),S=b(require("path"));var Ue=1024*1024,lo=5e3,co=20,uo=3e4,Cn=4096,po=new Int32Array(new SharedArrayBuffer(4)),_e=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function Be(e){return e instanceof _e}var w=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},fo=null;function K(){return new c("storage.unavailable","Owner-only plaintext credential ACLs cannot be enforced on Windows; --insecure-storage is disabled on this platform. Use Windows Credential Manager instead. `allscale logout` can still remove a legacy plaintext file when the requested profile is its only remaining profile.")}function De(){return(fo??process.platform)!=="win32"}function ii(){if(!De())throw K()}function ri(e){try{return d.default.lstatSync(e),!1}catch(n){if(!_(n,"ENOENT"))throw n}try{let n=d.default.lstatSync(S.dirname(e));return!n.isSymbolicLink()&&n.isDirectory()}catch(n){if(_(n,"ENOENT"))return!0;throw n}}function _(e,n){return typeof e=="object"&&e!==null&&e.code===n}function Se(e,n){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${n} is not owned by the current effective user`)}function Ae(e,n){return e.dev===n.dev&&e.ino===n.ino}function mo(e){Atomics.wait(po,0,0,e)}function oi(e){try{return process.kill(e,0),!0}catch(n){return!_(n,"ESRCH")}}function yo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zt(e,n){let t=S.dirname(e);n&&d.default.mkdirSync(t,{recursive:!0,mode:448});let i;try{i=d.default.lstatSync(t)}catch(o){if(!n&&_(o,"ENOENT"))return!1;throw o}if(i.isSymbolicLink()||!i.isDirectory())throw new Error("credential-store parent must be a real directory");if(process.platform==="win32")return!0;let r=null;try{r=d.default.openSync(t,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0));let o=d.default.fstatSync(r),a=d.default.lstatSync(t);if(!o.isDirectory()||a.isSymbolicLink()||!a.isDirectory()||!Ae(o,a))throw new Error("credential-store parent changed while it was being inspected");Se(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&S.basename(t)===".allscale"&&(d.default.fchmodSync(r,448),l=d.default.fstatSync(r)),(l.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{r!==null&&d.default.closeSync(r)}return!0}function v(e,n,t,i={}){if(!t.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");let r;try{r=d.default.lstatSync(e)}catch(o){throw i.retryOnPathChange&&_(o,"ENOENT")?new w:o}if(!Ae(t,r))throw i.retryOnPathChange?new w:new Error("credential-store target changed while it was being opened or is not a regular file");if(r.isSymbolicLink()||!r.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");if(!i.allowMultipleLinks&&(t.nlink!==1||r.nlink!==1))throw new _e;if(Se(t,"credential-store file"),process.platform!=="win32"){d.default.fchmodSync(n,384);let o=d.default.fstatSync(n);if((o.mode&63)!==0)throw new Error("credential-store file could not be made owner-only");return o}return t}function ho(e,n){if(n.size>Ue)throw new Error("credential-store file exceeds the maximum supported size");let t=Buffer.alloc(Ue+1),i=0;for(;i<t.length;){let r=d.default.readSync(e,t,i,t.length-i,null);if(r===0)break;i+=r}if(i>Ue)throw new Error("credential-store file exceeds the maximum supported size");return t.subarray(0,i).toString("utf8")}function Xt(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT"))try{if(d.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(_(o,"ENOENT"))return null;throw o}throw r}let t=d.default.fstatSync(n),i=v(e,n,t);return ho(n,i)}finally{n!==null&&d.default.closeSync(n)}}function Qt(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT")&&ri(e))return;throw r}let t=d.default.fstatSync(n),i=v(e,n,t);j(e,i)}finally{n!==null&&d.default.closeSync(n)}si(S.dirname(e))}function go(e){let n;try{n=d.default.lstatSync(e)}catch(t){if(_(t,"ENOENT"))return;throw t}if(n.isSymbolicLink()||!n.isFile())throw new Error("credential-store replacement target must be a regular file");if(n.nlink!==1)throw new _e;Se(n,"credential-store replacement target")}function _o(e,n){for(let t=0;t<8;t+=1){let i=(0,Rn.randomBytes)(12).toString("hex"),r=S.join(e,`.${n}.${process.pid}.${i}.tmp`);try{return{fd:d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384),tempPath:r}}catch(o){if(_(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function ai(e,n){let t=0;for(;t<n.length;){let i=d.default.writeSync(e,n,t,n.length-t,null);if(!Number.isSafeInteger(i)||i<=0)throw new Error("credential-store temp file write made no progress");t+=i}}function si(e){if(process.platform==="win32")return;let n=null;try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)),d.default.fsyncSync(n)}catch{}finally{if(n!==null)try{d.default.closeSync(n)}catch{}}}function So(e,n){let t=Buffer.from(n,"utf8");if(t.length>Ue)throw new Error("credential-store file exceeds the maximum supported size");let i=S.dirname(e),r=S.basename(e),o=null,a=null,l=!1;try{let s=_o(i,r);o=s.fd,a=s.tempPath;let u=d.default.fstatSync(o);if((v(a,o,u).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");ai(o,t),d.default.fsyncSync(o),v(a,o,d.default.fstatSync(o));let p=o;o=null,d.default.closeSync(p),go(e),d.default.renameSync(a,e),l=!0}finally{if(o!==null)try{d.default.closeSync(o)}catch{}if(!l&&a!==null)try{d.default.unlinkSync(a)}catch{}}si(i)}function Ao(e){return S.join(S.dirname(e),`.${S.basename(e)}.lock`)}function ko(e){return S.join(S.dirname(e),`.${S.basename(e)}.lock-recovery`)}function To(e,n){if(n.size>Cn)return null;let t=Buffer.alloc(Cn+1),i=0;for(;i<t.length;){let o=d.default.readSync(e,t,i,t.length-i,null);if(o===0)break;i+=o}if(i>Cn)return null;let r;try{r=JSON.parse(t.subarray(0,i).toString("utf8"))}catch{return null}return typeof r!="object"||r===null||!Number.isSafeInteger(r.pid)||(r.pid??0)<=0||typeof r.nonce!="string"||!/^[a-f0-9]{24}$/.test(r.nonce??"")||typeof r.target!="string"?null:r}function j(e,n){let t=d.default.lstatSync(e);if(t.isSymbolicLink()||!t.isFile()||!Ae(t,n))throw new Error("credential-store lock changed while it was being inspected");Se(t,"credential-store lock"),d.default.unlinkSync(e)}function Zt(e,n){let t=null;try{try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(s){if(_(s,"ENOENT"))try{let u=d.default.lstatSync(e);throw u.isSymbolicLink()||!u.isFile()?new Error("credential-store lock must be a real regular file"):new w}catch(u){if(_(u,"ENOENT"))return{state:"absent"};throw u}throw s}let i=d.default.fstatSync(t),r=v(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=To(t,r);return{state:(o?.target===n&&o?!oi(o.pid):Date.now()-r.mtimeMs>=uo)?"stale":"active",stats:r}}finally{t!==null&&d.default.closeSync(t)}}function Lo(e,n){for(let t=0;t<8;t+=1){let i=(0,Rn.randomBytes)(12).toString("hex"),r=S.join(e,`.${n}.${process.pid}.${i}.lock-claim`),o={pid:process.pid,nonce:i,target:n},a=null;try{a=d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384);let l=d.default.fstatSync(a),s=v(r,a,l,{allowMultipleLinks:!0});return ai(a,Buffer.from(JSON.stringify(o),"utf8")),d.default.fsyncSync(a),{claimPath:r,metadata:o,stats:s}}catch(l){if(_(l,"EEXIST"))continue;try{d.default.unlinkSync(r)}catch{}throw l}finally{a!==null&&d.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function bo(e,n){let t;try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(i){throw _(i,"ENOENT")?new w:i}try{let i=d.default.fstatSync(t),r=v(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!Ae(r,n))throw new w;return{fd:t,lockPath:e,stats:r}}catch(i){throw d.default.closeSync(t),i}}function ei(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(t){if(_(t,"ENOENT"))try{let i=d.default.lstatSync(e);throw i.isSymbolicLink()||!i.isFile()?new Error("credential-store recovery gate must be a real regular file"):new w}catch(i){if(_(i,"ENOENT"))return!1;throw i}throw t}return v(e,n,d.default.fstatSync(n),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{n!==null&&d.default.closeSync(n)}}function wo(e){let n;try{n=d.default.openSync(e,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_RDWR|(d.default.constants.O_NOFOLLOW??0),384)}catch(i){if(_(i,"EEXIST"))return null;throw i}let t=null;try{t=d.default.fstatSync(n);let i=v(e,n,t,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:n,lockPath:e,stats:i}}catch(i){if(t!==null)try{j(e,t)}catch{}throw d.default.closeSync(n),i}}function q(e,n){if(Date.now()>=e)throw n?new Error("credential-store recovery gate remained present past the bounded wait; a previous lock reclaimer may have crashed, so automatic recovery is intentionally disabled and manual inspection/removal is required"):new Error("credential-store lock remained busy past the bounded wait");mo(co)}function ni(e){let n=S.dirname(e),t=S.basename(e),i=Ao(e),r=ko(e),o=Lo(n,t),a=Date.now()+lo,l=!1,s=!1,u=null,f;try{for(;u===null;)try{if(ei(r)){q(a,!0);continue}d.default.linkSync(o.claimPath,i),s=!0,u=bo(i,o.stats),l=!0}catch(p){if(s&&!l){try{j(i,o.stats)}catch{}s=!1}if(p instanceof w){q(a,!1);continue}if(!_(p,"EEXIST"))throw p;let y;try{y=Zt(i,t)}catch(g){if(g instanceof w){q(a,!1);continue}throw g}if(y.state==="absent")continue;if(y.state==="stale"){let g;try{g=wo(r)}catch(A){if(A instanceof w){q(a,!1);continue}throw A}if(g!==null){try{let A;try{A=Zt(i,t)}catch(C){if(C instanceof w){q(a,!1);continue}throw C}A.state==="stale"&&j(i,A.stats)}finally{On(g)}continue}}let m;try{m=ei(r)}catch(g){if(g instanceof w){q(a,!1);continue}throw g}q(a,m)}}catch(p){f=p}try{j(o.claimPath,o.stats)}catch(p){!_(p,"ENOENT")&&!l&&f===void 0&&(f=p)}if(f!==void 0)throw f;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function On(e){try{j(e.lockPath,e.stats)}finally{d.default.closeSync(e.fd)}}function Eo(e,n){let t=yo(n),i=new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.tmp$`).exec(e)??new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.lock-claim$`).exec(e);if(!i)return null;let r=Number(i[1]);return Number.isSafeInteger(r)&&r>0?r:null}function ti(e){let n=S.dirname(e),t=S.basename(e);for(let i of d.default.readdirSync(n)){let r=Eo(i,t);if(r===null||oi(r))continue;let o=S.join(n,i),a=null;try{try{a=d.default.openSync(o,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(u){if(_(u,"ENOENT")||_(u,"ELOOP"))continue;throw u}let l=d.default.fstatSync(a),s=d.default.lstatSync(o);if(!l.isFile()||s.isSymbolicLink()||!s.isFile()||!Ae(l,s))continue;try{Se(l,"credential-store orphan")}catch{continue}j(o,l)}catch(l){if(!_(l,"ENOENT"))throw l}finally{a!==null&&d.default.closeSync(a)}}}function ke(e,n,t){if(!De()){if(n.allowUnsupportedPlatformCleanup){if(n.createParent)throw K();if(!zt(e,!1))return t({read:()=>null,remove:()=>{},write:()=>{throw K()}});let a=ni(e);try{return ti(e),t({read:()=>Xt(e),remove:()=>Qt(e),write:()=>{throw K()}})}finally{On(a)}}if(!n.createParent){let o=!1;try{o=ri(e)}catch{throw K()}if(o)return t({read:()=>null,remove:()=>{},write:()=>{throw K()}})}throw K()}if(!zt(e,n.createParent))return t({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let r=ni(e);try{return ti(e),t({read:()=>Xt(e),remove:()=>Qt(e),write:o=>So(e,o)})}finally{On(r)}}var In="allscale-cli";function Un(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ci(e){return Un(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function Y(e){return new c("internal",`The session credential store in the ${e} exists but could not be read as valid credential data. Refusing to treat it as empty or overwrite it; session credentials may still remain on this machine.`)}function vn(){return new c("internal","The session credential store in the plaintext file has multiple hard links. Refusing to read, modify, or delete it because another directory entry may retain session credentials. Remove every extra hard link, then re-run the command. If you intentionally keep a deduplicated backup, revoke or rotate its credentials before treating logout as complete.")}function $e(){return new c("internal","The session credential store in the plaintext file could not be written safely. Any previous credential file was left unchanged.")}var V,xn=!1;function No(){return Dt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Co(e){if(typeof e!="object"||e===null||e.code!=="MODULE_NOT_FOUND")return!1;let n=e.message;return typeof n=="string"&&n.split(`
|
|
16
|
+
`,1)[0]==="Cannot find module 'keytar'"}function Oo(){if(V!==void 0)return V;if(No())return xn=!1,V=null,V;try{V=require("keytar"),xn=!1}catch(e){xn=!Co(e),V=null}return V}var Ro="OS keychain could not be accessed on this system (keytar / libsecret may be unavailable, locked, or unusable).";function di(){let e=De()?"Re-run with --insecure-storage (or set ALLSCALE_INSECURE_STORAGE=1) to use the owner-only plaintext credential file.":"Plaintext credential fallback is unavailable on Windows because owner-only ACLs cannot be verified; use Windows Credential Manager.";return new c("storage.unavailable",`${Ro} `+e+" Never silently downgrade in production.")}async function Pn(e){try{return await e()}catch{throw di()}}var Bn=class{constructor(n){this.keytar=n}keytar;kind="keychain";async read(n){let t=await Pn(()=>this.keytar.getPassword(In,n));if(t===null)return null;let i;try{i=JSON.parse(t)}catch{throw Y("OS keychain")}if(!ci(i))throw Y("OS keychain");return i}async get(n){return this.read(n)}async set(n,t){await this.read(n),await Pn(()=>this.keytar.setPassword(In,n,JSON.stringify(t)))}async delete(n){await this.read(n),await Pn(()=>this.keytar.deletePassword(In,n))}},Io="credentials.json",Dn=class{kind="insecure-file";filePath;constructor(n){this.filePath=n??li.join(Nn(),Io)}read(n){let t;try{t=n.read()}catch(r){throw Be(r)?vn():Y("plaintext file")}if(t===null)return{profiles:{}};let i;try{i=JSON.parse(t)}catch{throw Y("plaintext file")}if(!Un(i)||!Un(i.profiles))throw Y("plaintext file");return i}write(n,t){try{n.write(JSON.stringify(t,null,2))}catch(i){throw Be(i)?vn():$e()}}profileTokens(n,t){let i=n.profiles[t];if(i!==void 0){if(!ci(i))throw Y("plaintext file");return i}}async get(n){try{return ke(this.filePath,{createParent:!1},t=>this.profileTokens(this.read(t),n)??null)}catch(t){throw t instanceof c?t:Y("plaintext file")}}async set(n,t){try{ke(this.filePath,{createParent:!0},i=>{let r=this.read(i);this.profileTokens(r,n),r.profiles[n]=t,this.write(i,r)})}catch(i){throw i instanceof c?i:$e()}}async delete(n){try{ke(this.filePath,{createParent:!1},t=>{let i=this.read(t);this.profileTokens(i,n)!==void 0&&(delete i.profiles[n],this.write(t,i))})}catch(t){throw t instanceof c?t:$e()}}async clearProfile(n){try{return ke(this.filePath,{createParent:!1,allowUnsupportedPlatformCleanup:!0},t=>{let i=this.read(t);return this.profileTokens(i,n)===void 0?!1:(delete i.profiles[n],Object.keys(i.profiles).length===0?t.remove():this.write(t,i),!0)})}catch(t){throw t instanceof c?t:Be(t)?vn():$e()}}};function Fe(e){if(e.insecureStorage)return ii(),new Dn(e.insecureFilePath);let n=Oo();if(n)return new Bn(n);throw di()}var $n=class{kind="insecure-file";async get(n){return null}async set(n,t){throw new c("internal","NoopTokenStore: refusing to persist tokens \u2014 caller used --token override path.")}async delete(n){}};function Me(){return new $n}var Ge="allscale_access_token",Fn="allscale_refresh_token";function ui(e){return(typeof e.getSetCookie=="function"?e.getSetCookie():e.get("set-cookie")?[e.get("set-cookie")]:[]).map(t=>{let i=t.indexOf(";"),r=i===-1?t:t.slice(0,i),o=r.indexOf("=");return o===-1?null:{name:r.slice(0,o).trim(),value:r.slice(o+1).trim()}}).filter(t=>t!==null)}function Mn(e){return e.map(n=>`${n.name}=${n.value}`).join("; ")}function Gn(e,n){return e.find(t=>t.name===n)?.value??null}var pi=b(require("crypto")),fi=b(require("fs")),mi=b(require("path"));var vo="key-id",xo="x-allscale-cli-version",qn="cli-1",Po="aScaLe_cli_obf_v1",Uo="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function Bo(e,n){let t=Buffer.from(e,"base64"),i=Buffer.from(n,"utf8"),r=Buffer.alloc(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^i[o%i.length];return r.toString("utf8")}var Do=Bo(Uo,Po),yi=`Bearer ${Do}`;function hi(e,n){let t=ln(e);if(t!==null)return n.find(i=>ln(i.base)===t)}function $o(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let n=ue();if(n.length>0){let i=hi(e,n);if(i)return i.key;if(F(e)){let r=process.env.ALLSCALE_SIGNING_KEY;return r&&r.trim().length>0?r:F(n[0].base)?n[0].key:void 0}return}let t=process.env.ALLSCALE_SIGNING_KEY;return t&&t.trim().length>0?t:void 0}function Fo(e){{let i="cli-1".trim();if(i.length>0)return i}let n=ue();if(n.length>0){let i=e!==void 0?hi(e,n):void 0;if(i)return i.keyId;if(e!==void 0&&F(e)){let r=process.env.ALLSCALE_SIGNING_KEY;if(r&&r.trim().length>0){let o=process.env.ALLSCALE_SIGNING_KEY_ID;return o!==void 0?o.trim():qn}if(!F(n[0].base))return qn}return n[0].keyId}let t=process.env.ALLSCALE_SIGNING_KEY_ID;return t!==void 0?t.trim():qn}function Mo(){return"1.0.3"}function Go(){return new c("signing.key_unavailable","No request-signing key is available for this destination in this build. Published builds embed one at publish time; when running from source or an internal build, set ALLSCALE_SIGNING_KEY + ALLSCALE_BUILD_API_BASE (or ALLSCALE_BUILD_PAIRS for more than one environment) in the environment.")}function Kn(e,n){let t=$o(n);if(!t)throw Go();let i=Fo(n),r=Math.floor(Date.now()/1e3).toString(),o=pi.createHash("sha256").update(`${t}${r}${e}`).digest("hex"),a={timestamp:r,"secret-key":o,[xo]:Mo()};return i.length>0&&(a[vo]=i),a}function gi(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function qo(e,n={}){let t;try{t=Gt(Oe())}catch{return}if(!(t.length===0||t.includes(e)))return new c("auth.unknown_profile",kt(e)+(n.messageSuffix??""),{profile:e})}function qe(e){if(e.profileExplicit){let n=qo(e.profile);if(n)return n}return new c("auth.no_token",At(e.profile))}var Ko=500,jo=8,_i=100;function jn(e,n=0){if(n>jo)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,_i),i=t.map(r=>jn(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null);for(let[i,r]of Object.entries(e).slice(0,_i))t[i]=we(i)?"<redacted>":jn(r,n+1);return t}return e}function Vo(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function Si(e,n=Ko){let t=Vo(e),i=t===void 0?be(e):JSON.stringify(jn(t));return Ee(i,n)}var Vn=256*1024,Ke=class extends c{constructor(n,t,i="backend-envelope"){let r=i==="successful-query",o=i==="successful-mutation";super(r?"transport.response_too_large":"backend.internal",r?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so it was not parsed. For list commands, request fewer rows by removing --all or using --input/--limit pagination, and reduce --select when possible; for other commands, contact support.`:o?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so its result was not parsed. The operation may already have completed; inspect authoritative state before retrying.`:`API response body exceeded the ${t}-byte safety limit and was not parsed.`,{status:n,max_body_bytes:t,...o?{outcome_ambiguous:!0}:{}}),this.name="ResponseBodyTooLargeError"}},je=class extends Error{status;timeoutMs;constructor(n,t){super(`API response body read exceeded its ${t}ms deadline.`),this.name="ResponseBodyReadTimeoutError",this.status=n,this.timeoutMs=t}};async function Yn(e,n,t={}){if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maxBytes must be a positive safe integer");if(t.timeoutMs!==void 0&&(!Number.isSafeInteger(t.timeoutMs)||t.timeoutMs<=0))throw new RangeError("timeoutMs must be a positive safe integer");let i=e.headers.get("content-length"),r=i!==null&&/^\d+$/.test(i.trim())?Number(i):void 0;if(r!==void 0&&r>n)throw e.body?.cancel().catch(()=>{}),new Ke(e.status,n,t.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),a=[],l=0,s,u=t.timeoutMs,f=u===void 0?void 0:new Promise((p,y)=>{s=setTimeout(()=>{y(new je(e.status,u))},u),s.unref?.()});try{for(;;){let p=o.read(),{done:y,value:m}=f?await Promise.race([p,f]):await p;if(y)break;if(l+=m.byteLength,l>n)throw o.cancel().catch(()=>{}),new Ke(e.status,n,t.oversizeKind);a.push(Buffer.from(m))}}catch(p){throw p instanceof je&&o.cancel(p).catch(()=>{}),p}finally{s!==void 0&&clearTimeout(s);try{o.releaseLock()}catch{}}return Buffer.concat(a,l).toString("utf8")}var Yo="X-AllScale-Api-Key",Jo=3e4,Ho=32*1024*1024,Wo=4*1024*1024;function zo(e,n){let t=new AbortController,i=!1,r=()=>{t.abort(e?.reason)};e?.aborted?r():e?.addEventListener("abort",r,{once:!0});let o=setTimeout(()=>{i=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>i,dispose:()=>{clearTimeout(o),e?.removeEventListener("abort",r)}}}function Xo(e,n){return n?n.aborted?Promise.reject(Object.assign(new Error("The operation was aborted"),{name:"AbortError"})):new Promise((t,i)=>{let r=()=>{i(Object.assign(new Error("The operation was aborted"),{name:"AbortError"}))};n.addEventListener("abort",r,{once:!0}),e.then(t,i).finally(()=>{n.removeEventListener("abort",r)})}):e}function Qo(e,n){if(!(e<300||e>=400))throw new c("transport.network",`API returned HTTP ${e} (a redirect) for ${D(n||"the request")}. The CLI does NOT follow redirects on credential-bearing requests \u2014 a cross-origin hop could re-send credentials and the request body to the new host. Check that --api-base / ALLSCALE_API_BASE points at the API origin directly and that no proxy is rewriting it.`,{status:e})}async function bi(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Qo(e.status,e.url)}}var Ai="--dns-result-order=ipv4first";async function Ve(e,n){if(e.status!==403)return;let t=e.headers.get("content-type")?.toLowerCase()??"",i=e.headers.get("cf-ray")??"",r=e.headers.get("cf-mitigated")?.trim().toLowerCase()==="challenge",o=t.includes("text/html"),a=n?.slice(0,4096)??"",l=/^\s*(?:<!doctype\s+html|<html\b)/i.test(a),s=/cf-error-details|\/cdn-cgi\/(?:challenge-platform|styles\/cf\.errors)|sorry,\s*you have been blocked|attention required[^<]{0,160}cloudflare|cloudflare ray id|error\s*(?:code\s*)?1020/i.test(a);if(!((o||l)&&(r||n!==void 0&&s)))return;if(n===void 0)try{e.body?.cancel().catch(()=>{})}catch{}let f=/^[A-Za-z0-9-]{1,128}$/.test(i)?i:void 0;throw new c("transport.network",`Cloudflare blocked this request before it reached the AllScale API (HTTP 403). This can happen when the release edge accepts IPv4 but rejects IPv6. Retry with NODE_OPTIONS=${Ai} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...f?{cf_ray:f}:{},ipv4_workaround:`NODE_OPTIONS=${Ai}`})}var J=class{constructor(n){this.opts=n}opts;refreshInFlight=null;async requestWithMetadata(n){return this.requestInternal(n,{withMetadata:!0})}async request(n){return this.requestInternal(n,{withMetadata:!1})}async requestInternal(n,t){let i=n.timeoutMs??this.opts.requestTimeoutMs??Jo;if(!Number.isFinite(i)||i<1)throw new c("input.invalid","HTTP request timeout must be a positive number of milliseconds.");ae(this.opts.apiBase),Ie(this.opts.apiBase);let r=this.opts.override?{access_token:this.opts.override.access_token,refresh_token:this.opts.override.refresh_token??""}:await this.opts.tokenStore.get(this.opts.profile),o=zo(n.signal,i);try{return await this.requestWithinDeadline({...n,signal:o.signal},t,r)}catch(a){throw o.timedOut()?new c("transport.timeout",`Request to ${D(new URL(n.path,this.opts.apiBase).toString())} timed out after ${i}ms.`,{timeout_ms:i}):n.signal?.aborted&&!(a instanceof c)?new c("transport.network",`Request to ${D(new URL(n.path,this.opts.apiBase).toString())} was aborted by the caller.`):a}finally{o.dispose()}}async requestWithinDeadline(n,t,i){let r=new URL(n.path,this.opts.apiBase).toString();jt(this.opts.apiBase,r);let o=i?.agent_key,a=n.auth??"auto",l=wi(n.path),s=a==="required"?!0:a==="none"?!1:na(n.path);if((l||a==="required")&&!n._isRefresh&&!this.opts.override&&!i?.access_token&&!o)throw qe({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let u=gi(n.body),f=!!o||!!i?.access_token;s&&f&&!this.opts.override&&Re(this.opts.apiBase,i?.api_base);let p=this.buildHeaders({attachAuth:s&&f,bodyForSig:u,tokens:i,extra:n.headers}),y=Date.now();k({type:"request",method:n.method??"GET",url:r,...n._isRefresh?{refresh:!0}:{}});let m;try{m=await fetch(r,{method:n.method??"GET",headers:p,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(A){throw new c("transport.network",`Network error contacting ${D(r)}: ${A instanceof Error?A.message:String(A)}`)}if(k({type:"response",status:m.status,durationMs:Date.now()-y}),s&&!!i?.access_token&&!o&&m.status===401&&!n._isRefresh&&!this.opts.override){let A=await Xo(this.refreshSingleFlight(),n.signal),C=this.buildHeaders({attachAuth:s&&!!A.access_token,bodyForSig:u,tokens:A,extra:n.headers}),O=Date.now();k({type:"request",method:n.method??"GET",url:r});let P;try{P=await fetch(r,{method:n.method??"GET",headers:C,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(U){throw new c("transport.network",`Network error contacting ${D(r)} on refresh-retry: ${U instanceof Error?U.message:String(U)}`)}return k({type:"response",status:P.status,durationMs:Date.now()-O}),ki(P,{withMetadata:t.withMetadata,authBearing:s,responseKind:Ti(n)})}return ki(m,{withMetadata:t.withMetadata,authBearing:s&&f,agentKeyAuth:s&&!!o,responseKind:Ti(n)})}buildHeaders(n){let i={Accept:"application/json","Content-Type":"application/json",...Kn(n.bodyForSig,this.opts.apiBase),...n.extra};if(n.attachAuth){i.Authorization=yi;let r=n.tokens;if(r?.agent_key)return i[Yo]=r.agent_key,i;let o=r?.access_token;o&&(i.Cookie=Mn([{name:Ge,value:o}]))}return i}async refreshSingleFlight(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.doRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}async adoptConcurrentlyRotatedTokens(n){let t;try{t=await this.opts.tokenStore.get(this.opts.profile)}catch{return null}if(!t?.access_token||!t?.refresh_token||t.refresh_token===n.refresh_token)return null;if(Re(this.opts.apiBase,t.api_base),t.agent_key)throw new c("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than use it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");return t}async doRefresh(){let n=await this.opts.tokenStore.get(this.opts.profile);if(!n?.access_token||!n?.refresh_token)throw new c("auth.token_expired",`No refresh token available; log in again \u2014 ${Le()}.`);if(Re(this.opts.apiBase,n.api_base),n.agent_key)throw new c("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than overwrite it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");let t=new URL("/api/public/auth/refresh_token",this.opts.apiBase).toString(),i=Mn([{name:Ge,value:n.access_token},{name:Fn,value:n.refresh_token}]),r=Kn("",this.opts.apiBase);k({type:"request",method:"POST",url:t,refresh:!0});let o=new AbortController,a=!1,l=setTimeout(()=>{a=!0,o.abort()},1e4),s;try{s=await fetch(t,{method:"POST",headers:{Accept:"application/json",Cookie:i,...r},signal:o.signal,redirect:"manual"})}catch(m){throw k({type:"refresh",ok:!1}),new c("transport.network",a&&m instanceof Error&&m.name==="AbortError"?`Token refresh against ${D(t)} timed out after 10s with no response.`:`Network error during token refresh against ${D(t)}: ${m instanceof Error?m.message:String(m)}`)}finally{clearTimeout(l)}k({type:"response",status:s.status,durationMs:0});try{await bi(s)}catch(m){throw k({type:"refresh",ok:!1}),m}if(s.status!==200){let m=null;try{await Ve(s);let g=await aa(s);await Ve(s,g),Ni(s.status,g),s.status===401&&(m=await this.adoptConcurrentlyRotatedTokens(n))}catch(g){throw k({type:"refresh",ok:!1}),g}if(m)return k({type:"refresh",ok:!0,adopted:!0}),m;throw k({type:"refresh",ok:!1}),new c("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${Le()}.`,{status:s.status})}let u=ui(s.headers),f=Gn(u,Ge),p=Gn(u,Fn);if(!f||!p)throw k({type:"refresh",ok:!1}),new c("auth.token_expired","Refresh response did not include new access/refresh cookies.");let y={...n,access_token:f,refresh_token:p};return await this.opts.tokenStore.set(this.opts.profile,y),k({type:"refresh",ok:!0}),y}},Zo=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function wi(e){let n=e.split(/[?#]/,1)[0];return Zo.some(t=>n===t||n.startsWith(`${t}/`))}var ea=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function Jn(e){let n=e.split(/[?#]/,1)[0];return ea.some(t=>t.test(n))}function na(e){return wi(e)||Jn(e)}async function ki(e,n={}){await bi(e);let t=e.status>=200&&e.status<300;t||await Ve(e);let i=n.responseKind??"mutation",o=await Yn(e,t?i==="query"?Ho:Wo:Vn,{oversizeKind:t?i==="query"?"successful-query":"successful-mutation":"backend-envelope"});t||await Ve(e,o);let a=null;if(o.length>0)try{a=JSON.parse(o)}catch{a={raw:o}}if(e.status>=200&&e.status<300){if(n.withMetadata){let s={};return e.headers.forEach((u,f)=>{s[f]=u}),{status:e.status,headers:s,body:a}}return a}let l=sa(a)??`HTTP ${e.status}`;if(Ni(e.status,a),ra(e.status,a,n),e.status===401){if(n.agentKeyAuth)throw new c("auth.token_expired","Agent key was rejected (expired or revoked). Re-run `allscale device-login` to mint a new scoped key.",{status:401,body:a});let s=n.authBearing?"auth.token_expired":"input.invalid";throw new c(s,l,{status:401,body:a})}throw e.status===403?new c("auth.permission_denied",l,{status:403,body:a}):e.status===404?new c("not_found",l,{status:404,body:a}):e.status===429?new c("rate_limited",l,{status:429,body:a}):e.status>=500?new c("backend.internal",l,{status:e.status,body:a}):new c("input.invalid",l,{status:e.status,body:a})}function Ti(e){if(e.responseKind)return e.responseKind;let n=(e.method??"GET").toUpperCase();return n==="GET"||n==="HEAD"?"query":"mutation"}var ta=2014,Li=2004;function Ei(e,n){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;let i=t.code;return i===n||i===String(n)}function ia(e){return Ei(e,ta)}function ra(e,n,t){if(!(e>=200&&e<300)&&t.authBearing&&!(e===401&&t.agentKeyAuth)&&Ei(n,Li))throw new c("auth.token_expired",`The API rejected this credential as invalid. Re-authenticate with ${Le()} and retry. If that does not help, upgrade the CLI \u2014 the API may have rotated the client credential this build carries.`,{status:e,backend_code:Li})}var oa=1e4;async function aa(e,n=oa){if(e.status>=200&&e.status<300)return"";try{return await Yn(e,Vn,{timeoutMs:n})}catch{return""}}function Ni(e,n){if(!(e>=200&&e<300)&&ia(n))throw new c("auth.signature_rejected","The AllScale API rejected this CLI build's request signing key. Download the latest version \u2014 `npm install -g @allscale/cli@latest` \u2014 and retry: retiring an old signing key is how a release is made mandatory. If you are already on the latest version, this build's key row is missing or misprovisioned on the backend \u2014 contact AllScale support. Re-logging in will not help either way; the key ships inside the CLI build itself.",{status:e,body:typeof n=="string"?Si(n):n})}function sa(e){if(!e||typeof e!="object")return;let n=e;if(typeof n.message=="string")return n.message;if(typeof n.detail=="string")return n.detail;if(Array.isArray(n.detail))return JSON.stringify(n.detail)}var la=/^\/(api\/)?(v1\/)?public\//;function Ci(e,n={}){let t=typeof n.pathHint=="string"?n.pathHint:"",i=t&&la.test(t),r=t&&Jn(t),o=i&&!r&&!n.forceAuth;if(e.token)return new J({apiBase:e.apiBase,tokenStore:Me(),profile:e.profile,profileExplicit:e.profileExplicit,override:{access_token:e.token}});if(o)return new J({apiBase:e.apiBase,tokenStore:Me(),profile:e.profile,profileExplicit:e.profileExplicit});try{return new J({apiBase:e.apiBase,tokenStore:Fe({insecureStorage:e.insecureStorage}),profile:e.profile,profileExplicit:e.profileExplicit})}catch(a){if(r)return new J({apiBase:e.apiBase,tokenStore:Me(),profile:e.profile,profileExplicit:e.profileExplicit});throw a}}var Ye=[{name:"create_claim_link",kind:"mutation",description:"Create a single App claim link. Returns the pending link, funding address, exact deposit total, and bearer claim URL. The link becomes available after the sender's deposit is confirmed. No claim-back.",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateClaimLinkInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"CreateClaimLinkResult",ofType:null}},deprecated:null},{name:"create_contact",kind:"mutation",description:"create a new contact",args:[{name:"create_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateContactInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"create_payment",kind:"mutation",description:"create a new payment",args:[{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreatePaymentInput",ofType:null}},defaultValue:null},{name:"wallet_ids",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"create_store",kind:"mutation",description:"create store",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateStoreInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"StoreCreateResult",ofType:null}},deprecated:null},{name:"update_payment",kind:"mutation",description:"update an existing payment status by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"UpdatePaymentInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"activities",kind:"query",description:"Get current user's activity list with multi-dimensional filters (type, status, contact, wallet, time range, amount range)",args:[{name:"filter_input",description:null,type:{kind:"INPUT_OBJECT",name:"ActivityFilterInput",ofType:null},defaultValue:"null"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"20"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItemPaginatedResponse",ofType:null}},deprecated:null},{name:"auto_payout_session_status",kind:"query",description:"Return the current merchant auto-payout status, expiry, total/used/remaining USD cap, per-transaction limit, and authorized chain/token pairs. Merchants without an active setup receive provisioned=false with null money/expiry fields and no pairs.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AutoPayoutSessionStatus",ofType:null}},deprecated:null},{name:"business",kind:"query",description:"get one business by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Business",ofType:null}},deprecated:null},{name:"business_contact_by_email",kind:"query",description:"Look up the contact card of the business whose login email is given. Used to fill the invoice header's From: block with the same name/email/phone the web editor shows.",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"BusinessContact",ofType:null}},deprecated:null},{name:"business_transaction_records",kind:"query",description:"get transaction records for business",args:[{name:"direction",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_type",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"business_wallets",kind:"query",description:"List the CALLER'S OWN non-custodial wallets (id, chain, address, coin balances). Takes no business id \u2014 the owner is derived from the authenticated identity, so there is no caller-supplied id to mismatch and no way to read another merchant's wallets. Returns [] when the account has no wallet yet.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"WalletEmbedded",ofType:null}}}},deprecated:null},{name:"claim_link",kind:"query",description:"Get one of the caller's own claim links by id (sender surface). A non-owned or unknown id returns CLAIM_LINK_NOT_AVAILABLE \u2014 no existence leak.",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},deprecated:null},{name:"contact",kind:"query",description:"get one contact by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contact_by_email",kind:"query",description:"get one contact by it's email",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contacts",kind:"query",description:"get multi contacts by owner business id",args:[{name:"owner_business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ContactPaginatedResponse",ofType:null}},deprecated:null},{name:"my_claim_links",kind:"query",description:"List the caller's claim links, newest first. Optional status and link_source filters narrow the results; query_input controls pagination, ordering, and the created_at time range.",args:[{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"link_source",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkPaginatedResponse",ofType:null}},deprecated:null},{name:"my_transactions",kind:"query",description:"get one user's successful transactions by query",args:[{name:"query_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"payment",kind:"query",description:"get one payment by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"payments",kind:"query",description:"All payments by business ID as sender or recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"recipient_payments",kind:"query",description:"Get multiple payments by business ID as recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"sender_payments",kind:"query",description:"Get multiple payments by business ID as sender",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"transaction",kind:"query",description:"get one transaction by id_str",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}},deprecated:null}],$=[{name:"ActivityFilterInput",kind:"INPUT",description:null,inputFields:[{name:"transaction_types",description:"Filter by transaction types (OR): 1=PAYMENT, 2=REWARD, 3=WITHDRAWAL, 8=CHECKOUT_INTENT_EPHEMERAL, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 11=CHECKOUT_INTENT_EPHEMERAL_REFUND, 13=CHECKOUT_INTENT_EPHEMERAL_NET_INCOME, 14=CLAIM_LINK",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"transaction_statuses",description:"Filter by transaction statuses (OR): 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"payment_statuses",description:"Filter by payment statuses (OR): -4=OVERDUE, -1=FAILED, 0=DRAFT, 1=SENT, 2=ACKNOWLEDGED, 3=PROCESSING, 10=PAID",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"withdraw_statuses",description:"Filter by withdraw statuses (OR): -4=CANCELED, -1=FAILED, 1=CREATED, 20=CONFIRMED",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"directions",description:"Filter by transaction direction (OR): 1=INFLOW, -1=OUTFLOW",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"contact_keyword",description:"Fuzzy search by contact name/email or store name. OR relationship with wallet_address.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"wallet_address",description:"Fuzzy search by counterparty wallet address (tx_from/tx_to). OR relationship with contact_keyword.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"start_time",description:"Filter transactions after this time, ISO8601 format (e.g. 2024-01-01T00:00:00.000Z)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"end_time",description:"Filter transactions before this time, ISO8601 format",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"min_amount",description:"Filter transactions with amount >= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"max_amount",description:"Filter transactions with amount <= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"is_claim_link",description:"When true, return only claim-link activity: a receiver's claim (an ON_CHAIN_TX tagged with claim_link_id) OR a sender's CLAIM_LINK row (single claim_link_id / batch claim_link_batch_id). Matched by claim-link linkage presence, NOT transaction_types \u2014 a receiver's claim shares transaction_type=ON_CHAIN_TX(10) with a plain deposit, so it cannot be selected by type alone (bug 6935616).",type:{kind:"SCALAR",name:"Boolean",ofType:null},defaultValue:"null"}]},{name:"ActivityItem",kind:"OBJECT",description:null,fields:[{name:"transaction_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Transaction record ID"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Transaction amount in cryptocurrency"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Transaction amount in fiat cents"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"When the transaction occurred on-chain"},{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Record creation time in UTC"},{name:"transaction_status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Status: 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked payment ID for PAYMENT type transactions"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Type: 1=PAYMENT, 2=REWARD, 3=SEND, 4=SERVICE_FEE, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 14=CLAIM_LINK"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Direction: 1=INFLOW (received), -1=OUTFLOW (sent)"},{name:"wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Counterparty wallet address (sender if INFLOW, recipient if OUTFLOW)"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"On-chain transaction hash"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Blockchain network type"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Block number of the on-chain transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"User-provided memo or notes"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Cryptocurrency type (e.g. USDT)"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Fiat currency type (e.g. USD, CNY)"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee = network_fee + service_fee"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"On-chain gas/network fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"AllScale platform service fee"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Counterparty's business ID if they are an AllScale user"},{name:"claim_link_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked claim link ID for CLAIM_LINK type transactions"}]},{name:"ActivityItemPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItem",ofType:null}}}},description:null}]},{name:"AuthorizedPolicyPair",kind:"OBJECT",description:null,fields:[{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain identified by its BlockChainType value (for example BASE = 5) \u2014 not the EIP-155 chain id."},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Stablecoin symbol: USDT or USDC"}]},{name:"AutoPayoutSessionStatus",kind:"OBJECT",description:null,fields:[{name:"provisioned",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether auto-payout setup has been completed for this merchant."},{name:"active",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"True iff provisioned AND the session has not expired (the runtime auto-pay gate)"},{name:"session_expires_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"Session expiry (drives the countdown); null when not provisioned"},{name:"total_cap_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified session total cap in USD (decimal string); null when not provisioned"},{name:"used_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Cumulative USD spent (reserved + committed) this session (decimal string); populated only for an ACTIVE session, else null"},{name:"remaining_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"max(0, total_cap - used) in USD (decimal string); populated only for an ACTIVE session, else null"},{name:"per_transaction_limit",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified single-transaction limit (token-unit decimal string, stablecoin $ 1:1) recorded when auto-payout is enabled; null when not provisioned or when recorded entries have different limits. Retained after a session expires, so it still reports what was recorded."},{name:"authorized_pairs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AuthorizedPolicyPair",ofType:null}}}},description:"The (chain, stable-coin) pairs the merchant authorized when enabling auto-payout; empty when auto-payout was never provisioned. Retained after a session expires, so it still reports what was authorized."},{name:"sponsor_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Lowercased sponsor address used to validate authorized payouts. Populated whether or not auto-payout is provisioned, so it is readable while enabling; null when unavailable."}]},{name:"Business",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"user name"},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"email of the user"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"description of the user"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the business"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address field for business"},{name:"country",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"country code of business"},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"contact name of business"},{name:"contact_avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact avatar url of business"},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact phone of business"},{name:"avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"avatar url of business"},{name:"default_currency",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"default currency for business"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the business"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax id of the business"},{name:"about",type:{kind:"SCALAR",name:"String",ofType:null},description:"about of the business, can be changed by business"},{name:"business_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"business type"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of accepted stablecoins for invoices (StableCoinFlag)"},{name:"employee_count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"total active employees in the business"}]},{name:"BusinessContact",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Display name of the business's user account."},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Login email of the business's user account."},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Contact person the business presents on its invoices. Preferred over `name` when both are set."},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"Contact phone the business presents on its invoices. Null when the business has not set one."}]},{name:"ClaimLink",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim link id"},{name:"business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"sender business that owns the link"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"ClaimLinkStatus lifecycle state"},{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount, decimal string in token units"},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"stablecoin symbol, e.g. USDT / USDC"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"BlockChainType the link is locked to"},{name:"sender_display_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name shown to the receiver (person or Store name)"},{name:"sender_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional message shown on the claim page"},{name:"receiver_email",type:{kind:"SCALAR",name:"String",ofType:null},description:"receiver email, if the sender supplied one"},{name:"reference_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"Optional merchant-supplied reference identifier."},{name:"expected_deposit_total",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the expected POOL balance (principal). The sender's gross outlay is the fee breakdown's total"},{name:"service_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"AllScale service fee fixed when the claim link is created; null when not applicable."},{name:"network_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"Network fee fixed when the claim link is created; null when not applicable."},{name:"funded_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the deposit actually received at the pool wallet"},{name:"funded_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the confirming sender deposit"},{name:"expiry_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC; the resolved claim-window deadline (funded_at + the chosen window, default 14d); None until link_sent"},{name:"claimed_via",type:{kind:"SCALAR",name:"String",ofType:null},description:"how it was claimed: masked receiver email or 0x address"},{name:"claim_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the successful claim"},{name:"refund_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the expiry refund back to the sender"},{name:"refunded_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC when the expiry refund proved on-chain"},{name:"cancel_requested_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC timestamp set when the sender requests cancellation while a claim is in progress. The request stays pending until the in-flight payout resolves: it is cleared if that payout completes (the cancellation is moot and the link is claimed), and retained if the payout did not go through and the link is cancelled and refunded. Null therefore means either no mid-claim cancellation was requested, or one that was resolved by a completed payout."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL returned by create and single-link detail operations. The sender distributes this URL themselves; it is never emailed to the receiver. Null when unavailable, and always null on list operations \u2014 selecting it there returns the field as null rather than omitting it."}]},{name:"ClaimLinkFeeBreakdown",kind:"OBJECT",description:null,fields:[{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount the receiver gets, decimal string"},{name:"network_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"gas reserve = gas_shares \xD7 per_transfer_gas, decimal string"},{name:"service_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"AllScale service fee for the chain, decimal string"},{name:"total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"amount + network_fee + service_fee \u2014 what the sender pays"},{name:"per_transfer_gas",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"one transfer's gas in token units (echoed for audit)"},{name:"gas_shares",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Number of per_transfer_gas shares reserved; currently 2 for a single claim link."}]},{name:"ClaimLinkPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}}}},description:null}]},{name:"CoinBalanceEmbedded",kind:"OBJECT",description:null,fields:[{name:"coin_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Stablecoin held, as the numeric StableCoin value (1 = USDT, 2 = USDC). `wallet list` decorates each balance with the derived `coin_name`."},{name:"balance",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Decimal",ofType:null}},description:"Balance of the coin"}]},{name:"Contact",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"id of the contact"},{name:"owner_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"owner id of the contact"},{name:"contact_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"contact id if contact is allscale business"},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name of the contact"},{name:"binding_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"the way of binding an allscale business id to the contact, by email matching(1) or scan qrcode(2), etc."},{name:"email",type:{kind:"SCALAR",name:"String",ofType:null},description:"email of the contact"},{name:"evm_wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"evm wallet address of the contact"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax number of the contact"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address of the contact"},{name:"phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"phone number of the contact"},{name:"last_payment_created_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last payment date of the contact"},{name:"last_paid_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last successful pay date"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"Free-form description of the contact."},{name:"is_favourite",type:{kind:"SCALAR",name:"Boolean",ofType:null},description:"is favourite or not"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the contact"}]},{name:"ContactPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}}}},description:null}]},{name:"CreateClaimLinkInput",kind:"INPUT",description:null,inputFields:[{name:"amount",description:"claim amount, decimal string in token units (e.g. '10.5')",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"token_symbol",description:"stablecoin symbol: 'USDT' or 'USDC'",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"BlockChainType value the link is locked to (EVM only)",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"per_transfer_gas",description:"one ERC-20 transfer's gas in TOKEN units (decimal string); from the App's withdraw estimate",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"receiver_email",description:"optional receiver email \u2014 a SENDER-SIDE LABEL ONLY, recording who the link is meant for. AllScale does NOT email the receiver (no invite, no expiry reminder, no resend); the sender must distribute `claim_url` themselves.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_display_name",description:"name shown to the receiver (person or Store name)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_message",description:"optional message shown on the claim page (<= 200 chars)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"idempotency_key",description:"optional client retry-safety token; a retried create with the same key returns the existing link instead of a duplicate",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_window_seconds",description:"Optional positive claim-window duration in seconds. Defaults to 14 days. The window starts when funding is confirmed; after it expires, unclaimed funds are returned to the sender.",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreateClaimLinkResult",kind:"OBJECT",description:null,fields:[{name:"claim_link",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},description:"the newly created link (pending_deposit)"},{name:"claim_token",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Bearer claim token returned only when the claim link is created and never available again. Capture and store it securely immediately; it preserves claim authority when claim_url is unavailable."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL; null when no claim-page URL is configured."},{name:"pool_wallet_address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"ERC-4337 address the sender funds"},{name:"expected_deposit_total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"the expected POOL balance (principal), decimal string; the sender's gross outlay is the fee breakdown's total"},{name:"fees",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkFeeBreakdown",ofType:null}},description:"the frozen fee breakdown"}]},{name:"CreateContactInput",kind:"INPUT",description:null,inputFields:[{name:"owner_business_id",description:"owner id of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"name",description:"name of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"email",description:"email of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"evm_wallet_address",description:"evm wallet address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"address",description:"address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"phone",description:"phone number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_number",description:"tax number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"description",description:"Free-form description of the contact.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"binding_type",description:"binding type of the contact",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"sender_contact_id",description:"contact id of the payer/sender",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"payment_type",description:"payment type of the payment",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"accepted_stable_coins",description:"optional per-invoice bitflag (StableCoinFlag) overriding the recipient business's accepted_stable_coins setting",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"payment_extra_info",description:"payment extra info of the payment, JSON object string",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"currency",description:"currency of the payment, only if the payment_type is CURRENCY",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_cents",description:"amount of the payment in cents",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_coins",description:"amount of the payment in coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"html_template",description:"HTML template for the invoice",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_id",description:"optional taxpayer identification for the invoice",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"datetime the payment is due",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"},{name:"wallets",description:"list of wallets address",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"PlainWalletEmbeddedInput",ofType:null}}}},defaultValue:null}]},{name:"CreateStoreInput",kind:"INPUT",description:null,inputFields:[{name:"name",description:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"logo_url",description:"logo url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:null},{name:"business_id",description:"pay account business id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"type",description:"type of the store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"default_timeout_seconds",description:"default timeout seconds for checkout intents",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"3600"},{name:"swidge_enabled",description:"whether Swidge cross-chain checkout is enabled for this store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"claim_link_claim_notify_enabled",description:"Whether AllScale sends merchant claim-notification emails for this store; defaults to false.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"false"},{name:"description",description:"description",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"scopes",description:"permission scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:'["*"]'},{name:"ip_allowlist",description:"allowed IPs/CIDRs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:"[]"},{name:"is_sandbox",description:"Whether to create the store in sandbox mode.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"rate_limit_per_minute",description:"Optional request-per-minute limit; defaults to 300, and 0 uses the platform default.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"300"},{name:"replay_window_seconds",description:"override replay window seconds",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_webhook",description:"transaction webhook url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_link_webhook_url",description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"redirect_url",description:"Redirect URL used after payment completes.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"fee_rate",description:"fee rate",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"accepted_stable_coins",description:"bitflag of accepted stablecoins for checkout (StableCoinFlag); null inherits from business",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"Payment",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the payment"},{name:"recipient_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"business id of the payee/recipient"},{name:"sender_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the payer/sender"},{name:"sender_contact_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"contact id of the payer/sender"},{name:"payment_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"payment type of the payment"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of stablecoins accepted for this payment (StableCoinFlag). None on payments created before the multi-coin rollout."},{name:"payment_extra_info",type:{kind:"SCALAR",name:"String",ofType:null},description:"payment extra info of the payment, JSON object string"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the payment, only if the payment_type is CURRENCY"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the payment"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount of the payment in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount of the payment in coins"},{name:"invoice_url",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice url of the payment"},{name:"invoice_visible_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice visible id of the pdf"},{name:"tax_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional taxpayer identification for the invoice"},{name:"error_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"error message of the payment if status is failed"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the payment"},{name:"due_datetime",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"datetime the payment is due"},{name:"display_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"display amount of the payment"},{name:"encrypted_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Opaque payment identifier used in public payment links."}]},{name:"PaymentPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}}}},description:null}]},{name:"PlainWalletEmbeddedInput",kind:"INPUT",description:null,inputFields:[{name:"id_str",description:"Unique identifier for the wallet",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"Blockchain type of the address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"address",description:"Blockchain address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}]},{name:"QueryInput",kind:"INPUT",description:null,inputFields:[{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"order_by",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"},{name:"raw_filter_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:'"{}"'},{name:"created_at_lte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"created_at_gte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"}]},{name:"Store",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Unique store identifier."},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name"},{name:"type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the store"},{name:"scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},description:"permission scopes"},{name:"is_sandbox",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether this store uses sandbox mode."},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the store"},{name:"transaction_webhook",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction webhook url"},{name:"claim_link_webhook_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook."},{name:"redirect_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Redirect URL used after payment completes."}]},{name:"StoreCreateResult",kind:"OBJECT",description:null,fields:[{name:"store",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Store",ofType:null}},description:"store"},{name:"api_secret",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Store API secret returned only when the store is created and never available again. Capture and store it securely immediately."}]},{name:"Transaction",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the transaction record"},{name:"owner_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"owner user type of the record"},{name:"owner_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id that owns this transaction record"},{name:"owner_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id that owns this transaction record"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the transaction"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"direction of the transaction"},{name:"reference_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"reference type of the related record"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"payment id when reference_type is PAYMENT"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the counterparty"},{name:"counterparty_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id of the counterparty"},{name:"counterparty_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name of the counterparty"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"payment type if this is a payment transaction"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the transaction"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount in coins"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the transaction"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"actual transaction time"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"hash of the transaction"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block chain of the transaction"},{name:"tx_from",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction sender address"},{name:"tx_to",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction receiver address"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block number of the transaction"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee (network_fee + service_fee)"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Network/gas fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Allscale service fee (0.03%)"}]},{name:"TransactionPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}}}},description:null}]},{name:"UpdatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_business_id",description:"sender business id of the payer",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"new payment deadline for an OVERDUE invoice. Only an overdue invoice may be extended, and only FORWARD. Extending past now also revives the invoice (back to SENT/ACKNOWLEDGED) so buyers can pay again.",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"}]},{name:"WalletEmbedded",kind:"OBJECT",description:null,fields:[{name:"id_str",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet id"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain the wallet lives on, as the numeric BlockChainType value (NOT a name). `wallet list` decorates each wallet with the derived `chain_name` and `eip155_chain_id`."},{name:"address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet address"},{name:"coin_balances",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"OBJECT",name:"CoinBalanceEmbedded",ofType:null}}},description:"wallet balance"}]}];var Je=new Set(["SCALAR","ENUM"]),ca=new Set(["password","password_hash","totp_secret","credential","credentials","private_key","encryption_key"]),da=[/(^|_)password(_|$)/i,/(^|_)secret(_|$)/i,/(^|_)token(_|$)/i,/(^|_)api[_-]?key(_|$)/i,/(^|_)signing[_-]?key(_|$)/i,/(^|_)private[_-]?key(_|$)/i,/(^|_)credential(_|$)/i],ua=new Set(["CreateClaimLinkResult.claim_token","StoreCreateResult.api_secret"]),pa=new Map([["StoreCreateResult.store",["id","name"]],["CreateClaimLinkResult.claim_link",["id","token_symbol","status"]]]),fa=new Set(["token_symbol"]),ma=new Set;function Hn(e,n){return ma.has(`${e}.${n}`)}function x(e){return fa.has(e.toLowerCase())?!1:ca.has(e)?!0:da.some(n=>n.test(e))}function ya(e,n){return ua.has(`${e}.${n}`)}function Wn(e){return e.kind==="NON_NULL"&&e.ofType?`${Wn(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${Wn(e.ofType)}]`:e.name??"Unknown"}function N(e){let n=e;for(;n&&n.ofType;)n=n.ofType;return!n||!n.name?null:{kind:n.kind,name:n.name}}function zn(e,n){let t=n.find(a=>a.name===e);if(!t||t.kind==="SCALAR"||t.kind==="ENUM")return"";if(t.kind==="UNION")return"__typename";let i=t.fields??[];if(i.length===0)return"";let r=[],o=!1;for(let a of i){let l=N(a.type);if(!l)continue;if(Je.has(l.kind)){if(x(a.name)&&!ya(e,a.name)||Hn(e,a.name))continue;r.push(a.name);continue}let s=pa.get(`${e}.${a.name}`);if(s){let u=n.find(m=>m.name===l.name),f=new Set((u?.fields??[]).filter(m=>{let g=N(m.type);return g!==null&&Je.has(g.kind)&&!x(m.name)}).map(m=>m.name)),p=s.filter(m=>!f.has(m));if(p.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${p.join(", ")}] that are not selectable scalars on ${l.name}; fix the entry or the public registry.`);let y=s.filter(m=>Hn(l.name,m));if(y.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${y.join(", ")}] that DEFAULT_SELECTION_EXCLUSIONS keeps out of default selections on ${l.name}; drop the field from the nested entry, or remove the exclusion if it is no longer true.`);r.push(`${a.name} { ${s.join(" ")} }`);continue}if(!o&&a.name==="items"&&a.type.kind==="NON_NULL"&&a.type.ofType?.kind==="LIST"){let u=ha(a.type)?.name;if(u){let f=ga(u,n);f&&r.push(`items { ${f} }`),o=!0}}}return r.length>0?r.join(" "):"__typename"}function ha(e){return N(e)}function ga(e,n){let t=n.find(o=>o.name===e);if(!t||t.kind==="UNION")return"__typename";let i=t.fields??[],r=[];for(let o of i){let a=N(o.type);if(a&&Je.has(a.kind)){if(x(o.name)||Hn(e,o.name))continue;r.push(o.name)}}return r.length>0?r.join(" "):"__typename"}function Oi(e,n,t){let i=_a(e.name),r=e.args.map(f=>{let p=Wn(f.type);return f.defaultValue!==null&&f.defaultValue!==void 0?`$${f.name}: ${p} = ${f.defaultValue}`:`$${f.name}: ${p}`}).join(", "),o=e.args.map(f=>`${f.name}: $${f.name}`).join(", "),a=r.length>0?`${e.kind} ${i}(${r})`:`${e.kind} ${i}`,l=o.length>0?`${e.name}(${o})`:e.name,s=N(e.returnType),u;if(s&&Je.has(s.kind))u=l;else{let f=t&&t.trim().length>0?t.trim():s&&zn(s.name,n)||"__typename";u=`${l} { ${f} }`}return`${a} { ${u} }`}function Ri(e,n){let i=e.args.filter(r=>r.type.kind==="NON_NULL"&&r.defaultValue===null).map(r=>r.name).filter(r=>!(r in n));return i.length===0?{ok:!0}:{ok:!1,missing:i}}function He(e,n,t){return e.find(i=>i.kind===n&&i.name===t)??null}function Ii(e){if(!e||typeof e!="object")return!1;let n=e.errors;return Array.isArray(n)&&n.length>0}function vi(e,n=3){let t=e.errors;return!Array.isArray(t)||t.length===0?"":t.slice(0,n).map(i=>typeof i=="object"&&i!==null&&typeof i.message=="string"?i.message:JSON.stringify(i)).join("; ")}function _a(e){return e.replace(/[^_0-9A-Za-z]/g,"_")}var Sa=new Set;var Aa=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","claim_link:read_only","claim_link:all","transaction:read_only","transaction:all","store:read_only","store:all","wallet:read_only","wallet:all"]),Xn=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","transaction:read_only","wallet:read_only","wallet:all","claim_link:read_only","claim_link:all","store:read_only","store:all"]),Qn=new Set(["payroll","admin:user","admin:org","admin:audit"]);function We(e){let n=e.lastIndexOf(":");return n===-1?e:e.slice(0,n)}function Zn(e,n){if(e===n)return!0;let t=":read_only";return n.endsWith(t)&&e===`${n.slice(0,-t.length)}:all`}var ka=new Set(["cli_op:all"]),Ta=new Set([...ka].map(We));var ql=new Set([...[...Aa,...Xn,...Sa].map(We),...Qn,...Ta]);var La={payments:"invoice:read_only",payment:"invoice:read_only",sender_payments:"invoice:read_only",recipient_payments:"invoice:read_only",business_contact_by_email:"invoice:read_only",create_payment:"invoice:all",update_payment:"invoice:all",contact_by_email:"contact:read_only",contact:"contact:read_only",contacts:"contact:read_only",create_contact:"contact:all",transaction:"transaction:read_only",my_transactions:"transaction:read_only",business_transaction_records:"transaction:read_only",activities:"transaction:read_only",business_wallets:"wallet:read_only",business_invoice:"payroll:read_only",auto_payout_session_status:"store:read_only",create_store:"store:all",my_claim_links:"claim_link:read_only",claim_link:"claim_link:read_only",claim_link_fee_preview:"claim_link:read_only",claim_link_limits:"claim_link:read_only",create_claim_link:"claim_link:all",claim_link_funding_by_idempotency_key:"claim_link:all"},ba={business:"the broad `business` query is default-denied for agent keys by design \u2014 no scope grants it, because allowing the entry point would expose every nested field of the Business type"},wa=/API key scope not granted:\s*requires\s+(.+?),\s*key has\s+(.+?)\.?\s*$/i,Ea=/is not available to API keys/i,xi=/^[a-z_]+(?::[a-z_]+)*:[a-z_]+$/;function Pi(e){if(typeof e!="string")return;let n=wa.exec(e);if(!n)return;let t=n[1].trim(),i=n[2].trim(),r=Ea.test(t),o=!r&&xi.test(t)?t:void 0,a;if(i.toLowerCase()==="none")a=[];else{let l=i.split(",").map(s=>s.trim()).filter(s=>xi.test(s));a=l.length>0?l:void 0}if(!(o===void 0&&!r))return{required:o,granted:a,notAvailableToKeys:r}}function Ui(e){let n=ba[e];if(n!==void 0)return{ungrantableReason:n};let t=La[e];if(t!==void 0)return{scope:t}}function Bi(e){if(Qn.has(We(e)))return{kind:"ungrantable"};for(let n of Xn)if(Zn(n,e))return{kind:"approval_screen"};return{kind:"otp_login_only"}}var Na=8100,Ca=new Set([Na]),Oa=new Set([...Ca,3e3,3200,3300,3400,3500,3600,4e3,4100,4200,4300,4400,4600,4700,4800,4900,4901,5e3,5200,5300,5400,5500,5600,6050,8300,8301,8302,8306]);function $i(e,n){let t=Fi(e),i={graphql_error_count:Ra(e.errors),...t===void 0?{}:{backend_code:t}};if(t===2102)throw Ia(e,n,i);if(t===429)throw new c("rate_limited",`GraphQL ${n.kind} '${n.operationName}' was rate limited. Retry after a backoff.`,i);if(t===1002)throw new c("auth.permission_denied",`The signed-in account is not permitted to perform GraphQL ${n.kind} '${n.operationName}'. This is a role or ownership restriction, not a missing agent-key scope \u2014 re-authorizing will not grant it.`,i);if(t!==void 0&&Oa.has(t))throw new c("not_found",`GraphQL ${n.kind} '${n.operationName}' could not find the requested resource.`,i);if(Ii(e))throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' returned errors: ${vi(e)}`,i);if(t!==void 0)throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' failed with backend code ${t}.`,i)}function Fi(e){let n=Di(e.code);if(n!==void 0)return n;if(Array.isArray(e.errors))for(let t of e.errors){if(!t||typeof t!="object")continue;let i=t.extensions;if(!i||typeof i!="object")continue;let r=Di(i.code);if(r!==void 0)return r}}function Di(e){if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d+$/.test(e)){let n=Number(e);if(Number.isSafeInteger(n)&&n>0)return n}}function Ra(e){return Array.isArray(e)?e.length:e==null?0:1}function Ia(e,n,t){let i=`GraphQL ${n.kind} '${n.operationName}'`,r={...t,operation:n.operationName},o=Pi(va(e,Fi(e))),a=Ui(n.operationName),l=o?.notAvailableToKeys===!0,s=o?.required??a?.scope,u=o?.granted,f=u===void 0?"":` This key holds ${u.length>0?u.join(", "):"no scopes"}.`;if(l||a?.ungrantableReason!==void 0){let p=a?.ungrantableReason!==void 0?`: ${a.ungrantableReason}`:"";return new c("auth.permission_denied",`${i} is not available to agent keys${p}. Re-authorizing will NOT help \u2014 no scope grants it.${f} Use a command that does not need it, or perform this action in the AllScale dashboard.`,{...r,missing_scopes:[],...u===void 0?{}:{granted_scopes:u},ungrantable:!0})}if(s!==void 0){let p=Bi(s),y=p.kind==="ungrantable"?`\`${s}\` cannot be granted to any key (the backend clips this category to nothing), so re-authorizing will NOT help.`:p.kind==="approval_screen"?`Re-run \`allscale device-login\` and enable it on the approval screen, or \`${Q()}\` with \`--scopes ${s}\`.`:`The browser approval screen does not offer \`${s}\`, so \`device-login\` cannot grant it \u2014 use \`${Q()}\` with \`--scopes ${s}\`.`;return new c("auth.permission_denied",`The current agent key lacks \`${s}\`, required by ${i}.${f} ${y}`,{...r,missing_scopes:[s],...u===void 0?{}:{granted_scopes:u},...p.kind==="ungrantable"?{ungrantable:!0}:{}})}return new c("auth.permission_denied",`The current agent key does not have the scope required by ${i}.${f} Re-run \`allscale device-login\` (or \`${Q()}\`) and grant the required scope.`,r)}function va(e,n){let t=e.errors;if(typeof t=="string")return t;if(!Array.isArray(t))return"";let i=r=>{if(r===null||typeof r!="object")return;let o=r.message;return typeof o=="string"?o:void 0};if(n!==void 0)for(let r of t){if(r===null||typeof r!="object")continue;let o=r.extensions;if(!o||typeof o!="object")continue;let a=o.code;if(a===n||typeof a=="string"&&Number(a)===n){let s=i(r);if(s!==void 0)return s}}for(let r of t){let o=i(r);if(o!==void 0)return o}return""}async function ze(e,n,t,i,r={}){let o=He(Ye,n,t);if(!o)throw new c("input.invalid",`No ${n} named '${t}' in the schema. Run \`allscale operations --kind ${n}\` to list options.`);let a=Ri(o,i);if(!a.ok)throw new c("input.invalid",`Missing required variables for ${t}: ${a.missing.join(", ")}`,{required:a.missing});let l=Oi(o,$,r.selection);return xa(e,{...r,kind:n,operationName:o.name,document:l,variables:i})}async function xa(e,n){n.showDoc&&process.stderr.write(`${n.document}
|
|
17
|
+
`);let t=Ci(e),i=n.path??"/api/secure/graphql",r=await t.request({method:"POST",path:i,responseKind:n.kind,body:{query:n.document,...Object.keys(n.variables).length>0?{variables:n.variables}:{},operationName:n.operationName}});$i(r,{kind:n.kind,operationName:n.operationName});let o=r.data?.[n.operationName];return o===void 0?null:o}function Pa(e,n){try{return JSON.parse(e)}catch(t){throw new c("input.invalid",`${n} is not valid JSON: ${t.message}`)}}var Ua=50;function Ba(e,n){if("raw_filter_str"in e)throw new c("input.invalid","--input must not contain 'raw_filter_str': it is a raw Mongo query document and the CLI refuses to pass one through. Use the typed QueryInput fields instead \u2014 created_at_gte / created_at_lte for creation-time bounds"+(n?`, or ${n}`:"")+".")}function Mi(e){if(typeof e.input=="string"&&e.input.length>0){let n=Pa(e.input,"--input");if(n===null||typeof n!="object"||Array.isArray(n))throw new c("input.invalid","--input must be a JSON object (the QueryInput shape).");let t=n;return Ba(t,e.typedAlternatives),t}return e.all?{limit:0}:{limit:Ua}}var Gi="Override the default selection set with a GraphQL fragment.",qi="Pass --show-doc to print the exact GraphQL document that gets sent.";function ji(...e){let n=Da(...e);if(n.length===0)return`${Gi} ${qi}`;let t=[];for(let a of n){let l=t.find(s=>s.typeName===a.typeName);l?l.labels.push(...a.labels):t.push({...a,labels:[...a.labels]})}let i=[Gi],r=n.length<e.length,o=t.length>1||r;for(let a of t){let l=o&&a.labels.length>0?`Default (${a.labels.join(", ")})`:"Default";a.preset&&i.push(`${l}: '${a.preset}'.`);for(let s of a.others){let u=s.example?` Object and list fields among them need their own sub-selection, e.g. --select '${s.example}'.`:"",f=s.hasSuppressedFields?" This list is not exhaustive \u2014 a deliberately broad credential-name filter withholds some fields from it.":"";if(s.fields.length===0){i.push(`Beyond the default, ${s.typeName} has further selectable fields, all withheld by a deliberately broad credential-name filter.`);continue}i.push(`Other selectable fields on ${s.typeName}: ${s.fields.join(", ")}.${u}${f}`)}}return i.push(qi),i.join(" ")}function Da(...e){return e.map(n=>{try{return $a(n)}catch{return null}}).filter(n=>n!==null)}function $a(e){let n=He(Ye,e.kind,e.name);if(!n)return null;let t=N(n.returnType);if(!t)return null;let i=e.preset?.trim();if(e.preset!==void 0&&!i)return null;let r=i??zn(t.name,$),o=$.find(y=>y.name===t.name),a=new Set(nt(r)),l=(o?.fields??[]).filter(y=>!a.has(y.name)),s=l.filter(y=>!x(y.name)),u=[],f=l.length-s.length;(s.length>0||f>0)&&u.push({typeName:t.name,fields:s.map(y=>y.name),example:Ki(s,et(nt(r),t.name)),hasSuppressedFields:f>0});let p=Fa(o,a,r);return p&&u.push({typeName:`${t.name}.${p.fieldName} (${p.typeName})`,fields:p.others.map(y=>y.name),example:Ki(p.others,p.anchorField,p.fieldName,p.wrapperScalars),hasSuppressedFields:p.hasSuppressedFields}),{labels:e.label?[e.label]:[],typeName:t.name,preset:r,others:u}}function Fa(e,n,t){let i=null;for(let r of e?.fields??[]){if(!n.has(r.name))continue;let o=N(r.type);if(!o||Xe.has(o.kind))continue;let a=$.find(p=>p.name===o.name);if(!a)continue;let l=nt(Ma(t,r.name)??""),s=new Set(l),u=(a.fields??[]).filter(p=>!s.has(p.name)),f=u.filter(p=>!x(p.name));if(f.length===0){u.length>0&&i===null&&(i={fieldName:r.name,typeName:o.name,others:[],hasSuppressedFields:!0,anchorField:et(l,o.name),wrapperScalars:[]});continue}return{fieldName:r.name,typeName:o.name,others:f,hasSuppressedFields:u.length>f.length,anchorField:et(l,o.name),wrapperScalars:(e?.fields??[]).filter(p=>{if(p.name===r.name||!n.has(p.name)||x(p.name))return!1;let y=N(p.type);return y!==null&&Xe.has(y.kind)}).map(p=>p.name)}}return i}function et(e,n){let t=$.find(r=>r.name===n),i=r=>{if(x(r))return!1;let o=(t?.fields??[]).find(l=>l.name===r),a=o?N(o.type):null;return a!==null&&Xe.has(a.kind)};return e.includes("id")&&i("id")?"id":e.find(i)??null}function Ki(e,n,t,i=[]){for(let r of e){let o=N(r.type);if(!o)continue;let l=($.find(s=>s.name===o.name)?.fields??[]).filter(s=>{let u=N(s.type);return u!==null&&Xe.has(u.kind)}).map(s=>s.name).filter(s=>!x(s)).slice(0,2);if(l.length>0){let s=`${r.name} { ${l.join(" ")} }`,u=n?`${n} ${s}`:s;return t?[...i,`${t} { ${u} }`].join(" "):u}}return null}var Xe=new Set(["SCALAR","ENUM"]);function nt(e){let n=[],t=0;for(let i of Vi(e))i==="{"?t+=1:i==="}"?t=Math.max(0,t-1):t===0&&n.push(i);return n}function Ma(e,n){let t=Vi(e),i=0;for(let r=0;r<t.length;r+=1){let o=t[r];if(o==="{"){i+=1;continue}if(o==="}"){i=Math.max(0,i-1);continue}if(i!==0||o!==n||t[r+1]!=="{")continue;let a=[],l=0;for(let s=r+1;s<t.length;s+=1){let u=t[s];if(u==="{"){if(l+=1,l===1)continue}else if(u==="}"&&(l-=1,l===0))return a.join(" ");a.push(u)}return a.join(" ")}return null}function Vi(e){return e.split(/([{}])/).flatMap(n=>n==="{"||n==="}"?[n]:n.split(/\s+/)).filter(n=>n.length>0)}async function Qe(e){if(e.token)return{kind:"override",accessToken:e.token};let t=await Fe({insecureStorage:e.insecureStorage}).get(e.profile),i=t?.api_base;return t?.agent_key?{kind:"agent",storedApiBase:i,businessId:tt(t.business_id),userEmail:tt(t.user_email),scopes:Ga(t.scopes)}:t?.access_token?{kind:"human",storedApiBase:i,accessToken:t.access_token,userEmail:tt(t.user_email)}:{kind:"none"}}function tt(e){return typeof e=="string"&&e.length>0?e:void 0}function Ga(e){if(!Array.isArray(e))return;let n=e.filter(t=>typeof t=="string"&&t.length>0);return n.length>0?n:void 0}function Ji(e){let n=e.split(".");if(n.length!==3)throw new c("auth.token_invalid","This token is not a JWT session. Agent API keys are not JWTs \u2014 this path needs a human session token.");let t;try{let i=Buffer.from(n[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");t=JSON.parse(i)}catch{throw Yi()}if(typeof t!="object"||t===null||Array.isArray(t))throw Yi();return t}function Yi(){return new c("auth.token_invalid","The provided token is not a valid JWT credential \u2014 its payload could not be decoded. Check the --token / ALLSCALE_TOKEN value, or re-authenticate to obtain a fresh session.")}async function it(e,n){if(typeof n=="string"&&n.length>0)return n;let t=await Qe(e);switch(t.kind){case"override":case"human":return Ka(t.accessToken);case"agent":if(t.businessId!==void 0)return t.businessId;throw new c("input.invalid","Agent-key sessions carry no JWT to derive the business id from \u2014 pass --business-id explicitly. (Re-run `allscale device-login` to store your business id automatically.)");case"none":throw qe({profile:e.profile,profileExplicit:e.profileExplicit});default:return qa(t)}}function qa(e){throw new c("internal",`Unhandled credential kind: ${JSON.stringify(e.kind)}`)}function Ka(e){let n=Ji(e),t=typeof n.user_id=="string"?n.user_id:void 0;if(!t)throw new c("input.invalid","Could not infer --business-id from the cached JWT (no user_id claim). Pass --business-id explicitly.");return t}var ja=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,9}))?\s*(Z|[+-]\d{2}:?\d{2})?)?$/i,rt="YYYY-MM-DDTHH:MM:SS.ffffffZ",Ze=`Accepts a date (2026-08-05), a naive datetime (2026-08-05T12:30:00, read as UTC), or an offset datetime (2026-08-05T20:30:00+08:00); the CLI converts to UTC and pads it to the backend's required ${rt}.`;function H(e,n){return new c("input.invalid",`${n} is not a datetime the CLI can read: '${e}'. ${Ze}`)}var Va=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z$/,Ya=/^(\d{4})-(\d{1,2})-( ?[1-9]|\d{1,2})T(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,6})Z$/;function Hi(e,n,t={}){let i=e.trim(),r=ja.exec(i);if(!r)throw H(e,n);let[,o,a,l,s,u,f,p,y]=r,m=s===void 0,g=Number(o),A=Number(a),C=Number(l),O=m?0:Number(s),P=m?0:Number(u),U=m||f===void 0?0:Number(f);if(A<1||A>12||C<1||C>31||O>23||P>59||U>59)throw H(e,n);let st=m?"":p??"",se=st.padEnd(6,"0").slice(0,6),lt=/[1-9]/.test(st.slice(6)),nn=0;if(y!==void 0&&y.toUpperCase()!=="Z"){let ce=y.startsWith("-")?-1:1,B=y.slice(1).replace(":",""),dt=Number(B.slice(0,2)),ut=Number(B.slice(2,4));if(dt>23||ut>59)throw H(e,n);nn=ce*(dt*60+ut)}let le=Date.UTC(g,A-1,C,O,P,U)-nn*6e4;if(Number.isNaN(le))throw H(e,n);let tn=new Date(le+nn*6e4);if(tn.getUTCFullYear()!==g||tn.getUTCMonth()!==A-1||tn.getUTCDate()!==C)throw H(e,n);let ct=ce=>{let B=Number(se)+ce;B<0?(se="999999",le-=1e3):B>999999?(se="000000",le+=1e3):se=String(B).padStart(6,"0")};t.exclusive?lt||ct(-1):lt&&ct(1);let W=new Date(le),z=(ce,B=2)=>String(ce).padStart(B,"0");return`${z(W.getUTCFullYear(),4)}-${z(W.getUTCMonth()+1)}-${z(W.getUTCDate())}T${z(W.getUTCHours())}:${z(W.getUTCMinutes())}:${z(W.getUTCSeconds())}.${se}Z`}function Wi(e,n,t){let i={...e},r=[["from",t.lowerKey,!1],["to",t.upperKey,!0]];for(let[s,u,f]of r){let p=n[s];if(!(typeof p!="string"||p.length===0)){if(i[u]!==void 0&&i[u]!==null)throw new c("input.invalid",`--${s} conflicts with '${u}' already set in --input. Pass one or the other, not both.`);i[u]=Hi(p,`--${s}`,{exclusive:f})}}let o=s=>{if(typeof s!="string"||s.length===0)return;if(Va.test(s))return s;let u=Ya.exec(s);if(u){let[,f,p,y,m,g,A,C]=u,O=(P,U=2)=>P.trim().padStart(U,"0");return`${f}-${O(p)}-${O(y)}T${O(m)}:${O(g)}:${O(A)}.${(C??"").padEnd(6,"0")}Z`}try{return Hi(s,"--input",{exclusive:!1})}catch{return}},a=o(i[t.lowerKey]),l=o(i[t.upperKey]);if(a!==void 0&&l!==void 0&&a>l)throw new c("input.invalid",`The ${t.rangeNoun} range is empty: the lower bound (${a}) is after the upper bound (${l}). Remember --to is EXCLUSIVE, so --from and --to may not name the same instant.`);return i}var Xi=new Map([["OVERDUE",-4],["FAILED",-1],["DRAFT",0],["SENT",1],["ACKNOWLEDGED",2],["PROCESSING",3],["PAID",10]]),Ja=new Set(["CURRENCY","FIAT"]);function ot(){return[...Xi.keys()]}function Ha(e){let n=e.trim(),t=Xi.get(n.toUpperCase());if(t!==void 0)return t;if(/^-?\d+$/.test(n))return Number(n);throw new c("input.invalid",`--status '${e}' is not a known invoice status. Accepted: ${ot().join(", ")} (case-insensitive), or a raw integer.`)}function Wa(e){let n=e.trim();if(Ja.has(n.toUpperCase()))return 0;let t=Jt(n);if(t!==null)return t;if(/^-?\d+$/.test(n))return Number(n);throw new c("input.invalid",`--payment-type '${e}' is not a known invoice currency. Accepted: CURRENCY (fiat), ${ve().join(", ")} (case-insensitive), or a raw integer.`)}function zi(e){let n=[...new Set(e)];return n.length===1?n[0]:{$in:n}}function Qi(e,n){let t=Wi(e,n,{lowerKey:"created_at_gte",upperKey:"created_at_lte",rangeNoun:"creation-date"}),i={};if(Array.isArray(n.status)&&n.status.length>0&&(i.status=zi(n.status.map(Ha))),Array.isArray(n["payment-type"])&&n["payment-type"].length>0&&(i.payment_type=zi(n["payment-type"].map(Wa))),typeof n.toContactId=="string"&&n.toContactId.length>0){if(!/^[0-9a-f]{24}$/i.test(n.toContactId))throw new c("backend.internal","contact_by_email returned a contact id that is not a plain ObjectId; refusing to build the --to-email filter from it.",{received:n.toContactId});i.sender_contact_id=n.toContactId}return Object.keys(i).length===0||(t.raw_filter_str=JSON.stringify(i)),t}var za="id email name address phone";function Xa(e){return e.startsWith("transport.")||e.startsWith("auth.")||e.startsWith("backend.")||e==="internal"||e==="rate_limited"}async function Qa(e,n,t={}){let i;try{i=await ze(e,"query","contact_by_email",{email:n},{selection:za,showDoc:!1})}catch(o){if(o instanceof c&&Xa(o.code))throw o;let a=o instanceof Error?o.message:String(o),l=t.notFoundMessage??`No contact found for "${n}". Re-run with \`--auto-create-contact\` (optionally \`--contact-name "<name>"\`) to create one, or pass the contact_id directly via --to-contact-id.`;throw new c("input.invalid",`${l}
|
|
18
|
+
Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.internal",`contact_by_email returned an unexpected shape for "${n}".`,{received:i});return r}async function Zi(e,n){let t=n.trim();if(t.length===0)throw new c("input.invalid","--to-email requires a non-empty email address.");return(await Qa(e,t,{notFoundMessage:`No contact found for "${t}" in this business. Every invoice is billed to an existing contact, so an unknown email cannot match any invoice. Check the address for typos \u2014 the lookup is exact, not fuzzy.`})).id}var er=`QueryInput as JSON. Supported fields: limit (0 = unbounded), skip, order_by (array of field names, '-field' for descending), created_at_gte / created_at_lte (both INCLUSIVE, format ${rt} \u2014 the fractional seconds and trailing Z are required). Only these fields are accepted. Overrides the default limit=50. Prefer --from / --to, which accept ordinary dates, normalize them for you, and give you a half-open range.`,Za="Only invoices you ISSUED to the contact with this email. The invoice's contact record belongs to the business that issued it, so this filter is inherently issue-side: on `invoice received` it is exactly 'invoices I billed to them', and on `invoice list` it narrows the both-directions view to the ones you issued. The email must match a contact in your business EXACTLY (no fuzzy match); an email with no contact is an error, not an empty list, because every invoice is issued to a contact. Under an agent key the contact lookup additionally requires the contact:read_only scope.";var at={status:T.Flags.string({description:`Only invoices in this status. Repeatable (matches any of them). Accepted: ${ot().join(", ")} (case-insensitive), or a raw integer.`,multiple:!0}),"payment-type":T.Flags.string({description:`Only invoices denominated in this currency. Repeatable (matches any of them). Accepted: CURRENCY (fiat), ${ve().join(", ")} (case-insensitive), or a raw integer.`,multiple:!0}),from:T.Flags.string({description:`Only invoices created at or after this time. INCLUSIVE \u2014 an invoice created at exactly this instant is included. ${Ze}`}),to:T.Flags.string({description:`Only invoices created strictly before this time. EXCLUSIVE \u2014 an invoice created at exactly this instant is NOT included, so --from 2026-07-01 --to 2026-08-01 is exactly July and consecutive ranges never overlap. A bare date therefore covers the whole day before it. ${Ze}`}),"to-email":T.Flags.string({description:Za})},Dc={...at,"to-email":T.Flags.string({hidden:!0,description:"Not supported on `invoice sent` \u2014 see the runtime error."})};var en=class e extends ge{static description='List invoices for a business. Wraps the `payments` GraphQL query. Defaults to the first 50 rows; pass --input \'{"limit":N,"skip":M}\' to paginate, or --all to request one unpaginated response. Filter with --status / --payment-type (repeatable), the creation-date range --from / --to (half-open: --from inclusive, --to exclusive), and --to-email, which narrows this both-directions view to the invoices you ISSUED to that contact.';static examples=["$ allscale invoice list","$ allscale invoice list --business-id 65ab1234567890abcdef0123",`$ allscale invoice list --input '{"limit":50,"skip":50}' # second page`,"$ allscale invoice list --all # everything (be careful)",`$ allscale invoice list --payment-type USDT --input '{"limit":5}' --select 'count items { id status amount_coins }'`,"$ allscale invoice list --status SENT --status OVERDUE # unpaid work","$ allscale invoice list --payment-type USDC # only USDC invoices","$ allscale invoice list --from 2026-07-01 --to 2026-08-01 # exactly July (--to is exclusive)","$ allscale invoice list --to-email client@example.com # what you billed that customer"];static flags={"business-id":T.Flags.string({char:"b",description:"Business id. Defaults to the logged-in user's business when omitted."}),input:T.Flags.string({char:"i",description:er,exclusive:["all"]}),...at,all:T.Flags.boolean({description:`Request all rows in one response (equivalent to --input '{"limit":0}'); the CLI rejects read-only responses over 32 MiB.`,default:!1,exclusive:["input"]}),select:T.Flags.string({char:"s",description:ji({kind:"query",name:"payments"})}),"show-doc":T.Flags.boolean({description:"Print the generated GraphQL document to stderr",default:!1}),...ge.baseFlags};async runCommand(){let{flags:n}=await this.parse(e),t=this.resolveContext(n),i=Mi({input:n.input,all:!!n.all,typedAlternatives:"--status / --payment-type / --from / --to / --to-email"}),r=await it(t,n["business-id"]),o=n["to-email"],a=o===void 0?void 0:await Zi(t,o),l={business_id_str:r,query_input:Qi(i,{status:n.status,"payment-type":n["payment-type"],from:n.from,to:n.to,toContactId:a})};return ze(t,"query","payments",l,{selection:n.select,showDoc:!!n["show-doc"]})}};
|
|
19
19
|
//# sourceMappingURL=list.js.map
|