@tinycloud/sdk-services 3.11.0 → 3.12.0-beta.16
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-Ma2MwJAd.d.ts → BaseService-BRDG69KR.d.ts} +1 -1
- package/dist/{BaseService-O0iyuFLk.d.cts → BaseService-CdBkfPGE.d.cts} +1 -1
- package/dist/{IHooksService-4QNODVy6.d.cts → IHooksService-C9p3stsB.d.cts} +1 -1
- package/dist/{IHooksService-CvTpJbQD.d.ts → IHooksService-D6eyZat1.d.ts} +1 -1
- package/dist/{ISQLService-Aly1CBsW.d.ts → ISQLService-B_4KcGA-.d.ts} +1 -1
- package/dist/{ISQLService-BOgWzHLT.d.cts → ISQLService-C6nNpcls.d.cts} +1 -1
- package/dist/context.cjs +4 -0
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.js +4 -0
- package/dist/context.js.map +1 -1
- package/dist/encryption/index.cjs +276 -14
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +26 -28
- package/dist/encryption/index.d.ts +26 -28
- package/dist/encryption/index.js +268 -14
- package/dist/encryption/index.js.map +1 -1
- package/dist/encryption/named-keys.cjs +225 -14
- package/dist/encryption/named-keys.cjs.map +1 -1
- package/dist/encryption/named-keys.d.cts +7 -2
- package/dist/encryption/named-keys.d.ts +7 -2
- package/dist/encryption/named-keys.js +225 -14
- package/dist/encryption/named-keys.js.map +1 -1
- package/dist/encryption/resource.cjs.map +1 -1
- package/dist/encryption/resource.js.map +1 -1
- package/dist/feed/index.cjs +4 -0
- package/dist/feed/index.cjs.map +1 -1
- package/dist/feed/index.d.cts +3 -3
- package/dist/feed/index.d.ts +3 -3
- package/dist/feed/index.js +4 -0
- package/dist/feed/index.js.map +1 -1
- package/dist/index.cjs +523 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +513 -29
- 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 +48 -11
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +5 -5
- package/dist/kv/index.d.ts +5 -5
- package/dist/kv/index.js +48 -11
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/index.cjs +39 -8
- 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 +38 -7
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/{scope-DEgc9f-W.d.cts → scope-DtcbyRKY.d.cts} +1 -1
- package/dist/{scope-BZr0QwxX.d.ts → scope-J20PQP3u.d.ts} +1 -1
- package/dist/sql/index.cjs +36 -0
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +4 -4
- package/dist/sql/index.d.ts +4 -4
- package/dist/sql/index.js +36 -0
- package/dist/sql/index.js.map +1 -1
- package/dist/telemetry/requestLog.cjs +4 -0
- package/dist/telemetry/requestLog.cjs.map +1 -1
- package/dist/telemetry/requestLog.d.cts +1 -1
- package/dist/telemetry/requestLog.d.ts +1 -1
- package/dist/telemetry/requestLog.js +4 -0
- package/dist/telemetry/requestLog.js.map +1 -1
- package/dist/{types-D4XbIfFJ.d.cts → types-DfqNz9Nu.d.cts} +135 -6
- package/dist/{types-CSd0RYir.d.ts → types-DjAP8dve.d.cts} +4 -0
- package/dist/{types-CSd0RYir.d.cts → types-DjAP8dve.d.ts} +4 -0
- package/dist/{types-Bf91gup6.d.ts → types-Nvi_RckJ.d.ts} +135 -6
- package/package.json +4 -1
package/dist/kv/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as BaseService } from '../BaseService-
|
|
2
|
-
import { f as Result, c as IService } from '../types-
|
|
3
|
-
import { aI as KVGetOptions, aN as KVResponse, aB as KVBatchReadResponse, aM as KVPutOptions, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aK as KVListOptions, aL as KVListResponse, aE as KVChangesOptions, aF as KVChangesResponse, aH as KVDeleteOptions, aJ as KVHeadOptions, aG as KVCreateSignedReadUrlOptions, aQ as KVSignedReadUrlResponse, aP as KVServiceConfig, c as KVReadThrough } from '../scope-
|
|
4
|
-
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, aC as KVChange, aD as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aO as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, w as PurgeTarget, z as ReplicaAuthorityState, H as ReplicaCoverage, N as ReplicaDevice, X as ReplicaGatedHandle, _ as ReplicaGrantInfo, a0 as ReplicaInspectedStatus, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from '../scope-
|
|
1
|
+
import { B as BaseService } from '../BaseService-CdBkfPGE.cjs';
|
|
2
|
+
import { f as Result, c as IService } from '../types-DjAP8dve.cjs';
|
|
3
|
+
import { aI as KVGetOptions, aN as KVResponse, aB as KVBatchReadResponse, aM as KVPutOptions, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aK as KVListOptions, aL as KVListResponse, aE as KVChangesOptions, aF as KVChangesResponse, aH as KVDeleteOptions, aJ as KVHeadOptions, aG as KVCreateSignedReadUrlOptions, aQ as KVSignedReadUrlResponse, aP as KVServiceConfig, c as KVReadThrough } from '../scope-DtcbyRKY.cjs';
|
|
4
|
+
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, aC as KVChange, aD as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aO as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, w as PurgeTarget, z as ReplicaAuthorityState, H as ReplicaCoverage, N as ReplicaDevice, X as ReplicaGatedHandle, _ as ReplicaGrantInfo, a0 as ReplicaInspectedStatus, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from '../scope-DtcbyRKY.cjs';
|
|
5
5
|
export { kvPrefixCovers } from './replication/prefix.cjs';
|
|
6
6
|
import './replication/contractConstants.cjs';
|
|
7
7
|
import './replication/grantPolicyConstants.cjs';
|
|
@@ -550,7 +550,7 @@ declare class KVService extends BaseService implements IKVService {
|
|
|
550
550
|
private readThrough;
|
|
551
551
|
private readThroughReady;
|
|
552
552
|
/** Delay KV routing until an asynchronously loaded read-through is attached. */
|
|
553
|
-
setReadThroughReady(ready: Promise<unknown>): void;
|
|
553
|
+
setReadThroughReady(ready: Promise<unknown> | (() => Promise<unknown>)): void;
|
|
554
554
|
/**
|
|
555
555
|
* Create a new KVService instance.
|
|
556
556
|
*
|
package/dist/kv/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as BaseService } from '../BaseService-
|
|
2
|
-
import { f as Result, c as IService } from '../types-
|
|
3
|
-
import { aI as KVGetOptions, aN as KVResponse, aB as KVBatchReadResponse, aM as KVPutOptions, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aK as KVListOptions, aL as KVListResponse, aE as KVChangesOptions, aF as KVChangesResponse, aH as KVDeleteOptions, aJ as KVHeadOptions, aG as KVCreateSignedReadUrlOptions, aQ as KVSignedReadUrlResponse, aP as KVServiceConfig, c as KVReadThrough } from '../scope-
|
|
4
|
-
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, aC as KVChange, aD as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aO as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, w as PurgeTarget, z as ReplicaAuthorityState, H as ReplicaCoverage, N as ReplicaDevice, X as ReplicaGatedHandle, _ as ReplicaGrantInfo, a0 as ReplicaInspectedStatus, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from '../scope-
|
|
1
|
+
import { B as BaseService } from '../BaseService-BRDG69KR.js';
|
|
2
|
+
import { f as Result, c as IService } from '../types-DjAP8dve.js';
|
|
3
|
+
import { aI as KVGetOptions, aN as KVResponse, aB as KVBatchReadResponse, aM as KVPutOptions, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aK as KVListOptions, aL as KVListResponse, aE as KVChangesOptions, aF as KVChangesResponse, aH as KVDeleteOptions, aJ as KVHeadOptions, aG as KVCreateSignedReadUrlOptions, aQ as KVSignedReadUrlResponse, aP as KVServiceConfig, c as KVReadThrough } from '../scope-J20PQP3u.js';
|
|
4
|
+
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, aC as KVChange, aD as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aO as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, w as PurgeTarget, z as ReplicaAuthorityState, H as ReplicaCoverage, N as ReplicaDevice, X as ReplicaGatedHandle, _ as ReplicaGrantInfo, a0 as ReplicaInspectedStatus, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from '../scope-J20PQP3u.js';
|
|
5
5
|
export { kvPrefixCovers } from './replication/prefix.js';
|
|
6
6
|
import './replication/contractConstants.js';
|
|
7
7
|
import './replication/grantPolicyConstants.js';
|
|
@@ -550,7 +550,7 @@ declare class KVService extends BaseService implements IKVService {
|
|
|
550
550
|
private readThrough;
|
|
551
551
|
private readThroughReady;
|
|
552
552
|
/** Delay KV routing until an asynchronously loaded read-through is attached. */
|
|
553
|
-
setReadThroughReady(ready: Promise<unknown>): void;
|
|
553
|
+
setReadThroughReady(ready: Promise<unknown> | (() => Promise<unknown>)): void;
|
|
554
554
|
/**
|
|
555
555
|
* Create a new KVService instance.
|
|
556
556
|
*
|
package/dist/kv/index.js
CHANGED
|
@@ -10,6 +10,10 @@ var ErrorCodes = {
|
|
|
10
10
|
/** HTTP 401: a delegation the cited one rests on was revoked. */
|
|
11
11
|
AUTH_DELEGATION_ANCESTOR_REVOKED: "AUTH_DELEGATION_ANCESTOR_REVOKED",
|
|
12
12
|
NETWORK_ERROR: "NETWORK_ERROR",
|
|
13
|
+
NODE_NOT_RESPONDING: "NODE_NOT_RESPONDING",
|
|
14
|
+
NODE_IDENTITY_MISMATCH: "NODE_IDENTITY_MISMATCH",
|
|
15
|
+
PARTIAL_NODE_WRITE: "PARTIAL_NODE_WRITE",
|
|
16
|
+
RESOURCE_NOT_ROUTED: "RESOURCE_NOT_ROUTED",
|
|
13
17
|
TIMEOUT: "TIMEOUT",
|
|
14
18
|
ABORTED: "ABORTED",
|
|
15
19
|
INVALID_INPUT: "INVALID_INPUT",
|
|
@@ -161,6 +165,34 @@ function parseNetworkId(networkId) {
|
|
|
161
165
|
return { networkId, ownerDid, name };
|
|
162
166
|
}
|
|
163
167
|
|
|
168
|
+
// src/resourceRouting.ts
|
|
169
|
+
var ROUTING_FAILURE_CODES = {
|
|
170
|
+
NODE_NOT_RESPONDING: true,
|
|
171
|
+
PARTIAL_NODE_WRITE: true,
|
|
172
|
+
NODE_IDENTITY_MISMATCH: true,
|
|
173
|
+
RESOURCE_NOT_ROUTED: true,
|
|
174
|
+
DECRYPTION_DEPENDENCY_UNAVAILABLE: true,
|
|
175
|
+
registry_unavailable: true,
|
|
176
|
+
node_not_found: true,
|
|
177
|
+
node_registry_entry_exists: true
|
|
178
|
+
};
|
|
179
|
+
function isRoutingFailureCode(code) {
|
|
180
|
+
return Object.prototype.hasOwnProperty.call(ROUTING_FAILURE_CODES, code);
|
|
181
|
+
}
|
|
182
|
+
function routingFailure(error) {
|
|
183
|
+
if (typeof error === "object" && error !== null && "code" in error && "message" in error && typeof error.code === "string" && typeof error.message === "string" && isRoutingFailureCode(error.code)) {
|
|
184
|
+
const candidate = "meta" in error ? error.meta : void 0;
|
|
185
|
+
let meta = typeof candidate === "object" && candidate !== null && !Array.isArray(candidate) ? candidate : void 0;
|
|
186
|
+
if (error.code === "NODE_NOT_RESPONDING" && "hosts" in error && Array.isArray(error.hosts)) {
|
|
187
|
+
meta = { ...meta, hosts: error.hosts };
|
|
188
|
+
} else if (error.code === "PARTIAL_NODE_WRITE" && "succeeded" in error && Array.isArray(error.succeeded) && "failed" in error && Array.isArray(error.failed)) {
|
|
189
|
+
meta = { ...meta, succeeded: error.succeeded, failed: error.failed };
|
|
190
|
+
}
|
|
191
|
+
return { code: error.code, message: error.message, ...error instanceof Error ? { cause: error } : {}, ...meta ? { meta } : {} };
|
|
192
|
+
}
|
|
193
|
+
return void 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
164
196
|
// src/errors.ts
|
|
165
197
|
function parsePermissionHint(value) {
|
|
166
198
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
@@ -434,6 +466,8 @@ function storageRejectionError(service, status, meta, responseText) {
|
|
|
434
466
|
return status === 402 ? storageQuotaExceededError(service, STORAGE_FULL_MESSAGE, quotaMeta) : storageLimitReachedError(service, STORAGE_WRITE_TOO_LARGE_MESSAGE, quotaMeta);
|
|
435
467
|
}
|
|
436
468
|
function wrapError(service, error, defaultCode = ErrorCodes.NETWORK_ERROR) {
|
|
469
|
+
const routing = routingFailure(error);
|
|
470
|
+
if (routing) return { ...routing, service };
|
|
437
471
|
if (error instanceof Error) {
|
|
438
472
|
if (isRequestTimeoutError(error)) {
|
|
439
473
|
return timeoutError(service, error.timeoutMs, error);
|
|
@@ -945,11 +979,15 @@ var KVService = class extends BaseService {
|
|
|
945
979
|
}
|
|
946
980
|
/** Delay KV routing until an asynchronously loaded read-through is attached. */
|
|
947
981
|
setReadThroughReady(ready) {
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
982
|
+
const start = () => {
|
|
983
|
+
if (typeof ready === "function") ready = Promise.resolve().then(ready);
|
|
984
|
+
const finish = () => {
|
|
985
|
+
if (this.readThroughReady === start) this.readThroughReady = null;
|
|
986
|
+
};
|
|
987
|
+
return ready.then(finish, finish);
|
|
988
|
+
};
|
|
989
|
+
this.readThroughReady = start;
|
|
990
|
+
if (typeof ready !== "function") void start();
|
|
953
991
|
}
|
|
954
992
|
/**
|
|
955
993
|
* Get the service configuration.
|
|
@@ -1196,7 +1234,6 @@ var KVService = class extends BaseService {
|
|
|
1196
1234
|
return aligned;
|
|
1197
1235
|
}
|
|
1198
1236
|
async batchRead(keys, action, options) {
|
|
1199
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
1200
1237
|
if (!this.requireAuth()) return err(authRequiredError("kv"));
|
|
1201
1238
|
if (keys.length === 0) return ok({ results: [], count: 0 });
|
|
1202
1239
|
if (keys.length > MAX_KV_BATCH_READ_ITEMS) {
|
|
@@ -1447,7 +1484,7 @@ var KVService = class extends BaseService {
|
|
|
1447
1484
|
*/
|
|
1448
1485
|
async get(key, options) {
|
|
1449
1486
|
return this.withTelemetry("get", key, async () => {
|
|
1450
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
1487
|
+
if (options?.source !== "network" && this.readThroughReady !== null) await this.readThroughReady();
|
|
1451
1488
|
if (!this.requireAuth()) {
|
|
1452
1489
|
return err(authRequiredError("kv"));
|
|
1453
1490
|
}
|
|
@@ -1566,7 +1603,7 @@ var KVService = class extends BaseService {
|
|
|
1566
1603
|
*/
|
|
1567
1604
|
async put(key, value, options) {
|
|
1568
1605
|
return this.withTelemetry("put", key, async () => {
|
|
1569
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
1606
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
1570
1607
|
if (!this.requireAuth()) {
|
|
1571
1608
|
return err(authRequiredError("kv"));
|
|
1572
1609
|
}
|
|
@@ -1651,7 +1688,7 @@ var KVService = class extends BaseService {
|
|
|
1651
1688
|
*/
|
|
1652
1689
|
async batchPut(items, options) {
|
|
1653
1690
|
return this.withTelemetry("batchPut", String(items.length), async () => {
|
|
1654
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
1691
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
1655
1692
|
if (!this.requireAuth()) {
|
|
1656
1693
|
return err(authRequiredError("kv"));
|
|
1657
1694
|
}
|
|
@@ -1850,7 +1887,7 @@ var KVService = class extends BaseService {
|
|
|
1850
1887
|
*/
|
|
1851
1888
|
async list(options) {
|
|
1852
1889
|
return this.withTelemetry("list", options?.prefix, async () => {
|
|
1853
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
1890
|
+
if (options?.source !== "network" && this.readThroughReady !== null) await this.readThroughReady();
|
|
1854
1891
|
if (!this.requireAuth()) {
|
|
1855
1892
|
return err(authRequiredError("kv"));
|
|
1856
1893
|
}
|
|
@@ -2138,7 +2175,7 @@ var KVService = class extends BaseService {
|
|
|
2138
2175
|
*/
|
|
2139
2176
|
async delete(key, options) {
|
|
2140
2177
|
return this.withTelemetry("delete", key, async () => {
|
|
2141
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
2178
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
2142
2179
|
if (!this.requireAuth()) {
|
|
2143
2180
|
return err(authRequiredError("kv"));
|
|
2144
2181
|
}
|