@tinycloud/sdk-services 3.8.0-beta.16 → 3.8.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/{BaseService-DO7vZ67k.d.ts → BaseService-Ma2MwJAd.d.ts} +1 -1
  2. package/dist/{BaseService-D-29xShG.d.cts → BaseService-O0iyuFLk.d.cts} +1 -1
  3. package/dist/IHooksService-4QNODVy6.d.cts +120 -0
  4. package/dist/IHooksService-CvTpJbQD.d.ts +120 -0
  5. package/dist/ISQLService-Aly1CBsW.d.ts +242 -0
  6. package/dist/ISQLService-BOgWzHLT.d.cts +242 -0
  7. package/dist/context.d.cts +1 -1
  8. package/dist/context.d.ts +1 -1
  9. package/dist/encryption/index.d.cts +4 -4
  10. package/dist/encryption/index.d.ts +4 -4
  11. package/dist/encryption/named-keys.d.cts +2 -2
  12. package/dist/encryption/named-keys.d.ts +2 -2
  13. package/dist/feed/index.cjs +787 -0
  14. package/dist/feed/index.cjs.map +1 -0
  15. package/dist/feed/index.d.cts +176 -0
  16. package/dist/feed/index.d.ts +176 -0
  17. package/dist/feed/index.js +739 -0
  18. package/dist/feed/index.js.map +1 -0
  19. package/dist/index.cjs +51 -8
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +15 -115
  22. package/dist/index.d.ts +15 -115
  23. package/dist/index.js +51 -8
  24. package/dist/index.js.map +1 -1
  25. package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
  26. package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
  27. package/dist/kv/index.d.cts +4 -4
  28. package/dist/kv/index.d.ts +4 -4
  29. package/dist/kv/replication/index.d.cts +3 -3
  30. package/dist/kv/replication/index.d.ts +3 -3
  31. package/dist/{scope-1-8skVDk.d.ts → scope-BZr0QwxX.d.ts} +1 -1
  32. package/dist/{scope-Dv3IAXMr.d.cts → scope-DEgc9f-W.d.cts} +1 -1
  33. package/dist/sql/index.cjs +21 -6
  34. package/dist/sql/index.cjs.map +1 -1
  35. package/dist/sql/index.d.cts +6 -236
  36. package/dist/sql/index.d.ts +6 -236
  37. package/dist/sql/index.js +21 -6
  38. package/dist/sql/index.js.map +1 -1
  39. package/dist/telemetry/requestLog.d.cts +1 -1
  40. package/dist/telemetry/requestLog.d.ts +1 -1
  41. package/dist/{types-DZBExWAf.d.ts → types-Bf91gup6.d.ts} +1 -1
  42. package/dist/{types-DAOyIbXu.d.ts → types-CSd0RYir.d.cts} +1 -1
  43. package/dist/{types-DAOyIbXu.d.cts → types-CSd0RYir.d.ts} +1 -1
  44. package/dist/{types-CBKrdtP8.d.cts → types-D4XbIfFJ.d.cts} +1 -1
  45. package/package.json +6 -1
package/dist/index.d.cts CHANGED
@@ -1,17 +1,20 @@
1
- import { f as ServiceError, h as Result, P as PermissionHint, c as IService, S as ServiceSession, I as IServiceContext, j as StorageQuotaInfo } from './types-DAOyIbXu.cjs';
2
- export { k as ErrorCode, l as ErrorCodes, E as EventHandler, F as FetchFunction, d as FetchRequestInit, e as FetchResponse, m as InvocationFact, n as InvocationFacts, o as InvokeAnyEntry, b as InvokeAnyFunction, a as InvokeFunction, R as RetryPolicy, i as RetryStats, p as ServiceErrorEvent, g as ServiceHeaders, q as ServiceRequestEvent, r as ServiceResponseEvent, s as ServiceRetryEvent, T as TelemetryConfig, t as TelemetryEventHandler, u as TelemetryEvents, v as TelemetrySpanEvent, w as defaultRetryPolicy, x as err, y as ok, z as serviceError } from './types-DAOyIbXu.cjs';
1
+ import { g as ServiceError, f as Result, P as PermissionHint, c as IService, S as ServiceSession, I as IServiceContext, j as StorageQuotaInfo } from './types-CSd0RYir.cjs';
2
+ export { k as ErrorCode, l as ErrorCodes, E as EventHandler, F as FetchFunction, d as FetchRequestInit, e as FetchResponse, m as InvocationFact, n as InvocationFacts, o as InvokeAnyEntry, b as InvokeAnyFunction, a as InvokeFunction, R as RetryPolicy, i as RetryStats, p as ServiceErrorEvent, h as ServiceHeaders, q as ServiceRequestEvent, r as ServiceResponseEvent, s as ServiceRetryEvent, T as TelemetryConfig, t as TelemetryEventHandler, u as TelemetryEvents, v as TelemetrySpanEvent, w as defaultRetryPolicy, x as err, y as ok, z as serviceError } from './types-CSd0RYir.cjs';
3
3
  import { z } from 'zod';
4
4
  export { ServiceContext, ServiceContextConfig } from './context.cjs';
5
5
  export { RequestEvent, RequestLog, RequestLogReader, RequestService, RequestSink } from './telemetry/requestLog.cjs';
6
- import { B as BaseService } from './BaseService-D-29xShG.cjs';
7
- export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-D-29xShG.cjs';
6
+ import { B as BaseService } from './BaseService-O0iyuFLk.cjs';
7
+ export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-O0iyuFLk.cjs';
8
8
  import { IKVService } from './kv/index.cjs';
9
9
  export { IPrefixedKVService, KVService, PrefixedKVService } from './kv/index.cjs';
10
- export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aB as KVBatchReadResponse, aC as KVChange, aD as KVChangesAuthority, aE as KVChangesOptions, aF as KVChangesResponse, aG as KVCreateSignedReadUrlOptions, aH as KVDeleteOptions, aI as KVGetOptions, aJ as KVHeadOptions, aK as KVListOptions, b as KVListPage, aL as KVListResponse, aM as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aN as KVResponse, aO as KVResponseHeaders, aP as KVServiceConfig, aQ 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 ReplicaLocalEraseOutcome, a3 as ReplicaPageAdmission, a4 as ReplicaPartitionEraser, a5 as ReplicaPartitionIndexEntry, a6 as ReplicaPeerCommit, a7 as ReplicaPrivateGateHash, a8 as ReplicaPurgeError, a9 as ReplicaPurgeFailedEvent, aa as ReplicaPurgeIntent, ab as ReplicaPurgeLocalCopyResult, ac as ReplicaPurgeTrigger, ad as ReplicaQuotaLedger, ae as ReplicaQuotaSpec, af as ReplicaSessionStamp, ag as ReplicaStampedReply, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, ar as SaltedHash, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from './scope-Dv3IAXMr.cjs';
10
+ export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aB as KVBatchReadResponse, aC as KVChange, aD as KVChangesAuthority, aE as KVChangesOptions, aF as KVChangesResponse, aG as KVCreateSignedReadUrlOptions, aH as KVDeleteOptions, aI as KVGetOptions, aJ as KVHeadOptions, aK as KVListOptions, b as KVListPage, aL as KVListResponse, aM as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aN as KVResponse, aO as KVResponseHeaders, aP as KVServiceConfig, aQ 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 ReplicaLocalEraseOutcome, a3 as ReplicaPageAdmission, a4 as ReplicaPartitionEraser, a5 as ReplicaPartitionIndexEntry, a6 as ReplicaPeerCommit, a7 as ReplicaPrivateGateHash, a8 as ReplicaPurgeError, a9 as ReplicaPurgeFailedEvent, aa as ReplicaPurgeIntent, ab as ReplicaPurgeLocalCopyResult, ac as ReplicaPurgeTrigger, ad as ReplicaQuotaLedger, ae as ReplicaQuotaSpec, af as ReplicaSessionStamp, ag as ReplicaStampedReply, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, ar as SaltedHash, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from './scope-DEgc9f-W.cjs';
11
11
  export { ClampConsentAnchor, ConsentDeadlineMs, EffectiveGrantExpiry, EffectiveGrantExpiryInput, MintRemainingMs, NeedsSilentRenewal, ReplicaConsentAnchor, ReplicaConsentSource, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.cjs';
12
- 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';
13
- import { D as DecryptCapabilityProof } from './types-CBKrdtP8.cjs';
14
- export { B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation, C as CanonicalJson, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, g as DecryptInvocationFact, h as DecryptInvocationSigner, i as DecryptRequestBody, j as DecryptResponseBody, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, E as EncryptionCrypto, n as EncryptionError, o as EncryptionErrorInput, I as InlineEncryptedEnvelope, J as Json, N as NetworkDescriptor, R as ReceiverKeyPair, p as ReceiverKeySigner, q as base64Decode, r as base64Encode, s as canonicalHashHex, t as canonicalizeEncryptionJson, u as encryptionError, v as hexDecode, w as hexEncode, x as utf8Decode, y as utf8Encode } from './types-CBKrdtP8.cjs';
12
+ export { DatabaseHandle, SQLMigrations, SQLService } from './sql/index.cjs';
13
+ export { B as BatchOptions, a as BatchResponse, E as ExecuteOptions, b as ExecuteResponse, I as IDatabaseHandle, c as ISQLMigrations, d as ISQLService, Q as QueryOptions, e as QueryResponse, S as SQLAction, f as SQLActionType, g as SQLServiceConfig, h as SqlMigration, i as SqlMigrationApplyOptions, j as SqlMigrationApplyResponse, k as SqlStatement, l as SqlValue } from './ISQLService-BOgWzHLT.cjs';
14
+ import { I as IHooksService, a as HooksServiceConfig, H as HookSubscription, S as SubscribeOptions, b as HookEvent, c as HookWebhookRegistration, d as HookWebhookRecord, e as HookWebhookListOptions, f as HookWebhookUnregisterOptions } from './IHooksService-4QNODVy6.cjs';
15
+ export { g as HookServiceName, h as HookStreamEvent, i as HookStreamRetryConfig, j as HookWebhookScope } from './IHooksService-4QNODVy6.cjs';
16
+ import { D as DecryptCapabilityProof } from './types-D4XbIfFJ.cjs';
17
+ export { B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation, C as CanonicalJson, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, g as DecryptInvocationFact, h as DecryptInvocationSigner, i as DecryptRequestBody, j as DecryptResponseBody, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, E as EncryptionCrypto, n as EncryptionError, o as EncryptionErrorInput, I as InlineEncryptedEnvelope, J as Json, N as NetworkDescriptor, R as ReceiverKeyPair, p as ReceiverKeySigner, q as base64Decode, r as base64Encode, s as canonicalHashHex, t as canonicalizeEncryptionJson, u as encryptionError, v as hexDecode, w as hexEncode, x as utf8Decode, y as utf8Encode } from './types-D4XbIfFJ.cjs';
15
18
  import { IEncryptionService } from './encryption/index.cjs';
16
19
  export { BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, CanonicalDecryptRequest, DecryptEnvelopeOptions, DecryptTransport, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionService, EncryptionServiceConfig, NETWORK_NAME_PATTERN, NetworkIdError, NodeDescriptorFetcher, ParsedEncryptionResource, ParsedNetworkId, RandomReceiverKeyInput, SignedReceiverKeyInput, VerifyDecryptResponseInput, WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalSignedResponse, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, isNetworkId, networkDiscoveryKey, openWrappedKey, parseEncryptionResource, parseNetworkId, validateEnvelope, verifyDecryptResponse } from './encryption/index.cjs';
17
20
  export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
@@ -1369,112 +1372,6 @@ declare class DuckDbDatabaseHandle implements IDuckDbDatabaseHandle {
1369
1372
  import(data: Uint8Array, options?: DuckDbOptions): Promise<Result<void>>;
1370
1373
  }
1371
1374
 
1372
- type HookServiceName = "kv" | "sql" | "duckdb";
1373
- interface HookSubscription {
1374
- space: string;
1375
- service: HookServiceName;
1376
- pathPrefix?: string;
1377
- abilities?: string[];
1378
- }
1379
- interface HookWebhookScope {
1380
- space: string;
1381
- service: HookServiceName;
1382
- pathPrefix?: string;
1383
- abilities?: string[];
1384
- }
1385
- interface HookWebhookRegistration extends HookWebhookScope {
1386
- callbackUrl: string;
1387
- secret: string;
1388
- }
1389
- interface HookWebhookRecord extends HookWebhookScope {
1390
- id: string;
1391
- subscriberDid?: string;
1392
- callbackUrl: string;
1393
- active: boolean;
1394
- createdAt: string;
1395
- }
1396
- interface HookWebhookListOptions {
1397
- space?: string;
1398
- service?: HookServiceName;
1399
- pathPrefix?: string;
1400
- }
1401
- interface HookWebhookUnregisterOptions {
1402
- target?: HookWebhookScope;
1403
- }
1404
- interface HookEvent {
1405
- type: "write";
1406
- id: string;
1407
- space: string;
1408
- service: string;
1409
- ability: string;
1410
- path?: string;
1411
- actor: string;
1412
- epoch: string;
1413
- eventIndex: number;
1414
- timestamp: string;
1415
- }
1416
- interface HookStreamEvent {
1417
- event: string;
1418
- data: string;
1419
- id?: string;
1420
- }
1421
- interface SubscribeOptions {
1422
- ttlSeconds?: number;
1423
- signal?: AbortSignal;
1424
- }
1425
- interface HooksServiceConfig extends Record<string, unknown> {
1426
- host?: string;
1427
- /** Shared-stream retry tuning; see {@link HookStreamRetryConfig}. */
1428
- streamRetry?: HookStreamRetryConfig;
1429
- }
1430
- /**
1431
- * Retry policy for the shared `/hooks/events` stream. When the stream fails
1432
- * (network error, 5xx, or an expired/rotated ticket rejected with 401/403)
1433
- * it is re-opened with exponential backoff: `HOOK_STREAM_RETRY_BASE_DELAY_MS`
1434
- * (~250 ms) doubling to `HOOK_STREAM_RETRY_MAX_DELAY_MS` (~30 s) with jitter.
1435
- * The retry streak resets after an event is received or a stream remains open
1436
- * for at least 5 seconds. Retries stop when no subscribers remain, when the
1437
- * service is aborted, or when minting the hook ticket is refused (the iterator
1438
- * throws that typed error instead).
1439
- */
1440
- interface HookStreamRetryConfig {
1441
- /**
1442
- * Delay before retry attempt `attempt` (1-based). Defaults to the jittered
1443
- * exponential backoff described above. Must return milliseconds.
1444
- */
1445
- delay?: (attempt: number) => number;
1446
- /**
1447
- * How a retry delay is awaited — the injectable clock. `delayMs` is the
1448
- * resolved delay for `attempt`; `signal` aborts the wait early when the
1449
- * subscription set changes or the service stops. Rejecting or throwing is
1450
- * treated like a completed wait. After a custom wait returns — whether it
1451
- * fulfilled, rejected or threw — the service still yields one event-loop
1452
- * turn so a persistently failing stream can never starve the process.
1453
- * Defaults to an abortable, unref'd `setTimeout`.
1454
- */
1455
- wait?: (delayMs: number, attempt: number, signal: AbortSignal) => Promise<void>;
1456
- }
1457
-
1458
- interface IHooksService {
1459
- /**
1460
- * Stream hook events until `options.signal` aborts, the SDK signs out or
1461
- * the session ends, or the consumer stops iterating. Transient stream
1462
- * failures — network errors, 5xx, and an expired or rotated ticket rejected
1463
- * by `/hooks/events` (401/403) — are retried internally with backoff and
1464
- * never reach the iterator.
1465
- *
1466
- * The iterator throws when minting the hook ticket is refused. The thrown
1467
- * plain `ServiceError` carries `meta.status` with the refusing HTTP status,
1468
- * so `for await` consumers can branch on it. Stream diagnostics contain only
1469
- * SDK allow-listed identifiers; foreign error messages and causes are not
1470
- * copied.
1471
- */
1472
- subscribe(subscriptions: HookSubscription[], options?: SubscribeOptions): AsyncIterable<HookEvent>;
1473
- register(webhook: HookWebhookRegistration): Promise<Result<HookWebhookRecord>>;
1474
- list(options?: HookWebhookListOptions): Promise<Result<HookWebhookRecord[]>>;
1475
- unregister(id: string, options?: HookWebhookUnregisterOptions): Promise<Result<void>>;
1476
- }
1477
-
1478
1375
  declare class HooksService extends BaseService implements IHooksService {
1479
1376
  static readonly serviceName = "hooks";
1480
1377
  protected _config: HooksServiceConfig;
@@ -1485,6 +1382,8 @@ declare class HooksService extends BaseService implements IHooksService {
1485
1382
  private _phase?;
1486
1383
  /** Bumped on every session change; part of the plan key. */
1487
1384
  private _sessionGeneration;
1385
+ private _streamGeneration;
1386
+ private _readyStream?;
1488
1387
  private _lastContextSignal?;
1489
1388
  constructor(config?: HooksServiceConfig);
1490
1389
  get config(): HooksServiceConfig;
@@ -1532,6 +1431,7 @@ declare class HooksService extends BaseService implements IHooksService {
1532
1431
  private pause;
1533
1432
  /** The stream the current subscribers need, or undefined when none remain. */
1534
1433
  private plan;
1434
+ private notifyReady;
1535
1435
  private dispatch;
1536
1436
  /**
1537
1437
  * Detach every subscriber. With `error`, their iterators throw it after
@@ -2556,4 +2456,4 @@ declare class SecretsService implements ISecretsService {
2556
2456
  listAll(): Promise<Result<SecretCatalogEntry[], SecretsError>>;
2557
2457
  }
2558
2458
 
2559
- 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, 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, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, 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, 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, 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 };
2459
+ 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, GenericKVResponseSchema, type GenericKVResponseType, GenericResultSchema, HookEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, type IDataVaultService, type IDuckDbDatabaseHandle, type IDuckDbService, IEncryptionService, IHooksService, IKVService, type ISecretsService, IService, IServiceContext, type IStorageService, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, 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, 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, SubscribeOptions, TC832_RESERVED_SCOPES, type TableInfo, 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,17 +1,20 @@
1
- import { f as ServiceError, h as Result, P as PermissionHint, c as IService, S as ServiceSession, I as IServiceContext, j as StorageQuotaInfo } from './types-DAOyIbXu.js';
2
- export { k as ErrorCode, l as ErrorCodes, E as EventHandler, F as FetchFunction, d as FetchRequestInit, e as FetchResponse, m as InvocationFact, n as InvocationFacts, o as InvokeAnyEntry, b as InvokeAnyFunction, a as InvokeFunction, R as RetryPolicy, i as RetryStats, p as ServiceErrorEvent, g as ServiceHeaders, q as ServiceRequestEvent, r as ServiceResponseEvent, s as ServiceRetryEvent, T as TelemetryConfig, t as TelemetryEventHandler, u as TelemetryEvents, v as TelemetrySpanEvent, w as defaultRetryPolicy, x as err, y as ok, z as serviceError } from './types-DAOyIbXu.js';
1
+ import { g as ServiceError, f as Result, P as PermissionHint, c as IService, S as ServiceSession, I as IServiceContext, j as StorageQuotaInfo } from './types-CSd0RYir.js';
2
+ export { k as ErrorCode, l as ErrorCodes, E as EventHandler, F as FetchFunction, d as FetchRequestInit, e as FetchResponse, m as InvocationFact, n as InvocationFacts, o as InvokeAnyEntry, b as InvokeAnyFunction, a as InvokeFunction, R as RetryPolicy, i as RetryStats, p as ServiceErrorEvent, h as ServiceHeaders, q as ServiceRequestEvent, r as ServiceResponseEvent, s as ServiceRetryEvent, T as TelemetryConfig, t as TelemetryEventHandler, u as TelemetryEvents, v as TelemetrySpanEvent, w as defaultRetryPolicy, x as err, y as ok, z as serviceError } from './types-CSd0RYir.js';
3
3
  import { z } from 'zod';
4
4
  export { ServiceContext, ServiceContextConfig } from './context.js';
5
5
  export { RequestEvent, RequestLog, RequestLogReader, RequestService, RequestSink } from './telemetry/requestLog.js';
6
- import { B as BaseService } from './BaseService-DO7vZ67k.js';
7
- export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-DO7vZ67k.js';
6
+ import { B as BaseService } from './BaseService-Ma2MwJAd.js';
7
+ export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-Ma2MwJAd.js';
8
8
  import { IKVService } from './kv/index.js';
9
9
  export { IPrefixedKVService, KVService, PrefixedKVService } from './kv/index.js';
10
- export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aB as KVBatchReadResponse, aC as KVChange, aD as KVChangesAuthority, aE as KVChangesOptions, aF as KVChangesResponse, aG as KVCreateSignedReadUrlOptions, aH as KVDeleteOptions, aI as KVGetOptions, aJ as KVHeadOptions, aK as KVListOptions, b as KVListPage, aL as KVListResponse, aM as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aN as KVResponse, aO as KVResponseHeaders, aP as KVServiceConfig, aQ 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 ReplicaLocalEraseOutcome, a3 as ReplicaPageAdmission, a4 as ReplicaPartitionEraser, a5 as ReplicaPartitionIndexEntry, a6 as ReplicaPeerCommit, a7 as ReplicaPrivateGateHash, a8 as ReplicaPurgeError, a9 as ReplicaPurgeFailedEvent, aa as ReplicaPurgeIntent, ab as ReplicaPurgeLocalCopyResult, ac as ReplicaPurgeTrigger, ad as ReplicaQuotaLedger, ae as ReplicaQuotaSpec, af as ReplicaSessionStamp, ag as ReplicaStampedReply, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, ar as SaltedHash, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from './scope-1-8skVDk.js';
10
+ export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, av as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, aw as KVAction, ax as KVActionType, ay as KVBatchPutItem, az as KVBatchPutOptions, aA as KVBatchPutResponse, aB as KVBatchReadResponse, aC as KVChange, aD as KVChangesAuthority, aE as KVChangesOptions, aF as KVChangesResponse, aG as KVCreateSignedReadUrlOptions, aH as KVDeleteOptions, aI as KVGetOptions, aJ as KVHeadOptions, aK as KVListOptions, b as KVListPage, aL as KVListResponse, aM as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, aN as KVResponse, aO as KVResponseHeaders, aP as KVServiceConfig, aQ 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 ReplicaLocalEraseOutcome, a3 as ReplicaPageAdmission, a4 as ReplicaPartitionEraser, a5 as ReplicaPartitionIndexEntry, a6 as ReplicaPeerCommit, a7 as ReplicaPrivateGateHash, a8 as ReplicaPurgeError, a9 as ReplicaPurgeFailedEvent, aa as ReplicaPurgeIntent, ab as ReplicaPurgeLocalCopyResult, ac as ReplicaPurgeTrigger, ad as ReplicaQuotaLedger, ae as ReplicaQuotaSpec, af as ReplicaSessionStamp, ag as ReplicaStampedReply, ah as ReplicaState, ai as ReplicaStatusEntry, aj as ReplicationAuthority, ak as ReplicationControl, al as ReplicationEvent, R as ReplicationIdentity, am as ReplicationOptions, an as ReplicationPurgeReport, ao as ReplicationReason, ap as ReplicationScheduler, aq as ResolvedReplicationOptions, ar as SaltedHash, as as canonicalReplicationIdentity, at as replicationIdentityKey, au as requiresSecretsOptIn } from './scope-BZr0QwxX.js';
11
11
  export { ClampConsentAnchor, ConsentDeadlineMs, EffectiveGrantExpiry, EffectiveGrantExpiryInput, MintRemainingMs, NeedsSilentRenewal, ReplicaConsentAnchor, ReplicaConsentSource, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.js';
12
- 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';
13
- import { D as DecryptCapabilityProof } from './types-DZBExWAf.js';
14
- export { B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation, C as CanonicalJson, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, g as DecryptInvocationFact, h as DecryptInvocationSigner, i as DecryptRequestBody, j as DecryptResponseBody, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, E as EncryptionCrypto, n as EncryptionError, o as EncryptionErrorInput, I as InlineEncryptedEnvelope, J as Json, N as NetworkDescriptor, R as ReceiverKeyPair, p as ReceiverKeySigner, q as base64Decode, r as base64Encode, s as canonicalHashHex, t as canonicalizeEncryptionJson, u as encryptionError, v as hexDecode, w as hexEncode, x as utf8Decode, y as utf8Encode } from './types-DZBExWAf.js';
12
+ export { DatabaseHandle, SQLMigrations, SQLService } from './sql/index.js';
13
+ export { B as BatchOptions, a as BatchResponse, E as ExecuteOptions, b as ExecuteResponse, I as IDatabaseHandle, c as ISQLMigrations, d as ISQLService, Q as QueryOptions, e as QueryResponse, S as SQLAction, f as SQLActionType, g as SQLServiceConfig, h as SqlMigration, i as SqlMigrationApplyOptions, j as SqlMigrationApplyResponse, k as SqlStatement, l as SqlValue } from './ISQLService-Aly1CBsW.js';
14
+ import { I as IHooksService, a as HooksServiceConfig, H as HookSubscription, S as SubscribeOptions, b as HookEvent, c as HookWebhookRegistration, d as HookWebhookRecord, e as HookWebhookListOptions, f as HookWebhookUnregisterOptions } from './IHooksService-CvTpJbQD.js';
15
+ export { g as HookServiceName, h as HookStreamEvent, i as HookStreamRetryConfig, j as HookWebhookScope } from './IHooksService-CvTpJbQD.js';
16
+ import { D as DecryptCapabilityProof } from './types-Bf91gup6.js';
17
+ export { B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation, C as CanonicalJson, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, g as DecryptInvocationFact, h as DecryptInvocationSigner, i as DecryptRequestBody, j as DecryptResponseBody, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, E as EncryptionCrypto, n as EncryptionError, o as EncryptionErrorInput, I as InlineEncryptedEnvelope, J as Json, N as NetworkDescriptor, R as ReceiverKeyPair, p as ReceiverKeySigner, q as base64Decode, r as base64Encode, s as canonicalHashHex, t as canonicalizeEncryptionJson, u as encryptionError, v as hexDecode, w as hexEncode, x as utf8Decode, y as utf8Encode } from './types-Bf91gup6.js';
15
18
  import { IEncryptionService } from './encryption/index.js';
16
19
  export { BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, CanonicalDecryptRequest, DecryptEnvelopeOptions, DecryptTransport, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionService, EncryptionServiceConfig, NETWORK_NAME_PATTERN, NetworkIdError, NodeDescriptorFetcher, ParsedEncryptionResource, ParsedNetworkId, RandomReceiverKeyInput, SignedReceiverKeyInput, VerifyDecryptResponseInput, WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalSignedResponse, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, isNetworkId, networkDiscoveryKey, openWrappedKey, parseEncryptionResource, parseNetworkId, validateEnvelope, verifyDecryptResponse } from './encryption/index.js';
17
20
  export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
@@ -1369,112 +1372,6 @@ declare class DuckDbDatabaseHandle implements IDuckDbDatabaseHandle {
1369
1372
  import(data: Uint8Array, options?: DuckDbOptions): Promise<Result<void>>;
1370
1373
  }
1371
1374
 
1372
- type HookServiceName = "kv" | "sql" | "duckdb";
1373
- interface HookSubscription {
1374
- space: string;
1375
- service: HookServiceName;
1376
- pathPrefix?: string;
1377
- abilities?: string[];
1378
- }
1379
- interface HookWebhookScope {
1380
- space: string;
1381
- service: HookServiceName;
1382
- pathPrefix?: string;
1383
- abilities?: string[];
1384
- }
1385
- interface HookWebhookRegistration extends HookWebhookScope {
1386
- callbackUrl: string;
1387
- secret: string;
1388
- }
1389
- interface HookWebhookRecord extends HookWebhookScope {
1390
- id: string;
1391
- subscriberDid?: string;
1392
- callbackUrl: string;
1393
- active: boolean;
1394
- createdAt: string;
1395
- }
1396
- interface HookWebhookListOptions {
1397
- space?: string;
1398
- service?: HookServiceName;
1399
- pathPrefix?: string;
1400
- }
1401
- interface HookWebhookUnregisterOptions {
1402
- target?: HookWebhookScope;
1403
- }
1404
- interface HookEvent {
1405
- type: "write";
1406
- id: string;
1407
- space: string;
1408
- service: string;
1409
- ability: string;
1410
- path?: string;
1411
- actor: string;
1412
- epoch: string;
1413
- eventIndex: number;
1414
- timestamp: string;
1415
- }
1416
- interface HookStreamEvent {
1417
- event: string;
1418
- data: string;
1419
- id?: string;
1420
- }
1421
- interface SubscribeOptions {
1422
- ttlSeconds?: number;
1423
- signal?: AbortSignal;
1424
- }
1425
- interface HooksServiceConfig extends Record<string, unknown> {
1426
- host?: string;
1427
- /** Shared-stream retry tuning; see {@link HookStreamRetryConfig}. */
1428
- streamRetry?: HookStreamRetryConfig;
1429
- }
1430
- /**
1431
- * Retry policy for the shared `/hooks/events` stream. When the stream fails
1432
- * (network error, 5xx, or an expired/rotated ticket rejected with 401/403)
1433
- * it is re-opened with exponential backoff: `HOOK_STREAM_RETRY_BASE_DELAY_MS`
1434
- * (~250 ms) doubling to `HOOK_STREAM_RETRY_MAX_DELAY_MS` (~30 s) with jitter.
1435
- * The retry streak resets after an event is received or a stream remains open
1436
- * for at least 5 seconds. Retries stop when no subscribers remain, when the
1437
- * service is aborted, or when minting the hook ticket is refused (the iterator
1438
- * throws that typed error instead).
1439
- */
1440
- interface HookStreamRetryConfig {
1441
- /**
1442
- * Delay before retry attempt `attempt` (1-based). Defaults to the jittered
1443
- * exponential backoff described above. Must return milliseconds.
1444
- */
1445
- delay?: (attempt: number) => number;
1446
- /**
1447
- * How a retry delay is awaited — the injectable clock. `delayMs` is the
1448
- * resolved delay for `attempt`; `signal` aborts the wait early when the
1449
- * subscription set changes or the service stops. Rejecting or throwing is
1450
- * treated like a completed wait. After a custom wait returns — whether it
1451
- * fulfilled, rejected or threw — the service still yields one event-loop
1452
- * turn so a persistently failing stream can never starve the process.
1453
- * Defaults to an abortable, unref'd `setTimeout`.
1454
- */
1455
- wait?: (delayMs: number, attempt: number, signal: AbortSignal) => Promise<void>;
1456
- }
1457
-
1458
- interface IHooksService {
1459
- /**
1460
- * Stream hook events until `options.signal` aborts, the SDK signs out or
1461
- * the session ends, or the consumer stops iterating. Transient stream
1462
- * failures — network errors, 5xx, and an expired or rotated ticket rejected
1463
- * by `/hooks/events` (401/403) — are retried internally with backoff and
1464
- * never reach the iterator.
1465
- *
1466
- * The iterator throws when minting the hook ticket is refused. The thrown
1467
- * plain `ServiceError` carries `meta.status` with the refusing HTTP status,
1468
- * so `for await` consumers can branch on it. Stream diagnostics contain only
1469
- * SDK allow-listed identifiers; foreign error messages and causes are not
1470
- * copied.
1471
- */
1472
- subscribe(subscriptions: HookSubscription[], options?: SubscribeOptions): AsyncIterable<HookEvent>;
1473
- register(webhook: HookWebhookRegistration): Promise<Result<HookWebhookRecord>>;
1474
- list(options?: HookWebhookListOptions): Promise<Result<HookWebhookRecord[]>>;
1475
- unregister(id: string, options?: HookWebhookUnregisterOptions): Promise<Result<void>>;
1476
- }
1477
-
1478
1375
  declare class HooksService extends BaseService implements IHooksService {
1479
1376
  static readonly serviceName = "hooks";
1480
1377
  protected _config: HooksServiceConfig;
@@ -1485,6 +1382,8 @@ declare class HooksService extends BaseService implements IHooksService {
1485
1382
  private _phase?;
1486
1383
  /** Bumped on every session change; part of the plan key. */
1487
1384
  private _sessionGeneration;
1385
+ private _streamGeneration;
1386
+ private _readyStream?;
1488
1387
  private _lastContextSignal?;
1489
1388
  constructor(config?: HooksServiceConfig);
1490
1389
  get config(): HooksServiceConfig;
@@ -1532,6 +1431,7 @@ declare class HooksService extends BaseService implements IHooksService {
1532
1431
  private pause;
1533
1432
  /** The stream the current subscribers need, or undefined when none remain. */
1534
1433
  private plan;
1434
+ private notifyReady;
1535
1435
  private dispatch;
1536
1436
  /**
1537
1437
  * Detach every subscriber. With `error`, their iterators throw it after
@@ -2556,4 +2456,4 @@ declare class SecretsService implements ISecretsService {
2556
2456
  listAll(): Promise<Result<SecretCatalogEntry[], SecretsError>>;
2557
2457
  }
2558
2458
 
2559
- 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, 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, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, 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, 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, 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 };
2459
+ 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, GenericKVResponseSchema, type GenericKVResponseType, GenericResultSchema, HookEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, type IDataVaultService, type IDuckDbDatabaseHandle, type IDuckDbService, IEncryptionService, IHooksService, IKVService, type ISecretsService, IService, IServiceContext, type IStorageService, KVListResponseSchema, type KVListResponseType, KVListResultSchema, type KVListResultType, KVResponseHeadersSchema, type KVResponseHeadersType, MAX_SECRET_SCOPE_LENGTH, type ParsedSecretCatalogKey, PermissionHint, type QuotaConfig, type QuotaStatus, type ResolvedSecretPath, Result, 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, 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, SubscribeOptions, TC832_RESERVED_SCOPES, type TableInfo, 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
@@ -3631,12 +3631,13 @@ var SQLService = class extends BaseService {
3631
3631
  request.signal
3632
3632
  );
3633
3633
  if (!response.ok) {
3634
- return await this.handleErrorResponse(response, "query", dbName, [action]);
3634
+ const failure = await this.handleErrorResponse(response, "query", dbName, [action]);
3635
+ return this.redactFailure(failure, options?.redactErrors, response.status);
3635
3636
  }
3636
3637
  const data = await response.json();
3637
3638
  return ok(data);
3638
3639
  } catch (error) {
3639
- return err(wrapError("sql", error));
3640
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
3640
3641
  } finally {
3641
3642
  request.dispose();
3642
3643
  }
@@ -3671,12 +3672,13 @@ var SQLService = class extends BaseService {
3671
3672
  request.signal
3672
3673
  );
3673
3674
  if (!response.ok) {
3674
- return await this.handleErrorResponse(response, "execute", dbName, requestedActions);
3675
+ const failure = await this.handleErrorResponse(response, "execute", dbName, requestedActions);
3676
+ return this.redactFailure(failure, options?.redactErrors, response.status);
3675
3677
  }
3676
3678
  const data = await response.json();
3677
3679
  return ok(data);
3678
3680
  } catch (error) {
3679
- return err(wrapError("sql", error));
3681
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
3680
3682
  } finally {
3681
3683
  request.dispose();
3682
3684
  }
@@ -3697,12 +3699,13 @@ var SQLService = class extends BaseService {
3697
3699
  request.signal
3698
3700
  );
3699
3701
  if (!response.ok) {
3700
- return await this.handleErrorResponse(response, "batch", dbName, requestedActions);
3702
+ const failure = await this.handleErrorResponse(response, "batch", dbName, requestedActions);
3703
+ return this.redactFailure(failure, options?.redactErrors, response.status);
3701
3704
  }
3702
3705
  const data = await response.json();
3703
3706
  return ok(data);
3704
3707
  } catch (error) {
3705
- return err(wrapError("sql", error));
3708
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
3706
3709
  } finally {
3707
3710
  request.dispose();
3708
3711
  }
@@ -3898,6 +3901,18 @@ var SQLService = class extends BaseService {
3898
3901
  }))
3899
3902
  );
3900
3903
  }
3904
+ redactFailure(result, redactErrors, status) {
3905
+ if (!redactErrors || result.ok) return result;
3906
+ const candidate = result.error.code;
3907
+ const code = typeof candidate === "string" && Object.prototype.hasOwnProperty.call(ErrorCodes, candidate) ? candidate : ErrorCodes.SQL_ERROR;
3908
+ const safeStatus = typeof status === "number" && Number.isInteger(status) && status >= 400 && status <= 599 ? status : void 0;
3909
+ return err(serviceError(
3910
+ code,
3911
+ "SQL operation failed",
3912
+ "sql",
3913
+ safeStatus === void 0 ? void 0 : { meta: { status: safeStatus } }
3914
+ ));
3915
+ }
3901
3916
  async handleErrorResponse(response, operation, dbName, requestedActions) {
3902
3917
  const errorText = await response.text();
3903
3918
  const meta = responseErrorMeta(response.status, response.statusText, errorText);
@@ -4495,6 +4510,7 @@ var HooksService = class extends BaseService {
4495
4510
  this._supervising = false;
4496
4511
  /** Bumped on every session change; part of the plan key. */
4497
4512
  this._sessionGeneration = 0;
4513
+ this._streamGeneration = 0;
4498
4514
  this._config = config;
4499
4515
  }
4500
4516
  get config() {
@@ -4515,6 +4531,7 @@ var HooksService = class extends BaseService {
4515
4531
  requested,
4516
4532
  signatures: requested.map(subscriptionSignature),
4517
4533
  ttlSeconds: options.ttlSeconds,
4534
+ onReady: options.onReady,
4518
4535
  queue: new AsyncQueue()
4519
4536
  };
4520
4537
  const leave = () => {
@@ -4529,6 +4546,7 @@ var HooksService = class extends BaseService {
4529
4546
  signal?.addEventListener("abort", leave, { once: true });
4530
4547
  this._subscribers.add(subscriber);
4531
4548
  this.wake();
4549
+ if (this._readyStream) this.notifyReady(subscriber, this._readyStream);
4532
4550
  try {
4533
4551
  for await (const event of subscriber.queue) {
4534
4552
  yield event;
@@ -4761,6 +4779,7 @@ var HooksService = class extends BaseService {
4761
4779
  async attempt(plan, signal, health) {
4762
4780
  let phase = "mint";
4763
4781
  let request;
4782
+ const generation = ++this._streamGeneration;
4764
4783
  const owns = () => !signal.aborted && !request?.signal.aborted && this.plan()?.key === plan.key;
4765
4784
  try {
4766
4785
  const context = this.context;
@@ -4825,6 +4844,14 @@ var HooksService = class extends BaseService {
4825
4844
  if (next.done) break;
4826
4845
  const message = next.value;
4827
4846
  if (!message.data) continue;
4847
+ if (message.event === "ready") {
4848
+ const marker = JSON.parse(message.data);
4849
+ if (marker !== null && typeof marker === "object" && "type" in marker && marker.type === "ready") {
4850
+ this._readyStream = { key: plan.key, generation };
4851
+ for (const subscriber of this._subscribers) this.notifyReady(subscriber, this._readyStream);
4852
+ }
4853
+ continue;
4854
+ }
4828
4855
  const event = parseHookEvent(message);
4829
4856
  if (!owns()) return { kind: "stopped" };
4830
4857
  this.dispatch(event);
@@ -4837,6 +4864,8 @@ var HooksService = class extends BaseService {
4837
4864
  return owns() ? { kind: "ended" } : { kind: "stopped" };
4838
4865
  } catch (thrown) {
4839
4866
  return request?.signal.aborted || thrown === SUPERSEDED ? { kind: "stopped" } : { kind: "failed", error: hookStreamFailure(phase, thrown) };
4867
+ } finally {
4868
+ if (this._readyStream?.generation === generation) this._readyStream = void 0;
4840
4869
  }
4841
4870
  }
4842
4871
  /**
@@ -4892,6 +4921,15 @@ var HooksService = class extends BaseService {
4892
4921
  ttlSeconds
4893
4922
  };
4894
4923
  }
4924
+ notifyReady(subscriber, ready) {
4925
+ if (!this._subscribers.has(subscriber) || subscriber.readyGeneration === ready.generation || this.plan()?.key !== ready.key || this._phase?.interrupt.signal.aborted) return;
4926
+ subscriber.readyGeneration = ready.generation;
4927
+ try {
4928
+ subscriber.onReady?.();
4929
+ } catch {
4930
+ this.report(serviceError(ErrorCodes.INVALID_INPUT, "Hook readiness callback failed", "hooks"));
4931
+ }
4932
+ }
4895
4933
  dispatch(event) {
4896
4934
  for (const subscriber of this._subscribers) {
4897
4935
  if (matchesAnySubscription(event, subscriber.requested)) {
@@ -5126,7 +5164,7 @@ function abortPromise(signal) {
5126
5164
  function normalizeSubscription(subscription) {
5127
5165
  return {
5128
5166
  ...subscription,
5129
- pathPrefix: normalizePathPrefix(subscription.pathPrefix),
5167
+ pathPrefix: subscription.service === "kv" ? normalizePathPrefix(subscription.pathPrefix) : subscription.pathPrefix?.replace(/^\/+/, "") || void 0,
5130
5168
  abilities: subscription.abilities ? [...subscription.abilities] : []
5131
5169
  };
5132
5170
  }
@@ -5150,7 +5188,11 @@ function matchesSubscription(event, subscription) {
5150
5188
  if (event.service !== subscription.service) {
5151
5189
  return false;
5152
5190
  }
5153
- if (subscription.pathPrefix) {
5191
+ if (event.service === "sql" || event.service === "duckdb") {
5192
+ const scope = subscription.pathPrefix;
5193
+ const database = event.databasePath ?? event.path;
5194
+ if (scope && scope !== "/" && (!database || (scope.endsWith("/") ? !database.startsWith(scope) : database !== scope))) return false;
5195
+ } else if (subscription.pathPrefix) {
5154
5196
  const prefix = subscription.pathPrefix.endsWith("/") ? subscription.pathPrefix : `${subscription.pathPrefix}/`;
5155
5197
  if (event.path && event.path !== subscription.pathPrefix && !event.path.startsWith(prefix)) {
5156
5198
  return false;
@@ -5310,6 +5352,7 @@ function parseHookEvent(message) {
5310
5352
  service: parsed.service ?? "",
5311
5353
  ability: parsed.ability ?? "",
5312
5354
  path: parsed.path,
5355
+ databasePath: typeof parsed.databasePath === "string" ? parsed.databasePath : void 0,
5313
5356
  actor: parsed.actor ?? "",
5314
5357
  epoch: parsed.epoch ?? "",
5315
5358
  eventIndex: parsed.eventIndex ?? 0,