jaz-clio 5.17.0 → 5.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/skills/api/SKILL.md +1 -1
- package/assets/skills/cli/SKILL.md +1 -1
- package/assets/skills/conversion/SKILL.md +1 -1
- package/assets/skills/jaz-pseudo-sql/SKILL.md +1 -1
- package/assets/skills/jobs/SKILL.md +1 -1
- package/assets/skills/transaction-recipes/SKILL.md +1 -1
- package/cli.mjs +2 -2
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -868,8 +868,8 @@ btType enum: SALE = invoice, PURCHASE = bill, SALE_CREDIT_NOTE = customer CN, PU
|
|
|
868
868
|
|
|
869
869
|
Each result carries contactSignals (Mid-7: cadence, outliers, severity, divergences from contact's modal pattern; null if no contact / no history) and breakdown (Balance-panel payload: line items + subtotal/tax/total/balance/exchange rate). Top-level contactSignalsMeta.unavailable=true \u2192 freshness layer offline for whole batch.
|
|
870
870
|
|
|
871
|
-
USE THIS to score a specific draft against contact history. For stand-alone "what does this contact normally look like?" without a draft \u2192 use get_contact_signals.`,params:{items:{type:"array",description:"Draft business transaction references (max 500). Mix any btType freely.",items:{type:"object",properties:{btResourceId:{type:"string",description:"Draft BT resource ID (UUID) \u2014 required"},btType:{type:"string",enum:["SALE","PURCHASE","SALE_CREDIT_NOTE","PURCHASE_CREDIT_NOTE"],description:"Required"}}}}},required:["items"],group:"drafts",readOnly:!0,isConcurrencySafe:!0,searchHint:"validate drafts eligibility check before convert promote",execute:async(t,e)=>(rv(e.items),SY(t.client,e.items))},{name:"convert_drafts_to_active",description:`BULK promote \u2014 finalize up to 500 draft business transactions to ACTIVE in ONE call, mixing any combination of invoices, bills, and credit notes (no per-type tools needed). ${Tu} NOT idempotent: a second call on already-promoted drafts returns 422. Filter the draft list by status: DRAFT before submitting. Pair with validate_drafts for a pre-flight check on large batches.`,params:{items:{type:"array",description:"Draft BT references (max 500). Mix any btType.",items:{type:"object",properties:{btResourceId:{type:"string",description:"Draft BT resource ID (UUID) \u2014 required"},btType:{type:"string",enum:["SALE","PURCHASE","SALE_CREDIT_NOTE","PURCHASE_CREDIT_NOTE"],description:"Required"}}}}},required:["items"],group:"drafts",readOnly:!1,searchHint:"convert drafts to active promote finalize bulk",execute:async(t,e)=>(rv(e.items),BY(t.client,e.items))},{name:"submit_drafts_for_approval",description:`BULK submit \u2014 route up to 500 draft business transactions into the approval workflow in ONE call, mixing any combination of invoices, bills, and credit notes. ${Tu} NOT idempotent on drafts that already have an in-flight approval request.`,params:{items:{type:"array",description:"Draft BT references (max 500). Mix any btType.",items:{type:"object",properties:{btResourceId:{type:"string",description:"Draft BT resource ID (UUID) \u2014 required"},btType:{type:"string",enum:["SALE","PURCHASE","SALE_CREDIT_NOTE","PURCHASE_CREDIT_NOTE"],description:"Required"}}}}},required:["items"],group:"drafts",readOnly:!1,searchHint:"submit drafts for approval workflow review bulk",execute:async(t,e)=>(rv(e.items),RY(t.client,e.items))},{name:"search_help_center",description:'Search the Jaz help center for how-to articles, feature guides, and accounting concepts. Use this for "how do I..." or "what is..." questions about Jaz: bank reconciliation, GST/VAT filing, multi-currency, fixed assets, custom fields, integrations, and so on. Returns top matching articles with title, section, content, and source URL.',params:{query:{type:"string",description:'Natural-language question or keywords (e.g. "how do I reconcile a bank statement", "set up GST", "multi-currency invoice").'},limit:{type:"number",description:"Maximum number of articles to return (default 3, max 10)."},section:{type:"string",description:'Optional: restrict to a single help-center section slug (e.g. "bank-reconciliations", "invoices").'}},required:["query"],group:"help_center",readOnly:!0,searchHint:"help center docs how to guide article search question",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>{let r=String(e.query??"").trim();if(!r)return{error:"Query is required.",hint:"Pass a natural-language question or keywords."};let n=typeof e.limit=="number"&&!Number.isNaN(e.limit)?e.limit:3,i=Math.max(1,Math.min(10,Math.floor(n))),s=typeof e.section=="string"?e.section:void 0;try{let o=HR();if(s&&!o.sections.some(u=>u.slug===s))return{error:`Unknown section: "${s}".`,available:o.sections.map(u=>u.slug),hint:"Omit the section parameter to search every section, or pick a slug from the available list."};let a=GR(),c=await VR(o,a,r,{mode:"hybrid",limit:i,section:s});return c.length===0?{results:[],hint:"No matching articles. Try broader keywords or rephrase the question."}:{results:c.map(u=>{let f=(Yae(u.article)??u.article.snippet).slice(0,1500);return{title:u.article.title,section:u.section.name,sectionSlug:u.section.slug,content:f,url:u.article.sourceUrl,score:Math.round(u.score*1e3)/1e3,scoreKind:u.scoreKind,matchedTerms:u.matchedTerms}}),totalArticles:o.articleCount,searchedSections:s?[s]:void 0}}catch(o){return{error:"Help center search failed.",detail:o instanceof Error?o.message:String(o),hint:"The bundled help-center index may be missing or corrupt."}}}}]});function Oit(t,e=5){let r=t.trim().toLowerCase();if(!r)return[];let n=r.split(/[\s_-]+/).filter(s=>s.length>=2);return n.length===0?[]:Qc.map(s=>{let o=0,a=s.name.toLowerCase(),c=s.description.toLowerCase();(a===r||a===r.replace(/\s+/g,"_"))&&(o+=5),a.includes(r)&&(o+=3),c.includes(r)&&(o+=1);for(let u of n)a.includes(u)&&(o+=2),c.includes(u)&&(o+=1);return{ns:s,score:o}}).filter(s=>s.score>0).sort((s,o)=>o.score-s.score).slice(0,e).map(s=>s.ns)}var Qc,Mx=re(()=>{"use strict";Qc=[{name:"invoices",description:"Sales invoices (INV/SI). Create, search, get, update, delete, pay, finalize, apply credits, download PDF. Also: receivables, AR, AR aging, billing, overdue invoices, dunning, recurring invoices.",groups:["invoices"]},{name:"customer_credit_notes",description:"Customer credit notes (CN). Create, search, update, delete, finalize, refund, download PDF. Also: sales returns, customer CN.",groups:["customer_credit_notes"]},{name:"bills",description:"Purchase bills (PO/PI). Create, search, get, update, delete, pay, finalize, apply credits. Also: payables, AP, vendor invoices, supplier bills.",groups:["bills"]},{name:"supplier_credit_notes",description:"Supplier credit notes. Create, search, update, delete, finalize, refund. Also: purchase returns, debit notes, supplier CN.",groups:["supplier_credit_notes"]},{name:"sale_orders",description:"Sales order documents: Sale Quotes (estimates/quotations) and Sale Orders. Create, get, search, update, and transition (accept a quote, confirm an order, void, delete). A Sale Order links to its quote via saleQuoteResourceId; the quote must be accepted first. Tracks fulfillment via orderState. Pipeline: quote \u2192 order \u2192 invoice (raise the invoice separately).",groups:["sale_orders"]},{name:"purchase_orders",description:"Purchase order documents: Purchase Requests (requisitions) and Purchase Orders (POs). Create, get, search, update, and transition (accept a request, confirm an order, void, delete). A Purchase Order links to its request via purchaseRequestResourceId; the request must be accepted first. Tracks fulfillment via orderState. Pipeline: request \u2192 order \u2192 bill (raise the bill separately).",groups:["purchase_orders"]},{name:"journals",description:"Journal entries (JE). Create, search, update, delete manual journals. Also: adjusting entries, accruals, reclassifications, corrections.",groups:["journals"]},{name:"cash_entries",description:"Cash-in receipts and cash-out disbursements for external cash movements. WHEN TO USE: money received from customers/external \u2192 cash-in. Money paid to suppliers/external \u2192 cash-out. For internal account-to-account transfers, use cash_transfers namespace.",groups:["cash_entries"]},{name:"cash_transfers",description:"Cash transfers between your own bank/cash accounts and cashflow transaction search. WHEN TO USE: moving funds between own accounts (main bank \u2192 petty cash, USD \u2192 SGD). For external receipts/payments, use cash_entries namespace.",groups:["cash_transfers"]},{name:"bank_accounts",description:"Bank accounts, bank statement imports (CSV/OFX), bank records search, auto-reconciliation. For unreconciled queries: ALWAYS search bank records with status UNRECONCILED after listing accounts. Also: bank feeds, bank balance.",groups:["bank"]},{name:"bank_rules",description:"Bank reconciliation rules (action shortcuts). Create, search, update, delete bank rules. Configure auto-matching rules for bank records.",groups:["bank_rules"]},{name:"reconciliations",description:"Apply a reconciliation decision to a bank statement entry \u2014 write side. Match bank records to EXISTING open bills/invoices/payments (reconcile_with_payments \u2014 the primary path, creates the payment for you), or to journals, cash entries, or transfers, or CREATE new bills/invoices (invoice_receipt/bill_receipt). Distinct from bank_accounts/bank_rules (which configure auto-reconciliation) and view_auto_reconciliation (which queries suggestions). Eleven endpoints: quick_reconcile + apply_bank_rule + magic_match (bulk), and direct_cash_entry / cash_journal / manual_journal / cash_transfer / invoice_receipt / bill_receipt / with_payments / learned_prediction (per-entry). Match-to-existing is preferred over create-new to avoid duplicates. Most fields prefill from the bank entry when omitted; FX is resolved server-side.",groups:["reconciliations"]},{name:"financial_reports",description:"Core financial statements: trial balance (TB), balance sheet (BS/B/S), profit & loss (PnL/P&L/income statement), cash flow, general ledger (GL), cash balance/position, equity movement, VAT/GST ledger. Also: how profitable, what is the balance. XLSX/PDF file exports of any of these statements are produced via download_export (lives in operational_reports namespace \u2014 switch there or call by name).",groups:["financial_reports"]},{name:"operational_reports",description:"Aging and operational reports: aged receivables (AR aging), aged payables (AP aging), AR report, bank balance summary, bank reconciliation reports, fixed asset (FA) summary, FA reconciliation. Data exports (CSV/Excel/XLSX). Anomaly detection and audit analysis: anomalous invoices, anomalous bills, cashflow anomalies, GL journal audit, exchange rate audit, receivables customer risk, cash expense health. Also: overdue analysis, how much owed, suspicious transactions, audit trail.",groups:["operational_reports","exports"]},{name:"pseudo_sql",description:"Pseudo-SQL ad-hoc read-only queries against the curated reporting schema (custom select, custom report, query data, run sql). Includes live schema introspection (get_pseudo_sql_schema) + sync preview (\u2264100 rows) + async CSV export. Use when search_* / download_export canonical reports don't cover the question.",groups:["pseudo_sql"]},{name:"contacts",description:"Contacts (customers/suppliers/vendors), contact groups, customer segmentation. Create, search, get, update, delete contacts. Bulk upsert contacts from CSV / spreadsheet imports \u2014 async, returns jobId, poll background_jobs. List/create contact groups.",groups:["contacts","contact_groups"]},{name:"items_and_inventory",description:"Products, services, inventory items. Create, search, get, update, delete items. Check inventory balance. Also: SKU, catalog, stock.",groups:["items","inventory"]},{name:"tags_and_custom_fields",description:"Tags for categorizing transactions. Custom fields for adding metadata (text, date, dropdown). Create, search, delete tags and custom fields.",groups:["tags","custom_fields"]},{name:"nano_classifiers",description:"Nano classifiers (tracking categories/dimensions). List, search, create, update, delete classifiers and their classes. Used for line-item tagging and dimensional reporting. Also: tracking categories, cost centers, departments, projects.",groups:["nano_classifiers"]},{name:"chart_of_accounts",description:"Chart of accounts (COA/GL accounts). Create, search, update accounts \u2014 including setting or removing an account's period lock date (lock / unlock a period, lock date: block recording or editing transactions on the account dated on or before a date). Bookmarks (favorites/shortcuts). Also: ledger codes, account types.",groups:["accounts","bookmarks"]},{name:"currencies",description:"Currencies, exchange rates (FX/forex). List/add org currencies. Set, update, import currency rates. Also: multi-currency, FX rates.",groups:["currencies"]},{name:"tax_profiles",description:"Tax profiles (GST/VAT/sales tax), withholding tax codes (WHT/ATC). Search, create, update tax profiles. List WHT codes.",groups:["tax_profiles"]},{name:"capsules_and_recipes",description:"Capsules (transaction groupings/capsule types). Financial recipes: amortization, depreciation, deferred revenue, IFRS 16 leases, hire purchase, fixed deposits, FX revaluation, loan schedules, ECL/expected credit loss, IAS 37 provisions, asset disposal. Two recipe execution paths: offline (plan_recipe + execute_recipe \u2014 client-side calculators, no API key) and server-side (list/get/preview/resume/rollback_capsule_recipe \u2014 produce real capsule entities via Jaz API). Plus capsuleRecipe payload on trigger mutations (create_bill, create_journal, create_cash_in, etc.) to create and trigger a recipe in one shot, with optional templateOverrides to customize the generated text (Customize Recipe). Keywords: calculate, provision, schedule, expected credit loss, revaluation, amortize, rollback recipe, customize template overrides slots.",groups:["capsules","recipes","capsule_recipes"]},{name:"scheduled_transactions",description:"Scheduled/recurring invoices, bills, journals. Create scheduled invoices/bills/journals, search scheduled transactions. Also: recurring, auto-generate.",groups:["schedulers"]},{name:"subscriptions",description:"Subscriptions (recurring billing/payment plans). Create, update, cancel, search subscriptions. Also: recurring charges, subscription schedules.",groups:["subscriptions"]},{name:"organization",description:"Organization info (name, currency, country, fiscal year). User management: invite, update, remove, search org users. Bulk invite.",groups:["organization","org_users"]},{name:"document_ai",description:"File attachments, spreadsheets, and document AI. Read and parse rows from attached spreadsheets \u2014 CSV, Excel, XLSX. Extract data from PDFs and images via AI/OCR: invoice, receipt, and bill scanning. Upload and list attachments; track extraction workflows.",groups:["attachments","magic"]},{name:"fixed_assets",description:"Fixed assets (PP&E/property, plant, equipment). Search, create, update, discard, sell, transfer, undo disposal. Also: depreciation, asset register.",groups:["fixed_assets"]},{name:"payments_and_search",description:"Payment records: get, update, delete individual payments. List payments/credits on invoices and bills. Reverse credit applications. Cashflow transaction search. Universal cross-entity search. Also: payment run, batch payment, payment matching, void payment, payment history, credit note applications.",groups:["payments","cashflow","search"]},{name:"quick_fix",description:"Quick Fix: bulk-update multiple transactions or line items in one call. Change dates, contacts, tags, accounts, tax profiles, custom fields across many invoices/bills/journals/credit-notes/cash-entries/schedulers at once. Also: batch update, mass edit.",groups:["quick_fix"]},{name:"export_records",description:"Export records to XLSX. List available columns, preview export scope (row count + sample), generate export file with pre-signed download URL. Supports any entity type: invoices, bills, contacts, items, journals, bank records, cashflow, fixed assets, etc. Pass query (structured search syntax) or filter (JSON), never both.",groups:["export_records"]},{name:"background_jobs",description:"Background job tracking. Poll any async operation by jobId (contacts bulk-upsert, items bulk-upsert, bank import, magic file processing, etc.). Filter by resourceId field to look up a specific job. Poll until status is SUCCESS, FAILED, or PARTIAL_SUCCESS.",groups:["background_jobs"]},{name:"drafts",description:"Draft business transactions \u2014 both local payload validation (invoices, bills, journals, credit notes) AND BULK-FRIENDLY server-side lifecycle: validate_drafts (sync eligibility check), convert_drafts_to_active (async promote to ACTIVE), submit_drafts_for_approval (async route to approval). The lifecycle tools are GENERIC and BULK \u2014 one call accepts up to 500 items mixing any combination of {btResourceId, btType: SALE|PURCHASE|SALE_CREDIT_NOTE|PURCHASE_CREDIT_NOTE}. No need for per-entity tools when promoting/submitting drafts at scale. NOT idempotent on already-promoted drafts.",groups:["drafts"]},{name:"help_center",description:"Search the Jaz help center for how-to articles, feature guides, accounting concepts, and troubleshooting. Returns top matches with title, section, snippet, and source URL. Works without an API key.",groups:["help_center"]}]});function Bbr(){if(!S8){S8=new Map;for(let t of kc)S8.set(t.name,t)}return S8}function iy(t){return Bbr().get(t)}function Px(){return kc}function Mh(t){return Px().filter(e=>e.group===t)}var S8,dv=re(()=>{"use strict";iv();S8=null});function B8(t){let e={type:t.type};if(t.description&&(e.description=t.description),t.enum&&(e.enum=t.enum),t.type==="array"&&t.items&&(e.items=B8(t.items)),t.type==="object"&&t.properties){let r={};for(let[n,i]of Object.entries(t.properties))r[n]=B8(i);e.properties=r,t.required?.length&&(e.required=t.required)}return e}function id(t,e){let r={};for(let[n,i]of Object.entries(t))r[n]=B8(i);return{type:"object",properties:r,...e.length>0?{required:e}:{}}}function sy(t){return{name:t.name,description:t.description,input_schema:id(t.params,t.required),...t.searchHint?{searchHint:t.searchHint}:{}}}var $x=re(()=>{"use strict"});function Ux(t){if(typeof t!="string")return t.isDestructive??!1;let e=t;return e.startsWith("delete_")||e.startsWith("pay_")||e.startsWith("finalize_")||e.includes("refund")||e==="remove_org_user"}function R8(t){return{readOnlyHint:t.readOnly,destructiveHint:!t.readOnly&&Ux(t),idempotentHint:t.readOnly,openWorldHint:t.openWorld??!1}}function Qit(t){if(!t.trim())return{namespaces:Qc.map(i=>{let s=i.groups.flatMap(o=>Mh(o));return{name:i.name,description:i.description,toolCount:s.length,tools:s.map(o=>o.name)}}),hint:"Call describe_tools with specific tool names to get full schemas before executing."};let e=Oit(t,5);if(e.length===0)return{matches:[],hint:`No tools match "${t}". Try broader terms or call search_tools with empty query to see all namespaces.`};let n=t.toLowerCase().split(/\s+/).filter(Boolean);return{matches:e.map(i=>{let o=i.groups.flatMap(a=>Mh(a)).map(a=>{let c=`${a.name} ${a.searchHint??""} ${a.description}`.toLowerCase(),u=n.filter(f=>c.includes(f)).length;return{tool:a,score:u}}).sort((a,c)=>c.score-a.score);return{namespace:i.name,description:i.description,tools:o.map(a=>({name:a.tool.name,description:a.tool.description.split(`
|
|
872
|
-
`)[0],...a.tool.searchHint?{searchHint:a.tool.searchHint}:{}}))}}),hint:"Call describe_tools with the tool names you need, then execute_tool to run them."}}function Lit(t){if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))return{error:"Invalid `tools` parameter. Expected string[]."};if(t.length===0)return{error:"Provide at least one tool name. Use search_tools first to discover tool names."};let e=[],r=[];for(let n of t){let i=iy(n);if(!i){r.push(n);continue}e.push({...sy(i),readOnly:i.readOnly,isDestructive:i.isDestructive??!1,isConcurrencySafe:i.isConcurrencySafe??!1,destructiveHint:!i.readOnly&&Ux(i),group:i.group})}return{tools:e,...r.length>0?{notFound:r,hint:`Tools not found: ${r.join(", ")}. Use search_tools to find correct names.`}:{}}}var Rbr,xbr,Tbr,Ph,sd,qx=re(()=>{"use strict";Mx();dv();$x();Rbr={name:"search_tools",description:"Search for available Jaz accounting tools by keyword. Returns matching tool namespaces with tool names and descriptions. Call with empty query to list all namespaces. ALWAYS call this first to discover what tools are available.",inputSchema:id({query:{type:"string",description:'Search keyword (e.g. "invoice", "bank recon", "depreciation"). Empty string lists all namespaces.'}},[])};xbr={name:"describe_tools",description:"Get full JSON Schema (parameters, types, required fields) for specific tools. Call this after search_tools to get the exact input format before calling execute_tool.",inputSchema:id({tools:{type:"array",items:{type:"string"},description:'Tool names to describe (e.g. ["create_invoice", "search_contacts"])'}},["tools"])},Tbr={name:"execute_tool",description:"Execute a Jaz accounting tool. Call describe_tools first to get the required parameters. Pass the tool name and its arguments.",inputSchema:id({tool:{type:"string",description:'Tool name (e.g. "create_invoice")'},arguments:{type:"object",description:"Tool arguments (see describe_tools for schema)"},org_id:{type:"string",description:"Organization ID (UUID). Required in multi-org mode (PAT or multiple API keys). Call list_organizations to get available IDs."}},["tool"])},Ph={name:"list_organizations",description:"List organizations available to the current authentication. Returns org names and resource IDs for use as org_id in execute_tool calls.",inputSchema:id({},[])},sd=[Rbr,xbr,Tbr]});var Hx=b(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.regexpCode=Dr.getEsmExportName=Dr.getProperty=Dr.safeStringify=Dr.stringify=Dr.strConcat=Dr.addCodeArg=Dr.str=Dr._=Dr.nil=Dr._Code=Dr.Name=Dr.IDENTIFIER=Dr._CodeOrName=void 0;var Yx=class{};Dr._CodeOrName=Yx;Dr.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var oy=class extends Yx{constructor(e){if(super(),!Dr.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Dr.Name=oy;var Lc=class extends Yx{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof oy&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Dr._Code=Lc;Dr.nil=new Lc("");function Uit(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Kue(r,e[n]),r.push(t[++n]);return new Lc(r)}Dr._=Uit;var Zue=new Lc("+");function qit(t,...e){let r=[zx(t[0])],n=0;for(;n<e.length;)r.push(Zue),Kue(r,e[n]),r.push(Zue,zx(t[++n]));return Mbr(r),new Lc(r)}Dr.str=qit;function Kue(t,e){e instanceof Lc?t.push(...e._items):e instanceof oy?t.push(e):t.push(Ubr(e))}Dr.addCodeArg=Kue;function Mbr(t){let e=1;for(;e<t.length-1;){if(t[e]===Zue){let r=Pbr(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Pbr(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof oy||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof oy))return`"${t}${e.slice(1)}`}function $br(t,e){return e.emptyStr()?t:t.emptyStr()?e:qit`${t}${e}`}Dr.strConcat=$br;function Ubr(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:zx(Array.isArray(t)?t.join(","):t)}function qbr(t){return new Lc(zx(t))}Dr.stringify=qbr;function zx(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Dr.safeStringify=zx;function jbr(t){return typeof t=="string"&&Dr.IDENTIFIER.test(t)?new Lc(`.${t}`):Uit`[${t}]`}Dr.getProperty=jbr;function Ybr(t){if(typeof t=="string"&&Dr.IDENTIFIER.test(t))return new Lc(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Dr.getEsmExportName=Ybr;function zbr(t){return new Lc(t.toString())}Dr.regexpCode=zbr});var tle=b(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.ValueScope=na.ValueScopeName=na.Scope=na.varKinds=na.UsedValueState=void 0;var ra=Hx(),Xue=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},k8;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(k8||(na.UsedValueState=k8={}));na.varKinds={const:new ra.Name("const"),let:new ra.Name("let"),var:new ra.Name("var")};var N8=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ra.Name?e:this.name(e)}name(e){return new ra.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};na.Scope=N8;var F8=class extends ra.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,ra._)`.${new ra.Name(r)}[${n}]`}};na.ValueScopeName=F8;var Hbr=(0,ra._)`\n`,ele=class extends N8{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Hbr:ra.nil}}get(){return this._scope}name(e){return new F8(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:s}=i,o=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let f=a.get(o);if(f)return f}else a=this._values[s]=new Map;a.set(o,i);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,i.setValue(r,{property:s,itemIndex:u}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,ra._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let s=ra.nil;for(let o in e){let a=e[o];if(!a)continue;let c=n[o]=n[o]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,k8.Started);let f=r(u);if(f){let d=this.opts.es5?na.varKinds.var:na.varKinds.const;s=(0,ra._)`${s}${d} ${u} = ${f};${this.opts._n}`}else if(f=i?.(u))s=(0,ra._)`${s}${f}${this.opts._n}`;else throw new Xue(u);c.set(u,k8.Completed)})}return s}};na.ValueScope=ele});var Pt=b(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.or=jt.and=jt.not=jt.CodeGen=jt.operators=jt.varKinds=jt.ValueScopeName=jt.ValueScope=jt.Scope=jt.Name=jt.regexpCode=jt.stringify=jt.getProperty=jt.nil=jt.strConcat=jt.str=jt._=void 0;var ur=Hx(),Fu=tle(),qh=Hx();Object.defineProperty(jt,"_",{enumerable:!0,get:function(){return qh._}});Object.defineProperty(jt,"str",{enumerable:!0,get:function(){return qh.str}});Object.defineProperty(jt,"strConcat",{enumerable:!0,get:function(){return qh.strConcat}});Object.defineProperty(jt,"nil",{enumerable:!0,get:function(){return qh.nil}});Object.defineProperty(jt,"getProperty",{enumerable:!0,get:function(){return qh.getProperty}});Object.defineProperty(jt,"stringify",{enumerable:!0,get:function(){return qh.stringify}});Object.defineProperty(jt,"regexpCode",{enumerable:!0,get:function(){return qh.regexpCode}});Object.defineProperty(jt,"Name",{enumerable:!0,get:function(){return qh.Name}});var M8=tle();Object.defineProperty(jt,"Scope",{enumerable:!0,get:function(){return M8.Scope}});Object.defineProperty(jt,"ValueScope",{enumerable:!0,get:function(){return M8.ValueScope}});Object.defineProperty(jt,"ValueScopeName",{enumerable:!0,get:function(){return M8.ValueScopeName}});Object.defineProperty(jt,"varKinds",{enumerable:!0,get:function(){return M8.varKinds}});jt.operators={GT:new ur._Code(">"),GTE:new ur._Code(">="),LT:new ur._Code("<"),LTE:new ur._Code("<="),EQ:new ur._Code("==="),NEQ:new ur._Code("!=="),NOT:new ur._Code("!"),OR:new ur._Code("||"),AND:new ur._Code("&&"),ADD:new ur._Code("+")};var ad=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},rle=class extends ad{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Fu.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Av(this.rhs,e,r)),this}get names(){return this.rhs instanceof ur._CodeOrName?this.rhs.names:{}}},O8=class extends ad{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ur.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Av(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ur.Name?{}:{...this.lhs.names};return L8(e,this.rhs)}},nle=class extends O8{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},ile=class extends ad{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},sle=class extends ad{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ole=class extends ad{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},ale=class extends ad{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Av(this.code,e,r),this}get names(){return this.code instanceof ur._CodeOrName?this.code.names:{}}},Gx=class extends ad{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let s=n[i];s.optimizeNames(e,r)||(Gbr(e,s.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>uy(e,r.names),{})}},cd=class extends Gx{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},cle=class extends Gx{},hv=class extends cd{};hv.kind="else";var ay=class t extends cd{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new hv(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(jit(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Av(this.condition,e,r),this}get names(){let e=super.names;return L8(e,this.condition),this.else&&uy(e,this.else.names),e}};ay.kind="if";var cy=class extends cd{};cy.kind="for";var ule=class extends cy{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Av(this.iteration,e,r),this}get names(){return uy(super.names,this.iteration.names)}},lle=class extends cy{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?Fu.varKinds.var:this.varKind,{name:n,from:i,to:s}=this;return`for(${r} ${n}=${i}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=L8(super.names,this.from);return L8(e,this.to)}},Q8=class extends cy{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Av(this.iterable,e,r),this}get names(){return uy(super.names,this.iterable.names)}},Vx=class extends cd{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Vx.kind="func";var Jx=class extends Gx{render(e){return"return "+super.render(e)}};Jx.kind="return";var fle=class extends cd{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&uy(e,this.catch.names),this.finally&&uy(e,this.finally.names),e}},Wx=class extends cd{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Wx.kind="catch";var Zx=class extends cd{render(e){return"finally"+super.render(e)}};Zx.kind="finally";var dle=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
871
|
+
USE THIS to score a specific draft against contact history. For stand-alone "what does this contact normally look like?" without a draft \u2192 use get_contact_signals.`,params:{items:{type:"array",description:"Draft business transaction references (max 500). Mix any btType freely.",items:{type:"object",properties:{btResourceId:{type:"string",description:"Draft BT resource ID (UUID) \u2014 required"},btType:{type:"string",enum:["SALE","PURCHASE","SALE_CREDIT_NOTE","PURCHASE_CREDIT_NOTE"],description:"Required"}}}}},required:["items"],group:"drafts",readOnly:!0,isConcurrencySafe:!0,searchHint:"validate drafts eligibility check before convert promote",execute:async(t,e)=>(rv(e.items),SY(t.client,e.items))},{name:"convert_drafts_to_active",description:`BULK promote \u2014 finalize up to 500 draft business transactions to ACTIVE in ONE call, mixing any combination of invoices, bills, and credit notes (no per-type tools needed). ${Tu} NOT idempotent: a second call on already-promoted drafts returns 422. Filter the draft list by status: DRAFT before submitting. Pair with validate_drafts for a pre-flight check on large batches.`,params:{items:{type:"array",description:"Draft BT references (max 500). Mix any btType.",items:{type:"object",properties:{btResourceId:{type:"string",description:"Draft BT resource ID (UUID) \u2014 required"},btType:{type:"string",enum:["SALE","PURCHASE","SALE_CREDIT_NOTE","PURCHASE_CREDIT_NOTE"],description:"Required"}}}}},required:["items"],group:"drafts",readOnly:!1,searchHint:"convert drafts to active promote finalize bulk",execute:async(t,e)=>(rv(e.items),BY(t.client,e.items))},{name:"submit_drafts_for_approval",description:`BULK submit \u2014 route up to 500 draft business transactions into the approval workflow in ONE call, mixing any combination of invoices, bills, and credit notes. ${Tu} NOT idempotent on drafts that already have an in-flight approval request.`,params:{items:{type:"array",description:"Draft BT references (max 500). Mix any btType.",items:{type:"object",properties:{btResourceId:{type:"string",description:"Draft BT resource ID (UUID) \u2014 required"},btType:{type:"string",enum:["SALE","PURCHASE","SALE_CREDIT_NOTE","PURCHASE_CREDIT_NOTE"],description:"Required"}}}}},required:["items"],group:"drafts",readOnly:!1,searchHint:"submit drafts for approval workflow review bulk",execute:async(t,e)=>(rv(e.items),RY(t.client,e.items))},{name:"search_help_center",description:'Search the Jaz help center for how-to articles, feature guides, and accounting concepts. Use this for "how do I..." or "what is..." questions about Jaz: bank reconciliation, GST/VAT filing, multi-currency, fixed assets, custom fields, integrations, and so on. Returns top matching articles with title, section, content, and source URL.',params:{query:{type:"string",description:'Natural-language question or keywords (e.g. "how do I reconcile a bank statement", "set up GST", "multi-currency invoice").'},limit:{type:"number",description:"Maximum number of articles to return (default 3, max 10)."},section:{type:"string",description:'Optional: restrict to a single help-center section slug (e.g. "bank-reconciliations", "invoices").'}},required:["query"],group:"help_center",readOnly:!0,searchHint:"help center docs how to guide article search question",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>{let r=String(e.query??"").trim();if(!r)return{error:"Query is required.",hint:"Pass a natural-language question or keywords."};let n=typeof e.limit=="number"&&!Number.isNaN(e.limit)?e.limit:3,i=Math.max(1,Math.min(10,Math.floor(n))),s=typeof e.section=="string"?e.section:void 0;try{let o=HR();if(s&&!o.sections.some(u=>u.slug===s))return{error:`Unknown section: "${s}".`,available:o.sections.map(u=>u.slug),hint:"Omit the section parameter to search every section, or pick a slug from the available list."};let a=GR(),c=await VR(o,a,r,{mode:"hybrid",limit:i,section:s});return c.length===0?{results:[],hint:"No matching articles. Try broader keywords or rephrase the question."}:{results:c.map(u=>{let f=(Yae(u.article)??u.article.snippet).slice(0,1500);return{title:u.article.title,section:u.section.name,sectionSlug:u.section.slug,content:f,url:u.article.sourceUrl,score:Math.round(u.score*1e3)/1e3,scoreKind:u.scoreKind,matchedTerms:u.matchedTerms}}),totalArticles:o.articleCount,searchedSections:s?[s]:void 0}}catch(o){return{error:"Help center search failed.",detail:o instanceof Error?o.message:String(o),hint:"The bundled help-center index may be missing or corrupt."}}}}]});function Oit(t,e=5){let r=t.trim().toLowerCase();if(!r)return[];let n=r.split(/[\s_-]+/).filter(s=>s.length>=2);return n.length===0?[]:Qc.map(s=>{let o=0,a=s.name.toLowerCase(),c=s.description.toLowerCase();(a===r||a===r.replace(/\s+/g,"_"))&&(o+=5),a.includes(r)&&(o+=3),c.includes(r)&&(o+=1);for(let u of n)a.includes(u)&&(o+=2),c.includes(u)&&(o+=1);return{ns:s,score:o}}).filter(s=>s.score>0).sort((s,o)=>o.score-s.score).slice(0,e).map(s=>s.ns)}var Qc,Mx=re(()=>{"use strict";Qc=[{name:"invoices",description:"Sales invoices (INV/SI). Create, search, get, update, delete, pay, finalize, apply credits, download PDF. Also: receivables, AR, AR aging, billing, overdue invoices, dunning, recurring invoices.",groups:["invoices"]},{name:"customer_credit_notes",description:"Customer credit notes (CN). Create, search, update, delete, finalize, refund, download PDF. Also: sales returns, customer CN.",groups:["customer_credit_notes"]},{name:"bills",description:"Purchase bills (PO/PI). Create, search, get, update, delete, pay, finalize, apply credits. Also: payables, AP, vendor invoices, supplier bills.",groups:["bills"]},{name:"supplier_credit_notes",description:"Supplier credit notes. Create, search, update, delete, finalize, refund. Also: purchase returns, debit notes, supplier CN.",groups:["supplier_credit_notes"]},{name:"sale_orders",description:"Sales order documents: Sale Quotes (estimates/quotations) and Sale Orders. Create, get, search, update, and transition (accept a quote, confirm an order, void, delete). A Sale Order links to its quote via saleQuoteResourceId; the quote must be accepted first. Tracks fulfillment via orderState. Pipeline: quote \u2192 order \u2192 invoice (raise the invoice separately).",groups:["sale_orders"]},{name:"purchase_orders",description:"Purchase order documents: Purchase Requests (requisitions) and Purchase Orders (POs). Create, get, search, update, and transition (accept a request, confirm an order, void, delete). A Purchase Order links to its request via purchaseRequestResourceId; the request must be accepted first. Tracks fulfillment via orderState. Pipeline: request \u2192 order \u2192 bill (raise the bill separately).",groups:["purchase_orders"]},{name:"journals",description:"Journal entries (JE). Create, search, update, delete manual journals. Also: adjusting entries, accruals, reclassifications, corrections.",groups:["journals"]},{name:"cash_entries",description:"Cash-in receipts and cash-out disbursements for external cash movements. WHEN TO USE: money received from customers/external \u2192 cash-in. Money paid to suppliers/external \u2192 cash-out. For internal account-to-account transfers, use cash_transfers namespace.",groups:["cash_entries"]},{name:"cash_transfers",description:"Cash transfers between your own bank/cash accounts and cashflow transaction search. WHEN TO USE: moving funds between own accounts (main bank \u2192 petty cash, USD \u2192 SGD). For external receipts/payments, use cash_entries namespace.",groups:["cash_transfers"]},{name:"bank_accounts",description:"Bank accounts, bank statement imports (CSV/OFX), bank records search, auto-reconciliation. For unreconciled queries: ALWAYS search bank records with status UNRECONCILED after listing accounts. Also: bank feeds, bank balance.",groups:["bank"]},{name:"bank_rules",description:"Bank reconciliation rules (action shortcuts). Create, search, update, delete bank rules. Configure auto-matching rules for bank records.",groups:["bank_rules"]},{name:"reconciliations",description:"Apply a reconciliation decision to a bank statement entry \u2014 write side. Match bank records to EXISTING open bills/invoices/payments (reconcile_with_payments \u2014 the primary path, creates the payment for you), or to journals, cash entries, or transfers, or CREATE new bills/invoices (invoice_receipt/bill_receipt). Distinct from bank_accounts/bank_rules (which configure auto-reconciliation) and view_auto_reconciliation (which queries suggestions). Eleven endpoints: quick_reconcile + apply_bank_rule + magic_match (bulk), and direct_cash_entry / cash_journal / manual_journal / cash_transfer / invoice_receipt / bill_receipt / with_payments / learned_prediction (per-entry). Match-to-existing is preferred over create-new to avoid duplicates. Most fields prefill from the bank entry when omitted; FX is resolved server-side.",groups:["reconciliations"]},{name:"financial_reports",description:"Core financial statements: trial balance (TB), balance sheet (BS/B/S), profit & loss (PnL/P&L/income statement), cash flow, general ledger (GL), cash balance/position, equity movement, VAT/GST ledger. Also: how profitable, what is the balance. XLSX/PDF file exports of any of these statements are produced via download_export (lives in operational_reports namespace \u2014 switch there or call by name).",groups:["financial_reports"]},{name:"operational_reports",description:"Aging and operational reports: aged receivables (AR aging), aged payables (AP aging), AR report, bank balance summary, bank reconciliation reports, fixed asset (FA) summary, FA reconciliation. Data exports (CSV/Excel/XLSX). Anomaly detection and audit analysis: anomalous invoices, anomalous bills, cashflow anomalies, GL journal audit, exchange rate audit, receivables customer risk, cash expense health. Also: overdue analysis, how much owed, suspicious transactions, audit trail.",groups:["operational_reports","exports"]},{name:"pseudo_sql",description:"Pseudo-SQL ad-hoc read-only queries against the curated reporting schema (custom select, custom report, query data, run sql). Includes live schema introspection (get_pseudo_sql_schema) + sync preview (\u2264100 rows) + async CSV export. Use when search_* / download_export canonical reports don't cover the question.",groups:["pseudo_sql"]},{name:"contacts",description:"Contacts (customers/suppliers/vendors), contact groups, customer segmentation. Create, search, get, update, delete contacts. Bulk upsert contacts from CSV / spreadsheet imports \u2014 async, returns jobId, poll background_jobs. List/create contact groups.",groups:["contacts","contact_groups"]},{name:"items_and_inventory",description:"Products, services, inventory items. Create, search, get, update, delete items. Check inventory balance. Also: SKU, catalog, stock.",groups:["items","inventory"]},{name:"tags_and_custom_fields",description:"Tags for categorizing transactions. Custom fields for adding metadata (text, date, dropdown). Create, search, delete tags and custom fields.",groups:["tags","custom_fields"]},{name:"nano_classifiers",description:"Nano classifiers (tracking categories/dimensions). List, search, create, update, delete classifiers and their classes. Used for line-item tagging and dimensional reporting. Also: tracking categories, cost centers, departments, projects.",groups:["nano_classifiers"]},{name:"chart_of_accounts",description:"Chart of accounts (COA/GL accounts). Create, search, update accounts \u2014 including setting or removing an account's period lock date (lock / unlock a period, lock date: block recording or editing transactions on the account dated on or before a date). Bookmarks (favorites/shortcuts). Also: ledger codes, account types.",groups:["accounts","bookmarks"]},{name:"currencies",description:"Currencies, exchange rates (FX/forex). List/add org currencies. Set, update, import currency rates. Also: multi-currency, FX rates.",groups:["currencies"]},{name:"tax_profiles",description:"Tax profiles (GST/VAT/sales tax), withholding tax codes (WHT/ATC). Search, create, update tax profiles. List WHT codes.",groups:["tax_profiles"]},{name:"capsules_and_recipes",description:"Capsules (transaction groupings/capsule types). Financial recipes: amortization, depreciation, deferred revenue, IFRS 16 leases, hire purchase, fixed deposits, FX revaluation, loan schedules, ECL/expected credit loss, IAS 37 provisions, asset disposal. Two recipe execution paths: offline (plan_recipe + execute_recipe \u2014 client-side calculators, no API key) and server-side (list/get/preview/resume/rollback_capsule_recipe \u2014 produce real capsule entities via Jaz API). Plus capsuleRecipe payload on trigger mutations (create_bill, create_journal, create_cash_in, etc.) to create and trigger a recipe in one shot, with optional templateOverrides to customize the generated text (Customize Recipe). Keywords: calculate, provision, schedule, expected credit loss, revaluation, amortize, rollback recipe, customize template overrides slots.",groups:["capsules","recipes","capsule_recipes"]},{name:"scheduled_transactions",description:"Scheduled/recurring invoices, bills, journals. Create scheduled invoices/bills/journals, search scheduled transactions. Also: recurring, auto-generate.",groups:["schedulers"]},{name:"subscriptions",description:"Subscriptions (recurring billing/payment plans). Create, update, cancel, search subscriptions. Also: recurring charges, subscription schedules.",groups:["subscriptions"]},{name:"organization",description:"Organization info (name, currency, country, fiscal year). User management: invite, update, remove, search org users. Bulk invite.",groups:["organization","org_users"]},{name:"document_ai",description:"File attachments, spreadsheets, and document AI. Read and parse rows from attached spreadsheets \u2014 CSV, Excel, XLSX. Extract data from PDFs and images via AI/OCR: invoice, receipt, and bill scanning. Upload and list attachments; track extraction workflows.",groups:["attachments","magic"]},{name:"fixed_assets",description:"Fixed assets (PP&E/property, plant, equipment). Search, create, update, discard, sell, transfer, undo disposal. Also: depreciation, asset register.",groups:["fixed_assets"]},{name:"payments_and_search",description:"Payment records: get, update, delete individual payments. List payments/credits on invoices and bills. Reverse credit applications. Cashflow transaction search. Universal cross-entity search. Also: payment run, batch payment, payment matching, void payment, payment history, credit note applications.",groups:["payments","cashflow","search"]},{name:"quick_fix",description:"Quick Fix: bulk-update multiple transactions or line items in one call. Change dates, contacts, tags, accounts, tax profiles, custom fields across many invoices/bills/journals/credit-notes/cash-entries/schedulers at once. Also: batch update, mass edit.",groups:["quick_fix"]},{name:"export_records",description:"Export records to XLSX. List available columns, preview export scope (row count + sample), generate export file with pre-signed download URL. Supports any entity type: invoices, bills, contacts, items, journals, bank records, cashflow, fixed assets, etc. Pass query (structured search syntax) or filter (JSON), never both.",groups:["export_records"]},{name:"background_jobs",description:"Background job tracking. Poll any async operation by jobId (contacts bulk-upsert, items bulk-upsert, bank import, magic file processing, etc.). Filter by resourceId field to look up a specific job. Poll until status is SUCCESS, FAILED, or PARTIAL_SUCCESS.",groups:["background_jobs"]},{name:"drafts",description:"Draft business transactions \u2014 both local payload validation (invoices, bills, journals, credit notes) AND BULK-FRIENDLY server-side lifecycle: validate_drafts (sync eligibility check), convert_drafts_to_active (async promote to ACTIVE), submit_drafts_for_approval (async route to approval). The lifecycle tools are GENERIC and BULK \u2014 one call accepts up to 500 items mixing any combination of {btResourceId, btType: SALE|PURCHASE|SALE_CREDIT_NOTE|PURCHASE_CREDIT_NOTE}. No need for per-entity tools when promoting/submitting drafts at scale. NOT idempotent on already-promoted drafts.",groups:["drafts"]},{name:"help_center",description:"Search the Jaz help center for how-to articles, feature guides, accounting concepts, and troubleshooting. Returns top matches with title, section, snippet, and source URL. Works without an API key.",groups:["help_center"]}]});function Bbr(){if(!S8){S8=new Map;for(let t of kc)S8.set(t.name,t)}return S8}function iy(t){return Bbr().get(t)}function Px(){return kc}function Mh(t){return Px().filter(e=>e.group===t)}var S8,dv=re(()=>{"use strict";iv();S8=null});function B8(t){let e={type:t.type};if(t.description&&(e.description=t.description),t.enum&&(e.enum=t.enum),t.type==="array"&&t.items&&(e.items=B8(t.items)),t.type==="object"&&t.properties){let r={};for(let[n,i]of Object.entries(t.properties))r[n]=B8(i);e.properties=r,t.required?.length&&(e.required=t.required)}return e}function id(t,e){let r={};for(let[n,i]of Object.entries(t))r[n]=B8(i);return{type:"object",properties:r,...e.length>0?{required:e}:{}}}function sy(t){return{name:t.name,description:t.description,input_schema:id(t.params,t.required),...t.searchHint?{searchHint:t.searchHint}:{}}}var $x=re(()=>{"use strict"});function Ux(t){if(typeof t!="string")return t.isDestructive??!1;let e=t;return e.startsWith("delete_")||e.startsWith("pay_")||e.startsWith("finalize_")||e.includes("refund")||e==="remove_org_user"}function R8(t){return{readOnlyHint:t.readOnly,destructiveHint:!t.readOnly&&Ux(t),idempotentHint:t.readOnly,openWorldHint:t.openWorld??!1}}function Qit(t){if(!t.trim())return{namespaces:Qc.map(i=>{let s=i.groups.flatMap(o=>Mh(o));return{name:i.name,description:i.description,toolCount:s.length,tools:s.map(o=>o.name)}}),hint:"Call describe_tools with specific tool names to get full schemas before executing."};let e=Oit(t,5);if(e.length===0)return{matches:[],hint:`No tools match "${t}". Try broader terms or call search_tools with empty query to see all namespaces.`};let n=t.toLowerCase().split(/\s+/).filter(Boolean);return{matches:e.map(i=>{let s=i.groups.flatMap(u=>Mh(u)),o=s.map(u=>`${u.name} ${u.searchHint??""} ${u.description}`.toLowerCase()),a=new Map(n.map(u=>{let f=o.filter(d=>d.includes(u)).length;return[u,Math.log((s.length+1)/(f+1))]})),c=s.map((u,f)=>{let d=o[f],p=n.reduce((h,A)=>d.includes(A)?h+(a.get(A)??0):h,0);return{tool:u,score:p}}).sort((u,f)=>f.score-u.score);return{namespace:i.name,description:i.description,tools:c.map(u=>({name:u.tool.name,description:u.tool.description.split(`
|
|
872
|
+
`)[0],...u.tool.searchHint?{searchHint:u.tool.searchHint}:{}}))}}),hint:"Call describe_tools with the tool names you need, then execute_tool to run them."}}function Lit(t){if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))return{error:"Invalid `tools` parameter. Expected string[]."};if(t.length===0)return{error:"Provide at least one tool name. Use search_tools first to discover tool names."};let e=[],r=[];for(let n of t){let i=iy(n);if(!i){r.push(n);continue}e.push({...sy(i),readOnly:i.readOnly,isDestructive:i.isDestructive??!1,isConcurrencySafe:i.isConcurrencySafe??!1,destructiveHint:!i.readOnly&&Ux(i),group:i.group})}return{tools:e,...r.length>0?{notFound:r,hint:`Tools not found: ${r.join(", ")}. Use search_tools to find correct names.`}:{}}}var Rbr,xbr,Tbr,Ph,sd,qx=re(()=>{"use strict";Mx();dv();$x();Rbr={name:"search_tools",description:"Search for available Jaz accounting tools by keyword. Returns matching tool namespaces with tool names and descriptions. Call with empty query to list all namespaces. ALWAYS call this first to discover what tools are available.",inputSchema:id({query:{type:"string",description:'Search keyword (e.g. "invoice", "bank recon", "depreciation"). Empty string lists all namespaces.'}},[])};xbr={name:"describe_tools",description:"Get full JSON Schema (parameters, types, required fields) for specific tools. Call this after search_tools to get the exact input format before calling execute_tool.",inputSchema:id({tools:{type:"array",items:{type:"string"},description:'Tool names to describe (e.g. ["create_invoice", "search_contacts"])'}},["tools"])},Tbr={name:"execute_tool",description:"Execute a Jaz accounting tool. Call describe_tools first to get the required parameters. Pass the tool name and its arguments.",inputSchema:id({tool:{type:"string",description:'Tool name (e.g. "create_invoice")'},arguments:{type:"object",description:"Tool arguments (see describe_tools for schema)"},org_id:{type:"string",description:"Organization ID (UUID). Required in multi-org mode (PAT or multiple API keys). Call list_organizations to get available IDs."}},["tool"])},Ph={name:"list_organizations",description:"List organizations available to the current authentication. Returns org names and resource IDs for use as org_id in execute_tool calls.",inputSchema:id({},[])},sd=[Rbr,xbr,Tbr]});var Hx=b(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.regexpCode=Dr.getEsmExportName=Dr.getProperty=Dr.safeStringify=Dr.stringify=Dr.strConcat=Dr.addCodeArg=Dr.str=Dr._=Dr.nil=Dr._Code=Dr.Name=Dr.IDENTIFIER=Dr._CodeOrName=void 0;var Yx=class{};Dr._CodeOrName=Yx;Dr.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var oy=class extends Yx{constructor(e){if(super(),!Dr.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Dr.Name=oy;var Lc=class extends Yx{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof oy&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Dr._Code=Lc;Dr.nil=new Lc("");function Uit(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Kue(r,e[n]),r.push(t[++n]);return new Lc(r)}Dr._=Uit;var Zue=new Lc("+");function qit(t,...e){let r=[zx(t[0])],n=0;for(;n<e.length;)r.push(Zue),Kue(r,e[n]),r.push(Zue,zx(t[++n]));return Mbr(r),new Lc(r)}Dr.str=qit;function Kue(t,e){e instanceof Lc?t.push(...e._items):e instanceof oy?t.push(e):t.push(Ubr(e))}Dr.addCodeArg=Kue;function Mbr(t){let e=1;for(;e<t.length-1;){if(t[e]===Zue){let r=Pbr(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Pbr(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof oy||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof oy))return`"${t}${e.slice(1)}`}function $br(t,e){return e.emptyStr()?t:t.emptyStr()?e:qit`${t}${e}`}Dr.strConcat=$br;function Ubr(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:zx(Array.isArray(t)?t.join(","):t)}function qbr(t){return new Lc(zx(t))}Dr.stringify=qbr;function zx(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Dr.safeStringify=zx;function jbr(t){return typeof t=="string"&&Dr.IDENTIFIER.test(t)?new Lc(`.${t}`):Uit`[${t}]`}Dr.getProperty=jbr;function Ybr(t){if(typeof t=="string"&&Dr.IDENTIFIER.test(t))return new Lc(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Dr.getEsmExportName=Ybr;function zbr(t){return new Lc(t.toString())}Dr.regexpCode=zbr});var tle=b(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.ValueScope=na.ValueScopeName=na.Scope=na.varKinds=na.UsedValueState=void 0;var ra=Hx(),Xue=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},k8;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(k8||(na.UsedValueState=k8={}));na.varKinds={const:new ra.Name("const"),let:new ra.Name("let"),var:new ra.Name("var")};var N8=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ra.Name?e:this.name(e)}name(e){return new ra.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};na.Scope=N8;var F8=class extends ra.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,ra._)`.${new ra.Name(r)}[${n}]`}};na.ValueScopeName=F8;var Hbr=(0,ra._)`\n`,ele=class extends N8{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Hbr:ra.nil}}get(){return this._scope}name(e){return new F8(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:s}=i,o=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let f=a.get(o);if(f)return f}else a=this._values[s]=new Map;a.set(o,i);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,i.setValue(r,{property:s,itemIndex:u}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,ra._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let s=ra.nil;for(let o in e){let a=e[o];if(!a)continue;let c=n[o]=n[o]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,k8.Started);let f=r(u);if(f){let d=this.opts.es5?na.varKinds.var:na.varKinds.const;s=(0,ra._)`${s}${d} ${u} = ${f};${this.opts._n}`}else if(f=i?.(u))s=(0,ra._)`${s}${f}${this.opts._n}`;else throw new Xue(u);c.set(u,k8.Completed)})}return s}};na.ValueScope=ele});var Pt=b(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.or=jt.and=jt.not=jt.CodeGen=jt.operators=jt.varKinds=jt.ValueScopeName=jt.ValueScope=jt.Scope=jt.Name=jt.regexpCode=jt.stringify=jt.getProperty=jt.nil=jt.strConcat=jt.str=jt._=void 0;var ur=Hx(),Fu=tle(),qh=Hx();Object.defineProperty(jt,"_",{enumerable:!0,get:function(){return qh._}});Object.defineProperty(jt,"str",{enumerable:!0,get:function(){return qh.str}});Object.defineProperty(jt,"strConcat",{enumerable:!0,get:function(){return qh.strConcat}});Object.defineProperty(jt,"nil",{enumerable:!0,get:function(){return qh.nil}});Object.defineProperty(jt,"getProperty",{enumerable:!0,get:function(){return qh.getProperty}});Object.defineProperty(jt,"stringify",{enumerable:!0,get:function(){return qh.stringify}});Object.defineProperty(jt,"regexpCode",{enumerable:!0,get:function(){return qh.regexpCode}});Object.defineProperty(jt,"Name",{enumerable:!0,get:function(){return qh.Name}});var M8=tle();Object.defineProperty(jt,"Scope",{enumerable:!0,get:function(){return M8.Scope}});Object.defineProperty(jt,"ValueScope",{enumerable:!0,get:function(){return M8.ValueScope}});Object.defineProperty(jt,"ValueScopeName",{enumerable:!0,get:function(){return M8.ValueScopeName}});Object.defineProperty(jt,"varKinds",{enumerable:!0,get:function(){return M8.varKinds}});jt.operators={GT:new ur._Code(">"),GTE:new ur._Code(">="),LT:new ur._Code("<"),LTE:new ur._Code("<="),EQ:new ur._Code("==="),NEQ:new ur._Code("!=="),NOT:new ur._Code("!"),OR:new ur._Code("||"),AND:new ur._Code("&&"),ADD:new ur._Code("+")};var ad=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},rle=class extends ad{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Fu.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Av(this.rhs,e,r)),this}get names(){return this.rhs instanceof ur._CodeOrName?this.rhs.names:{}}},O8=class extends ad{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ur.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Av(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ur.Name?{}:{...this.lhs.names};return L8(e,this.rhs)}},nle=class extends O8{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},ile=class extends ad{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},sle=class extends ad{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ole=class extends ad{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},ale=class extends ad{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Av(this.code,e,r),this}get names(){return this.code instanceof ur._CodeOrName?this.code.names:{}}},Gx=class extends ad{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let s=n[i];s.optimizeNames(e,r)||(Gbr(e,s.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>uy(e,r.names),{})}},cd=class extends Gx{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},cle=class extends Gx{},hv=class extends cd{};hv.kind="else";var ay=class t extends cd{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new hv(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(jit(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Av(this.condition,e,r),this}get names(){let e=super.names;return L8(e,this.condition),this.else&&uy(e,this.else.names),e}};ay.kind="if";var cy=class extends cd{};cy.kind="for";var ule=class extends cy{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Av(this.iteration,e,r),this}get names(){return uy(super.names,this.iteration.names)}},lle=class extends cy{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?Fu.varKinds.var:this.varKind,{name:n,from:i,to:s}=this;return`for(${r} ${n}=${i}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=L8(super.names,this.from);return L8(e,this.to)}},Q8=class extends cy{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Av(this.iterable,e,r),this}get names(){return uy(super.names,this.iterable.names)}},Vx=class extends cd{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Vx.kind="func";var Jx=class extends Gx{render(e){return"return "+super.render(e)}};Jx.kind="return";var fle=class extends cd{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&uy(e,this.catch.names),this.finally&&uy(e,this.finally.names),e}},Wx=class extends cd{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Wx.kind="catch";var Zx=class extends cd{render(e){return"finally"+super.render(e)}};Zx.kind="finally";var dle=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
873
873
|
`:""},this._extScope=e,this._scope=new Fu.Scope({parent:e}),this._nodes=[new cle]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let s=this._scope.toName(r);return n!==void 0&&i&&(this._constants[s.str]=n),this._leafNode(new rle(e,s,n)),s}const(e,r,n){return this._def(Fu.varKinds.const,e,r,n)}let(e,r,n){return this._def(Fu.varKinds.let,e,r,n)}var(e,r,n){return this._def(Fu.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new O8(e,r,n))}add(e,r){return this._leafNode(new nle(e,jt.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ur.nil&&this._leafNode(new ale(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,ur.addCodeArg)(r,i));return r.push("}"),new ur._Code(r)}if(e,r,n){if(this._blockNode(new ay(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new ay(e))}else(){return this._elseNode(new hv)}endIf(){return this._endBlockNode(ay,hv)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new ule(e),r)}forRange(e,r,n,i,s=this.opts.es5?Fu.varKinds.var:Fu.varKinds.let){let o=this._scope.toName(e);return this._for(new lle(s,o,r,n),()=>i(o))}forOf(e,r,n,i=Fu.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=r instanceof ur.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ur._)`${o}.length`,a=>{this.var(s,(0,ur._)`${o}[${a}]`),n(s)})}return this._for(new Q8("of",i,s,r),()=>n(s))}forIn(e,r,n,i=this.opts.es5?Fu.varKinds.var:Fu.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ur._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Q8("in",i,s,r),()=>n(s))}endFor(){return this._endBlockNode(cy)}label(e){return this._leafNode(new ile(e))}break(e){return this._leafNode(new sle(e))}return(e){let r=new Jx;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Jx)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new fle;if(this._blockNode(i),this.code(e),r){let s=this.name("e");this._currNode=i.catch=new Wx(s),r(s)}return n&&(this._currNode=i.finally=new Zx,this.code(n)),this._endBlockNode(Wx,Zx)}throw(e){return this._leafNode(new ole(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ur.nil,n,i){return this._blockNode(new Vx(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(Vx)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof ay))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};jt.CodeGen=dle;function uy(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function L8(t,e){return e instanceof ur._CodeOrName?uy(t,e.names):t}function Av(t,e,r){if(t instanceof ur.Name)return n(t);if(!i(t))return t;return new ur._Code(t._items.reduce((s,o)=>(o instanceof ur.Name&&(o=n(o)),o instanceof ur._Code?s.push(...o._items):s.push(o),s),[]));function n(s){let o=r[s.str];return o===void 0||e[s.str]!==1?s:(delete e[s.str],o)}function i(s){return s instanceof ur._Code&&s._items.some(o=>o instanceof ur.Name&&e[o.str]===1&&r[o.str]!==void 0)}}function Gbr(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function jit(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ur._)`!${ple(t)}`}jt.not=jit;var Vbr=Yit(jt.operators.AND);function Jbr(...t){return t.reduce(Vbr)}jt.and=Jbr;var Wbr=Yit(jt.operators.OR);function Zbr(...t){return t.reduce(Wbr)}jt.or=Zbr;function Yit(t){return(e,r)=>e===ur.nil?r:r===ur.nil?e:(0,ur._)`${ple(e)} ${t} ${ple(r)}`}function ple(t){return t instanceof ur.Name?t:(0,ur._)`(${t})`}});var Ar=b(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.checkStrictMode=Xt.getErrorPath=Xt.Type=Xt.useFunc=Xt.setEvaluated=Xt.evaluatedPropsToName=Xt.mergeEvaluated=Xt.eachItem=Xt.unescapeJsonPointer=Xt.escapeJsonPointer=Xt.escapeFragment=Xt.unescapeFragment=Xt.schemaRefOrVal=Xt.schemaHasRulesButRef=Xt.schemaHasRules=Xt.checkUnknownRules=Xt.alwaysValidSchema=Xt.toHash=void 0;var un=Pt(),Kbr=Hx();function Xbr(t){let e={};for(let r of t)e[r]=!0;return e}Xt.toHash=Xbr;function e0r(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Git(t,e),!Vit(e,t.self.RULES.all))}Xt.alwaysValidSchema=e0r;function Git(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let s in e)i[s]||Zit(t,`unknown keyword: "${s}"`)}Xt.checkUnknownRules=Git;function Vit(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Xt.schemaHasRules=Vit;function t0r(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Xt.schemaHasRulesButRef=t0r;function r0r({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,un._)`${r}`}return(0,un._)`${t}${e}${(0,un.getProperty)(n)}`}Xt.schemaRefOrVal=r0r;function n0r(t){return Jit(decodeURIComponent(t))}Xt.unescapeFragment=n0r;function i0r(t){return encodeURIComponent(Ale(t))}Xt.escapeFragment=i0r;function Ale(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Xt.escapeJsonPointer=Ale;function Jit(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Xt.unescapeJsonPointer=Jit;function s0r(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Xt.eachItem=s0r;function zit({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,s,o,a)=>{let c=o===void 0?s:o instanceof un.Name?(s instanceof un.Name?t(i,s,o):e(i,s,o),o):s instanceof un.Name?(e(i,o,s),s):r(s,o);return a===un.Name&&!(c instanceof un.Name)?n(i,c):c}}Xt.mergeEvaluated={props:zit({mergeNames:(t,e,r)=>t.if((0,un._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,un._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,un._)`${r} || {}`).code((0,un._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,un._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,un._)`${r} || {}`),mle(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Wit}),items:zit({mergeNames:(t,e,r)=>t.if((0,un._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,un._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,un._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,un._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Wit(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,un._)`{}`);return e!==void 0&&mle(t,r,e),r}Xt.evaluatedPropsToName=Wit;function mle(t,e,r){Object.keys(r).forEach(n=>t.assign((0,un._)`${e}${(0,un.getProperty)(n)}`,!0))}Xt.setEvaluated=mle;var Hit={};function o0r(t,e){return t.scopeValue("func",{ref:e,code:Hit[e.code]||(Hit[e.code]=new Kbr._Code(e.code))})}Xt.useFunc=o0r;var hle;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(hle||(Xt.Type=hle={}));function a0r(t,e,r){if(t instanceof un.Name){let n=e===hle.Num;return r?n?(0,un._)`"[" + ${t} + "]"`:(0,un._)`"['" + ${t} + "']"`:n?(0,un._)`"/" + ${t}`:(0,un._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,un.getProperty)(t).toString():"/"+Ale(t)}Xt.getErrorPath=a0r;function Zit(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Xt.checkStrictMode=Zit});var ud=b(gle=>{"use strict";Object.defineProperty(gle,"__esModule",{value:!0});var to=Pt(),c0r={data:new to.Name("data"),valCxt:new to.Name("valCxt"),instancePath:new to.Name("instancePath"),parentData:new to.Name("parentData"),parentDataProperty:new to.Name("parentDataProperty"),rootData:new to.Name("rootData"),dynamicAnchors:new to.Name("dynamicAnchors"),vErrors:new to.Name("vErrors"),errors:new to.Name("errors"),this:new to.Name("this"),self:new to.Name("self"),scope:new to.Name("scope"),json:new to.Name("json"),jsonPos:new to.Name("jsonPos"),jsonLen:new to.Name("jsonLen"),jsonPart:new to.Name("jsonPart")};gle.default=c0r});var Kx=b(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.extendErrors=ro.resetErrorsCount=ro.reportExtraError=ro.reportError=ro.keyword$DataError=ro.keywordError=void 0;var mr=Pt(),P8=Ar(),Ro=ud();ro.keywordError={message:({keyword:t})=>(0,mr.str)`must pass "${t}" keyword validation`};ro.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,mr.str)`"${t}" keyword must be ${e} ($data)`:(0,mr.str)`"${t}" keyword is invalid ($data)`};function u0r(t,e=ro.keywordError,r,n){let{it:i}=t,{gen:s,compositeRule:o,allErrors:a}=i,c=est(t,e,r);n??(o||a)?Kit(s,c):Xit(i,(0,mr._)`[${c}]`)}ro.reportError=u0r;function l0r(t,e=ro.keywordError,r){let{it:n}=t,{gen:i,compositeRule:s,allErrors:o}=n,a=est(t,e,r);Kit(i,a),s||o||Xit(n,Ro.default.vErrors)}ro.reportExtraError=l0r;function f0r(t,e){t.assign(Ro.default.errors,e),t.if((0,mr._)`${Ro.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,mr._)`${Ro.default.vErrors}.length`,e),()=>t.assign(Ro.default.vErrors,null)))}ro.resetErrorsCount=f0r;function d0r({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:s}){if(i===void 0)throw new Error("ajv implementation error");let o=t.name("err");t.forRange("i",i,Ro.default.errors,a=>{t.const(o,(0,mr._)`${Ro.default.vErrors}[${a}]`),t.if((0,mr._)`${o}.instancePath === undefined`,()=>t.assign((0,mr._)`${o}.instancePath`,(0,mr.strConcat)(Ro.default.instancePath,s.errorPath))),t.assign((0,mr._)`${o}.schemaPath`,(0,mr.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,mr._)`${o}.schema`,r),t.assign((0,mr._)`${o}.data`,n))})}ro.extendErrors=d0r;function Kit(t,e){let r=t.const("err",e);t.if((0,mr._)`${Ro.default.vErrors} === null`,()=>t.assign(Ro.default.vErrors,(0,mr._)`[${r}]`),(0,mr._)`${Ro.default.vErrors}.push(${r})`),t.code((0,mr._)`${Ro.default.errors}++`)}function Xit(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,mr._)`new ${t.ValidationError}(${e})`):(r.assign((0,mr._)`${n}.errors`,e),r.return(!1))}var ly={keyword:new mr.Name("keyword"),schemaPath:new mr.Name("schemaPath"),params:new mr.Name("params"),propertyName:new mr.Name("propertyName"),message:new mr.Name("message"),schema:new mr.Name("schema"),parentSchema:new mr.Name("parentSchema")};function est(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,mr._)`{}`:p0r(t,e,r)}function p0r(t,e,r={}){let{gen:n,it:i}=t,s=[h0r(i,r),A0r(t,r)];return m0r(t,e,s),n.object(...s)}function h0r({errorPath:t},{instancePath:e}){let r=e?(0,mr.str)`${t}${(0,P8.getErrorPath)(e,P8.Type.Str)}`:t;return[Ro.default.instancePath,(0,mr.strConcat)(Ro.default.instancePath,r)]}function A0r({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,mr.str)`${e}/${t}`;return r&&(i=(0,mr.str)`${i}${(0,P8.getErrorPath)(r,P8.Type.Str)}`),[ly.schemaPath,i]}function m0r(t,{params:e,message:r},n){let{keyword:i,data:s,schemaValue:o,it:a}=t,{opts:c,propertyName:u,topSchemaRef:f,schemaPath:d}=a;n.push([ly.keyword,i],[ly.params,typeof e=="function"?e(t):e||(0,mr._)`{}`]),c.messages&&n.push([ly.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([ly.schema,o],[ly.parentSchema,(0,mr._)`${f}${d}`],[Ro.default.data,s]),u&&n.push([ly.propertyName,u])}});var rst=b(mv=>{"use strict";Object.defineProperty(mv,"__esModule",{value:!0});mv.boolOrEmptySchema=mv.topBoolOrEmptySchema=void 0;var g0r=Kx(),y0r=Pt(),E0r=ud(),b0r={message:"boolean schema is false"};function C0r(t){let{gen:e,schema:r,validateName:n}=t;r===!1?tst(t,!1):typeof r=="object"&&r.$async===!0?e.return(E0r.default.data):(e.assign((0,y0r._)`${n}.errors`,null),e.return(!0))}mv.topBoolOrEmptySchema=C0r;function v0r(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),tst(t)):r.var(e,!0)}mv.boolOrEmptySchema=v0r;function tst(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,g0r.reportError)(i,b0r,void 0,e)}});var yle=b(gv=>{"use strict";Object.defineProperty(gv,"__esModule",{value:!0});gv.getRules=gv.isJSONType=void 0;var w0r=["string","number","integer","boolean","null","object","array"],I0r=new Set(w0r);function _0r(t){return typeof t=="string"&&I0r.has(t)}gv.isJSONType=_0r;function D0r(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}gv.getRules=D0r});var Ele=b(jh=>{"use strict";Object.defineProperty(jh,"__esModule",{value:!0});jh.shouldUseRule=jh.shouldUseGroup=jh.schemaHasRulesForType=void 0;function S0r({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&nst(t,n)}jh.schemaHasRulesForType=S0r;function nst(t,e){return e.rules.some(r=>ist(t,r))}jh.shouldUseGroup=nst;function ist(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}jh.shouldUseRule=ist});var Xx=b(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.reportTypeError=no.checkDataTypes=no.checkDataType=no.coerceAndCheckDataType=no.getJSONTypes=no.getSchemaTypes=no.DataType=void 0;var B0r=yle(),R0r=Ele(),x0r=Kx(),Lt=Pt(),sst=Ar(),yv;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(yv||(no.DataType=yv={}));function T0r(t){let e=ost(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}no.getSchemaTypes=T0r;function ost(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(B0r.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}no.getJSONTypes=ost;function k0r(t,e){let{gen:r,data:n,opts:i}=t,s=N0r(e,i.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,R0r.schemaHasRulesForType)(t,e[0]));if(o){let a=Cle(e,n,i.strictNumbers,yv.Wrong);r.if(a,()=>{s.length?F0r(t,e,s):vle(t)})}return o}no.coerceAndCheckDataType=k0r;var ast=new Set(["string","number","integer","boolean","null"]);function N0r(t,e){return e?t.filter(r=>ast.has(r)||e==="array"&&r==="array"):[]}function F0r(t,e,r){let{gen:n,data:i,opts:s}=t,o=n.let("dataType",(0,Lt._)`typeof ${i}`),a=n.let("coerced",(0,Lt._)`undefined`);s.coerceTypes==="array"&&n.if((0,Lt._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,Lt._)`${i}[0]`).assign(o,(0,Lt._)`typeof ${i}`).if(Cle(e,i,s.strictNumbers),()=>n.assign(a,i))),n.if((0,Lt._)`${a} !== undefined`);for(let u of r)(ast.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),vle(t),n.endIf(),n.if((0,Lt._)`${a} !== undefined`,()=>{n.assign(i,a),O0r(t,a)});function c(u){switch(u){case"string":n.elseIf((0,Lt._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Lt._)`"" + ${i}`).elseIf((0,Lt._)`${i} === null`).assign(a,(0,Lt._)`""`);return;case"number":n.elseIf((0,Lt._)`${o} == "boolean" || ${i} === null
|
|
874
874
|
|| (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,Lt._)`+${i}`);return;case"integer":n.elseIf((0,Lt._)`${o} === "boolean" || ${i} === null
|
|
875
875
|
|| (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,Lt._)`+${i}`);return;case"boolean":n.elseIf((0,Lt._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,Lt._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Lt._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Lt._)`${o} === "string" || ${o} === "number"
|