@linqapp/sdk 0.33.0 → 0.34.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 +14 -0
- package/client.d.mts +1 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -1
- package/client.d.ts.map +1 -1
- package/client.js +1 -1
- package/client.js.map +1 -1
- package/client.mjs +1 -1
- package/client.mjs.map +1 -1
- package/core/error.d.mts +13 -0
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +13 -0
- package/core/error.d.ts.map +1 -1
- package/core/error.js +5 -1
- package/core/error.js.map +1 -1
- package/core/error.mjs +5 -1
- package/core/error.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/chats/chats.d.mts +68 -24
- package/resources/chats/chats.d.mts.map +1 -1
- package/resources/chats/chats.d.ts +68 -24
- package/resources/chats/chats.d.ts.map +1 -1
- package/resources/chats/chats.js +6 -2
- package/resources/chats/chats.js.map +1 -1
- package/resources/chats/chats.mjs +6 -2
- package/resources/chats/chats.mjs.map +1 -1
- package/resources/chats/index.d.mts +1 -0
- package/resources/chats/index.d.mts.map +1 -1
- package/resources/chats/index.d.ts +1 -0
- package/resources/chats/index.d.ts.map +1 -1
- package/resources/chats/index.js +3 -1
- package/resources/chats/index.js.map +1 -1
- package/resources/chats/index.mjs +1 -0
- package/resources/chats/index.mjs.map +1 -1
- package/resources/chats/messages.d.mts +12 -5
- package/resources/chats/messages.d.mts.map +1 -1
- package/resources/chats/messages.d.ts +12 -5
- package/resources/chats/messages.d.ts.map +1 -1
- package/resources/chats/messages.js.map +1 -1
- package/resources/chats/messages.mjs.map +1 -1
- package/resources/chats/polls.d.mts +171 -0
- package/resources/chats/polls.d.mts.map +1 -0
- package/resources/chats/polls.d.ts +171 -0
- package/resources/chats/polls.d.ts.map +1 -0
- package/resources/chats/polls.js +95 -0
- package/resources/chats/polls.js.map +1 -0
- package/resources/chats/polls.mjs +91 -0
- package/resources/chats/polls.mjs.map +1 -0
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/index.d.mts +3 -0
- package/resources/messages/index.d.mts.map +1 -0
- package/resources/messages/index.d.ts +3 -0
- package/resources/messages/index.d.ts.map +1 -0
- package/resources/messages/index.js +9 -0
- package/resources/messages/index.js.map +1 -0
- package/resources/messages/index.mjs +4 -0
- package/resources/messages/index.mjs.map +1 -0
- package/resources/messages/messages.d.mts +795 -0
- package/resources/messages/messages.d.mts.map +1 -0
- package/resources/messages/messages.d.ts +795 -0
- package/resources/messages/messages.d.ts.map +1 -0
- package/resources/messages/messages.js +298 -0
- package/resources/messages/messages.js.map +1 -0
- package/resources/messages/messages.mjs +293 -0
- package/resources/messages/messages.mjs.map +1 -0
- package/resources/messages/poll.d.mts +131 -0
- package/resources/messages/poll.d.mts.map +1 -0
- package/resources/messages/poll.d.ts +131 -0
- package/resources/messages/poll.d.ts.map +1 -0
- package/resources/messages/poll.js +119 -0
- package/resources/messages/poll.js.map +1 -0
- package/resources/messages/poll.mjs +115 -0
- package/resources/messages/poll.mjs.map +1 -0
- package/resources/messages.d.mts +1 -783
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +1 -783
- package/resources/messages.d.ts.map +1 -1
- package/resources/messages.js +2 -286
- package/resources/messages.js.map +1 -1
- package/resources/messages.mjs +1 -284
- package/resources/messages.mjs.map +1 -1
- package/resources/webhook-events.d.mts +1 -1
- package/resources/webhook-events.d.mts.map +1 -1
- package/resources/webhook-events.d.ts +1 -1
- package/resources/webhook-events.d.ts.map +1 -1
- package/resources/webhooks.d.mts +40 -28
- package/resources/webhooks.d.mts.map +1 -1
- package/resources/webhooks.d.ts +40 -28
- package/resources/webhooks.d.ts.map +1 -1
- package/src/client.ts +15 -15
- package/src/core/error.ts +20 -1
- package/src/resources/chats/chats.ts +79 -24
- package/src/resources/chats/index.ts +1 -0
- package/src/resources/chats/messages.ts +14 -6
- package/src/resources/chats/polls.ts +196 -0
- package/src/resources/index.ts +1 -1
- package/src/resources/messages/index.ts +18 -0
- package/src/resources/messages/messages.ts +958 -0
- package/src/resources/messages/poll.ts +151 -0
- package/src/resources/messages.ts +1 -932
- package/src/resources/webhook-events.ts +9 -0
- package/src/resources/webhooks.ts +48 -27
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,KAAK,MAAM,qBAAkB;AACpC,OAAO,KAAK,QAAQ,0BAAuB;AAC3C,OAAO,KAAK,WAAW,6BAA0B;AACjD,OAAO,KAAK,OAAO,kBAAe;AAClC,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAe;AACpE,OAAO,EAAE,UAAU,EAAE,kCAA+B;AACpD,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,EACjC,WAAW,EACZ,iCAA8B;AAE/B,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAGhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,qBAAa,QAAS,SAAQ,WAAW;IACvC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAkC;IAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACH,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAYhG;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MG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QAEpB;;WAEG;QACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAE1B;;WAEG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B;CACF;AAID,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,OAAO,IAAI,OAAO,EACvB,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,OAAO,IAAI,OAAO,EACvB,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;IAEF,OAAO,EACL,IAAI,IAAI,IAAI,EACZ,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,cAAc,IAAI,cAAc,GACtC,CAAC;CACH"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Messages = void 0;
|
|
5
|
+
const tslib_1 = require("../../internal/tslib.js");
|
|
6
|
+
const resource_1 = require("../../core/resource.js");
|
|
7
|
+
const PollAPI = tslib_1.__importStar(require("./poll.js"));
|
|
8
|
+
const poll_1 = require("./poll.js");
|
|
9
|
+
const pagination_1 = require("../../core/pagination.js");
|
|
10
|
+
const headers_1 = require("../../internal/headers.js");
|
|
11
|
+
const path_1 = require("../../internal/utils/path.js");
|
|
12
|
+
/**
|
|
13
|
+
* Messages are individual communications within a chat thread.
|
|
14
|
+
*
|
|
15
|
+
* Messages can include text, media attachments, rich link previews, special effects
|
|
16
|
+
* (like confetti or fireworks), and reactions. All messages are associated with a
|
|
17
|
+
* specific chat and sent from a phone number you own.
|
|
18
|
+
*
|
|
19
|
+
* Messages support delivery status tracking, read receipts, and editing capabilities.
|
|
20
|
+
*
|
|
21
|
+
* ## Rich Link Previews
|
|
22
|
+
*
|
|
23
|
+
* Send a URL as a `link` part to deliver it with a rich preview card showing the
|
|
24
|
+
* page's title, description, and image (when available). A `link` part must be the
|
|
25
|
+
* **only** part in the message — it cannot be combined with text or media parts.
|
|
26
|
+
* To send a URL without a preview card, include it in a `text` part instead.
|
|
27
|
+
*
|
|
28
|
+
* **Limitations:**
|
|
29
|
+
* - A `link` part cannot be combined with other parts in the same message.
|
|
30
|
+
* - Maximum URL length: 2,048 characters.
|
|
31
|
+
*
|
|
32
|
+
* ## Ephemeral Messages (Privacy Tier)
|
|
33
|
+
*
|
|
34
|
+
* For regulated or sensitive conversations, opt in to the **ephemeral messages** tier by contacting your Linq support contact. When enabled, every message on the covered phone numbers is automatically given a fixed **24-hour retention window** — after that window the platform permanently deletes the message from Linq storage. There is no per-message flag; ephemerality is applied automatically based on your configuration.
|
|
35
|
+
*
|
|
36
|
+
* You can request it at two scopes:
|
|
37
|
+
*
|
|
38
|
+
* | Scope | Effect |
|
|
39
|
+
* |---|---|
|
|
40
|
+
* | **Partner-wide** | Every outbound and inbound message on every phone number under your account is retained for 24 hours, then deleted. |
|
|
41
|
+
* | **Per phone number** | Only the specified phone numbers have their messages auto-deleted. The rest follow the standard message-retention policy. |
|
|
42
|
+
*
|
|
43
|
+
* **Behavioral differences vs the standard default:**
|
|
44
|
+
*
|
|
45
|
+
* | Aspect | Standard | Ephemeral |
|
|
46
|
+
* |---|---|---|
|
|
47
|
+
* | Retention | Retained per the standard message-retention policy | **Hard backstop: 24 hours** from when the message is created |
|
|
48
|
+
* | After expiry | Message stays retrievable | Message is permanently deleted — `GET /v3/messages/{messageId}` returns `404` and it no longer appears in `GET /v3/chats/{chatId}/messages` |
|
|
49
|
+
* | Content on expiry | N/A | Text, formatting, and attachment references are scrubbed; the message is gone, not blanked out |
|
|
50
|
+
* | Cross-partner isolation | Enforced | Enforced |
|
|
51
|
+
*
|
|
52
|
+
* **How the 24-hour window works:**
|
|
53
|
+
*
|
|
54
|
+
* - The window is fixed at **24 hours from message creation** (`created_at`) and cannot be configured per message.
|
|
55
|
+
* - It mirrors the ephemeral *attachments* 1-day backstop, so a message and any media it carries expire together.
|
|
56
|
+
* - Expiry is delivery-independent — the clock starts when the message is created, not when it is delivered or read.
|
|
57
|
+
*
|
|
58
|
+
* **What you observe:**
|
|
59
|
+
*
|
|
60
|
+
* - **No expiry timestamp is exposed.** API responses and webhook payloads do not include the deletion time. If you need it, compute `created_at + 24h` yourself.
|
|
61
|
+
* - **No deletion webhook is sent.** There is no `message.deleted` event — a message simply stops being retrievable once its window passes.
|
|
62
|
+
* - **Delivery is unaffected.** Ephemeral messages send, deliver, and fire the usual `message.sent` / `message.received` and status webhooks exactly like standard messages. Only retention changes.
|
|
63
|
+
*
|
|
64
|
+
* **When to choose ephemeral:**
|
|
65
|
+
*
|
|
66
|
+
* - You have a compliance requirement that the platform must not retain message content beyond a short window.
|
|
67
|
+
* - The conversation is high-sensitivity (PHI, financial, identity verification) and you do not want it sitting in storage long-term.
|
|
68
|
+
* - Your application is the system of record — you capture what you need from the delivery webhook in real time and do not rely on reading message history back from Linq later.
|
|
69
|
+
*
|
|
70
|
+
* **Important:** ephemeral applies in *both directions* — messages you send **and** messages received by the phone numbers in that scope. Because Linq can no longer return the message after 24 hours, persist anything you need to keep from the webhook payload at the time it is delivered.
|
|
71
|
+
*/
|
|
72
|
+
class Messages extends resource_1.APIResource {
|
|
73
|
+
constructor() {
|
|
74
|
+
super(...arguments);
|
|
75
|
+
this.poll = new PollAPI.Poll(this._client);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Send a message to one or more recipients **without supplying a `from` number**.
|
|
79
|
+
* Linq resolves both the sending line and the target chat for you, then returns
|
|
80
|
+
* exactly which line was used, which chat the message landed in, whether a new
|
|
81
|
+
* chat was created, and every resulting message id.
|
|
82
|
+
*
|
|
83
|
+
* This fuses "create chat" and "send message" behind a single message-centric
|
|
84
|
+
* resource. Provide only the recipients (`to`) and the `message`; the platform
|
|
85
|
+
* decides the rest.
|
|
86
|
+
*
|
|
87
|
+
* ## How the from-number and chat are chosen
|
|
88
|
+
*
|
|
89
|
+
* - **Reuse** — if a chat with exactly these recipients already exists on a line
|
|
90
|
+
* that can still send, the message is sent into that chat on its existing line
|
|
91
|
+
* (`from_selection.reason = reused_active_chat`). The most-recently-active such
|
|
92
|
+
* chat wins; chats stranded on flagged lines (e.g. by an earlier failover) are
|
|
93
|
+
* skipped.
|
|
94
|
+
* - **New** — if no such chat exists, a new chat is created on the best available
|
|
95
|
+
* line (`from_selection.reason = new_best_number`).
|
|
96
|
+
* - **Failover** — if matching chats exist but none is on a line that can send, a
|
|
97
|
+
* **new** chat is created on a fresh best line and the flagged chat is abandoned
|
|
98
|
+
* (`from_selection.reason = failover_flagged`, `previous_chat_id` set). If you
|
|
99
|
+
* supply `continuation_message`, that text is sent as the single message INSTEAD
|
|
100
|
+
* of `message` (useful as a fresh-number-appropriate opener). Exactly one
|
|
101
|
+
* message is sent either way.
|
|
102
|
+
*
|
|
103
|
+
* Recipients (`to`) are an order-independent set: a single handle is a direct
|
|
104
|
+
* chat, multiple handles a group chat.
|
|
105
|
+
*
|
|
106
|
+
* ## Excluding lines
|
|
107
|
+
*
|
|
108
|
+
* `exclude_from` keeps specific lines out of **this** send's line pick. It only
|
|
109
|
+
* affects picking a line for a new chat — an existing chat is always reused on its
|
|
110
|
+
* own line, preferring a chat on a non-excluded line when the recipients have more
|
|
111
|
+
* than one. An exclusion never abandons a live chat or moves it to a new number,
|
|
112
|
+
* so if the only chat these recipients have is on an excluded line, that chat is
|
|
113
|
+
* still used. `from` tells you the line that was actually used.
|
|
114
|
+
*
|
|
115
|
+
* ## Differences from POST /v3/chats
|
|
116
|
+
*
|
|
117
|
+
* - The first message **may contain a link** (including for a newly created chat).
|
|
118
|
+
* Note: sending a link as the very first message on a freshly selected line can
|
|
119
|
+
* elevate that line's flagging risk — it is allowed, not recommended.
|
|
120
|
+
* - Voice memos are **not** supported here. To send an iMessage voice-memo bubble,
|
|
121
|
+
* use `POST /v3/chats/{chatId}/voicememo` with a known chat id.
|
|
122
|
+
*
|
|
123
|
+
* ## Service preference, effects, decorations
|
|
124
|
+
*
|
|
125
|
+
* Set `message.preferred_service` (`iMessage` | `RCS` | `SMS`), `message.effect`,
|
|
126
|
+
* and per-part `text_decorations` exactly as on the other send endpoints.
|
|
127
|
+
*
|
|
128
|
+
* Always responds `202 Accepted` — chat creation is incidental to the send.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const message = await client.messages.create({
|
|
133
|
+
* message: {
|
|
134
|
+
* parts: [
|
|
135
|
+
* {
|
|
136
|
+
* type: 'text',
|
|
137
|
+
* value:
|
|
138
|
+
* 'Hi! Thanks for reaching out — how can we help?',
|
|
139
|
+
* },
|
|
140
|
+
* ],
|
|
141
|
+
* },
|
|
142
|
+
* to: ['+14155559876'],
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
create(params, options) {
|
|
147
|
+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
148
|
+
return this._client.post('/v3/messages', {
|
|
149
|
+
body,
|
|
150
|
+
...options,
|
|
151
|
+
headers: (0, headers_1.buildHeaders)([
|
|
152
|
+
{ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined) },
|
|
153
|
+
options?.headers,
|
|
154
|
+
]),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Retrieve a specific message by its ID. This endpoint returns the full message
|
|
159
|
+
* details including text, attachments, reactions, and metadata.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const message = await client.messages.retrieve(
|
|
164
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
165
|
+
* );
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
retrieve(messageID, options) {
|
|
169
|
+
return this._client.get((0, path_1.path) `/v3/messages/${messageID}`, options);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Edit the text content of a specific part of a previously sent message.
|
|
173
|
+
*
|
|
174
|
+
* **Note:** A message can be edited up to 5 times, and only within 15 minutes of
|
|
175
|
+
* when it was originally sent.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const message = await client.messages.update(
|
|
180
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
181
|
+
* { text: 'This is the edited message content' },
|
|
182
|
+
* );
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
update(messageID, body, options) {
|
|
186
|
+
return this._client.patch((0, path_1.path) `/v3/messages/${messageID}`, { body, ...options });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Deletes a message from the Linq API only. This does NOT unsend or remove the
|
|
190
|
+
* message from the actual chat — recipients will still see the message. Re-sending
|
|
191
|
+
* with a deleted message's idempotency key returns 404 — a deleted message is
|
|
192
|
+
* never resent.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* await client.messages.delete(
|
|
197
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
198
|
+
* );
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
delete(messageID, options) {
|
|
202
|
+
return this._client.delete((0, path_1.path) `/v3/messages/${messageID}`, {
|
|
203
|
+
...options,
|
|
204
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Add or remove emoji reactions to messages. Reactions let users express their
|
|
209
|
+
* response to a message without sending a new message.
|
|
210
|
+
*
|
|
211
|
+
* **Supported Reactions:**
|
|
212
|
+
*
|
|
213
|
+
* - love ❤️
|
|
214
|
+
* - like 👍
|
|
215
|
+
* - dislike 👎
|
|
216
|
+
* - laugh 😂
|
|
217
|
+
* - emphasize ‼️
|
|
218
|
+
* - question ❓
|
|
219
|
+
* - custom - any emoji (use `custom_emoji` field to specify)
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const response = await client.messages.addReaction(
|
|
224
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
225
|
+
* { operation: 'add', type: 'love' },
|
|
226
|
+
* );
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
addReaction(messageID, body, options) {
|
|
230
|
+
return this._client.post((0, path_1.path) `/v3/messages/${messageID}/reactions`, { body, ...options });
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Retrieve all messages in a conversation thread. Given any message ID in the
|
|
234
|
+
* thread, returns the originator message and all replies in chronological order.
|
|
235
|
+
*
|
|
236
|
+
* If the message is not part of a thread, returns just that single message.
|
|
237
|
+
*
|
|
238
|
+
* Supports pagination and configurable ordering.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* // Automatically fetches more pages as needed.
|
|
243
|
+
* for await (const message of client.messages.listMessagesThread(
|
|
244
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
245
|
+
* )) {
|
|
246
|
+
* // ...
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
listMessagesThread(messageID, query = {}, options) {
|
|
251
|
+
return this._client.getAPIList((0, path_1.path) `/v3/messages/${messageID}/thread`, (pagination_1.ListMessagesPagination), {
|
|
252
|
+
query,
|
|
253
|
+
...options,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Replaces a previously delivered `imessage_app` card on the recipient's screen
|
|
258
|
+
* with new content, instead of posting a new bubble (like a game move redrawing
|
|
259
|
+
* the board).
|
|
260
|
+
*
|
|
261
|
+
* The update is delivered as a **new message** with its own id and delivery
|
|
262
|
+
* lifecycle (`message.sent` / `message.delivered` / `message.failed` webhooks fire
|
|
263
|
+
* for the new id). To update the card again, reference the message id returned by
|
|
264
|
+
* this call.
|
|
265
|
+
*
|
|
266
|
+
* Constraints:
|
|
267
|
+
*
|
|
268
|
+
* - The referenced message must be an `imessage_app` card sent by you (`400`
|
|
269
|
+
* otherwise — inbound cards cannot be updated).
|
|
270
|
+
* - The referenced card must already be delivered (`409` otherwise — retry after
|
|
271
|
+
* the `message.delivered` webhook for it).
|
|
272
|
+
* - The app identity (`team_id`, `bundle_id`, name) is inherited from the original
|
|
273
|
+
* card and cannot change; only `url`, `fallback_text`, and `layout` are
|
|
274
|
+
* replaced.
|
|
275
|
+
* - iMessage-only, like all app cards.
|
|
276
|
+
* - Concurrent updates against the same card are not serialized server-side; the
|
|
277
|
+
* last one delivered wins on the recipient's screen. Serialize updates by always
|
|
278
|
+
* referencing the message id returned by the previous call.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* const response = await client.messages.updateAppCard(
|
|
283
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
284
|
+
* {
|
|
285
|
+
* layout: { caption: 'Score: 2 – 1' },
|
|
286
|
+
* fallback_text: 'Score update',
|
|
287
|
+
* url: 'https://app.example.com/card?game=7f3a&move=2',
|
|
288
|
+
* },
|
|
289
|
+
* );
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
updateAppCard(messageID, body, options) {
|
|
293
|
+
return this._client.post((0, path_1.path) `/v3/messages/${messageID}/update`, { body, ...options });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
exports.Messages = Messages;
|
|
297
|
+
Messages.Poll = poll_1.Poll;
|
|
298
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAIlD,2DAAkC;AAClC,oCAAoE;AAEpE,yDAI+B;AAC/B,uDAAsD;AAEtD,uDAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAa,QAAS,SAAQ,sBAAW;IAAzC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IA8OtD,CAAC;IA5OC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACH,MAAM,CAAC,MAA2B,EAAE,OAAwB;QAC1D,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB,EAAE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACnF,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SAAiB,EAAE,OAAwB;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,gBAAgB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AAC,IAAI,CAAC,IAAA,WAAI,EAAA,gBAAgB,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;CACF;AA/OD,4BA+OC;AAymBD,QAAQ,CAAC,IAAI,GAAG,WAAI,CAAC"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../../core/resource.mjs";
|
|
3
|
+
import * as PollAPI from "./poll.mjs";
|
|
4
|
+
import { Poll } from "./poll.mjs";
|
|
5
|
+
import { ListMessagesPagination, } from "../../core/pagination.mjs";
|
|
6
|
+
import { buildHeaders } from "../../internal/headers.mjs";
|
|
7
|
+
import { path } from "../../internal/utils/path.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* Messages are individual communications within a chat thread.
|
|
10
|
+
*
|
|
11
|
+
* Messages can include text, media attachments, rich link previews, special effects
|
|
12
|
+
* (like confetti or fireworks), and reactions. All messages are associated with a
|
|
13
|
+
* specific chat and sent from a phone number you own.
|
|
14
|
+
*
|
|
15
|
+
* Messages support delivery status tracking, read receipts, and editing capabilities.
|
|
16
|
+
*
|
|
17
|
+
* ## Rich Link Previews
|
|
18
|
+
*
|
|
19
|
+
* Send a URL as a `link` part to deliver it with a rich preview card showing the
|
|
20
|
+
* page's title, description, and image (when available). A `link` part must be the
|
|
21
|
+
* **only** part in the message — it cannot be combined with text or media parts.
|
|
22
|
+
* To send a URL without a preview card, include it in a `text` part instead.
|
|
23
|
+
*
|
|
24
|
+
* **Limitations:**
|
|
25
|
+
* - A `link` part cannot be combined with other parts in the same message.
|
|
26
|
+
* - Maximum URL length: 2,048 characters.
|
|
27
|
+
*
|
|
28
|
+
* ## Ephemeral Messages (Privacy Tier)
|
|
29
|
+
*
|
|
30
|
+
* For regulated or sensitive conversations, opt in to the **ephemeral messages** tier by contacting your Linq support contact. When enabled, every message on the covered phone numbers is automatically given a fixed **24-hour retention window** — after that window the platform permanently deletes the message from Linq storage. There is no per-message flag; ephemerality is applied automatically based on your configuration.
|
|
31
|
+
*
|
|
32
|
+
* You can request it at two scopes:
|
|
33
|
+
*
|
|
34
|
+
* | Scope | Effect |
|
|
35
|
+
* |---|---|
|
|
36
|
+
* | **Partner-wide** | Every outbound and inbound message on every phone number under your account is retained for 24 hours, then deleted. |
|
|
37
|
+
* | **Per phone number** | Only the specified phone numbers have their messages auto-deleted. The rest follow the standard message-retention policy. |
|
|
38
|
+
*
|
|
39
|
+
* **Behavioral differences vs the standard default:**
|
|
40
|
+
*
|
|
41
|
+
* | Aspect | Standard | Ephemeral |
|
|
42
|
+
* |---|---|---|
|
|
43
|
+
* | Retention | Retained per the standard message-retention policy | **Hard backstop: 24 hours** from when the message is created |
|
|
44
|
+
* | After expiry | Message stays retrievable | Message is permanently deleted — `GET /v3/messages/{messageId}` returns `404` and it no longer appears in `GET /v3/chats/{chatId}/messages` |
|
|
45
|
+
* | Content on expiry | N/A | Text, formatting, and attachment references are scrubbed; the message is gone, not blanked out |
|
|
46
|
+
* | Cross-partner isolation | Enforced | Enforced |
|
|
47
|
+
*
|
|
48
|
+
* **How the 24-hour window works:**
|
|
49
|
+
*
|
|
50
|
+
* - The window is fixed at **24 hours from message creation** (`created_at`) and cannot be configured per message.
|
|
51
|
+
* - It mirrors the ephemeral *attachments* 1-day backstop, so a message and any media it carries expire together.
|
|
52
|
+
* - Expiry is delivery-independent — the clock starts when the message is created, not when it is delivered or read.
|
|
53
|
+
*
|
|
54
|
+
* **What you observe:**
|
|
55
|
+
*
|
|
56
|
+
* - **No expiry timestamp is exposed.** API responses and webhook payloads do not include the deletion time. If you need it, compute `created_at + 24h` yourself.
|
|
57
|
+
* - **No deletion webhook is sent.** There is no `message.deleted` event — a message simply stops being retrievable once its window passes.
|
|
58
|
+
* - **Delivery is unaffected.** Ephemeral messages send, deliver, and fire the usual `message.sent` / `message.received` and status webhooks exactly like standard messages. Only retention changes.
|
|
59
|
+
*
|
|
60
|
+
* **When to choose ephemeral:**
|
|
61
|
+
*
|
|
62
|
+
* - You have a compliance requirement that the platform must not retain message content beyond a short window.
|
|
63
|
+
* - The conversation is high-sensitivity (PHI, financial, identity verification) and you do not want it sitting in storage long-term.
|
|
64
|
+
* - Your application is the system of record — you capture what you need from the delivery webhook in real time and do not rely on reading message history back from Linq later.
|
|
65
|
+
*
|
|
66
|
+
* **Important:** ephemeral applies in *both directions* — messages you send **and** messages received by the phone numbers in that scope. Because Linq can no longer return the message after 24 hours, persist anything you need to keep from the webhook payload at the time it is delivered.
|
|
67
|
+
*/
|
|
68
|
+
export class Messages extends APIResource {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.poll = new PollAPI.Poll(this._client);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Send a message to one or more recipients **without supplying a `from` number**.
|
|
75
|
+
* Linq resolves both the sending line and the target chat for you, then returns
|
|
76
|
+
* exactly which line was used, which chat the message landed in, whether a new
|
|
77
|
+
* chat was created, and every resulting message id.
|
|
78
|
+
*
|
|
79
|
+
* This fuses "create chat" and "send message" behind a single message-centric
|
|
80
|
+
* resource. Provide only the recipients (`to`) and the `message`; the platform
|
|
81
|
+
* decides the rest.
|
|
82
|
+
*
|
|
83
|
+
* ## How the from-number and chat are chosen
|
|
84
|
+
*
|
|
85
|
+
* - **Reuse** — if a chat with exactly these recipients already exists on a line
|
|
86
|
+
* that can still send, the message is sent into that chat on its existing line
|
|
87
|
+
* (`from_selection.reason = reused_active_chat`). The most-recently-active such
|
|
88
|
+
* chat wins; chats stranded on flagged lines (e.g. by an earlier failover) are
|
|
89
|
+
* skipped.
|
|
90
|
+
* - **New** — if no such chat exists, a new chat is created on the best available
|
|
91
|
+
* line (`from_selection.reason = new_best_number`).
|
|
92
|
+
* - **Failover** — if matching chats exist but none is on a line that can send, a
|
|
93
|
+
* **new** chat is created on a fresh best line and the flagged chat is abandoned
|
|
94
|
+
* (`from_selection.reason = failover_flagged`, `previous_chat_id` set). If you
|
|
95
|
+
* supply `continuation_message`, that text is sent as the single message INSTEAD
|
|
96
|
+
* of `message` (useful as a fresh-number-appropriate opener). Exactly one
|
|
97
|
+
* message is sent either way.
|
|
98
|
+
*
|
|
99
|
+
* Recipients (`to`) are an order-independent set: a single handle is a direct
|
|
100
|
+
* chat, multiple handles a group chat.
|
|
101
|
+
*
|
|
102
|
+
* ## Excluding lines
|
|
103
|
+
*
|
|
104
|
+
* `exclude_from` keeps specific lines out of **this** send's line pick. It only
|
|
105
|
+
* affects picking a line for a new chat — an existing chat is always reused on its
|
|
106
|
+
* own line, preferring a chat on a non-excluded line when the recipients have more
|
|
107
|
+
* than one. An exclusion never abandons a live chat or moves it to a new number,
|
|
108
|
+
* so if the only chat these recipients have is on an excluded line, that chat is
|
|
109
|
+
* still used. `from` tells you the line that was actually used.
|
|
110
|
+
*
|
|
111
|
+
* ## Differences from POST /v3/chats
|
|
112
|
+
*
|
|
113
|
+
* - The first message **may contain a link** (including for a newly created chat).
|
|
114
|
+
* Note: sending a link as the very first message on a freshly selected line can
|
|
115
|
+
* elevate that line's flagging risk — it is allowed, not recommended.
|
|
116
|
+
* - Voice memos are **not** supported here. To send an iMessage voice-memo bubble,
|
|
117
|
+
* use `POST /v3/chats/{chatId}/voicememo` with a known chat id.
|
|
118
|
+
*
|
|
119
|
+
* ## Service preference, effects, decorations
|
|
120
|
+
*
|
|
121
|
+
* Set `message.preferred_service` (`iMessage` | `RCS` | `SMS`), `message.effect`,
|
|
122
|
+
* and per-part `text_decorations` exactly as on the other send endpoints.
|
|
123
|
+
*
|
|
124
|
+
* Always responds `202 Accepted` — chat creation is incidental to the send.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const message = await client.messages.create({
|
|
129
|
+
* message: {
|
|
130
|
+
* parts: [
|
|
131
|
+
* {
|
|
132
|
+
* type: 'text',
|
|
133
|
+
* value:
|
|
134
|
+
* 'Hi! Thanks for reaching out — how can we help?',
|
|
135
|
+
* },
|
|
136
|
+
* ],
|
|
137
|
+
* },
|
|
138
|
+
* to: ['+14155559876'],
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
create(params, options) {
|
|
143
|
+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
144
|
+
return this._client.post('/v3/messages', {
|
|
145
|
+
body,
|
|
146
|
+
...options,
|
|
147
|
+
headers: buildHeaders([
|
|
148
|
+
{ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined) },
|
|
149
|
+
options?.headers,
|
|
150
|
+
]),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Retrieve a specific message by its ID. This endpoint returns the full message
|
|
155
|
+
* details including text, attachments, reactions, and metadata.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const message = await client.messages.retrieve(
|
|
160
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
161
|
+
* );
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
retrieve(messageID, options) {
|
|
165
|
+
return this._client.get(path `/v3/messages/${messageID}`, options);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Edit the text content of a specific part of a previously sent message.
|
|
169
|
+
*
|
|
170
|
+
* **Note:** A message can be edited up to 5 times, and only within 15 minutes of
|
|
171
|
+
* when it was originally sent.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const message = await client.messages.update(
|
|
176
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
177
|
+
* { text: 'This is the edited message content' },
|
|
178
|
+
* );
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
update(messageID, body, options) {
|
|
182
|
+
return this._client.patch(path `/v3/messages/${messageID}`, { body, ...options });
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Deletes a message from the Linq API only. This does NOT unsend or remove the
|
|
186
|
+
* message from the actual chat — recipients will still see the message. Re-sending
|
|
187
|
+
* with a deleted message's idempotency key returns 404 — a deleted message is
|
|
188
|
+
* never resent.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* await client.messages.delete(
|
|
193
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
194
|
+
* );
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
delete(messageID, options) {
|
|
198
|
+
return this._client.delete(path `/v3/messages/${messageID}`, {
|
|
199
|
+
...options,
|
|
200
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Add or remove emoji reactions to messages. Reactions let users express their
|
|
205
|
+
* response to a message without sending a new message.
|
|
206
|
+
*
|
|
207
|
+
* **Supported Reactions:**
|
|
208
|
+
*
|
|
209
|
+
* - love ❤️
|
|
210
|
+
* - like 👍
|
|
211
|
+
* - dislike 👎
|
|
212
|
+
* - laugh 😂
|
|
213
|
+
* - emphasize ‼️
|
|
214
|
+
* - question ❓
|
|
215
|
+
* - custom - any emoji (use `custom_emoji` field to specify)
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const response = await client.messages.addReaction(
|
|
220
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
221
|
+
* { operation: 'add', type: 'love' },
|
|
222
|
+
* );
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
addReaction(messageID, body, options) {
|
|
226
|
+
return this._client.post(path `/v3/messages/${messageID}/reactions`, { body, ...options });
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Retrieve all messages in a conversation thread. Given any message ID in the
|
|
230
|
+
* thread, returns the originator message and all replies in chronological order.
|
|
231
|
+
*
|
|
232
|
+
* If the message is not part of a thread, returns just that single message.
|
|
233
|
+
*
|
|
234
|
+
* Supports pagination and configurable ordering.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* // Automatically fetches more pages as needed.
|
|
239
|
+
* for await (const message of client.messages.listMessagesThread(
|
|
240
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
241
|
+
* )) {
|
|
242
|
+
* // ...
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
listMessagesThread(messageID, query = {}, options) {
|
|
247
|
+
return this._client.getAPIList(path `/v3/messages/${messageID}/thread`, (ListMessagesPagination), {
|
|
248
|
+
query,
|
|
249
|
+
...options,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Replaces a previously delivered `imessage_app` card on the recipient's screen
|
|
254
|
+
* with new content, instead of posting a new bubble (like a game move redrawing
|
|
255
|
+
* the board).
|
|
256
|
+
*
|
|
257
|
+
* The update is delivered as a **new message** with its own id and delivery
|
|
258
|
+
* lifecycle (`message.sent` / `message.delivered` / `message.failed` webhooks fire
|
|
259
|
+
* for the new id). To update the card again, reference the message id returned by
|
|
260
|
+
* this call.
|
|
261
|
+
*
|
|
262
|
+
* Constraints:
|
|
263
|
+
*
|
|
264
|
+
* - The referenced message must be an `imessage_app` card sent by you (`400`
|
|
265
|
+
* otherwise — inbound cards cannot be updated).
|
|
266
|
+
* - The referenced card must already be delivered (`409` otherwise — retry after
|
|
267
|
+
* the `message.delivered` webhook for it).
|
|
268
|
+
* - The app identity (`team_id`, `bundle_id`, name) is inherited from the original
|
|
269
|
+
* card and cannot change; only `url`, `fallback_text`, and `layout` are
|
|
270
|
+
* replaced.
|
|
271
|
+
* - iMessage-only, like all app cards.
|
|
272
|
+
* - Concurrent updates against the same card are not serialized server-side; the
|
|
273
|
+
* last one delivered wins on the recipient's screen. Serialize updates by always
|
|
274
|
+
* referencing the message id returned by the previous call.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* const response = await client.messages.updateAppCard(
|
|
279
|
+
* '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
|
|
280
|
+
* {
|
|
281
|
+
* layout: { caption: 'Score: 2 – 1' },
|
|
282
|
+
* fallback_text: 'Score update',
|
|
283
|
+
* url: 'https://app.example.com/card?game=7f3a&move=2',
|
|
284
|
+
* },
|
|
285
|
+
* );
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
updateAppCard(messageID, body, options) {
|
|
289
|
+
return this._client.post(path `/v3/messages/${messageID}/update`, { body, ...options });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
Messages.Poll = Poll;
|
|
293
|
+
//# sourceMappingURL=messages.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAIlD,OAAO,KAAK,OAAO,mBAAe;AAClC,OAAO,EAAE,IAAI,EAAwC,mBAAe;AAEpE,OAAO,EACL,sBAAsB,GAGvB,kCAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,IAAI,EAAE,sCAAkC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IA8OtD,CAAC;IA5OC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACH,MAAM,CAAC,MAA2B,EAAE,OAAwB;QAC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