@tinycloud/sdk-services 3.3.0-beta.11 → 3.3.0-beta.39
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/{BaseService-Cc6Ueicm.d.cts → BaseService-BhfKzKke.d.cts} +5 -1
- package/dist/{BaseService-DOdXd7sr.d.ts → BaseService-x4AFZiEa.d.ts} +5 -1
- package/dist/encryption/index.cjs +18 -5
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +2 -2
- package/dist/encryption/index.d.ts +2 -2
- package/dist/encryption/index.js +18 -5
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +660 -651
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -10
- package/dist/index.d.ts +17 -10
- package/dist/index.js +660 -651
- package/dist/index.js.map +1 -1
- package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
- package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
- package/dist/kv/index.cjs +72 -80
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +4 -5
- package/dist/kv/index.d.ts +4 -5
- package/dist/kv/index.js +72 -80
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/index.cjs +6 -5
- package/dist/kv/replication/index.cjs.map +1 -1
- package/dist/kv/replication/index.d.cts +3 -3
- package/dist/kv/replication/index.d.ts +3 -3
- package/dist/kv/replication/index.js +6 -5
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/{scope-B-m6cKH-.d.ts → scope-BHTkk5Yk.d.ts} +13 -2
- package/dist/{scope-B7oeKdLM.d.cts → scope-DMhalRFn.d.cts} +13 -2
- package/dist/sql/index.cjs +30 -16
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +2 -2
- package/dist/sql/index.d.ts +2 -2
- package/dist/sql/index.js +30 -16
- package/dist/sql/index.js.map +1 -1
- package/dist/{types-BjH0ZtGy.d.cts → types-eVS1Whuf.d.cts} +24 -4
- package/dist/{types-BjH0ZtGy.d.ts → types-eVS1Whuf.d.ts} +24 -4
- package/package.json +2 -2
|
@@ -81,7 +81,7 @@ declare const ErrorCodes: {
|
|
|
81
81
|
readonly ABORTED: "ABORTED";
|
|
82
82
|
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
83
83
|
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
84
|
-
/** HTTP 503 `sql_busy:<stage>` / `unavailable_retryable`: nothing was applied; retry after `meta.retryAfterMs`. */
|
|
84
|
+
/** HTTP 503 `sql_busy:<stage>` / `unavailable_retryable`/`read_audit_busy`: nothing was applied; retry after `meta.retryAfterMs`. */
|
|
85
85
|
readonly NODE_BUSY: "NODE_BUSY";
|
|
86
86
|
/** HTTP 503 `request_timeout`: the node's deadline passed before any write began; nothing was applied. */
|
|
87
87
|
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
@@ -211,6 +211,17 @@ interface FetchResponse {
|
|
|
211
211
|
text(): Promise<string>;
|
|
212
212
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
213
213
|
blob(): Promise<Blob>;
|
|
214
|
+
/** Present on standard Responses; the retry reads a clone so the caller's body stays intact. */
|
|
215
|
+
clone?(): FetchResponse;
|
|
216
|
+
/** Set by `ServiceContext.invokeWithRetry` on the response it returns: how many requests it took. */
|
|
217
|
+
retry?: RetryStats;
|
|
218
|
+
}
|
|
219
|
+
/** What automatic retry cost one request, so latency can be split from backoff. */
|
|
220
|
+
interface RetryStats {
|
|
221
|
+
/** Requests sent, including the first (1 means no retry). */
|
|
222
|
+
attempts: number;
|
|
223
|
+
/** Total milliseconds spent waiting between attempts. */
|
|
224
|
+
backoffMs: number;
|
|
214
225
|
}
|
|
215
226
|
/**
|
|
216
227
|
* Fetch function signature - allows for custom fetch implementations.
|
|
@@ -218,7 +229,12 @@ interface FetchResponse {
|
|
|
218
229
|
*/
|
|
219
230
|
type FetchFunction = (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
|
|
220
231
|
/**
|
|
221
|
-
*
|
|
232
|
+
* Automatic retry of node responses that guarantee nothing was applied
|
|
233
|
+
* (`NODE_BUSY`, `REQUEST_TIMEOUT`). Applied once, in the service context's
|
|
234
|
+
* `invokeWithRetry`, which re-mints the signed invocation per attempt. Backoff
|
|
235
|
+
* is full-jitter: each delay is uniform in `[0, step]`, where
|
|
236
|
+
* `step` is the strategy's delay capped at `maxDelayMs`. A node `Retry-After`
|
|
237
|
+
* replaces the delay. Opt out with `{ maxAttempts: 1 }`.
|
|
222
238
|
*/
|
|
223
239
|
interface RetryPolicy {
|
|
224
240
|
/** Maximum number of attempts (including initial) */
|
|
@@ -229,8 +245,10 @@ interface RetryPolicy {
|
|
|
229
245
|
baseDelayMs: number;
|
|
230
246
|
/** Maximum delay in milliseconds between retries */
|
|
231
247
|
maxDelayMs: number;
|
|
232
|
-
/**
|
|
248
|
+
/** Node error codes that trigger a retry. `OUTCOME_UNKNOWN` is never retried. */
|
|
233
249
|
retryableErrors: string[];
|
|
250
|
+
/** Total time budget for all attempts and waits, in milliseconds. Unset: no cap. */
|
|
251
|
+
maxTotalMs?: number;
|
|
234
252
|
}
|
|
235
253
|
/**
|
|
236
254
|
* Default retry policy.
|
|
@@ -279,6 +297,8 @@ interface IServiceContext {
|
|
|
279
297
|
readonly invokeAny?: InvokeAnyFunction;
|
|
280
298
|
/** Fetch function (defaults to globalThis.fetch) */
|
|
281
299
|
readonly fetch: FetchFunction;
|
|
300
|
+
/** Send a signed invocation, retrying a busy node; `build` re-signs per attempt. Absent: sends once. */
|
|
301
|
+
invokeWithRetry?(url: string, build: () => FetchRequestInit | Promise<FetchRequestInit>): Promise<FetchResponse>;
|
|
282
302
|
/** Available TinyCloud host URLs */
|
|
283
303
|
readonly hosts: string[];
|
|
284
304
|
/** Get another registered service by name */
|
|
@@ -384,4 +404,4 @@ declare function serviceError(code: string, message: string, service: string, op
|
|
|
384
404
|
meta?: Record<string, unknown>;
|
|
385
405
|
}): ServiceError;
|
|
386
406
|
|
|
387
|
-
export { type EventHandler as E, type
|
|
407
|
+
export { type EventHandler as E, type FetchRequestInit as F, type IService as I, type PermissionHint as P, type Result as R, type ServiceSession as S, type TelemetryConfig as T, type IServiceContext as a, type ServiceError as b, type ServiceHeaders as c, type FetchResponse as d, type RetryStats as e, type FetchFunction as f, type InvokeFunction as g, type InvokeAnyFunction as h, type RetryPolicy as i, type StorageQuotaInfo as j, type ErrorCode as k, ErrorCodes as l, type InvocationFact as m, type InvocationFacts as n, type InvokeAnyEntry as o, type ServiceErrorEvent as p, type ServiceRequestEvent as q, type ServiceResponseEvent as r, type ServiceRetryEvent as s, type TelemetryEventHandler as t, TelemetryEvents as u, type TelemetrySpanEvent as v, defaultRetryPolicy as w, err as x, ok as y, serviceError as z };
|
|
@@ -81,7 +81,7 @@ declare const ErrorCodes: {
|
|
|
81
81
|
readonly ABORTED: "ABORTED";
|
|
82
82
|
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
83
83
|
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
84
|
-
/** HTTP 503 `sql_busy:<stage>` / `unavailable_retryable`: nothing was applied; retry after `meta.retryAfterMs`. */
|
|
84
|
+
/** HTTP 503 `sql_busy:<stage>` / `unavailable_retryable`/`read_audit_busy`: nothing was applied; retry after `meta.retryAfterMs`. */
|
|
85
85
|
readonly NODE_BUSY: "NODE_BUSY";
|
|
86
86
|
/** HTTP 503 `request_timeout`: the node's deadline passed before any write began; nothing was applied. */
|
|
87
87
|
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
@@ -211,6 +211,17 @@ interface FetchResponse {
|
|
|
211
211
|
text(): Promise<string>;
|
|
212
212
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
213
213
|
blob(): Promise<Blob>;
|
|
214
|
+
/** Present on standard Responses; the retry reads a clone so the caller's body stays intact. */
|
|
215
|
+
clone?(): FetchResponse;
|
|
216
|
+
/** Set by `ServiceContext.invokeWithRetry` on the response it returns: how many requests it took. */
|
|
217
|
+
retry?: RetryStats;
|
|
218
|
+
}
|
|
219
|
+
/** What automatic retry cost one request, so latency can be split from backoff. */
|
|
220
|
+
interface RetryStats {
|
|
221
|
+
/** Requests sent, including the first (1 means no retry). */
|
|
222
|
+
attempts: number;
|
|
223
|
+
/** Total milliseconds spent waiting between attempts. */
|
|
224
|
+
backoffMs: number;
|
|
214
225
|
}
|
|
215
226
|
/**
|
|
216
227
|
* Fetch function signature - allows for custom fetch implementations.
|
|
@@ -218,7 +229,12 @@ interface FetchResponse {
|
|
|
218
229
|
*/
|
|
219
230
|
type FetchFunction = (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
|
|
220
231
|
/**
|
|
221
|
-
*
|
|
232
|
+
* Automatic retry of node responses that guarantee nothing was applied
|
|
233
|
+
* (`NODE_BUSY`, `REQUEST_TIMEOUT`). Applied once, in the service context's
|
|
234
|
+
* `invokeWithRetry`, which re-mints the signed invocation per attempt. Backoff
|
|
235
|
+
* is full-jitter: each delay is uniform in `[0, step]`, where
|
|
236
|
+
* `step` is the strategy's delay capped at `maxDelayMs`. A node `Retry-After`
|
|
237
|
+
* replaces the delay. Opt out with `{ maxAttempts: 1 }`.
|
|
222
238
|
*/
|
|
223
239
|
interface RetryPolicy {
|
|
224
240
|
/** Maximum number of attempts (including initial) */
|
|
@@ -229,8 +245,10 @@ interface RetryPolicy {
|
|
|
229
245
|
baseDelayMs: number;
|
|
230
246
|
/** Maximum delay in milliseconds between retries */
|
|
231
247
|
maxDelayMs: number;
|
|
232
|
-
/**
|
|
248
|
+
/** Node error codes that trigger a retry. `OUTCOME_UNKNOWN` is never retried. */
|
|
233
249
|
retryableErrors: string[];
|
|
250
|
+
/** Total time budget for all attempts and waits, in milliseconds. Unset: no cap. */
|
|
251
|
+
maxTotalMs?: number;
|
|
234
252
|
}
|
|
235
253
|
/**
|
|
236
254
|
* Default retry policy.
|
|
@@ -279,6 +297,8 @@ interface IServiceContext {
|
|
|
279
297
|
readonly invokeAny?: InvokeAnyFunction;
|
|
280
298
|
/** Fetch function (defaults to globalThis.fetch) */
|
|
281
299
|
readonly fetch: FetchFunction;
|
|
300
|
+
/** Send a signed invocation, retrying a busy node; `build` re-signs per attempt. Absent: sends once. */
|
|
301
|
+
invokeWithRetry?(url: string, build: () => FetchRequestInit | Promise<FetchRequestInit>): Promise<FetchResponse>;
|
|
282
302
|
/** Available TinyCloud host URLs */
|
|
283
303
|
readonly hosts: string[];
|
|
284
304
|
/** Get another registered service by name */
|
|
@@ -384,4 +404,4 @@ declare function serviceError(code: string, message: string, service: string, op
|
|
|
384
404
|
meta?: Record<string, unknown>;
|
|
385
405
|
}): ServiceError;
|
|
386
406
|
|
|
387
|
-
export { type EventHandler as E, type
|
|
407
|
+
export { type EventHandler as E, type FetchRequestInit as F, type IService as I, type PermissionHint as P, type Result as R, type ServiceSession as S, type TelemetryConfig as T, type IServiceContext as a, type ServiceError as b, type ServiceHeaders as c, type FetchResponse as d, type RetryStats as e, type FetchFunction as f, type InvokeFunction as g, type InvokeAnyFunction as h, type RetryPolicy as i, type StorageQuotaInfo as j, type ErrorCode as k, ErrorCodes as l, type InvocationFact as m, type InvocationFacts as n, type InvokeAnyEntry as o, type ServiceErrorEvent as p, type ServiceRequestEvent as q, type ServiceResponseEvent as r, type ServiceRetryEvent as s, type TelemetryEventHandler as t, TelemetryEvents as u, type TelemetrySpanEvent as v, defaultRetryPolicy as w, err as x, ok as y, serviceError as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/sdk-services",
|
|
3
|
-
"version": "3.3.0-beta.
|
|
3
|
+
"version": "3.3.0-beta.39",
|
|
4
4
|
"description": "TinyCloud SDK Services - Platform-agnostic service implementations",
|
|
5
5
|
"author": "TinyCloud, Inc.",
|
|
6
6
|
"license": "EGPL",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
141
141
|
"@types/node": "^20",
|
|
142
|
-
"@tinycloud/node-sdk-wasm": "1.7.
|
|
142
|
+
"@tinycloud/node-sdk-wasm": "1.7.8-beta.0",
|
|
143
143
|
"tsup": "^8.0.0",
|
|
144
144
|
"typescript": "^5.9.3"
|
|
145
145
|
},
|