totalum-sdk 0.1.0-dev.9 → 1.1.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 (40) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/_types/{billing.d-BbSZh1wY.d.ts → billing.d-DWcflg9y.d.ts} +6 -2
  3. package/dist/_types/{coerce.d-C0KIW76L.d.ts → coerce.d-BXj_o-j6.d.ts} +1 -1
  4. package/dist/_types/{errors.d-Cu3q_E_r.d.ts → errors.d-Dtt-BIwJ.d.ts} +26 -2
  5. package/dist/_types/{integrations.d-BNGV70e3.d.ts → integrations.d-DjOeFaYn.d.ts} +2 -2
  6. package/dist/_types/{ops.d-C9375KIG.d.ts → ops.d-BKBWL6Qf.d.ts} +2 -2
  7. package/dist/ai/index.d.ts +49 -28
  8. package/dist/ai/index.js +21 -21
  9. package/dist/analytics/index.d.ts +4 -4
  10. package/dist/browser/index.d.ts +60 -5
  11. package/dist/browser/index.js +22 -5
  12. package/dist/cron/index.d.ts +5 -5
  13. package/dist/cron/index.js +2 -10
  14. package/dist/d1/index.d.ts +6 -4
  15. package/dist/d1/lazy.js +21 -3
  16. package/dist/d1/session.js +83 -15
  17. package/dist/deprecate.js +16 -0
  18. package/dist/email/index.d.ts +12 -6
  19. package/dist/email/index.js +4 -3
  20. package/dist/files/index.d.ts +11 -9
  21. package/dist/files/index.js +10 -5
  22. package/dist/index.d.ts +11 -8
  23. package/dist/index.js +3 -0
  24. package/dist/logs/index.d.ts +5 -5
  25. package/dist/payments/index.d.ts +5 -5
  26. package/dist/pdf/index.d.ts +5 -5
  27. package/dist/realtime/index.d.ts +2 -2
  28. package/dist/scan/index.d.ts +14 -6
  29. package/dist/scan/index.js +5 -1
  30. package/dist/seo/index.d.ts +4 -4
  31. package/dist/speech/index.d.ts +26 -13
  32. package/dist/speech/index.js +24 -12
  33. package/dist/vectors/index.d.ts +167 -0
  34. package/dist/vectors/index.js +28 -0
  35. package/dist/web/index.d.ts +6 -6
  36. package/dist/web/index.js +1 -1
  37. package/dist/webhooks/index.d.ts +4 -4
  38. package/package.json +13 -3
  39. package/totalum-sdk.md +122 -25
  40. package/totalum-sdk.signatures.json +313 -0
@@ -1,5 +1,5 @@
1
1
  import { isTotalumError } from '../errors.js';
2
- import { jsonClient } from '../http.js';
2
+ import { envelopeClient, jsonClient, withUsage } from '../http.js';
3
3
  export { TotalumError, isTotalumError } from '../errors.js';
4
4
  /**
5
5
  * `totalum.email` (plan 05 §6.4) over SDK-API `/v1/email/*` (scope `email`): Resend, HTML sent byte for byte, charged
@@ -7,14 +7,15 @@ export { TotalumError, isTotalumError } from '../errors.js';
7
7
  */
8
8
  export function totalumEmail(options = {}) {
9
9
  const call = jsonClient(options);
10
+ const envelope = envelopeClient(options);
10
11
  return {
11
12
  /**
12
- * Sends one e-mail (HTML byte for byte); charged per recipient.
13
+ * Sends one e-mail (HTML byte for byte); charged per recipient (`usage.credits`).
13
14
  *
14
15
  * @example
15
16
  * await email.send({ to: 'ana@example.com', subject: 'Welcome', html: '<p>Hi Ana</p>' });
16
17
  */
17
- send: (msg) => call('POST', '/v1/email/send', msg),
18
+ send: async (msg) => withUsage(await envelope('POST', '/v1/email/send', msg)),
18
19
  /** `null` when the e-mail is not this project's. */
19
20
  get: async (id) => {
20
21
  try {
@@ -1,8 +1,8 @@
1
- import { F as FileDescriptor, k as FileUploadUrlInput, m as FilesListQuery } from '../_types/integrations.d-BNGV70e3.js';
2
- export { l as FileUploadUrlOutput, n as FilesPage } from '../_types/integrations.d-BNGV70e3.js';
3
- import { TotalumClientOptions } from '../ai/index.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { F as FileDescriptor, k as FileUploadUrlInput, m as FilesListQuery } from '../_types/integrations.d-DjOeFaYn.js';
2
+ export { l as FileUploadUrlOutput, n as FilesPage } from '../_types/integrations.d-DjOeFaYn.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
7
  interface TotalumFilesOptions extends TotalumClientOptions {
8
8
  /** The public files host; default `TOTALUM_FILES_URL`, else `https://files.totalum-project.com` (A10.1). */
@@ -94,15 +94,17 @@ declare function totalumFiles(options?: TotalumFilesOptions): {
94
94
  expiresInSeconds?: number;
95
95
  download?: boolean;
96
96
  }) => Promise<string>;
97
- /** Same as `getSignedUrl`. */
97
+ /** @deprecated Since 1.0.0: use `getSignedUrl` (the same call). */
98
98
  getDownloadUrl: (key: string, opts?: {
99
99
  expiresInSeconds?: number;
100
100
  download?: boolean;
101
101
  }) => Promise<string>;
102
- /** Signed GET URLs for many keys at once (`ttl` in seconds, ≤ 7 days). */
102
+ /** Signed GET URLs for many keys at once (`expiresInSeconds` ≤ 7 days, default 15 min), keyed by file key. */
103
103
  presign(keys: string[], opts?: {
104
- ttl?: number;
104
+ expiresInSeconds?: number;
105
105
  download?: boolean;
106
+ /** @deprecated Since 1.0.0: use `expiresInSeconds`. */
107
+ ttl?: number;
106
108
  }): Promise<Record<string, string>>;
107
109
  /** Deletes one key, or up to 1000 keys at once. */
108
110
  delete(keys: string | string[]): Promise<void>;
@@ -115,5 +117,5 @@ declare function totalumFiles(options?: TotalumFilesOptions): {
115
117
  };
116
118
  type TotalumFiles = ReturnType<typeof totalumFiles>;
117
119
 
118
- export { FileDescriptor, FileUploadUrlInput, FilesListQuery, totalumFiles };
120
+ export { FileDescriptor, FileUploadUrlInput, FilesListQuery, TotalumClientOptions, totalumFiles };
119
121
  export type { TotalumFiles, TotalumFilesOptions, UploadOptions };
@@ -1,3 +1,4 @@
1
+ import { alias, deprecated } from '../deprecate.js';
1
2
  import { apiUrlOf, jsonClient, query, rawClient, readEnv } from '../http.js';
2
3
  export { TotalumError, isTotalumError } from '../errors.js';
3
4
  const DEFAULT_FILES_URL = 'https://files.totalum-project.com';
@@ -42,12 +43,16 @@ export function totalumFiles(options = {}) {
42
43
  get: (key) => call('GET', `${path(key)}/meta`),
43
44
  /** A presigned GET that R2 verifies: 15 min by default, at most 7 days — the way to hand a private file to a browser. */
44
45
  getSignedUrl,
45
- /** Same as `getSignedUrl`. */
46
- getDownloadUrl: getSignedUrl,
47
- /** Signed GET URLs for many keys at once (`ttl` in seconds, ≤ 7 days). */
46
+ /** @deprecated Since 1.0.0: use `getSignedUrl` (the same call). */
47
+ getDownloadUrl: alias(getSignedUrl, 'files.getDownloadUrl()', 'files.getSignedUrl()'),
48
+ /** Signed GET URLs for many keys at once (`expiresInSeconds` ≤ 7 days, default 15 min), keyed by file key. */
48
49
  async presign(keys, opts = {}) {
49
- return (await call('POST', '/v1/files/presign', { keys, ...opts }))
50
- .urls;
50
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- the old name still works until 2.0.0
51
+ const { expiresInSeconds, ttl, download } = opts;
52
+ if (ttl !== undefined)
53
+ deprecated('files.presign({ ttl })', 'files.presign({ expiresInSeconds })');
54
+ const body = { keys, ttl: expiresInSeconds ?? ttl, download };
55
+ return (await call('POST', '/v1/files/presign', body)).urls;
51
56
  },
52
57
  /** Deletes one key, or up to 1000 keys at once. */
53
58
  async delete(keys) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { totalumAi, TotalumAiOptions } from './ai/index.js';
2
- export { AiChatInput, AiEmbedInput, AiEmbedOutput, AiImageEditInput, AiImageInput, AiImageOutput, AiModelsOutput, AiTextOutput, AiVideoCreated, AiVideoInput, AiVideoJob, AiVisionDescribeInput, ChatResult, ChatStream, ChatUsage, TotalumAi } from './ai/index.js';
2
+ export { AiChatInput, AiEmbedInput, AiEmbedOutput, AiImageEditInput, AiImageInput, AiImageOutput, AiModelsOutput, AiPresetName, AiTextOutput, AiVideoCreated, AiVideoInput, AiVideoJob, AiVisionDescribeInput, ChatResult, ChatStream, ChatUsage, TotalumAi } from './ai/index.js';
3
3
  import { totalumAnalytics } from './analytics/index.js';
4
4
  export { SiteAnalyticsQuery, TotalumAnalytics } from './analytics/index.js';
5
5
  import { totalumBrowser } from './browser/index.js';
@@ -23,17 +23,19 @@ export { ScanDocumentResult, TotalumScan } from './scan/index.js';
23
23
  import { totalumSeo } from './seo/index.js';
24
24
  export { TotalumSeo } from './seo/index.js';
25
25
  import { totalumSpeech } from './speech/index.js';
26
- export { TotalumSpeech } from './speech/index.js';
26
+ export { SpeechAudio, TotalumSpeech } from './speech/index.js';
27
+ import { totalumVectors } from './vectors/index.js';
28
+ export { TotalumVectors, VectorFilter, VectorMatch, VectorMetadata, VectorRecord, VectorSpace, VectorUpsertItem, VectorsQueryInput } from './vectors/index.js';
27
29
  import { totalumWeb } from './web/index.js';
28
30
  export { TotalumWeb } from './web/index.js';
29
31
  import { totalumWebhooks } from './webhooks/index.js';
30
32
  export { TotalumWebhookError, TotalumWebhooks, verifyWebhook } from './webhooks/index.js';
31
33
  export { D1Database, D1DatabaseSession, D1ExecResult, D1PreparedStatement, D1Result, READ_YOUR_WRITES_COOKIE, TotalumD1ClientCode, TotalumD1Error, TotalumD1ErrorCode, TotalumD1Options, isTotalumD1Error, totalumD1, withTotalumSession } from './d1/index.js';
32
- export { T as TotalumClientOptions, a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from './_types/errors.d-Cu3q_E_r.js';
33
- export { C as CheckoutInput, a as CheckoutOutput, b as CronJob, c as CronJobInput, d as CronJobPatch, e as CronRun, f as CronRunsPage, g as CustomerPortalLinkInput, h as CustomerPortalLinkOutput, E as EmailSendInput, i as EmailSendOutput, j as EmailView, F as FileDescriptor, k as FileUploadUrlInput, l as FileUploadUrlOutput, m as FilesListQuery, n as FilesPage, J as JobCreated, O as OnboardingLinkInput, o as OnboardingLinkOutput, P as PaymentsStatus, p as PdfFromHtmlInput, q as PdfFromUrlInput, r as PdfOutput, S as ScanDocumentInput, s as ScanOcrInput, t as ScanOcrOutput, u as ScreenshotInput, v as ScreenshotOutput, w as SeoIndexNowKey, x as SeoNotifyOutput, y as SpeakInput, z as StoredMedia, T as TranscribeInput, A as TranscribeOutput, W as WebJob, B as WebScrapeOutput, D as WebSearchOutput } from './_types/integrations.d-BNGV70e3.js';
34
- export { L as LogsPage, S as SiteAnalyticsOutput, a as SiteDimension, b as SiteMetric } from './_types/ops.d-C9375KIG.js';
35
- export { W as WebhookConfig, a as WebhookEvent, b as WebhookSecretOutput } from './_types/billing.d-BbSZh1wY.js';
36
- import './_types/coerce.d-C0KIW76L.js';
34
+ export { T as TotalumClientOptions, a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from './_types/errors.d-Dtt-BIwJ.js';
35
+ export { C as CheckoutInput, a as CheckoutOutput, b as CronJob, c as CronJobInput, d as CronJobPatch, e as CronRun, f as CronRunsPage, g as CustomerPortalLinkInput, h as CustomerPortalLinkOutput, E as EmailSendInput, i as EmailSendOutput, j as EmailView, F as FileDescriptor, k as FileUploadUrlInput, l as FileUploadUrlOutput, m as FilesListQuery, n as FilesPage, J as JobCreated, O as OnboardingLinkInput, o as OnboardingLinkOutput, P as PaymentsStatus, p as PdfFromHtmlInput, q as PdfFromUrlInput, r as PdfOutput, S as ScanDocumentInput, s as ScanOcrInput, t as ScanOcrOutput, u as ScreenshotInput, v as ScreenshotOutput, w as SeoIndexNowKey, x as SeoNotifyOutput, y as SpeakInput, z as StoredMedia, T as TranscribeInput, A as TranscribeOutput, W as WebJob, B as WebScrapeOutput, D as WebSearchOutput } from './_types/integrations.d-DjOeFaYn.js';
36
+ export { L as LogsPage, S as SiteAnalyticsOutput, a as SiteDimension, b as SiteMetric } from './_types/ops.d-BKBWL6Qf.js';
37
+ export { W as WebhookConfig, a as WebhookEvent, b as WebhookSecretOutput } from './_types/billing.d-DWcflg9y.js';
38
+ import './_types/coerce.d-BXj_o-j6.js';
37
39
 
38
40
  /** The options of `createTotalum()`: every namespace's options in one object (each falls back to its env var). */
39
41
  type TotalumOptions = TotalumAiOptions & TotalumFilesOptions;
@@ -51,6 +53,7 @@ declare const namespaces: {
51
53
  scan: typeof totalumScan;
52
54
  seo: typeof totalumSeo;
53
55
  speech: typeof totalumSpeech;
56
+ vectors: typeof totalumVectors;
54
57
  web: typeof totalumWeb;
55
58
  webhooks: typeof totalumWebhooks;
56
59
  };
@@ -69,5 +72,5 @@ declare function createTotalum(options?: TotalumOptions): Totalum;
69
72
  /** The default instance, configured from the environment (`TOTALUM_PROJECT_KEY`, `TOTALUM_SDK_API_URL`, `TOTALUM_ENV`). */
70
73
  declare const totalum: Totalum;
71
74
 
72
- export { TotalumAiOptions, TotalumFilesOptions, createTotalum, totalum, totalumAi, totalumAnalytics, totalumBrowser, totalumCron, totalumEmail, totalumFiles, totalumLogs, totalumPayments, totalumPdf, totalumRealtime, totalumScan, totalumSeo, totalumSpeech, totalumWeb, totalumWebhooks };
75
+ export { TotalumAiOptions, TotalumFilesOptions, createTotalum, totalum, totalumAi, totalumAnalytics, totalumBrowser, totalumCron, totalumEmail, totalumFiles, totalumLogs, totalumPayments, totalumPdf, totalumRealtime, totalumScan, totalumSeo, totalumSpeech, totalumVectors, totalumWeb, totalumWebhooks };
73
76
  export type { Totalum, TotalumOptions };
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { totalumRealtime } from './realtime/index.js';
11
11
  import { totalumScan } from './scan/index.js';
12
12
  import { totalumSeo } from './seo/index.js';
13
13
  import { totalumSpeech } from './speech/index.js';
14
+ import { totalumVectors } from './vectors/index.js';
14
15
  import { totalumWeb } from './web/index.js';
15
16
  import { totalumWebhooks } from './webhooks/index.js';
16
17
  export * from './ai/index.js';
@@ -27,6 +28,7 @@ export * from './realtime/index.js';
27
28
  export * from './scan/index.js';
28
29
  export * from './seo/index.js';
29
30
  export * from './speech/index.js';
31
+ export * from './vectors/index.js';
30
32
  export * from './web/index.js';
31
33
  export * from './webhooks/index.js';
32
34
  const namespaces = {
@@ -43,6 +45,7 @@ const namespaces = {
43
45
  scan: totalumScan,
44
46
  seo: totalumSeo,
45
47
  speech: totalumSpeech,
48
+ vectors: totalumVectors,
46
49
  web: totalumWeb,
47
50
  webhooks: totalumWebhooks,
48
51
  };
@@ -1,8 +1,8 @@
1
- import { c as LogsQueryInput } from '../_types/ops.d-C9375KIG.js';
2
- export { L as LogsPage } from '../_types/ops.d-C9375KIG.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { c as LogsQueryInput } from '../_types/ops.d-BKBWL6Qf.js';
2
+ export { L as LogsPage } from '../_types/ops.d-BKBWL6Qf.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
7
  /** A `logs.query` filter: the window (default the last hour), level, substring, status class, path, request id, env. */
8
8
  type LogsQuery = Omit<LogsQueryInput, 'caller' | 'runId'>;
@@ -1,8 +1,8 @@
1
- import { O as OnboardingLinkInput, C as CheckoutInput, g as CustomerPortalLinkInput } from '../_types/integrations.d-BNGV70e3.js';
2
- export { a as CheckoutOutput, h as CustomerPortalLinkOutput, o as OnboardingLinkOutput, P as PaymentsStatus } from '../_types/integrations.d-BNGV70e3.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { O as OnboardingLinkInput, C as CheckoutInput, g as CustomerPortalLinkInput } from '../_types/integrations.d-DjOeFaYn.js';
2
+ export { a as CheckoutOutput, h as CustomerPortalLinkOutput, o as OnboardingLinkOutput, P as PaymentsStatus } from '../_types/integrations.d-DjOeFaYn.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
7
  /**
8
8
  * `totalum.payments` (plan 05, plan 11 §9.5) over SDK-API `/v1/payments/*` with a project key (scope `payments`): Stripe
@@ -1,8 +1,8 @@
1
- import { p as PdfFromHtmlInput, q as PdfFromUrlInput } from '../_types/integrations.d-BNGV70e3.js';
2
- export { r as PdfOutput } from '../_types/integrations.d-BNGV70e3.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { p as PdfFromHtmlInput, q as PdfFromUrlInput } from '../_types/integrations.d-DjOeFaYn.js';
2
+ export { r as PdfOutput } from '../_types/integrations.d-DjOeFaYn.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
7
  /** `totalum.pdf` (plan 04 §5.5) over `/v1/pdf/*` (scope `files:write`): a new file in the project's storage each time. */
8
8
  declare function totalumPdf(options?: TotalumClientOptions): {
@@ -1,5 +1,5 @@
1
- import { Z as ZodObject, c as ZodOptional, d as ZodString, g as ZodUnknown, m as $strip, o as output, t as ZodISODateTime, l as ZodInt, h as ZodRecord, j as ZodBoolean, T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
2
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
1
+ import { Z as ZodObject, c as ZodOptional, d as ZodString, g as ZodUnknown, m as $strip, o as output, u as ZodISODateTime, l as ZodInt, h as ZodRecord, j as ZodBoolean, T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
3
3
 
4
4
  /** `POST /v1/realtime/tickets` (scope `realtime`). `ttl` is the join window in seconds, not the session length. */
5
5
  declare const RealtimeTicketInput: ZodObject<{
@@ -1,10 +1,13 @@
1
- import { S as ScanDocumentInput, s as ScanOcrInput } from '../_types/integrations.d-BNGV70e3.js';
2
- export { t as ScanOcrOutput } from '../_types/integrations.d-BNGV70e3.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { S as ScanDocumentInput, s as ScanOcrInput } from '../_types/integrations.d-DjOeFaYn.js';
2
+ export { t as ScanOcrOutput } from '../_types/integrations.d-DjOeFaYn.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
- /** The v1 scan result: the extracted fields (one set per page with `processEveryPdfPageAsDifferentScan`) + `metadata`. */
7
+ /**
8
+ * The v1 scan result: the extracted fields (one set per page with `processEveryPdfPageAsDifferentScan`), the v1
9
+ * `metadata`, and `usage` like every other paid call.
10
+ */
8
11
  interface ScanDocumentResult {
9
12
  data: Record<string, unknown> | Record<string, unknown>[];
10
13
  metadata: {
@@ -14,6 +17,11 @@ interface ScanDocumentResult {
14
17
  provider: string;
15
18
  credits: number;
16
19
  };
20
+ usage: {
21
+ credits: number;
22
+ vendor?: string | undefined;
23
+ units?: number | undefined;
24
+ };
17
25
  }
18
26
  /** `totalum.scan` (plan 05 §6.7) over `/v1/scan/*` (scope `scan`): a vision model through Totalum's AI gateway. */
19
27
  declare function totalumScan(options?: TotalumClientOptions): {
@@ -5,7 +5,11 @@ export function totalumScan(options = {}) {
5
5
  const call = envelopeClient(options);
6
6
  return {
7
7
  /** Extracts the fields described by `properties` from a document or image (one set per page on request). */
8
- document: async (input) => (await call('POST', '/v1/scan/document', input)),
8
+ document: async (input) => {
9
+ const envelope = await call('POST', '/v1/scan/document', input);
10
+ const { usage } = withUsage({ ...envelope, data: {} });
11
+ return { data: envelope.data, metadata: envelope.metadata, usage };
12
+ },
9
13
  /** The text of a document or image, per page as Markdown. */
10
14
  ocr: async (input) => withUsage(await call('POST', '/v1/scan/ocr', input)),
11
15
  };
@@ -1,7 +1,7 @@
1
- export { w as SeoIndexNowKey, x as SeoNotifyOutput } from '../_types/integrations.d-BNGV70e3.js';
2
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
3
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
4
- import '../_types/coerce.d-C0KIW76L.js';
1
+ export { w as SeoIndexNowKey, x as SeoNotifyOutput } from '../_types/integrations.d-DjOeFaYn.js';
2
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
3
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ import '../_types/coerce.d-BXj_o-j6.js';
5
5
 
6
6
  /** `totalum.seo` (plan 05 §6.10) over SDK-API `/v1/seo/*` (scope `seo`): IndexNow for verified custom domains, free. */
7
7
  declare function totalumSeo(options?: TotalumClientOptions): {
@@ -1,12 +1,25 @@
1
- import { T as TranscribeInput, y as SpeakInput, z as StoredMedia } from '../_types/integrations.d-BNGV70e3.js';
2
- export { A as TranscribeOutput } from '../_types/integrations.d-BNGV70e3.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { T as TranscribeInput, y as SpeakInput, z as StoredMedia } from '../_types/integrations.d-DjOeFaYn.js';
2
+ export { A as TranscribeOutput } from '../_types/integrations.d-DjOeFaYn.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
+ /** The audio bytes of `synthesize` without `store`, and what the call cost (`usage.credits`, the call's hold). */
8
+ interface SpeechAudio {
9
+ audio: ArrayBuffer;
10
+ contentType: string;
11
+ usage: {
12
+ credits: number;
13
+ };
14
+ /** @deprecated Since 1.0.0: use `usage.credits` (the same number). */
15
+ readonly credits: number;
16
+ }
7
17
  /** `totalum.speech` (plan 05 §6.8) over `/v1/speech/*` (scope `speech`): OpenRouter speech through Totalum. */
8
18
  declare function totalumSpeech(options?: TotalumClientOptions): {
9
- /** Speech to text from `audioBase64` or a `url`; optional language, word timestamps and speakers. */
19
+ /**
20
+ * Speech to text from `audioBase64` (+ `filename` with its extension) or a `url` — a public one, or a file this
21
+ * project stored; optional language, word timestamps and speakers.
22
+ */
10
23
  transcribe: (input: TranscribeInput) => Promise<{
11
24
  text: string;
12
25
  durationSec: number;
@@ -28,14 +41,14 @@ declare function totalumSpeech(options?: TotalumClientOptions): {
28
41
  end: number;
29
42
  }[] | undefined;
30
43
  }>;
31
- /** The audio bytes, or with `store: true` the stored file `{key, url, usage}`; `credits` is the call's hold. */
32
- synthesize: (input: SpeakInput) => Promise<StoredMedia | {
33
- audio: ArrayBuffer;
34
- contentType: string;
35
- credits: number;
36
- }>;
44
+ synthesize: {
45
+ (input: SpeakInput & {
46
+ store: true;
47
+ }): Promise<StoredMedia>;
48
+ (input: SpeakInput): Promise<StoredMedia | SpeechAudio>;
49
+ };
37
50
  };
38
51
  type TotalumSpeech = ReturnType<typeof totalumSpeech>;
39
52
 
40
53
  export { SpeakInput, StoredMedia, TotalumClientOptions, TranscribeInput, totalumSpeech };
41
- export type { TotalumSpeech };
54
+ export type { SpeechAudio, TotalumSpeech };
@@ -1,22 +1,34 @@
1
+ import { deprecated } from '../deprecate.js';
1
2
  import { jsonClient, rawClient } from '../http.js';
2
3
  export { TotalumError, isTotalumError } from '../errors.js';
3
4
  /** `totalum.speech` (plan 05 §6.8) over `/v1/speech/*` (scope `speech`): OpenRouter speech through Totalum. */
4
5
  export function totalumSpeech(options = {}) {
5
6
  const call = jsonClient(options);
6
7
  const raw = rawClient(options);
8
+ async function synthesize(input) {
9
+ if (input.store)
10
+ return call('POST', '/v1/speech/speak', input);
11
+ const res = await raw('/v1/speech/speak', input);
12
+ const credits = Number(res.headers.get('x-totalum-credits') ?? 0);
13
+ const audio = {
14
+ audio: await res.arrayBuffer(),
15
+ contentType: res.headers.get('content-type') ?? 'audio/mpeg',
16
+ usage: { credits },
17
+ };
18
+ return Object.defineProperty(audio, 'credits', {
19
+ enumerable: true,
20
+ get() {
21
+ deprecated('speech.synthesize().credits', 'speech.synthesize().usage.credits');
22
+ return credits;
23
+ },
24
+ });
25
+ }
7
26
  return {
8
- /** Speech to text from `audioBase64` or a `url`; optional language, word timestamps and speakers. */
27
+ /**
28
+ * Speech to text from `audioBase64` (+ `filename` with its extension) or a `url` — a public one, or a file this
29
+ * project stored; optional language, word timestamps and speakers.
30
+ */
9
31
  transcribe: (input) => call('POST', '/v1/speech/transcribe', input),
10
- /** The audio bytes, or with `store: true` the stored file `{key, url, usage}`; `credits` is the call's hold. */
11
- synthesize: async (input) => {
12
- if (input.store)
13
- return call('POST', '/v1/speech/speak', input);
14
- const res = await raw('/v1/speech/speak', input);
15
- return {
16
- audio: await res.arrayBuffer(),
17
- contentType: res.headers.get('content-type') ?? 'audio/mpeg',
18
- credits: Number(res.headers.get('x-totalum-credits') ?? 0),
19
- };
20
- },
32
+ synthesize,
21
33
  };
22
34
  }
@@ -0,0 +1,167 @@
1
+ import { Z as ZodObject, d as ZodString, c as ZodOptional, e as ZodArray, k as ZodNumber, f as ZodEnum, h as ZodRecord, n as ZodUnion, j as ZodBoolean, m as $strip, o as output, l as ZodInt, q as $partial, x as $strict, T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
3
+
4
+ /** `text` = the `embed` preset's space; `image` = the `embed-image` preset's text+image space. */
5
+ declare const VectorSpace: ZodEnum<{
6
+ text: "text";
7
+ image: "image";
8
+ }>;
9
+ type VectorSpace = output<typeof VectorSpace>;
10
+ /** ≤ 9 KiB as JSON (Vectorize keeps 10 KiB); keys starting with `_` are reserved. */
11
+ declare const VectorMetadata: ZodRecord<ZodString, ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean, ZodArray<ZodString>]>>;
12
+ type VectorMetadata = output<typeof VectorMetadata>;
13
+ declare const VectorUpsertItem: ZodObject<{
14
+ id: ZodString;
15
+ values: ZodOptional<ZodArray<ZodNumber>>;
16
+ text: ZodOptional<ZodString>;
17
+ image: ZodOptional<ZodString>;
18
+ space: ZodOptional<ZodEnum<{
19
+ text: "text";
20
+ image: "image";
21
+ }>>;
22
+ metadata: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean, ZodArray<ZodString>]>>>;
23
+ }, $strip>;
24
+ type VectorUpsertItem = output<typeof VectorUpsertItem>;
25
+ /** A Vectorize metadata filter on `VECTOR_FILTER_KEYS` only. */
26
+ declare const VectorFilter: ZodRecord<ZodEnum<{
27
+ type: "type";
28
+ source: "source";
29
+ page: "page";
30
+ tag: "tag";
31
+ group: "group";
32
+ }> & $partial, ZodUnion<readonly [ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>, ZodObject<{
33
+ $eq: ZodOptional<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>;
34
+ $ne: ZodOptional<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>;
35
+ $in: ZodOptional<ZodArray<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>>;
36
+ $nin: ZodOptional<ZodArray<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>>;
37
+ $lt: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
38
+ $lte: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
39
+ $gt: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
40
+ $gte: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
41
+ }, $strict>]>>;
42
+ type VectorFilter = output<typeof VectorFilter>;
43
+ /**
44
+ * `POST /v1/vectors/query`: one of `text`, `values` or `image`. `space: 'image'` searches the images (with `text`,
45
+ * the words are embedded by `embed-image`: image search by text); an `image` query is always in the image space.
46
+ */
47
+ declare const VectorsQueryInput: ZodObject<{
48
+ text: ZodOptional<ZodString>;
49
+ values: ZodOptional<ZodArray<ZodNumber>>;
50
+ image: ZodOptional<ZodString>;
51
+ space: ZodOptional<ZodEnum<{
52
+ text: "text";
53
+ image: "image";
54
+ }>>;
55
+ topK: ZodOptional<ZodInt>;
56
+ filter: ZodOptional<ZodRecord<ZodEnum<{
57
+ type: "type";
58
+ source: "source";
59
+ page: "page";
60
+ tag: "tag";
61
+ group: "group";
62
+ }> & $partial, ZodUnion<readonly [ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>, ZodObject<{
63
+ $eq: ZodOptional<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>;
64
+ $ne: ZodOptional<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>;
65
+ $in: ZodOptional<ZodArray<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>>;
66
+ $nin: ZodOptional<ZodArray<ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean]>>>;
67
+ $lt: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
68
+ $lte: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
69
+ $gt: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
70
+ $gte: ZodOptional<ZodUnion<readonly [ZodNumber, ZodString]>>;
71
+ }, $strict>]>>>;
72
+ includeValues: ZodOptional<ZodBoolean>;
73
+ }, $strip>;
74
+ type VectorsQueryInput = output<typeof VectorsQueryInput>;
75
+ declare const VectorMatch: ZodObject<{
76
+ id: ZodString;
77
+ score: ZodNumber;
78
+ space: ZodEnum<{
79
+ text: "text";
80
+ image: "image";
81
+ }>;
82
+ metadata: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean, ZodArray<ZodString>]>>>;
83
+ values: ZodOptional<ZodArray<ZodNumber>>;
84
+ }, $strip>;
85
+ type VectorMatch = output<typeof VectorMatch>;
86
+ declare const VectorRecord: ZodObject<{
87
+ id: ZodString;
88
+ space: ZodEnum<{
89
+ text: "text";
90
+ image: "image";
91
+ }>;
92
+ values: ZodArray<ZodNumber>;
93
+ metadata: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodString, ZodNumber, ZodBoolean, ZodArray<ZodString>]>>>;
94
+ }, $strip>;
95
+ type VectorRecord = output<typeof VectorRecord>;
96
+
97
+ /**
98
+ * `totalum.vectors` over `/v1/vectors/*` (scope `vectors`; server-side code only: it needs the project key). Every
99
+ * project environment has its own private vector store: ids, namespaces and indexes are Totalum's, never yours to
100
+ * name, and `x-totalum-env` (the `env` option) keeps dev and live apart. Vectors are 1,024 numbers; `text` is
101
+ * embedded with the `embed` model and `image` (a project file key, a files URL, an https URL or a data URL) with the
102
+ * `embed-image` model, whose space also embeds text: search images by words with `space: 'image'`. Filter on the
103
+ * metadata keys `source`, `type`, `tag`, `group` (strings) and `page` (number).
104
+ */
105
+ declare function totalumVectors(options?: TotalumClientOptions): {
106
+ /** Inserts or replaces up to 100 vectors (≤ 8 images) from `values`, `text` or `image`, with optional metadata. */
107
+ upsert: (vectors: VectorUpsertItem[]) => Promise<Omit<{
108
+ upserted: number;
109
+ count: number;
110
+ usage: {
111
+ credits: number;
112
+ vendor?: string | undefined;
113
+ units?: number | undefined;
114
+ vendorCostUsd?: number | undefined;
115
+ };
116
+ }, "usage"> & {
117
+ usage: {
118
+ vendor?: string | undefined;
119
+ units?: number | undefined;
120
+ credits: number;
121
+ };
122
+ }>;
123
+ /** The `topK` (≤ 50, default 5) closest vectors to `text`, `values` or `image`, with their metadata. */
124
+ query: (input: VectorsQueryInput) => Promise<{
125
+ matches: VectorMatch[];
126
+ } & {
127
+ usage: {
128
+ vendor?: string | undefined;
129
+ units?: number | undefined;
130
+ credits: number;
131
+ };
132
+ }>;
133
+ /** The stored vectors (values and metadata) of up to 100 ids; unknown ids are left out. */
134
+ get: (ids: string[]) => Promise<{
135
+ id: string;
136
+ space: "text" | "image";
137
+ values: number[];
138
+ metadata?: Record<string, string | number | boolean | string[]> | undefined;
139
+ }[]>;
140
+ /** Deletes up to 1,000 ids; answers how many existed and how many are left. */
141
+ delete: (ids: string[]) => Promise<Omit<{
142
+ deleted: number;
143
+ count: number;
144
+ usage: {
145
+ credits: number;
146
+ vendor?: string | undefined;
147
+ units?: number | undefined;
148
+ vendorCostUsd?: number | undefined;
149
+ };
150
+ }, "usage"> & {
151
+ usage: {
152
+ vendor?: string | undefined;
153
+ units?: number | undefined;
154
+ credits: number;
155
+ };
156
+ }>;
157
+ /** How many vectors this environment stores (free). */
158
+ count: () => Promise<{
159
+ count: number;
160
+ text: number;
161
+ image: number;
162
+ }>;
163
+ };
164
+ type TotalumVectors = ReturnType<typeof totalumVectors>;
165
+
166
+ export { TotalumClientOptions, VectorFilter, VectorMatch, VectorMetadata, VectorRecord, VectorSpace, VectorUpsertItem, VectorsQueryInput, totalumVectors };
167
+ export type { TotalumVectors };
@@ -0,0 +1,28 @@
1
+ import { envelopeClient, jsonClient, withUsage } from '../http.js';
2
+ export { TotalumError, isTotalumError } from '../errors.js';
3
+ /**
4
+ * `totalum.vectors` over `/v1/vectors/*` (scope `vectors`; server-side code only: it needs the project key). Every
5
+ * project environment has its own private vector store: ids, namespaces and indexes are Totalum's, never yours to
6
+ * name, and `x-totalum-env` (the `env` option) keeps dev and live apart. Vectors are 1,024 numbers; `text` is
7
+ * embedded with the `embed` model and `image` (a project file key, a files URL, an https URL or a data URL) with the
8
+ * `embed-image` model, whose space also embeds text: search images by words with `space: 'image'`. Filter on the
9
+ * metadata keys `source`, `type`, `tag`, `group` (strings) and `page` (number).
10
+ */
11
+ export function totalumVectors(options = {}) {
12
+ const call = envelopeClient(options);
13
+ const data = jsonClient(options);
14
+ return {
15
+ /** Inserts or replaces up to 100 vectors (≤ 8 images) from `values`, `text` or `image`, with optional metadata. */
16
+ upsert: async (vectors) => withUsage(await call('POST', '/v1/vectors/upsert', {
17
+ vectors,
18
+ })),
19
+ /** The `topK` (≤ 50, default 5) closest vectors to `text`, `values` or `image`, with their metadata. */
20
+ query: async (input) => withUsage(await call('POST', '/v1/vectors/query', input)),
21
+ /** The stored vectors (values and metadata) of up to 100 ids; unknown ids are left out. */
22
+ get: async (ids) => (await data('POST', '/v1/vectors/get', { ids })).vectors,
23
+ /** Deletes up to 1,000 ids; answers how many existed and how many are left. */
24
+ delete: async (ids) => withUsage(await call('POST', '/v1/vectors/delete', { ids })),
25
+ /** How many vectors this environment stores (free). */
26
+ count: () => data('GET', '/v1/vectors/count'),
27
+ };
28
+ }
@@ -1,12 +1,12 @@
1
- import { G as WebScrapeInput, H as WebSearchInput, I as WebMapInput, K as WebCrawlInput, u as ScreenshotInput } from '../_types/integrations.d-BNGV70e3.js';
2
- export { J as JobCreated, v as ScreenshotOutput, W as WebJob, B as WebScrapeOutput, D as WebSearchOutput } from '../_types/integrations.d-BNGV70e3.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
5
- import '../_types/coerce.d-C0KIW76L.js';
1
+ import { G as WebScrapeInput, H as WebSearchInput, I as WebMapInput, K as WebCrawlInput, u as ScreenshotInput } from '../_types/integrations.d-DjOeFaYn.js';
2
+ export { J as JobCreated, v as ScreenshotOutput, W as WebJob, B as WebScrapeOutput, D as WebSearchOutput } from '../_types/integrations.d-DjOeFaYn.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
+ import '../_types/coerce.d-BXj_o-j6.js';
6
6
 
7
7
  /**
8
8
  * `totalum.web` (plan 05 §6.2) over SDK-API `/v1/web/*` (scope `web`): Firecrawl scrape/search/map/crawl and Browser
9
- * Run screenshots, charged provider cost × 28 — every result carries `usage.credits`.
9
+ * Run screenshots, charged provider cost × 4 / $0.07 — every result carries `usage.credits`.
10
10
  */
11
11
  declare function totalumWeb(options?: TotalumClientOptions): {
12
12
  /**
package/dist/web/index.js CHANGED
@@ -2,7 +2,7 @@ import { envelopeClient, withUsage } from '../http.js';
2
2
  export { TotalumError, isTotalumError } from '../errors.js';
3
3
  /**
4
4
  * `totalum.web` (plan 05 §6.2) over SDK-API `/v1/web/*` (scope `web`): Firecrawl scrape/search/map/crawl and Browser
5
- * Run screenshots, charged provider cost × 28 — every result carries `usage.credits`.
5
+ * Run screenshots, charged provider cost × 4 / $0.07 — every result carries `usage.credits`.
6
6
  */
7
7
  export function totalumWeb(options = {}) {
8
8
  const call = envelopeClient(options);
@@ -1,7 +1,7 @@
1
- import { a as WebhookEvent } from '../_types/billing.d-BbSZh1wY.js';
2
- export { W as WebhookConfig, b as WebhookSecretOutput } from '../_types/billing.d-BbSZh1wY.js';
3
- import { T as TotalumClientOptions, a as TotalumError } from '../_types/errors.d-Cu3q_E_r.js';
4
- export { i as isTotalumError } from '../_types/errors.d-Cu3q_E_r.js';
1
+ import { a as WebhookEvent } from '../_types/billing.d-DWcflg9y.js';
2
+ export { W as WebhookConfig, b as WebhookSecretOutput } from '../_types/billing.d-DWcflg9y.js';
3
+ import { T as TotalumClientOptions, a as TotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
4
+ export { b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
5
5
 
6
6
  /** A webhook refusal (plan 05 §7.2): the codes never travel, the app answers 400. */
7
7
  declare class TotalumWebhookError extends TotalumError {