@pilot-status/sdk 0.4.0 → 0.8.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 +51 -0
- package/README.md +203 -17
- package/dist/client.d.ts +53 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -4
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +58 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +65 -0
- package/dist/errors.js.map +1 -1
- package/dist/http.d.ts +7 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +19 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +27 -0
- package/dist/internal.js.map +1 -0
- package/dist/resources/api-keys.d.ts +20 -7
- package/dist/resources/api-keys.d.ts.map +1 -1
- package/dist/resources/api-keys.js +18 -5
- package/dist/resources/api-keys.js.map +1 -1
- package/dist/resources/billing.d.ts +18 -0
- package/dist/resources/billing.d.ts.map +1 -0
- package/dist/resources/billing.js +30 -0
- package/dist/resources/billing.js.map +1 -0
- package/dist/resources/branding.d.ts +18 -0
- package/dist/resources/branding.d.ts.map +1 -0
- package/dist/resources/branding.js +29 -0
- package/dist/resources/branding.js.map +1 -0
- package/dist/resources/chatwoot.d.ts +57 -0
- package/dist/resources/chatwoot.d.ts.map +1 -0
- package/dist/resources/chatwoot.js +117 -0
- package/dist/resources/chatwoot.js.map +1 -0
- package/dist/resources/conversations.d.ts +16 -0
- package/dist/resources/conversations.d.ts.map +1 -0
- package/dist/resources/conversations.js +28 -0
- package/dist/resources/conversations.js.map +1 -0
- package/dist/resources/embed.d.ts +24 -0
- package/dist/resources/embed.d.ts.map +1 -0
- package/dist/resources/embed.js +37 -0
- package/dist/resources/embed.js.map +1 -0
- package/dist/resources/flows.d.ts +203 -0
- package/dist/resources/flows.d.ts.map +1 -0
- package/dist/resources/flows.js +289 -0
- package/dist/resources/flows.js.map +1 -0
- package/dist/resources/groups.d.ts +37 -1
- package/dist/resources/groups.d.ts.map +1 -1
- package/dist/resources/groups.js +91 -0
- package/dist/resources/groups.js.map +1 -1
- package/dist/resources/messages.d.ts +61 -1
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +134 -1
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/meta.d.ts +19 -0
- package/dist/resources/meta.d.ts.map +1 -0
- package/dist/resources/meta.js +31 -0
- package/dist/resources/meta.js.map +1 -0
- package/dist/resources/numbers.d.ts +102 -1
- package/dist/resources/numbers.d.ts.map +1 -1
- package/dist/resources/numbers.js +152 -0
- package/dist/resources/numbers.js.map +1 -1
- package/dist/resources/service-window.d.ts +20 -0
- package/dist/resources/service-window.d.ts.map +1 -0
- package/dist/resources/service-window.js +26 -0
- package/dist/resources/service-window.js.map +1 -0
- package/dist/resources/subscription.d.ts +43 -0
- package/dist/resources/subscription.d.ts.map +1 -0
- package/dist/resources/subscription.js +60 -0
- package/dist/resources/subscription.js.map +1 -0
- package/dist/resources/templates.d.ts +31 -1
- package/dist/resources/templates.d.ts.map +1 -1
- package/dist/resources/templates.js +56 -0
- package/dist/resources/templates.js.map +1 -1
- package/dist/resources/webhooks.d.ts +53 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +97 -0
- package/dist/resources/webhooks.js.map +1 -0
- package/dist/resources/workspace.d.ts +57 -0
- package/dist/resources/workspace.d.ts.map +1 -0
- package/dist/resources/workspace.js +73 -0
- package/dist/resources/workspace.js.map +1 -0
- package/dist/types.d.ts +957 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/webhooks/parse.d.ts +16 -0
- package/dist/webhooks/parse.d.ts.map +1 -1
- package/dist/webhooks/parse.js +49 -0
- package/dist/webhooks/parse.js.map +1 -1
- package/dist/webhooks/signature.d.ts +42 -0
- package/dist/webhooks/signature.d.ts.map +1 -0
- package/dist/webhooks/signature.js +40 -0
- package/dist/webhooks/signature.js.map +1 -0
- package/dist/webhooks/types.d.ts +59 -1
- package/dist/webhooks/types.d.ts.map +1 -1
- package/package.json +5 -3
- package/dist/messages.test.d.ts +0 -2
- package/dist/messages.test.d.ts.map +0 -1
- package/dist/messages.test.js +0 -107
- package/dist/messages.test.js.map +0 -1
- package/dist/numbers.test.d.ts +0 -2
- package/dist/numbers.test.d.ts.map +0 -1
- package/dist/numbers.test.js +0 -57
- package/dist/numbers.test.js.map +0 -1
- package/dist/resources/groups.test.d.ts +0 -2
- package/dist/resources/groups.test.d.ts.map +0 -1
- package/dist/resources/groups.test.js +0 -19
- package/dist/resources/groups.test.js.map +0 -1
- package/dist/resources/newsletters.test.d.ts +0 -2
- package/dist/resources/newsletters.test.d.ts.map +0 -1
- package/dist/resources/newsletters.test.js +0 -19
- package/dist/resources/newsletters.test.js.map +0 -1
- package/dist/resources/projects.d.ts +0 -9
- package/dist/resources/projects.d.ts.map +0 -1
- package/dist/resources/projects.js +0 -23
- package/dist/resources/projects.js.map +0 -1
- package/dist/resources/templates.test.d.ts +0 -2
- package/dist/resources/templates.test.d.ts.map +0 -1
- package/dist/resources/templates.test.js +0 -28
- package/dist/resources/templates.test.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compact } from "../internal.js";
|
|
1
2
|
export class MessagesResource {
|
|
2
3
|
#http;
|
|
3
4
|
constructor(http) {
|
|
@@ -28,7 +29,7 @@ export class MessagesResource {
|
|
|
28
29
|
...(input.media
|
|
29
30
|
? { media: input.media, mediaType: input.mediaType ?? "image" }
|
|
30
31
|
: {}),
|
|
31
|
-
...(input.buttons?.length ? { buttons: input.buttons } : {}),
|
|
32
|
+
...(input.buttons?.length ? { buttons: input.buttons.map(withButtonText) } : {}),
|
|
32
33
|
...(input.text ? { text: input.text } : {}),
|
|
33
34
|
...(input.header ? { header: input.header } : {}),
|
|
34
35
|
...(input.footer ? { footer: input.footer } : {}),
|
|
@@ -41,6 +42,35 @@ export class MessagesResource {
|
|
|
41
42
|
path: `/v1/messages/${encodeURIComponent(id)}`,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The conversation history of the key's number, newest first — both
|
|
47
|
+
* directions, every provider, including messages imported from the device on
|
|
48
|
+
* connect. This is the way to fetch old messages: the webhook does not replay
|
|
49
|
+
* history by default (see `numbers.updateSettings`).
|
|
50
|
+
*
|
|
51
|
+
* Not to be confused with the message LOG: `get()` tracks the delivery status
|
|
52
|
+
* of something you sent; this is the chat thread itself.
|
|
53
|
+
*
|
|
54
|
+
* `startDate`/`endDate` filter `providerTimestamp` — when the message actually
|
|
55
|
+
* happened, not when we ingested it. `startDate` after `endDate` throws a 400
|
|
56
|
+
* with `code: "INVALID_DATE_RANGE"`.
|
|
57
|
+
*
|
|
58
|
+
* Requires a NUMBER-scoped API key; a tenant-scoped key gets a 400. Rows
|
|
59
|
+
* outside the number's PII retention window are still returned, with content,
|
|
60
|
+
* media and peer identity nulled and `redacted: true` set.
|
|
61
|
+
*/
|
|
62
|
+
async history(params) {
|
|
63
|
+
return this.#http.requestJson({
|
|
64
|
+
method: "GET",
|
|
65
|
+
path: "/v1/messages/history",
|
|
66
|
+
query: {
|
|
67
|
+
startDate: params?.startDate,
|
|
68
|
+
endDate: params?.endDate,
|
|
69
|
+
page: params?.page,
|
|
70
|
+
pageSize: params?.pageSize,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
44
74
|
async cancel(messageIds) {
|
|
45
75
|
return this.#http.requestJson({
|
|
46
76
|
method: "DELETE",
|
|
@@ -48,5 +78,108 @@ export class MessagesResource {
|
|
|
48
78
|
body: { messageIds },
|
|
49
79
|
});
|
|
50
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* The number's message LOG (`GET /v1/messages`), newest first, with the
|
|
83
|
+
* delivery status of each one.
|
|
84
|
+
*
|
|
85
|
+
* Not to be confused with {@link history}: here is the operational trail
|
|
86
|
+
* (status, `errorCode`, `origin`, whether the 24h window was open at send
|
|
87
|
+
* time); there is the conversation. `status` is a COMMA-SEPARATED list inside a
|
|
88
|
+
* single string, not an array — that is what the server reads.
|
|
89
|
+
*/
|
|
90
|
+
async list(params) {
|
|
91
|
+
return this.#http.requestJson({
|
|
92
|
+
method: "GET",
|
|
93
|
+
path: "/v1/messages",
|
|
94
|
+
query: compact({
|
|
95
|
+
page: params?.page,
|
|
96
|
+
pageSize: params?.pageSize,
|
|
97
|
+
status: params?.status,
|
|
98
|
+
direction: params?.direction,
|
|
99
|
+
startDate: params?.startDate,
|
|
100
|
+
endDate: params?.endDate,
|
|
101
|
+
search: params?.search,
|
|
102
|
+
templateId: params?.templateId,
|
|
103
|
+
window: params?.window,
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Stored group messages (`GET /v1/messages/group`). Empty on `RELAY_ONLY`. */
|
|
108
|
+
async group(params) {
|
|
109
|
+
return this.#http.requestJson({
|
|
110
|
+
method: "GET",
|
|
111
|
+
path: "/v1/messages/group",
|
|
112
|
+
query: compact({
|
|
113
|
+
startDate: params?.startDate,
|
|
114
|
+
endDate: params?.endDate,
|
|
115
|
+
page: params?.page,
|
|
116
|
+
pageSize: params?.pageSize,
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Unread inbound messages (`GET /v1/messages/unread`).
|
|
122
|
+
*
|
|
123
|
+
* `total` is the real unread count (the same one the dashboard shows, coming
|
|
124
|
+
* from the conversation counters) — it is NOT `messages.length`, because the
|
|
125
|
+
* list only carries the latest unread of each conversation. Empty on
|
|
126
|
+
* `RELAY_ONLY`.
|
|
127
|
+
*/
|
|
128
|
+
async unread(params) {
|
|
129
|
+
return this.#http.requestJson({
|
|
130
|
+
method: "GET",
|
|
131
|
+
path: "/v1/messages/unread",
|
|
132
|
+
query: compact({ page: params?.page, pageSize: params?.pageSize }),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Acknowledges the read receipt (blue tick) of the LAST message received from
|
|
137
|
+
* `to`, and of every earlier one, without sending any message at all
|
|
138
|
+
* (`POST /v1/messages/read`).
|
|
139
|
+
*
|
|
140
|
+
* Best-effort: a 200 with `acked: false` is the normal "there was nothing to
|
|
141
|
+
* acknowledge" case (empty thread) or a number on `RELAY_ONLY` — check `acked`,
|
|
142
|
+
* not just the HTTP status.
|
|
143
|
+
*/
|
|
144
|
+
async markRead(to) {
|
|
145
|
+
return this.#http.requestJson({
|
|
146
|
+
method: "POST",
|
|
147
|
+
path: "/v1/messages/read",
|
|
148
|
+
body: { to },
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Shows "typing…" / "recording…" to a contact, without sending a message
|
|
153
|
+
* (`POST /v1/messages/typing`). `state` defaults to `"typing"`.
|
|
154
|
+
*
|
|
155
|
+
* The indicator clears on its own once a message is sent, or on a provider
|
|
156
|
+
* timeout (~25s on Meta). On a META number the parity is not complete and the
|
|
157
|
+
* server tells you what it did in `effectiveState`: `"recording"` becomes
|
|
158
|
+
* `"typing"` (the Cloud API has no recording variant) and `"paused"` is a
|
|
159
|
+
* no-op. On the Evolution providers the three states are relayed as-is.
|
|
160
|
+
*/
|
|
161
|
+
async typing(input) {
|
|
162
|
+
return this.#http.requestJson({
|
|
163
|
+
method: "POST",
|
|
164
|
+
path: "/v1/messages/typing",
|
|
165
|
+
body: compact({ to: input.to, state: input.state }),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Maps the deprecated `label` onto `displayText`, which is the field the platform
|
|
171
|
+
* actually reads.
|
|
172
|
+
*
|
|
173
|
+
* ⚠️ This exists because the SDK's `Button` type declared `label` as its ONLY text
|
|
174
|
+
* field, and nothing on the other side reads it: the request schema passes it through
|
|
175
|
+
* untouched and the Meta adapter builds the button from `displayText`. Every button
|
|
176
|
+
* sent by an SDK user who followed the types arrived with an empty title — accepted,
|
|
177
|
+
* delivered, blank. Rather than break the published type by removing `label`, the
|
|
178
|
+
* mapping happens here, and `displayText` wins when both are set.
|
|
179
|
+
*/
|
|
180
|
+
function withButtonText(button) {
|
|
181
|
+
if (button.displayText || button.text || !button.label)
|
|
182
|
+
return button;
|
|
183
|
+
return { ...button, displayText: button.label };
|
|
51
184
|
}
|
|
52
185
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAoBzC,MAAM,OAAO,gBAAgB;IAClB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAuB;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE;gBACJ,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7D,GAAG,CAAC,KAAK,CAAC,iBAAiB;oBACzB,CAAC,CAAC,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE;oBAChD,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,E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AC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CAAC,KAAkB;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAe;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;SACpD,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,SAAS,cAAc,CAAC,MAAc;IAClC,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,MAAM,CAAC;IACtE,OAAO,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { MetaPricingParams, MetaPricingResult } from "../types.js";
|
|
3
|
+
/** The Meta surface that does not belong to a number (`/v1/meta/*`). */
|
|
4
|
+
export declare class MetaResource {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
/**
|
|
8
|
+
* Meta's PUBLIC rate card by market + currency + category
|
|
9
|
+
* (`GET /v1/meta/pricing`).
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ This is not what your account pays — it is the table Meta publishes. For
|
|
12
|
+
* actual cost use the wallet statement.
|
|
13
|
+
*
|
|
14
|
+
* With no arguments it returns the available markets/currencies/categories;
|
|
15
|
+
* with all three, the price; with `tiers: true`, also the volume tiers.
|
|
16
|
+
*/
|
|
17
|
+
pricing(params?: MetaPricingParams): Promise<MetaPricingResult>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/resources/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAExE,wEAAwE;AACxE,qBAAa,YAAY;;gBAGT,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;OASG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAYxE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { compact } from "../internal.js";
|
|
2
|
+
/** The Meta surface that does not belong to a number (`/v1/meta/*`). */
|
|
3
|
+
export class MetaResource {
|
|
4
|
+
#http;
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.#http = http;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Meta's PUBLIC rate card by market + currency + category
|
|
10
|
+
* (`GET /v1/meta/pricing`).
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ This is not what your account pays — it is the table Meta publishes. For
|
|
13
|
+
* actual cost use the wallet statement.
|
|
14
|
+
*
|
|
15
|
+
* With no arguments it returns the available markets/currencies/categories;
|
|
16
|
+
* with all three, the price; with `tiers: true`, also the volume tiers.
|
|
17
|
+
*/
|
|
18
|
+
async pricing(params) {
|
|
19
|
+
return this.#http.requestJson({
|
|
20
|
+
method: "GET",
|
|
21
|
+
path: "/v1/meta/pricing",
|
|
22
|
+
query: compact({
|
|
23
|
+
market: params?.market,
|
|
24
|
+
currency: params?.currency,
|
|
25
|
+
category: params?.category,
|
|
26
|
+
tiers: params?.tiers,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/resources/meta.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,wEAAwE;AACxE,MAAM,OAAO,YAAY;IACZ,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,CAAC,MAA0B;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAoB;YAC7C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE,OAAO,CAAC;gBACX,MAAM,EAAE,MAAM,EAAE,MAAM;gBACtB,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,KAAK,EAAE,MAAM,EAAE,KAAK;aACvB,CAAC;SACL,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type { CreateNumberInput, CreateNumberResult, DeleteNumberResult, NumberConnectResult, NumberStatusResult, RemotePairingInput, RemotePairingResult, WhatsAppNumberListItem } from "../types.js";
|
|
2
|
+
import type { CheckNumbersInput, CheckNumbersResult, CreateMetaNumberInput, CreateNumberInput, CreateNumberResult, DeleteNumberResult, NumberConnectResult, NumberDetail, NumberLogoutResult, NumberPurgeResult, NumberRestoreResult, NumberSettingsInput, NumberStatusResult, RemotePairingInput, RemotePairingResult, UpdateNumberInput, UpdateNumberResult, WhatsAppNumberListItem } from "../types.js";
|
|
3
3
|
export declare class NumbersResource {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(http: HttpClient);
|
|
@@ -12,9 +12,110 @@ export declare class NumbersResource {
|
|
|
12
12
|
* one (`lastKnownAt`) because the provider did not answer. A 503 throws
|
|
13
13
|
* with `body.code` = `NumberStatusFailureCode` — `PROVIDER_NOT_CONFIGURED`
|
|
14
14
|
* is permanent (stop polling), the others are worth retrying.
|
|
15
|
+
*
|
|
16
|
+
* A Meta number awaiting Embedded Signup answers `state: "PENDING"` (and
|
|
17
|
+
* `"EXPIRED"` once the pairing window closes) with `expiresAt` — poll until
|
|
18
|
+
* `OPEN`, stop on `EXPIRED`. A 200 does NOT mean connected.
|
|
15
19
|
*/
|
|
16
20
|
getStatus(id: string): Promise<NumberStatusResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Full detail of one number, including the `settings` block. Pass
|
|
23
|
+
* `{ refresh: true }` to force a live Meta Graph fetch instead of the cached
|
|
24
|
+
* snapshot (Meta numbers only).
|
|
25
|
+
*/
|
|
26
|
+
get(id: string, options?: {
|
|
27
|
+
refresh?: boolean;
|
|
28
|
+
}): Promise<NumberDetail>;
|
|
29
|
+
/**
|
|
30
|
+
* Partial update of a number: retention policy and/or `settings`. Only the
|
|
31
|
+
* fields you send change.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* await client.numbers.update(id, {
|
|
35
|
+
* piiMode: "STORE_X_DAYS",
|
|
36
|
+
* piiRetentionDays: 30,
|
|
37
|
+
* settings: { rejectCall: true },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
update(id: string, input: UpdateNumberInput): Promise<UpdateNumberResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Shorthand for {@link update} when you only care about `settings`.
|
|
44
|
+
*
|
|
45
|
+
* This is the ONLY settings endpoint — `POST /v1/numbers/{id}/settings` does
|
|
46
|
+
* not exist, and Evolution's `syncFullHistory` has no equivalent (use
|
|
47
|
+
* `historyImportEnabled`). Field names follow the Evolution GO dialect:
|
|
48
|
+
* `ignoreGroups`, not the v2 `groupsIgnore`.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* // stop replaying old messages into the webhook on every reconnect
|
|
52
|
+
* await client.numbers.updateSettings(id, { webhookHistoricalMessages: false });
|
|
53
|
+
*
|
|
54
|
+
* // stop WhatsApp Channel (`@newsletter`) posts from landing in the chat,
|
|
55
|
+
* // the logs and the webhook — the provider has no gate for them
|
|
56
|
+
* await client.numbers.updateSettings(id, { ignoreNewsletters: true });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
updateSettings(id: string, settings: NumberSettingsInput): Promise<UpdateNumberResult>;
|
|
60
|
+
/**
|
|
61
|
+
* ⚠️ **Its meaning changed: this is a 30-day SOFT delete.**
|
|
62
|
+
*
|
|
63
|
+
* Previously, `delete()` erased the line and freed the phone for an immediate
|
|
64
|
+
* reconnect — anyone who deleted-and-recreated relied on that. Now the device
|
|
65
|
+
* is logged out and the line survives until it is purged; the response carries
|
|
66
|
+
* `restorableUntil` so the window is discoverable without reading the docs.
|
|
67
|
+
*
|
|
68
|
+
* - Want the old behavior (destroy now and recreate right after)? →
|
|
69
|
+
* {@link purge}.
|
|
70
|
+
* - Changed your mind within the 30 days? → {@link restore}.
|
|
71
|
+
*
|
|
72
|
+
* It still does NOT reduce the paid capacity: the slot stays free for another
|
|
73
|
+
* number in the same cycle. Reducing the bill is `subscription.scheduleRemoval()`.
|
|
74
|
+
*/
|
|
17
75
|
delete(id: string): Promise<DeleteNumberResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Undoes the soft delete within the window (`POST /v1/numbers/{id}/restore`).
|
|
78
|
+
*
|
|
79
|
+
* ⚠️ It gives back the LINE, not the connection — the device was logged out on
|
|
80
|
+
* delete. That is what the response says with `requiresReconnect: true`: after
|
|
81
|
+
* restoring, call {@link connect} and read the QR / pairing code again.
|
|
82
|
+
*/
|
|
83
|
+
restore(id: string): Promise<NumberRestoreResult>;
|
|
84
|
+
/**
|
|
85
|
+
* IMMEDIATE hard delete (`DELETE /v1/numbers/{id}/purge`) — the behavior
|
|
86
|
+
* `delete()` had before the soft delete.
|
|
87
|
+
*
|
|
88
|
+
* It cascades through 13 FKs (chat, messages, templates, keys) and performs
|
|
89
|
+
* the irreversible teardown on Meta. There is no restore after this. Only use
|
|
90
|
+
* it when the flow REALLY is delete-and-recreate the same phone right after.
|
|
91
|
+
*/
|
|
92
|
+
purge(id: string): Promise<NumberPurgeResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Logs the paired device out without deleting anything
|
|
95
|
+
* (`POST /v1/numbers/{id}/logout`). The number reconnects with
|
|
96
|
+
* {@link connect}, keeping its id, keys, webhooks and history.
|
|
97
|
+
*/
|
|
98
|
+
logout(id: string): Promise<NumberLogoutResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Checks whether phone numbers exist on WhatsApp (`POST /v1/numbers/check`,
|
|
101
|
+
* up to 20).
|
|
102
|
+
*
|
|
103
|
+
* ⚠️ Only for an UNOFFICIAL number (Evolution GO/v2) — a Meta number answers
|
|
104
|
+
* `400 NOT_SUPPORTED_FOR_META`. For a Brazilian mobile (+55) the server also
|
|
105
|
+
* tries the variant with/without the ninth digit, and the `number` of each
|
|
106
|
+
* result is the REGISTERED form (the one you must use when sending), which
|
|
107
|
+
* may differ from what you sent.
|
|
108
|
+
*/
|
|
109
|
+
check(input: CheckNumbersInput): Promise<CheckNumbersResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Creates an official Meta Cloud API number with your own credentials
|
|
112
|
+
* (`POST /v1/numbers/meta`).
|
|
113
|
+
*
|
|
114
|
+
* This is the SERVER-SIDE path of the official onboarding — the
|
|
115
|
+
* `/v1/meta-embedded/*` routes exchange a `code` that only exists inside the
|
|
116
|
+
* Facebook JS SDK popup, which is why they have no method here.
|
|
117
|
+
*/
|
|
118
|
+
createMeta(input: CreateMetaNumberInput): Promise<CreateNumberResult>;
|
|
18
119
|
remotePairing(input: RemotePairingInput): Promise<RemotePairingResult>;
|
|
19
120
|
}
|
|
20
121
|
//# sourceMappingURL=numbers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/resources/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,E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AAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOrD;;;;;;OAMG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOvD;;;;;;;OAOG;IACG,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOnD;;;;OAIG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOrD;;;;;;;;;OASG;IACG,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQlE;;;;;;;OAOG;IACG,UAAU,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkBrE,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAY/E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compact } from "../internal.js";
|
|
1
2
|
export class NumbersResource {
|
|
2
3
|
#http;
|
|
3
4
|
constructor(http) {
|
|
@@ -11,6 +12,7 @@ export class NumbersResource {
|
|
|
11
12
|
name: input.name,
|
|
12
13
|
number: input.number,
|
|
13
14
|
...(input.linkToApiKey !== undefined ? { linkToApiKey: input.linkToApiKey } : {}),
|
|
15
|
+
...(input.settings !== undefined ? { settings: input.settings } : {}),
|
|
14
16
|
},
|
|
15
17
|
});
|
|
16
18
|
}
|
|
@@ -32,6 +34,10 @@ export class NumbersResource {
|
|
|
32
34
|
* one (`lastKnownAt`) because the provider did not answer. A 503 throws
|
|
33
35
|
* with `body.code` = `NumberStatusFailureCode` — `PROVIDER_NOT_CONFIGURED`
|
|
34
36
|
* is permanent (stop polling), the others are worth retrying.
|
|
37
|
+
*
|
|
38
|
+
* A Meta number awaiting Embedded Signup answers `state: "PENDING"` (and
|
|
39
|
+
* `"EXPIRED"` once the pairing window closes) with `expiresAt` — poll until
|
|
40
|
+
* `OPEN`, stop on `EXPIRED`. A 200 does NOT mean connected.
|
|
35
41
|
*/
|
|
36
42
|
async getStatus(id) {
|
|
37
43
|
return this.#http.requestJson({
|
|
@@ -39,12 +45,158 @@ export class NumbersResource {
|
|
|
39
45
|
path: `/v1/numbers/${encodeURIComponent(id)}/status`,
|
|
40
46
|
});
|
|
41
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Full detail of one number, including the `settings` block. Pass
|
|
50
|
+
* `{ refresh: true }` to force a live Meta Graph fetch instead of the cached
|
|
51
|
+
* snapshot (Meta numbers only).
|
|
52
|
+
*/
|
|
53
|
+
async get(id, options = {}) {
|
|
54
|
+
return this.#http.requestJson({
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: `/v1/numbers/${encodeURIComponent(id)}`,
|
|
57
|
+
...(options.refresh ? { query: { refresh: "1" } } : {}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Partial update of a number: retention policy and/or `settings`. Only the
|
|
62
|
+
* fields you send change.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* await client.numbers.update(id, {
|
|
66
|
+
* piiMode: "STORE_X_DAYS",
|
|
67
|
+
* piiRetentionDays: 30,
|
|
68
|
+
* settings: { rejectCall: true },
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
async update(id, input) {
|
|
73
|
+
return this.#http.requestJson({
|
|
74
|
+
method: "PATCH",
|
|
75
|
+
path: `/v1/numbers/${encodeURIComponent(id)}`,
|
|
76
|
+
body: input,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Shorthand for {@link update} when you only care about `settings`.
|
|
81
|
+
*
|
|
82
|
+
* This is the ONLY settings endpoint — `POST /v1/numbers/{id}/settings` does
|
|
83
|
+
* not exist, and Evolution's `syncFullHistory` has no equivalent (use
|
|
84
|
+
* `historyImportEnabled`). Field names follow the Evolution GO dialect:
|
|
85
|
+
* `ignoreGroups`, not the v2 `groupsIgnore`.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* // stop replaying old messages into the webhook on every reconnect
|
|
89
|
+
* await client.numbers.updateSettings(id, { webhookHistoricalMessages: false });
|
|
90
|
+
*
|
|
91
|
+
* // stop WhatsApp Channel (`@newsletter`) posts from landing in the chat,
|
|
92
|
+
* // the logs and the webhook — the provider has no gate for them
|
|
93
|
+
* await client.numbers.updateSettings(id, { ignoreNewsletters: true });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
async updateSettings(id, settings) {
|
|
97
|
+
return this.update(id, { settings });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* ⚠️ **Its meaning changed: this is a 30-day SOFT delete.**
|
|
101
|
+
*
|
|
102
|
+
* Previously, `delete()` erased the line and freed the phone for an immediate
|
|
103
|
+
* reconnect — anyone who deleted-and-recreated relied on that. Now the device
|
|
104
|
+
* is logged out and the line survives until it is purged; the response carries
|
|
105
|
+
* `restorableUntil` so the window is discoverable without reading the docs.
|
|
106
|
+
*
|
|
107
|
+
* - Want the old behavior (destroy now and recreate right after)? →
|
|
108
|
+
* {@link purge}.
|
|
109
|
+
* - Changed your mind within the 30 days? → {@link restore}.
|
|
110
|
+
*
|
|
111
|
+
* It still does NOT reduce the paid capacity: the slot stays free for another
|
|
112
|
+
* number in the same cycle. Reducing the bill is `subscription.scheduleRemoval()`.
|
|
113
|
+
*/
|
|
42
114
|
async delete(id) {
|
|
43
115
|
return this.#http.requestJson({
|
|
44
116
|
method: "DELETE",
|
|
45
117
|
path: `/v1/numbers/${encodeURIComponent(id)}`,
|
|
46
118
|
});
|
|
47
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Undoes the soft delete within the window (`POST /v1/numbers/{id}/restore`).
|
|
122
|
+
*
|
|
123
|
+
* ⚠️ It gives back the LINE, not the connection — the device was logged out on
|
|
124
|
+
* delete. That is what the response says with `requiresReconnect: true`: after
|
|
125
|
+
* restoring, call {@link connect} and read the QR / pairing code again.
|
|
126
|
+
*/
|
|
127
|
+
async restore(id) {
|
|
128
|
+
return this.#http.requestJson({
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: `/v1/numbers/${encodeURIComponent(id)}/restore`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* IMMEDIATE hard delete (`DELETE /v1/numbers/{id}/purge`) — the behavior
|
|
135
|
+
* `delete()` had before the soft delete.
|
|
136
|
+
*
|
|
137
|
+
* It cascades through 13 FKs (chat, messages, templates, keys) and performs
|
|
138
|
+
* the irreversible teardown on Meta. There is no restore after this. Only use
|
|
139
|
+
* it when the flow REALLY is delete-and-recreate the same phone right after.
|
|
140
|
+
*/
|
|
141
|
+
async purge(id) {
|
|
142
|
+
return this.#http.requestJson({
|
|
143
|
+
method: "DELETE",
|
|
144
|
+
path: `/v1/numbers/${encodeURIComponent(id)}/purge`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Logs the paired device out without deleting anything
|
|
149
|
+
* (`POST /v1/numbers/{id}/logout`). The number reconnects with
|
|
150
|
+
* {@link connect}, keeping its id, keys, webhooks and history.
|
|
151
|
+
*/
|
|
152
|
+
async logout(id) {
|
|
153
|
+
return this.#http.requestJson({
|
|
154
|
+
method: "POST",
|
|
155
|
+
path: `/v1/numbers/${encodeURIComponent(id)}/logout`,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Checks whether phone numbers exist on WhatsApp (`POST /v1/numbers/check`,
|
|
160
|
+
* up to 20).
|
|
161
|
+
*
|
|
162
|
+
* ⚠️ Only for an UNOFFICIAL number (Evolution GO/v2) — a Meta number answers
|
|
163
|
+
* `400 NOT_SUPPORTED_FOR_META`. For a Brazilian mobile (+55) the server also
|
|
164
|
+
* tries the variant with/without the ninth digit, and the `number` of each
|
|
165
|
+
* result is the REGISTERED form (the one you must use when sending), which
|
|
166
|
+
* may differ from what you sent.
|
|
167
|
+
*/
|
|
168
|
+
async check(input) {
|
|
169
|
+
return this.#http.requestJson({
|
|
170
|
+
method: "POST",
|
|
171
|
+
path: "/v1/numbers/check",
|
|
172
|
+
body: compact({ numbers: input.numbers, number: input.number }),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Creates an official Meta Cloud API number with your own credentials
|
|
177
|
+
* (`POST /v1/numbers/meta`).
|
|
178
|
+
*
|
|
179
|
+
* This is the SERVER-SIDE path of the official onboarding — the
|
|
180
|
+
* `/v1/meta-embedded/*` routes exchange a `code` that only exists inside the
|
|
181
|
+
* Facebook JS SDK popup, which is why they have no method here.
|
|
182
|
+
*/
|
|
183
|
+
async createMeta(input) {
|
|
184
|
+
return this.#http.requestJson({
|
|
185
|
+
method: "POST",
|
|
186
|
+
path: "/v1/numbers/meta",
|
|
187
|
+
body: compact({
|
|
188
|
+
name: input.name,
|
|
189
|
+
number: input.number,
|
|
190
|
+
metaPhoneId: input.metaPhoneId,
|
|
191
|
+
metaWabaId: input.metaWabaId,
|
|
192
|
+
metaAccessToken: input.metaAccessToken,
|
|
193
|
+
metaAppSecret: input.metaAppSecret,
|
|
194
|
+
metaAppId: input.metaAppId,
|
|
195
|
+
linkToApiKey: input.linkToApiKey,
|
|
196
|
+
routeWebhooksToPilot: input.routeWebhooksToPilot,
|
|
197
|
+
}),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
48
200
|
async remotePairing(input) {
|
|
49
201
|
return this.#http.requestJson({
|
|
50
202
|
method: "POST",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/resources/numbers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/resources/numbers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAsBzC,MAAM,OAAO,eAAe;IACf,KA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AED,KAAK,CAAC,aAAa,CAAC,KAAyB;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,4BAA4B;YAClC,IAAI,EAAE;gBACF,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,GAAG,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3F,GAAG,CAAC,KAAK,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3F;SACF,CAAC,CAAC;IACL,CAAC;CACA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { ServiceWindowResult } from "../types.js";
|
|
3
|
+
/** Meta's 24h customer service window (`GET /v1/service-window`). */
|
|
4
|
+
export declare class ServiceWindowResource {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
/**
|
|
8
|
+
* Tells you whether you can send a free-form message to `destinationNumber`
|
|
9
|
+
* right now. NUMBER-scoped key.
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ `open: true` does not mean the same thing on both providers. On a Meta
|
|
12
|
+
* number, `windowType: "META_24H"` and `open` is real — outside the window
|
|
13
|
+
* only an approved template gets through. On a web/unofficial number there is
|
|
14
|
+
* no Meta restriction: `windowType: "NONE"` and `open` is **always** `true`.
|
|
15
|
+
* Branching on `open` alone makes you think you checked a rule that does not
|
|
16
|
+
* exist there; branch on `windowType`.
|
|
17
|
+
*/
|
|
18
|
+
get(destinationNumber: string): Promise<ServiceWindowResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=service-window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-window.d.ts","sourceRoot":"","sources":["../../src/resources/service-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,qEAAqE;AACrE,qBAAa,qBAAqB;;gBAGlB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;OAUG;IACG,GAAG,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAOrE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Meta's 24h customer service window (`GET /v1/service-window`). */
|
|
2
|
+
export class ServiceWindowResource {
|
|
3
|
+
#http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.#http = http;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tells you whether you can send a free-form message to `destinationNumber`
|
|
9
|
+
* right now. NUMBER-scoped key.
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ `open: true` does not mean the same thing on both providers. On a Meta
|
|
12
|
+
* number, `windowType: "META_24H"` and `open` is real — outside the window
|
|
13
|
+
* only an approved template gets through. On a web/unofficial number there is
|
|
14
|
+
* no Meta restriction: `windowType: "NONE"` and `open` is **always** `true`.
|
|
15
|
+
* Branching on `open` alone makes you think you checked a rule that does not
|
|
16
|
+
* exist there; branch on `windowType`.
|
|
17
|
+
*/
|
|
18
|
+
async get(destinationNumber) {
|
|
19
|
+
return this.#http.requestJson({
|
|
20
|
+
method: "GET",
|
|
21
|
+
path: "/v1/service-window",
|
|
22
|
+
query: { destinationNumber },
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=service-window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-window.js","sourceRoot":"","sources":["../../src/resources/service-window.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,MAAM,OAAO,qBAAqB;IACrB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG,CAAC,iBAAyB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,EAAE,iBAAiB,EAAE;SAC/B,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { ExtraNumbersPreview, ExtraNumbersPurchaseResult, ExtraNumbersScheduleResult } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Paid number capacity (`/v1/subscription/extra-numbers*`). Requires a
|
|
5
|
+
* tenant-scoped credential.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ **Paid capacity ≠ connected number.** `numbers.delete()` frees the SLOT so
|
|
8
|
+
* another number can be connected, and does not cut a single cent off the bill.
|
|
9
|
+
* Reducing what you pay is {@link scheduleRemoval}, and it only takes effect on
|
|
10
|
+
* the following cycle.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SubscriptionResource {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(http: HttpClient);
|
|
15
|
+
/** Cost preview for buying `quantity` extra numbers (default 1). Charges nothing. */
|
|
16
|
+
previewExtraNumbers(params?: {
|
|
17
|
+
quantity?: number;
|
|
18
|
+
}): Promise<ExtraNumbersPreview>;
|
|
19
|
+
/**
|
|
20
|
+
* Buys `quantity` extra numbers. On a FREE plan this CONVERTS the account to
|
|
21
|
+
* On Demand, which is why it requires `confirm: true` — without it the server
|
|
22
|
+
* refuses, so that nobody changes plan by accident. With no card on file, the
|
|
23
|
+
* response carries a `checkoutUrl` instead of charging.
|
|
24
|
+
*/
|
|
25
|
+
addExtraNumbers(input?: {
|
|
26
|
+
quantity?: number;
|
|
27
|
+
confirm?: boolean;
|
|
28
|
+
}): Promise<ExtraNumbersPurchaseResult>;
|
|
29
|
+
/**
|
|
30
|
+
* SCHEDULES the return of `quantity` paid slots for the next cycle.
|
|
31
|
+
*
|
|
32
|
+
* Nothing changes right now and there is no refund: paid capacity is a 30-day
|
|
33
|
+
* entitlement. Calling it again OVERWRITES the scheduled target (it does not
|
|
34
|
+
* accumulate). It answers 409 `NUMBER_LIMIT_EXCEEDED` if the target would fall
|
|
35
|
+
* below the numbers currently connected.
|
|
36
|
+
*/
|
|
37
|
+
scheduleRemoval(input?: {
|
|
38
|
+
quantity?: number;
|
|
39
|
+
}): Promise<ExtraNumbersScheduleResult>;
|
|
40
|
+
/** Cancels the scheduled reduction — the next cycle keeps the current capacity. A no-op if there was none. */
|
|
41
|
+
cancelScheduledRemoval(): Promise<ExtraNumbersScheduleResult>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=subscription.d.ts.map
|