@sentdm/sentdm 0.37.0 → 0.39.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 +20 -0
- package/README.md +31 -0
- package/client.d.mts +22 -8
- package/client.d.mts.map +1 -1
- package/client.d.ts +22 -8
- package/client.d.ts.map +1 -1
- package/client.js +10 -0
- package/client.js.map +1 -1
- package/client.mjs +10 -0
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +164 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +164 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +212 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +202 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/package.json +11 -1
- package/pagination.d.mts +3 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +3 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +3 -0
- package/pagination.mjs.map +1 -0
- package/resources/contacts.d.mts +9 -52
- package/resources/contacts.d.mts.map +1 -1
- package/resources/contacts.d.ts +9 -52
- package/resources/contacts.d.ts.map +1 -1
- package/resources/contacts.js +8 -7
- package/resources/contacts.js.map +1 -1
- package/resources/contacts.mjs +8 -7
- package/resources/contacts.mjs.map +1 -1
- package/resources/conversations.d.mts +17 -32
- package/resources/conversations.d.mts.map +1 -1
- package/resources/conversations.d.ts +17 -32
- package/resources/conversations.d.ts.map +1 -1
- package/resources/conversations.js +17 -16
- package/resources/conversations.js.map +1 -1
- package/resources/conversations.mjs +17 -16
- package/resources/conversations.mjs.map +1 -1
- package/resources/index.d.mts +4 -4
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -4
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/templates.d.mts +162 -65
- package/resources/templates.d.mts.map +1 -1
- package/resources/templates.d.ts +162 -65
- package/resources/templates.d.ts.map +1 -1
- package/resources/templates.js +36 -9
- package/resources/templates.js.map +1 -1
- package/resources/templates.mjs +36 -9
- package/resources/templates.mjs.map +1 -1
- package/resources/webhooks.d.mts +340 -134
- package/resources/webhooks.d.mts.map +1 -1
- package/resources/webhooks.d.ts +340 -134
- package/resources/webhooks.d.ts.map +1 -1
- package/resources/webhooks.js +16 -13
- package/resources/webhooks.js.map +1 -1
- package/resources/webhooks.mjs +16 -13
- package/resources/webhooks.mjs.map +1 -1
- package/src/client.ts +80 -6
- package/src/core/pagination.ts +428 -0
- package/src/index.ts +1 -0
- package/src/pagination.ts +2 -0
- package/src/resources/contacts.ts +15 -62
- package/src/resources/conversations.ts +36 -48
- package/src/resources/index.ts +9 -3
- package/src/resources/templates.ts +169 -75
- package/src/resources/webhooks.ts +404 -163
- 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
package/resources/templates.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIResource } from "../core/resource.js";
|
|
2
|
-
import * as TemplatesAPI from "./templates.js";
|
|
3
2
|
import * as WebhooksAPI from "./webhooks.js";
|
|
4
3
|
import { APIPromise } from "../core/api-promise.js";
|
|
4
|
+
import { PagePromise, TemplatesPage, type TemplatesPageParams } from "../core/pagination.js";
|
|
5
5
|
import { RequestOptions } from "../internal/request-options.js";
|
|
6
6
|
/**
|
|
7
7
|
* Reusable message bodies with named variables.
|
|
@@ -12,7 +12,9 @@ export declare class Templates extends APIResource {
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new message template with header, body, footer, and buttons. The
|
|
14
14
|
* template can be submitted for review immediately or saved as draft for later
|
|
15
|
-
* submission.
|
|
15
|
+
* submission. There is no `name` field on create — the display name is derived
|
|
16
|
+
* from the template's content and can be changed afterwards with
|
|
17
|
+
* `PUT /v3/templates/{id}`.
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
@@ -34,7 +36,31 @@ export declare class Templates extends APIResource {
|
|
|
34
36
|
retrieve(id: string, params?: TemplateRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseTemplate>;
|
|
35
37
|
/**
|
|
36
38
|
* Updates an existing template's name, category, language, definition, or submits
|
|
37
|
-
* it for review.
|
|
39
|
+
* it for review. While the template is in review (status PENDING, or any channel
|
|
40
|
+
* awaiting a verdict) its definition, category and language are frozen and a
|
|
41
|
+
* resubmission is refused — those requests answer 409 CONFLICT_006. The display
|
|
42
|
+
* name stays editable throughout.
|
|
43
|
+
*
|
|
44
|
+
* `definition`, `category` and `language` are editable only from status DRAFT,
|
|
45
|
+
* REJECTED or APPROVED. An edit to any of them on a template in another state
|
|
46
|
+
* (PAUSED, DISABLED or REVOKED) is refused with 400 VALIDATION_001 and the detail
|
|
47
|
+
* "Template (except display name) cannot be updated unless it is in draft or
|
|
48
|
+
* rejected status"; `name` stays editable in every state. `submit_for_review` on a
|
|
49
|
+
* PAUSED, DISABLED or REVOKED template is accepted and answers 200, but opens no
|
|
50
|
+
* review and does not move the status — only the reviewer can reinstate it.
|
|
51
|
+
*
|
|
52
|
+
* Editing an APPROVED template is a live edit: the new content is stored
|
|
53
|
+
* immediately, and sending `submit_for_review: true` re-opens review, which
|
|
54
|
+
* returns the affected channels to PENDING so they stop sending until they are
|
|
55
|
+
* approved again. The previously approved content is never sent during re-review.
|
|
56
|
+
* Watch the per-channel `templates` webhook events rather than assuming the
|
|
57
|
+
* template-level status.
|
|
58
|
+
*
|
|
59
|
+
* Templates provisioned by Sent (light-onboarding templates, whose names carry the
|
|
60
|
+
* reserved `sent_` prefix) are read-only: every field is refused with 400
|
|
61
|
+
* VALIDATION*001 and the detail "This template is read-only. Only 'submit for
|
|
62
|
+
* review' is allowed.", and only `submit_for_review` is accepted. A `name`
|
|
63
|
+
* starting with `sent*` is refused for the same reason — the prefix is reserved.
|
|
38
64
|
*
|
|
39
65
|
* @example
|
|
40
66
|
* ```ts
|
|
@@ -50,13 +76,13 @@ export declare class Templates extends APIResource {
|
|
|
50
76
|
*
|
|
51
77
|
* @example
|
|
52
78
|
* ```ts
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* }
|
|
79
|
+
* // Automatically fetches more pages as needed.
|
|
80
|
+
* for await (const template of client.templates.list()) {
|
|
81
|
+
* // ...
|
|
82
|
+
* }
|
|
57
83
|
* ```
|
|
58
84
|
*/
|
|
59
|
-
list(params
|
|
85
|
+
list(params?: TemplateListParams | null | undefined, options?: RequestOptions): PagePromise<TemplatesTemplatesPage, Template>;
|
|
60
86
|
/**
|
|
61
87
|
* Deletes a template by ID. Optionally, you can also delete the template from
|
|
62
88
|
* WhatsApp/Meta by setting delete_from_meta=true.
|
|
@@ -70,6 +96,7 @@ export declare class Templates extends APIResource {
|
|
|
70
96
|
*/
|
|
71
97
|
delete(id: string, params: TemplateDeleteParams, options?: RequestOptions): APIPromise<void>;
|
|
72
98
|
}
|
|
99
|
+
export type TemplatesTemplatesPage = TemplatesPage<Template>;
|
|
73
100
|
/**
|
|
74
101
|
* Standard API response envelope for all v3 endpoints
|
|
75
102
|
*/
|
|
@@ -119,12 +146,38 @@ export interface Template {
|
|
|
119
146
|
* Unique template identifier
|
|
120
147
|
*/
|
|
121
148
|
id?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Which consent keyword this template answers, when it is one of Sent's
|
|
151
|
+
* auto-replies: OPT_IN, OPT_OUT, HELP, or OTHER for a customer-defined keyword.
|
|
152
|
+
* Null for an ordinary template, and omitted from the response, so its presence is
|
|
153
|
+
* the answer to "is this an auto-reply".
|
|
154
|
+
*
|
|
155
|
+
* Deliberately not required, unlike CustomerId, even though the same "no single
|
|
156
|
+
* mapper" argument applies: NJsonSchema publishes a C# required member in the
|
|
157
|
+
* schema's required array, so the contract would have advertised a field this
|
|
158
|
+
* response omits for every ordinary template, and a generated client could refuse
|
|
159
|
+
* the common case. A compile-time guard is not worth a wrong published contract.
|
|
160
|
+
* Every mapping site sets it explicitly, and TemplateResponseSchemaTests pins the
|
|
161
|
+
* field as optional so it cannot be reintroduced.
|
|
162
|
+
*/
|
|
163
|
+
auto_reply_action?: string | null;
|
|
122
164
|
/**
|
|
123
165
|
* Template category: MARKETING, UTILITY, AUTHENTICATION
|
|
124
166
|
*/
|
|
125
167
|
category?: string;
|
|
126
168
|
/**
|
|
127
|
-
*
|
|
169
|
+
* The channels this template's definition can render on, in canonical order: sms,
|
|
170
|
+
* whatsapp, rcs.
|
|
171
|
+
*
|
|
172
|
+
* Derived from the definition's body, mirroring each channel's send-time fallback
|
|
173
|
+
* chain, so a channel is listed only when a real body would be produced for it:
|
|
174
|
+
* SMS reads sms ?? multiChannel, WhatsApp reads whatsapp ?? multiChannel, and RCS
|
|
175
|
+
* reads rcs ?? multiChannel ?? sms. A multiChannel body therefore reports all
|
|
176
|
+
* three, and the extra SMS fallback on RCS is why an sms/whatsapp pair reports RCS
|
|
177
|
+
* too.
|
|
178
|
+
*
|
|
179
|
+
* This says what the content can render on, not what may be sent: sending also
|
|
180
|
+
* needs the template approved for that channel.
|
|
128
181
|
*/
|
|
129
182
|
channels?: Array<string> | null;
|
|
130
183
|
/**
|
|
@@ -144,7 +197,8 @@ export interface Template {
|
|
|
144
197
|
*/
|
|
145
198
|
name?: string;
|
|
146
199
|
/**
|
|
147
|
-
* Template status:
|
|
200
|
+
* Template status: DRAFT, PENDING, APPROVED, REJECTED. A template created with
|
|
201
|
+
* submit_for_review: false starts as DRAFT and stays there until it is submitted.
|
|
148
202
|
*/
|
|
149
203
|
status?: string;
|
|
150
204
|
/**
|
|
@@ -157,31 +211,73 @@ export interface Template {
|
|
|
157
211
|
variables?: Array<string> | null;
|
|
158
212
|
}
|
|
159
213
|
/**
|
|
160
|
-
* Body section of a message template
|
|
214
|
+
* Body section of a message template.
|
|
215
|
+
*
|
|
216
|
+
* A body picks one of two authoring strategies, and mixing them is refused
|
|
217
|
+
* (TemplateDefinitionValidator.HaveValidChannelConfiguration): a shared
|
|
218
|
+
* multiChannel body on its own, or an explicit sms + whatsapp pair, both present.
|
|
219
|
+
*
|
|
220
|
+
* multiChannel together with sms or whatsapp is rejected, and so is sms or
|
|
221
|
+
* whatsapp on its own — every template is expected to be deliverable on every
|
|
222
|
+
* channel. rcs is the one true override: it may accompany either strategy to vary
|
|
223
|
+
* the copy, but cannot stand alone.
|
|
161
224
|
*/
|
|
162
225
|
export interface TemplateBody {
|
|
163
226
|
/**
|
|
164
|
-
*
|
|
165
|
-
* channel-specific content is provided
|
|
227
|
+
* The shared body, used for every channel. One half of the choice described above.
|
|
166
228
|
*/
|
|
167
229
|
multiChannel?: TemplateBodyContent | null;
|
|
168
230
|
/**
|
|
169
|
-
* RCS-specific
|
|
231
|
+
* RCS-specific copy that overrides the chosen strategy for RCS only. The one true
|
|
232
|
+
* override: optional on top of either strategy, but it cannot be the only body
|
|
233
|
+
* present. Its length cap is the higher one described on Template.
|
|
170
234
|
*/
|
|
171
235
|
rcs?: TemplateBodyContent | null;
|
|
172
236
|
/**
|
|
173
|
-
* SMS
|
|
237
|
+
* The SMS body. It does not override multiChannel, it replaces it.
|
|
174
238
|
*/
|
|
175
239
|
sms?: TemplateBodyContent | null;
|
|
176
240
|
/**
|
|
177
|
-
* WhatsApp
|
|
178
|
-
* messages
|
|
241
|
+
* The WhatsApp body. It does not override multiChannel, it replaces it.
|
|
179
242
|
*/
|
|
180
243
|
whatsapp?: TemplateBodyContent | null;
|
|
181
244
|
}
|
|
182
245
|
export interface TemplateBodyContent {
|
|
246
|
+
/**
|
|
247
|
+
* The body copy, with variables written as {{index:variable}}.
|
|
248
|
+
*
|
|
249
|
+
* Length cap depends on which channel this body belongs to:
|
|
250
|
+
* TemplateContentLimits.MaxBodyLength (1024) for multiChannel, sms and whatsapp —
|
|
251
|
+
* Meta's BODY limit, which a multiChannel body may be delivered under — and
|
|
252
|
+
* TemplateContentLimits.MaxRcsBodyLength (3072) for an rcs body, which never
|
|
253
|
+
* reaches Meta. The maxLength advertised on this schema is the 1024 one, because
|
|
254
|
+
* all four channel bodies share this single schema — an rcs body between the two
|
|
255
|
+
* is accepted.
|
|
256
|
+
*
|
|
257
|
+
* Meta requires every variable to carry surrounding context, so a body is refused
|
|
258
|
+
* unless it also satisfies all of the following (enforced by
|
|
259
|
+
* TemplateDefinitionValidator): At least one letter before the first variable and
|
|
260
|
+
* after the last — trailing punctuation such as "... {{1:variable}}." does not
|
|
261
|
+
* count. At least (2 × variable count) + 1 words once the placeholders are
|
|
262
|
+
* removed. No two variables adjacent with only whitespace between them. No leading
|
|
263
|
+
* or trailing newline, no more than two consecutive line breaks, and no more than
|
|
264
|
+
* four consecutive spaces.
|
|
265
|
+
*
|
|
266
|
+
* Example: "Hello {{0:variable}}! Welcome to {{1:variable}}. We are glad to have
|
|
267
|
+
* you on board." — two variables, so at least five words are required, and the
|
|
268
|
+
* copy after the final variable contains letters.
|
|
269
|
+
*/
|
|
183
270
|
template: string;
|
|
271
|
+
/**
|
|
272
|
+
* The type of body content — send "text". It is dropped from the stored definition
|
|
273
|
+
* when null, so a body posted without it is saved with no type key at all and the
|
|
274
|
+
* template editor has nothing to render the block from.
|
|
275
|
+
*/
|
|
184
276
|
type?: string | null;
|
|
277
|
+
/**
|
|
278
|
+
* The variables referenced by the body copy, one entry per {{index:variable}}
|
|
279
|
+
* placeholder.
|
|
280
|
+
*/
|
|
185
281
|
variables?: Array<TemplateVariable> | null;
|
|
186
282
|
}
|
|
187
283
|
/**
|
|
@@ -197,7 +293,13 @@ export interface TemplateButton {
|
|
|
197
293
|
*/
|
|
198
294
|
type: string;
|
|
199
295
|
/**
|
|
200
|
-
* The
|
|
296
|
+
* The button's identifier (1-based index), unique within the template.
|
|
297
|
+
*
|
|
298
|
+
* Omitting it is only safe for a template holding a single button. The field is a
|
|
299
|
+
* non-nullable int, so every button that leaves it out defaults to 0, and two such
|
|
300
|
+
* buttons are refused by the unique-id rule ("Button IDs must be unique"). Number
|
|
301
|
+
* them from 1 in the order they should appear — order matters on RCS, where only
|
|
302
|
+
* the first four buttons render.
|
|
201
303
|
*/
|
|
202
304
|
id?: number;
|
|
203
305
|
}
|
|
@@ -207,6 +309,19 @@ export interface TemplateButtonProps {
|
|
|
207
309
|
offerCode: string;
|
|
208
310
|
phoneNumber: string;
|
|
209
311
|
quickReplyType: string;
|
|
312
|
+
/**
|
|
313
|
+
* The button's label. Required for every button type, and capped at
|
|
314
|
+
* TemplateContentLimits.MaxButtonTextLength (25) characters.
|
|
315
|
+
*
|
|
316
|
+
* Meta accepts only static text here, so a label is refused when it contains a
|
|
317
|
+
* {{...}} variable placeholder, a newline, an emoji, or WhatsApp formatting markup
|
|
318
|
+
* (\*, \_, ~) — enforced by ApplyButtonLabelContentRules in
|
|
319
|
+
* TemplateButtonValidator. Meta reports all four as one error: "Buttons can't have
|
|
320
|
+
* any variables, newlines, emojis, or formatting characters."
|
|
321
|
+
*
|
|
322
|
+
* AUTHENTICATION OTP buttons are the exception: Meta auto-localizes their label
|
|
323
|
+
* from the template language, and the converter drops whatever text was sent.
|
|
324
|
+
*/
|
|
210
325
|
text: string;
|
|
211
326
|
url: string;
|
|
212
327
|
urlType: string;
|
|
@@ -227,7 +342,16 @@ export interface TemplateButtonProps {
|
|
|
227
342
|
*/
|
|
228
343
|
export interface TemplateDefinition {
|
|
229
344
|
/**
|
|
230
|
-
* Body section of a message template
|
|
345
|
+
* Body section of a message template.
|
|
346
|
+
*
|
|
347
|
+
* A body picks one of two authoring strategies, and mixing them is refused
|
|
348
|
+
* (TemplateDefinitionValidator.HaveValidChannelConfiguration): a shared
|
|
349
|
+
* multiChannel body on its own, or an explicit sms + whatsapp pair, both present.
|
|
350
|
+
*
|
|
351
|
+
* multiChannel together with sms or whatsapp is rejected, and so is sms or
|
|
352
|
+
* whatsapp on its own — every template is expected to be deliverable on every
|
|
353
|
+
* channel. rcs is the one true override: it may accompany either strategy to vary
|
|
354
|
+
* the copy, but cannot stand alone.
|
|
231
355
|
*/
|
|
232
356
|
body: TemplateBody;
|
|
233
357
|
/**
|
|
@@ -287,9 +411,26 @@ export interface TemplateHeader {
|
|
|
287
411
|
variables?: Array<TemplateVariable> | null;
|
|
288
412
|
}
|
|
289
413
|
export interface TemplateVariable {
|
|
414
|
+
/**
|
|
415
|
+
* The variable's name, and the key callers use for it in a send request's
|
|
416
|
+
* parameters object. Must start with a letter and hold only letters, digits and
|
|
417
|
+
* underscores.
|
|
418
|
+
*/
|
|
290
419
|
name: string;
|
|
291
420
|
props: TemplateVariable.Props;
|
|
421
|
+
/**
|
|
422
|
+
* One of variable, link or media. Decides which Props fields are required.
|
|
423
|
+
*/
|
|
292
424
|
type: string;
|
|
425
|
+
/**
|
|
426
|
+
* The variable's index, and the number its {{index:variable}} placeholder refers
|
|
427
|
+
* to.
|
|
428
|
+
*
|
|
429
|
+
* Omitting it is only safe for a section holding a single variable. The field is a
|
|
430
|
+
* non-nullable int, so every variable that leaves it out defaults to 0, and a
|
|
431
|
+
* section with two such variables is refused by the unique-id rule ("variables
|
|
432
|
+
* must have unique IDs"). Number them from 0 in the order they appear.
|
|
433
|
+
*/
|
|
293
434
|
id?: number;
|
|
294
435
|
}
|
|
295
436
|
export declare namespace TemplateVariable {
|
|
@@ -303,42 +444,6 @@ export declare namespace TemplateVariable {
|
|
|
303
444
|
shortUrl?: string | null;
|
|
304
445
|
}
|
|
305
446
|
}
|
|
306
|
-
/**
|
|
307
|
-
* Standard API response envelope for all v3 endpoints
|
|
308
|
-
*/
|
|
309
|
-
export interface TemplateListResponse {
|
|
310
|
-
/**
|
|
311
|
-
* A paginated list of templates.
|
|
312
|
-
*/
|
|
313
|
-
data?: TemplateListResponse.Data | null;
|
|
314
|
-
/**
|
|
315
|
-
* Error information
|
|
316
|
-
*/
|
|
317
|
-
error?: WebhooksAPI.ErrorDetail | null;
|
|
318
|
-
/**
|
|
319
|
-
* Request and response metadata
|
|
320
|
-
*/
|
|
321
|
-
meta?: WebhooksAPI.APIMeta;
|
|
322
|
-
/**
|
|
323
|
-
* Indicates whether the request was successful
|
|
324
|
-
*/
|
|
325
|
-
success?: boolean;
|
|
326
|
-
}
|
|
327
|
-
export declare namespace TemplateListResponse {
|
|
328
|
-
/**
|
|
329
|
-
* A paginated list of templates.
|
|
330
|
-
*/
|
|
331
|
-
interface Data {
|
|
332
|
-
/**
|
|
333
|
-
* Pagination metadata for list responses
|
|
334
|
-
*/
|
|
335
|
-
pagination?: WebhooksAPI.PaginationMeta;
|
|
336
|
-
/**
|
|
337
|
-
* The templates on this page.
|
|
338
|
-
*/
|
|
339
|
-
templates?: Array<TemplatesAPI.Template>;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
447
|
export interface TemplateCreateParams {
|
|
343
448
|
/**
|
|
344
449
|
* Body param: Template category: MARKETING, UTILITY, AUTHENTICATION (optional,
|
|
@@ -430,15 +535,7 @@ export interface TemplateUpdateParams {
|
|
|
430
535
|
*/
|
|
431
536
|
'x-profile-id'?: string;
|
|
432
537
|
}
|
|
433
|
-
export interface TemplateListParams {
|
|
434
|
-
/**
|
|
435
|
-
* Query param: Page number (1-indexed)
|
|
436
|
-
*/
|
|
437
|
-
page: number;
|
|
438
|
-
/**
|
|
439
|
-
* Query param: Number of items per page
|
|
440
|
-
*/
|
|
441
|
-
page_size: number;
|
|
538
|
+
export interface TemplateListParams extends TemplatesPageParams {
|
|
442
539
|
/**
|
|
443
540
|
* Query param: Optional category filter: MARKETING, UTILITY, AUTHENTICATION
|
|
444
541
|
*/
|
|
@@ -485,6 +582,6 @@ export interface TemplateDeleteParams {
|
|
|
485
582
|
'x-profile-id'?: string;
|
|
486
583
|
}
|
|
487
584
|
export declare namespace Templates {
|
|
488
|
-
export { type APIResponseTemplate as APIResponseTemplate, type AuthenticationConfig as AuthenticationConfig, type Template as Template, type TemplateBody as TemplateBody, type TemplateBodyContent as TemplateBodyContent, type TemplateButton as TemplateButton, type TemplateButtonProps as TemplateButtonProps, type TemplateDefinition as TemplateDefinition, type TemplateFooter as TemplateFooter, type TemplateHeader as TemplateHeader, type TemplateVariable as TemplateVariable, type
|
|
585
|
+
export { type APIResponseTemplate as APIResponseTemplate, type AuthenticationConfig as AuthenticationConfig, type Template as Template, type TemplateBody as TemplateBody, type TemplateBodyContent as TemplateBodyContent, type TemplateButton as TemplateButton, type TemplateButtonProps as TemplateButtonProps, type TemplateDefinition as TemplateDefinition, type TemplateFooter as TemplateFooter, type TemplateHeader as TemplateHeader, type TemplateVariable as TemplateVariable, type TemplatesTemplatesPage as TemplatesTemplatesPage, type TemplateCreateParams as TemplateCreateParams, type TemplateRetrieveParams as TemplateRetrieveParams, type TemplateUpdateParams as TemplateUpdateParams, type TemplateListParams as TemplateListParams, type TemplateDeleteParams as TemplateDeleteParams, };
|
|
489
586
|
}
|
|
490
587
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,KAAK,WAAW,sBAAmB;AAC1C,OAAO,EAAE,UAAU,EAAE,+BAA4B;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,8BAA2B;AAE1F,OAAO,EAAE,cAAc,EAAE,uCAAoC;AAG7D;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CA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W,oBAAoB;IACnC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,OAAO,EACL,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,QAAQ,IAAI,QAAQ,EACzB,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,oBAAoB,IAAI,oBAAoB,GAClD,CAAC;CACH"}
|
package/resources/templates.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Templates = void 0;
|
|
5
5
|
const resource_1 = require("../core/resource.js");
|
|
6
|
+
const pagination_1 = require("../core/pagination.js");
|
|
6
7
|
const headers_1 = require("../internal/headers.js");
|
|
7
8
|
const path_1 = require("../internal/utils/path.js");
|
|
8
9
|
/**
|
|
@@ -14,7 +15,9 @@ class Templates extends resource_1.APIResource {
|
|
|
14
15
|
/**
|
|
15
16
|
* Creates a new message template with header, body, footer, and buttons. The
|
|
16
17
|
* template can be submitted for review immediately or saved as draft for later
|
|
17
|
-
* submission.
|
|
18
|
+
* submission. There is no `name` field on create — the display name is derived
|
|
19
|
+
* from the template's content and can be changed afterwards with
|
|
20
|
+
* `PUT /v3/templates/{id}`.
|
|
18
21
|
*
|
|
19
22
|
* @example
|
|
20
23
|
* ```ts
|
|
@@ -58,7 +61,31 @@ class Templates extends resource_1.APIResource {
|
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* Updates an existing template's name, category, language, definition, or submits
|
|
61
|
-
* it for review.
|
|
64
|
+
* it for review. While the template is in review (status PENDING, or any channel
|
|
65
|
+
* awaiting a verdict) its definition, category and language are frozen and a
|
|
66
|
+
* resubmission is refused — those requests answer 409 CONFLICT_006. The display
|
|
67
|
+
* name stays editable throughout.
|
|
68
|
+
*
|
|
69
|
+
* `definition`, `category` and `language` are editable only from status DRAFT,
|
|
70
|
+
* REJECTED or APPROVED. An edit to any of them on a template in another state
|
|
71
|
+
* (PAUSED, DISABLED or REVOKED) is refused with 400 VALIDATION_001 and the detail
|
|
72
|
+
* "Template (except display name) cannot be updated unless it is in draft or
|
|
73
|
+
* rejected status"; `name` stays editable in every state. `submit_for_review` on a
|
|
74
|
+
* PAUSED, DISABLED or REVOKED template is accepted and answers 200, but opens no
|
|
75
|
+
* review and does not move the status — only the reviewer can reinstate it.
|
|
76
|
+
*
|
|
77
|
+
* Editing an APPROVED template is a live edit: the new content is stored
|
|
78
|
+
* immediately, and sending `submit_for_review: true` re-opens review, which
|
|
79
|
+
* returns the affected channels to PENDING so they stop sending until they are
|
|
80
|
+
* approved again. The previously approved content is never sent during re-review.
|
|
81
|
+
* Watch the per-channel `templates` webhook events rather than assuming the
|
|
82
|
+
* template-level status.
|
|
83
|
+
*
|
|
84
|
+
* Templates provisioned by Sent (light-onboarding templates, whose names carry the
|
|
85
|
+
* reserved `sent_` prefix) are read-only: every field is refused with 400
|
|
86
|
+
* VALIDATION*001 and the detail "This template is read-only. Only 'submit for
|
|
87
|
+
* review' is allowed.", and only `submit_for_review` is accepted. A `name`
|
|
88
|
+
* starting with `sent*` is refused for the same reason — the prefix is reserved.
|
|
62
89
|
*
|
|
63
90
|
* @example
|
|
64
91
|
* ```ts
|
|
@@ -87,15 +114,15 @@ class Templates extends resource_1.APIResource {
|
|
|
87
114
|
*
|
|
88
115
|
* @example
|
|
89
116
|
* ```ts
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* }
|
|
117
|
+
* // Automatically fetches more pages as needed.
|
|
118
|
+
* for await (const template of client.templates.list()) {
|
|
119
|
+
* // ...
|
|
120
|
+
* }
|
|
94
121
|
* ```
|
|
95
122
|
*/
|
|
96
|
-
list(params, options) {
|
|
97
|
-
const { 'x-profile-id': xProfileID, ...query } = params;
|
|
98
|
-
return this._client.
|
|
123
|
+
list(params = {}, options) {
|
|
124
|
+
const { 'x-profile-id': xProfileID, ...query } = params ?? {};
|
|
125
|
+
return this._client.getAPIList('/v3/templates', (pagination_1.TemplatesPage), {
|
|
99
126
|
query,
|
|
100
127
|
...options,
|
|
101
128
|
headers: (0, headers_1.buildHeaders)([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,sDAA0F;AAC1F,oDAAmD;AAEnD,oDAA8C;AAE9C;;;;GAIG;AACH,MAAa,SAAU,SAAQ,sBAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAA4B,EAAE,OAAwB;QAC3D,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe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AU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACvF,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AA7JD,8BA6JC"}
|
package/resources/templates.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { APIResource } from "../core/resource.mjs";
|
|
3
|
+
import { TemplatesPage } from "../core/pagination.mjs";
|
|
3
4
|
import { buildHeaders } from "../internal/headers.mjs";
|
|
4
5
|
import { path } from "../internal/utils/path.mjs";
|
|
5
6
|
/**
|
|
@@ -11,7 +12,9 @@ export class Templates extends APIResource {
|
|
|
11
12
|
/**
|
|
12
13
|
* Creates a new message template with header, body, footer, and buttons. The
|
|
13
14
|
* template can be submitted for review immediately or saved as draft for later
|
|
14
|
-
* submission.
|
|
15
|
+
* submission. There is no `name` field on create — the display name is derived
|
|
16
|
+
* from the template's content and can be changed afterwards with
|
|
17
|
+
* `PUT /v3/templates/{id}`.
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```ts
|
|
@@ -55,7 +58,31 @@ export class Templates extends APIResource {
|
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
60
|
* Updates an existing template's name, category, language, definition, or submits
|
|
58
|
-
* it for review.
|
|
61
|
+
* it for review. While the template is in review (status PENDING, or any channel
|
|
62
|
+
* awaiting a verdict) its definition, category and language are frozen and a
|
|
63
|
+
* resubmission is refused — those requests answer 409 CONFLICT_006. The display
|
|
64
|
+
* name stays editable throughout.
|
|
65
|
+
*
|
|
66
|
+
* `definition`, `category` and `language` are editable only from status DRAFT,
|
|
67
|
+
* REJECTED or APPROVED. An edit to any of them on a template in another state
|
|
68
|
+
* (PAUSED, DISABLED or REVOKED) is refused with 400 VALIDATION_001 and the detail
|
|
69
|
+
* "Template (except display name) cannot be updated unless it is in draft or
|
|
70
|
+
* rejected status"; `name` stays editable in every state. `submit_for_review` on a
|
|
71
|
+
* PAUSED, DISABLED or REVOKED template is accepted and answers 200, but opens no
|
|
72
|
+
* review and does not move the status — only the reviewer can reinstate it.
|
|
73
|
+
*
|
|
74
|
+
* Editing an APPROVED template is a live edit: the new content is stored
|
|
75
|
+
* immediately, and sending `submit_for_review: true` re-opens review, which
|
|
76
|
+
* returns the affected channels to PENDING so they stop sending until they are
|
|
77
|
+
* approved again. The previously approved content is never sent during re-review.
|
|
78
|
+
* Watch the per-channel `templates` webhook events rather than assuming the
|
|
79
|
+
* template-level status.
|
|
80
|
+
*
|
|
81
|
+
* Templates provisioned by Sent (light-onboarding templates, whose names carry the
|
|
82
|
+
* reserved `sent_` prefix) are read-only: every field is refused with 400
|
|
83
|
+
* VALIDATION*001 and the detail "This template is read-only. Only 'submit for
|
|
84
|
+
* review' is allowed.", and only `submit_for_review` is accepted. A `name`
|
|
85
|
+
* starting with `sent*` is refused for the same reason — the prefix is reserved.
|
|
59
86
|
*
|
|
60
87
|
* @example
|
|
61
88
|
* ```ts
|
|
@@ -84,15 +111,15 @@ export class Templates extends APIResource {
|
|
|
84
111
|
*
|
|
85
112
|
* @example
|
|
86
113
|
* ```ts
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* }
|
|
114
|
+
* // Automatically fetches more pages as needed.
|
|
115
|
+
* for await (const template of client.templates.list()) {
|
|
116
|
+
* // ...
|
|
117
|
+
* }
|
|
91
118
|
* ```
|
|
92
119
|
*/
|
|
93
|
-
list(params, options) {
|
|
94
|
-
const { 'x-profile-id': xProfileID, ...query } = params;
|
|
95
|
-
return this._client.
|
|
120
|
+
list(params = {}, options) {
|
|
121
|
+
const { 'x-profile-id': xProfileID, ...query } = params ?? {};
|
|
122
|
+
return this._client.getAPIList('/v3/templates', (TemplatesPage), {
|
|
96
123
|
query,
|
|
97
124
|
...options,
|
|
98
125
|
headers: buildHeaders([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.mjs","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;
|
|
1
|
+
{"version":3,"file":"templates.mjs","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAG/C,OAAO,EAAe,aAAa,EAA4B,+BAA2B;AAC1F,OAAO,EAAE,YAAY,EAAE,gCAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,mCAA+B;AAE9C;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,WAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAA4B,EAAE,OAAwB;QAC3D,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YACxC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC;gBACpB;oBACE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC/E,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACrE;gBACD,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CACN,EAAU,EACV,SAAoD,EAAE,EACtD,OAAwB;QAExB,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,iBAAiB,EAAE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