totalum-sdk 0.1.0-dev.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/_types/{billing.d-BbSZh1wY.d.ts → billing.d-BcRcDH4Y.d.ts} +1 -1
- package/dist/_types/{coerce.d-C0KIW76L.d.ts → coerce.d-BXj_o-j6.d.ts} +1 -1
- package/dist/_types/{errors.d-Cu3q_E_r.d.ts → errors.d-Dtt-BIwJ.d.ts} +26 -2
- package/dist/_types/{integrations.d-BNGV70e3.d.ts → integrations.d-DjOeFaYn.d.ts} +2 -2
- package/dist/_types/{ops.d-C9375KIG.d.ts → ops.d-BKBWL6Qf.d.ts} +2 -2
- package/dist/ai/index.d.ts +42 -26
- package/dist/ai/index.js +13 -9
- package/dist/analytics/index.d.ts +4 -4
- package/dist/browser/index.d.ts +60 -5
- package/dist/browser/index.js +22 -5
- package/dist/cron/index.d.ts +5 -5
- package/dist/cron/index.js +2 -10
- package/dist/d1/index.d.ts +6 -4
- package/dist/d1/lazy.js +21 -3
- package/dist/d1/session.js +83 -15
- package/dist/deprecate.js +16 -0
- package/dist/email/index.d.ts +12 -6
- package/dist/email/index.js +4 -3
- package/dist/files/index.d.ts +11 -9
- package/dist/files/index.js +10 -5
- package/dist/index.d.ts +11 -8
- package/dist/index.js +3 -0
- package/dist/logs/index.d.ts +5 -5
- package/dist/payments/index.d.ts +5 -5
- package/dist/pdf/index.d.ts +5 -5
- package/dist/realtime/index.d.ts +2 -2
- package/dist/scan/index.d.ts +14 -6
- package/dist/scan/index.js +5 -1
- package/dist/seo/index.d.ts +4 -4
- package/dist/speech/index.d.ts +26 -13
- package/dist/speech/index.js +24 -12
- package/dist/vectors/index.d.ts +167 -0
- package/dist/vectors/index.js +28 -0
- package/dist/web/index.d.ts +6 -6
- package/dist/web/index.js +1 -1
- package/dist/webhooks/index.d.ts +4 -4
- package/package.json +13 -3
- package/totalum-sdk.md +120 -24
- package/totalum-sdk.signatures.json +313 -0
package/dist/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TotalumError } from '../errors.js';
|
|
2
|
-
import { jsonClient } from '../http.js';
|
|
2
|
+
import { jsonClient, query } from '../http.js';
|
|
3
3
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
4
4
|
/** The frozen 67 (contracts `BROWSER_COMMANDS`, plan 11 §3.4) as a literal, so nothing is imported at runtime. */
|
|
5
5
|
const BROWSER_COMMANDS = [
|
|
@@ -101,6 +101,18 @@ const POSITIONAL = {
|
|
|
101
101
|
* `totalum.browser` (plan 05 §6.3) over SDK-API `/v1/browser/*` (scope `browser`): Browserbase sessions driven entirely
|
|
102
102
|
* over HTTPS, so every command works from a Worker (A6.29). A command's refusal throws `TotalumError` with its frozen
|
|
103
103
|
* code (`ACTION_TIMEOUT`, `ACTION_FAILED`, …); `actions()` returns every result instead.
|
|
104
|
+
*
|
|
105
|
+
* #### Things that still need a CDP connection
|
|
106
|
+
*
|
|
107
|
+
* Nothing an app needs. Every capability is a command or a create-time option, so it works in a published app. The
|
|
108
|
+
* list keeps exactly two entries, neither of which an app needs (A6.30):
|
|
109
|
+
*
|
|
110
|
+
* - Attaching a raw CDP domain listener for a continuous event stream — `network.subscribe` is the push channel for the app case.
|
|
111
|
+
* - Driving the session with a third-party Node library's own protocol client (`connectOverCDP`, `puppeteer.connect`).
|
|
112
|
+
*
|
|
113
|
+
* #### Not possible for anyone, over any transport
|
|
114
|
+
*
|
|
115
|
+
* - Seeding a saved profile from raw bytes (`CONTEXT_SEED_UNSUPPORTED`) — the vendor's context upload is deprecated; create a profile by running a session with `context: { persist: true }`, and replay cookies and web storage with `cookies.set` and `storage.set` (a service worker or an IndexedDB database cannot be replayed).
|
|
104
116
|
*/
|
|
105
117
|
export function totalumBrowser(options = {}) {
|
|
106
118
|
const call = jsonClient(options);
|
|
@@ -140,13 +152,18 @@ export function totalumBrowser(options = {}) {
|
|
|
140
152
|
});
|
|
141
153
|
}
|
|
142
154
|
return {
|
|
143
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Opens a session. Totalum-synthesised over CDP (not vendor fields, so the vendor validates none of them):
|
|
157
|
+
* `locale`, `timezone`, `geolocation`, `userAgent`, `extraHeaders`, `blockResources`, `device`,
|
|
158
|
+
* `captureDownloads`, `viewport`. Mapped onto vendor fields: `stealth` (`'off' | 'basic' | 'verified'` → the
|
|
159
|
+
* vendor's `verified` and `os`; `'verified'` needs the vendor's Scale tier, else `STEALTH_TIER_UNAVAILABLE`, and
|
|
160
|
+
* ignores `viewport`) and `region` (the vendor's four regions; `'eu'`, `'us'` are aliases). Every other option is
|
|
161
|
+
* a vendor field.
|
|
162
|
+
*/
|
|
144
163
|
session: async (opts = {}) => handle(await call('POST', '/v1/browser/sessions', opts)),
|
|
145
164
|
sessions: {
|
|
146
165
|
/** The project's sessions, filtered by `status` or `metadata`. */
|
|
147
|
-
list: (q = {}) => call('GET', `/v1/browser/sessions
|
|
148
|
-
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
|
149
|
-
.join('&')}`),
|
|
166
|
+
list: (q = {}) => call('GET', `/v1/browser/sessions${query(q)}`),
|
|
150
167
|
/** A handle on an existing session (no call is made). */
|
|
151
168
|
get: (id) => handle({ id }),
|
|
152
169
|
},
|
package/dist/cron/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as CronJobInput, b as CronJob, d as CronJobPatch } from '../_types/integrations.d-
|
|
2
|
-
export { e as CronRun, f as CronRunsPage } from '../_types/integrations.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
1
|
+
import { c as CronJobInput, b as CronJob, d as CronJobPatch } from '../_types/integrations.d-DjOeFaYn.js';
|
|
2
|
+
export { e as CronRun, f as CronRunsPage } 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.cron` (plan 05 §6.9) over SDK-API `/v1/cron/*` (scope `cron`): HTTP jobs against the project's own host,
|
package/dist/cron/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isTotalumError } from '../errors.js';
|
|
2
|
-
import { jsonClient } from '../http.js';
|
|
2
|
+
import { jsonClient, query } from '../http.js';
|
|
3
3
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
4
4
|
/**
|
|
5
5
|
* `totalum.cron` (plan 05 §6.9) over SDK-API `/v1/cron/*` (scope `cron`): HTTP jobs against the project's own host,
|
|
@@ -46,15 +46,7 @@ export function totalumCron(options = {}) {
|
|
|
46
46
|
/** Lets a paused job fire again. */
|
|
47
47
|
resume: (id) => update(id, { enabled: true }),
|
|
48
48
|
/** A job's executions, newest first (30 days). */
|
|
49
|
-
runs: (id, opts = {}) => {
|
|
50
|
-
const q = new URLSearchParams();
|
|
51
|
-
if (opts.limit !== undefined)
|
|
52
|
-
q.set('limit', String(opts.limit));
|
|
53
|
-
if (opts.cursor !== undefined)
|
|
54
|
-
q.set('cursor', opts.cursor);
|
|
55
|
-
const qs = q.toString();
|
|
56
|
-
return call('GET', `${job(id)}/runs${qs ? `?${qs}` : ''}`);
|
|
57
|
-
},
|
|
49
|
+
runs: (id, opts = {}) => call('GET', `${job(id)}/runs${query(opts)}`),
|
|
58
50
|
/** Fires a job now, outside its schedule. */
|
|
59
51
|
trigger: (id) => call('POST', `${job(id)}/trigger`),
|
|
60
52
|
};
|
package/dist/d1/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SdkClientErrorCode, a as TotalumError, b as TotalumErrorCode, E as ErrorBody } from '../_types/errors.d-
|
|
1
|
+
import { S as SdkClientErrorCode, a as TotalumError, b as TotalumErrorCode, E as ErrorBody } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
2
2
|
import { TotalumClientOptions } from '../ai/index.js';
|
|
3
|
-
export { i as isTotalumError } from '../_types/errors.d-
|
|
3
|
+
export { i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Cloudflare's `D1Database` surface, re-declared structurally so an app needs no Cloudflare types to compile
|
|
@@ -65,6 +65,7 @@ interface TotalumD1Options extends TotalumClientOptions {
|
|
|
65
65
|
|
|
66
66
|
/** The client-side codes the driver throws (plan 05 §7.2), from contracts' `SDK_CLIENT_ERROR_CODES`. */
|
|
67
67
|
type TotalumD1ClientCode = Extract<SdkClientErrorCode, 'SDK_NOT_CONFIGURED' | 'NOT_SUPPORTED' | 'BATCH_FOREIGN_STATEMENT' | 'NETWORK_ERROR' | 'RESPONSE_PARSE_ERROR'>;
|
|
68
|
+
/** @deprecated Since 1.0.0: use `TotalumErrorCode` (the same type). */
|
|
68
69
|
type TotalumD1ErrorCode = TotalumErrorCode;
|
|
69
70
|
/**
|
|
70
71
|
* The database `TotalumError` (plan 05 §3.5): `message` is `D1_ERROR: …`-shaped so it reads like a native failure —
|
|
@@ -72,7 +73,7 @@ type TotalumD1ErrorCode = TotalumErrorCode;
|
|
|
72
73
|
*/
|
|
73
74
|
declare class TotalumD1Error extends TotalumError {
|
|
74
75
|
name: string;
|
|
75
|
-
constructor(errorCode:
|
|
76
|
+
constructor(errorCode: TotalumErrorCode, message: string, options?: {
|
|
76
77
|
status?: number;
|
|
77
78
|
details?: Record<string, unknown>;
|
|
78
79
|
requestId?: string;
|
|
@@ -90,7 +91,8 @@ declare const READ_YOUR_WRITES_COOKIE = "__tlm_d1_w";
|
|
|
90
91
|
* Runs one request of a Worker with a replicated D1 (A3.23, research 46 §6.3): a `GET`/`HEAD` reads through a
|
|
91
92
|
* `first-unconstrained` session — the nearest replica — unless the browser wrote in the last 10 s; any other method
|
|
92
93
|
* uses the plain binding (writes go to the primary; measured faster than any session) and its response sets the short
|
|
93
|
-
* cookie that sends that browser's next reads to the primary.
|
|
94
|
+
* cookie that sends that browser's next reads to the primary. A replica read that takes over `REPLICA_READ_TIMEOUT_MS`
|
|
95
|
+
* is answered by the primary instead, and the rest of that request reads the primary. `run` receives the env to hand to the app, whose
|
|
94
96
|
* `totalumD1()` reads `TOTALUM_DB` from it on every statement. No D1 binding (Turso, a laptop): `run(env)` unchanged.
|
|
95
97
|
*/
|
|
96
98
|
declare function withTotalumSession<E extends object>(request: Request, env: E, run: (env: E) => Promise<Response>): Promise<Response>;
|
package/dist/d1/lazy.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { TotalumD1Error } from './errors.js';
|
|
2
2
|
import { splitStatements } from './sql.js';
|
|
3
|
+
const READ = /^\s*(select|with)\b/i;
|
|
4
|
+
/**
|
|
5
|
+
* `batch()` answers rows as objects keyed by column name (no `raw()` mode), so a select with two columns of one name
|
|
6
|
+
* (`requests.id`, `users.id`) loses one, and Drizzle — which maps a batch row positionally from `Object.keys(row)` —
|
|
7
|
+
* shifts every later field. As a subquery, SQLite names the second `id:1`: every column survives, in order.
|
|
8
|
+
*/
|
|
9
|
+
const uniqueColumns = (sql) => READ.test(sql) ? `SELECT * FROM (\n${sql.replace(/[\s;]+$/, '')}\n)` : sql;
|
|
3
10
|
/**
|
|
4
11
|
* The object `totalumD1()` hands out: no I/O and no environment detection until the first statement runs;
|
|
5
12
|
* the target is resolved once and cached (plan 05 §3.1) — in a Worker that target reads the request's own binding on
|
|
@@ -45,13 +52,24 @@ export function lazyD1(resolve, migrate) {
|
|
|
45
52
|
}
|
|
46
53
|
const batchOn = (on) => async (statements) => {
|
|
47
54
|
const t = await on();
|
|
48
|
-
const
|
|
55
|
+
const lazy = statements.map((s) => {
|
|
49
56
|
if (!(s instanceof LazyStatement)) {
|
|
50
57
|
throw TotalumD1Error.client('BATCH_FOREIGN_STATEMENT', 'batch() only accepts statements prepared by this totalumD1() instance');
|
|
51
58
|
}
|
|
52
|
-
return
|
|
59
|
+
return s;
|
|
53
60
|
});
|
|
54
|
-
|
|
61
|
+
const run = (sql) => t.batch(lazy.map((s) => t.prepare(sql(s.sql)).bind(...s.params)));
|
|
62
|
+
if (!lazy.some((s) => READ.test(s.sql)))
|
|
63
|
+
return run((s) => s);
|
|
64
|
+
try {
|
|
65
|
+
return await run(uniqueColumns);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
// a SQL error is deterministic and rolled the batch back: answer it as the statements were written
|
|
69
|
+
if (e instanceof Error && e.message.endsWith('SQLITE_ERROR'))
|
|
70
|
+
return run((s) => s);
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
55
73
|
};
|
|
56
74
|
/**
|
|
57
75
|
* A D1 session (read replication, A3.23): on the native binding the binding's own `withSession()`, created on the
|
package/dist/d1/session.js
CHANGED
|
@@ -3,11 +3,21 @@ export const READ_YOUR_WRITES_COOKIE = '__tlm_d1_w';
|
|
|
3
3
|
/** Replicas lag the primary by 30–75 ms (Cloudflare); 10 s leaves a wide margin (research 46 §6.3). */
|
|
4
4
|
const WINDOW_SECONDS = 10;
|
|
5
5
|
const READS = new Set(['GET', 'HEAD']);
|
|
6
|
+
/**
|
|
7
|
+
* A replica read slower than this is re-run on the primary, and the rest of the request reads the primary. Replicas
|
|
8
|
+
* answer in tens of ms; measured stalls last 10 s or more while the primary stays fast (ui-evidence/preview-hang).
|
|
9
|
+
* D1's Sessions API documents no timeout or fallback of its own.
|
|
10
|
+
*/
|
|
11
|
+
export const REPLICA_READ_TIMEOUT_MS = 2000;
|
|
12
|
+
/** Only a `SELECT` is re-run: a write that stalled may still land, and running it twice would duplicate it. */
|
|
13
|
+
const PURE_READ = /^\s*select\b/i;
|
|
14
|
+
const LATE = Symbol('late');
|
|
6
15
|
/**
|
|
7
16
|
* Runs one request of a Worker with a replicated D1 (A3.23, research 46 §6.3): a `GET`/`HEAD` reads through a
|
|
8
17
|
* `first-unconstrained` session — the nearest replica — unless the browser wrote in the last 10 s; any other method
|
|
9
18
|
* uses the plain binding (writes go to the primary; measured faster than any session) and its response sets the short
|
|
10
|
-
* cookie that sends that browser's next reads to the primary.
|
|
19
|
+
* cookie that sends that browser's next reads to the primary. A replica read that takes over `REPLICA_READ_TIMEOUT_MS`
|
|
20
|
+
* is answered by the primary instead, and the rest of that request reads the primary. `run` receives the env to hand to the app, whose
|
|
11
21
|
* `totalumD1()` reads `TOTALUM_DB` from it on every statement. No D1 binding (Turso, a laptop): `run(env)` unchanged.
|
|
12
22
|
*/
|
|
13
23
|
export async function withTotalumSession(request, env, run) {
|
|
@@ -15,24 +25,82 @@ export async function withTotalumSession(request, env, run) {
|
|
|
15
25
|
if (typeof db?.withSession !== 'function')
|
|
16
26
|
return run(env);
|
|
17
27
|
const binding = db;
|
|
18
|
-
if (!READS.has(request.method))
|
|
19
|
-
|
|
20
|
-
if (res.status === 101)
|
|
21
|
-
return res; // a WebSocket upgrade cannot be re-wrapped
|
|
22
|
-
const out = new Response(res.body, res);
|
|
23
|
-
out.headers.append('set-cookie', `${READ_YOUR_WRITES_COOKIE}=1; Max-Age=${String(WINDOW_SECONDS)}; Path=/; HttpOnly; Secure; SameSite=None; Partitioned`);
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
28
|
+
if (!READS.has(request.method))
|
|
29
|
+
return withCookie(await run(env));
|
|
26
30
|
const cookies = request.headers.get('cookie') ?? '';
|
|
27
31
|
if (new RegExp(`(?:^|;\\s*)${READ_YOUR_WRITES_COOKIE}=`).test(cookies))
|
|
28
32
|
return run(env);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const replica = boundedReplica(binding, binding.withSession('first-unconstrained'));
|
|
34
|
+
const res = await run({ ...env, TOTALUM_DB: replica.db });
|
|
35
|
+
// a GET that wrote (a first visit creating its row, an OAuth callback) sends the browser's next reads to the primary too
|
|
36
|
+
return replica.wrote() ? withCookie(res) : res;
|
|
37
|
+
}
|
|
38
|
+
function withCookie(res) {
|
|
39
|
+
if (res.status === 101)
|
|
40
|
+
return res; // a WebSocket upgrade cannot be re-wrapped
|
|
41
|
+
const out = new Response(res.body, res);
|
|
42
|
+
out.headers.append('set-cookie', `${READ_YOUR_WRITES_COOKIE}=1; Max-Age=${String(WINDOW_SECONDS)}; Path=/; HttpOnly; Secure; SameSite=None; Partitioned`);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The request's database on the nearest replica, each pure read bounded by `REPLICA_READ_TIMEOUT_MS`: past it, the read
|
|
47
|
+
* runs on the primary (the stalled replica call is abandoned) and so does every later statement of this request. Any
|
|
48
|
+
* other statement (a write, even one that fails) runs on the primary and so does the rest of the request: a lost-race
|
|
49
|
+
* re-read (better-auth's rate limiter: insert → UNIQUE → read again) must see the row the replica has not received yet.
|
|
50
|
+
*/
|
|
51
|
+
function boundedReplica(binding, session) {
|
|
52
|
+
let primary = false;
|
|
53
|
+
let wrote = false;
|
|
54
|
+
async function read(sqls, call) {
|
|
55
|
+
if (!sqls.every((sql) => PURE_READ.test(sql))) {
|
|
56
|
+
primary = wrote = true;
|
|
57
|
+
return call(binding);
|
|
58
|
+
}
|
|
59
|
+
if (primary)
|
|
60
|
+
return call(binding);
|
|
61
|
+
let timer;
|
|
62
|
+
const late = new Promise((resolve) => {
|
|
63
|
+
timer = setTimeout(() => {
|
|
64
|
+
resolve(LATE);
|
|
65
|
+
}, REPLICA_READ_TIMEOUT_MS);
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
const out = await Promise.race([call(session), late]);
|
|
69
|
+
if (out !== LATE)
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
}
|
|
75
|
+
primary = true;
|
|
76
|
+
console.warn(JSON.stringify({ event: 'd1_replica_read_timeout', ms: REPLICA_READ_TIMEOUT_MS }));
|
|
77
|
+
return call(binding);
|
|
78
|
+
}
|
|
79
|
+
const statement = (sql, params = []) => {
|
|
80
|
+
const real = (db) => db.prepare(sql).bind(...params);
|
|
81
|
+
const bounded = (method) => (...args) => read([sql], (db) => real(db)[method](...args));
|
|
82
|
+
return {
|
|
83
|
+
sql,
|
|
84
|
+
real,
|
|
85
|
+
bind: (...values) => statement(sql, values),
|
|
86
|
+
first: bounded('first'),
|
|
87
|
+
run: bounded('run'),
|
|
88
|
+
all: bounded('all'),
|
|
89
|
+
raw: bounded('raw'),
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const db = {
|
|
93
|
+
prepare: (sql) => statement(sql),
|
|
94
|
+
batch: (statements) => {
|
|
95
|
+
const mine = statements;
|
|
96
|
+
return read(mine.map((s) => s.sql), (d) => d.batch(mine.map((s) => s.real(d))));
|
|
97
|
+
},
|
|
98
|
+
exec: (sql) => {
|
|
99
|
+
primary = wrote = true;
|
|
100
|
+
return binding.exec(sql);
|
|
101
|
+
},
|
|
34
102
|
dump: () => binding.dump(),
|
|
35
103
|
withSession: (c) => binding.withSession(c),
|
|
36
104
|
};
|
|
37
|
-
return
|
|
105
|
+
return { db, wrote: () => wrote };
|
|
38
106
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The deprecation policy (CHANGELOG.md): a deprecated name keeps working for at least one major version and warns
|
|
3
|
+
* once per process (per isolate in a Worker) with `console.warn`, naming its replacement.
|
|
4
|
+
*/
|
|
5
|
+
const warned = new Set();
|
|
6
|
+
export function deprecated(name, replacement) {
|
|
7
|
+
if (warned.has(name))
|
|
8
|
+
return;
|
|
9
|
+
warned.add(name);
|
|
10
|
+
console.warn(`[totalum-sdk] ${name} is deprecated and will be removed in totalum-sdk 2.0.0; use ${replacement}.`);
|
|
11
|
+
}
|
|
12
|
+
/** `fn` under an old name: same behaviour and type (overloads included), plus the one-time warning. */
|
|
13
|
+
export const alias = (fn, name, replacement) => ((...args) => {
|
|
14
|
+
deprecated(name, replacement);
|
|
15
|
+
return fn(...args);
|
|
16
|
+
});
|
package/dist/email/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { E as EmailSendInput, j as EmailView } from '../_types/integrations.d-
|
|
2
|
-
export { i as EmailSendOutput } from '../_types/integrations.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
1
|
+
import { E as EmailSendInput, j as EmailView } from '../_types/integrations.d-DjOeFaYn.js';
|
|
2
|
+
export { i as EmailSendOutput } 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.email` (plan 05 §6.4) over SDK-API `/v1/email/*` (scope `email`): Resend, HTML sent byte for byte, charged
|
|
@@ -10,7 +10,7 @@ import '../_types/coerce.d-C0KIW76L.js';
|
|
|
10
10
|
*/
|
|
11
11
|
declare function totalumEmail(options?: TotalumClientOptions): {
|
|
12
12
|
/**
|
|
13
|
-
* 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`).
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* await email.send({ to: 'ana@example.com', subject: 'Welcome', html: '<p>Hi Ana</p>' });
|
|
@@ -21,6 +21,12 @@ declare function totalumEmail(options?: TotalumClientOptions): {
|
|
|
21
21
|
messageId: string;
|
|
22
22
|
id: string;
|
|
23
23
|
status: "queued" | "sent";
|
|
24
|
+
} & {
|
|
25
|
+
usage: {
|
|
26
|
+
vendor?: string | undefined;
|
|
27
|
+
units?: number | undefined;
|
|
28
|
+
credits: number;
|
|
29
|
+
};
|
|
24
30
|
}>;
|
|
25
31
|
/** `null` when the e-mail is not this project's. */
|
|
26
32
|
get: (id: string) => Promise<EmailView | null>;
|
package/dist/email/index.js
CHANGED
|
@@ -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) =>
|
|
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 {
|
package/dist/files/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { F as FileDescriptor, k as FileUploadUrlInput, m as FilesListQuery } from '../_types/integrations.d-
|
|
2
|
-
export { l as FileUploadUrlOutput, n as FilesPage } from '../_types/integrations.d-
|
|
3
|
-
import { TotalumClientOptions } from '../
|
|
4
|
-
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
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
|
-
/**
|
|
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 (`
|
|
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
|
-
|
|
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 };
|
package/dist/files/index.js
CHANGED
|
@@ -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
|
-
/**
|
|
46
|
-
getDownloadUrl: getSignedUrl,
|
|
47
|
-
/** Signed GET URLs for many keys at once (`
|
|
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
|
-
|
|
50
|
-
|
|
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-
|
|
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-
|
|
34
|
-
export { L as LogsPage, S as SiteAnalyticsOutput, a as SiteDimension, b as SiteMetric } from './_types/ops.d-
|
|
35
|
-
export { W as WebhookConfig, a as WebhookEvent, b as WebhookSecretOutput } from './_types/billing.d-
|
|
36
|
-
import './_types/coerce.d-
|
|
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-BcRcDH4Y.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
|
};
|
package/dist/logs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as LogsQueryInput } from '../_types/ops.d-
|
|
2
|
-
export { L as LogsPage } from '../_types/ops.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
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'>;
|
package/dist/payments/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { O as OnboardingLinkInput, C as CheckoutInput, g as CustomerPortalLinkInput } from '../_types/integrations.d-
|
|
2
|
-
export { a as CheckoutOutput, h as CustomerPortalLinkOutput, o as OnboardingLinkOutput, P as PaymentsStatus } from '../_types/integrations.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
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
|
package/dist/pdf/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as PdfFromHtmlInput, q as PdfFromUrlInput } from '../_types/integrations.d-
|
|
2
|
-
export { r as PdfOutput } from '../_types/integrations.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
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): {
|
package/dist/realtime/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZodObject, c as ZodOptional, d as ZodString, g as ZodUnknown, m as $strip, o as output,
|
|
2
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
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<{
|
package/dist/scan/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { S as ScanDocumentInput, s as ScanOcrInput } from '../_types/integrations.d-
|
|
2
|
-
export { t as ScanOcrOutput } from '../_types/integrations.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
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
|
-
/**
|
|
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): {
|
package/dist/scan/index.js
CHANGED
|
@@ -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) =>
|
|
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
|
};
|