jaz-clio 5.24.14 → 5.24.15

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-api
3
- version: 5.24.14
3
+ version: 5.24.15
4
4
  description: >-
5
5
  Use this skill whenever you call, debug, or review code that touches the Jaz
6
6
  REST API. Covers field names, response shapes, 158 production gotchas, error
@@ -2400,7 +2400,7 @@ Append one review verb to a jot (append-only: annotates, never mutates).
2400
2400
  { "verb": "FLAG", "note": "Re-check the account mapping next close" }
2401
2401
  ```
2402
2402
 
2403
- `verb`: FLAG, REJECT, ENDORSE. The response may carry a `rollbackHandoff` pointer; execution lives in the rollback module.
2403
+ `verb`: FLAG, REJECT, ENDORSE. REJECT with `rollback:true` queues an async rollback in the platform; the per-ref outcomes land on the disposition's `rollbackOutcome` and are readable via jot search (recall).
2404
2404
 
2405
2405
  ---
2406
2406
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-cli
3
- version: 5.24.14
3
+ version: 5.24.15
4
4
  description: >-
5
5
  Use this skill when running Clio CLI commands, building shell scripts with
6
6
  Clio, debugging auth issues, understanding --json output, paginating results,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-conversion
3
- version: 5.24.14
3
+ version: 5.24.15
4
4
  description: >-
5
5
  Use this skill when migrating accounting data into Jaz — importing from Xero,
6
6
  QuickBooks, Sage, MYOB, or Excel exports. Covers the full conversion pipeline:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-pseudo-sql
3
- version: 5.24.14
3
+ version: 5.24.15
4
4
  description: >-
5
5
  Use this skill when answering ad-hoc data questions that aren't covered by
6
6
  download_export (canonical reports — anomaly, audit, aging, P&L, BS, GL,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-jobs
3
- version: 5.24.14
3
+ version: 5.24.15
4
4
  description: >-
5
5
  Use this skill for recurring accounting workflows — month/quarter/year-end
6
6
  close, bank reconciliation, GST/VAT filing, payment runs, credit control,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-recipes
3
- version: 5.24.14
3
+ version: 5.24.15
4
4
  description: >-
5
5
  Use this skill when modeling complex multi-step accounting transactions —
6
6
  anything that spans multiple periods, involves changing amounts, or requires
package/cli.mjs CHANGED
@@ -1058,7 +1058,7 @@ clio() {
1058
1058
  `))}process.exit(1)}await jS(o,n,d);let y=(await wl(o,n)).data,C=f.filter(E=>E!=="saveAsDraft"&&E!=="resourceId");i.json?console.log(JSON.stringify({finalized:!0,resourceId:y.resourceId,reference:y.reference||null,status:y.status,fieldsUpdated:C},null,2)):(console.log(Y(`
1059
1059
  \u2713 Supplier credit note finalized: ${y.reference||y.resourceId}`)),console.log(R(" Status:"),y.status),C.length>0&&console.log(R(" Updated:"),C.join(", "))),Ie(o,"finalize_supplier_credit_note",i,y)})(i)),r.command("attachments <resourceId>").description("List attachments for a supplier credit note (URLs for agent inspection)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let a=(await wl(o,n)).data,u=(await si(o,"supplier-credit-notes",n)).data;if(i.json)console.log(JSON.stringify({creditNoteResourceId:n,creditNoteReference:a.reference||null,attachments:u},null,2));else{if(u.length===0){console.log(`No attachments for supplier credit note ${a.reference||n}.`);return}console.log(R(`Attachments for ${a.reference||n}:
1060
1060
  `));for(let d of u)console.log(` ${Be(d.resourceId)} ${d.fileName||"(unnamed)"}`),d.fileUrl&&console.log(` ${z(d.fileUrl)}`)}})(i)),e.command("bulk-upsert").description("Create or update supplier credit notes in bulk (max 500). Natural key: creditNoteReference. Returns a jobId \u2014 poll with `clio background-jobs get <jobId>`.").option("--input <file>","Read JSON body from file (or pipe via stdin with --input -)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=Ce(i);o||(console.error('Error: --input <file> is required (JSON with { "supplierCreditNotes": [...] } or a bare array)'),process.exit(1));let s=o.supplierCreditNotes??o;Array.isArray(s)||(console.error('Error: expected { "supplierCreditNotes": [...] }'),process.exit(1)),s.length===0&&(console.error("Error: supplierCreditNotes array is empty."),process.exit(1)),s.length>500&&(console.error(`Error: max 500 per call (got ${s.length}). Split into batches.`),process.exit(1));let a=await c2(n,s);i.json?console.log(JSON.stringify(a.data,null,2)):(console.log(Y(`Bulk upsert started. Job ID: ${a.data.jobId}`)),console.log(Be(` Poll progress: clio background-jobs get ${a.data.jobId}`)))}))}Fe();m2();gt();Pt();var cit=[{key:"currencyCode",header:"Code"},{key:"currencyName",header:"Name"},{key:"currencySymbol",header:"Symbol"},{key:"baseCurrency",header:"Base"}];function lit(t){let e=t.command("currencies").description("Manage organization currencies");e.command("list").description("List enabled currencies for the organization").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await HS(r),o={data:i.data,totalElements:i.data.length,totalPages:1,truncated:!1};$e(o,cit,n,"Currencies")})),e.command("add <codes...>").description("Add currencies to the organization (e.g. clio currencies add EUR GBP)").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=r.map(a=>a.toUpperCase()),s=await u2(i,o);if(n.json||n.format){let a=Array.isArray(s.data)?s.data:[s.data],c={data:a,totalElements:a.length,totalPages:1,truncated:!1};$e(c,cit,n,"Currencies")}else console.log(Y(`Added currencies: ${o.join(", ")}`));Ie(i,"add_currency",n,s.data)})(n))}m2();gt();Pt();Lt();Fe();kt();dr();var tde=[{key:"resourceId",header:"ID",format:Te},{key:"rate",header:"Rate"},{key:"rateApplicableFrom",header:"From"},{key:"rateApplicableTo",header:"To"}];function uit(t){let e=t.command("currency-rates").description("Manage currency exchange rates");e.command("list <currencyCode>").description("List exchange rates for a currency").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=r.toUpperCase(),s=await He(n,a=>d2(i,o,a),{label:`Fetching ${o} rates`});$e(s,tde,n,`${o} Rates`)})(n)),e.command("add <currencyCode>").description("Add an exchange rate for a currency").option("--jot <text>",we).option("--rate <number>","Exchange rate",parseFloat).option("--from <YYYY-MM-DD>","Rate applicable from date").option("--to <YYYY-MM-DD>","Rate applicable to date (optional)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{Le(n,[{flag:"--rate",key:"rate"},{flag:"--from",key:"from"}]);let o=r.toUpperCase(),s={rate:n.rate,rateApplicableFrom:n.from};n.to&&(s.rateApplicableTo=n.to);let a=await f2(i,o,s);if(n.json||n.format){let c={data:[a.data],totalElements:1,totalPages:1,truncated:!1};$e(c,tde,n,`${o} Rates`)}else console.log(Y(`Rate added for ${o}: ${n.rate} (from ${n.from})`));Ie(i,"add_currency_rate",n,a.data)})(n)),e.command("update <currencyCode> <rateResourceId>").description("Update an exchange rate").option("--jot <text>",we).option("--rate <number>","Exchange rate",parseFloat).option("--from <YYYY-MM-DD>","Rate applicable from date").option("--to <YYYY-MM-DD>","Rate applicable to date (optional)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n,i)=>Q(async o=>{Le(i,[{flag:"--rate",key:"rate"},{flag:"--from",key:"from"}]);let s=r.toUpperCase(),a={rate:i.rate,rateApplicableFrom:i.from};i.to&&(a.rateApplicableTo=i.to);let c=await p2(o,s,n,a);if(i.json||i.format){let u={data:[c.data],totalElements:1,totalPages:1,truncated:!1};$e(u,tde,i,`${s} Rates`)}else console.log(Y(`Rate updated for ${s}: ${i.rate}`));Ie(o,"update_currency_rate",i,c.data)})(i)),e.command("bulk-upsert").description("Create exchange rates in bulk (max 500). Auto-enables currencies not yet in the org.").option("--jot <text>",we).option("--input <file>","Read JSON body from file (or pipe via stdin with --input -)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n);i||(console.error('Error: --input <file> is required (JSON with { "rates": [...] })'),process.exit(1));let o=i.rates??i;Array.isArray(o)||(console.error('Error: expected { "rates": [...] } or a JSON array'),process.exit(1)),o.length>500&&(console.error(`Error: max 500 rates per call (got ${o.length}). Split into batches.`),process.exit(1));let s=await h2(r,o);if(n.json)console.log(JSON.stringify(s.data,null,2));else{let a=s.data.resourceIds??[];console.log(Y(`${a.length} rate(s) upserted.`)),a.forEach(c=>console.log(` ${c}`))}Ie(r,"bulk_upsert_currency_rates",n,s.data)}))}Gh();gt();import{readFileSync as ICr}from"node:fs";import{basename as dit,extname as wCr,resolve as _Cr}from"node:path";Pt();Lt();Fe();var DCr=[{key:"resourceId",header:"ID",format:Te},{key:"fileName",header:"File Name"}],ff=["invoices","bills","journals","scheduled_journals","customer-credit-notes","supplier-credit-notes","sale-quotes","sale-orders","purchase-requests","purchase-orders"],SCr={".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".csv":"text/csv",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};function fit(t){let e=t.command("attachments").description("Manage transaction attachments");e.command("list").description("List attachments for a transaction").requiredOption("--type <type>",`Transaction type (${ff.join(", ")})`).requiredOption("--id <resourceId>","Transaction resourceId").option("--api-key <key>","API key").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=n.type;ff.includes(i)||(console.error(ie(`Invalid type. Use one of: ${ff.join(", ")}`)),process.exit(1));let o=await si(r,i,n.id),s=o.data??[],a={data:s,totalElements:o.totalElements??s.length,totalPages:o.totalPages??1,truncated:o.truncated??!1};$e(a,DCr,n,"Attachments")})),e.command("add").description("Add an attachment to a transaction (file upload or URL download)").option("--jot <text>",we).requiredOption("--type <type>",`Transaction type (${ff.join(", ")})`).requiredOption("--id <resourceId>","Transaction resourceId").option("--file <path>","Local file path (PDF, PNG, JPG, etc.)").option("--url <url>","Download file from URL and attach").option("--attachment-id <id>","Link existing attachment by ID").option("--api-key <key>","API key").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=n.type;ff.includes(i)||(console.error(ie(`Invalid type. Use one of: ${ff.join(", ")}`)),process.exit(1)),!n.attachmentId&&!n.url&&!n.file&&(console.error(ie("Provide --file, --url, or --attachment-id")),process.exit(1)),n.attachmentId&&FH.includes(i)&&(console.error(ie(`link-by-id (--attachment-id) is not supported for order documents (${i}). Use --file or --url instead.`)),process.exit(1));let o,s;if(n.file){let c=_Cr(n.file),u=wCr(c).toLowerCase(),d=SCr[u]??"application/octet-stream",f=ICr(c);o=new Blob([f],{type:d}),s=dit(c)}else if(n.url){let c=await fetch(n.url);c.ok||(console.error(ie(`Failed to download: ${c.status} ${c.statusText}`)),process.exit(1));let u=await c.arrayBuffer(),d=c.headers.get("content-type")??"application/octet-stream";o=new Blob([u],{type:d});let f=new URL(n.url).pathname;s=dit(f)||"attachment"}let a=await QH(r,{businessTransactionType:i,businessTransactionResourceId:n.id,file:o,fileName:s,attachmentId:n.attachmentId});n.json?console.log(JSON.stringify(a,null,2)):console.log(Y("Attachment added.")),Ie(r,"add_attachment",n,a.data)})),e.command("delete").description("Delete an attachment from a transaction").option("--jot <text>",we).requiredOption("--type <type>",`Transaction type (${ff.join(", ")})`).requiredOption("--id <resourceId>","Transaction resourceId").argument("<attachmentResourceId>","Attachment resourceId to delete").option("--api-key <key>","API key").option("--json","Output as JSON").action((r,n)=>{let i=n.type;return ff.includes(i)||(console.error(ie(`Invalid type. Use one of: ${ff.join(", ")}`)),process.exit(1)),Q(async o=>{let s=await LH(o,i,n.id,r);n.json?console.log(JSON.stringify(s,null,2)):console.log(Y("Attachment deleted.")),Ie(o,"delete_attachment",n,{resourceId:r})})(n)})}Fe();nD();pc();gt();kt();dr();Pt();Lt();fr();var pit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"taxRate",header:"Rate (%)"},{key:"taxTypeCode",header:"Tax Type"}],RCr=[{key:"code",header:"Code"},{key:"name",header:"Name"}];function hit(t){let e=t.command("tax-profiles").description("Manage tax profiles and tax types");e.command("list").description("List tax profiles").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>Qb(r,o),{label:"Fetching tax profiles"});$e(i,pit,n,"Tax Profiles")})),e.command("types").description("List available tax types (GST, VAT, WHT, etc.)").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>BL(r,o),{label:"Fetching tax types"});$e(i,RCr,n,"Tax Types")})),e.command("get <resourceId>").description("Get a tax profile by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await TL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Rate:"),`${s.taxRate}%`),console.log(R("Tax Type:"),s.taxTypeCode))})(n)),We({parent:e,fields:hS,defaults:mS,fetcher:Lb,columns:pit,label:"Searching tax profiles"}),e.command("update <resourceId>").description("Update a tax profile").option("--jot <text>",we).option("--name <name>","New name").option("--rate <n>","New tax rate as percentage",Ee).option("--tax-type-code <code>","New tax type code").option("--status <status>","New status (ACTIVE, INACTIVE)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.rate!==void 0&&(o.taxRate=n.rate),n.taxTypeCode!==void 0&&(o.taxTypeCode=n.taxTypeCode),n.status!==void 0&&(o.status=n.status);let s=await kL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Tax profile updated: ${s.data.name}`)),Ie(i,"update_tax_profile",n,s.data)})(n)),e.command("wht-codes").description("List withholding tax codes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await NL(r);if(n.json)console.log(JSON.stringify(i.data,null,2));else{if(i.data.length===0){console.log("No withholding tax codes found.");return}console.log(R(`Withholding Tax Codes (${i.data.length}):
1061
- `));for(let o of i.data)console.log(` ${Be(o.code??o.resourceId??"?")} ${o.description??""} ${z(o.countryCode??"")}`)}})),e.command("create").description("Create a new tax profile").option("--jot <text>",we).option("--name <name>",'Tax profile name (e.g., "GST 9%")').option("--rate <n>","Tax rate as percentage (e.g., 9)",Ee).option("--tax-type-code <code>","Tax type code (from tax-profiles types)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--rate",key:"rate"},{flag:"--tax-type-code",key:"taxTypeCode"}]);let i=await dM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Tax profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await xL(r,{name:n.name,taxRate:n.rate,taxTypeCode:n.taxTypeCode});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Tax profile created: ${n.name} (${n.rate}%)`)),console.log(R("ID:"),o.data.resourceId)),Ie(r,"create_tax_profile",n,o.data)}))}Fe();YL();PY();pc();gt();kt();dr();Pt();Lt();fr();var mit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"expenseAccountResourceId",header:"Expense Acct",format:Te}];function Ait(t){let e=t.command("claim-types").description("Manage employee-expense claim types (expense categories)");e.command("list").description("List claim types").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>PL(r,o),{label:"Fetching claim types"});$e(i,mit,n,"Claim Types")})),e.command("get <resourceId>").description("Get a claim type by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await UL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Default:"),s.isDefault),s.expenseAccount&&console.log(R("Expense Account:"),`${s.expenseAccount.code} ${s.expenseAccount.name}`),s.taxProfile&&console.log(R("Tax Profile:"),s.taxProfile.name))})(n)),We({parent:e,fields:eS,defaults:tS,fetcher:Pb,columns:mit,label:"Searching claim types"}),e.command("create").description("Create a claim type").option("--name <name>","Claim type name (unique per org)").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Magic OCR classifier defaults (JSON string)").option("--default","Make org default").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await pM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Claim type "${n.name}" already exists (${i.resourceId}).`));return}let o=await $L(r,{name:n.name,expenseAccountResourceId:n.expenseAccount,taxProfileResourceId:n.taxProfile,classifierConfig:n.classifierConfig,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Claim type created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a claim type").option("--name <name>","New name").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Classifier defaults (JSON string)").option("--default","Make org default").option("--clear <fields>","Comma-separated optional fields to NULL (expenseAccountResourceId,taxProfileResourceId,classifierConfig)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.expenseAccount!==void 0&&(o.expenseAccountResourceId=n.expenseAccount),n.taxProfile!==void 0&&(o.taxProfileResourceId=n.taxProfile),n.classifierConfig!==void 0&&(o.classifierConfig=n.classifierConfig),n.default!==void 0&&(o.isDefault=n.default),Object.assign(o,sy(Io(n.clear),oD));let s=await qL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Claim type updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim type").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await jL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim type deleted: ${r}`))})(n))}Fe();cD();PY();pc();gt();kt();dr();Pt();Lt();fr();var git=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"taxMode",header:"Tax Mode"},{key:"employeeBalanceAccountResourceId",header:"Balance Acct",format:Te}];function yit(t){let e={};return t.name!==void 0&&(e.name=t.name),t.approver!==void 0&&(e.approverUserResourceId=t.approver),t.visibleClaimTypes!==void 0&&(e.visibleClaimTypeIds=Io(t.visibleClaimTypes)),t.visibleTaxProfiles!==void 0&&(e.visibleTaxProfileIds=Io(t.visibleTaxProfiles)),t.visibleClassifiers!==void 0&&(e.visibleClassifierIds=Io(t.visibleClassifiers)),t.visibleVendors!==void 0&&(e.visibleVendorResourceIds=Io(t.visibleVendors)),t.allowedCurrencies!==void 0&&(e.allowedCurrencies=Io(t.allowedCurrencies)),t.minAmount!==void 0&&(e.minClaimAmount=t.minAmount),t.maxAmount!==void 0&&(e.maxClaimAmount=t.maxAmount),t.maxPerPeriod!==void 0&&(e.maxPerPeriodAmount=t.maxPerPeriod),t.perPeriod!==void 0&&(e.perPeriod=t.perPeriod),t.balanceAccount!==void 0&&(e.employeeBalanceAccountResourceId=t.balanceAccount),t.taxMode!==void 0&&(e.taxMode=t.taxMode),t.default!==void 0&&(e.isDefault=t.default),e}function Eit(t){return t.option("--approver <id>","Default approver user resourceId").option("--visible-claim-types <ids>","Allowed claim type IDs (comma-separated)").option("--visible-tax-profiles <ids>","Allowed tax profile IDs (comma-separated)").option("--visible-classifiers <ids>","Allowed classifier IDs (comma-separated)").option("--visible-vendors <ids>","Allowed vendor contact IDs (comma-separated)").option("--allowed-currencies <codes>","Allowed ISO currency codes (comma-separated)").option("--min-amount <n>","Min claim total",lr).option("--max-amount <n>","Max claim total",lr).option("--max-per-period <n>","Per-period spend cap (requires --per-period)",lr).option("--per-period <window>","DAILY | WEEKLY | MONTHLY | QUARTERLY | YEARLY").option("--balance-account <id>","Employee balance (CURRENT_LIABILITY) account resourceId").option("--tax-mode <mode>","NO_TAX | INCLUSIVE (EXCLUSIVE rejected)").option("--default","Make org default")}function bit(t){let e=t.command("claim-profiles").description("Manage employee-expense claim profiles (per-employee policy bundles)");e.command("list").description("List claim profiles").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>HL(r,o),{label:"Fetching claim profiles"});$e(i,git,n,"Claim Profiles")})),e.command("get <resourceId>").description("Get a claim profile by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await zL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Default:"),s.isDefault),s.taxMode&&console.log(R("Tax mode:"),s.taxMode),s.employeeBalanceAccount&&console.log(R("Balance account:"),`${s.employeeBalanceAccount.code} ${s.employeeBalanceAccount.name}`))})(n)),We({parent:e,fields:rS,defaults:nS,fetcher:Ub,columns:git,label:"Searching claim profiles"}),Eit(e.command("create").description("Create a claim profile").option("--name <name>","Profile name (unique per org)")).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await hM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Claim profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await GL(r,yit(n));n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Claim profile created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),Eit(e.command("update <resourceId>").description("Update a claim profile").option("--name <name>","New name")).option("--clear <fields>","Comma-separated optional fields to NULL (e.g. approverUserResourceId,perPeriod,taxMode)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=yit(n);Object.assign(o,sy(Io(n.clear),aD));let s=await JL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Claim profile updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim profile").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await VL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim profile deleted: ${r}`))})(n))}Fe();dD();pc();gt();kt();dr();Pt();Lt();fr();var Cit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"outerAxis",header:"Outer"},{key:"innerAxis",header:"Inner"},{key:"isDefault",header:"Default"}];function vit(t){let e=t.command("posting-rules").description("Manage claim posting rules (how approved claims group into journals at conversion)");e.command("list").description("List posting rules").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>WL(r,o),{label:"Fetching posting rules"});$e(i,Cit,n,"Posting Rules")})),e.command("get <resourceId>").description("Get a posting rule by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await ZL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Outer axis:"),s.outerAxis),console.log(R("Inner axis:"),s.innerAxis),console.log(R("Line template:"),s.lineDescriptionTemplate),console.log(R("Default:"),s.isDefault))})(n)),We({parent:e,fields:iS,defaults:oS,fetcher:$b,columns:Cit,label:"Searching posting rules"}),e.command("create").description("Create a posting rule").option("--name <name>","Rule name (unique per org)").option("--outer-axis <axis>","PER_EMPLOYEE | PER_VENDOR | PER_PAIR | ONE_BATCH | PER_CLAIM").option("--inner-axis <axis>","RAW | BY_CT_TP_NC | BY_CT_TP_NC_EMPLOYEE | BY_CT_TP_NC_VENDOR").option("--line-template <tpl>",'Handlebars line template, e.g. "{employeeName} - {claimType}"').option("--journal-reference-template <tpl>","Optional journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout","Create reimbursement DCE by default").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--outer-axis",key:"outerAxis"},{flag:"--inner-axis",key:"innerAxis"},{flag:"--line-template",key:"lineTemplate"}]);let i=await mM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Posting rule "${n.name}" already exists (${i.resourceId}).`));return}let o=await KL(r,{name:n.name,outerAxis:n.outerAxis,innerAxis:n.innerAxis,lineDescriptionTemplate:n.lineTemplate,journalReferenceTemplate:n.journalReferenceTemplate,defaultBankAccountResourceId:n.defaultBankAccount,defaultIncludeReimbursementPayout:n.defaultIncludePayout,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Posting rule created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a posting rule").option("--name <name>","New name").option("--outer-axis <axis>","Outer grouping axis").option("--inner-axis <axis>","Inner line-aggregation axis").option("--line-template <tpl>","Handlebars line template").option("--journal-reference-template <tpl>","Journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout <bool>","Create reimbursement DCE by default (true/false)").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.outerAxis!==void 0&&(o.outerAxis=n.outerAxis),n.innerAxis!==void 0&&(o.innerAxis=n.innerAxis),n.lineTemplate!==void 0&&(o.lineDescriptionTemplate=n.lineTemplate),n.journalReferenceTemplate!==void 0&&(o.journalReferenceTemplate=n.journalReferenceTemplate),n.defaultBankAccount!==void 0&&(o.defaultBankAccountResourceId=n.defaultBankAccount),n.defaultIncludePayout!==void 0&&(o.defaultIncludeReimbursementPayout=n.defaultIncludePayout==="true"),n.default!==void 0&&(o.isDefault=n.default);let s=await XL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Posting rule updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Delete a posting rule (the org default cannot be deleted while default)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await eM(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Posting rule deleted: ${r}`))})(n))}Fe();ZM();vue();Iue();u_();MH();gt();kt();Lt();kf();fr();import{randomUUID as BCr}from"node:crypto";import{readFileSync as Iit,statSync as xCr}from"node:fs";import{basename as TCr,extname as kCr,resolve as wit}from"node:path";var NCr=[{key:"resourceId",header:"ID",format:Te},{key:"reference",header:"Reference"},{key:"status",header:"Status"},{key:"employeeResourceId",header:"Employee",format:Te},{key:"totalAmount",header:"Amount"},{key:"currencyCode",header:"Ccy"}];function _it(t){let e=t.command("claims").description("Employee-expense claims: search, edit drafts, lifecycle, bulk actions");We({parent:e,fields:WD,defaults:ZD,fetcher:NM,columns:NCr,label:"Searching claims"}),e.command("get <resourceId>").description("Get a claim by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>Q(async c=>{let d=(await OM(c,s)).data;a.json?console.log(JSON.stringify(d,null,2)):(console.log(R("Reference:"),d.reference??"\u2014"),console.log(R("ID:"),d.resourceId),console.log(R("Status:"),d.status),console.log(R("Total:"),`${d.totalAmount??0} ${d.currencyCode??""}`),console.log(R("Lines:"),(d.claimItems??[]).length))})(a)),e.command("create").description("Create a claim directly (bare create). Vendor is EITHER --contact OR --vendor-name. --items / --custom-fields take a JSON array string.").requiredOption("--value-date <date>","Business-transaction date (YYYY-MM-DD)").requiredOption("--currency <code>","Claim currency (ISO 4217)").option("--reference <ref>","User reference").option("--employee <id>","Employee resourceId the claim is filed for").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency-symbol <symbol>","Currency symbol override").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(s=>Q(async a=>{let c={valueDate:s.valueDate,currencyCode:s.currency};s.reference!==void 0&&(c.reference=s.reference),s.employee!==void 0&&(c.employeeResourceId=s.employee),s.contact!==void 0&&(c.contactResourceId=s.contact),s.vendorName!==void 0&&(c.vendorName=s.vendorName),s.currencySymbol!==void 0&&(c.currencySymbol=s.currencySymbol),s.internalNotes!==void 0&&(c.internalNotes=s.internalNotes),s.claimProfile!==void 0&&(c.claimProfileResourceId=s.claimProfile),s.approver!==void 0&&(c.approverUserResourceId=s.approver),s.tags!==void 0&&(c.tags=Io(s.tags)??[]),s.items!==void 0&&(c.claimItems=gu(s.items,"--items")),s.customFields!==void 0&&(c.customFields=gu(s.customFields,"--custom-fields")),s.submit&&(c.saveAsDraft=!1);let u=await FM(a,c);s.json?console.log(JSON.stringify(u.data,null,2)):console.log(Y(`Claim created: ${u.data.reference??u.data.resourceId} (${u.data.status})`))})(s)),e.command("update <resourceId>").description("Update a DRAFT claim (partial). --items / --custom-fields take a JSON array string.").option("--reference <ref>","User reference").option("--value-date <date>","Business-transaction date (YYYY-MM-DD)").option("--employee <id>","Employee resourceId").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency <code>","Claim currency (ISO 4217)").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array (REPLACES all lines)").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>Q(async c=>{let u={};a.reference!==void 0&&(u.reference=a.reference),a.valueDate!==void 0&&(u.valueDate=a.valueDate),a.employee!==void 0&&(u.employeeResourceId=a.employee),a.contact!==void 0&&(u.contactResourceId=a.contact),a.vendorName!==void 0&&(u.vendorName=a.vendorName),a.currency!==void 0&&(u.currencyCode=a.currency),a.internalNotes!==void 0&&(u.internalNotes=a.internalNotes),a.claimProfile!==void 0&&(u.claimProfileResourceId=a.claimProfile),a.approver!==void 0&&(u.approverUserResourceId=a.approver),a.tags!==void 0&&(u.tags=Io(a.tags)??[]),a.items!==void 0&&(u.claimItems=gu(a.items,"--items")),a.customFields!==void 0&&(u.customFields=gu(a.customFields,"--custom-fields")),a.submit&&(u.saveAsDraft=!1);let d=await QM(c,s,u);a.json?console.log(JSON.stringify(d.data,null,2)):console.log(Y(`Claim updated: ${d.data.reference??d.data.resourceId} (${d.data.status})`))})(a)),e.command("delete <resourceId>").description("Delete a claim (only DRAFT / REJECTED / CANCELLED)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>Q(async c=>{await LM(c,s),a.json?console.log(JSON.stringify({deleted:!0,resourceId:s})):console.log(Y(`Claim deleted: ${s}`))})(a)),e.command("delete-attachment <resourceId> <attachmentResourceId>").description("Remove one attachment from a claim").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a,c)=>Q(async u=>{await MM(u,s,a),c.json?console.log(JSON.stringify({deleted:!0,resourceId:s,attachmentResourceId:a})):console.log(Y(`Attachment removed from claim ${s}`))})(c));let r=[["submit",PM,"Submit a DRAFT claim for approval"],["approve",UM,"Approve a SUBMITTED claim"],["unpost",jM,"Unpost a CONVERTED claim (reverse conversion)"]];for(let[s,a,c]of r)e.command(`${s} <resourceId>`).description(c).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>Q(async f=>{let p=await a(f,u);d.json?console.log(JSON.stringify(p,null,2)):console.log(Y(`Claim ${s}: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let n=[["reject",$M,"Reject a SUBMITTED/APPROVED claim"],["cancel",qM,"Cancel a DRAFT/SUBMITTED claim"]];for(let[s,a,c]of n)e.command(`${s} <resourceId>`).description(c).option("--reason <text>","Reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>Q(async f=>{Le(d,[{flag:"--reason",key:"reason"}]);let p=await a(f,u,d.reason);d.json?console.log(JSON.stringify(p,null,2)):console.log(Y(`Claim ${s}ed: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let i=[["bulk-submit",YM,"Bulk-submit DRAFT claims (async)"],["bulk-approve",HM,"Bulk-approve SUBMITTED claims (async)"],["bulk-delete",zM,"Bulk-delete DRAFT/REJECTED/CANCELLED claims (async)"]];for(let[s,a,c]of i)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"}]);let f=await a(u,Io(d.ids)??[]);d.json?console.log(JSON.stringify(f,null,2)):console.log(Y(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));let o=[["bulk-reject",GM,"Bulk-reject claims (async)"],["bulk-cancel",JM,"Bulk-cancel claims (async)"]];for(let[s,a,c]of o)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--reason <text>","Shared reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"},{flag:"--reason",key:"reason"}]);let f=await a(u,Io(d.ids)??[],d.reason);d.json?console.log(JSON.stringify(f,null,2)):console.log(Y(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));e.command("tracking-tags").description("List claim tracking-tag values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{let c=await VM(s);if(a.json)console.log(JSON.stringify(c,null,2));else{console.log(R(`Tracking tags (${c.length}):`));for(let u of c)console.log(` ${typeof u=="string"?u:JSON.stringify(u)}`)}})),e.command("custom-field-values").description("List claim custom-field values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{let c=await WM(s);a.json?console.log(JSON.stringify(c,null,2)):console.log(ke(c.length===0?"No custom field values.":`${c.length} custom field value(s).`))})),e.command("preview-conversion").description("Preview the journals an APPROVED claim batch would produce (no write)").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--payout-flow <flow>","POST | POST_AND_RECORD").option("--include-payout","Include reimbursement DCE lines").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{if(Le(a,[{flag:"--ids",key:"ids"}]),a.payoutFlow!==void 0&&!Yx.includes(a.payoutFlow))throw new Error(`--payout-flow must be one of: ${Yx.join(", ")}`);let c=await PH(s,{claimResourceIds:Io(a.ids)??[],postingRuleResourceId:a.postingRule,payoutFlow:a.payoutFlow,includeReimbursementPayout:a.includePayout});console.log(JSON.stringify(c.data,null,2))})),e.command("convert").description("Convert an APPROVED claim batch into journals (atomic). Preview first.").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--value-date <date>","Journal value date (YYYY-MM-DD), required").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--include-payout","Create books-only reimbursement DCEs").option("--bank-account <id>","Override reimbursement bank account").option("--idempotency-key <key>","Retry-dedup token (auto-generated if omitted)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{Le(a,[{flag:"--ids",key:"ids"},{flag:"--value-date",key:"valueDate"}]);let c=await UH(s,{claimResourceIds:Io(a.ids)??[],valueDate:a.valueDate,postingRuleResourceId:a.postingRule,includeReimbursementPayout:a.includePayout,bankAccountResourceIdOverride:a.bankAccount,idempotencyKey:a.idempotencyKey||BCr()});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(Y("Claims converted to journals."))})),e.command("record-payout").description("Record a books-only employee payout (reimbursement / advance)").option("--employee <id>","Employee resourceId").option("--amount <n>","Payout amount (> 0)",lr).option("--payment-account <id>","Bank/cash account the DCE credits").option("--value-date <date>","Value date (YYYY-MM-DD)").option("--payout-for <type>","REIMBURSEMENT | ADVANCE (default ADVANCE)").option("--currency <code>","Settle currency (ISO 4217)").option("--reference <ref>","Payout reference (auto-generated if omitted)").option("--description <text>","DCE line description").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{Le(a,[{flag:"--employee",key:"employee"},{flag:"--amount",key:"amount"},{flag:"--payment-account",key:"paymentAccount"},{flag:"--value-date",key:"valueDate"}]);let c=await $H(s,{employeeResourceId:a.employee,amount:a.amount,paymentAccountResourceId:a.paymentAccount,valueDate:a.valueDate,payoutFor:a.payoutFor,currencyCode:a.currency,reference:a.reference||$a("EP"),description:a.description,internalNotes:a.internalNotes});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(Y(`Payout recorded: ${c.data.resourceId}`))})),We({parent:e,commandName:"payouts",fields:KD,defaults:XD,fetcher:qH,columns:[{key:"resourceId",header:"ID",format:Te},{key:"reference",header:"Reference"},{key:"employeeResourceId",header:"Employee",format:Te},{key:"amount",header:"Amount"},{key:"payoutType",header:"Type"}],label:"Searching employee payouts"}),e.command("from-attachment").description("Create a claim DRAFT from a receipt via AI extraction \u2014 a local file (--file), a remote URL (--source-url), or raw HTML (--html)").option("--file <path>","Local receipt file (PDF / JPG / PNG / HEIC / XLS / XLSX / EML)").option("--source-url <url>","Remote receipt file URL (alternative to --file)").option("--html <value>","Raw HTML (e.g. an email body) \u2014 inline or @path to read from a file").option("--contact <id>","Vendor contact resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employee <id>","File on behalf of this employee resourceId (default: the uploader's own; server requires a claims Manager/Admin to name another)").option("--currency <code>","Currency override (ISO 4217)").option("--value-date <date>","Value date override (YYYY-MM-DD)").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{if([a.file,a.sourceUrl,a.html].filter(Boolean).length!==1)throw new Error("provide exactly one of --file / --source-url / --html.");let u,d;if(a.file){let h=wit(a.file),m=kCr(h).toLowerCase();if(!dd.has(m))throw new Error(`unsupported file type "${m}". Supported: ${[...dd].join(", ")}`);let A=25*1024*1024,g=xCr(h).size;if(g>A)throw new Error(`file too large (${(g/1048576).toFixed(1)}MB > 25MB). Compress or split the receipt.`);u=new Blob([Iit(h)],{type:Ym(m)}),d=TCr(h)}let f;a.html&&(a.html.startsWith("@")||console.error(ke("Warning: passing HTML inline can leak invoice data into shell history \u2014 prefer --html @path.")),f=a.html.startsWith("@")?Iit(wit(a.html.slice(1)),"utf8"):a.html);let p=await cb(s,{sourceFile:u,sourceFileName:d,sourceURL:a.sourceUrl,html:f,contactResourceId:a.contact,claimProfileResourceId:a.claimProfile,employeeResourceId:a.employee,currencyCode:a.currency,valueDate:a.valueDate,internalNotes:a.internalNotes});console.log(JSON.stringify(p,null,2))}))}Fe();fD();pc();gt();kt();Lt();fr();var Dit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"email",header:"Email"},{key:"employmentType",header:"Type"},{key:"active",header:"Active"}];function Sit(t){let e=t.command("employees").description("Manage employees (expense-claim members): CRUD, balances, bind-user, import");We({parent:e,fields:sS,defaults:aS,fetcher:qb,columns:Dit,label:"Searching employees"}),We({parent:e,commandName:"balances",fields:cS,defaults:lS,fetcher:tM,columns:Dit,label:"Searching employee balances"}),e.command("get <resourceId>").description("Get an employee by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await rM(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Email:"),s.email??"\u2014"),console.log(R("Active:"),s.active),s.userBinding&&console.log(R("Bound user:"),`${s.userBinding.name??""} (${s.userBinding.status??""})`),s.claimProfile&&console.log(R("Claim profile:"),s.claimProfile.name))})(n)),e.command("create").description("Create an employee (requires --user to bind; binding is permanent)").option("--name <name>","Employee name").option("--user <id>","Login user resourceId to bind (required)").option("--claim-profile <id>","Claim profile resourceId (defaults to org default)").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--employment-type <type>","FULL_TIME | PART_TIME | CONTRACTOR | INTERN | TEMPORARY | CONSULTANT").option("--inactive","Create as inactive").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{if(Le(n,[{flag:"--name",key:"name"},{flag:"--user",key:"user"}]),n.email){let o=await AM(r,n.email);if(o){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:o},null,2)):console.log(ke(`Employee with email "${n.email}" already exists (${o.resourceId}).`));return}}let i=await nM(r,{name:n.name,userResourceId:n.user,claimProfileResourceId:n.claimProfile,email:n.email,phone:n.phone,managerEmployeeResourceId:n.manager,active:n.inactive?!1:void 0,employmentType:n.employmentType});n.json?console.log(JSON.stringify(i.data,null,2)):(console.log(Y(`Employee created: ${n.name}`)),console.log(R("ID:"),i.data.resourceId))})),e.command("update <resourceId>").description("Update an employee. Use --archive to deactivate (reversible).").option("--name <name>","New name").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employment-type <type>","Employment classification").option("--archive","Set active=false (archive)").option("--activate","Set active=true").option("--clear-employment-type","Unset the classification").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};if(n.name!==void 0&&(o.name=n.name),n.email!==void 0&&(o.email=n.email),n.phone!==void 0&&(o.phone=n.phone),n.manager!==void 0&&(o.managerEmployeeResourceId=n.manager),n.claimProfile!==void 0&&(o.claimProfileResourceId=n.claimProfile),n.employmentType!==void 0&&(o.employmentType=n.employmentType),n.archive&&n.activate)throw new Error("--archive and --activate are mutually exclusive.");n.archive&&(o.active=!1),n.activate&&(o.active=!0),n.clearEmploymentType&&(o.clearEmploymentType=!0);let s=await iM(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Employee updated: ${s.data.name??r}`))})(n)),e.command("delete <resourceId>").description("Delete an employee (must be settled). Prefer update --archive.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await oM(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Employee deleted: ${r}`))})(n)),e.command("bind-user <resourceId> <userResourceId>").description("Bind a login user to an offline employee (no user bound yet). One-way, permanent \u2014 allowed only while unbound.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n,i)=>Q(async o=>{let s=await sM(o,r,n);i.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Bound user ${n} to employee ${r}`))})(i)),e.command("preprocess <fileUrl>").description("Preview an employee import sheet before importing").option("--file-name <name>","Display file name").option("--file-type <type>","CSV | XLS | XLSX").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=await aM(i,{fileUrl:r,fileName:n.fileName,fileType:n.fileType});console.log(JSON.stringify(o.data,null,2))})(n)),e.command("import").description("Bulk import employees (async). Pass --create / --update / --delete JSON arrays (max 100 each).").option("--create <json>","Create rows (JSON array)").option("--update <json>","Update rows (JSON array, each with employeeResourceId)").option("--delete <json>","Delete rows (JSON array, each with employeeResourceId)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i={};n.create!==void 0&&(i.create=gu(n.create,"--create")),n.update!==void 0&&(i.update=gu(n.update,"--update")),n.delete!==void 0&&(i.delete=gu(n.delete,"--delete"));let o=await cM(r,i);n.json?console.log(JSON.stringify(o.data,null,2)):console.log(Y(`Queued employee import \u2014 jobId ${o.data?.jobId??"?"}`))}))}mue();gt();kt();dr();Pt();Lt();Fe();var OCr=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"categoryCode",header:"Category"},{key:"value",header:"Value"}];function Rit(t){let e=t.command("bookmarks").description("Manage organization bookmarks");e.command("list").description("List bookmarks").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>AH(r,o),{label:"Fetching bookmarks"});$e(i,OCr,n,"Bookmarks")})),e.command("get <resourceId>").description("Get a bookmark by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await gH(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Category:"),s.categoryCode),console.log(R("Value:"),s.value))})(n)),e.command("create").description("Create bookmark(s)").option("--name <name>","Bookmark name").option("--value <value>","Bookmark value").option("--category <code>","Category code (GENERAL_INFORMATION, TAXATION_AND_COMPLIANCE, etc.)").option("--datatype <code>","Datatype code (default: TEXT)").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;if(i?o=await qx(r,i.items??[i]):(Le(n,[{flag:"--name",key:"name"},{flag:"--value",key:"value"},{flag:"--category",key:"category"}]),o=await qx(r,[{name:n.name,value:n.value,categoryCode:n.category,datatypeCode:n.datatype??"TEXT"}])),n.json)console.log(JSON.stringify(o.data,null,2));else{console.log(Y(`Bookmark(s) created: ${o.data.length} item(s)`));for(let s of o.data)console.log(` ${Be(s.resourceId)} ${s.name}`)}})),e.command("update <resourceId>").description("Update a bookmark").option("--name <name>","New name").option("--value <value>","New value").option("--category <code>","New category code").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=Ce(n),s=o||{...n.name&&{name:n.name},...n.value&&{value:n.value},...n.category&&{categoryCode:n.category}},a=await yH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`Bookmark updated: ${a.data.name}`))})(n))}bH();el();gt();kt();Pt();dr();Lt();Fe();var FCr=[{key:"resourceId",header:"ID",format:Te},{key:"kind",header:"Kind"},{key:"tier",header:"Tier"},{key:"call",header:"Call"},{key:"dispositions",header:"Dispositions",format:t=>Array.isArray(t)?t.map(e=>e.verb).join(" "):String(t)},{key:"createdAt",header:"Created",format:mp}];function Bit(t){let e=t.command("jots").description("Judgment journal: record and look up judgment entries");e.command("create").description("Record judgment entries (batch via --input, single via flags)").option("--kind <kind>","Judgment kind (CLASSIFICATION, MATCH, SCOPE, ASSUMPTION, RISK, METHOD, RECOVERY, DEVIATION, NOTE)").option("--tier <tier>","Severity tier (LOW, MEDIUM, HIGH, CRITICAL)").option("--call <call>","The decision, one line").option("--why <why>","The basis for the call").option("--ruled-out <text>","Alternatives considered and set aside").option("--ref <ref...>","Entity ref, grammar TYPE:resourceId[#field][:RELATION] (repeatable)").option("--frame <frame>","Set anchor: defining query + counts").option("--confidence <level>","Routing hint (LOW, MEDIUM, HIGH)").option("--cited-rule <rule>","Org rule, policy, threshold, or precedent applied").option("--workflow-label <label>","Short workflow label (e.g. month-end-close)").option("--agent-label <label>","Self-reported product/model").option("--idempotency-key <key>","Retry key: a replay returns the existing entry").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;i?o=i.entries??[i]:(Le(n,[{flag:"--kind",key:"kind"},{flag:"--tier",key:"tier"},{flag:"--call",key:"call"}]),o=[{kind:n.kind,tier:n.tier,call:n.call,...n.why&&{why:n.why},...n.ruledOut&&{ruledOut:n.ruledOut},...n.ref&&{refs:n.ref},...n.frame&&{frame:n.frame},...n.confidence&&{confidence:n.confidence},...n.citedRule&&{citedRule:n.citedRule},...n.workflowLabel&&{workflowLabel:n.workflowLabel},...n.agentLabel&&{agentLabel:n.agentLabel},...n.idempotencyKey&&{idempotencyKey:n.idempotencyKey}}]),o=o.map(d=>({writePath:"CLI",...d}));let s=await yv(r,o),a=s.data.records??[],c=a.filter(d=>!d.error),u=a.length>0&&c.length===0;u&&(process.exitCode=1),n.json?console.log(JSON.stringify(s.data,null,2)):(console.log(u?ie(`No jots recorded: ${a.length} error(s)`):Y(`Jot(s) recorded: ${c.length}/${a.length} entr${a.length===1?"y":"ies"}`)),a.forEach((d,f)=>{if(d.error)console.log(` ${ke(`entry ${f}:`)} ${d.error}${d.errorCode?z(` (${d.errorCode})`):""}`);else{let p=[d.replayed&&"replayed",d.duplicateCount&&`${d.duplicateCount} similar`].filter(Boolean).join(", ");console.log(` ${Be(d.resourceId??"")}${p?z(` ${p}`):""}`)}}))})),e.command("recall").description("Search judgment entries (sort pinned server-side: critical first, then newest)").option("--ref <ref>","Entity ref filter, TYPE:resourceId").option("--kind <kind>","Judgment kind filter").option("--tier <tier>","Severity tier filter").option("--disposition-verb <verb>","Only entries with a disposition of this verb (FLAG, REJECT, ENDORSE)").option("--freetext <text>","Case-insensitive substring over call and why").option("--created-from <epochMs>","Created-at lower bound, epoch ms (inclusive)",Je).option("--created-to <epochMs>","Created-at upper bound, epoch ms (inclusive)",Je).option("--first-party","Only entries from Jaz-operated agent surfaces (server-stamped origin)").option("--pinned","Only pinned entries (critical or withheld-write)").option("--stats","Include per-credential disposition counts").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i={...n.ref&&{ref:n.ref},...n.kind&&{kind:n.kind},...n.tier&&{tier:n.tier},...n.dispositionVerb&&{dispositionVerb:n.dispositionVerb},...n.freetext&&{freetext:n.freetext},...n.createdFrom!==void 0&&{createdFrom:n.createdFrom},...n.createdTo!==void 0&&{createdTo:n.createdTo},...n.firstParty&&{firstParty:!0},...n.pinned&&{pinned:!0}},o,s=await He(n,async a=>{let c=await EH(r,{limit:a.limit,offset:a.offset,...Object.keys(i).length?{filter:i}:{},...n.stats&&(!n.all||a.offset===0)&&{includeStats:!0}});return o??=c.stats,c},{label:"Fetching jots"});if($e(o?.length?{...s,stats:o}:s,FCr,n,"Jots"),n.stats&&o?.length&&!gl(n)){console.log(R("Disposition stats (per credential):"));for(let a of o)console.log(` ${a.credential??"(unknown)"} ${a.verb??""} ${a.count??0}`)}})),e.command("dispose <resourceId>").description("Append a review disposition to a jot (append-only)").option("--verb <verb>","Review verb: FLAG, REJECT, or ENDORSE").option("--note <note>","Optional reviewer note").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{Le(n,[{flag:"--verb",key:"verb"}]);let o;try{o=await Trt(i,r,{verb:n.verb,...n.note&&{note:n.note}})}catch(a){if(a instanceof jo&&a.status===403&&a.body?.error?.error_type==="JOT_DISPOSITION_HUMAN_ONLY"){let c=a.body?.error?.errors?.[0]??"Reviews are decided by people. Agents can flag for review.";n.json?console.error(JSON.stringify({error:{code:"JOT_DISPOSITION_HUMAN_ONLY",status:403,message:c,try:`clio jots dispose ${r} --verb FLAG`}})):(console.error(ie(`Not allowed: ${c}`)),console.error(z(" This credential is an agent credential. Use --verb FLAG to queue the entry for a person to decide."))),process.exitCode=2;return}throw a}let s=o.data;if(n.json)console.log(JSON.stringify(s,null,2));else if(console.log(Y(`Disposition recorded: ${s.verb} on ${s.jotResourceId}`)),s.rollbackOutcome?.length){console.log(R(" Rollback outcome (recorded):"));for(let a of QCr(s.rollbackOutcome))console.log(` ${a}`)}else s.rollbackHandoff&&console.log(z(" Rejected without rollback: the linked writes were left as they are. Rolling them back is done from the review surface in the dashboard, where restores run immediately."))})(n))}function QCr(t){return t.map(e=>{let r=e.ref??e.type??"(unknown ref)";switch(e.status){case"RESTORED":return`${Y("RESTORED")} ${r}${e.restoredToVersion?z(` -> version ${e.restoredToVersion}`):""}`;case"FAILED":return`${ie("FAILED")} ${r}${e.errorCode?z(` (${e.errorCode})`):""}`;case"EDITED_SINCE":return`${ke("EDITED_SINCE")} ${r} ${z("- changed since the agent worked on it; left untouched")}`;case"NO_PRIOR_VERSION":return`${ke("NO_PRIOR_VERSION")} ${r} ${z("- the agent created it; nothing earlier to restore")}`;case"UNSUPPORTED_TYPE":return`${z("UNSUPPORTED_TYPE")} ${r} ${z("- this record type has no rollback rail")}`;case"SKIPPED_RELATION":return`${z("SKIPPED_RELATION")} ${r} ${z("- context reference, not a write")}`;case"SKIPPED_CAP":return`${z("SKIPPED_CAP")} ${r} ${z("- beyond the per-rollback limit")}`;default:return`${z(e.status??"(unknown)")} ${r}`}})}Aue();CD();gt();kt();dr();Pt();Lt();Fe();fr();function e8(t,e){return r=>{let n=r.toUpperCase();if(!t.includes(n))throw new Error(`Invalid ${e}: ${r}. Allowed: ${t.join(", ")}`);return n}}function xit(t){return Kb.map(e=>({moduleName:e,roleCode:t}))}var Tit=[{key:"resourceId",header:"ID",format:Te},{key:"firstName",header:"First Name"},{key:"lastName",header:"Last Name"},{key:"email",header:"Email"},{key:"moduleRoles",header:"Roles",format:t=>Array.isArray(t)?t.map(e=>`${e.moduleName}:${e.roleCode}`).join(", "):String(t??"")}];function kit(t){let e=t.command("org-users").description("Manage organization users");e.command("list").description("List organization users").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>CH(r,o),{label:"Fetching org users"});$e(i,Tit,n,"Org Users")})),We({parent:e,fields:vS,defaults:IS,fetcher:vH,columns:Tit,label:"Searching org users",positionalArg:"name",positionalFilter:r=>({or:[{firstName:{contains:r}},{lastName:{contains:r}},{email:{contains:r}}]})}),e.command("invite").description("Invite a user to the organization").option("--jot <text>",we).option("--first-name <name>","First name").option("--last-name <name>","Last name").option("--email <email>","Email address").option("--user-type <type>","ADMIN | CUSTOM_USER (default: derived from --role)",e8(OA,"user-type")).option("--role <role>","Role code: ADMIN, PREPARER, MEMBER, NO_ACCESS (default: MEMBER). ADMIN \u2192 userType=ADMIN; others \u2192 userType=CUSTOM_USER with this role on every module.",e8(NA,"role")).option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;if(i)o=await Ev(r,i);else{Le(n,[{flag:"--first-name",key:"firstName"},{flag:"--last-name",key:"lastName"},{flag:"--email",key:"email"}]);let s=n.role??"MEMBER",a=n.userType??(s==="ADMIN"?"ADMIN":"CUSTOM_USER");o=await Ev(r,{firstName:n.firstName,lastName:n.lastName,email:n.email,userType:a,...a==="CUSTOM_USER"?{moduleRoles:xit(s)}:{}})}n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`User invited: ${n.firstName??""} ${n.lastName??""} (${n.email??""})`)),console.log(R("ID:"),o.data.resourceId)),Ie(r,"invite_org_user",n,o.data)})),e.command("update <resourceId>").description("Update a user's access tier and/or module roles").option("--jot <text>",we).option("--user-type <type>","ADMIN | CUSTOM_USER (default: derived from --role)",e8(OA,"user-type")).option("--role <role>","New role code: ADMIN, PREPARER, MEMBER, NO_ACCESS. ADMIN \u2192 userType=ADMIN; others \u2192 userType=CUSTOM_USER with this role on every module.",e8(NA,"role")).option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=Ce(n),s;if(o)s=o;else{if(!n.role&&!n.userType)throw new Error("At least one of --role or --user-type is required");let c=n.role,u=n.userType??(c==="ADMIN"?"ADMIN":c?"CUSTOM_USER":void 0);s={...u?{userType:u}:{},...u==="CUSTOM_USER"&&c?{moduleRoles:xit(c)}:{}}}let a=await IH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`User updated: ${a.data.firstName} ${a.data.lastName}`)),Ie(i,"update_org_user",n,a.data)})(n)),e.command("remove <resourceId>").description("Remove a user from the organization").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await wH(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`User ${r} removed.`)),Ie(i,"remove_org_user",n,{resourceId:r})})(n))}Fe();$x();fr();Lt();var LCr=[{key:"resourceId",header:"ID",format:Te},{key:"transactionReference",header:"Reference",format:$n},{key:"direction",header:"Dir",format:yL},{key:"valueDate",header:"Date",format:mp},{key:"totalAmount",header:"Amount",align:"right"},{key:"currencyCode",header:"Ccy"},{key:"businessTransactionType",header:"Type",format:t=>z(String(t??""))}];function Nit(t){let e=t.command("cashflow").description("Search cashflow transactions");We({parent:e,fields:xd,defaults:Td,fetcher:zh,columns:LCr,label:"Searching cashflow"})}function Oit(t){t.command("serve").description("HTTP daemon (not available in bundled CLI)").action(()=>{console.error("clio serve is not available in the bundled CLI. Use the full installation from the private repo."),process.exit(1)})}Fe();gt();kt();Ho();eue();pue();Xle();function ja(t){return t.option("--plan","Plan mode \u2014 show required accounts and step summary (offline, no auth)").option("--input <file>","Account mapping JSON file (optional \u2014 auto-resolves from chart of accounts if omitted)").option("--bank-account <id>","Bank/cash account name or resourceId (for cash-in/cash-out steps)").option("--contact <id>","Contact name or resourceId \u2014 supplier for bills, customer for invoices").option("--existing-txn <id>","Attach to existing transaction \u2014 skip initial step, create delta only").option("--ref <prefix>","Reference prefix (generates prefix-1, prefix-2, ...)").option("--finalize","Approve transactions immediately (default: create as drafts)").option("--jot <text>",we).option("--json","Output as JSON").option("--api-key <key>","API key override")}function Ya(t,e){return async r=>{try{let n=e(r);if(r.plan){let s=gv(t,n);r.json?console.log(JSON.stringify(s,null,2)):MCr(s);return}let i=Fx(n);i||(console.error(ie("Error: no blueprint generated. Provide --start-date to enable blueprint.")),process.exit(1)),await Q(async(s,a,c)=>{let u=!!a.json,d,f=Ce(a);if(f)d=f;else{let h=gv(t,n);u||process.stderr.write(z(` Auto-resolving accounts from chart of accounts...
1061
+ `));for(let o of i.data)console.log(` ${Be(o.code??o.resourceId??"?")} ${o.description??""} ${z(o.countryCode??"")}`)}})),e.command("create").description("Create a new tax profile").option("--jot <text>",we).option("--name <name>",'Tax profile name (e.g., "GST 9%")').option("--rate <n>","Tax rate as percentage (e.g., 9)",Ee).option("--tax-type-code <code>","Tax type code (from tax-profiles types)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--rate",key:"rate"},{flag:"--tax-type-code",key:"taxTypeCode"}]);let i=await dM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Tax profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await xL(r,{name:n.name,taxRate:n.rate,taxTypeCode:n.taxTypeCode});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Tax profile created: ${n.name} (${n.rate}%)`)),console.log(R("ID:"),o.data.resourceId)),Ie(r,"create_tax_profile",n,o.data)}))}Fe();YL();PY();pc();gt();kt();dr();Pt();Lt();fr();var mit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"expenseAccountResourceId",header:"Expense Acct",format:Te}];function Ait(t){let e=t.command("claim-types").description("Manage employee-expense claim types (expense categories)");e.command("list").description("List claim types").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>PL(r,o),{label:"Fetching claim types"});$e(i,mit,n,"Claim Types")})),e.command("get <resourceId>").description("Get a claim type by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await UL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Default:"),s.isDefault),s.expenseAccount&&console.log(R("Expense Account:"),`${s.expenseAccount.code} ${s.expenseAccount.name}`),s.taxProfile&&console.log(R("Tax Profile:"),s.taxProfile.name))})(n)),We({parent:e,fields:eS,defaults:tS,fetcher:Pb,columns:mit,label:"Searching claim types"}),e.command("create").description("Create a claim type").option("--name <name>","Claim type name (unique per org)").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Magic OCR classifier defaults (JSON string)").option("--default","Make org default").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await pM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Claim type "${n.name}" already exists (${i.resourceId}).`));return}let o=await $L(r,{name:n.name,expenseAccountResourceId:n.expenseAccount,taxProfileResourceId:n.taxProfile,classifierConfig:n.classifierConfig,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Claim type created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a claim type").option("--name <name>","New name").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Classifier defaults (JSON string)").option("--default","Make org default").option("--clear <fields>","Comma-separated optional fields to NULL (expenseAccountResourceId,taxProfileResourceId,classifierConfig)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.expenseAccount!==void 0&&(o.expenseAccountResourceId=n.expenseAccount),n.taxProfile!==void 0&&(o.taxProfileResourceId=n.taxProfile),n.classifierConfig!==void 0&&(o.classifierConfig=n.classifierConfig),n.default!==void 0&&(o.isDefault=n.default),Object.assign(o,sy(Io(n.clear),oD));let s=await qL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Claim type updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim type").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await jL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim type deleted: ${r}`))})(n))}Fe();cD();PY();pc();gt();kt();dr();Pt();Lt();fr();var git=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"taxMode",header:"Tax Mode"},{key:"employeeBalanceAccountResourceId",header:"Balance Acct",format:Te}];function yit(t){let e={};return t.name!==void 0&&(e.name=t.name),t.approver!==void 0&&(e.approverUserResourceId=t.approver),t.visibleClaimTypes!==void 0&&(e.visibleClaimTypeIds=Io(t.visibleClaimTypes)),t.visibleTaxProfiles!==void 0&&(e.visibleTaxProfileIds=Io(t.visibleTaxProfiles)),t.visibleClassifiers!==void 0&&(e.visibleClassifierIds=Io(t.visibleClassifiers)),t.visibleVendors!==void 0&&(e.visibleVendorResourceIds=Io(t.visibleVendors)),t.allowedCurrencies!==void 0&&(e.allowedCurrencies=Io(t.allowedCurrencies)),t.minAmount!==void 0&&(e.minClaimAmount=t.minAmount),t.maxAmount!==void 0&&(e.maxClaimAmount=t.maxAmount),t.maxPerPeriod!==void 0&&(e.maxPerPeriodAmount=t.maxPerPeriod),t.perPeriod!==void 0&&(e.perPeriod=t.perPeriod),t.balanceAccount!==void 0&&(e.employeeBalanceAccountResourceId=t.balanceAccount),t.taxMode!==void 0&&(e.taxMode=t.taxMode),t.default!==void 0&&(e.isDefault=t.default),e}function Eit(t){return t.option("--approver <id>","Default approver user resourceId").option("--visible-claim-types <ids>","Allowed claim type IDs (comma-separated)").option("--visible-tax-profiles <ids>","Allowed tax profile IDs (comma-separated)").option("--visible-classifiers <ids>","Allowed classifier IDs (comma-separated)").option("--visible-vendors <ids>","Allowed vendor contact IDs (comma-separated)").option("--allowed-currencies <codes>","Allowed ISO currency codes (comma-separated)").option("--min-amount <n>","Min claim total",lr).option("--max-amount <n>","Max claim total",lr).option("--max-per-period <n>","Per-period spend cap (requires --per-period)",lr).option("--per-period <window>","DAILY | WEEKLY | MONTHLY | QUARTERLY | YEARLY").option("--balance-account <id>","Employee balance (CURRENT_LIABILITY) account resourceId").option("--tax-mode <mode>","NO_TAX | INCLUSIVE (EXCLUSIVE rejected)").option("--default","Make org default")}function bit(t){let e=t.command("claim-profiles").description("Manage employee-expense claim profiles (per-employee policy bundles)");e.command("list").description("List claim profiles").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>HL(r,o),{label:"Fetching claim profiles"});$e(i,git,n,"Claim Profiles")})),e.command("get <resourceId>").description("Get a claim profile by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await zL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Default:"),s.isDefault),s.taxMode&&console.log(R("Tax mode:"),s.taxMode),s.employeeBalanceAccount&&console.log(R("Balance account:"),`${s.employeeBalanceAccount.code} ${s.employeeBalanceAccount.name}`))})(n)),We({parent:e,fields:rS,defaults:nS,fetcher:Ub,columns:git,label:"Searching claim profiles"}),Eit(e.command("create").description("Create a claim profile").option("--name <name>","Profile name (unique per org)")).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await hM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Claim profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await GL(r,yit(n));n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Claim profile created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),Eit(e.command("update <resourceId>").description("Update a claim profile").option("--name <name>","New name")).option("--clear <fields>","Comma-separated optional fields to NULL (e.g. approverUserResourceId,perPeriod,taxMode)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=yit(n);Object.assign(o,sy(Io(n.clear),aD));let s=await JL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Claim profile updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim profile").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await VL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim profile deleted: ${r}`))})(n))}Fe();dD();pc();gt();kt();dr();Pt();Lt();fr();var Cit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"outerAxis",header:"Outer"},{key:"innerAxis",header:"Inner"},{key:"isDefault",header:"Default"}];function vit(t){let e=t.command("posting-rules").description("Manage claim posting rules (how approved claims group into journals at conversion)");e.command("list").description("List posting rules").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>WL(r,o),{label:"Fetching posting rules"});$e(i,Cit,n,"Posting Rules")})),e.command("get <resourceId>").description("Get a posting rule by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await ZL(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Outer axis:"),s.outerAxis),console.log(R("Inner axis:"),s.innerAxis),console.log(R("Line template:"),s.lineDescriptionTemplate),console.log(R("Default:"),s.isDefault))})(n)),We({parent:e,fields:iS,defaults:oS,fetcher:$b,columns:Cit,label:"Searching posting rules"}),e.command("create").description("Create a posting rule").option("--name <name>","Rule name (unique per org)").option("--outer-axis <axis>","PER_EMPLOYEE | PER_VENDOR | PER_PAIR | ONE_BATCH | PER_CLAIM").option("--inner-axis <axis>","RAW | BY_CT_TP_NC | BY_CT_TP_NC_EMPLOYEE | BY_CT_TP_NC_VENDOR").option("--line-template <tpl>",'Handlebars line template, e.g. "{employeeName} - {claimType}"').option("--journal-reference-template <tpl>","Optional journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout","Create reimbursement DCE by default").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--outer-axis",key:"outerAxis"},{flag:"--inner-axis",key:"innerAxis"},{flag:"--line-template",key:"lineTemplate"}]);let i=await mM(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(ke(`Posting rule "${n.name}" already exists (${i.resourceId}).`));return}let o=await KL(r,{name:n.name,outerAxis:n.outerAxis,innerAxis:n.innerAxis,lineDescriptionTemplate:n.lineTemplate,journalReferenceTemplate:n.journalReferenceTemplate,defaultBankAccountResourceId:n.defaultBankAccount,defaultIncludeReimbursementPayout:n.defaultIncludePayout,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Posting rule created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a posting rule").option("--name <name>","New name").option("--outer-axis <axis>","Outer grouping axis").option("--inner-axis <axis>","Inner line-aggregation axis").option("--line-template <tpl>","Handlebars line template").option("--journal-reference-template <tpl>","Journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout <bool>","Create reimbursement DCE by default (true/false)").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.outerAxis!==void 0&&(o.outerAxis=n.outerAxis),n.innerAxis!==void 0&&(o.innerAxis=n.innerAxis),n.lineTemplate!==void 0&&(o.lineDescriptionTemplate=n.lineTemplate),n.journalReferenceTemplate!==void 0&&(o.journalReferenceTemplate=n.journalReferenceTemplate),n.defaultBankAccount!==void 0&&(o.defaultBankAccountResourceId=n.defaultBankAccount),n.defaultIncludePayout!==void 0&&(o.defaultIncludeReimbursementPayout=n.defaultIncludePayout==="true"),n.default!==void 0&&(o.isDefault=n.default);let s=await XL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Posting rule updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Delete a posting rule (the org default cannot be deleted while default)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await eM(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Posting rule deleted: ${r}`))})(n))}Fe();ZM();vue();Iue();u_();MH();gt();kt();Lt();kf();fr();import{randomUUID as BCr}from"node:crypto";import{readFileSync as Iit,statSync as xCr}from"node:fs";import{basename as TCr,extname as kCr,resolve as wit}from"node:path";var NCr=[{key:"resourceId",header:"ID",format:Te},{key:"reference",header:"Reference"},{key:"status",header:"Status"},{key:"employeeResourceId",header:"Employee",format:Te},{key:"totalAmount",header:"Amount"},{key:"currencyCode",header:"Ccy"}];function _it(t){let e=t.command("claims").description("Employee-expense claims: search, edit drafts, lifecycle, bulk actions");We({parent:e,fields:WD,defaults:ZD,fetcher:NM,columns:NCr,label:"Searching claims"}),e.command("get <resourceId>").description("Get a claim by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>Q(async c=>{let d=(await OM(c,s)).data;a.json?console.log(JSON.stringify(d,null,2)):(console.log(R("Reference:"),d.reference??"\u2014"),console.log(R("ID:"),d.resourceId),console.log(R("Status:"),d.status),console.log(R("Total:"),`${d.totalAmount??0} ${d.currencyCode??""}`),console.log(R("Lines:"),(d.claimItems??[]).length))})(a)),e.command("create").description("Create a claim directly (bare create). Vendor is EITHER --contact OR --vendor-name. --items / --custom-fields take a JSON array string.").requiredOption("--value-date <date>","Business-transaction date (YYYY-MM-DD)").requiredOption("--currency <code>","Claim currency (ISO 4217)").option("--reference <ref>","User reference").option("--employee <id>","Employee resourceId the claim is filed for").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency-symbol <symbol>","Currency symbol override").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(s=>Q(async a=>{let c={valueDate:s.valueDate,currencyCode:s.currency};s.reference!==void 0&&(c.reference=s.reference),s.employee!==void 0&&(c.employeeResourceId=s.employee),s.contact!==void 0&&(c.contactResourceId=s.contact),s.vendorName!==void 0&&(c.vendorName=s.vendorName),s.currencySymbol!==void 0&&(c.currencySymbol=s.currencySymbol),s.internalNotes!==void 0&&(c.internalNotes=s.internalNotes),s.claimProfile!==void 0&&(c.claimProfileResourceId=s.claimProfile),s.approver!==void 0&&(c.approverUserResourceId=s.approver),s.tags!==void 0&&(c.tags=Io(s.tags)??[]),s.items!==void 0&&(c.claimItems=gu(s.items,"--items")),s.customFields!==void 0&&(c.customFields=gu(s.customFields,"--custom-fields")),s.submit&&(c.saveAsDraft=!1);let u=await FM(a,c);s.json?console.log(JSON.stringify(u.data,null,2)):console.log(Y(`Claim created: ${u.data.reference??u.data.resourceId} (${u.data.status})`))})(s)),e.command("update <resourceId>").description("Update a DRAFT claim (partial). --items / --custom-fields take a JSON array string.").option("--reference <ref>","User reference").option("--value-date <date>","Business-transaction date (YYYY-MM-DD)").option("--employee <id>","Employee resourceId").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency <code>","Claim currency (ISO 4217)").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array (REPLACES all lines)").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>Q(async c=>{let u={};a.reference!==void 0&&(u.reference=a.reference),a.valueDate!==void 0&&(u.valueDate=a.valueDate),a.employee!==void 0&&(u.employeeResourceId=a.employee),a.contact!==void 0&&(u.contactResourceId=a.contact),a.vendorName!==void 0&&(u.vendorName=a.vendorName),a.currency!==void 0&&(u.currencyCode=a.currency),a.internalNotes!==void 0&&(u.internalNotes=a.internalNotes),a.claimProfile!==void 0&&(u.claimProfileResourceId=a.claimProfile),a.approver!==void 0&&(u.approverUserResourceId=a.approver),a.tags!==void 0&&(u.tags=Io(a.tags)??[]),a.items!==void 0&&(u.claimItems=gu(a.items,"--items")),a.customFields!==void 0&&(u.customFields=gu(a.customFields,"--custom-fields")),a.submit&&(u.saveAsDraft=!1);let d=await QM(c,s,u);a.json?console.log(JSON.stringify(d.data,null,2)):console.log(Y(`Claim updated: ${d.data.reference??d.data.resourceId} (${d.data.status})`))})(a)),e.command("delete <resourceId>").description("Delete a claim (only DRAFT / REJECTED / CANCELLED)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>Q(async c=>{await LM(c,s),a.json?console.log(JSON.stringify({deleted:!0,resourceId:s})):console.log(Y(`Claim deleted: ${s}`))})(a)),e.command("delete-attachment <resourceId> <attachmentResourceId>").description("Remove one attachment from a claim").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a,c)=>Q(async u=>{await MM(u,s,a),c.json?console.log(JSON.stringify({deleted:!0,resourceId:s,attachmentResourceId:a})):console.log(Y(`Attachment removed from claim ${s}`))})(c));let r=[["submit",PM,"Submit a DRAFT claim for approval"],["approve",UM,"Approve a SUBMITTED claim"],["unpost",jM,"Unpost a CONVERTED claim (reverse conversion)"]];for(let[s,a,c]of r)e.command(`${s} <resourceId>`).description(c).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>Q(async f=>{let p=await a(f,u);d.json?console.log(JSON.stringify(p,null,2)):console.log(Y(`Claim ${s}: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let n=[["reject",$M,"Reject a SUBMITTED/APPROVED claim"],["cancel",qM,"Cancel a DRAFT/SUBMITTED claim"]];for(let[s,a,c]of n)e.command(`${s} <resourceId>`).description(c).option("--reason <text>","Reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>Q(async f=>{Le(d,[{flag:"--reason",key:"reason"}]);let p=await a(f,u,d.reason);d.json?console.log(JSON.stringify(p,null,2)):console.log(Y(`Claim ${s}ed: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let i=[["bulk-submit",YM,"Bulk-submit DRAFT claims (async)"],["bulk-approve",HM,"Bulk-approve SUBMITTED claims (async)"],["bulk-delete",zM,"Bulk-delete DRAFT/REJECTED/CANCELLED claims (async)"]];for(let[s,a,c]of i)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"}]);let f=await a(u,Io(d.ids)??[]);d.json?console.log(JSON.stringify(f,null,2)):console.log(Y(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));let o=[["bulk-reject",GM,"Bulk-reject claims (async)"],["bulk-cancel",JM,"Bulk-cancel claims (async)"]];for(let[s,a,c]of o)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--reason <text>","Shared reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"},{flag:"--reason",key:"reason"}]);let f=await a(u,Io(d.ids)??[],d.reason);d.json?console.log(JSON.stringify(f,null,2)):console.log(Y(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));e.command("tracking-tags").description("List claim tracking-tag values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{let c=await VM(s);if(a.json)console.log(JSON.stringify(c,null,2));else{console.log(R(`Tracking tags (${c.length}):`));for(let u of c)console.log(` ${typeof u=="string"?u:JSON.stringify(u)}`)}})),e.command("custom-field-values").description("List claim custom-field values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{let c=await WM(s);a.json?console.log(JSON.stringify(c,null,2)):console.log(ke(c.length===0?"No custom field values.":`${c.length} custom field value(s).`))})),e.command("preview-conversion").description("Preview the journals an APPROVED claim batch would produce (no write)").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--payout-flow <flow>","POST | POST_AND_RECORD").option("--include-payout","Include reimbursement DCE lines").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{if(Le(a,[{flag:"--ids",key:"ids"}]),a.payoutFlow!==void 0&&!Yx.includes(a.payoutFlow))throw new Error(`--payout-flow must be one of: ${Yx.join(", ")}`);let c=await PH(s,{claimResourceIds:Io(a.ids)??[],postingRuleResourceId:a.postingRule,payoutFlow:a.payoutFlow,includeReimbursementPayout:a.includePayout});console.log(JSON.stringify(c.data,null,2))})),e.command("convert").description("Convert an APPROVED claim batch into journals (atomic). Preview first.").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--value-date <date>","Journal value date (YYYY-MM-DD), required").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--include-payout","Create books-only reimbursement DCEs").option("--bank-account <id>","Override reimbursement bank account").option("--idempotency-key <key>","Retry-dedup token (auto-generated if omitted)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{Le(a,[{flag:"--ids",key:"ids"},{flag:"--value-date",key:"valueDate"}]);let c=await UH(s,{claimResourceIds:Io(a.ids)??[],valueDate:a.valueDate,postingRuleResourceId:a.postingRule,includeReimbursementPayout:a.includePayout,bankAccountResourceIdOverride:a.bankAccount,idempotencyKey:a.idempotencyKey||BCr()});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(Y("Claims converted to journals."))})),e.command("record-payout").description("Record a books-only employee payout (reimbursement / advance)").option("--employee <id>","Employee resourceId").option("--amount <n>","Payout amount (> 0)",lr).option("--payment-account <id>","Bank/cash account the DCE credits").option("--value-date <date>","Value date (YYYY-MM-DD)").option("--payout-for <type>","REIMBURSEMENT | ADVANCE (default ADVANCE)").option("--currency <code>","Settle currency (ISO 4217)").option("--reference <ref>","Payout reference (auto-generated if omitted)").option("--description <text>","DCE line description").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{Le(a,[{flag:"--employee",key:"employee"},{flag:"--amount",key:"amount"},{flag:"--payment-account",key:"paymentAccount"},{flag:"--value-date",key:"valueDate"}]);let c=await $H(s,{employeeResourceId:a.employee,amount:a.amount,paymentAccountResourceId:a.paymentAccount,valueDate:a.valueDate,payoutFor:a.payoutFor,currencyCode:a.currency,reference:a.reference||$a("EP"),description:a.description,internalNotes:a.internalNotes});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(Y(`Payout recorded: ${c.data.resourceId}`))})),We({parent:e,commandName:"payouts",fields:KD,defaults:XD,fetcher:qH,columns:[{key:"resourceId",header:"ID",format:Te},{key:"reference",header:"Reference"},{key:"employeeResourceId",header:"Employee",format:Te},{key:"amount",header:"Amount"},{key:"payoutType",header:"Type"}],label:"Searching employee payouts"}),e.command("from-attachment").description("Create a claim DRAFT from a receipt via AI extraction \u2014 a local file (--file), a remote URL (--source-url), or raw HTML (--html)").option("--file <path>","Local receipt file (PDF / JPG / PNG / HEIC / XLS / XLSX / EML)").option("--source-url <url>","Remote receipt file URL (alternative to --file)").option("--html <value>","Raw HTML (e.g. an email body) \u2014 inline or @path to read from a file").option("--contact <id>","Vendor contact resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employee <id>","File on behalf of this employee resourceId (default: the uploader's own; server requires a claims Manager/Admin to name another)").option("--currency <code>","Currency override (ISO 4217)").option("--value-date <date>","Value date override (YYYY-MM-DD)").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(s,a)=>{if([a.file,a.sourceUrl,a.html].filter(Boolean).length!==1)throw new Error("provide exactly one of --file / --source-url / --html.");let u,d;if(a.file){let h=wit(a.file),m=kCr(h).toLowerCase();if(!dd.has(m))throw new Error(`unsupported file type "${m}". Supported: ${[...dd].join(", ")}`);let A=25*1024*1024,g=xCr(h).size;if(g>A)throw new Error(`file too large (${(g/1048576).toFixed(1)}MB > 25MB). Compress or split the receipt.`);u=new Blob([Iit(h)],{type:Ym(m)}),d=TCr(h)}let f;a.html&&(a.html.startsWith("@")||console.error(ke("Warning: passing HTML inline can leak invoice data into shell history \u2014 prefer --html @path.")),f=a.html.startsWith("@")?Iit(wit(a.html.slice(1)),"utf8"):a.html);let p=await cb(s,{sourceFile:u,sourceFileName:d,sourceURL:a.sourceUrl,html:f,contactResourceId:a.contact,claimProfileResourceId:a.claimProfile,employeeResourceId:a.employee,currencyCode:a.currency,valueDate:a.valueDate,internalNotes:a.internalNotes});console.log(JSON.stringify(p,null,2))}))}Fe();fD();pc();gt();kt();Lt();fr();var Dit=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"email",header:"Email"},{key:"employmentType",header:"Type"},{key:"active",header:"Active"}];function Sit(t){let e=t.command("employees").description("Manage employees (expense-claim members): CRUD, balances, bind-user, import");We({parent:e,fields:sS,defaults:aS,fetcher:qb,columns:Dit,label:"Searching employees"}),We({parent:e,commandName:"balances",fields:cS,defaults:lS,fetcher:tM,columns:Dit,label:"Searching employee balances"}),e.command("get <resourceId>").description("Get an employee by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await rM(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Email:"),s.email??"\u2014"),console.log(R("Active:"),s.active),s.userBinding&&console.log(R("Bound user:"),`${s.userBinding.name??""} (${s.userBinding.status??""})`),s.claimProfile&&console.log(R("Claim profile:"),s.claimProfile.name))})(n)),e.command("create").description("Create an employee (requires --user to bind; binding is permanent)").option("--name <name>","Employee name").option("--user <id>","Login user resourceId to bind (required)").option("--claim-profile <id>","Claim profile resourceId (defaults to org default)").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--employment-type <type>","FULL_TIME | PART_TIME | CONTRACTOR | INTERN | TEMPORARY | CONSULTANT").option("--inactive","Create as inactive").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{if(Le(n,[{flag:"--name",key:"name"},{flag:"--user",key:"user"}]),n.email){let o=await AM(r,n.email);if(o){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:o},null,2)):console.log(ke(`Employee with email "${n.email}" already exists (${o.resourceId}).`));return}}let i=await nM(r,{name:n.name,userResourceId:n.user,claimProfileResourceId:n.claimProfile,email:n.email,phone:n.phone,managerEmployeeResourceId:n.manager,active:n.inactive?!1:void 0,employmentType:n.employmentType});n.json?console.log(JSON.stringify(i.data,null,2)):(console.log(Y(`Employee created: ${n.name}`)),console.log(R("ID:"),i.data.resourceId))})),e.command("update <resourceId>").description("Update an employee. Use --archive to deactivate (reversible).").option("--name <name>","New name").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employment-type <type>","Employment classification").option("--archive","Set active=false (archive)").option("--activate","Set active=true").option("--clear-employment-type","Unset the classification").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};if(n.name!==void 0&&(o.name=n.name),n.email!==void 0&&(o.email=n.email),n.phone!==void 0&&(o.phone=n.phone),n.manager!==void 0&&(o.managerEmployeeResourceId=n.manager),n.claimProfile!==void 0&&(o.claimProfileResourceId=n.claimProfile),n.employmentType!==void 0&&(o.employmentType=n.employmentType),n.archive&&n.activate)throw new Error("--archive and --activate are mutually exclusive.");n.archive&&(o.active=!1),n.activate&&(o.active=!0),n.clearEmploymentType&&(o.clearEmploymentType=!0);let s=await iM(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Employee updated: ${s.data.name??r}`))})(n)),e.command("delete <resourceId>").description("Delete an employee (must be settled). Prefer update --archive.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await oM(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Employee deleted: ${r}`))})(n)),e.command("bind-user <resourceId> <userResourceId>").description("Bind a login user to an offline employee (no user bound yet). One-way, permanent \u2014 allowed only while unbound.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n,i)=>Q(async o=>{let s=await sM(o,r,n);i.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Bound user ${n} to employee ${r}`))})(i)),e.command("preprocess <fileUrl>").description("Preview an employee import sheet before importing").option("--file-name <name>","Display file name").option("--file-type <type>","CSV | XLS | XLSX").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=await aM(i,{fileUrl:r,fileName:n.fileName,fileType:n.fileType});console.log(JSON.stringify(o.data,null,2))})(n)),e.command("import").description("Bulk import employees (async). Pass --create / --update / --delete JSON arrays (max 100 each).").option("--create <json>","Create rows (JSON array)").option("--update <json>","Update rows (JSON array, each with employeeResourceId)").option("--delete <json>","Delete rows (JSON array, each with employeeResourceId)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i={};n.create!==void 0&&(i.create=gu(n.create,"--create")),n.update!==void 0&&(i.update=gu(n.update,"--update")),n.delete!==void 0&&(i.delete=gu(n.delete,"--delete"));let o=await cM(r,i);n.json?console.log(JSON.stringify(o.data,null,2)):console.log(Y(`Queued employee import \u2014 jobId ${o.data?.jobId??"?"}`))}))}mue();gt();kt();dr();Pt();Lt();Fe();var OCr=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"categoryCode",header:"Category"},{key:"value",header:"Value"}];function Rit(t){let e=t.command("bookmarks").description("Manage organization bookmarks");e.command("list").description("List bookmarks").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>AH(r,o),{label:"Fetching bookmarks"});$e(i,OCr,n,"Bookmarks")})),e.command("get <resourceId>").description("Get a bookmark by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await gH(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Category:"),s.categoryCode),console.log(R("Value:"),s.value))})(n)),e.command("create").description("Create bookmark(s)").option("--name <name>","Bookmark name").option("--value <value>","Bookmark value").option("--category <code>","Category code (GENERAL_INFORMATION, TAXATION_AND_COMPLIANCE, etc.)").option("--datatype <code>","Datatype code (default: TEXT)").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;if(i?o=await qx(r,i.items??[i]):(Le(n,[{flag:"--name",key:"name"},{flag:"--value",key:"value"},{flag:"--category",key:"category"}]),o=await qx(r,[{name:n.name,value:n.value,categoryCode:n.category,datatypeCode:n.datatype??"TEXT"}])),n.json)console.log(JSON.stringify(o.data,null,2));else{console.log(Y(`Bookmark(s) created: ${o.data.length} item(s)`));for(let s of o.data)console.log(` ${Be(s.resourceId)} ${s.name}`)}})),e.command("update <resourceId>").description("Update a bookmark").option("--name <name>","New name").option("--value <value>","New value").option("--category <code>","New category code").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=Ce(n),s=o||{...n.name&&{name:n.name},...n.value&&{value:n.value},...n.category&&{categoryCode:n.category}},a=await yH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`Bookmark updated: ${a.data.name}`))})(n))}bH();el();gt();kt();Pt();dr();Lt();Fe();var FCr=[{key:"resourceId",header:"ID",format:Te},{key:"kind",header:"Kind"},{key:"tier",header:"Tier"},{key:"call",header:"Call"},{key:"dispositions",header:"Dispositions",format:t=>Array.isArray(t)?t.map(e=>e.verb).join(" "):String(t)},{key:"createdAt",header:"Created",format:mp}];function Bit(t){let e=t.command("jots").description("Judgment journal: record and look up judgment entries");e.command("create").description("Record judgment entries (batch via --input, single via flags)").option("--kind <kind>","Judgment kind (CLASSIFICATION, MATCH, SCOPE, ASSUMPTION, RISK, METHOD, RECOVERY, DEVIATION, NOTE)").option("--tier <tier>","Severity tier (LOW, MEDIUM, HIGH, CRITICAL)").option("--call <call>","The decision, one line").option("--why <why>","The basis for the call").option("--ruled-out <text>","Alternatives considered and set aside").option("--ref <ref...>","Entity ref, grammar TYPE:resourceId[#field][:RELATION] (repeatable)").option("--frame <frame>","Set anchor: defining query + counts").option("--confidence <level>","Routing hint (LOW, MEDIUM, HIGH)").option("--cited-rule <rule>","Org rule, policy, threshold, or precedent applied").option("--workflow-label <label>","Short workflow label (e.g. month-end-close)").option("--agent-label <label>","Self-reported product/model").option("--idempotency-key <key>","Retry key: a replay returns the existing entry").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;i?o=i.entries??[i]:(Le(n,[{flag:"--kind",key:"kind"},{flag:"--tier",key:"tier"},{flag:"--call",key:"call"}]),o=[{kind:n.kind,tier:n.tier,call:n.call,...n.why&&{why:n.why},...n.ruledOut&&{ruledOut:n.ruledOut},...n.ref&&{refs:n.ref},...n.frame&&{frame:n.frame},...n.confidence&&{confidence:n.confidence},...n.citedRule&&{citedRule:n.citedRule},...n.workflowLabel&&{workflowLabel:n.workflowLabel},...n.agentLabel&&{agentLabel:n.agentLabel},...n.idempotencyKey&&{idempotencyKey:n.idempotencyKey}}]),o=o.map(d=>({writePath:"CLI",...d}));let s=await yv(r,o),a=s.data.records??[],c=a.filter(d=>!d.error),u=a.length>0&&c.length===0;u&&(process.exitCode=1),n.json?console.log(JSON.stringify(s.data,null,2)):(console.log(u?ie(`No jots recorded: ${a.length} error(s)`):Y(`Jot(s) recorded: ${c.length}/${a.length} entr${a.length===1?"y":"ies"}`)),a.forEach((d,f)=>{if(d.error)console.log(` ${ke(`entry ${f}:`)} ${d.error}${d.errorCode?z(` (${d.errorCode})`):""}`);else{let p=[d.replayed&&"replayed",d.duplicateCount&&`${d.duplicateCount} similar`].filter(Boolean).join(", ");console.log(` ${Be(d.resourceId??"")}${p?z(` ${p}`):""}`)}}))})),e.command("recall").description("Search judgment entries (sort pinned server-side: critical first, then newest)").option("--ref <ref>","Entity ref filter, TYPE:resourceId").option("--kind <kind>","Judgment kind filter").option("--tier <tier>","Severity tier filter").option("--disposition-verb <verb>","Only entries with a disposition of this verb (FLAG, REJECT, ENDORSE)").option("--freetext <text>","Case-insensitive substring over call and why").option("--created-from <epochMs>","Created-at lower bound, epoch ms (inclusive)",Je).option("--created-to <epochMs>","Created-at upper bound, epoch ms (inclusive)",Je).option("--first-party","Only entries from Jaz-operated agent surfaces (server-stamped origin)").option("--pinned","Only pinned entries (critical or withheld-write)").option("--stats","Include per-credential disposition counts").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i={...n.ref&&{ref:n.ref},...n.kind&&{kind:n.kind},...n.tier&&{tier:n.tier},...n.dispositionVerb&&{dispositionVerb:n.dispositionVerb},...n.freetext&&{freetext:n.freetext},...n.createdFrom!==void 0&&{createdFrom:n.createdFrom},...n.createdTo!==void 0&&{createdTo:n.createdTo},...n.firstParty&&{firstParty:!0},...n.pinned&&{pinned:!0}},o,s=await He(n,async a=>{let c=await EH(r,{limit:a.limit,offset:a.offset,...Object.keys(i).length?{filter:i}:{},...n.stats&&(!n.all||a.offset===0)&&{includeStats:!0}});return o??=c.stats,c},{label:"Fetching jots"});if($e(o?.length?{...s,stats:o}:s,FCr,n,"Jots"),n.stats&&o?.length&&!gl(n)){console.log(R("Disposition stats (per credential):"));for(let a of o)console.log(` ${a.credential??"(unknown)"} ${a.verb??""} ${a.count??0}`)}})),e.command("dispose <resourceId>").description("Append a review disposition to a jot (append-only)").option("--verb <verb>","Review verb: FLAG, REJECT, or ENDORSE").option("--note <note>","Optional reviewer note").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{Le(n,[{flag:"--verb",key:"verb"}]);let o;try{o=await Trt(i,r,{verb:n.verb,...n.note&&{note:n.note}})}catch(a){if(a instanceof jo&&a.status===403&&a.body?.error?.error_type==="JOT_DISPOSITION_HUMAN_ONLY"){let c=a.body?.error?.errors?.[0]??"Reviews are decided by people. Agents can flag for review.";n.json?console.error(JSON.stringify({error:{code:"JOT_DISPOSITION_HUMAN_ONLY",status:403,message:c,try:`clio jots dispose ${r} --verb FLAG`}})):(console.error(ie(`Not allowed: ${c}`)),console.error(z(" This credential is an agent credential. Use --verb FLAG to queue the entry for a person to decide."))),process.exitCode=2;return}throw a}let s=o.data;if(n.json)console.log(JSON.stringify(s,null,2));else if(console.log(Y(`Disposition recorded: ${s.verb} on ${s.jotResourceId}`)),s.rollbackOutcome?.length){console.log(R(" Rollback outcome:"));for(let a of QCr(s.rollbackOutcome))console.log(` ${a}`)}else s.verb==="REJECT"&&console.log(z(" REJECT recorded. If a rollback was requested, outcomes land on the jot as refs complete. Check recall."))})(n))}function QCr(t){return t.map(e=>{let r=e.ref??e.type??"(unknown ref)";switch(e.status){case"RESTORED":return`${Y("RESTORED")} ${r}${e.restoredToVersion?z(` -> version ${e.restoredToVersion}`):""}`;case"FAILED":return`${ie("FAILED")} ${r}${e.errorCode?z(` (${e.errorCode})`):""}`;case"EDITED_SINCE":return`${ke("EDITED_SINCE")} ${r} ${z("- changed since the agent worked on it; left untouched")}`;case"NO_PRIOR_VERSION":return`${ke("NO_PRIOR_VERSION")} ${r} ${z("- the agent created it; nothing earlier to restore")}`;case"UNSUPPORTED_TYPE":return`${z("UNSUPPORTED_TYPE")} ${r} ${z("- this record type has no rollback rail")}`;case"SKIPPED_RELATION":return`${z("SKIPPED_RELATION")} ${r} ${z("- context reference, not a write")}`;case"SKIPPED_CAP":return`${z("SKIPPED_CAP")} ${r} ${z("- beyond the per-rollback limit")}`;default:return`${z(e.status??"(unknown)")} ${r}`}})}Aue();CD();gt();kt();dr();Pt();Lt();Fe();fr();function e8(t,e){return r=>{let n=r.toUpperCase();if(!t.includes(n))throw new Error(`Invalid ${e}: ${r}. Allowed: ${t.join(", ")}`);return n}}function xit(t){return Kb.map(e=>({moduleName:e,roleCode:t}))}var Tit=[{key:"resourceId",header:"ID",format:Te},{key:"firstName",header:"First Name"},{key:"lastName",header:"Last Name"},{key:"email",header:"Email"},{key:"moduleRoles",header:"Roles",format:t=>Array.isArray(t)?t.map(e=>`${e.moduleName}:${e.roleCode}`).join(", "):String(t??"")}];function kit(t){let e=t.command("org-users").description("Manage organization users");e.command("list").description("List organization users").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Je).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await He(n,o=>CH(r,o),{label:"Fetching org users"});$e(i,Tit,n,"Org Users")})),We({parent:e,fields:vS,defaults:IS,fetcher:vH,columns:Tit,label:"Searching org users",positionalArg:"name",positionalFilter:r=>({or:[{firstName:{contains:r}},{lastName:{contains:r}},{email:{contains:r}}]})}),e.command("invite").description("Invite a user to the organization").option("--jot <text>",we).option("--first-name <name>","First name").option("--last-name <name>","Last name").option("--email <email>","Email address").option("--user-type <type>","ADMIN | CUSTOM_USER (default: derived from --role)",e8(OA,"user-type")).option("--role <role>","Role code: ADMIN, PREPARER, MEMBER, NO_ACCESS (default: MEMBER). ADMIN \u2192 userType=ADMIN; others \u2192 userType=CUSTOM_USER with this role on every module.",e8(NA,"role")).option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;if(i)o=await Ev(r,i);else{Le(n,[{flag:"--first-name",key:"firstName"},{flag:"--last-name",key:"lastName"},{flag:"--email",key:"email"}]);let s=n.role??"MEMBER",a=n.userType??(s==="ADMIN"?"ADMIN":"CUSTOM_USER");o=await Ev(r,{firstName:n.firstName,lastName:n.lastName,email:n.email,userType:a,...a==="CUSTOM_USER"?{moduleRoles:xit(s)}:{}})}n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`User invited: ${n.firstName??""} ${n.lastName??""} (${n.email??""})`)),console.log(R("ID:"),o.data.resourceId)),Ie(r,"invite_org_user",n,o.data)})),e.command("update <resourceId>").description("Update a user's access tier and/or module roles").option("--jot <text>",we).option("--user-type <type>","ADMIN | CUSTOM_USER (default: derived from --role)",e8(OA,"user-type")).option("--role <role>","New role code: ADMIN, PREPARER, MEMBER, NO_ACCESS. ADMIN \u2192 userType=ADMIN; others \u2192 userType=CUSTOM_USER with this role on every module.",e8(NA,"role")).option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=Ce(n),s;if(o)s=o;else{if(!n.role&&!n.userType)throw new Error("At least one of --role or --user-type is required");let c=n.role,u=n.userType??(c==="ADMIN"?"ADMIN":c?"CUSTOM_USER":void 0);s={...u?{userType:u}:{},...u==="CUSTOM_USER"&&c?{moduleRoles:xit(c)}:{}}}let a=await IH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`User updated: ${a.data.firstName} ${a.data.lastName}`)),Ie(i,"update_org_user",n,a.data)})(n)),e.command("remove <resourceId>").description("Remove a user from the organization").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await wH(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`User ${r} removed.`)),Ie(i,"remove_org_user",n,{resourceId:r})})(n))}Fe();$x();fr();Lt();var LCr=[{key:"resourceId",header:"ID",format:Te},{key:"transactionReference",header:"Reference",format:$n},{key:"direction",header:"Dir",format:yL},{key:"valueDate",header:"Date",format:mp},{key:"totalAmount",header:"Amount",align:"right"},{key:"currencyCode",header:"Ccy"},{key:"businessTransactionType",header:"Type",format:t=>z(String(t??""))}];function Nit(t){let e=t.command("cashflow").description("Search cashflow transactions");We({parent:e,fields:xd,defaults:Td,fetcher:zh,columns:LCr,label:"Searching cashflow"})}function Oit(t){t.command("serve").description("HTTP daemon (not available in bundled CLI)").action(()=>{console.error("clio serve is not available in the bundled CLI. Use the full installation from the private repo."),process.exit(1)})}Fe();gt();kt();Ho();eue();pue();Xle();function ja(t){return t.option("--plan","Plan mode \u2014 show required accounts and step summary (offline, no auth)").option("--input <file>","Account mapping JSON file (optional \u2014 auto-resolves from chart of accounts if omitted)").option("--bank-account <id>","Bank/cash account name or resourceId (for cash-in/cash-out steps)").option("--contact <id>","Contact name or resourceId \u2014 supplier for bills, customer for invoices").option("--existing-txn <id>","Attach to existing transaction \u2014 skip initial step, create delta only").option("--ref <prefix>","Reference prefix (generates prefix-1, prefix-2, ...)").option("--finalize","Approve transactions immediately (default: create as drafts)").option("--jot <text>",we).option("--json","Output as JSON").option("--api-key <key>","API key override")}function Ya(t,e){return async r=>{try{let n=e(r);if(r.plan){let s=gv(t,n);r.json?console.log(JSON.stringify(s,null,2)):MCr(s);return}let i=Fx(n);i||(console.error(ie("Error: no blueprint generated. Provide --start-date to enable blueprint.")),process.exit(1)),await Q(async(s,a,c)=>{let u=!!a.json,d,f=Ce(a);if(f)d=f;else{let h=gv(t,n);u||process.stderr.write(z(` Auto-resolving accounts from chart of accounts...
1062
1062
  `)),d=await E1e(s,h.plan.requiredAccounts,{silent:u})}if(a.contact){let h=await gi(s,a.contact,{silent:u});a.contact=h.resourceId}if(a.bankAccount){let h=await IM(s,a.bankAccount,{silent:u});a.bankAccount=h.resourceId}let p=await hH(s,{blueprint:i,calcType:t,accountMap:d,bankAccountId:a.bankAccount,contactId:a.contact,existingTxnId:a.existingTxn,referencePrefix:a.ref,finalize:a.finalize});a.json?console.log(JSON.stringify(p,null,2)):PCr(p),Ie(s,"execute_recipe",a,p)})(r)}catch(n){throw(n instanceof zt||n instanceof Error&&n.message.includes("blueprint"))&&(console.error(ie("Error: "+n.message)),process.exit(1)),n}}}function MCr(t){console.log(R(`
1063
1063
  Capsule Transaction Plan: `+t.recipe+`
1064
1064
  `)),console.log(" Capsule Type: "+t.plan.capsuleType),console.log(" Capsule Name: "+t.plan.capsuleName),console.log(" Total Steps: "+t.plan.steps.total),console.log(" Step Breakdown:");for(let[e,r]of Object.entries(t.plan.steps.byAction))console.log(" "+e+": "+r);console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaz-clio",
3
- "version": "5.24.14",
3
+ "version": "5.24.15",
4
4
  "description": "Clio: Command Line Interface Operator for Jaz AI.",
5
5
  "type": "module",
6
6
  "bin": {