@tinycloud/sdk-services 3.2.6-beta.2 → 3.3.0-beta.7
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-4wwJq1Gn.d.cts → BaseService-Cc6Ueicm.d.cts} +1 -1
- package/dist/{BaseService-BGr2slUz.d.ts → BaseService-DOdXd7sr.d.ts} +1 -1
- package/dist/encryption/index.cjs +10 -0
- 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 +10 -0
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +109 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.js +108 -64
- 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 +68 -21
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +7 -4
- package/dist/kv/index.d.ts +7 -4
- package/dist/kv/index.js +68 -21
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/contractConstants.cjs +115 -0
- package/dist/kv/replication/contractConstants.cjs.map +1 -0
- package/dist/kv/replication/contractConstants.d.cts +77 -0
- package/dist/kv/replication/contractConstants.d.ts +77 -0
- package/dist/kv/replication/contractConstants.js +75 -0
- package/dist/kv/replication/contractConstants.js.map +1 -0
- 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/grantPolicyConstants.cjs +42 -0
- package/dist/kv/replication/grantPolicyConstants.cjs.map +1 -0
- package/dist/kv/replication/grantPolicyConstants.d.cts +10 -0
- package/dist/kv/replication/grantPolicyConstants.d.ts +10 -0
- package/dist/kv/replication/grantPolicyConstants.js +14 -0
- package/dist/kv/replication/grantPolicyConstants.js.map +1 -0
- package/dist/kv/replication/grantPolicyTypes.cjs +19 -0
- package/dist/kv/replication/grantPolicyTypes.cjs.map +1 -0
- package/dist/kv/replication/grantPolicyTypes.d.cts +87 -0
- package/dist/kv/replication/grantPolicyTypes.d.ts +87 -0
- package/dist/kv/replication/grantPolicyTypes.js +1 -0
- package/dist/kv/replication/grantPolicyTypes.js.map +1 -0
- package/dist/kv/replication/index.cjs +575 -131
- package/dist/kv/replication/index.cjs.map +1 -1
- package/dist/kv/replication/index.d.cts +6 -3
- package/dist/kv/replication/index.d.ts +6 -3
- package/dist/kv/replication/index.js +575 -131
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/scope-B-m6cKH-.d.ts +1962 -0
- package/dist/scope-B7oeKdLM.d.cts +1962 -0
- package/dist/sql/index.cjs +72 -36
- 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 +72 -36
- package/dist/sql/index.js.map +1 -1
- package/dist/{types-D-9A3Sut.d.cts → types-BjH0ZtGy.d.cts} +8 -0
- package/dist/{types-D-9A3Sut.d.ts → types-BjH0ZtGy.d.ts} +8 -0
- package/package.json +55 -2
- package/dist/scope-CoKKmMiI.d.ts +0 -957
- package/dist/scope-D7wmjbMH.d.cts +0 -957
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { a as IServiceContext, c as InvokeFunction, d as InvokeAnyFunction, F as FetchFunction, S as ServiceSession, e as RetryPolicy, T as TelemetryConfig, I as IService, E as EventHandler, b as ServiceError, R as Result, P as PermissionHint, f as StorageQuotaInfo } from './types-
|
|
2
|
-
export { g as ErrorCode, h as ErrorCodes, i as FetchRequestInit, j as FetchResponse, k as InvocationFact, l as InvocationFacts, m as InvokeAnyEntry, n as ServiceErrorEvent, o as ServiceHeaders, p as ServiceRequestEvent, q as ServiceResponseEvent, r as ServiceRetryEvent, s as TelemetryEventHandler, t as TelemetryEvents, u as TelemetrySpanEvent, v as defaultRetryPolicy, w as err, x as ok, y as serviceError } from './types-
|
|
1
|
+
import { a as IServiceContext, c as InvokeFunction, d as InvokeAnyFunction, F as FetchFunction, S as ServiceSession, e as RetryPolicy, T as TelemetryConfig, I as IService, E as EventHandler, b as ServiceError, R as Result, P as PermissionHint, f as StorageQuotaInfo } from './types-BjH0ZtGy.cjs';
|
|
2
|
+
export { g as ErrorCode, h as ErrorCodes, i as FetchRequestInit, j as FetchResponse, k as InvocationFact, l as InvocationFacts, m as InvokeAnyEntry, n as ServiceErrorEvent, o as ServiceHeaders, p as ServiceRequestEvent, q as ServiceResponseEvent, r as ServiceRetryEvent, s as TelemetryEventHandler, t as TelemetryEvents, u as TelemetrySpanEvent, v as defaultRetryPolicy, w as err, x as ok, y as serviceError } from './types-BjH0ZtGy.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BaseService } from './BaseService-
|
|
5
|
-
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-
|
|
4
|
+
import { B as BaseService } from './BaseService-Cc6Ueicm.cjs';
|
|
5
|
+
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-Cc6Ueicm.cjs';
|
|
6
6
|
import { IKVService } from './kv/index.cjs';
|
|
7
7
|
export { IPrefixedKVService, KVService, PrefixedKVService } from './kv/index.cjs';
|
|
8
|
-
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING,
|
|
8
|
+
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, aq as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, ar as KVAction, as as KVActionType, at as KVBatchPutItem, au as KVBatchPutOptions, av as KVBatchPutResponse, aw as KVBatchReadResponse, ax as KVChange, ay as KVChangesAuthority, az as KVChangesOptions, aA as KVChangesResponse, aB as KVCreateSignedReadUrlOptions, aC as KVDeleteOptions, aD as KVGetOptions, aE as KVHeadOptions, aF as KVListOptions, b as KVListPage, aG as KVListResponse, aH as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aI as KVResponse, aJ as KVResponseHeaders, aK as KVServiceConfig, aL as KVSignedReadUrlResponse, 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, x as ReplicaAccountGate, y as ReplicaAdmitHook, z as ReplicaAuthorityState, B as ReplicaBrowserGateAccess, D as ReplicaBrowserGateSnapshot, E as ReplicaBrowserGateTx, F as ReplicaBrowserPageAdmission, G as ReplicaClock, H as ReplicaCoverage, I as ReplicaDeliveryDecision, J as ReplicaDenyInput, M as ReplicaDenyOutcome, N as ReplicaDevice, O as ReplicaEraseReport, Q as ReplicaGateAccess, S as ReplicaGateReason, T as ReplicaGateScope, U as ReplicaGateSnapshot, V as ReplicaGateTx, W as ReplicaGatedError, X as ReplicaGatedHandle, Y as ReplicaGatedSpec, Z as ReplicaGatedStorage, _ as ReplicaGrantInfo, $ as ReplicaGuardedStore, a0 as ReplicaInspectedStatus, a1 as ReplicaLifecycleGate, a2 as ReplicaPageAdmission, a3 as ReplicaPartitionEraser, a4 as ReplicaPartitionIndexEntry, a5 as ReplicaPeerCommit, a6 as ReplicaPrivateGateHash, a7 as ReplicaPurgeIntent, a8 as ReplicaQuotaLedger, a9 as ReplicaQuotaSpec, aa as ReplicaSessionStamp, ab as ReplicaStampedReply, ac as ReplicaState, ad as ReplicaStatusEntry, ae as ReplicationAuthority, af as ReplicationControl, ag as ReplicationEvent, R as ReplicationIdentity, ah as ReplicationOptions, ai as ReplicationPurgeReport, aj as ReplicationReason, ak as ReplicationScheduler, al as ResolvedReplicationOptions, am as SaltedHash, an as canonicalReplicationIdentity, ao as replicationIdentityKey, ap as requiresSecretsOptIn } from './scope-B7oeKdLM.cjs';
|
|
9
|
+
export { ClampConsentAnchor, ConsentDeadlineMs, EffectiveGrantExpiry, EffectiveGrantExpiryInput, MintRemainingMs, NeedsSilentRenewal, ReplicaConsentAnchor, ReplicaConsentSource, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.cjs';
|
|
9
10
|
export { BatchOptions, BatchResponse, DatabaseHandle, ExecuteOptions, ExecuteResponse, IDatabaseHandle, ISQLMigrations, ISQLService, QueryOptions, QueryResponse, SQLAction, SQLActionType, SQLMigrations, SQLService, SQLServiceConfig, SqlMigration, SqlMigrationApplyOptions, SqlMigrationApplyResponse, SqlStatement, SqlValue } from './sql/index.cjs';
|
|
10
11
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.cjs';
|
|
11
12
|
export { BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CanonicalDecryptRequest, CanonicalJson, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, InlineEncryptedEnvelope, Json, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, SignedReceiverKeyInput, VerifyDecryptResponseInput, WellKnownDescriptorFetcher, base64Decode, base64Encode, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalize as canonicalizeEncryptionJson, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, encryptionError, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, hexDecode, hexEncode, isNetworkId, networkDiscoveryKey, openWrappedKey, parseNetworkId, utf8Decode, utf8Encode, validateEnvelope, verifyDecryptResponse } from './encryption/index.cjs';
|
|
12
13
|
export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
|
|
13
14
|
export { kvPrefixCovers } from './kv/replication/prefix.cjs';
|
|
15
|
+
import './kv/replication/contractConstants.cjs';
|
|
16
|
+
import './kv/replication/grantPolicyConstants.cjs';
|
|
14
17
|
|
|
15
18
|
type TinyCloudDebugLevel = "debug";
|
|
16
19
|
interface TinyCloudDebugEvent {
|
|
@@ -488,14 +491,14 @@ declare const ServiceRequestEventSchema: z.ZodObject<{
|
|
|
488
491
|
timestamp: z.ZodNumber;
|
|
489
492
|
}, "strip", z.ZodTypeAny, {
|
|
490
493
|
timestamp: number;
|
|
491
|
-
service: string;
|
|
492
494
|
action: string;
|
|
495
|
+
service: string;
|
|
493
496
|
key?: string | undefined;
|
|
494
497
|
span?: string | undefined;
|
|
495
498
|
}, {
|
|
496
499
|
timestamp: number;
|
|
497
|
-
service: string;
|
|
498
500
|
action: string;
|
|
501
|
+
service: string;
|
|
499
502
|
key?: string | undefined;
|
|
500
503
|
span?: string | undefined;
|
|
501
504
|
}>;
|
|
@@ -514,16 +517,16 @@ declare const ServiceResponseEventSchema: z.ZodObject<{
|
|
|
514
517
|
}, "strip", z.ZodTypeAny, {
|
|
515
518
|
duration: number;
|
|
516
519
|
ok: boolean;
|
|
517
|
-
service: string;
|
|
518
520
|
action: string;
|
|
521
|
+
service: string;
|
|
519
522
|
durationMs?: number | undefined;
|
|
520
523
|
status?: number | undefined;
|
|
521
524
|
span?: string | undefined;
|
|
522
525
|
}, {
|
|
523
526
|
duration: number;
|
|
524
527
|
ok: boolean;
|
|
525
|
-
service: string;
|
|
526
528
|
action: string;
|
|
529
|
+
service: string;
|
|
527
530
|
durationMs?: number | undefined;
|
|
528
531
|
status?: number | undefined;
|
|
529
532
|
span?: string | undefined;
|
|
@@ -682,8 +685,8 @@ declare const TelemetrySpanEventSchema: z.ZodObject<{
|
|
|
682
685
|
meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
683
686
|
} | undefined;
|
|
684
687
|
status?: number | undefined;
|
|
685
|
-
service?: string | undefined;
|
|
686
688
|
action?: string | undefined;
|
|
689
|
+
service?: string | undefined;
|
|
687
690
|
}, {
|
|
688
691
|
durationMs: number;
|
|
689
692
|
ok: boolean;
|
|
@@ -696,8 +699,8 @@ declare const TelemetrySpanEventSchema: z.ZodObject<{
|
|
|
696
699
|
meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
697
700
|
} | undefined;
|
|
698
701
|
status?: number | undefined;
|
|
699
|
-
service?: string | undefined;
|
|
700
702
|
action?: string | undefined;
|
|
703
|
+
service?: string | undefined;
|
|
701
704
|
}>;
|
|
702
705
|
type TelemetrySpanEventType = z.infer<typeof TelemetrySpanEventSchema>;
|
|
703
706
|
/**
|
|
@@ -1054,6 +1057,29 @@ declare function authExpiredError(service: string): ServiceError;
|
|
|
1054
1057
|
* Create a service error for network issues.
|
|
1055
1058
|
*/
|
|
1056
1059
|
declare function networkError(service: string, message: string, cause?: Error): ServiceError;
|
|
1060
|
+
/**
|
|
1061
|
+
* Classify a node retry signal (tinycloud-node #347, TC-1054). The node's
|
|
1062
|
+
* bodies are plain text led by a stable token:
|
|
1063
|
+
* - `503 sql_busy: <stage>: ...` and `503 unavailable_retryable: ...` are
|
|
1064
|
+
* `NODE_BUSY`: nothing was applied; retry after `meta.retryAfterMs`.
|
|
1065
|
+
* - `503 request_timeout: ...` is `REQUEST_TIMEOUT`: the deadline passed before
|
|
1066
|
+
* any write began, so nothing was applied.
|
|
1067
|
+
* - `500 outcome_unknown: ...` is `OUTCOME_UNKNOWN`: a write may have been
|
|
1068
|
+
* applied; read back before retrying a non-idempotent operation.
|
|
1069
|
+
*
|
|
1070
|
+
* `meta.retryable` is the safe-to-retry verdict and `meta.retryAfterMs` the
|
|
1071
|
+
* node's `Retry-After` (the node sends whole seconds; anything else is
|
|
1072
|
+
* ignored). The SDK never retries on its own. Returns `undefined` for any
|
|
1073
|
+
* other response, including the bodyless 503/500 of nodes before 1.21, which
|
|
1074
|
+
* callers keep classifying as they always did.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function nodeRetryError(service: string, message: string, response: {
|
|
1077
|
+
status: number;
|
|
1078
|
+
statusText: string;
|
|
1079
|
+
headers: {
|
|
1080
|
+
get(name: string): string | null;
|
|
1081
|
+
};
|
|
1082
|
+
}, errorText: string): ServiceError | undefined;
|
|
1057
1083
|
/**
|
|
1058
1084
|
* Create a service error for timeouts.
|
|
1059
1085
|
*
|
|
@@ -2581,4 +2607,4 @@ declare class SecretsService implements ISecretsService {
|
|
|
2581
2607
|
listAll(): Promise<Result<SecretCatalogEntry[], SecretsError>>;
|
|
2582
2608
|
}
|
|
2583
2609
|
|
|
2584
|
-
export { type AuthorizationVerdict, BaseService, type ColumnInfo, type DataVaultConfig, DataVaultService, DecryptCapabilityProof, DuckDbAction, type DuckDbActionType, type DuckDbBatchOptions, type BatchResponse as DuckDbBatchResponse, DuckDbDatabaseHandle, type DuckDbExecuteOptions, type ExecuteResponse as DuckDbExecuteResponse, type DuckDbOptions, type DuckDbQueryOptions, type QueryResponse as DuckDbQueryResponse, DuckDbService, type DuckDbServiceConfig, type DuckDbStatement, type DuckDbValue, EventHandler, FetchFunction, GenericKVResponseSchema, type GenericKVResponseType, GenericResultSchema, type HookEvent, type HookServiceName, type HookStreamEvent, type HookStreamRetryConfig, type HookSubscription, type HookWebhookListOptions, type HookWebhookRecord, type HookWebhookRegistration, type HookWebhookScope, type HookWebhookUnregisterOptions, HooksService, type HooksServiceConfig, type IDataVaultService, type IDuckDbDatabaseHandle, type IDuckDbService, IEncryptionService, type IHooksService, IKVService, type ISecretsService, IService, IServiceContext, type IStorageService, InvokeAnyFunction, InvokeFunction, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, SECRET_SCOPE_RE, STORAGE_FULL_MESSAGE, STORAGE_MANAGE_URL, STORAGE_NEARLY_FULL_RATIO, STORAGE_WRITE_TOO_LARGE_MESSAGE, type SchemaInfo, type SecretCatalogEntry, type SecretPayload, type SecretPutOptions, type SecretScopeOptions, type SecretsError, SecretsService, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, ServiceRequestEventSchema, type ServiceRequestEventType, ServiceResponseEventSchema, type ServiceResponseEventType, ServiceRetryEventSchema, type ServiceRetryEventType, ServiceSession, ServiceSessionSchema, type ServiceSessionType, type StorageAccountUsage, type StorageFullEvent, type StorageFullHandler, StorageFullMonitor, StorageQuotaInfo, type StorageRejectionDetails, type StorageStatus, type StorageStatusOptions, type StorageUsage, type StorageUsageState, type SubscribeOptions, TC832_RESERVED_SCOPES, type TableInfo, TelemetryConfig, TelemetrySpanEventSchema, type TelemetrySpanEventType, type TinyCloudDebugEnableOptions, type TinyCloudDebugEvent, type TinyCloudDebugLevel, TinyCloudDebugLogger, type TinyCloudDebugTimer, TinyCloudQuota, type ValidationError, type VaultCrypto, type VaultEntry, type VaultError, type VaultGetOptions, type VaultGrantOptions, VaultHeaders, type VaultListOptions, type VaultListPage, type VaultNetworkReadResult, VaultPublicSpaceKVActions, type VaultPutOptions, type ViewInfo, type WasmVaultFunctions, abortedError, appSecretScope, authExpiredError, authRequiredError, authUnauthorizedError, authorizationVerdictOf, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isStorageFullError, networkError, notFoundError, parseAuthError, parseCapabilityResource, parsePermissionHint, parsePermissionHintFromErrorText, parseSecretCatalogKey, parseStorageQuotaBytes, parseStorageRejection, parseStorageStatus, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, storageRejectionError, storageUsageState, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, validatedCapabilityOf, wrapError };
|
|
2610
|
+
export { type AuthorizationVerdict, BaseService, type ColumnInfo, type DataVaultConfig, DataVaultService, DecryptCapabilityProof, DuckDbAction, type DuckDbActionType, type DuckDbBatchOptions, type BatchResponse as DuckDbBatchResponse, DuckDbDatabaseHandle, type DuckDbExecuteOptions, type ExecuteResponse as DuckDbExecuteResponse, type DuckDbOptions, type DuckDbQueryOptions, type QueryResponse as DuckDbQueryResponse, DuckDbService, type DuckDbServiceConfig, type DuckDbStatement, type DuckDbValue, EventHandler, FetchFunction, GenericKVResponseSchema, type GenericKVResponseType, GenericResultSchema, type HookEvent, type HookServiceName, type HookStreamEvent, type HookStreamRetryConfig, type HookSubscription, type HookWebhookListOptions, type HookWebhookRecord, type HookWebhookRegistration, type HookWebhookScope, type HookWebhookUnregisterOptions, HooksService, type HooksServiceConfig, type IDataVaultService, type IDuckDbDatabaseHandle, type IDuckDbService, IEncryptionService, type IHooksService, IKVService, type ISecretsService, IService, IServiceContext, type IStorageService, InvokeAnyFunction, InvokeFunction, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, SECRET_SCOPE_RE, STORAGE_FULL_MESSAGE, STORAGE_MANAGE_URL, STORAGE_NEARLY_FULL_RATIO, STORAGE_WRITE_TOO_LARGE_MESSAGE, type SchemaInfo, type SecretCatalogEntry, type SecretPayload, type SecretPutOptions, type SecretScopeOptions, type SecretsError, SecretsService, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, ServiceRequestEventSchema, type ServiceRequestEventType, ServiceResponseEventSchema, type ServiceResponseEventType, ServiceRetryEventSchema, type ServiceRetryEventType, ServiceSession, ServiceSessionSchema, type ServiceSessionType, type StorageAccountUsage, type StorageFullEvent, type StorageFullHandler, StorageFullMonitor, StorageQuotaInfo, type StorageRejectionDetails, type StorageStatus, type StorageStatusOptions, type StorageUsage, type StorageUsageState, type SubscribeOptions, TC832_RESERVED_SCOPES, type TableInfo, TelemetryConfig, TelemetrySpanEventSchema, type TelemetrySpanEventType, type TinyCloudDebugEnableOptions, type TinyCloudDebugEvent, type TinyCloudDebugLevel, TinyCloudDebugLogger, type TinyCloudDebugTimer, TinyCloudQuota, type ValidationError, type VaultCrypto, type VaultEntry, type VaultError, type VaultGetOptions, type VaultGrantOptions, VaultHeaders, type VaultListOptions, type VaultListPage, type VaultNetworkReadResult, VaultPublicSpaceKVActions, type VaultPutOptions, type ViewInfo, type WasmVaultFunctions, abortedError, appSecretScope, authExpiredError, authRequiredError, authUnauthorizedError, authorizationVerdictOf, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isStorageFullError, networkError, nodeRetryError, notFoundError, parseAuthError, parseCapabilityResource, parsePermissionHint, parsePermissionHintFromErrorText, parseSecretCatalogKey, parseStorageQuotaBytes, parseStorageRejection, parseStorageStatus, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, storageRejectionError, storageUsageState, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, validatedCapabilityOf, wrapError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { a as IServiceContext, c as InvokeFunction, d as InvokeAnyFunction, F as FetchFunction, S as ServiceSession, e as RetryPolicy, T as TelemetryConfig, I as IService, E as EventHandler, b as ServiceError, R as Result, P as PermissionHint, f as StorageQuotaInfo } from './types-
|
|
2
|
-
export { g as ErrorCode, h as ErrorCodes, i as FetchRequestInit, j as FetchResponse, k as InvocationFact, l as InvocationFacts, m as InvokeAnyEntry, n as ServiceErrorEvent, o as ServiceHeaders, p as ServiceRequestEvent, q as ServiceResponseEvent, r as ServiceRetryEvent, s as TelemetryEventHandler, t as TelemetryEvents, u as TelemetrySpanEvent, v as defaultRetryPolicy, w as err, x as ok, y as serviceError } from './types-
|
|
1
|
+
import { a as IServiceContext, c as InvokeFunction, d as InvokeAnyFunction, F as FetchFunction, S as ServiceSession, e as RetryPolicy, T as TelemetryConfig, I as IService, E as EventHandler, b as ServiceError, R as Result, P as PermissionHint, f as StorageQuotaInfo } from './types-BjH0ZtGy.js';
|
|
2
|
+
export { g as ErrorCode, h as ErrorCodes, i as FetchRequestInit, j as FetchResponse, k as InvocationFact, l as InvocationFacts, m as InvokeAnyEntry, n as ServiceErrorEvent, o as ServiceHeaders, p as ServiceRequestEvent, q as ServiceResponseEvent, r as ServiceRetryEvent, s as TelemetryEventHandler, t as TelemetryEvents, u as TelemetrySpanEvent, v as defaultRetryPolicy, w as err, x as ok, y as serviceError } from './types-BjH0ZtGy.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BaseService } from './BaseService-
|
|
5
|
-
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-
|
|
4
|
+
import { B as BaseService } from './BaseService-DOdXd7sr.js';
|
|
5
|
+
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-DOdXd7sr.js';
|
|
6
6
|
import { IKVService } from './kv/index.js';
|
|
7
7
|
export { IPrefixedKVService, KVService, PrefixedKVService } from './kv/index.js';
|
|
8
|
-
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING,
|
|
8
|
+
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, aq as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, ar as KVAction, as as KVActionType, at as KVBatchPutItem, au as KVBatchPutOptions, av as KVBatchPutResponse, aw as KVBatchReadResponse, ax as KVChange, ay as KVChangesAuthority, az as KVChangesOptions, aA as KVChangesResponse, aB as KVCreateSignedReadUrlOptions, aC as KVDeleteOptions, aD as KVGetOptions, aE as KVHeadOptions, aF as KVListOptions, b as KVListPage, aG as KVListResponse, aH as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aI as KVResponse, aJ as KVResponseHeaders, aK as KVServiceConfig, aL as KVSignedReadUrlResponse, 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, x as ReplicaAccountGate, y as ReplicaAdmitHook, z as ReplicaAuthorityState, B as ReplicaBrowserGateAccess, D as ReplicaBrowserGateSnapshot, E as ReplicaBrowserGateTx, F as ReplicaBrowserPageAdmission, G as ReplicaClock, H as ReplicaCoverage, I as ReplicaDeliveryDecision, J as ReplicaDenyInput, M as ReplicaDenyOutcome, N as ReplicaDevice, O as ReplicaEraseReport, Q as ReplicaGateAccess, S as ReplicaGateReason, T as ReplicaGateScope, U as ReplicaGateSnapshot, V as ReplicaGateTx, W as ReplicaGatedError, X as ReplicaGatedHandle, Y as ReplicaGatedSpec, Z as ReplicaGatedStorage, _ as ReplicaGrantInfo, $ as ReplicaGuardedStore, a0 as ReplicaInspectedStatus, a1 as ReplicaLifecycleGate, a2 as ReplicaPageAdmission, a3 as ReplicaPartitionEraser, a4 as ReplicaPartitionIndexEntry, a5 as ReplicaPeerCommit, a6 as ReplicaPrivateGateHash, a7 as ReplicaPurgeIntent, a8 as ReplicaQuotaLedger, a9 as ReplicaQuotaSpec, aa as ReplicaSessionStamp, ab as ReplicaStampedReply, ac as ReplicaState, ad as ReplicaStatusEntry, ae as ReplicationAuthority, af as ReplicationControl, ag as ReplicationEvent, R as ReplicationIdentity, ah as ReplicationOptions, ai as ReplicationPurgeReport, aj as ReplicationReason, ak as ReplicationScheduler, al as ResolvedReplicationOptions, am as SaltedHash, an as canonicalReplicationIdentity, ao as replicationIdentityKey, ap as requiresSecretsOptIn } from './scope-B-m6cKH-.js';
|
|
9
|
+
export { ClampConsentAnchor, ConsentDeadlineMs, EffectiveGrantExpiry, EffectiveGrantExpiryInput, MintRemainingMs, NeedsSilentRenewal, ReplicaConsentAnchor, ReplicaConsentSource, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.js';
|
|
9
10
|
export { BatchOptions, BatchResponse, DatabaseHandle, ExecuteOptions, ExecuteResponse, IDatabaseHandle, ISQLMigrations, ISQLService, QueryOptions, QueryResponse, SQLAction, SQLActionType, SQLMigrations, SQLService, SQLServiceConfig, SqlMigration, SqlMigrationApplyOptions, SqlMigrationApplyResponse, SqlStatement, SqlValue } from './sql/index.js';
|
|
10
11
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.js';
|
|
11
12
|
export { BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CanonicalDecryptRequest, CanonicalJson, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, InlineEncryptedEnvelope, Json, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, SignedReceiverKeyInput, VerifyDecryptResponseInput, WellKnownDescriptorFetcher, base64Decode, base64Encode, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalize as canonicalizeEncryptionJson, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, encryptionError, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, hexDecode, hexEncode, isNetworkId, networkDiscoveryKey, openWrappedKey, parseNetworkId, utf8Decode, utf8Encode, validateEnvelope, verifyDecryptResponse } from './encryption/index.js';
|
|
12
13
|
export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
|
|
13
14
|
export { kvPrefixCovers } from './kv/replication/prefix.js';
|
|
15
|
+
import './kv/replication/contractConstants.js';
|
|
16
|
+
import './kv/replication/grantPolicyConstants.js';
|
|
14
17
|
|
|
15
18
|
type TinyCloudDebugLevel = "debug";
|
|
16
19
|
interface TinyCloudDebugEvent {
|
|
@@ -488,14 +491,14 @@ declare const ServiceRequestEventSchema: z.ZodObject<{
|
|
|
488
491
|
timestamp: z.ZodNumber;
|
|
489
492
|
}, "strip", z.ZodTypeAny, {
|
|
490
493
|
timestamp: number;
|
|
491
|
-
service: string;
|
|
492
494
|
action: string;
|
|
495
|
+
service: string;
|
|
493
496
|
key?: string | undefined;
|
|
494
497
|
span?: string | undefined;
|
|
495
498
|
}, {
|
|
496
499
|
timestamp: number;
|
|
497
|
-
service: string;
|
|
498
500
|
action: string;
|
|
501
|
+
service: string;
|
|
499
502
|
key?: string | undefined;
|
|
500
503
|
span?: string | undefined;
|
|
501
504
|
}>;
|
|
@@ -514,16 +517,16 @@ declare const ServiceResponseEventSchema: z.ZodObject<{
|
|
|
514
517
|
}, "strip", z.ZodTypeAny, {
|
|
515
518
|
duration: number;
|
|
516
519
|
ok: boolean;
|
|
517
|
-
service: string;
|
|
518
520
|
action: string;
|
|
521
|
+
service: string;
|
|
519
522
|
durationMs?: number | undefined;
|
|
520
523
|
status?: number | undefined;
|
|
521
524
|
span?: string | undefined;
|
|
522
525
|
}, {
|
|
523
526
|
duration: number;
|
|
524
527
|
ok: boolean;
|
|
525
|
-
service: string;
|
|
526
528
|
action: string;
|
|
529
|
+
service: string;
|
|
527
530
|
durationMs?: number | undefined;
|
|
528
531
|
status?: number | undefined;
|
|
529
532
|
span?: string | undefined;
|
|
@@ -682,8 +685,8 @@ declare const TelemetrySpanEventSchema: z.ZodObject<{
|
|
|
682
685
|
meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
683
686
|
} | undefined;
|
|
684
687
|
status?: number | undefined;
|
|
685
|
-
service?: string | undefined;
|
|
686
688
|
action?: string | undefined;
|
|
689
|
+
service?: string | undefined;
|
|
687
690
|
}, {
|
|
688
691
|
durationMs: number;
|
|
689
692
|
ok: boolean;
|
|
@@ -696,8 +699,8 @@ declare const TelemetrySpanEventSchema: z.ZodObject<{
|
|
|
696
699
|
meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
697
700
|
} | undefined;
|
|
698
701
|
status?: number | undefined;
|
|
699
|
-
service?: string | undefined;
|
|
700
702
|
action?: string | undefined;
|
|
703
|
+
service?: string | undefined;
|
|
701
704
|
}>;
|
|
702
705
|
type TelemetrySpanEventType = z.infer<typeof TelemetrySpanEventSchema>;
|
|
703
706
|
/**
|
|
@@ -1054,6 +1057,29 @@ declare function authExpiredError(service: string): ServiceError;
|
|
|
1054
1057
|
* Create a service error for network issues.
|
|
1055
1058
|
*/
|
|
1056
1059
|
declare function networkError(service: string, message: string, cause?: Error): ServiceError;
|
|
1060
|
+
/**
|
|
1061
|
+
* Classify a node retry signal (tinycloud-node #347, TC-1054). The node's
|
|
1062
|
+
* bodies are plain text led by a stable token:
|
|
1063
|
+
* - `503 sql_busy: <stage>: ...` and `503 unavailable_retryable: ...` are
|
|
1064
|
+
* `NODE_BUSY`: nothing was applied; retry after `meta.retryAfterMs`.
|
|
1065
|
+
* - `503 request_timeout: ...` is `REQUEST_TIMEOUT`: the deadline passed before
|
|
1066
|
+
* any write began, so nothing was applied.
|
|
1067
|
+
* - `500 outcome_unknown: ...` is `OUTCOME_UNKNOWN`: a write may have been
|
|
1068
|
+
* applied; read back before retrying a non-idempotent operation.
|
|
1069
|
+
*
|
|
1070
|
+
* `meta.retryable` is the safe-to-retry verdict and `meta.retryAfterMs` the
|
|
1071
|
+
* node's `Retry-After` (the node sends whole seconds; anything else is
|
|
1072
|
+
* ignored). The SDK never retries on its own. Returns `undefined` for any
|
|
1073
|
+
* other response, including the bodyless 503/500 of nodes before 1.21, which
|
|
1074
|
+
* callers keep classifying as they always did.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function nodeRetryError(service: string, message: string, response: {
|
|
1077
|
+
status: number;
|
|
1078
|
+
statusText: string;
|
|
1079
|
+
headers: {
|
|
1080
|
+
get(name: string): string | null;
|
|
1081
|
+
};
|
|
1082
|
+
}, errorText: string): ServiceError | undefined;
|
|
1057
1083
|
/**
|
|
1058
1084
|
* Create a service error for timeouts.
|
|
1059
1085
|
*
|
|
@@ -2581,4 +2607,4 @@ declare class SecretsService implements ISecretsService {
|
|
|
2581
2607
|
listAll(): Promise<Result<SecretCatalogEntry[], SecretsError>>;
|
|
2582
2608
|
}
|
|
2583
2609
|
|
|
2584
|
-
export { type AuthorizationVerdict, BaseService, type ColumnInfo, type DataVaultConfig, DataVaultService, DecryptCapabilityProof, DuckDbAction, type DuckDbActionType, type DuckDbBatchOptions, type BatchResponse as DuckDbBatchResponse, DuckDbDatabaseHandle, type DuckDbExecuteOptions, type ExecuteResponse as DuckDbExecuteResponse, type DuckDbOptions, type DuckDbQueryOptions, type QueryResponse as DuckDbQueryResponse, DuckDbService, type DuckDbServiceConfig, type DuckDbStatement, type DuckDbValue, EventHandler, FetchFunction, GenericKVResponseSchema, type GenericKVResponseType, GenericResultSchema, type HookEvent, type HookServiceName, type HookStreamEvent, type HookStreamRetryConfig, type HookSubscription, type HookWebhookListOptions, type HookWebhookRecord, type HookWebhookRegistration, type HookWebhookScope, type HookWebhookUnregisterOptions, HooksService, type HooksServiceConfig, type IDataVaultService, type IDuckDbDatabaseHandle, type IDuckDbService, IEncryptionService, type IHooksService, IKVService, type ISecretsService, IService, IServiceContext, type IStorageService, InvokeAnyFunction, InvokeFunction, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, SECRET_SCOPE_RE, STORAGE_FULL_MESSAGE, STORAGE_MANAGE_URL, STORAGE_NEARLY_FULL_RATIO, STORAGE_WRITE_TOO_LARGE_MESSAGE, type SchemaInfo, type SecretCatalogEntry, type SecretPayload, type SecretPutOptions, type SecretScopeOptions, type SecretsError, SecretsService, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, ServiceRequestEventSchema, type ServiceRequestEventType, ServiceResponseEventSchema, type ServiceResponseEventType, ServiceRetryEventSchema, type ServiceRetryEventType, ServiceSession, ServiceSessionSchema, type ServiceSessionType, type StorageAccountUsage, type StorageFullEvent, type StorageFullHandler, StorageFullMonitor, StorageQuotaInfo, type StorageRejectionDetails, type StorageStatus, type StorageStatusOptions, type StorageUsage, type StorageUsageState, type SubscribeOptions, TC832_RESERVED_SCOPES, type TableInfo, TelemetryConfig, TelemetrySpanEventSchema, type TelemetrySpanEventType, type TinyCloudDebugEnableOptions, type TinyCloudDebugEvent, type TinyCloudDebugLevel, TinyCloudDebugLogger, type TinyCloudDebugTimer, TinyCloudQuota, type ValidationError, type VaultCrypto, type VaultEntry, type VaultError, type VaultGetOptions, type VaultGrantOptions, VaultHeaders, type VaultListOptions, type VaultListPage, type VaultNetworkReadResult, VaultPublicSpaceKVActions, type VaultPutOptions, type ViewInfo, type WasmVaultFunctions, abortedError, appSecretScope, authExpiredError, authRequiredError, authUnauthorizedError, authorizationVerdictOf, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isStorageFullError, networkError, notFoundError, parseAuthError, parseCapabilityResource, parsePermissionHint, parsePermissionHintFromErrorText, parseSecretCatalogKey, parseStorageQuotaBytes, parseStorageRejection, parseStorageStatus, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, storageRejectionError, storageUsageState, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, validatedCapabilityOf, wrapError };
|
|
2610
|
+
export { type AuthorizationVerdict, BaseService, type ColumnInfo, type DataVaultConfig, DataVaultService, DecryptCapabilityProof, DuckDbAction, type DuckDbActionType, type DuckDbBatchOptions, type BatchResponse as DuckDbBatchResponse, DuckDbDatabaseHandle, type DuckDbExecuteOptions, type ExecuteResponse as DuckDbExecuteResponse, type DuckDbOptions, type DuckDbQueryOptions, type QueryResponse as DuckDbQueryResponse, DuckDbService, type DuckDbServiceConfig, type DuckDbStatement, type DuckDbValue, EventHandler, FetchFunction, GenericKVResponseSchema, type GenericKVResponseType, GenericResultSchema, type HookEvent, type HookServiceName, type HookStreamEvent, type HookStreamRetryConfig, type HookSubscription, type HookWebhookListOptions, type HookWebhookRecord, type HookWebhookRegistration, type HookWebhookScope, type HookWebhookUnregisterOptions, HooksService, type HooksServiceConfig, type IDataVaultService, type IDuckDbDatabaseHandle, type IDuckDbService, IEncryptionService, type IHooksService, IKVService, type ISecretsService, IService, IServiceContext, type IStorageService, InvokeAnyFunction, InvokeFunction, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, SECRET_SCOPE_RE, STORAGE_FULL_MESSAGE, STORAGE_MANAGE_URL, STORAGE_NEARLY_FULL_RATIO, STORAGE_WRITE_TOO_LARGE_MESSAGE, type SchemaInfo, type SecretCatalogEntry, type SecretPayload, type SecretPutOptions, type SecretScopeOptions, type SecretsError, SecretsService, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, ServiceRequestEventSchema, type ServiceRequestEventType, ServiceResponseEventSchema, type ServiceResponseEventType, ServiceRetryEventSchema, type ServiceRetryEventType, ServiceSession, ServiceSessionSchema, type ServiceSessionType, type StorageAccountUsage, type StorageFullEvent, type StorageFullHandler, StorageFullMonitor, StorageQuotaInfo, type StorageRejectionDetails, type StorageStatus, type StorageStatusOptions, type StorageUsage, type StorageUsageState, type SubscribeOptions, TC832_RESERVED_SCOPES, type TableInfo, TelemetryConfig, TelemetrySpanEventSchema, type TelemetrySpanEventType, type TinyCloudDebugEnableOptions, type TinyCloudDebugEvent, type TinyCloudDebugLevel, TinyCloudDebugLogger, type TinyCloudDebugTimer, TinyCloudQuota, type ValidationError, type VaultCrypto, type VaultEntry, type VaultError, type VaultGetOptions, type VaultGrantOptions, VaultHeaders, type VaultListOptions, type VaultListPage, type VaultNetworkReadResult, VaultPublicSpaceKVActions, type VaultPutOptions, type ViewInfo, type WasmVaultFunctions, abortedError, appSecretScope, authExpiredError, authRequiredError, authUnauthorizedError, authorizationVerdictOf, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isStorageFullError, networkError, nodeRetryError, notFoundError, parseAuthError, parseCapabilityResource, parsePermissionHint, parsePermissionHintFromErrorText, parseSecretCatalogKey, parseStorageQuotaBytes, parseStorageRejection, parseStorageStatus, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, storageRejectionError, storageUsageState, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, validatedCapabilityOf, wrapError };
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,14 @@ var ErrorCodes = {
|
|
|
14
14
|
ABORTED: "ABORTED",
|
|
15
15
|
INVALID_INPUT: "INVALID_INPUT",
|
|
16
16
|
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
17
|
+
// Node retry signals (tinycloud-node #347). `meta.retryable` says whether a
|
|
18
|
+
// retry is safe; `meta.retryAfterMs` carries the node's Retry-After.
|
|
19
|
+
/** HTTP 503 `sql_busy:<stage>` / `unavailable_retryable`: nothing was applied; retry after `meta.retryAfterMs`. */
|
|
20
|
+
NODE_BUSY: "NODE_BUSY",
|
|
21
|
+
/** HTTP 503 `request_timeout`: the node's deadline passed before any write began; nothing was applied. */
|
|
22
|
+
REQUEST_TIMEOUT: "REQUEST_TIMEOUT",
|
|
23
|
+
/** HTTP 500 `outcome_unknown`: a write may have been applied; read back before retrying a non-idempotent operation. */
|
|
24
|
+
OUTCOME_UNKNOWN: "OUTCOME_UNKNOWN",
|
|
17
25
|
// KV-specific errors
|
|
18
26
|
KV_NOT_FOUND: "KV_NOT_FOUND",
|
|
19
27
|
KV_WRITE_FAILED: "KV_WRITE_FAILED",
|
|
@@ -68,6 +76,8 @@ var TelemetryEvents = {
|
|
|
68
76
|
REPLICATION_SYNC: "replication.sync",
|
|
69
77
|
REPLICATION_STATE: "replication.state",
|
|
70
78
|
REPLICATION_DIVERGENCE: "replication.divergence",
|
|
79
|
+
REPLICATION_GRANT: "replication.grant",
|
|
80
|
+
REPLICATION_LIFECYCLE: "replication.lifecycle",
|
|
71
81
|
/** Emitted once, on the first write rejected because storage is full. */
|
|
72
82
|
STORAGE_FULL: "storage.full"
|
|
73
83
|
};
|
|
@@ -104,21 +114,27 @@ var SAFE_NUMBER_FIELDS = /* @__PURE__ */ new Set([
|
|
|
104
114
|
"fetched",
|
|
105
115
|
"pages",
|
|
106
116
|
"lagMs",
|
|
107
|
-
"pendingCleared"
|
|
117
|
+
"pendingCleared",
|
|
118
|
+
"partitions",
|
|
119
|
+
"remaining",
|
|
120
|
+
"expiryMs"
|
|
108
121
|
]);
|
|
109
|
-
var SAFE_BOOLEAN_FIELDS = /* @__PURE__ */ new Set(["authenticated", "ok", "persisted"]);
|
|
122
|
+
var SAFE_BOOLEAN_FIELDS = /* @__PURE__ */ new Set(["authenticated", "ok", "persisted", "purgePending"]);
|
|
110
123
|
var SAFE_REPLICATION_FIELDS = {
|
|
111
124
|
source: ["replica", "network", "none"],
|
|
112
|
-
reason: ["hit", "absent", "deleted", "content_missing", "coverage_incomplete", "not_covered", "pending_write", "grant_missing", "grant_expired", "grant_revoked", "grant_not_yet_valid", "stale", "replica_error", "runtime_unsupported", "replica_unavailable", "unsupported_option", "network_cursor", "cursor_restart", "aborted", "REPLICA_BEHIND_OWN_WRITES", "REPLICA_UNPROVEN_SINCE_START", "NETWORK_REQUESTED"],
|
|
125
|
+
reason: ["hit", "absent", "deleted", "content_missing", "coverage_incomplete", "not_covered", "pending_write", "grant_missing", "grant_expired", "grant_revoked", "grant_not_yet_valid", "stale", "replica_error", "runtime_unsupported", "replica_unavailable", "unsupported_option", "network_cursor", "cursor_restart", "aborted", "REPLICA_BEHIND_OWN_WRITES", "REPLICA_UNPROVEN_SINCE_START", "NETWORK_REQUESTED", "replica_gated", "sign_out", "account_switch", "consent_expired", "startup"],
|
|
113
126
|
op: ["get", "list", "put", "delete", "batchPut"],
|
|
114
|
-
trigger: ["start", "interval", "stale_read", "manual"],
|
|
127
|
+
trigger: ["start", "interval", "stale_read", "manual", "peer"],
|
|
128
|
+
origin: ["peer"],
|
|
115
129
|
outcome: ["found", "not_found", "error", "committed", "failed", "ambiguous", "ok", "busy", "aborted"],
|
|
116
|
-
class: ["offline", "authority", "storage", "node"],
|
|
117
|
-
state: ["opened", "grant_installed", "grant_missing", "runtime_unsupported", "unavailable", "revoked", "recreated", "purged", "purge_failed", "pending_store_error", "pinned", "pending_cleared", "closed", "idle", "ready"],
|
|
130
|
+
class: ["offline", "authority", "storage", "node", "lifecycle"],
|
|
131
|
+
state: ["opened", "grant_installed", "grant_missing", "runtime_unsupported", "unavailable", "revoked", "recreated", "purged", "purge_failed", "pending_store_error", "pinned", "pending_cleared", "closed", "idle", "ready", "gated"],
|
|
132
|
+
action: ["minted", "renewed", "renewal_refused", "renewal_deferred", "capped", "expired", "consent_deadline_reached", "denied", "deny_stale", "deny_failed", "database_deleted", "marker_set", "marker_cleared", "unguarded", "drained", "erased", "erase_failed", "activation_blocked", "activated", "recovered"],
|
|
133
|
+
gate: ["not_established", "stamp_stale", "principal_mismatch", "purge_pending", "logout_pending", "gate_unavailable"],
|
|
118
134
|
kind: ["value", "missing_local", "extra_local", "keys", "order"],
|
|
119
135
|
coverage: ["empty", "bootstrapping", "complete"],
|
|
120
136
|
authority: ["valid", "expired", "revoked", "not-yet-valid"],
|
|
121
|
-
code: ["NETWORK_ERROR", "TIMEOUT", "ABORTED", "REPLICA_BUSY", "REPLICA_BEHIND_OWN_WRITES", "REPLICA_UNPROVEN_SINCE_START", "NETWORK_REQUESTED", "INTEGRITY_ERROR", "STORAGE_ERROR", "REPLICA_CLOSED", "RUNTIME_UNSUPPORTED", "GRANT_EXPIRED", "GRANT_REVOKED", "GRANT_NOT_YET_VALID", "GRANT_MISSING", "GRANT_INVALID", "SOURCE_CHANGED", "PROTOCOL_ERROR", "SCOPE_VIOLATION", "NODE_ERROR", "CONTENT_MISMATCH", "STORAGE_FULL"],
|
|
137
|
+
code: ["NETWORK_ERROR", "TIMEOUT", "ABORTED", "REPLICA_BUSY", "REPLICA_BEHIND_OWN_WRITES", "REPLICA_UNPROVEN_SINCE_START", "NETWORK_REQUESTED", "INTEGRITY_ERROR", "STORAGE_ERROR", "REPLICA_CLOSED", "RUNTIME_UNSUPPORTED", "GRANT_EXPIRED", "GRANT_REVOKED", "GRANT_NOT_YET_VALID", "GRANT_MISSING", "GRANT_INVALID", "SOURCE_CHANGED", "PROTOCOL_ERROR", "SCOPE_VIOLATION", "NODE_ERROR", "CONTENT_MISMATCH", "STORAGE_FULL", "REPLICA_GATED", "RESET_REQUIRED", "STORAGE_BUDGET", "CONSENT_EXPIRED"],
|
|
122
138
|
pendingState: ["in_flight", "committed", "ambiguous"],
|
|
123
139
|
strategy: ["session", "minted", "installed"],
|
|
124
140
|
verify: ["match", "diverged", "error", "aborted"]
|
|
@@ -950,6 +966,42 @@ var ServiceContext = class {
|
|
|
950
966
|
}
|
|
951
967
|
};
|
|
952
968
|
|
|
969
|
+
// src/responseErrors.ts
|
|
970
|
+
function parseServiceErrorBody(errorText) {
|
|
971
|
+
try {
|
|
972
|
+
return JSON.parse(errorText);
|
|
973
|
+
} catch {
|
|
974
|
+
return {};
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
function formatServiceResponseError(serviceLabel, operation, status, errorText, parsed) {
|
|
978
|
+
if (parsed.message) {
|
|
979
|
+
return compactMessage(parsed.message);
|
|
980
|
+
}
|
|
981
|
+
if (looksLikeHtml(errorText)) {
|
|
982
|
+
if (status === 524 || /524\s*[:-]/i.test(errorText) || /a timeout occurred/i.test(errorText)) {
|
|
983
|
+
return `${serviceLabel} ${operation} failed: upstream request timed out. Please retry.`;
|
|
984
|
+
}
|
|
985
|
+
return `${serviceLabel} ${operation} failed: upstream service returned an HTML error page (${status}).`;
|
|
986
|
+
}
|
|
987
|
+
return `${serviceLabel} ${operation} failed: ${status} - ${compactMessage(errorText)}`;
|
|
988
|
+
}
|
|
989
|
+
function responseErrorMeta(status, statusText, errorText) {
|
|
990
|
+
const meta = { status, statusText };
|
|
991
|
+
const snippet = compactMessage(errorText);
|
|
992
|
+
if (snippet) {
|
|
993
|
+
meta.responseSnippet = snippet.slice(0, 300);
|
|
994
|
+
}
|
|
995
|
+
return meta;
|
|
996
|
+
}
|
|
997
|
+
function looksLikeHtml(text) {
|
|
998
|
+
return /<!doctype html/i.test(text) || /<html[\s>]/i.test(text);
|
|
999
|
+
}
|
|
1000
|
+
function compactMessage(message) {
|
|
1001
|
+
const compact = message.replace(/\s+/g, " ").trim();
|
|
1002
|
+
return compact.length > 500 ? `${compact.slice(0, 500)}...` : compact;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
953
1005
|
// src/errors.ts
|
|
954
1006
|
import { CAPABILITY_REGISTRY } from "@tinycloud/bootstrap";
|
|
955
1007
|
|
|
@@ -1109,6 +1161,30 @@ function networkError(service, message, cause) {
|
|
|
1109
1161
|
cause
|
|
1110
1162
|
};
|
|
1111
1163
|
}
|
|
1164
|
+
function nodeRetryError(service, message, response, errorText) {
|
|
1165
|
+
const body = errorText.trim();
|
|
1166
|
+
const [, token, stage] = /^([a-z_]+)(?::\s*([a-z_]+):)?/.exec(body) ?? [];
|
|
1167
|
+
let code;
|
|
1168
|
+
if (response.status === 503 && (token === "sql_busy" || token === "unavailable_retryable")) {
|
|
1169
|
+
code = ErrorCodes.NODE_BUSY;
|
|
1170
|
+
} else if (response.status === 503 && token === "request_timeout") {
|
|
1171
|
+
code = ErrorCodes.REQUEST_TIMEOUT;
|
|
1172
|
+
} else if (response.status === 500 && token === "outcome_unknown") {
|
|
1173
|
+
code = ErrorCodes.OUTCOME_UNKNOWN;
|
|
1174
|
+
} else {
|
|
1175
|
+
return void 0;
|
|
1176
|
+
}
|
|
1177
|
+
const retryable = code !== ErrorCodes.OUTCOME_UNKNOWN;
|
|
1178
|
+
const retryAfter = response.headers.get("retry-after")?.trim();
|
|
1179
|
+
return serviceError(code, message, service, {
|
|
1180
|
+
meta: {
|
|
1181
|
+
...responseErrorMeta(response.status, response.statusText, errorText),
|
|
1182
|
+
retryable,
|
|
1183
|
+
...token === "sql_busy" && stage ? { stage } : {},
|
|
1184
|
+
...retryable && retryAfter && /^\d{1,9}$/.test(retryAfter) ? { retryAfterMs: Number(retryAfter) * 1e3 } : {}
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1112
1188
|
var RequestTimeoutError = class extends Error {
|
|
1113
1189
|
constructor(timeoutMs) {
|
|
1114
1190
|
super(`Request timed out after ${timeoutMs}ms.`);
|
|
@@ -2447,9 +2523,12 @@ var KVService = class extends BaseService {
|
|
|
2447
2523
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
2448
2524
|
));
|
|
2449
2525
|
}
|
|
2526
|
+
const message = `Failed to get key ${JSON.stringify(key)}: ${response.status} - ${errorText}`;
|
|
2527
|
+
const retryError = nodeRetryError("kv", message, response, errorText);
|
|
2528
|
+
if (retryError) return err(retryError);
|
|
2450
2529
|
return err(serviceError(
|
|
2451
2530
|
ErrorCodes.NETWORK_ERROR,
|
|
2452
|
-
|
|
2531
|
+
message,
|
|
2453
2532
|
"kv",
|
|
2454
2533
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
2455
2534
|
));
|
|
@@ -2531,19 +2610,14 @@ var KVService = class extends BaseService {
|
|
|
2531
2610
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
2532
2611
|
));
|
|
2533
2612
|
}
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
`Concurrent KV update conflicted for key ${JSON.stringify(key)}`,
|
|
2538
|
-
"kv",
|
|
2539
|
-
{ meta: { status: response.status, statusText: response.statusText } }
|
|
2540
|
-
));
|
|
2541
|
-
}
|
|
2613
|
+
const message = `Failed to put key ${JSON.stringify(key)}: ${response.status} - ${errorText}`;
|
|
2614
|
+
const retryError = nodeRetryError("kv", message, response, errorText);
|
|
2615
|
+
if (retryError) return err(retryError);
|
|
2542
2616
|
const quotaError = this.handleQuotaErrorResponse(response, errorText, key);
|
|
2543
2617
|
if (quotaError) return quotaError;
|
|
2544
2618
|
return err(serviceError(
|
|
2545
2619
|
ErrorCodes.KV_WRITE_FAILED,
|
|
2546
|
-
|
|
2620
|
+
message,
|
|
2547
2621
|
"kv",
|
|
2548
2622
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
2549
2623
|
));
|
|
@@ -2843,9 +2917,12 @@ var KVService = class extends BaseService {
|
|
|
2843
2917
|
);
|
|
2844
2918
|
}
|
|
2845
2919
|
const errorText = await response.text();
|
|
2920
|
+
const message = `Failed to list keys: ${response.status} - ${errorText}`;
|
|
2921
|
+
const retryError = nodeRetryError("kv", message, response, errorText);
|
|
2922
|
+
if (retryError) return err(retryError);
|
|
2846
2923
|
return err(serviceError(
|
|
2847
2924
|
ErrorCodes.NETWORK_ERROR,
|
|
2848
|
-
|
|
2925
|
+
message,
|
|
2849
2926
|
"kv",
|
|
2850
2927
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
2851
2928
|
));
|
|
@@ -3096,17 +3173,12 @@ var KVService = class extends BaseService {
|
|
|
3096
3173
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
3097
3174
|
));
|
|
3098
3175
|
}
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
`Concurrent KV delete conflicted for key ${JSON.stringify(key)}`,
|
|
3103
|
-
"kv",
|
|
3104
|
-
{ meta: { status: response.status, statusText: response.statusText } }
|
|
3105
|
-
));
|
|
3106
|
-
}
|
|
3176
|
+
const message = `Failed to delete key ${JSON.stringify(key)}: ${response.status} - ${errorText}`;
|
|
3177
|
+
const retryError = nodeRetryError("kv", message, response, errorText);
|
|
3178
|
+
if (retryError) return err(retryError);
|
|
3107
3179
|
return err(serviceError(
|
|
3108
3180
|
ErrorCodes.NETWORK_ERROR,
|
|
3109
|
-
|
|
3181
|
+
message,
|
|
3110
3182
|
"kv",
|
|
3111
3183
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
3112
3184
|
));
|
|
@@ -3147,10 +3219,13 @@ var KVService = class extends BaseService {
|
|
|
3147
3219
|
return await this.classifyNotFound(response, key);
|
|
3148
3220
|
}
|
|
3149
3221
|
const errorText = await response.text();
|
|
3222
|
+
const message = `Failed to get metadata for key ${JSON.stringify(key)}: ${response.status} - ${errorText}`;
|
|
3223
|
+
const retryError = nodeRetryError("kv", message, response, errorText);
|
|
3224
|
+
if (retryError) return err(retryError);
|
|
3150
3225
|
return err(
|
|
3151
3226
|
serviceError(
|
|
3152
3227
|
ErrorCodes.NETWORK_ERROR,
|
|
3153
|
-
|
|
3228
|
+
message,
|
|
3154
3229
|
"kv",
|
|
3155
3230
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
3156
3231
|
)
|
|
@@ -3342,42 +3417,6 @@ function requiresSecretsOptIn(space, prefix) {
|
|
|
3342
3417
|
return prefix.split("/", 1)[0] === "vault";
|
|
3343
3418
|
}
|
|
3344
3419
|
|
|
3345
|
-
// src/responseErrors.ts
|
|
3346
|
-
function parseServiceErrorBody(errorText) {
|
|
3347
|
-
try {
|
|
3348
|
-
return JSON.parse(errorText);
|
|
3349
|
-
} catch {
|
|
3350
|
-
return {};
|
|
3351
|
-
}
|
|
3352
|
-
}
|
|
3353
|
-
function formatServiceResponseError(serviceLabel, operation, status, errorText, parsed) {
|
|
3354
|
-
if (parsed.message) {
|
|
3355
|
-
return compactMessage(parsed.message);
|
|
3356
|
-
}
|
|
3357
|
-
if (looksLikeHtml(errorText)) {
|
|
3358
|
-
if (status === 524 || /524\s*[:-]/i.test(errorText) || /a timeout occurred/i.test(errorText)) {
|
|
3359
|
-
return `${serviceLabel} ${operation} failed: upstream request timed out. Please retry.`;
|
|
3360
|
-
}
|
|
3361
|
-
return `${serviceLabel} ${operation} failed: upstream service returned an HTML error page (${status}).`;
|
|
3362
|
-
}
|
|
3363
|
-
return `${serviceLabel} ${operation} failed: ${status} - ${compactMessage(errorText)}`;
|
|
3364
|
-
}
|
|
3365
|
-
function responseErrorMeta(status, statusText, errorText) {
|
|
3366
|
-
const meta = { status, statusText };
|
|
3367
|
-
const snippet = compactMessage(errorText);
|
|
3368
|
-
if (snippet) {
|
|
3369
|
-
meta.responseSnippet = snippet.slice(0, 300);
|
|
3370
|
-
}
|
|
3371
|
-
return meta;
|
|
3372
|
-
}
|
|
3373
|
-
function looksLikeHtml(text) {
|
|
3374
|
-
return /<!doctype html/i.test(text) || /<html[\s>]/i.test(text);
|
|
3375
|
-
}
|
|
3376
|
-
function compactMessage(message) {
|
|
3377
|
-
const compact = message.replace(/\s+/g, " ").trim();
|
|
3378
|
-
return compact.length > 500 ? `${compact.slice(0, 500)}...` : compact;
|
|
3379
|
-
}
|
|
3380
|
-
|
|
3381
3420
|
// src/sql/SQLMigrations.ts
|
|
3382
3421
|
var SQLMigrations = class {
|
|
3383
3422
|
constructor(service, dbName) {
|
|
@@ -3793,6 +3832,8 @@ var SQLService = class extends BaseService {
|
|
|
3793
3832
|
if (response.status === 413 && parseStorageRejection(errorText)) {
|
|
3794
3833
|
return err(storageRejectionError("sql", 413, meta, errorText));
|
|
3795
3834
|
}
|
|
3835
|
+
const retryError = nodeRetryError("sql", `SQL ${operation} failed: ${response.status} - ${errorText}`, response, errorText);
|
|
3836
|
+
if (retryError) return err(retryError);
|
|
3796
3837
|
const errorBody = parseServiceErrorBody(errorText);
|
|
3797
3838
|
const errorCode = this.mapHttpStatusToErrorCode(
|
|
3798
3839
|
response.status,
|
|
@@ -4262,6 +4303,8 @@ var DuckDbService = class extends BaseService {
|
|
|
4262
4303
|
if (response.status === 413 && parseStorageRejection(errorText)) {
|
|
4263
4304
|
return err(storageRejectionError("duckdb", 413, meta, errorText));
|
|
4264
4305
|
}
|
|
4306
|
+
const retryError = nodeRetryError("duckdb", `DuckDB ${operation} failed: ${response.status} - ${errorText}`, response, errorText);
|
|
4307
|
+
if (retryError) return err(retryError);
|
|
4265
4308
|
const errorBody = parseServiceErrorBody(errorText);
|
|
4266
4309
|
const errorCode = this.mapHttpStatusToErrorCode(
|
|
4267
4310
|
response.status,
|
|
@@ -8302,6 +8345,7 @@ export {
|
|
|
8302
8345
|
kvPrefixCovers,
|
|
8303
8346
|
networkDiscoveryKey,
|
|
8304
8347
|
networkError,
|
|
8348
|
+
nodeRetryError,
|
|
8305
8349
|
notFoundError,
|
|
8306
8350
|
ok,
|
|
8307
8351
|
openWrappedKey,
|