@go-labs-sg/bb 1.18.1 → 1.20.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 +13 -7
- package/dist/api-client.js +3 -3
- package/dist/cli-trace.js +30 -0
- package/dist/commands.js +373 -13
- package/dist/index.js +358 -18
- package/dist/parse-cli-enums.js +41 -3
- package/dist/parse-mutation-payload.js +62 -0
- package/dist/prisma-enums.js +16 -0
- package/package.json +1 -1
|
@@ -34,6 +34,32 @@ function requiredString(value, fieldLabel) {
|
|
|
34
34
|
}
|
|
35
35
|
return t;
|
|
36
36
|
}
|
|
37
|
+
const EMAIL_ADDRESS_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
38
|
+
const requiredEmail = (value, fieldLabel) => {
|
|
39
|
+
const email = requiredString(value, fieldLabel);
|
|
40
|
+
if (!EMAIL_ADDRESS_PATTERN.test(email)) {
|
|
41
|
+
throw new Error(`${fieldLabel} must be a valid email address.`);
|
|
42
|
+
}
|
|
43
|
+
return email;
|
|
44
|
+
};
|
|
45
|
+
/** Matches the web estimate composer (`email.sendEstimateToContactPerson`). */
|
|
46
|
+
export const parseSendEstimateToContactPersonPayload = (raw) => {
|
|
47
|
+
const input = requireObject(raw, "send-estimate-to-contact-person payload");
|
|
48
|
+
if (!Array.isArray(input.cc)) {
|
|
49
|
+
throw new Error("send-estimate-to-contact-person payload.cc must be an email array.");
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
to: requiredEmail(input.to, "send-estimate-to-contact-person payload.to"),
|
|
53
|
+
cc: input.cc.map((email, index) => requiredEmail(email, `send-estimate-to-contact-person payload.cc[${index}]`)),
|
|
54
|
+
replyTo: requiredEmail(input.replyTo, "send-estimate-to-contact-person payload.replyTo"),
|
|
55
|
+
subject: requiredString(input.subject, "send-estimate-to-contact-person payload.subject"),
|
|
56
|
+
content: requiredString(input.content, "send-estimate-to-contact-person payload.content"),
|
|
57
|
+
signature: requiredString(input.signature, "send-estimate-to-contact-person payload.signature"),
|
|
58
|
+
estimateId: requiredString(input.estimateId, "send-estimate-to-contact-person payload.estimateId"),
|
|
59
|
+
estimateDocNumber: optionalString(input.estimateDocNumber),
|
|
60
|
+
budgetId: requiredString(input.budgetId, "send-estimate-to-contact-person payload.budgetId"),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
37
63
|
/** Matches budget.createBudget — optional pipedriveDealId; Asana deal is project.asanaTaskId. */
|
|
38
64
|
export function parseCreateBudgetPayload(raw) {
|
|
39
65
|
const o = requireObject(raw, "create-budget payload");
|
|
@@ -190,6 +216,42 @@ export function parseUpdateBillPayload(raw) {
|
|
|
190
216
|
id: requiredString(o.id, "update-bill payload.id"),
|
|
191
217
|
};
|
|
192
218
|
}
|
|
219
|
+
/** Server performs the authoritative bill-selection and quotation-coverage checks. */
|
|
220
|
+
export function parseValidateBillSelectionPayload(raw) {
|
|
221
|
+
requireObject(raw, "validate-bill-selection payload");
|
|
222
|
+
return raw;
|
|
223
|
+
}
|
|
224
|
+
/** Matches bill.updatePaymentEvidence for already-paid supplier bills. */
|
|
225
|
+
export function parseUpdateBillPaymentEvidencePayload(raw) {
|
|
226
|
+
requireObject(raw, "update-bill-payment-evidence payload");
|
|
227
|
+
return raw;
|
|
228
|
+
}
|
|
229
|
+
/** Server validates quotation amounts, line items, and the single attachment. */
|
|
230
|
+
export function parseCreateQuotationPayload(raw) {
|
|
231
|
+
requireObject(raw, "create-quotation payload");
|
|
232
|
+
return raw;
|
|
233
|
+
}
|
|
234
|
+
export function parseUpdateQuotationPayload(raw) {
|
|
235
|
+
requireObject(raw, "update-quotation payload");
|
|
236
|
+
return raw;
|
|
237
|
+
}
|
|
238
|
+
export function parseCreateCustomerInvoicePayload(raw) {
|
|
239
|
+
const input = requireObject(raw, "create-customer-invoice payload");
|
|
240
|
+
if (!Array.isArray(input.splits) || input.splits.length === 0) {
|
|
241
|
+
throw new Error("create-customer-invoice payload.splits must be a non-empty array.");
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
budgetId: requiredString(input.budgetId, "create-customer-invoice payload.budgetId"),
|
|
245
|
+
splits: input.splits.map((rawSplit, index) => {
|
|
246
|
+
const split = requireObject(rawSplit, `create-customer-invoice payload.splits[${index}]`);
|
|
247
|
+
return {
|
|
248
|
+
dueDate: toDate(split.dueDate, `create-customer-invoice payload.splits[${index}].dueDate`),
|
|
249
|
+
label: requiredString(split.label, `create-customer-invoice payload.splits[${index}].label`),
|
|
250
|
+
percentage: Number(split.percentage),
|
|
251
|
+
};
|
|
252
|
+
}),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
193
255
|
/** Matches project.updateProject — dateRange.from/to may be ISO strings. */
|
|
194
256
|
export function parseUpdateProjectPayload(raw) {
|
|
195
257
|
const o = requireObject(raw, "update-project payload");
|
package/dist/prisma-enums.js
CHANGED
|
@@ -10,8 +10,24 @@ export const ProjectStatus = {
|
|
|
10
10
|
PITCH: "PITCH",
|
|
11
11
|
WON: "WON",
|
|
12
12
|
COMPLETED: "COMPLETED",
|
|
13
|
+
RECONCILED: "RECONCILED",
|
|
13
14
|
LOST: "LOST",
|
|
14
15
|
};
|
|
16
|
+
export const SupplierQuotationStatus = {
|
|
17
|
+
DRAFT: "DRAFT",
|
|
18
|
+
PENDING_APPROVAL: "PENDING_APPROVAL",
|
|
19
|
+
APPROVED: "APPROVED",
|
|
20
|
+
REJECTED: "REJECTED",
|
|
21
|
+
SUPERSEDED: "SUPERSEDED",
|
|
22
|
+
};
|
|
23
|
+
export const CustomerInvoiceBatchStatus = {
|
|
24
|
+
CREATING: "CREATING",
|
|
25
|
+
PENDING_APPROVAL: "PENDING_APPROVAL",
|
|
26
|
+
APPROVED: "APPROVED",
|
|
27
|
+
REJECTED_VOIDED: "REJECTED_VOIDED",
|
|
28
|
+
EXPIRED_VOIDED: "EXPIRED_VOIDED",
|
|
29
|
+
PARTIAL_QBO_FAILURE: "PARTIAL_QBO_FAILURE",
|
|
30
|
+
};
|
|
15
31
|
export const BudgetStatus = {
|
|
16
32
|
DRAFT: "DRAFT",
|
|
17
33
|
PENDING_APPROVAL: "PENDING_APPROVAL",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-labs-sg/bb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Budget Builder CLI for AI agents — manage budgets, bills, and claims; bill records use isClaimable=false for bills and isClaimable=true for claims.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|