tempest-express-sdk 0.7.0 → 0.8.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/README.md +3 -3
- package/dist/chunk-JWJJAIXV.js +6 -0
- package/dist/{chunk-PKUUVK7K.js.map → chunk-JWJJAIXV.js.map} +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +159 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -2
- package/dist/index.d.ts +108 -2
- package/dist/index.js +158 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-PKUUVK7K.js +0 -6
package/dist/index.d.cts
CHANGED
|
@@ -1635,6 +1635,45 @@ interface SessionMiddlewareOptions {
|
|
|
1635
1635
|
*/
|
|
1636
1636
|
declare function makeSessionMiddleware(service: SessionService, options?: SessionMiddlewareOptions): RequestHandler;
|
|
1637
1637
|
|
|
1638
|
+
/**
|
|
1639
|
+
* Redis-backed {@link SessionStore} for multi-replica deployments.
|
|
1640
|
+
*
|
|
1641
|
+
* Sessions live under `sess:<idHash>` with a Redis TTL; a per-user set
|
|
1642
|
+
* (`sess:user:<userId>`) indexes them so `listByUser`/`deleteByUser` work
|
|
1643
|
+
* without scanning. Takes an injected client (node-redis v4 compatible) so the
|
|
1644
|
+
* SDK never hard-depends on `redis`. Expired keys drop via TTL; stale index
|
|
1645
|
+
* entries are pruned lazily on read.
|
|
1646
|
+
*/
|
|
1647
|
+
|
|
1648
|
+
/** The subset of a node-redis v4 client this store needs. */
|
|
1649
|
+
interface SessionRedisLike {
|
|
1650
|
+
get(key: string): Promise<string | null>;
|
|
1651
|
+
set(key: string, value: string, options?: {
|
|
1652
|
+
EX?: number;
|
|
1653
|
+
}): Promise<unknown>;
|
|
1654
|
+
del(key: string): Promise<unknown>;
|
|
1655
|
+
sAdd(key: string, member: string): Promise<unknown>;
|
|
1656
|
+
sRem(key: string, member: string): Promise<unknown>;
|
|
1657
|
+
sMembers(key: string): Promise<string[]>;
|
|
1658
|
+
}
|
|
1659
|
+
/** Redis-backed session store. */
|
|
1660
|
+
declare class RedisSessionStore implements SessionStore {
|
|
1661
|
+
private readonly client;
|
|
1662
|
+
private readonly prefix;
|
|
1663
|
+
/**
|
|
1664
|
+
* @param client - A connected node-redis v4 (or compatible) client.
|
|
1665
|
+
* @param prefix - Key prefix. Default `sess:`.
|
|
1666
|
+
*/
|
|
1667
|
+
constructor(client: SessionRedisLike, prefix?: string);
|
|
1668
|
+
private key;
|
|
1669
|
+
private userKey;
|
|
1670
|
+
get(idHash: string): Promise<Session | null>;
|
|
1671
|
+
set(session: Session): Promise<void>;
|
|
1672
|
+
delete(idHash: string): Promise<void>;
|
|
1673
|
+
deleteByUser(userId: string): Promise<number>;
|
|
1674
|
+
listByUser(userId: string): Promise<Session[]>;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1638
1677
|
/**
|
|
1639
1678
|
* Server-Sent Events primitives, mirroring `sse.event_stream`.
|
|
1640
1679
|
*
|
|
@@ -1761,6 +1800,73 @@ declare class SSEBroker {
|
|
|
1761
1800
|
publish(channel: string, data: unknown, event?: string): number;
|
|
1762
1801
|
}
|
|
1763
1802
|
|
|
1803
|
+
/**
|
|
1804
|
+
* Redis pub/sub SSE broker for multi-replica deployments.
|
|
1805
|
+
*
|
|
1806
|
+
* The in-process {@link SSEBroker} only reaches subscribers on the same node.
|
|
1807
|
+
* {@link RedisSSEBroker} publishes to a Redis channel; every replica's
|
|
1808
|
+
* subscriber connection receives it and fans out to its local {@link EventStream}s
|
|
1809
|
+
* — so a publish on any node reaches SSE clients on all nodes. Takes injected
|
|
1810
|
+
* node-redis v4 clients (a dedicated subscriber connection, per Redis pub/sub
|
|
1811
|
+
* rules) so the SDK never hard-depends on `redis`.
|
|
1812
|
+
*/
|
|
1813
|
+
|
|
1814
|
+
/** Publisher side (the main client). */
|
|
1815
|
+
interface RedisPublisherLike {
|
|
1816
|
+
publish(channel: string, message: string): Promise<unknown>;
|
|
1817
|
+
}
|
|
1818
|
+
/** Subscriber side (a dedicated connection — `client.duplicate()`). */
|
|
1819
|
+
interface RedisSubscriberLike {
|
|
1820
|
+
subscribe(channel: string, listener: (message: string) => void): Promise<unknown>;
|
|
1821
|
+
unsubscribe(channel: string): Promise<unknown>;
|
|
1822
|
+
}
|
|
1823
|
+
/** Options for {@link RedisSSEBroker}. */
|
|
1824
|
+
interface RedisSSEBrokerOptions extends EventStreamOptions {
|
|
1825
|
+
/** Redis channel prefix. Default `sse:`. */
|
|
1826
|
+
prefix?: string;
|
|
1827
|
+
}
|
|
1828
|
+
/** Cross-replica SSE fan-out over Redis pub/sub. */
|
|
1829
|
+
declare class RedisSSEBroker {
|
|
1830
|
+
private readonly publisher;
|
|
1831
|
+
private readonly subscriber;
|
|
1832
|
+
private readonly local;
|
|
1833
|
+
private readonly prefix;
|
|
1834
|
+
private readonly streamOptions;
|
|
1835
|
+
/**
|
|
1836
|
+
* @param publisher - The main Redis client (used to `publish`).
|
|
1837
|
+
* @param subscriber - A dedicated subscriber connection (`client.duplicate()`).
|
|
1838
|
+
* @param options - Channel prefix + per-stream options.
|
|
1839
|
+
*/
|
|
1840
|
+
constructor(publisher: RedisPublisherLike, subscriber: RedisSubscriberLike, options?: RedisSSEBrokerOptions);
|
|
1841
|
+
private channelKey;
|
|
1842
|
+
/** Emit a decoded payload to every local stream on a channel. */
|
|
1843
|
+
private emitLocal;
|
|
1844
|
+
/**
|
|
1845
|
+
* Register a subscriber stream, subscribing to the Redis channel on first use.
|
|
1846
|
+
*
|
|
1847
|
+
* @param channel - The channel name.
|
|
1848
|
+
* @returns A fresh {@link EventStream} to serve to the client.
|
|
1849
|
+
*/
|
|
1850
|
+
register(channel: string): Promise<EventStream>;
|
|
1851
|
+
/**
|
|
1852
|
+
* Remove a subscriber stream; unsubscribe from Redis when the last leaves.
|
|
1853
|
+
*
|
|
1854
|
+
* @param channel - The channel name.
|
|
1855
|
+
* @param stream - The stream to remove.
|
|
1856
|
+
*/
|
|
1857
|
+
unregister(channel: string, stream: EventStream): Promise<void>;
|
|
1858
|
+
/** Local subscriber count on `channel` (this replica only). */
|
|
1859
|
+
localSubscribers(channel: string): number;
|
|
1860
|
+
/**
|
|
1861
|
+
* Publish to every subscriber across all replicas.
|
|
1862
|
+
*
|
|
1863
|
+
* @param channel - The channel name.
|
|
1864
|
+
* @param data - The payload (JSON-encoded).
|
|
1865
|
+
* @param event - Optional event name.
|
|
1866
|
+
*/
|
|
1867
|
+
publish(channel: string, data: unknown, event?: string): Promise<void>;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1764
1870
|
/** WebSocket message envelope, mirroring `websockets.schemas`. */
|
|
1765
1871
|
|
|
1766
1872
|
/** The canonical message envelope exchanged over a socket. */
|
|
@@ -3469,6 +3575,6 @@ interface RunServerOptions {
|
|
|
3469
3575
|
declare function runServer(app: Express, options?: RunServerOptions): Promise<Server>;
|
|
3470
3576
|
|
|
3471
3577
|
/** The installed SDK version. Single source of truth for the barrel + CLI. */
|
|
3472
|
-
declare const VERSION = "0.
|
|
3578
|
+
declare const VERSION = "0.8.0";
|
|
3473
3579
|
|
|
3474
|
-
export { type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, type CacheManager, type CachedOptions, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type EmailMessage, type EmailOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTPClient, type HTTPClientOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, type MemoryMetrics, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, type MessagingProvider, MetricsUtils, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, PHONE_BR_PATTERN, type PaginationFilter, type PasswordResetConfirmInput, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, RetryPolicy, type RunServerOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
|
3580
|
+
export { type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, type CacheManager, type CachedOptions, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type EmailMessage, type EmailOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTPClient, type HTTPClientOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, type MemoryMetrics, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, type MessagingProvider, MetricsUtils, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, PHONE_BR_PATTERN, type PaginationFilter, type PasswordResetConfirmInput, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedisPublisherLike, RedisSSEBroker, type RedisSSEBrokerOptions, RedisSessionStore, type RedisSubscriberLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, RetryPolicy, type RunServerOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, type SessionRedisLike, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1635,6 +1635,45 @@ interface SessionMiddlewareOptions {
|
|
|
1635
1635
|
*/
|
|
1636
1636
|
declare function makeSessionMiddleware(service: SessionService, options?: SessionMiddlewareOptions): RequestHandler;
|
|
1637
1637
|
|
|
1638
|
+
/**
|
|
1639
|
+
* Redis-backed {@link SessionStore} for multi-replica deployments.
|
|
1640
|
+
*
|
|
1641
|
+
* Sessions live under `sess:<idHash>` with a Redis TTL; a per-user set
|
|
1642
|
+
* (`sess:user:<userId>`) indexes them so `listByUser`/`deleteByUser` work
|
|
1643
|
+
* without scanning. Takes an injected client (node-redis v4 compatible) so the
|
|
1644
|
+
* SDK never hard-depends on `redis`. Expired keys drop via TTL; stale index
|
|
1645
|
+
* entries are pruned lazily on read.
|
|
1646
|
+
*/
|
|
1647
|
+
|
|
1648
|
+
/** The subset of a node-redis v4 client this store needs. */
|
|
1649
|
+
interface SessionRedisLike {
|
|
1650
|
+
get(key: string): Promise<string | null>;
|
|
1651
|
+
set(key: string, value: string, options?: {
|
|
1652
|
+
EX?: number;
|
|
1653
|
+
}): Promise<unknown>;
|
|
1654
|
+
del(key: string): Promise<unknown>;
|
|
1655
|
+
sAdd(key: string, member: string): Promise<unknown>;
|
|
1656
|
+
sRem(key: string, member: string): Promise<unknown>;
|
|
1657
|
+
sMembers(key: string): Promise<string[]>;
|
|
1658
|
+
}
|
|
1659
|
+
/** Redis-backed session store. */
|
|
1660
|
+
declare class RedisSessionStore implements SessionStore {
|
|
1661
|
+
private readonly client;
|
|
1662
|
+
private readonly prefix;
|
|
1663
|
+
/**
|
|
1664
|
+
* @param client - A connected node-redis v4 (or compatible) client.
|
|
1665
|
+
* @param prefix - Key prefix. Default `sess:`.
|
|
1666
|
+
*/
|
|
1667
|
+
constructor(client: SessionRedisLike, prefix?: string);
|
|
1668
|
+
private key;
|
|
1669
|
+
private userKey;
|
|
1670
|
+
get(idHash: string): Promise<Session | null>;
|
|
1671
|
+
set(session: Session): Promise<void>;
|
|
1672
|
+
delete(idHash: string): Promise<void>;
|
|
1673
|
+
deleteByUser(userId: string): Promise<number>;
|
|
1674
|
+
listByUser(userId: string): Promise<Session[]>;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1638
1677
|
/**
|
|
1639
1678
|
* Server-Sent Events primitives, mirroring `sse.event_stream`.
|
|
1640
1679
|
*
|
|
@@ -1761,6 +1800,73 @@ declare class SSEBroker {
|
|
|
1761
1800
|
publish(channel: string, data: unknown, event?: string): number;
|
|
1762
1801
|
}
|
|
1763
1802
|
|
|
1803
|
+
/**
|
|
1804
|
+
* Redis pub/sub SSE broker for multi-replica deployments.
|
|
1805
|
+
*
|
|
1806
|
+
* The in-process {@link SSEBroker} only reaches subscribers on the same node.
|
|
1807
|
+
* {@link RedisSSEBroker} publishes to a Redis channel; every replica's
|
|
1808
|
+
* subscriber connection receives it and fans out to its local {@link EventStream}s
|
|
1809
|
+
* — so a publish on any node reaches SSE clients on all nodes. Takes injected
|
|
1810
|
+
* node-redis v4 clients (a dedicated subscriber connection, per Redis pub/sub
|
|
1811
|
+
* rules) so the SDK never hard-depends on `redis`.
|
|
1812
|
+
*/
|
|
1813
|
+
|
|
1814
|
+
/** Publisher side (the main client). */
|
|
1815
|
+
interface RedisPublisherLike {
|
|
1816
|
+
publish(channel: string, message: string): Promise<unknown>;
|
|
1817
|
+
}
|
|
1818
|
+
/** Subscriber side (a dedicated connection — `client.duplicate()`). */
|
|
1819
|
+
interface RedisSubscriberLike {
|
|
1820
|
+
subscribe(channel: string, listener: (message: string) => void): Promise<unknown>;
|
|
1821
|
+
unsubscribe(channel: string): Promise<unknown>;
|
|
1822
|
+
}
|
|
1823
|
+
/** Options for {@link RedisSSEBroker}. */
|
|
1824
|
+
interface RedisSSEBrokerOptions extends EventStreamOptions {
|
|
1825
|
+
/** Redis channel prefix. Default `sse:`. */
|
|
1826
|
+
prefix?: string;
|
|
1827
|
+
}
|
|
1828
|
+
/** Cross-replica SSE fan-out over Redis pub/sub. */
|
|
1829
|
+
declare class RedisSSEBroker {
|
|
1830
|
+
private readonly publisher;
|
|
1831
|
+
private readonly subscriber;
|
|
1832
|
+
private readonly local;
|
|
1833
|
+
private readonly prefix;
|
|
1834
|
+
private readonly streamOptions;
|
|
1835
|
+
/**
|
|
1836
|
+
* @param publisher - The main Redis client (used to `publish`).
|
|
1837
|
+
* @param subscriber - A dedicated subscriber connection (`client.duplicate()`).
|
|
1838
|
+
* @param options - Channel prefix + per-stream options.
|
|
1839
|
+
*/
|
|
1840
|
+
constructor(publisher: RedisPublisherLike, subscriber: RedisSubscriberLike, options?: RedisSSEBrokerOptions);
|
|
1841
|
+
private channelKey;
|
|
1842
|
+
/** Emit a decoded payload to every local stream on a channel. */
|
|
1843
|
+
private emitLocal;
|
|
1844
|
+
/**
|
|
1845
|
+
* Register a subscriber stream, subscribing to the Redis channel on first use.
|
|
1846
|
+
*
|
|
1847
|
+
* @param channel - The channel name.
|
|
1848
|
+
* @returns A fresh {@link EventStream} to serve to the client.
|
|
1849
|
+
*/
|
|
1850
|
+
register(channel: string): Promise<EventStream>;
|
|
1851
|
+
/**
|
|
1852
|
+
* Remove a subscriber stream; unsubscribe from Redis when the last leaves.
|
|
1853
|
+
*
|
|
1854
|
+
* @param channel - The channel name.
|
|
1855
|
+
* @param stream - The stream to remove.
|
|
1856
|
+
*/
|
|
1857
|
+
unregister(channel: string, stream: EventStream): Promise<void>;
|
|
1858
|
+
/** Local subscriber count on `channel` (this replica only). */
|
|
1859
|
+
localSubscribers(channel: string): number;
|
|
1860
|
+
/**
|
|
1861
|
+
* Publish to every subscriber across all replicas.
|
|
1862
|
+
*
|
|
1863
|
+
* @param channel - The channel name.
|
|
1864
|
+
* @param data - The payload (JSON-encoded).
|
|
1865
|
+
* @param event - Optional event name.
|
|
1866
|
+
*/
|
|
1867
|
+
publish(channel: string, data: unknown, event?: string): Promise<void>;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1764
1870
|
/** WebSocket message envelope, mirroring `websockets.schemas`. */
|
|
1765
1871
|
|
|
1766
1872
|
/** The canonical message envelope exchanged over a socket. */
|
|
@@ -3469,6 +3575,6 @@ interface RunServerOptions {
|
|
|
3469
3575
|
declare function runServer(app: Express, options?: RunServerOptions): Promise<Server>;
|
|
3470
3576
|
|
|
3471
3577
|
/** The installed SDK version. Single source of truth for the barrel + CLI. */
|
|
3472
|
-
declare const VERSION = "0.
|
|
3578
|
+
declare const VERSION = "0.8.0";
|
|
3473
3579
|
|
|
3474
|
-
export { type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, type CacheManager, type CachedOptions, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type EmailMessage, type EmailOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTPClient, type HTTPClientOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, type MemoryMetrics, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, type MessagingProvider, MetricsUtils, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, PHONE_BR_PATTERN, type PaginationFilter, type PasswordResetConfirmInput, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, RetryPolicy, type RunServerOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
|
3580
|
+
export { type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, type CacheManager, type CachedOptions, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type EmailMessage, type EmailOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTPClient, type HTTPClientOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, type MemoryMetrics, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, type MessagingProvider, MetricsUtils, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, PHONE_BR_PATTERN, type PaginationFilter, type PasswordResetConfirmInput, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedisPublisherLike, RedisSSEBroker, type RedisSSEBrokerOptions, RedisSessionStore, type RedisSubscriberLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, RetryPolicy, type RunServerOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, type SessionRedisLike, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { VERSION } from './chunk-
|
|
1
|
+
export { VERSION } from './chunk-JWJJAIXV.js';
|
|
2
2
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
3
|
import { extendZodWithOpenApi, OpenAPIRegistry, OpenApiGeneratorV31, OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
|
|
4
4
|
export { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
@@ -7326,6 +7326,76 @@ function makeSessionMiddleware(service, options = {}) {
|
|
|
7326
7326
|
};
|
|
7327
7327
|
}
|
|
7328
7328
|
|
|
7329
|
+
// src/sessions/redisStore.ts
|
|
7330
|
+
var RedisSessionStore = class {
|
|
7331
|
+
/**
|
|
7332
|
+
* @param client - A connected node-redis v4 (or compatible) client.
|
|
7333
|
+
* @param prefix - Key prefix. Default `sess:`.
|
|
7334
|
+
*/
|
|
7335
|
+
constructor(client, prefix = "sess:") {
|
|
7336
|
+
this.client = client;
|
|
7337
|
+
this.prefix = prefix;
|
|
7338
|
+
}
|
|
7339
|
+
client;
|
|
7340
|
+
prefix;
|
|
7341
|
+
key(idHash) {
|
|
7342
|
+
return `${this.prefix}${idHash}`;
|
|
7343
|
+
}
|
|
7344
|
+
userKey(userId) {
|
|
7345
|
+
return `${this.prefix}user:${userId}`;
|
|
7346
|
+
}
|
|
7347
|
+
async get(idHash) {
|
|
7348
|
+
const raw = await this.client.get(this.key(idHash));
|
|
7349
|
+
if (raw === null) return null;
|
|
7350
|
+
const session = JSON.parse(raw);
|
|
7351
|
+
if (session.expiresAt <= Date.now()) {
|
|
7352
|
+
await this.delete(idHash);
|
|
7353
|
+
return null;
|
|
7354
|
+
}
|
|
7355
|
+
return session;
|
|
7356
|
+
}
|
|
7357
|
+
async set(session) {
|
|
7358
|
+
const ttlSeconds = Math.max(1, Math.ceil((session.expiresAt - Date.now()) / 1e3));
|
|
7359
|
+
await this.client.set(this.key(session.idHash), JSON.stringify(session), {
|
|
7360
|
+
EX: ttlSeconds
|
|
7361
|
+
});
|
|
7362
|
+
await this.client.sAdd(this.userKey(session.userId), session.idHash);
|
|
7363
|
+
}
|
|
7364
|
+
async delete(idHash) {
|
|
7365
|
+
const raw = await this.client.get(this.key(idHash));
|
|
7366
|
+
await this.client.del(this.key(idHash));
|
|
7367
|
+
if (raw) {
|
|
7368
|
+
const session = JSON.parse(raw);
|
|
7369
|
+
await this.client.sRem(this.userKey(session.userId), idHash);
|
|
7370
|
+
}
|
|
7371
|
+
}
|
|
7372
|
+
async deleteByUser(userId) {
|
|
7373
|
+
const ids = await this.client.sMembers(this.userKey(userId));
|
|
7374
|
+
let count = 0;
|
|
7375
|
+
for (const idHash of ids) {
|
|
7376
|
+
await this.client.del(this.key(idHash));
|
|
7377
|
+
await this.client.sRem(this.userKey(userId), idHash);
|
|
7378
|
+
count += 1;
|
|
7379
|
+
}
|
|
7380
|
+
return count;
|
|
7381
|
+
}
|
|
7382
|
+
async listByUser(userId) {
|
|
7383
|
+
const ids = await this.client.sMembers(this.userKey(userId));
|
|
7384
|
+
const sessions = [];
|
|
7385
|
+
const now = Date.now();
|
|
7386
|
+
for (const idHash of ids) {
|
|
7387
|
+
const raw = await this.client.get(this.key(idHash));
|
|
7388
|
+
if (raw === null) {
|
|
7389
|
+
await this.client.sRem(this.userKey(userId), idHash);
|
|
7390
|
+
continue;
|
|
7391
|
+
}
|
|
7392
|
+
const session = JSON.parse(raw);
|
|
7393
|
+
if (session.expiresAt > now) sessions.push(session);
|
|
7394
|
+
}
|
|
7395
|
+
return sessions.sort((a, b) => a.createdAt - b.createdAt);
|
|
7396
|
+
}
|
|
7397
|
+
};
|
|
7398
|
+
|
|
7329
7399
|
// src/sse/eventStream.ts
|
|
7330
7400
|
var ServerSentEvent = class {
|
|
7331
7401
|
constructor(init) {
|
|
@@ -7498,6 +7568,92 @@ var SSEBroker = class {
|
|
|
7498
7568
|
}
|
|
7499
7569
|
};
|
|
7500
7570
|
|
|
7571
|
+
// src/sse/redisBroker.ts
|
|
7572
|
+
var RedisSSEBroker = class {
|
|
7573
|
+
/**
|
|
7574
|
+
* @param publisher - The main Redis client (used to `publish`).
|
|
7575
|
+
* @param subscriber - A dedicated subscriber connection (`client.duplicate()`).
|
|
7576
|
+
* @param options - Channel prefix + per-stream options.
|
|
7577
|
+
*/
|
|
7578
|
+
constructor(publisher, subscriber, options = {}) {
|
|
7579
|
+
this.publisher = publisher;
|
|
7580
|
+
this.subscriber = subscriber;
|
|
7581
|
+
this.prefix = options.prefix ?? "sse:";
|
|
7582
|
+
const { prefix: _p, ...streamOptions } = options;
|
|
7583
|
+
this.streamOptions = streamOptions;
|
|
7584
|
+
}
|
|
7585
|
+
publisher;
|
|
7586
|
+
subscriber;
|
|
7587
|
+
local = /* @__PURE__ */ new Map();
|
|
7588
|
+
prefix;
|
|
7589
|
+
streamOptions;
|
|
7590
|
+
channelKey(channel) {
|
|
7591
|
+
return `${this.prefix}${channel}`;
|
|
7592
|
+
}
|
|
7593
|
+
/** Emit a decoded payload to every local stream on a channel. */
|
|
7594
|
+
emitLocal(channel, data, event) {
|
|
7595
|
+
const set = this.local.get(channel);
|
|
7596
|
+
if (!set) return;
|
|
7597
|
+
for (const stream of set) stream.publish(data, event);
|
|
7598
|
+
}
|
|
7599
|
+
/**
|
|
7600
|
+
* Register a subscriber stream, subscribing to the Redis channel on first use.
|
|
7601
|
+
*
|
|
7602
|
+
* @param channel - The channel name.
|
|
7603
|
+
* @returns A fresh {@link EventStream} to serve to the client.
|
|
7604
|
+
*/
|
|
7605
|
+
async register(channel) {
|
|
7606
|
+
const stream = new EventStream(this.streamOptions);
|
|
7607
|
+
let set = this.local.get(channel);
|
|
7608
|
+
if (!set) {
|
|
7609
|
+
set = /* @__PURE__ */ new Set();
|
|
7610
|
+
this.local.set(channel, set);
|
|
7611
|
+
await this.subscriber.subscribe(this.channelKey(channel), (raw) => {
|
|
7612
|
+
try {
|
|
7613
|
+
const { data, event } = JSON.parse(raw);
|
|
7614
|
+
this.emitLocal(channel, data, event);
|
|
7615
|
+
} catch {
|
|
7616
|
+
}
|
|
7617
|
+
});
|
|
7618
|
+
}
|
|
7619
|
+
set.add(stream);
|
|
7620
|
+
return stream;
|
|
7621
|
+
}
|
|
7622
|
+
/**
|
|
7623
|
+
* Remove a subscriber stream; unsubscribe from Redis when the last leaves.
|
|
7624
|
+
*
|
|
7625
|
+
* @param channel - The channel name.
|
|
7626
|
+
* @param stream - The stream to remove.
|
|
7627
|
+
*/
|
|
7628
|
+
async unregister(channel, stream) {
|
|
7629
|
+
const set = this.local.get(channel);
|
|
7630
|
+
if (!set) return;
|
|
7631
|
+
set.delete(stream);
|
|
7632
|
+
stream.close();
|
|
7633
|
+
if (set.size === 0) {
|
|
7634
|
+
this.local.delete(channel);
|
|
7635
|
+
await this.subscriber.unsubscribe(this.channelKey(channel));
|
|
7636
|
+
}
|
|
7637
|
+
}
|
|
7638
|
+
/** Local subscriber count on `channel` (this replica only). */
|
|
7639
|
+
localSubscribers(channel) {
|
|
7640
|
+
return this.local.get(channel)?.size ?? 0;
|
|
7641
|
+
}
|
|
7642
|
+
/**
|
|
7643
|
+
* Publish to every subscriber across all replicas.
|
|
7644
|
+
*
|
|
7645
|
+
* @param channel - The channel name.
|
|
7646
|
+
* @param data - The payload (JSON-encoded).
|
|
7647
|
+
* @param event - Optional event name.
|
|
7648
|
+
*/
|
|
7649
|
+
async publish(channel, data, event) {
|
|
7650
|
+
await this.publisher.publish(
|
|
7651
|
+
this.channelKey(channel),
|
|
7652
|
+
JSON.stringify({ data, ...event ? { event } : {} })
|
|
7653
|
+
);
|
|
7654
|
+
}
|
|
7655
|
+
};
|
|
7656
|
+
|
|
7501
7657
|
// src/websockets/schemas.ts
|
|
7502
7658
|
var wsEnvelopeSchema = z.object({
|
|
7503
7659
|
type: z.string().openapi({ description: "Message type discriminator." }),
|
|
@@ -9223,6 +9379,6 @@ function runServer(app, options = {}) {
|
|
|
9223
9379
|
});
|
|
9224
9380
|
}
|
|
9225
9381
|
|
|
9226
|
-
export { ActivationService, AdminSite, AppException, AttemptThrottle, BaseController, BaseModel, BaseService, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, CircuitOpenError, CompositeFeatureFlagBackend, ConflictException, DEFAULT_LOCALE, EmailUtils, EnvFeatureFlagBackend, EventStream, ExpiredTokenException, FeatureFlags, ForbiddenException, HTTPClient, HTTP_500_MARKER, InvalidTokenException, JSONLogger, JWTUtils, LocalUploadStorage, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, MetricsUtils, MfaService, NotFoundException, PHONE_BR_PATTERN, PasswordResetService, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, RedisCacheManager, Region, RetryPolicy, SSEBroker, ServerSentEvent, SessionService, TOTPHelper, TaskManager, TelegramProvider, TooManyRequestsException, TwilioSmsProvider, UF, UnauthorizedException, UserAuthService, ValidationException, WebPushDispatcher, WebPushError, WebPushGoneError, WebSocketHub, WhatsAppProvider, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached3 as cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
|
9382
|
+
export { ActivationService, AdminSite, AppException, AttemptThrottle, BaseController, BaseModel, BaseService, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, CircuitOpenError, CompositeFeatureFlagBackend, ConflictException, DEFAULT_LOCALE, EmailUtils, EnvFeatureFlagBackend, EventStream, ExpiredTokenException, FeatureFlags, ForbiddenException, HTTPClient, HTTP_500_MARKER, InvalidTokenException, JSONLogger, JWTUtils, LocalUploadStorage, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, MetricsUtils, MfaService, NotFoundException, PHONE_BR_PATTERN, PasswordResetService, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, RedisCacheManager, RedisSSEBroker, RedisSessionStore, Region, RetryPolicy, SSEBroker, ServerSentEvent, SessionService, TOTPHelper, TaskManager, TelegramProvider, TooManyRequestsException, TwilioSmsProvider, UF, UnauthorizedException, UserAuthService, ValidationException, WebPushDispatcher, WebPushError, WebPushGoneError, WebSocketHub, WhatsAppProvider, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached3 as cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
|
9227
9383
|
//# sourceMappingURL=index.js.map
|
|
9228
9384
|
//# sourceMappingURL=index.js.map
|