jaz-clio 5.4.0 → 5.4.2

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,4 +1,4 @@
1
- Auto-generated from [help.jaz.ai](https://help.jaz.ai) — 2026-05-04 — 186 articles
1
+ Auto-generated from [help.jaz.ai](https://help.jaz.ai) — 2026-05-11 — 186 articles
2
2
 
3
3
  | Section | Articles | File |
4
4
  |---|---|---|
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-cli
3
- version: 5.4.0
3
+ version: 5.4.2
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.4.0
3
+ version: 5.4.2
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-jobs
3
- version: 5.4.0
3
+ version: 5.4.2
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-practice
3
- version: 5.4.0
3
+ version: 5.4.2
4
4
  description: >-
5
5
  Use this skill whenever an accounting practitioner is doing client work in
6
6
  Jaz — closing the books, filing GST, year-end statutory, onboarding a new
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-recipes
3
- version: 5.4.0
3
+ version: 5.4.2
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
@@ -433,7 +433,7 @@ ${a}`)}throw new Error(`No bank account matching "${e}".
433
433
 
434
434
  Available accounts:
435
435
  ${s}`)}var jM={".pdf":"application/pdf",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".csv":"text/csv",".ofx":"application/x-ofx"};async function MM(e){let{plan:t,client:r,bankAccountId:n,onProgress:o}=e,i=t.folders.flatMap(a=>a.files.filter(c=>c.documentType==="INVOICE"||c.documentType==="BILL"||c.documentType==="CUSTOMER_CREDIT_NOTE"||c.documentType==="SUPPLIER_CREDIT_NOTE"||c.documentType==="BANK_STATEMENT")),s=[];for(let a=0;a<i.length;a++){let c=i[a],u=c.documentType,l;try{let d=c.absolutePath;c.encrypted&&c.filePassword&&(l=Sd(c.absolutePath,c.filePassword),d=l);let f=yoe(d),p=Doe(c.filename).toLowerCase(),m=jM[p];if(!m)throw new Error(`Unsupported file extension "${p}" \u2014 expected one of: ${Object.keys(jM).join(", ")}`);let h=new Blob([f],{type:m}),g;u==="BANK_STATEMENT"?g=(await Wc(r,{businessTransactionType:u,accountResourceId:n,sourceFile:h,sourceFileName:c.filename})).data:g=(await is(r,{businessTransactionType:u,sourceFile:h,sourceFileName:c.filename})).data;let D={file:`${c.folder}/${c.filename}`,type:u,status:"uploaded",response:g};s.push(D),o?.(D,a,i.length)}catch(d){let f=d instanceof Error?d.message:String(d),p={file:`${c.folder}/${c.filename}`,type:u,status:"failed",error:f};s.push(p),o?.(p,a,i.length)}finally{l&&zc(l)}}return{total:i.length,success:s.filter(a=>a.status==="uploaded").length,failed:s.filter(a=>a.status==="failed").length,results:s}}K();var boe={dropbox:"Dropbox",gdrive:"Google Drive",onedrive:"OneDrive"};function BM(e,t){console.log(),console.log(_(t)),console.log(bn(`Source: ${e.source}`)),e.sourceType==="url"&&e.cloudProvider&&(console.log(bn(`Provider: ${boe[e.cloudProvider]??e.cloudProvider}`)),console.log(bn(`Local path: ${e.localPath}`))),console.log()}function UM(e){for(let t of e.folders){let r=t.documentType==="UNKNOWN"?V("UNKNOWN \u2014 requires classification"):T(t.documentType),n=t.documentType==="UNKNOWN"?V("[!] "):" ";console.log(`${n}${_(t.folder)}/ (${t.count} files \u2192 ${r})`);let o=t.files.map(s=>s.encrypted&&s.filePassword?`${s.filename} ${T("(pw)")}`:s.encrypted?`${s.filename} ${V("(encrypted)")}`:s.filename),i=o.slice(0,8);console.log(bn(` ${i.join(", ")}${o.length>8?`, ... and ${o.length-8} more`:""}`)),console.log()}}function voe(e){if(console.log(_("Summary")),console.log(` Total files: ${e.summary.total}`),console.log(` Uploadable: ${T(String(e.summary.uploadable))}`),e.summary.needClassification>0&&console.log(` Need classification: ${V(String(e.summary.needClassification))}`),e.summary.skipped>0&&console.log(` Skipped: ${bn(String(e.summary.skipped))}`),e.summary.encrypted>0){let t=e.folders.flatMap(o=>o.files).filter(o=>o.encrypted&&o.filePassword).length,r=e.summary.encrypted-t,n=[];t>0&&n.push(T(`${t} password from filename`)),r>0&&n.push(V(`${r} need __pw__<password> in filename`)),console.log(` Encrypted: ${e.summary.encrypted} (${n.join(", ")})`)}if(Object.keys(e.summary.byType).length>0){console.log();for(let[t,r]of Object.entries(e.summary.byType))console.log(` ${t}: ${r}`)}}function qM(e){BM(e,"Document Collection \u2014 Ingestion Plan"),UM(e),voe(e),console.log()}function zM(e){console.log(JSON.stringify(e,null,2))}function YM(e,t,r){let n=e.status==="uploaded"?T("\u2713"):N("\u2717"),o=e.status==="uploaded"?e.type.toLowerCase():N(`failed: ${e.error}`);process.stderr.write(` ${n} [${t+1}/${r}] ${e.file} \u2192 ${o}
436
- `)}function JM(e){BM(e,"Document Collection \u2014 Ingest + Upload"),UM(e),console.log(_("Upload Results"));let{upload:t}=e;if(t.total===0)console.log(V(" No files to upload."));else{console.log(` ${T(String(t.success))} uploaded, ${t.failed>0?N(String(t.failed)):"0"} failed`);let r=t.results.filter(n=>n.status==="failed");if(r.length>0){console.log(),console.log(N(" Failed:"));for(let n of r)console.log(N(` ${n.file}: ${n.error}`))}}console.log()}function GM(e){console.log(JSON.stringify(e,null,2))}async function Gr(e,t,r,n){return e.post(t,{[r]:n})}function cr(e,t,r=500,n=t){if(!Array.isArray(e))throw new Error(`${t} must be an array.`);if(e.length===0)throw new Error(`${t} array is empty.`);if(e.length>r)throw new Error(`max ${r} ${n} per call. Split into batches.`)}var Soe=/^\d{4}-\d{2}-\d{2}$/;function no(e,t){e.forEach((r,n)=>{if(!r||typeof r!="object")return;let o=r;if("dateFormat"in o)throw new Error(`row ${n}: dateFormat field is no longer supported (ISO 8601 YYYY-MM-DD only)`);for(let i of t){let s=o[i];if(s!=null&&(typeof s!="string"||!Soe.test(s)))throw new Error(`row ${n}: ${i} must be YYYY-MM-DD (got ${JSON.stringify(s)})`)}})}async function xy(e,t){return e.list("/api/v1/bills",t)}async function oo(e,t){return e.get(`/api/v1/bills/${t}`)}async function ss(e,t){return e.search("/api/v1/bills/search",t)}async function Ca(e,t){return e.post("/api/v1/bills",{...t,saveAsDraft:t.saveAsDraft??!0})}async function wy(e,t,r){return e.put(`/api/v1/bills/${t}`,r)}async function Cd(e,t,r){return e.put(`/api/v1/bills/${t}`,{...r,resourceId:t,saveAsDraft:!1})}async function Ty(e,t){await e.delete(`/api/v1/bills/${t}`)}async function Ad(e,t,r){return e.post(`/api/v1/bills/${t}/payments`,{...r,saveAsDraft:r.saveAsDraft??!0})}async function Oy(e,t,r){return e.post(`/api/v1/bills/${t}/credits`,{credits:r})}async function xd(e,t){return e.post("/api/v1/scheduled/bills",t)}async function $y(e,t){let r=await e.get(`/api/v1/bills/${t}/payments`);return{data:Array.isArray(r)?r:r.data??[]}}async function Ry(e,t){let r=await e.get(`/api/v1/bills/${t}/credits`);return{data:Array.isArray(r)?r:r.data??[]}}async function Ny(e,t,r){await e.delete(`/api/v1/bills/${t}/credits/${r}`)}async function ky(e,t){return Gr(e,"/api/v1/bills/bulk-upsert","bills",t)}async function Fy(e,t){return Gr(e,"/api/v1/bills/line-items/bulk-upsert","bills",t)}async function VM(e,t,r){return e.get(`/api/v1/contacts/${t}/signals`,{btType:r})}async function as(e,t){return e.list("/api/v1/contacts",t)}async function qn(e,t){return e.search("/api/v1/contacts/search",t)}async function Zc(e,t){return e.post("/api/v1/contacts",t)}async function Py(e,t,r){return e.put(`/api/v1/contacts/${t}`,r)}async function Aa(e,t){return e.get(`/api/v1/contacts/${t}`)}async function Ly(e,t){await e.delete(`/api/v1/contacts/${t}`)}async function jy(e,t){return Gr(e,"/api/v1/contacts/bulk-upsert","contacts",t)}ts();Kc();Te();K();async function WD(e,t){return e.list("/api/v1/items",t)}async function mp(e,t){return e.get(`/api/v1/items/${t}`)}async function hu(e,t){return e.search("/api/v1/items/search",t)}async function hp(e,t){let r={...t};return t.appliesToSale&&!r.saleItemName&&(r.saleItemName=t.internalName),t.appliesToPurchase&&!r.purchaseItemName&&(r.purchaseItemName=t.internalName),e.post("/api/v1/items",r)}async function ZD(e,t,r){let o=(await mp(e,t)).data,i={itemCode:o.itemCode,internalName:o.internalName,appliesToSale:o.appliesToSale,appliesToPurchase:o.appliesToPurchase};return o.appliesToSale&&(o.saleItemName&&(i.saleItemName=o.saleItemName),o.salePrice!==void 0&&(i.salePrice=o.salePrice),o.saleAccountResourceId&&(i.saleAccountResourceId=o.saleAccountResourceId)),o.appliesToPurchase&&(o.purchaseItemName&&(i.purchaseItemName=o.purchaseItemName),o.purchasePrice!==void 0&&(i.purchaseItemPrice=o.purchasePrice),o.purchaseAccountResourceId&&(i.purchaseAccountResourceId=o.purchaseAccountResourceId)),Object.assign(i,r),e.put(`/api/v1/items/${t}`,i)}async function KD(e,t){await e.delete(`/api/v1/items/${t}`)}async function XD(e,t){return e.post("/api/v1/items/bulk-upsert",{items:t})}async function gu(e){return e.get("/api/v1/capsuleTypes")}async function gp(e,t){return e.post("/api/v1/capsuleTypes",t)}async function QD(e,t){return e.list("/api/v1/capsules",t)}async function yu(e,t){return e.search("/api/v1/capsules/search",t)}async function yp(e,t){return e.get(`/api/v1/capsules/${t}`)}async function Pa(e,t){return e.post("/api/v1/capsules",t)}async function eb(e,t,r){let n=await yp(e,t),o=n.data.capsuleType?.resourceId;if(!o)throw new Error(`Cannot update capsule ${t}: missing capsuleType.resourceId from GET response`);let i={resourceId:t,capsuleTypeResourceId:o,title:n.data.title,description:n.data.description,...r};return e.put(`/api/v1/capsules/${t}`,i)}async function tb(e,t){await e.delete(`/api/v1/capsules/${t}`)}async function Du(e,t){return e.list("/api/v1/tax-profiles",t)}async function rb(e,t){return e.list("/api/v1/tax-types",t)}async function nb(e,t){return e.post("/api/v1/tax-profiles",t)}async function bu(e,t){return e.post("/api/v1/tax-profiles/search",t)}async function ob(e,t){return e.get(`/api/v1/tax-profiles/${t}`)}async function ib(e,t,r){return e.put(`/api/v1/tax-profiles/${t}`,r)}async function sb(e){let t=await e.get("/api/v1/withholding-tax-codes");return{data:Array.isArray(t)?t:t.data??[]}}async function vu(e,t){return e.list("/api/v1/tags",t)}async function ab(e,t){return e.get(`/api/v1/tags/${t}`)}async function cb(e,t){return e.search("/api/v1/tags/search",t)}async function Dp(e,t){return e.post("/api/v1/tags",t)}async function ub(e,t,r){return e.put(`/api/v1/tags/${t}`,r)}async function lb(e,t){await e.delete(`/api/v1/tags/${t}`)}async function bp(e,t){return t?((await qn(e,{filter:{name:{eq:t}},limit:5}))?.data??[]).find(n=>n.name===t):void 0}async function db(e,t){return t?((await hu(e,{filter:{itemCode:{eq:t}},limit:5}))?.data??[]).find(n=>n.itemCode===t):void 0}var fde={"current assets":"Current Asset","current asset":"Current Asset","fixed assets":"Fixed Asset","fixed asset":"Fixed Asset","bank account":"Bank Accounts","bank accounts":"Bank Accounts",bank:"Bank Accounts","current liabilities":"Current Liability","current liability":"Current Liability","non-current liabilities":"Non-current Liability","non-current liability":"Non-current Liability",equity:"Shareholders Equity","shareholders equity":"Shareholders Equity","shareholders' equity":"Shareholders Equity","shareholder's equity":"Shareholders Equity",revenue:"Operating Revenue","operating revenue":"Operating Revenue","other revenue":"Other Revenue","other income":"Other Revenue",expense:"Operating Expense","operating expense":"Operating Expense",expenses:"Operating Expense","direct costs":"Direct Costs","cost of goods sold":"Direct Costs",cogs:"Direct Costs",cash:"Cash",inventory:"Inventory","discontinued expense":"Discontinued Expense","discontinued income":"Discontinued Income","finance cost":"Finance Cost","finance costs":"Finance Cost","financing income":"Financing Income",goodwill:"Goodwill","income tax expense":"Income Tax Expense","income tax":"Income Tax Expense","tax expense":"Income Tax Expense","investing expense":"Investing Expense","investing income":"Investing Income",investment:"Investment",investments:"Investment"};function Su(e){if(typeof e!="string")return String(e??"");let t=e.trim();return fde[t.toLowerCase()]??t}async function t3(e,t){if(!t?.trim())return;let r=t.trim().toLowerCase();return((await yu(e,{filter:{title:{contains:t.trim()}},limit:20}))?.data??[]).find(o=>o.title?.trim().toLowerCase()===r)}async function pb(e,t){return t?((await _u(e,{filter:{name:{eq:t}},limit:5}))?.data??[]).find(n=>n.name===t):void 0}async function fb(e,t){return t?((await bu(e,{filter:{name:{eq:t}},limit:5}))?.data??[]).find(n=>n.name===t):void 0}async function mb(e,t){if(!t)return;let r=t.toLowerCase().trim();return((await vu(e,{limit:500}))?.data??[]).find(o=>o.name.toLowerCase().trim()===r)}var mde=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function r3(e,t,r){if(!mde.test(e))throw new Error(`${t} must be a valid UUID (got "${e}"). ${r}`)}async function Oi(e,t){return e.list("/api/v1/chart-of-accounts",t)}async function _u(e,t){return e.search("/api/v1/chart-of-accounts/search",t)}async function n3(e,t){return e.get(`/api/v1/chart-of-accounts/${t}`)}async function vp(e,t){return e.post("/api/v1/chart-of-accounts",t)}async function o3(e,t,r){return e.put(`/api/v1/chart-of-accounts/${t}`,r)}var hde=["resourceId","code","name","accountType","currencyCode","description","status"];function hb(e){let t={};for(let r of hde){let n=e[r];n!=null&&(r==="accountType"&&typeof n=="string"?t.accountType=Su(n):t[r]=n)}return t}async function gb(e,t){return e.post("/api/v1/chart-of-accounts/bulk-upsert",{data:t})}async function yb(e,t){await e.delete(`/api/v1/chart-of-accounts/${t}`)}FD();function Eu(e,t,r={}){let n=r.threshold??.4,o=r.limit??5,i=e.toLowerCase().trim(),s=t.find(c=>c.code?.toLowerCase()===i);if(s)return[{item:s,score:1}];let a=t.find(c=>c.name.toLowerCase()===i);return a?[{item:a,score:1}]:Ea(e,t,c=>c.name,{threshold:n,limit:o})}function Db(e,t){let r=Eu(e,t,{threshold:.45,limit:1});return r.length>0?r[0].item:null}function i3(e){return e.filter(t=>t.status==="ACTIVE"&&!t.controlFlag&&t.accountType!=="Bank Accounts"&&t.accountType!=="Cash")}function s3(e){return e.filter(t=>t.status==="ACTIVE"&&(t.accountType==="Bank Accounts"||t.accountType==="Cash"))}function bb(e,t,r={}){let n=r.threshold??.4,o=r.limit??5;return t.map(s=>{let a=[s.billingName,s.name].filter(Boolean),c=Math.max(...a.map(u=>DA(e,u)));return{item:s,score:c}}).filter(s=>s.score>=n).sort((s,a)=>a.score-s.score).slice(0,o)}var vb=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function La(e){return e.length>12?e.slice(0,8)+"-...":e}async function Vr(e,t,r){if(vb.test(t))return{resourceId:t,displayName:t};let n=t.trim(),i=(await qn(e,{filter:{name:{contains:n}},limit:50})).data;if(i.length===0&&(i=(await as(e,{offset:0,limit:500})).data),i.length===0)throw new Error("No contacts found. Create one in Jaz first.");let s=n.toLowerCase(),a=i.find(d=>d.billingName?.toLowerCase()===s||d.name?.toLowerCase()===s);if(a){let d=a.billingName||a.name||"Unknown";return r?.silent||process.stderr.write(C(` Contact: ${d} (${La(a.resourceId)})
436
+ `)}function JM(e){BM(e,"Document Collection \u2014 Ingest + Upload"),UM(e),console.log(_("Upload Results"));let{upload:t}=e;if(t.total===0)console.log(V(" No files to upload."));else{console.log(` ${T(String(t.success))} uploaded, ${t.failed>0?N(String(t.failed)):"0"} failed`);let r=t.results.filter(n=>n.status==="failed");if(r.length>0){console.log(),console.log(N(" Failed:"));for(let n of r)console.log(N(` ${n.file}: ${n.error}`))}}console.log()}function GM(e){console.log(JSON.stringify(e,null,2))}async function Gr(e,t,r,n){return e.post(t,{[r]:n})}function cr(e,t,r=500,n=t){if(!Array.isArray(e))throw new Error(`${t} must be an array.`);if(e.length===0)throw new Error(`${t} array is empty.`);if(e.length>r)throw new Error(`max ${r} ${n} per call. Split into batches.`)}var Soe=/^\d{4}-\d{2}-\d{2}$/;function no(e,t){e.forEach((r,n)=>{if(!r||typeof r!="object")return;let o=r;if("dateFormat"in o)throw new Error(`row ${n}: dateFormat field is no longer supported (ISO 8601 YYYY-MM-DD only)`);for(let i of t){let s=o[i];if(s!=null&&(typeof s!="string"||!Soe.test(s)))throw new Error(`row ${n}: ${i} must be YYYY-MM-DD (got ${JSON.stringify(s)})`)}})}async function xy(e,t){return e.list("/api/v1/bills",t)}async function oo(e,t){return e.get(`/api/v1/bills/${t}`)}async function ss(e,t){return e.search("/api/v1/bills/search",t)}async function Ca(e,t){return e.post("/api/v1/bills",{...t,saveAsDraft:t.saveAsDraft??!0})}async function wy(e,t,r){return e.put(`/api/v1/bills/${t}`,r)}async function Cd(e,t,r){return e.put(`/api/v1/bills/${t}`,{...r,resourceId:t,saveAsDraft:!1})}async function Ty(e,t){await e.delete(`/api/v1/bills/${t}`)}async function Ad(e,t,r){return e.post(`/api/v1/bills/${t}/payments`,{...r,saveAsDraft:r.saveAsDraft??!0})}async function Oy(e,t,r){return e.post(`/api/v1/bills/${t}/credits`,{credits:r})}async function xd(e,t){return e.post("/api/v1/scheduled/bills",t)}async function $y(e,t){let r=await e.get(`/api/v1/bills/${t}/payments`);return{data:Array.isArray(r)?r:r.data??[]}}async function Ry(e,t){let r=await e.get(`/api/v1/bills/${t}/credits`);return{data:Array.isArray(r)?r:r.data??[]}}async function Ny(e,t,r){await e.delete(`/api/v1/bills/${t}/credits/${r}`)}async function ky(e,t){return Gr(e,"/api/v1/bills/bulk-upsert","bills",t)}async function Fy(e,t){return Gr(e,"/api/v1/bills/line-items/bulk-upsert","bills",t)}async function VM(e,t,r){return e.get(`/api/v1/contacts/${t}/signals`,{btType:r})}async function as(e,t){return e.list("/api/v1/contacts",t)}async function qn(e,t){return e.search("/api/v1/contacts/search",t)}async function Zc(e,t){return e.post("/api/v1/contacts",t)}async function Py(e,t,r){return e.put(`/api/v1/contacts/${t}`,r)}async function Aa(e,t){return e.get(`/api/v1/contacts/${t}`)}async function Ly(e,t){await e.delete(`/api/v1/contacts/${t}`)}async function jy(e,t){return Gr(e,"/api/v1/contacts/bulk-upsert","contacts",t)}ts();Kc();Te();K();async function WD(e,t){return e.list("/api/v1/items",t)}async function mp(e,t){return e.get(`/api/v1/items/${t}`)}async function hu(e,t){return e.search("/api/v1/items/search",t)}async function hp(e,t){let r={...t};return t.appliesToSale&&!r.saleItemName&&(r.saleItemName=t.internalName),t.appliesToPurchase&&!r.purchaseItemName&&(r.purchaseItemName=t.internalName),e.post("/api/v1/items",r)}async function ZD(e,t,r){let o=(await mp(e,t)).data,i={itemCode:o.itemCode,internalName:o.internalName,appliesToSale:o.appliesToSale,appliesToPurchase:o.appliesToPurchase};return o.appliesToSale&&(o.saleItemName&&(i.saleItemName=o.saleItemName),o.salePrice!==void 0&&(i.salePrice=o.salePrice),o.saleAccountResourceId&&(i.saleAccountResourceId=o.saleAccountResourceId)),o.appliesToPurchase&&(o.purchaseItemName&&(i.purchaseItemName=o.purchaseItemName),o.purchasePrice!==void 0&&(i.purchaseItemPrice=o.purchasePrice),o.purchaseAccountResourceId&&(i.purchaseAccountResourceId=o.purchaseAccountResourceId)),Object.assign(i,r),e.put(`/api/v1/items/${t}`,i)}async function KD(e,t){await e.delete(`/api/v1/items/${t}`)}async function XD(e,t){return e.post("/api/v1/items/bulk-upsert",{items:t})}async function gu(e){return e.get("/api/v1/capsuleTypes")}async function gp(e,t){return e.post("/api/v1/capsuleTypes",t)}async function QD(e,t){return e.list("/api/v1/capsules",t)}async function yu(e,t){return e.search("/api/v1/capsules/search",t)}async function yp(e,t){return e.get(`/api/v1/capsules/${t}`)}async function Pa(e,t){return e.post("/api/v1/capsules",t)}async function eb(e,t,r){let n=await yp(e,t),o=n.data.capsuleType?.resourceId;if(!o)throw new Error(`Cannot update capsule ${t}: missing capsuleType.resourceId from GET response`);let i={resourceId:t,capsuleTypeResourceId:o,title:n.data.title,description:n.data.description,...r};return e.put(`/api/v1/capsules/${t}`,i)}async function tb(e,t){await e.delete(`/api/v1/capsules/${t}`)}async function Du(e,t){return e.list("/api/v1/tax-profiles",t)}async function rb(e,t){return e.list("/api/v1/tax-types",t)}async function nb(e,t){return e.post("/api/v1/tax-profiles",t)}async function bu(e,t){return e.post("/api/v1/tax-profiles/search",t)}async function ob(e,t){return e.get(`/api/v1/tax-profiles/${t}`)}async function ib(e,t,r){return e.put(`/api/v1/tax-profiles/${t}`,r)}async function sb(e){let t=await e.get("/api/v1/withholding-tax-codes");return{data:Array.isArray(t)?t:t.data??[]}}async function vu(e,t){return e.list("/api/v1/tags",t)}async function ab(e,t){return e.get(`/api/v1/tags/${t}`)}async function cb(e,t){return e.search("/api/v1/tags/search",t)}async function Dp(e,t){return e.post("/api/v1/tags",t)}async function ub(e,t,r){return e.put(`/api/v1/tags/${t}`,r)}async function lb(e,t){await e.delete(`/api/v1/tags/${t}`)}async function bp(e,t){return t?((await qn(e,{filter:{name:{eq:t}},limit:5}))?.data??[]).find(n=>n.name===t):void 0}async function db(e,t){return t?((await hu(e,{filter:{itemCode:{eq:t}},limit:5}))?.data??[]).find(n=>n.itemCode===t):void 0}var fde={"current assets":"Current Asset","current asset":"Current Asset","fixed assets":"Fixed Asset","fixed asset":"Fixed Asset","bank account":"Bank Accounts","bank accounts":"Bank Accounts",bank:"Bank Accounts","current liabilities":"Current Liability","current liability":"Current Liability","non-current liabilities":"Non-current Liability","non-current liability":"Non-current Liability",equity:"Shareholders Equity","shareholders equity":"Shareholders Equity","shareholders' equity":"Shareholders Equity","shareholder's equity":"Shareholders Equity",revenue:"Operating Revenue","operating revenue":"Operating Revenue","other revenue":"Other Revenue","other income":"Other Revenue",expense:"Operating Expense","operating expense":"Operating Expense",expenses:"Operating Expense","direct costs":"Direct Costs","cost of goods sold":"Direct Costs",cogs:"Direct Costs",cash:"Cash",inventory:"Inventory","discontinued expense":"Discontinued Expense","discontinued income":"Discontinued Income","finance cost":"Finance Cost","finance costs":"Finance Cost","financing income":"Financing Income",goodwill:"Goodwill","income tax expense":"Income Tax Expense","income tax":"Income Tax Expense","tax expense":"Income Tax Expense","investing expense":"Investing Expense","investing income":"Investing Income",investment:"Investment",investments:"Investment"};function Su(e){if(typeof e!="string")return String(e??"");let t=e.trim();return fde[t.toLowerCase()]??t}async function t3(e,t){if(!t?.trim())return;let r=t.trim().toLowerCase();return((await yu(e,{filter:{title:{contains:t.trim()}},limit:20}))?.data??[]).find(o=>o.title?.trim().toLowerCase()===r)}async function pb(e,t){return t?((await _u(e,{filter:{name:{eq:t}},limit:5}))?.data??[]).find(n=>n.name===t):void 0}async function fb(e,t){return t?((await bu(e,{filter:{name:{eq:t}},limit:5}))?.data??[]).find(n=>n.name===t):void 0}async function mb(e,t){if(!t)return;let r=t.toLowerCase().trim();return((await vu(e,{limit:500}))?.data??[]).find(o=>o.name.toLowerCase().trim()===r)}var mde=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function r3(e,t,r){if(!mde.test(e))throw new Error(`${t} must be a valid UUID (got "${e}"). ${r}`)}async function Oi(e,t){return e.list("/api/v1/chart-of-accounts",t)}async function _u(e,t){return e.search("/api/v1/chart-of-accounts/search",t)}async function n3(e,t){return e.get(`/api/v1/chart-of-accounts/${t}`)}async function vp(e,t){return e.post("/api/v1/chart-of-accounts",t)}async function o3(e,t,r){return e.put(`/api/v1/chart-of-accounts/${t}`,r)}var hde=["resourceId","code","name","accountType","currencyCode","description","status"];function hb(e){let t={};for(let r of hde){let n=e[r];n!=null&&(r==="accountType"&&typeof n=="string"?t.accountType=Su(n):t[r]=n)}return t}async function gb(e,t){return e.post("/api/v1/chart-of-accounts/bulk-upsert",{accounts:t})}async function yb(e,t){await e.delete(`/api/v1/chart-of-accounts/${t}`)}FD();function Eu(e,t,r={}){let n=r.threshold??.4,o=r.limit??5,i=e.toLowerCase().trim(),s=t.find(c=>c.code?.toLowerCase()===i);if(s)return[{item:s,score:1}];let a=t.find(c=>c.name.toLowerCase()===i);return a?[{item:a,score:1}]:Ea(e,t,c=>c.name,{threshold:n,limit:o})}function Db(e,t){let r=Eu(e,t,{threshold:.45,limit:1});return r.length>0?r[0].item:null}function i3(e){return e.filter(t=>t.status==="ACTIVE"&&!t.controlFlag&&t.accountType!=="Bank Accounts"&&t.accountType!=="Cash")}function s3(e){return e.filter(t=>t.status==="ACTIVE"&&(t.accountType==="Bank Accounts"||t.accountType==="Cash"))}function bb(e,t,r={}){let n=r.threshold??.4,o=r.limit??5;return t.map(s=>{let a=[s.billingName,s.name].filter(Boolean),c=Math.max(...a.map(u=>DA(e,u)));return{item:s,score:c}}).filter(s=>s.score>=n).sort((s,a)=>a.score-s.score).slice(0,o)}var vb=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function La(e){return e.length>12?e.slice(0,8)+"-...":e}async function Vr(e,t,r){if(vb.test(t))return{resourceId:t,displayName:t};let n=t.trim(),i=(await qn(e,{filter:{name:{contains:n}},limit:50})).data;if(i.length===0&&(i=(await as(e,{offset:0,limit:500})).data),i.length===0)throw new Error("No contacts found. Create one in Jaz first.");let s=n.toLowerCase(),a=i.find(d=>d.billingName?.toLowerCase()===s||d.name?.toLowerCase()===s);if(a){let d=a.billingName||a.name||"Unknown";return r?.silent||process.stderr.write(C(` Contact: ${d} (${La(a.resourceId)})
437
437
  `)),{resourceId:a.resourceId,displayName:d}}let c=bb(n,i,{threshold:.5,limit:5});if(c.length>=1&&c[0].score>=.7){let d=c[0],f=c.length>1?c[1].score:0;if(c.length===1||d.score-f>=.1){let p=d.item,m=p.billingName||p.name||"Unknown";return r?.silent||process.stderr.write(C(` Contact: ${m} (${La(p.resourceId)})
438
438
  `)),{resourceId:p.resourceId,displayName:m}}}if(c.length>1){let d=c.map(f=>` ${f.item.billingName||f.item.name} (${(f.score*100).toFixed(0)}%)`).join(`
439
439
  `);throw new Error(`Multiple contacts match "${n}":