@go-labs-sg/bb 2.19.0 → 2.23.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 +64 -27
- package/command-manifest.json +775 -4
- package/command-reference.md +29 -4
- package/dist/index.js +21134 -1997
- package/package.json +2 -2
- package/role-aware-agent-guide.md +4 -2
- package/dist/api-client.js +0 -93
- package/dist/cli-trace.js +0 -86
- package/dist/commands.js +0 -2299
- package/dist/filter-enums.js +0 -58
- package/dist/load-env.js +0 -6
- package/dist/parse-args.js +0 -55
- package/dist/parse-cli-enums.js +0 -336
- package/dist/parse-json-flag.js +0 -20
- package/dist/parse-mutation-payload.js +0 -363
- package/dist/prisma-enums.js +0 -81
- package/dist/registry/generate-command-artifacts.js +0 -36
- package/dist/registry/index.js +0 -633
- package/dist/rich-text.js +0 -34
- package/dist/runtime/confirmation.js +0 -76
- package/dist/runtime/error.js +0 -143
- package/dist/runtime/index.js +0 -6
- package/dist/runtime/output.js +0 -36
- package/dist/runtime/process-runtime.js +0 -28
- package/dist/runtime/sanitize.js +0 -50
- package/dist/runtime/session.js +0 -50
- package/dist/runtime/types.js +0 -1
package/dist/registry/index.js
DELETED
|
@@ -1,633 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Declarative command catalogue for the Budget Builder CLI.
|
|
3
|
-
*
|
|
4
|
-
* The first v2 integration step uses `legacyTarget` to dispatch through the
|
|
5
|
-
* established command implementation. New command handlers can replace that
|
|
6
|
-
* target incrementally by supplying `load` instead.
|
|
7
|
-
*/
|
|
8
|
-
export const globalCommandOptions = [
|
|
9
|
-
{ name: "--help", description: "Show help for this command." },
|
|
10
|
-
{ name: "--quiet", description: "Suppress non-error diagnostics." },
|
|
11
|
-
{ name: "--debug", description: "Emit sanitized diagnostic traces." },
|
|
12
|
-
{
|
|
13
|
-
name: "--api-url",
|
|
14
|
-
description: "Override the Budget Builder API base URL.",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: "--allow-state-change",
|
|
18
|
-
description: "Allow a Budget Builder state change in non-interactive use.",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "--allow-email",
|
|
22
|
-
description: "Allow sending email in non-interactive use.",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "--allow-external-write",
|
|
26
|
-
description: "Allow writes to external systems in non-interactive use.",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "--allow-delete",
|
|
30
|
-
description: "Allow deleting data in non-interactive use.",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "--allow-financial-write",
|
|
34
|
-
description: "Allow financial-record changes in non-interactive use.",
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
const mutationPrefixes = [
|
|
38
|
-
"add-",
|
|
39
|
-
"approve-",
|
|
40
|
-
"archive-",
|
|
41
|
-
"attach-",
|
|
42
|
-
"cleanup-",
|
|
43
|
-
"complete-",
|
|
44
|
-
"create-",
|
|
45
|
-
"delete-",
|
|
46
|
-
"discard-",
|
|
47
|
-
"import-",
|
|
48
|
-
"mark-",
|
|
49
|
-
"patch-",
|
|
50
|
-
"reactivate-",
|
|
51
|
-
"reconcile-",
|
|
52
|
-
"reject-",
|
|
53
|
-
"remove-",
|
|
54
|
-
"replace-",
|
|
55
|
-
"rename-",
|
|
56
|
-
"reorder-",
|
|
57
|
-
"restore-",
|
|
58
|
-
"retry-",
|
|
59
|
-
"revoke-",
|
|
60
|
-
"save-",
|
|
61
|
-
"send-",
|
|
62
|
-
"stage-",
|
|
63
|
-
"setup-",
|
|
64
|
-
"submit-",
|
|
65
|
-
"sync-",
|
|
66
|
-
"update-",
|
|
67
|
-
"upload-",
|
|
68
|
-
"void-",
|
|
69
|
-
];
|
|
70
|
-
const emailTargets = new Set([
|
|
71
|
-
"approve-bill",
|
|
72
|
-
"approve-budget",
|
|
73
|
-
"approve-customer-invoice",
|
|
74
|
-
"approve-supplier",
|
|
75
|
-
"create-bill",
|
|
76
|
-
"create-bill-approval",
|
|
77
|
-
"create-budget-approval",
|
|
78
|
-
"create-customer-invoice",
|
|
79
|
-
"create-supplier",
|
|
80
|
-
"reject-bill",
|
|
81
|
-
"reject-budget",
|
|
82
|
-
"reject-customer-invoice",
|
|
83
|
-
"reject-supplier",
|
|
84
|
-
"send-estimate-email",
|
|
85
|
-
"send-estimate-to-contact-person",
|
|
86
|
-
"send-customer-invoice-to-contact-person",
|
|
87
|
-
"update-bill-status",
|
|
88
|
-
"update-supplier",
|
|
89
|
-
]);
|
|
90
|
-
const externalWriteTargets = new Set([
|
|
91
|
-
"approve-bill",
|
|
92
|
-
"approve-customer-invoice",
|
|
93
|
-
"approve-supplier",
|
|
94
|
-
"complete-project",
|
|
95
|
-
"create-bill",
|
|
96
|
-
"create-company",
|
|
97
|
-
"create-estimate",
|
|
98
|
-
"create-placeholder-bill",
|
|
99
|
-
"create-customer-invoice",
|
|
100
|
-
"create-item",
|
|
101
|
-
"create-item-category",
|
|
102
|
-
"create-project",
|
|
103
|
-
"create-supplier",
|
|
104
|
-
"delete-bill",
|
|
105
|
-
"delete-budget",
|
|
106
|
-
"delete-company",
|
|
107
|
-
"delete-customer-invoice",
|
|
108
|
-
"delete-item",
|
|
109
|
-
"delete-project",
|
|
110
|
-
"delete-suppliers",
|
|
111
|
-
"discard-customer-invoice",
|
|
112
|
-
"import-qbo-project",
|
|
113
|
-
"mark-budget-items-not-utilized",
|
|
114
|
-
"mark-budget-won",
|
|
115
|
-
"reconcile-project",
|
|
116
|
-
"reject-customer-invoice",
|
|
117
|
-
"reactivate-suppliers",
|
|
118
|
-
"restore-budget-item",
|
|
119
|
-
"restore-budget-version",
|
|
120
|
-
"retry-integration-operation",
|
|
121
|
-
"setup-project-hub",
|
|
122
|
-
"sync-project-hub-commercial-documents",
|
|
123
|
-
"sync-customer-invoice",
|
|
124
|
-
"update-bill",
|
|
125
|
-
"update-budget-status",
|
|
126
|
-
"update-company",
|
|
127
|
-
"update-item",
|
|
128
|
-
"update-item-category",
|
|
129
|
-
"update-project",
|
|
130
|
-
"update-project-status",
|
|
131
|
-
"update-supplier",
|
|
132
|
-
"void-customer-invoice",
|
|
133
|
-
]);
|
|
134
|
-
const financialWriteTargets = new Set([
|
|
135
|
-
"approve-bill",
|
|
136
|
-
"approve-customer-invoice",
|
|
137
|
-
"complete-project",
|
|
138
|
-
"create-bill",
|
|
139
|
-
"create-customer-invoice",
|
|
140
|
-
"create-estimate",
|
|
141
|
-
"create-placeholder-bill",
|
|
142
|
-
"delete-budget-commission",
|
|
143
|
-
"delete-budget-discount",
|
|
144
|
-
"delete-bill",
|
|
145
|
-
"delete-budget",
|
|
146
|
-
"delete-customer-invoice",
|
|
147
|
-
"mark-budget-items-not-utilized",
|
|
148
|
-
"mark-budget-won",
|
|
149
|
-
"patch-bill-payment",
|
|
150
|
-
"reject-customer-invoice",
|
|
151
|
-
"restore-budget-item",
|
|
152
|
-
"restore-budget-version",
|
|
153
|
-
"replace-budget-item",
|
|
154
|
-
"sync-customer-invoice",
|
|
155
|
-
"update-bill",
|
|
156
|
-
"update-bill-payment-evidence",
|
|
157
|
-
"update-bill-status",
|
|
158
|
-
"update-budget-commission",
|
|
159
|
-
"update-budget-discount",
|
|
160
|
-
"update-budget-status",
|
|
161
|
-
"update-project-status",
|
|
162
|
-
"void-customer-invoice",
|
|
163
|
-
]);
|
|
164
|
-
const deleteTargets = new Set([
|
|
165
|
-
"cleanup-staged-bill-attachments",
|
|
166
|
-
"cleanup-staged-quotation-attachments",
|
|
167
|
-
"discard-customer-invoice",
|
|
168
|
-
"complete-project",
|
|
169
|
-
"mark-budget-items-not-utilized",
|
|
170
|
-
"remove-budget-item",
|
|
171
|
-
"restore-budget-version",
|
|
172
|
-
"update-project-status",
|
|
173
|
-
]);
|
|
174
|
-
const effectsFor = (legacyTarget) => {
|
|
175
|
-
const effects = new Set();
|
|
176
|
-
if (mutationPrefixes.some((prefix) => legacyTarget.startsWith(prefix))) {
|
|
177
|
-
effects.add("state-change");
|
|
178
|
-
}
|
|
179
|
-
if (legacyTarget.startsWith("delete-") || deleteTargets.has(legacyTarget)) {
|
|
180
|
-
effects.add("delete");
|
|
181
|
-
}
|
|
182
|
-
if (emailTargets.has(legacyTarget))
|
|
183
|
-
effects.add("email");
|
|
184
|
-
if (externalWriteTargets.has(legacyTarget))
|
|
185
|
-
effects.add("external-write");
|
|
186
|
-
if (financialWriteTargets.has(legacyTarget))
|
|
187
|
-
effects.add("financial-write");
|
|
188
|
-
return [...effects];
|
|
189
|
-
};
|
|
190
|
-
const titleCase = (value) => value
|
|
191
|
-
.split("-")
|
|
192
|
-
.map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`)
|
|
193
|
-
.join(" ");
|
|
194
|
-
const summaryFor = (legacyTarget) => {
|
|
195
|
-
if (legacyTarget === "whoami")
|
|
196
|
-
return "Show the active API-key identity.";
|
|
197
|
-
if (legacyTarget === "download-customer-invoice-pdf") {
|
|
198
|
-
return "Download a customer invoice PDF when permitted.";
|
|
199
|
-
}
|
|
200
|
-
if (legacyTarget === "send-customer-invoice-to-contact-person") {
|
|
201
|
-
return "Send a customer invoice and update the project billing email.";
|
|
202
|
-
}
|
|
203
|
-
if (legacyTarget.startsWith("list-")) {
|
|
204
|
-
return `List ${legacyTarget.slice("list-".length).replaceAll("-", " ")}.`;
|
|
205
|
-
}
|
|
206
|
-
if (legacyTarget.startsWith("get-")) {
|
|
207
|
-
return `Get ${legacyTarget.slice("get-".length).replaceAll("-", " ")}.`;
|
|
208
|
-
}
|
|
209
|
-
return `${titleCase(legacyTarget)}.`;
|
|
210
|
-
};
|
|
211
|
-
const aliasesFor = (legacyTarget, aliases) => [
|
|
212
|
-
...new Set([legacyTarget, ...aliases].flatMap((alias) => [
|
|
213
|
-
alias,
|
|
214
|
-
alias.replaceAll("-", "_"),
|
|
215
|
-
])),
|
|
216
|
-
];
|
|
217
|
-
const legacyCommand = (legacyTarget, path, aliases = [], commandOptions = []) => ({
|
|
218
|
-
path,
|
|
219
|
-
legacyAliases: aliasesFor(legacyTarget, aliases),
|
|
220
|
-
summary: summaryFor(legacyTarget),
|
|
221
|
-
options: [...globalCommandOptions, ...commandOptions],
|
|
222
|
-
effects: effectsFor(legacyTarget),
|
|
223
|
-
legacyTarget,
|
|
224
|
-
});
|
|
225
|
-
const registry = [
|
|
226
|
-
legacyCommand("whoami", ["auth", "whoami"]),
|
|
227
|
-
legacyCommand("list-budgets", ["budget", "list"]),
|
|
228
|
-
legacyCommand("get-budget", ["budget", "get"]),
|
|
229
|
-
legacyCommand("upload-budget-attachment", ["budget", "attachment", "upload"]),
|
|
230
|
-
legacyCommand("mark-budget-won", ["budget", "won", "mark"]),
|
|
231
|
-
legacyCommand("get-budget-items", ["budget", "item", "list"]),
|
|
232
|
-
legacyCommand("get-budget-details", ["budget", "detail", "get"]),
|
|
233
|
-
legacyCommand("get-budget-categories", ["budget", "category", "list"]),
|
|
234
|
-
legacyCommand("get-budget-versions", ["budget", "version", "list"]),
|
|
235
|
-
legacyCommand("rename-budget-version", ["budget", "version", "rename"]),
|
|
236
|
-
legacyCommand("restore-budget-version", ["budget", "version", "restore"]),
|
|
237
|
-
legacyCommand("update-budget-status", ["budget", "status", "update"]),
|
|
238
|
-
legacyCommand("create-budget-approval", ["budget", "approval", "create"]),
|
|
239
|
-
legacyCommand("create-estimate", ["budget", "estimate", "create"]),
|
|
240
|
-
legacyCommand("send-estimate-to-contact-person", ["budget", "estimate", "send"], ["send-estimate-email"]),
|
|
241
|
-
legacyCommand("create-budget", ["budget", "create"]),
|
|
242
|
-
legacyCommand("update-budget", ["budget", "update"]),
|
|
243
|
-
legacyCommand("delete-budget", ["budget", "delete"]),
|
|
244
|
-
legacyCommand("add-budget-items", ["budget", "item", "add"]),
|
|
245
|
-
legacyCommand("update-budget-item", ["budget", "item", "update"]),
|
|
246
|
-
legacyCommand("remove-budget-item", ["budget", "item", "remove"]),
|
|
247
|
-
legacyCommand("replace-budget-item", ["budget", "item", "replace"]),
|
|
248
|
-
legacyCommand("approve-unavailable-item-exception", [
|
|
249
|
-
"budget",
|
|
250
|
-
"item",
|
|
251
|
-
"exception",
|
|
252
|
-
"approve",
|
|
253
|
-
]),
|
|
254
|
-
legacyCommand("reorder-budget-items", ["budget", "item", "reorder"]),
|
|
255
|
-
legacyCommand("update-budget-item-supplier", [
|
|
256
|
-
"budget",
|
|
257
|
-
"item",
|
|
258
|
-
"supplier",
|
|
259
|
-
"update",
|
|
260
|
-
]),
|
|
261
|
-
legacyCommand("create-budget-category", ["budget", "category", "create"]),
|
|
262
|
-
legacyCommand("update-budget-category", ["budget", "category", "update"]),
|
|
263
|
-
legacyCommand("delete-budget-category", ["budget", "category", "delete"]),
|
|
264
|
-
legacyCommand("update-budget-commission", ["budget", "commission", "update"]),
|
|
265
|
-
legacyCommand("update-budget-discount", ["budget", "discount", "update"]),
|
|
266
|
-
legacyCommand("delete-budget-commission", ["budget", "commission", "delete"]),
|
|
267
|
-
legacyCommand("delete-budget-discount", ["budget", "discount", "delete"]),
|
|
268
|
-
legacyCommand("mark-budget-items-not-utilized", [
|
|
269
|
-
"budget",
|
|
270
|
-
"item",
|
|
271
|
-
"mark-not-utilized",
|
|
272
|
-
]),
|
|
273
|
-
legacyCommand("restore-budget-item", ["budget", "item", "restore"]),
|
|
274
|
-
legacyCommand("create-placeholder-bill", [
|
|
275
|
-
"budget",
|
|
276
|
-
"item",
|
|
277
|
-
"placeholder-bill",
|
|
278
|
-
"create",
|
|
279
|
-
]),
|
|
280
|
-
legacyCommand("list-bills", ["bill", "list"]),
|
|
281
|
-
legacyCommand("list-claims", ["claim", "list"]),
|
|
282
|
-
legacyCommand("create-bill-approval", ["bill", "approval", "create"]),
|
|
283
|
-
legacyCommand("create-bill", ["bill", "create"]),
|
|
284
|
-
legacyCommand("validate-bill-selection", ["bill", "selection", "validate"]),
|
|
285
|
-
legacyCommand("update-bill", ["bill", "update"]),
|
|
286
|
-
legacyCommand("update-bill-payment-evidence", [
|
|
287
|
-
"bill",
|
|
288
|
-
"payment-evidence",
|
|
289
|
-
"update",
|
|
290
|
-
]),
|
|
291
|
-
legacyCommand("delete-bill", ["bill", "delete"]),
|
|
292
|
-
legacyCommand("update-bill-status", ["bill", "status", "update"]),
|
|
293
|
-
legacyCommand("patch-bill-payment", ["bill", "payment", "patch"]),
|
|
294
|
-
legacyCommand("patch-bill-invoice-number", [
|
|
295
|
-
"bill",
|
|
296
|
-
"invoice-number",
|
|
297
|
-
"patch",
|
|
298
|
-
]),
|
|
299
|
-
legacyCommand("get-bill-attachments", ["bill", "attachment", "list"]),
|
|
300
|
-
legacyCommand("stage-bill-attachment", ["bill", "attachment", "stage"]),
|
|
301
|
-
legacyCommand("cleanup-staged-bill-attachments", [
|
|
302
|
-
"bill",
|
|
303
|
-
"attachment",
|
|
304
|
-
"staged",
|
|
305
|
-
"cleanup",
|
|
306
|
-
]),
|
|
307
|
-
legacyCommand("upload-bill-attachment", ["bill", "attachment", "upload"], ["attach-bill-attachment"]),
|
|
308
|
-
legacyCommand("attach-bill-payment-receipt", [
|
|
309
|
-
"bill",
|
|
310
|
-
"payment-receipt",
|
|
311
|
-
"attach",
|
|
312
|
-
]),
|
|
313
|
-
legacyCommand("attach-bill-documents", ["bill", "document", "attach"]),
|
|
314
|
-
legacyCommand("get-bill-details", ["bill", "get"]),
|
|
315
|
-
legacyCommand("list-quotations", ["quotation", "list"]),
|
|
316
|
-
legacyCommand("get-quotation", ["quotation", "get"]),
|
|
317
|
-
legacyCommand("upload-quotation-attachment", [
|
|
318
|
-
"quotation",
|
|
319
|
-
"attachment",
|
|
320
|
-
"upload",
|
|
321
|
-
]),
|
|
322
|
-
legacyCommand("cleanup-staged-quotation-attachments", [
|
|
323
|
-
"quotation",
|
|
324
|
-
"attachment",
|
|
325
|
-
"staged",
|
|
326
|
-
"cleanup",
|
|
327
|
-
]),
|
|
328
|
-
legacyCommand("create-quotation", ["quotation", "create"]),
|
|
329
|
-
legacyCommand("update-quotation", ["quotation", "update"]),
|
|
330
|
-
legacyCommand("delete-quotation", ["quotation", "delete"]),
|
|
331
|
-
legacyCommand("submit-quotation", ["quotation", "submit"]),
|
|
332
|
-
legacyCommand("approve-quotation", ["quotation", "approve"]),
|
|
333
|
-
legacyCommand("reject-quotation", ["quotation", "reject"]),
|
|
334
|
-
legacyCommand("download-quotation-pdf", ["quotation", "pdf", "download"]),
|
|
335
|
-
legacyCommand("check-customer-invoice-readiness", [
|
|
336
|
-
"customer-invoice",
|
|
337
|
-
"readiness",
|
|
338
|
-
"check",
|
|
339
|
-
]),
|
|
340
|
-
legacyCommand("list-eligible-customer-invoice-budgets", [
|
|
341
|
-
"customer-invoice",
|
|
342
|
-
"eligible-budget",
|
|
343
|
-
"list",
|
|
344
|
-
]),
|
|
345
|
-
legacyCommand("list-customer-invoices", ["customer-invoice", "list"]),
|
|
346
|
-
legacyCommand("get-customer-invoice", ["customer-invoice", "get"]),
|
|
347
|
-
legacyCommand("get-customer-invoice-email-context", [
|
|
348
|
-
"customer-invoice",
|
|
349
|
-
"email-context",
|
|
350
|
-
"get",
|
|
351
|
-
]),
|
|
352
|
-
legacyCommand("create-customer-invoice", ["customer-invoice", "create"]),
|
|
353
|
-
legacyCommand("discard-customer-invoice", ["customer-invoice", "discard"]),
|
|
354
|
-
legacyCommand("delete-customer-invoice", ["customer-invoice", "delete"]),
|
|
355
|
-
legacyCommand("void-customer-invoice", ["customer-invoice", "void"]),
|
|
356
|
-
legacyCommand("approve-customer-invoice", ["customer-invoice", "approve"]),
|
|
357
|
-
legacyCommand("reject-customer-invoice", ["customer-invoice", "reject"]),
|
|
358
|
-
legacyCommand("send-customer-invoice-to-contact-person", [
|
|
359
|
-
"customer-invoice",
|
|
360
|
-
"send",
|
|
361
|
-
]),
|
|
362
|
-
legacyCommand("download-customer-invoice-pdf", [
|
|
363
|
-
"customer-invoice",
|
|
364
|
-
"pdf",
|
|
365
|
-
"download",
|
|
366
|
-
]),
|
|
367
|
-
legacyCommand("sync-customer-invoice", ["customer-invoice", "sync"]),
|
|
368
|
-
legacyCommand("list-approvals", ["approval", "list"], ["get-pending-approvals"]),
|
|
369
|
-
legacyCommand("approve-bill", ["bill", "approve"]),
|
|
370
|
-
legacyCommand("reject-bill", ["bill", "reject"]),
|
|
371
|
-
legacyCommand("approve-budget", ["budget", "approve"]),
|
|
372
|
-
legacyCommand("reject-budget", ["budget", "reject"]),
|
|
373
|
-
legacyCommand("approve-supplier", ["supplier", "approve"]),
|
|
374
|
-
legacyCommand("reject-supplier", ["supplier", "reject"]),
|
|
375
|
-
legacyCommand("get-supplier-details", ["supplier", "detail", "get"]),
|
|
376
|
-
legacyCommand("list-companies", ["company", "list"]),
|
|
377
|
-
legacyCommand("get-company", ["company", "get"]),
|
|
378
|
-
legacyCommand("create-company", ["company", "create"]),
|
|
379
|
-
legacyCommand("update-company", ["company", "update"]),
|
|
380
|
-
legacyCommand("delete-company", ["company", "delete"]),
|
|
381
|
-
legacyCommand("list-projects", ["project", "list"]),
|
|
382
|
-
legacyCommand("list-project-hubs", ["project", "hub", "list"], [], [
|
|
383
|
-
{
|
|
384
|
-
name: "--q",
|
|
385
|
-
description: "Search project and company names.",
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: "--status",
|
|
389
|
-
description: "Filter by comma-separated project statuses.",
|
|
390
|
-
},
|
|
391
|
-
{ name: "--page", description: "Select a results page." },
|
|
392
|
-
{ name: "--perPage", description: "Set the results page size." },
|
|
393
|
-
{
|
|
394
|
-
name: "--sortBy",
|
|
395
|
-
description: "Sort by startDate, name, companyName, or status.",
|
|
396
|
-
},
|
|
397
|
-
{ name: "--sortDir", description: "Sort in asc or desc order." },
|
|
398
|
-
]),
|
|
399
|
-
legacyCommand("get-project", ["project", "get"]),
|
|
400
|
-
legacyCommand("get-project-hub-status", ["project", "hub", "status"]),
|
|
401
|
-
legacyCommand("setup-project-hub", ["project", "hub", "setup"]),
|
|
402
|
-
legacyCommand("sync-project-hub-commercial-documents", [
|
|
403
|
-
"project",
|
|
404
|
-
"hub",
|
|
405
|
-
"sync",
|
|
406
|
-
]),
|
|
407
|
-
legacyCommand("create-project", ["project", "create"]),
|
|
408
|
-
legacyCommand("update-project", ["project", "update"]),
|
|
409
|
-
legacyCommand("delete-project", ["project", "delete"]),
|
|
410
|
-
legacyCommand("check-project-reconciliation", [
|
|
411
|
-
"project",
|
|
412
|
-
"reconciliation",
|
|
413
|
-
"check",
|
|
414
|
-
]),
|
|
415
|
-
legacyCommand("reconcile-project", ["project", "reconcile"]),
|
|
416
|
-
legacyCommand("complete-project", ["project", "complete"]),
|
|
417
|
-
legacyCommand("import-qbo-project", ["project", "quickbooks", "import"]),
|
|
418
|
-
legacyCommand("update-project-status", ["project", "status", "update"]),
|
|
419
|
-
legacyCommand("list-contacts", ["contact", "list"]),
|
|
420
|
-
legacyCommand("create-contact-person", ["contact", "create"]),
|
|
421
|
-
legacyCommand("update-contact-person", ["contact", "update"]),
|
|
422
|
-
legacyCommand("list-suppliers", ["supplier", "list"]),
|
|
423
|
-
legacyCommand("create-supplier", ["supplier", "create"]),
|
|
424
|
-
legacyCommand("update-supplier", ["supplier", "update"]),
|
|
425
|
-
legacyCommand("delete-suppliers", ["supplier", "delete"]),
|
|
426
|
-
legacyCommand("reactivate-suppliers", ["supplier", "reactivate"]),
|
|
427
|
-
legacyCommand("create-certification", [
|
|
428
|
-
"supplier",
|
|
429
|
-
"certification",
|
|
430
|
-
"create",
|
|
431
|
-
]),
|
|
432
|
-
legacyCommand("create-payment-method", [
|
|
433
|
-
"supplier",
|
|
434
|
-
"payment-method",
|
|
435
|
-
"create",
|
|
436
|
-
]),
|
|
437
|
-
legacyCommand("create-supplier-role", ["supplier", "role", "create"]),
|
|
438
|
-
legacyCommand("create-supplier-tag", ["supplier", "tag", "create"]),
|
|
439
|
-
legacyCommand("get-supplier-analytics", ["supplier", "analytics", "get"]),
|
|
440
|
-
legacyCommand("list-items", ["item", "list"]),
|
|
441
|
-
legacyCommand("get-item", ["item", "get"]),
|
|
442
|
-
legacyCommand("create-item", ["item", "create"]),
|
|
443
|
-
legacyCommand("update-item", ["item", "update"]),
|
|
444
|
-
legacyCommand("archive-items", ["item", "archive"]),
|
|
445
|
-
legacyCommand("delete-item", ["item", "delete"]),
|
|
446
|
-
legacyCommand("list-item-categories", ["item", "category", "list"]),
|
|
447
|
-
legacyCommand("create-item-category", ["item", "category", "create"]),
|
|
448
|
-
legacyCommand("update-item-category", ["item", "category", "update"]),
|
|
449
|
-
legacyCommand("delete-item-categories", ["item", "category", "delete"]),
|
|
450
|
-
legacyCommand("list-users", ["user", "list"]),
|
|
451
|
-
legacyCommand("create-user", ["user", "create"]),
|
|
452
|
-
legacyCommand("create-api-key", ["user", "api-key", "create"]),
|
|
453
|
-
legacyCommand("list-api-keys", ["user", "api-key", "list"]),
|
|
454
|
-
legacyCommand("revoke-api-key", ["user", "api-key", "revoke"]),
|
|
455
|
-
legacyCommand("get-user-performance", ["user", "performance", "get"]),
|
|
456
|
-
legacyCommand("get-dashboard", ["dashboard", "get"]),
|
|
457
|
-
legacyCommand("get-monthly-metrics", ["dashboard", "monthly-metrics", "get"]),
|
|
458
|
-
legacyCommand("get-system-overview", ["dashboard", "system-overview", "get"]),
|
|
459
|
-
legacyCommand("get-estimate-performance", [
|
|
460
|
-
"dashboard",
|
|
461
|
-
"estimate-performance",
|
|
462
|
-
"get",
|
|
463
|
-
]),
|
|
464
|
-
legacyCommand("get-financial-overview", [
|
|
465
|
-
"dashboard",
|
|
466
|
-
"financial-overview",
|
|
467
|
-
"get",
|
|
468
|
-
]),
|
|
469
|
-
legacyCommand("get-recent-errors", ["error", "recent", "list"]),
|
|
470
|
-
legacyCommand("get-error-metrics", ["error", "metrics", "get"]),
|
|
471
|
-
legacyCommand("list-integration-operations", [
|
|
472
|
-
"integration",
|
|
473
|
-
"operation",
|
|
474
|
-
"list",
|
|
475
|
-
]),
|
|
476
|
-
legacyCommand("retry-integration-operation", [
|
|
477
|
-
"integration",
|
|
478
|
-
"operation",
|
|
479
|
-
"retry",
|
|
480
|
-
]),
|
|
481
|
-
legacyCommand("list-inbound-sources", ["inbound", "source", "list"]),
|
|
482
|
-
legacyCommand("create-inbound-source", ["inbound", "source", "create"]),
|
|
483
|
-
legacyCommand("get-inbound-source", ["inbound", "source", "get"]),
|
|
484
|
-
legacyCommand("update-inbound-source", ["inbound", "source", "update"]),
|
|
485
|
-
legacyCommand("list-inbound-submissions", ["inbound", "submission", "list"]),
|
|
486
|
-
legacyCommand("get-inbound-submission", ["inbound", "submission", "get"]),
|
|
487
|
-
legacyCommand("save-inbound-mapping", ["inbound", "mapping", "save"]),
|
|
488
|
-
legacyCommand("save-inbound-automation-config", [
|
|
489
|
-
"inbound",
|
|
490
|
-
"automation",
|
|
491
|
-
"save",
|
|
492
|
-
]),
|
|
493
|
-
legacyCommand("update-inbound-processing", [
|
|
494
|
-
"inbound",
|
|
495
|
-
"processing",
|
|
496
|
-
"update",
|
|
497
|
-
]),
|
|
498
|
-
legacyCommand("get-approved-budgets", ["budget", "approved", "list"]),
|
|
499
|
-
legacyCommand("get-budget-category-benchmarks", [
|
|
500
|
-
"budget",
|
|
501
|
-
"category",
|
|
502
|
-
"benchmark",
|
|
503
|
-
"get",
|
|
504
|
-
]),
|
|
505
|
-
legacyCommand("get-item-pricing-history", [
|
|
506
|
-
"item",
|
|
507
|
-
"pricing-history",
|
|
508
|
-
"list",
|
|
509
|
-
]),
|
|
510
|
-
legacyCommand("get-supplier-pricing-history", [
|
|
511
|
-
"supplier",
|
|
512
|
-
"pricing-history",
|
|
513
|
-
"list",
|
|
514
|
-
]),
|
|
515
|
-
];
|
|
516
|
-
const normalizeToken = (value) => value.replaceAll("_", "-");
|
|
517
|
-
const normalizedPath = (path) => path.map(normalizeToken);
|
|
518
|
-
const assertRegistry = (commands) => {
|
|
519
|
-
const paths = new Set();
|
|
520
|
-
const aliases = new Set();
|
|
521
|
-
for (const command of commands) {
|
|
522
|
-
const path = command.path.join(" ");
|
|
523
|
-
if (paths.has(path))
|
|
524
|
-
throw new Error(`Duplicate canonical command path: ${path}`);
|
|
525
|
-
paths.add(path);
|
|
526
|
-
const commandAliases = new Set();
|
|
527
|
-
for (const alias of command.legacyAliases) {
|
|
528
|
-
const normalizedAlias = normalizeToken(alias);
|
|
529
|
-
if (commandAliases.has(normalizedAlias))
|
|
530
|
-
continue;
|
|
531
|
-
commandAliases.add(normalizedAlias);
|
|
532
|
-
if (aliases.has(normalizedAlias)) {
|
|
533
|
-
throw new Error(`Duplicate legacy command alias: ${alias}`);
|
|
534
|
-
}
|
|
535
|
-
aliases.add(normalizedAlias);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
assertRegistry(registry);
|
|
540
|
-
export const commandRegistry = registry;
|
|
541
|
-
export const resolveCommand = (argv) => {
|
|
542
|
-
const normalizedArgv = argv.map(normalizeToken);
|
|
543
|
-
const canonical = [...commandRegistry]
|
|
544
|
-
.sort((left, right) => right.path.length - left.path.length)
|
|
545
|
-
.find((command) => {
|
|
546
|
-
const path = normalizedPath(command.path);
|
|
547
|
-
return path.every((segment, index) => normalizedArgv[index] === segment);
|
|
548
|
-
});
|
|
549
|
-
if (canonical) {
|
|
550
|
-
return {
|
|
551
|
-
command: canonical,
|
|
552
|
-
argv: argv.slice(canonical.path.length),
|
|
553
|
-
invokedAs: argv.slice(0, canonical.path.length),
|
|
554
|
-
isLegacyAlias: false,
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
const rawAlias = argv[0];
|
|
558
|
-
if (!rawAlias)
|
|
559
|
-
return undefined;
|
|
560
|
-
const normalizedAlias = normalizeToken(rawAlias);
|
|
561
|
-
const legacy = commandRegistry.find((command) => command.legacyAliases.some((alias) => normalizeToken(alias) === normalizedAlias));
|
|
562
|
-
if (!legacy)
|
|
563
|
-
return undefined;
|
|
564
|
-
return {
|
|
565
|
-
command: legacy,
|
|
566
|
-
argv: argv.slice(1),
|
|
567
|
-
invokedAs: [rawAlias],
|
|
568
|
-
isLegacyAlias: true,
|
|
569
|
-
};
|
|
570
|
-
};
|
|
571
|
-
export const createCommandManifest = () => commandRegistry.map((command) => ({
|
|
572
|
-
path: command.path,
|
|
573
|
-
legacyAliases: command.legacyAliases,
|
|
574
|
-
summary: command.summary,
|
|
575
|
-
globalOptions: command.options,
|
|
576
|
-
argumentMode: "legacyTarget" in command ? "legacy-passthrough" : "typed",
|
|
577
|
-
effects: command.effects,
|
|
578
|
-
...("legacyTarget" in command
|
|
579
|
-
? { legacyTarget: command.legacyTarget }
|
|
580
|
-
: {}),
|
|
581
|
-
}));
|
|
582
|
-
export const createHumanHelp = () => {
|
|
583
|
-
const lines = commandRegistry.map((command) => {
|
|
584
|
-
const canonical = `bb ${command.path.join(" ")}`;
|
|
585
|
-
const aliases = command.legacyAliases
|
|
586
|
-
.filter((alias) => alias.includes("-"))
|
|
587
|
-
.map((alias) => `bb ${alias}`)
|
|
588
|
-
.join(", ");
|
|
589
|
-
return ` ${canonical}\n ${command.summary}${aliases ? ` Legacy: ${aliases}.` : ""}`;
|
|
590
|
-
});
|
|
591
|
-
return [
|
|
592
|
-
"bb — Budget Builder CLI",
|
|
593
|
-
"",
|
|
594
|
-
"Usage: bb <resource> <operation> [options] [args]",
|
|
595
|
-
"",
|
|
596
|
-
"Global options",
|
|
597
|
-
...globalCommandOptions.map((option) => ` ${option.name}\n ${option.description}`),
|
|
598
|
-
"",
|
|
599
|
-
"Canonical commands",
|
|
600
|
-
...lines,
|
|
601
|
-
"",
|
|
602
|
-
"Use `bb completion <shell>` to generate shell completion scripts.",
|
|
603
|
-
].join("\n");
|
|
604
|
-
};
|
|
605
|
-
const completionWords = () => {
|
|
606
|
-
const words = new Set();
|
|
607
|
-
for (const command of commandRegistry) {
|
|
608
|
-
for (const segment of command.path)
|
|
609
|
-
words.add(segment);
|
|
610
|
-
for (const alias of command.legacyAliases)
|
|
611
|
-
words.add(alias);
|
|
612
|
-
}
|
|
613
|
-
words.add("help");
|
|
614
|
-
words.add("version");
|
|
615
|
-
words.add("completion");
|
|
616
|
-
return [...words].sort();
|
|
617
|
-
};
|
|
618
|
-
export const createCompletionScript = (shell) => {
|
|
619
|
-
const words = completionWords().join(" ");
|
|
620
|
-
switch (shell) {
|
|
621
|
-
case "bash":
|
|
622
|
-
return `# bash completion for bb\n_bb() {\n COMPREPLY=( $(compgen -W '${words}' -- "${"$"}{COMP_WORDS[COMP_CWORD]}") )\n}\ncomplete -F _bb bb\n`;
|
|
623
|
-
case "zsh":
|
|
624
|
-
return `#compdef bb\n_bb() {\n local -a commands\n commands=(${words})\n _describe 'bb command' commands\n}\ncompdef _bb bb\n`;
|
|
625
|
-
case "fish":
|
|
626
|
-
return completionWords()
|
|
627
|
-
.map((word) => `complete -c bb -f -a '${word}'`)
|
|
628
|
-
.join("\n")
|
|
629
|
-
.concat("\n");
|
|
630
|
-
case "powershell":
|
|
631
|
-
return `Register-ArgumentCompleter -Native -CommandName bb -ScriptBlock {\n param($wordToComplete)\n '${words}'.Split(' ') | Where-Object { $_ -like "$wordToComplete*" }\n}\n`;
|
|
632
|
-
}
|
|
633
|
-
};
|
package/dist/rich-text.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const escapeHtml = (text) => text
|
|
2
|
-
.replace(/&/g, "&")
|
|
3
|
-
.replace(/</g, "<")
|
|
4
|
-
.replace(/>/g, ">")
|
|
5
|
-
.replace(/"/g, """)
|
|
6
|
-
.replace(/'/g, "'");
|
|
7
|
-
export const createRichTextFromPlainText = (text) => {
|
|
8
|
-
const lines = text?.split(/\r?\n/) ?? [];
|
|
9
|
-
const paragraphs = lines.length ? lines : [""];
|
|
10
|
-
return {
|
|
11
|
-
json: {
|
|
12
|
-
type: "doc",
|
|
13
|
-
content: paragraphs.map((line) => ({
|
|
14
|
-
type: "paragraph",
|
|
15
|
-
...(line ? { content: [{ type: "text", text: line }] } : {}),
|
|
16
|
-
})),
|
|
17
|
-
},
|
|
18
|
-
html: paragraphs.map((line) => `<p>${escapeHtml(line)}</p>`).join(""),
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export const isRichTextJson = (value) => Boolean(value &&
|
|
22
|
-
typeof value === "object" &&
|
|
23
|
-
"json" in value &&
|
|
24
|
-
"html" in value &&
|
|
25
|
-
typeof value.html === "string");
|
|
26
|
-
export const normalizePlainTextRichTextField = ({ input, textField, richTextField, }) => {
|
|
27
|
-
if (isRichTextJson(input[richTextField]) || input[textField] === undefined) {
|
|
28
|
-
return input;
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
...input,
|
|
32
|
-
[richTextField]: createRichTextFromPlainText(String(input[textField] ?? "")),
|
|
33
|
-
};
|
|
34
|
-
};
|