@tinycloud/sdk-services 3.2.6-beta.4 → 3.3.0-beta.25
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-1Ug6y7DC.d.cts → BaseService-BhfKzKke.d.cts} +5 -1
- package/dist/{BaseService-Bn07Vudy.d.ts → BaseService-x4AFZiEa.d.ts} +5 -1
- package/dist/encryption/index.cjs +25 -4
- 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 +25 -4
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +959 -808
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -7
- package/dist/index.d.ts +114 -7
- package/dist/index.js +958 -808
- 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 +136 -99
- 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 +136 -99
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/grantPolicy.cjs +82 -0
- package/dist/kv/replication/grantPolicy.cjs.map +1 -0
- package/dist/kv/replication/grantPolicy.d.cts +19 -0
- package/dist/kv/replication/grantPolicy.d.ts +19 -0
- package/dist/kv/replication/grantPolicy.js +50 -0
- package/dist/kv/replication/grantPolicy.js.map +1 -0
- package/dist/kv/replication/index.cjs +576 -132
- 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 +576 -132
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/{scope-BnyVPZ5E.d.ts → scope-9U4gVNFN.d.ts} +312 -7
- package/dist/{scope-CQ5kmHlt.d.cts → scope-BzdcrOZG.d.cts} +312 -7
- package/dist/sql/index.cjs +98 -50
- 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 +98 -50
- package/dist/sql/index.js.map +1 -1
- package/dist/{types-gmdUiorz.d.cts → types-eVS1Whuf.d.cts} +29 -3
- package/dist/{types-gmdUiorz.d.ts → types-eVS1Whuf.d.ts} +29 -3
- package/package.json +16 -2
|
@@ -81,6 +81,12 @@ 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`/`read_audit_busy`: nothing was applied; retry after `meta.retryAfterMs`. */
|
|
85
|
+
readonly NODE_BUSY: "NODE_BUSY";
|
|
86
|
+
/** HTTP 503 `request_timeout`: the node's deadline passed before any write began; nothing was applied. */
|
|
87
|
+
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
88
|
+
/** HTTP 500 `outcome_unknown`: a write may have been applied; read back before retrying a non-idempotent operation. */
|
|
89
|
+
readonly OUTCOME_UNKNOWN: "OUTCOME_UNKNOWN";
|
|
84
90
|
readonly KV_NOT_FOUND: "KV_NOT_FOUND";
|
|
85
91
|
readonly KV_WRITE_FAILED: "KV_WRITE_FAILED";
|
|
86
92
|
readonly KV_PRECONDITION_FAILED: "KV_PRECONDITION_FAILED";
|
|
@@ -205,6 +211,17 @@ interface FetchResponse {
|
|
|
205
211
|
text(): Promise<string>;
|
|
206
212
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
207
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;
|
|
208
225
|
}
|
|
209
226
|
/**
|
|
210
227
|
* Fetch function signature - allows for custom fetch implementations.
|
|
@@ -212,7 +229,12 @@ interface FetchResponse {
|
|
|
212
229
|
*/
|
|
213
230
|
type FetchFunction = (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
|
|
214
231
|
/**
|
|
215
|
-
*
|
|
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 }`.
|
|
216
238
|
*/
|
|
217
239
|
interface RetryPolicy {
|
|
218
240
|
/** Maximum number of attempts (including initial) */
|
|
@@ -223,8 +245,10 @@ interface RetryPolicy {
|
|
|
223
245
|
baseDelayMs: number;
|
|
224
246
|
/** Maximum delay in milliseconds between retries */
|
|
225
247
|
maxDelayMs: number;
|
|
226
|
-
/**
|
|
248
|
+
/** Node error codes that trigger a retry. `OUTCOME_UNKNOWN` is never retried. */
|
|
227
249
|
retryableErrors: string[];
|
|
250
|
+
/** Total time budget for all attempts and waits, in milliseconds. Unset: no cap. */
|
|
251
|
+
maxTotalMs?: number;
|
|
228
252
|
}
|
|
229
253
|
/**
|
|
230
254
|
* Default retry policy.
|
|
@@ -273,6 +297,8 @@ interface IServiceContext {
|
|
|
273
297
|
readonly invokeAny?: InvokeAnyFunction;
|
|
274
298
|
/** Fetch function (defaults to globalThis.fetch) */
|
|
275
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>;
|
|
276
302
|
/** Available TinyCloud host URLs */
|
|
277
303
|
readonly hosts: string[];
|
|
278
304
|
/** Get another registered service by name */
|
|
@@ -378,4 +404,4 @@ declare function serviceError(code: string, message: string, service: string, op
|
|
|
378
404
|
meta?: Record<string, unknown>;
|
|
379
405
|
}): ServiceError;
|
|
380
406
|
|
|
381
|
-
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
|
+
"version": "3.3.0-beta.25",
|
|
4
4
|
"description": "TinyCloud SDK Services - Platform-agnostic service implementations",
|
|
5
5
|
"author": "TinyCloud, Inc.",
|
|
6
6
|
"license": "EGPL",
|
|
@@ -66,6 +66,16 @@
|
|
|
66
66
|
"default": "./dist/kv/replication/grantPolicyTypes.cjs"
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
+
"./kv/replication/grantPolicy": {
|
|
70
|
+
"import": {
|
|
71
|
+
"types": "./dist/kv/replication/grantPolicy.d.ts",
|
|
72
|
+
"default": "./dist/kv/replication/grantPolicy.js"
|
|
73
|
+
},
|
|
74
|
+
"require": {
|
|
75
|
+
"types": "./dist/kv/replication/grantPolicy.d.cts",
|
|
76
|
+
"default": "./dist/kv/replication/grantPolicy.cjs"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
69
79
|
"./kv/replication": {
|
|
70
80
|
"import": {
|
|
71
81
|
"types": "./dist/kv/replication/index.d.ts",
|
|
@@ -108,6 +118,9 @@
|
|
|
108
118
|
],
|
|
109
119
|
"kv/replication/grantPolicyTypes": [
|
|
110
120
|
"dist/kv/replication/grantPolicyTypes.d.ts"
|
|
121
|
+
],
|
|
122
|
+
"kv/replication/grantPolicy": [
|
|
123
|
+
"dist/kv/replication/grantPolicy.d.ts"
|
|
111
124
|
]
|
|
112
125
|
}
|
|
113
126
|
},
|
|
@@ -117,7 +130,8 @@
|
|
|
117
130
|
"scripts": {
|
|
118
131
|
"build": "tsup",
|
|
119
132
|
"clean": "rm -rf dist",
|
|
120
|
-
"test": "bun test"
|
|
133
|
+
"test": "bun test",
|
|
134
|
+
"typecheck:contract": "tsc --noEmit -p tsconfig.contract.json"
|
|
121
135
|
},
|
|
122
136
|
"dependencies": {
|
|
123
137
|
"@tinycloud/bootstrap": "2.8.0",
|