totalum-sdk 1.11.0 → 1.11.1

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 (51) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/_types/{coerce.d-BKhuaDya.d.ts → coerce.d-D_rylvPs.d.ts} +1 -1
  3. package/dist/_types/{errors.d-RTRkidv5.d.ts → errors.d-BPpY5QKu.d.ts} +20 -2
  4. package/dist/_types/{integrations.d-CzTa9T-L.d.ts → integrations.d-BTZHy48D.d.ts} +2 -2
  5. package/dist/_types/{ops.d-CNsrT4Ma.d.ts → ops.d-Ce5zJyX0.d.ts} +2 -2
  6. package/dist/ai/index.d.ts +275 -23
  7. package/dist/ai/index.js +305 -24
  8. package/dist/analytics/index.d.ts +58 -12
  9. package/dist/analytics/index.js +46 -3
  10. package/dist/browser/index.d.ts +208 -18
  11. package/dist/browser/index.js +122 -13
  12. package/dist/connections/index.d.ts +305 -23
  13. package/dist/connections/index.js +302 -21
  14. package/dist/cron/index.d.ts +147 -20
  15. package/dist/cron/index.js +157 -15
  16. package/dist/d1/errors.js +15 -0
  17. package/dist/d1/index.d.ts +254 -10
  18. package/dist/d1/index.js +24 -4
  19. package/dist/d1/session.js +26 -2
  20. package/dist/email/index.d.ts +65 -10
  21. package/dist/email/index.js +60 -5
  22. package/dist/errors.js +17 -0
  23. package/dist/files/index.d.ts +243 -20
  24. package/dist/files/index.js +247 -14
  25. package/dist/index.d.ts +24 -9
  26. package/dist/index.js +19 -5
  27. package/dist/logs/index.d.ts +48 -10
  28. package/dist/logs/index.js +39 -4
  29. package/dist/payments/index.d.ts +221 -23
  30. package/dist/payments/index.js +216 -18
  31. package/dist/pdf/index.d.ts +59 -9
  32. package/dist/pdf/index.js +54 -4
  33. package/dist/react/index.d.ts +78 -6
  34. package/dist/react/index.js +51 -5
  35. package/dist/realtime/index.d.ts +55 -8
  36. package/dist/realtime/index.js +53 -6
  37. package/dist/scan/index.d.ts +78 -10
  38. package/dist/scan/index.js +63 -3
  39. package/dist/seo/index.d.ts +43 -7
  40. package/dist/seo/index.js +39 -3
  41. package/dist/speech/index.d.ts +34 -10
  42. package/dist/speech/index.js +25 -5
  43. package/dist/vectors/index.d.ts +96 -9
  44. package/dist/vectors/index.js +93 -7
  45. package/dist/web/index.d.ts +168 -15
  46. package/dist/web/index.js +163 -10
  47. package/dist/webhooks/index.d.ts +122 -15
  48. package/dist/webhooks/index.js +119 -13
  49. package/package.json +2 -1
  50. package/totalum-sdk.md +8841 -754
  51. package/totalum-sdk.signatures.json +1 -1
@@ -1,5 +1,5 @@
1
- import { Z as ZodObject, d as ZodString, f as ZodEnum, u as ZodISODateTime, m as $strip, o as output, c as ZodOptional, h as ZodRecord, g as ZodUnknown, j as ZodBoolean, r as ZodLiteral, e as ZodArray, k as ZodNumber, p as ZodURL, T as TotalumClientOptions, U as Usage } from '../_types/errors.d-RTRkidv5.js';
2
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-RTRkidv5.js';
1
+ import { Z as ZodObject, d as ZodString, f as ZodEnum, u as ZodISODateTime, m as $strip, o as output, c as ZodOptional, h as ZodRecord, g as ZodUnknown, j as ZodBoolean, r as ZodLiteral, e as ZodArray, k as ZodNumber, p as ZodURL, T as TotalumClientOptions, U as Usage } from '../_types/errors.d-BPpY5QKu.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BPpY5QKu.js';
3
3
 
4
4
  /** `POST /v1/connections/link`: the URL the user is sent to; it comes back to `returnUrl?connection=success|failed&toolkit=…`. */
5
5
  declare const ConnectionLinkInput: ZodObject<{
@@ -144,23 +144,67 @@ declare const ConnectionEvent: ZodObject<{
144
144
  type ConnectionEvent = output<typeof ConnectionEvent>;
145
145
 
146
146
  /**
147
- * `totalum.connections` over `/v1/connections/*` (scope `connections`; server-side code only: it needs the project
148
- * key). Your app's users connect their own accounts of ~1,500 apps — Google Calendar, Gmail, Google Drive, Outlook,
147
+ * Creates the `connections` namespace (the same object as `totalum.connections`; scope `connections`; server-side code
148
+ * only: it needs the project key). Your app's users connect their own accounts of ~1,500 apps — Google Calendar, Gmail, Google Drive, Outlook,
149
149
  * OneDrive, Slack, Dropbox, Notion, HubSpot, GitHub, Stripe, Airtable, … — on a hosted page (they sign in at the
150
150
  * provider, or type their own API key there), with no OAuth app of yours; then your server runs actions on them
151
151
  * (`GOOGLECALENDAR_CREATE_EVENT`, `GMAIL_SEND_EMAIL`, …) and receives their events (`subscribe`). The tokens never
152
152
  * reach your app. `userId` is always **your signed-in user's id** (the one in your database), taken from the session
153
153
  * on the server — never from the request: each user, project and environment (dev/live) only ever sees its own
154
154
  * connections.
155
+ *
156
+ * @param options - The project key, API URL and environment; each falls back to its environment variable.
157
+ * @returns The `connections` namespace: the methods below.
158
+ * @example
159
+ * import { totalumConnections } from 'totalum-sdk/connections';
160
+ *
161
+ * const connections = totalumConnections();
162
+ * const list = await connections.list({ userId: user.id });
155
163
  */
156
164
  declare function totalumConnections(options?: TotalumClientOptions): {
157
165
  /**
158
166
  * The URL to send the user to so they connect `toolkit` (e.g. `'googlecalendar'`); valid about 10 minutes, so
159
- * make it when the user clicks "Connect" and redirect at once. They come back to `returnUrl` with
160
- * `?connection=success|failed&toolkit=<toolkit>` added.
167
+ * make it when the user clicks "Connect" and redirect at once. They sign in at the provider (or type their own key
168
+ * on the hosted page) and come back to `returnUrl` with `?connection=success|failed&toolkit=<toolkit>` added. A new
169
+ * connection through Totalum's sign-in is billed once in credits when it becomes active.
170
+ *
171
+ * @param input - Your user, the app to connect and where to come back.
172
+ * @returns The hosted sign-in URL to redirect the user to.
173
+ * @throws VALIDATION_ERROR (400) `returnUrl` is not `https://` (only `localhost` may be `http`).
174
+ * @throws RECORD_NOT_FOUND (404) No app with this slug: look it up with `toolkits({ search })`.
175
+ * @throws TOOLKIT_NOT_AVAILABLE (400) This app cannot be connected.
176
+ * @throws TOOLKIT_NEEDS_OWN_APP (400) This app only signs in through an OAuth app registered by the developer, which is
177
+ * not available.
178
+ * @example
179
+ * // src/app/api/connect/google-calendar/route.ts
180
+ * const user = await requireUser(); // your own session
181
+ * const url = await totalum.connections.connectUrl({
182
+ * userId: user.id,
183
+ * toolkit: 'googlecalendar',
184
+ * returnUrl: 'https://acme.totalum.app/settings/integrations',
185
+ * });
186
+ * return Response.redirect(url, 302);
187
+ * //=>
188
+ * "https://connect.<sign-in host>/link/lk_Iem_dXdIv3-i"
161
189
  */
162
190
  connectUrl: (input: ConnectionLinkInput) => Promise<string>;
163
- /** The user's connections (newest first), optionally of one toolkit; `status` is `active` when usable. */
191
+ /**
192
+ * The user's connected accounts (newest first), optionally of one app: show them on a settings page with a
193
+ * "Disconnect" button. `status` is `active` when usable. Free.
194
+ *
195
+ * @param input - Your user, and optionally one app.
196
+ * @param input.userId - Your signed-in user's id, from the session.
197
+ * @param input.toolkit - Only connections of this app (`googlecalendar`).
198
+ * @returns The connections.
199
+ * @throws VALIDATION_ERROR (400) `userId` is empty or over 200 characters.
200
+ * @example
201
+ * const list = await totalum.connections.list({ userId: 'user_42' });
202
+ * //=>
203
+ * [
204
+ * { "id": "ca_8Qw2nZ4kLp", "toolkit": "googlecalendar", "status": "active", "createdAt": "2026-10-02T09:14:00.000Z" },
205
+ * { "id": "ca_3Hy7tR1mXc", "toolkit": "gmail", "status": "expired", "createdAt": "2026-08-21T16:40:00.000Z" }
206
+ * ]
207
+ */
164
208
  list: (input: {
165
209
  userId: string;
166
210
  toolkit?: string;
@@ -170,12 +214,36 @@ declare function totalumConnections(options?: TotalumClientOptions): {
170
214
  status: "failed" | "expired" | "pending" | "active" | "disabled";
171
215
  createdAt: string;
172
216
  }[]>;
173
- /** Whether the user has an active connection of `toolkit`. */
217
+ /**
218
+ * Whether the user has an active connection of an app: show "Connect" or the feature that needs it. Free.
219
+ *
220
+ * @param input - Your user and the app.
221
+ * @param input.userId - Your signed-in user's id, from the session.
222
+ * @param input.toolkit - The app's slug (`googlecalendar`).
223
+ * @returns `true` when the user has an active connection of `toolkit`.
224
+ * @throws VALIDATION_ERROR (400) `userId` is empty or over 200 characters.
225
+ * @example
226
+ * const connected = await totalum.connections.isConnected({ userId: 'user_42', toolkit: 'googlecalendar' });
227
+ * //=>
228
+ * false
229
+ */
174
230
  isConnected: (input: {
175
231
  userId: string;
176
232
  toolkit: string;
177
233
  }) => Promise<boolean>;
178
- /** Disconnects one of the user's connections (`id` from `list`). */
234
+ /**
235
+ * Disconnects one of the user's connected accounts (the provider's access is revoked). Free.
236
+ *
237
+ * @param input - Your user and the connection.
238
+ * @param input.userId - Your signed-in user's id, from the session.
239
+ * @param input.id - The connection's `id`, from `list()`.
240
+ * @returns `{ deleted: true }`.
241
+ * @throws RECORD_NOT_FOUND (404) The user has no connection with this id.
242
+ * @example
243
+ * await totalum.connections.disconnect({ userId: 'user_42', id: 'ca_8Qw2nZ4kLp' });
244
+ * //=>
245
+ * { "deleted": true }
246
+ */
179
247
  disconnect: (input: {
180
248
  userId: string;
181
249
  id: string;
@@ -184,15 +252,58 @@ declare function totalumConnections(options?: TotalumClientOptions): {
184
252
  }>;
185
253
  /**
186
254
  * Runs `action` (e.g. `GOOGLECALENDAR_CREATE_EVENT`) with the user's active connection of its toolkit and
187
- * returns the provider's answer in `data`. Throws `CONNECTION_REQUIRED` (409) when the user has not connected
188
- * it yet — send them to `connectUrl()` — and `CONNECTION_ACTION_FAILED` (422) when the provider refuses.
255
+ * returns the provider's answer in `data`. Read the action's `inputSchema` with `action(slug)` to build `input`.
256
+ * Billed in credits per action.
257
+ *
258
+ * @param input - Your user, the action and its input.
259
+ * @returns The provider's answer and what the action cost.
260
+ * @throws CONNECTION_REQUIRED (409) The user has not connected this app yet: send them to `connectUrl()`;
261
+ * `details.action` names the action.
262
+ * @throws CONNECTION_ACTION_FAILED (422) The provider refused the action (a bad input, a missing permission); the
263
+ * message says why.
264
+ * @throws RECORD_NOT_FOUND (404) No action with this slug.
265
+ * @throws PROVIDER_TIMEOUT (504) The provider did not answer in time.
266
+ * @example
267
+ * const { data } = await totalum.connections.execute({
268
+ * userId: 'user_42',
269
+ * action: 'GOOGLECALENDAR_CREATE_EVENT',
270
+ * input: {
271
+ * summary: 'Demo with Acme',
272
+ * start_datetime: '2026-10-14T10:00:00',
273
+ * timezone: 'Europe/Madrid',
274
+ * event_duration_minutes: 30,
275
+ * attendees: ['ana@example.com'],
276
+ * },
277
+ * });
278
+ * //=>
279
+ * {
280
+ * "data": { "id": "5r1q8m2v6k0c4n9b", "status": "confirmed", "htmlLink": "https://www.google.com/calendar/event?eid=NXIxcThtMnY2azBj…", … },
281
+ * "usage": { "credits": 0.0028 }
282
+ * }
189
283
  */
190
284
  execute: (input: ConnectionExecuteInput) => Promise<Omit<{
285
+ /** The provider's answer, as the action's documentation describes (the created event, the sent message, …). */
191
286
  data: unknown;
192
287
  }, "usage"> & {
193
288
  usage: Usage;
194
289
  }>;
195
- /** The actions of a toolkit (slug, name, description), optionally filtered by `search`. */
290
+ /**
291
+ * The actions an app offers (slug, name, description), optionally filtered by words — to find the slug to pass to
292
+ * `execute()`. Free.
293
+ *
294
+ * @param input - The app and an optional search.
295
+ * @param input.toolkit - The app's slug (`googlecalendar`).
296
+ * @param input.search - Only actions matching these words (`create event`).
297
+ * @returns The matching actions, without their input schemas (read one with `action(slug)`).
298
+ * @throws RECORD_NOT_FOUND (404) No app with this slug.
299
+ * @example
300
+ * const actions = await totalum.connections.actions({ toolkit: 'googlecalendar', search: 'create event' });
301
+ * //=>
302
+ * [
303
+ * { "slug": "GOOGLECALENDAR_CREATE_EVENT", "toolkit": "googlecalendar", "name": "Create Event", "description": "Creates a timed event using start_datetime and either end_datetime or duration fields, or an all-day event…" },
304
+ * { "slug": "GOOGLECALENDAR_QUICK_ADD", "toolkit": "googlecalendar", "name": "Quick Add Event", "description": "Creates an event from a text string such as 'Lunch with Ana tomorrow at 1pm'…" }
305
+ * ]
306
+ */
196
307
  actions: (input: {
197
308
  toolkit: string;
198
309
  search?: string;
@@ -203,7 +314,30 @@ declare function totalumConnections(options?: TotalumClientOptions): {
203
314
  description: string;
204
315
  inputSchema?: Record<string, unknown> | undefined;
205
316
  }[]>;
206
- /** One action with its `inputSchema` (JSON Schema of `execute`'s `input`). */
317
+ /**
318
+ * One action with its `inputSchema`: the JSON Schema of what `execute()` takes as `input`. Free.
319
+ *
320
+ * @param slug - The action's slug (`GOOGLECALENDAR_CREATE_EVENT`).
321
+ * @returns The action and its input schema.
322
+ * @throws RECORD_NOT_FOUND (404) No action with this slug.
323
+ * @example
324
+ * const action = await totalum.connections.action('GOOGLECALENDAR_CREATE_EVENT');
325
+ * //=>
326
+ * {
327
+ * "slug": "GOOGLECALENDAR_CREATE_EVENT",
328
+ * "toolkit": "googlecalendar",
329
+ * "name": "Create Event",
330
+ * "description": "Creates a timed event using start_datetime and either end_datetime or duration fields…",
331
+ * "inputSchema": {
332
+ * "type": "object",
333
+ * "properties": {
334
+ * "summary": { "type": "string", "description": "Summary (title) of the event." },
335
+ * "start_datetime": { "type": "string", "description": "Event start time…" },
336
+ * …
337
+ * }
338
+ * }
339
+ * }
340
+ */
207
341
  action: (slug: string) => Promise<{
208
342
  slug: string;
209
343
  toolkit: string;
@@ -215,7 +349,26 @@ declare function totalumConnections(options?: TotalumClientOptions): {
215
349
  * Searches the catalogue of apps (`search` matches names and descriptions, `category` e.g. `crm`); `connect`
216
350
  * says how a user connects it: `oauth` (signs in at the provider), `credentials` (types their own key on the
217
351
  * hosted page), `none` (no connection: run its actions directly), `unavailable` (cannot be connected). Pages
218
- * with `cursor` = the previous `nextCursor`.
352
+ * with `cursor` = the previous `nextCursor`. Free.
353
+ *
354
+ * @param input - The search, category and paging; all optional.
355
+ * @param input.search - Words to match in app names and descriptions (`calendar`).
356
+ * @param input.category - Only apps of this category (`crm`, `email`, `calendar`).
357
+ * @param input.cursor - The previous page's `nextCursor`.
358
+ * @param input.limit - Apps per page.
359
+ * @returns One page of apps, the cursor of the next and the total.
360
+ * @throws PROVIDER_UNAVAILABLE (503) The catalogue is not available right now; retry later.
361
+ * @example
362
+ * const page = await totalum.connections.toolkits({ search: 'calendar', limit: 2 });
363
+ * //=>
364
+ * {
365
+ * "toolkits": [
366
+ * { "slug": "googlecalendar", "name": "Google Calendar", "description": "Google Calendar is a time management tool…", "categories": ["scheduling-&-booking"], "authSchemes": ["OAUTH2"], "connect": "oauth", "actionsCount": 47, "triggersCount": 7 },
367
+ * { "slug": "outlook", "name": "Outlook", "description": "Outlook is Microsoft's email and calendaring platform…", "categories": ["email", "calendar"], "authSchemes": ["OAUTH2", "S2S_OAUTH2"], "connect": "oauth", "actionsCount": 297, "triggersCount": 5 }
368
+ * ],
369
+ * "nextCursor": "Mi0y",
370
+ * "total": 18
371
+ * }
219
372
  */
220
373
  toolkits: (input?: {
221
374
  search?: string;
@@ -236,7 +389,27 @@ declare function totalumConnections(options?: TotalumClientOptions): {
236
389
  nextCursor: string | null;
237
390
  total: number;
238
391
  }>;
239
- /** One app, exactly: how it connects and, for `credentials`, the fields the user types on the hosted page. */
392
+ /**
393
+ * One app, exactly: how it connects and, for `credentials`, the fields the user types on the hosted page. Free.
394
+ *
395
+ * @param slug - The app's slug (`googlecalendar`).
396
+ * @returns The app's details.
397
+ * @throws RECORD_NOT_FOUND (404) No app with this slug.
398
+ * @example
399
+ * const app = await totalum.connections.toolkit('googlecalendar');
400
+ * //=>
401
+ * {
402
+ * "slug": "googlecalendar",
403
+ * "name": "Google Calendar",
404
+ * "description": "Google Calendar is a time management tool providing scheduling features…",
405
+ * "categories": ["scheduling-&-booking"],
406
+ * "authSchemes": ["OAUTH2"],
407
+ * "connect": "oauth",
408
+ * "actionsCount": 47,
409
+ * "triggersCount": 7,
410
+ * "credentialFields": []
411
+ * }
412
+ */
240
413
  toolkit: (slug: string) => Promise<{
241
414
  slug: string;
242
415
  name: string;
@@ -252,7 +425,22 @@ declare function totalumConnections(options?: TotalumClientOptions): {
252
425
  description: string;
253
426
  }[];
254
427
  }>;
255
- /** The events (triggers) a toolkit can send, e.g. `GMAIL_NEW_GMAIL_MESSAGE`. */
428
+ /**
429
+ * The events (triggers) an app can send, such as `GMAIL_NEW_GMAIL_MESSAGE` — to find the slug to pass to
430
+ * `subscribe()`. Free.
431
+ *
432
+ * @param input - The app.
433
+ * @param input.toolkit - The app's slug (`gmail`).
434
+ * @returns The app's triggers, without their schemas (read one with `trigger(slug)`).
435
+ * @throws RECORD_NOT_FOUND (404) No app with this slug.
436
+ * @example
437
+ * const triggers = await totalum.connections.triggers({ toolkit: 'gmail' });
438
+ * //=>
439
+ * [
440
+ * { "slug": "GMAIL_EMAIL_SENT_TRIGGER", "toolkit": "gmail", "name": "Email Sent", "description": "Triggers when a Gmail message is sent by the authenticated user…", "type": "poll" },
441
+ * { "slug": "GMAIL_NEW_GMAIL_MESSAGE", "toolkit": "gmail", "name": "New Gmail Message Received Trigger", "description": "Triggers when a new message is received in Gmail.", "type": "poll" }
442
+ * ]
443
+ */
256
444
  triggers: (input: {
257
445
  toolkit: string;
258
446
  }) => Promise<{
@@ -265,7 +453,32 @@ declare function totalumConnections(options?: TotalumClientOptions): {
265
453
  configSchema?: Record<string, unknown> | undefined;
266
454
  payloadSchema?: Record<string, unknown> | undefined;
267
455
  }[]>;
268
- /** One trigger with `configSchema` (what `subscribe`'s `config` takes) and `payloadSchema` (the event's shape). */
456
+ /**
457
+ * One trigger with `configSchema` (what `subscribe`'s `config` takes) and `payloadSchema` (the event's shape).
458
+ * Free.
459
+ *
460
+ * @param slug - The trigger's slug (`GMAIL_NEW_GMAIL_MESSAGE`).
461
+ * @returns The trigger and its schemas.
462
+ * @throws RECORD_NOT_FOUND (404) No trigger with this slug.
463
+ * @example
464
+ * const trigger = await totalum.connections.trigger('GMAIL_NEW_GMAIL_MESSAGE');
465
+ * //=>
466
+ * {
467
+ * "slug": "GMAIL_NEW_GMAIL_MESSAGE",
468
+ * "toolkit": "gmail",
469
+ * "name": "New Gmail Message Received Trigger",
470
+ * "description": "Triggers when a new message is received in Gmail.",
471
+ * "type": "poll",
472
+ * "instructions": "Provide the user ID (usually 'me')…",
473
+ * "configSchema": {
474
+ * "properties": {
475
+ * "interval": { "type": "number", "default": 2, "description": "Periodic Interval to Check for Updates & Send a Trigger in Minutes" },
476
+ * "labelIds": { "type": "string", "default": "INBOX", "description": "Filter messages by a single label ID…" }
477
+ * }
478
+ * },
479
+ * "payloadSchema": { "properties": { "message_id": { "type": "string" }, "sender": { "type": "string" }, "subject": { "type": "string" }, … } }
480
+ * }
481
+ */
269
482
  trigger: (slug: string) => Promise<{
270
483
  slug: string;
271
484
  toolkit: string;
@@ -279,8 +492,22 @@ declare function totalumConnections(options?: TotalumClientOptions): {
279
492
  /**
280
493
  * Watches `trigger` on the user's active connection of its toolkit: each event is POSTed to `deliverTo` (a path
281
494
  * of your own app, default `/api/webhooks/connections`) on the preview (dev users) or the published site (live
282
- * users), signed with your project's webhook secret — read it with `verifyEvent`. Throws `CONNECTION_REQUIRED`
283
- * (409) when the user has not connected that toolkit.
495
+ * users), signed with your project's webhook secret — read it with `verifyEvent`. Each delivered event is billed in
496
+ * credits.
497
+ *
498
+ * @param input - Your user, the trigger, its configuration and where to deliver.
499
+ * @returns The subscription; keep its `id` to `unsubscribe()` later.
500
+ * @throws CONNECTION_REQUIRED (409) The user has not connected this app yet: send them to `connectUrl()`.
501
+ * @throws RECORD_NOT_FOUND (404) No trigger with this slug.
502
+ * @throws VALIDATION_ERROR (400) `config` does not match the trigger's `configSchema`, or `deliverTo` is not a path.
503
+ * @example
504
+ * const sub = await totalum.connections.subscribe({
505
+ * userId: 'user_42',
506
+ * trigger: 'GMAIL_NEW_GMAIL_MESSAGE',
507
+ * config: { labelIds: 'INBOX', interval: 1 },
508
+ * });
509
+ * //=>
510
+ * { "id": "ti_Zp4Lm8Qw2nXc", "trigger": "GMAIL_NEW_GMAIL_MESSAGE", "connectionId": "ca_3Hy7tR1mXc", "config": { "labelIds": "INBOX", "interval": 1 }, "enabled": true }
284
511
  */
285
512
  subscribe: (input: ConnectionSubscribeInput) => Promise<{
286
513
  id: string;
@@ -289,7 +516,20 @@ declare function totalumConnections(options?: TotalumClientOptions): {
289
516
  config: Record<string, unknown>;
290
517
  enabled: boolean;
291
518
  }>;
292
- /** The user's subscriptions. */
519
+ /**
520
+ * The user's event subscriptions. Free.
521
+ *
522
+ * @param input - Your user.
523
+ * @param input.userId - Your signed-in user's id, from the session.
524
+ * @returns The subscriptions.
525
+ * @throws VALIDATION_ERROR (400) `userId` is empty or over 200 characters.
526
+ * @example
527
+ * const subs = await totalum.connections.subscriptions({ userId: 'user_42' });
528
+ * //=>
529
+ * [
530
+ * { "id": "ti_Zp4Lm8Qw2nXc", "trigger": "GMAIL_NEW_GMAIL_MESSAGE", "connectionId": "ca_3Hy7tR1mXc", "config": { "labelIds": "INBOX", "interval": 1 }, "enabled": true }
531
+ * ]
532
+ */
293
533
  subscriptions: (input: {
294
534
  userId: string;
295
535
  }) => Promise<{
@@ -299,7 +539,19 @@ declare function totalumConnections(options?: TotalumClientOptions): {
299
539
  config: Record<string, unknown>;
300
540
  enabled: boolean;
301
541
  }[]>;
302
- /** Stops one of the user's subscriptions (`id` from `subscribe` or `subscriptions`). */
542
+ /**
543
+ * Stops one of the user's subscriptions: no more events are delivered. Free.
544
+ *
545
+ * @param input - Your user and the subscription.
546
+ * @param input.userId - Your signed-in user's id, from the session.
547
+ * @param input.id - The subscription's `id`, from `subscribe()` or `subscriptions()`.
548
+ * @returns `{ deleted: true }`.
549
+ * @throws RECORD_NOT_FOUND (404) The user has no subscription with this id.
550
+ * @example
551
+ * await totalum.connections.unsubscribe({ userId: 'user_42', id: 'ti_Zp4Lm8Qw2nXc' });
552
+ * //=>
553
+ * { "deleted": true }
554
+ */
303
555
  unsubscribe: (input: {
304
556
  userId: string;
305
557
  id: string;
@@ -308,8 +560,38 @@ declare function totalumConnections(options?: TotalumClientOptions): {
308
560
  }>;
309
561
  /**
310
562
  * Verifies one delivered event (the raw body text and the request headers of your `deliverTo` route) with
311
- * `TOTALUM_WEBHOOK_SECRET` and returns it typed: `data.userId` is your user, `data.payload` the event. Throws
312
- * `TotalumWebhookError` on a bad signature (answer 401). Answer 2xx quickly; a failed delivery is retried.
563
+ * `TOTALUM_WEBHOOK_SECRET` and returns it typed: `data.userId` is your user, `data.payload` the event. Answer 2xx
564
+ * quickly; a failed delivery is retried.
565
+ *
566
+ * @param rawBody - The request body as text, untouched (`await request.text()`).
567
+ * @param headers - The request's headers.
568
+ * @param secret - The signing secret. Default: `TOTALUM_WEBHOOK_SECRET`.
569
+ * @returns The verified event.
570
+ * @throws WEBHOOK_SIGNATURE_INVALID (401) Not signed by Totalum (or the body was changed): answer 401.
571
+ * @throws WEBHOOK_TIMESTAMP_EXPIRED (401) A replayed delivery: answer 401.
572
+ * @throws WEBHOOK_SECRET_MISSING No secret is set or passed.
573
+ * @example
574
+ * // src/app/api/webhooks/connections/route.ts
575
+ * export async function POST(request: Request) {
576
+ * const event = await totalum.connections.verifyEvent(await request.text(), request.headers);
577
+ * if (event.data.trigger === 'GMAIL_NEW_GMAIL_MESSAGE') await saveInboxItem(event.data.userId, event.data.payload);
578
+ * return new Response('ok');
579
+ * }
580
+ * //=>
581
+ * {
582
+ * "id": "evt_01M4P2A9K3J7H5G1F8D6S4A2Q0",
583
+ * "type": "connections.event",
584
+ * "createdAt": "2026-10-11T18:20:31.000Z",
585
+ * "projectId": "acme-crm",
586
+ * "env": "live",
587
+ * "data": {
588
+ * "subscriptionId": "ti_Zp4Lm8Qw2nXc",
589
+ * "trigger": "GMAIL_NEW_GMAIL_MESSAGE",
590
+ * "userId": "user_42",
591
+ * "connectionId": "ca_3Hy7tR1mXc",
592
+ * "payload": { "message_id": "19a2c4e6f8b0d1e3", "sender": "Ana <ana@example.com>", "subject": "Quote for October", … }
593
+ * }
594
+ * }
313
595
  */
314
596
  verifyEvent: (rawBody: string, headers: Headers | Record<string, string | undefined>, secret?: string) => Promise<ConnectionEvent>;
315
597
  };