@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/filter-enums.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ApprovalStatus, ApprovalType, BillStatus, BudgetStatus, ErrorSeverity, ErrorStatus, EstimationMode, ProjectStatus, } from "./prisma-enums.js";
|
|
2
|
-
export const ExtendedApprovalStatus = {
|
|
3
|
-
...ApprovalStatus,
|
|
4
|
-
ALL: "ALL",
|
|
5
|
-
};
|
|
6
|
-
export const ExtendedApprovalType = {
|
|
7
|
-
...ApprovalType,
|
|
8
|
-
ALL: "ALL",
|
|
9
|
-
};
|
|
10
|
-
export const ExtendedProjectStatus = {
|
|
11
|
-
...ProjectStatus,
|
|
12
|
-
ALL: "ALL",
|
|
13
|
-
};
|
|
14
|
-
export const ExtendedBudgetStatus = {
|
|
15
|
-
...BudgetStatus,
|
|
16
|
-
ALL: "ALL",
|
|
17
|
-
};
|
|
18
|
-
export const ExtendedBillStatus = {
|
|
19
|
-
...BillStatus,
|
|
20
|
-
ALL: "ALL",
|
|
21
|
-
};
|
|
22
|
-
export const ExtendedEstimationMode = {
|
|
23
|
-
...EstimationMode,
|
|
24
|
-
ALL: "ALL",
|
|
25
|
-
};
|
|
26
|
-
export const BudgetRole = {
|
|
27
|
-
ALL: "ALL",
|
|
28
|
-
BD: "BD",
|
|
29
|
-
CREATOR: "CREATOR",
|
|
30
|
-
INSIDE_SALES: "INSIDE_SALES",
|
|
31
|
-
};
|
|
32
|
-
export const Deals = {
|
|
33
|
-
ALL: "ALL",
|
|
34
|
-
SUCCESSFUL: "SUCCESSFUL",
|
|
35
|
-
LOST: "LOST",
|
|
36
|
-
};
|
|
37
|
-
export const TimeFrame = {
|
|
38
|
-
ALL: "ALL",
|
|
39
|
-
LAST_YEAR: "LAST_YEAR",
|
|
40
|
-
LAST_6_MONTHS: "LAST_6_MONTHS",
|
|
41
|
-
LAST_3_MONTHS: "LAST_3_MONTHS",
|
|
42
|
-
CUSTOM: "CUSTOM",
|
|
43
|
-
};
|
|
44
|
-
export const ChartTimeFrame = {
|
|
45
|
-
LAST_30_DAYS: "last_30_days",
|
|
46
|
-
LAST_3_MONTHS: "last_3_months",
|
|
47
|
-
LAST_6_MONTHS: "last_6_months",
|
|
48
|
-
LAST_1_YEAR: "last_1_year",
|
|
49
|
-
ALL_TIME: "all_time",
|
|
50
|
-
};
|
|
51
|
-
export const ExtendedErrorSeverity = {
|
|
52
|
-
ALL: "ALL",
|
|
53
|
-
...ErrorSeverity,
|
|
54
|
-
};
|
|
55
|
-
export const ExtendedErrorStatus = {
|
|
56
|
-
ALL: "ALL",
|
|
57
|
-
...ErrorStatus,
|
|
58
|
-
};
|
package/dist/load-env.js
DELETED
package/dist/parse-args.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal argv parser for bb CLI.
|
|
3
|
-
* Supports: command [positional...] [--key=value] [--key value]
|
|
4
|
-
*/
|
|
5
|
-
export function parseArgs(argv) {
|
|
6
|
-
const args = argv.slice(2); // drop node and script
|
|
7
|
-
const positional = [];
|
|
8
|
-
const flags = {};
|
|
9
|
-
for (let i = 0; i < args.length; i++) {
|
|
10
|
-
const arg = args[i];
|
|
11
|
-
if (arg === undefined || arg === "")
|
|
12
|
-
continue;
|
|
13
|
-
if (arg === "--") {
|
|
14
|
-
for (const rest of args.slice(i + 1)) {
|
|
15
|
-
if (rest !== "")
|
|
16
|
-
positional.push(rest);
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
if (arg.startsWith("--")) {
|
|
21
|
-
const eq = arg.indexOf("=");
|
|
22
|
-
if (eq > 0) {
|
|
23
|
-
flags[arg.slice(2, eq)] = arg.slice(eq + 1);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// --flag or --flag value
|
|
27
|
-
const key = arg.slice(2);
|
|
28
|
-
const next = args[i + 1];
|
|
29
|
-
if (next !== undefined && !next.startsWith("--")) {
|
|
30
|
-
flags[key] = next;
|
|
31
|
-
i++;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
flags[key] = true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else if (arg === "-q") {
|
|
39
|
-
flags.q = true;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
positional.push(arg);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const command = positional[0] ?? "";
|
|
46
|
-
return { command, positional: positional.slice(1), flags };
|
|
47
|
-
}
|
|
48
|
-
export function getFlag(flags, key, parse) {
|
|
49
|
-
const v = flags[key];
|
|
50
|
-
if (v === undefined || v === true)
|
|
51
|
-
return undefined;
|
|
52
|
-
if (parse)
|
|
53
|
-
return parse(v);
|
|
54
|
-
return v;
|
|
55
|
-
}
|
package/dist/parse-cli-enums.js
DELETED
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { BudgetRole, Deals, ExtendedApprovalStatus, ExtendedBillStatus, ExtendedErrorSeverity, ExtendedErrorStatus, ExtendedProjectStatus, TimeFrame, } from "./filter-enums.js";
|
|
2
|
-
import { BillStatus, BudgetStatus, CustomerInvoiceBatchStatus, ProjectStatus, SupplierQuotationStatus, UserRole, } from "./prisma-enums.js";
|
|
3
|
-
const BUDGET_STATUS_VALUES = new Set(Object.values(BudgetStatus));
|
|
4
|
-
const BILL_STATUS_VALUES = new Set(Object.values(BillStatus));
|
|
5
|
-
const PROJECT_STATUS_VALUES = new Set(Object.values(ProjectStatus));
|
|
6
|
-
const SUPPLIER_QUOTATION_STATUS_VALUES = new Set(Object.values(SupplierQuotationStatus));
|
|
7
|
-
const CUSTOMER_INVOICE_BATCH_STATUS_VALUES = new Set(Object.values(CustomerInvoiceBatchStatus));
|
|
8
|
-
const USER_ROLE_VALUES = new Set(Object.values(UserRole));
|
|
9
|
-
const EXTENDED_PROJECT_STATUS_VALUES = new Set(Object.values(ExtendedProjectStatus));
|
|
10
|
-
const DASHBOARD_ROLE_VALUES = new Set([
|
|
11
|
-
"BD",
|
|
12
|
-
"CREATOR",
|
|
13
|
-
"INSIDE_SALES",
|
|
14
|
-
"ALL",
|
|
15
|
-
]);
|
|
16
|
-
const DEALS_VALUES = new Set(Object.values(Deals));
|
|
17
|
-
const TIME_FRAME_VALUES = new Set(Object.values(TimeFrame));
|
|
18
|
-
const BUDGET_ROLE_VALUES = new Set(Object.values(BudgetRole));
|
|
19
|
-
const SUPPLIER_ANALYTICS_TF = new Set([
|
|
20
|
-
"ALL",
|
|
21
|
-
"LAST_YEAR",
|
|
22
|
-
"LAST_6_MONTHS",
|
|
23
|
-
"LAST_3_MONTHS",
|
|
24
|
-
"CUSTOM",
|
|
25
|
-
]);
|
|
26
|
-
const SUPPLIER_APPROVAL_STATUS_VALUES = new Set(Object.values(ExtendedApprovalStatus));
|
|
27
|
-
const EXT_ERROR_SEVERITY_VALUES = new Set(Object.values(ExtendedErrorSeverity));
|
|
28
|
-
const EXT_ERROR_STATUS_VALUES = new Set(Object.values(ExtendedErrorStatus));
|
|
29
|
-
const INTEGRATION_OPERATION_STATUS_VALUES = new Set([
|
|
30
|
-
"PENDING",
|
|
31
|
-
"PROCESSING",
|
|
32
|
-
"FAILED",
|
|
33
|
-
"COMPLETED",
|
|
34
|
-
]);
|
|
35
|
-
export function isBudgetStatusListToken(s) {
|
|
36
|
-
if (s === "ALL")
|
|
37
|
-
return true;
|
|
38
|
-
return BUDGET_STATUS_VALUES.has(s);
|
|
39
|
-
}
|
|
40
|
-
export function isBillStatusListToken(s) {
|
|
41
|
-
if (s === "ALL")
|
|
42
|
-
return true;
|
|
43
|
-
return BILL_STATUS_VALUES.has(s);
|
|
44
|
-
}
|
|
45
|
-
export function isBudgetStatusUpdate(s) {
|
|
46
|
-
return BUDGET_STATUS_VALUES.has(s);
|
|
47
|
-
}
|
|
48
|
-
/** For bill.updateStatus — PENDING_APPROVAL must use createBillApproval. */
|
|
49
|
-
export function parseBillStatusForUpdate(raw) {
|
|
50
|
-
if (!BILL_STATUS_VALUES.has(raw)) {
|
|
51
|
-
throw new Error(`Invalid bill status "${raw}". Use one of: ${[...BILL_STATUS_VALUES].join(", ")}.`);
|
|
52
|
-
}
|
|
53
|
-
if (raw === BillStatus.PENDING_APPROVAL) {
|
|
54
|
-
throw new Error("Cannot set PENDING_APPROVAL via update-bill-status. Use create-bill-approval <billId> instead.");
|
|
55
|
-
}
|
|
56
|
-
return raw;
|
|
57
|
-
}
|
|
58
|
-
export function parseProjectStatusForUpdate(raw) {
|
|
59
|
-
if (!PROJECT_STATUS_VALUES.has(raw)) {
|
|
60
|
-
throw new Error(`Invalid project status "${raw}". Use one of: ${[...PROJECT_STATUS_VALUES].join(", ")}.`);
|
|
61
|
-
}
|
|
62
|
-
return raw;
|
|
63
|
-
}
|
|
64
|
-
export function parseUserRole(raw) {
|
|
65
|
-
if (raw === undefined || raw === "")
|
|
66
|
-
return UserRole.USER;
|
|
67
|
-
const normalizedRole = raw.trim().toUpperCase();
|
|
68
|
-
if (!USER_ROLE_VALUES.has(normalizedRole)) {
|
|
69
|
-
throw new Error(`Invalid user role "${raw}". Use one of: ${[...USER_ROLE_VALUES].join(", ")}.`);
|
|
70
|
-
}
|
|
71
|
-
return normalizedRole;
|
|
72
|
-
}
|
|
73
|
-
export function parseOptionalExtendedProjectStatus(raw) {
|
|
74
|
-
if (raw === undefined || raw === "")
|
|
75
|
-
return undefined;
|
|
76
|
-
if (!EXTENDED_PROJECT_STATUS_VALUES.has(raw)) {
|
|
77
|
-
throw new Error(`Invalid project list status "${raw}". Use one of: ${[...EXTENDED_PROJECT_STATUS_VALUES].join(", ")}.`);
|
|
78
|
-
}
|
|
79
|
-
return raw;
|
|
80
|
-
}
|
|
81
|
-
export function parseCommaSeparatedProjectStatuses(raw) {
|
|
82
|
-
if (raw === undefined)
|
|
83
|
-
return undefined;
|
|
84
|
-
const statuses = raw
|
|
85
|
-
.split(",")
|
|
86
|
-
.map((value) => value.trim().toUpperCase())
|
|
87
|
-
.filter(Boolean);
|
|
88
|
-
if (statuses.length === 0)
|
|
89
|
-
return undefined;
|
|
90
|
-
for (const status of statuses) {
|
|
91
|
-
if (!PROJECT_STATUS_VALUES.has(status)) {
|
|
92
|
-
throw new Error(`Invalid project status "${status}". Use one of: ${[...PROJECT_STATUS_VALUES].join(", ")}.`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return statuses;
|
|
96
|
-
}
|
|
97
|
-
const PROJECT_HUB_SORT_FIELDS = new Set([
|
|
98
|
-
"startDate",
|
|
99
|
-
"name",
|
|
100
|
-
"companyName",
|
|
101
|
-
"status",
|
|
102
|
-
]);
|
|
103
|
-
export function parseOptionalProjectHubSortBy(raw) {
|
|
104
|
-
if (raw === undefined || raw === "")
|
|
105
|
-
return undefined;
|
|
106
|
-
if (!PROJECT_HUB_SORT_FIELDS.has(raw)) {
|
|
107
|
-
throw new Error(`Invalid --sortBy "${raw}". Use one of: ${[...PROJECT_HUB_SORT_FIELDS].join(", ")}.`);
|
|
108
|
-
}
|
|
109
|
-
return raw;
|
|
110
|
-
}
|
|
111
|
-
export function parseOptionalDashboardRole(raw) {
|
|
112
|
-
if (raw === undefined || raw === "")
|
|
113
|
-
return undefined;
|
|
114
|
-
if (!DASHBOARD_ROLE_VALUES.has(raw)) {
|
|
115
|
-
throw ERROR_BAD_DASHBOARD_ROLE;
|
|
116
|
-
}
|
|
117
|
-
return raw;
|
|
118
|
-
}
|
|
119
|
-
const ERROR_BAD_DASHBOARD_ROLE = new Error(`Invalid dashboard role. Use one of: ${[...DASHBOARD_ROLE_VALUES].join(", ")}.`);
|
|
120
|
-
export function parseOptionalFinancialRole(raw) {
|
|
121
|
-
if (raw === undefined || raw === "")
|
|
122
|
-
return undefined;
|
|
123
|
-
if (!BUDGET_ROLE_VALUES.has(raw)) {
|
|
124
|
-
throw new Error(`Invalid financial role. Use one of: ${[...BUDGET_ROLE_VALUES].join(", ")}.`);
|
|
125
|
-
}
|
|
126
|
-
return raw;
|
|
127
|
-
}
|
|
128
|
-
export function parseOptionalDeals(raw) {
|
|
129
|
-
if (raw === undefined || raw === "")
|
|
130
|
-
return undefined;
|
|
131
|
-
if (!DEALS_VALUES.has(raw)) {
|
|
132
|
-
throw new Error(`Invalid deals filter. Use one of: ${[...DEALS_VALUES].join(", ")}.`);
|
|
133
|
-
}
|
|
134
|
-
return raw;
|
|
135
|
-
}
|
|
136
|
-
export function parseOptionalTimeFrame(raw) {
|
|
137
|
-
if (raw === undefined || raw === "")
|
|
138
|
-
return undefined;
|
|
139
|
-
if (!TIME_FRAME_VALUES.has(raw)) {
|
|
140
|
-
throw new Error(`Invalid timeFrame. Use one of: ${[...TIME_FRAME_VALUES].join(", ")}.`);
|
|
141
|
-
}
|
|
142
|
-
return raw;
|
|
143
|
-
}
|
|
144
|
-
export function parseOptionalSupplierAnalyticsTimeFrame(raw) {
|
|
145
|
-
if (raw === undefined || raw === "")
|
|
146
|
-
return "ALL";
|
|
147
|
-
if (!SUPPLIER_ANALYTICS_TF.has(raw)) {
|
|
148
|
-
throw new Error(`Invalid supplier analytics timeFrame. Use one of: ${[...SUPPLIER_ANALYTICS_TF].join(", ")}.`);
|
|
149
|
-
}
|
|
150
|
-
return raw;
|
|
151
|
-
}
|
|
152
|
-
export function parseOptionalErrorSeverity(raw) {
|
|
153
|
-
if (raw === undefined || raw === "")
|
|
154
|
-
return undefined;
|
|
155
|
-
if (!EXT_ERROR_SEVERITY_VALUES.has(raw)) {
|
|
156
|
-
throw new Error(`Invalid error severity. Use one of: ${[...EXT_ERROR_SEVERITY_VALUES].join(", ")}.`);
|
|
157
|
-
}
|
|
158
|
-
return raw;
|
|
159
|
-
}
|
|
160
|
-
export function parseOptionalErrorStatus(raw) {
|
|
161
|
-
if (raw === undefined || raw === "")
|
|
162
|
-
return undefined;
|
|
163
|
-
if (!EXT_ERROR_STATUS_VALUES.has(raw)) {
|
|
164
|
-
throw new Error(`Invalid error status. Use one of: ${[...EXT_ERROR_STATUS_VALUES].join(", ")}.`);
|
|
165
|
-
}
|
|
166
|
-
return raw;
|
|
167
|
-
}
|
|
168
|
-
/** Comma-separated user IDs (e.g. `--createdByIds u1,u2` on list-bills). */
|
|
169
|
-
export function parseCommaSeparatedIds(raw) {
|
|
170
|
-
if (raw === undefined || raw.trim() === "")
|
|
171
|
-
return undefined;
|
|
172
|
-
const ids = raw
|
|
173
|
-
.split(",")
|
|
174
|
-
.map((s) => s.trim())
|
|
175
|
-
.filter(Boolean);
|
|
176
|
-
return ids.length > 0 ? ids : undefined;
|
|
177
|
-
}
|
|
178
|
-
export function parseCommaSeparatedIntegrationOperationStatuses(raw) {
|
|
179
|
-
if (raw === undefined)
|
|
180
|
-
return undefined;
|
|
181
|
-
const statuses = raw
|
|
182
|
-
.split(",")
|
|
183
|
-
.map((value) => value.trim().toUpperCase())
|
|
184
|
-
.filter(Boolean);
|
|
185
|
-
if (statuses.length === 0)
|
|
186
|
-
return undefined;
|
|
187
|
-
for (const status of statuses) {
|
|
188
|
-
if (!INTEGRATION_OPERATION_STATUS_VALUES.has(status)) {
|
|
189
|
-
throw new Error(`Invalid integration operation status "${status}". Use one or more of: ${[...INTEGRATION_OPERATION_STATUS_VALUES].join(", ")}.`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return statuses;
|
|
193
|
-
}
|
|
194
|
-
export function parseCommaSeparatedBudgetStatuses(raw) {
|
|
195
|
-
if (raw === undefined)
|
|
196
|
-
return undefined;
|
|
197
|
-
const parts = raw
|
|
198
|
-
.split(",")
|
|
199
|
-
.map((x) => x.trim())
|
|
200
|
-
.filter(Boolean);
|
|
201
|
-
if (parts.length === 0)
|
|
202
|
-
return undefined;
|
|
203
|
-
const out = [];
|
|
204
|
-
for (const p of parts) {
|
|
205
|
-
if (!isBudgetStatusListToken(p)) {
|
|
206
|
-
throw new Error(`Invalid budget status "${p}". Use ALL or one of: ${[...BUDGET_STATUS_VALUES].join(", ")}.`);
|
|
207
|
-
}
|
|
208
|
-
out.push(p);
|
|
209
|
-
}
|
|
210
|
-
return out;
|
|
211
|
-
}
|
|
212
|
-
export function parseCommaSeparatedSupplierStatuses(raw) {
|
|
213
|
-
if (raw === undefined)
|
|
214
|
-
return undefined;
|
|
215
|
-
const parts = raw
|
|
216
|
-
.split(",")
|
|
217
|
-
.map((x) => x.trim())
|
|
218
|
-
.filter(Boolean);
|
|
219
|
-
if (parts.length === 0)
|
|
220
|
-
return undefined;
|
|
221
|
-
const out = [];
|
|
222
|
-
for (const p of parts) {
|
|
223
|
-
if (!SUPPLIER_APPROVAL_STATUS_VALUES.has(p)) {
|
|
224
|
-
throw new Error(`Invalid supplier approval status "${p}". Use one of: ${[...SUPPLIER_APPROVAL_STATUS_VALUES].join(", ")}.`);
|
|
225
|
-
}
|
|
226
|
-
out.push(p);
|
|
227
|
-
}
|
|
228
|
-
return out;
|
|
229
|
-
}
|
|
230
|
-
export function parseCommaSeparatedQuotationStatuses(raw) {
|
|
231
|
-
if (raw === undefined)
|
|
232
|
-
return undefined;
|
|
233
|
-
const parts = raw
|
|
234
|
-
.split(",")
|
|
235
|
-
.map((value) => value.trim().toUpperCase())
|
|
236
|
-
.filter(Boolean);
|
|
237
|
-
if (parts.length === 0)
|
|
238
|
-
return undefined;
|
|
239
|
-
for (const status of parts) {
|
|
240
|
-
if (!SUPPLIER_QUOTATION_STATUS_VALUES.has(status)) {
|
|
241
|
-
throw new Error(`Invalid quotation status "${status}". Use one of: ${[...SUPPLIER_QUOTATION_STATUS_VALUES].join(", ")}.`);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return parts;
|
|
245
|
-
}
|
|
246
|
-
export function parseCommaSeparatedCustomerInvoiceStatuses(raw) {
|
|
247
|
-
if (raw === undefined)
|
|
248
|
-
return undefined;
|
|
249
|
-
const parts = raw
|
|
250
|
-
.split(",")
|
|
251
|
-
.map((value) => value.trim().toUpperCase())
|
|
252
|
-
.filter(Boolean);
|
|
253
|
-
if (parts.length === 0)
|
|
254
|
-
return undefined;
|
|
255
|
-
for (const status of parts) {
|
|
256
|
-
if (!CUSTOMER_INVOICE_BATCH_STATUS_VALUES.has(status)) {
|
|
257
|
-
throw new Error(`Invalid customer invoice status "${status}". Use one of: ${[...CUSTOMER_INVOICE_BATCH_STATUS_VALUES].join(", ")}.`);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return parts;
|
|
261
|
-
}
|
|
262
|
-
export function parseBillStatusFlag(raw) {
|
|
263
|
-
if (raw === undefined)
|
|
264
|
-
return undefined;
|
|
265
|
-
if (!isBillStatusListToken(raw)) {
|
|
266
|
-
throw new Error(`Invalid bill status "${raw}". Use ALL or one of: ${[...BILL_STATUS_VALUES].join(", ")}.`);
|
|
267
|
-
}
|
|
268
|
-
return raw;
|
|
269
|
-
}
|
|
270
|
-
/** Comma-separated bill statuses (`ALL` or `BillStatus` values), same as list-budgets `--status`. */
|
|
271
|
-
export function parseCommaSeparatedBillStatuses(raw) {
|
|
272
|
-
if (raw === undefined)
|
|
273
|
-
return undefined;
|
|
274
|
-
const parts = raw
|
|
275
|
-
.split(",")
|
|
276
|
-
.map((x) => x.trim())
|
|
277
|
-
.filter(Boolean);
|
|
278
|
-
if (parts.length === 0)
|
|
279
|
-
return undefined;
|
|
280
|
-
const out = [];
|
|
281
|
-
for (const p of parts) {
|
|
282
|
-
if (!isBillStatusListToken(p)) {
|
|
283
|
-
throw new Error(`Invalid bill status "${p}". Use ALL or one of: ${[...BILL_STATUS_VALUES].join(", ")}.`);
|
|
284
|
-
}
|
|
285
|
-
out.push(p);
|
|
286
|
-
}
|
|
287
|
-
return out;
|
|
288
|
-
}
|
|
289
|
-
/** Strip `ALL` tokens; empty after strip => no status filter (all statuses). */
|
|
290
|
-
export function billStatusesForApi(statuses) {
|
|
291
|
-
if (!statuses?.length)
|
|
292
|
-
return undefined;
|
|
293
|
-
const withoutAll = statuses.filter((s) => s !== ExtendedBillStatus.ALL);
|
|
294
|
-
return withoutAll.length > 0 ? withoutAll : undefined;
|
|
295
|
-
}
|
|
296
|
-
const BILL_SORT_BY = new Set(["createdAt", "amount", "status"]);
|
|
297
|
-
export function parseOptionalBillListSortBy(raw) {
|
|
298
|
-
if (raw === undefined || raw === "")
|
|
299
|
-
return undefined;
|
|
300
|
-
if (!BILL_SORT_BY.has(raw)) {
|
|
301
|
-
throw new Error(`Invalid --sortBy "${raw}". Use one of: ${[...BILL_SORT_BY].join(", ")}.`);
|
|
302
|
-
}
|
|
303
|
-
return raw;
|
|
304
|
-
}
|
|
305
|
-
export function parseOptionalBillListSortDir(raw) {
|
|
306
|
-
if (raw === undefined || raw === "")
|
|
307
|
-
return undefined;
|
|
308
|
-
if (raw !== "asc" && raw !== "desc") {
|
|
309
|
-
throw new Error(`Invalid --sortDir "${raw}". Use asc or desc.`);
|
|
310
|
-
}
|
|
311
|
-
return raw;
|
|
312
|
-
}
|
|
313
|
-
function isPendingRequestType(s) {
|
|
314
|
-
return (s === "BUDGET" ||
|
|
315
|
-
s === "BILL" ||
|
|
316
|
-
s === "SUPPLIER" ||
|
|
317
|
-
s === "QUOTATION" ||
|
|
318
|
-
s === "CUSTOMER_INVOICE");
|
|
319
|
-
}
|
|
320
|
-
export function parseApprovalTypeFlag(raw) {
|
|
321
|
-
if (raw === undefined)
|
|
322
|
-
return undefined;
|
|
323
|
-
const u = raw.trim().toUpperCase();
|
|
324
|
-
if (u === "ALL")
|
|
325
|
-
return "ALL";
|
|
326
|
-
if (!isPendingRequestType(u)) {
|
|
327
|
-
throw new Error(`Invalid --type "${raw}". Use budget, supplier, bill, quotation, customer_invoice, or all.`);
|
|
328
|
-
}
|
|
329
|
-
return u;
|
|
330
|
-
}
|
|
331
|
-
/** For help text / error messages (values from `./prisma-enums.js`, synced with Prisma). */
|
|
332
|
-
export const budgetStatusesForHelp = Object.values(BudgetStatus);
|
|
333
|
-
export const billStatusesForHelp = Object.values(BillStatus);
|
|
334
|
-
export const billStatusesForUpdateHelp = Object.values(BillStatus).filter((s) => s !== BillStatus.PENDING_APPROVAL);
|
|
335
|
-
export const projectStatusesForHelp = Object.values(ProjectStatus);
|
|
336
|
-
export const userRolesForHelp = Object.values(UserRole);
|
package/dist/parse-json-flag.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function parseJsonFlag(raw, label) {
|
|
2
|
-
if (raw === undefined || raw === "") {
|
|
3
|
-
throw new Error(`${label} is required (JSON string).`);
|
|
4
|
-
}
|
|
5
|
-
try {
|
|
6
|
-
return JSON.parse(raw);
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
throw new Error(`${label} must be valid JSON.`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export function parseOptionalNumber(raw, label) {
|
|
13
|
-
if (raw === undefined || raw === "")
|
|
14
|
-
return undefined;
|
|
15
|
-
const n = typeof raw === "number" ? raw : Number.parseFloat(String(raw).trim());
|
|
16
|
-
if (!Number.isFinite(n)) {
|
|
17
|
-
throw new Error(`${label} must be a number.`);
|
|
18
|
-
}
|
|
19
|
-
return n;
|
|
20
|
-
}
|