jaz-clio 4.35.2 → 4.46.0
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/README.md +65 -223
- package/assets/skills/api/SKILL.md +6 -2
- package/assets/skills/api/help-center-mirror/bank-reconciliations.md +20 -10
- package/assets/skills/api/help-center-mirror/bills.md +46 -38
- package/assets/skills/api/help-center-mirror/contacts.md +61 -62
- package/assets/skills/api/help-center-mirror/get-started.md +7 -2
- package/assets/skills/api/help-center-mirror/help-center-embeddings.json +1 -1
- package/assets/skills/api/help-center-mirror/help-center-index.json +1 -1
- package/assets/skills/api/help-center-mirror/import-data.md +22 -17
- package/assets/skills/api/help-center-mirror/index.md +2 -3
- package/assets/skills/api/help-center-mirror/security-privacy.md +1 -1
- package/assets/skills/api/help-center-mirror/settings.md +102 -31
- package/assets/skills/api/references/endpoints.md +87 -0
- package/assets/skills/api/references/full-api-surface.md +3 -1
- 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/cli.mjs +1642 -0
- package/help-center-mirror/ai-agents.md +142 -0
- package/help-center-mirror/approvals.md +68 -0
- package/help-center-mirror/bank-reconciliations.md +662 -0
- package/help-center-mirror/bills.md +1122 -0
- package/help-center-mirror/cashflow.md +105 -0
- package/help-center-mirror/collaboration.md +58 -0
- package/help-center-mirror/contacts.md +199 -0
- package/help-center-mirror/customer-credits.md +745 -0
- package/help-center-mirror/deposits.md +75 -0
- package/help-center-mirror/get-started.md +478 -0
- package/help-center-mirror/help-center-embeddings.json +1 -0
- package/help-center-mirror/help-center-index.json +1 -0
- package/help-center-mirror/import-data.md +256 -0
- package/help-center-mirror/index.md +22 -0
- package/help-center-mirror/invoices.md +1389 -0
- package/help-center-mirror/journal-entries.md +350 -0
- package/help-center-mirror/products.md +201 -0
- package/help-center-mirror/reports.md +852 -0
- package/help-center-mirror/security-privacy.md +42 -0
- package/help-center-mirror/settings.md +1778 -0
- package/help-center-mirror/supplier-credits.md +703 -0
- package/package.json +6 -35
- package/dist/commands/accounts.js +0 -128
- package/dist/commands/api-action.js +0 -73
- package/dist/commands/attachments.js +0 -152
- package/dist/commands/auth.js +0 -407
- package/dist/commands/bank-rules.js +0 -178
- package/dist/commands/bank.js +0 -239
- package/dist/commands/bills.js +0 -643
- package/dist/commands/bookmarks.js +0 -121
- package/dist/commands/calc.js +0 -317
- package/dist/commands/capsules.js +0 -212
- package/dist/commands/cash-entry.js +0 -246
- package/dist/commands/cash-transfer.js +0 -171
- package/dist/commands/cashflow.js +0 -49
- package/dist/commands/contact-groups.js +0 -109
- package/dist/commands/contacts.js +0 -227
- package/dist/commands/currencies.js +0 -46
- package/dist/commands/currency-rates.js +0 -140
- package/dist/commands/custom-fields.js +0 -187
- package/dist/commands/customer-credit-notes.js +0 -516
- package/dist/commands/draft-helpers.js +0 -136
- package/dist/commands/exports.js +0 -58
- package/dist/commands/fixed-assets.js +0 -330
- package/dist/commands/format-helpers.js +0 -49
- package/dist/commands/help-examples.js +0 -127
- package/dist/commands/init.js +0 -95
- package/dist/commands/inventory.js +0 -82
- package/dist/commands/invoices.js +0 -620
- package/dist/commands/items.js +0 -223
- package/dist/commands/jobs.js +0 -943
- package/dist/commands/journals.js +0 -437
- package/dist/commands/kb.js +0 -68
- package/dist/commands/magic.js +0 -490
- package/dist/commands/mcp.js +0 -223
- package/dist/commands/nano-classifiers.js +0 -173
- package/dist/commands/org-users.js +0 -164
- package/dist/commands/org.js +0 -32
- package/dist/commands/output.js +0 -121
- package/dist/commands/pagination.js +0 -82
- package/dist/commands/parsers.js +0 -173
- package/dist/commands/payments.js +0 -143
- package/dist/commands/picker.js +0 -223
- package/dist/commands/quick-fix.js +0 -123
- package/dist/commands/recipe.js +0 -429
- package/dist/commands/reports.js +0 -202
- package/dist/commands/resolve.js +0 -278
- package/dist/commands/schedulers.js +0 -449
- package/dist/commands/schema.js +0 -231
- package/dist/commands/search.js +0 -34
- package/dist/commands/subscriptions.js +0 -212
- package/dist/commands/supplier-credit-notes.js +0 -500
- package/dist/commands/table-formatter.js +0 -5
- package/dist/commands/tags.js +0 -142
- package/dist/commands/tax-profiles.js +0 -187
- package/dist/commands/ui/banner.js +0 -21
- package/dist/commands/ui/error.js +0 -96
- package/dist/commands/ui/index.js +0 -8
- package/dist/commands/ui/picker.js +0 -180
- package/dist/commands/ui/progress.js +0 -32
- package/dist/commands/ui/record.js +0 -72
- package/dist/commands/ui/table.js +0 -109
- package/dist/commands/ui/theme.js +0 -55
- package/dist/commands/update.js +0 -28
- package/dist/commands/versions.js +0 -33
- package/dist/core/api/attachments.js +0 -36
- package/dist/core/api/bank-rules.js +0 -31
- package/dist/core/api/bank.js +0 -37
- package/dist/core/api/bills.js +0 -61
- package/dist/core/api/bookmarks.js +0 -12
- package/dist/core/api/capsules.js +0 -46
- package/dist/core/api/cash-entries.js +0 -31
- package/dist/core/api/cash-transfers.js +0 -12
- package/dist/core/api/cashflow.js +0 -6
- package/dist/core/api/chart-of-accounts.js +0 -21
- package/dist/core/api/circuit-breaker.js +0 -64
- package/dist/core/api/client.js +0 -223
- package/dist/core/api/contact-groups.js +0 -18
- package/dist/core/api/contacts.js +0 -18
- package/dist/core/api/currencies.js +0 -23
- package/dist/core/api/custom-fields.js +0 -18
- package/dist/core/api/customer-cn.js +0 -40
- package/dist/core/api/data-exports.js +0 -7
- package/dist/core/api/fixed-assets.js +0 -37
- package/dist/core/api/guards.js +0 -82
- package/dist/core/api/index.js +0 -39
- package/dist/core/api/inventory.js +0 -12
- package/dist/core/api/invoices.js +0 -72
- package/dist/core/api/items.js +0 -56
- package/dist/core/api/journals.js +0 -34
- package/dist/core/api/magic.js +0 -74
- package/dist/core/api/message-pdf.js +0 -7
- package/dist/core/api/nano-classifiers.js +0 -37
- package/dist/core/api/org-users.js +0 -15
- package/dist/core/api/organization.js +0 -6
- package/dist/core/api/pagination.js +0 -74
- package/dist/core/api/payments.js +0 -27
- package/dist/core/api/quick-fix.js +0 -25
- package/dist/core/api/reports.js +0 -51
- package/dist/core/api/schedulers.js +0 -54
- package/dist/core/api/search.js +0 -6
- package/dist/core/api/subscriptions.js +0 -48
- package/dist/core/api/supplier-cn.js +0 -37
- package/dist/core/api/tags.js +0 -18
- package/dist/core/api/tax-profiles.js +0 -23
- package/dist/core/api/transfer-trial-balance.js +0 -3
- package/dist/core/api/types.js +0 -2
- package/dist/core/auth/credentials.js +0 -155
- package/dist/core/auth/index.js +0 -2
- package/dist/core/auth/resolve.js +0 -99
- package/dist/core/auth/types.js +0 -1
- package/dist/core/calc/accrued-expense.js +0 -74
- package/dist/core/calc/amortization.js +0 -122
- package/dist/core/calc/asset-disposal.js +0 -155
- package/dist/core/calc/blueprint.js +0 -46
- package/dist/core/calc/depreciation.js +0 -200
- package/dist/core/calc/dividend.js +0 -100
- package/dist/core/calc/ecl.js +0 -101
- package/dist/core/calc/fixed-deposit.js +0 -178
- package/dist/core/calc/format.js +0 -604
- package/dist/core/calc/fx-reval.js +0 -93
- package/dist/core/calc/lease.js +0 -150
- package/dist/core/calc/leave-accrual.js +0 -73
- package/dist/core/calc/loan.js +0 -107
- package/dist/core/calc/provision.js +0 -128
- package/dist/core/calc/types.js +0 -31
- package/dist/core/calc/validate.js +0 -134
- package/dist/core/drafts/index.js +0 -14
- package/dist/core/drafts/merge.js +0 -86
- package/dist/core/drafts/sanitize.js +0 -90
- package/dist/core/drafts/validate.js +0 -157
- package/dist/core/intelligence/account-resolver.js +0 -48
- package/dist/core/intelligence/actions-summary.js +0 -152
- package/dist/core/intelligence/amount-parser.js +0 -101
- package/dist/core/intelligence/bank-resolver.js +0 -65
- package/dist/core/intelligence/contact-resolver.js +0 -28
- package/dist/core/intelligence/date-normalizer.js +0 -146
- package/dist/core/intelligence/fuzzy.js +0 -102
- package/dist/core/intelligence/index.js +0 -19
- package/dist/core/intelligence/no-reply.js +0 -58
- package/dist/core/intelligence/recipe-resolver.js +0 -106
- package/dist/core/jobs/audit-prep/blueprint.js +0 -211
- package/dist/core/jobs/bank-recon/blueprint.js +0 -163
- package/dist/core/jobs/bank-recon/tools/match/match-utils.js +0 -218
- package/dist/core/jobs/bank-recon/tools/match/match.js +0 -631
- package/dist/core/jobs/credit-control/blueprint.js +0 -126
- package/dist/core/jobs/document-collection/blueprint.js +0 -152
- package/dist/core/jobs/document-collection/tools/ingest/classify.js +0 -206
- package/dist/core/jobs/document-collection/tools/ingest/cloud/dropbox.js +0 -156
- package/dist/core/jobs/document-collection/tools/ingest/cloud/gdrive.js +0 -99
- package/dist/core/jobs/document-collection/tools/ingest/cloud/index.js +0 -68
- package/dist/core/jobs/document-collection/tools/ingest/cloud/onedrive.js +0 -165
- package/dist/core/jobs/document-collection/tools/ingest/cloud/providers.js +0 -71
- package/dist/core/jobs/document-collection/tools/ingest/cloud/types.js +0 -4
- package/dist/core/jobs/document-collection/tools/ingest/cloud/utils.js +0 -96
- package/dist/core/jobs/document-collection/tools/ingest/cloud/zip.js +0 -107
- package/dist/core/jobs/document-collection/tools/ingest/decrypt.js +0 -130
- package/dist/core/jobs/document-collection/tools/ingest/format.js +0 -110
- package/dist/core/jobs/document-collection/tools/ingest/ingest.js +0 -101
- package/dist/core/jobs/document-collection/tools/ingest/scanner.js +0 -215
- package/dist/core/jobs/document-collection/tools/ingest/upload.js +0 -108
- package/dist/core/jobs/fa-review/blueprint.js +0 -121
- package/dist/core/jobs/format.js +0 -102
- package/dist/core/jobs/gst-vat/blueprint.js +0 -187
- package/dist/core/jobs/month-end/blueprint.js +0 -232
- package/dist/core/jobs/payment-run/blueprint.js +0 -201
- package/dist/core/jobs/payment-run/tools/bank-file/format.js +0 -64
- package/dist/core/jobs/payment-run/tools/bank-file/formats/dbs-giro.js +0 -177
- package/dist/core/jobs/payment-run/tools/bank-file/formats/index.js +0 -3
- package/dist/core/jobs/payment-run/tools/bank-file/formats/ocbc-giro.js +0 -171
- package/dist/core/jobs/payment-run/tools/bank-file/formats/uob-giro.js +0 -240
- package/dist/core/jobs/payment-run/tools/bank-file/generate.js +0 -24
- package/dist/core/jobs/payment-run/tools/bank-file/index.js +0 -3
- package/dist/core/jobs/payment-run/tools/bank-file/types.js +0 -25
- package/dist/core/jobs/payment-run/tools/bank-file/validate.js +0 -217
- package/dist/core/jobs/payment-run/tools/outstanding/format.js +0 -61
- package/dist/core/jobs/payment-run/tools/outstanding/group.js +0 -90
- package/dist/core/jobs/payment-run/tools/outstanding/index.js +0 -2
- package/dist/core/jobs/payment-run/tools/outstanding/types.js +0 -5
- package/dist/core/jobs/quarter-end/blueprint.js +0 -135
- package/dist/core/jobs/statutory-filing/blueprint.js +0 -135
- package/dist/core/jobs/statutory-filing/tools/sg-tax/capital-allowances.js +0 -160
- package/dist/core/jobs/statutory-filing/tools/sg-tax/constants.js +0 -63
- package/dist/core/jobs/statutory-filing/tools/sg-tax/exemptions.js +0 -76
- package/dist/core/jobs/statutory-filing/tools/sg-tax/form-cs.js +0 -349
- package/dist/core/jobs/statutory-filing/tools/sg-tax/format-sg.js +0 -134
- package/dist/core/jobs/statutory-filing/tools/sg-tax/format.js +0 -18
- package/dist/core/jobs/statutory-filing/tools/sg-tax/types.js +0 -9
- package/dist/core/jobs/statutory-filing/tools/sg-tax/validate.js +0 -124
- package/dist/core/jobs/supplier-recon/blueprint.js +0 -132
- package/dist/core/jobs/types.js +0 -38
- package/dist/core/jobs/validate.js +0 -115
- package/dist/core/jobs/year-end/blueprint.js +0 -153
- package/dist/core/kb/embeddings.js +0 -218
- package/dist/core/kb/index.js +0 -2
- package/dist/core/kb/search.js +0 -235
- package/dist/core/kb/types.js +0 -2
- package/dist/core/recipe/dispatch.js +0 -155
- package/dist/core/recipe/engine.js +0 -304
- package/dist/core/recipe/index.js +0 -3
- package/dist/core/recipe/plan.js +0 -60
- package/dist/core/recipe/types.js +0 -16
- package/dist/core/registry/errors.js +0 -31
- package/dist/core/registry/index.js +0 -3
- package/dist/core/registry/lookup.js +0 -35
- package/dist/core/registry/namespaces.js +0 -161
- package/dist/core/registry/pagination.js +0 -150
- package/dist/core/registry/tools.js +0 -4482
- package/dist/core/registry/types.js +0 -1
- package/dist/core/registry/validate.js +0 -82
- package/dist/index.js +0 -322
- package/dist/types/index.js +0 -8
- package/dist/utils/github.js +0 -81
- package/dist/utils/logger.js +0 -31
- package/dist/utils/template.js +0 -105
package/dist/commands/picker.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { showPicker, isCancel } from './ui/picker.js';
|
|
2
|
-
import { accent, muted } from './ui/theme.js';
|
|
3
|
-
// ── Category map ────────────────────────────────────────────────────
|
|
4
|
-
const CATEGORIES = {
|
|
5
|
-
invoices: 'AR',
|
|
6
|
-
'customer-credit-notes': 'AR',
|
|
7
|
-
bills: 'AP',
|
|
8
|
-
'supplier-credit-notes': 'AP',
|
|
9
|
-
journals: 'Acctg',
|
|
10
|
-
'cash-in': 'Acctg',
|
|
11
|
-
'cash-out': 'Acctg',
|
|
12
|
-
'cash-transfer': 'Acctg',
|
|
13
|
-
bank: 'Banking',
|
|
14
|
-
payments: 'Banking',
|
|
15
|
-
cashflow: 'Banking',
|
|
16
|
-
contacts: 'Data',
|
|
17
|
-
accounts: 'Data',
|
|
18
|
-
items: 'Data',
|
|
19
|
-
tags: 'Data',
|
|
20
|
-
capsules: 'Data',
|
|
21
|
-
currencies: 'Data',
|
|
22
|
-
'currency-rates': 'Data',
|
|
23
|
-
'tax-profiles': 'Data',
|
|
24
|
-
bookmarks: 'Data',
|
|
25
|
-
'org-users': 'Data',
|
|
26
|
-
attachments: 'Data',
|
|
27
|
-
calc: 'Calc',
|
|
28
|
-
'capsule-transaction': 'Recipes',
|
|
29
|
-
jobs: 'Jobs',
|
|
30
|
-
reports: 'Reports',
|
|
31
|
-
exports: 'Reports',
|
|
32
|
-
schedulers: 'Reports',
|
|
33
|
-
magic: 'AI',
|
|
34
|
-
'help-center': 'AI',
|
|
35
|
-
context: 'AI',
|
|
36
|
-
init: 'Setup',
|
|
37
|
-
update: 'Setup',
|
|
38
|
-
versions: 'Setup',
|
|
39
|
-
auth: 'Setup',
|
|
40
|
-
org: 'Setup',
|
|
41
|
-
};
|
|
42
|
-
const CATEGORY_ORDER = [
|
|
43
|
-
'AR', 'AP', 'Acctg', 'Banking', 'Jobs', 'Calc', 'Recipes',
|
|
44
|
-
'Reports', 'Data', 'AI', 'Setup',
|
|
45
|
-
];
|
|
46
|
-
const CATEGORY_HINTS = {
|
|
47
|
-
AR: 'Invoices, credit notes, payments',
|
|
48
|
-
AP: 'Bills, supplier credit notes',
|
|
49
|
-
Acctg: 'Journals, cash in/out/transfer',
|
|
50
|
-
Banking: 'Bank, reconciliation, cashflow',
|
|
51
|
-
Jobs: 'Month-end, recon, tax filing',
|
|
52
|
-
Calc: 'Loan, lease, depreciation, ECL',
|
|
53
|
-
Recipes: 'Capsule transactions (IFRS)',
|
|
54
|
-
Reports: 'TB, P&L, balance sheet, exports',
|
|
55
|
-
Data: 'Contacts, accounts, items, tags',
|
|
56
|
-
AI: 'Magic extraction, help center',
|
|
57
|
-
Setup: 'Auth, org, init, update',
|
|
58
|
-
};
|
|
59
|
-
const SKIP = new Set(['serve', 'mcp', 'help']);
|
|
60
|
-
// ── Collect leaf commands ───────────────────────────────────────────
|
|
61
|
-
function collectLeaves(commands, prefix, category) {
|
|
62
|
-
const leaves = [];
|
|
63
|
-
for (const cmd of commands) {
|
|
64
|
-
const name = cmd.name();
|
|
65
|
-
if (SKIP.has(name))
|
|
66
|
-
continue;
|
|
67
|
-
const path = prefix ? `${prefix} ${name}` : name;
|
|
68
|
-
const cat = prefix ? category : (CATEGORIES[name] ?? 'Other');
|
|
69
|
-
const subs = cmd.commands.filter(c => !SKIP.has(c.name()));
|
|
70
|
-
const hasOwnAction = cmd._actionHandler != null;
|
|
71
|
-
if (subs.length > 0) {
|
|
72
|
-
if (hasOwnAction)
|
|
73
|
-
leaves.push({ path, description: cmd.description(), category: cat });
|
|
74
|
-
leaves.push(...collectLeaves(subs, path, cat));
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
leaves.push({ path, description: cmd.description(), category: cat });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return leaves;
|
|
81
|
-
}
|
|
82
|
-
function truncateDesc(desc, max) {
|
|
83
|
-
const short = desc.split(/[.;—]/).shift()?.trim() ?? desc;
|
|
84
|
-
return short.length <= max ? short : short.slice(0, max - 1) + '…';
|
|
85
|
-
}
|
|
86
|
-
// ── TTY guard ───────────────────────────────────────────────────────
|
|
87
|
-
export function shouldShowPicker() {
|
|
88
|
-
if (!process.stdout.isTTY || !process.stdin.isTTY)
|
|
89
|
-
return false;
|
|
90
|
-
const args = process.argv.slice(2);
|
|
91
|
-
return !args.some(a => a === '--json' || a === '--help' || a === '-h' ||
|
|
92
|
-
a === '--version' || a === '-V');
|
|
93
|
-
}
|
|
94
|
-
// ── Top-level picker ────────────────────────────────────────────────
|
|
95
|
-
export async function showCommandPicker(program, authInfo) {
|
|
96
|
-
const leaves = collectLeaves(program.commands, '', '');
|
|
97
|
-
const version = program.version() ?? '';
|
|
98
|
-
const safe = (s) => s.replace(/[\x00-\x1F\x7F]/g, '').replace(/\x1B\[[0-9;]*[A-Za-z]/g, '');
|
|
99
|
-
// Build header
|
|
100
|
-
let headerText = `Clio v${version}`;
|
|
101
|
-
if (authInfo) {
|
|
102
|
-
headerText += ` ${muted('·')} ${safe(authInfo.label)} ${muted('·')} ${safe(authInfo.orgName)} (${safe(authInfo.currency)})`;
|
|
103
|
-
if (authInfo.otherOrgCount > 0)
|
|
104
|
-
headerText += ` ${muted(`+${authInfo.otherOrgCount} more`)}`;
|
|
105
|
-
}
|
|
106
|
-
// ── Level 1: Categories ──
|
|
107
|
-
while (true) {
|
|
108
|
-
const categoryItems = CATEGORY_ORDER.map(cat => {
|
|
109
|
-
const count = leaves.filter(l => l.category === cat).length;
|
|
110
|
-
return {
|
|
111
|
-
label: cat,
|
|
112
|
-
value: cat,
|
|
113
|
-
hint: `${String(count).padStart(3)} commands ${CATEGORY_HINTS[cat] ?? ''}`,
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
const category = await showPicker({
|
|
117
|
-
header: headerText,
|
|
118
|
-
items: categoryItems,
|
|
119
|
-
});
|
|
120
|
-
if (isCancel(category))
|
|
121
|
-
process.exit(0);
|
|
122
|
-
// ── Level 2: Commands in category ──
|
|
123
|
-
const catLeaves = leaves
|
|
124
|
-
.filter(l => l.category === category)
|
|
125
|
-
.sort((a, b) => a.path.localeCompare(b.path));
|
|
126
|
-
const descBudget = Math.max(20, (process.stdout.columns || 80) - 44);
|
|
127
|
-
const commandItems = [
|
|
128
|
-
{ label: '← Back', value: '__back__', hint: 'Return to categories' },
|
|
129
|
-
...catLeaves.map(leaf => ({
|
|
130
|
-
label: leaf.path,
|
|
131
|
-
value: leaf.path,
|
|
132
|
-
hint: truncateDesc(leaf.description, descBudget),
|
|
133
|
-
})),
|
|
134
|
-
];
|
|
135
|
-
const selected = await showPicker({
|
|
136
|
-
header: `${accent(String(category))} ${muted('·')} ${catLeaves.length} commands`,
|
|
137
|
-
items: commandItems,
|
|
138
|
-
filterable: true,
|
|
139
|
-
});
|
|
140
|
-
if (isCancel(selected))
|
|
141
|
-
process.exit(0);
|
|
142
|
-
if (selected === '__back__')
|
|
143
|
-
continue;
|
|
144
|
-
return selected;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// ── Subcommand picker ───────────────────────────────────────────────
|
|
148
|
-
async function showSubcommandPicker(parent, parentPath) {
|
|
149
|
-
const topLevel = parentPath.split(' ')[0];
|
|
150
|
-
const category = CATEGORIES[topLevel] ?? 'Other';
|
|
151
|
-
const leaves = collectLeaves(parent.commands, parentPath, category)
|
|
152
|
-
.sort((a, b) => a.path.localeCompare(b.path));
|
|
153
|
-
const descBudget = Math.max(20, (process.stdout.columns || 80) - 44);
|
|
154
|
-
const items = leaves.map(leaf => ({
|
|
155
|
-
label: leaf.path,
|
|
156
|
-
value: leaf.path,
|
|
157
|
-
hint: truncateDesc(leaf.description, descBudget),
|
|
158
|
-
}));
|
|
159
|
-
const result = await showPicker({
|
|
160
|
-
header: `clio ${parentPath}`,
|
|
161
|
-
items,
|
|
162
|
-
filterable: items.length > 10,
|
|
163
|
-
});
|
|
164
|
-
if (isCancel(result))
|
|
165
|
-
process.exit(0);
|
|
166
|
-
return result ?? null;
|
|
167
|
-
}
|
|
168
|
-
// ── Attach subcommand pickers ───────────────────────────────────────
|
|
169
|
-
export function attachSubcommandPickers(program) {
|
|
170
|
-
function recurse(parent, parentPath) {
|
|
171
|
-
for (const cmd of parent.commands) {
|
|
172
|
-
const name = cmd.name();
|
|
173
|
-
if (SKIP.has(name))
|
|
174
|
-
continue;
|
|
175
|
-
const path = parentPath ? `${parentPath} ${name}` : name;
|
|
176
|
-
const subs = cmd.commands.filter(c => !SKIP.has(c.name()));
|
|
177
|
-
if (subs.length > 0) {
|
|
178
|
-
const hasOwnAction = cmd._actionHandler != null;
|
|
179
|
-
if (!hasOwnAction) {
|
|
180
|
-
cmd.action(async () => {
|
|
181
|
-
const selected = await showSubcommandPicker(cmd, path);
|
|
182
|
-
if (!selected)
|
|
183
|
-
process.exit(0);
|
|
184
|
-
await program.parseAsync(['node', 'clio', ...selected.split(' ')]);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
else if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
188
|
-
const originalAction = cmd._actionHandler;
|
|
189
|
-
let inDisambiguation = false;
|
|
190
|
-
cmd._actionHandler = async (...args) => {
|
|
191
|
-
if (inDisambiguation)
|
|
192
|
-
return originalAction.call(cmd, ...args);
|
|
193
|
-
inDisambiguation = true;
|
|
194
|
-
try {
|
|
195
|
-
const items = [
|
|
196
|
-
{ label: `${name} (default)`, value: '__default__', hint: truncateDesc(cmd.description(), 50) },
|
|
197
|
-
...subs.map(sub => ({
|
|
198
|
-
label: `${name} ${sub.name()}`,
|
|
199
|
-
value: sub.name(),
|
|
200
|
-
hint: truncateDesc(sub.description(), 50),
|
|
201
|
-
})),
|
|
202
|
-
];
|
|
203
|
-
const action = await showPicker({
|
|
204
|
-
header: `clio ${path}`,
|
|
205
|
-
items,
|
|
206
|
-
});
|
|
207
|
-
if (isCancel(action))
|
|
208
|
-
process.exit(0);
|
|
209
|
-
if (action === '__default__')
|
|
210
|
-
return originalAction.call(cmd, ...args);
|
|
211
|
-
await program.parseAsync(['node', 'clio', ...path.split(' '), action]);
|
|
212
|
-
}
|
|
213
|
-
finally {
|
|
214
|
-
inDisambiguation = false;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
recurse(cmd, path);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
recurse(program, '');
|
|
223
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { accent, danger, success } from './ui/theme.js';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { quickFix, quickFixLineItems, QUICK_FIX_ENTITIES } from '../core/api/quick-fix.js';
|
|
4
|
-
import { apiAction } from './api-action.js';
|
|
5
|
-
function parseJson(source, label) {
|
|
6
|
-
try {
|
|
7
|
-
return JSON.parse(source);
|
|
8
|
-
}
|
|
9
|
-
catch (err) {
|
|
10
|
-
console.error(danger(`Invalid JSON in ${label}: ${err.message}`));
|
|
11
|
-
process.exitCode = 1;
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function registerQuickFixCommand(program) {
|
|
16
|
-
const cmd = program
|
|
17
|
-
.command('quick-fix <entity>')
|
|
18
|
-
.description('Bulk-update transactions or line items in one call')
|
|
19
|
-
.addHelpText('after', `
|
|
20
|
-
Entities (grouped by domain):
|
|
21
|
-
ARAP: invoices, bills, customer-credit-notes, supplier-credit-notes
|
|
22
|
-
Accounting: journals, cash-entries
|
|
23
|
-
Schedulers: sale-schedules, purchase-schedules, subscription-schedules, journal-schedules
|
|
24
|
-
|
|
25
|
-
Examples:
|
|
26
|
-
clio quick-fix invoices --ids id1,id2 --attributes '{"valueDate":"2026-01-15","tag":"Q1"}'
|
|
27
|
-
clio quick-fix bills --ids id1 --date 2026-02-01 --due 2026-03-01 --tag Marketing
|
|
28
|
-
clio quick-fix journals --line-items --ids li1,li2 --attributes '{"organizationAccountResourceId":"<uuid>"}'
|
|
29
|
-
clio quick-fix sale-schedules --line-items --input scheduler-updates.json`)
|
|
30
|
-
.option('--ids <csv>', 'Comma-separated resourceIds (transaction or line item)')
|
|
31
|
-
.option('--line-items', 'Target line items instead of transactions')
|
|
32
|
-
.option('--attributes <json>', 'Attributes JSON object')
|
|
33
|
-
.option('--input <file>', 'Read attributes/body from JSON file')
|
|
34
|
-
.option('--date <date>', 'Shorthand: set valueDate (YYYY-MM-DD)')
|
|
35
|
-
.option('--due <date>', 'Shorthand: set dueDate (YYYY-MM-DD)')
|
|
36
|
-
.option('--tag <name>', 'Shorthand: set tag')
|
|
37
|
-
.option('--contact <id>', 'Shorthand: set contactResourceId')
|
|
38
|
-
.option('--account <id>', 'Shorthand: set organizationAccountResourceId (line items)')
|
|
39
|
-
.option('--tax-profile <id>', 'Shorthand: set taxProfileResourceId (line items)')
|
|
40
|
-
.option('--api-key <key>', 'API key')
|
|
41
|
-
.option('--json', 'JSON output')
|
|
42
|
-
.action((entity, opts) => apiAction(async (client) => {
|
|
43
|
-
// ── Validate entity ──────────────────────────────────────
|
|
44
|
-
if (!QUICK_FIX_ENTITIES.includes(entity)) {
|
|
45
|
-
console.error(danger(`Unknown entity: ${entity}`));
|
|
46
|
-
console.error(`Valid entities: ${QUICK_FIX_ENTITIES.join(', ')}`);
|
|
47
|
-
process.exitCode = 1;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
// ── Build body ───────────────────────────────────────────
|
|
51
|
-
if (opts.input) {
|
|
52
|
-
const raw = parseJson(readFileSync(opts.input, 'utf-8'), '--input');
|
|
53
|
-
if (!raw)
|
|
54
|
-
return;
|
|
55
|
-
const result = opts.lineItems
|
|
56
|
-
? await quickFixLineItems(client, entity, raw)
|
|
57
|
-
: await quickFix(client, entity, raw);
|
|
58
|
-
formatResult(result, opts.json);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const ids = opts.ids ? opts.ids.split(',').map((s) => s.trim()).filter(Boolean) : [];
|
|
62
|
-
if (ids.length === 0) {
|
|
63
|
-
console.error(danger('--ids is required (comma-separated resourceIds)'));
|
|
64
|
-
process.exitCode = 1;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
// Merge --attributes JSON with shorthand flags
|
|
68
|
-
let attrs = {};
|
|
69
|
-
if (opts.attributes) {
|
|
70
|
-
const parsed = parseJson(opts.attributes, '--attributes');
|
|
71
|
-
if (!parsed)
|
|
72
|
-
return;
|
|
73
|
-
attrs = parsed;
|
|
74
|
-
}
|
|
75
|
-
if (opts.date)
|
|
76
|
-
attrs.valueDate = opts.date;
|
|
77
|
-
if (opts.due)
|
|
78
|
-
attrs.dueDate = opts.due;
|
|
79
|
-
if (opts.tag)
|
|
80
|
-
attrs.tags = [opts.tag];
|
|
81
|
-
if (opts.contact)
|
|
82
|
-
attrs.contactResourceId = opts.contact;
|
|
83
|
-
if (opts.account)
|
|
84
|
-
attrs.organizationAccountResourceId = opts.account;
|
|
85
|
-
if (opts.taxProfile)
|
|
86
|
-
attrs.taxProfileResourceId = opts.taxProfile;
|
|
87
|
-
if (opts.lineItems) {
|
|
88
|
-
const result = await quickFixLineItems(client, entity, {
|
|
89
|
-
lineItemResourceIds: ids,
|
|
90
|
-
attributes: attrs,
|
|
91
|
-
});
|
|
92
|
-
formatResult(result, opts.json);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const result = await quickFix(client, entity, {
|
|
96
|
-
resourceIds: ids,
|
|
97
|
-
attributes: attrs,
|
|
98
|
-
});
|
|
99
|
-
formatResult(result, opts.json);
|
|
100
|
-
}
|
|
101
|
-
})(opts));
|
|
102
|
-
}
|
|
103
|
-
function formatResult(result, json) {
|
|
104
|
-
if (json) {
|
|
105
|
-
console.log(JSON.stringify(result, null, 2));
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (result.updated.length > 0) {
|
|
109
|
-
console.log(success(`Updated ${result.updated.length} item(s):`));
|
|
110
|
-
for (const id of result.updated)
|
|
111
|
-
console.log(` ${accent(id)}`);
|
|
112
|
-
}
|
|
113
|
-
if (result.failed.length > 0) {
|
|
114
|
-
console.log(danger(`Failed ${result.failed.length} item(s):`));
|
|
115
|
-
for (const f of result.failed) {
|
|
116
|
-
console.log(` ${accent(f.resourceId)} ${danger(f.error)} (${f.errorCode})`);
|
|
117
|
-
}
|
|
118
|
-
process.exitCode = 1;
|
|
119
|
-
}
|
|
120
|
-
if (result.updated.length === 0 && result.failed.length === 0) {
|
|
121
|
-
console.log('No items processed.');
|
|
122
|
-
}
|
|
123
|
-
}
|