totalum-sdk 1.10.0 → 1.10.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.
- package/dist/_types/{coerce.d-3Xj4xYuy.d.ts → coerce.d-DiNiCkat.d.ts} +1 -1
- package/dist/_types/{errors.d-BBRayxHv.d.ts → errors.d-BfXTsxYG.d.ts} +6 -6
- package/dist/_types/{integrations.d-Hj3BqI02.d.ts → integrations.d-DL2_rTOs.d.ts} +11 -11
- package/dist/_types/{ops.d-D_3lqkJ2.d.ts → ops.d-fwLDriUN.d.ts} +3 -3
- package/dist/ai/index.d.ts +11 -12
- package/dist/ai/index.js +3 -3
- package/dist/analytics/index.d.ts +5 -5
- package/dist/analytics/index.js +1 -1
- package/dist/browser/index.d.ts +10 -10
- package/dist/browser/index.js +4 -4
- package/dist/cron/index.d.ts +10 -10
- package/dist/cron/index.js +5 -5
- package/dist/d1/d1-limits.js +1 -1
- package/dist/d1/errors.js +3 -3
- package/dist/d1/https.js +3 -3
- package/dist/d1/index.d.ts +12 -12
- package/dist/d1/index.js +2 -2
- package/dist/d1/lazy.js +4 -4
- package/dist/d1/libsql.js +5 -5
- package/dist/d1/migrate-rules.js +5 -5
- package/dist/d1/native-shape.js +2 -2
- package/dist/d1/retry.js +3 -3
- package/dist/d1/session.js +3 -3
- package/dist/d1/sql.js +2 -2
- package/dist/email/index.d.ts +6 -6
- package/dist/email/index.js +1 -1
- package/dist/errors.js +4 -4
- package/dist/files/index.d.ts +11 -11
- package/dist/files/index.js +4 -4
- package/dist/http.js +7 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/logs/index.d.ts +6 -6
- package/dist/logs/index.js +1 -1
- package/dist/payments/index.d.ts +7 -7
- package/dist/payments/index.js +2 -2
- package/dist/pdf/index.d.ts +6 -6
- package/dist/pdf/index.js +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/realtime/index.d.ts +5 -5
- package/dist/realtime/index.js +1 -1
- package/dist/scan/index.d.ts +6 -6
- package/dist/scan/index.js +1 -1
- package/dist/seo/index.d.ts +5 -5
- package/dist/seo/index.js +1 -1
- package/dist/speech/index.d.ts +6 -6
- package/dist/speech/index.js +1 -1
- package/dist/vectors/index.d.ts +4 -4
- package/dist/web/index.d.ts +6 -6
- package/dist/web/index.js +1 -1
- package/dist/webhooks/index.d.ts +5 -5
- package/dist/webhooks/index.js +4 -4
- package/package.json +1 -1
- package/totalum-sdk.md +23 -23
- package/totalum-sdk.signatures.json +1 -1
|
@@ -2708,12 +2708,12 @@ declare const ErrorCode: ZodEnum<{
|
|
|
2708
2708
|
}>;
|
|
2709
2709
|
type ErrorCode = output<typeof ErrorCode>;
|
|
2710
2710
|
/**
|
|
2711
|
-
* Codes thrown only by `totalum-sdk` on the client, never sent by
|
|
2711
|
+
* Codes thrown only by `totalum-sdk` on the client, never sent by the Totalum API. Kept apart from
|
|
2712
2712
|
* `ERROR_CODES` so a server test never expects one; the SDK's `errorCode` type is the union of both lists.
|
|
2713
2713
|
*/
|
|
2714
2714
|
declare const SDK_CLIENT_ERROR_CODES: readonly ["SDK_NOT_CONFIGURED", "NOT_SUPPORTED", "BATCH_FOREIGN_STATEMENT", "TRANSACTIONS_NOT_SUPPORTED", "NETWORK_ERROR", "TIMEOUT", "RESPONSE_PARSE_ERROR", "NODE_ONLY", "WEBHOOK_SECRET_MISSING", "WEBHOOK_SIGNATURE_INVALID", "WEBHOOK_TIMESTAMP_EXPIRED"];
|
|
2715
2715
|
type SdkClientErrorCode = (typeof SDK_CLIENT_ERROR_CODES)[number];
|
|
2716
|
-
/** `errors` of a failed call — `errorCode` is authoritative, the HTTP status is informative
|
|
2716
|
+
/** `errors` of a failed call — `errorCode` is authoritative, the HTTP status is informative. */
|
|
2717
2717
|
declare const ErrorBody: ZodObject<{
|
|
2718
2718
|
errorCode: ZodEnum<{
|
|
2719
2719
|
SERVICE_UNAUTHORIZED: "SERVICE_UNAUTHORIZED";
|
|
@@ -3124,7 +3124,7 @@ declare const ErrorBody: ZodObject<{
|
|
|
3124
3124
|
}, $strip>;
|
|
3125
3125
|
type ErrorBody = output<typeof ErrorBody>;
|
|
3126
3126
|
|
|
3127
|
-
/** The options every namespace takes; each one falls back to the same environment variable everywhere
|
|
3127
|
+
/** The options every namespace takes; each one falls back to the same environment variable everywhere. */
|
|
3128
3128
|
interface TotalumClientOptions {
|
|
3129
3129
|
/** Project key `tlm_pk_…`; default `TOTALUM_PROJECT_KEY`. Server-side only. */
|
|
3130
3130
|
key?: string;
|
|
@@ -3138,10 +3138,10 @@ interface Usage {
|
|
|
3138
3138
|
credits: number;
|
|
3139
3139
|
}
|
|
3140
3140
|
|
|
3141
|
-
/** Every code a `TotalumError` can carry:
|
|
3141
|
+
/** Every code a `TotalumError` can carry: the Totalum API's frozen codes plus the client-side ones. */
|
|
3142
3142
|
type TotalumErrorCode = ErrorCode | SdkClientErrorCode;
|
|
3143
3143
|
/**
|
|
3144
|
-
* The one error every `totalum-sdk` call throws
|
|
3144
|
+
* The one error every `totalum-sdk` call throws: the Totalum API envelope's frozen `errorCode`, the HTTP
|
|
3145
3145
|
* status and `details`. `TotalumD1Error` (`totalum-sdk/d1`) and `TotalumWebhookError` (`totalum-sdk/webhooks`)
|
|
3146
3146
|
* extend it, so one `isTotalumError(e)` check covers the whole package.
|
|
3147
3147
|
*/
|
|
@@ -3151,7 +3151,7 @@ declare class TotalumError extends Error {
|
|
|
3151
3151
|
/** HTTP status; 0 for network errors, 500 for client-side refusals. */
|
|
3152
3152
|
readonly status: number;
|
|
3153
3153
|
readonly details: Record<string, unknown> | undefined;
|
|
3154
|
-
/**
|
|
3154
|
+
/** the Totalum API's request id, for support and the logs explorer. */
|
|
3155
3155
|
readonly requestId: string | undefined;
|
|
3156
3156
|
constructor(errorCode: TotalumErrorCode, message: string, status?: number, details?: Record<string, unknown>, requestId?: string);
|
|
3157
3157
|
/** `TotalumError [CODE]: message` — what a log shows for `String(err)` (workerd's tail serialises an Error so). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZodObject, d as ZodString, c as ZodOptional, f as ZodEnum, k as ZodNumber, j as ZodBoolean, m as $strip, o as output, p as ZodURL, e as ZodArray, n as ZodUnion, l as ZodInt, h as ZodRecord, w as ZodNullable, u as ZodISODateTime, y as ZodEmail, r as ZodLiteral, g as ZodUnknown } from './errors.d-
|
|
2
|
-
import { Z as ZodCoercedNumber } from './coerce.d-
|
|
1
|
+
import { Z as ZodObject, d as ZodString, c as ZodOptional, f as ZodEnum, k as ZodNumber, j as ZodBoolean, m as $strip, o as output, p as ZodURL, e as ZodArray, n as ZodUnion, l as ZodInt, h as ZodRecord, w as ZodNullable, u as ZodISODateTime, y as ZodEmail, r as ZodLiteral, g as ZodUnknown } from './errors.d-BfXTsxYG.js';
|
|
2
|
+
import { Z as ZodCoercedNumber } from './coerce.d-DiNiCkat.js';
|
|
3
3
|
|
|
4
4
|
/** `202` of every async integration call; `estimatedCredits` = the reserved estimate (settled to the real cost). */
|
|
5
5
|
declare const JobCreated: ZodObject<{
|
|
@@ -8,7 +8,7 @@ declare const JobCreated: ZodObject<{
|
|
|
8
8
|
}, $strip>;
|
|
9
9
|
type JobCreated = output<typeof JobCreated>;
|
|
10
10
|
/**
|
|
11
|
-
* The file descriptor every file route answers (
|
|
11
|
+
* The file descriptor every file route answers (the `{fileName, fileSize, fileUrl}` convention
|
|
12
12
|
* keeps). `fileUrl` is the public `https://files.<zone>/<key>` URL, `null` when private (read it through a signed URL).
|
|
13
13
|
* `name`/`url`/`size`/`id`/`fileNameId` are the compat keys of the upload response (`fileNameId` = `key`).
|
|
14
14
|
*/
|
|
@@ -181,7 +181,7 @@ declare const WebCrawlInput: ZodObject<{
|
|
|
181
181
|
webhook: ZodOptional<ZodBoolean>;
|
|
182
182
|
}, $strip>;
|
|
183
183
|
type WebCrawlInput = output<typeof WebCrawlInput>;
|
|
184
|
-
/** `GET /v1/web/jobs/:jobId`: progress, the
|
|
184
|
+
/** `GET /v1/web/jobs/:jobId`: progress, the credits used, pages paged by `next`. */
|
|
185
185
|
declare const WebJob: ZodObject<{
|
|
186
186
|
jobId: ZodString;
|
|
187
187
|
status: ZodEnum<{
|
|
@@ -224,7 +224,7 @@ declare const WebMapInput: ZodObject<{
|
|
|
224
224
|
limit: ZodOptional<ZodInt>;
|
|
225
225
|
}, $strip>;
|
|
226
226
|
type WebMapInput = output<typeof WebMapInput>;
|
|
227
|
-
/** `POST /v1/web/search
|
|
227
|
+
/** `POST /v1/web/search`; `scrapeOptions` scrapes the results inline. */
|
|
228
228
|
declare const WebSearchInput: ZodObject<{
|
|
229
229
|
query: ZodString;
|
|
230
230
|
limit: ZodOptional<ZodInt>;
|
|
@@ -552,7 +552,7 @@ declare const EmailView: ZodObject<{
|
|
|
552
552
|
}, $strip>>;
|
|
553
553
|
}, $strip>;
|
|
554
554
|
type EmailView = output<typeof EmailView>;
|
|
555
|
-
/** `POST /v1/cron/jobs`; header values may reference `{{secret:NAME}}` (resolved by
|
|
555
|
+
/** `POST /v1/cron/jobs`; header values may reference `{{secret:NAME}}` (resolved by Totalum at fire time). */
|
|
556
556
|
declare const CronJobInput: ZodObject<{
|
|
557
557
|
name: ZodString;
|
|
558
558
|
schedule: ZodUnion<readonly [ZodString, ZodObject<{
|
|
@@ -745,8 +745,8 @@ declare const OnboardingLinkOutput: ZodObject<{
|
|
|
745
745
|
type OnboardingLinkOutput = output<typeof OnboardingLinkOutput>;
|
|
746
746
|
/**
|
|
747
747
|
* `POST /v1/payments/checkout` — the direct charge: a hosted Checkout Session on the connected account
|
|
748
|
-
* (`Stripe-Account`),
|
|
749
|
-
* `mode: 'setup'` saves a card for a later charge
|
|
748
|
+
* (`Stripe-Account`), the Totalum API injects the application fee; any `card[...]` field → `400 CARD_DATA_NOT_ACCEPTED`.
|
|
749
|
+
* `mode: 'setup'` saves a card for a later charge: no `lineItems`, and `currency` is required — Stripe
|
|
750
750
|
* asks for one in setup mode. `mode: 'subscription'` takes a recurring price: a `priceId` the owner made in Stripe, or an
|
|
751
751
|
* inline item with `recurring`; `metadata` is copied onto the subscription, so its webhooks carry it too.
|
|
752
752
|
*/
|
|
@@ -792,7 +792,7 @@ declare const CheckoutOutput: ZodObject<{
|
|
|
792
792
|
}, $strip>;
|
|
793
793
|
type CheckoutOutput = output<typeof CheckoutOutput>;
|
|
794
794
|
/**
|
|
795
|
-
* `GET /v1/payments/checkout/:id
|
|
795
|
+
* `GET /v1/payments/checkout/:id`: the Checkout Session read back from the project's own connected
|
|
796
796
|
* account, so the page Stripe returns the buyer to (`successUrl` with `{CHECKOUT_SESSION_ID}`) can confirm the payment
|
|
797
797
|
* itself — no webhook to set up. A session of another account is Stripe's 404.
|
|
798
798
|
*/
|
|
@@ -819,7 +819,7 @@ declare const CheckoutSession: ZodObject<{
|
|
|
819
819
|
}, $strip>;
|
|
820
820
|
type CheckoutSession = output<typeof CheckoutSession>;
|
|
821
821
|
/**
|
|
822
|
-
* `GET|PATCH|DELETE /v1/payments/subscriptions/:id` (
|
|
822
|
+
* `GET|PATCH|DELETE /v1/payments/subscriptions/:id` (G1): a subscription on the project's own connected
|
|
823
823
|
* account (another account's id is Stripe's 404). Access is `status` `active` or `trialing`; `currentPeriodEnd` = the
|
|
824
824
|
* next renewal (or the end of access when `cancelAtPeriodEnd`). `DELETE` cancels at once (`status: 'canceled'`).
|
|
825
825
|
*/
|
|
@@ -847,7 +847,7 @@ declare const SubscriptionUpdateInput: ZodObject<{
|
|
|
847
847
|
cancelAtPeriodEnd: ZodBoolean;
|
|
848
848
|
}, $strip>;
|
|
849
849
|
type SubscriptionUpdateInput = output<typeof SubscriptionUpdateInput>;
|
|
850
|
-
/** `POST /v1/payments/customer-portal-link`: Stripe's hosted customer portal on the connected account
|
|
850
|
+
/** `POST /v1/payments/customer-portal-link`: Stripe's hosted customer portal on the connected account. */
|
|
851
851
|
declare const CustomerPortalLinkInput: ZodObject<{
|
|
852
852
|
customerId: ZodString;
|
|
853
853
|
returnUrl: ZodURL;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZodObject, c as ZodOptional, e as ZodArray, u as ZodISODateTime, v as $catchall, k as ZodNumber, d as ZodString, f as ZodEnum, m as $strip, r as ZodLiteral, j as ZodBoolean, o as output, w as ZodNullable, l as ZodInt } from './errors.d-
|
|
2
|
-
import { Z as ZodCoercedNumber } from './coerce.d-
|
|
1
|
+
import { Z as ZodObject, c as ZodOptional, e as ZodArray, u as ZodISODateTime, v as $catchall, k as ZodNumber, d as ZodString, f as ZodEnum, m as $strip, r as ZodLiteral, j as ZodBoolean, o as output, w as ZodNullable, l as ZodInt } from './errors.d-BfXTsxYG.js';
|
|
2
|
+
import { Z as ZodCoercedNumber } from './coerce.d-DiNiCkat.js';
|
|
3
3
|
|
|
4
4
|
declare const SiteMetric: ZodEnum<{
|
|
5
5
|
bytes: "bytes";
|
|
@@ -47,7 +47,7 @@ declare const SiteAnalyticsOutput: ZodObject<{
|
|
|
47
47
|
cachedAt: ZodISODateTime;
|
|
48
48
|
}, $strip>;
|
|
49
49
|
type SiteAnalyticsOutput = output<typeof SiteAnalyticsOutput>;
|
|
50
|
-
/** `POST /projects/:id/logs/query` (
|
|
50
|
+
/** `POST /projects/:id/logs/query` (Totalum) = `GET /v1/logs` query (the Totalum API). `env`: dev = preview, live = published. */
|
|
51
51
|
declare const LogsQueryInput: ZodObject<{
|
|
52
52
|
requestId: ZodOptional<ZodString>;
|
|
53
53
|
limit: ZodOptional<ZodCoercedNumber<unknown>>;
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { SpeechAudio } from '../speech/index.js';
|
|
2
|
-
import { Z as ZodObject, c as ZodOptional, d as ZodString, e as ZodArray, f as ZodEnum, g as ZodUnknown, $ as $loose, h as ZodRecord, j as ZodBoolean, k as ZodNumber, l as ZodInt, m as $strip, o as output, n as ZodUnion, p as ZodURL, q as $partial, r as ZodLiteral, T as TotalumClientOptions, U as Usage } from '../_types/errors.d-
|
|
3
|
-
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-
|
|
2
|
+
import { Z as ZodObject, c as ZodOptional, d as ZodString, e as ZodArray, f as ZodEnum, g as ZodUnknown, $ as $loose, h as ZodRecord, j as ZodBoolean, k as ZodNumber, l as ZodInt, m as $strip, o as output, n as ZodUnion, p as ZodURL, q as $partial, r as ZodLiteral, T as TotalumClientOptions, U as Usage } from '../_types/errors.d-BfXTsxYG.js';
|
|
3
|
+
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BfXTsxYG.js';
|
|
4
4
|
import { SpeakInput, StoredMedia, TranscribeInput } from '../index.js';
|
|
5
|
-
import '../_types/coerce.d-
|
|
5
|
+
import '../_types/coerce.d-DiNiCkat.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Named model presets
|
|
9
|
-
*
|
|
10
|
-
* field takes a preset or a pinned OpenRouter slug; a `:free` slug is never sent (20 req/min, shared by every tenant).
|
|
8
|
+
* Named model presets: the Totalum API resolves each to an model id refreshed from the model catalogue to the newest non-deprecated model of the preset's family. A `model`
|
|
9
|
+
* field takes a preset or a pinned model id; a `:free` slug is never sent (20 req/min, shared by every tenant).
|
|
11
10
|
*/
|
|
12
11
|
declare const AI_PRESETS: readonly ["fast", "smart", "reasoning", "vision", "image", "image-edit", "video", "tts", "stt", "embed", "embed-image"];
|
|
13
12
|
type AiPresetName = (typeof AI_PRESETS)[number];
|
|
@@ -119,7 +118,7 @@ declare const AiImageOutput: ZodObject<{
|
|
|
119
118
|
imageUrl: ZodOptional<ZodURL>;
|
|
120
119
|
}, $strip>;
|
|
121
120
|
type AiImageOutput = output<typeof AiImageOutput>;
|
|
122
|
-
/** `POST /v1/ai/video` (integration `ai_video`, every plan incl. Free —
|
|
121
|
+
/** `POST /v1/ai/video` (integration `ai_video`, every plan incl. Free — ): `202 AiVideoCreated`. */
|
|
123
122
|
declare const AiVideoInput: ZodObject<{
|
|
124
123
|
prompt: ZodString;
|
|
125
124
|
model: ZodOptional<ZodString>;
|
|
@@ -208,7 +207,7 @@ interface TotalumAiOptions extends TotalumClientOptions {
|
|
|
208
207
|
/** The OpenAI-compatible AI gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
|
|
209
208
|
aiBaseUrl?: string;
|
|
210
209
|
}
|
|
211
|
-
/** What a call was charged, in Totalum credits — the only usage Totalum shows (no tokens
|
|
210
|
+
/** What a call was charged, in Totalum credits — the only usage Totalum shows (no tokens). */
|
|
212
211
|
interface ChatUsage {
|
|
213
212
|
credits: number;
|
|
214
213
|
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
@@ -224,7 +223,7 @@ interface ToolCall {
|
|
|
224
223
|
arguments: string;
|
|
225
224
|
};
|
|
226
225
|
}
|
|
227
|
-
/** `ai.chat()
|
|
226
|
+
/** `ai.chat()`: the first choice read out, the raw completion kept. */
|
|
228
227
|
interface ChatResult {
|
|
229
228
|
id: string;
|
|
230
229
|
model: string;
|
|
@@ -241,10 +240,10 @@ interface ChatStream {
|
|
|
241
240
|
result(): Promise<ChatResult>;
|
|
242
241
|
}
|
|
243
242
|
/**
|
|
244
|
-
* `totalum.ai`
|
|
243
|
+
* `totalum.ai` over the Totalum API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
|
|
245
244
|
* `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
246
245
|
* of its family, resolved by Totalum) or a pinned model id; every call returned with the Totalum credits it was
|
|
247
|
-
* charged (`usage.credits`, never tokens
|
|
246
|
+
* charged (`usage.credits`, never tokens). No `ai.agent()` — the
|
|
248
247
|
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
249
248
|
*/
|
|
250
249
|
declare function totalumAi(options?: TotalumAiOptions): {
|
|
@@ -399,7 +398,7 @@ declare function totalumAi(options?: TotalumAiOptions): {
|
|
|
399
398
|
denylist?: string[] | undefined;
|
|
400
399
|
}>;
|
|
401
400
|
};
|
|
402
|
-
/** The OpenAI-compatible API for any OpenAI-compatible client
|
|
401
|
+
/** The OpenAI-compatible API for any OpenAI-compatible client: `new OpenAI(ai.gatewayConfig())`. Server-side only. */
|
|
403
402
|
gatewayConfig: () => {
|
|
404
403
|
baseURL: string;
|
|
405
404
|
apiKey: string;
|
package/dist/ai/index.js
CHANGED
|
@@ -83,10 +83,10 @@ function chatStream(body) {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* `totalum.ai`
|
|
86
|
+
* `totalum.ai` over the Totalum API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
|
|
87
87
|
* `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
88
88
|
* of its family, resolved by Totalum) or a pinned model id; every call returned with the Totalum credits it was
|
|
89
|
-
* charged (`usage.credits`, never tokens
|
|
89
|
+
* charged (`usage.credits`, never tokens). No `ai.agent()` — the
|
|
90
90
|
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
91
91
|
*/
|
|
92
92
|
export function totalumAi(options = {}) {
|
|
@@ -176,7 +176,7 @@ export function totalumAi(options = {}) {
|
|
|
176
176
|
/** Each preset's current model and the models a project may call, with their prices. */
|
|
177
177
|
list: () => call('GET', '/v1/ai/models'),
|
|
178
178
|
},
|
|
179
|
-
/** The OpenAI-compatible API for any OpenAI-compatible client
|
|
179
|
+
/** The OpenAI-compatible API for any OpenAI-compatible client: `new OpenAI(ai.gatewayConfig())`. Server-side only. */
|
|
180
180
|
gatewayConfig: () => ({
|
|
181
181
|
baseURL: options.aiBaseUrl ?? readEnv('TOTALUM_AI_BASE_URL') ?? 'https://ai.totalum.app/api/v1',
|
|
182
182
|
apiKey: projectKey(options),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as SiteMetric, a as SiteDimension, S as SiteAnalyticsOutput } from '../_types/ops.d-
|
|
2
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
3
|
-
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-
|
|
4
|
-
import '../_types/coerce.d-
|
|
1
|
+
import { b as SiteMetric, a as SiteDimension, S as SiteAnalyticsOutput } from '../_types/ops.d-fwLDriUN.js';
|
|
2
|
+
import { T as TotalumClientOptions } from '../_types/errors.d-BfXTsxYG.js';
|
|
3
|
+
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BfXTsxYG.js';
|
|
4
|
+
import '../_types/coerce.d-DiNiCkat.js';
|
|
5
5
|
|
|
6
6
|
interface SiteAnalyticsQuery {
|
|
7
7
|
/** ISO; default the last 7 days. */
|
|
@@ -19,7 +19,7 @@ interface SiteAnalyticsQuery {
|
|
|
19
19
|
/** `dev` = the preview host, `live` = the published and custom hosts; omitted = both. */
|
|
20
20
|
env?: 'dev' | 'live';
|
|
21
21
|
}
|
|
22
|
-
/** `totalum.analytics`
|
|
22
|
+
/** `totalum.analytics` over the Totalum API `/v1/analytics/site` (scope `analytics:read`): the site's own traffic. Free. */
|
|
23
23
|
declare function totalumAnalytics(options?: TotalumClientOptions): {
|
|
24
24
|
/**
|
|
25
25
|
* Page views, visits, uniques, errors, bytes or TTFB as a series or a top-N.
|
package/dist/analytics/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsonClient, query } from '../http.js';
|
|
2
2
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
3
|
-
/** `totalum.analytics`
|
|
3
|
+
/** `totalum.analytics` over the Totalum API `/v1/analytics/site` (scope `analytics:read`): the site's own traffic. Free. */
|
|
4
4
|
export function totalumAnalytics(options = {}) {
|
|
5
5
|
const call = jsonClient(options);
|
|
6
6
|
return {
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZodObject, e as ZodArray, j as ZodBoolean, c as ZodOptional, g as ZodUnknown, f as ZodEnum, d as ZodString, m as $strip, l as ZodInt, o as output, $ as $loose, s as ZodType, t as $ZodTypeInternals, h as ZodRecord, p as ZodURL, u as ZodISODateTime, k as ZodNumber, r as ZodLiteral, T as TotalumClientOptions } from '../_types/errors.d-
|
|
2
|
-
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-
|
|
1
|
+
import { Z as ZodObject, e as ZodArray, j as ZodBoolean, c as ZodOptional, g as ZodUnknown, f as ZodEnum, d as ZodString, m as $strip, l as ZodInt, o as output, $ as $loose, s as ZodType, t as $ZodTypeInternals, h as ZodRecord, p as ZodURL, u as ZodISODateTime, k as ZodNumber, r as ZodLiteral, T as TotalumClientOptions } from '../_types/errors.d-BfXTsxYG.js';
|
|
2
|
+
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BfXTsxYG.js';
|
|
3
3
|
|
|
4
4
|
declare const BrowserCommandName: ZodEnum<{
|
|
5
5
|
type: "type";
|
|
@@ -72,7 +72,7 @@ declare const BrowserCommandName: ZodEnum<{
|
|
|
72
72
|
}>;
|
|
73
73
|
type BrowserCommandName = output<typeof BrowserCommandName>;
|
|
74
74
|
/**
|
|
75
|
-
* One command: `{ type
|
|
75
|
+
* One command: `{ type,...params }`, the parameters of –§3.4.10 / per command. Every
|
|
76
76
|
* interaction command takes optional `frame`, `tabId` and `timeoutMs`. A `type` outside the list is
|
|
77
77
|
* `400 UNKNOWN_COMMAND`.
|
|
78
78
|
*/
|
|
@@ -152,7 +152,7 @@ declare const BrowserCommand: ZodObject<{
|
|
|
152
152
|
}, $loose>;
|
|
153
153
|
type BrowserCommand = output<typeof BrowserCommand>;
|
|
154
154
|
/**
|
|
155
|
-
* `POST /v1/browser/sessions
|
|
155
|
+
* `POST /v1/browser/sessions`. The first block is passed to the vendor; `locale`, `timezone`,
|
|
156
156
|
* `geolocation`, `userAgent`, `extraHeaders`, `blockResources`, `device`, `captureDownloads` and `viewport` are
|
|
157
157
|
* synthesised by the `BrowserSession` DO over CDP (the vendor validates none of them). `stealth:'verified'` below the
|
|
158
158
|
* vendor's Scale tier is `409 STEALTH_TIER_UNAVAILABLE`; `viewport` is ignored under it.
|
|
@@ -240,7 +240,7 @@ declare const BrowserSessionInput: ZodObject<{
|
|
|
240
240
|
}, $strip>>;
|
|
241
241
|
}, $strip>;
|
|
242
242
|
type BrowserSessionInput = output<typeof BrowserSessionInput>;
|
|
243
|
-
/** `201` of the create: `liveViewUrl` is
|
|
243
|
+
/** `201` of the create: `liveViewUrl` is the Totalum API-proxied and signed (the vendor URL embeds Totalum's key). */
|
|
244
244
|
declare const BrowserSessionCreated: ZodObject<{
|
|
245
245
|
id: ZodString;
|
|
246
246
|
status: ZodLiteral<"running">;
|
|
@@ -1597,7 +1597,7 @@ type Group<K extends string> = K extends `${infer G}.${infer M}` ? {
|
|
|
1597
1597
|
[P in G]: Record<M, Command>;
|
|
1598
1598
|
} : Record<K, Command>;
|
|
1599
1599
|
type Merge<U> = (U extends unknown ? (u: U) => void : never) extends (u: infer I) => void ? I : never;
|
|
1600
|
-
/** One method per command of
|
|
1600
|
+
/** One method per command of (`goto`, `click`, … `tabs.new`, `network.har`, …), named like the command. */
|
|
1601
1601
|
type BrowserCommands = Merge<Group<BrowserCommandName>>;
|
|
1602
1602
|
type BrowserSession = BrowserCommands & {
|
|
1603
1603
|
readonly id: string;
|
|
@@ -1607,20 +1607,20 @@ type BrowserSession = BrowserCommands & {
|
|
|
1607
1607
|
actions(batch: BrowserCommand[], opts?: {
|
|
1608
1608
|
stopOnError?: boolean;
|
|
1609
1609
|
}): Promise<BrowserCommandResult[]>;
|
|
1610
|
-
/** A declarative program
|
|
1610
|
+
/** A declarative program: the commands plus bounded `repeat`, `if`, `try`, `set` — data, never code. */
|
|
1611
1611
|
program(program: BrowserProgram): Promise<BrowserProgramCreated>;
|
|
1612
1612
|
status(): Promise<BrowserSessionStatus>;
|
|
1613
1613
|
close(): Promise<BrowserSessionClosed>;
|
|
1614
1614
|
};
|
|
1615
1615
|
/**
|
|
1616
|
-
* `totalum.browser`
|
|
1617
|
-
* over HTTPS, so every command works from a Worker
|
|
1616
|
+
* `totalum.browser` over the Totalum API `/v1/browser/*` (scope `browser`): remote browser sessions driven entirely
|
|
1617
|
+
* over HTTPS, so every command works from a Worker. A command's refusal throws `TotalumError` with its frozen
|
|
1618
1618
|
* code (`ACTION_TIMEOUT`, `ACTION_FAILED`, …); `actions()` returns every result instead.
|
|
1619
1619
|
*
|
|
1620
1620
|
* #### Things that still need a CDP connection
|
|
1621
1621
|
*
|
|
1622
1622
|
* Nothing an app needs. Every capability is a command or a create-time option, so it works in a published app. The
|
|
1623
|
-
* list keeps exactly two entries, neither of which an app needs
|
|
1623
|
+
* list keeps exactly two entries, neither of which an app needs:
|
|
1624
1624
|
*
|
|
1625
1625
|
* - Attaching a raw CDP domain listener for a continuous event stream — `network.subscribe` is the push channel for the app case.
|
|
1626
1626
|
* - Driving the session with a third-party Node library's own protocol client (`connectOverCDP`, `puppeteer.connect`).
|
package/dist/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TotalumError } from '../errors.js';
|
|
2
2
|
import { jsonClient, query } from '../http.js';
|
|
3
3
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
4
|
-
/** The frozen 67 (contracts `BROWSER_COMMANDS
|
|
4
|
+
/** The frozen 67 (contracts `BROWSER_COMMANDS`) as a literal, so nothing is imported at runtime. */
|
|
5
5
|
const BROWSER_COMMANDS = [
|
|
6
6
|
...[
|
|
7
7
|
'goto',
|
|
@@ -98,14 +98,14 @@ const POSITIONAL = {
|
|
|
98
98
|
observe: ['instruction'],
|
|
99
99
|
};
|
|
100
100
|
/**
|
|
101
|
-
* `totalum.browser`
|
|
102
|
-
* over HTTPS, so every command works from a Worker
|
|
101
|
+
* `totalum.browser` over the Totalum API `/v1/browser/*` (scope `browser`): remote browser sessions driven entirely
|
|
102
|
+
* over HTTPS, so every command works from a Worker. A command's refusal throws `TotalumError` with its frozen
|
|
103
103
|
* code (`ACTION_TIMEOUT`, `ACTION_FAILED`, …); `actions()` returns every result instead.
|
|
104
104
|
*
|
|
105
105
|
* #### Things that still need a CDP connection
|
|
106
106
|
*
|
|
107
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
|
|
108
|
+
* list keeps exactly two entries, neither of which an app needs:
|
|
109
109
|
*
|
|
110
110
|
* - Attaching a raw CDP domain listener for a continuous event stream — `network.subscribe` is the push channel for the app case.
|
|
111
111
|
* - Driving the session with a third-party Node library's own protocol client (`connectOverCDP`, `puppeteer.connect`).
|
package/dist/cron/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { d as CronJobInput, c as CronJob, e as CronJobPatch } from '../_types/integrations.d-
|
|
2
|
-
export { f as CronRun, g as CronRunsPage } from '../_types/integrations.d-
|
|
3
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
4
|
-
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-
|
|
5
|
-
import '../_types/coerce.d-
|
|
1
|
+
import { d as CronJobInput, c as CronJob, e as CronJobPatch } from '../_types/integrations.d-DL2_rTOs.js';
|
|
2
|
+
export { f as CronRun, g as CronRunsPage } from '../_types/integrations.d-DL2_rTOs.js';
|
|
3
|
+
import { T as TotalumClientOptions } from '../_types/errors.d-BfXTsxYG.js';
|
|
4
|
+
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BfXTsxYG.js';
|
|
5
|
+
import '../_types/coerce.d-DiNiCkat.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* `totalum.cron`
|
|
8
|
+
* `totalum.cron` over the Totalum API `/v1/cron/*` (scope `cron`): HTTP jobs against the project's own host,
|
|
9
9
|
* fired by Totalum's Scheduler; limits per plan (`429 CRON_LIMIT_REACHED {limit, plan}`, `400 INVALID_SCHEDULE
|
|
10
10
|
* {minIntervalSeconds}`). Executions cost nothing. `timezone` (IANA) reads the schedule on that zone's clock, daylight
|
|
11
11
|
* saving included; `pauseAfterFailures` (1–100, default 3; `null` = never) sets how many failed runs in a row pause it.
|
|
@@ -16,10 +16,10 @@ declare function totalumCron(options?: TotalumClientOptions): {
|
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* await cron.create({
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* name: 'daily-report',
|
|
20
|
+
* schedule: '0 8 * * *', // 08:00 in Madrid all year
|
|
21
|
+
* timezone: 'Europe/Madrid',
|
|
22
|
+
* request: { method: 'POST', url: 'https://my-app.totalum-project.com/api/cron/report' },
|
|
23
23
|
* });
|
|
24
24
|
*/
|
|
25
25
|
create: (input: CronJobInput) => Promise<{
|
package/dist/cron/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isTotalumError } from '../errors.js';
|
|
|
2
2
|
import { jsonClient, query } from '../http.js';
|
|
3
3
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
4
4
|
/**
|
|
5
|
-
* `totalum.cron`
|
|
5
|
+
* `totalum.cron` over the Totalum API `/v1/cron/*` (scope `cron`): HTTP jobs against the project's own host,
|
|
6
6
|
* fired by Totalum's Scheduler; limits per plan (`429 CRON_LIMIT_REACHED {limit, plan}`, `400 INVALID_SCHEDULE
|
|
7
7
|
* {minIntervalSeconds}`). Executions cost nothing. `timezone` (IANA) reads the schedule on that zone's clock, daylight
|
|
8
8
|
* saving included; `pauseAfterFailures` (1–100, default 3; `null` = never) sets how many failed runs in a row pause it.
|
|
@@ -17,10 +17,10 @@ export function totalumCron(options = {}) {
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* await cron.create({
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* name: 'daily-report',
|
|
21
|
+
* schedule: '0 8 * * *', // 08:00 in Madrid all year
|
|
22
|
+
* timezone: 'Europe/Madrid',
|
|
23
|
+
* request: { method: 'POST', url: 'https://my-app.totalum-project.com/api/cron/report' },
|
|
24
24
|
* });
|
|
25
25
|
*/
|
|
26
26
|
create: (input) => call('POST', '/v1/cron/jobs', input),
|
package/dist/d1/d1-limits.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { d1Error } from './native-shape.js';
|
|
2
2
|
/**
|
|
3
3
|
* D1's per-statement limits, for the engine that has none of them (Turso, reached by libsql from a Worker): a statement
|
|
4
|
-
* D1 refuses is refused here before it runs, with D1's own words (
|
|
4
|
+
* D1 refuses is refused here before it runs, with D1's own words (measured on production D1 and
|
|
5
5
|
* Miniflare). So an app built and tried against D1 — `npm run dev` is always a local D1 — behaves the same once its
|
|
6
6
|
* project moved to Turso. A pattern built at run time (`LIKE '%' || ? || '%'`) cannot be measured before it runs and is
|
|
7
7
|
* not checked.
|
package/dist/d1/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TotalumError } from '../errors.js';
|
|
2
2
|
/**
|
|
3
|
-
* The database `TotalumError
|
|
3
|
+
* The database `TotalumError`: `message` is `D1_ERROR: …`-shaped so it reads like a native failure —
|
|
4
4
|
* byte-identical to the binding's message when the failure is SQLite's.
|
|
5
5
|
*/
|
|
6
6
|
export class TotalumD1Error extends TotalumError {
|
|
@@ -13,7 +13,7 @@ export class TotalumD1Error extends TotalumError {
|
|
|
13
13
|
return new TotalumD1Error(errorCode, `D1_ERROR: ${errorCode}: ${message}`);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* SQLite's own failure, as the binding throws it
|
|
16
|
+
* SQLite's own failure, as the binding throws it: `name` `Error`, `message` `D1_ERROR: <sqlite>`, `cause`
|
|
17
17
|
* an `Error` with SQLite's words — so `String(err)`, `err.message` and `String(err.cause)` read the same on every path.
|
|
18
18
|
* Still a `TotalumD1Error` (`errorCode` `SQL_ERROR`) for code that checks.
|
|
19
19
|
*/
|
|
@@ -33,7 +33,7 @@ export class TotalumD1Error extends TotalumError {
|
|
|
33
33
|
});
|
|
34
34
|
return e;
|
|
35
35
|
}
|
|
36
|
-
/** The
|
|
36
|
+
/** The Totalum API error envelope → typed error; `SQL_ERROR` is rebuilt as the binding's own error from `sqliteMessage`. */
|
|
37
37
|
static fromWire(errors, status, requestId) {
|
|
38
38
|
const details = isRecord(errors.errorDetails) ? errors.errorDetails : undefined;
|
|
39
39
|
const sqlite = details?.['sqliteMessage'];
|
package/dist/d1/https.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TotalumD1Error } from './errors.js';
|
|
2
2
|
import { bindable, pickFirst } from './sql.js';
|
|
3
3
|
/**
|
|
4
|
-
* The wire headers the driver sends, as literals so the published package has no runtime dependency (
|
|
4
|
+
* The wire headers the driver sends, as literals so the published package has no runtime dependency (
|
|
5
5
|
* §1); `satisfies` over contracts' `as const` object fails the build if either side ever drifts.
|
|
6
6
|
*/
|
|
7
7
|
const HEADERS = {
|
|
@@ -9,7 +9,7 @@ const HEADERS = {
|
|
|
9
9
|
migrate: 'x-totalum-migrate',
|
|
10
10
|
migrateDestructive: 'x-totalum-migrate-destructive',
|
|
11
11
|
};
|
|
12
|
-
/** The `D1Database` half that speaks `POST /v1/db/query|batch` (
|
|
12
|
+
/** The `D1Database` half that speaks `POST /v1/db/query|batch` (contracts `db.ts`). */
|
|
13
13
|
export function httpsExecutor(config) {
|
|
14
14
|
const headers = {
|
|
15
15
|
authorization: `Bearer ${config.key}`,
|
|
@@ -86,7 +86,7 @@ export function httpsExecutor(config) {
|
|
|
86
86
|
},
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
/** Bytes travel as `{ $bytes: base64 }
|
|
89
|
+
/** Bytes travel as `{ $bytes: base64 }`; every other bindable value is JSON already. */
|
|
90
90
|
function encodeParam(value) {
|
|
91
91
|
if (value instanceof ArrayBuffer)
|
|
92
92
|
return { $bytes: toBase64(new Uint8Array(value)) };
|
package/dist/d1/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-BfXTsxYG.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-BfXTsxYG.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Cloudflare's `D1Database` surface, re-declared structurally so an app needs no Cloudflare types to compile
|
|
7
|
-
* and `drizzle-orm/d1` accepts the object
|
|
7
|
+
* and `drizzle-orm/d1` accepts the object. `D1Meta` is Cloudflare's own interface
|
|
8
8
|
* (`size_after` required); the contracts wire shape is looser and every value here satisfies it (type-tested).
|
|
9
9
|
*/
|
|
10
10
|
type D1Meta = {
|
|
@@ -55,7 +55,7 @@ interface D1Database {
|
|
|
55
55
|
interface TotalumD1Options extends TotalumClientOptions {
|
|
56
56
|
/** `'migrate'` (scripts/migrate.ts only) sends `x-totalum-migrate: 1` and enables `exec()`; default `'query'`. */
|
|
57
57
|
mode?: 'query' | 'migrate';
|
|
58
|
-
/** Migrate mode only: sends `x-totalum-migrate-destructive: 1
|
|
58
|
+
/** Migrate mode only: sends `x-totalum-migrate-destructive: 1`. */
|
|
59
59
|
destructive?: boolean;
|
|
60
60
|
/** An explicit binding wins over detection (plain Workers: `env.TOTALUM_DB`; tests: a Miniflare D1). */
|
|
61
61
|
binding?: D1Database;
|
|
@@ -63,12 +63,12 @@ interface TotalumD1Options extends TotalumClientOptions {
|
|
|
63
63
|
transport?: 'auto' | 'https';
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/** The client-side codes the driver throws
|
|
66
|
+
/** The client-side codes the driver throws, 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
68
|
/** @deprecated Since 1.0.0: use `TotalumErrorCode` (the same type). */
|
|
69
69
|
type TotalumD1ErrorCode = TotalumErrorCode;
|
|
70
70
|
/**
|
|
71
|
-
* The database `TotalumError
|
|
71
|
+
* The database `TotalumError`: `message` is `D1_ERROR: …`-shaped so it reads like a native failure —
|
|
72
72
|
* byte-identical to the binding's message when the failure is SQLite's.
|
|
73
73
|
*/
|
|
74
74
|
declare class TotalumD1Error extends TotalumError {
|
|
@@ -81,7 +81,7 @@ declare class TotalumD1Error extends TotalumError {
|
|
|
81
81
|
/** A client-side refusal (`D1_ERROR: <code>: <message>`). */
|
|
82
82
|
static client(errorCode: TotalumD1ClientCode | 'EXEC_REQUIRES_MIGRATE_MODE', message: string): TotalumD1Error;
|
|
83
83
|
/**
|
|
84
|
-
* SQLite's own failure, as the binding throws it
|
|
84
|
+
* SQLite's own failure, as the binding throws it: `name` `Error`, `message` `D1_ERROR: <sqlite>`, `cause`
|
|
85
85
|
* an `Error` with SQLite's words — so `String(err)`, `err.message` and `String(err.cause)` read the same on every path.
|
|
86
86
|
* Still a `TotalumD1Error` (`errorCode` `SQL_ERROR`) for code that checks.
|
|
87
87
|
*/
|
|
@@ -90,7 +90,7 @@ declare class TotalumD1Error extends TotalumError {
|
|
|
90
90
|
details?: Record<string, unknown>;
|
|
91
91
|
requestId?: string;
|
|
92
92
|
}): TotalumD1Error;
|
|
93
|
-
/** The
|
|
93
|
+
/** The Totalum API error envelope → typed error; `SQL_ERROR` is rebuilt as the binding's own error from `sqliteMessage`. */
|
|
94
94
|
static fromWire(errors: ErrorBody, status: number, requestId: string | undefined): TotalumD1Error;
|
|
95
95
|
}
|
|
96
96
|
declare function isTotalumD1Error(e: unknown): e is TotalumD1Error;
|
|
@@ -98,12 +98,12 @@ declare function isTotalumD1Error(e: unknown): e is TotalumD1Error;
|
|
|
98
98
|
/** Set on every mutating response; while the browser holds it, its reads go to the primary (read-your-writes). */
|
|
99
99
|
declare const READ_YOUR_WRITES_COOKIE = "__tlm_d1_w";
|
|
100
100
|
/**
|
|
101
|
-
* Runs one request of a Worker with a replicated D1
|
|
101
|
+
* Runs one request of a Worker with a replicated D1: a `GET`/`HEAD` reads through a
|
|
102
102
|
* `first-unconstrained` session — the nearest replica — unless the browser wrote in the last 10 s; any other method
|
|
103
103
|
* uses the plain binding (writes go to the primary; measured faster than any session) and its response sets the short
|
|
104
104
|
* cookie that sends that browser's next reads to the primary. A replica read that takes over `REPLICA_READ_TIMEOUT_MS`
|
|
105
105
|
* is answered by the primary instead, and the rest of that request reads the primary. A mutation's pure read the primary
|
|
106
|
-
* does not answer in that time is asked again on the primary (
|
|
106
|
+
* does not answer in that time is asked again on the primary (one call stalled while the database answered
|
|
107
107
|
* others; a sign-up waited on its first SELECT until the Worker was cancelled). `run` receives the env to hand to the
|
|
108
108
|
* app, whose `totalumD1()` reads `TOTALUM_DB` from it on every statement. No D1 binding (Turso, a laptop): `run(env)`
|
|
109
109
|
* unchanged.
|
|
@@ -111,9 +111,9 @@ declare const READ_YOUR_WRITES_COOKIE = "__tlm_d1_w";
|
|
|
111
111
|
declare function withTotalumSession<E extends object>(request: Request, env: E, run: (env: E) => Promise<Response>): Promise<Response>;
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* A `D1Database` for the project's own database wherever the code runs
|
|
114
|
+
* A `D1Database` for the project's own database wherever the code runs: the bound
|
|
115
115
|
* `TOTALUM_DB` inside a Worker, the libsql adapter when the environment moved to Turso, the local D1 that
|
|
116
|
-
* `initOpenNextCloudflareForDev()` binds under `next dev`, and an HTTPS client to
|
|
116
|
+
* `initOpenNextCloudflareForDev()` binds under `next dev`, and an HTTPS client to the Totalum API everywhere else.
|
|
117
117
|
* Detection happens on the first statement, never at call time (§3.1).
|
|
118
118
|
*/
|
|
119
119
|
declare function totalumD1(options?: TotalumD1Options): D1Database;
|
package/dist/d1/index.js
CHANGED
|
@@ -8,9 +8,9 @@ export { TotalumError, isTotalumError } from '../errors.js';
|
|
|
8
8
|
export { TotalumD1Error, isTotalumD1Error } from './errors.js';
|
|
9
9
|
export { READ_YOUR_WRITES_COOKIE, withTotalumSession } from './session.js';
|
|
10
10
|
/**
|
|
11
|
-
* A `D1Database` for the project's own database wherever the code runs
|
|
11
|
+
* A `D1Database` for the project's own database wherever the code runs: the bound
|
|
12
12
|
* `TOTALUM_DB` inside a Worker, the libsql adapter when the environment moved to Turso, the local D1 that
|
|
13
|
-
* `initOpenNextCloudflareForDev()` binds under `next dev`, and an HTTPS client to
|
|
13
|
+
* `initOpenNextCloudflareForDev()` binds under `next dev`, and an HTTPS client to the Totalum API everywhere else.
|
|
14
14
|
* Detection happens on the first statement, never at call time (§3.1).
|
|
15
15
|
*/
|
|
16
16
|
export function totalumD1(options = {}) {
|