@tinycloud/sdk-services 2.8.0 → 2.10.0
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-DxSU4U-v.d.cts → BaseService-BhpVpA9b.d.cts} +1 -1
- package/dist/{BaseService-BiYeqCRT.d.ts → BaseService-CuV-ZVPs.d.ts} +1 -1
- 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.map +1 -1
- package/dist/index.cjs +231 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -5
- package/dist/index.d.ts +35 -5
- package/dist/index.js +231 -5
- 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 +216 -2
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +34 -3
- package/dist/kv/index.d.ts +34 -3
- package/dist/kv/index.js +216 -2
- package/dist/kv/index.js.map +1 -1
- 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.map +1 -1
- package/dist/{types-KCcgZiab.d.cts → types-qwMmB7qB.d.cts} +1 -0
- package/dist/{types-KCcgZiab.d.ts → types-qwMmB7qB.d.ts} +1 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-qwMmB7qB.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-qwMmB7qB.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BaseService } from './BaseService-
|
|
4
|
+
import { B as BaseService } from './BaseService-BhpVpA9b.cjs';
|
|
5
5
|
import { IKVService } from './kv/index.cjs';
|
|
6
|
-
export { DEFAULT_SIGNED_READ_URL_EXPIRY_MS, IPrefixedKVService, KVAction, KVActionType, KVBatchPutItem, KVBatchPutOptions, KVBatchPutResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, PrefixedKVService } 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
7
|
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
8
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.cjs';
|
|
9
9
|
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';
|
|
@@ -418,10 +418,16 @@ type GenericKVResponseType = z.infer<typeof GenericKVResponseSchema>;
|
|
|
418
418
|
declare const KVListResponseSchema: z.ZodObject<{
|
|
419
419
|
/** Array of keys matching the list criteria */
|
|
420
420
|
keys: z.ZodArray<z.ZodString, "many">;
|
|
421
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
422
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
421
423
|
}, "strip", z.ZodTypeAny, {
|
|
422
424
|
keys: string[];
|
|
425
|
+
truncated?: boolean | undefined;
|
|
426
|
+
nextCursor?: string | undefined;
|
|
423
427
|
}, {
|
|
424
428
|
keys: string[];
|
|
429
|
+
truncated?: boolean | undefined;
|
|
430
|
+
nextCursor?: string | undefined;
|
|
425
431
|
}>;
|
|
426
432
|
type KVListResponseType = z.infer<typeof KVListResponseSchema>;
|
|
427
433
|
/**
|
|
@@ -432,19 +438,29 @@ declare const KVListResultSchema: z.ZodDiscriminatedUnion<"ok", [z.ZodObject<{
|
|
|
432
438
|
data: z.ZodObject<{
|
|
433
439
|
/** Array of keys matching the list criteria */
|
|
434
440
|
keys: z.ZodArray<z.ZodString, "many">;
|
|
441
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
442
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
435
443
|
}, "strip", z.ZodTypeAny, {
|
|
436
444
|
keys: string[];
|
|
445
|
+
truncated?: boolean | undefined;
|
|
446
|
+
nextCursor?: string | undefined;
|
|
437
447
|
}, {
|
|
438
448
|
keys: string[];
|
|
449
|
+
truncated?: boolean | undefined;
|
|
450
|
+
nextCursor?: string | undefined;
|
|
439
451
|
}>;
|
|
440
452
|
}, "strip", z.ZodTypeAny, {
|
|
441
453
|
data: {
|
|
442
454
|
keys: string[];
|
|
455
|
+
truncated?: boolean | undefined;
|
|
456
|
+
nextCursor?: string | undefined;
|
|
443
457
|
};
|
|
444
458
|
ok: true;
|
|
445
459
|
}, {
|
|
446
460
|
data: {
|
|
447
461
|
keys: string[];
|
|
462
|
+
truncated?: boolean | undefined;
|
|
463
|
+
nextCursor?: string | undefined;
|
|
448
464
|
};
|
|
449
465
|
ok: true;
|
|
450
466
|
}>, z.ZodObject<{
|
|
@@ -1595,6 +1611,15 @@ interface VaultListOptions {
|
|
|
1595
1611
|
prefix?: string;
|
|
1596
1612
|
/** Remove prefix from returned keys */
|
|
1597
1613
|
removePrefix?: boolean;
|
|
1614
|
+
/** Maximum number of keys to return. */
|
|
1615
|
+
limit?: number;
|
|
1616
|
+
/** Opaque cursor returned by a prior bounded page. */
|
|
1617
|
+
cursor?: string;
|
|
1618
|
+
}
|
|
1619
|
+
interface VaultListPage {
|
|
1620
|
+
keys: string[];
|
|
1621
|
+
truncated: boolean;
|
|
1622
|
+
nextCursor?: string;
|
|
1598
1623
|
}
|
|
1599
1624
|
/**
|
|
1600
1625
|
* Options for vault grant (sharing) operations.
|
|
@@ -1763,6 +1788,8 @@ interface IDataVaultService extends IService {
|
|
|
1763
1788
|
* @returns Result with the decrypted entry
|
|
1764
1789
|
*/
|
|
1765
1790
|
get<T = unknown>(key: string, options?: VaultGetOptions<T>): Promise<Result<VaultEntry<T>, VaultError>>;
|
|
1791
|
+
/** Read a network-encrypted value with safe, phase-classified failures. */
|
|
1792
|
+
readNetworkEncrypted<T = unknown>(key: string, options?: VaultGetOptions<T>): Promise<VaultNetworkReadResult<T>>;
|
|
1766
1793
|
/**
|
|
1767
1794
|
* Delete an encrypted key.
|
|
1768
1795
|
*
|
|
@@ -1776,6 +1803,8 @@ interface IDataVaultService extends IService {
|
|
|
1776
1803
|
* @returns Result with array of key names
|
|
1777
1804
|
*/
|
|
1778
1805
|
list(options?: VaultListOptions): Promise<Result<string[], VaultError>>;
|
|
1806
|
+
/** List one bounded, cursor-aware page of vault keys. */
|
|
1807
|
+
listPage(options?: VaultListOptions): Promise<Result<VaultListPage, VaultError>>;
|
|
1779
1808
|
/**
|
|
1780
1809
|
* Get envelope metadata for a key without decrypting the value.
|
|
1781
1810
|
*
|
|
@@ -2049,6 +2078,7 @@ declare class DataVaultService extends BaseService implements IDataVaultService
|
|
|
2049
2078
|
* @returns Result with array of key names (vault/ prefix stripped)
|
|
2050
2079
|
*/
|
|
2051
2080
|
list(options?: VaultListOptions): Promise<Result<string[], VaultError>>;
|
|
2081
|
+
listPage(options?: VaultListOptions): Promise<Result<VaultListPage, VaultError>>;
|
|
2052
2082
|
/**
|
|
2053
2083
|
* Get envelope metadata for a key without decrypting the value.
|
|
2054
2084
|
*
|
|
@@ -2200,4 +2230,4 @@ declare class SecretsService implements ISecretsService {
|
|
|
2200
2230
|
list(options?: SecretScopeOptions): Promise<Result<string[], SecretsError>>;
|
|
2201
2231
|
}
|
|
2202
2232
|
|
|
2203
|
-
export { BaseService, type BaseServiceOptions, 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, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, type SchemaInfo, type SecretPayload, type SecretScopeOptions, type SecretsError, SecretsService, type ServiceConstructor, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, type ServiceRegistration, 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 VaultNetworkReadResult, VaultPublicSpaceKVActions, type VaultPutOptions, type ViewInfo, type WasmVaultFunctions, abortedError, authExpiredError, authRequiredError, authUnauthorizedError, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, networkError, notFoundError, parseAuthError, parsePermissionHint, parsePermissionHintFromErrorText, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, wrapError };
|
|
2233
|
+
export { BaseService, type BaseServiceOptions, 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, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, type SchemaInfo, type SecretPayload, type SecretScopeOptions, type SecretsError, SecretsService, type ServiceConstructor, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, type ServiceRegistration, 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, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, networkError, notFoundError, parseAuthError, parsePermissionHint, parsePermissionHintFromErrorText, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, wrapError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-qwMmB7qB.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-qwMmB7qB.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BaseService } from './BaseService-
|
|
4
|
+
import { B as BaseService } from './BaseService-CuV-ZVPs.js';
|
|
5
5
|
import { IKVService } from './kv/index.js';
|
|
6
|
-
export { DEFAULT_SIGNED_READ_URL_EXPIRY_MS, IPrefixedKVService, KVAction, KVActionType, KVBatchPutItem, KVBatchPutOptions, KVBatchPutResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, PrefixedKVService } 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
7
|
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
8
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.js';
|
|
9
9
|
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';
|
|
@@ -418,10 +418,16 @@ type GenericKVResponseType = z.infer<typeof GenericKVResponseSchema>;
|
|
|
418
418
|
declare const KVListResponseSchema: z.ZodObject<{
|
|
419
419
|
/** Array of keys matching the list criteria */
|
|
420
420
|
keys: z.ZodArray<z.ZodString, "many">;
|
|
421
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
422
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
421
423
|
}, "strip", z.ZodTypeAny, {
|
|
422
424
|
keys: string[];
|
|
425
|
+
truncated?: boolean | undefined;
|
|
426
|
+
nextCursor?: string | undefined;
|
|
423
427
|
}, {
|
|
424
428
|
keys: string[];
|
|
429
|
+
truncated?: boolean | undefined;
|
|
430
|
+
nextCursor?: string | undefined;
|
|
425
431
|
}>;
|
|
426
432
|
type KVListResponseType = z.infer<typeof KVListResponseSchema>;
|
|
427
433
|
/**
|
|
@@ -432,19 +438,29 @@ declare const KVListResultSchema: z.ZodDiscriminatedUnion<"ok", [z.ZodObject<{
|
|
|
432
438
|
data: z.ZodObject<{
|
|
433
439
|
/** Array of keys matching the list criteria */
|
|
434
440
|
keys: z.ZodArray<z.ZodString, "many">;
|
|
441
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
442
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
435
443
|
}, "strip", z.ZodTypeAny, {
|
|
436
444
|
keys: string[];
|
|
445
|
+
truncated?: boolean | undefined;
|
|
446
|
+
nextCursor?: string | undefined;
|
|
437
447
|
}, {
|
|
438
448
|
keys: string[];
|
|
449
|
+
truncated?: boolean | undefined;
|
|
450
|
+
nextCursor?: string | undefined;
|
|
439
451
|
}>;
|
|
440
452
|
}, "strip", z.ZodTypeAny, {
|
|
441
453
|
data: {
|
|
442
454
|
keys: string[];
|
|
455
|
+
truncated?: boolean | undefined;
|
|
456
|
+
nextCursor?: string | undefined;
|
|
443
457
|
};
|
|
444
458
|
ok: true;
|
|
445
459
|
}, {
|
|
446
460
|
data: {
|
|
447
461
|
keys: string[];
|
|
462
|
+
truncated?: boolean | undefined;
|
|
463
|
+
nextCursor?: string | undefined;
|
|
448
464
|
};
|
|
449
465
|
ok: true;
|
|
450
466
|
}>, z.ZodObject<{
|
|
@@ -1595,6 +1611,15 @@ interface VaultListOptions {
|
|
|
1595
1611
|
prefix?: string;
|
|
1596
1612
|
/** Remove prefix from returned keys */
|
|
1597
1613
|
removePrefix?: boolean;
|
|
1614
|
+
/** Maximum number of keys to return. */
|
|
1615
|
+
limit?: number;
|
|
1616
|
+
/** Opaque cursor returned by a prior bounded page. */
|
|
1617
|
+
cursor?: string;
|
|
1618
|
+
}
|
|
1619
|
+
interface VaultListPage {
|
|
1620
|
+
keys: string[];
|
|
1621
|
+
truncated: boolean;
|
|
1622
|
+
nextCursor?: string;
|
|
1598
1623
|
}
|
|
1599
1624
|
/**
|
|
1600
1625
|
* Options for vault grant (sharing) operations.
|
|
@@ -1763,6 +1788,8 @@ interface IDataVaultService extends IService {
|
|
|
1763
1788
|
* @returns Result with the decrypted entry
|
|
1764
1789
|
*/
|
|
1765
1790
|
get<T = unknown>(key: string, options?: VaultGetOptions<T>): Promise<Result<VaultEntry<T>, VaultError>>;
|
|
1791
|
+
/** Read a network-encrypted value with safe, phase-classified failures. */
|
|
1792
|
+
readNetworkEncrypted<T = unknown>(key: string, options?: VaultGetOptions<T>): Promise<VaultNetworkReadResult<T>>;
|
|
1766
1793
|
/**
|
|
1767
1794
|
* Delete an encrypted key.
|
|
1768
1795
|
*
|
|
@@ -1776,6 +1803,8 @@ interface IDataVaultService extends IService {
|
|
|
1776
1803
|
* @returns Result with array of key names
|
|
1777
1804
|
*/
|
|
1778
1805
|
list(options?: VaultListOptions): Promise<Result<string[], VaultError>>;
|
|
1806
|
+
/** List one bounded, cursor-aware page of vault keys. */
|
|
1807
|
+
listPage(options?: VaultListOptions): Promise<Result<VaultListPage, VaultError>>;
|
|
1779
1808
|
/**
|
|
1780
1809
|
* Get envelope metadata for a key without decrypting the value.
|
|
1781
1810
|
*
|
|
@@ -2049,6 +2078,7 @@ declare class DataVaultService extends BaseService implements IDataVaultService
|
|
|
2049
2078
|
* @returns Result with array of key names (vault/ prefix stripped)
|
|
2050
2079
|
*/
|
|
2051
2080
|
list(options?: VaultListOptions): Promise<Result<string[], VaultError>>;
|
|
2081
|
+
listPage(options?: VaultListOptions): Promise<Result<VaultListPage, VaultError>>;
|
|
2052
2082
|
/**
|
|
2053
2083
|
* Get envelope metadata for a key without decrypting the value.
|
|
2054
2084
|
*
|
|
@@ -2200,4 +2230,4 @@ declare class SecretsService implements ISecretsService {
|
|
|
2200
2230
|
list(options?: SecretScopeOptions): Promise<Result<string[], SecretsError>>;
|
|
2201
2231
|
}
|
|
2202
2232
|
|
|
2203
|
-
export { BaseService, type BaseServiceOptions, 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, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, type SchemaInfo, type SecretPayload, type SecretScopeOptions, type SecretsError, SecretsService, type ServiceConstructor, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, type ServiceRegistration, 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 VaultNetworkReadResult, VaultPublicSpaceKVActions, type VaultPutOptions, type ViewInfo, type WasmVaultFunctions, abortedError, authExpiredError, authRequiredError, authUnauthorizedError, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, networkError, notFoundError, parseAuthError, parsePermissionHint, parsePermissionHintFromErrorText, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, wrapError };
|
|
2233
|
+
export { BaseService, type BaseServiceOptions, 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, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, RetryPolicy, RetryPolicySchema, type RetryPolicyType, SECRET_NAME_RE, type SchemaInfo, type SecretPayload, type SecretScopeOptions, type SecretsError, SecretsService, type ServiceConstructor, ServiceContext, type ServiceContextConfig, ServiceError, ServiceErrorEventSchema, type ServiceErrorEventType, ServiceErrorSchema, type ServiceErrorType, type ServiceRegistration, 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, canonicalizeSecretScope, clearTinyCloudDebugLogs, createKVResponseSchema, createResultSchema, createVaultCrypto, disableTinyCloudDebug, enableTinyCloudDebug, errorResult, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, networkError, notFoundError, parseAuthError, parsePermissionHint, parsePermissionHintFromErrorText, permissionDeniedError, resolveSecretListPrefix, resolveSecretPath, storageLimitReachedError, storageQuotaExceededError, timeoutError, tinyCloudDebugLogger, validateKVListResponse, validateKVResponseHeaders, validateRetryPolicy, validateServiceError, validateServiceRequestEvent, validateServiceResponseEvent, validateServiceSession, validateTelemetrySpanEvent, wrapError };
|
package/dist/index.js
CHANGED
|
@@ -373,7 +373,9 @@ function createKVResponseSchema(dataSchema) {
|
|
|
373
373
|
var GenericKVResponseSchema = createKVResponseSchema(z.unknown());
|
|
374
374
|
var KVListResponseSchema = z.object({
|
|
375
375
|
/** Array of keys matching the list criteria */
|
|
376
|
-
keys: z.array(z.string())
|
|
376
|
+
keys: z.array(z.string()),
|
|
377
|
+
truncated: z.boolean().optional(),
|
|
378
|
+
nextCursor: z.string().optional()
|
|
377
379
|
});
|
|
378
380
|
var KVListResultSchema = createResultSchema(KVListResponseSchema);
|
|
379
381
|
var ServiceRequestEventSchema = z.object({
|
|
@@ -1277,6 +1279,20 @@ var PrefixedKVService = class _PrefixedKVService {
|
|
|
1277
1279
|
const fullKey = this.getFullKey(key);
|
|
1278
1280
|
return this._kv.get(fullKey, { ...options, prefix: "" });
|
|
1279
1281
|
}
|
|
1282
|
+
async batchGet(keys, options) {
|
|
1283
|
+
const response = await this._kv.batchGet(
|
|
1284
|
+
keys.map((key) => this.getFullKey(key)),
|
|
1285
|
+
{ ...options, prefix: "" }
|
|
1286
|
+
);
|
|
1287
|
+
if (!response.ok) return response;
|
|
1288
|
+
return ok({
|
|
1289
|
+
...response.data,
|
|
1290
|
+
results: response.data.results.map((item, index) => ({
|
|
1291
|
+
...item,
|
|
1292
|
+
key: keys[index]
|
|
1293
|
+
}))
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1280
1296
|
/**
|
|
1281
1297
|
* Store a value at a key.
|
|
1282
1298
|
*/
|
|
@@ -1321,6 +1337,20 @@ var PrefixedKVService = class _PrefixedKVService {
|
|
|
1321
1337
|
const fullKey = this.getFullKey(key);
|
|
1322
1338
|
return this._kv.head(fullKey, { ...options, prefix: "" });
|
|
1323
1339
|
}
|
|
1340
|
+
async batchHead(keys, options) {
|
|
1341
|
+
const response = await this._kv.batchHead(
|
|
1342
|
+
keys.map((key) => this.getFullKey(key)),
|
|
1343
|
+
{ ...options, prefix: "" }
|
|
1344
|
+
);
|
|
1345
|
+
if (!response.ok) return response;
|
|
1346
|
+
return ok({
|
|
1347
|
+
...response.data,
|
|
1348
|
+
results: response.data.results.map((item, index) => ({
|
|
1349
|
+
...item,
|
|
1350
|
+
key: keys[index]
|
|
1351
|
+
}))
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1324
1354
|
/**
|
|
1325
1355
|
* Create a short-lived signed URL for reading a KV object.
|
|
1326
1356
|
*/
|
|
@@ -1349,6 +1379,7 @@ var KVAction = {
|
|
|
1349
1379
|
};
|
|
1350
1380
|
|
|
1351
1381
|
// src/kv/KVService.ts
|
|
1382
|
+
var MAX_KV_BATCH_READ_ITEMS = 100;
|
|
1352
1383
|
function encodeKvBatchPartName(path) {
|
|
1353
1384
|
return encodeURIComponent(path).replace(
|
|
1354
1385
|
/[!'()*]/g,
|
|
@@ -1583,6 +1614,173 @@ var KVService = class extends BaseService {
|
|
|
1583
1614
|
get: (name) => headers.get(name)
|
|
1584
1615
|
};
|
|
1585
1616
|
}
|
|
1617
|
+
createBatchResponseHeaders(values) {
|
|
1618
|
+
const normalized = new Map(
|
|
1619
|
+
Object.entries(values).map(([name, value]) => [name.toLowerCase(), value])
|
|
1620
|
+
);
|
|
1621
|
+
return this.createResponseHeaders({
|
|
1622
|
+
get: (name) => normalized.get(name.toLowerCase()) ?? null
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
parseBatchValue(dataBase64, headers, raw = false, binary = false) {
|
|
1626
|
+
const encoded = globalThis.atob(dataBase64);
|
|
1627
|
+
const bytes = Uint8Array.from(encoded, (character) => character.charCodeAt(0));
|
|
1628
|
+
if (binary) return bytes;
|
|
1629
|
+
const text = new TextDecoder().decode(bytes);
|
|
1630
|
+
if (raw) return text;
|
|
1631
|
+
const contentType = Object.entries(headers).find(
|
|
1632
|
+
([name]) => name.toLowerCase() === "content-type"
|
|
1633
|
+
)?.[1];
|
|
1634
|
+
return contentType?.includes("application/json") ? JSON.parse(text) : text;
|
|
1635
|
+
}
|
|
1636
|
+
normalizeBatchReadResponse(data, paths, requireData) {
|
|
1637
|
+
if (!data || typeof data !== "object") return void 0;
|
|
1638
|
+
const response = data;
|
|
1639
|
+
if (!Array.isArray(response.results) || response.results.length !== paths.length) {
|
|
1640
|
+
return void 0;
|
|
1641
|
+
}
|
|
1642
|
+
for (let index = 0; index < response.results.length; index++) {
|
|
1643
|
+
const item = response.results[index];
|
|
1644
|
+
if (!item || typeof item !== "object" || item.key !== paths[index] || typeof item.ok !== "boolean") {
|
|
1645
|
+
return void 0;
|
|
1646
|
+
}
|
|
1647
|
+
if (item.ok && (!item.headers || typeof item.headers !== "object" || Object.values(item.headers).some((value) => typeof value !== "string") || requireData && typeof item.dataBase64 !== "string")) {
|
|
1648
|
+
return void 0;
|
|
1649
|
+
}
|
|
1650
|
+
if (!item.ok && (!item.error || typeof item.error.code !== "string" || typeof item.error.message !== "string")) {
|
|
1651
|
+
return void 0;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
return response;
|
|
1655
|
+
}
|
|
1656
|
+
async batchRead(keys, action, options) {
|
|
1657
|
+
if (!this.requireAuth()) return err(authRequiredError("kv"));
|
|
1658
|
+
if (keys.length === 0) return ok({ results: [], count: 0 });
|
|
1659
|
+
if (keys.length > MAX_KV_BATCH_READ_ITEMS) {
|
|
1660
|
+
return err(serviceError(
|
|
1661
|
+
ErrorCodes.INVALID_INPUT,
|
|
1662
|
+
`KV batch reads accept at most ${MAX_KV_BATCH_READ_ITEMS} keys`,
|
|
1663
|
+
"kv"
|
|
1664
|
+
));
|
|
1665
|
+
}
|
|
1666
|
+
if (keys.length === 1) {
|
|
1667
|
+
const key = keys[0];
|
|
1668
|
+
const result = action === KVAction.GET ? await this.get(key, options) : await this.head(key, options);
|
|
1669
|
+
return ok({
|
|
1670
|
+
results: [{ key, result }],
|
|
1671
|
+
count: 1
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
if (!this.context.invokeAny) {
|
|
1675
|
+
return err(serviceError(
|
|
1676
|
+
ErrorCodes.INVALID_INPUT,
|
|
1677
|
+
"KV batch reads require SDK runtime support for multi-resource invocations",
|
|
1678
|
+
"kv"
|
|
1679
|
+
));
|
|
1680
|
+
}
|
|
1681
|
+
const getOptions = action === KVAction.GET ? options : void 0;
|
|
1682
|
+
if (getOptions?.maxResponseBytes !== void 0 && (!Number.isSafeInteger(getOptions.maxResponseBytes) || getOptions.maxResponseBytes <= 0)) {
|
|
1683
|
+
return err(serviceError(
|
|
1684
|
+
ErrorCodes.INVALID_INPUT,
|
|
1685
|
+
"KV maxResponseBytes must be a positive safe integer",
|
|
1686
|
+
"kv"
|
|
1687
|
+
));
|
|
1688
|
+
}
|
|
1689
|
+
const paths = keys.map((key) => this.getFullPath(key, options?.prefix));
|
|
1690
|
+
if (new Set(paths).size !== paths.length) {
|
|
1691
|
+
return err(serviceError(
|
|
1692
|
+
ErrorCodes.INVALID_INPUT,
|
|
1693
|
+
"KV batch read received duplicate keys after prefix resolution",
|
|
1694
|
+
"kv"
|
|
1695
|
+
));
|
|
1696
|
+
}
|
|
1697
|
+
try {
|
|
1698
|
+
const session = this.context.session;
|
|
1699
|
+
const invocationHeaders = this.context.invokeAny(
|
|
1700
|
+
session,
|
|
1701
|
+
paths.map((path) => ({
|
|
1702
|
+
spaceId: session.spaceId,
|
|
1703
|
+
service: "kv",
|
|
1704
|
+
path,
|
|
1705
|
+
action
|
|
1706
|
+
}))
|
|
1707
|
+
);
|
|
1708
|
+
const limitHeaders = {};
|
|
1709
|
+
if (getOptions?.maxResponseBytes !== void 0) {
|
|
1710
|
+
limitHeaders["x-tinycloud-max-response-bytes"] = String(
|
|
1711
|
+
getOptions.maxResponseBytes
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
const headers = Array.isArray(invocationHeaders) ? [...invocationHeaders, ...Object.entries(limitHeaders)] : { ...invocationHeaders, ...limitHeaders };
|
|
1715
|
+
const response = await this.context.fetch(`${this.host}/invoke`, {
|
|
1716
|
+
method: "POST",
|
|
1717
|
+
headers,
|
|
1718
|
+
signal: this.combineSignals(options?.signal)
|
|
1719
|
+
});
|
|
1720
|
+
if (!response.ok) {
|
|
1721
|
+
const errorText = await response.text();
|
|
1722
|
+
if (response.status === 401 || response.status === 403) {
|
|
1723
|
+
const { resource, action: requiredAction } = parseAuthError(errorText);
|
|
1724
|
+
return err(authUnauthorizedError("kv", errorText, {
|
|
1725
|
+
status: response.status,
|
|
1726
|
+
...requiredAction && { requiredAction },
|
|
1727
|
+
...resource && { resource }
|
|
1728
|
+
}));
|
|
1729
|
+
}
|
|
1730
|
+
if (response.status === 413) {
|
|
1731
|
+
return err(serviceError(
|
|
1732
|
+
ErrorCodes.KV_RESPONSE_TOO_LARGE,
|
|
1733
|
+
"A KV batch value exceeds the requested response limit",
|
|
1734
|
+
"kv",
|
|
1735
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
1736
|
+
));
|
|
1737
|
+
}
|
|
1738
|
+
return err(serviceError(
|
|
1739
|
+
ErrorCodes.NETWORK_ERROR,
|
|
1740
|
+
`Failed to batch read ${keys.length} key(s): ${response.status} - ${errorText}`,
|
|
1741
|
+
"kv",
|
|
1742
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
1743
|
+
));
|
|
1744
|
+
}
|
|
1745
|
+
const payload = this.normalizeBatchReadResponse(
|
|
1746
|
+
await response.json(),
|
|
1747
|
+
paths,
|
|
1748
|
+
action === KVAction.GET
|
|
1749
|
+
);
|
|
1750
|
+
if (!payload) {
|
|
1751
|
+
return err(serviceError(
|
|
1752
|
+
ErrorCodes.NETWORK_ERROR,
|
|
1753
|
+
"KV batch read response did not match the requested keys",
|
|
1754
|
+
"kv"
|
|
1755
|
+
));
|
|
1756
|
+
}
|
|
1757
|
+
const results = payload.results.map((item, index) => {
|
|
1758
|
+
if (!item.ok) {
|
|
1759
|
+
return {
|
|
1760
|
+
key: keys[index],
|
|
1761
|
+
result: err(serviceError(item.error.code, item.error.message, "kv"))
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
const headers2 = item.headers;
|
|
1765
|
+
const data = action === KVAction.HEAD ? void 0 : this.parseBatchValue(
|
|
1766
|
+
item.dataBase64,
|
|
1767
|
+
headers2,
|
|
1768
|
+
getOptions?.raw,
|
|
1769
|
+
getOptions?.binary
|
|
1770
|
+
);
|
|
1771
|
+
return {
|
|
1772
|
+
key: keys[index],
|
|
1773
|
+
result: ok({
|
|
1774
|
+
data,
|
|
1775
|
+
headers: this.createBatchResponseHeaders(headers2)
|
|
1776
|
+
})
|
|
1777
|
+
};
|
|
1778
|
+
});
|
|
1779
|
+
return ok({ results, count: results.length });
|
|
1780
|
+
} catch (error) {
|
|
1781
|
+
return err(wrapError("kv", error));
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1586
1784
|
/**
|
|
1587
1785
|
* Parse response body based on content type.
|
|
1588
1786
|
*
|
|
@@ -1729,6 +1927,13 @@ var KVService = class extends BaseService {
|
|
|
1729
1927
|
}
|
|
1730
1928
|
});
|
|
1731
1929
|
}
|
|
1930
|
+
async batchGet(keys, options) {
|
|
1931
|
+
return this.withTelemetry(
|
|
1932
|
+
"batchGet",
|
|
1933
|
+
String(keys.length),
|
|
1934
|
+
() => this.batchRead(keys, KVAction.GET, options)
|
|
1935
|
+
);
|
|
1936
|
+
}
|
|
1732
1937
|
/**
|
|
1733
1938
|
* Store a value at a key.
|
|
1734
1939
|
*/
|
|
@@ -1936,7 +2141,10 @@ var KVService = class extends BaseService {
|
|
|
1936
2141
|
KVAction.LIST,
|
|
1937
2142
|
void 0,
|
|
1938
2143
|
options?.signal,
|
|
1939
|
-
options?.limit === void 0 ? void 0 : {
|
|
2144
|
+
options?.limit === void 0 && options?.cursor === void 0 ? void 0 : {
|
|
2145
|
+
...options?.limit === void 0 ? {} : { "x-tinycloud-limit": String(options.limit) },
|
|
2146
|
+
...options?.cursor === void 0 ? {} : { "x-tinycloud-cursor": options.cursor }
|
|
2147
|
+
}
|
|
1940
2148
|
);
|
|
1941
2149
|
if (!response.ok) {
|
|
1942
2150
|
if (response.status === 401) {
|
|
@@ -1968,7 +2176,8 @@ var KVService = class extends BaseService {
|
|
|
1968
2176
|
}
|
|
1969
2177
|
return ok({
|
|
1970
2178
|
keys,
|
|
1971
|
-
...response.headers.get("x-tinycloud-truncated") === null ? {} : { truncated: response.headers.get("x-tinycloud-truncated") === "true" }
|
|
2179
|
+
...response.headers.get("x-tinycloud-truncated") === null ? {} : { truncated: response.headers.get("x-tinycloud-truncated") === "true" },
|
|
2180
|
+
...response.headers.get("x-tinycloud-next-cursor") === null ? {} : { nextCursor: response.headers.get("x-tinycloud-next-cursor") ?? void 0 }
|
|
1972
2181
|
});
|
|
1973
2182
|
} catch (error) {
|
|
1974
2183
|
return err(wrapError("kv", error));
|
|
@@ -2088,6 +2297,13 @@ var KVService = class extends BaseService {
|
|
|
2088
2297
|
}
|
|
2089
2298
|
});
|
|
2090
2299
|
}
|
|
2300
|
+
async batchHead(keys, options) {
|
|
2301
|
+
return this.withTelemetry(
|
|
2302
|
+
"batchHead",
|
|
2303
|
+
String(keys.length),
|
|
2304
|
+
() => this.batchRead(keys, KVAction.HEAD, options)
|
|
2305
|
+
);
|
|
2306
|
+
}
|
|
2091
2307
|
/**
|
|
2092
2308
|
* Create a short-lived signed URL for reading a KV object.
|
|
2093
2309
|
*/
|
|
@@ -4686,6 +4902,10 @@ var DataVaultService = class extends BaseService {
|
|
|
4686
4902
|
* @returns Result with array of key names (vault/ prefix stripped)
|
|
4687
4903
|
*/
|
|
4688
4904
|
async list(options) {
|
|
4905
|
+
const page = await this.listPage(options);
|
|
4906
|
+
return page.ok ? { ok: true, data: page.data.keys } : page;
|
|
4907
|
+
}
|
|
4908
|
+
async listPage(options) {
|
|
4689
4909
|
return this.withTelemetry("list", options?.prefix, async () => {
|
|
4690
4910
|
if (!this.isUnlocked) {
|
|
4691
4911
|
return vaultError({
|
|
@@ -4703,7 +4923,9 @@ var DataVaultService = class extends BaseService {
|
|
|
4703
4923
|
const listPrefix = options?.prefix ? `vault/${options.prefix}` : "vault/";
|
|
4704
4924
|
const listResult = await this.tc.kv.list({
|
|
4705
4925
|
prefix: listPrefix,
|
|
4706
|
-
removePrefix: true
|
|
4926
|
+
removePrefix: true,
|
|
4927
|
+
...options?.limit === void 0 ? {} : { limit: options.limit },
|
|
4928
|
+
...options?.cursor === void 0 ? {} : { cursor: options.cursor }
|
|
4707
4929
|
});
|
|
4708
4930
|
if (!listResult.ok) {
|
|
4709
4931
|
return vaultError({
|
|
@@ -4720,7 +4942,11 @@ var DataVaultService = class extends BaseService {
|
|
|
4720
4942
|
(k) => k.startsWith(userPrefix) ? k.slice(userPrefix.length) : k
|
|
4721
4943
|
);
|
|
4722
4944
|
}
|
|
4723
|
-
return ok(
|
|
4945
|
+
return ok({
|
|
4946
|
+
keys,
|
|
4947
|
+
truncated: listResult.data.truncated === true,
|
|
4948
|
+
...listResult.data.nextCursor === void 0 ? {} : { nextCursor: listResult.data.nextCursor }
|
|
4949
|
+
});
|
|
4724
4950
|
} catch (error) {
|
|
4725
4951
|
return vaultError({
|
|
4726
4952
|
code: "STORAGE_ERROR",
|