@allscale/cli 0.1.0 → 1.0.1
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 +113 -41
- package/bin/dev.js +11 -1
- package/bin/run-oclif.js +216 -27
- package/bin/run.js +19 -1
- package/dist/commands/build-info.js +13 -13
- package/dist/commands/claim-link/claim.js +14 -14
- package/dist/commands/claim-link/create.js +40 -37
- package/dist/commands/claim-link/get.js +26 -15
- package/dist/commands/claim-link/list.js +15 -15
- package/dist/commands/claim-link/status.js +13 -13
- package/dist/commands/describe.js +13 -13
- package/dist/commands/device-login.js +23 -24
- package/dist/commands/invoice/get.js +15 -15
- package/dist/commands/invoice/list.js +16 -16
- package/dist/commands/invoice/pay.js +40 -41
- package/dist/commands/invoice/received.js +16 -16
- package/dist/commands/invoice/send.js +42 -34
- package/dist/commands/invoice/sent.js +15 -15
- package/dist/commands/invoice/update.js +17 -15
- package/dist/commands/logout.js +14 -14
- package/dist/commands/operations.js +13 -13
- package/dist/commands/otp-login.js +21 -20
- package/dist/commands/otp-send.js +13 -13
- package/dist/commands/payout/send.js +14 -14
- package/dist/commands/payout/status.js +15 -15
- package/dist/commands/scope.js +17 -16
- package/dist/commands/store/create.js +17 -17
- package/dist/commands/transaction/get.js +15 -15
- package/dist/commands/transaction/list.js +15 -15
- package/dist/commands/wallet/list.js +15 -15
- package/dist/commands/wallet/send.js +40 -43
- package/dist/commands/whoami.js +14 -14
- package/dist/hooks/version-suffix.js +1 -1
- package/dist/index.js +14 -14
- package/dist/lib/help.js +7 -2
- package/dist/lib/output/audit-lifecycle.js +7 -0
- package/oclif.manifest.json +123 -292
- package/package.json +4 -6
- package/dist/commands/claim-link/preview.js +0 -18
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).some(n=>
|
|
3
|
-
`)}var
|
|
4
|
-
`)}else
|
|
5
|
-
`);return}
|
|
6
|
-
`);return}
|
|
7
|
-
`)}catch(i){if(
|
|
8
|
-
`)}catch{}}}var
|
|
9
|
-
The CLI default is now ${
|
|
1
|
+
"use strict";var Rr=Object.create;var Re=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Ur=Object.getPrototypeOf,Dr=Object.prototype.hasOwnProperty;var Br=(e,n)=>{for(var t in n)Re(e,t,{get:n[t],enumerable:!0})},Ot=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Pr(n))!Dr.call(e,r)&&r!==t&&Re(e,r,{get:()=>n[r],enumerable:!(i=xr(n,r))||i.enumerable});return e};var b=(e,n,t)=>(t=e!=null?Rr(Ur(e)):{},Ot(n||!e||!e.__esModule?Re(t,"default",{value:e,enumerable:!0}):t,e)),$r=e=>Ot(Re({},"__esModule",{value:!0}),e);var Ds={};Br(Ds,{default:()=>dn,parseLineFlag:()=>Os,parseLineFlags:()=>Cr,resolveInvoiceAmountAndLines:()=>Nr});module.exports=$r(Ds);var X=require("process");var R=require("@oclif/core");var vt="public",Rt="https://app.allscale.io";var xt=["https://app.allscale.io"];var Sn="Override the API base URL (public builds accept only https://app.allscale.io)";var An="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function Pt(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 Ut(e){return Pt(e)!==null}function Tn(e){let n=Pt(e);return n!==null&&xt.includes(n.origin)}function fe(){return"".trim()||void 0}function ye(){return"public"}function G(e){try{let{hostname:n}=new URL(e);return n==="127.0.0.1"||n==="localhost"||n==="[::1]"}catch{return!1}}function wn(e){try{return new URL(e).origin}catch{return null}}function he(){{let e="[]".trim();if(e.length===0)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}return kn()}function kn(){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:s,keyId:l}=o;if(typeof a!="string"||a.trim().length===0||typeof s!="string"||s.trim().length===0)continue;let u=typeof l=="string"?l.trim():"";r.push({base:a.trim(),key:s,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 En="device-login",Fr=/^[A-Za-z0-9._-]{1,64}$/;function Nn(e){return Fr.test(e)?e:"<profile>"}function q(e){return"allscale otp-login --profile "+(e===void 0?"<profile>":Nn(e))+" --email <you@example.com> --scopes <scope> --otp-stdin"}function xe(){return"`allscale device-login` (or `allscale otp-login` \u2014 requires `--email` and `--scopes` \u2014 for headless automation)"}function Bt(e){let n=Nn(e);return`No tokens stored for profile '${e}'. Run \`allscale device-login --profile ${n}\` (recommended), or use \`${q(e)}\` for headless automation.`}function $t(e){return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. Check the spelling first; to deliberately create '${e}', run \`allscale ${En} --profile ${Nn(e)}\`.`}var Mr={"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_expired":5,"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},Gr=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 Cn(e){return(typeof e=="string"?e:String(e??"")).replace(Gr,"")}var qr=64;function Ln(e,n=new Map,t=0){if(typeof e=="string")return Cn(e);if(e===null||typeof e!="object")return e;let i=n.get(e);if(i!==void 0)return i;if(t>=qr)return e;if(Array.isArray(e)){let a=[];n.set(e,a);for(let s of e)a.push(Ln(s,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,s]of Object.entries(e))Object.defineProperty(o,a,{value:Ln(s,n,t+1),writable:!0,enumerable:!0,configurable:!0});return o}var c=class extends Error{code;details;constructor(n,t,i){super(Cn(t)),this.code=n,this.details=i&&Ln(i),this.name="AllscaleError"}get exitCode(){return Mr[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function Ft(e){if(e instanceof c)return e;if(e instanceof Error){if(Vr(e)){let n=zr(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 Yr=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),Kr=[/^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 Vr(e){if(Hr(e))return!0;let n=e.name??"";return Yr.has(n)?n==="CLIError"?bn(e,"parse")||Dt(e.message):!0:Dt(e.message)}function Hr(e){if(!bn(e,"oclif"))return!1;let n=e.oclif;return typeof n=="object"&&n!==null&&n.exit===2&&bn(e,"parse")}function Dt(e){return e?Cn(e).split(`
|
|
2
|
+
`).some(n=>Kr.some(t=>t.test(n.trim()))):!1}function bn(e,n){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,n)}function zr(e){let n=e,t={};for(let i of["code","exitCode","suggestions","ref"])n[i]!==void 0&&(t[i]=n[i]);return t}function Mt(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var y=b(require("fs")),$e=b(require("path")),zt=b(require("crypto"));var Jr="...<truncated>",Wr=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,jr=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,xn=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,In=String.raw`(?:proxy[_-]?)?authorization`,Xr=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${In}"|'${In}'|${In})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${xn}`,"gi"),Zr=/\b(https?:\/\/)[^\s/?#]+@/gi,Qr=String.raw`(?:[A-Za-z0-9]+[_-])*`,eo=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,qt=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)`,Gt=qt(Qr),no=qt(eo),to=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Gt}"|'${Gt}'|${no})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${xn}`,"gi"),On=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)`,io=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${On}"|'${On}'|${On})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${xn}`,"g");function Pe(e){return e.replace(Zr,"$1<redacted>@").replace(Wr,"<redacted-jwt>").replace(Xr,"$1$2$3<redacted>").replace(to,"$1$2<redacted>").replace(io,"$1$2<redacted>").replace(jr,"Bearer <redacted>")}var ro=/(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 Ue(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return ro.test(n)}function Yt(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 De(e,n,t=Jr){if(n<=0)return"";if(Buffer.byteLength(e,"utf8")<=n)return e;let i=Buffer.byteLength(t,"utf8");if(i>=n){let s="",l=0;for(let u of t){let p=Buffer.byteLength(u,"utf8");if(l+p>n)break;s+=u,l+=p}return s}let r=n-i,o="",a=0;for(let s of e){let l=Buffer.byteLength(s,"utf8");if(a+l>r)break;o+=s,a+=l}return`${o}${t}`}function w(e,n=16384){return De(Yt(Pe(e)),n)}var vn=100,oo=8,ao=8*1024;function Be(){return{remaining:ao}}function Rn(e,n){let t=Math.min(16384,n.remaining),i=De(e,t);return n.remaining-=Buffer.byteLength(i,"utf8"),i}function ee(e,n,t=0,i={}){if(t>oo)return Rn("<truncated>",n);if(typeof e=="string"){let r=Pe(e);return Rn(i.escapeControls?Yt(r):r,n)}if(Array.isArray(e)){let r=e.slice(0,vn),o=r.map(a=>ee(a,n,t+1,i));return e.length>r.length&&o.push(Rn(`<${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,s]of o.slice(0,vn))r[a]=ee(s,n,t+1,i);return o.length>vn&&(r.output_truncated=!0),r}return e}var Pn=require("process");var Un=!1;function Dn(e){Un=e}function Vt(){return Un}var Kt="1";function te(e,n){if(Un){let t={...e};delete t.version;let i=Be(),r={event:t.event,...t},o=ee(r,i,0,{escapeControls:!0}),a=JSON.stringify({version:Kt,...o});Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:Kt,event:o.event,output_truncated:!0})),Pn.stderr.write(`${a}
|
|
4
|
+
`)}else Pn.stderr.write(n)}var Ht="2",ie=null,N=null,re=!1,ge=!1;function so(){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=zt.randomBytes(4).toString("hex");return $e.join(n,`allscale-output-${t}-${i}.ndjson`)}return null}var Bn=64*1024*1024,lo=null;function $n(e={}){if(e.quiet&&(ge=!0),re)return;let n=so();if(!n)return;ie=null;let t=null;try{if((lo??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let i=$e.dirname(n);if(y.mkdirSync(i,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let l=y.statSync(i),u=l.mode&511;if(!l.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=y.constants.O_NOFOLLOW??0;t=y.openSync(n,y.constants.O_APPEND|y.constants.O_CREAT|y.constants.O_WRONLY|(y.constants.O_NONBLOCK??0)|r,384);let o=y.fstatSync(t),a=y.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 s=o.mode&511;if((s&63)!==0)throw new Error(`existing sidecar file must already be owner-only; current mode is ${s.toString(8).padStart(3,"0")}. Rotate or remove it before retrying`);y.fchmodSync(t,384)}catch(i){if(t!==null)try{y.closeSync(t)}catch{}ge||te({event:"sidecar_disabled",reason:"open_failed",detail:w(`sidecar path '${n}' could not be opened safely (${i.message})`)},`${w(`[allscale] sidecar path '${n}' could not be opened safely (${i.message}); refusing to write. Sidecar disabled for this run.`)}
|
|
5
|
+
`);return}ie=n,N=t,re=!0}var co=[/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 uo(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return co.some(t=>t.test(n))}function Jt(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=po(n.pathname);let r=t;n.pathname!==i&&(r=!0);for(let[o]of n.searchParams)uo(o)&&(n.searchParams.set(o,"<redacted>"),r=!0);return r?n.toString():e}catch{return e}}function po(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function mo(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:Jt(e.url)}:e}function fo(e){let n=new Date().toISOString(),t=e,{type:i,...r}=t,o=ee(r,Be()),a=JSON.stringify({version:Ht,timestamp:n,type:i,...o});return Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:Ht,timestamp:n,type:i,output_truncated:!0})),a}function T(e){if(!re||!ie||N===null)return;let n=mo(e),t=fo(n);try{if(y.fstatSync(N).size+Buffer.byteLength(t,"utf8")+1>Bn){re=!1;try{y.closeSync(N)}catch{}N=null,ge||te({event:"sidecar_disabled",reason:"size_limit",...ie===null?{}:{path:w(ie)},max_bytes:Bn},`${w(`[allscale] sidecar exceeded ${Bn} bytes; disabling it for the rest of this run. Rotate or remove ${ie}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
|
+
`);return}y.appendFileSync(N,`${t}
|
|
7
|
+
`)}catch(i){if(re=!1,N!==null){try{y.closeSync(N)}catch{}N=null}try{ge||te({event:"sidecar_disabled",reason:"write_failed",detail:w(i.message)},`${w(`[allscale] sidecar write failed (${i.message}); disabling sidecar for the rest of this run.`)}
|
|
8
|
+
`)}catch{}}}var B=Jt;function Wt(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function _e(){if(ge=!1,re=!1,N!==null){try{y.closeSync(N)}catch{}N=null}}function jt(e=!1){let n=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||Wt()||!n}var Se=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"]),yo=new Set(Array.from(Se).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),ho=Array.from(Se).filter(e=>e.startsWith("--")).sort((e,n)=>n.length-e.length),go=new Set(["--otp-stdin","--password-stdin"]);function Fn(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(Se.has(a)){n.push(`${a}=<redacted>`);continue}}}if(Se.has(i)){n.push(i),t+1<e.length&&(Se.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(yo.has(o)){n.push(`${o}<redacted>`);continue}}let r=go.has(i)?void 0:ho.find(o=>i.length>o.length&&i.startsWith(o));if(r){n.push(`${r}<redacted>`);continue}n.push(i)}return n}function Xt(e){T({type:"error",code:e.code,message:w(e.message)}),T({type:"command-end",ok:!1,exitCode:e.exitCode}),_e()}var Ae=fe()??Rt,ae={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 $(e){return Ut(e)?new URL(e).origin:null}function O(e){try{let n=new URL(e);return`${n.protocol}//${n.host}`}catch{return"<unparseable URL>"}}function Zt(){let e=process.env[ae.TOKEN]?.trim();return e&&e.length>0?e:void 0}function Mn(){let e=process.env[ae.PROFILE]?.trim();return e&&e.length>0?e:void 0}function Fe(){let e=process.env[ae.API_BASE]?.trim();return e&&e.length>0?e:void 0}function Qt(){let e=process.env[ae.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function ei(){let e=process.env[ae.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function ni(){let e=process.env[ae.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function ti(e){let{resolvedApiBase:n,fromExplicitOverride:t,profileApiBase:i,profileApiBaseSource:r}=e;if(fe()===void 0&&Ae!==""&&"".length!==0&&!t&&r!=="explicit"&&i===""&&n==="")return`Notice: this profile is pinned to ${""} (staging) in ~/.allscale/config.toml.
|
|
9
|
+
The CLI default is now ${Ae} (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
|
-
To keep staging, re-run login with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
|
-
To move to production, run:
|
|
14
|
-
`}var
|
|
15
|
-
`)}},Ne=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"]),Rr=new Set(Array.from(Ne).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2));function vr(e){let n=[];for(let t=0;t<e.length;t+=1){let i=e[t];if(i.startsWith("-")){let r=i.indexOf("=");if(r!==-1){let o=i.slice(0,r);if(Ne.has(o)){n.push(`${o}=<redacted>`);continue}}}if(Ne.has(i)){n.push(i),t+1<e.length&&(Ne.has(e[t+1])||(n.push("<redacted>"),t+=1));continue}if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2&&i[1]!=="="){let r=i.slice(0,2);if(Rr.has(r)){n.push(`${r}<redacted>`);continue}}n.push(i)}return n}var xr=/(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 Ur(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return xr.test(n)}var Pr=/_(removed|cleared|count|total)$/i;function Br(e,n){return typeof n=="number"&&Pr.test(e)}var Dr=new Set(Ut);function $r(e,n){return e==="token_symbol"&&typeof n=="string"&&Dr.has(n)}var be=100;function An(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,be),i=t.map(r=>An(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,be))t[r]=Ur(r)&&!Br(r,o)&&!$r(r,o)?"<redacted>":An(o,n+1);if(i.length>be){let r="<truncated>";for(;r in t;)r=`<${r}>`;t[r]=`${i.length-be} more keys`}return t}return typeof e=="string"?N(e):e}function Fr(e){let n=gt()?void 0:2,t=An(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:N(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function Mr(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 Jt=w(require("path"));var wn=require("crypto"),d=w(require("fs")),_=w(require("path"));var Ee=1024*1024,Gr=5e3,qr=20,Kr=3e4,Sn=4096,Vr=new Int32Array(new SharedArrayBuffer(4)),ue=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function Ce(e){return e instanceof ue}var b=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},Hr=null;function G(){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 Ie(){return(Hr??process.platform)!=="win32"}function qt(){if(!Ie())throw G()}function Kt(e){try{return d.default.lstatSync(e),!1}catch(n){if(!g(n,"ENOENT"))throw n}try{let n=d.default.lstatSync(_.dirname(e));return!n.isSymbolicLink()&&n.isDirectory()}catch(n){if(g(n,"ENOENT"))return!0;throw n}}function g(e,n){return typeof e=="object"&&e!==null&&e.code===n}function pe(e,n){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${n} is not owned by the current effective user`)}function me(e,n){return e.dev===n.dev&&e.ino===n.ino}function Yr(e){Atomics.wait(Vr,0,0,e)}function Vt(e){try{return process.kill(e,0),!0}catch(n){return!g(n,"ESRCH")}}function Jr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pt(e,n){let t=_.dirname(e);n&&d.default.mkdirSync(t,{recursive:!0,mode:448});let i;try{i=d.default.lstatSync(t)}catch(o){if(!n&&g(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()||!me(o,a))throw new Error("credential-store parent changed while it was being inspected");pe(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&_.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&&g(o,"ENOENT")?new b:o}if(!me(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 ue;if(pe(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 zr(e,n){if(n.size>Ee)throw new Error("credential-store file exceeds the maximum supported size");let t=Buffer.alloc(Ee+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>Ee)throw new Error("credential-store file exceeds the maximum supported size");return t.subarray(0,i).toString("utf8")}function Bt(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(g(r,"ENOENT"))try{if(d.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(g(o,"ENOENT"))return null;throw o}throw r}let t=d.default.fstatSync(n),i=v(e,n,t);return zr(n,i)}finally{n!==null&&d.default.closeSync(n)}}function Dt(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(g(r,"ENOENT")&&Kt(e))return;throw r}let t=d.default.fstatSync(n),i=v(e,n,t);q(e,i)}finally{n!==null&&d.default.closeSync(n)}Yt(_.dirname(e))}function jr(e){let n;try{n=d.default.lstatSync(e)}catch(t){if(g(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 ue;pe(n,"credential-store replacement target")}function Wr(e,n){for(let t=0;t<8;t+=1){let i=(0,wn.randomBytes)(12).toString("hex"),r=_.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(g(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function Ht(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 Yt(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 Zr(e,n){let t=Buffer.from(n,"utf8");if(t.length>Ee)throw new Error("credential-store file exceeds the maximum supported size");let i=_.dirname(e),r=_.basename(e),o=null,a=null,l=!1;try{let s=Wr(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");Ht(o,t),d.default.fsyncSync(o),v(a,o,d.default.fstatSync(o));let m=o;o=null,d.default.closeSync(m),jr(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{}}Yt(i)}function Xr(e){return _.join(_.dirname(e),`.${_.basename(e)}.lock`)}function Qr(e){return _.join(_.dirname(e),`.${_.basename(e)}.lock-recovery`)}function eo(e,n){if(n.size>Sn)return null;let t=Buffer.alloc(Sn+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>Sn)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 q(e,n){let t=d.default.lstatSync(e);if(t.isSymbolicLink()||!t.isFile()||!me(t,n))throw new Error("credential-store lock changed while it was being inspected");pe(t,"credential-store lock"),d.default.unlinkSync(e)}function $t(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(g(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(g(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=eo(t,r);return{state:(o?.target===n&&o?!Vt(o.pid):Date.now()-r.mtimeMs>=Kr)?"stale":"active",stats:r}}finally{t!==null&&d.default.closeSync(t)}}function no(e,n){for(let t=0;t<8;t+=1){let i=(0,wn.randomBytes)(12).toString("hex"),r=_.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 Ht(a,Buffer.from(JSON.stringify(o),"utf8")),d.default.fsyncSync(a),{claimPath:r,metadata:o,stats:s}}catch(l){if(g(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 to(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 g(i,"ENOENT")?new b:i}try{let i=d.default.fstatSync(t),r=v(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!me(r,n))throw new b;return{fd:t,lockPath:e,stats:r}}catch(i){throw d.default.closeSync(t),i}}function Ft(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(g(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(g(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 io(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(g(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{q(e,t)}catch{}throw d.default.closeSync(n),i}}function M(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");Yr(qr)}function Mt(e){let n=_.dirname(e),t=_.basename(e),i=Xr(e),r=Qr(e),o=no(n,t),a=Date.now()+Gr,l=!1,s=!1,u=null,p;try{for(;u===null;)try{if(Ft(r)){M(a,!0);continue}d.default.linkSync(o.claimPath,i),s=!0,u=to(i,o.stats),l=!0}catch(m){if(s&&!l){try{q(i,o.stats)}catch{}s=!1}if(m instanceof b){M(a,!1);continue}if(!g(m,"EEXIST"))throw m;let f;try{f=$t(i,t)}catch(A){if(A instanceof b){M(a,!1);continue}throw A}if(f.state==="absent")continue;if(f.state==="stale"){let A;try{A=io(r)}catch(k){if(k instanceof b){M(a,!1);continue}throw k}if(A!==null){try{let k;try{k=$t(i,t)}catch(D){if(D instanceof b){M(a,!1);continue}throw D}k.state==="stale"&&q(i,k.stats)}finally{Ln(A)}continue}}let y;try{y=Ft(r)}catch(A){if(A instanceof b){M(a,!1);continue}throw A}M(a,y)}}catch(m){p=m}try{q(o.claimPath,o.stats)}catch(m){!g(m,"ENOENT")&&!l&&p===void 0&&(p=m)}if(p!==void 0)throw p;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function Ln(e){try{q(e.lockPath,e.stats)}finally{d.default.closeSync(e.fd)}}function ro(e,n){let t=Jr(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 Gt(e){let n=_.dirname(e),t=_.basename(e);for(let i of d.default.readdirSync(n)){let r=ro(i,t);if(r===null||Vt(r))continue;let o=_.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(g(u,"ENOENT")||g(u,"ELOOP"))continue;throw u}let l=d.default.fstatSync(a),s=d.default.lstatSync(o);if(!l.isFile()||s.isSymbolicLink()||!s.isFile()||!me(l,s))continue;try{pe(l,"credential-store orphan")}catch{continue}q(o,l)}catch(l){if(!g(l,"ENOENT"))throw l}finally{a!==null&&d.default.closeSync(a)}}}function fe(e,n,t){if(!Ie()){if(n.allowUnsupportedPlatformCleanup){if(n.createParent)throw G();if(!Pt(e,!1))return t({read:()=>null,remove:()=>{},write:()=>{throw G()}});let a=Mt(e);try{return Gt(e),t({read:()=>Bt(e),remove:()=>Dt(e),write:()=>{throw G()}})}finally{Ln(a)}}if(!n.createParent){let o=!1;try{o=Kt(e)}catch{throw G()}if(o)return t({read:()=>null,remove:()=>{},write:()=>{throw G()}})}throw G()}if(!Pt(e,n.createParent))return t({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let r=Mt(e);try{return Gt(e),t({read:()=>Bt(e),remove:()=>Dt(e),write:o=>Zr(e,o)})}finally{Ln(r)}}var bn="allscale-cli";function In(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zt(e){return In(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function V(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 Nn(){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 Oe(){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 K,En=!1;function oo(){return Nt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function ao(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 so(){if(K!==void 0)return K;if(oo())return En=!1,K=null,K;try{K=require("keytar"),En=!1}catch(e){En=!ao(e),K=null}return K}function jt(){let e=Ie()?"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 Cn(e){try{return await e()}catch{throw jt()}}var On=class{constructor(n){this.keytar=n}keytar;kind="keychain";async read(n){let t=await Cn(()=>this.keytar.getPassword(bn,n));if(t===null)return null;let i;try{i=JSON.parse(t)}catch{throw V("OS keychain")}if(!zt(i))throw V("OS keychain");return i}async get(n){return this.read(n)}async set(n,t){await this.read(n),await Cn(()=>this.keytar.setPassword(bn,n,JSON.stringify(t)))}async delete(n){await this.read(n),await Cn(()=>this.keytar.deletePassword(bn,n))}},lo="credentials.json",Rn=class{kind="insecure-file";filePath;constructor(n){this.filePath=n??Jt.join(_n(),lo)}read(n){let t;try{t=n.read()}catch(r){throw Ce(r)?Nn():V("plaintext file")}if(t===null)return{profiles:{}};let i;try{i=JSON.parse(t)}catch{throw V("plaintext file")}if(!In(i)||!In(i.profiles))throw V("plaintext file");return i}write(n,t){try{n.write(JSON.stringify(t,null,2))}catch(i){throw Ce(i)?Nn():Oe()}}profileTokens(n,t){let i=n.profiles[t];if(i!==void 0){if(!zt(i))throw V("plaintext file");return i}}async get(n){try{return fe(this.filePath,{createParent:!1},t=>this.profileTokens(this.read(t),n)??null)}catch(t){throw t instanceof c?t:V("plaintext file")}}async set(n,t){try{fe(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:Oe()}}async delete(n){try{fe(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:Oe()}}async clearProfile(n){try{return fe(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:Ce(t)?Nn():Oe()}}};function Re(e){if(e.insecureStorage)return qt(),new Rn(e.insecureFilePath);let n=so();if(n)return new On(n);throw jt()}var vn=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 ve(){return new vn}var xe="allscale_access_token",xn="allscale_refresh_token";function Wt(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 Un(e){return e.map(n=>`${n.name}=${n.value}`).join("; ")}function Pn(e,n){return e.find(t=>t.name===n)?.value??null}var Zt=w(require("crypto")),Xt=w(require("fs")),Qt=w(require("path"));var co="key-id",uo="x-allscale-cli-version",Bn="cli-1",po="aScaLe_cli_obf_v1",mo="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function fo(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 yo=fo(mo,po),ei=`Bearer ${yo}`;function ni(e,n){let t=Qe(e);if(t!==null)return n.find(i=>Qe(i.base)===t)}function ho(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let n=se();if(n.length>0){let i=ni(e,n);if(i)return i.key;if($(e)){let r=process.env.ALLSCALE_SIGNING_KEY;return r&&r.trim().length>0?r:$(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 go(e){{let i="cli-1".trim();if(i.length>0)return i}let n=se();if(n.length>0){let i=e!==void 0?ni(e,n):void 0;if(i)return i.keyId;if(e!==void 0&&$(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():Bn}if(!$(n[0].base))return Bn}return n[0].keyId}let t=process.env.ALLSCALE_SIGNING_KEY_ID;return t!==void 0?t.trim():Bn}function _o(){return"0.1.0"}function ko(){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 Dn(e,n){let t=ho(n);if(!t)throw ko();let i=go(n),r=Math.floor(Date.now()/1e3).toString(),o=Zt.createHash("sha256").update(`${t}${r}${e}`).digest("hex"),a={timestamp:r,"secret-key":o,[uo]:_o()};return i.length>0&&(a[co]=i),a}function ti(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function To(e,n={}){let t;try{t=Ot(Le())}catch{return}if(!(t.length===0||t.includes(e)))return new c("auth.unknown_profile",dt(e,t)+(n.messageSuffix??""),{profile:e,known_profiles:t})}function ye(e){if(e.profileExplicit){let n=To(e.profile);if(n)return n}return new c("auth.no_token",ct(e.profile,e.flow))}var $n=256*1024,Ue=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"}},Pe=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 Fn(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 Ue(e.status,n,t.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),a=[],l=0,s,u=t.timeoutMs,p=u===void 0?void 0:new Promise((m,f)=>{s=setTimeout(()=>{f(new Pe(e.status,u))},u),s.unref?.()});try{for(;;){let m=o.read(),{done:f,value:y}=p?await Promise.race([m,p]):await m;if(f)break;if(l+=y.byteLength,l>n)throw o.cancel().catch(()=>{}),new Ue(e.status,n,t.oversizeKind);a.push(Buffer.from(y))}}catch(m){throw m instanceof Pe&&o.cancel(m).catch(()=>{}),m}finally{s!==void 0&&clearTimeout(s);try{o.releaseLock()}catch{}}return Buffer.concat(a,l).toString("utf8")}var Ao="X-AllScale-Api-Key",So=3e4,Lo=32*1024*1024,wo=4*1024*1024;function bo(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 No(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 Eo(e,n){if(!(e<300||e>=400))throw new c("transport.network",`API returned HTTP ${e} (a redirect) for ${U(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 si(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Eo(e.status,e.url)}}var ii="--dns-result-order=ipv4first";async function Be(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 p=/^[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=${ii} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...p?{cf_ray:p}:{},ipv4_workaround:`NODE_OPTIONS=${ii}`})}var H=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??So;if(!Number.isFinite(i)||i<1)throw new c("input.invalid","HTTP request timeout must be a positive number of milliseconds.");F(this.opts.apiBase),we(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=bo(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 ${U(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 ${U(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();xt(this.opts.apiBase,r);let o=i?.agent_key,a=n.auth??"auto",l=li(n.path),s=a==="required"?!0:a==="none"?!1:Oo(n.path);if((l||a==="required")&&!n._isRefresh&&!this.opts.override&&!i?.access_token&&!o)throw ye({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let u=ti(n.body),p=!!o||!!i?.access_token;s&&p&&!this.opts.override&&kn(this.opts.apiBase,i?.api_base);let m=this.buildHeaders({attachAuth:s&&p,bodyForSig:u,tokens:i,extra:n.headers}),f=Date.now();L({type:"request",method:n.method??"GET",url:r,...n._isRefresh?{refresh:!0}:{}});let y;try{y=await fetch(r,{method:n.method??"GET",headers:m,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(k){throw new c("transport.network",`Network error contacting ${U(r)}: ${k instanceof Error?k.message:String(k)}`)}if(L({type:"response",status:y.status,durationMs:Date.now()-f}),s&&!!i?.access_token&&!o&&y.status===401&&!n._isRefresh&&!this.opts.override){let k=await No(this.refreshSingleFlight(),n.signal),D=this.buildHeaders({attachAuth:s&&!!k.access_token,bodyForSig:u,tokens:k,extra:n.headers}),ne=Date.now();L({type:"request",method:n.method??"GET",url:r});let O;try{O=await fetch(r,{method:n.method??"GET",headers:D,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(C){throw new c("transport.network",`Network error contacting ${U(r)} on refresh-retry: ${C instanceof Error?C.message:String(C)}`)}return L({type:"response",status:O.status,durationMs:Date.now()-ne}),ri(O,{withMetadata:t.withMetadata,authBearing:s,responseKind:oi(n)})}return ri(y,{withMetadata:t.withMetadata,authBearing:s&&p,agentKeyAuth:s&&!!o,responseKind:oi(n)})}buildHeaders(n){let i={Accept:"application/json","Content-Type":"application/json",...Dn(n.bodyForSig,this.opts.apiBase),...n.extra};if(n.attachAuth){i.Authorization=ei;let r=n.tokens;if(r?.agent_key)return i[Ao]=r.agent_key,i;let o=r?.access_token;o&&(i.Cookie=Un([{name:xe,value:o}]))}return i}async refreshSingleFlight(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.doRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}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 ${tn()}.`);if(kn(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=Un([{name:xe,value:n.access_token},{name:xn,value:n.refresh_token}]),r=Dn("",this.opts.apiBase);L({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(y){throw L({type:"refresh",ok:!1}),new c("transport.network",a&&y instanceof Error&&y.name==="AbortError"?`Token refresh against ${U(t)} timed out after 10s with no response.`:`Network error during token refresh against ${U(t)}: ${y instanceof Error?y.message:String(y)}`)}finally{clearTimeout(l)}L({type:"response",status:s.status,durationMs:0});try{await si(s)}catch(y){throw L({type:"refresh",ok:!1}),y}if(s.status!==200){L({type:"refresh",ok:!1}),await Be(s);let y=await xo(s);throw await Be(s,y),ci(s.status,y),new c("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${tn()}.`,{status:s.status})}let u=Wt(s.headers),p=Pn(u,xe),m=Pn(u,xn);if(!p||!m)throw L({type:"refresh",ok:!1}),new c("auth.token_expired","Refresh response did not include new access/refresh cookies.");let f={...n,access_token:p,refresh_token:m};return await this.opts.tokenStore.set(this.opts.profile,f),L({type:"refresh",ok:!0}),f}},Co=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function li(e){let n=e.split(/[?#]/,1)[0];return Co.some(t=>n===t||n.startsWith(`${t}/`))}var Io=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function Mn(e){let n=e.split(/[?#]/,1)[0];return Io.some(t=>t.test(n))}function Oo(e){return li(e)||Mn(e)}async function ri(e,n={}){await si(e);let t=e.status>=200&&e.status<300;t||await Be(e);let i=n.responseKind??"mutation",o=await Fn(e,t?i==="query"?Lo:wo:$n,{oversizeKind:t?i==="query"?"successful-query":"successful-mutation":"backend-envelope"});t||await Be(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,p)=>{s[p]=u}),{status:e.status,headers:s,body:a}}return a}let l=Uo(a)??`HTTP ${e.status}`;if(ci(e.status,a),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 oi(e){if(e.responseKind)return e.responseKind;let n=(e.method??"GET").toUpperCase();return n==="GET"||n==="HEAD"?"query":"mutation"}var ai=2014;function Ro(e){let n=e;if(typeof e=="string")try{n=JSON.parse(e)}catch{return!1}if(!n||typeof n!="object")return!1;let t=n.code;return t===ai||t===String(ai)}var vo=1e4;async function xo(e,n=vo){if(e.status>=200&&e.status<300)return"";try{return await Fn(e,$n,{timeoutMs:n})}catch{return""}}function ci(e,n){if(!(e>=200&&e<300)&&Ro(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"?n.slice(0,500):n})}function Uo(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 Po=/^\/(api\/)?(v1\/)?public\//;function Gn(e,n={}){let t=typeof n.pathHint=="string"?n.pathHint:"",i=t&&Po.test(t),r=t&&Mn(t),o=i&&!r&&!n.forceAuth;if(e.token)return new H({apiBase:e.apiBase,tokenStore:ve(),profile:e.profile,profileExplicit:e.profileExplicit,override:{access_token:e.token}});if(o)return new H({apiBase:e.apiBase,tokenStore:ve(),profile:e.profile,profileExplicit:e.profileExplicit});try{return new H({apiBase:e.apiBase,tokenStore:Re({insecureStorage:e.insecureStorage}),profile:e.profile,profileExplicit:e.profileExplicit})}catch(a){if(r)return new H({apiBase:e.apiBase,tokenStore:ve(),profile:e.profile,profileExplicit:e.profileExplicit});throw a}}var di=[{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_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:"claim_link_fee_preview",kind:"query",description:"Preview the Amount / Network fee / Service fee / Total breakdown without creating a link. Asset and precision validation matches create, but create-time amount and rate limits are enforced only when the link is created, so a successful preview does not guarantee create will succeed. per_transfer_gas is the withdrawal gas estimate in token units.",args:[{name:"amount",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"token_symbol",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"per_transfer_gas",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:"ClaimLinkFeeBreakdown",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}],ui=[{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:"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 De=new Set(["SCALAR","ENUM"]),Bo=new Set(["password","password_hash","totp_secret","credential","credentials","private_key","encryption_key"]),Do=[/(^|_)password(_|$)/i,/(^|_)secret(_|$)/i,/(^|_)token(_|$)/i,/(^|_)api[_-]?key(_|$)/i,/(^|_)signing[_-]?key(_|$)/i,/(^|_)private[_-]?key(_|$)/i,/(^|_)credential(_|$)/i],$o=new Set(["CreateClaimLinkResult.claim_token","StoreCreateResult.api_secret"]),Fo=new Map([["StoreCreateResult.store",["id","name"]],["CreateClaimLinkResult.claim_link",["id","token_symbol","status"]]]),Mo=new Set(["token_symbol"]);function qn(e){return Mo.has(e.toLowerCase())?!1:Bo.has(e)?!0:Do.some(n=>n.test(e))}function Go(e,n){return $o.has(`${e}.${n}`)}function Kn(e){return e.kind==="NON_NULL"&&e.ofType?`${Kn(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${Kn(e.ofType)}]`:e.name??"Unknown"}function he(e){let n=e;for(;n&&n.ofType;)n=n.ofType;return!n||!n.name?null:{kind:n.kind,name:n.name}}function qo(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=he(a.type);if(!l)continue;if(De.has(l.kind)){if(qn(a.name)&&!Go(e,a.name))continue;r.push(a.name);continue}let s=Fo.get(`${e}.${a.name}`);if(s){let u=n.find(f=>f.name===l.name),p=new Set((u?.fields??[]).filter(f=>{let y=he(f.type);return y!==null&&De.has(y.kind)&&!qn(f.name)}).map(f=>f.name)),m=s.filter(f=>!p.has(f));if(m.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${m.join(", ")}] that are not selectable scalars on ${l.name}; fix the entry or the public registry.`);r.push(`${a.name} { ${s.join(" ")} }`);continue}if(!o&&a.name==="items"&&a.type.kind==="NON_NULL"&&a.type.ofType?.kind==="LIST"){let u=Ko(a.type)?.name;if(u){let p=Vo(u,n);p&&r.push(`items { ${p} }`),o=!0}}}return r.length>0?r.join(" "):"__typename"}function Ko(e){return he(e)}function Vo(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=he(o.type);if(a&&De.has(a.kind)){if(qn(o.name))continue;r.push(o.name)}}return r.length>0?r.join(" "):"__typename"}function pi(e,n,t){let i=Ho(e.name),r=e.args.map(p=>{let m=Kn(p.type);return p.defaultValue!==null&&p.defaultValue!==void 0?`$${p.name}: ${m} = ${p.defaultValue}`:`$${p.name}: ${m}`}).join(", "),o=e.args.map(p=>`${p.name}: $${p.name}`).join(", "),a=r.length>0?`${e.kind} ${i}(${r})`:`${e.kind} ${i}`,l=o.length>0?`${e.name}(${o})`:e.name,s=he(e.returnType),u;if(s&&De.has(s.kind))u=l;else{let p=t&&t.trim().length>0?t.trim():s&&qo(s.name,n)||"__typename";u=`${l} { ${p} }`}return`${a} { ${u} }`}function mi(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 fi(e,n,t){return e.find(i=>i.kind===n&&i.name===t)??null}function yi(e){if(!e||typeof e!="object")return!1;let n=e.errors;return Array.isArray(n)&&n.length>0}function hi(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 Ho(e){return e.replace(/[^_0-9A-Za-z]/g,"_")}var gi=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","transaction:read_only","wallet:read_only","claim_link:read_only","claim_link:all","store:all"]),_i=new Set(["payroll","admin:user","admin:org","admin:audit"]);function ki(e){let n=e.lastIndexOf(":");return n===-1?e:e.slice(0,n)}function Ti(e,n){if(e===n)return!0;let t=":read_only";return n.endsWith(t)&&e===`${n.slice(0,-t.length)}:all`}var Yo={payments:"invoice:read_only",payment:"invoice:read_only",sender_payments:"invoice:read_only",recipient_payments:"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",create_store:"store:all",auto_payout_session_status:"claim_link:read_only",my_claim_links:"claim_link:read_only",claim_link:"claim_link:read_only",claim_link_fee_preview:"claim_link:read_only",create_claim_link:"claim_link:all",claim_link_funding_by_idempotency_key:"claim_link:all"},Jo={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"},zo=/API key scope not granted:\s*requires\s+(.+?),\s*key has\s+(.+?)\.?\s*$/i,jo=/is not available to API keys/i,Ai=/^[a-z_]+(?::[a-z_]+)*:[a-z_]+$/;function Si(e){if(typeof e!="string")return;let n=zo.exec(e);if(!n)return;let t=n[1].trim(),i=n[2].trim(),r=jo.test(t),o=!r&&Ai.test(t)?t:void 0,a;if(i.toLowerCase()==="none")a=[];else{let l=i.split(",").map(s=>s.trim()).filter(s=>Ai.test(s));a=l.length>0?l:void 0}if(!(o===void 0&&!r))return{required:o,granted:a,notAvailableToKeys:r}}function Li(e){let n=Jo[e];if(n!==void 0)return{ungrantableReason:n};let t=Yo[e];if(t!==void 0)return{scope:t}}function wi(e){if(_i.has(ki(e)))return{kind:"ungrantable"};for(let n of gi)if(Ti(n,e))return{kind:"approval_screen"};return{kind:"otp_login_only"}}function Vn(e,n){let t=Ni(e),i={graphql_error_count:Wo(e.errors),...t===void 0?{}:{backend_code:t}};if(t===2102)throw Zo(e,n,i);if(t===3400)throw new c("not_found",`GraphQL ${n.kind} '${n.operationName}' could not find the requested resource.`,i);if(yi(e))throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' returned errors: ${hi(e)}`,i);if(t!==void 0)throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' failed with backend code ${t}.`,i)}function Ni(e){let n=bi(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=bi(i.code);if(r!==void 0)return r}}function bi(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 Wo(e){return Array.isArray(e)?e.length:e==null?0:1}function Zo(e,n,t){let i=`GraphQL ${n.kind} '${n.operationName}'`,r={...t,operation:n.operationName},o=Si(Xo(e,Ni(e))),a=Li(n.operationName),l=o?.notAvailableToKeys===!0,s=o?.required??a?.scope,u=o?.granted,p=u===void 0?"":` This key holds ${u.length>0?u.join(", "):"no scopes"}.`;if(l||a?.ungrantableReason!==void 0){let m=a?.ungrantableReason!==void 0?`: ${a.ungrantableReason}`:"";return new c("auth.permission_denied",`${i} is not available to agent keys${m}. Re-authorizing will NOT help \u2014 no scope grants it.${p} 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 m=wi(s),f=m.kind==="ungrantable"?`\`${s}\` cannot be granted to any key (the backend clips this category to nothing), so re-authorizing will NOT help.`:m.kind==="approval_screen"?`Re-run \`allscale device-login\` and enable it on the approval screen, or \`${le()}\` with \`--scopes ${s}\`.`:`The browser approval screen does not offer \`${s}\`, so \`device-login\` cannot grant it \u2014 use \`${le()}\` with \`--scopes ${s}\`.`;return new c("auth.permission_denied",`The current agent key lacks \`${s}\`, required by ${i}.${p} ${f}`,{...r,missing_scopes:[s],...u===void 0?{}:{granted_scopes:u},...m.kind==="ungrantable"?{ungrantable:!0}:{}})}return new c("auth.permission_denied",`The current agent key does not have the scope required by ${i}.${p} Re-run \`allscale device-login\` (or \`${le()}\`) and grant the required scope.`,r)}function Xo(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 x(e,n,t,i,r={}){let o=fi(di,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=mi(o,i);if(!a.ok)throw new c("input.invalid",`Missing required variables for ${t}: ${a.missing.join(", ")}`,{required:a.missing});let l=pi(o,ui,r.selection);return Qo(e,{...r,kind:n,operationName:o.name,document:l,variables:i})}async function Qo(e,n){n.showDoc&&process.stderr.write(`${n.document}
|
|
17
|
-
`);let t=
|
|
18
|
-
`);return}if(t.toLowerCase()!==n.toLowerCase())throw new c("auth.permission_denied",`--business-id '${n}' is not the business you are signed in as. This command always acts as the authenticated business, so a different business id cannot be used. Omit the flag, or sign in as that business.`)}function
|
|
19
|
-
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
|
|
20
|
-
|
|
21
|
-
`),
|
|
22
|
-
`),
|
|
12
|
+
To keep staging, re-run \`allscale device-login\` with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
|
+
To move to production, run: allscale device-login --api-base ${Ae}
|
|
14
|
+
`}var Y=b(require("fs")),ii=b(require("os")),Gn=b(require("path")),qn=b(require("@iarna/toml"));var Ao=".allscale",To="config.toml";function Yn(){return Gn.join(ii.homedir(),Ao)}function ko(){return Gn.join(Yn(),To)}function Me(){let e=ko();if(!Y.existsSync(e))return{};let n=Y.readFileSync(e,"utf-8");try{return qn.parse(n)}catch(t){throw new c("internal",`Failed to parse ${e}: ${t.message}`)}}function ri(e){return Object.keys(e.profile??{}).sort()}function oi(e,n){return e.profile?.[n]}function ai(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 K(e){if(!Tn(e))throw new c("input.invalid",`Refusing to send credentials to API base ${O(e)}. `+An)}function Ge(e,n){K(e);let t=$(e),i=typeof n=="string"?$(n):null;if(t&&i===t)return;let r=typeof n=="string"?O(n):"<missing origin binding>";throw new c("input.invalid",`Refusing to send stored credentials: API base ${O(e)} does not match their bound origin ${r}. Re-login against the intended API base before retrying.`)}function si(e,n){let t=$(e),i=$(n);if(!(t&&i===t))throw new c("input.invalid",`Refusing API request to ${O(n)} because it is outside the configured API origin ${O(e)}.`)}function qe(e){let n=fe();if(n===void 0||G(e))return;let t=$(e),i=he();if(i.length>0){let o=i.map(s=>$(s.base)).filter(s=>s!==null);if(t!==null&&o.includes(t))return;let a=i.map(s=>O(s.base)).join(", ");throw new c("input.invalid",`Refusing to send to ${O(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.`)}let r=$(n);if(!(t!==null&&t===r))throw new c("input.invalid",`Refusing to send to ${O(e)} \u2014 this build only signs for ${O(n)}. Re-login against this build's environment, or use a build for that one.`)}var wo=require("@noble/hashes/sha3");var Lo=new Set([1,2,3,5,6,7,8,9]);function Kn(e){return Lo.has(e)}var li=["USDT","USDC"];var bl=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var ci=new Map([[1,"USDT"],[2,"USDC"],[3,"BUSD"],[4,"DAI"],[5,"TUSD"],[6,"PAX"],[7,"GUSD"],[8,"USTC"],[9,"FRAX"],[10,"EURS"]]);function Vn(e){return ci.get(e)??`Coin ${e}`}function di(){return[...ci.values()]}var k=require("@oclif/core"),Te=class e extends R.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:R.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:R.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:ye()==="public"}),"api-base":R.Flags.string({description:Sn,helpGroup:"GLOBAL",hidden:ye()==="public"}),"insecure-storage":R.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{Dn(this.jsonEnabled()),$n(),T({type:"session-start",command:this.id??"",argv:Fn(this.argv)});let n=this.constructor;if(ye()==="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&&Fe()!==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=jt(this.jsonEnabled()),i=this.argv.length===0&&!t&&vo(n)?this.config.findCommand(this.id??""):void 0;if(i){_e();let o=await(0,R.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&&!ni())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 T({type:"command-end",ok:!0}),_e(),n.emitsOwnOutput?void 0:(this.jsonEnabled()||Mt(r),{data:r})}catch(n){let t=Ft(n);Xt({code:t.code,message:t.message,exitCode:t.exitCode}),this.emitError(t),process.exitCode=t.exitCode;return}finally{Dn(!1)}}resolveSessionApiBaseChain(n){let t=Me(),i=n.profile??void 0,r=n["api-base"]??void 0,o=i!==void 0||Mn()!==void 0,a=ai(t,i,Mn()),s=oi(t,a),l=r??Fe(),u=l??s?.api_base??Ae,p=ti({resolvedApiBase:u,fromExplicitOverride:l!==void 0,profileApiBase:s?.api_base,profileApiBaseSource:s?.api_base_source});return p&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,te({event:"legacy_staging_profile",api_base:u,profile:a},p)),{apiBase:u,explicitApiBase:l,profileApiBase:s?.api_base,profile:a,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(n){let{apiBase:t}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||K(t),t}resolveContext(n){if(ye()==="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&&Fe()!==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,profile:a,profileApiBase:s,profileExplicit:l}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||(K(r),qe(r)),{apiBase:r,profile:a,token:t??Zt(),insecureStorage:i||Qt(),apiBaseSource:o!==void 0?"explicit":s!==void 0?"profile":"default",profileExplicit:l}}emitError(n){process.stderr.write(`${Oo(n)}
|
|
15
|
+
`)}};var bo=/_(removed|cleared|count|total)$/i;function Eo(e,n){return typeof n=="number"&&bo.test(e)}var No=new Set(li);function Co(e,n){return e==="token_symbol"&&typeof n=="string"&&No.has(n)}var Ye=100;function Ke(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,Ye),i=t.map(r=>Ke(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,Ye))t[r]=Ue(r)&&!Eo(r,o)&&!Co(r,o)?"<redacted>":Ke(o,n+1);if(i.length>Ye){let r="<truncated>";for(;r in t;)r=`<${r}>`;t[r]=`${i.length-Ye} more keys`}return t}if(typeof e=="string"){let t=Io(e);return t!==void 0?w(JSON.stringify(Ke(t,n+1))):w(e)}return e}function Io(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 Oo(e){let n=Vt()?void 0:2,t=Ke(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:w(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function vo(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 wi=b(require("path"));var Jn=require("crypto"),d=b(require("fs")),S=b(require("path"));var Ve=1024*1024,Ro=5e3,xo=20,Po=3e4,Hn=4096,Uo=new Int32Array(new SharedArrayBuffer(4)),ke=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function He(e){return e instanceof ke}var E=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},Do=null;function H(){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 ze(){return(Do??process.platform)!=="win32"}function _i(){if(!ze())throw H()}function Si(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 we(e,n){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${n} is not owned by the current effective user`)}function Le(e,n){return e.dev===n.dev&&e.ino===n.ino}function Bo(e){Atomics.wait(Uo,0,0,e)}function Ai(e){try{return process.kill(e,0),!0}catch(n){return!_(n,"ESRCH")}}function $o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ui(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()||!Le(o,a))throw new Error("credential-store parent changed while it was being inspected");we(o,"credential-store parent");let s=o;if((o.mode&63)!==0&&S.basename(t)===".allscale"&&(d.default.fchmodSync(r,448),s=d.default.fstatSync(r)),(s.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 x(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 E:o}if(!Le(t,r))throw i.retryOnPathChange?new E: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 ke;if(we(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 Fo(e,n){if(n.size>Ve)throw new Error("credential-store file exceeds the maximum supported size");let t=Buffer.alloc(Ve+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>Ve)throw new Error("credential-store file exceeds the maximum supported size");return t.subarray(0,i).toString("utf8")}function pi(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=x(e,n,t);return Fo(n,i)}finally{n!==null&&d.default.closeSync(n)}}function mi(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")&&Si(e))return;throw r}let t=d.default.fstatSync(n),i=x(e,n,t);z(e,i)}finally{n!==null&&d.default.closeSync(n)}ki(S.dirname(e))}function Mo(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 ke;we(n,"credential-store replacement target")}function Go(e,n){for(let t=0;t<8;t+=1){let i=(0,Jn.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 Ti(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 ki(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 qo(e,n){let t=Buffer.from(n,"utf8");if(t.length>Ve)throw new Error("credential-store file exceeds the maximum supported size");let i=S.dirname(e),r=S.basename(e),o=null,a=null,s=!1;try{let l=Go(i,r);o=l.fd,a=l.tempPath;let u=d.default.fstatSync(o);if((x(a,o,u).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");Ti(o,t),d.default.fsyncSync(o),x(a,o,d.default.fstatSync(o));let m=o;o=null,d.default.closeSync(m),Mo(e),d.default.renameSync(a,e),s=!0}finally{if(o!==null)try{d.default.closeSync(o)}catch{}if(!s&&a!==null)try{d.default.unlinkSync(a)}catch{}}ki(i)}function Yo(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 Vo(e,n){if(n.size>Hn)return null;let t=Buffer.alloc(Hn+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>Hn)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 z(e,n){let t=d.default.lstatSync(e);if(t.isSymbolicLink()||!t.isFile()||!Le(t,n))throw new Error("credential-store lock changed while it was being inspected");we(t,"credential-store lock"),d.default.unlinkSync(e)}function fi(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(l){if(_(l,"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 E}catch(u){if(_(u,"ENOENT"))return{state:"absent"};throw u}throw l}let i=d.default.fstatSync(t),r=x(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=Vo(t,r);return{state:(o?.target===n&&o?!Ai(o.pid):Date.now()-r.mtimeMs>=Po)?"stale":"active",stats:r}}finally{t!==null&&d.default.closeSync(t)}}function Ho(e,n){for(let t=0;t<8;t+=1){let i=(0,Jn.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 s=d.default.fstatSync(a),l=x(r,a,s,{allowMultipleLinks:!0});return Ti(a,Buffer.from(JSON.stringify(o),"utf8")),d.default.fsyncSync(a),{claimPath:r,metadata:o,stats:l}}catch(s){if(_(s,"EEXIST"))continue;try{d.default.unlinkSync(r)}catch{}throw s}finally{a!==null&&d.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function zo(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 E:i}try{let i=d.default.fstatSync(t),r=x(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!Le(r,n))throw new E;return{fd:t,lockPath:e,stats:r}}catch(i){throw d.default.closeSync(t),i}}function yi(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 E}catch(i){if(_(i,"ENOENT"))return!1;throw i}throw t}return x(e,n,d.default.fstatSync(n),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{n!==null&&d.default.closeSync(n)}}function Jo(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=x(e,n,t,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:n,lockPath:e,stats:i}}catch(i){if(t!==null)try{z(e,t)}catch{}throw d.default.closeSync(n),i}}function V(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");Bo(xo)}function hi(e){let n=S.dirname(e),t=S.basename(e),i=Yo(e),r=Ko(e),o=Ho(n,t),a=Date.now()+Ro,s=!1,l=!1,u=null,p;try{for(;u===null;)try{if(yi(r)){V(a,!0);continue}d.default.linkSync(o.claimPath,i),l=!0,u=zo(i,o.stats),s=!0}catch(m){if(l&&!s){try{z(i,o.stats)}catch{}l=!1}if(m instanceof E){V(a,!1);continue}if(!_(m,"EEXIST"))throw m;let h;try{h=fi(i,t)}catch(A){if(A instanceof E){V(a,!1);continue}throw A}if(h.state==="absent")continue;if(h.state==="stale"){let A;try{A=Jo(r)}catch(L){if(L instanceof E){V(a,!1);continue}throw L}if(A!==null){try{let L;try{L=fi(i,t)}catch(U){if(U instanceof E){V(a,!1);continue}throw U}L.state==="stale"&&z(i,L.stats)}finally{zn(A)}continue}}let f;try{f=yi(r)}catch(A){if(A instanceof E){V(a,!1);continue}throw A}V(a,f)}}catch(m){p=m}try{z(o.claimPath,o.stats)}catch(m){!_(m,"ENOENT")&&!s&&p===void 0&&(p=m)}if(p!==void 0)throw p;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function zn(e){try{z(e.lockPath,e.stats)}finally{d.default.closeSync(e.fd)}}function Wo(e,n){let t=$o(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 gi(e){let n=S.dirname(e),t=S.basename(e);for(let i of d.default.readdirSync(n)){let r=Wo(i,t);if(r===null||Ai(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 s=d.default.fstatSync(a),l=d.default.lstatSync(o);if(!s.isFile()||l.isSymbolicLink()||!l.isFile()||!Le(s,l))continue;try{we(s,"credential-store orphan")}catch{continue}z(o,s)}catch(s){if(!_(s,"ENOENT"))throw s}finally{a!==null&&d.default.closeSync(a)}}}function be(e,n,t){if(!ze()){if(n.allowUnsupportedPlatformCleanup){if(n.createParent)throw H();if(!ui(e,!1))return t({read:()=>null,remove:()=>{},write:()=>{throw H()}});let a=hi(e);try{return gi(e),t({read:()=>pi(e),remove:()=>mi(e),write:()=>{throw H()}})}finally{zn(a)}}if(!n.createParent){let o=!1;try{o=Si(e)}catch{throw H()}if(o)return t({read:()=>null,remove:()=>{},write:()=>{throw H()}})}throw H()}if(!ui(e,n.createParent))return t({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let r=hi(e);try{return gi(e),t({read:()=>pi(e),remove:()=>mi(e),write:o=>qo(e,o)})}finally{zn(r)}}var Wn="allscale-cli";function Qn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Li(e){return Qn(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function W(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 jn(){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 Je(){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 J,Xn=!1;function jo(){return ei()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Xo(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 Zo(){if(J!==void 0)return J;if(jo())return Xn=!1,J=null,J;try{J=require("keytar"),Xn=!1}catch(e){Xn=!Xo(e),J=null}return J}function bi(){let e=ze()?"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 Zn(e){try{return await e()}catch{throw bi()}}var et=class{constructor(n){this.keytar=n}keytar;kind="keychain";async read(n){let t=await Zn(()=>this.keytar.getPassword(Wn,n));if(t===null)return null;let i;try{i=JSON.parse(t)}catch{throw W("OS keychain")}if(!Li(i))throw W("OS keychain");return i}async get(n){return this.read(n)}async set(n,t){await this.read(n),await Zn(()=>this.keytar.setPassword(Wn,n,JSON.stringify(t)))}async delete(n){await this.read(n),await Zn(()=>this.keytar.deletePassword(Wn,n))}},Qo="credentials.json",nt=class{kind="insecure-file";filePath;constructor(n){this.filePath=n??wi.join(Yn(),Qo)}read(n){let t;try{t=n.read()}catch(r){throw He(r)?jn():W("plaintext file")}if(t===null)return{profiles:{}};let i;try{i=JSON.parse(t)}catch{throw W("plaintext file")}if(!Qn(i)||!Qn(i.profiles))throw W("plaintext file");return i}write(n,t){try{n.write(JSON.stringify(t,null,2))}catch(i){throw He(i)?jn():Je()}}profileTokens(n,t){let i=n.profiles[t];if(i!==void 0){if(!Li(i))throw W("plaintext file");return i}}async get(n){try{return be(this.filePath,{createParent:!1},t=>this.profileTokens(this.read(t),n)??null)}catch(t){throw t instanceof c?t:W("plaintext file")}}async set(n,t){try{be(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:Je()}}async delete(n){try{be(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:Je()}}async clearProfile(n){try{return be(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:He(t)?jn():Je()}}};function We(e){if(e.insecureStorage)return _i(),new nt(e.insecureFilePath);let n=Zo();if(n)return new et(n);throw bi()}var tt=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 je(){return new tt}var Xe="allscale_access_token",it="allscale_refresh_token";function Ei(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 rt(e){return e.map(n=>`${n.name}=${n.value}`).join("; ")}function ot(e,n){return e.find(t=>t.name===n)?.value??null}var Ni=b(require("crypto")),Ci=b(require("fs")),Ii=b(require("path"));var ea="key-id",na="x-allscale-cli-version",at="cli-1",ta="aScaLe_cli_obf_v1",ia="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function ra(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 oa=ra(ia,ta),Oi=`Bearer ${oa}`;function vi(e,n){let t=wn(e);if(t!==null)return n.find(i=>wn(i.base)===t)}function aa(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let n=he();if(n.length>0){let i=vi(e,n);if(i)return i.key;if(G(e)){let r=process.env.ALLSCALE_SIGNING_KEY;return r&&r.trim().length>0?r:G(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 sa(e){{let i="cli-1".trim();if(i.length>0)return i}let n=he();if(n.length>0){let i=e!==void 0?vi(e,n):void 0;if(i)return i.keyId;if(e!==void 0&&G(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():at}if(!G(n[0].base))return at}return n[0].keyId}let t=process.env.ALLSCALE_SIGNING_KEY_ID;return t!==void 0?t.trim():at}function la(){return"1.0.1"}function ca(){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 st(e,n){let t=aa(n);if(!t)throw ca();let i=sa(n),r=Math.floor(Date.now()/1e3).toString(),o=Ni.createHash("sha256").update(`${t}${r}${e}`).digest("hex"),a={timestamp:r,"secret-key":o,[na]:la()};return i.length>0&&(a[ea]=i),a}function Ri(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function da(e,n={}){let t;try{t=ri(Me())}catch{return}if(!(t.length===0||t.includes(e)))return new c("auth.unknown_profile",$t(e)+(n.messageSuffix??""),{profile:e})}function Ee(e){if(e.profileExplicit){let n=da(e.profile);if(n)return n}return new c("auth.no_token",Bt(e.profile))}var ua=500,pa=8,xi=100;function lt(e,n=0){if(n>pa)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,xi),i=t.map(r=>lt(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,xi))t[i]=Ue(i)?"<redacted>":lt(r,n+1);return t}return e}function ma(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 Pi(e,n=ua){let t=ma(e),i=t===void 0?Pe(e):JSON.stringify(lt(t));return De(i,n)}var ct=256*1024,Ze=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"}},Qe=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 dt(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 Ze(e.status,n,t.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),a=[],s=0,l,u=t.timeoutMs,p=u===void 0?void 0:new Promise((m,h)=>{l=setTimeout(()=>{h(new Qe(e.status,u))},u),l.unref?.()});try{for(;;){let m=o.read(),{done:h,value:f}=p?await Promise.race([m,p]):await m;if(h)break;if(s+=f.byteLength,s>n)throw o.cancel().catch(()=>{}),new Ze(e.status,n,t.oversizeKind);a.push(Buffer.from(f))}}catch(m){throw m instanceof Qe&&o.cancel(m).catch(()=>{}),m}finally{l!==void 0&&clearTimeout(l);try{o.releaseLock()}catch{}}return Buffer.concat(a,s).toString("utf8")}var fa="X-AllScale-Api-Key",ya=3e4,ha=32*1024*1024,ga=4*1024*1024;function _a(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 Sa(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 Aa(e,n){if(!(e<300||e>=400))throw new c("transport.network",`API returned HTTP ${e} (a redirect) for ${B(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 Fi(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Aa(e.status,e.url)}}var Ui="--dns-result-order=ipv4first";async function en(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)??"",s=/^\s*(?:<!doctype\s+html|<html\b)/i.test(a),l=/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||s)&&(r||n!==void 0&&l)))return;if(n===void 0)try{e.body?.cancel().catch(()=>{})}catch{}let p=/^[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=${Ui} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...p?{cf_ray:p}:{},ipv4_workaround:`NODE_OPTIONS=${Ui}`})}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??ya;if(!Number.isFinite(i)||i<1)throw new c("input.invalid","HTTP request timeout must be a positive number of milliseconds.");K(this.opts.apiBase),qe(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=_a(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 ${B(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 ${B(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();si(this.opts.apiBase,r);let o=i?.agent_key,a=n.auth??"auto",s=Mi(n.path),l=a==="required"?!0:a==="none"?!1:wa(n.path);if((s||a==="required")&&!n._isRefresh&&!this.opts.override&&!i?.access_token&&!o)throw Ee({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let u=Ri(n.body),p=!!o||!!i?.access_token;l&&p&&!this.opts.override&&Ge(this.opts.apiBase,i?.api_base);let m=this.buildHeaders({attachAuth:l&&p,bodyForSig:u,tokens:i,extra:n.headers}),h=Date.now();T({type:"request",method:n.method??"GET",url:r,...n._isRefresh?{refresh:!0}:{}});let f;try{f=await fetch(r,{method:n.method??"GET",headers:m,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(L){throw new c("transport.network",`Network error contacting ${B(r)}: ${L instanceof Error?L.message:String(L)}`)}if(T({type:"response",status:f.status,durationMs:Date.now()-h}),l&&!!i?.access_token&&!o&&f.status===401&&!n._isRefresh&&!this.opts.override){let L=await Sa(this.refreshSingleFlight(),n.signal),U=this.buildHeaders({attachAuth:l&&!!L.access_token,bodyForSig:u,tokens:L,extra:n.headers}),Z=Date.now();T({type:"request",method:n.method??"GET",url:r});let C;try{C=await fetch(r,{method:n.method??"GET",headers:U,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(I){throw new c("transport.network",`Network error contacting ${B(r)} on refresh-retry: ${I instanceof Error?I.message:String(I)}`)}return T({type:"response",status:C.status,durationMs:Date.now()-Z}),Di(C,{withMetadata:t.withMetadata,authBearing:l,responseKind:Bi(n)})}return Di(f,{withMetadata:t.withMetadata,authBearing:l&&p,agentKeyAuth:l&&!!o,responseKind:Bi(n)})}buildHeaders(n){let i={Accept:"application/json","Content-Type":"application/json",...st(n.bodyForSig,this.opts.apiBase),...n.extra};if(n.attachAuth){i.Authorization=Oi;let r=n.tokens;if(r?.agent_key)return i[fa]=r.agent_key,i;let o=r?.access_token;o&&(i.Cookie=rt([{name:Xe,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(Ge(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 ${xe()}.`);if(Ge(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=rt([{name:Xe,value:n.access_token},{name:it,value:n.refresh_token}]),r=st("",this.opts.apiBase);T({type:"request",method:"POST",url:t,refresh:!0});let o=new AbortController,a=!1,s=setTimeout(()=>{a=!0,o.abort()},1e4),l;try{l=await fetch(t,{method:"POST",headers:{Accept:"application/json",Cookie:i,...r},signal:o.signal,redirect:"manual"})}catch(f){throw T({type:"refresh",ok:!1}),new c("transport.network",a&&f instanceof Error&&f.name==="AbortError"?`Token refresh against ${B(t)} timed out after 10s with no response.`:`Network error during token refresh against ${B(t)}: ${f instanceof Error?f.message:String(f)}`)}finally{clearTimeout(s)}T({type:"response",status:l.status,durationMs:0});try{await Fi(l)}catch(f){throw T({type:"refresh",ok:!1}),f}if(l.status!==200){let f=null;try{await en(l);let A=await Ca(l);await en(l,A),qi(l.status,A),l.status===401&&(f=await this.adoptConcurrentlyRotatedTokens(n))}catch(A){throw T({type:"refresh",ok:!1}),A}if(f)return T({type:"refresh",ok:!0,adopted:!0}),f;throw T({type:"refresh",ok:!1}),new c("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${xe()}.`,{status:l.status})}let u=Ei(l.headers),p=ot(u,Xe),m=ot(u,it);if(!p||!m)throw T({type:"refresh",ok:!1}),new c("auth.token_expired","Refresh response did not include new access/refresh cookies.");let h={...n,access_token:p,refresh_token:m};return await this.opts.tokenStore.set(this.opts.profile,h),T({type:"refresh",ok:!0}),h}},Ta=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function Mi(e){let n=e.split(/[?#]/,1)[0];return Ta.some(t=>n===t||n.startsWith(`${t}/`))}var ka=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function ut(e){let n=e.split(/[?#]/,1)[0];return ka.some(t=>t.test(n))}function wa(e){return Mi(e)||ut(e)}async function Di(e,n={}){await Fi(e);let t=e.status>=200&&e.status<300;t||await en(e);let i=n.responseKind??"mutation",o=await dt(e,t?i==="query"?ha:ga:ct,{oversizeKind:t?i==="query"?"successful-query":"successful-mutation":"backend-envelope"});t||await en(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 l={};return e.headers.forEach((u,p)=>{l[p]=u}),{status:e.status,headers:l,body:a}}return a}let s=Ia(a)??`HTTP ${e.status}`;if(qi(e.status,a),Ea(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 l=n.authBearing?"auth.token_expired":"input.invalid";throw new c(l,s,{status:401,body:a})}throw e.status===403?new c("auth.permission_denied",s,{status:403,body:a}):e.status===404?new c("not_found",s,{status:404,body:a}):e.status===429?new c("rate_limited",s,{status:429,body:a}):e.status>=500?new c("backend.internal",s,{status:e.status,body:a}):new c("input.invalid",s,{status:e.status,body:a})}function Bi(e){if(e.responseKind)return e.responseKind;let n=(e.method??"GET").toUpperCase();return n==="GET"||n==="HEAD"?"query":"mutation"}var La=2014,$i=2004;function Gi(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 ba(e){return Gi(e,La)}function Ea(e,n,t){if(!(e>=200&&e<300)&&t.authBearing&&!(e===401&&t.agentKeyAuth)&&Gi(n,$i))throw new c("auth.token_expired",`The API rejected this credential as invalid. Re-authenticate with ${xe()} 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:$i})}var Na=1e4;async function Ca(e,n=Na){if(e.status>=200&&e.status<300)return"";try{return await dt(e,ct,{timeoutMs:n})}catch{return""}}function qi(e,n){if(!(e>=200&&e<300)&&ba(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"?Pi(n):n})}function Ia(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 Oa=/^\/(api\/)?(v1\/)?public\//;function pt(e,n={}){let t=typeof n.pathHint=="string"?n.pathHint:"",i=t&&Oa.test(t),r=t&&ut(t),o=i&&!r&&!n.forceAuth;if(e.token)return new j({apiBase:e.apiBase,tokenStore:je(),profile:e.profile,profileExplicit:e.profileExplicit,override:{access_token:e.token}});if(o)return new j({apiBase:e.apiBase,tokenStore:je(),profile:e.profile,profileExplicit:e.profileExplicit});try{return new j({apiBase:e.apiBase,tokenStore:We({insecureStorage:e.insecureStorage}),profile:e.profile,profileExplicit:e.profileExplicit})}catch(a){if(r)return new j({apiBase:e.apiBase,tokenStore:je(),profile:e.profile,profileExplicit:e.profileExplicit});throw a}}var Yi=[{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}],Ki=[{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 nn=new Set(["SCALAR","ENUM"]),va=new Set(["password","password_hash","totp_secret","credential","credentials","private_key","encryption_key"]),Ra=[/(^|_)password(_|$)/i,/(^|_)secret(_|$)/i,/(^|_)token(_|$)/i,/(^|_)api[_-]?key(_|$)/i,/(^|_)signing[_-]?key(_|$)/i,/(^|_)private[_-]?key(_|$)/i,/(^|_)credential(_|$)/i],xa=new Set(["CreateClaimLinkResult.claim_token","StoreCreateResult.api_secret"]),Pa=new Map([["StoreCreateResult.store",["id","name"]],["CreateClaimLinkResult.claim_link",["id","token_symbol","status"]]]),Ua=new Set(["token_symbol"]),Da=new Set;function mt(e,n){return Da.has(`${e}.${n}`)}function ft(e){return Ua.has(e.toLowerCase())?!1:va.has(e)?!0:Ra.some(n=>n.test(e))}function Ba(e,n){return xa.has(`${e}.${n}`)}function yt(e){return e.kind==="NON_NULL"&&e.ofType?`${yt(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${yt(e.ofType)}]`:e.name??"Unknown"}function Ne(e){let n=e;for(;n&&n.ofType;)n=n.ofType;return!n||!n.name?null:{kind:n.kind,name:n.name}}function $a(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 s=Ne(a.type);if(!s)continue;if(nn.has(s.kind)){if(ft(a.name)&&!Ba(e,a.name)||mt(e,a.name))continue;r.push(a.name);continue}let l=Pa.get(`${e}.${a.name}`);if(l){let u=n.find(f=>f.name===s.name),p=new Set((u?.fields??[]).filter(f=>{let A=Ne(f.type);return A!==null&&nn.has(A.kind)&&!ft(f.name)}).map(f=>f.name)),m=l.filter(f=>!p.has(f));if(m.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${m.join(", ")}] that are not selectable scalars on ${s.name}; fix the entry or the public registry.`);let h=l.filter(f=>mt(s.name,f));if(h.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${h.join(", ")}] that DEFAULT_SELECTION_EXCLUSIONS keeps out of default selections on ${s.name}; drop the field from the nested entry, or remove the exclusion if it is no longer true.`);r.push(`${a.name} { ${l.join(" ")} }`);continue}if(!o&&a.name==="items"&&a.type.kind==="NON_NULL"&&a.type.ofType?.kind==="LIST"){let u=Fa(a.type)?.name;if(u){let p=Ma(u,n);p&&r.push(`items { ${p} }`),o=!0}}}return r.length>0?r.join(" "):"__typename"}function Fa(e){return Ne(e)}function Ma(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=Ne(o.type);if(a&&nn.has(a.kind)){if(ft(o.name)||mt(e,o.name))continue;r.push(o.name)}}return r.length>0?r.join(" "):"__typename"}function Vi(e,n,t){let i=Ga(e.name),r=e.args.map(p=>{let m=yt(p.type);return p.defaultValue!==null&&p.defaultValue!==void 0?`$${p.name}: ${m} = ${p.defaultValue}`:`$${p.name}: ${m}`}).join(", "),o=e.args.map(p=>`${p.name}: $${p.name}`).join(", "),a=r.length>0?`${e.kind} ${i}(${r})`:`${e.kind} ${i}`,s=o.length>0?`${e.name}(${o})`:e.name,l=Ne(e.returnType),u;if(l&&nn.has(l.kind))u=s;else{let p=t&&t.trim().length>0?t.trim():l&&$a(l.name,n)||"__typename";u=`${s} { ${p} }`}return`${a} { ${u} }`}function Hi(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 zi(e,n,t){return e.find(i=>i.kind===n&&i.name===t)??null}function Ji(e){if(!e||typeof e!="object")return!1;let n=e.errors;return Array.isArray(n)&&n.length>0}function Wi(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 qa=new Set;var Ya=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"]),ht=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","transaction:read_only","wallet:read_only","claim_link:read_only","claim_link:all","store:read_only","store:all"]),gt=new Set(["payroll","admin:user","admin:org","admin:audit"]);function tn(e){let n=e.lastIndexOf(":");return n===-1?e:e.slice(0,n)}function rn(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"]),Va=new Set([...Ka].map(tn));var wc=new Set([...[...Ya,...ht,...qa].map(tn),...gt,...Va]);var Ha={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"},za={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"},Ja=/API key scope not granted:\s*requires\s+(.+?),\s*key has\s+(.+?)\.?\s*$/i,Wa=/is not available to API keys/i,ji=/^[a-z_]+(?::[a-z_]+)*:[a-z_]+$/;function Xi(e){if(typeof e!="string")return;let n=Ja.exec(e);if(!n)return;let t=n[1].trim(),i=n[2].trim(),r=Wa.test(t),o=!r&&ji.test(t)?t:void 0,a;if(i.toLowerCase()==="none")a=[];else{let s=i.split(",").map(l=>l.trim()).filter(l=>ji.test(l));a=s.length>0?s:void 0}if(!(o===void 0&&!r))return{required:o,granted:a,notAvailableToKeys:r}}function Zi(e){let n=za[e];if(n!==void 0)return{ungrantableReason:n};let t=Ha[e];if(t!==void 0)return{scope:t}}function Qi(e){if(gt.has(tn(e)))return{kind:"ungrantable"};for(let n of ht)if(rn(n,e))return{kind:"approval_screen"};return{kind:"otp_login_only"}}var ja=new Set([3e3,3200,3300,3400,3500,3600,4e3,4100,4200,4300,4400,4600,4700,4800,4900,4901,5e3,5100,5150,5200,5300,5400,5500,5600,6050,8300,8301,8302,8306]);function _t(e,n){let t=nr(e),i={graphql_error_count:Xa(e.errors),...t===void 0?{}:{backend_code:t}};if(t===2102)throw Za(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&&ja.has(t))throw new c("not_found",`GraphQL ${n.kind} '${n.operationName}' could not find the requested resource.`,i);if(Ji(e))throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' returned errors: ${Wi(e)}`,i);if(t!==void 0)throw new c("input.invalid",`GraphQL ${n.kind} '${n.operationName}' failed with backend code ${t}.`,i)}function nr(e){let n=er(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=er(i.code);if(r!==void 0)return r}}function er(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 Xa(e){return Array.isArray(e)?e.length:e==null?0:1}function Za(e,n,t){let i=`GraphQL ${n.kind} '${n.operationName}'`,r={...t,operation:n.operationName},o=Xi(Qa(e,nr(e))),a=Zi(n.operationName),s=o?.notAvailableToKeys===!0,l=o?.required??a?.scope,u=o?.granted,p=u===void 0?"":` This key holds ${u.length>0?u.join(", "):"no scopes"}.`;if(s||a?.ungrantableReason!==void 0){let m=a?.ungrantableReason!==void 0?`: ${a.ungrantableReason}`:"";return new c("auth.permission_denied",`${i} is not available to agent keys${m}. Re-authorizing will NOT help \u2014 no scope grants it.${p} 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(l!==void 0){let m=Qi(l),h=m.kind==="ungrantable"?`\`${l}\` cannot be granted to any key (the backend clips this category to nothing), so re-authorizing will NOT help.`:m.kind==="approval_screen"?`Re-run \`allscale device-login\` and enable it on the approval screen, or \`${q()}\` with \`--scopes ${l}\`.`:`The browser approval screen does not offer \`${l}\`, so \`device-login\` cannot grant it \u2014 use \`${q()}\` with \`--scopes ${l}\`.`;return new c("auth.permission_denied",`The current agent key lacks \`${l}\`, required by ${i}.${p} ${h}`,{...r,missing_scopes:[l],...u===void 0?{}:{granted_scopes:u},...m.kind==="ungrantable"?{ungrantable:!0}:{}})}return new c("auth.permission_denied",`The current agent key does not have the scope required by ${i}.${p} Re-run \`allscale device-login\` (or \`${q()}\`) and grant the required scope.`,r)}function Qa(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 l=i(r);if(l!==void 0)return l}}for(let r of t){let o=i(r);if(o!==void 0)return o}return""}async function v(e,n,t,i,r={}){let o=zi(Yi,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=Hi(o,i);if(!a.ok)throw new c("input.invalid",`Missing required variables for ${t}: ${a.missing.join(", ")}`,{required:a.missing});let s=Vi(o,Ki,r.selection);return es(e,{...r,kind:n,operationName:o.name,document:s,variables:i})}async function es(e,n){n.showDoc&&process.stderr.write(`${n.document}
|
|
17
|
+
`);let t=pt(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}});_t(r,{kind:n.kind,operationName:n.operationName});let o=r.data?.[n.operationName];return o===void 0?null:o}async function P(e){if(e.token)return{kind:"override",accessToken:e.token};let t=await We({insecureStorage:e.insecureStorage}).get(e.profile),i=t?.api_base;return t?.agent_key?{kind:"agent",storedApiBase:i,businessId:St(t.business_id),userEmail:St(t.user_email),scopes:ns(t.scopes)}:t?.access_token?{kind:"human",storedApiBase:i,accessToken:t.access_token,userEmail:St(t.user_email)}:{kind:"none"}}function St(e){return typeof e=="string"&&e.length>0?e:void 0}function ns(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 At(e){let n=e.split(".");if(n.length!==3)throw new c("auth.token_expired","This token is not a JWT session. Agent API keys are not JWTs \u2014 this path needs a human session token.");try{let t=Buffer.from(n[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");return JSON.parse(t)}catch(t){throw new c("auth.token_expired",`Failed to decode JWT payload: ${t.message}`)}}async function on(e,n){if(typeof n=="string"&&n.length>0)return n;let t=await P(e);switch(t.kind){case"override":case"human":return rs(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 Ee({profile:e.profile,profileExplicit:e.profileExplicit});default:return tr(t)}}async function ts(e){let n=i=>{let r=At(i);return typeof r.user_id=="string"&&r.user_id.length>0?r.user_id:void 0},t=await P(e);switch(t.kind){case"override":case"human":return n(t.accessToken);case"agent":return t.businessId;case"none":throw Ee({profile:e.profile,profileExplicit:e.profileExplicit});default:return tr(t)}}function tr(e){throw new c("internal",`Unhandled credential kind: ${JSON.stringify(e.kind)}`)}var is=/^[0-9a-f]{24}$/i;async function ir(e,n){if(typeof n!="string"||n.length===0)return;if(!is.test(n))throw new c("input.invalid",`--business-id '${n}' is not a valid business id (expected 24 hexadecimal characters). Omit the flag to use the business you are signed in as.`);let t=await ts(e);if(t===void 0){process.stderr.write(`Note: could not verify that --business-id '${n}' is your own business \u2014 this session stores no business id (an agent-key login predating the backend returning it). The command acts as the business you are signed in as regardless. Re-run \`allscale device-login\` to store it and enable this check.
|
|
18
|
+
`);return}if(t.toLowerCase()!==n.toLowerCase())throw new c("auth.permission_denied",`--business-id '${n}' is not the business you are signed in as. This command always acts as the authenticated business, so a different business id cannot be used. Omit the flag, or sign in as that business.`)}function rs(e){let n=At(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}function Tt(e,n){return{lacks:e.kind==="agent"&&e.scopes!==void 0&&!e.scopes.some(i=>rn(i,n)),grantedScopes:e.kind==="agent"?e.scopes:void 0}}async function rr(e,n){return Tt(await P(e),n).lacks}var an="id email name address phone",se="contact:all";function or(e){return`Re-run \`allscale ${En} --profile ${e}\` and turn the Contacts write toggle ON, or mint a key with explicit scopes via \`${q(e)}\` including ${se} \u2014 note an explicit --scopes list replaces the defaults, so list every scope this workflow needs. Alternatively create the contact in the web app first, or pass an existing contact via --to-contact-id.`}function os(e){return e.startsWith("transport.")||e.startsWith("auth.")||e.startsWith("backend.")||e==="internal"||e==="rate_limited"}async function as(e,n,t={}){let i;try{i=await v(e,"query","contact_by_email",{email:n},{selection:an,showDoc:!1})}catch(o){if(o instanceof c&&os(o.code))throw o;let a=o instanceof Error?o.message:String(o),s=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",`${s}
|
|
19
|
+
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 ar(e,n,t){let i=n.trim().toLowerCase(),o=(await v(e,"query","contacts",{owner_business_id_str:t,query_input:{limit:500,skip:0}},{selection:`count items { ${an} }`,showDoc:!1}))?.items??[];for(let a of o)if(typeof a?.email=="string"&&a.email.toLowerCase()===i)return a;return null}function ss(e){return e instanceof Error?/A contact named .* already exists/i.test(e.message):!1}async function sr(e,n,t={}){try{return await as(e,n)}catch(l){if(!(l instanceof c)||l.code!=="input.invalid")throw l;if(!t.autoCreateName||t.autoCreateName.length===0)throw await rr(e,se)?new c("input.invalid",`${l.message}
|
|
20
|
+
Note: --auto-create-contact will not work with the current agent key either \u2014 it was minted without the ${se} scope that create_contact requires. `+or(e.profile)):l}let i=await on(e,t.businessIdFlag),r=t.stderr??process.stderr,o=await ar(e,n,i);if(o)return r.write(`Found existing contact "${o.name??n}" <${n}> (id=${o.id}) via list fallback \u2014 skipping auto-create.
|
|
21
|
+
`),o;let a=Tt(await P(e),se);if(a.lacks)throw new c("auth.permission_denied",`Cannot auto-create a contact for "${n}": creating contacts requires the ${se} scope, and this agent key was minted without it (granted scopes are checked by the backend on each request). `+or(e.profile),{operation:"create_contact",missing_scopes:[se],...a.grantedScopes===void 0?{}:{granted_scopes:a.grantedScopes}});let s;try{s=await v(e,"mutation","create_contact",{create_input:{owner_business_id:i,name:t.autoCreateName,email:n}},{selection:an,showDoc:!1})}catch(l){if(ss(l)){let u=await ar(e,n,i);if(u)return r.write(`create_contact reported "${t.autoCreateName}" already exists; recovered existing contact <${n}> (id=${u.id}) via list fallback.
|
|
22
|
+
`),u;throw new c("input.invalid",`Cannot auto-create contact "${t.autoCreateName}" \u2014 a contact with that name already exists on your business, but its email is not "${n}". Pass --contact-name "<different-name>" or look up the existing contact's id_str and use --to-contact-id instead.`)}throw l}if(!s||typeof s.id!="string")throw new c("backend.internal",`create_contact returned an unexpected shape for "${n}".`,{received:s});return r.write(`Auto-created contact "${t.autoCreateName}" <${n}> (id=${s.id}) \u2014 proceeding with invoice send.
|
|
23
|
+
`),s}async function lr(e,n){let t=await v(e,"query","contact",{id_str:n},{selection:an,showDoc:!1}),i=t;if(!i||typeof i.id!="string")throw new c("backend.internal",`contact(id_str:"${n}") returned an unexpected shape.`,{received:t});return i}var pr=b(require("handlebars"));var cr=`<!DOCTYPE html>
|
|
23
24
|
<html lang="en">
|
|
24
25
|
<head>
|
|
25
26
|
<meta charset="UTF-8"/>
|
|
@@ -37,7 +38,7 @@ Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.
|
|
|
37
38
|
<div style="display:table-cell;vertical-align:top;">
|
|
38
39
|
<h1 style="font-size:2rem;font-weight:bold;color:#0C3124;margin:0">INVOICE</h1>
|
|
39
40
|
<p style="margin-top:0.1rem;color:#6b7280;font-size:0.875rem;">[invoice_id]</p>
|
|
40
|
-
<p style="margin-top:1rem;color:#0C3124;font-size:0.875rem;">{{invoiceData.date}}</p>
|
|
41
|
+
<p style="margin-top:1rem;color:#0C3124;font-size:0.875rem;">{{formatDate invoiceData.date}}</p>
|
|
41
42
|
</div>
|
|
42
43
|
<div style="display:table-cell;vertical-align:top">
|
|
43
44
|
<img src="https://cdn.prod.website-files.com/6779cec685b83bf2876d67f3/677b485c6298df1f5c44d8c2_AllScale-a1-Transparent.svg"
|
|
@@ -68,7 +69,7 @@ Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.
|
|
|
68
69
|
|
|
69
70
|
<div style="width:48%;display:inline-block;vertical-align:top;box-sizing:border-box;">
|
|
70
71
|
<h2 style="font-size:0.875rem;font-weight:600;color:#646464;margin-bottom:0.5rem;">Due Date:</h2>
|
|
71
|
-
<p style="margin:0.25rem 0;color:#0C3124;font-size:0.875rem;font-weight:600;">{{invoiceData.dueDate}}</p>
|
|
72
|
+
<p style="margin:0.25rem 0;color:#0C3124;font-size:0.875rem;font-weight:600;">{{formatDate invoiceData.dueDate}}</p>
|
|
72
73
|
</div>
|
|
73
74
|
<div style="clear:both;margin-bottom:2rem;"></div>
|
|
74
75
|
|
|
@@ -94,7 +95,7 @@ Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.
|
|
|
94
95
|
{{#each invoiceData.items}}
|
|
95
96
|
<tr style="border-bottom:1px solid #f3f4f6;">
|
|
96
97
|
<td style="padding:0.5rem;color:#0C3124;font-size:0.875rem;">{{description}}</td>
|
|
97
|
-
<td style="padding:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;">{{quantity}}</td>
|
|
98
|
+
<td style="padding:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;">{{formatQuantity quantity}}</td>
|
|
98
99
|
<td style="padding:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;">{{formatMoneyWithCode
|
|
99
100
|
amount}}
|
|
100
101
|
</td>
|
|
@@ -106,7 +107,10 @@ Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.
|
|
|
106
107
|
{{/each}}
|
|
107
108
|
</tbody>
|
|
108
109
|
<tfoot>
|
|
109
|
-
{{
|
|
110
|
+
{{!-- taxPercentage is part of both conditions so a chosen rate keeps
|
|
111
|
+
its rows visible (as $0.00) while items are still empty, instead
|
|
112
|
+
of the whole fee summary silently vanishing (604984) --}}
|
|
113
|
+
{{#if (or (or invoiceData.tax invoiceData.discountApplied) invoiceData.taxPercentage)}}
|
|
110
114
|
<tr>
|
|
111
115
|
<td colspan="3" style="padding-top:1rem;text-align:right;color:#0C3124;font-size:0.875rem;font-weight:500;">
|
|
112
116
|
Subtotal:
|
|
@@ -116,22 +120,22 @@ Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.
|
|
|
116
120
|
</td>
|
|
117
121
|
</tr>
|
|
118
122
|
{{/if}}
|
|
119
|
-
{{#if invoiceData.
|
|
123
|
+
{{#if invoiceData.discountApplied}}
|
|
120
124
|
<tr>
|
|
121
125
|
<td colspan="3"
|
|
122
126
|
style="padding-top:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;font-weight:500;">
|
|
123
127
|
Discount:
|
|
124
128
|
</td>
|
|
125
129
|
<td style="padding-top:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;font-weight:500;">
|
|
126
|
-
-{{formatMoneyWithCode invoiceData.
|
|
130
|
+
-{{formatMoneyWithCode invoiceData.discountApplied}}
|
|
127
131
|
</td>
|
|
128
132
|
</tr>
|
|
129
133
|
{{/if}}
|
|
130
|
-
{{#if invoiceData.tax}}
|
|
134
|
+
{{#if (or invoiceData.tax invoiceData.taxPercentage)}}
|
|
131
135
|
<tr>
|
|
132
136
|
<td colspan="3"
|
|
133
137
|
style="padding-top:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;font-weight:500;">
|
|
134
|
-
Tax:
|
|
138
|
+
Tax{{#if invoiceData.taxPercentage}} ({{invoiceData.taxPercentage}}%){{/if}}:
|
|
135
139
|
</td>
|
|
136
140
|
<td style="padding-top:0.5rem;text-align:right;color:#0C3124;font-size:0.875rem;font-weight:500;">
|
|
137
141
|
{{formatMoneyWithCode invoiceData.tax}}
|
|
@@ -158,10 +162,14 @@ Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new c("backend.
|
|
|
158
162
|
</div>
|
|
159
163
|
</body>
|
|
160
164
|
</html>
|
|
161
|
-
`;function sa(e=0,n="en-US",t="USD"){let i=la(e),r;try{r=new Intl.NumberFormat(n,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:8,currencyDisplay:"code"})}catch{return`${t} ${i}`}let o=r.formatToParts(i),a=o.filter(s=>s.type!=="currency"&&s.type!=="literal").map(s=>s.value).join("");return`${o.find(s=>s.type==="currency")?.value??t} ${a.trim()}`}function la(e){let n=e<0,t=BigInt(Math.abs(e));return`${n?"-":""}${t/100n}.`+(t%100n).toString().padStart(2,"0")}function Jn(e,n){return Math.round(e*n)}var Me=null;function ca(){if(Me)return Me;let e=Ui.default.create();return e.registerHelper("multiply",Jn),e.registerHelper("or",(n,t)=>!!n||!!t),e.registerHelper("formatMoneyWithCode",sa),Me=e.compile(xi),Me}function Pi(e){return ca()({invoiceData:e.invoiceData,invoiceTotal:e.invoiceTotal??e.invoiceData.total??0,baseUrl:e.baseUrl??""})}var zn=/^(?:0|[1-9]\d*)(?:\.\d+)?$/,da=/^0(?:\.0+)?$/,ge=128;function jn(e,n,t={}){if(n.length>ge)throw new c("input.invalid",`${e} is too long; decimal values may contain at most ${ge} characters.`);let i=n.trim();if(!zn.test(i))throw new c("input.invalid",`${e} must be a decimal string without sign or exponent; got '${n}'.`);if(!t.allowZero&&da.test(i))throw new c("input.invalid",`${e} must be greater than zero; got '${n}'.`);return i}var ua=/^(\d{4})-(\d{2})-(\d{2})$/,pa=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d{1,9})?)?$/,ma=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?([Zz]|([+-])(\d{2}):?(\d{2}))$/,fa=/[T ]\d{2}:\d{2}:\d{2}(\.\d{1,9})/;function Wn(e,n,t){let i=Number(t.y),r=Number(t.m),o=Number(t.d),a=new Date(Date.UTC(i,r-1,o));if(a.getUTCFullYear()!==i||a.getUTCMonth()!==r-1||a.getUTCDate()!==o)throw Ge(e,`${t.y}-${t.m}-${t.d} is not a real calendar date`,n);let l=(s,u,p)=>{if(u===void 0)return;if(Number(u)>p)throw Ge(e,`${s} ${u} is out of range (0-${p})`,n)};l("hour",t.hh,23),l("minute",t.mm,59),l("second",t.ss,59),l("offset hours",t.offH,23),l("offset minutes",t.offM,59)}function Ge(e,n,t){return new c("input.invalid",`${t} '${e}' is not a valid date/time: ${n}. Accepted: 2026-06-01, 2026-06-01T09:30:00 (both read as UTC), 2026-06-01T09:30:00Z, or 2026-06-01T09:30:00+08:00.`)}function Bi(e,n="--due"){let t=e.trim();if(t.length===0)throw Ge(e,"it is empty",n);let i=ma.exec(t);if(i){Wn(t,n,{y:i[1],m:i[2],d:i[3],hh:i[4],mm:i[5],ss:i[6],offH:i[9],offM:i[10]});let a=`${i[1]}-${i[2]}-${i[3]}T${i[4]}:${i[5]}`,l=i[6]===void 0?"":`:${i[6]}`,s=fa.exec(t)?.[1]??"",u=i[7].toUpperCase()==="Z"?"Z":`${i[8]}${i[9]}:${i[10]}`;return`${a}${l}${s}${u}`}let r=pa.exec(t);if(r){Wn(t,n,{y:r[1],m:r[2],d:r[3],hh:r[4],mm:r[5],ss:r[6]});let[,a,l,s,u,p,m,f]=r;return`${a}-${l}-${s}T${u}:${p}:${m??"00"}${f??""}Z`}let o=ua.exec(t);if(o)return Wn(t,n,{y:o[1],m:o[2],d:o[3],hh:"00",mm:"00"}),`${o[1]}-${o[2]}-${o[3]}T00:00:00Z`;throw Ge(e,"it is not an ISO 8601 date or date-time",n)}var Zn=Math.floor(Number.MAX_SAFE_INTEGER/100),Di=BigInt(Zn),ya=10,ha=new Set([1,2]),qe=class e extends de{static description="Send an invoice by email. Resolves the contact, selects receiving wallets, renders a minimal HTML invoice, and submits create_payment through the authenticated session. No browser ceremony \u2014 the payer signs when they pay, not when you issue. Returns a fixed summary (payment_id, contact, amount, wallet count) rather than a GraphQL selection, which is why there is no --select here; read the created invoice back with `invoice get <payment_id> --select ...`. Note the direction: an invoice you send lists YOU as the payee, so it appears under `invoice received`, not `invoice sent`.";static examples=["$ allscale invoice send --to-email client@example.com --amount 1.00",'$ allscale invoice send --to-email client@example.com --amount 250 --payment-type 2 --currency-label USDC --memo "January retainer" --due 2026-06-01','$ allscale invoice send --to-contact-id 695da2cd3b9598f5edcdcb56 --amount 50 --line "Design|1|30.00" --line "Copy|1|20.00"','$ allscale invoice send --to-email client@example.com --amount 75 --line "Consulting retainer"','$ allscale invoice send --to-email client@example.com --amount 350 --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"','$ allscale invoice send --to-email client@example.com --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"',"$ allscale invoice send --to-email client@example.com --amount 100 --wallet-id 66ac....","$ allscale invoice send --to-email newclient@example.com --amount 100 --auto-create-contact",'$ allscale invoice send --to-email billing@acme.com --amount 100 --auto-create-contact --contact-name "Acme Inc"'];static requiresInput=!0;static flags={"to-email":S.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Email of the contact to invoice. Resolves via contact_by_email. If no contact exists for the email, add --auto-create-contact to create one before invoicing. Mutually exclusive with --to-contact-id.",exclusive:["to-contact-id"]}),"to-contact-id":S.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Contact id_str directly (skip the email lookup). Mutually exclusive with --to-email.",exclusive:["to-email"]}),amount:S.Flags.string({helpGroup:"CONDITIONAL",description:'Decimal amount in coin units (e.g. "1.00" for one USDT; minimum 0.10 for USDT/USDC). Optional when every --line is the three-field "<description>|<quantity>|<amount>" form \u2014 in that case the CLI sums the lines to derive the invoice total. Required otherwise.'}),"auto-create-contact":S.Flags.boolean({description:"If --to-email doesn't resolve to an existing contact, auto-create the contact (using the email + your business as owner; name defaults to the full email address, override with --contact-name) and proceed with the invoice. Ignored when the contact already exists (safe to leave on in scripts). Requires --to-email; not valid with --to-contact-id.",default:!1,exclusive:["to-contact-id"]}),"contact-name":S.Flags.string({description:"Display name to use when --auto-create-contact creates a new contact. Optional \u2014 defaults to the full email address (unique enough to avoid the BE's per-business name-uniqueness collision). Has no effect when the contact already exists or when --auto-create-contact is not set.",exclusive:["to-contact-id"]}),"currency-label":S.Flags.string({description:"Label shown next to the amount in the rendered invoice (e.g. USDT, USDC). Display only; select the stablecoin with --payment-type=1 (USDT) or --payment-type=2 (USDC). --currency-int applies only to --payment-type=0 fiat invoices. Default: USDT.",default:"USDT"}),"currency-int":S.Flags.integer({description:"Backend Currency enum value (USD=1, AED=2, ...). Only sent when --payment-type=0 (CURRENCY/fiat invoice); ignored for stablecoin payment types. Default: 1 (USD).",default:1}),"payment-type":S.Flags.integer({description:"CreatePaymentInput.payment_type. Run `allscale describe create_payment` for the enum. Default: 1.",default:1}),memo:S.Flags.string({description:"Free-form invoice memo / description shown to the payer."}),due:S.Flags.string({description:"Invoice due date / datetime (ISO 8601), e.g. 2026-06-01, 2026-06-01T09:30:00, 2026-06-01T09:30:00Z, or 2026-06-01T09:30:00+08:00. A value without a UTC offset is read as UTC (so 2026-06-01 means 2026-06-01T00:00:00Z) \u2014 stated explicitly because interpreting it in the local timezone would make the same command mean different things on different machines. Rendered in the HTML body exactly as you typed it."}),"tax-id":S.Flags.string({description:"Optional taxpayer identification shown in the invoice footer."}),line:S.Flags.string({description:'Line item on the rendered invoice. Repeatable. Two forms: "<description>" (qty=1, amount=full --amount) or "<description>|<quantity>|<amount>" (all explicit; same decimal units as --amount). Use the three-field form for more than one line: the single-field form gives EVERY line the full --amount, so two such lines sum to twice --amount and trigger the totals-mismatch warning. With three-field lines you may omit --amount entirely and the CLI sums them. The backend charges --amount regardless; --line only shapes the rendered HTML.',multiple:!0}),"wallet-id":S.Flags.string({description:"id_str of a wallet to receive payment. Repeatable. When given, the backend resolves and validates the ids (no wallet read needed \u2014 works with an invoice-scope-only agent key). When omitted, the CLI fetches your wallets via the narrow `business_wallets` query, which requires the wallet:read_only scope on an agent key.",multiple:!0}),"business-id":S.Flags.string({description:"Your own business id_str. Optional and redundant \u2014 the invoice is always issued as the business you are signed in as, and contacts and wallets always resolve against it. Supplying a different business id is rejected rather than silently ignored; omit the flag unless a script needs to assert which business it is acting as."}),"show-doc":S.Flags.boolean({description:"Print the generated GraphQL document to stderr.",default:!1}),...de.baseFlags};async runCommand(){let{flags:n}=await this.parse(e),t=n.amount,i=n.line??[],r=n["payment-type"],o=String(n["currency-label"]),a=n.due?.trim(),l=a===void 0||a.length===0?void 0:Bi(a),{amountCents:s,amountSource:u,parsedLines:p,subtotal:m}=ga({paymentType:r,rawAmount:t,rawLines:i,currencyLabel:o}),f=0,y=n["currency-int"];if(r===f&&(!Number.isInteger(y)||y<1))throw new c("input.invalid",`--currency-int=${y} is not a valid Currency enum value (the enum starts at USD=1). Pass --currency-int=1 for USD, or change --payment-type to a stablecoin (USDT=1, USDC=2, ...) where currency is unused.`);u==="derived-from-lines"?ee.stderr.write(`Deriving --amount from --line totals: ${B(s)} ${o}.
|
|
162
|
-
`):
|
|
163
|
-
`);let
|
|
164
|
-
`),!
|
|
165
|
-
`)}
|
|
166
|
-
`),{payment_id:(await
|
|
165
|
+
`;var ls=new Set(["integer","group","decimal","fraction","minusSign","plusSign"]);function cs(e="0",n="en-US",t="USD",i=2){let r=fr(e),o;try{o=dr(n,t,i)}catch{o=dr(n,"USD",i)}return`${o.formatToParts(r).filter(l=>ls.has(l.type)).map(l=>l.value).join("")} ${t}`}function dr(e,n,t){return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:Math.max(2,t),currencyDisplay:"code"})}function ln(e){let n=typeof e=="string"?e:String(e??"0"),t=/^(-?)(\d+)(?:\.(\d+))?$/.exec(n);if(!t)return null;let i=(t[3]??"").replace(/0+$/,"");return{negative:t[1]==="-",units:BigInt(`${t[2]}${i}`),scale:i.length}}function mr(e){let n=10n**BigInt(e.scale),t=e.units/n,i=e.scale===0?"":(e.units%n).toString().padStart(e.scale,"0").replace(/0+$/,"");return`${e.negative&&e.units!==0n?"-":""}${t}${i.length>0?`.${i}`:""}`}function fr(e){return mr(ln(e)??{negative:!1,units:0n,scale:0})}function ur(e){if(e===void 0)return;let n=ln(e);return n&&n.units!==0n?e:void 0}function ds(e,n){let t=ln(e),i=ln(n);return!t||!i?"0":mr({negative:t.negative!==i.negative,units:t.units*i.units,scale:t.scale+i.scale})}function us(e){if(e==null||e==="")return"";let n=Number(e);return Number.isFinite(n)?n.toLocaleString("en-US"):String(e)}var ps=/(\.\d{3})\d+/,ms=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;function fs(e,n){if(!e)return"";let t=String(e).replace(ps,"$1"),i=new Date(ms.test(t)?`${t.replace(" ","T")}Z`:t);return Number.isNaN(i.getTime())?"Invalid Date":new Intl.DateTimeFormat("en-US",{month:"short",day:"2-digit",year:"numeric",...n?{timeZone:n}:{}}).format(i)}var sn=null;function ys(){if(sn)return sn;let e=pr.default.create();return e.registerHelper("multiply",ds),e.registerHelper("or",(n,t)=>!!n||!!t),e.registerHelper("formatQuantity",us),e.registerHelper("formatDate",n=>fs(n)),sn=e.compile(cr),sn}function yr(e){let n=ys(),t=e.currencyLabel??"USD",i={...e.invoiceData,discountApplied:ur(e.invoiceData.discountApplied),tax:ur(e.invoiceData.tax)};return n({invoiceData:i,invoiceTotal:e.invoiceTotal??i.total??"0",baseUrl:e.baseUrl??""},{helpers:{formatMoneyWithCode:(r,...o)=>cs(fr(r),"en-US",t,e.amountScale??2)}})}function gr(e=new Date){let n=new Date(e.getTime());return n.setDate(n.getDate()+30),n}function _r(e=new Date){return gr(e).toISOString()}function Sr(e,n,t){return new Date(e,n,t).toISOString()}function Ar(e){let n=Number(e.slice(0,4)),t=Number(e.slice(5,7)),i=Number(e.slice(8,10));return Sr(n,t-1,i)}function Tr(e=new Date){let n=gr(e);return Sr(n.getFullYear(),n.getMonth(),n.getDate())}function hr(e){let n=new Date(e.getTime());return n.setHours(0,0,0,0),n.getTime()}function kr(e,n=new Date){let t=new Date(e),i=Number.isNaN(t.getTime())?30:Math.max(1,Math.round((hr(t)-hr(n))/864e5));return`Thank you for your business! Payment is due within ${i} ${i===1?"day":"days"}.`}var kt=/^(?:0|[1-9]\d*)(?:\.\d+)?$/,hs=/^0(?:\.0+)?$/,Ce=128;function Ie(e,n,t={}){if(n.length>Ce)throw new c("input.invalid",`${e} is too long; decimal values may contain at most ${Ce} characters.`);let i=n.trim();if(!kt.test(i))throw new c("input.invalid",`${e} must be a decimal string without sign or exponent; got '${n}'.`);if(!t.allowZero&&hs.test(i))throw new c("input.invalid",`${e} must be greater than zero; got '${n}'.`);return i}function wr(e,n,t,i="for the selected token and chain"){if((n.split(".")[1]??"").replace(/0+$/,"").length>t)throw new c("input.invalid",`${e} supports at most ${t} effective decimal places ${i}; got '${n}'. The CLI will not round a funds amount.`);return n}var gs=/^(\d{4})-(\d{2})-(\d{2})$/,_s=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d{1,9})?)?$/,Ss=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?([Zz]|([+-])(\d{2}):?(\d{2}))$/,As=/[T ]\d{2}:\d{2}:\d{2}(\.\d{1,9})/;function wt(e,n,t){let i=Number(t.y),r=Number(t.m),o=Number(t.d),a=new Date(Date.UTC(i,r-1,o));if(a.getUTCFullYear()!==i||a.getUTCMonth()!==r-1||a.getUTCDate()!==o)throw cn(e,`${t.y}-${t.m}-${t.d} is not a real calendar date`,n);let s=(l,u,p)=>{if(u===void 0)return;if(Number(u)>p)throw cn(e,`${l} ${u} is out of range (0-${p})`,n)};s("hour",t.hh,23),s("minute",t.mm,59),s("second",t.ss,59),s("offset hours",t.offH,23),s("offset minutes",t.offM,59)}function cn(e,n,t){return new c("input.invalid",`${t} '${e}' is not a valid date/time: ${n}. Accepted: YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss (both read as UTC), YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss+08:00.`)}function Lr(e,n="--due"){let t=e.trim();if(t.length===0)throw cn(e,"it is empty",n);let i=Ss.exec(t);if(i){wt(t,n,{y:i[1],m:i[2],d:i[3],hh:i[4],mm:i[5],ss:i[6],offH:i[9],offM:i[10]});let a=`${i[1]}-${i[2]}-${i[3]}T${i[4]}:${i[5]}`,s=i[6]===void 0?"":`:${i[6]}`,l=As.exec(t)?.[1]??"",u=i[7].toUpperCase()==="Z"?"Z":`${i[8]}${i[9]}:${i[10]}`;return`${a}${s}${l}${u}`}let r=_s.exec(t);if(r){wt(t,n,{y:r[1],m:r[2],d:r[3],hh:r[4],mm:r[5],ss:r[6]});let[,a,s,l,u,p,m,h]=r;return`${a}-${s}-${l}T${u}:${p}:${m??"00"}${h??""}Z`}let o=gs.exec(t);if(o)return wt(t,n,{y:o[1],m:o[2],d:o[3],hh:"00",mm:"00"}),`${o[1]}-${o[2]}-${o[3]}T00:00:00Z`;throw cn(e,"it is not an ISO 8601 date or date-time",n)}function Ts(e){if(e==null)return null;let n=typeof e=="string"?Number(e):e;return Number.isFinite(n)?n===0?null:n===1?1:n===2?2:"unsupported":"unsupported"}function br(e){let n=Ts(e);return n===null||n==="unsupported"?null:1<<n-1}var Td=String(Number.MAX_SAFE_INTEGER);var ks=Math.floor(Number.MAX_SAFE_INTEGER/100),ws=BigInt(ks),Ls=2147483647n,bs=10,ce=2,Lt=0,Es=6,Er=new Set([1,2]),dn=class e extends Te{static description="Send an invoice by email. Resolves the contact, selects receiving wallets, renders a minimal HTML invoice, and submits create_payment through the authenticated session. No browser ceremony \u2014 the payer signs when they pay, not when you issue. Returns a fixed summary (payment_id, contact, amount, wallet count) rather than a GraphQL selection, which is why there is no --select here; read the created invoice back with `invoice get \"$PAYMENT_ID\" --select 'id status amount_coins display_amount payment_type'`, using the payment_id returned by this command. The follow-up reflects the default USDT path; display_amount remains the denomination-aware value. Note the direction: an invoice you send lists YOU as the payee, so it appears under `invoice received`, not `invoice sent`.";static examples=["$ allscale invoice send --to-email client@example.com --amount 1.00",`$ allscale invoice send --to-email client@example.com --amount 250 --payment-type 2 --currency-label USDC --memo "January retainer" --due "$(node -p 'new Date(Date.now()+30*864e5).toISOString().slice(0,10)')"`,'$ allscale invoice send --to-contact-id 695da2cd3b9598f5edcdcb56 --amount 50 --line "Design|1|30.00" --line "Copy|1|20.00"','$ allscale invoice send --to-email client@example.com --amount 75 --line "Consulting retainer"','$ allscale invoice send --to-email client@example.com --amount 350 --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"','$ allscale invoice send --to-email client@example.com --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"',"$ allscale invoice send --to-email client@example.com --amount 100 --wallet-id 66ac1234567890abcdef0123","$ allscale invoice send --to-email newclient@example.com --amount 100 --auto-create-contact",'$ allscale invoice send --to-email billing@acme.com --amount 100 --auto-create-contact --contact-name "Acme Inc"'];static requiresInput=!0;static flags={"to-email":k.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Email of the contact to invoice. Resolves via contact_by_email. If no contact exists for the email, add --auto-create-contact to create one before invoicing. Mutually exclusive with --to-contact-id.",exclusive:["to-contact-id"]}),"to-contact-id":k.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Contact id directly (skip the email lookup). Mutually exclusive with --to-email.",exclusive:["to-email"]}),amount:k.Flags.string({helpGroup:"CONDITIONAL",description:'Exact decimal amount: USDT/USDC accept up to 6 effective decimal places (minimum 0.10), while fiat accepts up to 2. Redundant trailing zeroes are allowed and canonicalized; the CLI never rounds or truncates. Optional when every --line is the three-field "<description>|<quantity>|<amount>" form \u2014 in that case the CLI sums the lines to derive the invoice total. Required otherwise.'}),"auto-create-contact":k.Flags.boolean({description:"If --to-email doesn't resolve to an existing contact, auto-create the contact (using the email + your business as owner; name defaults to the full email address, override with --contact-name) and proceed with the invoice. Ignored when the contact already exists (safe to leave on in scripts). Requires --to-email; not valid with --to-contact-id.",default:!1,exclusive:["to-contact-id"]}),"contact-name":k.Flags.string({description:"Display name to use when --auto-create-contact creates a new contact. Optional \u2014 defaults to the full email address (unique enough to avoid a per-business name collision). Has no effect when the contact already exists or when --auto-create-contact is not set.",exclusive:["to-contact-id"]}),"currency-label":k.Flags.string({description:'Label shown after each amount in the rendered invoice (e.g. "250.00 USDT"). Display only \u2014 it changes no amount, no asset, and nothing the payer is charged. Which stablecoins the invoice ACCEPTS is decided by --payment-type when you pass it explicitly (=1 USDT, =2 USDC); omit that flag and the invoice accepts whatever your business is configured for. Defaults to the label matching --payment-type (USDT or USDC; USD for --payment-type=0 fiat \u2014 pass this flag explicitly for a non-USD --currency-int).'}),"currency-int":k.Flags.integer({description:"Fiat currency code, such as USD=1 or AED=2. Only sent when --payment-type=0 (fiat invoice); ignored for stablecoin payment types. Default: 1 (USD).",default:1}),"payment-type":k.Flags.integer({description:"What the invoice is denominated in AND which stablecoin it may be paid with: 0 = fiat (pair with --currency-int), 1 = USDT, 2 = USDC. Passing 1 or 2 EXPLICITLY pins the invoice to that coin \u2014 a payment arriving in the other stablecoin is rejected, and the payer's email names only this coin. Omit the flag and the invoice accepts whichever stablecoins your business is configured for (it is still denominated in USDT, the default). For 0 the amount is fiat but settlement is still in a stablecoin, so the payer may likewise use any coin your business accepts. Run `allscale describe create_payment` for the full list. Default: 1 (denomination only \u2014 omitting the flag pins nothing).",default:1}),memo:k.Flags.string({description:'Free-form invoice memo / description shown to the payer. When omitted, defaults to the same note the web invoice editor generates: "Thank you for your business! Payment is due within N days." with N derived from the due date (30 unless --due says otherwise).'}),due:k.Flags.string({description:`Invoice due date / datetime (ISO 8601), e.g. YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss, YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss+08:00. A value without a UTC offset is read as UTC (so a date-only value means midnight UTC) \u2014 stated explicitly because interpreting it in the local timezone would make the same command mean different things on different machines. When omitted, defaults to 30 days from now, matching the web invoice editor. The rendered document shows the NORMALIZED date in the web's display format ("MMM DD, YYYY"), not the raw flag text. The examples compute the date with POSIX command substitution, which sh/bash/zsh and PowerShell expand but cmd.exe does not; on cmd.exe pass an explicit date instead.`}),"tax-id":k.Flags.string({description:"Optional taxpayer identification shown in the invoice footer."}),line:k.Flags.string({description:`Line item on the rendered invoice. Repeatable. Two forms: "<description>" (qty=1, amount=full --amount) or "<description>|<quantity>|<amount>" (all explicit; same exact decimal precision as --amount). Use the three-field form for more than one line: the single-field form gives EVERY line the full --amount, so two such lines sum to twice --amount and trigger the totals-mismatch warning. With three-field lines you may omit --amount entirely and the CLI sums them. Every line total (quantity x amount) must fit the selected denomination's precision, whether or not --amount is given; the CLI never rounds it.`,multiple:!0}),"wallet-id":k.Flags.string({description:"id of a wallet to receive payment, as listed by `wallet list`. Repeatable. When given, the backend resolves and validates the ids (no wallet read needed \u2014 works with an invoice-scope-only agent key). When omitted, the CLI fetches your wallets via the narrow `business_wallets` query, which requires the wallet:read_only scope on an agent key.",multiple:!0}),"business-id":k.Flags.string({char:"b",description:"Your own business id. Optional and redundant \u2014 the invoice is always issued as the business you are signed in as, and contacts and wallets always resolve against it. Supplying a different business id is rejected rather than silently ignored; omit the flag unless a script needs to assert which business it is acting as."}),"show-doc":k.Flags.boolean({description:"Print the generated GraphQL document to stderr.",default:!1}),...Te.baseFlags};async runCommand(){let{flags:n,metadata:t}=await this.parse(e),i=n.amount,r=n.line??[],o=n["payment-type"],a=t.flags["payment-type"]?.setFromDefault!==!0,s=n["currency-label"]??(o===0?"USD":Vn(o)),l=new Date,u=n.due?.trim(),p=u===void 0||u.length===0?_r(l):Lr(u),m=u===void 0||u.length===0?Tr(l):Ar(p),h=n.memo??kr(m,l),{amount:f,amountSource:A,parsedLines:L,subtotal:U}=Nr({paymentType:o,rawAmount:i,rawLines:r,currencyLabel:s}),Z=n["currency-int"];if(o===Lt&&(!Number.isInteger(Z)||Z<1))throw new c("input.invalid",`--currency-int=${Z} is not a valid Currency enum value (the enum starts at USD=1). Pass --currency-int=1 for USD, or change --payment-type to a stablecoin (USDT=1, USDC=2, ...) where currency is unused.`);A==="derived-from-lines"?X.stderr.write(`Deriving --amount from --line totals: ${f.canonical} ${s}.
|
|
166
|
+
`):U.atomicUnits!==f.atomicUnits&&X.stderr.write(`Warning: --line totals sum to ${U.canonical} ${s}, but --amount is ${f.canonical} ${s}. The recipient is charged --amount; the rendered invoice shows the line breakdown.
|
|
167
|
+
`);let C=this.resolveContext(n),I=n["wallet-id"]??[];if(I.some(g=>g.length===0||g.trim()!==g)||new Set(I).size!==I.length||I.length>64)throw new c("input.invalid","--wallet-id values must be non-empty, unique, unpadded wallet ids (maximum 64).");let Et=n["to-email"],pn=n["to-contact-id"];if(!Et&&!pn)throw new c("input.invalid","One of --to-email or --to-contact-id is required.");await ir(C,n["business-id"]);let de,Q,mn,fn,yn;if(pn){let g=await lr(C,pn);de=g.id,Q=g.email,mn=g.name,fn=g.address??void 0,yn=g.phone??void 0}else{let g=Et,me=n["auto-create-contact"]?n["contact-name"]??g:void 0,F=await sr(C,g,{autoCreateName:me,businessIdFlag:n["business-id"]});de=F.id,Q=F.email,mn=F.name,fn=F.address??void 0,yn=F.phone??void 0}let ue=I.length>0,Nt=ue?[]:await Ps(C),hn=Nt.filter(g=>Kn(g.chain)),gn=Nt.filter(g=>!Kn(g.chain));if(!ue&&gn.length>0&&X.stderr.write(`Skipping ${gn.length} wallet(s) on chains the invoice flow doesn't accept (create_payment requires notification-supported chains): ${gn.map(g=>`chain=${g.chain}`).join(", ")}
|
|
168
|
+
`),!ue&&hn.length===0)throw new c("input.invalid","No noncustodial wallets found on your business that the invoice flow accepts. Add a wallet on a supported chain (ETH/BASE/BNB/ARBITRUM/POLYGON/OPTIMISM/SOL/TRON) first, or pin wallets explicitly with --wallet-id.");let pe=await Us(C,n["business-id"]);pe.notice&&X.stderr.write(pe.notice);let _n=[...L.items];_n.length===0&&_n.push({description:"Invoice",quantity:"1",amount:f.canonical});let Or=yr({invoiceData:{date:l.toISOString(),dueDate:m,from:{name:pe.name,email:pe.email,phone:pe.phone},to:{name:mn??Q,email:Q,address:fn,phone:yn},items:_n,note:h,taxId:n["tax-id"],subtotal:U.canonical,total:f.canonical},invoiceTotal:f.canonical,amountScale:f.scale,currencyLabel:s,baseUrl:C.apiBase}),D={sender_contact_id:de,payment_type:o,html_template:Or,wallets:[]};o===Lt?(D.currency=Z,D.amount_cents=Number(f.atomicUnits)):D.amount_coins=f.canonical;let Ct=a?br(o):null;if(Ct!==null){D.accepted_stable_coins=Ct;let g=n["currency-label"];if(g){let me=Vn(o).toUpperCase(),F=g.trim().toUpperCase(),It=di().map(M=>M.toUpperCase()).filter(M=>M!==me&&new RegExp(`\\b${M}\\b`).test(F));if(It.length>0){let M=It.join(" / ");X.stderr.write(`Warning: --currency-label ${M} contradicts --payment-type ${o} (${me}). The invoice document will read ${JSON.stringify(w(g))}, but this invoice accepts ${me} only \u2014 a payer who follows the label and sends ${M} will have the payment rejected. Drop --currency-label to let it follow --payment-type.
|
|
169
|
+
`)}}}h.length>0&&(D.memo=h),D.due_datetime=p,n["tax-id"]&&(D.tax_id=n["tax-id"]);let vr=ue?I:hn.map(g=>g.id_str);return X.stderr.write(`Issuing invoice for ${f.canonical} ${s} to ${Q} (contact ${de})...
|
|
170
|
+
`),{payment_id:(await v(C,"mutation","create_payment",{payment:D,wallet_ids:vr},{selection:"id amount_coins currency status created_at",showDoc:!!n["show-doc"]}))?.id,to_contact_id:de,to_email:Q,amount:f.canonical,currency_label:s,wallets:ue?I.length:hn.length}}};function Nr(e){let n=Er.has(e.paymentType)?Es:ce,t=typeof e.rawAmount=="string"&&e.rawAmount.trim().length>0,i,r;if(t){let l=Ie("--amount",e.rawAmount);i=un(l,"--amount",n),r="flag"}else{if(e.rawLines.length===0)throw new c("input.invalid",'Need either --amount or one or more --line entries to know what to charge. Re-run with --amount=<decimal>, or pass --line items in the "<desc>|<qty>|<amount>" form so the total can be derived.');let l=e.rawLines.map((u,p)=>({raw:u,idx:p,isThreeField:u.includes("|")})).filter(u=>!u.isThreeField);if(l.length>0)throw new c("input.invalid",`Without --amount, every --line must be in the "<description>|<quantity>|<amount>" form so the total can be derived. Single-field entry at --line[${l[0].idx}] ("${l[0].raw}") doesn't supply an amount. Either re-run with --amount=<decimal>, or expand the single-field --line to the full three-field form.`);i=bt(0n,n),r="derived-from-lines"}let o=Cr(e.rawLines,i.canonical,{amountScale:n}),a=e.rawLines.length===0?i:o.subtotal;r==="derived-from-lines"&&(i=a);let s=xs(i.scale,e.paymentType);if(i.atomicUnits>s){let l=r==="flag"?"--amount is":"--line totals are";throw new c("input.invalid",`${l} too large to render and charge without rounding; the maximum is '${ve(s,i.scale)}'.`)}if(Er.has(e.paymentType)&&i.atomicUnits<BigInt(bs)*10n**BigInt(i.scale-ce)){let l=e.paymentType===2?"USDC":"USDT";throw new c("input.invalid",`${l} invoice total must be at least 0.10; got ${i.canonical}.`)}if(r==="derived-from-lines"&&i.atomicUnits<=0n)throw new c("input.invalid",`--line totals sum to ${a.canonical} ${e.currencyLabel}; an invoice must charge more than zero. Check the per-line amounts and quantities, or pass --amount explicitly.`);return{amount:i,amountSource:r,parsedLines:o,subtotal:a}}var Ns=/^(?:\d+(?:\.\d*)?|\.\d+)$/,Cs=/^(?:0+(?:\.0*)?|\.0+)$/;function Is(e,n){if(n.length>Ce)throw new c("input.invalid",`${e} is too long; decimal values may contain at most ${Ce} characters.`);let t=n.trim();if(!Ns.test(t))throw new c("input.invalid",`${e} must be a decimal string without sign or exponent; got '${n}'.`);if(Cs.test(t))throw new c("input.invalid",`${e} must be greater than zero; got '${n}'.`);let i=t.startsWith(".")?`0${t}`:t,[r,o]=i.split("."),a=r.replace(/^0+(?=\d)/,"");return o===void 0?a:`${a}.${o}`}function Cr(e,n,t={}){let i=t.amountScale??ce,r=un(Ie("--amount",n,{allowZero:!0}),"--amount",i,{allowZero:!0}),o=e.map((a,s)=>Ir(a,s,r));return{items:o.map(({item:a})=>a),subtotal:Rs(o,i)}}function Os(e,n,t,i=ce){let r=un(Ie("--amount",t,{allowZero:!0}),"--amount",i,{allowZero:!0});return Ir(e,n,r).item}function Ir(e,n,t){let i=e.split("|");if(i.length===1)return{item:{description:i[0].trim(),quantity:"1",amount:t.canonical},amount:t,quantityUnits:1n,quantityScale:0};if(i.length!==3)throw new c("input.invalid",`--line[${n}] must be "<description>" or "<description>|<quantity>|<amount>" (got "${e}").`);let[r,o,a]=i.map(h=>h.trim()),s=Is(`--line[${n}] quantity`,o),l=Number(s);if(!Number.isFinite(l)||l<=0)throw new c("input.invalid",`--line[${n}] quantity must be a positive number; got "${o}".`);let u=Ie(`--line[${n}] amount`,a,{allowZero:!0}),p=un(u,`--line[${n}] amount`,t.scale,{allowZero:!0}),m=vs(s);return{item:{description:r,quantity:ve(m.units,m.scale),amount:p.canonical},amount:p,quantityUnits:m.units,quantityScale:m.scale}}function vs(e){let[n,t=""]=e.split("."),i=t.replace(/0+$/,"");return{units:BigInt(`${n}${i}`),scale:i.length}}function Rs(e,n){let t=0n;for(let[i,r]of e.entries()){let o=10n**BigInt(r.quantityScale),a=r.amount.atomicUnits*r.quantityUnits;if(a%o!==0n)throw new c("input.invalid",`--line[${i}] total has more than ${n} effective decimal places and cannot be represented exactly. Adjust its quantity or per-line amount; the CLI will not round a funds amount.`);t+=a/o}if(t>Oe(n))throw new c("input.invalid",`--line totals are too large to render and charge without rounding; the maximum is ${ve(Oe(n),n)}.`);return bt(t,n)}function Oe(e){return ws*10n**BigInt(e-ce)}function xs(e,n){return n===Lt?Ls:Oe(e)}function un(e,n,t,i={}){if(!kt.test(e))throw new c("input.invalid",`${n} must be a decimal string without sign or exponent; got '${e}'.`);wr(n,e,t,"for this invoice denomination");let[r,o=""]=e.split("."),a=o.replace(/0+$/,""),s=BigInt(r)*10n**BigInt(t)+BigInt(a.padEnd(t,"0")||"0");if(s>Oe(t))throw new c("input.invalid",`${n} is too large to render and charge without rounding; the maximum is '${ve(Oe(t),t)}'.`);if(!i.allowZero&&s<=0n)throw new c("input.invalid",`${n} must be greater than zero; got '${e}'.`);return bt(s,t)}function bt(e,n){return{canonical:ve(e,n,ce),atomicUnits:e,scale:n}}function ve(e,n,t=0){if(n===0)return e.toString();let i=10n**BigInt(n),r=e/i,a=(e%i).toString().padStart(n,"0").replace(/0+$/,"").padEnd(Math.min(t,n),"0");return a.length>0?`${r}.${a}`:r.toString()}async function Ps(e){return await v(e,"query","business_wallets",{},{selection:"id_str chain address",showDoc:!1})??[]}async function Us(e,n){let t;try{t=await P(e)}catch{return{name:"",email:"",notice:`Invoice header's From: block is blank: your stored credentials could not be read to identify the issuer. The invoice itself is unaffected.
|
|
171
|
+
`}}let i=t.kind==="human"||t.kind==="agent"?t.userEmail:void 0;if(i===void 0)try{let r=await on(e,n),o=await v(e,"query","business",{id_str:r},{selection:"name email",showDoc:!1}),a=le(o?.name),s=le(o?.email);if(a!==void 0||s!==void 0)return{name:a??s??"",email:s??""}}catch{}if(i===void 0)return{name:"",email:"",notice:t.kind==="override"?`Invoice header's From: block is blank: the --token session's business lookup did not return a name or email. Use a stored login (device-login / otp-login) to fill it from your contact card. The invoice itself is unaffected.
|
|
172
|
+
`:"Invoice header's From: block is blank: this session predates the CLI recording your login email. Re-run `allscale device-login` (or otp-login) to record it. The invoice itself is unaffected.\n"};try{let r=await v(e,"query","business_contact_by_email",{email:i},{selection:"contact_name name email contact_phone",showDoc:!1});return{name:le(r?.contact_name)??le(r?.name)??i,email:le(r?.email)??i,phone:le(r?.contact_phone)}}catch{return{name:i,email:i,notice:t.kind==="agent"?`Invoice header shows your login email instead of your business contact card: the business_contact_by_email lookup was refused or failed. On an agent key this usually means the backend does not yet allow that lookup for agent keys. The invoice itself is unaffected.
|
|
173
|
+
`:`Invoice header shows your login email instead of your business contact card: the business_contact_by_email lookup failed. The invoice itself is unaffected.
|
|
174
|
+
`}}}function le(e){return typeof e=="string"&&e.length>0?e:void 0}0&&(module.exports={parseLineFlag,parseLineFlags,resolveInvoiceAmountAndLines});
|
|
167
175
|
//# sourceMappingURL=send.js.map
|