qubesync 0.0.0-stage → 0.2.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/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/README.md +324 -2
- package/client.js +660 -0
- package/index.d.ts +367 -0
- package/index.js +409 -0
- package/index.mjs +22 -0
- package/operations/account.d.ts +263 -0
- package/operations/account.js +50 -0
- package/operations/account_tax_line_info.d.ts +31 -0
- package/operations/account_tax_line_info.js +26 -0
- package/operations/aging_report.d.ts +100 -0
- package/operations/aging_report.js +26 -0
- package/operations/alert.d.ts +118 -0
- package/operations/alert.js +50 -0
- package/operations/ar_refund_credit_card.d.ts +201 -0
- package/operations/ar_refund_credit_card.js +38 -0
- package/operations/bar_code.d.ts +40 -0
- package/operations/bar_code.js +26 -0
- package/operations/bill.d.ts +612 -0
- package/operations/bill.js +50 -0
- package/operations/bill_payment_check.d.ts +276 -0
- package/operations/bill_payment_check.js +50 -0
- package/operations/bill_payment_credit_card.d.ts +178 -0
- package/operations/bill_payment_credit_card.js +38 -0
- package/operations/bill_to_pay.d.ts +54 -0
- package/operations/bill_to_pay.js +26 -0
- package/operations/billing_rate.d.ts +159 -0
- package/operations/billing_rate.js +38 -0
- package/operations/budget_summary_report.d.ts +71 -0
- package/operations/budget_summary_report.js +26 -0
- package/operations/build_assembly.d.ts +264 -0
- package/operations/build_assembly.js +50 -0
- package/operations/charge.d.ts +330 -0
- package/operations/charge.js +50 -0
- package/operations/check.d.ts +394 -0
- package/operations/check.js +50 -0
- package/operations/class.d.ts +170 -0
- package/operations/class.js +50 -0
- package/operations/cleared_status.d.ts +43 -0
- package/operations/cleared_status.js +26 -0
- package/operations/client.d.ts +254 -0
- package/operations/company.d.ts +36 -0
- package/operations/company.js +26 -0
- package/operations/company_activity.d.ts +32 -0
- package/operations/company_activity.js +26 -0
- package/operations/credit_card_charge.d.ts +280 -0
- package/operations/credit_card_charge.js +50 -0
- package/operations/credit_card_credit.d.ts +280 -0
- package/operations/credit_card_credit.js +50 -0
- package/operations/credit_memo.d.ts +642 -0
- package/operations/credit_memo.js +50 -0
- package/operations/currency.d.ts +195 -0
- package/operations/currency.js +50 -0
- package/operations/custom_detail_report.d.ts +108 -0
- package/operations/custom_detail_report.js +26 -0
- package/operations/custom_summary_report.d.ts +119 -0
- package/operations/custom_summary_report.js +26 -0
- package/operations/customer.d.ts +639 -0
- package/operations/customer.js +50 -0
- package/operations/customer_msg.d.ts +121 -0
- package/operations/customer_msg.js +38 -0
- package/operations/customer_type.d.ts +127 -0
- package/operations/customer_type.js +38 -0
- package/operations/data_event_recovery_info.d.ts +61 -0
- package/operations/data_event_recovery_info.js +38 -0
- package/operations/data_ext.d.ts +197 -0
- package/operations/data_ext.js +50 -0
- package/operations/data_ext_def.d.ts +173 -0
- package/operations/data_ext_def.js +62 -0
- package/operations/date_driven_terms.d.ts +141 -0
- package/operations/date_driven_terms.js +38 -0
- package/operations/deposit.d.ts +402 -0
- package/operations/deposit.js +50 -0
- package/operations/employee.d.ts +683 -0
- package/operations/employee.js +50 -0
- package/operations/employee_default.d.ts +133 -0
- package/operations/employee_default.js +38 -0
- package/operations/entity.d.ts +96 -0
- package/operations/entity.js +26 -0
- package/operations/estimate.d.ts +590 -0
- package/operations/estimate.js +50 -0
- package/operations/form1099_category_account_mapping.d.ts +89 -0
- package/operations/form1099_category_account_mapping.js +38 -0
- package/operations/general_detail_report.d.ts +108 -0
- package/operations/general_detail_report.js +26 -0
- package/operations/general_summary_report.d.ts +115 -0
- package/operations/general_summary_report.js +26 -0
- package/operations/host.d.ts +43 -0
- package/operations/host.js +26 -0
- package/operations/index.js +397 -0
- package/operations/inventory_adjustment.d.ts +389 -0
- package/operations/inventory_adjustment.js +50 -0
- package/operations/inventory_site.d.ts +247 -0
- package/operations/inventory_site.js +50 -0
- package/operations/invoice.d.ts +682 -0
- package/operations/invoice.js +50 -0
- package/operations/item.d.ts +100 -0
- package/operations/item.js +26 -0
- package/operations/item_assemblies_can_build.d.ts +41 -0
- package/operations/item_assemblies_can_build.js +26 -0
- package/operations/item_discount.d.ts +256 -0
- package/operations/item_discount.js +50 -0
- package/operations/item_fixed_asset.d.ts +382 -0
- package/operations/item_fixed_asset.js +50 -0
- package/operations/item_group.d.ts +236 -0
- package/operations/item_group.js +50 -0
- package/operations/item_inventory.d.ts +350 -0
- package/operations/item_inventory.js +50 -0
- package/operations/item_inventory_assembly.d.ts +368 -0
- package/operations/item_inventory_assembly.js +50 -0
- package/operations/item_non_inventory.d.ts +264 -0
- package/operations/item_non_inventory.js +50 -0
- package/operations/item_other_charge.d.ts +244 -0
- package/operations/item_other_charge.js +50 -0
- package/operations/item_payment.d.ts +220 -0
- package/operations/item_payment.js +50 -0
- package/operations/item_receipt.d.ts +362 -0
- package/operations/item_receipt.js +50 -0
- package/operations/item_sales_tax.d.ts +228 -0
- package/operations/item_sales_tax.js +50 -0
- package/operations/item_sales_tax_group.d.ts +192 -0
- package/operations/item_sales_tax_group.js +50 -0
- package/operations/item_service.d.ts +256 -0
- package/operations/item_service.js +50 -0
- package/operations/item_sites.d.ts +81 -0
- package/operations/item_sites.js +26 -0
- package/operations/item_subtotal.d.ts +188 -0
- package/operations/item_subtotal.js +50 -0
- package/operations/job_report.d.ts +99 -0
- package/operations/job_report.js +26 -0
- package/operations/job_type.d.ts +127 -0
- package/operations/job_type.js +38 -0
- package/operations/journal_entry.d.ts +339 -0
- package/operations/journal_entry.js +50 -0
- package/operations/lead.d.ts +291 -0
- package/operations/lead.js +50 -0
- package/operations/list.d.ts +39 -0
- package/operations/list.js +26 -0
- package/operations/list_deleted.d.ts +44 -0
- package/operations/list_deleted.js +26 -0
- package/operations/list_display.d.ts +65 -0
- package/operations/list_display.js +38 -0
- package/operations/list_merge.d.ts +58 -0
- package/operations/list_merge.js +26 -0
- package/operations/other_name.d.ts +280 -0
- package/operations/other_name.js +50 -0
- package/operations/paycheck.d.ts +82 -0
- package/operations/paycheck.js +26 -0
- package/operations/payment_method.d.ts +131 -0
- package/operations/payment_method.js +38 -0
- package/operations/payroll_detail_report.d.ts +97 -0
- package/operations/payroll_detail_report.js +26 -0
- package/operations/payroll_item.d.ts +83 -0
- package/operations/payroll_item.js +26 -0
- package/operations/payroll_item_addition.d.ts +95 -0
- package/operations/payroll_item_addition.js +38 -0
- package/operations/payroll_item_company_contribution.d.ts +105 -0
- package/operations/payroll_item_company_contribution.js +38 -0
- package/operations/payroll_item_deduction.d.ts +101 -0
- package/operations/payroll_item_deduction.js +38 -0
- package/operations/payroll_item_direct_deposit.d.ts +65 -0
- package/operations/payroll_item_direct_deposit.js +38 -0
- package/operations/payroll_item_non_wage.d.ts +92 -0
- package/operations/payroll_item_non_wage.js +26 -0
- package/operations/payroll_item_tax.d.ts +108 -0
- package/operations/payroll_item_tax.js +38 -0
- package/operations/payroll_item_wage.d.ts +169 -0
- package/operations/payroll_item_wage.js +50 -0
- package/operations/payroll_item_workers_compensation.d.ts +77 -0
- package/operations/payroll_item_workers_compensation.js +38 -0
- package/operations/payroll_last_period.d.ts +31 -0
- package/operations/payroll_last_period.js +26 -0
- package/operations/payroll_liability_adjustment.d.ts +137 -0
- package/operations/payroll_liability_adjustment.js +38 -0
- package/operations/payroll_liability_check.d.ts +82 -0
- package/operations/payroll_liability_check.js +26 -0
- package/operations/payroll_prior_payment.d.ts +126 -0
- package/operations/payroll_prior_payment.js +38 -0
- package/operations/payroll_summary_report.d.ts +107 -0
- package/operations/payroll_summary_report.js +26 -0
- package/operations/payroll_year_to_date_adjustment.d.ts +156 -0
- package/operations/payroll_year_to_date_adjustment.js +38 -0
- package/operations/preferences.d.ts +64 -0
- package/operations/preferences.js +38 -0
- package/operations/price_level.d.ts +234 -0
- package/operations/price_level.js +50 -0
- package/operations/purchase_order.d.ts +620 -0
- package/operations/purchase_order.js +50 -0
- package/operations/qb_command_exec.d.ts +49 -0
- package/operations/qb_command_exec.js +26 -0
- package/operations/receive_payment.d.ts +450 -0
- package/operations/receive_payment.js +50 -0
- package/operations/receive_payment_to_deposit.d.ts +36 -0
- package/operations/receive_payment_to_deposit.js +26 -0
- package/operations/sales_order.d.ts +612 -0
- package/operations/sales_order.js +50 -0
- package/operations/sales_receipt.d.ts +650 -0
- package/operations/sales_receipt.js +50 -0
- package/operations/sales_rep.d.ts +170 -0
- package/operations/sales_rep.js +50 -0
- package/operations/sales_tax_code.d.ts +194 -0
- package/operations/sales_tax_code.js +50 -0
- package/operations/sales_tax_payable.d.ts +42 -0
- package/operations/sales_tax_payable.js +26 -0
- package/operations/sales_tax_payment_check.d.ts +254 -0
- package/operations/sales_tax_payment_check.js +50 -0
- package/operations/sales_tax_return.d.ts +35 -0
- package/operations/sales_tax_return.js +26 -0
- package/operations/sales_tax_return_line.d.ts +36 -0
- package/operations/sales_tax_return_line.js +26 -0
- package/operations/ship_method.d.ts +121 -0
- package/operations/ship_method.js +38 -0
- package/operations/special_account.d.ts +40 -0
- package/operations/special_account.js +26 -0
- package/operations/special_item.d.ts +44 -0
- package/operations/special_item.js +26 -0
- package/operations/standard_terms.d.ts +133 -0
- package/operations/standard_terms.js +38 -0
- package/operations/template.d.ts +36 -0
- package/operations/template.js +26 -0
- package/operations/terms.d.ts +90 -0
- package/operations/terms.js +26 -0
- package/operations/time_report.d.ts +84 -0
- package/operations/time_report.js +26 -0
- package/operations/time_tracking.d.ts +214 -0
- package/operations/time_tracking.js +50 -0
- package/operations/to_do.d.ts +254 -0
- package/operations/to_do.js +50 -0
- package/operations/transaction.d.ts +244 -0
- package/operations/transaction.js +26 -0
- package/operations/transfer.d.ts +178 -0
- package/operations/transfer.js +50 -0
- package/operations/transfer_inventory.d.ts +290 -0
- package/operations/transfer_inventory.js +50 -0
- package/operations/txn.d.ts +39 -0
- package/operations/txn.js +26 -0
- package/operations/txn_deleted.d.ts +44 -0
- package/operations/txn_deleted.js +26 -0
- package/operations/txn_display.d.ts +69 -0
- package/operations/txn_display.js +38 -0
- package/operations/txn_void.d.ts +39 -0
- package/operations/txn_void.js +26 -0
- package/operations/types.d.ts +1259 -0
- package/operations/unit_of_measure_set.d.ts +168 -0
- package/operations/unit_of_measure_set.js +38 -0
- package/operations/vehicle.d.ts +168 -0
- package/operations/vehicle.js +50 -0
- package/operations/vehicle_mileage.d.ts +147 -0
- package/operations/vehicle_mileage.js +38 -0
- package/operations/vendor.d.ts +541 -0
- package/operations/vendor.js +50 -0
- package/operations/vendor_credit.d.ts +365 -0
- package/operations/vendor_credit.js +50 -0
- package/operations/vendor_type.d.ts +127 -0
- package/operations/vendor_type.js +38 -0
- package/operations/workers_comp_code.d.ts +199 -0
- package/operations/workers_comp_code.js +50 -0
- package/package.json +52 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
// Type definitions for qubesync (the QuBe Sync v2 API client and webhooks).
|
|
2
|
+
|
|
3
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
|
|
4
|
+
export interface JsonObject {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare const VERSION: string;
|
|
9
|
+
/** The header QuBe Sync signs deliveries in. Node lowercases it: `req.headers["x-qube-signature"]`. */
|
|
10
|
+
export declare const SIGNATURE_HEADER: "X-QUBE-Signature";
|
|
11
|
+
export declare const DEFAULT_TOLERANCE: 300;
|
|
12
|
+
|
|
13
|
+
export type SignatureErrorReason = "missing" | "malformed" | "stale" | "mismatch";
|
|
14
|
+
export declare const REASONS: readonly SignatureErrorReason[];
|
|
15
|
+
|
|
16
|
+
/** Thrown by `verify` when a delivery can't be trusted. Answer 401. The message is safe to log. */
|
|
17
|
+
export declare class SignatureError extends Error {
|
|
18
|
+
constructor(reason: SignatureErrorReason, message: string);
|
|
19
|
+
readonly name: "SignatureError";
|
|
20
|
+
readonly reason: SignatureErrorReason;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The raw request body exactly as received. A `Buffer` is a `Uint8Array`. */
|
|
24
|
+
export type RawBody = string | Uint8Array;
|
|
25
|
+
|
|
26
|
+
export interface VerifyOptions {
|
|
27
|
+
/** One secret, or several while one rotates. Required and non-empty. */
|
|
28
|
+
secrets: string | readonly string[];
|
|
29
|
+
/** Seconds the timestamp may be off either way. Default 300. */
|
|
30
|
+
tolerance?: number;
|
|
31
|
+
/** Unix seconds or a Date. Default: the current time. */
|
|
32
|
+
now?: number | Date;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type EventType = "request" | "workflow_run" | "notification" | "connection" | "name_index" | "unknown";
|
|
36
|
+
|
|
37
|
+
export declare abstract class Event {
|
|
38
|
+
/** The whole parsed body. */
|
|
39
|
+
readonly body: JsonObject;
|
|
40
|
+
readonly type: EventType;
|
|
41
|
+
readonly event: string | null;
|
|
42
|
+
readonly timestamp: number | null;
|
|
43
|
+
readonly appId: string | null;
|
|
44
|
+
readonly sandbox: boolean | null;
|
|
45
|
+
readonly revision: number | null;
|
|
46
|
+
readonly reference: string | null;
|
|
47
|
+
readonly dedupeKey: string | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A queued request's answer: no `event` key, has `page_request_id`. */
|
|
51
|
+
export declare class RequestEvent extends Event {
|
|
52
|
+
readonly type: "request";
|
|
53
|
+
readonly revision: null;
|
|
54
|
+
readonly reference: null;
|
|
55
|
+
readonly id: string | null;
|
|
56
|
+
readonly pageRequestId: string | null;
|
|
57
|
+
readonly state: string | null;
|
|
58
|
+
readonly page: number | null;
|
|
59
|
+
readonly iterationState: string | null;
|
|
60
|
+
readonly responseJson: JsonValue;
|
|
61
|
+
readonly error: JsonValue;
|
|
62
|
+
/** `"<page_request_id>:<state>"`. */
|
|
63
|
+
readonly dedupeKey: string | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** `workflow_run.awaiting_input`, `.completed`, `.failed` or `.cancelled`. */
|
|
67
|
+
export declare class WorkflowRunEvent extends Event {
|
|
68
|
+
readonly type: "workflow_run";
|
|
69
|
+
readonly event: string;
|
|
70
|
+
readonly runId: string | null;
|
|
71
|
+
readonly runState: string | null;
|
|
72
|
+
readonly workflow: string | null;
|
|
73
|
+
readonly connectionId: string | null;
|
|
74
|
+
readonly prompt: JsonObject | null;
|
|
75
|
+
readonly outcome: string | null;
|
|
76
|
+
readonly output: JsonValue;
|
|
77
|
+
readonly error: JsonValue;
|
|
78
|
+
readonly summary: JsonObject | null;
|
|
79
|
+
readonly cancelReason: string | null;
|
|
80
|
+
readonly links: JsonObject | null;
|
|
81
|
+
/** Always null: apply a run's webhook when `newerThan(storedRevision)`. */
|
|
82
|
+
readonly dedupeKey: null;
|
|
83
|
+
/** True when `storedRevision` is null/undefined, else `revision > storedRevision`. */
|
|
84
|
+
newerThan(storedRevision: number | null | undefined): boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** `workflow_run.notification`: data a run sends along the way. Never skipped by revision. */
|
|
88
|
+
export declare class NotificationEvent extends Event {
|
|
89
|
+
readonly type: "notification";
|
|
90
|
+
readonly event: "workflow_run.notification";
|
|
91
|
+
readonly runId: string | null;
|
|
92
|
+
readonly deliveryId: string | null;
|
|
93
|
+
readonly seq: number | null;
|
|
94
|
+
readonly name: string | null;
|
|
95
|
+
readonly state: string | null;
|
|
96
|
+
readonly from: JsonObject | null;
|
|
97
|
+
readonly data: JsonValue;
|
|
98
|
+
/** The `delivery_id`. */
|
|
99
|
+
readonly dedupeKey: string | null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** `connection.*`. */
|
|
103
|
+
export declare class ConnectionEvent extends Event {
|
|
104
|
+
readonly type: "connection";
|
|
105
|
+
readonly event: string;
|
|
106
|
+
readonly reference: null;
|
|
107
|
+
readonly deliveryId: string | null;
|
|
108
|
+
readonly connection: JsonObject | null;
|
|
109
|
+
/** `connection.id`. */
|
|
110
|
+
readonly connectionId: string | null;
|
|
111
|
+
readonly stallReason: string | null;
|
|
112
|
+
/** The `delivery_id`. */
|
|
113
|
+
readonly dedupeKey: string | null;
|
|
114
|
+
/** True when `storedRevision` is null/undefined, else `revision > storedRevision`. */
|
|
115
|
+
newerThan(storedRevision: number | null | undefined): boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** `name_index.*`. */
|
|
119
|
+
export declare class NameIndexEvent extends Event {
|
|
120
|
+
readonly type: "name_index";
|
|
121
|
+
readonly event: string;
|
|
122
|
+
readonly revision: null;
|
|
123
|
+
readonly reference: null;
|
|
124
|
+
readonly connectionId: string | null;
|
|
125
|
+
readonly nameIndex: JsonObject | null;
|
|
126
|
+
readonly dedupeKey: null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Anything else, including events newer than this library. Never refused. */
|
|
130
|
+
export declare class UnknownEvent extends Event {
|
|
131
|
+
readonly type: "unknown";
|
|
132
|
+
readonly revision: null;
|
|
133
|
+
readonly reference: null;
|
|
134
|
+
readonly dedupeKey: null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type WebhookEvent =
|
|
138
|
+
| RequestEvent
|
|
139
|
+
| WorkflowRunEvent
|
|
140
|
+
| NotificationEvent
|
|
141
|
+
| ConnectionEvent
|
|
142
|
+
| NameIndexEvent
|
|
143
|
+
| UnknownEvent;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Verifies the X-QUBE-Signature header over the raw body, then parses it.
|
|
147
|
+
* Throws `SignatureError` (reason `missing`, `malformed`, `stale` or `mismatch`),
|
|
148
|
+
* or `TypeError` for a programming mistake (no secrets, a parsed body).
|
|
149
|
+
*/
|
|
150
|
+
export declare function verify(
|
|
151
|
+
rawBody: RawBody,
|
|
152
|
+
header: string | readonly string[] | null | undefined,
|
|
153
|
+
options: VerifyOptions
|
|
154
|
+
): WebhookEvent;
|
|
155
|
+
|
|
156
|
+
/** Parses a body into a typed event without verifying it. */
|
|
157
|
+
export declare function parse(rawBody: RawBody): WebhookEvent;
|
|
158
|
+
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
// The v2 API client
|
|
161
|
+
|
|
162
|
+
/** What the API answers: plain objects with the API's own snake_case keys. */
|
|
163
|
+
export type ApiObject = { [key: string]: any };
|
|
164
|
+
|
|
165
|
+
export type QueryValue = string | number | boolean | null | undefined;
|
|
166
|
+
export type Query = { [key: string]: QueryValue | readonly QueryValue[] };
|
|
167
|
+
|
|
168
|
+
/** What `onRetry` is told before each retry's wait. Never the API key, headers or body. */
|
|
169
|
+
export interface RetryInfo {
|
|
170
|
+
/** The retry about to be made: 1, 2... */
|
|
171
|
+
readonly attempt: number;
|
|
172
|
+
readonly maxRetries: number;
|
|
173
|
+
/** The wait before it, in ms (the backoff, or the answer's Retry-After). */
|
|
174
|
+
readonly delayMs: number;
|
|
175
|
+
/** Ms since the call started. */
|
|
176
|
+
readonly elapsedMs: number;
|
|
177
|
+
/** Upper case. */
|
|
178
|
+
readonly method: string;
|
|
179
|
+
/** The request URL without its query string. */
|
|
180
|
+
readonly url: string;
|
|
181
|
+
/** The HTTP status that's retried, or null for a network failure or timeout. */
|
|
182
|
+
readonly status: number | null;
|
|
183
|
+
/** The network failure or timeout that's retried, or null for a status. */
|
|
184
|
+
readonly error: Error | null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface ClientOptions {
|
|
188
|
+
/** Your app's API key. Required; the client never reads the environment. */
|
|
189
|
+
apiKey: string;
|
|
190
|
+
/** Default `"https://qubesync.com"`. Trailing slashes are dropped; the API is `baseUrl + "/api/v2"`. */
|
|
191
|
+
baseUrl?: string;
|
|
192
|
+
/** Milliseconds to open the connection. Default 5000. */
|
|
193
|
+
connectTimeout?: number;
|
|
194
|
+
/** Milliseconds the socket may sit idle waiting for the answer. Default 30000. */
|
|
195
|
+
timeout?: number;
|
|
196
|
+
/** Retries for a retry-safe request (GET, PUT, DELETE, or one with an Idempotency-Key). Default 2. */
|
|
197
|
+
maxRetries?: number;
|
|
198
|
+
/** Ms a call may take, retries and their waits included. Default 60000. */
|
|
199
|
+
totalTimeout?: number;
|
|
200
|
+
/** Called before each retry's wait. Anything it throws stops the call and rejects with that error. */
|
|
201
|
+
onRetry?: (info: RetryInfo) => void;
|
|
202
|
+
/** Waits between retries; for tests. Default: setTimeout. */
|
|
203
|
+
sleep?: (ms: number) => Promise<void>;
|
|
204
|
+
/** A monotonic clock in ms; for tests. Default: performance.now. */
|
|
205
|
+
clock?: () => number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface ConnectionOptions {
|
|
209
|
+
webhookUrl?: string;
|
|
210
|
+
name?: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface StartRunOptions {
|
|
214
|
+
/** Your own id for the run; also sent as the Idempotency-Key. */
|
|
215
|
+
reference: string;
|
|
216
|
+
webhookUrl: string;
|
|
217
|
+
version?: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ListRunsFilters {
|
|
221
|
+
reference?: string;
|
|
222
|
+
state?: string;
|
|
223
|
+
outcome?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface RunEventsOptions {
|
|
227
|
+
after?: number | string;
|
|
228
|
+
limit?: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface RunEventsPage {
|
|
232
|
+
data: ApiObject[];
|
|
233
|
+
next_after: number | string | null;
|
|
234
|
+
[key: string]: any;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface AnswerOptions {
|
|
238
|
+
/** One of the prompt's choices. */
|
|
239
|
+
choice: string | number;
|
|
240
|
+
/** The fields the choice takes. */
|
|
241
|
+
data?: ApiObject;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface SearchOptions {
|
|
245
|
+
field: string;
|
|
246
|
+
q: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
import type { OperationOptions, QueuedRequest } from "./operations/types";
|
|
250
|
+
import type { ClientOperations } from "./operations/client";
|
|
251
|
+
export type { OperationOptions, QueuedRequest } from "./operations/types";
|
|
252
|
+
export type { ClientOperations } from "./operations/client";
|
|
253
|
+
|
|
254
|
+
export type QueueMethod = "GET" | "POST" | "PUT" | "DELETE" | "get" | "post" | "put" | "delete";
|
|
255
|
+
|
|
256
|
+
export interface QueueOptions extends OperationOptions {
|
|
257
|
+
/** Needed, with `path`, for an operation id this version doesn't know; case-insensitive. */
|
|
258
|
+
method?: QueueMethod;
|
|
259
|
+
/** Relative to the connection (`"customers"`); needed, with `method`, for an id this version doesn't know. */
|
|
260
|
+
path?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface QueueQbxmlOptions {
|
|
264
|
+
webhookUrl: string;
|
|
265
|
+
idempotencyKey?: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface ListRequestsFilters {
|
|
269
|
+
page?: number;
|
|
270
|
+
pageSize?: number;
|
|
271
|
+
state?: string;
|
|
272
|
+
webhookState?: string;
|
|
273
|
+
sort?: string;
|
|
274
|
+
sortDirection?: "asc" | "desc" | string;
|
|
275
|
+
searchPhrase?: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface RequestsPage {
|
|
279
|
+
data: ApiObject[];
|
|
280
|
+
meta: { page: number; total_pages: number; [key: string]: any };
|
|
281
|
+
[key: string]: any;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface RequestOptions {
|
|
285
|
+
query?: Query;
|
|
286
|
+
headers?: { [name: string]: string | number | undefined };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The QuBe Sync v2 API. Every method returns a Promise of the response's `data`, or null
|
|
291
|
+
* for an empty answer. A non-2xx answer rejects with `APIError`; a connection that still fails
|
|
292
|
+
* after the retries rejects with Node's own error. A link on another origin than `baseUrl`
|
|
293
|
+
* rejects with a `TypeError` before any request is made.
|
|
294
|
+
*/
|
|
295
|
+
/** The entity accessors (`qube.customer`, `qube.customerMsg`...) come from `ClientOperations`. */
|
|
296
|
+
export interface Client extends ClientOperations {}
|
|
297
|
+
export declare class Client {
|
|
298
|
+
constructor(options: ClientOptions);
|
|
299
|
+
readonly baseUrl: string;
|
|
300
|
+
readonly connectTimeout: number;
|
|
301
|
+
readonly timeout: number;
|
|
302
|
+
readonly maxRetries: number;
|
|
303
|
+
readonly totalTimeout: number;
|
|
304
|
+
toJSON(): { baseUrl: string };
|
|
305
|
+
|
|
306
|
+
createConnection(options: ConnectionOptions & { webhookUrl: string }): Promise<ApiObject>;
|
|
307
|
+
getConnection(id: string): Promise<ApiObject>;
|
|
308
|
+
listConnections(): Promise<ApiObject[]>;
|
|
309
|
+
updateConnection(id: string, options: ConnectionOptions): Promise<ApiObject>;
|
|
310
|
+
/** Null on success, and on a retry's 404 after an earlier attempt's answer was lost. */
|
|
311
|
+
deleteConnection(id: string): Promise<null>;
|
|
312
|
+
regenerateOnboarding(id: string): Promise<ApiObject>;
|
|
313
|
+
/** `{ id, password }`. Without `password`, QuBe Sync makes one. */
|
|
314
|
+
setPassword(id: string, options?: { password?: string }): Promise<ApiObject>;
|
|
315
|
+
/** The QWC file's XML. */
|
|
316
|
+
getQwc(id: string): Promise<string>;
|
|
317
|
+
|
|
318
|
+
startRun(connectionId: string, workflow: string, input: ApiObject, options: StartRunOptions): Promise<ApiObject>;
|
|
319
|
+
/** A run by its `links.run` URL, or by connection and run id. */
|
|
320
|
+
getRun(runUrl: string): Promise<ApiObject>;
|
|
321
|
+
getRun(connectionId: string, runId: string): Promise<ApiObject>;
|
|
322
|
+
listRuns(connectionId: string, filters?: ListRunsFilters): Promise<ApiObject[]>;
|
|
323
|
+
/** Takes the run's `links.cancel`. */
|
|
324
|
+
cancelRun(cancelUrl: string, options?: { reason?: string }): Promise<ApiObject>;
|
|
325
|
+
/** The whole body, `{ data, next_after }`. */
|
|
326
|
+
runEvents(connectionId: string, runId: string, options?: RunEventsOptions): Promise<RunEventsPage>;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Takes the prompt's `links.decisions`. Retried when the link has a `prompt_token`; a retry after
|
|
330
|
+
* a lost answer may reject with a 409 `prompt_changed`: the question has been answered.
|
|
331
|
+
*/
|
|
332
|
+
answer(decisionsUrl: string, options: AnswerOptions): Promise<ApiObject>;
|
|
333
|
+
/** Takes the prompt's `links.search`. */
|
|
334
|
+
search(searchUrl: string, options: SearchOptions): Promise<ApiObject[]>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Queues any operation by its id (`"customer.create"`), as `qube.customer.create(...)` does. An id
|
|
338
|
+
* this version doesn't know (an operation newer than it) needs `method` and `path`.
|
|
339
|
+
*/
|
|
340
|
+
queue(operationId: string, connectionId: string, params: ApiObject | undefined, options: QueueOptions): Promise<QueuedRequest>;
|
|
341
|
+
queueQbxml(connectionId: string, requestXml: string, options: QueueQbxmlOptions): Promise<ApiObject>;
|
|
342
|
+
getRequest(connectionId: string, id: string): Promise<ApiObject>;
|
|
343
|
+
requestPages(connectionId: string, id: string): Promise<ApiObject[]>;
|
|
344
|
+
/** The whole body, `{ data, meta: { page, total_pages } }`. */
|
|
345
|
+
listRequests(connectionId: string, filters?: ListRequestsFilters): Promise<RequestsPage>;
|
|
346
|
+
/** Every request on every page. */
|
|
347
|
+
eachRequest(connectionId: string, filters?: Omit<ListRequestsFilters, "page">): AsyncGenerator<ApiObject, void, undefined>;
|
|
348
|
+
discardRequest(connectionId: string, id: string): Promise<ApiObject>;
|
|
349
|
+
|
|
350
|
+
/** Any v2 call: a path under /api/v2 or a same-origin URL. Returns the parsed body whole, or null. */
|
|
351
|
+
request(method: string, pathOrUrl: string, body?: unknown, options?: RequestOptions): Promise<any>;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Any answer outside 2xx. The message is one line and never holds the API key. */
|
|
355
|
+
export declare class APIError extends Error {
|
|
356
|
+
readonly name: "APIError";
|
|
357
|
+
/** The HTTP status. */
|
|
358
|
+
readonly status: number;
|
|
359
|
+
/** `errors["code"]` when `errors` is an object with a string code (`prompt_changed`, `not_awaiting_input`). */
|
|
360
|
+
readonly code: string | null;
|
|
361
|
+
/** The body's `errors` as parsed: a sentence, `{ detail, code }`, fields, or `{ path, message }` problems. */
|
|
362
|
+
readonly errors: string | ApiObject | ApiObject[] | null;
|
|
363
|
+
/** The raw response body. */
|
|
364
|
+
readonly body: string;
|
|
365
|
+
/** The `x-request-id` header, for support. */
|
|
366
|
+
readonly requestId: string | null;
|
|
367
|
+
}
|