totalum-sdk 0.1.0-dev.4 → 0.1.0-dev.6

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/README.md +7 -3
  2. package/dist/_types/billing.d-C1exPLN6.d.ts +38 -0
  3. package/dist/_types/coerce.d-RtY2zQyw.d.ts +6 -0
  4. package/dist/_types/errors.d-yrue1e9O.d.ts +3057 -0
  5. package/dist/_types/integrations.d-BKPWost0.d.ts +793 -0
  6. package/dist/_types/ops.d-BOMT9yln.d.ts +117 -0
  7. package/dist/ai/index.d.ts +424 -0
  8. package/dist/ai/index.js +185 -0
  9. package/dist/analytics/index.d.ts +35 -0
  10. package/dist/analytics/index.js +15 -0
  11. package/dist/browser/index.d.ts +1541 -0
  12. package/dist/browser/index.js +168 -0
  13. package/dist/cron/index.d.ts +180 -0
  14. package/dist/cron/index.js +61 -0
  15. package/dist/d1/errors.js +5 -13
  16. package/dist/d1/index.d.ts +90 -5
  17. package/dist/d1/index.js +6 -10
  18. package/dist/email/index.d.ts +31 -0
  19. package/dist/email/index.js +30 -0
  20. package/dist/errors.js +35 -0
  21. package/dist/files/index.d.ts +119 -0
  22. package/dist/files/index.js +63 -0
  23. package/dist/http.js +85 -0
  24. package/dist/index.d.ts +73 -0
  25. package/dist/index.js +68 -0
  26. package/dist/logs/index.d.ts +51 -0
  27. package/dist/logs/index.js +18 -0
  28. package/dist/payments/index.d.ts +47 -0
  29. package/dist/payments/index.js +20 -0
  30. package/dist/pdf/index.d.ts +42 -0
  31. package/dist/pdf/index.js +17 -0
  32. package/dist/realtime/index.d.ts +103 -0
  33. package/dist/realtime/index.js +30 -0
  34. package/dist/scan/index.d.ts +46 -0
  35. package/dist/scan/index.js +12 -0
  36. package/dist/seo/index.d.ts +23 -0
  37. package/dist/seo/index.js +12 -0
  38. package/dist/speech/index.d.ts +41 -0
  39. package/dist/speech/index.js +22 -0
  40. package/dist/web/index.d.ts +170 -0
  41. package/dist/web/index.js +31 -0
  42. package/dist/webhooks/index.d.ts +48 -0
  43. package/dist/webhooks/index.js +61 -0
  44. package/package.json +77 -5
  45. package/totalum-sdk.md +1055 -0
  46. package/dist/d1/errors.d.ts +0 -27
  47. package/dist/d1/https.d.ts +0 -10
  48. package/dist/d1/lazy.d.ts +0 -7
  49. package/dist/d1/libsql.d.ts +0 -23
  50. package/dist/d1/sql.d.ts +0 -9
  51. package/dist/d1/types.d.ts +0 -72
@@ -1,27 +0,0 @@
1
- import type { ErrorBody, ErrorCode } from '@speed-paradigm/totalum-contracts';
2
- /** Client-side codes of plan 05 §7.2 that never travel on the wire, so they are not in the contracts enum. */
3
- export type TotalumD1ClientCode = 'SDK_NOT_CONFIGURED' | 'NOT_SUPPORTED' | 'BATCH_FOREIGN_STATEMENT' | 'NETWORK_ERROR' | 'RESPONSE_PARSE_ERROR';
4
- export type TotalumD1ErrorCode = ErrorCode | TotalumD1ClientCode;
5
- /**
6
- * The database twin of `TotalumError` (plan 05 §3.5): `message` is `D1_ERROR: …`-shaped so it reads like a
7
- * native failure — byte-identical to the binding's message when the failure is SQLite's.
8
- */
9
- export declare class TotalumD1Error extends Error {
10
- readonly name = "TotalumD1Error";
11
- readonly errorCode: TotalumD1ErrorCode;
12
- /** HTTP status; 0 for network errors, 500 for client-side refusals. */
13
- readonly status: number;
14
- readonly details: Record<string, unknown> | undefined;
15
- readonly requestId: string | undefined;
16
- constructor(errorCode: TotalumD1ErrorCode, message: string, options?: {
17
- status?: number;
18
- details?: Record<string, unknown>;
19
- requestId?: string;
20
- });
21
- /** A client-side refusal (`D1_ERROR: <code>: <message>`). */
22
- static client(errorCode: TotalumD1ClientCode | 'EXEC_REQUIRES_MIGRATE_MODE', message: string): TotalumD1Error;
23
- /** The SDK-API error envelope → typed error; `SQL_ERROR` rebuilds the native message from `sqliteMessage`. */
24
- static fromWire(errors: ErrorBody, status: number, requestId: string | undefined): TotalumD1Error;
25
- }
26
- export declare function isTotalumD1Error(e: unknown): e is TotalumD1Error;
27
- export declare function isRecord(v: unknown): v is Record<string, unknown>;
@@ -1,10 +0,0 @@
1
- import type { Executor } from './types.js';
2
- export interface HttpsConfig {
3
- apiUrl: string;
4
- key: string;
5
- env: 'dev' | 'live';
6
- migrate: boolean;
7
- destructive: boolean;
8
- }
9
- /** The `D1Database` half that speaks `POST /v1/db/query|batch` (plan 04 §3.2; contracts `db.ts`). */
10
- export declare function httpsExecutor(config: HttpsConfig): Executor;
package/dist/d1/lazy.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { D1Database, Executor } from './types.js';
2
- /**
3
- * The object `totalumD1()` hands out: no I/O and no environment detection until the first statement runs;
4
- * the target is resolved once and cached (plan 05 §3.1). Statements remember `sql` + params and are
5
- * materialised on the resolved target when executed, so `drizzle(totalumD1())` at module scope is legal.
6
- */
7
- export declare function lazyD1(resolve: () => Promise<Executor>, migrate: boolean): D1Database;
@@ -1,23 +0,0 @@
1
- import type { Executor } from './types.js';
2
- /** The slice of `@libsql/client`'s `Client` the adapter uses, declared structurally (no third-party types leak). */
3
- export interface LibsqlClient {
4
- execute(statement: LibsqlStatement): Promise<LibsqlResultSet>;
5
- batch(statements: LibsqlStatement[], mode: 'write'): Promise<LibsqlResultSet[]>;
6
- }
7
- export type LibsqlValue = string | number | bigint | boolean | null | ArrayBuffer | Uint8Array;
8
- export interface LibsqlStatement {
9
- sql: string;
10
- args: LibsqlValue[];
11
- }
12
- export interface LibsqlResultSet {
13
- columns: string[];
14
- rows: ArrayLike<unknown>[];
15
- rowsAffected: number;
16
- lastInsertRowid: bigint | undefined | null;
17
- }
18
- /**
19
- * The Turso path (A3.8, plan 05 §3.10): a `D1Database`-compatible executor over a libsql client created with
20
- * `intMode: 'bigint'` (integers beyond 2^53 then degrade to the same double D1 returns instead of throwing).
21
- * `meta` is synthesised from what libsql reports; `size_after` is not reported by libsql and is 0.
22
- */
23
- export declare function libsqlExecutor(client: LibsqlClient): Executor;
package/dist/d1/sql.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /** Native D1 refuses these at `bind()` time with `D1_TYPE_ERROR`; both non-native paths do the same, synchronously. */
2
- export declare function assertBindable(values: unknown[]): void;
3
- /** `first(col)` as the binding does it: `null` on no rows, `D1_COLUMN_NOTFOUND` on an unknown column. */
4
- export declare function pickFirst(results: unknown[], colName: string | undefined): unknown;
5
- /**
6
- * Splits an `exec()` script on statement boundaries — `;` inside string literals, quoted identifiers and
7
- * comments is not a boundary (plan 05 §3.4). Empty trailing fragments are dropped.
8
- */
9
- export declare function splitStatements(script: string): string[];
@@ -1,72 +0,0 @@
1
- /**
2
- * Cloudflare's `D1Database` surface, re-declared structurally so an app needs no Cloudflare types to compile
3
- * and `drizzle-orm/d1` accepts the object (plan 05 §1, §3.1). `D1Meta` is Cloudflare's own interface
4
- * (`size_after` required); the contracts wire shape is looser and every value here satisfies it (type-tested).
5
- */
6
- export type D1Meta = {
7
- duration: number;
8
- size_after: number;
9
- rows_read: number;
10
- rows_written: number;
11
- last_row_id: number;
12
- changed_db: boolean;
13
- changes: number;
14
- served_by_region?: string;
15
- served_by_primary?: boolean;
16
- };
17
- export interface D1Result<T = Record<string, unknown>> {
18
- results: T[];
19
- success: true;
20
- meta: D1Meta;
21
- }
22
- export interface D1ExecResult {
23
- count: number;
24
- duration: number;
25
- }
26
- export interface D1PreparedStatement {
27
- bind(...values: unknown[]): D1PreparedStatement;
28
- first<T = Record<string, unknown>>(colName?: string): Promise<T | null>;
29
- run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
30
- all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
31
- raw<T = unknown[]>(options: {
32
- columnNames: true;
33
- }): Promise<[string[], ...T[]]>;
34
- raw<T = unknown[]>(options?: {
35
- columnNames?: false;
36
- }): Promise<T[]>;
37
- }
38
- export interface D1DatabaseSession {
39
- prepare(sql: string): D1PreparedStatement;
40
- batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
41
- getBookmark(): string | null;
42
- }
43
- export interface D1Database {
44
- prepare(sql: string): D1PreparedStatement;
45
- batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
46
- exec(sql: string): Promise<D1ExecResult>;
47
- dump(): Promise<ArrayBuffer>;
48
- withSession(constraintOrBookmark?: string): D1DatabaseSession;
49
- }
50
- /** What a resolved target must offer; a native binding satisfies it, the HTTPS and libsql executors implement it. */
51
- export interface Executor {
52
- prepare(sql: string): D1PreparedStatement;
53
- batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
54
- /** Native only: the binding's own line-based `exec`. Executors without it run `exec` as one atomic batch. */
55
- exec?(sql: string): Promise<D1ExecResult>;
56
- }
57
- export interface TotalumD1Options {
58
- /** `'migrate'` (scripts/migrate.ts only) sends `x-totalum-migrate: 1` and enables `exec()`; default `'query'`. */
59
- mode?: 'query' | 'migrate';
60
- /** Migrate mode only: sends `x-totalum-migrate-destructive: 1` (A10.4). */
61
- destructive?: boolean;
62
- /** HTTPS path only; default `TOTALUM_ENV`, then `'live'`. */
63
- env?: 'dev' | 'live';
64
- /** Default `TOTALUM_SDK_API_URL`, then `https://sdk-api.totalum.app`. */
65
- apiUrl?: string;
66
- /** Default `TOTALUM_PROJECT_KEY`. */
67
- key?: string;
68
- /** An explicit binding wins over detection (plain Workers: `env.TOTALUM_DB`; tests: a Miniflare D1). */
69
- binding?: D1Database;
70
- /** `'https'` forces the HTTPS path even inside a Worker (the conformance corpus); default `'auto'`. */
71
- transport?: 'auto' | 'https';
72
- }