@tinycloud/sdk-services 3.8.0-beta.1 → 3.8.0-beta.18
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-DO7vZ67k.d.ts → BaseService-Ma2MwJAd.d.ts} +1 -1
- package/dist/{BaseService-D-29xShG.d.cts → BaseService-O0iyuFLk.d.cts} +1 -1
- package/dist/IHooksService-4QNODVy6.d.cts +120 -0
- package/dist/IHooksService-CvTpJbQD.d.ts +120 -0
- package/dist/ISQLService-Aly1CBsW.d.ts +242 -0
- package/dist/ISQLService-BOgWzHLT.d.cts +242 -0
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/encryption/index.cjs +80 -7
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +23 -11
- package/dist/encryption/index.d.ts +23 -11
- package/dist/encryption/index.js +79 -7
- package/dist/encryption/index.js.map +1 -1
- package/dist/encryption/named-keys.cjs.map +1 -1
- package/dist/encryption/named-keys.d.cts +2 -2
- package/dist/encryption/named-keys.d.ts +2 -2
- 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 +787 -0
- package/dist/feed/index.cjs.map +1 -0
- package/dist/feed/index.d.cts +176 -0
- package/dist/feed/index.d.ts +176 -0
- package/dist/feed/index.js +739 -0
- package/dist/feed/index.js.map +1 -0
- package/dist/index.cjs +131 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -116
- package/dist/index.d.ts +16 -116
- package/dist/index.js +130 -15
- 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.map +1 -1
- package/dist/kv/index.d.cts +4 -4
- package/dist/kv/index.d.ts +4 -4
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/index.cjs +1 -0
- 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 +1 -0
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/{scope-Cg00IaWk.d.ts → scope-BZr0QwxX.d.ts} +78 -3
- package/dist/{scope-Cjo4O0uO.d.cts → scope-DEgc9f-W.d.cts} +78 -3
- package/dist/sql/index.cjs +21 -6
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +6 -236
- package/dist/sql/index.d.ts +6 -236
- package/dist/sql/index.js +21 -6
- package/dist/sql/index.js.map +1 -1
- package/dist/telemetry/requestLog.d.cts +1 -1
- package/dist/telemetry/requestLog.d.ts +1 -1
- package/dist/{types-BGRzS1ob.d.ts → types-Bf91gup6.d.ts} +7 -2
- package/dist/{types-DAOyIbXu.d.cts → types-CSd0RYir.d.cts} +1 -1
- package/dist/{types-DAOyIbXu.d.ts → types-CSd0RYir.d.ts} +1 -1
- package/dist/{types-B_rbS4XE.d.cts → types-D4XbIfFJ.d.cts} +7 -2
- package/package.json +6 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as RetryStats,
|
|
1
|
+
import { i as RetryStats, f as Result, F as FetchFunction } from './types-CSd0RYir.js';
|
|
2
2
|
import { REPLICA_KV_STORES } from './kv/replication/contractConstants.js';
|
|
3
3
|
import { ReplicaConsentAnchor, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.js';
|
|
4
4
|
|
|
@@ -591,7 +591,9 @@ type ReplicaGateReason =
|
|
|
591
591
|
/** Browser only: the `localStorage` logout marker is set. */
|
|
592
592
|
| "logout_pending"
|
|
593
593
|
/** The gate store itself could not be read; fail closed. */
|
|
594
|
-
| "gate_unavailable"
|
|
594
|
+
| "gate_unavailable"
|
|
595
|
+
/** Browser: replication is configured but no wallet provider can prove the connected account. */
|
|
596
|
+
| "wallet_provider_required";
|
|
595
597
|
/** Shape of every gate refusal error: `Error & { code: "REPLICA_GATED"; gate }`. */
|
|
596
598
|
interface ReplicaGatedError extends Error {
|
|
597
599
|
code: "REPLICA_GATED";
|
|
@@ -877,6 +879,63 @@ interface ReplicaLifecycleGate {
|
|
|
877
879
|
}): Promise<ReplicaEraseReport>;
|
|
878
880
|
/** Outstanding intents; non-empty means status `purgePending: true`. */
|
|
879
881
|
pendingPurge(): Promise<ReplicaPurgeIntent[]>;
|
|
882
|
+
/**
|
|
883
|
+
* Browser only. Under the gate lock, erases pending intents and deletes the whole origin
|
|
884
|
+
* database. Deletes only when nothing live is at stake: the gate is denied (null principal),
|
|
885
|
+
* the gate is behind the persisted deny tombstone, or the logout marker is set with a tombstone.
|
|
886
|
+
* A live or other-account gate is `refused` and left untouched. On a failed delete it sets the
|
|
887
|
+
* logout marker (when a tombstone exists) so `recover` finishes the erase on the next load.
|
|
888
|
+
* Never clears the deny tombstone.
|
|
889
|
+
*/
|
|
890
|
+
eraseLocalCopy?(o: {
|
|
891
|
+
signal: AbortSignal;
|
|
892
|
+
}): Promise<ReplicaLocalEraseOutcome>;
|
|
893
|
+
}
|
|
894
|
+
/** Result of {@link ReplicaLifecycleGate.eraseLocalCopy}. */
|
|
895
|
+
type ReplicaLocalEraseOutcome =
|
|
896
|
+
/** The database is gone and the logout marker (if any) is cleared. */
|
|
897
|
+
{
|
|
898
|
+
status: "erased";
|
|
899
|
+
}
|
|
900
|
+
/** Delete blocked or storage error; a retry can succeed. `marker` is true when the next-load marker is set. */
|
|
901
|
+
| {
|
|
902
|
+
status: "failed";
|
|
903
|
+
code: string;
|
|
904
|
+
marker: boolean;
|
|
905
|
+
}
|
|
906
|
+
/** The gate does not authorize destruction; nothing was deleted. A retry cannot succeed until the gate is denied. */
|
|
907
|
+
| {
|
|
908
|
+
status: "refused";
|
|
909
|
+
code: string;
|
|
910
|
+
};
|
|
911
|
+
/** What triggered a local-copy erase. */
|
|
912
|
+
type ReplicaPurgeTrigger = "sign_out" | "account_switch" | "purge_local_copy";
|
|
913
|
+
/** Result of `replication.purgeLocalCopy()`. `retryNow` means a short bounded retry is meaningful. */
|
|
914
|
+
type ReplicaPurgeLocalCopyResult = {
|
|
915
|
+
ok: true;
|
|
916
|
+
} | {
|
|
917
|
+
ok: false;
|
|
918
|
+
retryNow: boolean;
|
|
919
|
+
};
|
|
920
|
+
/**
|
|
921
|
+
* Emitted (`on("replica.purge.failed", …)`) when the local copy could not be erased after the
|
|
922
|
+
* bounded retries. The SDK finishes the erase on the next load through the logout marker.
|
|
923
|
+
*/
|
|
924
|
+
interface ReplicaPurgeFailedEvent {
|
|
925
|
+
type: "replica.purge.failed";
|
|
926
|
+
trigger: ReplicaPurgeTrigger;
|
|
927
|
+
/** Typed reason: `logout_pending` (marker set, erase retried on next load) or `gate_unavailable`. */
|
|
928
|
+
reason: ReplicaGateReason;
|
|
929
|
+
/** Storage error code of the last attempt. */
|
|
930
|
+
code: string;
|
|
931
|
+
/** True when a short bounded retry is meaningful (delete blocked or storage error). */
|
|
932
|
+
retryNow: boolean;
|
|
933
|
+
}
|
|
934
|
+
/** Rejection of `signOut()` when the deny itself was `unguarded` and the erase did not complete. */
|
|
935
|
+
interface ReplicaPurgeError extends Error {
|
|
936
|
+
code: "REPLICA_PURGE_FAILED";
|
|
937
|
+
reason: ReplicaGateReason;
|
|
938
|
+
retryNow: boolean;
|
|
880
939
|
}
|
|
881
940
|
/** Node/CLI profile-local fencing token, not a secret capability; the profile lock remains authoritative. */
|
|
882
941
|
interface ProfileReplicaDeferredToken {
|
|
@@ -1401,6 +1460,8 @@ interface KVReplicaSpec {
|
|
|
1401
1460
|
grantPolicy?: ReplicaGrantPolicy;
|
|
1402
1461
|
/** Quota settings; absent means unbounded. */
|
|
1403
1462
|
quota?: ReplicaQuotaSpec;
|
|
1463
|
+
/** Value download policy for syncs of this handle; absent means `"eager"`. See `ReplicationOptions.contentFetch`. */
|
|
1464
|
+
contentFetch?: "eager" | "lazy";
|
|
1404
1465
|
/**
|
|
1405
1466
|
* Called when another tab/process commits a sync for this partition (browser: the worker's
|
|
1406
1467
|
* `committed` BroadcastChannel message). The controller emits `replication.sync` with
|
|
@@ -1764,6 +1825,15 @@ interface ReplicationControl {
|
|
|
1764
1825
|
* and committed records remain. Exposed callers MUST show CLEAR_PENDING_WARNING first.
|
|
1765
1826
|
*/
|
|
1766
1827
|
clearPending(): Promise<number>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Browser: erases the whole local copy (the IndexedDB database) once the account has been
|
|
1830
|
+
* denied by sign-out or account switch; `signOut()` and account switch already do this. Retries
|
|
1831
|
+
* a few times when the delete is blocked. `{ ok: false, retryNow: true }`: the copy is still
|
|
1832
|
+
* there and a short bounded retry is meaningful (the deny outcome kept the keys, or the delete
|
|
1833
|
+
* is blocked); the SDK also finishes the erase on the next load. `retryNow: false`: nothing is
|
|
1834
|
+
* erasable now (a session is live, or the storage has no browser database). Never rejects.
|
|
1835
|
+
*/
|
|
1836
|
+
purgeLocalCopy(): Promise<ReplicaPurgeLocalCopyResult>;
|
|
1767
1837
|
close(): Promise<void>;
|
|
1768
1838
|
}
|
|
1769
1839
|
interface ReplicationOptions {
|
|
@@ -1774,6 +1844,11 @@ interface ReplicationOptions {
|
|
|
1774
1844
|
allowSecrets?: boolean;
|
|
1775
1845
|
/** Sign-in asks for kv/sync on each declared prefix only and never widens to a root entry that covers them. */
|
|
1776
1846
|
syncScope?: "prefixes";
|
|
1847
|
+
/**
|
|
1848
|
+
* `"eager"` (default) downloads each changed value while syncing. `"lazy"` syncs entry names
|
|
1849
|
+
* without downloading values; a read of a value the replica does not hold goes to the network.
|
|
1850
|
+
*/
|
|
1851
|
+
contentFetch?: "eager" | "lazy";
|
|
1777
1852
|
/** Background interval; default 60 seconds. */
|
|
1778
1853
|
syncIntervalMs?: number;
|
|
1779
1854
|
maxStalenessMs?: number;
|
|
@@ -1972,4 +2047,4 @@ declare function replicationIdentityKey(id: ReplicationIdentity): string;
|
|
|
1972
2047
|
/** Whether replicating this space/prefix can copy encrypted secret material to disk. */
|
|
1973
2048
|
declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
|
|
1974
2049
|
|
|
1975
|
-
export { type ReplicaGuardedStore as $, type AuthorityRefusal as A, type ReplicaBrowserGateAccess as B, CLEAR_PENDING_WARNING as C, type ReplicaBrowserGateSnapshot as D, type ReplicaBrowserGateTx as E, type ReplicaBrowserPageAdmission as F, type ReplicaClock as G, type ReplicaCoverage as H, type ReplicaDeliveryDecision as I, type ReplicaDenyInput as J, type KVReplicationDeps as K, type LocalGetResult as L, type ReplicaDenyOutcome as M, type ReplicaDevice as N, type ReplicaEraseReport as O, type PendingWriteStore as P, type ReplicaGateAccess as Q, type ReplicationIdentity as R, type ReplicaGateReason as S, type ReplicaGateScope as T, type ReplicaGateSnapshot as U, type ReplicaGateTx as V, type ReplicaGatedError as W, type ReplicaGatedHandle as X, type ReplicaGatedSpec as Y, type ReplicaGatedStorage as Z, type ReplicaGrantInfo as _, type KVReplicationController as a, type ReplicaInspectedStatus as a0, type ReplicaLifecycleGate as a1, type
|
|
2050
|
+
export { type ReplicaGuardedStore as $, type AuthorityRefusal as A, type ReplicaBrowserGateAccess as B, CLEAR_PENDING_WARNING as C, type ReplicaBrowserGateSnapshot as D, type ReplicaBrowserGateTx as E, type ReplicaBrowserPageAdmission as F, type ReplicaClock as G, type ReplicaCoverage as H, type ReplicaDeliveryDecision as I, type ReplicaDenyInput as J, type KVReplicationDeps as K, type LocalGetResult as L, type ReplicaDenyOutcome as M, type ReplicaDevice as N, type ReplicaEraseReport as O, type PendingWriteStore as P, type ReplicaGateAccess as Q, type ReplicationIdentity as R, type ReplicaGateReason as S, type ReplicaGateScope as T, type ReplicaGateSnapshot as U, type ReplicaGateTx as V, type ReplicaGatedError as W, type ReplicaGatedHandle as X, type ReplicaGatedSpec as Y, type ReplicaGatedStorage as Z, type ReplicaGrantInfo as _, type KVReplicationController as a, type ReplicaInspectedStatus as a0, type ReplicaLifecycleGate as a1, type ReplicaLocalEraseOutcome as a2, type ReplicaPageAdmission as a3, type ReplicaPartitionEraser as a4, type ReplicaPartitionIndexEntry as a5, type ReplicaPeerCommit as a6, type ReplicaPrivateGateHash as a7, type ReplicaPurgeError as a8, type ReplicaPurgeFailedEvent as a9, type KVBatchPutResponse as aA, type KVBatchReadResponse as aB, type KVChange as aC, type KVChangesAuthority as aD, type KVChangesOptions as aE, type KVChangesResponse as aF, type KVCreateSignedReadUrlOptions as aG, type KVDeleteOptions as aH, type KVGetOptions as aI, type KVHeadOptions as aJ, type KVListOptions as aK, type KVListResponse as aL, type KVPutOptions as aM, type KVResponse as aN, type KVResponseHeaders as aO, type KVServiceConfig as aP, type KVSignedReadUrlResponse as aQ, type ReplicaPurgeIntent as aa, type ReplicaPurgeLocalCopyResult as ab, type ReplicaPurgeTrigger as ac, type ReplicaQuotaLedger as ad, type ReplicaQuotaSpec as ae, type ReplicaSessionStamp as af, type ReplicaStampedReply as ag, type ReplicaState as ah, type ReplicaStatusEntry as ai, type ReplicationAuthority as aj, type ReplicationControl as ak, type ReplicationEvent as al, type ReplicationOptions as am, type ReplicationPurgeReport as an, type ReplicationReason as ao, type ReplicationScheduler as ap, type ResolvedReplicationOptions as aq, type SaltedHash as ar, canonicalReplicationIdentity as as, replicationIdentityKey as at, requiresSecretsOptIn as au, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as av, KVAction as aw, type KVActionType as ax, type KVBatchPutItem as ay, type KVBatchPutOptions as az, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type ProfileReplicaApprovalEntry as n, type ProfileReplicaDeferredDenyOutcome as o, type ProfileReplicaDeferredToken as p, type ProfileReplicaLogoutPending as q, type ProfileReplicaPreflight as r, type ProfileReplicaPurge as s, type ProfileReplicaRemoteLogoutState as t, type ProfileReplicaRootIdentity as u, type ProfileReplicaUnknownEntry as v, type PurgeTarget as w, type ReplicaAccountGate as x, type ReplicaAdmitHook as y, type ReplicaAuthorityState as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as RetryStats,
|
|
1
|
+
import { i as RetryStats, f as Result, F as FetchFunction } from './types-CSd0RYir.cjs';
|
|
2
2
|
import { REPLICA_KV_STORES } from './kv/replication/contractConstants.cjs';
|
|
3
3
|
import { ReplicaConsentAnchor, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.cjs';
|
|
4
4
|
|
|
@@ -591,7 +591,9 @@ type ReplicaGateReason =
|
|
|
591
591
|
/** Browser only: the `localStorage` logout marker is set. */
|
|
592
592
|
| "logout_pending"
|
|
593
593
|
/** The gate store itself could not be read; fail closed. */
|
|
594
|
-
| "gate_unavailable"
|
|
594
|
+
| "gate_unavailable"
|
|
595
|
+
/** Browser: replication is configured but no wallet provider can prove the connected account. */
|
|
596
|
+
| "wallet_provider_required";
|
|
595
597
|
/** Shape of every gate refusal error: `Error & { code: "REPLICA_GATED"; gate }`. */
|
|
596
598
|
interface ReplicaGatedError extends Error {
|
|
597
599
|
code: "REPLICA_GATED";
|
|
@@ -877,6 +879,63 @@ interface ReplicaLifecycleGate {
|
|
|
877
879
|
}): Promise<ReplicaEraseReport>;
|
|
878
880
|
/** Outstanding intents; non-empty means status `purgePending: true`. */
|
|
879
881
|
pendingPurge(): Promise<ReplicaPurgeIntent[]>;
|
|
882
|
+
/**
|
|
883
|
+
* Browser only. Under the gate lock, erases pending intents and deletes the whole origin
|
|
884
|
+
* database. Deletes only when nothing live is at stake: the gate is denied (null principal),
|
|
885
|
+
* the gate is behind the persisted deny tombstone, or the logout marker is set with a tombstone.
|
|
886
|
+
* A live or other-account gate is `refused` and left untouched. On a failed delete it sets the
|
|
887
|
+
* logout marker (when a tombstone exists) so `recover` finishes the erase on the next load.
|
|
888
|
+
* Never clears the deny tombstone.
|
|
889
|
+
*/
|
|
890
|
+
eraseLocalCopy?(o: {
|
|
891
|
+
signal: AbortSignal;
|
|
892
|
+
}): Promise<ReplicaLocalEraseOutcome>;
|
|
893
|
+
}
|
|
894
|
+
/** Result of {@link ReplicaLifecycleGate.eraseLocalCopy}. */
|
|
895
|
+
type ReplicaLocalEraseOutcome =
|
|
896
|
+
/** The database is gone and the logout marker (if any) is cleared. */
|
|
897
|
+
{
|
|
898
|
+
status: "erased";
|
|
899
|
+
}
|
|
900
|
+
/** Delete blocked or storage error; a retry can succeed. `marker` is true when the next-load marker is set. */
|
|
901
|
+
| {
|
|
902
|
+
status: "failed";
|
|
903
|
+
code: string;
|
|
904
|
+
marker: boolean;
|
|
905
|
+
}
|
|
906
|
+
/** The gate does not authorize destruction; nothing was deleted. A retry cannot succeed until the gate is denied. */
|
|
907
|
+
| {
|
|
908
|
+
status: "refused";
|
|
909
|
+
code: string;
|
|
910
|
+
};
|
|
911
|
+
/** What triggered a local-copy erase. */
|
|
912
|
+
type ReplicaPurgeTrigger = "sign_out" | "account_switch" | "purge_local_copy";
|
|
913
|
+
/** Result of `replication.purgeLocalCopy()`. `retryNow` means a short bounded retry is meaningful. */
|
|
914
|
+
type ReplicaPurgeLocalCopyResult = {
|
|
915
|
+
ok: true;
|
|
916
|
+
} | {
|
|
917
|
+
ok: false;
|
|
918
|
+
retryNow: boolean;
|
|
919
|
+
};
|
|
920
|
+
/**
|
|
921
|
+
* Emitted (`on("replica.purge.failed", …)`) when the local copy could not be erased after the
|
|
922
|
+
* bounded retries. The SDK finishes the erase on the next load through the logout marker.
|
|
923
|
+
*/
|
|
924
|
+
interface ReplicaPurgeFailedEvent {
|
|
925
|
+
type: "replica.purge.failed";
|
|
926
|
+
trigger: ReplicaPurgeTrigger;
|
|
927
|
+
/** Typed reason: `logout_pending` (marker set, erase retried on next load) or `gate_unavailable`. */
|
|
928
|
+
reason: ReplicaGateReason;
|
|
929
|
+
/** Storage error code of the last attempt. */
|
|
930
|
+
code: string;
|
|
931
|
+
/** True when a short bounded retry is meaningful (delete blocked or storage error). */
|
|
932
|
+
retryNow: boolean;
|
|
933
|
+
}
|
|
934
|
+
/** Rejection of `signOut()` when the deny itself was `unguarded` and the erase did not complete. */
|
|
935
|
+
interface ReplicaPurgeError extends Error {
|
|
936
|
+
code: "REPLICA_PURGE_FAILED";
|
|
937
|
+
reason: ReplicaGateReason;
|
|
938
|
+
retryNow: boolean;
|
|
880
939
|
}
|
|
881
940
|
/** Node/CLI profile-local fencing token, not a secret capability; the profile lock remains authoritative. */
|
|
882
941
|
interface ProfileReplicaDeferredToken {
|
|
@@ -1401,6 +1460,8 @@ interface KVReplicaSpec {
|
|
|
1401
1460
|
grantPolicy?: ReplicaGrantPolicy;
|
|
1402
1461
|
/** Quota settings; absent means unbounded. */
|
|
1403
1462
|
quota?: ReplicaQuotaSpec;
|
|
1463
|
+
/** Value download policy for syncs of this handle; absent means `"eager"`. See `ReplicationOptions.contentFetch`. */
|
|
1464
|
+
contentFetch?: "eager" | "lazy";
|
|
1404
1465
|
/**
|
|
1405
1466
|
* Called when another tab/process commits a sync for this partition (browser: the worker's
|
|
1406
1467
|
* `committed` BroadcastChannel message). The controller emits `replication.sync` with
|
|
@@ -1764,6 +1825,15 @@ interface ReplicationControl {
|
|
|
1764
1825
|
* and committed records remain. Exposed callers MUST show CLEAR_PENDING_WARNING first.
|
|
1765
1826
|
*/
|
|
1766
1827
|
clearPending(): Promise<number>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Browser: erases the whole local copy (the IndexedDB database) once the account has been
|
|
1830
|
+
* denied by sign-out or account switch; `signOut()` and account switch already do this. Retries
|
|
1831
|
+
* a few times when the delete is blocked. `{ ok: false, retryNow: true }`: the copy is still
|
|
1832
|
+
* there and a short bounded retry is meaningful (the deny outcome kept the keys, or the delete
|
|
1833
|
+
* is blocked); the SDK also finishes the erase on the next load. `retryNow: false`: nothing is
|
|
1834
|
+
* erasable now (a session is live, or the storage has no browser database). Never rejects.
|
|
1835
|
+
*/
|
|
1836
|
+
purgeLocalCopy(): Promise<ReplicaPurgeLocalCopyResult>;
|
|
1767
1837
|
close(): Promise<void>;
|
|
1768
1838
|
}
|
|
1769
1839
|
interface ReplicationOptions {
|
|
@@ -1774,6 +1844,11 @@ interface ReplicationOptions {
|
|
|
1774
1844
|
allowSecrets?: boolean;
|
|
1775
1845
|
/** Sign-in asks for kv/sync on each declared prefix only and never widens to a root entry that covers them. */
|
|
1776
1846
|
syncScope?: "prefixes";
|
|
1847
|
+
/**
|
|
1848
|
+
* `"eager"` (default) downloads each changed value while syncing. `"lazy"` syncs entry names
|
|
1849
|
+
* without downloading values; a read of a value the replica does not hold goes to the network.
|
|
1850
|
+
*/
|
|
1851
|
+
contentFetch?: "eager" | "lazy";
|
|
1777
1852
|
/** Background interval; default 60 seconds. */
|
|
1778
1853
|
syncIntervalMs?: number;
|
|
1779
1854
|
maxStalenessMs?: number;
|
|
@@ -1972,4 +2047,4 @@ declare function replicationIdentityKey(id: ReplicationIdentity): string;
|
|
|
1972
2047
|
/** Whether replicating this space/prefix can copy encrypted secret material to disk. */
|
|
1973
2048
|
declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
|
|
1974
2049
|
|
|
1975
|
-
export { type ReplicaGuardedStore as $, type AuthorityRefusal as A, type ReplicaBrowserGateAccess as B, CLEAR_PENDING_WARNING as C, type ReplicaBrowserGateSnapshot as D, type ReplicaBrowserGateTx as E, type ReplicaBrowserPageAdmission as F, type ReplicaClock as G, type ReplicaCoverage as H, type ReplicaDeliveryDecision as I, type ReplicaDenyInput as J, type KVReplicationDeps as K, type LocalGetResult as L, type ReplicaDenyOutcome as M, type ReplicaDevice as N, type ReplicaEraseReport as O, type PendingWriteStore as P, type ReplicaGateAccess as Q, type ReplicationIdentity as R, type ReplicaGateReason as S, type ReplicaGateScope as T, type ReplicaGateSnapshot as U, type ReplicaGateTx as V, type ReplicaGatedError as W, type ReplicaGatedHandle as X, type ReplicaGatedSpec as Y, type ReplicaGatedStorage as Z, type ReplicaGrantInfo as _, type KVReplicationController as a, type ReplicaInspectedStatus as a0, type ReplicaLifecycleGate as a1, type
|
|
2050
|
+
export { type ReplicaGuardedStore as $, type AuthorityRefusal as A, type ReplicaBrowserGateAccess as B, CLEAR_PENDING_WARNING as C, type ReplicaBrowserGateSnapshot as D, type ReplicaBrowserGateTx as E, type ReplicaBrowserPageAdmission as F, type ReplicaClock as G, type ReplicaCoverage as H, type ReplicaDeliveryDecision as I, type ReplicaDenyInput as J, type KVReplicationDeps as K, type LocalGetResult as L, type ReplicaDenyOutcome as M, type ReplicaDevice as N, type ReplicaEraseReport as O, type PendingWriteStore as P, type ReplicaGateAccess as Q, type ReplicationIdentity as R, type ReplicaGateReason as S, type ReplicaGateScope as T, type ReplicaGateSnapshot as U, type ReplicaGateTx as V, type ReplicaGatedError as W, type ReplicaGatedHandle as X, type ReplicaGatedSpec as Y, type ReplicaGatedStorage as Z, type ReplicaGrantInfo as _, type KVReplicationController as a, type ReplicaInspectedStatus as a0, type ReplicaLifecycleGate as a1, type ReplicaLocalEraseOutcome as a2, type ReplicaPageAdmission as a3, type ReplicaPartitionEraser as a4, type ReplicaPartitionIndexEntry as a5, type ReplicaPeerCommit as a6, type ReplicaPrivateGateHash as a7, type ReplicaPurgeError as a8, type ReplicaPurgeFailedEvent as a9, type KVBatchPutResponse as aA, type KVBatchReadResponse as aB, type KVChange as aC, type KVChangesAuthority as aD, type KVChangesOptions as aE, type KVChangesResponse as aF, type KVCreateSignedReadUrlOptions as aG, type KVDeleteOptions as aH, type KVGetOptions as aI, type KVHeadOptions as aJ, type KVListOptions as aK, type KVListResponse as aL, type KVPutOptions as aM, type KVResponse as aN, type KVResponseHeaders as aO, type KVServiceConfig as aP, type KVSignedReadUrlResponse as aQ, type ReplicaPurgeIntent as aa, type ReplicaPurgeLocalCopyResult as ab, type ReplicaPurgeTrigger as ac, type ReplicaQuotaLedger as ad, type ReplicaQuotaSpec as ae, type ReplicaSessionStamp as af, type ReplicaStampedReply as ag, type ReplicaState as ah, type ReplicaStatusEntry as ai, type ReplicationAuthority as aj, type ReplicationControl as ak, type ReplicationEvent as al, type ReplicationOptions as am, type ReplicationPurgeReport as an, type ReplicationReason as ao, type ReplicationScheduler as ap, type ResolvedReplicationOptions as aq, type SaltedHash as ar, canonicalReplicationIdentity as as, replicationIdentityKey as at, requiresSecretsOptIn as au, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as av, KVAction as aw, type KVActionType as ax, type KVBatchPutItem as ay, type KVBatchPutOptions as az, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type ProfileReplicaApprovalEntry as n, type ProfileReplicaDeferredDenyOutcome as o, type ProfileReplicaDeferredToken as p, type ProfileReplicaLogoutPending as q, type ProfileReplicaPreflight as r, type ProfileReplicaPurge as s, type ProfileReplicaRemoteLogoutState as t, type ProfileReplicaRootIdentity as u, type ProfileReplicaUnknownEntry as v, type PurgeTarget as w, type ReplicaAccountGate as x, type ReplicaAdmitHook as y, type ReplicaAuthorityState as z };
|
package/dist/sql/index.cjs
CHANGED
|
@@ -770,12 +770,13 @@ var SQLService = class extends BaseService {
|
|
|
770
770
|
request.signal
|
|
771
771
|
);
|
|
772
772
|
if (!response.ok) {
|
|
773
|
-
|
|
773
|
+
const failure = await this.handleErrorResponse(response, "query", dbName, [action]);
|
|
774
|
+
return this.redactFailure(failure, options?.redactErrors, response.status);
|
|
774
775
|
}
|
|
775
776
|
const data = await response.json();
|
|
776
777
|
return ok(data);
|
|
777
778
|
} catch (error) {
|
|
778
|
-
return err(wrapError("sql", error));
|
|
779
|
+
return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
|
|
779
780
|
} finally {
|
|
780
781
|
request.dispose();
|
|
781
782
|
}
|
|
@@ -810,12 +811,13 @@ var SQLService = class extends BaseService {
|
|
|
810
811
|
request.signal
|
|
811
812
|
);
|
|
812
813
|
if (!response.ok) {
|
|
813
|
-
|
|
814
|
+
const failure = await this.handleErrorResponse(response, "execute", dbName, requestedActions);
|
|
815
|
+
return this.redactFailure(failure, options?.redactErrors, response.status);
|
|
814
816
|
}
|
|
815
817
|
const data = await response.json();
|
|
816
818
|
return ok(data);
|
|
817
819
|
} catch (error) {
|
|
818
|
-
return err(wrapError("sql", error));
|
|
820
|
+
return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
|
|
819
821
|
} finally {
|
|
820
822
|
request.dispose();
|
|
821
823
|
}
|
|
@@ -836,12 +838,13 @@ var SQLService = class extends BaseService {
|
|
|
836
838
|
request.signal
|
|
837
839
|
);
|
|
838
840
|
if (!response.ok) {
|
|
839
|
-
|
|
841
|
+
const failure = await this.handleErrorResponse(response, "batch", dbName, requestedActions);
|
|
842
|
+
return this.redactFailure(failure, options?.redactErrors, response.status);
|
|
840
843
|
}
|
|
841
844
|
const data = await response.json();
|
|
842
845
|
return ok(data);
|
|
843
846
|
} catch (error) {
|
|
844
|
-
return err(wrapError("sql", error));
|
|
847
|
+
return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
|
|
845
848
|
} finally {
|
|
846
849
|
request.dispose();
|
|
847
850
|
}
|
|
@@ -1037,6 +1040,18 @@ var SQLService = class extends BaseService {
|
|
|
1037
1040
|
}))
|
|
1038
1041
|
);
|
|
1039
1042
|
}
|
|
1043
|
+
redactFailure(result, redactErrors, status) {
|
|
1044
|
+
if (!redactErrors || result.ok) return result;
|
|
1045
|
+
const candidate = result.error.code;
|
|
1046
|
+
const code = typeof candidate === "string" && Object.prototype.hasOwnProperty.call(ErrorCodes, candidate) ? candidate : ErrorCodes.SQL_ERROR;
|
|
1047
|
+
const safeStatus = typeof status === "number" && Number.isInteger(status) && status >= 400 && status <= 599 ? status : void 0;
|
|
1048
|
+
return err(serviceError(
|
|
1049
|
+
code,
|
|
1050
|
+
"SQL operation failed",
|
|
1051
|
+
"sql",
|
|
1052
|
+
safeStatus === void 0 ? void 0 : { meta: { status: safeStatus } }
|
|
1053
|
+
));
|
|
1054
|
+
}
|
|
1040
1055
|
async handleErrorResponse(response, operation, dbName, requestedActions) {
|
|
1041
1056
|
const errorText = await response.text();
|
|
1042
1057
|
const meta = responseErrorMeta(response.status, response.statusText, errorText);
|