@wuapidev/sdk 0.1.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/LICENSE +21 -0
- package/README.md +355 -0
- package/dist/client.d.ts +50 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +80 -0
- package/dist/client.js.map +1 -0
- package/dist/core.d.ts +58 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +191 -0
- package/dist/core.js.map +1 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +29 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +23 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +53 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/accounts.d.ts +76 -0
- package/dist/resources/accounts.d.ts.map +1 -0
- package/dist/resources/accounts.js +139 -0
- package/dist/resources/accounts.js.map +1 -0
- package/dist/resources/base.d.ts +18 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/base.js +34 -0
- package/dist/resources/base.js.map +1 -0
- package/dist/resources/channels.d.ts +22 -0
- package/dist/resources/channels.d.ts.map +1 -0
- package/dist/resources/channels.js +45 -0
- package/dist/resources/channels.js.map +1 -0
- package/dist/resources/chats.d.ts +35 -0
- package/dist/resources/chats.d.ts.map +1 -0
- package/dist/resources/chats.js +64 -0
- package/dist/resources/chats.js.map +1 -0
- package/dist/resources/contacts.d.ts +45 -0
- package/dist/resources/contacts.d.ts.map +1 -0
- package/dist/resources/contacts.js +79 -0
- package/dist/resources/contacts.js.map +1 -0
- package/dist/resources/groups.d.ts +36 -0
- package/dist/resources/groups.d.ts.map +1 -0
- package/dist/resources/groups.js +81 -0
- package/dist/resources/groups.js.map +1 -0
- package/dist/resources/messages.d.ts +36 -0
- package/dist/resources/messages.d.ts.map +1 -0
- package/dist/resources/messages.js +60 -0
- package/dist/resources/messages.js.map +1 -0
- package/dist/resources/misc.d.ts +21 -0
- package/dist/resources/misc.d.ts.map +1 -0
- package/dist/resources/misc.js +23 -0
- package/dist/resources/misc.js.map +1 -0
- package/dist/resources/projects.d.ts +65 -0
- package/dist/resources/projects.d.ts.map +1 -0
- package/dist/resources/projects.js +115 -0
- package/dist/resources/projects.js.map +1 -0
- package/dist/types.d.ts +1073 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +46 -0
- package/dist/types.js.map +1 -0
- package/dist/webhook.d.ts +15 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +77 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +56 -0
package/dist/core.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { WuapiError } from "./errors.js";
|
|
2
|
+
export const VERSION = "0.1.0";
|
|
3
|
+
export const DEFAULT_BASE_URL = "https://api.wuapi.dev";
|
|
4
|
+
export const PROJECT_HEADER = "Wuapi-Project";
|
|
5
|
+
export const IDEMPOTENCY_HEADER = "Idempotency-Key";
|
|
6
|
+
const MAX_BACKOFF_MS = 8_000;
|
|
7
|
+
const MAX_RETRY_AFTER_MS = 60_000;
|
|
8
|
+
function readEnvApiKey() {
|
|
9
|
+
const proc = globalThis.process;
|
|
10
|
+
return proc?.env?.WUAPI_API_KEY;
|
|
11
|
+
}
|
|
12
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
|
+
function parseRetryAfter(value) {
|
|
14
|
+
if (value === null)
|
|
15
|
+
return undefined;
|
|
16
|
+
const seconds = Number(value);
|
|
17
|
+
if (Number.isFinite(seconds) && seconds >= 0)
|
|
18
|
+
return seconds;
|
|
19
|
+
const date = Date.parse(value);
|
|
20
|
+
if (!Number.isNaN(date))
|
|
21
|
+
return Math.max(0, (date - Date.now()) / 1000);
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
export class HttpClient {
|
|
25
|
+
baseUrl;
|
|
26
|
+
timeoutMs;
|
|
27
|
+
maxRetries;
|
|
28
|
+
/** The `Wuapi-Project` header value, when this client is scoped to a project. */
|
|
29
|
+
project;
|
|
30
|
+
#apiKey;
|
|
31
|
+
#fetch;
|
|
32
|
+
#options;
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
const apiKey = options.apiKey ?? readEnvApiKey();
|
|
35
|
+
if (!apiKey) {
|
|
36
|
+
throw new Error("wuapi: missing API key. Pass { apiKey } or set the WUAPI_API_KEY environment variable.");
|
|
37
|
+
}
|
|
38
|
+
this.#apiKey = apiKey;
|
|
39
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
40
|
+
this.timeoutMs = options.timeoutMs ?? 30_000;
|
|
41
|
+
this.maxRetries = Math.max(0, options.maxRetries ?? 2);
|
|
42
|
+
if (!options.fetch && typeof globalThis.fetch !== "function")
|
|
43
|
+
throw new Error("wuapi: no global fetch found. Use Node 18+ or pass { fetch }.");
|
|
44
|
+
this.#fetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
45
|
+
const project = options.project?.trim();
|
|
46
|
+
if (project !== undefined && project.length > 200)
|
|
47
|
+
throw new Error("wuapi: `project` must be at most 200 characters.");
|
|
48
|
+
this.project = project ? project : undefined;
|
|
49
|
+
this.#options = { ...options, apiKey };
|
|
50
|
+
}
|
|
51
|
+
/** A client with the same configuration, scoped to another project. */
|
|
52
|
+
withProject(project) {
|
|
53
|
+
if (!project || !project.trim())
|
|
54
|
+
throw new Error("wuapi: withProject needs a project id or `ext:<externalId>`.");
|
|
55
|
+
return new HttpClient({ ...this.#options, project });
|
|
56
|
+
}
|
|
57
|
+
buildUrl(path, query) {
|
|
58
|
+
let url = this.baseUrl + path;
|
|
59
|
+
if (query) {
|
|
60
|
+
const search = new URLSearchParams();
|
|
61
|
+
for (const [k, v] of Object.entries(query)) {
|
|
62
|
+
if (v !== undefined && v !== null)
|
|
63
|
+
search.append(k, String(v));
|
|
64
|
+
}
|
|
65
|
+
const s = search.toString();
|
|
66
|
+
if (s)
|
|
67
|
+
url += `?${s}`;
|
|
68
|
+
}
|
|
69
|
+
return url;
|
|
70
|
+
}
|
|
71
|
+
async request(opts) {
|
|
72
|
+
const url = this.buildUrl(opts.path, opts.query);
|
|
73
|
+
const headers = {
|
|
74
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
75
|
+
Accept: "application/json",
|
|
76
|
+
};
|
|
77
|
+
if (this.project)
|
|
78
|
+
headers[PROJECT_HEADER] = this.project;
|
|
79
|
+
// Every method is safe to repeat: GET/PUT/PATCH/DELETE by nature, POST
|
|
80
|
+
// through the idempotency key the server replays.
|
|
81
|
+
if (opts.method === "POST" || opts.idempotencyKey !== undefined) {
|
|
82
|
+
headers[IDEMPOTENCY_HEADER] = opts.idempotencyKey ?? randomKey();
|
|
83
|
+
}
|
|
84
|
+
let body;
|
|
85
|
+
if (opts.body !== undefined) {
|
|
86
|
+
headers["Content-Type"] = "application/json";
|
|
87
|
+
body = JSON.stringify(opts.body);
|
|
88
|
+
}
|
|
89
|
+
for (let attempt = 0;; attempt++) {
|
|
90
|
+
const canRetry = attempt < this.maxRetries;
|
|
91
|
+
let response;
|
|
92
|
+
const controller = new AbortController();
|
|
93
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
94
|
+
const onAbort = () => controller.abort();
|
|
95
|
+
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
96
|
+
try {
|
|
97
|
+
if (opts.signal?.aborted)
|
|
98
|
+
throw opts.signal.reason ?? new Error("Aborted");
|
|
99
|
+
response = await this.#fetch(url, {
|
|
100
|
+
method: opts.method,
|
|
101
|
+
headers,
|
|
102
|
+
...(body !== undefined ? { body } : {}),
|
|
103
|
+
signal: controller.signal,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (cause) {
|
|
107
|
+
clearTimeout(timer);
|
|
108
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
109
|
+
if (opts.signal?.aborted) {
|
|
110
|
+
throw new WuapiError({ status: 0, code: "aborted", message: "Request aborted.", cause });
|
|
111
|
+
}
|
|
112
|
+
const timedOut = controller.signal.aborted;
|
|
113
|
+
if (canRetry) {
|
|
114
|
+
await sleep(this.#backoff(attempt));
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
throw new WuapiError({
|
|
118
|
+
status: 0,
|
|
119
|
+
code: timedOut ? "timeout" : "network_error",
|
|
120
|
+
message: timedOut
|
|
121
|
+
? `Request timed out after ${this.timeoutMs} ms.`
|
|
122
|
+
: `Network error: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
123
|
+
cause,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
clearTimeout(timer);
|
|
127
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
128
|
+
if (response.ok) {
|
|
129
|
+
if (response.status === 204)
|
|
130
|
+
return undefined;
|
|
131
|
+
const text = await response.text();
|
|
132
|
+
return (text ? JSON.parse(text) : undefined);
|
|
133
|
+
}
|
|
134
|
+
const error = await this.#toError(response);
|
|
135
|
+
const retryable = response.status === 429 || response.status >= 500;
|
|
136
|
+
if (retryable && canRetry) {
|
|
137
|
+
const wait = error.retryAfter !== undefined
|
|
138
|
+
? Math.min(error.retryAfter * 1000, MAX_RETRY_AFTER_MS)
|
|
139
|
+
: this.#backoff(attempt);
|
|
140
|
+
await sleep(wait);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
#backoff(attempt) {
|
|
147
|
+
const base = Math.min(500 * 2 ** attempt, MAX_BACKOFF_MS);
|
|
148
|
+
return base / 2 + Math.random() * (base / 2);
|
|
149
|
+
}
|
|
150
|
+
async #toError(response) {
|
|
151
|
+
const requestId = response.headers.get("x-request-id") ?? undefined;
|
|
152
|
+
const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
|
|
153
|
+
let code = `http_${response.status}`;
|
|
154
|
+
let message = `Request failed with status ${response.status}.`;
|
|
155
|
+
let details;
|
|
156
|
+
try {
|
|
157
|
+
const text = await response.text();
|
|
158
|
+
if (text) {
|
|
159
|
+
const parsed = JSON.parse(text);
|
|
160
|
+
if (typeof parsed.code === "string")
|
|
161
|
+
code = parsed.code;
|
|
162
|
+
if (typeof parsed.message === "string")
|
|
163
|
+
message = parsed.message;
|
|
164
|
+
if (parsed.details && typeof parsed.details === "object") {
|
|
165
|
+
details = parsed.details;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Non-JSON body: keep the generic message.
|
|
171
|
+
}
|
|
172
|
+
return new WuapiError({ status: response.status, code, message, details, requestId, retryAfter });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export const enc = encodeURIComponent;
|
|
176
|
+
/** Spread into `RequestOptions`. */
|
|
177
|
+
export function callOpts(options) {
|
|
178
|
+
return { idempotencyKey: options?.idempotencyKey, signal: options?.signal };
|
|
179
|
+
}
|
|
180
|
+
/** A random idempotency key, so automatic retries never repeat a POST. */
|
|
181
|
+
export function randomKey() {
|
|
182
|
+
const c = globalThis.crypto;
|
|
183
|
+
if (c?.randomUUID)
|
|
184
|
+
return c.randomUUID();
|
|
185
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}${Math.random().toString(36).slice(2)}`;
|
|
186
|
+
}
|
|
187
|
+
/** `/v1/accounts/{accountId}` plus a suffix, with every segment encoded. */
|
|
188
|
+
export function accountPath(accountId, suffix = "") {
|
|
189
|
+
return `/v1/accounts/${enc(accountId)}${suffix}`;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,U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GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnH,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,MAAM,GAAG,EAAE;IACxD,OAAO,gBAAgB,GAAG,CAAC,SAAS,CAAC,GAAG,MAAM,EAAE,CAAC;AACnD,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Error thrown for any non-2xx API response, network failure or timeout. */
|
|
2
|
+
export declare class WuapiError extends Error {
|
|
3
|
+
/** HTTP status. 0 for network errors and timeouts. */
|
|
4
|
+
readonly status: number;
|
|
5
|
+
/** Machine-readable code, e.g. `invalid_request`, `account_not_ready`. */
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly details: Record<string, unknown> | undefined;
|
|
8
|
+
/** Value of the `x-request-id` response header, when present. */
|
|
9
|
+
readonly requestId: string | undefined;
|
|
10
|
+
/** Seconds from the `Retry-After` header, when present. */
|
|
11
|
+
readonly retryAfter: number | undefined;
|
|
12
|
+
constructor(init: {
|
|
13
|
+
status: number;
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
details?: Record<string, unknown> | undefined;
|
|
17
|
+
requestId?: string | undefined;
|
|
18
|
+
retryAfter?: number | undefined;
|
|
19
|
+
cause?: unknown;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Thrown by `verifyWebhook` when a signature is missing, malformed, wrong or stale. */
|
|
23
|
+
export declare class WebhookVerificationError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qBAAa,UAAW,SAAQ,KAAK;IACnC,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACtD,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE5B,IAAI,EAAE;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QAC9C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CASF;AAED,wFAAwF;AACxF,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Error thrown for any non-2xx API response, network failure or timeout. */
|
|
2
|
+
export class WuapiError extends Error {
|
|
3
|
+
/** HTTP status. 0 for network errors and timeouts. */
|
|
4
|
+
status;
|
|
5
|
+
/** Machine-readable code, e.g. `invalid_request`, `account_not_ready`. */
|
|
6
|
+
code;
|
|
7
|
+
details;
|
|
8
|
+
/** Value of the `x-request-id` response header, when present. */
|
|
9
|
+
requestId;
|
|
10
|
+
/** Seconds from the `Retry-After` header, when present. */
|
|
11
|
+
retryAfter;
|
|
12
|
+
constructor(init) {
|
|
13
|
+
super(init.message, init.cause !== undefined ? { cause: init.cause } : undefined);
|
|
14
|
+
this.name = "WuapiError";
|
|
15
|
+
this.status = init.status;
|
|
16
|
+
this.code = init.code;
|
|
17
|
+
this.details = init.details;
|
|
18
|
+
this.requestId = init.requestId;
|
|
19
|
+
this.retryAfter = init.retryAfter;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Thrown by `verifyWebhook` when a signature is missing, malformed, wrong or stale. */
|
|
23
|
+
export class WebhookVerificationError extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "WebhookVerificationError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,sDAAsD;IAC7C,MAAM,CAAS;IACxB,0EAA0E;IACjE,IAAI,CAAS;IACb,OAAO,CAAsC;IACtD,iEAAiE;IACxD,SAAS,CAAqB;IACvC,2DAA2D;IAClD,UAAU,CAAqB;IAExC,YAAY,IAQX;QACC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAClF,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;CACF;AAED,wFAAwF;AACxF,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { Wuapi } from "./client.js";
|
|
2
|
+
export { Wuapi as default } from "./client.js";
|
|
3
|
+
export { VERSION, DEFAULT_BASE_URL, PROJECT_HEADER, IDEMPOTENCY_HEADER } from "./core.js";
|
|
4
|
+
export type { ClientOptions, FetchLike } from "./core.js";
|
|
5
|
+
export { WuapiError, WebhookVerificationError } from "./errors.js";
|
|
6
|
+
export { Paginator } from "./pagination.js";
|
|
7
|
+
export { verifyWebhook, computeSignature } from "./webhook.js";
|
|
8
|
+
export type { Accounts, ProxyLocations, WaitOptions, WaitUntilReadyOptions } from "./resources/accounts.js";
|
|
9
|
+
export type { Messages, Stories } from "./resources/messages.js";
|
|
10
|
+
export type { Chats, Labels } from "./resources/chats.js";
|
|
11
|
+
export type { Contacts, Bots, Profile, Privacy } from "./resources/contacts.js";
|
|
12
|
+
export type { Groups } from "./resources/groups.js";
|
|
13
|
+
export type { Channels } from "./resources/channels.js";
|
|
14
|
+
export type { Calls, StickerPacks, Orders } from "./resources/misc.js";
|
|
15
|
+
export type { Projects, ProjectApiKeys, Invitations, WebhookEndpoints, BrandingResource, UsageResource, } from "./resources/projects.js";
|
|
16
|
+
export * from "./types.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC1F,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC5G,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACjE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAChF,YAAY,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACvE,YAAY,EACV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Wuapi } from "./client.js";
|
|
2
|
+
export { Wuapi as default } from "./client.js";
|
|
3
|
+
export { VERSION, DEFAULT_BASE_URL, PROJECT_HEADER, IDEMPOTENCY_HEADER } from "./core.js";
|
|
4
|
+
export { WuapiError, WebhookVerificationError } from "./errors.js";
|
|
5
|
+
export { Paginator } from "./pagination.js";
|
|
6
|
+
export { verifyWebhook, computeSignature } from "./webhook.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAgB/D,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ListParams, Page } from "./types.js";
|
|
2
|
+
export type PageFetcher<T, P extends ListParams> = (params: P) => Promise<Page<T>>;
|
|
3
|
+
/**
|
|
4
|
+
* A list result. Iterate it with `for await` to walk every item across pages,
|
|
5
|
+
* or call `page()` for a single page.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* for await (const message of client.messages.list({ accountId })) { ... }
|
|
9
|
+
* const { items, nextCursor } = await client.messages.list({ limit: 20 }).page();
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class Paginator<T, P extends ListParams = ListParams> implements AsyncIterable<T> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(fetch: PageFetcher<T, P>, params: P);
|
|
15
|
+
/** Fetch one page. Defaults to the cursor the list was created with. */
|
|
16
|
+
page(cursor?: string): Promise<Page<T>>;
|
|
17
|
+
/** Iterate page by page. */
|
|
18
|
+
pages(): AsyncGenerator<Page<T>, void, undefined>;
|
|
19
|
+
[Symbol.asyncIterator](): AsyncGenerator<T, void, undefined>;
|
|
20
|
+
/** Collect every item into an array. Stops after `max` items when given. */
|
|
21
|
+
toArray(max?: number): Promise<T[]>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnF;;;;;;;;GAQG;AACH,qBAAa,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;;gBAI1E,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;IAK/C,wEAAwE;IACxE,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAMvC,4BAA4B;IACrB,KAAK,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC;IAUjD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC;IAMnE,4EAA4E;IACtE,OAAO,CAAC,GAAG,SAAW,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;CAS5C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list result. Iterate it with `for await` to walk every item across pages,
|
|
3
|
+
* or call `page()` for a single page.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* for await (const message of client.messages.list({ accountId })) { ... }
|
|
7
|
+
* const { items, nextCursor } = await client.messages.list({ limit: 20 }).page();
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export class Paginator {
|
|
11
|
+
#fetch;
|
|
12
|
+
#params;
|
|
13
|
+
constructor(fetch, params) {
|
|
14
|
+
this.#fetch = fetch;
|
|
15
|
+
this.#params = params;
|
|
16
|
+
}
|
|
17
|
+
/** Fetch one page. Defaults to the cursor the list was created with. */
|
|
18
|
+
page(cursor) {
|
|
19
|
+
const params = { ...this.#params };
|
|
20
|
+
if (cursor !== undefined)
|
|
21
|
+
params.cursor = cursor;
|
|
22
|
+
return this.#fetch(params);
|
|
23
|
+
}
|
|
24
|
+
/** Iterate page by page. */
|
|
25
|
+
async *pages() {
|
|
26
|
+
let cursor = this.#params.cursor;
|
|
27
|
+
for (;;) {
|
|
28
|
+
const page = await this.page(cursor);
|
|
29
|
+
yield page;
|
|
30
|
+
if (!page.nextCursor)
|
|
31
|
+
return;
|
|
32
|
+
cursor = page.nextCursor;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async *[Symbol.asyncIterator]() {
|
|
36
|
+
for await (const page of this.pages()) {
|
|
37
|
+
yield* page.items;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Collect every item into an array. Stops after `max` items when given. */
|
|
41
|
+
async toArray(max = Infinity) {
|
|
42
|
+
const out = [];
|
|
43
|
+
if (max <= 0)
|
|
44
|
+
return out;
|
|
45
|
+
for await (const item of this) {
|
|
46
|
+
out.push(item);
|
|
47
|
+
if (out.length >= max)
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceR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EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG;gBAAE,MAAM;QAC/B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Paginator } from "../pagination.js";
|
|
2
|
+
import type { Account, AccountCreateParams, AccountListParams, AccountPresenceState, AccountUpdateParams, CallOptions, DisappearingSeconds, PairingCode, ProxyLocationItem, ProxyLocationListParams } from "../types.js";
|
|
3
|
+
import { Resource } from "./base.js";
|
|
4
|
+
export interface WaitOptions {
|
|
5
|
+
/** Poll interval in milliseconds. Defaults to 2000. */
|
|
6
|
+
intervalMs?: number;
|
|
7
|
+
/** Give up after this many milliseconds. Defaults to 180000 (3 minutes). */
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
export interface WaitUntilReadyOptions extends WaitOptions {
|
|
12
|
+
/** Called every time a new QR code appears (including rotations), with its PNG data URL. */
|
|
13
|
+
onQrCode?: (qrCodeUrl: string, account: Account) => void;
|
|
14
|
+
/** Called every time a new pairing code appears, for accounts linking by phone number. */
|
|
15
|
+
onPairingCode?: (code: string, account: Account) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare class Accounts extends Resource {
|
|
18
|
+
#private;
|
|
19
|
+
/** List accounts, newest first. Iterate with `for await` or call `.page()`. */
|
|
20
|
+
list(params?: AccountListParams, options?: CallOptions): Paginator<Account, AccountListParams>;
|
|
21
|
+
/**
|
|
22
|
+
* Start linking a new number, exiting from `proxyLocation` (see
|
|
23
|
+
* `proxyLocations.list()`). A new organization links its first account
|
|
24
|
+
* with no card; after that it needs an active or trialing subscription
|
|
25
|
+
* (402 otherwise). Pass `pairingPhone` to link by pairing code instead of QR
|
|
26
|
+
* code, then `waitForPairingCode`.
|
|
27
|
+
*/
|
|
28
|
+
create(params: AccountCreateParams, options?: CallOptions): Promise<Account>;
|
|
29
|
+
get(accountId: string, options?: CallOptions): Promise<Account>;
|
|
30
|
+
/** Rename it, set automatic call rejection, or tune its `pacing` (`null` resets it). */
|
|
31
|
+
update(accountId: string, params: AccountUpdateParams, options?: CallOptions): Promise<Account>;
|
|
32
|
+
/** Unlink from the phone, delete the account and stop billing for it. */
|
|
33
|
+
delete(accountId: string, options?: CallOptions): Promise<void>;
|
|
34
|
+
/** Restart the session. Produces a fresh QR code when the link is no longer valid. */
|
|
35
|
+
reconnect(accountId: string, options?: CallOptions): Promise<Account>;
|
|
36
|
+
/** Unlink from the phone and stop billing, keeping the account and its messages. */
|
|
37
|
+
logout(accountId: string, options?: CallOptions): Promise<Account>;
|
|
38
|
+
/**
|
|
39
|
+
* Request a pairing code to link by phone number instead of QR code. The
|
|
40
|
+
* owner types it in WhatsApp > Linked devices > Link a device > Link with
|
|
41
|
+
* phone number instead. It lives about 160 seconds. 409 `already_linked`
|
|
42
|
+
* when the account is ready.
|
|
43
|
+
*/
|
|
44
|
+
createPairingCode(accountId: string, params: {
|
|
45
|
+
phone: string;
|
|
46
|
+
}, options?: CallOptions): Promise<PairingCode>;
|
|
47
|
+
/** Show the account as online or offline to contacts. */
|
|
48
|
+
setPresence(accountId: string, state: AccountPresenceState, options?: CallOptions): Promise<void>;
|
|
49
|
+
/** The disappearing-messages timer for new chats. 0 turns it off. */
|
|
50
|
+
setDefaultDisappearingTimer(accountId: string, durationSeconds: DisappearingSeconds, options?: CallOptions): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Poll until the account has a QR code to scan, and return it with
|
|
53
|
+
* `qrCodeUrl` set. Returns the account as is if it is already `ready`.
|
|
54
|
+
* Throws a `WuapiError` with code `account_failed` if it reaches `failed`,
|
|
55
|
+
* or `wait_timeout` after `timeoutMs`.
|
|
56
|
+
*/
|
|
57
|
+
waitForQrCode(accountId: string, options?: WaitOptions): Promise<Account>;
|
|
58
|
+
/**
|
|
59
|
+
* Poll until the account has a pairing code to type on the phone. For
|
|
60
|
+
* accounts created with `pairingPhone`, or after `createPairingCode()`.
|
|
61
|
+
*/
|
|
62
|
+
waitForPairingCode(accountId: string, options?: WaitOptions): Promise<Account>;
|
|
63
|
+
/**
|
|
64
|
+
* Poll until the account is `ready` and return it. `onQrCode` and
|
|
65
|
+
* `onPairingCode` are told about each new code (they rotate while waiting).
|
|
66
|
+
*/
|
|
67
|
+
waitUntilReady(accountId: string, options?: WaitUntilReadyOptions): Promise<Account>;
|
|
68
|
+
}
|
|
69
|
+
export declare class ProxyLocations extends Resource {
|
|
70
|
+
/**
|
|
71
|
+
* Every supported `{country, city}` pair, ordered by country name, then by city population, largest first.
|
|
72
|
+
* Filter with `country`, or search with `q` (`{ q: "sao" }` finds São Paulo); a search comes back best match first.
|
|
73
|
+
*/
|
|
74
|
+
list(params?: ProxyLocationListParams, options?: CallOptions): Paginator<ProxyLocationItem, ProxyLocationListParams>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD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CAAC;IAI5G,yDAAyD;IACzD,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG,qEAAqE;IACrE,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1H;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ7E;;;OAGG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlF;;;OAGG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,OAAO,CAAC;CAyCzF;AAED,qBAAa,cAAe,SAAQ,QAAQ;IAC1C;;;OAGG;IACH,IAAI,CAAC,MAAM,GAAE,uBAA4B,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;CAGzH"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { accountPath } from "../core.js";
|
|
2
|
+
import { WuapiError } from "../errors.js";
|
|
3
|
+
import { Resource } from "./base.js";
|
|
4
|
+
const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
5
|
+
if (signal?.aborted)
|
|
6
|
+
return reject(signal.reason ?? new Error("Aborted"));
|
|
7
|
+
const t = setTimeout(() => {
|
|
8
|
+
signal?.removeEventListener("abort", onAbort);
|
|
9
|
+
resolve();
|
|
10
|
+
}, ms);
|
|
11
|
+
const onAbort = () => {
|
|
12
|
+
clearTimeout(t);
|
|
13
|
+
reject(signal?.reason ?? new Error("Aborted"));
|
|
14
|
+
};
|
|
15
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
16
|
+
});
|
|
17
|
+
export class Accounts extends Resource {
|
|
18
|
+
/** List accounts, newest first. Iterate with `for await` or call `.page()`. */
|
|
19
|
+
list(params = {}, options) {
|
|
20
|
+
return this._list("/v1/accounts", params, (p) => ({ projectId: p.projectId }), options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Start linking a new number, exiting from `proxyLocation` (see
|
|
24
|
+
* `proxyLocations.list()`). A new organization links its first account
|
|
25
|
+
* with no card; after that it needs an active or trialing subscription
|
|
26
|
+
* (402 otherwise). Pass `pairingPhone` to link by pairing code instead of QR
|
|
27
|
+
* code, then `waitForPairingCode`.
|
|
28
|
+
*/
|
|
29
|
+
create(params, options) {
|
|
30
|
+
return this._post("/v1/accounts", params, options);
|
|
31
|
+
}
|
|
32
|
+
get(accountId, options) {
|
|
33
|
+
return this._get(accountPath(accountId), undefined, options);
|
|
34
|
+
}
|
|
35
|
+
/** Rename it, set automatic call rejection, or tune its `pacing` (`null` resets it). */
|
|
36
|
+
update(accountId, params, options) {
|
|
37
|
+
return this._patch(accountPath(accountId), params, options);
|
|
38
|
+
}
|
|
39
|
+
/** Unlink from the phone, delete the account and stop billing for it. */
|
|
40
|
+
delete(accountId, options) {
|
|
41
|
+
return this._delete(accountPath(accountId), undefined, options);
|
|
42
|
+
}
|
|
43
|
+
/** Restart the session. Produces a fresh QR code when the link is no longer valid. */
|
|
44
|
+
reconnect(accountId, options) {
|
|
45
|
+
return this._post(accountPath(accountId, "/reconnect"), undefined, options);
|
|
46
|
+
}
|
|
47
|
+
/** Unlink from the phone and stop billing, keeping the account and its messages. */
|
|
48
|
+
logout(accountId, options) {
|
|
49
|
+
return this._post(accountPath(accountId, "/logout"), undefined, options);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Request a pairing code to link by phone number instead of QR code. The
|
|
53
|
+
* owner types it in WhatsApp > Linked devices > Link a device > Link with
|
|
54
|
+
* phone number instead. It lives about 160 seconds. 409 `already_linked`
|
|
55
|
+
* when the account is ready.
|
|
56
|
+
*/
|
|
57
|
+
createPairingCode(accountId, params, options) {
|
|
58
|
+
return this._post(accountPath(accountId, "/pairing-code"), params, options);
|
|
59
|
+
}
|
|
60
|
+
/** Show the account as online or offline to contacts. */
|
|
61
|
+
setPresence(accountId, state, options) {
|
|
62
|
+
return this._post(accountPath(accountId, "/presence"), { state }, options);
|
|
63
|
+
}
|
|
64
|
+
/** The disappearing-messages timer for new chats. 0 turns it off. */
|
|
65
|
+
setDefaultDisappearingTimer(accountId, durationSeconds, options) {
|
|
66
|
+
return this._put(accountPath(accountId, "/disappearing-timer"), { durationSeconds }, options);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Poll until the account has a QR code to scan, and return it with
|
|
70
|
+
* `qrCodeUrl` set. Returns the account as is if it is already `ready`.
|
|
71
|
+
* Throws a `WuapiError` with code `account_failed` if it reaches `failed`,
|
|
72
|
+
* or `wait_timeout` after `timeoutMs`.
|
|
73
|
+
*/
|
|
74
|
+
waitForQrCode(accountId, options = {}) {
|
|
75
|
+
return this.#poll(accountId, options, (account) => (account.status === "qr_ready" && account.qrCodeUrl !== null) || account.status === "ready");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Poll until the account has a pairing code to type on the phone. For
|
|
79
|
+
* accounts created with `pairingPhone`, or after `createPairingCode()`.
|
|
80
|
+
*/
|
|
81
|
+
waitForPairingCode(accountId, options = {}) {
|
|
82
|
+
return this.#poll(accountId, options, (account) => account.pairingCode !== null || account.status === "ready");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Poll until the account is `ready` and return it. `onQrCode` and
|
|
86
|
+
* `onPairingCode` are told about each new code (they rotate while waiting).
|
|
87
|
+
*/
|
|
88
|
+
waitUntilReady(accountId, options = {}) {
|
|
89
|
+
let lastQr = null;
|
|
90
|
+
let lastCode = null;
|
|
91
|
+
return this.#poll(accountId, options, (account) => {
|
|
92
|
+
if (account.status === "qr_ready" && account.qrCodeUrl && account.qrCodeUrl !== lastQr) {
|
|
93
|
+
lastQr = account.qrCodeUrl;
|
|
94
|
+
options.onQrCode?.(account.qrCodeUrl, account);
|
|
95
|
+
}
|
|
96
|
+
if (account.status !== "ready" && account.pairingCode && account.pairingCode !== lastCode) {
|
|
97
|
+
lastCode = account.pairingCode;
|
|
98
|
+
options.onPairingCode?.(account.pairingCode, account);
|
|
99
|
+
}
|
|
100
|
+
return account.status === "ready";
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async #poll(accountId, options, done) {
|
|
104
|
+
const interval = options.intervalMs ?? 2_000;
|
|
105
|
+
const deadline = Date.now() + (options.timeoutMs ?? 180_000);
|
|
106
|
+
for (;;) {
|
|
107
|
+
const account = await this.get(accountId, options.signal ? { signal: options.signal } : undefined);
|
|
108
|
+
if (done(account))
|
|
109
|
+
return account;
|
|
110
|
+
if (account.status === "failed") {
|
|
111
|
+
throw new WuapiError({
|
|
112
|
+
status: 0,
|
|
113
|
+
code: "account_failed",
|
|
114
|
+
message: `Account ${accountId} failed${account.lastError ? `: ${account.lastError}` : ""}.`,
|
|
115
|
+
details: { account },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (Date.now() + interval > deadline) {
|
|
119
|
+
throw new WuapiError({
|
|
120
|
+
status: 0,
|
|
121
|
+
code: "wait_timeout",
|
|
122
|
+
message: `Timed out waiting for account ${accountId}. Last status: ${account.status}.`,
|
|
123
|
+
details: { account },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
await sleep(interval, options.signal);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export class ProxyLocations extends Resource {
|
|
131
|
+
/**
|
|
132
|
+
* Every supported `{country, city}` pair, ordered by country name, then by city population, largest first.
|
|
133
|
+
* Filter with `country`, or search with `q` (`{ q: "sao" }` finds São Paulo); a search comes back best match first.
|
|
134
|
+
*/
|
|
135
|
+
list(params = {}, options) {
|
|
136
|
+
return this._list("/v1/proxy-locations", params, (p) => ({ country: p.country, q: p.q }), options);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAiBrC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,MAAoB,EAAE,EAAE,CACjD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACpC,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE;QACxB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,YAAY,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEL,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,+EAA+E;IAC/E,IAAI,CAAC,SAA4B,EAAE,EAAE,OAAqB;QACxD,OAAO,IAAI,CAAC,KAAK,CAAC,cAA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