@tinycloud/sdk-services 3.1.0-beta.1 → 3.1.0-beta.10
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-BhpVpA9b.d.cts → BaseService-B_UKhVht.d.ts} +74 -2
- package/dist/{BaseService-CuV-ZVPs.d.ts → BaseService-DWbPbov7.d.cts} +74 -2
- package/dist/encryption/index.cjs +199 -100
- 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 +199 -100
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +739 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -42
- package/dist/index.d.ts +66 -42
- package/dist/index.js +714 -240
- 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 +568 -74
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +197 -15
- package/dist/kv/index.d.ts +197 -15
- package/dist/kv/index.js +568 -74
- package/dist/kv/index.js.map +1 -1
- package/dist/sql/index.cjs +191 -35
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +6 -3
- package/dist/sql/index.d.ts +6 -3
- package/dist/sql/index.js +182 -26
- package/dist/sql/index.js.map +1 -1
- package/dist/{types-qwMmB7qB.d.cts → types-CVwwxqXF.d.cts} +8 -0
- package/dist/{types-qwMmB7qB.d.ts → types-CVwwxqXF.d.ts} +8 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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-CVwwxqXF.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-CVwwxqXF.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BaseService } from './BaseService-
|
|
4
|
+
import { B as BaseService } from './BaseService-DWbPbov7.cjs';
|
|
5
|
+
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-DWbPbov7.cjs';
|
|
5
6
|
import { IKVService } from './kv/index.cjs';
|
|
6
|
-
export { DEFAULT_SIGNED_READ_URL_EXPIRY_MS, IPrefixedKVService, KVAction, KVActionType, KVBatchPutItem, KVBatchPutOptions, KVBatchPutResponse, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, PrefixedKVService } from './kv/index.cjs';
|
|
7
|
+
export { DEFAULT_SIGNED_READ_URL_EXPIRY_MS, IPrefixedKVService, KVAction, KVActionType, KVBatchPutItem, KVBatchPutOptions, KVBatchPutResponse, KVBatchReadResponse, KVChange, KVChangesAuthority, KVChangesOptions, KVChangesResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, PrefixedKVService } from './kv/index.cjs';
|
|
7
8
|
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';
|
|
8
9
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.cjs';
|
|
9
10
|
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';
|
|
@@ -1050,8 +1051,11 @@ declare function authExpiredError(service: string): ServiceError;
|
|
|
1050
1051
|
declare function networkError(service: string, message: string, cause?: Error): ServiceError;
|
|
1051
1052
|
/**
|
|
1052
1053
|
* Create a service error for timeouts.
|
|
1054
|
+
*
|
|
1055
|
+
* @param timeoutMs - The configured timeout that elapsed, when known
|
|
1056
|
+
* @param cause - The underlying timeout error, when known
|
|
1053
1057
|
*/
|
|
1054
|
-
declare function timeoutError(service: string): ServiceError;
|
|
1058
|
+
declare function timeoutError(service: string, timeoutMs?: number, cause?: Error): ServiceError;
|
|
1055
1059
|
/**
|
|
1056
1060
|
* Create a service error for aborted requests.
|
|
1057
1061
|
*/
|
|
@@ -1083,6 +1087,24 @@ declare function authUnauthorizedError(service: string, message: string, meta?:
|
|
|
1083
1087
|
* - `"other"`: a non-authorization HTTP error status (4xx/5xx).
|
|
1084
1088
|
*/
|
|
1085
1089
|
type AuthorizationVerdict = "unauthenticated" | "forbidden" | "other";
|
|
1090
|
+
/**
|
|
1091
|
+
* Parse a canonical TinyCloud resource, keeping nested space names intact.
|
|
1092
|
+
* The first registered service segment is authoritative: a later matching
|
|
1093
|
+
* segment in the path cannot turn a different service into grant advice.
|
|
1094
|
+
*/
|
|
1095
|
+
declare function parseCapabilityResource(resource: string, service: string): {
|
|
1096
|
+
space: string;
|
|
1097
|
+
path: string;
|
|
1098
|
+
} | undefined;
|
|
1099
|
+
/**
|
|
1100
|
+
* Return a grantable missing capability only when typed authorization evidence
|
|
1101
|
+
* and both safe, service-matched capability fields are present. Status alone,
|
|
1102
|
+
* message text, wildcard actions and unrecognized actions cannot grant scope.
|
|
1103
|
+
*/
|
|
1104
|
+
declare function validatedCapabilityOf(error: unknown): {
|
|
1105
|
+
resource: string;
|
|
1106
|
+
requiredAction: string;
|
|
1107
|
+
} | undefined;
|
|
1086
1108
|
/**
|
|
1087
1109
|
* Classify an error from its typed HTTP error status (`status`, `statusCode`,
|
|
1088
1110
|
* or `meta.status`, 4xx/5xx only) and `AUTH_UNAUTHORIZED` code, following the
|
|
@@ -1101,49 +1123,44 @@ declare function storageQuotaExceededError(service: string, message: string, met
|
|
|
1101
1123
|
* Create a service error for storage limit reached (413 Payload Too Large).
|
|
1102
1124
|
*/
|
|
1103
1125
|
declare function storageLimitReachedError(service: string, message: string, meta?: Record<string, unknown>): ServiceError;
|
|
1126
|
+
/** Shown when a write is rejected because the owner's storage is full. */
|
|
1127
|
+
declare const STORAGE_FULL_MESSAGE = "TinyCloud storage is full, so this change was not saved. Reading still works. Free up space or upgrade your plan to save again.";
|
|
1128
|
+
/** Shown when a write is larger than the storage the owner has left. */
|
|
1129
|
+
declare const STORAGE_WRITE_TOO_LARGE_MESSAGE = "This change is larger than the TinyCloud storage you have left, so it was not saved. Reading still works. Free up space or upgrade your plan to save it.";
|
|
1130
|
+
/**
|
|
1131
|
+
* Parse the byte counts from a node storage rejection
|
|
1132
|
+
* ("... Used: 155744 bytes, Limit: 0 bytes"). The limit is the share of the
|
|
1133
|
+
* owner's account-wide budget left for this space, so it is 0 when the
|
|
1134
|
+
* owner's other spaces already use the whole budget.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function parseStorageQuotaBytes(responseText: string): {
|
|
1137
|
+
usedBytes: number;
|
|
1138
|
+
limitBytes: number;
|
|
1139
|
+
} | undefined;
|
|
1104
1140
|
/**
|
|
1105
|
-
*
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
* Create an error Result from a ServiceError.
|
|
1110
|
-
*/
|
|
1111
|
-
declare function errorResult(error: ServiceError): Result<never, ServiceError>;
|
|
1112
|
-
|
|
1113
|
-
/**
|
|
1114
|
-
* Base Service Types
|
|
1115
|
-
*
|
|
1116
|
-
* Types specific to the base service infrastructure.
|
|
1141
|
+
* Build the error for a write the node rejected for storage: 402 when storage
|
|
1142
|
+
* is already full, 413 when this write is larger than what is left. KV, SQL
|
|
1143
|
+
* and DuckDB all report it with the same codes and message so an app can
|
|
1144
|
+
* detect "storage full" in one place with {@link isStorageFullError}.
|
|
1117
1145
|
*/
|
|
1118
|
-
|
|
1146
|
+
declare function storageRejectionError(service: string, status: 402 | 413, meta: Record<string, unknown>, responseText: string): ServiceError;
|
|
1119
1147
|
/**
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1148
|
+
* True when a write failed for storage: the owner's TinyCloud storage is full
|
|
1149
|
+
* (`STORAGE_QUOTA_EXCEEDED`), or this write is larger than what is left
|
|
1150
|
+
* (`STORAGE_LIMIT_REACHED`). Reads keep working in both cases, so apps should
|
|
1151
|
+
* stay usable read-only and point the user at freeing up space or upgrading.
|
|
1122
1152
|
*/
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
/** Create a new instance of the service */
|
|
1127
|
-
new (config?: TConfig): TService;
|
|
1128
|
-
}
|
|
1153
|
+
declare function isStorageFullError(error: {
|
|
1154
|
+
code?: string;
|
|
1155
|
+
} | null | undefined): boolean;
|
|
1129
1156
|
/**
|
|
1130
|
-
*
|
|
1157
|
+
* Wrap an unknown error in a ServiceError.
|
|
1131
1158
|
*/
|
|
1132
|
-
|
|
1133
|
-
/** The service class constructor */
|
|
1134
|
-
constructor: ServiceConstructor;
|
|
1135
|
-
/** Configuration for this service instance */
|
|
1136
|
-
config?: Record<string, unknown>;
|
|
1137
|
-
}
|
|
1159
|
+
declare function wrapError(service: string, error: unknown, defaultCode?: string): ServiceError;
|
|
1138
1160
|
/**
|
|
1139
|
-
*
|
|
1161
|
+
* Create an error Result from a ServiceError.
|
|
1140
1162
|
*/
|
|
1141
|
-
|
|
1142
|
-
/** Override the default timeout for this operation */
|
|
1143
|
-
timeout?: number;
|
|
1144
|
-
/** Custom abort signal for this operation */
|
|
1145
|
-
signal?: AbortSignal;
|
|
1146
|
-
}
|
|
1163
|
+
declare function errorResult(error: ServiceError): Result<never, ServiceError>;
|
|
1147
1164
|
|
|
1148
1165
|
/**
|
|
1149
1166
|
* DuckDB Service Types
|
|
@@ -1160,7 +1177,10 @@ interface DuckDbServiceConfig {
|
|
|
1160
1177
|
*/
|
|
1161
1178
|
defaultDatabase?: string;
|
|
1162
1179
|
/**
|
|
1163
|
-
*
|
|
1180
|
+
* Timeout in milliseconds for each DuckDB request, including reading the
|
|
1181
|
+
* response body. When it elapses the request is aborted and the operation
|
|
1182
|
+
* returns an `ErrorCodes.TIMEOUT` error. Unset (the default), `0`, or
|
|
1183
|
+
* `Infinity` means no timeout.
|
|
1164
1184
|
*/
|
|
1165
1185
|
timeout?: number;
|
|
1166
1186
|
/** Allow additional config properties */
|
|
@@ -1719,6 +1739,10 @@ type VaultErrorInput = {
|
|
|
1719
1739
|
code: "STORAGE_ERROR";
|
|
1720
1740
|
cause: Error;
|
|
1721
1741
|
message?: string;
|
|
1742
|
+
} | {
|
|
1743
|
+
code: "STORAGE_QUOTA_EXCEEDED" | "STORAGE_LIMIT_REACHED";
|
|
1744
|
+
message: string;
|
|
1745
|
+
meta?: Record<string, unknown>;
|
|
1722
1746
|
};
|
|
1723
1747
|
/**
|
|
1724
1748
|
* Vault error with service field (compatible with ServiceError).
|
|
@@ -2263,4 +2287,4 @@ declare class SecretsService implements ISecretsService {
|
|
|
2263
2287
|
listAll(): Promise<Result<SecretCatalogEntry[], SecretsError>>;
|
|
2264
2288
|
}
|
|
2265
2289
|
|
|
2266
|
-
export { type AuthorizationVerdict, BaseService, type
|
|
2290
|
+
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 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, InvokeAnyFunction, InvokeFunction, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, STORAGE_FULL_MESSAGE, STORAGE_WRITE_TOO_LARGE_MESSAGE, type SchemaInfo, type SecretCatalogEntry, type SecretPayload, 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, StorageQuotaInfo, type SubscribeOptions, 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, authExpiredError, authRequiredError, authUnauthorizedError, authorizationVerdictOf, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isStorageFullError, networkError, notFoundError, parseAuthError, parseCapabilityResource, parsePermissionHint, parsePermissionHintFromErrorText, parseSecretCatalogKey, parseStorageQuotaBytes, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, storageRejectionError, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, validatedCapabilityOf, wrapError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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-CVwwxqXF.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-CVwwxqXF.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BaseService } from './BaseService-
|
|
4
|
+
import { B as BaseService } from './BaseService-B_UKhVht.js';
|
|
5
|
+
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-B_UKhVht.js';
|
|
5
6
|
import { IKVService } from './kv/index.js';
|
|
6
|
-
export { DEFAULT_SIGNED_READ_URL_EXPIRY_MS, IPrefixedKVService, KVAction, KVActionType, KVBatchPutItem, KVBatchPutOptions, KVBatchPutResponse, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, PrefixedKVService } from './kv/index.js';
|
|
7
|
+
export { DEFAULT_SIGNED_READ_URL_EXPIRY_MS, IPrefixedKVService, KVAction, KVActionType, KVBatchPutItem, KVBatchPutOptions, KVBatchPutResponse, KVBatchReadResponse, KVChange, KVChangesAuthority, KVChangesOptions, KVChangesResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, PrefixedKVService } from './kv/index.js';
|
|
7
8
|
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';
|
|
8
9
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.js';
|
|
9
10
|
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';
|
|
@@ -1050,8 +1051,11 @@ declare function authExpiredError(service: string): ServiceError;
|
|
|
1050
1051
|
declare function networkError(service: string, message: string, cause?: Error): ServiceError;
|
|
1051
1052
|
/**
|
|
1052
1053
|
* Create a service error for timeouts.
|
|
1054
|
+
*
|
|
1055
|
+
* @param timeoutMs - The configured timeout that elapsed, when known
|
|
1056
|
+
* @param cause - The underlying timeout error, when known
|
|
1053
1057
|
*/
|
|
1054
|
-
declare function timeoutError(service: string): ServiceError;
|
|
1058
|
+
declare function timeoutError(service: string, timeoutMs?: number, cause?: Error): ServiceError;
|
|
1055
1059
|
/**
|
|
1056
1060
|
* Create a service error for aborted requests.
|
|
1057
1061
|
*/
|
|
@@ -1083,6 +1087,24 @@ declare function authUnauthorizedError(service: string, message: string, meta?:
|
|
|
1083
1087
|
* - `"other"`: a non-authorization HTTP error status (4xx/5xx).
|
|
1084
1088
|
*/
|
|
1085
1089
|
type AuthorizationVerdict = "unauthenticated" | "forbidden" | "other";
|
|
1090
|
+
/**
|
|
1091
|
+
* Parse a canonical TinyCloud resource, keeping nested space names intact.
|
|
1092
|
+
* The first registered service segment is authoritative: a later matching
|
|
1093
|
+
* segment in the path cannot turn a different service into grant advice.
|
|
1094
|
+
*/
|
|
1095
|
+
declare function parseCapabilityResource(resource: string, service: string): {
|
|
1096
|
+
space: string;
|
|
1097
|
+
path: string;
|
|
1098
|
+
} | undefined;
|
|
1099
|
+
/**
|
|
1100
|
+
* Return a grantable missing capability only when typed authorization evidence
|
|
1101
|
+
* and both safe, service-matched capability fields are present. Status alone,
|
|
1102
|
+
* message text, wildcard actions and unrecognized actions cannot grant scope.
|
|
1103
|
+
*/
|
|
1104
|
+
declare function validatedCapabilityOf(error: unknown): {
|
|
1105
|
+
resource: string;
|
|
1106
|
+
requiredAction: string;
|
|
1107
|
+
} | undefined;
|
|
1086
1108
|
/**
|
|
1087
1109
|
* Classify an error from its typed HTTP error status (`status`, `statusCode`,
|
|
1088
1110
|
* or `meta.status`, 4xx/5xx only) and `AUTH_UNAUTHORIZED` code, following the
|
|
@@ -1101,49 +1123,44 @@ declare function storageQuotaExceededError(service: string, message: string, met
|
|
|
1101
1123
|
* Create a service error for storage limit reached (413 Payload Too Large).
|
|
1102
1124
|
*/
|
|
1103
1125
|
declare function storageLimitReachedError(service: string, message: string, meta?: Record<string, unknown>): ServiceError;
|
|
1126
|
+
/** Shown when a write is rejected because the owner's storage is full. */
|
|
1127
|
+
declare const STORAGE_FULL_MESSAGE = "TinyCloud storage is full, so this change was not saved. Reading still works. Free up space or upgrade your plan to save again.";
|
|
1128
|
+
/** Shown when a write is larger than the storage the owner has left. */
|
|
1129
|
+
declare const STORAGE_WRITE_TOO_LARGE_MESSAGE = "This change is larger than the TinyCloud storage you have left, so it was not saved. Reading still works. Free up space or upgrade your plan to save it.";
|
|
1130
|
+
/**
|
|
1131
|
+
* Parse the byte counts from a node storage rejection
|
|
1132
|
+
* ("... Used: 155744 bytes, Limit: 0 bytes"). The limit is the share of the
|
|
1133
|
+
* owner's account-wide budget left for this space, so it is 0 when the
|
|
1134
|
+
* owner's other spaces already use the whole budget.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function parseStorageQuotaBytes(responseText: string): {
|
|
1137
|
+
usedBytes: number;
|
|
1138
|
+
limitBytes: number;
|
|
1139
|
+
} | undefined;
|
|
1104
1140
|
/**
|
|
1105
|
-
*
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
* Create an error Result from a ServiceError.
|
|
1110
|
-
*/
|
|
1111
|
-
declare function errorResult(error: ServiceError): Result<never, ServiceError>;
|
|
1112
|
-
|
|
1113
|
-
/**
|
|
1114
|
-
* Base Service Types
|
|
1115
|
-
*
|
|
1116
|
-
* Types specific to the base service infrastructure.
|
|
1141
|
+
* Build the error for a write the node rejected for storage: 402 when storage
|
|
1142
|
+
* is already full, 413 when this write is larger than what is left. KV, SQL
|
|
1143
|
+
* and DuckDB all report it with the same codes and message so an app can
|
|
1144
|
+
* detect "storage full" in one place with {@link isStorageFullError}.
|
|
1117
1145
|
*/
|
|
1118
|
-
|
|
1146
|
+
declare function storageRejectionError(service: string, status: 402 | 413, meta: Record<string, unknown>, responseText: string): ServiceError;
|
|
1119
1147
|
/**
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1148
|
+
* True when a write failed for storage: the owner's TinyCloud storage is full
|
|
1149
|
+
* (`STORAGE_QUOTA_EXCEEDED`), or this write is larger than what is left
|
|
1150
|
+
* (`STORAGE_LIMIT_REACHED`). Reads keep working in both cases, so apps should
|
|
1151
|
+
* stay usable read-only and point the user at freeing up space or upgrading.
|
|
1122
1152
|
*/
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
/** Create a new instance of the service */
|
|
1127
|
-
new (config?: TConfig): TService;
|
|
1128
|
-
}
|
|
1153
|
+
declare function isStorageFullError(error: {
|
|
1154
|
+
code?: string;
|
|
1155
|
+
} | null | undefined): boolean;
|
|
1129
1156
|
/**
|
|
1130
|
-
*
|
|
1157
|
+
* Wrap an unknown error in a ServiceError.
|
|
1131
1158
|
*/
|
|
1132
|
-
|
|
1133
|
-
/** The service class constructor */
|
|
1134
|
-
constructor: ServiceConstructor;
|
|
1135
|
-
/** Configuration for this service instance */
|
|
1136
|
-
config?: Record<string, unknown>;
|
|
1137
|
-
}
|
|
1159
|
+
declare function wrapError(service: string, error: unknown, defaultCode?: string): ServiceError;
|
|
1138
1160
|
/**
|
|
1139
|
-
*
|
|
1161
|
+
* Create an error Result from a ServiceError.
|
|
1140
1162
|
*/
|
|
1141
|
-
|
|
1142
|
-
/** Override the default timeout for this operation */
|
|
1143
|
-
timeout?: number;
|
|
1144
|
-
/** Custom abort signal for this operation */
|
|
1145
|
-
signal?: AbortSignal;
|
|
1146
|
-
}
|
|
1163
|
+
declare function errorResult(error: ServiceError): Result<never, ServiceError>;
|
|
1147
1164
|
|
|
1148
1165
|
/**
|
|
1149
1166
|
* DuckDB Service Types
|
|
@@ -1160,7 +1177,10 @@ interface DuckDbServiceConfig {
|
|
|
1160
1177
|
*/
|
|
1161
1178
|
defaultDatabase?: string;
|
|
1162
1179
|
/**
|
|
1163
|
-
*
|
|
1180
|
+
* Timeout in milliseconds for each DuckDB request, including reading the
|
|
1181
|
+
* response body. When it elapses the request is aborted and the operation
|
|
1182
|
+
* returns an `ErrorCodes.TIMEOUT` error. Unset (the default), `0`, or
|
|
1183
|
+
* `Infinity` means no timeout.
|
|
1164
1184
|
*/
|
|
1165
1185
|
timeout?: number;
|
|
1166
1186
|
/** Allow additional config properties */
|
|
@@ -1719,6 +1739,10 @@ type VaultErrorInput = {
|
|
|
1719
1739
|
code: "STORAGE_ERROR";
|
|
1720
1740
|
cause: Error;
|
|
1721
1741
|
message?: string;
|
|
1742
|
+
} | {
|
|
1743
|
+
code: "STORAGE_QUOTA_EXCEEDED" | "STORAGE_LIMIT_REACHED";
|
|
1744
|
+
message: string;
|
|
1745
|
+
meta?: Record<string, unknown>;
|
|
1722
1746
|
};
|
|
1723
1747
|
/**
|
|
1724
1748
|
* Vault error with service field (compatible with ServiceError).
|
|
@@ -2263,4 +2287,4 @@ declare class SecretsService implements ISecretsService {
|
|
|
2263
2287
|
listAll(): Promise<Result<SecretCatalogEntry[], SecretsError>>;
|
|
2264
2288
|
}
|
|
2265
2289
|
|
|
2266
|
-
export { type AuthorizationVerdict, BaseService, type
|
|
2290
|
+
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 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, InvokeAnyFunction, InvokeFunction, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, STORAGE_FULL_MESSAGE, STORAGE_WRITE_TOO_LARGE_MESSAGE, type SchemaInfo, type SecretCatalogEntry, type SecretPayload, 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, StorageQuotaInfo, type SubscribeOptions, 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, authExpiredError, authRequiredError, authUnauthorizedError, authorizationVerdictOf, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isStorageFullError, networkError, notFoundError, parseAuthError, parseCapabilityResource, parsePermissionHint, parsePermissionHintFromErrorText, parseSecretCatalogKey, parseStorageQuotaBytes, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, storageRejectionError, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, validatedCapabilityOf, wrapError };
|