tempest-express-sdk 0.1.0 → 0.2.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 +10 -5
- package/dist/chunk-6QNSLBL3.js +6 -0
- package/dist/{chunk-2NB7ZA7G.js.map → chunk-6QNSLBL3.js.map} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +875 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +756 -10
- package/dist/index.d.ts +756 -10
- package/dist/index.js +849 -7
- package/dist/index.js.map +1 -1
- package/package.json +14 -2
- package/dist/chunk-2NB7ZA7G.js +0 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ export { z } from 'zod';
|
|
|
3
3
|
import * as tempest_db_js from 'tempest-db-js';
|
|
4
4
|
import { Model, ModelClass, BaseRepository, InferModel, WhereInput, InferInsert, PaginationFilter as PaginationFilter$1, PaginationResult } from 'tempest-db-js';
|
|
5
5
|
export { AsyncDriver, AsyncEngine, AsyncResult, AsyncSession, BaseRepository, BelongsTo, ColType, Column, ColumnFlags, CompiledQuery, CondNode, Condition, DeleteBuilder, DeleteNode, Dialect, EngineOptions, Executable, HasMany, InferInsert, InferModel, InsertBuilder, InsertNode, Model, ModelClass, NoResultError, NodeSqliteDriver, Operator, OrderTerm, PaginationResult, ParsedDatabaseUrl, PostgresDialect, QueryNode, RecordNotFound, Relation, RelationValue, PaginationFilter as RepositoryPaginationFilter, Returning, RowOf, SelectBuilder, SelectNode, SortDirection, SqliteDialect, SyncEngine, SyncSession, UpdateBuilder, UpdateNode, WhereArg, WhereInput, WithRelations, and, belongsTo, column, columnsOf, createEngine, createSyncEngine, del, detectDialect, getDialect, hasMany, insert, join, loadRelations, not, or, parseDatabaseUrl, select, sql, update } from 'tempest-db-js';
|
|
6
|
-
import { Request,
|
|
6
|
+
import { RequestHandler, Request, Response, Router, ErrorRequestHandler, Express } from 'express';
|
|
7
|
+
import * as ws from 'ws';
|
|
8
|
+
import { Server } from 'node:http';
|
|
7
9
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
8
10
|
export { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
9
|
-
import { Server } from 'node:http';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Request-scoped context propagation via `AsyncLocalStorage`.
|
|
@@ -1129,6 +1130,751 @@ declare class AttemptThrottle {
|
|
|
1129
1130
|
reset(key: string): Promise<void>;
|
|
1130
1131
|
}
|
|
1131
1132
|
|
|
1133
|
+
/**
|
|
1134
|
+
* Cache managers, mirroring `cache.redis_manager`.
|
|
1135
|
+
*
|
|
1136
|
+
* A narrow async cache interface ({@link CacheManager}) with two backends: an
|
|
1137
|
+
* in-process {@link MemoryCacheManager} (dev/tests/single replica) and a
|
|
1138
|
+
* {@link RedisCacheManager} backed by the optional `redis` peer (lazily
|
|
1139
|
+
* imported, like the auth helpers). Values are JSON-serialized.
|
|
1140
|
+
*/
|
|
1141
|
+
/** Narrow async cache surface every backend implements. */
|
|
1142
|
+
interface CacheManager {
|
|
1143
|
+
/** Read a value by key, or `null` when missing/expired. */
|
|
1144
|
+
get<T>(key: string): Promise<T | null>;
|
|
1145
|
+
/** Write a value with an optional TTL in seconds. */
|
|
1146
|
+
set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
|
|
1147
|
+
/** Delete a key. Idempotent. */
|
|
1148
|
+
delete(key: string): Promise<void>;
|
|
1149
|
+
/** Whether a live (non-expired) value exists for `key`. */
|
|
1150
|
+
has(key: string): Promise<boolean>;
|
|
1151
|
+
/** Remove every entry. */
|
|
1152
|
+
clear(): Promise<void>;
|
|
1153
|
+
}
|
|
1154
|
+
/** In-process {@link CacheManager} backed by a `Map`, with lazy TTL expiry. */
|
|
1155
|
+
declare class MemoryCacheManager implements CacheManager {
|
|
1156
|
+
private readonly store;
|
|
1157
|
+
private live;
|
|
1158
|
+
get<T>(key: string): Promise<T | null>;
|
|
1159
|
+
set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
|
|
1160
|
+
delete(key: string): Promise<void>;
|
|
1161
|
+
has(key: string): Promise<boolean>;
|
|
1162
|
+
clear(): Promise<void>;
|
|
1163
|
+
}
|
|
1164
|
+
/** A minimal subset of the `redis` client this manager relies on. */
|
|
1165
|
+
interface RedisLike {
|
|
1166
|
+
get(key: string): Promise<string | null>;
|
|
1167
|
+
set(key: string, value: string, options?: {
|
|
1168
|
+
EX?: number;
|
|
1169
|
+
}): Promise<unknown>;
|
|
1170
|
+
del(key: string): Promise<unknown>;
|
|
1171
|
+
exists(key: string): Promise<number>;
|
|
1172
|
+
flushDb(): Promise<unknown>;
|
|
1173
|
+
}
|
|
1174
|
+
/** Redis-backed {@link CacheManager}. Pass a connected `redis` v4 client. */
|
|
1175
|
+
declare class RedisCacheManager implements CacheManager {
|
|
1176
|
+
private readonly client;
|
|
1177
|
+
private readonly prefix;
|
|
1178
|
+
/**
|
|
1179
|
+
* @param client - A connected `redis` (node-redis v4) client or compatible.
|
|
1180
|
+
* @param prefix - Optional key prefix applied to every operation.
|
|
1181
|
+
*/
|
|
1182
|
+
constructor(client: RedisLike, prefix?: string);
|
|
1183
|
+
private key;
|
|
1184
|
+
get<T>(key: string): Promise<T | null>;
|
|
1185
|
+
set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
|
|
1186
|
+
delete(key: string): Promise<void>;
|
|
1187
|
+
has(key: string): Promise<boolean>;
|
|
1188
|
+
clear(): Promise<void>;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* Read-through memoization helper, mirroring `cache.decorator.cached`.
|
|
1193
|
+
*
|
|
1194
|
+
* Wraps an async function so its result is cached under a derived key. On a hit
|
|
1195
|
+
* the cached value is returned without calling the function; on a miss the
|
|
1196
|
+
* function runs and its result is stored with an optional TTL.
|
|
1197
|
+
*/
|
|
1198
|
+
|
|
1199
|
+
/** Options for {@link cached}. */
|
|
1200
|
+
interface CachedOptions<A extends unknown[]> {
|
|
1201
|
+
/** The cache backend to read/write. */
|
|
1202
|
+
manager: CacheManager;
|
|
1203
|
+
/** Build the cache key from the call arguments. */
|
|
1204
|
+
key: (...args: A) => string;
|
|
1205
|
+
/** TTL in seconds for stored values. Omit for no expiry. */
|
|
1206
|
+
ttlSeconds?: number;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Wrap an async function with read-through caching.
|
|
1210
|
+
*
|
|
1211
|
+
* @param fn - The async function to memoize.
|
|
1212
|
+
* @param options - Cache backend, key builder and optional TTL.
|
|
1213
|
+
* @returns A function with the same signature, served from cache when possible.
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```ts
|
|
1217
|
+
* const getUser = cached(fetchUser, {
|
|
1218
|
+
* manager,
|
|
1219
|
+
* key: (id: string) => `user:${id}`,
|
|
1220
|
+
* ttlSeconds: 60,
|
|
1221
|
+
* });
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
declare function cached<A extends unknown[], R>(fn: (...args: A) => Promise<R>, options: CachedOptions<A>): (...args: A) => Promise<R>;
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* Session model + store, mirroring `sessions.store` / `sessions.schemas`.
|
|
1228
|
+
*
|
|
1229
|
+
* Sessions are keyed by the SHA-256 hash of the opaque cookie value, so a leak
|
|
1230
|
+
* of the store yields no reusable cookies. The {@link SessionStore} interface is
|
|
1231
|
+
* narrow; {@link MemorySessionStore} is the in-process implementation for
|
|
1232
|
+
* dev/tests/single-replica (a Redis store is a planned follow-up).
|
|
1233
|
+
*/
|
|
1234
|
+
/** A persisted session row. */
|
|
1235
|
+
interface Session {
|
|
1236
|
+
/** SHA-256 hash of the opaque cookie value (the store key). */
|
|
1237
|
+
idHash: string;
|
|
1238
|
+
/** The owning user id. */
|
|
1239
|
+
userId: string;
|
|
1240
|
+
/** Arbitrary JSON-serializable session payload. */
|
|
1241
|
+
data: Record<string, unknown>;
|
|
1242
|
+
/** Creation timestamp (epoch ms). */
|
|
1243
|
+
createdAt: number;
|
|
1244
|
+
/** Expiry timestamp (epoch ms). */
|
|
1245
|
+
expiresAt: number;
|
|
1246
|
+
}
|
|
1247
|
+
/** Persistence port every session backend implements. */
|
|
1248
|
+
interface SessionStore {
|
|
1249
|
+
/** Return the live session for `idHash`, or `null` when missing/expired. */
|
|
1250
|
+
get(idHash: string): Promise<Session | null>;
|
|
1251
|
+
/** Persist or overwrite a session. */
|
|
1252
|
+
set(session: Session): Promise<void>;
|
|
1253
|
+
/** Remove a single session. Idempotent. */
|
|
1254
|
+
delete(idHash: string): Promise<void>;
|
|
1255
|
+
/** Remove every session for `userId`; returns the count deleted. */
|
|
1256
|
+
deleteByUser(userId: string): Promise<number>;
|
|
1257
|
+
/** Return every live session for `userId` (oldest first). */
|
|
1258
|
+
listByUser(userId: string): Promise<Session[]>;
|
|
1259
|
+
}
|
|
1260
|
+
/** In-process {@link SessionStore} with a secondary user index. */
|
|
1261
|
+
declare class MemorySessionStore implements SessionStore {
|
|
1262
|
+
private readonly byHash;
|
|
1263
|
+
private live;
|
|
1264
|
+
get(idHash: string): Promise<Session | null>;
|
|
1265
|
+
set(session: Session): Promise<void>;
|
|
1266
|
+
delete(idHash: string): Promise<void>;
|
|
1267
|
+
deleteByUser(userId: string): Promise<number>;
|
|
1268
|
+
listByUser(userId: string): Promise<Session[]>;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Session service, mirroring `sessions.service`.
|
|
1273
|
+
*
|
|
1274
|
+
* Issues opaque session cookies, persists only their SHA-256 hash, and resolves
|
|
1275
|
+
* an incoming cookie back to a live {@link Session}. Built on the SDK's opaque
|
|
1276
|
+
* token helpers so the store never holds a usable cookie value.
|
|
1277
|
+
*/
|
|
1278
|
+
|
|
1279
|
+
/** Options for {@link SessionService}. */
|
|
1280
|
+
interface SessionServiceOptions {
|
|
1281
|
+
/** The backing store. */
|
|
1282
|
+
store: SessionStore;
|
|
1283
|
+
/** Default session lifetime in seconds. Default 604800 (7 days). */
|
|
1284
|
+
ttlSeconds?: number;
|
|
1285
|
+
}
|
|
1286
|
+
/** A freshly created session and its one-time plaintext cookie value. */
|
|
1287
|
+
interface IssuedSession {
|
|
1288
|
+
/** The opaque cookie value to set on the client (shown once). */
|
|
1289
|
+
token: string;
|
|
1290
|
+
/** The persisted session row. */
|
|
1291
|
+
session: Session;
|
|
1292
|
+
}
|
|
1293
|
+
declare class SessionService {
|
|
1294
|
+
private readonly store;
|
|
1295
|
+
private readonly ttlSeconds;
|
|
1296
|
+
/**
|
|
1297
|
+
* @param options - Store and default TTL.
|
|
1298
|
+
*/
|
|
1299
|
+
constructor(options: SessionServiceOptions);
|
|
1300
|
+
/**
|
|
1301
|
+
* Create a session for `userId` and return its one-time cookie value.
|
|
1302
|
+
*
|
|
1303
|
+
* @param userId - The owning user id.
|
|
1304
|
+
* @param data - Arbitrary session payload.
|
|
1305
|
+
* @param ttlSeconds - Override the default lifetime.
|
|
1306
|
+
* @returns The plaintext token (set as a cookie) and the stored session.
|
|
1307
|
+
*/
|
|
1308
|
+
create(userId: string, data?: Record<string, unknown>, ttlSeconds?: number): Promise<IssuedSession>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Resolve an opaque cookie value to its live session.
|
|
1311
|
+
*
|
|
1312
|
+
* @param token - The plaintext cookie value.
|
|
1313
|
+
* @returns The session, or `null` when missing/expired.
|
|
1314
|
+
*/
|
|
1315
|
+
resolve(token: string): Promise<Session | null>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Revoke a single session by its cookie value.
|
|
1318
|
+
*
|
|
1319
|
+
* @param token - The plaintext cookie value.
|
|
1320
|
+
*/
|
|
1321
|
+
destroy(token: string): Promise<void>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Revoke every session a user owns (global logout).
|
|
1324
|
+
*
|
|
1325
|
+
* @param userId - The user id.
|
|
1326
|
+
* @returns The number of sessions removed.
|
|
1327
|
+
*/
|
|
1328
|
+
destroyByUser(userId: string): Promise<number>;
|
|
1329
|
+
/**
|
|
1330
|
+
* List a user's live sessions (e.g. an "active devices" view).
|
|
1331
|
+
*
|
|
1332
|
+
* @param userId - The user id.
|
|
1333
|
+
* @returns The user's sessions, oldest first.
|
|
1334
|
+
*/
|
|
1335
|
+
listByUser(userId: string): Promise<Session[]>;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Session middleware, mirroring `sessions.middleware`.
|
|
1340
|
+
*
|
|
1341
|
+
* Reads the session cookie, resolves it to a live {@link Session} via the
|
|
1342
|
+
* {@link SessionService}, and attaches it to `req.session` (or `null` when
|
|
1343
|
+
* absent/expired). Pairs with {@link makeJwtAuthMiddleware} for JWT auth; use
|
|
1344
|
+
* whichever model fits the surface.
|
|
1345
|
+
*/
|
|
1346
|
+
|
|
1347
|
+
declare global {
|
|
1348
|
+
namespace Express {
|
|
1349
|
+
/** The live session for this request, populated by the middleware. */
|
|
1350
|
+
interface Request {
|
|
1351
|
+
session?: Session | null;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
/** Parse the `Cookie` header into a name → value map. */
|
|
1356
|
+
declare function parseCookies(header: string | undefined): Record<string, string>;
|
|
1357
|
+
/** Read the session cookie value from a request, or `null`. */
|
|
1358
|
+
declare function sessionCookie(req: Request, cookieName: string): string | null;
|
|
1359
|
+
/** Options for {@link makeSessionMiddleware}. */
|
|
1360
|
+
interface SessionMiddlewareOptions {
|
|
1361
|
+
/** Cookie name carrying the opaque session id. Default `sid`. */
|
|
1362
|
+
cookieName?: string;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Build middleware that resolves the session cookie into `req.session`.
|
|
1366
|
+
*
|
|
1367
|
+
* @param service - The session service used to resolve cookies.
|
|
1368
|
+
* @param options - Cookie name.
|
|
1369
|
+
* @returns An Express middleware.
|
|
1370
|
+
*/
|
|
1371
|
+
declare function makeSessionMiddleware(service: SessionService, options?: SessionMiddlewareOptions): RequestHandler;
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* Server-Sent Events primitives, mirroring `sse.event_stream`.
|
|
1375
|
+
*
|
|
1376
|
+
* {@link ServerSentEvent} encodes the SSE wire format; {@link EventStream} is a
|
|
1377
|
+
* per-subscriber push queue exposed as an async iterator with an optional
|
|
1378
|
+
* heartbeat; {@link sseResponse} wires a stream to an Express response.
|
|
1379
|
+
*/
|
|
1380
|
+
|
|
1381
|
+
/** A single Server-Sent Event. */
|
|
1382
|
+
interface ServerSentEventInit {
|
|
1383
|
+
/** The event payload (serialized to one or more `data:` lines). */
|
|
1384
|
+
data: string;
|
|
1385
|
+
/** Optional event name (`event:` line). */
|
|
1386
|
+
event?: string;
|
|
1387
|
+
/** Optional event id (`id:` line). */
|
|
1388
|
+
id?: string;
|
|
1389
|
+
/** Optional reconnection hint in ms (`retry:` line). */
|
|
1390
|
+
retry?: number;
|
|
1391
|
+
}
|
|
1392
|
+
/** An SSE event that can encode itself to the wire format. */
|
|
1393
|
+
declare class ServerSentEvent {
|
|
1394
|
+
private readonly init;
|
|
1395
|
+
constructor(init: ServerSentEventInit);
|
|
1396
|
+
/**
|
|
1397
|
+
* Encode to the SSE wire format (terminated by a blank line).
|
|
1398
|
+
*
|
|
1399
|
+
* @returns The encoded event block.
|
|
1400
|
+
*/
|
|
1401
|
+
encode(): string;
|
|
1402
|
+
}
|
|
1403
|
+
/** Options for {@link EventStream}. */
|
|
1404
|
+
interface EventStreamOptions {
|
|
1405
|
+
/** Heartbeat interval in seconds (comment ping). `null` disables. Default 15. */
|
|
1406
|
+
heartbeatSeconds?: number | null;
|
|
1407
|
+
}
|
|
1408
|
+
/** A single subscriber's event queue, consumable as an async iterator. */
|
|
1409
|
+
declare class EventStream {
|
|
1410
|
+
private readonly queue;
|
|
1411
|
+
private waiter;
|
|
1412
|
+
private closed;
|
|
1413
|
+
private readonly heartbeatSeconds;
|
|
1414
|
+
/**
|
|
1415
|
+
* @param options - Heartbeat configuration.
|
|
1416
|
+
*/
|
|
1417
|
+
constructor(options?: EventStreamOptions);
|
|
1418
|
+
/** Enqueue raw SSE-encoded text and wake the iterator. */
|
|
1419
|
+
private push;
|
|
1420
|
+
/**
|
|
1421
|
+
* Publish a data payload as an SSE event.
|
|
1422
|
+
*
|
|
1423
|
+
* @param data - The payload; objects are JSON-encoded.
|
|
1424
|
+
* @param event - Optional event name.
|
|
1425
|
+
*/
|
|
1426
|
+
publish(data: unknown, event?: string): void;
|
|
1427
|
+
/** Publish a pre-built {@link ServerSentEvent}. */
|
|
1428
|
+
publishEvent(event: ServerSentEvent): void;
|
|
1429
|
+
/** Close the stream; the iterator finishes after draining. */
|
|
1430
|
+
close(): void;
|
|
1431
|
+
/**
|
|
1432
|
+
* Async iterator yielding encoded SSE chunks, with periodic heartbeats.
|
|
1433
|
+
*
|
|
1434
|
+
* @returns An async iterator of encoded event strings.
|
|
1435
|
+
*/
|
|
1436
|
+
stream(): AsyncIterator<string> & AsyncIterable<string>;
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Stream an {@link EventStream} to an Express response as `text/event-stream`.
|
|
1440
|
+
*
|
|
1441
|
+
* Sets the SSE headers, writes each encoded chunk, and closes the stream when
|
|
1442
|
+
* the client disconnects.
|
|
1443
|
+
*
|
|
1444
|
+
* @param req - The Express request (used to detect disconnect).
|
|
1445
|
+
* @param res - The Express response to stream into.
|
|
1446
|
+
* @param stream - The event stream to drain.
|
|
1447
|
+
*/
|
|
1448
|
+
declare function sseResponse(req: Request, res: Response, stream: EventStream): Promise<void>;
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* In-process SSE broker, mirroring `sse.broker.SSEBroker`.
|
|
1452
|
+
*
|
|
1453
|
+
* Tracks subscribers per channel and fans published events out to every live
|
|
1454
|
+
* {@link EventStream} on that channel. Single-process (no cross-replica
|
|
1455
|
+
* transport yet — a Redis pub/sub backend is a planned follow-up).
|
|
1456
|
+
*/
|
|
1457
|
+
|
|
1458
|
+
/** Fan-out hub mapping channels to subscriber streams. */
|
|
1459
|
+
declare class SSEBroker {
|
|
1460
|
+
private readonly streamOptions;
|
|
1461
|
+
private readonly channels;
|
|
1462
|
+
/**
|
|
1463
|
+
* @param streamOptions - Options applied to every {@link EventStream} created
|
|
1464
|
+
* by {@link register} (e.g. heartbeat interval).
|
|
1465
|
+
*/
|
|
1466
|
+
constructor(streamOptions?: EventStreamOptions);
|
|
1467
|
+
/**
|
|
1468
|
+
* Register a new subscriber stream on `channel`.
|
|
1469
|
+
*
|
|
1470
|
+
* @param channel - The channel name.
|
|
1471
|
+
* @returns A fresh {@link EventStream} to serve to the subscriber.
|
|
1472
|
+
*/
|
|
1473
|
+
register(channel: string): EventStream;
|
|
1474
|
+
/**
|
|
1475
|
+
* Remove a subscriber stream from `channel` and close it.
|
|
1476
|
+
*
|
|
1477
|
+
* @param channel - The channel name.
|
|
1478
|
+
* @param stream - The stream to remove.
|
|
1479
|
+
*/
|
|
1480
|
+
unregister(channel: string, stream: EventStream): void;
|
|
1481
|
+
/**
|
|
1482
|
+
* Number of live subscribers on `channel`.
|
|
1483
|
+
*
|
|
1484
|
+
* @param channel - The channel name.
|
|
1485
|
+
* @returns The subscriber count.
|
|
1486
|
+
*/
|
|
1487
|
+
localSubscribers(channel: string): number;
|
|
1488
|
+
/**
|
|
1489
|
+
* Publish an event to every subscriber on `channel`.
|
|
1490
|
+
*
|
|
1491
|
+
* @param channel - The channel name.
|
|
1492
|
+
* @param data - The payload (objects are JSON-encoded).
|
|
1493
|
+
* @param event - Optional event name.
|
|
1494
|
+
* @returns The number of subscribers the event was delivered to.
|
|
1495
|
+
*/
|
|
1496
|
+
publish(channel: string, data: unknown, event?: string): number;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/** WebSocket message envelope, mirroring `websockets.schemas`. */
|
|
1500
|
+
|
|
1501
|
+
/** The canonical message envelope exchanged over a socket. */
|
|
1502
|
+
declare const wsEnvelopeSchema: z.ZodObject<{
|
|
1503
|
+
type: z.ZodString;
|
|
1504
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
1505
|
+
}, "strip", z.ZodTypeAny, {
|
|
1506
|
+
type: string;
|
|
1507
|
+
data?: unknown;
|
|
1508
|
+
}, {
|
|
1509
|
+
type: string;
|
|
1510
|
+
data?: unknown;
|
|
1511
|
+
}>;
|
|
1512
|
+
/** A typed message envelope. */
|
|
1513
|
+
type WSEnvelope = z.infer<typeof wsEnvelopeSchema>;
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* In-process connection hub, mirroring `websockets.hub.WebSocketHub`.
|
|
1517
|
+
*
|
|
1518
|
+
* Transport-agnostic: it tracks {@link WebSocketLike} connections (anything with
|
|
1519
|
+
* `send`/`close`) so it works with the `ws` package or any compatible socket.
|
|
1520
|
+
* Supports per-user delivery, topic subscriptions, broadcast and a per-user
|
|
1521
|
+
* connection cap with oldest-eviction.
|
|
1522
|
+
*/
|
|
1523
|
+
|
|
1524
|
+
/** The minimal socket surface the hub needs. */
|
|
1525
|
+
interface WebSocketLike {
|
|
1526
|
+
/** Send a text frame. */
|
|
1527
|
+
send(data: string): void;
|
|
1528
|
+
/** Close the socket, optionally with a status code. */
|
|
1529
|
+
close(code?: number): void;
|
|
1530
|
+
}
|
|
1531
|
+
/** A registered live connection. */
|
|
1532
|
+
interface WebSocketConnection {
|
|
1533
|
+
/** Unique connection id. */
|
|
1534
|
+
id: string;
|
|
1535
|
+
/** The owning user id. */
|
|
1536
|
+
userId: string;
|
|
1537
|
+
/** The underlying socket. */
|
|
1538
|
+
ws: WebSocketLike;
|
|
1539
|
+
/** Topics this connection is subscribed to. */
|
|
1540
|
+
topics: Set<string>;
|
|
1541
|
+
}
|
|
1542
|
+
/** Options for {@link WebSocketHub}. */
|
|
1543
|
+
interface WebSocketHubOptions {
|
|
1544
|
+
/** Max simultaneous connections per user (oldest evicted). Default 5. */
|
|
1545
|
+
maxPerUser?: number;
|
|
1546
|
+
}
|
|
1547
|
+
declare class WebSocketHub {
|
|
1548
|
+
private readonly byId;
|
|
1549
|
+
private readonly byUser;
|
|
1550
|
+
private readonly maxPerUser;
|
|
1551
|
+
/**
|
|
1552
|
+
* @param options - Per-user connection cap.
|
|
1553
|
+
*/
|
|
1554
|
+
constructor(options?: WebSocketHubOptions);
|
|
1555
|
+
/**
|
|
1556
|
+
* Register a new connection for `userId`, evicting the oldest if over cap.
|
|
1557
|
+
*
|
|
1558
|
+
* @param userId - The owning user id.
|
|
1559
|
+
* @param ws - The socket to register.
|
|
1560
|
+
* @returns The created connection record.
|
|
1561
|
+
*/
|
|
1562
|
+
register(userId: string, ws: WebSocketLike): WebSocketConnection;
|
|
1563
|
+
/**
|
|
1564
|
+
* Remove a connection and close its socket.
|
|
1565
|
+
*
|
|
1566
|
+
* @param connectionId - The connection id.
|
|
1567
|
+
* @param code - Optional WebSocket close code.
|
|
1568
|
+
*/
|
|
1569
|
+
unregister(connectionId: string, code?: number): void;
|
|
1570
|
+
/** Subscribe a connection to a topic. */
|
|
1571
|
+
subscribe(connectionId: string, topic: string): void;
|
|
1572
|
+
/** Unsubscribe a connection from a topic. */
|
|
1573
|
+
unsubscribe(connectionId: string, topic: string): void;
|
|
1574
|
+
/** Serialize and send an envelope to a single connection. */
|
|
1575
|
+
private deliver;
|
|
1576
|
+
/**
|
|
1577
|
+
* Send an envelope to every connection of `userId`.
|
|
1578
|
+
*
|
|
1579
|
+
* @param userId - The target user.
|
|
1580
|
+
* @param envelope - The message envelope.
|
|
1581
|
+
* @returns The number of connections delivered to.
|
|
1582
|
+
*/
|
|
1583
|
+
sendTo(userId: string, envelope: WSEnvelope): number;
|
|
1584
|
+
/**
|
|
1585
|
+
* Broadcast an envelope to all connections, or only a topic's subscribers.
|
|
1586
|
+
*
|
|
1587
|
+
* @param envelope - The message envelope.
|
|
1588
|
+
* @param topic - Optional topic to scope the broadcast.
|
|
1589
|
+
* @returns The number of connections delivered to.
|
|
1590
|
+
*/
|
|
1591
|
+
broadcast(envelope: WSEnvelope, topic?: string): number;
|
|
1592
|
+
/** The set of users with at least one live connection. */
|
|
1593
|
+
onlineUsers(): Set<string>;
|
|
1594
|
+
/** Total live connection count. */
|
|
1595
|
+
connectionCount(): number;
|
|
1596
|
+
/** Number of connections subscribed to `topic`. */
|
|
1597
|
+
topicCount(topic: string): number;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
/** Handshake info passed to the authenticator. */
|
|
1601
|
+
interface HandshakeInfo {
|
|
1602
|
+
/** The request URL (includes the query string, e.g. `/ws?token=…`). */
|
|
1603
|
+
url: string;
|
|
1604
|
+
/** The raw request headers. */
|
|
1605
|
+
headers: Record<string, string | string[] | undefined>;
|
|
1606
|
+
}
|
|
1607
|
+
/** Options for {@link attachWebSocketHub}. */
|
|
1608
|
+
interface AttachWebSocketOptions {
|
|
1609
|
+
/** Path the WebSocket server listens on. Default `/ws`. */
|
|
1610
|
+
path?: string;
|
|
1611
|
+
/**
|
|
1612
|
+
* Resolve a user id from the handshake, or `null` to reject (closes 1008).
|
|
1613
|
+
* Default accepts every connection as `"anonymous"`.
|
|
1614
|
+
*/
|
|
1615
|
+
authenticate?: (info: HandshakeInfo) => Promise<string | null> | string | null;
|
|
1616
|
+
/** Heartbeat interval in seconds (`0` disables). Default 30. */
|
|
1617
|
+
heartbeatSeconds?: number;
|
|
1618
|
+
/** Handler invoked for each inbound text message. */
|
|
1619
|
+
onMessage?: (connection: WebSocketConnection, message: string) => void;
|
|
1620
|
+
}
|
|
1621
|
+
/** Read a `token` query param from a handshake URL, or `null`. */
|
|
1622
|
+
declare function tokenFromUrl(url: string): string | null;
|
|
1623
|
+
/**
|
|
1624
|
+
* Attach a hub to an HTTP server over the `ws` package.
|
|
1625
|
+
*
|
|
1626
|
+
* @param server - The Node HTTP server (e.g. from `runServer`).
|
|
1627
|
+
* @param hub - The hub to register connections into.
|
|
1628
|
+
* @param options - Path, authenticator, heartbeat and message handler.
|
|
1629
|
+
* @returns The created `ws` `WebSocketServer` instance.
|
|
1630
|
+
* @throws {Error} When the optional `ws` peer is not installed.
|
|
1631
|
+
*/
|
|
1632
|
+
declare function attachWebSocketHub(server: Server, hub: WebSocketHub, options?: AttachWebSocketOptions): Promise<ws.WebSocketServer>;
|
|
1633
|
+
|
|
1634
|
+
/**
|
|
1635
|
+
* Message broker, mirroring `queue.manager.AsyncBrokerManager`.
|
|
1636
|
+
*
|
|
1637
|
+
* A narrow async pub/sub surface ({@link BrokerManager}) with two backends: an
|
|
1638
|
+
* in-process {@link MemoryBroker} (dev/tests) and a {@link RabbitBroker} over the
|
|
1639
|
+
* optional `amqplib` peer (lazily imported). Messages are JSON-serialized.
|
|
1640
|
+
*/
|
|
1641
|
+
/** A handler invoked for each delivered message. */
|
|
1642
|
+
type MessageHandler = (message: unknown) => Promise<void> | void;
|
|
1643
|
+
/** Narrow async pub/sub surface every backend implements. */
|
|
1644
|
+
interface BrokerManager {
|
|
1645
|
+
/** Publish a message to a named queue. */
|
|
1646
|
+
publish(queue: string, message: unknown): Promise<void>;
|
|
1647
|
+
/** Subscribe to a queue; resolves to an unsubscribe function. */
|
|
1648
|
+
subscribe(queue: string, handler: MessageHandler): Promise<() => Promise<void>>;
|
|
1649
|
+
/** Close the broker and release resources. */
|
|
1650
|
+
close(): Promise<void>;
|
|
1651
|
+
}
|
|
1652
|
+
/** In-process {@link BrokerManager} backed by handler sets. */
|
|
1653
|
+
declare class MemoryBroker implements BrokerManager {
|
|
1654
|
+
private readonly handlers;
|
|
1655
|
+
publish(queue: string, message: unknown): Promise<void>;
|
|
1656
|
+
subscribe(queue: string, handler: MessageHandler): Promise<() => Promise<void>>;
|
|
1657
|
+
close(): Promise<void>;
|
|
1658
|
+
}
|
|
1659
|
+
/** Options for {@link RabbitBroker}. */
|
|
1660
|
+
interface RabbitBrokerOptions {
|
|
1661
|
+
/** AMQP connection URL, e.g. `amqp://localhost`. */
|
|
1662
|
+
url: string;
|
|
1663
|
+
/** Whether queues are declared durable. Default `true`. */
|
|
1664
|
+
durable?: boolean;
|
|
1665
|
+
}
|
|
1666
|
+
/** RabbitMQ-backed {@link BrokerManager} over the optional `amqplib` peer. */
|
|
1667
|
+
declare class RabbitBroker implements BrokerManager {
|
|
1668
|
+
private readonly options;
|
|
1669
|
+
private connection;
|
|
1670
|
+
private channel;
|
|
1671
|
+
private readonly durable;
|
|
1672
|
+
/**
|
|
1673
|
+
* @param options - Connection URL and queue durability.
|
|
1674
|
+
*/
|
|
1675
|
+
constructor(options: RabbitBrokerOptions);
|
|
1676
|
+
/** Lazily connect and open a channel. */
|
|
1677
|
+
private ready;
|
|
1678
|
+
publish(queue: string, message: unknown): Promise<void>;
|
|
1679
|
+
subscribe(queue: string, handler: MessageHandler): Promise<() => Promise<void>>;
|
|
1680
|
+
close(): Promise<void>;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* Background task manager, mirroring `tasks.manager.AsyncTaskBrokerManager`.
|
|
1685
|
+
*
|
|
1686
|
+
* Rides on a {@link BrokerManager}: enqueue publishes a `{ name, payload }`
|
|
1687
|
+
* envelope to a task queue; a worker started with {@link TaskManager.start}
|
|
1688
|
+
* consumes it and dispatches to the registered handler. Defaults to an
|
|
1689
|
+
* in-process {@link MemoryBroker} so it works with zero infrastructure.
|
|
1690
|
+
*/
|
|
1691
|
+
|
|
1692
|
+
/** A handler for a registered task. */
|
|
1693
|
+
type TaskHandler<P = unknown> = (payload: P) => Promise<void> | void;
|
|
1694
|
+
/** Options for {@link TaskManager}. */
|
|
1695
|
+
interface TaskManagerOptions {
|
|
1696
|
+
/** The broker to publish/consume on. Defaults to a {@link MemoryBroker}. */
|
|
1697
|
+
broker?: BrokerManager;
|
|
1698
|
+
/** Queue name used for the task stream. Default `tasks`. */
|
|
1699
|
+
queue?: string;
|
|
1700
|
+
}
|
|
1701
|
+
declare class TaskManager {
|
|
1702
|
+
private readonly broker;
|
|
1703
|
+
private readonly queue;
|
|
1704
|
+
private readonly handlers;
|
|
1705
|
+
private unsubscribe;
|
|
1706
|
+
/**
|
|
1707
|
+
* @param options - Broker and queue name.
|
|
1708
|
+
*/
|
|
1709
|
+
constructor(options?: TaskManagerOptions);
|
|
1710
|
+
/**
|
|
1711
|
+
* Register a handler for a named task.
|
|
1712
|
+
*
|
|
1713
|
+
* @param name - The task name.
|
|
1714
|
+
* @param handler - The handler invoked with the task payload.
|
|
1715
|
+
*/
|
|
1716
|
+
register<P = unknown>(name: string, handler: TaskHandler<P>): void;
|
|
1717
|
+
/**
|
|
1718
|
+
* Enqueue a task by name.
|
|
1719
|
+
*
|
|
1720
|
+
* @param name - The registered task name.
|
|
1721
|
+
* @param payload - The JSON-serializable payload.
|
|
1722
|
+
*/
|
|
1723
|
+
enqueue(name: string, payload?: unknown): Promise<void>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Start the worker: subscribe to the task queue and dispatch to handlers.
|
|
1726
|
+
* A task with no registered handler is logged and skipped.
|
|
1727
|
+
*/
|
|
1728
|
+
start(): Promise<void>;
|
|
1729
|
+
/** Stop the worker (stops consuming; does not close the broker). */
|
|
1730
|
+
stop(): Promise<void>;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
/**
|
|
1734
|
+
* Feature-flag backends, mirroring `flags.backends`.
|
|
1735
|
+
*
|
|
1736
|
+
* A flag resolves to a boolean given a flag name and optional context. Backends
|
|
1737
|
+
* are composable — {@link CompositeFeatureFlagBackend} tries each in order and
|
|
1738
|
+
* returns the first definitive answer.
|
|
1739
|
+
*/
|
|
1740
|
+
/** Arbitrary evaluation context (user id, roles, attributes). */
|
|
1741
|
+
type FlagContext = Record<string, unknown>;
|
|
1742
|
+
/** Resolves a flag to enabled/disabled, or `null` when it has no opinion. */
|
|
1743
|
+
interface FeatureFlagBackend {
|
|
1744
|
+
/** Resolve `flag`; `null` defers to the next backend. */
|
|
1745
|
+
resolve(flag: string, context?: FlagContext): Promise<boolean | null> | boolean | null;
|
|
1746
|
+
}
|
|
1747
|
+
/** Coerce a loose value (`"1"`, `"true"`, `"on"`, …) to a boolean. */
|
|
1748
|
+
declare function coerceFlag(value: unknown): boolean;
|
|
1749
|
+
/** In-memory backend backed by a `Map`, ideal for tests and overrides. */
|
|
1750
|
+
declare class MemoryFeatureFlagBackend implements FeatureFlagBackend {
|
|
1751
|
+
private readonly flags;
|
|
1752
|
+
/**
|
|
1753
|
+
* @param initial - Initial flag → enabled map.
|
|
1754
|
+
*/
|
|
1755
|
+
constructor(initial?: Record<string, boolean>);
|
|
1756
|
+
/** Set or override a flag. */
|
|
1757
|
+
set(flag: string, enabled: boolean): void;
|
|
1758
|
+
resolve(flag: string): boolean | null;
|
|
1759
|
+
}
|
|
1760
|
+
/** Reads flags from env vars, e.g. flag `new-ui` → `FLAG_NEW_UI`. */
|
|
1761
|
+
declare class EnvFeatureFlagBackend implements FeatureFlagBackend {
|
|
1762
|
+
private readonly env;
|
|
1763
|
+
private readonly prefix;
|
|
1764
|
+
/**
|
|
1765
|
+
* @param env - Environment source (defaults to `process.env`).
|
|
1766
|
+
* @param prefix - Env var prefix. Default `FLAG_`.
|
|
1767
|
+
*/
|
|
1768
|
+
constructor(env?: NodeJS.ProcessEnv, prefix?: string);
|
|
1769
|
+
private key;
|
|
1770
|
+
resolve(flag: string): boolean | null;
|
|
1771
|
+
}
|
|
1772
|
+
/** Tries each backend in order; first non-`null` answer wins. */
|
|
1773
|
+
declare class CompositeFeatureFlagBackend implements FeatureFlagBackend {
|
|
1774
|
+
private readonly backends;
|
|
1775
|
+
/**
|
|
1776
|
+
* @param backends - Backends in priority order.
|
|
1777
|
+
*/
|
|
1778
|
+
constructor(backends: FeatureFlagBackend[]);
|
|
1779
|
+
resolve(flag: string, context?: FlagContext): Promise<boolean | null>;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* Feature-flag service + Express guard, mirroring `flags.service` /
|
|
1784
|
+
* `flags.dependencies`.
|
|
1785
|
+
*/
|
|
1786
|
+
|
|
1787
|
+
/** Evaluates flags against a backend, applying a default when undecided. */
|
|
1788
|
+
declare class FeatureFlags {
|
|
1789
|
+
private readonly backend;
|
|
1790
|
+
private readonly defaultEnabled;
|
|
1791
|
+
/**
|
|
1792
|
+
* @param backend - The resolving backend.
|
|
1793
|
+
* @param defaultEnabled - Value used when the backend returns `null`.
|
|
1794
|
+
*/
|
|
1795
|
+
constructor(backend: FeatureFlagBackend, defaultEnabled?: boolean);
|
|
1796
|
+
/**
|
|
1797
|
+
* Whether `flag` is enabled for the given context.
|
|
1798
|
+
*
|
|
1799
|
+
* @param flag - The flag name.
|
|
1800
|
+
* @param context - Optional evaluation context.
|
|
1801
|
+
* @returns `true` when enabled (or default when the backend is undecided).
|
|
1802
|
+
*/
|
|
1803
|
+
isEnabled(flag: string, context?: FlagContext): Promise<boolean>;
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Build middleware that rejects with 404 when `flag` is disabled (hiding the
|
|
1807
|
+
* route entirely, the common kill-switch behavior).
|
|
1808
|
+
*
|
|
1809
|
+
* @param flags - The flag service.
|
|
1810
|
+
* @param flag - The flag name to gate on.
|
|
1811
|
+
* @returns An Express middleware.
|
|
1812
|
+
*/
|
|
1813
|
+
declare function makeFlagGuard(flags: FeatureFlags, flag: string): RequestHandler;
|
|
1814
|
+
|
|
1815
|
+
/**
|
|
1816
|
+
* File storage abstraction, mirroring `utils.storage_backends` / `utils.upload`.
|
|
1817
|
+
*
|
|
1818
|
+
* A narrow {@link UploadStorage} interface with a filesystem-backed
|
|
1819
|
+
* {@link LocalUploadStorage}. For S3/MinIO, implement the same interface over
|
|
1820
|
+
* your client (the interface intentionally avoids a hard cloud dependency).
|
|
1821
|
+
*/
|
|
1822
|
+
/** The result of persisting an object. */
|
|
1823
|
+
interface UploadResult {
|
|
1824
|
+
/** The storage key (path within the backend). */
|
|
1825
|
+
key: string;
|
|
1826
|
+
/** A URL the object can be served from. */
|
|
1827
|
+
url: string;
|
|
1828
|
+
/** The stored byte size. */
|
|
1829
|
+
size: number;
|
|
1830
|
+
/** The declared content type, when known. */
|
|
1831
|
+
contentType?: string;
|
|
1832
|
+
}
|
|
1833
|
+
/** Options for {@link UploadStorage.save}. */
|
|
1834
|
+
interface SaveOptions {
|
|
1835
|
+
/** MIME type recorded on the result. */
|
|
1836
|
+
contentType?: string;
|
|
1837
|
+
}
|
|
1838
|
+
/** Narrow object-storage surface backends implement. */
|
|
1839
|
+
interface UploadStorage {
|
|
1840
|
+
/** Persist bytes under `key`, returning metadata. */
|
|
1841
|
+
save(key: string, data: Uint8Array, options?: SaveOptions): Promise<UploadResult>;
|
|
1842
|
+
/** Read bytes back by key. */
|
|
1843
|
+
read(key: string): Promise<Buffer>;
|
|
1844
|
+
/** Delete an object. Idempotent. */
|
|
1845
|
+
delete(key: string): Promise<void>;
|
|
1846
|
+
/** The URL an object is served from. */
|
|
1847
|
+
url(key: string): string;
|
|
1848
|
+
}
|
|
1849
|
+
/** Options for {@link LocalUploadStorage}. */
|
|
1850
|
+
interface LocalUploadStorageOptions {
|
|
1851
|
+
/** Filesystem root every key is written under. */
|
|
1852
|
+
root: string;
|
|
1853
|
+
/** Public base URL prefix for {@link LocalUploadStorage.url}. Default `""`. */
|
|
1854
|
+
baseUrl?: string;
|
|
1855
|
+
}
|
|
1856
|
+
/** Filesystem-backed {@link UploadStorage} for local/dev or single-host setups. */
|
|
1857
|
+
declare class LocalUploadStorage implements UploadStorage {
|
|
1858
|
+
private readonly root;
|
|
1859
|
+
private readonly baseUrl;
|
|
1860
|
+
/**
|
|
1861
|
+
* @param options - Filesystem root and public base URL.
|
|
1862
|
+
*/
|
|
1863
|
+
constructor(options: LocalUploadStorageOptions);
|
|
1864
|
+
save(key: string, data: Uint8Array, options?: SaveOptions): Promise<UploadResult>;
|
|
1865
|
+
read(key: string): Promise<Buffer>;
|
|
1866
|
+
delete(key: string): Promise<void>;
|
|
1867
|
+
url(key: string): string;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Build a `Content-Disposition` header value.
|
|
1871
|
+
*
|
|
1872
|
+
* @param filename - The download filename.
|
|
1873
|
+
* @param inline - When `true`, use `inline`; otherwise `attachment`.
|
|
1874
|
+
* @returns The header value (RFC 5987 `filename*` encoded).
|
|
1875
|
+
*/
|
|
1876
|
+
declare function buildContentDisposition(filename: string, inline?: boolean): string;
|
|
1877
|
+
|
|
1132
1878
|
/**
|
|
1133
1879
|
* Auth DTOs (Zod), mirroring `auth.schemas`.
|
|
1134
1880
|
*
|
|
@@ -1197,14 +1943,14 @@ declare const userPublicSchema: z.ZodObject<{
|
|
|
1197
1943
|
}, "strip", z.ZodTypeAny, {
|
|
1198
1944
|
id: string;
|
|
1199
1945
|
isActive: boolean;
|
|
1200
|
-
email: string;
|
|
1201
1946
|
name: string | null;
|
|
1947
|
+
email: string;
|
|
1202
1948
|
roles: string[];
|
|
1203
1949
|
}, {
|
|
1204
1950
|
id: string;
|
|
1205
1951
|
isActive: boolean;
|
|
1206
|
-
email: string;
|
|
1207
1952
|
name: string | null;
|
|
1953
|
+
email: string;
|
|
1208
1954
|
roles: string[];
|
|
1209
1955
|
}>;
|
|
1210
1956
|
/** Response body for `POST /auth/signup` and `POST /auth/login`. */
|
|
@@ -1218,14 +1964,14 @@ declare const authResponseSchema: z.ZodObject<{
|
|
|
1218
1964
|
}, "strip", z.ZodTypeAny, {
|
|
1219
1965
|
id: string;
|
|
1220
1966
|
isActive: boolean;
|
|
1221
|
-
email: string;
|
|
1222
1967
|
name: string | null;
|
|
1968
|
+
email: string;
|
|
1223
1969
|
roles: string[];
|
|
1224
1970
|
}, {
|
|
1225
1971
|
id: string;
|
|
1226
1972
|
isActive: boolean;
|
|
1227
|
-
email: string;
|
|
1228
1973
|
name: string | null;
|
|
1974
|
+
email: string;
|
|
1229
1975
|
roles: string[];
|
|
1230
1976
|
}>;
|
|
1231
1977
|
tokens: z.ZodObject<{
|
|
@@ -1248,8 +1994,8 @@ declare const authResponseSchema: z.ZodObject<{
|
|
|
1248
1994
|
user: {
|
|
1249
1995
|
id: string;
|
|
1250
1996
|
isActive: boolean;
|
|
1251
|
-
email: string;
|
|
1252
1997
|
name: string | null;
|
|
1998
|
+
email: string;
|
|
1253
1999
|
roles: string[];
|
|
1254
2000
|
};
|
|
1255
2001
|
tokens: {
|
|
@@ -1262,8 +2008,8 @@ declare const authResponseSchema: z.ZodObject<{
|
|
|
1262
2008
|
user: {
|
|
1263
2009
|
id: string;
|
|
1264
2010
|
isActive: boolean;
|
|
1265
|
-
email: string;
|
|
1266
2011
|
name: string | null;
|
|
2012
|
+
email: string;
|
|
1267
2013
|
roles: string[];
|
|
1268
2014
|
};
|
|
1269
2015
|
tokens: {
|
|
@@ -1721,6 +2467,6 @@ interface RunServerOptions {
|
|
|
1721
2467
|
declare function runServer(app: Express, options?: RunServerOptions): Promise<Server>;
|
|
1722
2468
|
|
|
1723
2469
|
/** The installed SDK version. Single source of truth for the barrel + CLI. */
|
|
1724
|
-
declare const VERSION = "0.
|
|
2470
|
+
declare const VERSION = "0.2.0";
|
|
1725
2471
|
|
|
1726
|
-
export { AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CatalogData, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type Enum, type EnumHelpers, type EnumSpec, type ExceptionDetails, ExpiredTokenException, ForbiddenException, type GenerateOpenApiOptions, HTTP_500_MARKER, type HealthCheck, type HealthRouterOptions, InvalidTokenException, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, type LogExtra, type LogLevel, type LoginInput, MemoryThrottleBackend, MessageCatalog, NotFoundException, type OpenApiDocument, type OpenApiInfo, PHONE_BR_PATTERN, type PaginationFilter, PasswordUtils, REQUEST_ID_HEADER, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, type RunServerOptions, type SignupInput, type StateBR, type SwaggerOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, cepField, citiesByUf, cnpjField, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAppExceptionHandler, makeAuthRouter, makeHealthRouter, makeJwtAuthMiddleware, makeUnhandledExceptionHandler, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, setRequestId, signupSchema, statesByRegion, tableNameFor, toDict, toUtc, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, verifyOpaqueToken };
|
|
2472
|
+
export { 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 CacheManager, type CachedOptions, type CatalogData, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, NotFoundException, type OpenApiDocument, type OpenApiInfo, PHONE_BR_PATTERN, type PaginationFilter, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, type RunServerOptions, SSEBroker, type SaveOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type TaskHandler, TaskManager, type TaskManagerOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, 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, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeUnhandledExceptionHandler, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, verifyOpaqueToken, wsEnvelopeSchema };
|