Types (totalum-sdk)
The types every module shares: the client options and the error.
#TotalumClientOptions
The options every namespace takes; each one falls back to the same environment variable everywhere.
| Name | Type | Required | Description |
|---|---|---|---|
key | string | no | Project key tlm_pk_…; default TOTALUM_PROJECT_KEY. Server-side only. |
apiUrl | string | no | The Totalum API's URL: default TOTALUM_SDK_API_URL, else https://sdk-api.totalum.app. |
env | 'dev' | 'live' | no | Sent as x-totalum-env on every call (the database it targets, and dev vs live usage); default TOTALUM_ENV, else live. |
#TotalumError
The one error every totalum-sdk call throws: the Totalum API envelope's frozen errorCode, the HTTP
status and details. TotalumD1Error (totalum-sdk/d1) and TotalumWebhookError (totalum-sdk/webhooks)
extend it, so one isTotalumError(e) check covers the whole package.
| Member | Type | Description |
|---|---|---|
name | string | 'TotalumError' (or the subclass's name). |
errorCode | TotalumErrorCode | The frozen error code (FILE_NOT_FOUND, INSUFFICIENT_CREDITS, …): branch on it, never on message. |
status | number | HTTP status; 0 for network errors, 500 for client-side refusals. |
details | Record<string, unknown> | Extra data about the failure (maxBytes, retryAfterMs, the field that failed validation), when any. |
requestId | string | the Totalum API's request id, for support and the logs explorer. |
| Method | Description |
|---|---|
toString() → string | TotalumError [CODE]: message — what a log shows for String(err) (workerd's tail serialises an Error so). |
toJSON() → Record<string, unknown> | Every field a log or Response.json needs (undefined ones drop out); workerd's tail logs an Error through this. |
#TotalumErrorCode
Every code a TotalumError can carry: the Totalum API's frozen codes plus the client-side ones (see Errors).
type TotalumErrorCode = 'SERVICE_UNAUTHORIZED' | 'SERVICE_REPLAY' | 'ACTOR_MISMATCH' | 'PAYLOAD_TOO_LARGE' | 'VALIDATION_ERROR' | 'PROJECT_NOT_FOUND' | 'PROJECT_NOT_READY' | 'OPERATION_IN_PROGRESS' | … // 421 values#isTotalumError type
Whether e is an error thrown by totalum-sdk (TotalumError or a subclass): then e.errorCode, e.status,
e.details and e.requestId are typed.
type isTotalumError = any