jaz-clio 5.24.2 → 5.24.4

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.2
3
+ version: 5.24.4
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
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-cli
3
- version: 5.24.2
3
+ version: 5.24.4
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.2
3
+ version: 5.24.4
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.2
3
+ version: 5.24.4
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.2
3
+ version: 5.24.4
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.2
3
+ version: 5.24.4
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
@@ -1057,7 +1057,7 @@ clio() {
1057
1057
  `))}process.exit(1)}await $S(o,n,d);let y=(await bl(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(`
1058
1058
  \u2713 Supplier credit note finalized: ${y.reference||y.resourceId}`)),console.log(R(" Status:"),y.status),C.length>0&&console.log(R(" Updated:"),C.join(", ")))})(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 bl(o,n)).data,u=(await ii(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}:
1059
1059
  `));for(let d of u)console.log(` ${Se(d.resourceId)} ${d.fileName||"(unnamed)"}`),d.fileUrl&&console.log(` ${G(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 r2(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(Se(` Poll progress: clio background-jobs get ${a.data.jobId}`)))}))}Oe();l2();mt();Pt();var znt=[{key:"currencyCode",header:"Code"},{key:"currencyName",header:"Name"},{key:"currencySymbol",header:"Symbol"},{key:"baseCurrency",header:"Base"}];function Gnt(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 jS(r),o={data:i.data,totalElements:i.data.length,totalPages:1,truncated:!1};Pe(o,znt,n,"Currencies")})),e.command("add <codes...>").description("Add currencies to the organization (e.g. clio currencies add EUR GBP)").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 i2(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};Pe(c,znt,n,"Currencies")}else console.log(Y(`Added currencies: ${o.join(", ")}`))})(n))}l2();mt();Pt();Ft();Oe();xt();lr();var Gue=[{key:"resourceId",header:"ID",format:Be},{key:"rate",header:"Rate"},{key:"rateApplicableFrom",header:"From"},{key:"rateApplicableTo",header:"To"}];function Vnt(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)",ze).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 je(n,a=>o2(i,o,a),{label:`Fetching ${o} rates`});Pe(s,Gue,n,`${o} Rates`)})(n)),e.command("add <currencyCode>").description("Add an exchange rate for a currency").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=>{Fe(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 s2(i,o,s);if(n.json||n.format){let c={data:[a.data],totalElements:1,totalPages:1,truncated:!1};Pe(c,Gue,n,`${o} Rates`)}else console.log(Y(`Rate added for ${o}: ${n.rate} (from ${n.from})`))})(n)),e.command("update <currencyCode> <rateResourceId>").description("Update an exchange rate").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=>{Fe(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 a2(o,s,n,a);if(i.json||i.format){let u={data:[c.data],totalElements:1,totalPages:1,truncated:!1};Pe(u,Gue,i,`${s} Rates`)}else console.log(Y(`Rate updated for ${s}: ${i.rate}`))})(i)),e.command("bulk-upsert").description("Create exchange rates in bulk (max 500). Auto-enables currencies not yet in the org.").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 c2(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}`))}}))}Hh();mt();Pt();Ft();Oe();import{readFileSync as tCr}from"node:fs";import{basename as Jnt,extname as rCr,resolve as nCr}from"node:path";var iCr=[{key:"resourceId",header:"ID",format:Be},{key:"fileName",header:"File Name"}],uf=["invoices","bills","journals","scheduled_journals","customer-credit-notes","supplier-credit-notes","sale-quotes","sale-orders","purchase-requests","purchase-orders"],oCr={".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 Wnt(t){let e=t.command("attachments").description("Manage transaction attachments");e.command("list").description("List attachments for a transaction").requiredOption("--type <type>",`Transaction type (${uf.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;uf.includes(i)||(console.error(ie(`Invalid type. Use one of: ${uf.join(", ")}`)),process.exit(1));let o=await ii(r,i,n.id),s=o.data??[],a={data:s,totalElements:o.totalElements??s.length,totalPages:o.totalPages??1,truncated:o.truncated??!1};Pe(a,iCr,n,"Attachments")})),e.command("add").description("Add an attachment to a transaction (file upload or URL download)").requiredOption("--type <type>",`Transaction type (${uf.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;uf.includes(i)||(console.error(ie(`Invalid type. Use one of: ${uf.join(", ")}`)),process.exit(1)),!n.attachmentId&&!n.url&&!n.file&&(console.error(ie("Provide --file, --url, or --attachment-id")),process.exit(1)),n.attachmentId&&SH.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=nCr(n.file),u=rCr(c).toLowerCase(),d=oCr[u]??"application/octet-stream",f=tCr(c);o=new Blob([f],{type:d}),s=Jnt(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=Jnt(f)||"attachment"}let a=await RH(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."))})),e.command("delete").description("Delete an attachment from a transaction").requiredOption("--type <type>",`Transaction type (${uf.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 uf.includes(i)||(console.error(ie(`Invalid type. Use one of: ${uf.join(", ")}`)),process.exit(1)),Q(async o=>{let s=await BH(o,i,n.id,r);n.json?console.log(JSON.stringify(s,null,2)):console.log(Y("Attachment deleted."))})(n)})}Oe();rD();dc();mt();xt();lr();Pt();Ft();ur();var Znt=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"taxRate",header:"Rate (%)"},{key:"taxTypeCode",header:"Tax Type"}],sCr=[{key:"code",header:"Code"},{key:"name",header:"Name"}];function Knt(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)",ze).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 je(n,o=>Fb(r,o),{label:"Fetching tax profiles"});Pe(i,Znt,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)",ze).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 je(n,o=>wL(r,o),{label:"Fetching tax types"});Pe(i,sCr,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 DL(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)),Ve({parent:e,fields:fS,defaults:pS,fetcher:Qb,columns:Znt,label:"Searching tax profiles"}),e.command("update <resourceId>").description("Update a tax profile").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 SL(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Tax profile updated: ${s.data.name}`))})(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 RL(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}):
1060
- `));for(let o of i.data)console.log(` ${Se(o.code??o.resourceId??"?")} ${o.description??""} ${G(o.countryCode??"")}`)}})),e.command("create").description("Create a new tax profile").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)=>{Fe(n,[{flag:"--name",key:"name"},{flag:"--rate",key:"rate"},{flag:"--tax-type-code",key:"taxTypeCode"}]);let i=await sM(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 _L(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))}))}Oe();PL();NY();dc();mt();xt();lr();Pt();Ft();ur();var Xnt=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"expenseAccountResourceId",header:"Expense Acct",format:Be}];function eit(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)",ze).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 je(n,o=>OL(r,o),{label:"Fetching claim types"});Pe(i,Xnt,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 FL(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)),Ve({parent:e,fields:KD,defaults:XD,fetcher:Mb,columns:Xnt,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)=>{Fe(n,[{flag:"--name",key:"name"}]);let i=await cM(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 QL(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,oy(Co(n.clear),iD));let s=await LL(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 ML(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim type deleted: ${r}`))})(n))}Oe();aD();NY();dc();mt();xt();lr();Pt();Ft();ur();var tit=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"taxMode",header:"Tax Mode"},{key:"employeeBalanceAccountResourceId",header:"Balance Acct",format:Be}];function rit(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=Co(t.visibleClaimTypes)),t.visibleTaxProfiles!==void 0&&(e.visibleTaxProfileIds=Co(t.visibleTaxProfiles)),t.visibleClassifiers!==void 0&&(e.visibleClassifierIds=Co(t.visibleClassifiers)),t.visibleVendors!==void 0&&(e.visibleVendorResourceIds=Co(t.visibleVendors)),t.allowedCurrencies!==void 0&&(e.allowedCurrencies=Co(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 nit(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",ar).option("--max-amount <n>","Max claim total",ar).option("--max-per-period <n>","Per-period spend cap (requires --per-period)",ar).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 iit(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)",ze).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 je(n,o=>UL(r,o),{label:"Fetching claim profiles"});Pe(i,tit,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 $L(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)),Ve({parent:e,fields:eS,defaults:tS,fetcher:Pb,columns:tit,label:"Searching claim profiles"}),nit(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)=>{Fe(n,[{flag:"--name",key:"name"}]);let i=await lM(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 qL(r,rit(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))})),nit(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=rit(n);Object.assign(o,oy(Co(n.clear),sD));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 YL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim profile deleted: ${r}`))})(n))}Oe();uD();dc();mt();xt();lr();Pt();Ft();ur();var oit=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"outerAxis",header:"Outer"},{key:"innerAxis",header:"Inner"},{key:"isDefault",header:"Default"}];function sit(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)",ze).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 je(n,o=>HL(r,o),{label:"Fetching posting rules"});Pe(i,oit,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)),Ve({parent:e,fields:rS,defaults:nS,fetcher:Ub,columns:oit,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)=>{Fe(n,[{flag:"--name",key:"name"},{flag:"--outer-axis",key:"outerAxis"},{flag:"--inner-axis",key:"innerAxis"},{flag:"--line-template",key:"lineTemplate"}]);let i=await uM(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 GL(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 VL(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 JL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Posting rule deleted: ${r}`))})(n))}Oe();HM();mue();Aue();l_();xH();mt();xt();Ft();xf();ur();import{randomUUID as aCr}from"node:crypto";import{readFileSync as ait,statSync as cCr}from"node:fs";import{basename as lCr,extname as uCr,resolve as cit}from"node:path";var dCr=[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"status",header:"Status"},{key:"employeeResourceId",header:"Employee",format:Be},{key:"totalAmount",header:"Amount"},{key:"currencyCode",header:"Ccy"}];function lit(t){let e=t.command("claims").description("Employee-expense claims: search, edit drafts, lifecycle, bulk actions");Ve({parent:e,fields:VD,defaults:JD,fetcher:SM,columns:dCr,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 RM(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=Co(s.tags)??[]),s.items!==void 0&&(c.claimItems=hu(s.items,"--items")),s.customFields!==void 0&&(c.customFields=hu(s.customFields,"--custom-fields")),s.submit&&(c.saveAsDraft=!1);let u=await BM(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=Co(a.tags)??[]),a.items!==void 0&&(u.claimItems=hu(a.items,"--items")),a.customFields!==void 0&&(u.customFields=hu(a.customFields,"--custom-fields")),a.submit&&(u.saveAsDraft=!1);let d=await xM(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 TM(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 kM(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",NM,"Submit a DRAFT claim for approval"],["approve",OM,"Approve a SUBMITTED claim"],["unpost",LM,"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",FM,"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=>{Fe(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",MM,"Bulk-submit DRAFT claims (async)"],["bulk-approve",PM,"Bulk-approve SUBMITTED claims (async)"],["bulk-delete",UM,"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)=>{Fe(d,[{flag:"--ids",key:"ids"}]);let f=await a(u,Co(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",$M,"Bulk-reject claims (async)"],["bulk-cancel",qM,"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)=>{Fe(d,[{flag:"--ids",key:"ids"},{flag:"--reason",key:"reason"}]);let f=await a(u,Co(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 jM(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 YM(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(Fe(a,[{flag:"--ids",key:"ids"}]),a.payoutFlow!==void 0&&!Ux.includes(a.payoutFlow))throw new Error(`--payout-flow must be one of: ${Ux.join(", ")}`);let c=await TH(s,{claimResourceIds:Co(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)=>{Fe(a,[{flag:"--ids",key:"ids"},{flag:"--value-date",key:"valueDate"}]);let c=await kH(s,{claimResourceIds:Co(a.ids)??[],valueDate:a.valueDate,postingRuleResourceId:a.postingRule,includeReimbursementPayout:a.includePayout,bankAccountResourceIdOverride:a.bankAccount,idempotencyKey:a.idempotencyKey||aCr()});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)",ar).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)=>{Fe(a,[{flag:"--employee",key:"employee"},{flag:"--amount",key:"amount"},{flag:"--payment-account",key:"paymentAccount"},{flag:"--value-date",key:"valueDate"}]);let c=await NH(s,{employeeResourceId:a.employee,amount:a.amount,paymentAccountResourceId:a.paymentAccount,valueDate:a.valueDate,payoutFor:a.payoutFor,currencyCode:a.currency,reference:a.reference||Pa("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}`))})),Ve({parent:e,commandName:"payouts",fields:WD,defaults:ZD,fetcher:OH,columns:[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"employeeResourceId",header:"Employee",format:Be},{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=cit(a.file),m=uCr(h).toLowerCase();if(!cd.has(m))throw new Error(`unsupported file type "${m}". Supported: ${[...cd].join(", ")}`);let A=25*1024*1024,g=cCr(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([ait(h)],{type:jm(m)}),d=lCr(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("@")?ait(cit(a.html.slice(1)),"utf8"):a.html);let p=await ab(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))}))}Oe();dD();dc();mt();xt();Ft();ur();var uit=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"email",header:"Email"},{key:"employmentType",header:"Type"},{key:"active",header:"Active"}];function dit(t){let e=t.command("employees").description("Manage employees (expense-claim members): CRUD, balances, bind-user, import");Ve({parent:e,fields:iS,defaults:oS,fetcher:$b,columns:uit,label:"Searching employees"}),Ve({parent:e,commandName:"balances",fields:sS,defaults:aS,fetcher:WL,columns:uit,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 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("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(Fe(n,[{flag:"--name",key:"name"},{flag:"--user",key:"user"}]),n.email){let o=await dM(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 KL(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 XL(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 eM(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 tM(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 rM(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=hu(n.create,"--create")),n.update!==void 0&&(i.update=hu(n.update,"--update")),n.delete!==void 0&&(i.delete=hu(n.delete,"--delete"));let o=await nM(r,i);n.json?console.log(JSON.stringify(o.data,null,2)):console.log(Y(`Queued employee import \u2014 jobId ${o.data?.jobId??"?"}`))}))}cue();mt();xt();lr();Pt();Ft();Oe();var fCr=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"categoryCode",header:"Category"},{key:"value",header:"Value"}];function fit(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)",ze).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 je(n,o=>cH(r,o),{label:"Fetching bookmarks"});Pe(i,fCr,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 lH(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 Mx(r,i.items??[i]):(Fe(n,[{flag:"--name",key:"name"},{flag:"--value",key:"value"},{flag:"--category",key:"category"}]),o=await Mx(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(` ${Se(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 uH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`Bookmark updated: ${a.data.name}`))})(n))}fH();mt();xt();Pt();lr();Ft();Oe();var pCr=[{key:"resourceId",header:"ID",format:Be},{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:pp}];function pit(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)").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]:(Fe(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 gv(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?G(` (${d.errorCode})`):""}`);else{let p=[d.replayed&&"replayed",d.duplicateCount&&`${d.duplicateCount} similar`].filter(Boolean).join(", ");console.log(` ${Se(d.resourceId??"")}${p?G(` ${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)",ze).option("--created-to <epochMs>","Created-at upper bound, epoch ms (inclusive)",ze).option("--stats","Include per-credential disposition counts").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",ze).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}},o,s=await je(n,async a=>{let c=await dH(r,{limit:a.limit,offset:a.offset,...Object.keys(i).length?{filter:i}:{},...n.stats&&{includeStats:!0}});return o??=c.stats,c},{label:"Fetching jots"});if(Pe(o?.length?{...s,stats:o}:s,pCr,n,"Jots"),n.stats&&o?.length&&!wd(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=>{Fe(n,[{flag:"--verb",key:"verb"}]);let s=(await brt(i,r,{verb:n.verb,...n.note&&{note:n.note}})).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(Y(`Disposition recorded: ${s.verb} on ${s.jotResourceId}`)),s.rollbackHandoff&&console.log(G(" Rollback handoff pointer returned: execution lives in the rollback module.")))})(n))}lue();ED();mt();xt();lr();Pt();Ft();Oe();ur();function Hz(t,e){return r=>{let n=r.toUpperCase();if(!t.includes(n))throw new Error(`Invalid ${e}: ${r}. Allowed: ${t.join(", ")}`);return n}}function hit(t){return Zb.map(e=>({moduleName:e,roleCode:t}))}var mit=[{key:"resourceId",header:"ID",format:Be},{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 Ait(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)",ze).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 je(n,o=>pH(r,o),{label:"Fetching org users"});Pe(i,mit,n,"Org Users")})),Ve({parent:e,fields:bS,defaults:CS,fetcher:hH,columns:mit,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("--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)",Hz(NA,"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.",Hz(kA,"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 yv(r,i);else{Fe(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 yv(r,{firstName:n.firstName,lastName:n.lastName,email:n.email,userType:a,...a==="CUSTOM_USER"?{moduleRoles:hit(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))})),e.command("update <resourceId>").description("Update a user's access tier and/or module roles").option("--user-type <type>","ADMIN | CUSTOM_USER (default: derived from --role)",Hz(NA,"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.",Hz(kA,"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:hit(c)}:{}}}let a=await mH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`User updated: ${a.data.firstName} ${a.data.lastName}`))})(n)),e.command("remove <resourceId>").description("Remove a user from the organization").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await AH(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`User ${r} removed.`))})(n))}Oe();Lx();ur();Ft();var hCr=[{key:"resourceId",header:"ID",format:Be},{key:"transactionReference",header:"Reference",format:Pn},{key:"direction",header:"Dir",format:pL},{key:"valueDate",header:"Date",format:pp},{key:"totalAmount",header:"Amount",align:"right"},{key:"currencyCode",header:"Ccy"},{key:"businessTransactionType",header:"Type",format:t=>G(String(t??""))}];function git(t){let e=t.command("cashflow").description("Search cashflow transactions");Ve({parent:e,fields:Rd,defaults:Bd,fetcher:Yh,columns:hCr,label:"Searching cashflow"})}function yit(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)})}Oe();mt();xt();qo();zle();sue();Hle();function $a(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("--json","Output as JSON").option("--api-key <key>","API key override")}function qa(t,e){return async r=>{try{let n=e(r);if(r.plan){let s=Av(t,n);r.json?console.log(JSON.stringify(s,null,2)):mCr(s);return}let i=Nx(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=Av(t,n);u||process.stderr.write(G(` Auto-resolving accounts from chart of accounts...
1060
+ `));for(let o of i.data)console.log(` ${Se(o.code??o.resourceId??"?")} ${o.description??""} ${G(o.countryCode??"")}`)}})),e.command("create").description("Create a new tax profile").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)=>{Fe(n,[{flag:"--name",key:"name"},{flag:"--rate",key:"rate"},{flag:"--tax-type-code",key:"taxTypeCode"}]);let i=await sM(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 _L(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))}))}Oe();PL();NY();dc();mt();xt();lr();Pt();Ft();ur();var Xnt=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"expenseAccountResourceId",header:"Expense Acct",format:Be}];function eit(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)",ze).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 je(n,o=>OL(r,o),{label:"Fetching claim types"});Pe(i,Xnt,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 FL(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)),Ve({parent:e,fields:KD,defaults:XD,fetcher:Mb,columns:Xnt,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)=>{Fe(n,[{flag:"--name",key:"name"}]);let i=await cM(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 QL(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,oy(Co(n.clear),iD));let s=await LL(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 ML(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim type deleted: ${r}`))})(n))}Oe();aD();NY();dc();mt();xt();lr();Pt();Ft();ur();var tit=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"taxMode",header:"Tax Mode"},{key:"employeeBalanceAccountResourceId",header:"Balance Acct",format:Be}];function rit(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=Co(t.visibleClaimTypes)),t.visibleTaxProfiles!==void 0&&(e.visibleTaxProfileIds=Co(t.visibleTaxProfiles)),t.visibleClassifiers!==void 0&&(e.visibleClassifierIds=Co(t.visibleClassifiers)),t.visibleVendors!==void 0&&(e.visibleVendorResourceIds=Co(t.visibleVendors)),t.allowedCurrencies!==void 0&&(e.allowedCurrencies=Co(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 nit(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",ar).option("--max-amount <n>","Max claim total",ar).option("--max-per-period <n>","Per-period spend cap (requires --per-period)",ar).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 iit(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)",ze).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 je(n,o=>UL(r,o),{label:"Fetching claim profiles"});Pe(i,tit,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 $L(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)),Ve({parent:e,fields:eS,defaults:tS,fetcher:Pb,columns:tit,label:"Searching claim profiles"}),nit(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)=>{Fe(n,[{flag:"--name",key:"name"}]);let i=await lM(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 qL(r,rit(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))})),nit(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=rit(n);Object.assign(o,oy(Co(n.clear),sD));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 YL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Claim profile deleted: ${r}`))})(n))}Oe();uD();dc();mt();xt();lr();Pt();Ft();ur();var oit=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"outerAxis",header:"Outer"},{key:"innerAxis",header:"Inner"},{key:"isDefault",header:"Default"}];function sit(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)",ze).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 je(n,o=>HL(r,o),{label:"Fetching posting rules"});Pe(i,oit,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)),Ve({parent:e,fields:rS,defaults:nS,fetcher:Ub,columns:oit,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)=>{Fe(n,[{flag:"--name",key:"name"},{flag:"--outer-axis",key:"outerAxis"},{flag:"--inner-axis",key:"innerAxis"},{flag:"--line-template",key:"lineTemplate"}]);let i=await uM(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 GL(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 VL(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 JL(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Posting rule deleted: ${r}`))})(n))}Oe();HM();mue();Aue();l_();xH();mt();xt();Ft();xf();ur();import{randomUUID as aCr}from"node:crypto";import{readFileSync as ait,statSync as cCr}from"node:fs";import{basename as lCr,extname as uCr,resolve as cit}from"node:path";var dCr=[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"status",header:"Status"},{key:"employeeResourceId",header:"Employee",format:Be},{key:"totalAmount",header:"Amount"},{key:"currencyCode",header:"Ccy"}];function lit(t){let e=t.command("claims").description("Employee-expense claims: search, edit drafts, lifecycle, bulk actions");Ve({parent:e,fields:VD,defaults:JD,fetcher:SM,columns:dCr,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 RM(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=Co(s.tags)??[]),s.items!==void 0&&(c.claimItems=hu(s.items,"--items")),s.customFields!==void 0&&(c.customFields=hu(s.customFields,"--custom-fields")),s.submit&&(c.saveAsDraft=!1);let u=await BM(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=Co(a.tags)??[]),a.items!==void 0&&(u.claimItems=hu(a.items,"--items")),a.customFields!==void 0&&(u.customFields=hu(a.customFields,"--custom-fields")),a.submit&&(u.saveAsDraft=!1);let d=await xM(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 TM(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 kM(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",NM,"Submit a DRAFT claim for approval"],["approve",OM,"Approve a SUBMITTED claim"],["unpost",LM,"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",FM,"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=>{Fe(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",MM,"Bulk-submit DRAFT claims (async)"],["bulk-approve",PM,"Bulk-approve SUBMITTED claims (async)"],["bulk-delete",UM,"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)=>{Fe(d,[{flag:"--ids",key:"ids"}]);let f=await a(u,Co(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",$M,"Bulk-reject claims (async)"],["bulk-cancel",qM,"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)=>{Fe(d,[{flag:"--ids",key:"ids"},{flag:"--reason",key:"reason"}]);let f=await a(u,Co(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 jM(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 YM(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(Fe(a,[{flag:"--ids",key:"ids"}]),a.payoutFlow!==void 0&&!Ux.includes(a.payoutFlow))throw new Error(`--payout-flow must be one of: ${Ux.join(", ")}`);let c=await TH(s,{claimResourceIds:Co(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)=>{Fe(a,[{flag:"--ids",key:"ids"},{flag:"--value-date",key:"valueDate"}]);let c=await kH(s,{claimResourceIds:Co(a.ids)??[],valueDate:a.valueDate,postingRuleResourceId:a.postingRule,includeReimbursementPayout:a.includePayout,bankAccountResourceIdOverride:a.bankAccount,idempotencyKey:a.idempotencyKey||aCr()});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)",ar).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)=>{Fe(a,[{flag:"--employee",key:"employee"},{flag:"--amount",key:"amount"},{flag:"--payment-account",key:"paymentAccount"},{flag:"--value-date",key:"valueDate"}]);let c=await NH(s,{employeeResourceId:a.employee,amount:a.amount,paymentAccountResourceId:a.paymentAccount,valueDate:a.valueDate,payoutFor:a.payoutFor,currencyCode:a.currency,reference:a.reference||Pa("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}`))})),Ve({parent:e,commandName:"payouts",fields:WD,defaults:ZD,fetcher:OH,columns:[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"employeeResourceId",header:"Employee",format:Be},{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=cit(a.file),m=uCr(h).toLowerCase();if(!cd.has(m))throw new Error(`unsupported file type "${m}". Supported: ${[...cd].join(", ")}`);let A=25*1024*1024,g=cCr(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([ait(h)],{type:jm(m)}),d=lCr(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("@")?ait(cit(a.html.slice(1)),"utf8"):a.html);let p=await ab(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))}))}Oe();dD();dc();mt();xt();Ft();ur();var uit=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"email",header:"Email"},{key:"employmentType",header:"Type"},{key:"active",header:"Active"}];function dit(t){let e=t.command("employees").description("Manage employees (expense-claim members): CRUD, balances, bind-user, import");Ve({parent:e,fields:iS,defaults:oS,fetcher:$b,columns:uit,label:"Searching employees"}),Ve({parent:e,commandName:"balances",fields:sS,defaults:aS,fetcher:WL,columns:uit,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 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("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(Fe(n,[{flag:"--name",key:"name"},{flag:"--user",key:"user"}]),n.email){let o=await dM(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 KL(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 XL(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 eM(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 tM(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 rM(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=hu(n.create,"--create")),n.update!==void 0&&(i.update=hu(n.update,"--update")),n.delete!==void 0&&(i.delete=hu(n.delete,"--delete"));let o=await nM(r,i);n.json?console.log(JSON.stringify(o.data,null,2)):console.log(Y(`Queued employee import \u2014 jobId ${o.data?.jobId??"?"}`))}))}cue();mt();xt();lr();Pt();Ft();Oe();var fCr=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"categoryCode",header:"Category"},{key:"value",header:"Value"}];function fit(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)",ze).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 je(n,o=>cH(r,o),{label:"Fetching bookmarks"});Pe(i,fCr,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 lH(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 Mx(r,i.items??[i]):(Fe(n,[{flag:"--name",key:"name"},{flag:"--value",key:"value"},{flag:"--category",key:"category"}]),o=await Mx(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(` ${Se(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 uH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`Bookmark updated: ${a.data.name}`))})(n))}fH();mt();xt();Pt();lr();Ft();Oe();var pCr=[{key:"resourceId",header:"ID",format:Be},{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:pp}];function pit(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)").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]:(Fe(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 gv(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?G(` (${d.errorCode})`):""}`);else{let p=[d.replayed&&"replayed",d.duplicateCount&&`${d.duplicateCount} similar`].filter(Boolean).join(", ");console.log(` ${Se(d.resourceId??"")}${p?G(` ${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)",ze).option("--created-to <epochMs>","Created-at upper bound, epoch ms (inclusive)",ze).option("--stats","Include per-credential disposition counts").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",ze).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}},o,s=await je(n,async a=>{let c=await dH(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(Pe(o?.length?{...s,stats:o}:s,pCr,n,"Jots"),n.stats&&o?.length&&!wd(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=>{Fe(n,[{flag:"--verb",key:"verb"}]);let s=(await brt(i,r,{verb:n.verb,...n.note&&{note:n.note}})).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(Y(`Disposition recorded: ${s.verb} on ${s.jotResourceId}`)),s.rollbackHandoff&&console.log(G(" Rollback handoff pointer returned: execution lives in the rollback module.")))})(n))}lue();ED();mt();xt();lr();Pt();Ft();Oe();ur();function Hz(t,e){return r=>{let n=r.toUpperCase();if(!t.includes(n))throw new Error(`Invalid ${e}: ${r}. Allowed: ${t.join(", ")}`);return n}}function hit(t){return Zb.map(e=>({moduleName:e,roleCode:t}))}var mit=[{key:"resourceId",header:"ID",format:Be},{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 Ait(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)",ze).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 je(n,o=>pH(r,o),{label:"Fetching org users"});Pe(i,mit,n,"Org Users")})),Ve({parent:e,fields:bS,defaults:CS,fetcher:hH,columns:mit,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("--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)",Hz(NA,"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.",Hz(kA,"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 yv(r,i);else{Fe(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 yv(r,{firstName:n.firstName,lastName:n.lastName,email:n.email,userType:a,...a==="CUSTOM_USER"?{moduleRoles:hit(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))})),e.command("update <resourceId>").description("Update a user's access tier and/or module roles").option("--user-type <type>","ADMIN | CUSTOM_USER (default: derived from --role)",Hz(NA,"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.",Hz(kA,"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:hit(c)}:{}}}let a=await mH(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`User updated: ${a.data.firstName} ${a.data.lastName}`))})(n)),e.command("remove <resourceId>").description("Remove a user from the organization").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await AH(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`User ${r} removed.`))})(n))}Oe();Lx();ur();Ft();var hCr=[{key:"resourceId",header:"ID",format:Be},{key:"transactionReference",header:"Reference",format:Pn},{key:"direction",header:"Dir",format:pL},{key:"valueDate",header:"Date",format:pp},{key:"totalAmount",header:"Amount",align:"right"},{key:"currencyCode",header:"Ccy"},{key:"businessTransactionType",header:"Type",format:t=>G(String(t??""))}];function git(t){let e=t.command("cashflow").description("Search cashflow transactions");Ve({parent:e,fields:Rd,defaults:Bd,fetcher:Yh,columns:hCr,label:"Searching cashflow"})}function yit(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)})}Oe();mt();xt();qo();zle();sue();Hle();function $a(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("--json","Output as JSON").option("--api-key <key>","API key override")}function qa(t,e){return async r=>{try{let n=e(r);if(r.plan){let s=Av(t,n);r.json?console.log(JSON.stringify(s,null,2)):mCr(s);return}let i=Nx(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=Av(t,n);u||process.stderr.write(G(` Auto-resolving accounts from chart of accounts...
1061
1061
  `)),d=await f1e(s,h.plan.requiredAccounts,{silent:u})}if(a.contact){let h=await mi(s,a.contact,{silent:u});a.contact=h.resourceId}if(a.bankAccount){let h=await yM(s,a.bankAccount,{silent:u});a.bankAccount=h.resourceId}let p=await sH(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)):ACr(p)})(r)}catch(n){throw(n instanceof Yt||n instanceof Error&&n.message.includes("blueprint"))&&(console.error(ie("Error: "+n.message)),process.exit(1)),n}}}function mCr(t){console.log(R(`
1062
1062
  Capsule Transaction Plan: `+t.recipe+`
1063
1063
  `)),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.2",
3
+ "version": "5.24.4",
4
4
  "description": "Clio: Command Line Interface Operator for Jaz AI.",
5
5
  "type": "module",
6
6
  "bin": {