palbase 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +2 -2
  3. package/dist/ai/index.js +17 -0
  4. package/dist/backend/engine.js +2 -0
  5. package/dist/backend/env.js +1 -0
  6. package/dist/backend/index.js +12 -0
  7. package/dist/backend/stack.js +1 -0
  8. package/dist/backend/test.js +2 -0
  9. package/dist/chunks/5W6XJM46.js +13 -0
  10. package/dist/chunks/6OPBXB7Z.js +2 -0
  11. package/dist/chunks/7LOMYBLN.js +20 -0
  12. package/dist/chunks/AN5LCF5K.js +55 -0
  13. package/dist/chunks/ECUYQ73P.js +2 -0
  14. package/dist/chunks/HDX6YUAB.js +2 -0
  15. package/dist/chunks/HVC2C35F.js +2 -0
  16. package/dist/chunks/I3JNX6MZ.js +4 -0
  17. package/dist/chunks/JEJ5CFTK.js +2 -0
  18. package/dist/chunks/K3C2IEDS.js +2 -0
  19. package/dist/chunks/KRBVYYME.js +2 -0
  20. package/dist/chunks/NIJHTHNF.js +2 -0
  21. package/dist/chunks/TL4H6V3P.js +2 -0
  22. package/dist/chunks/UTRQWCMD.js +6 -0
  23. package/dist/chunks/ZFPDYRRY.js +2 -0
  24. package/dist/cli.js +815 -0
  25. package/dist/refuse/ai.js +2 -0
  26. package/dist/refuse/backend.js +2 -0
  27. package/dist/refuse/server.js +2 -0
  28. package/dist/server/index.js +2 -0
  29. package/dist/server/testing.js +2 -0
  30. package/dist/web/index.js +2 -0
  31. package/dist/web/palbe.js +2 -0
  32. package/dist/web/paywall.js +2 -0
  33. package/dist/web/vite.js +3 -0
  34. package/package.json +111 -4
  35. package/types/ai/src/ai.d.ts +178 -0
  36. package/types/ai/src/index.d.ts +5 -0
  37. package/types/ai/src/partial.d.ts +1 -0
  38. package/types/ai/src/schema.d.ts +47 -0
  39. package/types/backend/src/bootstrap.d.ts +72 -0
  40. package/types/backend/src/cache.d.ts +32 -0
  41. package/types/backend/src/container.d.ts +49 -0
  42. package/types/backend/src/database.d.ts +148 -0
  43. package/types/backend/src/db-env.d.ts +4 -0
  44. package/types/backend/src/decorators.d.ts +293 -0
  45. package/types/backend/src/engine-db.d.ts +24 -0
  46. package/types/backend/src/engine-exports.d.ts +3 -0
  47. package/types/backend/src/engine.d.ts +124 -0
  48. package/types/backend/src/env.d.ts +27 -0
  49. package/types/backend/src/errors.d.ts +70 -0
  50. package/types/backend/src/i18n.d.ts +21 -0
  51. package/types/backend/src/index.d.ts +23 -0
  52. package/types/backend/src/openapi.d.ts +73 -0
  53. package/types/backend/src/platform-calls.d.ts +41 -0
  54. package/types/backend/src/requests.d.ts +81 -0
  55. package/types/backend/src/rooms.d.ts +168 -0
  56. package/types/backend/src/router.d.ts +22 -0
  57. package/types/backend/src/runtime.d.ts +56 -0
  58. package/types/backend/src/services.d.ts +262 -0
  59. package/types/backend/src/stack.d.ts +20 -0
  60. package/types/backend/src/strings-files.d.ts +3 -0
  61. package/types/backend/src/testing/index.d.ts +3 -0
  62. package/types/backend/src/testing/unit.d.ts +66 -0
  63. package/types/backend/src/upload.d.ts +125 -0
  64. package/types/backend/src/webhooks.d.ts +113 -0
  65. package/types/internal/src/event.d.ts +9 -0
  66. package/types/internal/src/modules/ai.d.ts +678 -0
  67. package/types/internal/src/modules/analytics.d.ts +1414 -0
  68. package/types/internal/src/modules/auth.d.ts +5660 -0
  69. package/types/internal/src/modules/cache.d.ts +158 -0
  70. package/types/internal/src/modules/events.d.ts +19 -0
  71. package/types/internal/src/modules/flags.d.ts +957 -0
  72. package/types/internal/src/modules/index.d.ts +13 -0
  73. package/types/internal/src/modules/machines.d.ts +1584 -0
  74. package/types/internal/src/modules/notify.d.ts +1450 -0
  75. package/types/internal/src/modules/purchases.d.ts +4113 -0
  76. package/types/internal/src/modules/realtime.d.ts +326 -0
  77. package/types/internal/src/modules/secrets.d.ts +275 -0
  78. package/types/internal/src/modules/storage.d.ts +691 -0
  79. package/types/internal/src/modules/stores.d.ts +1516 -0
  80. package/types/internal/src/retry.d.ts +14 -0
  81. package/types/internal/src/transport.d.ts +106 -0
  82. package/types/server/src/auth/dpop.d.ts +47 -0
  83. package/types/server/src/auth/jwt.d.ts +115 -0
  84. package/types/server/src/index.d.ts +9 -0
  85. package/types/server/src/pages.d.ts +4 -0
  86. package/types/server/src/purchases.d.ts +51 -0
  87. package/types/server/src/secrets-env.d.ts +22 -0
  88. package/types/server/src/server.d.ts +40 -0
  89. package/types/server/src/testing.d.ts +91 -0
  90. package/types/server/src/webhooks.d.ts +72 -0
  91. package/types/web/src/analytics.d.ts +87 -0
  92. package/types/web/src/auth.d.ts +155 -0
  93. package/types/web/src/backend-error.d.ts +38 -0
  94. package/types/web/src/backend-names.d.ts +25 -0
  95. package/types/web/src/backends.d.ts +84 -0
  96. package/types/web/src/client.d.ts +51 -0
  97. package/types/web/src/index.d.ts +13 -0
  98. package/types/web/src/palbe.d.ts +2 -0
  99. package/types/web/src/paywall/icons.d.ts +5 -0
  100. package/types/web/src/paywall/index.d.ts +5 -0
  101. package/types/web/src/paywall/placement.d.ts +85 -0
  102. package/types/web/src/paywall/prices.d.ts +40 -0
  103. package/types/web/src/paywall/render.d.ts +54 -0
  104. package/types/web/src/paywall/resolve.d.ts +149 -0
  105. package/types/web/src/purchases.d.ts +86 -0
  106. package/types/web/src/rooms.d.ts +61 -0
  107. package/types/web/src/session.d.ts +91 -0
  108. package/types/web/src/socket.d.ts +87 -0
  109. package/types/web/src/vite.d.ts +49 -0
@@ -0,0 +1,1450 @@
1
+ import { type Reply, type Transport } from '../transport.js';
2
+ /**
3
+ * What a push put on its way: a message per user it reaches, in the users' order, and the users whose preferences turned its category off. A push to a topic is one message, spread by the worker.
4
+ */
5
+ export type ChannelQueued = {
6
+ message_ids: string[];
7
+ skipped_user_ids: string[];
8
+ };
9
+ /**
10
+ * Whether a channel can send now, and how.
11
+ */
12
+ export type ChannelReadiness = {
13
+ because?: string;
14
+ channel: "email" | "sms" | "verify" | "whatsapp" | "push";
15
+ ok: boolean;
16
+ remedy?: string;
17
+ /**
18
+ * Whether its provider reports what became of what it sent: its credential holds what verifies the reports, or, for the shared sender, the platform reads the reports its account makes.
19
+ */
20
+ reports: boolean;
21
+ /**
22
+ * The project's own providers in failover order, or shared (the platform's sender, email only).
23
+ */
24
+ via: string[];
25
+ };
26
+ /**
27
+ * Each channel's readiness.
28
+ */
29
+ export type Deliverability = {
30
+ channels: ChannelReadiness[];
31
+ };
32
+ /**
33
+ * A provider's report about a message.
34
+ */
35
+ export type DeliveryEvent = {
36
+ /**
37
+ * The provider's own words: a bounce's reason, an error code.
38
+ */
39
+ detail?: string;
40
+ event: "sent" | "delivered" | "read" | "opened" | "clicked" | "bounced" | "complained" | "failed" | "undelivered" | "expired" | "rejected";
41
+ occurred_at: string;
42
+ provider: string;
43
+ };
44
+ /**
45
+ * A user's device — never its token.
46
+ */
47
+ export type Device = {
48
+ app_version?: string;
49
+ created_at: string;
50
+ device_id: string;
51
+ id: string;
52
+ installation_id?: string;
53
+ last_used_at?: string;
54
+ locale?: string;
55
+ platform: "android" | "ios" | "ios_voip" | "web";
56
+ updated_at: string;
57
+ user_id: string;
58
+ };
59
+ /**
60
+ * A user's devices.
61
+ */
62
+ export type DeviceList = {
63
+ devices: Device[];
64
+ };
65
+ /**
66
+ * A page of devices, the most recently registered first.
67
+ */
68
+ export type DevicePage = {
69
+ devices: Device[];
70
+ next_cursor?: string;
71
+ };
72
+ /**
73
+ * A device's push token as the app's push SDK gave it: FCM's, APNs' (a PushKit VoIP token on ios_voip), or Expo's (ExponentPushToken[…]). A token another device held moves here.
74
+ */
75
+ export type DeviceRegistration = {
76
+ app_version?: string | null;
77
+ /**
78
+ * The app's own stable name for the device.
79
+ */
80
+ device_id: string;
81
+ installation_id?: string | null;
82
+ /**
83
+ * The device's language: the push it gets is in it.
84
+ */
85
+ locale?: string | null;
86
+ platform: "android" | "ios" | "ios_voip" | "web";
87
+ token: string;
88
+ };
89
+ /**
90
+ * The project's devices, counted.
91
+ */
92
+ export type DeviceStats = {
93
+ /**
94
+ * Every platform a device registers on, in the order the API names them; one with no device has a zero.
95
+ */
96
+ platforms: PlatformDevices[];
97
+ /**
98
+ * Every device registered.
99
+ */
100
+ total: number;
101
+ /**
102
+ * The users with at least one device.
103
+ */
104
+ users: number;
105
+ };
106
+ /**
107
+ * The send's own sender, over the project's settings (its own provider only).
108
+ */
109
+ export type EmailFrom = {
110
+ email: string;
111
+ name?: string;
112
+ };
113
+ /**
114
+ * An email: a template with its variables — and, through the project's own provider, its own subject, html or text over the template's — or a subject with an html or text body (own provider only). Without a text part, the html's text is sent as one.
115
+ */
116
+ export type EmailSend = {
117
+ /**
118
+ * The message's kind: transactional (the default) reaches every user; any other — marketing, news — only users who did not turn it off on this channel (preferences). 1 to 64 of a-z, 0-9, _ . -.
119
+ */
120
+ category?: string;
121
+ from?: EmailFrom;
122
+ html?: string;
123
+ locale?: string;
124
+ /**
125
+ * More locales the send would take, most wanted first, after locale (10 at most): each, then its language alone, then the project's default and English.
126
+ */
127
+ locales?: string[];
128
+ metadata?: Metadata;
129
+ /**
130
+ * high: tried again sooner when it could not leave (5 s, 15 s, 1 min instead of 10 s, 30 s, 2 min).
131
+ */
132
+ priority?: "high" | "normal";
133
+ /**
134
+ * Where replies go (own provider only).
135
+ */
136
+ reply_to?: string;
137
+ subject?: string;
138
+ /**
139
+ * A template's slug. Auth's (auth.*) are sent through the project's own provider: on the platform's shared sender they are auth's flows' alone (403 auth_template_reserved).
140
+ */
141
+ template?: string;
142
+ text?: string;
143
+ /**
144
+ * One email address.
145
+ */
146
+ to: string;
147
+ /**
148
+ * The user the message is for: their preferences hold, and deleting them deletes it.
149
+ */
150
+ user_id?: string;
151
+ variables?: {
152
+ [key: string]: unknown;
153
+ };
154
+ };
155
+ /**
156
+ * A template as it renders now.
157
+ */
158
+ export type EmailTemplate = {
159
+ customized: boolean;
160
+ html_body: string;
161
+ locale: string;
162
+ slug: string;
163
+ subject: string;
164
+ text_body: string;
165
+ /**
166
+ * When the project last wrote its override; absent on the platform's default, which was never written.
167
+ */
168
+ updated_at?: string;
169
+ variables: string[];
170
+ };
171
+ /**
172
+ * Every template the project's email renders from, as a list shows it.
173
+ */
174
+ export type EmailTemplateList = {
175
+ templates: EmailTemplateSummary[];
176
+ };
177
+ /**
178
+ * An email template in one locale, as a list shows it: its subject (998 bytes at most), never its body — a body is up to 256 KiB of HTML and as much text.
179
+ */
180
+ export type EmailTemplateSummary = {
181
+ /**
182
+ * Whether the project overrides it.
183
+ */
184
+ customized: boolean;
185
+ locale: string;
186
+ slug: string;
187
+ subject: string;
188
+ /**
189
+ * When the project last wrote its override; absent on the platform's default, which was never written.
190
+ */
191
+ updated_at?: string;
192
+ variables: string[];
193
+ };
194
+ /**
195
+ * A template override.
196
+ */
197
+ export type EmailTemplateWrite = {
198
+ html_body: string;
199
+ subject: string;
200
+ text_body: string;
201
+ };
202
+ export type ErrorResponse = {
203
+ /**
204
+ * Machine-readable error code (snake_case)
205
+ */
206
+ error: string;
207
+ /**
208
+ * Human-readable explanation
209
+ */
210
+ error_description: string;
211
+ /**
212
+ * Correlation ID
213
+ */
214
+ request_id: string;
215
+ /**
216
+ * Seconds to wait before retrying, when the refusal ends with time.
217
+ */
218
+ retry_after?: number;
219
+ /**
220
+ * HTTP status code
221
+ */
222
+ status: number;
223
+ };
224
+ /**
225
+ * A WhatsApp message a user sent the project's number.
226
+ */
227
+ export type Inbound = {
228
+ id: string;
229
+ /**
230
+ * text, image, audio, location, … as Meta names it.
231
+ */
232
+ kind: string;
233
+ message: MetaMessage;
234
+ phone_number_id: string;
235
+ received_at: string;
236
+ sent_at: string;
237
+ };
238
+ /**
239
+ * A page of the WhatsApp messages users sent, newest first.
240
+ */
241
+ export type InboundPage = {
242
+ messages: Inbound[];
243
+ next_cursor?: string;
244
+ };
245
+ /**
246
+ * A text per BCP 47 locale.
247
+ */
248
+ export type LocaleTexts = {
249
+ [key: string]: string;
250
+ };
251
+ /**
252
+ * A text, or one per locale: each device gets the one in its language (its locale, that language, default_locale, the project's default, English), filled with variables (Handlebars, as a template) and cut to what a banner shows (65 characters for a title, 240 for a body).
253
+ */
254
+ export type LocalizedText = PlainText | LocaleTexts;
255
+ /**
256
+ * Meta's message object whole: its sender (from), its text or media.
257
+ */
258
+ export type MetaMessage = {
259
+ [key: string]: unknown;
260
+ };
261
+ /**
262
+ * Meta's WhatsApp Business Account webhook call: statuses of the messages the project sent, messages users sent its number.
263
+ */
264
+ export type MetaNotification = {
265
+ [key: string]: unknown;
266
+ };
267
+ /**
268
+ * The project's own data about the message (a JSON object, 4 KiB at most), kept with its report; null is none.
269
+ */
270
+ export type Metadata = ({
271
+ [key: string]: unknown;
272
+ }) | null;
273
+ /**
274
+ * One day's count of one channel's messages in one status.
275
+ */
276
+ export type MetricsDay = {
277
+ channel: string;
278
+ count: number;
279
+ day: string;
280
+ status: string;
281
+ };
282
+ /**
283
+ * The window counted, in whole UTC days: from, inclusive, to to, exclusive.
284
+ */
285
+ export type MetricsRange = {
286
+ from: string;
287
+ to: string;
288
+ };
289
+ /**
290
+ * Status → how many messages.
291
+ */
292
+ export type MetricsStatusCounts = {
293
+ [key: string]: number;
294
+ };
295
+ /**
296
+ * A window's counts of the project's messages, by the day they were created and their status now. A topic push is counted as its followers' pushes.
297
+ */
298
+ export type MetricsSummary = {
299
+ range: MetricsRange;
300
+ series: MetricsDay[];
301
+ /**
302
+ * Channel → status → count.
303
+ */
304
+ totals: {
305
+ [key: string]: MetricsStatusCounts;
306
+ };
307
+ };
308
+ /**
309
+ * A message's delivery report.
310
+ */
311
+ export type NotifyMessage = {
312
+ attempts: number;
313
+ /**
314
+ * The message's kind (transactional unless its send named another).
315
+ */
316
+ category: string;
317
+ channel: "email" | "sms" | "push" | "whatsapp";
318
+ created_at: string;
319
+ delivered_at?: string;
320
+ /**
321
+ * A push's report per device.
322
+ */
323
+ deliveries?: PushDelivery[];
324
+ error?: string;
325
+ /**
326
+ * What its provider reported after it left, oldest first.
327
+ */
328
+ events?: DeliveryEvent[];
329
+ id: string;
330
+ locale?: string;
331
+ metadata?: Metadata;
332
+ /**
333
+ * The topic push this is a follower's push of.
334
+ */
335
+ parent_id?: string;
336
+ priority: "high" | "normal";
337
+ provider?: string;
338
+ provider_message_id?: string;
339
+ /**
340
+ * The platform's shared sender or the project's own provider.
341
+ */
342
+ rail: "shared" | "own";
343
+ read_at?: string;
344
+ recipient_hint: string;
345
+ /**
346
+ * A topic push: how many followers it reached so far.
347
+ */
348
+ recipients?: number;
349
+ /**
350
+ * How many SMS segments a text took: what its provider bills.
351
+ */
352
+ segments?: number;
353
+ sent_at?: string;
354
+ status: "queued" | "sending" | "sent" | "failed" | "delivered" | "read" | "bounced" | "complained" | "undelivered" | "expired" | "rejected";
355
+ template?: string;
356
+ /**
357
+ * The user the message is for, when its send named one.
358
+ */
359
+ user_id?: string;
360
+ };
361
+ /**
362
+ * A page of messages, newest first.
363
+ */
364
+ export type NotifyMessagePage = {
365
+ messages: NotifyMessage[];
366
+ /**
367
+ * The cursor of the next page; absent on the last page.
368
+ */
369
+ next_cursor?: string;
370
+ };
371
+ /**
372
+ * A project's provider — never its credentials.
373
+ */
374
+ export type NotifyProvider = {
375
+ active: boolean;
376
+ channel: "email" | "sms" | "verify" | "whatsapp" | "push";
377
+ created_at: string;
378
+ /**
379
+ * Lower is tried first.
380
+ */
381
+ priority: number;
382
+ provider: string;
383
+ updated_at: string;
384
+ };
385
+ /**
386
+ * The project's providers.
387
+ */
388
+ export type NotifyProviderList = {
389
+ providers: NotifyProvider[];
390
+ };
391
+ /**
392
+ * A provider's credentials and place in the failover order.
393
+ */
394
+ export type NotifyProviderWrite = {
395
+ active?: boolean;
396
+ /**
397
+ * The provider's credentials, by channel. email — acs {connection_string, from_email}; ses {region, access_key_id, secret_access_key, from_domain}; sendgrid {api_key, from_domain, webhook_public_key: the signed Event Webhook's verification key, for delivery reports}; smtp {host, port, username, password, from_email, use_starttls}. sms — twilio {account_sid, auth_token or api_key_sid + api_key_secret, from_number or messaging_service_sid; with the auth token Twilio reports each text's delivery}; vonage {api_key, api_secret, from, signature_secret + signature_method (md5hash, md5, sha1, sha256, sha512) for its signed delivery receipts}; acs {connection_string, from_number}. verify — twilio_verify {account_sid, auth_token or api_key_sid + api_key_secret, service_sid}. whatsapp — meta {phone_number_id, access_token, api_version, app_secret + verify_token for its webhook}. push — fcm {the service account JSON}; apns {private_key, team_id, key_id, bundle_id, is_production}; expo {access_token}.
398
+ */
399
+ credentials: {
400
+ [key: string]: unknown;
401
+ };
402
+ priority?: number;
403
+ };
404
+ /**
405
+ * What a project's messages say about it, and where its texts may go.
406
+ */
407
+ export type NotifySettings = {
408
+ default_locale: string;
409
+ /**
410
+ * Who email through the project's own provider is from.
411
+ */
412
+ from_email: string | null;
413
+ /**
414
+ * The sender's display name, through the project's own SMTP, SendGrid or SES provider. ACS shows the name its sender username is registered with on the domain.
415
+ */
416
+ from_name: string | null;
417
+ /**
418
+ * Refuse an email whose recipient's domain takes no mail (no MX record, a null one, or no address), before it is queued. Off unless set.
419
+ */
420
+ mx_check?: boolean;
421
+ /**
422
+ * Where replies go.
423
+ */
424
+ reply_to: string | null;
425
+ /**
426
+ * The E.164 calling codes the project's texts may not reach even when sms_countries would let them (+1876 within +1); null: none.
427
+ */
428
+ sms_blocked_countries: string[] | null;
429
+ /**
430
+ * The E.164 calling codes the project's texts may reach (+1, +44, +90); null: every country.
431
+ */
432
+ sms_countries: string[] | null;
433
+ };
434
+ /**
435
+ * One text, for every device.
436
+ */
437
+ export type PlainText = string;
438
+ /**
439
+ * One platform's devices.
440
+ */
441
+ export type PlatformDevices = {
442
+ /**
443
+ * The devices registered on it.
444
+ */
445
+ devices: number;
446
+ platform: "android" | "ios" | "ios_voip" | "web";
447
+ };
448
+ /**
449
+ * A channel's categories: whether the user takes each.
450
+ */
451
+ export type PreferenceChannel = {
452
+ [key: string]: boolean;
453
+ };
454
+ /**
455
+ * A user's preferences: channel (email, sms, whatsapp, push) → category → whether they take it. Every channel shows transactional (always on) and marketing; a category the user never set is on.
456
+ */
457
+ export type Preferences = {
458
+ [key: string]: PreferenceChannel;
459
+ };
460
+ /**
461
+ * Key-value data for the app (4 KiB at most).
462
+ */
463
+ export type PushData = {
464
+ [key: string]: string;
465
+ };
466
+ /**
467
+ * How a push went to one device: token_invalid when its provider says no app holds the token any more, and the device is forgotten.
468
+ */
469
+ export type PushDelivery = {
470
+ at: string;
471
+ device_id: string;
472
+ error?: string;
473
+ platform: string;
474
+ provider: string;
475
+ provider_message_id?: string;
476
+ status: "sent" | "failed" | "token_invalid";
477
+ };
478
+ /**
479
+ * Who the push is for: users, or the followers of a topic.
480
+ */
481
+ export type PushRecipients = {
482
+ /**
483
+ * A topic's name: the push reaches its followers, spread by the worker.
484
+ */
485
+ topic?: string;
486
+ user_ids?: string[];
487
+ };
488
+ /**
489
+ * A push to the project's users, one message each, to every device of theirs the push reaches — or to a topic's followers.
490
+ */
491
+ export type PushSend = {
492
+ /**
493
+ * The app's localized placeholder banner key, shown until the extension rewrites it.
494
+ */
495
+ alert_loc_key?: string;
496
+ badge?: number;
497
+ body?: LocalizedText;
498
+ /**
499
+ * The message's kind: transactional (the default) reaches every user; any other — marketing, news — only users who did not turn it off on this channel (preferences). 1 to 64 of a-z, 0-9, _ . -.
500
+ */
501
+ category?: string;
502
+ collapse_key?: string;
503
+ content_available?: boolean;
504
+ data?: PushData;
505
+ /**
506
+ * A URL with a scheme (https://, myapp://); not javascript:.
507
+ */
508
+ deep_link?: string;
509
+ default_locale?: string;
510
+ /**
511
+ * An https URL.
512
+ */
513
+ image?: string;
514
+ metadata?: Metadata;
515
+ /**
516
+ * An alert the app's notification service extension rewrites before it shows (an end-to-end encrypted message's wake).
517
+ */
518
+ mutable_content?: boolean;
519
+ priority?: "high" | "normal";
520
+ /**
521
+ * voip: a PushKit call ring, to ios_voip devices only; none: every other device.
522
+ */
523
+ push_type?: "voip";
524
+ /**
525
+ * A background push the user does not see.
526
+ */
527
+ silent?: boolean;
528
+ sound?: string;
529
+ title?: LocalizedText;
530
+ to: PushRecipients;
531
+ /**
532
+ * Seconds, up to 28 days.
533
+ */
534
+ ttl?: number;
535
+ variables?: PushData;
536
+ };
537
+ /**
538
+ * A message accepted for sending — or skipped: its user turned its category off on this channel, and nothing was queued or counted.
539
+ */
540
+ export type Queued = {
541
+ message_id?: string;
542
+ skipped?: boolean;
543
+ };
544
+ /**
545
+ * A text: a template with its variables, or a body.
546
+ */
547
+ export type SMSSend = {
548
+ /**
549
+ * The text itself: 1,600 bytes and ten segments at most.
550
+ */
551
+ body?: string;
552
+ /**
553
+ * The message's kind: transactional (the default) reaches every user; any other — marketing, news — only users who did not turn it off on this channel (preferences). 1 to 64 of a-z, 0-9, _ . -.
554
+ */
555
+ category?: string;
556
+ locale?: string;
557
+ /**
558
+ * More locales the send would take, most wanted first, after locale (10 at most): each, then its language alone, then the project's default and English.
559
+ */
560
+ locales?: string[];
561
+ metadata?: Metadata;
562
+ /**
563
+ * high: tried again sooner when it could not leave (5 s, 15 s, 1 min instead of 10 s, 30 s, 2 min).
564
+ */
565
+ priority?: "high" | "normal";
566
+ template?: string;
567
+ /**
568
+ * One number in E.164 form (+14155551212).
569
+ */
570
+ to: string;
571
+ /**
572
+ * The user the message is for: their preferences hold, and deleting them deletes it.
573
+ */
574
+ user_id?: string;
575
+ variables?: {
576
+ [key: string]: unknown;
577
+ };
578
+ };
579
+ /**
580
+ * An SMS template as it renders now.
581
+ */
582
+ export type SMSTemplate = {
583
+ body: string;
584
+ customized: boolean;
585
+ locale: string;
586
+ slug: string;
587
+ /**
588
+ * When the project last wrote its override; absent on the platform's default, which was never written.
589
+ */
590
+ updated_at?: string;
591
+ variables: string[];
592
+ };
593
+ /**
594
+ * Every template the project's texts render from, each whole.
595
+ */
596
+ export type SMSTemplateList = {
597
+ templates: SMSTemplate[];
598
+ };
599
+ /**
600
+ * An SMS template override.
601
+ */
602
+ export type SMSTemplateWrite = {
603
+ body: string;
604
+ };
605
+ /**
606
+ * One SendGrid event, as SendGrid sends it.
607
+ */
608
+ export type SendGridEvent = {
609
+ [key: string]: unknown;
610
+ };
611
+ /**
612
+ * SendGrid's Event Webhook call: an array of events.
613
+ */
614
+ export type SendGridEvents = SendGridEvent[];
615
+ /**
616
+ * A text accepted for sending, and what its body takes on the wire — or skipped: its user turned its category off by SMS, and nothing was queued or counted.
617
+ */
618
+ export type Texted = {
619
+ /**
620
+ * GSM-7 when every character is in its alphabet, else UCS-2 (fewer characters a segment).
621
+ */
622
+ encoding?: "gsm7" | "ucs2";
623
+ message_id?: string;
624
+ /**
625
+ * The SMS segments the text takes.
626
+ */
627
+ segments?: number;
628
+ skipped?: boolean;
629
+ };
630
+ /**
631
+ * A topic users follow.
632
+ */
633
+ export type Topic = {
634
+ created_at: string;
635
+ id: string;
636
+ name: string;
637
+ /**
638
+ * Whether a user follows it from the app (POST /notify/topics/{name}/subscription). Otherwise only the project adds its followers — a team, its admins — and a user asking is refused (403 topic_closed). A user leaves any topic.
639
+ */
640
+ self_subscribe: boolean;
641
+ subscribers: number;
642
+ };
643
+ /**
644
+ * Opens a topic to users following it from the app, or closes it; who follows it stays.
645
+ */
646
+ export type TopicChange = {
647
+ /**
648
+ * Whether a user follows it from the app (POST /notify/topics/{name}/subscription). Otherwise only the project adds its followers — a team, its admins — and a user asking is refused (403 topic_closed). A user leaves any topic.
649
+ */
650
+ self_subscribe: boolean;
651
+ };
652
+ /**
653
+ * A new topic: its name, and whether users follow it from the app (closed unless self_subscribe).
654
+ */
655
+ export type TopicCreate = {
656
+ /**
657
+ * 1 to 128 of A-Z, a-z, 0-9, _ . : -
658
+ */
659
+ name: string;
660
+ /**
661
+ * Whether a user follows it from the app (POST /notify/topics/{name}/subscription). Otherwise only the project adds its followers — a team, its admins — and a user asking is refused (403 topic_closed). A user leaves any topic.
662
+ */
663
+ self_subscribe?: boolean;
664
+ };
665
+ /**
666
+ * A page of the project's topics, newest first.
667
+ */
668
+ export type TopicPage = {
669
+ next_cursor?: string;
670
+ topics: Topic[];
671
+ };
672
+ /**
673
+ * Users to add to a topic.
674
+ */
675
+ export type TopicSubscribers = {
676
+ user_ids: string[];
677
+ };
678
+ /**
679
+ * Twilio's status callback for a message, as Twilio sends it (a form).
680
+ */
681
+ export type TwilioStatusCallback = {
682
+ [key: string]: unknown;
683
+ };
684
+ /**
685
+ * Whether the code is the one the service sent: false for a wrong code and for one that is over (expired, used, out of attempts).
686
+ */
687
+ export type Verdict = {
688
+ approved: boolean;
689
+ };
690
+ /**
691
+ * A code to check against the one texted to the number.
692
+ */
693
+ export type VerificationCheck = {
694
+ code: string;
695
+ to: string;
696
+ };
697
+ /**
698
+ * A number to text a one-time code to, through the project's verification service.
699
+ */
700
+ export type VerificationStart = {
701
+ /**
702
+ * The text's language; empty: the service's own.
703
+ */
704
+ locale?: string;
705
+ /**
706
+ * One number in E.164 form.
707
+ */
708
+ to: string;
709
+ /**
710
+ * The user the code is for, kept with its report.
711
+ */
712
+ user_id?: string;
713
+ };
714
+ /**
715
+ * A code on its way: its report's id, and the verification service's own id and status for it.
716
+ */
717
+ export type VerificationStarted = {
718
+ message_id?: string;
719
+ status?: string;
720
+ verification_sid?: string;
721
+ };
722
+ /**
723
+ * Vonage's delivery receipt, as the account sends it (a form or JSON; or a query on GET).
724
+ */
725
+ export type VonageReceipt = {
726
+ [key: string]: unknown;
727
+ };
728
+ /**
729
+ * One of a Meta template's components, in Meta's own shape: a body's parameters, a button.
730
+ */
731
+ export type WhatsAppComponent = {
732
+ [key: string]: unknown;
733
+ };
734
+ /**
735
+ * A WhatsApp message: exactly one of a text (Meta takes one inside a conversation the user opened in the last 24 hours), a template approved on the project's account, or one of its template slugs with the slug's variables.
736
+ */
737
+ export type WhatsAppSend = {
738
+ body?: string;
739
+ /**
740
+ * The message's kind: transactional (the default) reaches every user; any other — marketing, news — only users who did not turn it off on this channel (preferences). 1 to 64 of a-z, 0-9, _ . -.
741
+ */
742
+ category?: string;
743
+ locale?: string;
744
+ /**
745
+ * More locales the send would take, most wanted first, after locale (10 at most): each, then its language alone, then the project's default and English.
746
+ */
747
+ locales?: string[];
748
+ metadata?: Metadata;
749
+ /**
750
+ * high: tried again sooner when it could not leave (5 s, 15 s, 1 min instead of 10 s, 30 s, 2 min).
751
+ */
752
+ priority?: "high" | "normal";
753
+ template?: WhatsAppTemplate;
754
+ template_slug?: string;
755
+ /**
756
+ * One number in E.164 form.
757
+ */
758
+ to: string;
759
+ /**
760
+ * The user the message is for: their preferences hold, and deleting them deletes it.
761
+ */
762
+ user_id?: string;
763
+ variables?: {
764
+ [key: string]: unknown;
765
+ };
766
+ };
767
+ /**
768
+ * A template approved on the project's Meta account: its name, language, and components in Meta's own shape.
769
+ */
770
+ export type WhatsAppTemplate = {
771
+ /**
772
+ * Meta's components: body parameters, buttons.
773
+ */
774
+ components?: WhatsAppComponent[];
775
+ language: string;
776
+ name: string;
777
+ };
778
+ /**
779
+ * A project's slug in a locale, mapped to a template approved on its Meta account: the variables fill its body in order, and a code button copies the one variable of an authentication template.
780
+ */
781
+ export type WhatsAppTemplateMap = {
782
+ code_button: boolean;
783
+ language: string;
784
+ locale: string;
785
+ name: string;
786
+ slug: string;
787
+ /**
788
+ * When the project last wrote the mapping.
789
+ */
790
+ updated_at: string;
791
+ variables: string[];
792
+ };
793
+ /**
794
+ * The project's WhatsApp template mappings.
795
+ */
796
+ export type WhatsAppTemplateMapList = {
797
+ templates: WhatsAppTemplateMap[];
798
+ };
799
+ /**
800
+ * Maps a slug in a locale to a template approved on the project's Meta account.
801
+ */
802
+ export type WhatsAppTemplateWrite = {
803
+ /**
804
+ * An authentication template's copy-code button: exactly one variable.
805
+ */
806
+ code_button?: boolean;
807
+ language: string;
808
+ name: string;
809
+ variables?: string[];
810
+ };
811
+ /** Palbase Notify */
812
+ export declare function client(t: Transport): {
813
+ /**
814
+ * Get deliverability
815
+ *
816
+ * Whether each channel can send now, through what, why not and what to do, and whether its provider reports what became of what it sent.
817
+ */
818
+ getDeliverability(input?: {
819
+ signal?: AbortSignal;
820
+ }): Promise<Reply<200, Deliverability>>;
821
+ /**
822
+ * List devices
823
+ *
824
+ * The signed-in user's devices; with the project's secret key, every device of the project — one platform's (platform), one user's (user_id). Never a token.
825
+ */
826
+ listDevices(input?: {
827
+ query?: {
828
+ limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
829
+ cursor?: string; /** Only this platform's devices. */
830
+ platform?: "android" | "ios" | "ios_voip" | "web"; /** Only this user's devices (the secret key's filter; a user sees their own). */
831
+ user_id?: string;
832
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
833
+ signal?: AbortSignal;
834
+ }): Promise<Reply<200, DevicePage>>;
835
+ /**
836
+ * Register a device
837
+ *
838
+ * Records the signed-in user's device, or its new token. A token another device held moves here: one token reaches one user. The device is the session's it is registered in: when that session ends — the user signs out, ends it from another device, an admin revokes it — the device is forgotten and no push of theirs reaches it; registered again in another session, it is that one's. A registration in a session that has ended is refused (401 session_ended).
839
+ */
840
+ registerDevice(input: {
841
+ headers?: {
842
+ "Idempotency-Key"?: string;
843
+ };
844
+ body: DeviceRegistration; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
845
+ signal?: AbortSignal;
846
+ }): Promise<Reply<200, Device>>;
847
+ /**
848
+ * Read the device stats
849
+ *
850
+ * The project's devices, counted: how many are registered, of how many users (a user with at least one device), and how many on each platform — every platform listed, one with no device as a zero. A device its user forgot, or whose token a provider called dead, is in no count.
851
+ */
852
+ getDeviceStats(input?: {
853
+ signal?: AbortSignal;
854
+ }): Promise<Reply<200, DeviceStats>>;
855
+ /**
856
+ * Forget a device
857
+ *
858
+ * Forgets the signed-in user's device by the app's own id for it — every token it registered (an iPhone's alert and VoIP tokens) — on sign-out: no push reaches it. A session ended without this call — from another device, by an admin, its refresh token revoked — forgets the devices registered in it all the same.
859
+ */
860
+ deleteMyDevice(input: {
861
+ path: {
862
+ device_id: string;
863
+ };
864
+ headers?: {
865
+ "Idempotency-Key"?: string;
866
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
867
+ signal?: AbortSignal;
868
+ }): Promise<Reply<204, undefined>>;
869
+ /**
870
+ * Send an email
871
+ *
872
+ * Queues an email through the project's own provider: a template with its variables — the platform's, as the project overrode them, or one it made — or a message composed whole. The platform's shared sender, which a project with no email provider of its own has, sends none of them for the project's key: auth's templates (auth.*) leave it from auth's own flows alone — a sign-up's confirmation, a password reset, a sign-in link — with auth's link, to the address the flow is for, and a key's send of one is refused with 403 `auth_template_reserved`; anything else is refused with 403 `own_provider_required`. Palbase's own project, Studio's, sends its notices and its organizations' invitations to Studio's developers through the shared sender with its key.
873
+ */
874
+ sendEmail(input: {
875
+ headers?: {
876
+ "Idempotency-Key"?: string;
877
+ };
878
+ body: EmailSend; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
879
+ signal?: AbortSignal;
880
+ }): Promise<Reply<202, Queued>>;
881
+ /**
882
+ * List the project's messages
883
+ *
884
+ * The project's messages, newest first: their delivery reports, never what they said; one channel's, status's, user's, category's or topic push's, created in a window.
885
+ */
886
+ listNotifyMessages(input?: {
887
+ query?: {
888
+ limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
889
+ cursor?: string; /** Only this channel's messages. */
890
+ channel?: "email" | "sms" | "whatsapp" | "push"; /** Only messages in this status. */
891
+ status?: "queued" | "sending" | "sent" | "failed" | "delivered" | "read" | "bounced" | "complained" | "undelivered" | "expired" | "rejected"; /** Only messages for this user. */
892
+ user_id?: string; /** Only this category's messages. */
893
+ category?: string; /** Only the followers' pushes of this topic push. */
894
+ parent_id?: string; /** Only messages created at or after this time (RFC 3339). */
895
+ created_after?: string; /** Only messages created before this time (RFC 3339). */
896
+ created_before?: string;
897
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
898
+ signal?: AbortSignal;
899
+ }): Promise<Reply<200, NotifyMessagePage>>;
900
+ /**
901
+ * Read a message's report
902
+ *
903
+ * A message's delivery report.
904
+ */
905
+ getNotifyMessage(input: {
906
+ path: {
907
+ id: string;
908
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
909
+ signal?: AbortSignal;
910
+ }): Promise<Reply<200, NotifyMessage>>;
911
+ /**
912
+ * Get the metrics summary
913
+ *
914
+ * The project's messages counted per channel, status and day, over a window of up to 92 days (the last 7 by default), counted in whole UTC days: from is taken back to its day's start, to on to the next day's. Reports are kept 30 days; past them a day's counts are kept.
915
+ */
916
+ getMetricsSummary(input?: {
917
+ query?: {
918
+ from?: string; /** The window's end (RFC 3339), now by default. */
919
+ to?: string;
920
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
921
+ signal?: AbortSignal;
922
+ }): Promise<Reply<200, MetricsSummary>>;
923
+ /**
924
+ * Get my preferences
925
+ *
926
+ * The signed-in user's preferences: which categories they take on which channel.
927
+ */
928
+ getMyPreferences(input?: {
929
+ signal?: AbortSignal;
930
+ }): Promise<Reply<200, Preferences>>;
931
+ /**
932
+ * Set my preferences
933
+ *
934
+ * Sets some of the signed-in user's preferences ({channel: {category: on}}) and answers all of them. Transactional is not theirs to turn off and is left as it is; a write sets 100 at most, and a user keeps 50 categories.
935
+ */
936
+ setMyPreferences(input: {
937
+ headers?: {
938
+ "Idempotency-Key"?: string;
939
+ };
940
+ body: Preferences; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
941
+ signal?: AbortSignal;
942
+ }): Promise<Reply<200, Preferences>>;
943
+ /**
944
+ * List the project's providers
945
+ *
946
+ * The project's own providers, by channel and failover order — never their credentials.
947
+ */
948
+ listNotifyProviders(input?: {
949
+ signal?: AbortSignal;
950
+ }): Promise<Reply<200, NotifyProviderList>>;
951
+ /**
952
+ * Bring a provider
953
+ *
954
+ * Stores the project's own provider for a channel — its credentials sealed with the project's key, checked as the sender will use them. A project with an active email provider sends its email through it instead of the platform's shared sender. Texts go through the project's own SMS providers only, and its one-time codes through them or through its own verification service (Twilio Verify).
955
+ */
956
+ putNotifyProvider(input: {
957
+ path: {
958
+ channel: "email" | "sms" | "verify" | "whatsapp" | "push"; /** The provider: for email acs, ses, sendgrid or smtp; for sms twilio, vonage or acs; for verify twilio_verify; for whatsapp meta; for push fcm, apns or expo. */
959
+ provider: "acs" | "ses" | "sendgrid" | "smtp" | "twilio" | "vonage" | "twilio_verify" | "meta" | "fcm" | "apns" | "expo";
960
+ };
961
+ headers?: {
962
+ "Idempotency-Key"?: string;
963
+ };
964
+ body: NotifyProviderWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
965
+ signal?: AbortSignal;
966
+ }): Promise<Reply<200, NotifyProvider>>;
967
+ /**
968
+ * Remove a provider
969
+ *
970
+ * Forgets the provider and its credentials.
971
+ */
972
+ deleteNotifyProvider(input: {
973
+ path: {
974
+ channel: "email" | "sms" | "verify" | "whatsapp" | "push"; /** The provider: for email acs, ses, sendgrid or smtp; for sms twilio, vonage or acs; for verify twilio_verify; for whatsapp meta; for push fcm, apns or expo. */
975
+ provider: "acs" | "ses" | "sendgrid" | "smtp" | "twilio" | "vonage" | "twilio_verify" | "meta" | "fcm" | "apns" | "expo";
976
+ };
977
+ headers?: {
978
+ "Idempotency-Key"?: string;
979
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
980
+ signal?: AbortSignal;
981
+ }): Promise<Reply<204, undefined>>;
982
+ /**
983
+ * Push to users
984
+ *
985
+ * Queues one push per user — each whose preferences take its category — delivered to each of their devices through the project's own FCM, APNs or Expo account: an Expo token through Expo, a VoIP token through APNs, an iOS token through APNs if the project has it (else FCM), Android and web through FCM. To a topic, it is one message the worker spreads to the followers. A dead token is forgotten. A quota that refuses past its limit stops pushes until the next month.
986
+ */
987
+ sendPush(input: {
988
+ headers?: {
989
+ "Idempotency-Key"?: string;
990
+ };
991
+ body: PushSend; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
992
+ signal?: AbortSignal;
993
+ }): Promise<Reply<202, ChannelQueued>>;
994
+ /**
995
+ * Read the project's message settings
996
+ *
997
+ * The locale a template falls back to, and who an email through the project's own provider is from, with their revision in the ETag header. A save sends that ETag back in If-Match.
998
+ */
999
+ getNotifySettings(input?: {
1000
+ signal?: AbortSignal;
1001
+ }): Promise<Reply<200, NotifySettings>>;
1002
+ /**
1003
+ * Write the project's message settings
1004
+ *
1005
+ * Sets the default locale, the from address and name, and the reply-to address used with the project's own provider. Requires If-Match with the ETag of the settings the change was made against: without it 428 settings_revision_required, with a revision that is no longer current 412 settings_revision_conflict (read again and review before saving). Answers the saved settings and their new ETag.
1006
+ */
1007
+ putNotifySettings(input: {
1008
+ headers: {
1009
+ "If-Match": string; /** Makes the write safe to send again (at most 255 characters). A retry with the same key and the same request gets the first answer back, marked `Idempotent-Replayed: true`, and changes nothing; the same key with a different request is refused with 422, and while the first request still runs a retry gets 409 with Retry-After. Answers are kept for 24 hours. */
1010
+ "Idempotency-Key"?: string;
1011
+ };
1012
+ body: NotifySettings; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1013
+ signal?: AbortSignal;
1014
+ }): Promise<Reply<200, NotifySettings>>;
1015
+ /**
1016
+ * Send a text
1017
+ *
1018
+ * Queues a text through the project's own SMS providers, in failover order: a template with its variables, or a body. A number gets one text a minute and ten a day; a project that texts more distinct numbers at once than its users would ask for is paused for a few minutes; a quota that refuses past its limit stops its texts until the next month.
1019
+ */
1020
+ sendSms(input: {
1021
+ headers?: {
1022
+ "Idempotency-Key"?: string;
1023
+ };
1024
+ body: SMSSend; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1025
+ signal?: AbortSignal;
1026
+ }): Promise<Reply<202, Texted>>;
1027
+ /**
1028
+ * List the email templates
1029
+ *
1030
+ * Every template the project's email renders from — the platform's defaults and the project's overrides — with the subject and variables each uses and when the project last wrote it. Never a body: read the template for that. On the platform's shared sender, auth's templates (auth.*) go out in Palbase's words; the project's edits of them are used with its own email provider.
1031
+ */
1032
+ listEmailTemplates(input?: {
1033
+ signal?: AbortSignal;
1034
+ }): Promise<Reply<200, EmailTemplateList>>;
1035
+ /**
1036
+ * Read an email template
1037
+ *
1038
+ * The template as it renders now in this locale: the project's override, or the platform's default. On the platform's shared sender, auth's templates (auth.*) go out in Palbase's words; the project's edits of them are used with its own email provider.
1039
+ */
1040
+ getEmailTemplate(input: {
1041
+ path: {
1042
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1043
+ locale: string;
1044
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1045
+ signal?: AbortSignal;
1046
+ }): Promise<Reply<200, EmailTemplate>>;
1047
+ /**
1048
+ * Override an email template
1049
+ *
1050
+ * Overrides the template in this locale. It is Handlebars ({{name}}, {{#if}} {{#unless}} {{#each}} {{#with}}, lookup, equal): {{name}} in an HTML body is escaped, {{{name}}} is not; a subject, a text body and an SMS are text; an override of a platform template uses only the variables its sender passes. On the platform's shared sender, auth's templates (auth.*) go out in Palbase's words; the project's edits of them are used with its own email provider.
1051
+ */
1052
+ putEmailTemplate(input: {
1053
+ path: {
1054
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1055
+ locale: string;
1056
+ };
1057
+ headers?: {
1058
+ "Idempotency-Key"?: string;
1059
+ };
1060
+ body: EmailTemplateWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1061
+ signal?: AbortSignal;
1062
+ }): Promise<Reply<200, EmailTemplate>>;
1063
+ /**
1064
+ * Remove an override
1065
+ *
1066
+ * Removes the project's override; the platform's default renders again.
1067
+ */
1068
+ deleteEmailTemplate(input: {
1069
+ path: {
1070
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1071
+ locale: string;
1072
+ };
1073
+ headers?: {
1074
+ "Idempotency-Key"?: string;
1075
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1076
+ signal?: AbortSignal;
1077
+ }): Promise<Reply<204, undefined>>;
1078
+ /**
1079
+ * List the SMS templates
1080
+ *
1081
+ * Every template the project's texts render from — the platform's defaults and the project's overrides — each whole (a body is 1600 bytes at most), with the variables it uses and when the project last wrote it.
1082
+ */
1083
+ listSmsTemplates(input?: {
1084
+ signal?: AbortSignal;
1085
+ }): Promise<Reply<200, SMSTemplateList>>;
1086
+ /**
1087
+ * Read an SMS template
1088
+ *
1089
+ * The template as it renders now in this locale: the project's override, or the platform's default.
1090
+ */
1091
+ getSmsTemplate(input: {
1092
+ path: {
1093
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1094
+ locale: string;
1095
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1096
+ signal?: AbortSignal;
1097
+ }): Promise<Reply<200, SMSTemplate>>;
1098
+ /**
1099
+ * Override an SMS template
1100
+ *
1101
+ * Overrides the SMS template in this locale. It is Handlebars ({{name}}, {{#if}} {{#unless}} {{#each}} {{#with}}, lookup, equal): {{name}} in an HTML body is escaped, {{{name}}} is not; a subject, a text body and an SMS are text; an override of a platform template uses only the variables its sender passes.
1102
+ */
1103
+ putSmsTemplate(input: {
1104
+ path: {
1105
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1106
+ locale: string;
1107
+ };
1108
+ headers?: {
1109
+ "Idempotency-Key"?: string;
1110
+ };
1111
+ body: SMSTemplateWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1112
+ signal?: AbortSignal;
1113
+ }): Promise<Reply<200, SMSTemplate>>;
1114
+ /**
1115
+ * Remove an SMS override
1116
+ *
1117
+ * Removes the project's override; the platform's default renders again.
1118
+ */
1119
+ deleteSmsTemplate(input: {
1120
+ path: {
1121
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1122
+ locale: string;
1123
+ };
1124
+ headers?: {
1125
+ "Idempotency-Key"?: string;
1126
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1127
+ signal?: AbortSignal;
1128
+ }): Promise<Reply<204, undefined>>;
1129
+ /**
1130
+ * List the WhatsApp template mappings
1131
+ *
1132
+ * The project's slugs mapped to templates approved on its Meta account.
1133
+ */
1134
+ listWhatsAppTemplates(input?: {
1135
+ signal?: AbortSignal;
1136
+ }): Promise<Reply<200, WhatsAppTemplateMapList>>;
1137
+ /**
1138
+ * Read a WhatsApp template mapping
1139
+ *
1140
+ * The template this slug maps to in this locale.
1141
+ */
1142
+ getWhatsAppTemplate(input: {
1143
+ path: {
1144
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1145
+ locale: string;
1146
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1147
+ signal?: AbortSignal;
1148
+ }): Promise<Reply<200, WhatsAppTemplateMap>>;
1149
+ /**
1150
+ * Map a slug to a WhatsApp template
1151
+ *
1152
+ * Maps the slug in this locale to a template approved on the project's Meta account.
1153
+ */
1154
+ putWhatsAppTemplate(input: {
1155
+ path: {
1156
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1157
+ locale: string;
1158
+ };
1159
+ headers?: {
1160
+ "Idempotency-Key"?: string;
1161
+ };
1162
+ body: WhatsAppTemplateWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1163
+ signal?: AbortSignal;
1164
+ }): Promise<Reply<200, WhatsAppTemplateMap>>;
1165
+ /**
1166
+ * Remove a WhatsApp template mapping
1167
+ *
1168
+ * Removes the mapping.
1169
+ */
1170
+ deleteWhatsAppTemplate(input: {
1171
+ path: {
1172
+ slug: string; /** A BCP 47 locale, e.g. en or tr. */
1173
+ locale: string;
1174
+ };
1175
+ headers?: {
1176
+ "Idempotency-Key"?: string;
1177
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1178
+ signal?: AbortSignal;
1179
+ }): Promise<Reply<204, undefined>>;
1180
+ /**
1181
+ * List topics
1182
+ *
1183
+ * A page of the project's topics, newest first, with how many users follow each.
1184
+ */
1185
+ listTopics(input?: {
1186
+ query?: {
1187
+ limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
1188
+ cursor?: string;
1189
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1190
+ signal?: AbortSignal;
1191
+ }): Promise<Reply<200, TopicPage>>;
1192
+ /**
1193
+ * Create a topic
1194
+ *
1195
+ * Makes a topic users can follow; a push to it reaches its followers.
1196
+ */
1197
+ createTopic(input: {
1198
+ headers?: {
1199
+ "Idempotency-Key"?: string;
1200
+ };
1201
+ body: TopicCreate; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1202
+ signal?: AbortSignal;
1203
+ }): Promise<Reply<201, Topic>>;
1204
+ /**
1205
+ * Delete a topic
1206
+ *
1207
+ * Deletes a topic and who follows it; a push to it under way reaches no one more.
1208
+ */
1209
+ deleteTopic(input: {
1210
+ path: {
1211
+ name: string;
1212
+ };
1213
+ headers?: {
1214
+ "Idempotency-Key"?: string;
1215
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1216
+ signal?: AbortSignal;
1217
+ }): Promise<Reply<204, undefined>>;
1218
+ /**
1219
+ * Open or close a topic
1220
+ *
1221
+ * Opens a topic to users following it from the app (self_subscribe), or closes it; who follows it stays.
1222
+ */
1223
+ changeTopic(input: {
1224
+ path: {
1225
+ name: string;
1226
+ };
1227
+ headers?: {
1228
+ "Idempotency-Key"?: string;
1229
+ };
1230
+ body: TopicChange; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1231
+ signal?: AbortSignal;
1232
+ }): Promise<Reply<200, Topic>>;
1233
+ /**
1234
+ * Add followers
1235
+ *
1236
+ * Adds users to a topic (a user already on it stays).
1237
+ */
1238
+ addTopicSubscribers(input: {
1239
+ path: {
1240
+ name: string;
1241
+ };
1242
+ headers?: {
1243
+ "Idempotency-Key"?: string;
1244
+ };
1245
+ body: TopicSubscribers; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1246
+ signal?: AbortSignal;
1247
+ }): Promise<Reply<204, undefined>>;
1248
+ /**
1249
+ * Remove a follower
1250
+ *
1251
+ * Takes a user off a topic.
1252
+ */
1253
+ removeTopicSubscriber(input: {
1254
+ path: {
1255
+ name: string; /** The user's id. */
1256
+ user_id: string;
1257
+ };
1258
+ headers?: {
1259
+ "Idempotency-Key"?: string;
1260
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1261
+ signal?: AbortSignal;
1262
+ }): Promise<Reply<204, undefined>>;
1263
+ /**
1264
+ * Follow a topic
1265
+ *
1266
+ * The signed-in user follows a topic. A user follows only a topic the project opened to them (self_subscribe).
1267
+ */
1268
+ followTopic(input: {
1269
+ path: {
1270
+ name: string;
1271
+ };
1272
+ headers?: {
1273
+ "Idempotency-Key"?: string;
1274
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1275
+ signal?: AbortSignal;
1276
+ }): Promise<Reply<204, undefined>>;
1277
+ /**
1278
+ * Unfollow a topic
1279
+ *
1280
+ * The signed-in user stops following a topic.
1281
+ */
1282
+ unfollowTopic(input: {
1283
+ path: {
1284
+ name: string;
1285
+ };
1286
+ headers?: {
1287
+ "Idempotency-Key"?: string;
1288
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1289
+ signal?: AbortSignal;
1290
+ }): Promise<Reply<204, undefined>>;
1291
+ /**
1292
+ * List a user's devices
1293
+ *
1294
+ * A user's devices, for the project's backend.
1295
+ */
1296
+ listUserDevices(input: {
1297
+ path: {
1298
+ user_id: string;
1299
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1300
+ signal?: AbortSignal;
1301
+ }): Promise<Reply<200, DeviceList>>;
1302
+ /**
1303
+ * Get a user's preferences
1304
+ *
1305
+ * A user's preferences, for the project's backend or support desk.
1306
+ */
1307
+ getUserPreferences(input: {
1308
+ path: {
1309
+ user_id: string;
1310
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1311
+ signal?: AbortSignal;
1312
+ }): Promise<Reply<200, Preferences>>;
1313
+ /**
1314
+ * Set a user's preferences
1315
+ *
1316
+ * Sets some of a user's preferences for them, and answers all of them.
1317
+ */
1318
+ setUserPreferences(input: {
1319
+ path: {
1320
+ user_id: string;
1321
+ };
1322
+ headers?: {
1323
+ "Idempotency-Key"?: string;
1324
+ };
1325
+ body: Preferences; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1326
+ signal?: AbortSignal;
1327
+ }): Promise<Reply<200, Preferences>>;
1328
+ /**
1329
+ * Text a one-time code
1330
+ *
1331
+ * Has the project's own verification service (Twilio Verify) generate a one-time code and text it, from senders it has approved in each country. It is a text like any other: the number guard, the project's countries and its quota apply, and it is reported. 502 when the service fails.
1332
+ */
1333
+ startVerification(input: {
1334
+ headers?: {
1335
+ "Idempotency-Key"?: string;
1336
+ };
1337
+ body: VerificationStart; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1338
+ signal?: AbortSignal;
1339
+ }): Promise<Reply<202, VerificationStarted>>;
1340
+ /**
1341
+ * Check a one-time code
1342
+ *
1343
+ * Asks the project's verification service whether the code is the one it texted to the number.
1344
+ */
1345
+ checkVerification(input: {
1346
+ headers?: {
1347
+ "Idempotency-Key"?: string;
1348
+ };
1349
+ body: VerificationCheck; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1350
+ signal?: AbortSignal;
1351
+ }): Promise<Reply<200, Verdict>>;
1352
+ /**
1353
+ * SendGrid events
1354
+ *
1355
+ * Where the project's SendGrid account reports what became of its emails (Event Webhook, signed): delivered, bounced, dropped, spam report, open, click. Verified with the project's own SendGrid credential's webhook_public_key; a call it did not sign is refused (401). A call sent again is kept once, and a message only moves forward.
1356
+ */
1357
+ receiveSendGridEvents(input: {
1358
+ body: SendGridEvents; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1359
+ signal?: AbortSignal;
1360
+ }): Promise<Reply<204, undefined>>;
1361
+ /**
1362
+ * Twilio status callback
1363
+ *
1364
+ * Where the project's Twilio account reports what became of a text: the address notify gives with each text when the credential holds the auth token. Verified with the project's own auth token (X-Twilio-Signature); a call it did not sign is refused (401). A call sent again is kept once, and a message only moves forward.
1365
+ */
1366
+ receiveTwilioStatus(input: {
1367
+ body: TwilioStatusCallback; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1368
+ signal?: AbortSignal;
1369
+ }): Promise<Reply<204, undefined>>;
1370
+ /**
1371
+ * Vonage receipt (query)
1372
+ *
1373
+ * Vonage's delivery receipt as a query. Verified with the project's own signature secret (sig); a call it did not sign is refused (401). A call sent again is kept once, and a message only moves forward.
1374
+ */
1375
+ receiveVonageReceiptQuery(input?: {
1376
+ query?: {
1377
+ messageId?: string; /** delivered, expired, failed, rejected, accepted, buffered or unknown. */
1378
+ status?: string; /** Vonage's error code. */
1379
+ "err-code"?: string; /** The recipient's number. */
1380
+ msisdn?: string; /** The sender. */
1381
+ to?: string; /** The recipient's network. */
1382
+ "network-code"?: string; /** What the text cost. */
1383
+ price?: string; /** When the network reported it. */
1384
+ scts?: string; /** When Vonage received the report. */
1385
+ "message-timestamp"?: string; /** The send's reference. */
1386
+ "client-ref"?: string; /** The account's key. */
1387
+ "api-key"?: string; /** When Vonage signed the receipt (Unix seconds); a receipt older than 5 minutes is refused. */
1388
+ timestamp?: string; /** Vonage's nonce. */
1389
+ nonce?: string; /** The receipt's signature, with the project's signature secret. */
1390
+ sig?: string;
1391
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1392
+ signal?: AbortSignal;
1393
+ }): Promise<Reply<204, undefined>>;
1394
+ /**
1395
+ * Vonage receipt
1396
+ *
1397
+ * Where the project's Vonage account reports what became of a text: the address notify gives with each text when the credential holds the signature secret. Verified with the project's own signature secret (sig); a call it did not sign is refused (401). A call sent again is kept once, and a message only moves forward.
1398
+ */
1399
+ receiveVonageReceipt(input: {
1400
+ body: VonageReceipt; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1401
+ signal?: AbortSignal;
1402
+ }): Promise<Reply<204, undefined>>;
1403
+ /**
1404
+ * Meta subscription check
1405
+ *
1406
+ * Meta's check when the project subscribes its app's webhook to this address: hub.mode=subscribe and the verify_token the project's Meta credential names; the hub.challenge is echoed.
1407
+ */
1408
+ subscribeMetaWebhook(input: {
1409
+ query: {
1410
+ "hub.mode": "subscribe"; /** The verify token the project set on its Meta credential (verify_token). */
1411
+ "hub.verify_token": string; /** Echoed back when the token is the project's. */
1412
+ "hub.challenge": string;
1413
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1414
+ signal?: AbortSignal;
1415
+ }): Promise<Reply<200, Response>>;
1416
+ /**
1417
+ * Meta notification
1418
+ *
1419
+ * Where the project's Meta app reports the statuses of its WhatsApp messages (sent, delivered, read, failed) and the messages users send its number, which are kept sealed and announced (notification.received). Verified with the project's own app_secret (X-Hub-Signature-256); a call it did not sign is refused (401). A call sent again is kept once, and a message only moves forward.
1420
+ */
1421
+ receiveMetaNotification(input: {
1422
+ body: MetaNotification; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1423
+ signal?: AbortSignal;
1424
+ }): Promise<Reply<204, undefined>>;
1425
+ /**
1426
+ * Send a WhatsApp message
1427
+ *
1428
+ * Queues a WhatsApp message through the project's own WhatsApp Business account (Meta). A quota that refuses past its limit stops them until the next month.
1429
+ */
1430
+ sendWhatsApp(input: {
1431
+ headers?: {
1432
+ "Idempotency-Key"?: string;
1433
+ };
1434
+ body: WhatsAppSend; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1435
+ signal?: AbortSignal;
1436
+ }): Promise<Reply<202, Queued>>;
1437
+ /**
1438
+ * List inbound WhatsApp messages
1439
+ *
1440
+ * A page of the WhatsApp messages users sent the project's number, newest first, each Meta's message whole. Kept 30 days.
1441
+ */
1442
+ listWhatsAppInbound(input?: {
1443
+ query?: {
1444
+ limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
1445
+ cursor?: string;
1446
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1447
+ signal?: AbortSignal;
1448
+ }): Promise<Reply<200, InboundPage>>;
1449
+ };
1450
+ export type Client = ReturnType<typeof client>;