@go-labs-sg/bb 3.23.0 → 3.24.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/dist/index.js CHANGED
@@ -6346,11 +6346,13 @@ var checkCustomerInvoiceReadiness = __name2(async (budgetId) => {
6346
6346
  const result = await api2.customerInvoice.previewExistingInvoice.mutate(input);
6347
6347
  out(result);
6348
6348
  }, "previewQboCustomerInvoice"), importQboCustomerInvoice = __name2(async (input) => {
6349
- await confirmCurrentCommand({ action: "Link existing QuickBooks invoice", target: "QuickBooks invoice ".concat(input.qboInvoiceId, " to budget ").concat(input.budgetId), details: "records the reviewed invoice in Budget Builder only; QuickBooks access is read-only; preserves original evidence and revalidates the preview token" });
6349
+ await confirmCurrentCommand({ action: "Link existing QuickBooks invoice", target: "QuickBooks invoice ".concat(input.qboInvoiceId, " to budget ").concat(input.budgetId), details: "records the reviewed invoice in Budget Builder only; QuickBooks access is read-only; preserves original evidence and revalidates the preview token".concat(input.confirmEstimateLineage ? "; you confirm this invoice, which has no QuickBooks estimate link, belongs to this budget's estimate" : "") });
6350
6350
  const result = await api2.customerInvoice.linkExistingInvoice.mutate(input);
6351
6351
  out(result);
6352
6352
  }, "importQboCustomerInvoice"), createCustomerInvoice = __name2(async (raw) => {
6353
- const input = parseCreateCustomerInvoicePayload(raw), readiness = await api2.customerInvoice.getInvoiceReadiness.query({ budgetId: input.budgetId, includePreview: !0 });
6353
+ const input = parseCreateCustomerInvoicePayload(
6354
+ raw
6355
+ ), readiness = await api2.customerInvoice.getInvoiceReadiness.query({ budgetId: input.budgetId, includePreview: !0 });
6354
6356
  if (!readiness.ready) throw new CliRuntimeError("VALIDATION", readiness.issues.join("; ") || "Invoice is not ready for creation.");
6355
6357
  await assertSensitiveWorkflowConfirmed({ action: "Create customer invoice", entity: "budget ".concat(input.budgetId), details: "queues ".concat(input.splits.length, " invoice(s) for creation in QuickBooks from the budget's remaining uninvoiced balance: ").concat(input.splits.map((split) => "".concat(split.label, " (").concat(split.percentage, "% of the estimate), due ").concat(new Date(split.dueDate).toISOString().slice(0, 10))).join("; "), ". Admin creation is auto-approved; other creators request approval. No customer email is sent.") });
6356
6358
  const result = await api2.customerInvoice.createInvoiceBatch.mutate(input);
@@ -6391,11 +6393,7 @@ var checkCustomerInvoiceReadiness = __name2(async (budgetId) => {
6391
6393
  }, "updateCustomerInvoiceDetails"), updateCustomerInvoiceQboDrift = __name2(async ({ invoiceId, requestId, resolution }) => {
6392
6394
  const keepRequestId = resolution === "KEEP_BB" ? requestId ?? randomUUID2() : void 0;
6393
6395
  await assertSensitiveWorkflowConfirmed({ action: resolution === "ACCEPT_QBO" ? "Accept QuickBooks invoice changes into BB" : "Keep BB invoice values over QuickBooks changes", entity: "invoice ".concat(invoiceId), details: resolution === "ACCEPT_QBO" ? "copies the held QuickBooks bill-to address, memo, bill email and total into BB; QuickBooks is not changed" : "keeps BB's values; queues BB's bill-to address and memo to QuickBooks (external write); bill email and total are not changed in QuickBooks; retry a lost response with --requestId ".concat(keepRequestId) });
6394
- const result = await api2.customerInvoice.resolveQboDrift.mutate({
6395
- invoiceId,
6396
- resolution,
6397
- ...keepRequestId ? { requestId: keepRequestId } : {}
6398
- });
6396
+ const result = await api2.customerInvoice.resolveQboDrift.mutate({ invoiceId, resolution, ...keepRequestId ? { requestId: keepRequestId } : {} });
6399
6397
  out(result);
6400
6398
  }, "updateCustomerInvoiceQboDrift"), markCustomerInvoiceSentExternally = __name2(async (input) => {
6401
6399
  await assertSensitiveWorkflowConfirmed({ action: "Record customer invoice as sent externally", entity: "invoice ".concat(input.invoiceId), details: "records the invoice as SENT (source EXTERNAL) at ".concat(input.sentAt, " for ").concat(input.recipients.join(", "), "; sends no email and does not write to QuickBooks") });
@@ -6412,10 +6410,13 @@ async function updateBillFromPayload(raw) {
6412
6410
  out(result);
6413
6411
  }
6414
6412
  __name(updateBillFromPayload, "updateBillFromPayload"), __name2(updateBillFromPayload, "updateBillFromPayload");
6415
- var validateBillSelectionFromPayload = __name2(async (raw, quotationFlags) => {
6416
- const input = parseValidateBillSelectionPayload(raw, quotationFlags), result = await api2.bill.validateSelection.mutate(input);
6417
- out(result);
6418
- }, "validateBillSelectionFromPayload"), linkBillQuotations = __name2(async (billId, raw) => {
6413
+ var validateBillSelectionFromPayload = __name2(
6414
+ async (raw, quotationFlags) => {
6415
+ const input = parseValidateBillSelectionPayload(raw, quotationFlags), result = await api2.bill.validateSelection.mutate(input);
6416
+ out(result);
6417
+ },
6418
+ "validateBillSelectionFromPayload"
6419
+ ), linkBillQuotations = __name2(async (billId, raw) => {
6419
6420
  const input = parseLinkBillQuotationsPayload(billId, raw), result = await api2.bill.linkQuotations.mutate(input);
6420
6421
  out(result);
6421
6422
  }, "linkBillQuotations"), updateBillPaymentEvidenceFromPayload = __name2(async (raw) => {
@@ -6462,9 +6463,7 @@ async function createSupplierFromPayload(raw) {
6462
6463
  __name(createSupplierFromPayload, "createSupplierFromPayload"), __name2(createSupplierFromPayload, "createSupplierFromPayload");
6463
6464
  async function updateSupplierFromPayload(raw) {
6464
6465
  const input = parseSupplierUpdatePayload(raw);
6465
- await assertSensitiveWorkflowConfirmed(
6466
- { action: "Update supplier", entity: "supplier ".concat(input.id), details: "Normal-user edits also request approval and queue approval emails." }
6467
- );
6466
+ await assertSensitiveWorkflowConfirmed({ action: "Update supplier", entity: "supplier ".concat(input.id), details: "Normal-user edits also request approval and queue approval emails." });
6468
6467
  const updated = await api2.supplier.updateSupplier.mutate(input);
6469
6468
  out(updated);
6470
6469
  }
@@ -6483,11 +6482,12 @@ async function createContactPersonFromPayload(raw) {
6483
6482
  const input = parseContactCreatePayload(raw), result = await api2.contactPerson.createContactPerson.mutate(input);
6484
6483
  out(result);
6485
6484
  }
6486
- __name(createContactPersonFromPayload, "createContactPersonFromPayload"), __name2(createContactPersonFromPayload, "createContactPersonFromPayload");
6485
+ __name(createContactPersonFromPayload, "createContactPersonFromPayload"), __name2(
6486
+ createContactPersonFromPayload,
6487
+ "createContactPersonFromPayload"
6488
+ );
6487
6489
  async function updateContactPersonFromPayload(raw) {
6488
- const input = parseContactUpdatePayload(
6489
- raw
6490
- ), result = await api2.contactPerson.updateContactPerson.mutate(input);
6490
+ const input = parseContactUpdatePayload(raw), result = await api2.contactPerson.updateContactPerson.mutate(input);
6491
6491
  out(result);
6492
6492
  }
6493
6493
  __name(updateContactPersonFromPayload, "updateContactPersonFromPayload"), __name2(updateContactPersonFromPayload, "updateContactPersonFromPayload");
@@ -6521,7 +6521,10 @@ async function approveBudget(budgetId) {
6521
6521
  }
6522
6522
  __name(approveBudget, "approveBudget"), __name2(approveBudget, "approveBudget");
6523
6523
  async function rejectBudget(budgetId, reason) {
6524
- await assertSensitiveWorkflowConfirmed({ action: "Reject budget", entity: "budget ".concat(budgetId), details: 'with reason "'.concat(reason, '" and send requester reply email') });
6524
+ await assertSensitiveWorkflowConfirmed({ action: "Reject budget", entity: "budget ".concat(budgetId), details: 'with reason "'.concat(
6525
+ reason,
6526
+ '" and send requester reply email'
6527
+ ) });
6525
6528
  const approval = (await getAllPendingApprovals()).filter((n) => n.notificationType === "request" && n.status === ExtendedApprovalStatus.PENDING_APPROVAL && n.type === ExtendedApprovalType.BUDGET && (n.budgetId === budgetId || n.budget?.id === budgetId))[0];
6526
6529
  if (!approval) throw new Error("No pending budget approval found for this budget and approver.");
6527
6530
  const result = await api2.budget.updateBudgetApproval.mutate({ budgetApprovalId: approval.id, status: ExtendedApprovalStatus.REJECTED, rejectionReason: reason });
@@ -6549,25 +6552,21 @@ async function getSupplierItems(supplierId) {
6549
6552
  __name(getSupplierItems, "getSupplierItems"), __name2(getSupplierItems, "getSupplierItems");
6550
6553
  async function getSupplierDetails(supplierId) {
6551
6554
  const supplier = await api2.supplier.getSupplierById.query({ id: supplierId }), respondedStatuses = /* @__PURE__ */ new Set([ExtendedApprovalStatus.APPROVED, ExtendedApprovalStatus.REJECTED]), latestRespondedApproval = [...supplier.approvals.filter((approval) => respondedStatuses.has(approval.status))].sort((a, b) => new Date(b.respondedAt ?? b.updatedAt).getTime() - new Date(a.respondedAt ?? a.updatedAt).getTime() || new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0], pendingApprovals = supplier.approvals.filter((approval) => approval.status === ExtendedApprovalStatus.PENDING_APPROVAL), supersededApprovals = supplier.approvals.filter((approval) => approval.status === ExtendedApprovalStatus.SUPERSEDED), respondedByApproval = latestRespondedApproval ?? null, responseUser = respondedByApproval ? respondedByApproval.responder ?? respondedByApproval.approver : null;
6552
- out({ ...supplier, supplierApprovalSummary: {
6553
- pendingApprovalCount: pendingApprovals.length,
6554
- pendingApprovers: pendingApprovals.map((approval) => ({ approvalId: approval.id, approverId: approval.approverId, name: approval.approver.name, email: approval.approver.email, createdAt: approval.createdAt, updatedAt: approval.updatedAt })),
6555
- supersededApprovalCount: supersededApprovals.length,
6556
- supersededApprovers: supersededApprovals.map((approval) => ({ approvalId: approval.id, approverId: approval.approverId, name: approval.approver.name, email: approval.approver.email, respondedAt: approval.respondedAt, responder: approval.responder ? { id: approval.responder.id, name: approval.responder.name, email: approval.responder.email } : null })),
6557
- respondedBy: respondedByApproval && responseUser ? { approvalId: respondedByApproval.id, status: respondedByApproval.status, approverId: respondedByApproval.approverId, responderId: respondedByApproval.responderId, name: responseUser.name, email: responseUser.email, respondedAt: respondedByApproval.respondedAt, updatedAt: respondedByApproval.updatedAt } : null
6558
- } });
6555
+ out({ ...supplier, supplierApprovalSummary: { pendingApprovalCount: pendingApprovals.length, pendingApprovers: pendingApprovals.map((approval) => ({ approvalId: approval.id, approverId: approval.approverId, name: approval.approver.name, email: approval.approver.email, createdAt: approval.createdAt, updatedAt: approval.updatedAt })), supersededApprovalCount: supersededApprovals.length, supersededApprovers: supersededApprovals.map((approval) => ({ approvalId: approval.id, approverId: approval.approverId, name: approval.approver.name, email: approval.approver.email, respondedAt: approval.respondedAt, responder: approval.responder ? { id: approval.responder.id, name: approval.responder.name, email: approval.responder.email } : null })), respondedBy: respondedByApproval && responseUser ? { approvalId: respondedByApproval.id, status: respondedByApproval.status, approverId: respondedByApproval.approverId, responderId: respondedByApproval.responderId, name: responseUser.name, email: responseUser.
6556
+ email, respondedAt: respondedByApproval.respondedAt, updatedAt: respondedByApproval.updatedAt } : null } });
6559
6557
  }
6560
- __name(getSupplierDetails, "getSupplierDetails"), __name2(
6561
- getSupplierDetails,
6562
- "getSupplierDetails"
6563
- );
6558
+ __name(getSupplierDetails, "getSupplierDetails"), __name2(getSupplierDetails, "getSupplierDetails");
6564
6559
  async function approveSupplier(supplierId) {
6565
6560
  const supplier = await api2.supplier.getSupplierOverview.query({ id: supplierId });
6566
6561
  if (supplier.status === ExtendedApprovalStatus.REJECTED) {
6567
6562
  await assertSensitiveWorkflowConfirmed({ action: "Re-approve supplier", entity: "supplier ".concat(supplierId), effects: ["state-change", "external-write"], details: supplier.active ? "and queue its QuickBooks vendor sync (it is usable once QuickBooks confirms); append a new approval and retain earlier history; no requester reply email is sent" : "and queue its QuickBooks vendor sync; append a new approval and retain earlier history; it remains archived and no requester reply email is sent" }), out(await api2.supplier.reapproveSupplier.mutate({ supplierId }));
6568
6563
  return;
6569
6564
  }
6570
- await assertSensitiveWorkflowConfirmed({ action: "Approve supplier", entity: "supplier ".concat(supplierId), details: "and send requester reply email" });
6565
+ await assertSensitiveWorkflowConfirmed({
6566
+ action: "Approve supplier",
6567
+ entity: "supplier ".concat(supplierId),
6568
+ details: "and send requester reply email"
6569
+ });
6571
6570
  const approval = (await getAllPendingApprovals()).filter((n) => n.notificationType === "request" && n.status === ExtendedApprovalStatus.PENDING_APPROVAL && n.type === ExtendedApprovalType.SUPPLIER && (n.supplierId === supplierId || n.supplier?.id === supplierId))[0];
6572
6571
  if (!approval) throw new Error("No pending supplier approval found.");
6573
6572
  const result = await api2.supplier.updateSupplierApproval.mutate({ supplierApprovalId: approval.id, status: ExtendedApprovalStatus.APPROVED });
@@ -6633,7 +6632,9 @@ async function rejectQuotation(quotationId, reason) {
6633
6632
  __name(rejectQuotation, "rejectQuotation"), __name2(rejectQuotation, "rejectQuotation");
6634
6633
  var listCompanies = __name2(async (input) => {
6635
6634
  const result = await api2.company.getCompanies.query(input);
6636
- out(result);
6635
+ out(
6636
+ result
6637
+ );
6637
6638
  }, "listCompanies"), countCompanies = __name2(async (input) => {
6638
6639
  const result = await api2.company.getCompanyCounts.query(input);
6639
6640
  out(result);
@@ -6658,9 +6659,12 @@ var searchExistingCompanies = __name2(async (input) => {
6658
6659
  }, "listProjects"), countProjects = __name2(async (input) => {
6659
6660
  const result = await api2.project.getProjectCounts.query(input);
6660
6661
  out(result);
6661
- }, "countProjects"), listProjectHubs = __name2(async (input) => {
6662
- out(await api2.project.getAllProjectHubs.query(input));
6663
- }, "listProjectHubs"), countProjectHubs = __name2(async (input) => {
6662
+ }, "countProjects"), listProjectHubs = __name2(
6663
+ async (input) => {
6664
+ out(await api2.project.getAllProjectHubs.query(input));
6665
+ },
6666
+ "listProjectHubs"
6667
+ ), countProjectHubs = __name2(async (input) => {
6664
6668
  out(await api2.project.getProjectHubCounts.query(input));
6665
6669
  }, "countProjectHubs");
6666
6670
  async function getProject(id) {
@@ -6682,7 +6686,9 @@ var getProjectHubStatus = __name2(async (projectId) => {
6682
6686
  }, "syncProjectHubCommercialDocuments");
6683
6687
  async function createProject(opts) {
6684
6688
  const name = parseQuickBooksName(opts.name), asanaTaskId = await resolveCreateProjectAsanaTaskId({ name, asanaTaskId: opts.asanaTaskId, asanaSearch: opts.asanaSearch }), result = await api2.project.createProject.mutate({ name, description: opts.description, companyId: opts.companyId, contactPersonId: opts.contactPersonId, insideSalesId: opts.insideSalesId, businessDevelopmentId: opts.businessDevelopmentId, projectManagerId: opts.projectManagerId, venue: opts.venue, pax: opts.pax, asanaTaskId, dateRange: { from: new Date(opts.startDate), to: opts.endDate ? new Date(opts.endDate) : void 0 } });
6685
- out(result);
6689
+ out(
6690
+ result
6691
+ );
6686
6692
  }
6687
6693
  __name(createProject, "createProject"), __name2(createProject, "createProject");
6688
6694
  async function updateProjectStatus(id, status, opts) {
@@ -6698,9 +6704,12 @@ var checkProjectReconciliation = __name2(async (projectId) => {
6698
6704
  await assertSensitiveWorkflowConfirmed({ action: "Reconcile project", entity: "project ".concat(projectId), details: "rerun all reconciliation checks and mark it RECONCILED" });
6699
6705
  const result = await api2.project.reconcile.mutate({ projectId });
6700
6706
  out(result);
6701
- }, "reconcileProject"), completeProject = __name2(async (projectId) => {
6702
- await updateProjectStatus(projectId, ProjectStatus2.COMPLETED);
6703
- }, "completeProject"), importQuickBooksProjectId = __name2(async (projectId, projectUrl) => {
6707
+ }, "reconcileProject"), completeProject = __name2(
6708
+ async (projectId) => {
6709
+ await updateProjectStatus(projectId, ProjectStatus2.COMPLETED);
6710
+ },
6711
+ "completeProject"
6712
+ ), importQuickBooksProjectId = __name2(async (projectId, projectUrl) => {
6704
6713
  const result = await api2.project.importQboProjectId.mutate({ projectId, projectUrl });
6705
6714
  out(result);
6706
6715
  }, "importQuickBooksProjectId"), listWebhookEventTypes = __name2(async () => {
@@ -6715,7 +6724,9 @@ var checkProjectReconciliation = __name2(async (projectId) => {
6715
6724
  }, "createWebhookEndpoint"), updateWebhookEndpoint = __name2(async (input) => {
6716
6725
  out(await api2.webhook.updateEndpoint.mutate(input));
6717
6726
  }, "updateWebhookEndpoint"), deleteWebhookEndpoint = __name2(async (id) => {
6718
- await assertSensitiveWorkflowConfirmed({ action: "Delete webhook endpoint and its delivery history", entity: "webhook endpoint ".concat(id) }), out(await api2.webhook.deleteEndpoint.mutate({ id }));
6727
+ await assertSensitiveWorkflowConfirmed(
6728
+ { action: "Delete webhook endpoint and its delivery history", entity: "webhook endpoint ".concat(id) }
6729
+ ), out(await api2.webhook.deleteEndpoint.mutate({ id }));
6719
6730
  }, "deleteWebhookEndpoint"), rotateWebhookSecret = __name2(async (input) => {
6720
6731
  await assertSensitiveWorkflowConfirmed({ action: "Rotate webhook signing secret", entity: "webhook endpoint ".concat(input.id), details: "previous secrets keep signing for ".concat(input.previousSecretTtlHours ?? 24, "h") });
6721
6732
  const result = await api2.webhook.rotateSecret.mutate(input);
@@ -6726,15 +6737,15 @@ var checkProjectReconciliation = __name2(async (projectId) => {
6726
6737
  out(await api2.webhook.listDeliveries.query(input));
6727
6738
  }, "listWebhookDeliveries"), getWebhookDelivery = __name2(async (deliveryId) => {
6728
6739
  out(await api2.webhook.getDelivery.query({ deliveryId }));
6729
- }, "getWebhookDelivery"), replayWebhookDelivery = __name2(async (deliveryId) => {
6730
- out(await api2.webhook.replayDelivery.mutate({ deliveryId }));
6731
- }, "replayWebhookDelivery"), listIntegrationOperations = __name2(
6732
- async (input) => {
6733
- const result = await api2.integration.listOperations.query(input);
6734
- out(result);
6740
+ }, "getWebhookDelivery"), replayWebhookDelivery = __name2(
6741
+ async (deliveryId) => {
6742
+ out(await api2.webhook.replayDelivery.mutate({ deliveryId }));
6735
6743
  },
6736
- "listIntegrationOperations"
6737
- ), getIntegrationOperation = __name2(async (operationId) => {
6744
+ "replayWebhookDelivery"
6745
+ ), listIntegrationOperations = __name2(async (input) => {
6746
+ const result = await api2.integration.listOperations.query(input);
6747
+ out(result);
6748
+ }, "listIntegrationOperations"), getIntegrationOperation = __name2(async (operationId) => {
6738
6749
  const result = await api2.integration.getOperation.query({ operationId });
6739
6750
  out(result);
6740
6751
  }, "getIntegrationOperation"), countIntegrationOperations = __name2(async (input) => {
@@ -6747,16 +6758,16 @@ var checkProjectReconciliation = __name2(async (projectId) => {
6747
6758
  await assertSensitiveWorkflowConfirmed({ action: "Verify QuickBooks resource outcome", entity: "operation ".concat(operationId), details: "verify the saved receipt or read QuickBooks when the attempt is uncertain, then queue local update/archive/reactivation finalization without repeating the provider mutation" });
6748
6759
  const result = await api2.integration.reconcileResourceOperation.mutate({ operationId });
6749
6760
  out(result);
6750
- }, "reconcileResourceOperation"), listInboundSources = __name2(async (input) => {
6751
- const result = await api2.inbound.listSources.query(input);
6752
- out(result);
6753
- }, "listInboundSources"), countInboundSources = __name2(
6761
+ }, "reconcileResourceOperation"), listInboundSources = __name2(
6754
6762
  async (input) => {
6755
- const result = await api2.inbound.countSources.query(input);
6763
+ const result = await api2.inbound.listSources.query(input);
6756
6764
  out(result);
6757
6765
  },
6758
- "countInboundSources"
6759
- ), createInboundSource = __name2(async (input) => {
6766
+ "listInboundSources"
6767
+ ), countInboundSources = __name2(async (input) => {
6768
+ const result = await api2.inbound.countSources.query(input);
6769
+ out(result);
6770
+ }, "countInboundSources"), createInboundSource = __name2(async (input) => {
6760
6771
  const result = await api2.inbound.createSource.mutate(input);
6761
6772
  out(result);
6762
6773
  }, "createInboundSource"), getInboundSource = __name2(async (sourceId) => {
@@ -6797,10 +6808,7 @@ async function getItem(id) {
6797
6808
  const item = await api2.item.getItem.query({ id });
6798
6809
  out(item);
6799
6810
  }
6800
- __name(getItem, "getItem"), __name2(
6801
- getItem,
6802
- "getItem"
6803
- );
6811
+ __name(getItem, "getItem"), __name2(getItem, "getItem");
6804
6812
  var getItemQuickBooksSyncStatus = __name2(async (itemId) => {
6805
6813
  const result = await api2.item.getQuickBooksSyncStatus.query({ id: itemId });
6806
6814
  out(result);
@@ -6852,10 +6860,7 @@ async function getDashboard(input) {
6852
6860
  const result = await api2.dashboard.getDashboard.query({ userId: input.userId, role: input.role ?? "ALL", deals: input.deals ?? "ALL", timeFrame: input.timeFrame ?? "ALL", startDate: input.startDate, endDate: input.endDate });
6853
6861
  out(result);
6854
6862
  }
6855
- __name(getDashboard, "getDashboard"), __name2(
6856
- getDashboard,
6857
- "getDashboard"
6858
- );
6863
+ __name(getDashboard, "getDashboard"), __name2(getDashboard, "getDashboard");
6859
6864
  async function getMonthlyMetrics(input) {
6860
6865
  const result = await api2.dashboard.getMonthlyMetrics.query({ userId: input.userId, role: input.role ?? "ALL", deals: input.deals ?? "ALL", timeFrame: input.timeFrame ?? "ALL", startDate: input.startDate, endDate: input.endDate });
6861
6866
  out(result);
@@ -6925,9 +6930,7 @@ async function getBillReview(billId) {
6925
6930
  }
6926
6931
  __name(getBillReview, "getBillReview"), __name2(getBillReview, "getBillReview");
6927
6932
  async function requestBillReview(billId, requestId) {
6928
- out(await api2.ai.requestBillReview.mutate(
6929
- { billId, requestId }
6930
- ));
6933
+ out(await api2.ai.requestBillReview.mutate({ billId, requestId }));
6931
6934
  }
6932
6935
  __name(requestBillReview, "requestBillReview"), __name2(requestBillReview, "requestBillReview");
6933
6936
  function parseLongFlag(arg, next, flags) {
@@ -6976,7 +6979,10 @@ __name(parseJsonObjectFlag, "parseJsonObjectFlag"), __name2(parseJsonObjectFlag,
6976
6979
  function parseOptionalNumber(raw, label) {
6977
6980
  if (raw === void 0 || raw === "") return;
6978
6981
  const n = typeof raw == "number" ? raw : Number.parseFloat(String(raw).trim());
6979
- if (!Number.isFinite(n)) throw new CliRuntimeError("VALIDATION", "".concat(label, " must be a number."));
6982
+ if (!Number.isFinite(n)) throw new CliRuntimeError("VALIDATION", "".concat(
6983
+ label,
6984
+ " must be a number."
6985
+ ));
6980
6986
  return n;
6981
6987
  }
6982
6988
  __name(parseOptionalNumber, "parseOptionalNumber"), __name2(parseOptionalNumber, "parseOptionalNumber");
@@ -7004,121 +7010,60 @@ remove-budget-item", "restore-budget-version", "update-project-status"]), explic
7004
7010
  if (explicit) return explicit;
7005
7011
  const effects = /* @__PURE__ */ new Set();
7006
7012
  return mutationPrefixes.some((prefix) => legacyTarget.startsWith(prefix)) && effects.add("state-change"), (legacyTarget.startsWith("delete-") || deleteTargets.has(legacyTarget)) && effects.add("delete"), emailTargets.has(legacyTarget) && effects.add("email"), externalWriteTargets.has(legacyTarget) && effects.add("external-write"), financialWriteTargets.has(legacyTarget) && effects.add("financial-write"), [...effects];
7007
- }, "effectsFor"), titleCase = __name2((value) => value.split("-").map((word) => "".concat(word.slice(0, 1).toUpperCase()).concat(
7008
- word.slice(1)
7009
- )).join(" "), "titleCase"), SUMMARIES = /* @__PURE__ */ new Map([
7010
- ["update-budget-status", "Update budget status. APPROVED requires a current Lead/Admin role; budget management permission alone is insufficient. Ordinary users must request approval. Status changes invalidate old pending requests."],
7011
- ["approve-budget", "Decide your assigned pending budget approval as a current Lead/Admin. Material edits supersede old requests; inspect the latest content and use a fresh request after edits."],
7012
- ["reject-budget", "Decide your assigned pending budget approval as a current Lead/Admin. Material edits supersede old requests; inspect the latest content and use a fresh request after edits."],
7013
- ["create-budget-approval", "Request budget approval for the current content, superseding older pending requests. Existing Lead/Admin autoapproval remains available."],
7014
- ["update-budget-item-supplier", "Change a budget item's eligible supplier/GST snapshot as a material financial edit. Supersede pending approvals and apply the standard budget-to-DRAFT reset policy; inspect and request approval again. An unchanged supplier is a no-op."],
7015
- ["submit-quotation", "Submit a quotation for signing and approval. Claim the captured revision and exact allocation selection; concurrent edits, budget-item deletion or restore cascades conflict instead of attaching old signed PDFs. Refresh and resubmit the current content. The signed PDF is stamped by a queued job (pdfProcessing: PROCESSING until linked); a file whose PDF conversion failed must be uploaded again first. The result includes gstMismatch (null, or the basis, expected GST, saved GST and their difference; see create-quotation); it is a warning only and the approval email shows it to approvers."],
7016
- ["approve-quotation", "Approve your assigned pending quotation as a current Admin. Claim the captured revision and exact allocation selection after signing; concurrent changes conflict and roll back the decision, signed-PDF job and email/outbox. Refresh and review the current content before retrying. The final signed PDF is stamped by a queued job (pdfProcessing); a stopped earlier PDF step blocks approval until it is retried."],
7017
- ["approve-supplier", "Approve a pending supplier request and send a requester reply email, or directly re-approve a rejected supplier as Admin/Lead without a pending request or email. The QuickBooks vendor is created, linked or updated by a queued job (quickBooksSyncQueued, operationId); the supplier stays PENDING_APPROVAL until QuickBooks confirms, and archived suppliers remain archived. Argument: <supplierId>."],
7018
- ["list-approvals", "List one page of requests currently assigned to you and pending approval, oldest first. Returns { items, pageInfo }; follow nextCursor with unchanged --type. --page/--perPage are rejected."],
7019
- ["get-pending-approval", "Read one request still pending your approval, or null if it is no longer pending/assigned. Argument: <approvalId>."],
7020
- ["get-bill-review", "Read current advisory AI bill review and evidence. Passive; no provider calls. Argument: <billId>."],
7021
- ["request-bill-review", "Queue an advisory AI review of a bill pending your approval. No financial decision is made. <billId> [--requestId <id>]"],
7022
- ["get-bill-details", "Get a bill's summary as shown in the web app: status, amounts, people, payment and line totals. Use get-bill-line-items, get-bill-approvals, get-bill-attachments or get-bill-payment for more detail. Argument: <billId>."],
7023
- ["get-bill-line-items", "List a bill's line items with budget-item and quotation-allocation detail. <billId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7024
- ["get-bill-approvals", "List a bill's approval requests with approver, requester and responder. <billId> [--limit 1-50] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7025
- ["get-bill-payment", "Get a bill's payment status, reference, date, tracking URL, QuickBooks link and external payment. Argument: <billId>."],
7026
- ["get-quotation", "Get a quotation as shown in the web app: status, documentOnly (true for a $0 supplier document that is never a bill quotation source and does not count as coverage), amounts, people, line totals, files and approvals. pdfProcessing is { status: PROCESSING | FAILED, step: NORMALIZE | STAMP, operationId, error } while a queued PDF conversion or signing step has not linked its PDF, else null. gstMismatch is null, or { basis, expectedGstAmount, enteredGstAmount, difference, message } when the saved GST is non-zero and more than $0.05 away from the expected GST (TAXABLE_LINES: the bill calculation for the quoted lines; FULL_SUBTOTAL: 9% of the subtotal); check it before approving. Use get-quotation-line-items for budget-item detail. Argument: <quotationId>."],
7027
- ["get-customer-invoice", "Get an invoice batch as shown in the web app: status, totals, people, approvals and invoice summaries. Use get-customer-invoice-invoices, get-customer-invoice-lines, get-customer-invoice-approvals or get-customer-invoice-history for more detail. Argument: <batchId>."],
7028
- ["get-customer-invoice-invoices", "List a batch's invoices with QuickBooks id/doc number, issue/due dates, amounts, sync state and sender. Argument: <batchId>."],
7029
- ["get-customer-invoice-lines", "List one invoice's lines (name, description, QuickBooks item/tax code, quantity, amounts). <invoiceId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7030
- ["get-customer-invoice-approvals", "List an invoice batch's approval requests with approver, requester and responder. <batchId> [--limit 1-50] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7031
- ["get-customer-invoice-history", "List an invoice batch's status history (batch/invoice status changes, source, note, actor). <batchId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7032
- ["get-customer-invoice-payments", "List the payments QuickBooks applied to one invoice: payment id, date, reference, amount applied, total and attachment names. Argument: <invoiceId> (from get-customer-invoice-invoices). Live QuickBooks read."],
7033
- ["get-quotation-line-items", "List a quotation's line items with budget-item, supplier and budget detail. <quotationId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7034
- ["get-bill-attachments", "List bill attachments with cursor pagination. <billId> [--limit 1-50] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."],
7035
- ["get-budget-categories", "List budget categories with cursor pagination. [--q] [--limit 1-100] [--cursor <token>] Active categories, name A\u2013Z. Returns { items, pageInfo }; follow nextCursor with the same --q."],
7036
- ["get-supplier-overview", "Get a supplier's profile, approvals, pending update, attachments and tab counts (usageCount, _count.items). Skips usage rows, spending and items; use get-supplier-usage or get-supplier-items for those."],
7037
- ["get-supplier-usage", "Get a supplier's usage rows (accepted/closed budget lines and lines with its actual spending) plus spending, actualSpending and estimatedSpending."],
7038
- ["get-supplier-items", "Get the inventory items catalogued under a supplier."],
7039
- ["get-supplier-analytics", "List supplier analytics rows with cursor pagination. [--name] [--status CSV] [--gstRegistered true|false] [--createdBy <text>] [--timeFrame ALL|LAST_YEAR|LAST_6_MONTHS|LAST_3_MONTHS|CUSTOM] [--startDate <ISO> --endDate <ISO>] [--sortBy name|gstRegistered|status|phone|email|updatedAt|createdAt] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Admin. Returns { items, pageInfo }; follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected."],
7040
- ["list-api-keys", "List API keys with cursor pagination. [--userId <userId>] [--limit 1-100] [--cursor <token>] (newest first, { items, pageInfo }; defaults to the caller; admin required for another user)"],
7041
- [
7042
- "list-claims",
7043
- "List reimbursable claims with cursor pagination. Same flags as list-bills (--limit 1-100, --cursor, --direction forward|backward); ignores --isClaimable. Returns { items, pageInfo }."
7044
- ],
7045
- ["list-bills", "List bills with cursor pagination. [--projectId] [--budgetId] [--status CSV] [--search <text>] [--isClaimable true|false] [--createdByIds <csv>] [--sortBy createdAt|amount|status] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Returns { items, pageInfo }; pass nextCursor with --direction forward or previousCursor with --direction backward, keeping the same filters and sort. --page/--pageSize/--perPage are rejected."],
7046
- ["list-customer-invoices", "List customer invoice batches with cursor pagination. [budgetId] [--projectId <id>] [--companyIds CSV] [--projectIds CSV] [--budgetIds CSV] [--createdByIds CSV] [--status CSV] [--search] [--sortBy createdAt|status|totalInvoiceAmount|approvalExpiresAt] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Returns { items, pageInfo }; follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected. No scope flag lists invoices globally. --projectId uses the project scope. A positional budgetId is a backward-compatible shortcut for --budgetIds."],
7047
- ["list-quotations", "List quotations with cursor pagination. [--projectId] [--budgetId] [--supplierId] [--status CSV] [--createdBy CSV] [--search] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Newest first; returns { items, pageInfo }; each row carries documentOnly (document-only $0 quotations are listed and counted like any other). Follow nextCursor/previousCursor with the same filters. --page/--pageSize/--perPage are rejected; --requesterIds remains an alias for --createdBy."],
7048
- ["list-users", "List users with cursor pagination. [--q] [--projectTeamOnly true|false] [--limit 1-100] [--cursor <token>] Name A\u2013Z. Returns { items, pageInfo }; follow nextCursor with the same --q and --projectTeamOnly. --projectTeamOnly true lists only active @getout.sg users, the only accounts accepted as Inside Sales, Business Development or Project Manager. --page/--perPage are rejected."],
7049
- ["list-companies", "List companies with cursor pagination. Returns { items, pageInfo }; default sort is createdAt descending with limit 20. Pass nextCursor forward or previousCursor backward unchanged. Legacy page/perPage flags are rejected."],
7050
- ["count-companies", "Count companies independently from list pagination. Returns { totalCount, counts: { active: { true, false } } }; accepts filters only and rejects pagination/sorting flags."],
7051
- ["list-projects", "List projects with cursor pagination. Returns { items, pageInfo }; default sort is createdAt descending with limit 20. Supports legacy --status plus optional --statuses, WON-date filters (--wonFrom, --wonTo, --wonWithinDays) and --sortBy wonAt; pass nextCursor forward or previousCursor backward unchanged. Legacy page/perPage flags are rejected."],
7052
- ["count-projects", "Count projects independently from list pagination. Returns { totalCount, counts: { status, active: { true, false } } }; accepts project filters only and rejects pagination/sorting flags."],
7053
- ["search-existing-companies", "Search BB and QuickBooks companies without writes. --query <name> [--limit 1-50] [--cursor <token>]. Returns { items, totalCount, pageInfo }; follow pageInfo.nextCursor with the same --query. Legacy --page is rejected."],
7054
- ["use-existing-company", "Reuse a company in BB and QuickBooks, creating only its missing counterpart. Supply --companyId <bbId> and/or --quickbooksId <qboId>; both explicitly connect records with different names. Importing a QuickBooks-only company also needs --name <QuickBooks name from search-existing-companies>. --website <url> fills a missing QBO import website only. --confirmDistinct true confirms no similar record represents this entity. BB saves the company now; its QuickBooks customer is checked, found or created and linked by a queued job (quickBooksSyncQueued, operationId). Estimates, invoices and QuickBooks projects wait for that link."],
7055
- ["create-company", "Create or reuse a company in BB and QuickBooks. --name <name> --website <url> [--billingEmails '<json-array>'] (up to 50 invoice Cc defaults, stored in BB only for new companies; reused company defaults are preserved). Similar names require --confirmDistinct true; inactive companies are never reactivated. BB saves the company now; its QuickBooks customer is found or created by a queued job (quickBooksSyncQueued, operationId), which stops if similar QuickBooks customers exist without --confirmDistinct."],
7056
- ["create-project", "Create a project linked to an existing Asana Deals lead task. Supply --asanaTaskId in non-interactive use; interactive use searches for and selects a lead task (optionally --asanaSearch). For a new direct client, create the lead task using the website form first."],
7057
- ["create-supplier", "Create a supplier using --payload JSON; pending-approval suppliers also request approval and send emails. Reusing an archived name requires Admin; normal users and Leads must ask an Admin to reactivate it before editing. Recreation preserves the existing approval status and creator. Lead/Admin-created suppliers (and archived-name revivals) queue their QuickBooks vendor create or link (quickBooksSyncQueued, operationId) and become usable once QuickBooks confirms; the request makes no QuickBooks call."],
7058
- ["preview-qbo-customer-invoice", "Preview an available QuickBooks invoice selected for a BB budget using read-only QBO access. Arguments: <budgetId> <qboInvoiceId>."],
7059
- ["preview-customer-invoice-amount", "Preview amount before GST, GST, and total for a percentage of an accepted estimate. Arguments: <budgetId> <percentage-of-estimate>."],
7060
- ["list-available-qbo-customer-invoices", "List unlinked QuickBooks invoices available for an accepted or closed estimate. Argument: <budgetId>."],
7061
- ["resubmit-customer-invoice", "Resubmit a confirmed expired-and-voided BB invoice as its original requester. Argument: <batchId>. Queues one replacement using the current estimate, original percentage, due date and details; retries return the same replacement. No customer email."],
7062
- ["create-customer-invoice", "Create one invoice from an eligible budget using --payload JSON with invoice date, due date, billing address, customer memo, and a percentage of the original estimate that does not exceed its remaining coverage."],
7063
- ["import-qbo-customer-invoice", "Link an existing QuickBooks invoice in BB only after reviewing preview-qbo. Arguments: <budgetId> <qboInvoiceId> --token <previewToken>. Supports closed estimates; no QBO writes or emails."],
7064
- ["whoami", "Show the active API-key identity."],
7065
- ["list-budgets", "List one cursor page of budgets ({ items, pageInfo }; --limit/--cursor/--direction). Omit --active for active budgets only; use --active false or --active all for Admin-only historical reads."],
7066
- ["list-items", "List one cursor page of catalogue items ({ items, pageInfo }; --limit/--cursor/--direction, optional --sortBy/--sortDir). --page/--perPage are rejected."],
7067
- ["list-item-categories", "List one cursor page of active item categories ({ items, pageInfo }; --limit/--cursor/--direction, optional --name/--sortBy/--sortDir). --page/--perPage are rejected."],
7068
- ["create-item-category", "Admin only. Create (or reactivate) an item category. Budget Builder saves it now and a queued job creates or links the QuickBooks category (quickBooksSyncQueued, operationId); the request makes no QuickBooks call."],
7069
- ["update-item-category", "Rename an item category. Budget Builder saves the name immediately; a category linked to QuickBooks is renamed there by a queued job (quickBooksSyncQueued: true, operationId), never during the request."],
7070
- ["count-item-categories", "Count active item categories matching --name: { totalCount }."],
7071
- ["list-webhook-deliveries", "Admin-only: list webhook deliveries newest first. Returns { items, pageInfo }; follow pageInfo.nextCursor (or previousCursor with --direction backward). Cursors are opaque and filter-bound; raw delivery ids are rejected."],
7072
- ["list-integration-operations", "List one cursor page of integration operations, newest first ({ items, pageInfo }; --limit/--cursor/--direction). --page/--perPage are rejected. Admin only."],
7073
- ["count-integration-operations", "Provider filter options for integration operations: { filterOptions }. No total; filter flags are accepted but do not change the result. Admin only."],
7074
- ["count-items", "Count catalogue items matching filters: total plus category and supplier facets (each ignores its own filter)."],
7075
- ["count-budgets", "Count budgets matching filters: totalCount plus status and active facets. Omit --active for active budgets only."],
7076
- ["get-budget", "Get a budget by ID. Omit --includeInactive for active budgets only; --includeInactive is an Admin-only historical read."],
7077
- ["get-budget-items", "Get line items for a budget. Omit --includeInactive for active budgets only; --includeInactive is an Admin-only historical read."],
7078
- ["get-budget-details", "Get budget details. Omit --includeInactive for active budgets only; --includeInactive is an Admin-only historical read."],
7079
- ["create-bill", "Create a bill or claim with an approved supplier. All amount fields exclude GST: amount is the portion billed; extractedAmount is the full invoice subtotal; lineAmounts and quotationAllocations also exclude GST. Example: 1800 + 162 GST = 1962 total requires amount=1800 and extractedAmount=1800 for a full bill. The CLI does not strip GST from input. If the selected quotations cannot split the bill amount across every selected line (a line without a quoted amount that cannot be derived from the quotation total), pass lineAmounts; updates that keep the same amount and lines reuse the existing line amounts. --draft-only guarantees DRAFT without email or external writes; otherwise unpaid creation skips email permission but keeps external-write permission. The result includes quotationOverBillingWarnings; a non-empty list means linked non-rejected bills exceed a quotation's quoted amount. It is a warning only and the write still succeeds. An Admin's unpaid bill is approved\
7080
- on creation and its QuickBooks bill is created by a queued job: the result has quickBooksSyncQueued: true and operationId; follow it with list-integration-operations. The request itself never writes to QuickBooks. Quotations with documentOnly: true (a $0 supplier document) are never valid bill quotation sources and are rejected; a budget line covered only by one still counts as unquoted."],
7081
- ["record-external-bill-payment", "Record an already-made payment on an APPROVED bill or claim, with no email and no money transfer. Requires <billId> --paymentReference --paymentDate YYYY-MM-DD --paymentAccount <QBO account ID> [--paymentProof receipt.pdf]. The account must be in the cached list (list-external-payment-accounts); the request makes no QuickBooks call. An inactive account (inactiveAccounts) only links the bill's existing QuickBooks payment when the bill is already settled; if there is none, the job is refused before anything is created and the bill goes back to APPROVED. Reuses settled QBO payment links or queues one dated payment from the selected account; the queued job re-checks the account in QuickBooks and stops in the Integration Queue if it is not active. Exact retries are safe; do not pay again while reconciliation is pending."],
7082
- ["mark-customer-invoice-sent-externally", "Admin only. Record an APPROVED customer invoice as SENT (source EXTERNAL) because it was emailed to the customer outside Budget Builder. Sends no email and writes nothing to QuickBooks. Requires <invoiceId> --sentAt <ISO datetime, not in the future, not before approval> --recipients a@x.com,b@y.com [--note <message reference>]."],
7083
- ["list-external-payment-accounts", "List active QuickBooks bank and credit-card account IDs for recording external payments (admin only), from Budget Builder's cached list: { accounts, cacheState, inactiveAccounts, refreshedAt, refresh }. inactiveAccounts can only link an already-settled bill's existing payment. No QuickBooks call. The worker refreshes the list automatically every day and after a QuickBooks company change; cacheState is READY, NOT_LOADED (first load pending), REALM_CHANGED (refreshing after a company change; no accounts served and external payments refused until it lands) or DISCONNECTED."],
7084
- ["refresh-external-payment-accounts", "Admin only. Queue a refresh of the cached QuickBooks payment-account list ({ operationId, status: QUEUED }); a refresh already waiting is reused. Optional: the worker already refreshes the list every day and after a QuickBooks company change. Check refreshedAt with list-external-payment-accounts."],
7085
- ["update-bill", "Update a bill or claim with a partial payload including id; omitted fields are preserved. Comment-only updates are allowed on approved/paid bills without altering financial data or QuickBooks. All amount fields exclude GST: amount is the portion billed; extractedAmount is the full invoice subtotal; lineAmounts and quotationAllocations also exclude GST. Example: 1800 + 162 GST = 1962 total requires amount=1800 and extractedAmount=1800 for a full bill. The CLI does not strip GST from input. If the selected quotations cannot split the bill amount across every selected line (a line without a quoted amount that cannot be derived from the quotation total), pass lineAmounts; updates that keep the same amount and lines reuse the existing line amounts. Re-read and verify both amount fields and allocations after correcting a gross/net mistake. The result includes quotationOverBillingWarnings; a non-empty list means linked non-rejected bills exceed a quotation's quoted amount. \
7086
- It is a warning only and the write still succeeds. Quotations with documentOnly: true (a $0 supplier document) are never valid bill quotation sources and are rejected; a budget line covered only by one still counts as unquoted."],
7087
- ["validate-bill-selection", "Validate the approved supplier and selected bill line items. Supplier bills need approved quotation sources (quotationIds, legacy quotationId, or quotationAllocations with lineAmounts) for every line that is not quotation-exempt (Go Internal lines, or projects/budgets created before the quotation cutoff). With billId, lines already on the bill keep their stored sources unless new sources are supplied. Exemption is decided by the server, so there is no --quotation-exempt flag here. Amounts (amount, lineAmounts, quotationAllocations) are ex-GST dollars with at most 2 decimal places. Returns { success, quotationOverBillingWarnings }: a non-empty warning list means the selection would bill a quotation above its quoted amount (counting other non-rejected bills); this is a warning only and does not fail validation. Quotations with documentOnly: true (a $0 supplier document) are never valid bill quotation sources and are rejected; a budget line covered only by o\
7088
- ne still counts as unquoted."],
7089
- ["create-quotation", 'Create a quotation with an approved supplier using --payload JSON. Include projectId, budgetId, supplierId, budgetItemIds, amountWithoutGst, gstAmount, and one uploaded attachment in attachments. Multiple budget items require lineAmounts: [{"budgetItemId":"<first-id>","amount":750},{"budgetItemId":"<second-id>","amount":450}], covering every selected budget-item ID exactly once and summing to amountWithoutGst. Amounts exclude GST; use gstAmount: 0 for no GST. Example: amountWithoutGst: 1200 with line amounts 750 and 450. The upload is checked and converted to PDF by a queued job (pdfProcessing in the result and in get-quotation). The result includes gstMismatch: null, or { basis, expectedGstAmount, enteredGstAmount, difference, message } when gstAmount is non-zero and more than $0.05 away from the expected GST. basis TAXABLE_LINES uses the bill calculation for the quoted lines (9% of each in-scope line, rounded per line; none for a non-GST-registered supplier); \
7090
- FULL_SUBTOTAL is 9% of amountWithoutGst, used when line amounts are unknown. It is a warning only (GST 0 is always accepted) and the write still succeeds. Document-only quotation (a $0 supplier document, for example a supplier contract or proposal with no price): set documentOnly: true with amountWithoutGst: 0, gstAmount: 0 and every lineAmounts amount 0 (lineAmounts may be omitted; the API fills zeros). It uses the normal draft, submit, sign and Admin approve flow with the attachment, appears in list/get output with documentOnly: true, counts in quotation lists and approval queues, but does not count as quotation coverage: a budget line covered only by it still counts as unquoted, and it is never a valid bill quotation source (create-bill, update-bill, validate-bill-selection and link-bill-quotations are rejected by the API). Without documentOnly (default false), amountWithoutGst must be positive.'],
7091
- ["cleanup-staged-quotation-attachments", "Queue independent cleanup operations for unattached staged quotation uploads; returns operation IDs and queued/skipped counts, not deletion confirmation. Arguments: <projectId> --keys <csv>."],
7092
- ["update-quotation", 'Update a DRAFT or REJECTED quotation using --payload JSON with id and the complete creation payload. Multiple budget items require lineAmounts: [{"budgetItemId":"<first-id>","amount":750},{"budgetItemId":"<second-id>","amount":450}], covering every budgetItemIds entry exactly once and summing to amountWithoutGst. Amounts exclude GST; use gstAmount: 0 for no GST. The result includes gstMismatch: null, or { basis, expectedGstAmount, enteredGstAmount, difference, message } when gstAmount is non-zero and more than $0.05 away from the expected GST. basis TAXABLE_LINES uses the bill calculation for the quoted lines (9% of each in-scope line, rounded per line; none for a non-GST-registered supplier); FULL_SUBTOTAL is 9% of amountWithoutGst, used when line amounts are unknown. It is a warning only (GST 0 is always accepted) and the write still succeeds. Update is a full replace: send documentOnly: true again when updating a document-only quotation (documentOnly: true wi\
7093
- th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false requires a positive amountWithoutGst), or it is treated as a priced quotation. Document-only quotations are never valid bill quotation sources and do not count as quotation coverage.'],
7094
- ["download-customer-invoice-pdf", "Download a customer invoice PDF when permitted."],
7095
- ["send-customer-invoice-to-contact-person", "Send a customer invoice and update the project billing email. Omit payload cc to use company billing defaults; an explicit list replaces them and [] removes them. Required internal Cc still applies."],
7096
- ["update-company", "Save company fields in BB and queue independent QuickBooks name/website synchronization; returns operation ID, not provider completion. Optional payload billingEmails: email string array (max 50), omit to preserve defaults or [] to clear. Billing emails stay in BB; estimates are unchanged."],
7097
- ["get-company-quickbooks-sync-status", "Read saved company synchronization status without provider calls or polling; use companyId."],
7098
- ["get-item-quickbooks-sync-status", "Read saved item QuickBooks synchronization status without provider calls or polling; use itemId."],
7099
- ["create-webhook-endpoint", "Admin-only: subscribe an HTTPS endpoint to BB events. --name --url --events <type|prefix.*|*,...>. Prints the whsec_ signing secret once; deliveries use Standard Webhooks headers."],
7100
- ["rotate-webhook-secret", "Admin-only: issue a new signing secret; older secrets keep signing for --previousSecretTtlHours (default 24). Prints the new secret once. Argument: <endpointId>."],
7101
- ["send-webhook-test-event", "Admin-only: send a signed webhook.test event to one endpoint. Argument: <endpointId>."],
7102
- ["replay-webhook-delivery", "Admin-only: resend a finished webhook delivery with the same eventId on a fresh attempt chain. Argument: <deliveryId>."],
7103
- ["get-error", "Admin-only: one error log with full diagnostics (stack, cause, request details, metadata, AI summary, resolution). Argument: <errorId>. error recent list returns table columns only."],
7104
- ["get-webhook-delivery", "Admin-only: one webhook delivery with payload and attempts (status codes, errors, durations). Argument: <deliveryId>."],
7105
- ["list-webhook-event-types", "List the outbound webhook event catalogue with group and live/planned status."],
7106
- ["reconcile-resource-operation", "Admin-only check of a saved QuickBooks invoice/company/item job outcome; reads the provider only when uncertain. Applied changes are finished locally without repeating the provider mutation; provably unapplied ones are queued again. Argument: <operationId>."],
7107
- ["get-integration-operation", "Admin-only read of one integration job: who queued it, the records it is for with app links, saved QuickBooks progress, admin actions and Retry state. No provider calls. Argument: <operationId>."],
7108
- ["retry-integration-operation", "Admin-only retry of a failed integration job. QuickBooks jobs with a saved attempt check QuickBooks first: applied changes finish without resending, provably unapplied ones are sent again, unprovable ones stay stopped with the reason. Argument: <operationId>."]
7109
- ]), summaryFor = __name2((legacyTarget) => {
7013
+ }, "effectsFor"), titleCase = __name2((value) => value.split("-").map((word) => "".concat(word.slice(0, 1).toUpperCase()).concat(word.slice(1))).join(" "), "titleCase"), SUMMARIES = /* @__PURE__ */ new Map([["update-budget-status", "Update budget status. APPROVED requires a current Lead/Admin role; budget management permission alone is insufficient. Ordinary users must request approval. Status changes invalidate old pending requests."], ["approve-budget", "Decide your assigned pending budget approval as a current Lead/Admin. Material edits supersede old requests; inspect the latest content and use a fresh request after edits."], ["reject-budget", "Decide your assigned pending budget approval as a current Lead/Admin. Material edits supersede old requests; inspect the latest content and use a fresh request after edits."], ["create-budget-approval", "Request budget approval for the current content, superseding older pending requests. Existing Lead/Admin autoapproval remains available."], [
7014
+ "update-budget-item-supplier", "Change a budget item's eligible supplier/GST snapshot as a material financial edit. Supersede pending approvals and apply the standard budget-to-DRAFT reset policy; inspect and request approval again. An unchanged supplier is a no-op."], ["submit-quotation", "Submit a quotation for signing and approval. Claim the captured revision and exact allocation selection; concurrent edits, budget-item deletion or restore cascades conflict instead of attaching old signed PDFs. Refresh and resubmit the current content. The signed PDF is stamped by a queued job (pdfProcessing: PROCESSING until linked); a file whose PDF conversion failed must be uploaded again first. The result includes gstMismatch (null, or the basis, expected GST, saved GST and their difference; see create-quotation); it is a warning only and the approval email shows it to approvers."], ["approve-quotation", "Approve your assigned pending quotation as a current Admin. Claim the captured revision and\
7015
+ exact allocation selection after signing; concurrent changes conflict and roll back the decision, signed-PDF job and email/outbox. Refresh and review the current content before retrying. The final signed PDF is stamped by a queued job (pdfProcessing); a stopped earlier PDF step blocks approval until it is retried."], ["approve-supplier", "Approve a pending supplier request and send a requester reply email, or directly re-approve a rejected supplier as Admin/Lead without a pending request or email. The QuickBooks vendor is created, linked or updated by a queued job (quickBooksSyncQueued, operationId); the supplier stays PENDING_APPROVAL until QuickBooks confirms, and archived suppliers remain archived. Argument: <supplierId>."], ["list-approvals", "List one page of requests currently assigned to you and pending approval, oldest first. Returns { items, pageInfo }; follow nextCursor with unchanged --type. --page/--perPage are rejected."], ["get-pending-approval", "Read one request still \
7016
+ pending your approval, or null if it is no longer pending/assigned. Argument: <approvalId>."], ["get-bill-review", "Read current advisory AI bill review and evidence. Passive; no provider calls. Argument: <billId>."], ["request-bill-review", "Queue an advisory AI review of a bill pending your approval. No financial decision is made. <billId> [--requestId <id>]"], ["get-bill-details", "Get a bill's summary as shown in the web app: status, amounts, people, payment and line totals. Use get-bill-line-items, get-bill-approvals, get-bill-attachments or get-bill-payment for more detail. Argument: <billId>."], ["get-bill-line-items", "List a bill's line items with budget-item and quotation-allocation detail. <billId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."], ["get-bill-approvals", "List a bill's approval requests with approver, requester and responder. <billId> [--limit 1-50] [--cursor <token>] Newest first. Returns { items, pageInfo };\
7017
+ follow nextCursor."], [
7018
+ "get-bill-payment",
7019
+ "Get a bill's payment status, reference, date, tracking URL, QuickBooks link and external payment. Argument: <billId>."
7020
+ ], ["get-quotation", "Get a quotation as shown in the web app: status, documentOnly (true for a $0 supplier document that is never a bill quotation source and does not count as coverage), amounts, people, line totals, files and approvals. pdfProcessing is { status: PROCESSING | FAILED, step: NORMALIZE | STAMP, operationId, error } while a queued PDF conversion or signing step has not linked its PDF, else null. gstMismatch is null, or { basis, expectedGstAmount, enteredGstAmount, difference, message } when the saved GST is non-zero and more than $0.05 away from the expected GST (TAXABLE_LINES: the bill calculation for the quoted lines; FULL_SUBTOTAL: 9% of the subtotal); check it before approving. Use get-quotation-line-items for budget-item detail. Argument: <quotationId>."], ["get-customer-invoice", "Get an invoice batch as shown in the web app: status, totals, people, approvals and invoice summaries. Use get-customer-invoice-invoices, get-customer-invoice-lines, get-customer-invoice-\
7021
+ approvals or get-customer-invoice-history for more detail. Argument: <batchId>."], ["get-customer-invoice-invoices", "List a batch's invoices with QuickBooks id/doc number, issue/due dates, amounts, sync state and sender. Argument: <batchId>."], ["get-customer-invoice-lines", "List one invoice's lines (name, description, QuickBooks item/tax code, quantity, amounts). <invoiceId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."], ["get-customer-invoice-approvals", "List an invoice batch's approval requests with approver, requester and responder. <batchId> [--limit 1-50] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."], ["get-customer-invoice-history", "List an invoice batch's status history (batch/invoice status changes, source, note, actor). <batchId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."], ["get-customer-invoice-payments", "List the payments Qui\
7022
+ ckBooks applied to one invoice: payment id, date, reference, amount applied, total and attachment names. Argument: <invoiceId> (from get-customer-invoice-invoices). Live QuickBooks read."], ["get-quotation-line-items", "List a quotation's line items with budget-item, supplier and budget detail. <quotationId> [--limit 1-100] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."], ["get-bill-attachments", "List bill attachments with cursor pagination. <billId> [--limit 1-50] [--cursor <token>] Newest first. Returns { items, pageInfo }; follow nextCursor."], ["get-budget-categories", "List budget categories with cursor pagination. [--q] [--limit 1-100] [--cursor <token>] Active categories, name A\u2013Z. Returns { items, pageInfo }; follow nextCursor with the same --q."], ["get-supplier-overview", "Get a supplier's profile, approvals, pending update, attachments and tab counts (usageCount, _count.items). Skips usage rows, spending and items; use get-supplier-us\
7023
+ age or get-supplier-items for those."], ["get-supplier-usage", "Get a supplier's usage rows (accepted/closed budget lines and lines with its actual spending) plus spending, actualSpending and estimatedSpending."], ["get-supplier-items", "Get the inventory items catalogued under a supplier."], ["get-supplier-analytics", "List supplier analytics rows with cursor pagination. [--name] [--status CSV] [--gstRegistered true|false] [--createdBy <text>] [--timeFrame ALL|LAST_YEAR|LAST_6_MONTHS|LAST_3_MONTHS|CUSTOM] [--startDate <ISO> --endDate <ISO>] [--sortBy name|gstRegistered|status|phone|email|updatedAt|createdAt] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Admin. Returns { items, pageInfo }; follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected."], ["list-api-keys", "List API keys with cursor pagination. [--userId <userId>] [--limit 1-100] [--cursor <token>] (newest first, { items, pageInfo }; defaults to t\
7024
+ he caller; admin required for another user)"], ["list-claims", "List reimbursable claims with cursor pagination. Same flags as list-bills (--limit 1-100, --cursor, --direction forward|backward); ignores --isClaimable. Returns { items, pageInfo }."], ["list-bills", "List bills with cursor pagination. [--projectId] [--budgetId] [--status CSV] [--search <text>] [--isClaimable true|false] [--createdByIds <csv>] [--sortBy createdAt|amount|status] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Returns { items, pageInfo }; pass nextCursor with --direction forward or previousCursor with --direction backward, keeping the same filters and sort. --page/--pageSize/--perPage are rejected."], ["list-customer-invoices", "List customer invoice batches with cursor pagination. [budgetId] [--projectId <id>] [--companyIds CSV] [--projectIds CSV] [--budgetIds CSV] [--createdByIds CSV] [--status CSV] [--search] [--sortBy createdAt|status|totalInvoiceAmount|approvalExp\
7025
+ iresAt] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Returns { items, pageInfo }; follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected. No scope flag lists invoices globally. --projectId uses the project scope. A positional budgetId is a backward-compatible shortcut for --budgetIds."], ["list-quotations", "List quotations with cursor pagination. [--projectId] [--budgetId] [--supplierId] [--status CSV] [--createdBy CSV] [--search] [--limit 1-100] [--cursor <token>] [--direction forward|backward] Newest first; returns { items, pageInfo }; each row carries documentOnly (document-only $0 quotations are listed and counted like any other). Follow nextCursor/previousCursor with the same filters. --page/--pageSize/--perPage are rejected; --requesterIds remains an alias for --createdBy."], ["list-users", "List users with cursor pagination. [--q] [--projectTeamOnly true|false] [--limit 1-100] [--cursor <token>] N\
7026
+ ame A\u2013Z. Returns { items, pageInfo }; follow nextCursor with the same --q and --projectTeamOnly. --projectTeamOnly true lists only active @getout.sg users, the only accounts accepted as Inside Sales, Business Development or Project Manager. --page/--perPage are rejected."], ["list-companies", "List companies with cursor pagination. Returns { items, pageInfo }; default sort is createdAt descending with limit 20. Pass nextCursor forward or previousCursor backward unchanged. Legacy page/perPage flags are rejected."], ["count-companies", "Count companies independently from list pagination. Returns { totalCount, counts: { active: { true, false } } }; accepts filters only and rejects pagination/sorting flags."], ["list-projects", "List projects with cursor pagination. Returns { items, pageInfo }; default sort is createdAt descending with limit 20. Supports legacy --status plus optional --statuses, WON-date filters (--wonFrom, --wonTo, --wonWithinDays) and --sortBy wonAt; pass nextCursor\
7027
+ forward or previousCursor backward unchanged. Legacy page/perPage flags are rejected."], ["count-projects", "Count projects independently from list pagination. Returns { totalCount, counts: { status, active: { true, false } } }; accepts project filters only and rejects pagination/sorting flags."], ["search-existing-companies", "Search BB and QuickBooks companies without writes. --query <name> [--limit 1-50] [--cursor <token>]. Returns { items, totalCount, pageInfo }; follow pageInfo.nextCursor with the same --query. Legacy --page is rejected."], ["use-existing-company", "Reuse a company in BB and QuickBooks, creating only its missing counterpart. Supply --companyId <bbId> and/or --quickbooksId <qboId>; both explicitly connect records with different names. Importing a QuickBooks-only company also needs --name <QuickBooks name from search-existing-companies>. --website <url> fills a missing QBO import website only. --confirmDistinct true confirms no similar record represents this entity\
7028
+ . BB saves the company now; its QuickBooks customer is checked, found or created and linked by a queued job (quickBooksSyncQueued, operationId). Estimates, invoices and QuickBooks projects wait for that link."], ["create-company", "Create or reuse a company in BB and QuickBooks. --name <name> --website <url> [--billingEmails '<json-array>'] (up to 50 invoice Cc defaults, stored in BB only for new companies; reused company defaults are preserved). Similar names require --confirmDistinct true; inactive companies are never reactivated. BB saves the company now; its QuickBooks customer is found or created by a queued job (quickBooksSyncQueued, operationId), which stops if similar QuickBooks customers exist without --confirmDistinct."], ["create-project", "Create a project linked to an existing Asana Deals lead task. Supply --asanaTaskId in non-interactive use; interactive use searches for and selects a lead task (optionally --asanaSearch). For a new direct client, create the lead task usin\
7029
+ g the website form first."], ["create-supplier", "Create a supplier using --payload JSON; pending-approval suppliers also request approval and send emails. Reusing an archived name requires Admin; normal users and Leads must ask an Admin to reactivate it before editing. Recreation preserves the existing approval status and creator. Lead/Admin-created suppliers (and archived-name revivals) queue their QuickBooks vendor create or link (quickBooksSyncQueued, operationId) and become usable once QuickBooks confirms; the request makes no QuickBooks call."], ["preview-qbo-customer-invoice", "Preview an available QuickBooks invoice selected for a BB budget using read-only QBO access. Arguments: <budgetId> <qboInvoiceId> [--confirmEstimateLineage true]. Use --confirmEstimateLineage only after confirming an invoice with no QuickBooks estimate link belongs to this budget's estimate."], ["preview-customer-invoice-amount", "Preview amount before GST, GST, and total for a percentage of an accepted e\
7030
+ stimate. Arguments: <budgetId> <percentage-of-estimate>."], ["list-available-qbo-customer-invoices", "List unlinked QuickBooks invoices available for an accepted or closed estimate. Argument: <budgetId>."], ["resubmit-customer-invoice", "Resubmit a confirmed expired-and-voided BB invoice as its original requester. Argument: <batchId>. Queues one replacement using the current estimate, original percentage, due date and details; retries return the same replacement. No customer email."], ["create-customer-invoice", "Create one invoice from an eligible budget using --payload JSON with invoice date, due date, billing address, customer memo, and a percentage of the original estimate that does not exceed its remaining coverage."], ["import-qbo-customer-invoice", "Link an existing QuickBooks invoice in BB only after reviewing preview-qbo. Arguments: <budgetId> <qboInvoiceId> --token <previewToken> [--confirmEstimateLineage true] (repeat the preview's flag). Supports closed estimates; no QBO wr\
7031
+ ites or emails."], ["whoami", "Show the active API-key identity."], ["list-budgets", "List one cursor page of budgets ({ items, pageInfo }; --limit/--cursor/--direction). Omit --active for active budgets only; use --active false or --active all for Admin-only historical reads."], ["list-items", "List one cursor page of catalogue items ({ items, pageInfo }; --limit/--cursor/--direction, optional --sortBy/--sortDir). --page/--perPage are rejected."], ["list-item-categories", "List one cursor page of active item categories ({ items, pageInfo }; --limit/--cursor/--direction, optional --name/--sortBy/--sortDir). --page/--perPage are rejected."], ["create-item-category", "Admin only. Create (or reactivate) an item category. Budget Builder saves it now and a queued job creates or links the QuickBooks category (quickBooksSyncQueued, operationId); the request makes no QuickBooks call."], ["update-item-category", "Rename an item category. Budget Builder saves the name immediately; a category lin\
7032
+ ked to QuickBooks is renamed there by a queued job (quickBooksSyncQueued: true, operationId), never during the request."], ["count-item-categories", "Count active item categories matching --name: { totalCount }."], ["list-webhook-deliveries", "Admin-only: list webhook deliveries newest first. Returns { items, pageInfo }; follow pageInfo.nextCursor (or previousCursor with --direction backward). Cursors are opaque and filter-bound; raw delivery ids are rejected."], ["list-integration-operations", "List one cursor page of integration operations, newest first ({ items, pageInfo }; --limit/--cursor/--direction). --page/--perPage are rejected. Admin only."], ["count-integration-operations", "Provider filter options for integration operations: { filterOptions }. No total; filter flags are accepted but do not change the result. Admin only."], ["count-items", "Count catalogue items matching filters: total plus category and supplier facets (each ignores its own filter)."], ["count-budgets", "Cou\
7033
+ nt budgets matching filters: totalCount plus status and active facets. Omit --active for active budgets only."], ["get-budget", "Get a budget by ID. Omit --includeInactive for active budgets only; --includeInactive is an Admin-only historical read."], ["get-budget-items", "Get line items for a budget. Omit --includeInactive for active budgets only; --includeInactive is an Admin-only historical read."], ["get-budget-details", "Get budget details. Omit --includeInactive for active budgets only; --includeInactive is an Admin-only historical read."], ["create-bill", "Create a bill or claim with an approved supplier. All amount fields exclude GST: amount is the portion billed; extractedAmount is the full invoice subtotal; lineAmounts and quotationAllocations also exclude GST. Example: 1800 + 162 GST = 1962 total requires amount=1800 and extractedAmount=1800 for a full bill. The CLI does not strip GST from input. If the selected quotations cannot split the bill amount across every selected l\
7034
+ ine (a line without a quoted amount that cannot be derived from the quotation total), pass lineAmounts; updates that keep the same amount and lines reuse the existing line amounts. --draft-only guarantees DRAFT without email or external writes; otherwise unpaid creation skips email permission but keeps external-write permission. The result includes quotationOverBillingWarnings; a non-empty list means linked non-rejected bills exceed a quotation's quoted amount. It is a warning only and the write still succeeds. An Admin's unpaid bill is approved on creation and its QuickBooks bill is created by a queued job: the result has quickBooksSyncQueued: true and operationId; follow it with list-integration-operations. The request itself never writes to QuickBooks. Quotations with documentOnly: true (a $0 supplier document) are never valid bill quotation sources and are rejected; a budget line covered only by one still counts as unquoted."], ["record-external-bill-payment", "Record an already-ma\
7035
+ de payment on an APPROVED bill or claim, with no email and no money transfer. Requires <billId> --paymentReference --paymentDate YYYY-MM-DD --paymentAccount <QBO account ID> [--paymentProof receipt.pdf]. The account must be in the cached list (list-external-payment-accounts); the request makes no QuickBooks call. An inactive account (inactiveAccounts) only links the bill's existing QuickBooks payment when the bill is already settled; if there is none, the job is refused before anything is created and the bill goes back to APPROVED. Reuses settled QBO payment links or queues one dated payment from the selected account; the queued job re-checks the account in QuickBooks and stops in the Integration Queue if it is not active. Exact retries are safe; do not pay again while reconciliation is pending."], ["mark-customer-invoice-sent-externally", "Admin only. Record an APPROVED customer invoice as SENT (source EXTERNAL) because it was emailed to the customer outside Budget Builder. Sends no e\
7036
+ mail and writes nothing to QuickBooks. Requires <invoiceId> --sentAt <ISO datetime, not in the future, not before approval> --recipients a@x.com,b@y.com [--note <message reference>]."], ["list-external-payment-accounts", "List active QuickBooks bank and credit-card account IDs for recording external payments (admin only), from Budget Builder's cached list: { accounts, cacheState, inactiveAccounts, refreshedAt, refresh }. inactiveAccounts can only link an already-settled bill's existing payment. No QuickBooks call. The worker refreshes the list automatically every day and after a QuickBooks company change; cacheState is READY, NOT_LOADED (first load pending), REALM_CHANGED (refreshing after a company change; no accounts served and external payments refused until it lands) or DISCONNECTED."], ["refresh-external-payment-accounts", "Admin only. Queue a refresh of the cached QuickBooks payment-account list ({ operationId, status: QUEUED }); a refresh already waiting is reused. Optional: the\
7037
+ worker already refreshes the list every day and after a QuickBooks company change. Check refreshedAt with list-external-payment-accounts."], ["update-bill", "Update a bill or claim with a partial payload including id; omitted fields are preserved. Comment-only updates are allowed on approved/paid bills without altering financial data or QuickBooks. All amount fields exclude GST: amount is the portion billed; extractedAmount is the full invoice subtotal; lineAmounts and quotationAllocations also exclude GST. Example: 1800 + 162 GST = 1962 total requires amount=1800 and extractedAmount=1800 for a full bill. The CLI does not strip GST from input. If the selected quotations cannot split the bill amount across every selected line (a line without a quoted amount that cannot be derived from the quotation total), pass lineAmounts; updates that keep the same amount and lines reuse the existing line amounts. Re-read and verify both amount fields and allocations after correcting a gross/net mist\
7038
+ ake. The result includes quotationOverBillingWarnings; a non-empty list means linked non-rejected bills exceed a quotation's quoted amount. It is a warning only and the write still succeeds. Quotations with documentOnly: true (a $0 supplier document) are never valid bill quotation sources and are rejected; a budget line covered only by one still counts as unquoted."], ["validate-bill-selection", "Validate the approved supplier and selected bill line items. Supplier bills need approved quotation sources (quotationIds, legacy quotationId, or quotationAllocations with lineAmounts) for every line that is not quotation-exempt (Go Internal lines, or projects/budgets created before the quotation cutoff). With billId, lines already on the bill keep their stored sources unless new sources are supplied. Exemption is decided by the server, so there is no --quotation-exempt flag here. Amounts (amount, lineAmounts, quotationAllocations) are ex-GST dollars with at most 2 decimal places. Returns { su\
7039
+ ccess, quotationOverBillingWarnings }: a non-empty warning list means the selection would bill a quotation above its quoted amount (counting other non-rejected bills); this is a warning only and does not fail validation. Quotations with documentOnly: true (a $0 supplier document) are never valid bill quotation sources and are rejected; a budget line covered only by one still counts as unquoted."], ["create-quotation", 'Create a quotation with an approved supplier using --payload JSON. Include projectId, budgetId, supplierId, budgetItemIds, amountWithoutGst, gstAmount, and one uploaded attachment in attachments. Multiple budget items require lineAmounts: [{"budgetItemId":"<first-id>","amount":750},{"budgetItemId":"<second-id>","amount":450}], covering every selected budget-item ID exactly once and summing to amountWithoutGst. Amounts exclude GST; use gstAmount: 0 for no GST. Example: amountWithoutGst: 1200 with line amounts 750 and 450. The upload is checked and converted to PDF by a qu\
7040
+ eued job (pdfProcessing in the result and in get-quotation). The result includes gstMismatch: null, or { basis, expectedGstAmount, enteredGstAmount, difference, message } when gstAmount is non-zero and more than $0.05 away from the expected GST. basis TAXABLE_LINES uses the bill calculation for the quoted lines (9% of each in-scope line, rounded per line; none for a non-GST-registered supplier); FULL_SUBTOTAL is 9% of amountWithoutGst, used when line amounts are unknown. It is a warning only (GST 0 is always accepted) and the write still succeeds. Document-only quotation (a $0 supplier document, for example a supplier contract or proposal with no price): set documentOnly: true with amountWithoutGst: 0, gstAmount: 0 and every lineAmounts amount 0 (lineAmounts may be omitted; the API fills zeros). It uses the normal draft, submit, sign and Admin approve flow with the attachment, appears in list/get output with documentOnly: true, counts in quotation lists and approval queues, but does no\
7041
+ t count as quotation coverage: a budget line covered only by it still counts as unquoted, and it is never a valid bill quotation source (create-bill, update-bill, validate-bill-selection and link-bill-quotations are rejected by the API). Without documentOnly (default false), amountWithoutGst must be positive.'], ["cleanup-staged-quotation-attachments", "Queue independent cleanup operations for unattached staged quotation uploads; returns operation IDs and queued/skipped counts, not deletion confirmation. Arguments: <projectId> --keys <csv>."], ["update-quotation", 'Update a DRAFT or REJECTED quotation using --payload JSON with id and the complete creation payload. Multiple budget items require lineAmounts: [{"budgetItemId":"<first-id>","amount":750},{"budgetItemId":"<second-id>","amount":450}], covering every budgetItemIds entry exactly once and summing to amountWithoutGst. Amounts exclude GST; use gstAmount: 0 for no GST. The result includes gstMismatch: null, or { basis, expectedGstA\
7042
+ mount, enteredGstAmount, difference, message } when gstAmount is non-zero and more than $0.05 away from the expected GST. basis TAXABLE_LINES uses the bill calculation for the quoted lines (9% of each in-scope line, rounded per line; none for a non-GST-registered supplier); FULL_SUBTOTAL is 9% of amountWithoutGst, used when line amounts are unknown. It is a warning only (GST 0 is always accepted) and the write still succeeds. Update is a full replace: send documentOnly: true again when updating a document-only quotation (documentOnly: true with amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false requires a positive amountWithoutGst), or it is treated as a priced quotation. Document-only quotations are never valid bill quotation sources and do not count as quotation coverage.'], ["download-customer-invoice-pdf", "Download a customer invoice PDF when permitted."], ["send-customer-invoice-to-contact-person", "Send a customer invoice and update the project billing email. \
7043
+ Omit payload cc to use company billing defaults; an explicit list replaces them and [] removes them. Required internal Cc still applies."], ["update-company", "Save company fields in BB and queue independent QuickBooks name/website synchronization; returns operation ID, not provider completion. Optional payload billingEmails: email string array (max 50), omit to preserve defaults or [] to clear. Billing emails stay in BB; estimates are unchanged."], ["get-company-quickbooks-sync-status", "Read saved company synchronization status without provider calls or polling; use companyId."], ["get-item-quickbooks-sync-status", "Read saved item QuickBooks synchronization status without provider calls or polling; use itemId."], ["create-webhook-endpoint", "Admin-only: subscribe an HTTPS endpoint to BB events. --name --url --events <type|prefix.*|*,...>. Prints the whsec_ signing secret once; deliveries use Standard Webhooks headers."], ["rotate-webhook-secret", "Admin-only: issue a new signing sec\
7044
+ ret; older secrets keep signing for --previousSecretTtlHours (default 24). Prints the new secret once. Argument: <endpointId>."], ["send-webhook-test-event", "Admin-only: send a signed webhook.test event to one endpoint. Argument: <endpointId>."], ["replay-webhook-delivery", "Admin-only: resend a finished webhook delivery with the same eventId on a fresh attempt chain. Argument: <deliveryId>."], ["get-error", "Admin-only: one error log with full diagnostics (stack, cause, request details, metadata, AI summary, resolution). Argument: <errorId>. error recent list returns table columns only."], ["get-webhook-delivery", "Admin-only: one webhook delivery with payload and attempts (status codes, errors, durations). Argument: <deliveryId>."], ["list-webhook-event-types", "List the outbound webhook event catalogue with group and live/planned status."], ["reconcile-resource-operation", "Admin-only check of a saved QuickBooks invoice/company/item job outcome; reads the provider only when uncerta\
7045
+ in. Applied changes are finished locally without repeating the provider mutation; provably unapplied ones are queued again. Argument: <operationId>."], ["get-integration-operation", "Admin-only read of one integration job: who queued it, the records it is for with app links, saved QuickBooks progress, admin actions and Retry state. No provider calls. Argument: <operationId>."], ["retry-integration-operation", "Admin-only retry of a failed integration job. QuickBooks jobs with a saved attempt check QuickBooks first: applied changes finish without resending, provably unapplied ones are sent again, unprovable ones stay stopped with the reason. Argument: <operationId>."]]), summaryFor = __name2((legacyTarget) => {
7110
7046
  const summary = SUMMARIES.get(legacyTarget);
7111
7047
  return summary !== void 0 ? summary : legacyTarget.startsWith("list-") ? "List ".concat(legacyTarget.slice(5).replaceAll("-", " "), ".") : legacyTarget.startsWith("get-") ? "Get ".concat(legacyTarget.slice(4).replaceAll("-", " "), ".") : "".concat(titleCase(legacyTarget), ".");
7112
- }, "summaryFor"), aliasesFor = __name2((legacyTarget, aliases) => [...new Set([legacyTarget, ...aliases].flatMap((alias) => [alias, alias.replaceAll("-", "_")]))], "aliasesFor"), legacyCommand = __name2((legacyTarget, path2, aliases = [], commandOptions = []) => ({ path: path2, legacyAliases: aliasesFor(legacyTarget, aliases), summary: summaryFor(legacyTarget), options: [...globalCommandOptions, ...commandOptions], effects: effectsFor(
7113
- legacyTarget
7114
- ), legacyTarget }), "legacyCommand"), budgetPreflightOptions = [{ name: "--companyPayload <json>", description: "Company update JSON object with id, name, and website fields." }, { name: "--contactPayload <json>", description: "Contact update JSON object with companyId, title, firstName, lastName, email, and mobile fields." }, { name: "--eventPayload <json>", description: "Event timing JSON object with date, startTime, and endTime fields." }], authCommand = __name2((action, summary) => ({ path: ["auth", action], legacyAliases: [], summary, options: globalCommandOptions, effects: [], load: __name2(async () => async () => ({}), "load") }), "authCommand"), registry2 = [
7115
- authCommand("login", "Authorize this device through Budget Builder in your browser."),
7048
+ }, "summaryFor"), aliasesFor = __name2(
7049
+ (legacyTarget, aliases) => [...new Set([legacyTarget, ...aliases].flatMap((alias) => [alias, alias.replaceAll("-", "_")]))],
7050
+ "aliasesFor"
7051
+ ), legacyCommand = __name2((legacyTarget, path2, aliases = [], commandOptions = []) => ({ path: path2, legacyAliases: aliasesFor(legacyTarget, aliases), summary: summaryFor(legacyTarget), options: [...globalCommandOptions, ...commandOptions], effects: effectsFor(legacyTarget), legacyTarget }), "legacyCommand"), budgetPreflightOptions = [{ name: "--companyPayload <json>", description: "Company update JSON object with id, name, and website fields." }, { name: "--contactPayload <json>", description: "Contact update JSON object with companyId, title, firstName, lastName, email, and mobile fields." }, { name: "--eventPayload <json>", description: "Event timing JSON object with date, startTime, and endTime fields." }], authCommand = __name2((action, summary) => ({ path: ["auth", action], legacyAliases: [], summary, options: globalCommandOptions, effects: [], load: __name2(async () => async () => ({}), "load") }), "authCommand"), registry2 = [
7052
+ authCommand(
7053
+ "login",
7054
+ "Authorize this device through Budget Builder in your browser."
7055
+ ),
7116
7056
  authCommand("status", "Show the active CLI authentication method and session status."),
7117
7057
  authCommand("logout", "Revoke the interactive CLI session and remove its local credential."),
7118
7058
  legacyCommand("whoami", ["auth", "whoami"]),
7119
7059
  legacyCommand("list-budgets", ["budget", "list"], [], [{ name: "--active <true|false|all>", description: "Omit for active budgets only; false or all requires Admin access." }, { name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor (or previousCursor with --direction backward) from the last page, unchanged; keep the same filters and sort." }, { name: "--direction <forward|backward>", description: "forward (default) or backward; backward needs --cursor." }]),
7120
7060
  legacyCommand("count-budgets", ["budget", "count"], [], [{ name: "--active <true|false|all>", description: "Omit for active budgets only; false or all requires Admin access." }]),
7121
- legacyCommand("get-budget", ["budget", "get"], [], [{ name: "--includeInactive", description: "Include inactive historical budgets; Admin only." }]),
7061
+ legacyCommand(
7062
+ "get-budget",
7063
+ ["budget", "get"],
7064
+ [],
7065
+ [{ name: "--includeInactive", description: "Include inactive historical budgets; Admin only." }]
7066
+ ),
7122
7067
  legacyCommand("upload-budget-attachment", ["budget", "attachment", "upload"]),
7123
7068
  legacyCommand("mark-budget-won", ["budget", "won", "mark"]),
7124
7069
  legacyCommand("get-budget-items", ["budget", "item", "list"], [], [{ name: "--includeInactive", description: "Include inactive historical budgets; Admin only." }]),
@@ -7147,7 +7092,10 @@ th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false require
7147
7092
  legacyCommand("update-budget-commission", ["budget", "commission", "update"]),
7148
7093
  legacyCommand("update-budget-discount", ["budget", "discount", "update"]),
7149
7094
  legacyCommand("delete-budget-commission", ["budget", "commission", "delete"]),
7150
- legacyCommand("delete-budget-discount", ["budget", "discount", "delete"]),
7095
+ legacyCommand(
7096
+ "delete-budget-discount",
7097
+ ["budget", "discount", "delete"]
7098
+ ),
7151
7099
  legacyCommand("mark-budget-items-not-utilized", ["budget", "item", "mark-not-utilized"]),
7152
7100
  legacyCommand("restore-budget-item", ["budget", "item", "restore"]),
7153
7101
  legacyCommand("create-placeholder-bill", ["budget", "item", "placeholder-bill", "create"]),
@@ -7156,16 +7104,10 @@ th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false require
7156
7104
  legacyCommand("count-bills", ["bill", "count"]),
7157
7105
  legacyCommand("count-claims", ["claim", "count"]),
7158
7106
  legacyCommand("create-bill-approval", ["bill", "approval", "create"]),
7159
- legacyCommand("create-bill", ["bill", "create"], [], [{
7160
- name: "--draft-only",
7161
- description: "Create a draft for every role; no approval, email, or QuickBooks writes. Conflicts with alreadyPaid: true."
7162
- }, { name: "--quotation-exempt", description: "Explicitly request an eligible server-validated supplier-bill quotation exemption. Cannot be combined with quotation IDs." }]),
7107
+ legacyCommand("create-bill", ["bill", "create"], [], [{ name: "--draft-only", description: "Create a draft for every role; no approval, email, or QuickBooks writes. Conflicts with alreadyPaid: true." }, { name: "--quotation-exempt", description: "Explicitly request an eligible server-validated supplier-bill quotation exemption. Cannot be combined with quotation IDs." }]),
7163
7108
  legacyCommand("validate-bill-selection", ["bill", "selection", "validate"], [], [{ name: "--quotationIds <csv>", description: "Approved quotation IDs for a supplier bill. Each selected budget item must be covered once." }, { name: "--quotationId <id>", description: "Legacy syntax for selecting one approved quotation." }]),
7164
7109
  legacyCommand("link-bill-quotations", ["bill", "quotation", "link"], ["billId"], [{ name: "--payload <json>", description: "Explicit quotationAllocations for split source coverage on the bill's stored line amounts; documentOnly quotations are rejected." }, { name: "--quotationIds <csv>", description: "Approved quotation IDs to link across the bill's disjoint line coverage; documentOnly quotations are rejected." }]),
7165
- legacyCommand(
7166
- "update-bill",
7167
- ["bill", "update"]
7168
- ),
7110
+ legacyCommand("update-bill", ["bill", "update"]),
7169
7111
  legacyCommand("update-bill-payment-evidence", ["bill", "payment-evidence", "update"]),
7170
7112
  legacyCommand("delete-bill", ["bill", "delete"]),
7171
7113
  legacyCommand("update-bill-status", ["bill", "status", "update"]),
@@ -7176,10 +7118,7 @@ th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false require
7176
7118
  legacyCommand("patch-bill-invoice-number", ["bill", "invoice-number", "patch"]),
7177
7119
  legacyCommand("get-bill-attachments", ["bill", "attachment", "list"], [], [{ name: "--limit <1-50>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]),
7178
7120
  legacyCommand("stage-bill-attachment", ["bill", "attachment", "stage"]),
7179
- legacyCommand(
7180
- "cleanup-staged-bill-attachments",
7181
- ["bill", "attachment", "staged", "cleanup"]
7182
- ),
7121
+ legacyCommand("cleanup-staged-bill-attachments", ["bill", "attachment", "staged", "cleanup"]),
7183
7122
  legacyCommand("upload-bill-attachment", ["bill", "attachment", "upload"], ["attach-bill-attachment"]),
7184
7123
  legacyCommand("attach-bill-payment-receipt", ["bill", "payment-receipt", "attach"]),
7185
7124
  legacyCommand("attach-bill-documents", ["bill", "document", "attach"]),
@@ -7192,13 +7131,21 @@ th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false require
7192
7131
  legacyCommand("list-quotations", ["quotation", "list"], [], [{ name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor (or previousCursor with --direction backward) from the last page, unchanged; keep the same filters and sort." }, { name: "--direction <forward|backward>", description: "forward (default) or backward; backward needs --cursor." }]),
7193
7132
  legacyCommand("count-quotations", ["quotation", "count"]),
7194
7133
  legacyCommand("get-quotation", ["quotation", "get"]),
7195
- legacyCommand("get-quotation-line-items", ["quotation", "line-item", "list"], [], [{ name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]),
7134
+ legacyCommand(
7135
+ "get-quotation-line-items",
7136
+ ["quotation", "line-item", "list"],
7137
+ [],
7138
+ [{ name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]
7139
+ ),
7196
7140
  legacyCommand("upload-quotation-attachment", ["quotation", "attachment", "upload"]),
7197
7141
  legacyCommand("cleanup-staged-quotation-attachments", ["quotation", "attachment", "staged", "cleanup"]),
7198
7142
  legacyCommand("create-quotation", ["quotation", "create"], [], [{ name: "--payload", description: "Quotation JSON including lineAmounts for multiple selected budget items; see the payload format above. Set documentOnly: true with zero amounts for a $0 supplier document.", required: !0 }]),
7199
7143
  legacyCommand("update-quotation", ["quotation", "update"], [], [{ name: "--payload", description: "Complete quotation JSON plus id, including lineAmounts for multiple selected budget items. Send documentOnly: true again when updating a document-only quotation.", required: !0 }]),
7200
7144
  legacyCommand("delete-quotation", ["quotation", "delete"]),
7201
- legacyCommand("submit-quotation", ["quotation", "submit"]),
7145
+ legacyCommand(
7146
+ "submit-quotation",
7147
+ ["quotation", "submit"]
7148
+ ),
7202
7149
  legacyCommand("approve-quotation", ["quotation", "approve"]),
7203
7150
  legacyCommand("reject-quotation", ["quotation", "reject"]),
7204
7151
  legacyCommand("download-quotation-pdf", ["quotation", "pdf", "download"]),
@@ -7212,7 +7159,10 @@ th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false require
7212
7159
  legacyCommand("get-customer-invoice-invoices", ["customer-invoice", "invoice", "list"]),
7213
7160
  legacyCommand("get-customer-invoice-lines", ["customer-invoice", "line", "list"], [], [{ name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]),
7214
7161
  legacyCommand("get-customer-invoice-approvals", ["customer-invoice", "approval", "list"], [], [{ name: "--limit <1-50>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]),
7215
- legacyCommand("get-customer-invoice-history", ["customer-invoice", "history", "list"], [], [{ name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]),
7162
+ legacyCommand("get-customer-invoice-history", ["customer-invoice", "history", "list"], [], [
7163
+ { name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." },
7164
+ { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }
7165
+ ]),
7216
7166
  legacyCommand("get-customer-invoice-payments", ["customer-invoice", "payments", "list"]),
7217
7167
  legacyCommand("get-customer-invoice-email-context", ["customer-invoice", "email-context", "get"]),
7218
7168
  legacyCommand("preview-qbo-customer-invoice", ["customer-invoice", "preview-qbo"]),
@@ -7232,17 +7182,17 @@ th amountWithoutGst: 0, gstAmount: 0 and zero lineAmounts; default false require
7232
7182
  legacyCommand("mark-customer-invoice-sent-externally", ["customer-invoice", "mark-sent-externally"]),
7233
7183
  legacyCommand("list-approvals", ["approval", "list"], ["get-pending-approvals"], [{ name: "--type <type>", description: "Filter budget, supplier, bill, quotation, customer_invoice, or all." }, { name: "--limit <number>", description: "Page size 1\u2013100; default 50." }, { name: "--cursor <token>", description: "Opaque cursor from pageInfo." }, { name: "--direction <direction>", description: "forward (default) or backward; backward requires a cursor." }]),
7234
7184
  legacyCommand("get-pending-approval", ["approval", "get"]),
7235
- legacyCommand("approve-bill", ["bill", "approve"]),
7185
+ legacyCommand("approve-bill", [
7186
+ "bill",
7187
+ "approve"
7188
+ ]),
7236
7189
  legacyCommand("reject-bill", ["bill", "reject"]),
7237
7190
  legacyCommand("approve-budget", ["budget", "approve"]),
7238
7191
  legacyCommand("reject-budget", ["budget", "reject"]),
7239
7192
  legacyCommand("approve-supplier", ["supplier", "approve"]),
7240
7193
  legacyCommand("reject-supplier", ["supplier", "reject"]),
7241
7194
  legacyCommand("get-supplier-details", ["supplier", "detail", "get"]),
7242
- legacyCommand(
7243
- "get-supplier-overview",
7244
- ["supplier", "overview", "get"]
7245
- ),
7195
+ legacyCommand("get-supplier-overview", ["supplier", "overview", "get"]),
7246
7196
  legacyCommand("get-supplier-usage", ["supplier", "usage", "get"]),
7247
7197
  legacyCommand("get-supplier-items", ["supplier", "items", "get"]),
7248
7198
  legacyCommand("list-companies", ["company", "list"], [], [{ name: "--name <text>", description: "Filter by company name substring." }, { name: "--createdBy <userId>", description: "Filter by one creator user ID." }, { name: "--createdByIds <csv>", description: "Filter by a comma-separated creator user ID list." }, { name: "--active <true|false>", description: "Filter by active status; omit to include both states." }, { name: "--sortBy <name|createdAt>", description: "Sort field (default createdAt)." }, { name: "--sortDir <asc|desc>", description: "Sort direction (default desc)." }, { name: "--limit <1-100>", description: "Bounded page size (default 20)." }, { name: "--cursor <token>", description: "Opaque pageInfo cursor; pass nextCursor forward or previousCursor backward unchanged." }, { name: "--direction <forward|backward>", description: "Use forward by default; backward requires --cursor." }]),
@@ -7297,7 +7247,10 @@ At." }, { name: "--sortDir <asc|desc>", description: "Descending createdAt by de
7297
7247
  legacyCommand("delete-item", ["item", "delete"]),
7298
7248
  legacyCommand("list-item-categories", ["item", "category", "list"], [], [{ name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor (or previousCursor with --direction backward) from the last page, unchanged; keep the same filters and sort." }, { name: "--direction <forward|backward>", description: "forward (default) or backward; backward needs --cursor." }]),
7299
7249
  legacyCommand("count-item-categories", ["item", "category", "count"]),
7300
- legacyCommand("create-item-category", ["item", "category", "create"]),
7250
+ legacyCommand(
7251
+ "create-item-category",
7252
+ ["item", "category", "create"]
7253
+ ),
7301
7254
  legacyCommand("update-item-category", ["item", "category", "update"]),
7302
7255
  legacyCommand("delete-item-categories", ["item", "category", "delete"]),
7303
7256
  legacyCommand("list-users", ["user", "list"], [], [{ name: "--q <text>", description: "Search user names and emails (name A\u2013Z). A bare --q is rejected; use -q/--quiet to hide logs." }, { name: "--projectTeamOnly <true|false>", description: "true lists only active @getout.sg users, the only accounts accepted as Inside Sales, Business Development or Project Manager." }, { name: "--limit <1-100>", description: "Rows per page. Output is { items, pageInfo }." }, { name: "--cursor <token>", description: "pageInfo.nextCursor from the last page, unchanged; pages forward only." }]),
@@ -7308,10 +7261,7 @@ At." }, { name: "--sortDir <asc|desc>", description: "Descending createdAt by de
7308
7261
  legacyCommand("revoke-api-key", ["user", "api-key", "revoke"]),
7309
7262
  legacyCommand("get-user-performance", ["user", "performance", "get"]),
7310
7263
  legacyCommand("get-dashboard", ["dashboard", "get"]),
7311
- legacyCommand(
7312
- "get-monthly-metrics",
7313
- ["dashboard", "monthly-metrics", "get"]
7314
- ),
7264
+ legacyCommand("get-monthly-metrics", ["dashboard", "monthly-metrics", "get"]),
7315
7265
  legacyCommand("get-system-overview", ["dashboard", "system-overview", "get"]),
7316
7266
  legacyCommand("get-estimate-performance", ["dashboard", "estimate-performance", "get"]),
7317
7267
  legacyCommand("get-financial-overview", ["dashboard", "financial-overview", "get"]),
@@ -7331,7 +7281,10 @@ At." }, { name: "--sortDir <asc|desc>", description: "Descending createdAt by de
7331
7281
  legacyCommand("update-webhook-endpoint", ["webhook", "endpoint", "update"]),
7332
7282
  legacyCommand("delete-webhook-endpoint", ["webhook", "endpoint", "delete"]),
7333
7283
  legacyCommand("rotate-webhook-secret", ["webhook", "secret", "rotate"]),
7334
- legacyCommand("send-webhook-test-event", ["webhook", "endpoint", "test"]),
7284
+ legacyCommand(
7285
+ "send-webhook-test-event",
7286
+ ["webhook", "endpoint", "test"]
7287
+ ),
7335
7288
  legacyCommand("list-webhook-deliveries", ["webhook", "delivery", "list"], [], [{ name: "--endpointId <id>", description: "Only deliveries to this endpoint." }, { name: "--status <PENDING|SUCCEEDED|FAILED,...>", description: "Comma-separated delivery statuses." }, { name: "--eventType <type>", description: "Exact event type, e.g. bill.approved." }, { name: "--limit <n>", description: "Rows per cursor page (1..100; default 20)." }, { name: "--cursor <token>", description: "Opaque token from pageInfo.nextCursor or pageInfo.previousCursor; bound to the same filters." }, { name: "--direction <value>", description: "forward or backward (default forward; backward requires cursor)." }]),
7336
7289
  legacyCommand("get-webhook-delivery", ["webhook", "delivery", "get"]),
7337
7290
  legacyCommand("replay-webhook-delivery", ["webhook", "delivery", "replay"]),
@@ -7340,7 +7293,12 @@ At." }, { name: "--sortDir <asc|desc>", description: "Descending createdAt by de
7340
7293
  legacyCommand("create-inbound-source", ["inbound", "source", "create"]),
7341
7294
  legacyCommand("get-inbound-source", ["inbound", "source", "get"]),
7342
7295
  legacyCommand("update-inbound-source", ["inbound", "source", "update"]),
7343
- legacyCommand("list-inbound-submissions", ["inbound", "submission", "list"], [], [{ name: "--limit <number>", description: "Page size from 1 to 100 (default 25). Returns submissions, hasMore and nextCursor; no total." }, { name: "--cursor <token>", description: "Pass the previous response's nextCursor unchanged. Omit for newest submissions. Replaces --page/--perPage." }, { name: "--sourceId <id>", description: "Filter submissions to this source; keep the same filter while following cursors." }]),
7296
+ legacyCommand(
7297
+ "list-inbound-submissions",
7298
+ ["inbound", "submission", "list"],
7299
+ [],
7300
+ [{ name: "--limit <number>", description: "Page size from 1 to 100 (default 25). Returns submissions, hasMore and nextCursor; no total." }, { name: "--cursor <token>", description: "Pass the previous response's nextCursor unchanged. Omit for newest submissions. Replaces --page/--perPage." }, { name: "--sourceId <id>", description: "Filter submissions to this source; keep the same filter while following cursors." }]
7301
+ ),
7344
7302
  legacyCommand("count-inbound-submissions", ["inbound", "submission", "count"], [], [{ name: "--sourceId <id>", description: "Optional source filter. Returns an independently calculated exact totalCount, not a list snapshot." }]),
7345
7303
  legacyCommand("get-inbound-submission", ["inbound", "submission", "get"]),
7346
7304
  legacyCommand("save-inbound-mapping", ["inbound", "mapping", "save"]),
@@ -7350,10 +7308,7 @@ At." }, { name: "--sortDir <asc|desc>", description: "Descending createdAt by de
7350
7308
  legacyCommand("get-budget-category-benchmarks", ["budget", "category", "benchmark", "get"]),
7351
7309
  legacyCommand("get-item-pricing-history", ["item", "pricing-history", "list"]),
7352
7310
  legacyCommand("get-supplier-pricing-history", ["supplier", "pricing-history", "list"])
7353
- ], normalizeToken = __name2((value) => value.replaceAll("_", "-"), "normalizeToken"), normalizedPath = __name2(
7354
- (path2) => path2.map(normalizeToken),
7355
- "normalizedPath"
7356
- ), assertRegistry = __name2((commands) => {
7311
+ ], normalizeToken = __name2((value) => value.replaceAll("_", "-"), "normalizeToken"), normalizedPath = __name2((path2) => path2.map(normalizeToken), "normalizedPath"), assertRegistry = __name2((commands) => {
7357
7312
  const paths = /* @__PURE__ */ new Set(), aliases = /* @__PURE__ */ new Set();
7358
7313
  for (const command of commands) {
7359
7314
  const path2 = command.path.join(" ");
@@ -7369,12 +7324,12 @@ At." }, { name: "--sortDir <asc|desc>", description: "Descending createdAt by de
7369
7324
  }
7370
7325
  }
7371
7326
  }, "assertRegistry");
7372
- assertRegistry(registry2);
7327
+ assertRegistry(
7328
+ registry2
7329
+ );
7373
7330
  var commandRegistry = registry2, resolveCommand = __name2((argv) => {
7374
7331
  const normalizedArgv = argv.map(normalizeToken), canonical = [...commandRegistry].sort((left, right) => right.path.length - left.path.length).find((command) => normalizedPath(command.path).every((segment, index) => normalizedArgv[index] === segment));
7375
- if (canonical) return { command: canonical, argv: argv.slice(
7376
- canonical.path.length
7377
- ), invokedAs: argv.slice(0, canonical.path.length), isLegacyAlias: !1 };
7332
+ if (canonical) return { command: canonical, argv: argv.slice(canonical.path.length), invokedAs: argv.slice(0, canonical.path.length), isLegacyAlias: !1 };
7378
7333
  const rawAlias = argv[0];
7379
7334
  if (!rawAlias) return;
7380
7335
  const normalizedAlias = normalizeToken(rawAlias), legacy = commandRegistry.find((command) => command.legacyAliases.some((alias) => normalizeToken(alias) === normalizedAlias));
@@ -7436,21 +7391,33 @@ var COMPANY_SORT_FIELDS = ["name", "createdAt"], COMPANY_SORT_DIRECTIONS = ["asc
7436
7391
  return value;
7437
7392
  }, "parseCompanyDirection"), parseCompanyListFlags = __name2((flags) => {
7438
7393
  rejectCompanyPageFlags(flags, "list");
7439
- for (const key of ["name", "createdBy", "createdByIds", "active", "limit", "cursor", "direction", "sortBy", "sortDir"])
7440
- rejectBareFlag(flags, key);
7394
+ for (const key of ["name", "createdBy", "createdByIds", "active", "limit", "cursor", "direction", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
7441
7395
  const cursor = getFlag(flags, "cursor"), direction = parseCompanyDirection(getFlag(flags, "direction"));
7442
7396
  if (direction === "backward" && cursor === void 0) throw new Error("--direction backward requires --cursor <token>.");
7443
7397
  if (cursor === "") throw new Error("--cursor requires a non-empty token.");
7444
- return { name: getFlag(flags, "name"), createdBy: getFlag(flags, "createdBy"), createdByIds: parseCommaSeparatedIds(getFlag(flags, "createdByIds")), active: parseOptionalBoolFlag(flags, "active"), limit: parseCompanyLimit(getFlag(flags, "limit")), cursor, direction, sortBy: parseCompanySortBy(getFlag(flags, "sortBy")), sortDir: parseCompanySortDir(getFlag(flags, "sortDir")) };
7398
+ return {
7399
+ name: getFlag(flags, "name"),
7400
+ createdBy: getFlag(flags, "createdBy"),
7401
+ createdByIds: parseCommaSeparatedIds(getFlag(flags, "createdByIds")),
7402
+ active: parseOptionalBoolFlag(flags, "active"),
7403
+ limit: parseCompanyLimit(getFlag(flags, "limit")),
7404
+ cursor,
7405
+ direction,
7406
+ sortBy: parseCompanySortBy(getFlag(flags, "sortBy")),
7407
+ sortDir: parseCompanySortDir(getFlag(flags, "sortDir"))
7408
+ };
7445
7409
  }, "parseCompanyListFlags"), parseCompanyCountFlags = __name2((flags) => {
7446
7410
  rejectCompanyPageFlags(flags, "count");
7447
7411
  for (const key of ["name", "createdBy", "createdByIds", "active", "limit", "cursor", "direction", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
7448
7412
  if (flags.limit !== void 0 || flags.cursor !== void 0 || flags.direction !== void 0) throw new Error("company count does not accept list pagination flags.");
7449
7413
  if (flags.sortBy !== void 0 || flags.sortDir !== void 0) throw new Error("company count does not accept list sorting flags.");
7450
7414
  return { name: getFlag(flags, "name"), createdBy: getFlag(flags, "createdBy"), createdByIds: parseCommaSeparatedIds(getFlag(flags, "createdByIds")), active: parseOptionalBoolFlag(flags, "active") };
7451
- }, "parseCompanyCountFlags"), PROJECT_SORT_FIELDS = ["name", "createdAt", "status", "companyName", "wonAt"], PROJECT_SORT_DIRECTIONS = ["asc", "desc"], PROJECT_PAGE_FLAGS = ["page", "perPage", "pageSize", "page-size", "per-page", "page_size", "per_page"], rejectProjectPageFlags = __name2((flags, command) => {
7452
- for (const key of PROJECT_PAGE_FLAGS) if (flags[key] !== void 0) throw new Error("--".concat(key, " is not supported by project ").concat(command, "; use --limit and --cursor for list or project count for totals."));
7453
- }, "rejectProjectPageFlags"), parseProjectLimit = __name2((value) => {
7415
+ }, "parseCompanyCountFlags"), PROJECT_SORT_FIELDS = ["name", "createdAt", "status", "companyName", "wonAt"], PROJECT_SORT_DIRECTIONS = ["asc", "desc"], PROJECT_PAGE_FLAGS = ["page", "perPage", "pageSize", "page-size", "per-page", "page_size", "per_page"], rejectProjectPageFlags = __name2(
7416
+ (flags, command) => {
7417
+ for (const key of PROJECT_PAGE_FLAGS) if (flags[key] !== void 0) throw new Error("--".concat(key, " is not supported by project ").concat(command, "; use --limit and --cursor for list or project count for totals."));
7418
+ },
7419
+ "rejectProjectPageFlags"
7420
+ ), parseProjectLimit = __name2((value) => {
7454
7421
  if (value === void 0) return 20;
7455
7422
  const parsed = Number(String(value));
7456
7423
  if (!Number.isInteger(parsed) || parsed < 1 || parsed > 100) throw new Error("--limit must be an integer from 1 to 100.");
@@ -7470,9 +7437,7 @@ var COMPANY_SORT_FIELDS = ["name", "createdAt"], COMPANY_SORT_DIRECTIONS = ["asc
7470
7437
  return parsed;
7471
7438
  }, "parseProjectWonWithinDays"), parseProjectDirection = __name2((value) => {
7472
7439
  if (value === void 0) return "forward";
7473
- if (value !== "forward" && value !== "backward") throw new Error(
7474
- '--direction must be "forward" or "backward".'
7475
- );
7440
+ if (value !== "forward" && value !== "backward") throw new Error('--direction must be "forward" or "backward".');
7476
7441
  return value;
7477
7442
  }, "parseProjectDirection"), parseProjectListFlags = __name2((flags) => {
7478
7443
  rejectProjectPageFlags(flags, "list");
@@ -7480,11 +7445,7 @@ var COMPANY_SORT_FIELDS = ["name", "createdAt"], COMPANY_SORT_DIRECTIONS = ["asc
7480
7445
  const cursor = getFlag(flags, "cursor"), direction = parseProjectDirection(getFlag(flags, "direction"));
7481
7446
  if (direction === "backward" && cursor === void 0) throw new Error("--direction backward requires --cursor <token>.");
7482
7447
  if (cursor === "") throw new Error("--cursor requires a non-empty token.");
7483
- return { companyId: getFlag(flags, "companyId"), name: getFlag(flags, "name"), status: parseOptionalExtendedProjectStatus(getFlag(flags, "status")), statuses: parseCommaSeparatedProjectStatuses(getFlag(flags, "statuses")), active: parseOptionalBoolFlag(flags, "active"), wonFrom: parseOptionalIsoDateFlag(getFlag(flags, "wonFrom"), "--wonFrom"), wonTo: parseOptionalIsoDateFlag(
7484
- getFlag(flags, "wonTo"),
7485
- "--wonTo",
7486
- { endOfDay: !0 }
7487
- ), wonWithinDays: parseProjectWonWithinDays(getFlag(flags, "wonWithinDays")), limit: parseProjectLimit(getFlag(flags, "limit")), cursor, direction, sortBy: parseProjectSortBy(getFlag(flags, "sortBy")), sortDir: parseProjectSortDir(getFlag(flags, "sortDir")) };
7448
+ return { companyId: getFlag(flags, "companyId"), name: getFlag(flags, "name"), status: parseOptionalExtendedProjectStatus(getFlag(flags, "status")), statuses: parseCommaSeparatedProjectStatuses(getFlag(flags, "statuses")), active: parseOptionalBoolFlag(flags, "active"), wonFrom: parseOptionalIsoDateFlag(getFlag(flags, "wonFrom"), "--wonFrom"), wonTo: parseOptionalIsoDateFlag(getFlag(flags, "wonTo"), "--wonTo", { endOfDay: !0 }), wonWithinDays: parseProjectWonWithinDays(getFlag(flags, "wonWithinDays")), limit: parseProjectLimit(getFlag(flags, "limit")), cursor, direction, sortBy: parseProjectSortBy(getFlag(flags, "sortBy")), sortDir: parseProjectSortDir(getFlag(flags, "sortDir")) };
7488
7449
  }, "parseProjectListFlags"), parseProjectCountFlags = __name2((flags) => {
7489
7450
  rejectProjectPageFlags(flags, "count");
7490
7451
  for (const key of ["companyId", "name", "status", "statuses", "active", "wonFrom", "wonTo", "wonWithinDays", "limit", "cursor", "direction", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
@@ -7522,22 +7483,26 @@ __name(parseCustomerInvoiceSortBy, "parseCustomerInvoiceSortBy"), __name2(parseC
7522
7483
  function parseCommercialRejectionProjectStatus(flags) {
7523
7484
  const raw = flags.projectStatusOnCommercialRejection;
7524
7485
  if (raw === void 0) return;
7525
- if (raw === !0) throw new Error("--projectStatusOnCommercialRejection requires PITCH or LOST.");
7486
+ if (raw === !0) throw new Error(
7487
+ "--projectStatusOnCommercialRejection requires PITCH or LOST."
7488
+ );
7526
7489
  const status = String(raw).toUpperCase();
7527
7490
  if (status === ProjectStatus2.PITCH || status === ProjectStatus2.LOST) return status;
7528
7491
  throw new Error("--projectStatusOnCommercialRejection must be PITCH or LOST.");
7529
7492
  }
7530
7493
  __name(parseCommercialRejectionProjectStatus, "parseCommercialRejectionProjectStatus"), __name2(parseCommercialRejectionProjectStatus, "parseCommercialRejectionProjectStatus");
7531
7494
  var rejectRetiredPageFlags = __name2((flags) => {
7532
- for (const key of PROJECT_PAGE_FLAGS)
7533
- if (flags[key] !== void 0) throw new Error("--".concat(key, " is retired; use --limit/--cursor, or the matching count command for totals."));
7495
+ for (const key of PROJECT_PAGE_FLAGS) if (flags[key] !== void 0) throw new Error("--".concat(key, " is retired; use --limit/--cursor, or the matching count command for totals."));
7534
7496
  }, "rejectRetiredPageFlags"), parseDetailFeedPage = __name2((command, idLabel, positional, flags, maxLimit) => {
7535
7497
  const id = positional[0];
7536
7498
  if (!id) throw new Error("".concat(command, " requires ").concat(idLabel));
7537
7499
  rejectRetiredPageFlags(flags);
7538
7500
  for (const key of ["limit", "cursor"]) rejectBareFlag(flags, key);
7539
7501
  if (flags.direction !== void 0) throw new Error("".concat(command, " pages forward only; follow pageInfo.nextCursor with --cursor."));
7540
- const cursor = getFlag(flags, "cursor");
7502
+ const cursor = getFlag(
7503
+ flags,
7504
+ "cursor"
7505
+ );
7541
7506
  if (cursor === "" || (cursor?.length ?? 0) > 8192) throw new Error("--cursor must be a non-empty opaque token of at most 8192 characters.");
7542
7507
  const limitFlag = getFlag(flags, "limit"), limit = limitFlag === void 0 ? void 0 : Number(limitFlag);
7543
7508
  if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > maxLimit)) throw new Error("--limit must be an integer from 1 to ".concat(maxLimit, "."));
@@ -7545,10 +7510,13 @@ var rejectRetiredPageFlags = __name2((flags) => {
7545
7510
  }, "parseDetailFeedPage"), parseBillFilterFlags = __name2((flags) => {
7546
7511
  const statusRaw = getFlag(flags, "status"), createdByIdsRaw = getFlag(flags, "createdByIds"), searchRaw = getFlag(flags, "search");
7547
7512
  return { projectId: getFlag(flags, "projectId"), budgetId: getFlag(flags, "budgetId"), statuses: parseCommaSeparatedBillStatuses(statusRaw !== void 0 ? String(statusRaw) : void 0), search: searchRaw !== void 0 ? String(searchRaw) : void 0, isClaimable: parseOptionalBoolFlag(flags, "isClaimable"), createdByIds: parseCommaSeparatedIds(createdByIdsRaw !== void 0 ? String(createdByIdsRaw) : void 0) };
7548
- }, "parseBillFilterFlags"), parseQuotationFilterFlags = __name2((flags) => {
7549
- const createdByRaw = getFlag(flags, "createdBy") ?? getFlag(flags, "requesterIds"), searchRaw = getFlag(flags, "search");
7550
- return { projectId: getFlag(flags, "projectId"), budgetId: getFlag(flags, "budgetId"), supplierId: getFlag(flags, "supplierId"), status: parseCommaSeparatedQuotationStatuses(getFlag(flags, "status")), createdBy: parseCommaSeparatedIds(createdByRaw), search: searchRaw !== void 0 && String(searchRaw).trim() || void 0 };
7551
- }, "parseQuotationFilterFlags");
7513
+ }, "parseBillFilterFlags"), parseQuotationFilterFlags = __name2(
7514
+ (flags) => {
7515
+ const createdByRaw = getFlag(flags, "createdBy") ?? getFlag(flags, "requesterIds"), searchRaw = getFlag(flags, "search");
7516
+ return { projectId: getFlag(flags, "projectId"), budgetId: getFlag(flags, "budgetId"), supplierId: getFlag(flags, "supplierId"), status: parseCommaSeparatedQuotationStatuses(getFlag(flags, "status")), createdBy: parseCommaSeparatedIds(createdByRaw), search: searchRaw !== void 0 && String(searchRaw).trim() || void 0 };
7517
+ },
7518
+ "parseQuotationFilterFlags"
7519
+ );
7552
7520
  function parseListBillsFlags(flags) {
7553
7521
  rejectRetiredPageFlags(flags);
7554
7522
  for (const key of ["limit", "cursor", "direction", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
@@ -7561,13 +7529,7 @@ function parseListBillsFlags(flags) {
7561
7529
  __name(parseListBillsFlags, "parseListBillsFlags"), __name2(parseListBillsFlags, "parseListBillsFlags");
7562
7530
  function parseCountBillsFlags(flags) {
7563
7531
  rejectRetiredPageFlags(flags);
7564
- for (const key of [
7565
- "limit",
7566
- "cursor",
7567
- "direction",
7568
- "sortBy",
7569
- "sortDir"
7570
- ]) if (flags[key] !== void 0) throw new Error("bill count does not accept --".concat(key, "; totals use filters only."));
7532
+ for (const key of ["limit", "cursor", "direction", "sortBy", "sortDir"]) if (flags[key] !== void 0) throw new Error("bill count does not accept --".concat(key, "; totals use filters only."));
7571
7533
  return { ...parseBillFilterFlags(flags), includeMetrics: parseOptionalBoolFlag(flags, "includeMetrics") ?? !1 };
7572
7534
  }
7573
7535
  __name(parseCountBillsFlags, "parseCountBillsFlags"), __name2(parseCountBillsFlags, "parseCountBillsFlags");
@@ -7581,15 +7543,14 @@ function parseOptionalSupplierSortBy(raw) {
7581
7543
  __name(parseOptionalSupplierSortBy, "parseOptionalSupplierSortBy"), __name2(parseOptionalSupplierSortBy, "parseOptionalSupplierSortBy");
7582
7544
  var parseSupplierFilters = __name2((flags) => {
7583
7545
  for (const key of ["name", "createdBy", "gstRegistered", "status", "supplierTags", "active"]) rejectBareFlag(flags, key);
7584
- return { name: getFlag(flags, "name"), createdBy: parseCommaSeparatedIds(getFlag(flags, "createdBy")), gstRegistered: parseOptionalBoolFlag(
7585
- flags,
7586
- "gstRegistered"
7587
- ) ?? null, status: parseCommaSeparatedSupplierStatuses(getFlag(flags, "status")), supplierTags: parseCommaSeparatedIds(getFlag(flags, "supplierTags")), active: parseOptionalBoolFlag(flags, "active") ?? !0 };
7546
+ return { name: getFlag(flags, "name"), createdBy: parseCommaSeparatedIds(getFlag(flags, "createdBy")), gstRegistered: parseOptionalBoolFlag(flags, "gstRegistered") ?? null, status: parseCommaSeparatedSupplierStatuses(getFlag(flags, "status")), supplierTags: parseCommaSeparatedIds(getFlag(flags, "supplierTags")), active: parseOptionalBoolFlag(flags, "active") ?? !0 };
7588
7547
  }, "parseSupplierFilters"), rejectSupplierPageFlags = __name2((flags) => {
7589
7548
  for (const key of PROJECT_PAGE_FLAGS) if (flags[key] !== void 0) throw new Error("--".concat(key, " is retired for suppliers; use --limit/--cursor or supplier count for totals."));
7590
7549
  }, "rejectSupplierPageFlags"), parseSupplierListSortEntries = __name2((sortRaw) => {
7591
7550
  const parsed = parseJsonFlag(sortRaw, "--sort");
7592
- if (!Array.isArray(parsed) || parsed.length > 8) throw new Error("--sort must be a JSON array of at most eight {id, desc} entries.");
7551
+ if (!Array.isArray(
7552
+ parsed
7553
+ ) || parsed.length > 8) throw new Error("--sort must be a JSON array of at most eight {id, desc} entries.");
7593
7554
  return parsed.map((item) => {
7594
7555
  if (typeof item != "object" || item === null || !("id" in item) || !("desc" in item) || typeof item.id != "string" || typeof item.desc != "boolean" || Object.keys(item).some((key) => key !== "id" && key !== "desc")) throw new Error("Invalid --sort entry; use {id, desc}.");
7595
7556
  const id = parseOptionalSupplierSortBy(item.id);
@@ -7604,26 +7565,26 @@ var parseSupplierFilters = __name2((flags) => {
7604
7565
  }
7605
7566
  const sortBy = parseOptionalSupplierSortBy(getFlag(flags, "sortBy")), sortDir = parseOptionalBillListSortDir(getFlag(flags, "sortDir"));
7606
7567
  return [{ id: sortBy ?? "createdAt", desc: (sortDir ?? "desc") === "desc" }];
7607
- }, "parseSupplierListSort"), parseListSuppliersFlags = __name2((flags) => {
7608
- rejectSupplierPageFlags(flags);
7609
- for (const key of ["limit", "cursor", "direction", "sort", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
7610
- const limit = getFlag(flags, "limit") === void 0 ? 10 : parseProjectLimit(getFlag(flags, "limit")), cursor = getFlag(flags, "cursor");
7611
- if (cursor === "" || (cursor?.length ?? 0) > 8192) throw new Error("--cursor must be a non-empty opaque token of at most 8192 characters.");
7612
- const direction = parseProjectDirection(getFlag(flags, "direction"));
7613
- if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
7614
- const sort = parseSupplierListSort(flags);
7615
- return { ...parseSupplierFilters(flags), limit, cursor, direction, sort };
7616
- }, "parseListSuppliersFlags"), parseCountSuppliersFlags = __name2((flags) => {
7568
+ }, "parseSupplierListSort"), parseListSuppliersFlags = __name2(
7569
+ (flags) => {
7570
+ rejectSupplierPageFlags(flags);
7571
+ for (const key of ["limit", "cursor", "direction", "sort", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
7572
+ const limit = getFlag(flags, "limit") === void 0 ? 10 : parseProjectLimit(getFlag(flags, "limit")), cursor = getFlag(flags, "cursor");
7573
+ if (cursor === "" || (cursor?.length ?? 0) > 8192) throw new Error("--cursor must be a non-empty opaque token of at most 8192 characters.");
7574
+ const direction = parseProjectDirection(getFlag(flags, "direction"));
7575
+ if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
7576
+ const sort = parseSupplierListSort(flags);
7577
+ return { ...parseSupplierFilters(flags), limit, cursor, direction, sort };
7578
+ },
7579
+ "parseListSuppliersFlags"
7580
+ ), parseCountSuppliersFlags = __name2((flags) => {
7617
7581
  rejectSupplierPageFlags(flags);
7618
7582
  for (const key of ["limit", "cursor", "direction", "sort", "sortBy", "sortDir"]) if (flags[key] !== void 0) throw new Error("supplier count does not accept --".concat(key, "; totals use filters only."));
7619
7583
  return parseSupplierFilters(flags);
7620
7584
  }, "parseCountSuppliersFlags");
7621
7585
  function parseDashboardQueryFlags(flags) {
7622
7586
  const roleRaw = getFlag(flags, "role"), timeFrameRaw = getFlag(flags, "timeFrame");
7623
- return { userId: getFlag(flags, "userId"), role: parseOptionalDashboardRole(roleRaw !== void 0 ? String(roleRaw) : void 0), deals: parseOptionalDeals(getFlag(flags, "deals")), timeFrame: parseOptionalTimeFrame(timeFrameRaw !== void 0 ? String(timeFrameRaw) : void 0), startDate: getFlag(
7624
- flags,
7625
- "startDate"
7626
- ), endDate: getFlag(flags, "endDate") };
7587
+ return { userId: getFlag(flags, "userId"), role: parseOptionalDashboardRole(roleRaw !== void 0 ? String(roleRaw) : void 0), deals: parseOptionalDeals(getFlag(flags, "deals")), timeFrame: parseOptionalTimeFrame(timeFrameRaw !== void 0 ? String(timeFrameRaw) : void 0), startDate: getFlag(flags, "startDate"), endDate: getFlag(flags, "endDate") };
7627
7588
  }
7628
7589
  __name(parseDashboardQueryFlags, "parseDashboardQueryFlags"), __name2(parseDashboardQueryFlags, "parseDashboardQueryFlags");
7629
7590
  function printLegacyHelp(runtime) {
@@ -7659,11 +7620,14 @@ ks vendor: quickBooksSyncQueued, operationId)\n update-supplier --pa
7659
7620
  json>' (item.updateItem; must include id)\n archive-items --ids <csv> (item.archiveItems; Budget Builder only; max 100; users can archive their own items, leads/admins any item; open estimates retain snapshot lines and require resolution before send/acceptance)\n delete-item <id> (item.deleteItem; admin; archives in Budget Builder and makes the item inactive in QuickBooks; blocked while used by an open estimate)\n get-supplier-details <supplierId>\n get-supplier-overview <supplierId> (supplier.getSupplierOverview; profile, approvals, attachments and tab counts; no usage or items)\n get-supplier-usage <supplierId> (supplier.getSupplierUsage; usage rows and spending)\n get-supplier-items <supplierId> (supplier.getSupplierItems; inventory items)\n get-supplier-analytics [--name] [--status CSV] [--gstRegistered true|false] [--createdBy <text>] [--timeFrame ALL|LAST_YEAR|LAST_6_MONTHS|LAST_3_MONTHS|CUSTOM] [--startDate <ISO> --endDate <ISO>] [--sortB\
7660
7621
  y name|gstRegistered|status|phone|email|updatedAt|createdAt] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward]\n Admin. Returns { items, pageInfo }; follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected.\n count-supplier-analytics [--name] [--status] [--gstRegistered] [--createdBy] [--timeFrame] [--startDate --endDate] Admin. totalCount for the same filters\n list-items [--name] [--includeQuickBooksDeactivationPending true] [--sortBy createdAt|updatedAt|name|cost|itemCategory|supplier] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward]\n Returns { items, pageInfo }; follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected.\n count-items [same filter flags as list-items] total plus category and supplier facets\n get-item <id>\n get-item-quickbooks-sync-status <itemId> (saved status only; no provi\
7661
7622
  der call or polling)\n list-item-categories [--name] [--sortBy createdAt|name|itemCount|createdBy] [--sortDir asc|desc] [--limit 1-100] [--cursor <token>] [--direction forward|backward]\n Active categories only; returns { items, pageInfo }. Follow nextCursor/previousCursor with the same filters and sort. --page/--perPage are rejected.\n count-item-categories [--name] totalCount of active categories\n create-item-category --name (admin; saves the category and queues its QuickBooks create: quickBooksSyncQueued, operationId)\n update-item-category --id --name (authenticated; renames in BB now and queues the QuickBooks rename: quickBooksSyncQueued, operationId)\n delete-item-categories --ids <csv> (itemCategory.deleteItemCategories; admin; empty categories only)\n\nDashboard & users\n whoami Show the user identity and role for the active API key.\n list-users [--q] [--projectTeamOnly true|false] [--limit 1-100] [--cursor <t\
7662
- oken>]\n Name A\u2013Z. Returns { items, pageInfo }; follow nextCursor with the same --q and --projectTeamOnly. --page/--perPage are rejected.\n --projectTeamOnly true lists only active @getout.sg users, the only accounts accepted as Inside Sales, Business Development or Project Manager.\n count-users [--q] [--projectTeamOnly true|false] totalCount for the same search\n create-user --email <email> [--name <name>] [--role ").concat(userRolesForHelp.join("|"), '] (admin; API-only service identity with no Google sign-in)\n create-api-key --name <label> [--userId <userId>] (defaults to the caller; admin required for another user; raw key is shown once)\n list-api-keys [--userId <userId>] [--limit 1-100] [--cursor <token>] (newest first, { items, pageInfo }; defaults to the caller; admin required for another user)\n revoke-api-key <apiKeyId> [--userId <userId>] (defaults to the caller; admin required for another user)\n g\
7663
- et-user-performance [--userId] (admin)\n get-dashboard [--userId] [--role BD|CREATOR|INSIDE_SALES|ALL] [--deals ALL|SUCCESSFUL|LOST] [--timeFrame] [--startDate] [--endDate] (admin)\n get-monthly-metrics [same optional flags as get-dashboard] (admin; dashboard.getMonthlyMetrics)\n get-system-overview [same optional flags as get-dashboard] (admin; dashboard.getSystemOverview)\n get-estimate-performance [same optional flags as get-dashboard] (admin; dashboard.getEstimatePerformance)\n get-financial-overview [same optional flags as dashboard; role uses BudgetRole enum] (admin)\n\nErrors\n get-recent-errors [--cursor] [--direction forward|backward] [--limit] [--severity] [--status] [--timeFrame] (admin)\n count-errors [--severity] [--status] [--timeFrame] (admin)\n get-error <errorId> Full diagnostics: stack, cause, request, metadata (admin)\n get-error-metrics (admin)\n\nAutomation (admin)\n list-integration-\
7664
- operations [--search] [--destination <provider,...>] [--status <PENDING|PROCESSING|FAILED|COMPLETED,...>] [--limit 1-100] [--cursor <token>] [--direction forward|backward]\n Newest first; returns { items, pageInfo }. Follow nextCursor/previousCursor with the same filters. --page/--perPage are rejected.\n count-integration-operations [same filter flags] provider filter options only (no total; filters do not change the result)\n get-integration-operation <operationId> (one job: who queued it, what it is for, saved progress, Retry state)\n retry-integration-operation <operationId> [--confirmExternalStateReconciled true|false] [--outboundEmailResolution ACCEPTED|NOT_ACCEPTED_RETRY] [--providerMessageId <id>] (QuickBooks jobs with a saved attempt check QuickBooks first: applied changes finish without resending, unapplied ones are sent again)\n reconcile-resource-operation <operationId> (admin: check a QuickBooks invoice/company/item job outcome without retrying; same check Retry runs\
7665
- first)\n\nWebhooks (admin)\n list-webhook-event-types (event catalogue: type, group, live|planned)\n list-webhook-endpoints\n get-webhook-endpoint <endpointId>\n create-webhook-endpoint --name <name> --url <https-url> --events <type|prefix.*|*,...> [--enabled true|false] (prints the signing secret once)\n update-webhook-endpoint <endpointId> [--name] [--url] [--events <...>] [--enabled true|false]\n delete-webhook-endpoint <endpointId>\n rotate-webhook-secret <endpointId> [--previousSecretTtlHours <0-168>] (prints the new secret once)\n send-webhook-test-event <endpointId>\n list-webhook-deliveries [--endpointId] [--status <PENDING|SUCCEEDED|FAILED,...>] [--eventType] [--limit 1-100] [--cursor <token>] [--direction forward|backward] (newest first; prints items + pageInfo)\n get-webhook-delivery <deliveryId> (attempts with response codes)\n replay-webhook-delivery <deliveryId> (same eventId, new attempt chain)\n\nHistorical / benchmarks\n get-approved-budgets [--projectId] [--\
7666
- limit] [--minRevenue] [--maxRevenue]\n get-budget-category-benchmarks <categoryId> [--limit]\n get-item-pricing-history [--itemName] [--categoryId] [--supplierId] [--limit]\n get-supplier-pricing-history <supplierId> [--itemCategoryId] [--limit]\n\nOutput: JSON to stdout. Errors to stderr; exit 1 on failure.\n\nMCP parity: every MCP tool maps to one command above. The CLI also exposes\n reorder-budget-items and update-budget-item-supplier (web UI\u2013oriented tRPC).\n You may use MCP-style snake_case (e.g. bb list_bills) \u2014 normalized to kebab-case.\n\nNote: MCP also exposes a Prisma schema resource; the CLI has no equivalent.\n\nNot covered vs MCP get_budget: "get-budget" also fetches line items in one call.\n').trim();
7623
+ oken>]\n Name A\u2013Z. Returns { items, pageInfo }; follow nextCursor with the same --q and --projectTeamOnly. --page/--perPage are rejected.\n --projectTeamOnly true lists only active @getout.sg users, the only accounts accepted as Inside Sales, Business Development or Project Manager.\n count-users [--q] [--projectTeamOnly true|false] totalCount for the same search\n create-user --email <email> [--name <name>] [--role ").concat(
7624
+ userRolesForHelp.join("|"),
7625
+ '] (admin; API-only service identity with no Google sign-in)\n create-api-key --name <label> [--userId <userId>] (defaults to the caller; admin required for another user; raw key is shown once)\n list-api-keys [--userId <userId>] [--limit 1-100] [--cursor <token>] (newest first, { items, pageInfo }; defaults to the caller; admin required for another user)\n revoke-api-key <apiKeyId> [--userId <userId>] (defaults to the caller; admin required for another user)\n get-user-performance [--userId] (admin)\n get-dashboard [--userId] [--role BD|CREATOR|INSIDE_SALES|ALL] [--deals ALL|SUCCESSFUL|LOST] [--timeFrame] [--startDate] [--endDate] (admin)\n get-monthly-metrics [same optional flags as get-dashboard] (admin; dashboard.getMonthlyMetrics)\n get-system-overview [same optional flags as get-dashboard] (admin; dashboard.getSystemOverview)\n get-estimate-performance [same optional flags as get-dashboard] (admin; dashboar\
7626
+ d.getEstimatePerformance)\n get-financial-overview [same optional flags as dashboard; role uses BudgetRole enum] (admin)\n\nErrors\n get-recent-errors [--cursor] [--direction forward|backward] [--limit] [--severity] [--status] [--timeFrame] (admin)\n count-errors [--severity] [--status] [--timeFrame] (admin)\n get-error <errorId> Full diagnostics: stack, cause, request, metadata (admin)\n get-error-metrics (admin)\n\nAutomation (admin)\n list-integration-operations [--search] [--destination <provider,...>] [--status <PENDING|PROCESSING|FAILED|COMPLETED,...>] [--limit 1-100] [--cursor <token>] [--direction forward|backward]\n Newest first; returns { items, pageInfo }. Follow nextCursor/previousCursor with the same filters. --page/--perPage are rejected.\n count-integration-operations [same filter flags] provider filter options only (no total; filters do not change the result)\n get-integration-operation <operationId> (one job: who queued it\
7627
+ , what it is for, saved progress, Retry state)\n retry-integration-operation <operationId> [--confirmExternalStateReconciled true|false] [--outboundEmailResolution ACCEPTED|NOT_ACCEPTED_RETRY] [--providerMessageId <id>] (QuickBooks jobs with a saved attempt check QuickBooks first: applied changes finish without resending, unapplied ones are sent again)\n reconcile-resource-operation <operationId> (admin: check a QuickBooks invoice/company/item job outcome without retrying; same check Retry runs first)\n\nWebhooks (admin)\n list-webhook-event-types (event catalogue: type, group, live|planned)\n list-webhook-endpoints\n get-webhook-endpoint <endpointId>\n create-webhook-endpoint --name <name> --url <https-url> --events <type|prefix.*|*,...> [--enabled true|false] (prints the signing secret once)\n update-webhook-endpoint <endpointId> [--name] [--url] [--events <...>] [--enabled true|false]\n delete-webhook-endpoint <endpointId>\n rotate-webhook-secret <endpointId> [--previousSecretTtl\
7628
+ Hours <0-168>] (prints the new secret once)\n send-webhook-test-event <endpointId>\n list-webhook-deliveries [--endpointId] [--status <PENDING|SUCCEEDED|FAILED,...>] [--eventType] [--limit 1-100] [--cursor <token>] [--direction forward|backward] (newest first; prints items + pageInfo)\n get-webhook-delivery <deliveryId> (attempts with response codes)\n replay-webhook-delivery <deliveryId> (same eventId, new attempt chain)\n\nHistorical / benchmarks\n get-approved-budgets [--projectId] [--limit] [--minRevenue] [--maxRevenue]\n get-budget-category-benchmarks <categoryId> [--limit]\n get-item-pricing-history [--itemName] [--categoryId] [--supplierId] [--limit]\n get-supplier-pricing-history <supplierId> [--itemCategoryId] [--limit]\n\nOutput: JSON to stdout. Errors to stderr; exit 1 on failure.\n\nMCP parity: every MCP tool maps to one command above. The CLI also exposes\n reorder-budget-items and update-budget-item-supplier (web UI\u2013oriented tRPC).\n You may use MCP-style snake_case\
7629
+ (e.g. bb list_bills) \u2014 normalized to kebab-case.\n\nNote: MCP also exposes a Prisma schema resource; the CLI has no equivalent.\n\nNot covered vs MCP get_budget: "get-budget" also fetches line items in one call.\n'
7630
+ ).trim();
7667
7631
  runtime.stdout.write("".concat(help, "\n"));
7668
7632
  }
7669
7633
  __name(printLegacyHelp, "printLegacyHelp"), __name2(printLegacyHelp, "printLegacyHelp");
@@ -7714,7 +7678,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7714
7678
  return { apiBaseUrl, commandArgv };
7715
7679
  }, "parseRootArguments"), effectPermissionsFromArgv = __name2((argv) => ({ allowStateChange: isEnabledFlag(argv, "--allow-state-change"), allowEmail: isEnabledFlag(argv, "--allow-email"), allowExternalWrite: isEnabledFlag(argv, "--allow-external-write"), allowDelete: isEnabledFlag(argv, "--allow-delete"), allowFinancialWrite: isEnabledFlag(argv, "--allow-financial-write") }), "effectPermissionsFromArgv"), isCompletionShell = __name2((value) => value === "bash" || value === "zsh" || value === "fish" || value === "powershell", "isCompletionShell"), legacyArgvForCommand = __name2((argv, resolvedCommand) => {
7716
7680
  const legacyTarget = resolvedCommand.command.legacyTarget;
7717
- if (legacyTarget === void 0) throw new CliRuntimeError("INTERNAL", "Command ".concat(resolvedCommand.command.path.join(" "), " has no dispatcher target."));
7681
+ if (legacyTarget === void 0) throw new CliRuntimeError(
7682
+ "INTERNAL",
7683
+ "Command ".concat(resolvedCommand.command.path.join(" "), " has no dispatcher target.")
7684
+ );
7718
7685
  return [argv[0] ?? "node", argv[1] ?? "bb", legacyTarget, ...resolvedCommand.argv.filter((value) => !isRuntimeOnlyArgument(value))];
7719
7686
  }, "legacyArgvForCommand"), normalizeDispatcherError = __name2((error2) => error2 instanceof Error && new __cliRegExp("\\brequires\\b|\\bmust be\\b|\\bmust include\\b|^Invalid\\b|^Missing\\b|^--", "").test(error2.message) ? new CliRuntimeError("VALIDATION", error2.message) : error2, "normalizeDispatcherError"), commandConfirmationTarget = __name2((resolvedCommand) => {
7720
7687
  const positionalTarget = resolvedCommand.argv.find((value) => value !== "--" && !value.startsWith("-"));
@@ -7735,10 +7702,11 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7735
7702
  return sortDir;
7736
7703
  }, "parseAscDescSortDir"), commandWhoami = __name2(async () => {
7737
7704
  await whoAmI();
7738
- }, "commandWhoami"), commandListBudgets = __name2(async ({ cmd, flags }) => {
7739
- const statusStr = getFlag(flags, "status"), statuses = parseCommaSeparatedBudgetStatuses(statusStr !== void 0 ? String(statusStr) : void 0), filters = { projectId: getFlag(flags, "projectId"), name: getFlag(flags, "name"), statuses, createdBy: getFlag(flags, "createdBy"), dateFrom: getFlag(flags, "dateFrom"), dateTo: getFlag(flags, "dateTo"), active: parseBudgetActiveFlag(
7740
- flags
7741
- ) };
7705
+ }, "commandWhoami"), commandListBudgets = __name2(async ({
7706
+ cmd,
7707
+ flags
7708
+ }) => {
7709
+ const statusStr = getFlag(flags, "status"), statuses = parseCommaSeparatedBudgetStatuses(statusStr !== void 0 ? String(statusStr) : void 0), filters = { projectId: getFlag(flags, "projectId"), name: getFlag(flags, "name"), statuses, createdBy: getFlag(flags, "createdBy"), dateFrom: getFlag(flags, "dateFrom"), dateTo: getFlag(flags, "dateTo"), active: parseBudgetActiveFlag(flags) };
7742
7710
  if (rejectRetiredPageFlags(flags), cmd === "count-budgets") {
7743
7711
  for (const key of ["limit", "cursor", "direction", "sortBy", "sortDir"]) if (flags[key] !== void 0) throw new Error("count-budgets does not accept --".concat(key, "; totals use filters only."));
7744
7712
  await countBudgets(filters);
@@ -7748,26 +7716,24 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7748
7716
  const cursor = getFlag(flags, "cursor");
7749
7717
  if (cursor === "" || (cursor?.length ?? 0) > 8192) throw new Error("--cursor must be a non-empty opaque token of at most 8192 characters.");
7750
7718
  const direction = parseProjectDirection(getFlag(flags, "direction"));
7751
- if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
7719
+ if (direction === "backward" && !cursor) throw new Error(
7720
+ "--direction backward requires --cursor <token>."
7721
+ );
7752
7722
  await listBudgets({ ...filters, limit: parseProjectLimit(getFlag(flags, "limit")), cursor, direction, sortBy: getFlag(flags, "sortBy"), sortDir: getFlag(flags, "sortDir"), includeDetails: flags.summary === !0 ? !1 : parseOptionalBoolFlag(flags, "includeDetails") ?? !0 });
7753
- }, "commandListBudgets"), commandGetBudget = __name2(
7754
- async ({ flags, positional }) => {
7755
- const id = positional[0];
7756
- if (!id) throw new Error("get-budget requires <id>");
7757
- await getBudget(id, { includeInactive: flags.includeInactive === !0 ? !0 : parseOptionalBoolFlag(flags, "includeInactive") ?? !1 });
7758
- },
7759
- "commandGetBudget"
7760
- ), commandUploadBudgetAttachment = __name2(async ({ positional }) => {
7723
+ }, "commandListBudgets"), commandGetBudget = __name2(async ({ flags, positional }) => {
7724
+ const id = positional[0];
7725
+ if (!id) throw new Error("get-budget requires <id>");
7726
+ await getBudget(id, { includeInactive: flags.includeInactive === !0 ? !0 : parseOptionalBoolFlag(flags, "includeInactive") ?? !1 });
7727
+ }, "commandGetBudget"), commandUploadBudgetAttachment = __name2(async ({ positional }) => {
7761
7728
  const [budgetId, filePath] = positional;
7762
7729
  if (!budgetId || !filePath) throw new Error("upload-budget-attachment requires <budgetId> <filePath>");
7763
7730
  await uploadBudgetAttachmentFromPath(budgetId, filePath);
7764
7731
  }, "commandUploadBudgetAttachment"), commandMarkBudgetWon = __name2(async ({ flags, positional }) => {
7765
7732
  const [budgetId, filePath] = positional;
7766
- if (!budgetId || !filePath) throw new Error("mark-budget-won requires <budgetId> <filePath>");
7767
- await markBudgetWonWithProof(budgetId, filePath, { projectManagerId: getFlag(flags, "projectManagerId") !== void 0 ? String(getFlag(flags, "projectManagerId")) : void 0, markProjectWon: parseOptionalBoolFlag(flags, "markProjectWon"), projectInvoiceSettings: getFlag(flags, "invoiceSettings") !== void 0 ? parseJsonFlag(
7768
- String(getFlag(flags, "invoiceSettings")),
7769
- "--invoiceSettings"
7770
- ) : void 0 });
7733
+ if (!budgetId || !filePath) throw new Error(
7734
+ "mark-budget-won requires <budgetId> <filePath>"
7735
+ );
7736
+ await markBudgetWonWithProof(budgetId, filePath, { projectManagerId: getFlag(flags, "projectManagerId") !== void 0 ? String(getFlag(flags, "projectManagerId")) : void 0, markProjectWon: parseOptionalBoolFlag(flags, "markProjectWon"), projectInvoiceSettings: getFlag(flags, "invoiceSettings") !== void 0 ? parseJsonFlag(String(getFlag(flags, "invoiceSettings")), "--invoiceSettings") : void 0 });
7771
7737
  }, "commandMarkBudgetWon"), commandGetBudgetItems = __name2(async ({ flags, positional }) => {
7772
7738
  const id = positional[0];
7773
7739
  if (!id) throw new Error("get-budget-items requires <budgetId>");
@@ -7801,10 +7767,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7801
7767
  }, "commandRestoreBudgetVersion"), commandUpdateBudgetStatus = __name2(async ({ flags, positional }) => {
7802
7768
  const [id, status] = positional;
7803
7769
  if (!id || !status) throw new Error("update-budget-status requires <id> <status>");
7804
- if (!isBudgetStatusUpdate(status)) throw new Error("Invalid status. Use one of: ".concat(budgetStatusesForHelp.join(", ")));
7805
- await updateBudgetStatus(id, status, { projectManagerId: getFlag(flags, "projectManagerId") !== void 0 ? String(getFlag(flags, "projectManagerId")) : void 0, markProjectWon: parseOptionalBoolFlag(flags, "markProjectWon"), projectStatusOnCommercialRejection: parseCommercialRejectionProjectStatus(
7806
- flags
7807
- ), projectInvoiceSettings: getFlag(flags, "invoiceSettings") !== void 0 ? parseJsonFlag(String(getFlag(flags, "invoiceSettings")), "--invoiceSettings") : void 0 });
7770
+ if (!isBudgetStatusUpdate(
7771
+ status
7772
+ )) throw new Error("Invalid status. Use one of: ".concat(budgetStatusesForHelp.join(", ")));
7773
+ await updateBudgetStatus(id, status, { projectManagerId: getFlag(flags, "projectManagerId") !== void 0 ? String(getFlag(flags, "projectManagerId")) : void 0, markProjectWon: parseOptionalBoolFlag(flags, "markProjectWon"), projectStatusOnCommercialRejection: parseCommercialRejectionProjectStatus(flags), projectInvoiceSettings: getFlag(flags, "invoiceSettings") !== void 0 ? parseJsonFlag(String(getFlag(flags, "invoiceSettings")), "--invoiceSettings") : void 0 });
7808
7774
  }, "commandUpdateBudgetStatus"), commandCreateBudgetApproval = __name2(async ({ flags, positional }) => {
7809
7775
  const id = positional[0];
7810
7776
  if (!id) throw new Error("create-budget-approval requires <budgetId>");
@@ -7816,15 +7782,16 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7816
7782
  const companyPayloadRaw = getFlag(flags, "companyPayload"), contactPayloadRaw = getFlag(flags, "contactPayload"), eventPayloadRaw = getFlag(flags, "eventPayload");
7817
7783
  await createEstimate(id, { company: companyPayloadRaw !== void 0 ? parseJsonObjectFlag(String(companyPayloadRaw), "--companyPayload") : void 0, contactPerson: contactPayloadRaw !== void 0 ? parseJsonObjectFlag(String(contactPayloadRaw), "--contactPayload") : void 0, eventDetails: eventPayloadRaw !== void 0 ? parseJsonObjectFlag(String(eventPayloadRaw), "--eventPayload") : void 0 });
7818
7784
  }, "commandCreateEstimate"), commandSendEstimateEmail = __name2(async ({ flags }) => {
7819
- const payloadRaw = getFlag(flags, "payload");
7785
+ const payloadRaw = getFlag(
7786
+ flags,
7787
+ "payload"
7788
+ );
7820
7789
  if (!payloadRaw) throw new Error("send-estimate-to-contact-person requires --payload '<json>'");
7821
7790
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
7822
7791
  await sendEstimateToContactPersonFromPayload(raw);
7823
7792
  }, "commandSendEstimateEmail"), commandCreateBudget = __name2(async ({ flags }) => {
7824
7793
  const payloadRaw = getFlag(flags, "payload");
7825
- if (!payloadRaw) throw new Error(
7826
- "create-budget requires --payload '<json>'"
7827
- );
7794
+ if (!payloadRaw) throw new Error("create-budget requires --payload '<json>'");
7828
7795
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
7829
7796
  await createBudgetFromPayload(raw);
7830
7797
  }, "commandCreateBudget"), commandUpdateBudget = __name2(async ({ flags }) => {
@@ -7836,20 +7803,26 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7836
7803
  const id = positional[0];
7837
7804
  if (!id) throw new Error("delete-budget requires <budgetId>");
7838
7805
  await deleteBudgetById(id);
7839
- }, "commandDeleteBudget"), commandAddBudgetItems = __name2(async ({ flags }) => {
7840
- const budgetId = getFlag(flags, "budgetId");
7841
- if (!budgetId) throw new Error("add-budget-items requires --budgetId");
7842
- const items = parseJsonFlag(String(getFlag(flags, "items")), "--items");
7843
- await addBudgetItems({ budgetId: String(budgetId), items });
7844
- }, "commandAddBudgetItems"), commandUpdateBudgetItem = __name2(async ({ flags }) => {
7806
+ }, "commandDeleteBudget"), commandAddBudgetItems = __name2(
7807
+ async ({ flags }) => {
7808
+ const budgetId = getFlag(flags, "budgetId");
7809
+ if (!budgetId) throw new Error("add-budget-items requires --budgetId");
7810
+ const items = parseJsonFlag(String(getFlag(flags, "items")), "--items");
7811
+ await addBudgetItems({ budgetId: String(budgetId), items });
7812
+ },
7813
+ "commandAddBudgetItems"
7814
+ ), commandUpdateBudgetItem = __name2(async ({ flags }) => {
7845
7815
  const id = getFlag(flags, "id");
7846
7816
  if (!id) throw new Error("update-budget-item requires --id");
7847
7817
  await updateBudgetItem({ id: String(id), description: getFlag(flags, "description"), note: getFlag(flags, "note"), quantity: parseOptionalNumber(getFlag(flags, "quantity"), "--quantity"), markup: parseOptionalNumber(getFlag(flags, "markup"), "--markup"), cost: parseOptionalNumber(getFlag(flags, "cost"), "--cost"), unitPrice: parseOptionalNumber(getFlag(flags, "unitPrice"), "--unitPrice"), isFreeOfCharge: parseOptionalBoolFlag(flags, "isFreeOfCharge"), gstInclusive: parseOptionalBoolFlag(flags, "gstInclusive"), gstOutOfScope: parseOptionalBoolFlag(flags, "gstOutOfScope") });
7848
- }, "commandUpdateBudgetItem"), commandRemoveBudgetItem = __name2(async ({ positional }) => {
7849
- const id = positional[0];
7850
- if (!id) throw new Error("remove-budget-item requires <budgetItemId>");
7851
- await removeBudgetItem(id);
7852
- }, "commandRemoveBudgetItem"), commandReplaceBudgetItem = __name2(async ({ flags }) => {
7818
+ }, "commandUpdateBudgetItem"), commandRemoveBudgetItem = __name2(
7819
+ async ({ positional }) => {
7820
+ const id = positional[0];
7821
+ if (!id) throw new Error("remove-budget-item requires <budgetItemId>");
7822
+ await removeBudgetItem(id);
7823
+ },
7824
+ "commandRemoveBudgetItem"
7825
+ ), commandReplaceBudgetItem = __name2(async ({ flags }) => {
7853
7826
  const budgetItemId = getFlag(flags, "budgetItemId"), replacementItemId = getFlag(flags, "replacementItemId");
7854
7827
  if (!budgetItemId || !replacementItemId) throw new Error("replace-budget-item requires --budgetItemId and --replacementItemId");
7855
7828
  await replaceBudgetItem({ budgetItemId: String(budgetItemId), replacementItemId: String(replacementItemId) });
@@ -7857,20 +7830,25 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7857
7830
  const budgetItemId = getFlag(flags, "budgetItemId"), reason = getFlag(flags, "reason");
7858
7831
  if (!budgetItemId || !reason) throw new Error("approve-unavailable-item-exception requires --budgetItemId and --reason");
7859
7832
  await approveUnavailableItemException({ budgetItemId: String(budgetItemId), reason: String(reason) });
7860
- }, "commandApproveUnavailableItemException"), commandReorderBudgetItems = __name2(async ({ flags, positional }) => {
7861
- const budgetId = positional[0], itemIdsRaw = getFlag(flags, "itemIds");
7862
- if (!budgetId || itemIdsRaw === void 0) throw new Error("reorder-budget-items requires <budgetId> --itemIds <csv>");
7863
- const itemIds = parseCommaSeparatedIds(String(itemIdsRaw));
7864
- if (!itemIds?.length) throw new Error("reorder-budget-items requires non-empty --itemIds <csv>");
7865
- await reorderBudgetItemsCli({ budgetId, itemIds });
7866
- }, "commandReorderBudgetItems"), commandUpdateBudgetItemSupplier = __name2(async ({ flags }) => {
7833
+ }, "commandApproveUnavailableItemException"), commandReorderBudgetItems = __name2(
7834
+ async ({ flags, positional }) => {
7835
+ const budgetId = positional[0], itemIdsRaw = getFlag(flags, "itemIds");
7836
+ if (!budgetId || itemIdsRaw === void 0) throw new Error("reorder-budget-items requires <budgetId> --itemIds <csv>");
7837
+ const itemIds = parseCommaSeparatedIds(String(itemIdsRaw));
7838
+ if (!itemIds?.length) throw new Error("reorder-budget-items requires non-empty --itemIds <csv>");
7839
+ await reorderBudgetItemsCli({ budgetId, itemIds });
7840
+ },
7841
+ "commandReorderBudgetItems"
7842
+ ), commandUpdateBudgetItemSupplier = __name2(async ({ flags }) => {
7867
7843
  const budgetItemId = getFlag(flags, "budgetItemId"), supplierId = getFlag(flags, "supplierId");
7868
7844
  if (!budgetItemId || !supplierId) throw new Error("update-budget-item-supplier requires --budgetItemId and --supplierId");
7869
7845
  await updateBudgetItemSupplierCli({ budgetItemId: String(budgetItemId), supplierId: String(supplierId) });
7870
7846
  }, "commandUpdateBudgetItemSupplier"), commandCreateBudgetCategory = __name2(async ({ flags }) => {
7871
7847
  const name = getFlag(flags, "name");
7872
7848
  if (!name) throw new Error("create-budget-category requires --name");
7873
- await createBudgetCategory(String(name));
7849
+ await createBudgetCategory(
7850
+ String(name)
7851
+ );
7874
7852
  }, "commandCreateBudgetCategory"), commandUpdateBudgetCategory = __name2(async ({ flags }) => {
7875
7853
  const id = getFlag(flags, "id"), name = getFlag(flags, "name");
7876
7854
  if (!id || !name) throw new Error("update-budget-category requires --id and --name");
@@ -7919,14 +7897,14 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7919
7897
  await countBills({ ...parseCountBillsFlags(flags), isClaimable: !0 });
7920
7898
  }, "commandCountClaims"), commandCreateBillApproval = __name2(async ({ positional }) => {
7921
7899
  const id = positional[0];
7922
- if (!id) throw new Error("create-bill-approval requires <billId>");
7900
+ if (!id) throw new Error(
7901
+ "create-bill-approval requires <billId>"
7902
+ );
7923
7903
  await createBillApproval(id);
7924
7904
  }, "commandCreateBillApproval"), commandCreateBill = __name2(async ({ flags }) => {
7925
7905
  const payloadRaw = getFlag(flags, "payload");
7926
7906
  if (!payloadRaw) throw new Error("create-bill requires --payload '<json>'");
7927
- const raw = parseJsonFlag(String(
7928
- payloadRaw
7929
- ), "--payload"), draftOnly = flags["draft-only"] === !0 ? !0 : parseOptionalBoolFlag(flags, "draft-only"), quotationExempt = flags["quotation-exempt"] === !0;
7907
+ const raw = parseJsonFlag(String(payloadRaw), "--payload"), draftOnly = flags["draft-only"] === !0 ? !0 : parseOptionalBoolFlag(flags, "draft-only"), quotationExempt = flags["quotation-exempt"] === !0;
7930
7908
  if (flags["quotation-exempt"] !== void 0 && flags["quotation-exempt"] !== !0) throw new Error("--quotation-exempt does not take a value.");
7931
7909
  await createBillFromPayload(raw, draftOnly, quotationExempt);
7932
7910
  }, "commandCreateBill"), commandValidateBillSelection = __name2(async ({ flags }) => {
@@ -7938,16 +7916,15 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7938
7916
  if (quotationId && quotationIds && (quotationIds.length !== 1 || quotationIds[0] !== quotationId)) throw new Error("--quotationId conflicts with --quotationIds.");
7939
7917
  if (quotationIds && new Set(quotationIds).size !== quotationIds.length) throw new Error("--quotationIds must not contain duplicates.");
7940
7918
  await validateBillSelectionFromPayload(raw, { ...quotationId ? { quotationId } : {}, ...quotationIds ? { quotationIds } : {} });
7941
- }, "commandValidateBillSelection"), commandLinkBillQuotations = __name2(
7942
- async ({ flags, positional }) => {
7943
- const billId = positional[0], payloadRaw = getFlag(flags, "payload"), quotationIds = parseCommaSeparatedIds(getFlag(flags, "quotationIds"));
7944
- if (!billId || !payloadRaw && (!quotationIds || quotationIds.length === 0)) throw new Error("link-bill-quotations requires <billId> and either --payload '<json>' or --quotationIds <csv>");
7945
- if (payloadRaw && quotationIds) throw new Error("--payload cannot be combined with --quotationIds.");
7946
- if (quotationIds && new Set(quotationIds).size !== quotationIds.length) throw new Error("--quotationIds must not contain duplicates.");
7947
- await linkBillQuotations(billId, payloadRaw ? parseJsonFlag(String(payloadRaw), "--payload") : { quotationIds });
7948
- },
7949
- "commandLinkBillQuotations"
7950
- ), commandUpdateBill = __name2(async ({ flags }) => {
7919
+ }, "commandValidateBillSelection"), commandLinkBillQuotations = __name2(async ({ flags, positional }) => {
7920
+ const billId = positional[0], payloadRaw = getFlag(flags, "payload"), quotationIds = parseCommaSeparatedIds(getFlag(flags, "quotationIds"));
7921
+ if (!billId || !payloadRaw && (!quotationIds || quotationIds.length === 0)) throw new Error("link-bill-quotations requires <billId> and either --payload '<json>' or --quotationIds <csv>");
7922
+ if (payloadRaw && quotationIds) throw new Error(
7923
+ "--payload cannot be combined with --quotationIds."
7924
+ );
7925
+ if (quotationIds && new Set(quotationIds).size !== quotationIds.length) throw new Error("--quotationIds must not contain duplicates.");
7926
+ await linkBillQuotations(billId, payloadRaw ? parseJsonFlag(String(payloadRaw), "--payload") : { quotationIds });
7927
+ }, "commandLinkBillQuotations"), commandUpdateBill = __name2(async ({ flags }) => {
7951
7928
  const payloadRaw = getFlag(flags, "payload");
7952
7929
  if (!payloadRaw) throw new Error("update-bill requires --payload '<json>'");
7953
7930
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
@@ -7959,7 +7936,9 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7959
7936
  await updateBillPaymentEvidenceFromPayload(raw);
7960
7937
  }, "commandUpdateBillPaymentEvidence"), commandDeleteBill = __name2(async ({ positional }) => {
7961
7938
  const id = positional[0];
7962
- if (!id) throw new Error("delete-bill requires <billId>");
7939
+ if (!id) throw new Error(
7940
+ "delete-bill requires <billId>"
7941
+ );
7963
7942
  await deleteBillById(id);
7964
7943
  }, "commandDeleteBill"), commandUpdateBillStatus = __name2(async ({ flags, positional }) => {
7965
7944
  const [id, statusRaw] = positional;
@@ -7980,7 +7959,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
7980
7959
  const id = positional[0];
7981
7960
  if (!id) throw new Error("patch-bill-payment requires <billId>");
7982
7961
  const paymentTrackingUrl = (() => {
7983
- const clear = parseOptionalBoolFlag(flags, "clearPaymentTrackingUrl"), raw = getFlag(flags, "paymentTrackingUrl");
7962
+ const clear = parseOptionalBoolFlag(
7963
+ flags,
7964
+ "clearPaymentTrackingUrl"
7965
+ ), raw = getFlag(flags, "paymentTrackingUrl");
7984
7966
  if (clear === !0 && raw !== void 0) throw new Error("Use either --paymentTrackingUrl or --clearPaymentTrackingUrl true, not both");
7985
7967
  if (clear === !0) return null;
7986
7968
  if (raw !== void 0) return String(raw);
@@ -8012,44 +7994,54 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8012
7994
  const page = parseDetailFeedPage("get-bill-approvals", "<billId>", positional, flags, 50);
8013
7995
  await getBillApprovals(page);
8014
7996
  }, "commandGetBillApprovals"), commandGetBillLineItems = __name2(async ({ flags, positional }) => {
8015
- const page = parseDetailFeedPage("get-bill-line-items", "<billId>", positional, flags, 100);
7997
+ const page = parseDetailFeedPage(
7998
+ "get-bill-line-items",
7999
+ "<billId>",
8000
+ positional,
8001
+ flags,
8002
+ 100
8003
+ );
8016
8004
  await getBillLineItems(page);
8017
8005
  }, "commandGetBillLineItems"), commandGetBillPayment = __name2(async ({ positional }) => {
8018
8006
  const id = positional[0];
8019
8007
  if (!id) throw new Error("get-bill-payment requires <billId>");
8020
- await getBillPayment(
8021
- id
8022
- );
8008
+ await getBillPayment(id);
8023
8009
  }, "commandGetBillPayment"), commandStageBillAttachment = __name2(async ({ flags, positional }) => {
8024
8010
  const [projectId, ...positionalFilePaths] = positional, fileFlag = getFlag(flags, "file"), filesFlag = getFlag(flags, "files"), filePaths = [...positionalFilePaths, ...fileFlag !== void 0 ? [String(fileFlag)] : [], ...filesFlag !== void 0 ? String(filesFlag).split(",").map((value) => value.trim()).filter(Boolean) : []];
8025
8011
  if (!projectId || filePaths.length === 0) throw new Error("stage-bill-attachment requires <projectId> <filePath...> or --file/--files");
8026
8012
  await stageBillAttachmentsFromPaths(projectId, filePaths);
8027
8013
  }, "commandStageBillAttachment"), commandCleanupStagedBillAttachments = __name2(async ({ flags, positional }) => {
8028
- const projectId = positional[0], keys = parseCommaSeparatedIds(getFlag(flags, "keys"));
8014
+ const projectId = positional[0], keys = parseCommaSeparatedIds(getFlag(
8015
+ flags,
8016
+ "keys"
8017
+ ));
8029
8018
  if (!projectId || !keys) throw new Error("cleanup-staged-bill-attachments requires <projectId> --keys <csv>");
8030
8019
  await cleanupStagedBillAttachments(projectId, keys);
8031
- }, "commandCleanupStagedBillAttachments"), commandUploadBillAttachment = __name2(async ({ cmd, flags, positional }) => {
8032
- const [billId, ...positionalFilePaths] = positional, fileFlag = getFlag(flags, "file"), filesFlag = getFlag(flags, "files"), filePaths = [...positionalFilePaths, ...fileFlag !== void 0 ? [String(fileFlag)] : [], ...filesFlag !== void 0 ? String(filesFlag).split(",").map((value) => value.trim()).filter(Boolean) : []];
8033
- if (!billId || filePaths.length === 0) throw new Error("".concat(cmd, " requires <billId> <filePath...> or --file/--files"));
8034
- const attachmentType = cmd === "attach-bill-payment-receipt" ? AttachmentType.BILL_PAYMENT_PROOF : AttachmentType.BILL, [firstFilePath] = filePaths;
8035
- filePaths.length === 1 && firstFilePath !== void 0 ? await uploadBillAttachmentFromPath(billId, firstFilePath, attachmentType) : await uploadBillAttachmentsFromPaths(billId, filePaths, attachmentType);
8036
- }, "commandUploadBillAttachment"), commandAttachBillDocuments = __name2(async ({ flags, positional }) => {
8037
- const billId = positional[0];
8038
- if (!billId) throw new Error("attach-bill-documents requires <billId>");
8039
- const getFlagAlias = __name2((...flagNames) => {
8040
- for (const flagName of flagNames) {
8041
- const value = getFlag(
8042
- flags,
8043
- flagName
8044
- );
8045
- if (value !== void 0) return value;
8046
- }
8047
- }, "getFlagAlias"), parseFilesFlag = __name2((...flagNames) => {
8048
- const raw = getFlagAlias(...flagNames);
8049
- return raw === void 0 ? [] : String(raw).split(",").map((value) => value.trim()).filter(Boolean);
8050
- }, "parseFilesFlag"), invoicePath = getFlagAlias("invoice", "invoice-file"), paymentProofPath = getFlagAlias("paymentProof", "payment-proof", "proof", "receipt"), invoicePaths = [...invoicePath !== void 0 ? [String(invoicePath)] : [], ...parseFilesFlag("invoices", "invoice-files")], paymentProofPaths = [...paymentProofPath !== void 0 ? [String(paymentProofPath)] : [], ...parseFilesFlag("paymentProofs", "payment-proofs", "proofs", "receipts")];
8051
- await uploadBillDocumentsFromPaths({ billId, invoicePaths, paymentProofPaths });
8052
- }, "commandAttachBillDocuments"), commandGetBillReview = __name2(async ({ positional }) => {
8020
+ }, "commandCleanupStagedBillAttachments"), commandUploadBillAttachment = __name2(
8021
+ async ({ cmd, flags, positional }) => {
8022
+ const [billId, ...positionalFilePaths] = positional, fileFlag = getFlag(flags, "file"), filesFlag = getFlag(flags, "files"), filePaths = [...positionalFilePaths, ...fileFlag !== void 0 ? [String(fileFlag)] : [], ...filesFlag !== void 0 ? String(filesFlag).split(",").map((value) => value.trim()).filter(Boolean) : []];
8023
+ if (!billId || filePaths.length === 0) throw new Error("".concat(cmd, " requires <billId> <filePath...> or --file/--files"));
8024
+ const attachmentType = cmd === "attach-bill-payment-receipt" ? AttachmentType.BILL_PAYMENT_PROOF : AttachmentType.BILL, [firstFilePath] = filePaths;
8025
+ filePaths.length === 1 && firstFilePath !== void 0 ? await uploadBillAttachmentFromPath(billId, firstFilePath, attachmentType) : await uploadBillAttachmentsFromPaths(billId, filePaths, attachmentType);
8026
+ },
8027
+ "commandUploadBillAttachment"
8028
+ ), commandAttachBillDocuments = __name2(
8029
+ async ({ flags, positional }) => {
8030
+ const billId = positional[0];
8031
+ if (!billId) throw new Error("attach-bill-documents requires <billId>");
8032
+ const getFlagAlias = __name2((...flagNames) => {
8033
+ for (const flagName of flagNames) {
8034
+ const value = getFlag(flags, flagName);
8035
+ if (value !== void 0) return value;
8036
+ }
8037
+ }, "getFlagAlias"), parseFilesFlag = __name2((...flagNames) => {
8038
+ const raw = getFlagAlias(...flagNames);
8039
+ return raw === void 0 ? [] : String(raw).split(",").map((value) => value.trim()).filter(Boolean);
8040
+ }, "parseFilesFlag"), invoicePath = getFlagAlias("invoice", "invoice-file"), paymentProofPath = getFlagAlias("paymentProof", "payment-proof", "proof", "receipt"), invoicePaths = [...invoicePath !== void 0 ? [String(invoicePath)] : [], ...parseFilesFlag("invoices", "invoice-files")], paymentProofPaths = [...paymentProofPath !== void 0 ? [String(paymentProofPath)] : [], ...parseFilesFlag("paymentProofs", "payment-proofs", "proofs", "receipts")];
8041
+ await uploadBillDocumentsFromPaths({ billId, invoicePaths, paymentProofPaths });
8042
+ },
8043
+ "commandAttachBillDocuments"
8044
+ ), commandGetBillReview = __name2(async ({ positional }) => {
8053
8045
  const id = positional[0];
8054
8046
  if (!id) throw new Error("bill review requires <billId>");
8055
8047
  await getBillReview(id);
@@ -8066,7 +8058,9 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8066
8058
  for (const key of ["limit", "cursor", "direction"]) rejectBareFlag(flags, key);
8067
8059
  const cursor = getFlag(flags, "cursor");
8068
8060
  if (cursor === "" || (cursor?.length ?? 0) > 8192) throw new Error("--cursor must be a non-empty opaque token of at most 8192 characters.");
8069
- const direction = parseProjectDirection(getFlag(flags, "direction"));
8061
+ const direction = parseProjectDirection(
8062
+ getFlag(flags, "direction")
8063
+ );
8070
8064
  if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
8071
8065
  await listQuotations({ ...parseQuotationFilterFlags(flags), limit: parseProjectLimit(getFlag(flags, "limit")), cursor, direction });
8072
8066
  }, "commandListQuotations"), commandCountQuotations = __name2(async ({ flags }) => {
@@ -8092,14 +8086,14 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8092
8086
  const payloadRaw = getFlag(flags, "payload");
8093
8087
  if (!payloadRaw) throw new Error("create-quotation requires --payload '<json>'");
8094
8088
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8095
- await createQuotationFromPayload(raw);
8089
+ await createQuotationFromPayload(
8090
+ raw
8091
+ );
8096
8092
  }, "commandCreateQuotation"), commandUpdateQuotation = __name2(async ({ flags }) => {
8097
8093
  const payloadRaw = getFlag(flags, "payload");
8098
8094
  if (!payloadRaw) throw new Error("update-quotation requires --payload '<json>'");
8099
8095
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8100
- await updateQuotationFromPayload(
8101
- raw
8102
- );
8096
+ await updateQuotationFromPayload(raw);
8103
8097
  }, "commandUpdateQuotation"), commandDeleteQuotation = __name2(async ({ positional }) => {
8104
8098
  const id = positional[0];
8105
8099
  if (!id) throw new Error("delete-quotation requires <quotationId>");
@@ -8116,16 +8110,13 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8116
8110
  const id = positional[0], reason = getFlag(flags, "reason");
8117
8111
  if (!id || reason === void 0) throw new Error("reject-quotation requires <quotationId> --reason <text>");
8118
8112
  await rejectQuotation(id, reason);
8119
- }, "commandRejectQuotation"), commandDownloadQuotationPdf = __name2(
8120
- async ({ positional }) => {
8121
- const id = positional[0];
8122
- if (!id) throw new Error("download-quotation-pdf requires <quotationId> [original|staff|final]");
8123
- const roleRaw = (positional[1] ?? "final").toLowerCase(), fileRole = roleRaw === "original" ? SupplierQuotationFileRole.ORIGINAL : roleRaw === "staff" ? SupplierQuotationFileRole.STAFF_SIGNED : roleRaw === "final" ? SupplierQuotationFileRole.FINAL_SIGNED : null;
8124
- if (!fileRole) throw new Error("download-quotation-pdf role must be original, staff, or final");
8125
- await downloadQuotationPdf(id, fileRole);
8126
- },
8127
- "commandDownloadQuotationPdf"
8128
- ), commandCheckCustomerInvoiceReadiness = __name2(async ({ positional }) => {
8113
+ }, "commandRejectQuotation"), commandDownloadQuotationPdf = __name2(async ({ positional }) => {
8114
+ const id = positional[0];
8115
+ if (!id) throw new Error("download-quotation-pdf requires <quotationId> [original|staff|final]");
8116
+ const roleRaw = (positional[1] ?? "final").toLowerCase(), fileRole = roleRaw === "original" ? SupplierQuotationFileRole.ORIGINAL : roleRaw === "staff" ? SupplierQuotationFileRole.STAFF_SIGNED : roleRaw === "final" ? SupplierQuotationFileRole.FINAL_SIGNED : null;
8117
+ if (!fileRole) throw new Error("download-quotation-pdf role must be original, staff, or final");
8118
+ await downloadQuotationPdf(id, fileRole);
8119
+ }, "commandDownloadQuotationPdf"), commandCheckCustomerInvoiceReadiness = __name2(async ({ positional }) => {
8129
8120
  const budgetId = positional[0];
8130
8121
  if (!budgetId) throw new Error("check-customer-invoice-readiness requires <budgetId>");
8131
8122
  await checkCustomerInvoiceReadiness(budgetId);
@@ -8142,13 +8133,12 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8142
8133
  if (!budgetId || positional.length !== 1) throw new Error("list-available-qbo-customer-invoices requires <budgetId>");
8143
8134
  await listAvailableQboCustomerInvoices(budgetId);
8144
8135
  }, "commandListAvailableQboCustomerInvoices"), customerInvoiceFiltersFromFlags = __name2((flags, positionalBudgetId) => {
8145
- const projectId = getFlag(
8146
- flags,
8147
- "projectId"
8148
- ), projectIds = parseCommaSeparatedIds(getFlag(flags, "projectIds"));
8136
+ const projectId = getFlag(flags, "projectId"), projectIds = parseCommaSeparatedIds(getFlag(flags, "projectIds"));
8149
8137
  if (projectId && projectIds) throw new Error("Use either --projectId for project scope or --projectIds for a global filter, not both.");
8150
8138
  const budgetIds = [...positionalBudgetId ? [positionalBudgetId] : [], ...parseCommaSeparatedIds(getFlag(flags, "budgetIds")) ?? []], statusRaw = getFlag(flags, "status");
8151
- return { scope: projectId ? { type: "project", projectId } : { type: "global" }, q: getFlag(flags, "search") ?? "", statuses: parseCommaSeparatedCustomerInvoiceStatuses(statusRaw !== void 0 ? String(statusRaw) : void 0), companyIds: parseCommaSeparatedIds(getFlag(flags, "companyIds")), projectIds, budgetIds: budgetIds.length > 0 ? [...new Set(budgetIds)] : void 0, createdByIds: parseCommaSeparatedIds(getFlag(flags, "createdByIds")) };
8139
+ return { scope: projectId ? { type: "project", projectId } : { type: "global" }, q: getFlag(flags, "search") ?? "", statuses: parseCommaSeparatedCustomerInvoiceStatuses(statusRaw !== void 0 ? String(statusRaw) : void 0), companyIds: parseCommaSeparatedIds(getFlag(flags, "companyIds")), projectIds, budgetIds: budgetIds.length > 0 ? [...new Set(budgetIds)] : void 0, createdByIds: parseCommaSeparatedIds(
8140
+ getFlag(flags, "createdByIds")
8141
+ ) };
8152
8142
  }, "customerInvoiceFiltersFromFlags"), commandListCustomerInvoices = __name2(async ({ cmd, flags, positional }) => {
8153
8143
  const filters = customerInvoiceFiltersFromFlags(flags, positional[0]);
8154
8144
  if (rejectRetiredPageFlags(flags), cmd === "count-customer-invoices") {
@@ -8162,7 +8152,9 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8162
8152
  const batchId = positional[0];
8163
8153
  if (!batchId) throw new Error("get-customer-invoice requires <batchId>");
8164
8154
  await getCustomerInvoice(batchId);
8165
- }, "commandGetCustomerInvoice"), commandGetCustomerInvoiceInvoices = __name2(async ({ positional }) => {
8155
+ }, "commandGetCustomerInvoice"), commandGetCustomerInvoiceInvoices = __name2(async ({
8156
+ positional
8157
+ }) => {
8166
8158
  const batchId = positional[0];
8167
8159
  if (!batchId) throw new Error("get-customer-invoice-invoices requires <batchId>");
8168
8160
  await getCustomerInvoiceInvoices(batchId);
@@ -8187,20 +8179,20 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8187
8179
  const [budgetId, qboInvoiceId] = positional;
8188
8180
  if (!budgetId?.trim() || !qboInvoiceId || positional.length !== 2) throw new Error("".concat(cmd, " requires <budgetId> <qboInvoiceId>"));
8189
8181
  if (!new __cliRegExp("^\\d+$", "").test(qboInvoiceId)) throw new Error("qboInvoiceId must be the numeric QuickBooks transaction ID, not the invoice number");
8190
- if (cmd === "preview-qbo-customer-invoice") await previewQboCustomerInvoice({ budgetId, qboInvoiceId });
8182
+ const confirmEstimateLineage = flags.confirmEstimateLineage === !0 ? !0 : parseOptionalBoolFlag(flags, "confirmEstimateLineage");
8183
+ if (cmd === "preview-qbo-customer-invoice") await previewQboCustomerInvoice(
8184
+ { budgetId, qboInvoiceId, confirmEstimateLineage }
8185
+ );
8191
8186
  else {
8192
8187
  const token = getFlag(flags, "token");
8193
8188
  if (!token || !new __cliRegExp("^[a-f0-9]{64}$", "").test(token)) throw new Error("import-qbo-customer-invoice requires --token <64-character preview token> from a reviewed preview-qbo result");
8194
- await importQboCustomerInvoice({ budgetId, qboInvoiceId, token });
8189
+ await importQboCustomerInvoice({ budgetId, qboInvoiceId, token, confirmEstimateLineage });
8195
8190
  }
8196
- }, "commandPreviewQboCustomerInvoice"), commandCreateCustomerInvoice = __name2(
8197
- async ({ flags }) => {
8198
- const payloadRaw = getFlag(flags, "payload");
8199
- if (!payloadRaw) throw new Error("create-customer-invoice requires --payload '<json>'");
8200
- await createCustomerInvoice(parseJsonFlag(String(payloadRaw), "--payload"));
8201
- },
8202
- "commandCreateCustomerInvoice"
8203
- ), commandResubmitCustomerInvoice = __name2(async ({ positional }) => {
8191
+ }, "commandPreviewQboCustomerInvoice"), commandCreateCustomerInvoice = __name2(async ({ flags }) => {
8192
+ const payloadRaw = getFlag(flags, "payload");
8193
+ if (!payloadRaw) throw new Error("create-customer-invoice requires --payload '<json>'");
8194
+ await createCustomerInvoice(parseJsonFlag(String(payloadRaw), "--payload"));
8195
+ }, "commandCreateCustomerInvoice"), commandResubmitCustomerInvoice = __name2(async ({ positional }) => {
8204
8196
  const batchId = positional[0];
8205
8197
  if (!batchId) throw new Error("resubmit-customer-invoice requires <batchId>");
8206
8198
  await resubmitCustomerInvoice(batchId);
@@ -8212,9 +8204,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8212
8204
  const batchId = positional[0];
8213
8205
  if (!batchId) throw new Error("delete-customer-invoice requires <batchId>");
8214
8206
  await deleteCustomerInvoice(batchId);
8215
- }, "commandDeleteCustomerInvoice"), commandVoidCustomerInvoice = __name2(async ({
8216
- positional
8217
- }) => {
8207
+ }, "commandDeleteCustomerInvoice"), commandVoidCustomerInvoice = __name2(async ({ positional }) => {
8218
8208
  const batchId = positional[0];
8219
8209
  if (!batchId) throw new Error("void-customer-invoice requires <batchId>");
8220
8210
  await voidCustomerInvoice(batchId);
@@ -8224,15 +8214,14 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8224
8214
  await approveCustomerInvoice(batchId);
8225
8215
  }, "commandApproveCustomerInvoice"), commandRejectCustomerInvoice = __name2(async ({ flags, positional }) => {
8226
8216
  const batchId = positional[0], reason = getFlag(flags, "reason");
8227
- if (!batchId || reason === void 0) throw new Error("reject-customer-invoice requires <batchId> --reason <text>");
8217
+ if (!batchId || reason === void 0) throw new Error(
8218
+ "reject-customer-invoice requires <batchId> --reason <text>"
8219
+ );
8228
8220
  await rejectCustomerInvoice(batchId, String(reason));
8229
8221
  }, "commandRejectCustomerInvoice"), commandSendCustomerInvoiceToContactPerson = __name2(async ({ flags }) => {
8230
8222
  const payloadRaw = getFlag(flags, "payload");
8231
8223
  if (!payloadRaw) throw new Error("send-customer-invoice-to-contact-person requires --payload '<json>'");
8232
- await sendCustomerInvoiceToContactPersonFromPayload(parseJsonFlag(
8233
- String(payloadRaw),
8234
- "--payload"
8235
- ));
8224
+ await sendCustomerInvoiceToContactPersonFromPayload(parseJsonFlag(String(payloadRaw), "--payload"));
8236
8225
  }, "commandSendCustomerInvoiceToContactPerson"), commandDownloadCustomerInvoicePdf = __name2(async ({ flags, positional }) => {
8237
8226
  const invoiceId = positional[0];
8238
8227
  if (!invoiceId) throw new Error("download-customer-invoice-pdf requires <invoiceId> [--output <path>]");
@@ -8241,12 +8230,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8241
8230
  const invoiceId = positional[0], billingAddress = getFlag(flags, "billingAddress"), customerMemo = getFlag(flags, "customerMemo");
8242
8231
  if (!invoiceId || typeof billingAddress != "string" || typeof customerMemo != "string") throw new Error("update-customer-invoice-details requires <invoiceId> --billingAddress <text> --customerMemo <text> (send both; use \\n for address lines). The bill email is managed in QuickBooks.");
8243
8232
  const requestId = getFlag(flags, "requestId");
8244
- await updateCustomerInvoiceDetails({
8245
- billingAddress: billingAddress.replaceAll("\\n", "\n"),
8246
- customerMemo,
8247
- invoiceId,
8248
- ...typeof requestId == "string" ? { requestId } : {}
8249
- });
8233
+ await updateCustomerInvoiceDetails({ billingAddress: billingAddress.replaceAll("\\n", "\n"), customerMemo, invoiceId, ...typeof requestId == "string" ? { requestId } : {} });
8250
8234
  }, "commandUpdateCustomerInvoiceDetails"), commandUpdateCustomerInvoiceQboDrift = __name2(async ({ flags, positional }) => {
8251
8235
  const invoiceId = positional[0], resolution = getFlag(flags, "resolution");
8252
8236
  if (!invoiceId || resolution !== "ACCEPT_QBO" && resolution !== "KEEP_BB") throw new Error("update-customer-invoice-qbo-drift requires <invoiceId> --resolution ACCEPT_QBO|KEEP_BB");
@@ -8255,12 +8239,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8255
8239
  }, "commandUpdateCustomerInvoiceQboDrift"), commandMarkCustomerInvoiceSentExternally = __name2(async ({ flags, positional }) => {
8256
8240
  const invoiceId = positional[0], sentAt = getFlag(flags, "sentAt"), recipients = getFlag(flags, "recipients");
8257
8241
  if (!invoiceId || !sentAt || !recipients) throw new Error("mark-customer-invoice-sent-externally requires <invoiceId> --sentAt <ISO datetime> --recipients a@x.com,b@y.com [--note <text>]");
8258
- await markCustomerInvoiceSentExternally({
8259
- invoiceId,
8260
- sentAt,
8261
- recipients: recipients.split(",").map((recipient) => recipient.trim()).filter(Boolean),
8262
- note: getFlag(flags, "note")
8263
- });
8242
+ await markCustomerInvoiceSentExternally({ invoiceId, sentAt, recipients: recipients.split(",").map((recipient) => recipient.trim()).filter(Boolean), note: getFlag(flags, "note") });
8264
8243
  }, "commandMarkCustomerInvoiceSentExternally"), commandSyncCustomerInvoice = __name2(async ({ positional }) => {
8265
8244
  const invoiceId = positional[0];
8266
8245
  if (!invoiceId) throw new Error("sync-customer-invoice requires <invoiceId>");
@@ -8282,7 +8261,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8282
8261
  const id = positional[0];
8283
8262
  if (!id) throw new Error("approve-budget requires <budgetId>");
8284
8263
  await approveBudget(id);
8285
- }, "commandApproveBudget"), commandRejectBudget = __name2(async ({ flags, positional }) => {
8264
+ }, "commandApproveBudget"), commandRejectBudget = __name2(async ({
8265
+ flags,
8266
+ positional
8267
+ }) => {
8286
8268
  const id = positional[0], reason = getFlag(flags, "reason");
8287
8269
  if (!id || reason === void 0) throw new Error("reject-budget requires <budgetId> --reason <text>");
8288
8270
  await rejectBudget(id, reason);
@@ -8290,14 +8272,11 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8290
8272
  const id = positional[0];
8291
8273
  if (!id) throw new Error("approve-supplier requires <supplierId>");
8292
8274
  await approveSupplier(id);
8293
- }, "commandApproveSupplier"), commandRejectSupplier = __name2(
8294
- async ({ flags, positional }) => {
8295
- const id = positional[0], reason = getFlag(flags, "reason");
8296
- if (!id || reason === void 0) throw new Error("reject-supplier requires <supplierId> --reason <text>");
8297
- await rejectSupplier(id, reason);
8298
- },
8299
- "commandRejectSupplier"
8300
- ), commandGetSupplierDetails = __name2(async ({ positional }) => {
8275
+ }, "commandApproveSupplier"), commandRejectSupplier = __name2(async ({ flags, positional }) => {
8276
+ const id = positional[0], reason = getFlag(flags, "reason");
8277
+ if (!id || reason === void 0) throw new Error("reject-supplier requires <supplierId> --reason <text>");
8278
+ await rejectSupplier(id, reason);
8279
+ }, "commandRejectSupplier"), commandGetSupplierDetails = __name2(async ({ positional }) => {
8301
8280
  const id = positional[0];
8302
8281
  if (!id) throw new Error("get-supplier-details requires <supplierId>");
8303
8282
  await getSupplierDetails(id);
@@ -8312,9 +8291,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8312
8291
  }, "commandGetSupplierUsage"), commandGetSupplierItems = __name2(async ({ positional }) => {
8313
8292
  const id = positional[0];
8314
8293
  if (!id) throw new Error("get-supplier-items requires <supplierId>");
8315
- await getSupplierItems(
8316
- id
8317
- );
8294
+ await getSupplierItems(id);
8318
8295
  }, "commandGetSupplierItems"), commandListCompanies = __name2(async ({ flags }) => {
8319
8296
  await listCompanies(parseCompanyListFlags(flags));
8320
8297
  }, "commandListCompanies"), commandCountCompanies = __name2(async ({ flags }) => {
@@ -8325,7 +8302,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8325
8302
  await getCompany(id);
8326
8303
  }, "commandGetCompany"), commandCreateCompany = __name2(async ({ flags }) => {
8327
8304
  rejectBareFlag(flags, "billingEmails");
8328
- const billingEmailsRaw = getFlag(flags, "billingEmails"), billingEmails = billingEmailsRaw === void 0 ? void 0 : parseCompanyBillingEmails(parseJsonFlag(billingEmailsRaw, "--billingEmails")), name = getFlag(flags, "name"), website = getFlag(flags, "website");
8305
+ const billingEmailsRaw = getFlag(
8306
+ flags,
8307
+ "billingEmails"
8308
+ ), billingEmails = billingEmailsRaw === void 0 ? void 0 : parseCompanyBillingEmails(parseJsonFlag(billingEmailsRaw, "--billingEmails")), name = getFlag(flags, "name"), website = getFlag(flags, "website");
8329
8309
  if (!name || !website) throw new Error("create-company requires --name and --website <url>");
8330
8310
  await createCompany({ name, website, ...billingEmails === void 0 ? {} : { billingEmails }, confirmDistinct: parseOptionalBoolFlag(flags, "confirmDistinct") });
8331
8311
  }, "commandCreateCompany"), commandSearchExistingCompanies = __name2(async ({ flags }) => {
@@ -8341,14 +8321,14 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8341
8321
  }, "commandSearchExistingCompanies"), commandUseExistingCompany = __name2(async ({ flags }) => {
8342
8322
  const companyId = getFlag(flags, "companyId"), quickbooksId = getFlag(flags, "quickbooksId");
8343
8323
  if (!companyId && !quickbooksId) throw new Error("Supply --companyId and/or --quickbooksId");
8344
- companyId ? await reuseExistingCompany(
8345
- { source: "bb", companyId, quickbooksId, confirmDistinct: parseOptionalBoolFlag(flags, "confirmDistinct") }
8346
- ) : quickbooksId && await reuseExistingCompany({ source: "qbo", quickbooksId, name: getFlag(flags, "name"), website: getFlag(flags, "website"), confirmDistinct: parseOptionalBoolFlag(flags, "confirmDistinct") });
8324
+ companyId ? await reuseExistingCompany({ source: "bb", companyId, quickbooksId, confirmDistinct: parseOptionalBoolFlag(flags, "confirmDistinct") }) : quickbooksId && await reuseExistingCompany({ source: "qbo", quickbooksId, name: getFlag(flags, "name"), website: getFlag(flags, "website"), confirmDistinct: parseOptionalBoolFlag(flags, "confirmDistinct") });
8347
8325
  }, "commandUseExistingCompany"), commandUpdateCompany = __name2(async ({ flags }) => {
8348
8326
  const payloadRaw = getFlag(flags, "payload");
8349
8327
  if (!payloadRaw) throw new Error("update-company requires --payload '<json>'");
8350
8328
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8351
- await updateCompanyFromPayload(raw);
8329
+ await updateCompanyFromPayload(
8330
+ raw
8331
+ );
8352
8332
  }, "commandUpdateCompany"), commandGetCompanyQuickbooksSyncStatus = __name2(async ({ positional }) => {
8353
8333
  const id = positional[0];
8354
8334
  if (!id) throw new Error("get-company-quickbooks-sync-status requires <companyId>");
@@ -8356,9 +8336,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8356
8336
  }, "commandGetCompanyQuickbooksSyncStatus"), commandDeleteCompany = __name2(async ({ positional }) => {
8357
8337
  const id = positional[0];
8358
8338
  if (!id) throw new Error("delete-company requires <id>");
8359
- await deleteCompanyById(
8360
- id
8361
- );
8339
+ await deleteCompanyById(id);
8362
8340
  }, "commandDeleteCompany"), commandListProjects = __name2(async ({ flags }) => {
8363
8341
  await listProjects(parseProjectListFlags(flags));
8364
8342
  }, "commandListProjects"), commandCountProjects = __name2(async ({ flags }) => {
@@ -8374,48 +8352,49 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8374
8352
  for (const key of ["limit", "cursor", "direction", "sortBy", "sortDir"]) rejectBareFlag(flags, key);
8375
8353
  const cursor = getFlag(flags, "cursor");
8376
8354
  if (cursor === "" || (cursor?.length ?? 0) > 8192) throw new Error("--cursor must be a non-empty opaque token of at most 8192 characters.");
8377
- const direction = parseProjectDirection(
8378
- getFlag(flags, "direction")
8379
- );
8355
+ const direction = parseProjectDirection(getFlag(flags, "direction"));
8380
8356
  if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
8381
8357
  await listProjectHubs({ ...filters, limit: parseProjectLimit(getFlag(flags, "limit")), cursor, direction, sortBy: parseOptionalProjectHubSortBy(getFlag(flags, "sortBy")), sortDir: parseOptionalBillListSortDir(getFlag(flags, "sortDir")) });
8382
8358
  }, "commandListProjectHubs"), commandGetProject = __name2(async ({ positional }) => {
8383
8359
  const id = positional[0];
8384
8360
  if (!id) throw new Error("get-project requires <id>");
8385
8361
  await getProject(id);
8386
- }, "commandGetProject"), commandGetProjectHubStatus = __name2(async ({ positional }) => {
8387
- const projectId = positional[0];
8388
- if (!projectId) throw new Error("get-project-hub-status requires <projectId>");
8389
- await getProjectHubStatus(projectId);
8390
- }, "commandGetProjectHubStatus"), commandSetupProjectHub = __name2(async ({ positional }) => {
8362
+ }, "commandGetProject"), commandGetProjectHubStatus = __name2(
8363
+ async ({ positional }) => {
8364
+ const projectId = positional[0];
8365
+ if (!projectId) throw new Error("get-project-hub-status requires <projectId>");
8366
+ await getProjectHubStatus(projectId);
8367
+ },
8368
+ "commandGetProjectHubStatus"
8369
+ ), commandSetupProjectHub = __name2(async ({ positional }) => {
8391
8370
  const projectId = positional[0];
8392
8371
  if (!projectId) throw new Error("setup-project-hub requires <projectId>");
8393
8372
  await setupProjectHub(projectId);
8394
- }, "commandSetupProjectHub"), commandSyncProjectHubCommercialDocuments = __name2(
8395
- async ({ positional }) => {
8396
- const projectId = positional[0];
8397
- if (!projectId) throw new Error("sync-project-hub-commercial-documents requires <projectId>");
8398
- await syncProjectHubCommercialDocuments(projectId);
8373
+ }, "commandSetupProjectHub"), commandSyncProjectHubCommercialDocuments = __name2(async ({ positional }) => {
8374
+ const projectId = positional[0];
8375
+ if (!projectId) throw new Error("sync-project-hub-commercial-documents requires <projectId>");
8376
+ await syncProjectHubCommercialDocuments(projectId);
8377
+ }, "commandSyncProjectHubCommercialDocuments"), commandCreateProject = __name2(
8378
+ async ({ flags }) => {
8379
+ const name = getFlag(flags, "name"), companyId = getFlag(flags, "companyId"), contactPersonId = getFlag(flags, "contactPersonId"), insideSalesId = getFlag(flags, "insideSalesId"), businessDevelopmentId = getFlag(flags, "businessDevelopmentId"), projectManagerId = getFlag(
8380
+ flags,
8381
+ "projectManagerId"
8382
+ ), venue = getFlag(flags, "venue"), pax = getFlag(flags, "pax"), asanaTaskId = getFlag(flags, "asanaTaskId"), asanaSearch = getFlag(flags, "asanaSearch"), startDate = getFlag(flags, "startDate");
8383
+ if (getFlag(flags, "requestQboAccountantNotification") !== void 0) throw new Error("create-project does not allow --requestQboAccountantNotification; CLI project creation always requests the QuickBooks project import like the web app.");
8384
+ if (!name || !companyId || !contactPersonId || !insideSalesId || !businessDevelopmentId || !venue || !startDate) throw new Error("create-project requires --name --companyId --contactPersonId --insideSalesId --businessDevelopmentId --venue --startDate (ISO/datetime flags as appropriate); optional --projectManagerId, --asanaTaskId, --asanaSearch, --pax and --endDate");
8385
+ await createProject({ name, companyId, contactPersonId, insideSalesId, businessDevelopmentId, projectManagerId, venue, pax, asanaTaskId, asanaSearch, startDate, endDate: getFlag(flags, "endDate"), description: getFlag(flags, "description") });
8399
8386
  },
8400
- "commandSyncProjectHubCommercialDocuments"
8401
- ), commandCreateProject = __name2(async ({ flags }) => {
8402
- const name = getFlag(flags, "name"), companyId = getFlag(flags, "companyId"), contactPersonId = getFlag(flags, "contactPersonId"), insideSalesId = getFlag(flags, "insideSalesId"), businessDevelopmentId = getFlag(flags, "businessDevelopmentId"), projectManagerId = getFlag(flags, "projectManagerId"), venue = getFlag(flags, "venue"), pax = getFlag(flags, "pax"), asanaTaskId = getFlag(flags, "asanaTaskId"), asanaSearch = getFlag(flags, "asanaSearch"), startDate = getFlag(flags, "startDate");
8403
- if (getFlag(flags, "requestQboAccountantNotification") !== void 0) throw new Error("create-project does not allow --requestQboAccountantNotification; CLI project creation always requests the QuickBooks project import like the web app.");
8404
- if (!name || !companyId || !contactPersonId || !insideSalesId || !businessDevelopmentId || !venue || !startDate) throw new Error("create-project requires --name --companyId --contactPersonId --insideSalesId --businessDevelopmentId --venue --startDate (ISO/datetime flags as appropriate); optional --projectManagerId, --asanaTaskId, --asanaSearch, --pax and --endDate");
8405
- await createProject({ name, companyId, contactPersonId, insideSalesId, businessDevelopmentId, projectManagerId, venue, pax, asanaTaskId, asanaSearch, startDate, endDate: getFlag(flags, "endDate"), description: getFlag(flags, "description") });
8406
- }, "commandCreateProject"), commandUpdateProject = __name2(async ({ flags }) => {
8387
+ "commandCreateProject"
8388
+ ), commandUpdateProject = __name2(async ({ flags }) => {
8407
8389
  const payloadRaw = getFlag(flags, "payload");
8408
8390
  if (!payloadRaw) throw new Error("update-project requires --payload '<json>'");
8409
8391
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8410
8392
  await updateProjectFromPayload(raw);
8411
- }, "commandUpdateProject"), commandDeleteProject = __name2(
8412
- async ({ positional }) => {
8413
- const id = positional[0];
8414
- if (!id) throw new Error("delete-project requires <id>");
8415
- await deleteProjectById(id);
8416
- },
8417
- "commandDeleteProject"
8418
- ), commandCheckProjectReconciliation = __name2(async ({ positional }) => {
8393
+ }, "commandUpdateProject"), commandDeleteProject = __name2(async ({ positional }) => {
8394
+ const id = positional[0];
8395
+ if (!id) throw new Error("delete-project requires <id>");
8396
+ await deleteProjectById(id);
8397
+ }, "commandDeleteProject"), commandCheckProjectReconciliation = __name2(async ({ positional }) => {
8419
8398
  const id = positional[0];
8420
8399
  if (!id) throw new Error("check-project-reconciliation requires <id>");
8421
8400
  await checkProjectReconciliation(id);
@@ -8425,16 +8404,15 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8425
8404
  await reconcileProject(id);
8426
8405
  }, "commandReconcileProject"), commandCompleteProject = __name2(async ({ positional }) => {
8427
8406
  const id = positional[0];
8428
- if (!id) throw new Error("complete-project requires <id>");
8407
+ if (!id) throw new Error(
8408
+ "complete-project requires <id>"
8409
+ );
8429
8410
  await completeProject(id);
8430
8411
  }, "commandCompleteProject"), commandImportQboProject = __name2(async ({ flags, positional }) => {
8431
8412
  const projectId = positional[0], projectUrl = getFlag(flags, "url");
8432
8413
  if (!projectId || projectUrl === void 0) throw new Error("import-qbo-project requires <projectId> --url <quickBooksProjectUrl>");
8433
8414
  await importQuickBooksProjectId(projectId, String(projectUrl));
8434
- }, "commandImportQboProject"), commandUpdateProjectStatus = __name2(async ({
8435
- flags,
8436
- positional
8437
- }) => {
8415
+ }, "commandImportQboProject"), commandUpdateProjectStatus = __name2(async ({ flags, positional }) => {
8438
8416
  const [id, statusRaw] = positional;
8439
8417
  if (!id || !statusRaw) throw new Error("update-project-status requires <id> <status>");
8440
8418
  const pmIdFlag = getFlag(flags, "projectManagerId"), pmEmailFlag = getFlag(flags, "projectManagerEmail");
@@ -8449,10 +8427,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8449
8427
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8450
8428
  await createContactPersonFromPayload(raw);
8451
8429
  }, "commandCreateContactPerson"), commandUpdateContactPerson = __name2(async ({ flags }) => {
8452
- const payloadRaw = getFlag(
8453
- flags,
8454
- "payload"
8455
- );
8430
+ const payloadRaw = getFlag(flags, "payload");
8456
8431
  if (!payloadRaw) throw new Error("update-contact-person requires --payload '<json>'");
8457
8432
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8458
8433
  await updateContactPersonFromPayload(raw);
@@ -8461,7 +8436,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8461
8436
  }, "commandCountSuppliers"), commandListSuppliers = __name2(async ({ flags }) => {
8462
8437
  await listSuppliers(parseListSuppliersFlags(flags));
8463
8438
  }, "commandListSuppliers"), commandCreateSupplier = __name2(async ({ flags }) => {
8464
- const payloadRaw = getFlag(flags, "payload");
8439
+ const payloadRaw = getFlag(
8440
+ flags,
8441
+ "payload"
8442
+ );
8465
8443
  if (!payloadRaw) throw new Error("create-supplier requires --payload '<json>'");
8466
8444
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8467
8445
  await createSupplierFromPayload(raw);
@@ -8469,9 +8447,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8469
8447
  const payloadRaw = getFlag(flags, "payload");
8470
8448
  if (!payloadRaw) throw new Error("update-supplier requires --payload '<json>'");
8471
8449
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8472
- await updateSupplierFromPayload(
8473
- raw
8474
- );
8450
+ await updateSupplierFromPayload(raw);
8475
8451
  }, "commandUpdateSupplier"), commandDeleteSuppliers = __name2(async ({ flags }) => {
8476
8452
  const idsRaw = getFlag(flags, "ids");
8477
8453
  if (idsRaw === void 0) throw new Error("delete-suppliers requires --ids <csv>");
@@ -8488,9 +8464,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8488
8464
  const name = getFlag(flags, "name");
8489
8465
  if (!name) throw new Error("create-certification requires --name");
8490
8466
  await createSupplierCertification(String(name));
8491
- }, "commandCreateCertification"), commandCreatePaymentMethod = __name2(async ({
8492
- flags
8493
- }) => {
8467
+ }, "commandCreateCertification"), commandCreatePaymentMethod = __name2(async ({ flags }) => {
8494
8468
  const name = getFlag(flags, "name");
8495
8469
  if (!name) throw new Error("create-payment-method requires --name");
8496
8470
  await createSupplierPaymentMethod(String(name));
@@ -8544,10 +8518,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8544
8518
  if (!id) throw new Error("get-item-quickbooks-sync-status requires <itemId>");
8545
8519
  await getItemQuickBooksSyncStatus(id);
8546
8520
  }, "commandGetItemQuickbooksSyncStatus"), commandCreateItem = __name2(async ({ flags }) => {
8547
- const payloadRaw = getFlag(
8548
- flags,
8549
- "payload"
8550
- );
8521
+ const payloadRaw = getFlag(flags, "payload");
8551
8522
  if (!payloadRaw) throw new Error("create-item requires --payload '<json>'");
8552
8523
  const raw = parseJsonFlag(String(payloadRaw), "--payload");
8553
8524
  await createItemFromPayload(raw);
@@ -8566,10 +8537,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8566
8537
  const ids = parseCommaSeparatedIds(String(idsRaw));
8567
8538
  if (!ids?.length) throw new Error("archive-items requires non-empty --ids");
8568
8539
  await archiveItemsByIds(ids);
8569
- }, "commandArchiveItems"), commandListItemCategories = __name2(async ({
8570
- cmd,
8571
- flags
8572
- }) => {
8540
+ }, "commandArchiveItems"), commandListItemCategories = __name2(async ({ cmd, flags }) => {
8573
8541
  rejectRetiredPageFlags(flags);
8574
8542
  const filters = { name: getFlag(flags, "name") };
8575
8543
  if (cmd === "count-item-categories") {
@@ -8579,17 +8547,16 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8579
8547
  rejectBarePagingFlags(flags);
8580
8548
  const { cursor, direction } = parseCursorAndDirection(flags), sortByRaw = getFlag(flags, "sortBy"), sortBy = ITEM_CATEGORY_SORT_IDS.find((id) => id === sortByRaw);
8581
8549
  if (sortByRaw !== void 0 && !sortBy) throw new Error('Invalid --sortBy "'.concat(sortByRaw, '". Use one of: ').concat(ITEM_CATEGORY_SORT_IDS.join(", "), "."));
8582
- const sortDir = parseAscDescSortDir(flags);
8550
+ const sortDir = parseAscDescSortDir(
8551
+ flags
8552
+ );
8583
8553
  await listItemCategories({ ...filters, limit: parseProjectLimit(getFlag(flags, "limit")), cursor, direction, sortBy, sortDir });
8584
8554
  }, "commandListItemCategories"), commandCreateItemCategory = __name2(async ({ flags }) => {
8585
8555
  const name = getFlag(flags, "name");
8586
8556
  if (!name) throw new Error("create-item-category requires --name");
8587
8557
  await createItemCategory(String(name));
8588
8558
  }, "commandCreateItemCategory"), commandUpdateItemCategory = __name2(async ({ flags }) => {
8589
- const id = getFlag(
8590
- flags,
8591
- "id"
8592
- ), name = getFlag(flags, "name");
8559
+ const id = getFlag(flags, "id"), name = getFlag(flags, "name");
8593
8560
  if (!id || !name) throw new Error("update-item-category requires --id and --name");
8594
8561
  await updateItemCategory({ id: String(id), name: String(name) });
8595
8562
  }, "commandUpdateItemCategory"), commandDeleteItemCategories = __name2(async ({ flags }) => {
@@ -8620,9 +8587,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8620
8587
  }, "commandCreateUser"), commandCreateApiKey = __name2(async ({ flags }) => {
8621
8588
  const userId = getFlag(flags, "userId"), name = getFlag(flags, "name");
8622
8589
  if (!name) throw new Error("create-api-key requires --name <label> [--userId <userId>]");
8623
- await createApiKeyForUser(
8624
- { userId, name }
8625
- );
8590
+ await createApiKeyForUser({ userId, name });
8626
8591
  }, "commandCreateApiKey"), commandListApiKeys = __name2(async ({ flags }) => {
8627
8592
  rejectRetiredPageFlags(flags);
8628
8593
  for (const key of ["limit", "cursor"]) rejectBareFlag(flags, key);
@@ -8647,14 +8612,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8647
8612
  }, "commandGetSystemOverview"), commandGetEstimatePerformance = __name2(async ({ flags }) => {
8648
8613
  await getEstimatePerformance(parseDashboardQueryFlags(flags));
8649
8614
  }, "commandGetEstimatePerformance"), commandGetFinancialOverview = __name2(async ({ flags }) => {
8650
- await getFinancialOverview({
8651
- userId: getFlag(flags, "userId"),
8652
- role: parseOptionalFinancialRole(getFlag(flags, "role")),
8653
- deals: parseOptionalDeals(getFlag(flags, "deals")),
8654
- timeFrame: parseOptionalTimeFrame(getFlag(flags, "timeFrame")),
8655
- startDate: getFlag(flags, "startDate"),
8656
- endDate: getFlag(flags, "endDate")
8657
- });
8615
+ await getFinancialOverview({ userId: getFlag(flags, "userId"), role: parseOptionalFinancialRole(getFlag(flags, "role")), deals: parseOptionalDeals(getFlag(flags, "deals")), timeFrame: parseOptionalTimeFrame(getFlag(flags, "timeFrame")), startDate: getFlag(flags, "startDate"), endDate: getFlag(flags, "endDate") });
8658
8616
  }, "commandGetFinancialOverview"), commandGetRecentErrors = __name2(async ({ cmd, flags }) => {
8659
8617
  if (getFlag(flags, "page") !== void 0 || getFlag(flags, "perPage") !== void 0) throw new Error("Error logs now use --cursor and --limit; --page/--perPage are no longer supported.");
8660
8618
  const rawTimeFrame = getFlag(flags, "timeFrame"), timeFrame = Object.values(ChartTimeFrame).find((value) => value === rawTimeFrame);
@@ -8664,10 +8622,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8664
8622
  else {
8665
8623
  const direction = getFlag(flags, "direction");
8666
8624
  if (direction !== void 0 && direction !== "forward" && direction !== "backward") throw new Error("--direction must be forward or backward.");
8667
- await getRecentErrors({ ...filters, cursor: getFlag(flags, "cursor"), limit: parsePositiveIntFlag(
8668
- getFlag(flags, "limit"),
8669
- "--limit"
8670
- ), direction });
8625
+ await getRecentErrors({ ...filters, cursor: getFlag(flags, "cursor"), limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit"), direction });
8671
8626
  }
8672
8627
  }, "commandGetRecentErrors"), commandGetError = __name2(async ({ positional }) => {
8673
8628
  const id = positional[0];
@@ -8677,7 +8632,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8677
8632
  await getErrorMetrics();
8678
8633
  }, "commandGetErrorMetrics"), commandListIntegrationOperations = __name2(async ({ cmd, flags }) => {
8679
8634
  rejectRetiredPageFlags(flags);
8680
- const filters = { destination: parseCommaSeparatedIds(getFlag(flags, "destination")), search: getFlag(flags, "search"), status: parseCommaSeparatedIntegrationOperationStatuses(getFlag(flags, "status")) };
8635
+ const filters = { destination: parseCommaSeparatedIds(getFlag(flags, "destination")), search: getFlag(
8636
+ flags,
8637
+ "search"
8638
+ ), status: parseCommaSeparatedIntegrationOperationStatuses(getFlag(flags, "status")) };
8681
8639
  if (cmd === "count-integration-operations") {
8682
8640
  for (const key of ["limit", "cursor", "direction"]) if (flags[key] !== void 0) throw new Error("count-integration-operations does not accept --".concat(key, "; it takes filter flags only."));
8683
8641
  await countIntegrationOperations(filters);
@@ -8690,11 +8648,14 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8690
8648
  if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
8691
8649
  const limitRaw = getFlag(flags, "limit");
8692
8650
  await listIntegrationOperations({ ...filters, limit: limitRaw === void 0 ? 25 : parseProjectLimit(limitRaw), cursor, direction });
8693
- }, "commandListIntegrationOperations"), commandGetIntegrationOperation = __name2(async ({ positional }) => {
8694
- const operationId = positional[0];
8695
- if (!operationId) throw new Error("get-integration-operation requires <operationId>");
8696
- await getIntegrationOperation(operationId);
8697
- }, "commandGetIntegrationOperation"), commandRetryIntegrationOperation = __name2(async ({ flags, positional }) => {
8651
+ }, "commandListIntegrationOperations"), commandGetIntegrationOperation = __name2(
8652
+ async ({ positional }) => {
8653
+ const operationId = positional[0];
8654
+ if (!operationId) throw new Error("get-integration-operation requires <operationId>");
8655
+ await getIntegrationOperation(operationId);
8656
+ },
8657
+ "commandGetIntegrationOperation"
8658
+ ), commandRetryIntegrationOperation = __name2(async ({ flags, positional }) => {
8698
8659
  const operationId = positional[0];
8699
8660
  if (!operationId) throw new Error("retry-integration-operation requires <operationId>");
8700
8661
  const outboundEmailResolution = getFlag(flags, "outboundEmailResolution");
@@ -8702,17 +8663,18 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8702
8663
  await retryIntegrationOperation(operationId, parseOptionalBoolFlag(flags, "confirmExternalStateReconciled") ?? !1, outboundEmailResolution, getFlag(flags, "providerMessageId"));
8703
8664
  }, "commandRetryIntegrationOperation"), commandListWebhookEventTypes = __name2(async () => {
8704
8665
  await listWebhookEventTypes();
8705
- }, "commandListWebhookEventTypes"), commandListWebhookEndpoints = __name2(async () => {
8706
- await listWebhookEndpoints();
8707
- }, "commandListWebhookEndpoints"), commandGetWebhookEndpoint = __name2(async ({ positional }) => {
8666
+ }, "commandListWebhookEventTypes"), commandListWebhookEndpoints = __name2(
8667
+ async () => {
8668
+ await listWebhookEndpoints();
8669
+ },
8670
+ "commandListWebhookEndpoints"
8671
+ ), commandGetWebhookEndpoint = __name2(async ({ positional }) => {
8708
8672
  const id = positional[0];
8709
8673
  if (!id) throw new Error("get-webhook-endpoint requires <id>");
8710
8674
  await getWebhookEndpoint(id);
8711
8675
  }, "commandGetWebhookEndpoint"), commandCreateWebhookEndpoint = __name2(async ({ flags }) => {
8712
8676
  const name = getFlag(flags, "name"), url = getFlag(flags, "url"), events = parseCommaSeparatedIds(getFlag(flags, "events"));
8713
- if (!name || !url || !events?.length) throw new Error(
8714
- "create-webhook-endpoint requires --name, --url and --events"
8715
- );
8677
+ if (!name || !url || !events?.length) throw new Error("create-webhook-endpoint requires --name, --url and --events");
8716
8678
  await createWebhookEndpoint({ name, url, eventPatterns: events, enabled: parseOptionalBoolFlag(flags, "enabled") ?? !0 });
8717
8679
  }, "commandCreateWebhookEndpoint"), commandUpdateWebhookEndpoint = __name2(async ({ flags, positional }) => {
8718
8680
  const id = positional[0];
@@ -8726,10 +8688,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8726
8688
  }, "commandDeleteWebhookEndpoint"), commandRotateWebhookSecret = __name2(async ({ flags, positional }) => {
8727
8689
  const id = positional[0];
8728
8690
  if (!id) throw new Error("rotate-webhook-secret requires <id>");
8729
- const ttl = getFlag(
8730
- flags,
8731
- "previousSecretTtlHours"
8732
- );
8691
+ const ttl = getFlag(flags, "previousSecretTtlHours");
8733
8692
  await rotateWebhookSecret({ id, previousSecretTtlHours: ttl === void 0 ? void 0 : Number.parseInt(ttl, 10) });
8734
8693
  }, "commandRotateWebhookSecret"), commandSendWebhookTestEvent = __name2(async ({ positional }) => {
8735
8694
  const id = positional[0];
@@ -8737,17 +8696,11 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8737
8696
  await sendWebhookTestEvent(id);
8738
8697
  }, "commandSendWebhookTestEvent"), commandListWebhookDeliveries = __name2(async ({ flags }) => {
8739
8698
  const statuses = (getFlag(flags, "status") ?? "").split(",").map((value) => value.trim()).filter(Boolean);
8740
- for (const status of statuses) if (status !== "PENDING" && status !== "SUCCEEDED" && status !== "FAILED") throw new Error("--status must be PENDING, SUCCEEDED or FAILED (comma-separated)");
8699
+ for (const status of statuses)
8700
+ if (status !== "PENDING" && status !== "SUCCEEDED" && status !== "FAILED") throw new Error("--status must be PENDING, SUCCEEDED or FAILED (comma-separated)");
8741
8701
  const cursor = getFlag(flags, "cursor"), direction = parseProjectDirection(getFlag(flags, "direction"));
8742
8702
  if (direction === "backward" && !cursor) throw new Error("--direction backward requires --cursor <token>.");
8743
- await listWebhookDeliveries({
8744
- endpointId: getFlag(flags, "endpointId"),
8745
- ...statuses.length ? { status: statuses } : {},
8746
- eventType: getFlag(flags, "eventType"),
8747
- cursor,
8748
- direction,
8749
- limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit")
8750
- });
8703
+ await listWebhookDeliveries({ endpointId: getFlag(flags, "endpointId"), ...statuses.length ? { status: statuses } : {}, eventType: getFlag(flags, "eventType"), cursor, direction, limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit") });
8751
8704
  }, "commandListWebhookDeliveries"), commandGetWebhookDelivery = __name2(async ({ positional }) => {
8752
8705
  const id = positional[0];
8753
8706
  if (!id) throw new Error("get-webhook-delivery requires <id>");
@@ -8779,7 +8732,8 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8779
8732
  }, "parseInboundSourcePaging"), commandListInboundSources = __name2(async ({ cmd, flags }) => {
8780
8733
  const filters = inboundSourceFiltersFromFlags(flags);
8781
8734
  if (cmd === "count-inbound-sources") {
8782
- if (["limit", "cursor", "direction"].some((key) => flags[key] !== void 0)) throw new Error("Source counts accept filters only, not pagination flags.");
8735
+ if (["limit", "cursor", "direction"].some((key) => flags[key] !== void 0))
8736
+ throw new Error("Source counts accept filters only, not pagination flags.");
8783
8737
  await countInboundSources(filters);
8784
8738
  } else {
8785
8739
  const { cursor, direction, limit } = parseInboundSourcePaging(flags);
@@ -8821,24 +8775,19 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8821
8775
  if (!sourceId || !mode || enabled === void 0 || !Object.values(InboundProcessingMode).includes(String(mode))) throw new Error("update-inbound-processing requires <sourceId> --mode COLLECT_ONLY|SHADOW|ACTIVE --enabled true|false");
8822
8776
  await updateInboundProcessing({ processingEnabled: enabled, processingMode: String(mode), sourceId });
8823
8777
  }, "commandUpdateInboundProcessing"), commandGetApprovedBudgets = __name2(async ({ flags }) => {
8824
- await getApprovedBudgets({ projectId: getFlag(flags, "projectId"), limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit"), minRevenue: parseOptionalNumber(getFlag(
8825
- flags,
8826
- "minRevenue"
8827
- ), "--minRevenue"), maxRevenue: parseOptionalNumber(getFlag(flags, "maxRevenue"), "--maxRevenue") });
8778
+ await getApprovedBudgets({ projectId: getFlag(flags, "projectId"), limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit"), minRevenue: parseOptionalNumber(getFlag(flags, "minRevenue"), "--minRevenue"), maxRevenue: parseOptionalNumber(getFlag(flags, "maxRevenue"), "--maxRevenue") });
8828
8779
  }, "commandGetApprovedBudgets"), commandGetBudgetCategoryBenchmarks = __name2(async ({ flags, positional }) => {
8829
8780
  const id = positional[0];
8830
8781
  if (!id) throw new Error("get-budget-category-benchmarks requires <categoryId> [--limit]");
8831
8782
  await getBudgetCategoryBenchmarks({ categoryId: id, limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit") });
8832
8783
  }, "commandGetBudgetCategoryBenchmarks"), commandGetItemPricingHistory = __name2(async ({ flags }) => {
8833
- await getItemPricingHistory({ itemName: getFlag(flags, "itemName"), categoryId: getFlag(flags, "categoryId"), supplierId: getFlag(flags, "supplierId"), limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit") });
8784
+ await getItemPricingHistory(
8785
+ { itemName: getFlag(flags, "itemName"), categoryId: getFlag(flags, "categoryId"), supplierId: getFlag(flags, "supplierId"), limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit") }
8786
+ );
8834
8787
  }, "commandGetItemPricingHistory"), commandGetSupplierPricingHistory = __name2(async ({ flags, positional }) => {
8835
8788
  const id = positional[0];
8836
8789
  if (!id) throw new Error("get-supplier-pricing-history requires <supplierId> [--itemCategoryId] [--limit]");
8837
- await getSupplierPricingHistory({
8838
- supplierId: id,
8839
- itemCategoryId: getFlag(flags, "itemCategoryId"),
8840
- limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit")
8841
- });
8790
+ await getSupplierPricingHistory({ supplierId: id, itemCategoryId: getFlag(flags, "itemCategoryId"), limit: parsePositiveIntFlag(getFlag(flags, "limit"), "--limit") });
8842
8791
  }, "commandGetSupplierPricingHistory"), CLI_COMMAND_HANDLERS = /* @__PURE__ */ new Map([
8843
8792
  ["whoami", commandWhoami],
8844
8793
  ["list-budgets", commandListBudgets],
@@ -8889,7 +8838,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8889
8838
  ["update-bill-payment-evidence", commandUpdateBillPaymentEvidence],
8890
8839
  ["delete-bill", commandDeleteBill],
8891
8840
  ["update-bill-status", commandUpdateBillStatus],
8892
- ["list-external-payment-accounts", commandListExternalPaymentAccounts],
8841
+ [
8842
+ "list-external-payment-accounts",
8843
+ commandListExternalPaymentAccounts
8844
+ ],
8893
8845
  ["refresh-external-payment-accounts", commandRefreshExternalPaymentAccounts],
8894
8846
  ["record-external-bill-payment", commandRecordExternalBillPayment],
8895
8847
  ["patch-bill-payment", commandPatchBillPayment],
@@ -8948,9 +8900,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8948
8900
  ["update-customer-invoice-qbo-drift", commandUpdateCustomerInvoiceQboDrift],
8949
8901
  ["mark-customer-invoice-sent-externally", commandMarkCustomerInvoiceSentExternally],
8950
8902
  ["sync-customer-invoice", commandSyncCustomerInvoice],
8951
- ["get-pending-approval", async ({
8952
- positional
8953
- }) => {
8903
+ ["get-pending-approval", async ({ positional }) => {
8954
8904
  const id = positional[0];
8955
8905
  if (!id) throw new Error("approval get requires <approvalId>");
8956
8906
  await getPendingApproval(id);
@@ -8986,7 +8936,10 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
8986
8936
  ["sync-project-hub-commercial-documents", commandSyncProjectHubCommercialDocuments],
8987
8937
  ["create-project", commandCreateProject],
8988
8938
  ["update-project", commandUpdateProject],
8989
- ["delete-project", commandDeleteProject],
8939
+ [
8940
+ "delete-project",
8941
+ commandDeleteProject
8942
+ ],
8990
8943
  ["check-project-reconciliation", commandCheckProjectReconciliation],
8991
8944
  ["reconcile-project", commandReconcileProject],
8992
8945
  ["complete-project", commandCompleteProject],
@@ -9067,16 +9020,16 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
9067
9020
  ["get-budget-category-benchmarks", commandGetBudgetCategoryBenchmarks],
9068
9021
  ["get-item-pricing-history", commandGetItemPricingHistory],
9069
9022
  ["get-supplier-pricing-history", commandGetSupplierPricingHistory]
9070
- ]), dispatchCliCommand = __name2(async (context) => {
9071
- const handler = CLI_COMMAND_HANDLERS.get(context.cmd);
9072
- if (!handler) throw new Error("Unknown command: ".concat(context.cmd, ". Run 'bb help'."));
9073
- await handler(context);
9074
- }, "dispatchCliCommand"), startCliSession = __name2(
9075
- (context, command) => {
9076
- setActiveCliSession({ runtime: context.runtime, invocation: { command, cliVersion: context.version, apiBaseUrl: BUDGET_BUILDER_API_BASE_URL, quiet: context.quiet, debug: context.debug }, effects: [], permissions: {} });
9023
+ ]), dispatchCliCommand = __name2(
9024
+ async (context) => {
9025
+ const handler = CLI_COMMAND_HANDLERS.get(context.cmd);
9026
+ if (!handler) throw new Error("Unknown command: ".concat(context.cmd, ". Run 'bb help'."));
9027
+ await handler(context);
9077
9028
  },
9078
- "startCliSession"
9079
- ), failCliSession = __name2((context, command, error2) => {
9029
+ "dispatchCliCommand"
9030
+ ), startCliSession = __name2((context, command) => {
9031
+ setActiveCliSession({ runtime: context.runtime, invocation: { command, cliVersion: context.version, apiBaseUrl: BUDGET_BUILDER_API_BASE_URL, quiet: context.quiet, debug: context.debug }, effects: [], permissions: {} });
9032
+ }, "startCliSession"), failCliSession = __name2((context, command, error2) => {
9080
9033
  startCliSession(context, command);
9081
9034
  const exitCode = emitCommandError(error2);
9082
9035
  return clearActiveCliSession(), exitCode;
@@ -9099,10 +9052,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
9099
9052
  }, "authStatusResult"), runAuthAction = __name2(async (context, authAction, rawArgv, store) => {
9100
9053
  const { runtime } = context;
9101
9054
  if (authAction === "login") {
9102
- const credentials = await loginWithBrowser({ apiBaseUrl: BUDGET_BUILDER_API_BASE_URL, clientVersion: context.version, onVerification: __name2(({ browserOpened, userCode, verificationUriComplete }) => runtime.stderr.write("".concat(browserOpened ? "Opened" : "Open", " ").concat(verificationUriComplete, "\nCode: ").concat(userCode, "\nWaiting for approval\u2026\n")), "onVerification"), ...isEnabledFlag(
9103
- rawArgv,
9104
- "--no-browser"
9105
- ) ? { openBrowser: __name2(async () => !1, "openBrowser") } : {}, store });
9055
+ const credentials = await loginWithBrowser({ apiBaseUrl: BUDGET_BUILDER_API_BASE_URL, clientVersion: context.version, onVerification: __name2(({ browserOpened, userCode, verificationUriComplete }) => runtime.stderr.write("".concat(browserOpened ? "Opened" : "Open", " ").concat(verificationUriComplete, "\nCode: ").concat(userCode, "\nWaiting for approval\u2026\n")), "onVerification"), ...isEnabledFlag(rawArgv, "--no-browser") ? { openBrowser: __name2(async () => !1, "openBrowser") } : {}, store });
9106
9056
  emitCommandResult({ authenticated: !0, method: "browser-session", session: credentials.session, storage: "Bun.secrets" });
9107
9057
  } else emitCommandResult(authAction === "status" ? await authStatusResult(runtime, store) : { loggedOut: !0, ...await logoutCliSession({ apiBaseUrl: BUDGET_BUILDER_API_BASE_URL, store }), apiKeyActive: !!runtime.env.BB_API_KEY?.trim() });
9108
9058
  }, "runAuthAction"), runAuthCommand = __name2(async (context, authAction, commandArgv, rawArgv, credentialStore) => {
@@ -9132,9 +9082,7 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
9132
9082
  }
9133
9083
  configureAccessToken(accessToken);
9134
9084
  }, "configureCliAuthentication"), CONFIRMATION_EXEMPT_COMMANDS = /* @__PURE__ */ new Set(["create-bill", "import-qbo-customer-invoice", "approve-supplier"]), confirmCanonicalMutation = __name2(async (resolvedCommand, cmd) => {
9135
- resolvedCommand.isLegacyAlias || CONFIRMATION_EXEMPT_COMMANDS.has(cmd) || resolvedCommand.command.effects.length === 0 || await confirmCurrentCommand(
9136
- { action: resolvedCommand.command.path.join(" "), target: commandConfirmationTarget(resolvedCommand), details: "Canonical v2 mutation. Supply every effect-specific --allow-* flag for non-interactive execution." }
9137
- );
9085
+ resolvedCommand.isLegacyAlias || CONFIRMATION_EXEMPT_COMMANDS.has(cmd) || resolvedCommand.command.effects.length === 0 || await confirmCurrentCommand({ action: resolvedCommand.command.path.join(" "), target: commandConfirmationTarget(resolvedCommand), details: "Canonical v2 mutation. Supply every effect-specific --allow-* flag for non-interactive execution." });
9138
9086
  }, "confirmCanonicalMutation"), runResolvedCommand = __name2(async (context, argv, rawArgv, resolvedCommand, credentialStore, configureAccessToken) => {
9139
9087
  const { runtime, quiet, debug } = context, effectiveArgv = legacyArgvForCommand(argv, resolvedCommand), { command, positional, flags } = parseArgs(effectiveArgv);
9140
9088
  consumeCliQuietFlags(flags), setCliQuiet(resolvedCommand.isLegacyAlias ? quiet : quiet || !debug), setActiveCliSession({ runtime, invocation: { command: resolvedCommand.command.path.join(" "), cliVersion: context.version, apiBaseUrl: BUDGET_BUILDER_API_BASE_URL, legacy: resolvedCommand.isLegacyAlias, quiet, debug }, effects: resolvedCommand.command.effects, permissions: effectPermissionsFromArgv(rawArgv) }), resolvedCommand.isLegacyAlias && !quiet && runtime.stderr.write('[bb] Deprecated command "'.concat(resolvedCommand.invokedAs.join(" "), '"; use "bb ').concat(resolvedCommand.command.path.join(" "), '".\n'));
@@ -9142,7 +9090,9 @@ var booleanFlagValues = /* @__PURE__ */ new Set(["true", "false", "1", "0"]), is
9142
9090
  shouldLogCliActions() && logCliAction({ event: "cli.command", phase: "start", command: cmd, positional, flags: sanitizeFlagsForTrace(flags) });
9143
9091
  try {
9144
9092
  if (flags.q === !0) throw new CliRuntimeError("USAGE", "--q needs a search value (--q <text> or --q=<text>). Use -q or --quiet to hide logs.");
9145
- return await configureCliAuthentication(runtime, credentialStore, configureAccessToken), await confirmCanonicalMutation(resolvedCommand, cmd), await dispatchCliCommand({ cmd, flags, positional }), shouldLogCliActions() && logCliAction({ event: "cli.command", phase: "ok", command: cmd, durationMs: Date.now() - t0 }), clearActiveCliSession(), 0;
9093
+ return await configureCliAuthentication(runtime, credentialStore, configureAccessToken), await confirmCanonicalMutation(resolvedCommand, cmd), await dispatchCliCommand(
9094
+ { cmd, flags, positional }
9095
+ ), shouldLogCliActions() && logCliAction({ event: "cli.command", phase: "ok", command: cmd, durationMs: Date.now() - t0 }), clearActiveCliSession(), 0;
9146
9096
  } catch (err) {
9147
9097
  const message = err instanceof Error ? err.message : String(err);
9148
9098
  shouldLogCliActions() && logCliAction({ event: "cli.command", phase: "error", command: cmd, durationMs: Date.now() - t0, error: message });
@@ -9163,9 +9113,7 @@ async function runCli(argv = process.argv, runtime = createProcessRuntime(), cre
9163
9113
  if (isHelpRequest(commandArgv)) return printCliHelp(commandArgv, runtime), 0;
9164
9114
  if (commandArgv[0] === "completion") return runCompletionCommand(context, commandArgv);
9165
9115
  if (isVersionRequest(commandArgv)) return runVersionCommand(context);
9166
- const authAction = authActionFromArgv(
9167
- commandArgv
9168
- );
9116
+ const authAction = authActionFromArgv(commandArgv);
9169
9117
  if (authAction !== void 0) return await runAuthCommand(context, authAction, commandArgv, rawArgv, credentialStore);
9170
9118
  const resolvedCommand = resolveCommand(commandArgv);
9171
9119
  return resolvedCommand === void 0 ? failCliSession(context, commandArgv[0] ?? "unknown", new CliRuntimeError("USAGE", "Unknown command: ".concat(commandArgv.join(" "), ". Run 'bb help'."))) : await runResolvedCommand(context, argv, rawArgv, resolvedCommand, credentialStore, configureAccessToken);