jaz-clio 4.34.5 → 4.34.6
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 +3 -2
- package/assets/skills/cli/SKILL.md +1 -1
- package/assets/skills/conversion/SKILL.md +1 -1
- package/assets/skills/jobs/SKILL.md +1 -1
- package/assets/skills/transaction-recipes/SKILL.md +1 -1
- package/dist/commands/magic.js +14 -0
- package/dist/core/api/magic.js +2 -6
- package/dist/core/registry/tools.js +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: jaz-api
|
|
3
|
-
version: 4.34.
|
|
3
|
+
version: 4.34.6
|
|
4
4
|
description: >-
|
|
5
5
|
Use this skill whenever you call, debug, or review code that touches the Jaz
|
|
6
6
|
REST API. Covers field names, response shapes, 117 production gotchas, error
|
|
@@ -150,7 +150,8 @@ You are working with the **Jaz REST API** — the accounting platform backend. A
|
|
|
150
150
|
### Jaz Magic — Extraction & Autofill
|
|
151
151
|
57. **When the user starts from an attachment, always use Jaz Magic** — if the input is a PDF, JPG, or any document image (invoice, bill, receipt), the correct path is `POST /magic/createBusinessTransactionFromAttachment`. Do NOT manually construct a `POST /invoices` or `POST /bills` payload from an attachment — Jaz Magic handles the entire extraction-and-autofill pipeline server-side: OCR, line item detection, contact matching, CoA auto-mapping via ML learning, and draft creation with all fields pre-filled. Only use `POST /invoices` or `POST /bills` when building transactions from structured data (JSON, CSV, database rows) where the fields are already known.
|
|
152
152
|
58. **Two upload modes with different content types** — `sourceType: "FILE"` requires **multipart/form-data** with `sourceFile` blob (JSON body fails with 400 "sourceFile is a required field"). `sourceType: "URL"` accepts **application/json** with `sourceURL` string. The OAS only documents URL mode — FILE mode (the common case) is undocumented.
|
|
153
|
-
59. **Three required fields**: `sourceFile` (multipart blob — NOT `file`), `businessTransactionType` (`"INVOICE"`, `"BILL"`, `"CUSTOMER_CREDIT_NOTE"`, or `"SUPPLIER_CREDIT_NOTE"` — `EXPENSE` rejected), `sourceType` (`"FILE"` or `"URL"`). All
|
|
153
|
+
59. **Three required fields + one optional**: `sourceFile` (multipart blob — NOT `file`), `businessTransactionType` (`"INVOICE"`, `"BILL"`, `"CUSTOMER_CREDIT_NOTE"`, or `"SUPPLIER_CREDIT_NOTE"` — `EXPENSE` rejected), `sourceType` (`"FILE"` or `"URL"`). Optional: `uploadMode` (`"SEPARATE"` default, or `"MERGED"` for a single PDF containing multiple documents — the backend splits it via boundary detection before extraction). All required fields are validated server-side. **CRITICAL: multipart form field names are camelCase** — `businessTransactionType`, `sourceType`, `sourceFile`, `uploadMode`, NOT snake_case. Using `business_transaction_type` returns 422 "businessTransactionType is a required field". The File blob must include a filename and correct MIME type (e.g. `application/pdf`, `image/jpeg`) — bare `application/octet-stream` blobs are rejected with 400 "Invalid file type".
|
|
154
|
+
59a. **MERGED upload workflow tracking** — When `uploadMode: "MERGED"`, the upload response `workflowResourceId` is a **parent** tracking ID. The backend splits the PDF, then creates **child** workflows for each split page — these child IDs appear in `POST /magic/workflows/search` (by fileName or createdAt), NOT the parent ID. To track MERGED progress, search by `fileName` rather than the parent `workflowResourceId`.
|
|
154
155
|
60. **Response maps transaction types**: Request `INVOICE` → response `SALE`. Request `BILL` → response `PURCHASE`. Request `CUSTOMER_CREDIT_NOTE` → response `SALE_CREDIT_NOTE`. Request `SUPPLIER_CREDIT_NOTE` → response `PURCHASE_CREDIT_NOTE`. S3 paths follow the response type. The response `validFiles[]` array contains `workflowResourceId` for tracking extraction progress via `POST /magic/workflows/search`.
|
|
155
156
|
61. **Extraction is asynchronous** — the API response is immediate (file upload confirmation only). The actual Magic pipeline — OCR, line item extraction, contact matching, CoA learning, and autofill — runs asynchronously. Use `POST /magic/workflows/search` with `filter.resourceId.eq: "<workflowResourceId>"` to check status (SUBMITTED → PROCESSING → COMPLETED/FAILED). When COMPLETED, `businessTransactionDetails.businessTransactionResourceId` contains the created draft BT ID. The `subscriptionFBPath` in the response is a Firebase Realtime Database path for real-time status updates (alternative to polling).
|
|
156
157
|
62. **Accepts PDF and JPG/JPEG** — both file types confirmed working. Handwritten documents are accepted at upload stage (extraction quality varies). `fileType` in response reflects actual format: `"PDF"`, `"JPEG"`.
|
package/dist/commands/magic.js
CHANGED
|
@@ -51,6 +51,7 @@ export function registerMagicCommand(program) {
|
|
|
51
51
|
.option('--file <path>', 'Local file path (PDF, JPG, PNG, HEIC, XLS, XLSX, EML, ZIP). ZIP: extracts and uploads each file. Encrypted PDFs: name__pw__password.pdf')
|
|
52
52
|
.option('--url <url>', 'Remote file URL (alternative to --file)')
|
|
53
53
|
.option('--type <type>', `Document type: ${VALID_TYPES}`)
|
|
54
|
+
.option('--merged', 'Treat file as a merged PDF containing multiple documents (split before extraction)')
|
|
54
55
|
.option('--api-key <key>', 'API key (overrides stored/env)')
|
|
55
56
|
.option('--json', 'Output as JSON')
|
|
56
57
|
.action(apiAction(async (client, opts) => {
|
|
@@ -72,6 +73,18 @@ export function registerMagicCommand(program) {
|
|
|
72
73
|
console.error(chalk.red(`Error: invalid type "${opts.type}". Valid: ${VALID_TYPES}`));
|
|
73
74
|
process.exit(1);
|
|
74
75
|
}
|
|
76
|
+
// Validate --merged constraints
|
|
77
|
+
if (opts.merged) {
|
|
78
|
+
if (opts.url) {
|
|
79
|
+
console.error(chalk.red('Error: --merged is only supported with --file, not --url'));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const ext = extname(opts.file).toLowerCase();
|
|
83
|
+
if (ext !== '.pdf') {
|
|
84
|
+
console.error(chalk.red('Error: --merged requires a PDF file (got ' + ext + ')'));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
75
88
|
let sourceFile;
|
|
76
89
|
let sourceFileName;
|
|
77
90
|
let decryptedPath;
|
|
@@ -105,6 +118,7 @@ export function registerMagicCommand(program) {
|
|
|
105
118
|
sourceFile,
|
|
106
119
|
sourceFileName,
|
|
107
120
|
sourceUrl: opts.url,
|
|
121
|
+
uploadMode: opts.merged ? 'MERGED' : undefined,
|
|
108
122
|
});
|
|
109
123
|
const data = res.data;
|
|
110
124
|
const validFile = data.validFiles?.[0];
|
package/dist/core/api/magic.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// ── API Functions ────────────────────────────────────────────────
|
|
2
|
-
/**
|
|
3
|
-
* Upload a file or URL to create a draft business transaction via OCR extraction.
|
|
4
|
-
* Processing is async — response returns immediately with workflowResourceId.
|
|
5
|
-
* Use searchMagicWorkflows() to check status.
|
|
6
|
-
*/
|
|
7
1
|
export async function createFromAttachment(client, data) {
|
|
8
2
|
const formData = new FormData();
|
|
9
3
|
formData.append('businessTransactionType', data.businessTransactionType);
|
|
@@ -14,6 +8,8 @@ export async function createFromAttachment(client, data) {
|
|
|
14
8
|
formData.append('sourceUrl', data.sourceUrl);
|
|
15
9
|
if (data.attachmentId)
|
|
16
10
|
formData.append('attachmentId', data.attachmentId);
|
|
11
|
+
if (data.uploadMode)
|
|
12
|
+
formData.append('uploadMode', data.uploadMode);
|
|
17
13
|
return client.postMultipart('/api/v1/magic/createBusinessTransactionFromAttachment', formData);
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
@@ -2675,6 +2675,7 @@ Dynamic strings for reference/name/notes: {{Day}}, {{Date}}, {{Date+X}}, {{DateR
|
|
|
2675
2675
|
},
|
|
2676
2676
|
sourceUrl: { type: 'string', description: 'URL of the source file' },
|
|
2677
2677
|
attachmentId: { type: 'string', description: 'Attachment ID (alternative to URL)' },
|
|
2678
|
+
uploadMode: { type: 'string', enum: ['SEPARATE', 'MERGED'], description: 'Upload mode: SEPARATE (default, one doc per file) or MERGED (single PDF with multiple docs, auto-split before extraction). MERGED only works with PDF files.' },
|
|
2678
2679
|
},
|
|
2679
2680
|
required: ['businessTransactionType'],
|
|
2680
2681
|
group: 'magic',
|
|
@@ -2687,6 +2688,7 @@ Dynamic strings for reference/name/notes: {{Day}}, {{Date}}, {{Date+X}}, {{DateR
|
|
|
2687
2688
|
businessTransactionType: input.businessTransactionType,
|
|
2688
2689
|
sourceUrl: input.sourceUrl,
|
|
2689
2690
|
attachmentId: input.attachmentId,
|
|
2691
|
+
uploadMode: input.uploadMode,
|
|
2690
2692
|
});
|
|
2691
2693
|
},
|
|
2692
2694
|
},
|