@lunora/client 1.0.0-alpha.227 → 1.0.0-alpha.228
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/index.d.mts
CHANGED
|
@@ -665,6 +665,28 @@ interface LiveStream {
|
|
|
665
665
|
* @param url the `connect` route URL (its sibling `control` route is derived)
|
|
666
666
|
*/
|
|
667
667
|
declare const connectLiveStream: (url: string, options?: ConnectLiveStreamOptions) => LiveStream;
|
|
668
|
+
/** Options for {@link subscribeLiveTopic}. */
|
|
669
|
+
interface SubscribeLiveTopicOptions extends Omit<ConnectLiveStreamOptions, "fetch"> {
|
|
670
|
+
/** Called when the shard refuses this subscription (403, 409, 429 and similar). */
|
|
671
|
+
onError?: (error: LiveStreamSubscribeError) => void;
|
|
672
|
+
/** Called for every event on `topic`. */
|
|
673
|
+
onEvent?: (payload: unknown) => void;
|
|
674
|
+
/**
|
|
675
|
+
* Partitions the shared connection. A cookie-authenticated stream is bound to the session that opened it, so
|
|
676
|
+
* pass something that changes when the signed-in user does (a user id): a new value opens a new connection
|
|
677
|
+
* and the old one closes once its subscribers have moved. It is never sent to the server.
|
|
678
|
+
*/
|
|
679
|
+
sessionKey?: string;
|
|
680
|
+
/** The topic to follow. */
|
|
681
|
+
topic: string;
|
|
682
|
+
/** The `connect` route URL of a `defineLiveStream`. */
|
|
683
|
+
url: string;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Follow `topic` on the shared connection for `url`.
|
|
687
|
+
* @returns an unsubscribe handle; the last one out closes the connection
|
|
688
|
+
*/
|
|
689
|
+
declare const subscribeLiveTopic: (options: SubscribeLiveTopicOptions) => (() => void);
|
|
668
690
|
/**
|
|
669
691
|
* The structural surface of a TanStack `Transaction` a bound custom mutator
|
|
670
692
|
* returns — its `isPersisted.promise` resolves once the write is persisted and
|
|
@@ -1018,4 +1040,4 @@ declare const createIndexedDbQueryCache: (options?: IndexedDbQueryCacheOptions)
|
|
|
1018
1040
|
* ```
|
|
1019
1041
|
*/
|
|
1020
1042
|
declare const createSnapshotPrecondition: (client: LunoraClient, functionRef: FunctionReference, args: Record<string, unknown>, shardKey?: string) => (() => boolean);
|
|
1021
|
-
export { type AsyncStorageLike, type AsyncStoragePersistenceOptions, type AsyncStorageQueryCacheOptions, type BookmarkStorage, CONFLICT_ERROR_CODE, type ConnectLiveStreamOptions, type ConnectionStatus, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamOptions, type HttpStreamRef, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, type LiveStream, type LiveStreamEvent, type LiveStreamSubscribeOptions, LunoraClient, type MutationDelta, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type OptimisticMessage, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, RETIRE_AFTER_DURABLE_SEQ_ADVANCE, type ReconcileDurableMessage, type ReconnectCalculator, type ReconnectOptions, type StreamIterable, type SubscriptionError, TabCoordinator, TransportError, applyDelta, connectLiveStream, createAsyncStoragePersistence, createAsyncStorageQueryCache, createCallRunner, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutatorRunner, createReconnect, createSnapshotPrecondition, getErrorCode, getRetryAfterMs, httpStream, isAuthReplayFailure, isConflictError, isForbiddenError, isMutationDelta, isRateLimitedError, isUnauthorizedError, maxSeq, queryCacheKey, reconcileOptimistic };
|
|
1043
|
+
export { type AsyncStorageLike, type AsyncStoragePersistenceOptions, type AsyncStorageQueryCacheOptions, type BookmarkStorage, CONFLICT_ERROR_CODE, type ConnectLiveStreamOptions, type ConnectionStatus, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamOptions, type HttpStreamRef, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, type LiveStream, type LiveStreamEvent, type LiveStreamSubscribeError, type LiveStreamSubscribeOptions, LunoraClient, type MutationDelta, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type OptimisticMessage, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, RETIRE_AFTER_DURABLE_SEQ_ADVANCE, type ReconcileDurableMessage, type ReconnectCalculator, type ReconnectOptions, type StreamIterable, type SubscribeLiveTopicOptions, type SubscriptionError, TabCoordinator, TransportError, applyDelta, connectLiveStream, createAsyncStoragePersistence, createAsyncStorageQueryCache, createCallRunner, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutatorRunner, createReconnect, createSnapshotPrecondition, getErrorCode, getRetryAfterMs, httpStream, isAuthReplayFailure, isConflictError, isForbiddenError, isMutationDelta, isRateLimitedError, isUnauthorizedError, maxSeq, queryCacheKey, reconcileOptimistic, subscribeLiveTopic };
|
package/dist/index.d.ts
CHANGED
|
@@ -665,6 +665,28 @@ interface LiveStream {
|
|
|
665
665
|
* @param url the `connect` route URL (its sibling `control` route is derived)
|
|
666
666
|
*/
|
|
667
667
|
declare const connectLiveStream: (url: string, options?: ConnectLiveStreamOptions) => LiveStream;
|
|
668
|
+
/** Options for {@link subscribeLiveTopic}. */
|
|
669
|
+
interface SubscribeLiveTopicOptions extends Omit<ConnectLiveStreamOptions, "fetch"> {
|
|
670
|
+
/** Called when the shard refuses this subscription (403, 409, 429 and similar). */
|
|
671
|
+
onError?: (error: LiveStreamSubscribeError) => void;
|
|
672
|
+
/** Called for every event on `topic`. */
|
|
673
|
+
onEvent?: (payload: unknown) => void;
|
|
674
|
+
/**
|
|
675
|
+
* Partitions the shared connection. A cookie-authenticated stream is bound to the session that opened it, so
|
|
676
|
+
* pass something that changes when the signed-in user does (a user id): a new value opens a new connection
|
|
677
|
+
* and the old one closes once its subscribers have moved. It is never sent to the server.
|
|
678
|
+
*/
|
|
679
|
+
sessionKey?: string;
|
|
680
|
+
/** The topic to follow. */
|
|
681
|
+
topic: string;
|
|
682
|
+
/** The `connect` route URL of a `defineLiveStream`. */
|
|
683
|
+
url: string;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Follow `topic` on the shared connection for `url`.
|
|
687
|
+
* @returns an unsubscribe handle; the last one out closes the connection
|
|
688
|
+
*/
|
|
689
|
+
declare const subscribeLiveTopic: (options: SubscribeLiveTopicOptions) => (() => void);
|
|
668
690
|
/**
|
|
669
691
|
* The structural surface of a TanStack `Transaction` a bound custom mutator
|
|
670
692
|
* returns — its `isPersisted.promise` resolves once the write is persisted and
|
|
@@ -1018,4 +1040,4 @@ declare const createIndexedDbQueryCache: (options?: IndexedDbQueryCacheOptions)
|
|
|
1018
1040
|
* ```
|
|
1019
1041
|
*/
|
|
1020
1042
|
declare const createSnapshotPrecondition: (client: LunoraClient, functionRef: FunctionReference, args: Record<string, unknown>, shardKey?: string) => (() => boolean);
|
|
1021
|
-
export { type AsyncStorageLike, type AsyncStoragePersistenceOptions, type AsyncStorageQueryCacheOptions, type BookmarkStorage, CONFLICT_ERROR_CODE, type ConnectLiveStreamOptions, type ConnectionStatus, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamOptions, type HttpStreamRef, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, type LiveStream, type LiveStreamEvent, type LiveStreamSubscribeOptions, LunoraClient, type MutationDelta, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type OptimisticMessage, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, RETIRE_AFTER_DURABLE_SEQ_ADVANCE, type ReconcileDurableMessage, type ReconnectCalculator, type ReconnectOptions, type StreamIterable, type SubscriptionError, TabCoordinator, TransportError, applyDelta, connectLiveStream, createAsyncStoragePersistence, createAsyncStorageQueryCache, createCallRunner, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutatorRunner, createReconnect, createSnapshotPrecondition, getErrorCode, getRetryAfterMs, httpStream, isAuthReplayFailure, isConflictError, isForbiddenError, isMutationDelta, isRateLimitedError, isUnauthorizedError, maxSeq, queryCacheKey, reconcileOptimistic };
|
|
1043
|
+
export { type AsyncStorageLike, type AsyncStoragePersistenceOptions, type AsyncStorageQueryCacheOptions, type BookmarkStorage, CONFLICT_ERROR_CODE, type ConnectLiveStreamOptions, type ConnectionStatus, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamOptions, type HttpStreamRef, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, type LiveStream, type LiveStreamEvent, type LiveStreamSubscribeError, type LiveStreamSubscribeOptions, LunoraClient, type MutationDelta, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type OptimisticMessage, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, RETIRE_AFTER_DURABLE_SEQ_ADVANCE, type ReconcileDurableMessage, type ReconnectCalculator, type ReconnectOptions, type StreamIterable, type SubscribeLiveTopicOptions, type SubscriptionError, TabCoordinator, TransportError, applyDelta, connectLiveStream, createAsyncStoragePersistence, createAsyncStorageQueryCache, createCallRunner, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutatorRunner, createReconnect, createSnapshotPrecondition, getErrorCode, getRetryAfterMs, httpStream, isAuthReplayFailure, isConflictError, isForbiddenError, isMutationDelta, isRateLimitedError, isUnauthorizedError, maxSeq, queryCacheKey, reconcileOptimistic, subscribeLiveTopic };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RETIRE_AFTER_DURABLE_SEQ_ADVANCE as o,maxSeq as t,reconcileOptimistic as a}from"./packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs";import{createAsyncStoragePersistence as
|
|
1
|
+
import{RETIRE_AFTER_DURABLE_SEQ_ADVANCE as o,maxSeq as t,reconcileOptimistic as a}from"./packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs";import{createAsyncStoragePersistence as i}from"./packem_shared/createAsyncStoragePersistence-6FCvqc6C.mjs";import{createAsyncStorageQueryCache as m}from"./packem_shared/createAsyncStorageQueryCache-f5023fdB.mjs";import{default as f}from"./packem_shared/createInMemoryBookmarkStorage-BooZhW0n.mjs";import{createCallRunner as x}from"./packem_shared/createCallRunner-Bwcrfh76.mjs";import{createClientQuery as l}from"./packem_shared/createClientQuery-B8Nfj-7o.mjs";import{TabCoordinator as d}from"./packem_shared/TabCoordinator-CXD7vulJ.mjs";import{a as R,i as C}from"./packem_shared/delta-merge-Ls3DED4g.mjs";import{CONFLICT_ERROR_CODE as A,TransportError as h,getErrorCode as D,getRetryAfterMs as L,isAuthReplayFailure as Q,isConflictError as _,isForbiddenError as b,isRateLimitedError as F,isUnauthorizedError as I}from"./packem_shared/CONFLICT_ERROR_CODE-B7qNZMMk.mjs";import{httpStream as T}from"./packem_shared/httpStream-BhSpxRWB.mjs";import{connectLiveStream as O}from"./packem_shared/connectLiveStream-2grXejmG.mjs";import{subscribeLiveTopic as U}from"./packem_shared/subscribeLiveTopic-CKVb3Txs.mjs";import{c as k}from"./packem_shared/local-store-fqWV2n_Z.mjs";import{LunoraClient as v}from"./packem_shared/LunoraClient-CJCINRHw.mjs";import{createMutatorRunner as z}from"./packem_shared/createMutatorRunner-CuMRJpUx.mjs";import{O as V}from"./packem_shared/offline-queue-D_fr-uQ3.mjs";import{createInMemoryPersistence as j,createIndexedDbPersistence as w}from"./packem_shared/createInMemoryPersistence-Cz2W6XVj.mjs";import{preloadQuery as H,preloadedQueryResult as J}from"./packem_shared/preloadQuery-uFy24PCR.mjs";import{createInMemoryQueryCache as Y,createIndexedDbQueryCache as Z,queryCacheKey as $}from"./packem_shared/createInMemoryQueryCache-D2uNHLfM.mjs";import{createReconnect as re}from"./packem_shared/createReconnect-CjTmjJDH.mjs";import{default as te}from"./packem_shared/createSnapshotPrecondition-CLkxVeN1.mjs";import{DEFAULT_MAX_BUFFER as ce,createStream as ie}from"./packem_shared/DEFAULT_MAX_BUFFER-Bd-_iyiV.mjs";import{SubscriptionRegistry as me}from"./packem_shared/SubscriptionRegistry-DKIXE7M7.mjs";export{A as CONFLICT_ERROR_CODE,ce as DEFAULT_MAX_BUFFER,v as LunoraClient,V as OfflineQueue,o as RETIRE_AFTER_DURABLE_SEQ_ADVANCE,me as SubscriptionRegistry,d as TabCoordinator,h as TransportError,R as applyDelta,O as connectLiveStream,i as createAsyncStoragePersistence,m as createAsyncStorageQueryCache,x as createCallRunner,l as createClientQuery,f as createInMemoryBookmarkStorage,j as createInMemoryPersistence,Y as createInMemoryQueryCache,w as createIndexedDbPersistence,Z as createIndexedDbQueryCache,k as createLocalStore,z as createMutatorRunner,re as createReconnect,te as createSnapshotPrecondition,ie as createStream,D as getErrorCode,L as getRetryAfterMs,T as httpStream,Q as isAuthReplayFailure,_ as isConflictError,b as isForbiddenError,C as isMutationDelta,F as isRateLimitedError,I as isUnauthorizedError,t as maxSeq,H as preloadQuery,J as preloadedQueryResult,$ as queryCacheKey,a as reconcileOptimistic,U as subscribeLiveTopic};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{connectLiveStream as d}from"./connectLiveStream-2grXejmG.mjs";const c=new Map,u=e=>JSON.stringify([e.url,e.sessionKey,e.withCredentials===!0,e.retryDelay,e.maxDelayMs,Object.entries(e.headers??{}).toSorted(([t],[r])=>t.localeCompare(r))]),f=e=>{const t=u(e);let r=c.get(t);if(r===void 0){const{headers:i,maxDelayMs:m,retryDelay:o,withCredentials:n}=e;r={closeTimer:void 0,refs:0,stream:d(e.url,{headers:i,maxDelayMs:m,retryDelay:o,withCredentials:n})},c.set(t,r)}clearTimeout(r.closeTimer),r.closeTimer=void 0,r.refs+=1;const s=r,a=s.stream.subscribe({id:e.topic,onError:e.onError,onEvent:e.onEvent,topic:e.topic});let l=!1;return()=>{l||(l=!0,a(),s.refs-=1,s.refs===0&&(s.closeTimer=setTimeout(()=>{c.delete(t),s.stream.close()},0)))}};export{f as subscribeLiveTopic};
|