@wabot-dev/framework 0.9.2 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/addon/async/pg/PgCronJobRepository.js +7 -5
- package/dist/src/addon/async/pg/PgJobRepository.js +7 -5
- package/dist/src/addon/async/pg/PgTransactionAdapter.js +4 -4
- package/dist/src/addon/auth/api-key/ApiKey.js +4 -4
- package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +9 -8
- package/dist/src/addon/auth/jwt/JwtRefreshToken.js +4 -4
- package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +6 -5
- package/dist/src/addon/chat-bot/pg/PgChatMemory.js +8 -7
- package/dist/src/addon/chat-bot/pg/PgChatRepository.js +7 -6
- package/dist/src/addon/chat-controller/cmd/@cmd.js +7 -2
- package/dist/src/addon/chat-controller/cmd/CmdChannel.js +85 -61
- package/dist/src/addon/chat-controller/cmd/CmdChannelConfig.js +8 -0
- package/dist/src/addon/chat-controller/cmd/CmdChannelServer.js +169 -0
- package/dist/src/addon/chat-controller/cmd/cmdChannelSocketPath.js +16 -0
- package/dist/src/addon/chat-controller/cmd/runCmdClient.js +226 -0
- package/dist/src/core/repository/CrudRepository.js +25 -0
- package/dist/src/feature/pg/@pgExtension.js +33 -0
- package/dist/src/feature/pg/PgJsonRepositoryAdapter.js +50 -0
- package/dist/src/feature/pg/index.js +4 -7
- package/dist/src/feature/project-runner/ProjectRunner.js +67 -17
- package/dist/src/feature/repository/@memoryExtension.js +29 -0
- package/dist/src/feature/repository/@query.js +22 -0
- package/dist/src/feature/repository/@queryExtension.js +21 -0
- package/dist/src/feature/repository/@repository.js +170 -0
- package/dist/src/feature/repository/MemoryRepositoryAdapter.js +110 -0
- package/dist/src/feature/repository/RepositoryAdapterRegistry.js +27 -0
- package/dist/src/feature/repository/RepositoryMetadataStore.js +102 -0
- package/dist/src/feature/repository/evaluateQueryAst.js +134 -0
- package/dist/src/index.d.ts +197 -47
- package/dist/src/index.js +18 -7
- package/package.json +4 -2
- package/dist/src/feature/pg/query/@pgJsonRepository.js +0 -73
- package/dist/src/feature/pg/query/@query.js +0 -14
- package/dist/src/feature/pg/query/PgJsonRepository.js +0 -23
- package/dist/src/feature/pg/query/PgRepositoryMetadataStore.js +0 -44
- /package/dist/src/feature/pg/{query/buildQuerySql.js → buildQuerySql.js} +0 -0
- /package/dist/src/feature/{pg/query → repository}/parseQueryMethodName.js +0 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -417,7 +417,18 @@ declare class Random {
|
|
|
417
417
|
static numberCode(length: number): string;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
interface ICrudRepository<T
|
|
420
|
+
interface ICrudRepository<T extends Entity<IEntityData>> {
|
|
421
|
+
find(id: string): Promise<T | null>;
|
|
422
|
+
findOrThrow(id: string): Promise<T>;
|
|
423
|
+
findByIds(ids: string[]): Promise<T[]>;
|
|
424
|
+
findAll(id: string): Promise<T[]>;
|
|
425
|
+
create(item: T): Promise<void>;
|
|
426
|
+
update(item: T): Promise<void>;
|
|
427
|
+
delete(item: T): Promise<void>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
declare class CrudRepository<T extends Entity<IEntityData>, Ext = never> implements ICrudRepository<T> {
|
|
431
|
+
protected readonly extension: Ext;
|
|
421
432
|
find(id: string): Promise<T | null>;
|
|
422
433
|
findOrThrow(id: string): Promise<T>;
|
|
423
434
|
findByIds(ids: string[]): Promise<T[]>;
|
|
@@ -1114,11 +1125,13 @@ declare function safeJsonParse<T = unknown>(json: string | undefined | null, con
|
|
|
1114
1125
|
|
|
1115
1126
|
interface IProjectRunnerConfig {
|
|
1116
1127
|
directories?: string[];
|
|
1128
|
+
exclude?: string[];
|
|
1117
1129
|
connectionString?: string;
|
|
1118
1130
|
chatAdapters?: IConstructor<IChatAdapter>[];
|
|
1119
1131
|
}
|
|
1120
1132
|
declare class ProjectRunner {
|
|
1121
1133
|
private directories;
|
|
1134
|
+
private exclude;
|
|
1122
1135
|
private chatAdapters;
|
|
1123
1136
|
private connectionString;
|
|
1124
1137
|
private isPg;
|
|
@@ -1283,6 +1296,10 @@ declare class PgRepositoryBase<P extends Entity<IEntityData>> {
|
|
|
1283
1296
|
protected ensureColumns(client: PoolClient): Promise<void>;
|
|
1284
1297
|
}
|
|
1285
1298
|
|
|
1299
|
+
declare const PG_ADAPTER_ID: unique symbol;
|
|
1300
|
+
type ExtensionOf$1<R> = R extends CrudRepository<any, infer Ext> ? Ext : never;
|
|
1301
|
+
declare function pgExtension<R extends CrudRepository<any, any>>(repositoryClass: IConstructor<R>): <E extends PgRepositoryBase<any> & ExtensionOf$1<R>>(target: IConstructor<E>) => void;
|
|
1302
|
+
|
|
1286
1303
|
declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
1287
1304
|
protected readonly config: IPgRepositoryConfig<P>;
|
|
1288
1305
|
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
@@ -1295,6 +1312,116 @@ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgReposito
|
|
|
1295
1312
|
delete(item: P): Promise<void>;
|
|
1296
1313
|
}
|
|
1297
1314
|
|
|
1315
|
+
interface IRepositoryConfig<P extends Entity<IEntityData>> {
|
|
1316
|
+
table: string;
|
|
1317
|
+
constructor: IConstructor<P>;
|
|
1318
|
+
schema?: string;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
type QueryPrefix = 'find' | 'findOne' | 'count' | 'exists' | 'delete';
|
|
1322
|
+
type QueryOperator = 'Equals' | 'Not' | 'Like' | 'NotLike' | 'In' | 'NotIn' | 'Gt' | 'Gte' | 'Lt' | 'Lte' | 'IsNull' | 'IsNotNull';
|
|
1323
|
+
type QueryConnector = 'And' | 'Or';
|
|
1324
|
+
interface IQueryCondition {
|
|
1325
|
+
field: string;
|
|
1326
|
+
operator: QueryOperator;
|
|
1327
|
+
connector?: QueryConnector;
|
|
1328
|
+
}
|
|
1329
|
+
interface IQueryOrderBy {
|
|
1330
|
+
field: string;
|
|
1331
|
+
direction: 'ASC' | 'DESC';
|
|
1332
|
+
}
|
|
1333
|
+
interface IQueryAst {
|
|
1334
|
+
prefix: QueryPrefix;
|
|
1335
|
+
conditions: IQueryCondition[];
|
|
1336
|
+
orderBy: IQueryOrderBy[];
|
|
1337
|
+
limit?: number;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
interface IRepositoryRuntime<P extends Entity<IEntityData>> {
|
|
1341
|
+
find(id: string): Promise<P | null>;
|
|
1342
|
+
findOrThrow(id: string): Promise<P>;
|
|
1343
|
+
findByIds(ids: string[]): Promise<P[]>;
|
|
1344
|
+
findAll(): Promise<P[]>;
|
|
1345
|
+
create(item: P): Promise<void>;
|
|
1346
|
+
update(item: P): Promise<void>;
|
|
1347
|
+
delete(item: P): Promise<void>;
|
|
1348
|
+
runQuery(ast: IQueryAst, args: unknown[]): Promise<P[]>;
|
|
1349
|
+
runCount(ast: IQueryAst, args: unknown[]): Promise<number>;
|
|
1350
|
+
runExists(ast: IQueryAst, args: unknown[]): Promise<boolean>;
|
|
1351
|
+
runDelete(ast: IQueryAst, args: unknown[]): Promise<void>;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
interface IRepositoryAdapter {
|
|
1355
|
+
readonly id: symbol;
|
|
1356
|
+
build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
|
|
1357
|
+
buildExtension?<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
declare class MemoryRepositoryExtension<P extends Entity<IEntityData>> {
|
|
1361
|
+
protected readonly items: Map<string, P>;
|
|
1362
|
+
protected readonly config: IRepositoryConfig<P>;
|
|
1363
|
+
constructor(items: Map<string, P>, config: IRepositoryConfig<P>);
|
|
1364
|
+
protected clone(item: P): P;
|
|
1365
|
+
}
|
|
1366
|
+
declare const MEMORY_ADAPTER_ID: unique symbol;
|
|
1367
|
+
declare class MemoryRepositoryAdapter implements IRepositoryAdapter {
|
|
1368
|
+
readonly id: symbol;
|
|
1369
|
+
private stores;
|
|
1370
|
+
private getStore;
|
|
1371
|
+
build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
|
|
1372
|
+
buildExtension<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
type ExtensionOf<R> = R extends CrudRepository<any, infer Ext> ? Ext : never;
|
|
1376
|
+
declare function memoryExtension<R extends CrudRepository<any, any>>(repositoryClass: IConstructor<R>): <E extends MemoryRepositoryExtension<any> & ExtensionOf<R>>(target: IConstructor<E>) => void;
|
|
1377
|
+
|
|
1378
|
+
declare function query(): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
1379
|
+
|
|
1380
|
+
declare function queryExtension(): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
1381
|
+
|
|
1382
|
+
declare function repository<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): (target: IConstructor<any>) => void;
|
|
1383
|
+
|
|
1384
|
+
declare function evaluateQueryAst<P extends Entity<IEntityData>>(items: Iterable<P>, ast: IQueryAst, args: unknown[]): P[];
|
|
1385
|
+
|
|
1386
|
+
declare function parseQueryMethodName(name: string): IQueryAst;
|
|
1387
|
+
|
|
1388
|
+
declare class RepositoryAdapterRegistry {
|
|
1389
|
+
private adapter;
|
|
1390
|
+
setDefault(adapter: IRepositoryAdapter): void;
|
|
1391
|
+
getDefault(): IRepositoryAdapter;
|
|
1392
|
+
hasDefault(): boolean;
|
|
1393
|
+
clear(): void;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
interface IQueryMethodMetadata {
|
|
1397
|
+
repositoryConstructor: IConstructor<any>;
|
|
1398
|
+
functionName: string;
|
|
1399
|
+
}
|
|
1400
|
+
declare class RepositoryMetadataStore {
|
|
1401
|
+
private queryMethods;
|
|
1402
|
+
private extensionMethods;
|
|
1403
|
+
private repositoryConfigs;
|
|
1404
|
+
private extensions;
|
|
1405
|
+
saveQueryMethodMetadata(metadata: IQueryMethodMetadata): void;
|
|
1406
|
+
saveExtensionMethodMetadata(metadata: IQueryMethodMetadata): void;
|
|
1407
|
+
saveRepositoryConfig<P extends Entity<IEntityData>>(ctor: IConstructor<any>, config: IRepositoryConfig<P>): void;
|
|
1408
|
+
getRepositoryConfig(ctor: IConstructor<any>): IRepositoryConfig<any> | undefined;
|
|
1409
|
+
getQueryMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
|
|
1410
|
+
getExtensionMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
|
|
1411
|
+
private collectMethodsFromHierarchy;
|
|
1412
|
+
saveExtension(repositoryConstructor: IConstructor<any>, adapterId: symbol, extensionConstructor: IConstructor<any>): void;
|
|
1413
|
+
getExtension(ctor: IConstructor<any>, adapterId: symbol): IConstructor<any> | undefined;
|
|
1414
|
+
validateExtensionsRegistered(adapterId: symbol): void;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
declare class PgJsonRepositoryAdapter implements IRepositoryAdapter {
|
|
1418
|
+
private readonly pool;
|
|
1419
|
+
readonly id: symbol;
|
|
1420
|
+
constructor(pool: Pool);
|
|
1421
|
+
build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
|
|
1422
|
+
buildExtension<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1298
1425
|
declare class PgLocker implements ILocker {
|
|
1299
1426
|
private readonly pool;
|
|
1300
1427
|
constructor(pool: Pool);
|
|
@@ -1320,46 +1447,6 @@ declare const pgStorage: AsyncLocalStorage<ClientMap>;
|
|
|
1320
1447
|
*/
|
|
1321
1448
|
declare function getClientMap(): ClientMap;
|
|
1322
1449
|
|
|
1323
|
-
declare function pgJsonRepository<P extends Entity<IEntityData>>(config: IPgRepositoryConfig<P>): (target: IConstructor<any>) => void;
|
|
1324
|
-
|
|
1325
|
-
declare function query(): (target: object, propertyKey: string | symbol) => void;
|
|
1326
|
-
|
|
1327
|
-
declare class PgJsonRepository<P extends Entity<IEntityData>> extends PgCrudRepository<P> {
|
|
1328
|
-
constructor(pool: Pool);
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
interface IQueryMethodMetadata {
|
|
1332
|
-
repositoryConstructor: IConstructor<any>;
|
|
1333
|
-
functionName: string;
|
|
1334
|
-
}
|
|
1335
|
-
declare class PgRepositoryMetadataStore {
|
|
1336
|
-
private queryMethods;
|
|
1337
|
-
private repositoryConfigs;
|
|
1338
|
-
saveQueryMethodMetadata(metadata: IQueryMethodMetadata): void;
|
|
1339
|
-
saveRepositoryConfig<P extends Entity<IEntityData>>(ctor: IConstructor<any>, config: IPgRepositoryConfig<P>): void;
|
|
1340
|
-
getRepositoryConfig(ctor: IConstructor<any>): IPgRepositoryConfig<any> | undefined;
|
|
1341
|
-
getQueryMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
type QueryPrefix = 'find' | 'findOne' | 'count' | 'exists' | 'delete';
|
|
1345
|
-
type QueryOperator = 'Equals' | 'Not' | 'Like' | 'NotLike' | 'In' | 'NotIn' | 'Gt' | 'Gte' | 'Lt' | 'Lte' | 'IsNull' | 'IsNotNull';
|
|
1346
|
-
type QueryConnector = 'And' | 'Or';
|
|
1347
|
-
interface IQueryCondition {
|
|
1348
|
-
field: string;
|
|
1349
|
-
operator: QueryOperator;
|
|
1350
|
-
connector?: QueryConnector;
|
|
1351
|
-
}
|
|
1352
|
-
interface IQueryOrderBy {
|
|
1353
|
-
field: string;
|
|
1354
|
-
direction: 'ASC' | 'DESC';
|
|
1355
|
-
}
|
|
1356
|
-
interface IQueryAst {
|
|
1357
|
-
prefix: QueryPrefix;
|
|
1358
|
-
conditions: IQueryCondition[];
|
|
1359
|
-
orderBy: IQueryOrderBy[];
|
|
1360
|
-
limit?: number;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
1450
|
interface IBuiltQuery {
|
|
1364
1451
|
sql: string;
|
|
1365
1452
|
argCount: number;
|
|
@@ -1367,8 +1454,6 @@ interface IBuiltQuery {
|
|
|
1367
1454
|
}
|
|
1368
1455
|
declare function buildQuerySql(ast: IQueryAst, table: string, columns: string): IBuiltQuery;
|
|
1369
1456
|
|
|
1370
|
-
declare function parseQueryMethodName(name: string): IQueryAst;
|
|
1371
|
-
|
|
1372
1457
|
/**
|
|
1373
1458
|
* Runs a function with a shared Postgres client for the given pool.
|
|
1374
1459
|
* Reuses the client if already present in the async context.
|
|
@@ -1872,6 +1957,34 @@ declare class WabotChatAdapter implements IChatAdapter {
|
|
|
1872
1957
|
|
|
1873
1958
|
declare function cmd(): (target: object, propertyKey: string | symbol) => void;
|
|
1874
1959
|
|
|
1960
|
+
declare class CmdChannelConfig {
|
|
1961
|
+
readonly route: string;
|
|
1962
|
+
constructor(route: string);
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
interface ICmdChannelHandlers {
|
|
1966
|
+
onMessage: (text: string, reply: (response: {
|
|
1967
|
+
senderName?: string;
|
|
1968
|
+
text: string;
|
|
1969
|
+
}) => void) => Promise<void> | void;
|
|
1970
|
+
}
|
|
1971
|
+
declare class CmdChannelServer {
|
|
1972
|
+
private server;
|
|
1973
|
+
private channels;
|
|
1974
|
+
private client;
|
|
1975
|
+
private buffer;
|
|
1976
|
+
private activeRoute;
|
|
1977
|
+
register(route: string, handlers: ICmdChannelHandlers): void;
|
|
1978
|
+
unregister(route: string): void;
|
|
1979
|
+
private ensureStarted;
|
|
1980
|
+
private shutdown;
|
|
1981
|
+
private handleConnection;
|
|
1982
|
+
private handleData;
|
|
1983
|
+
private handleMessage;
|
|
1984
|
+
private sendToClient;
|
|
1985
|
+
private send;
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1875
1988
|
declare const cmdChannelName: "CmdChannel";
|
|
1876
1989
|
|
|
1877
1990
|
interface ICmdReceivedMessage extends IReceivedMessage {
|
|
@@ -1885,18 +1998,55 @@ interface ICmdChannelMessage extends ICmdReceivedMessage {
|
|
|
1885
1998
|
|
|
1886
1999
|
declare class CmdChannel implements IChatChannel {
|
|
1887
2000
|
private auth;
|
|
1888
|
-
private
|
|
1889
|
-
private
|
|
2001
|
+
private server;
|
|
2002
|
+
private config;
|
|
1890
2003
|
static channelName: "CmdChannel";
|
|
2004
|
+
private chatId;
|
|
1891
2005
|
private callBack;
|
|
1892
|
-
constructor(auth: Auth<any
|
|
2006
|
+
constructor(auth: Auth<any>, server: CmdChannelServer, config: CmdChannelConfig);
|
|
1893
2007
|
listen(callback: (message: ICmdChannelMessage) => Promise<void>): void;
|
|
1894
2008
|
disconnect(): void;
|
|
1895
2009
|
connect(): void;
|
|
2010
|
+
private routeSlug;
|
|
2011
|
+
private chatIdPath;
|
|
2012
|
+
private authInfoPath;
|
|
2013
|
+
private ensureChatId;
|
|
2014
|
+
private ensureAuthLoaded;
|
|
1896
2015
|
}
|
|
1897
2016
|
declare function writeJsonToFile<T>(filename: string, data: T): void;
|
|
1898
2017
|
declare function readJsonFromFile<T>(filename: string): T | null;
|
|
1899
2018
|
|
|
2019
|
+
declare function cmdChannelSocketPath(): string;
|
|
2020
|
+
|
|
2021
|
+
interface ICmdChannelEntry {
|
|
2022
|
+
route: string;
|
|
2023
|
+
}
|
|
2024
|
+
type CmdClientMessage = {
|
|
2025
|
+
type: 'hello';
|
|
2026
|
+
} | {
|
|
2027
|
+
type: 'select';
|
|
2028
|
+
route: string;
|
|
2029
|
+
} | {
|
|
2030
|
+
type: 'message';
|
|
2031
|
+
text: string;
|
|
2032
|
+
};
|
|
2033
|
+
type CmdServerMessage = {
|
|
2034
|
+
type: 'channels';
|
|
2035
|
+
list: ICmdChannelEntry[];
|
|
2036
|
+
} | {
|
|
2037
|
+
type: 'selected';
|
|
2038
|
+
route: string;
|
|
2039
|
+
} | {
|
|
2040
|
+
type: 'reply';
|
|
2041
|
+
senderName?: string;
|
|
2042
|
+
text: string;
|
|
2043
|
+
} | {
|
|
2044
|
+
type: 'error';
|
|
2045
|
+
message: string;
|
|
2046
|
+
};
|
|
2047
|
+
|
|
2048
|
+
declare function runCmdClient(): void;
|
|
2049
|
+
|
|
1900
2050
|
interface ISocketChannelConfig {
|
|
1901
2051
|
namespace: string | ConfigReference<string>;
|
|
1902
2052
|
handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
|
|
@@ -2307,4 +2457,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
|
2307
2457
|
new (): {};
|
|
2308
2458
|
};
|
|
2309
2459
|
|
|
2310
|
-
export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatAdapterMetadataStore, ChatAdapterRegistry, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatOperator, ChatRepository, ChatResolver, type ClientMap, CmdChannel, type ConfigReference, type ConfigReferenceType, ConfigResolver, Container, ControllerMetadataStore, CronJob, CronJobRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, type ErrorSeverity, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IBuiltQuery, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterDecoratorConfig, type IChatAdapterMetadata, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatMessageDocument, type IChatMessageFile, type IChatMessageImage, type IChatMessagesPrivateFile, type IChatMessagesPublicFile, type IChatRepository, type IChatType, type ICmdChannelMessage, type ICmdReceivedMessage, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICronConfig, type ICronHandler, type ICronJobData, type ICronJobRepository, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IErrorHandlersConfig, type IErrorMonitor, type IErrorMonitorContext, type IExtractChatMessageTextOptions, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type ILockKey, type ILocker, type ILockerKey, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModelKind, type IMindsetModelRef, type IMindsetModels, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IProjectRunnerConfig, type IPropertyValidatorInfo, type IQueryAst, type IQueryCondition, type IQueryMethodMetadata, type IQueryOrderBy, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type IScheduleAt, type IScheduleDelay, type ISendWhatsAppMessageReq, type ISendWhatsAppTemplateReq, type ISocketChannelConfig, type ISocketChannelMessage, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type ISocketReceivedMessage, type IStorableData, type ITelegramChannelConfig, type ITelegramChannelMessage, type ITelegramReceivedMessage, type ITransactionAdapter, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWasenderChannelConfig, type IWasenderChannelMessageListener, type IWasenderDeviceListMetadata, type IWasenderEvent, type IWasenderMessageContent, type IWasenderMessageContextInfo, type IWasenderMessageKey, type IWasenderMessageReceivedData, type IWasenderMessageReceivedEvent, type IWasenderQrUpdatedEvent, type IWasenderReceivedMessage, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppSender, type IWhatsAppTemplateData, type IWhatsAppTemplateParameter, type IchatControllerConfig, InMemoryChatMemory, InMemoryChatRepository, InMemoryCronJobRepository, InMemoryJobRepository, InMemoryLockKey, InMemoryLocker, Job, JobRepository, JobRunner, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenRouterChatAdapter, OpenaiChatAdapter, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository,
|
|
2460
|
+
export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatAdapterMetadataStore, ChatAdapterRegistry, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatOperator, ChatRepository, ChatResolver, type ClientMap, CmdChannel, CmdChannelConfig, CmdChannelServer, type CmdClientMessage, type CmdServerMessage, type ConfigReference, type ConfigReferenceType, ConfigResolver, Container, ControllerMetadataStore, CronJob, CronJobRepository, CrudRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, type ErrorSeverity, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IBuiltQuery, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterDecoratorConfig, type IChatAdapterMetadata, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatMessageDocument, type IChatMessageFile, type IChatMessageImage, type IChatMessagesPrivateFile, type IChatMessagesPublicFile, type IChatRepository, type IChatType, type ICmdChannelEntry, type ICmdChannelHandlers, type ICmdChannelMessage, type ICmdReceivedMessage, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICronConfig, type ICronHandler, type ICronJobData, type ICronJobRepository, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IErrorHandlersConfig, type IErrorMonitor, type IErrorMonitorContext, type IExtractChatMessageTextOptions, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type ILockKey, type ILocker, type ILockerKey, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModelKind, type IMindsetModelRef, type IMindsetModels, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IProjectRunnerConfig, type IPropertyValidatorInfo, type IQueryAst, type IQueryCondition, type IQueryMethodMetadata, type IQueryOrderBy, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRepositoryAdapter, type IRepositoryConfig, type IRepositoryRuntime, type IRestControllerConfig, type IRestControllerMetadata, type IScheduleAt, type IScheduleDelay, type ISendWhatsAppMessageReq, type ISendWhatsAppTemplateReq, type ISocketChannelConfig, type ISocketChannelMessage, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type ISocketReceivedMessage, type IStorableData, type ITelegramChannelConfig, type ITelegramChannelMessage, type ITelegramReceivedMessage, type ITransactionAdapter, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWasenderChannelConfig, type IWasenderChannelMessageListener, type IWasenderDeviceListMetadata, type IWasenderEvent, type IWasenderMessageContent, type IWasenderMessageContextInfo, type IWasenderMessageKey, type IWasenderMessageReceivedData, type IWasenderMessageReceivedEvent, type IWasenderQrUpdatedEvent, type IWasenderReceivedMessage, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppSender, type IWhatsAppTemplateData, type IWhatsAppTemplateParameter, type IchatControllerConfig, InMemoryChatMemory, InMemoryChatRepository, InMemoryCronJobRepository, InMemoryJobRepository, InMemoryLockKey, InMemoryLocker, Job, JobRepository, JobRunner, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, MEMORY_ADAPTER_ID, Mapper, MemoryRepositoryAdapter, MemoryRepositoryExtension, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenRouterChatAdapter, OpenaiChatAdapter, PG_ADAPTER_ID, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJsonRepositoryAdapter, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgRepositoryBase as PgRepositoryExtension, PgTransactionAdapter, ProjectRunner, type QueryConnector, type QueryOperator, type QueryPrefix, Random, RemoteApiKeyRepository, RepositoryAdapterRegistry, RepositoryMetadataStore, type ResolvedConfig, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelMessageFile, SocketChannelReceivedMessage, SocketControllerMetadataStore, SocketServerConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, TransactionMetadataStore, UnionChatAdapter, ValidationMetadataStore, WabotChatAdapter, WasenderChannel, WasenderChannelConfig, WasenderReceiver, WasenderSender, WasenderWebhookController, WhatsAppApiSender, WhatsAppReceiverByCloudApi, WhatsAppSender, apiKeyGuard, apiKeyHandshakeGuard, bool, boolArr, buildQuerySql, chatAdapter, chatBot, chatController, chatItemTypeOptions, cmd, cmdChannelName, cmdChannelSocketPath, command, commandHandler, container, cronHandler, description, errorToPlainObject, evaluateQueryAst, extractChatMessageText, extractNumberFromWasenderMessageKey, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isChatMessageEmpty, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isRetryableError, isString, jwtGuard, jwtHandshakeGuard, max, memoryExtension, middleware, min, mindset, mindsetModule, modelInfo, num, numArr, obj, onDelete, onGet, onPost, onPut, onSocketEvent, parseQueryMethodName, pgExtension, pgStorage, query, queryExtension, readJsonFromFile, repository, resolveConfigReferences, restController, run, runChatAdapters, runChatControllers, runCmdClient, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, safeJsonParse, scoped, setupErrorHandlers, singleton, socket, socketChannelName, socketController, stopCommandHandlers, stopCronHandlers, str, strArr, telegram, telegramChannelName, transaction, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, wasender, wasenderChannelName, withPgClient, withPgTransaction, writeJsonToFile };
|
package/dist/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { Logger } from './core/logger/Logger.js';
|
|
|
10
10
|
export { Mapper } from './core/mapper/Mapper.js';
|
|
11
11
|
export { Password } from './core/password/Password.js';
|
|
12
12
|
export { Random } from './core/random/Random.js';
|
|
13
|
+
export { CrudRepository } from './core/repository/CrudRepository.js';
|
|
13
14
|
export { Storable } from './core/storable/Storable.js';
|
|
14
15
|
export { isModel } from './core/validation/metadata/@isModel.js';
|
|
15
16
|
export { isOptional } from './core/validation/metadata/@isOptional.js';
|
|
@@ -89,19 +90,25 @@ export { Mindset } from './feature/mindset/IMindset.js';
|
|
|
89
90
|
export { MindsetOperator } from './feature/mindset/MindsetOperator.js';
|
|
90
91
|
export { Money } from './feature/money/Money.js';
|
|
91
92
|
export { MoneyDto } from './feature/money/MoneyDto.js';
|
|
93
|
+
export { PG_ADAPTER_ID, pgExtension } from './feature/pg/@pgExtension.js';
|
|
92
94
|
export { PgCrudRepository } from './feature/pg/PgCrudRepository.js';
|
|
95
|
+
export { PgJsonRepositoryAdapter } from './feature/pg/PgJsonRepositoryAdapter.js';
|
|
93
96
|
export { PgLocker } from './feature/pg/PgLocker.js';
|
|
94
97
|
export { PgLockKey } from './feature/pg/PgLockKey.js';
|
|
95
|
-
export { PgRepositoryBase } from './feature/pg/PgRepositoryBase.js';
|
|
98
|
+
export { PgRepositoryBase, PgRepositoryBase as PgRepositoryExtension } from './feature/pg/PgRepositoryBase.js';
|
|
96
99
|
export { getClientMap, pgStorage } from './feature/pg/pgStorage.js';
|
|
97
|
-
export {
|
|
98
|
-
export { query } from './feature/pg/query/@query.js';
|
|
99
|
-
export { PgJsonRepository } from './feature/pg/query/PgJsonRepository.js';
|
|
100
|
-
export { PgRepositoryMetadataStore } from './feature/pg/query/PgRepositoryMetadataStore.js';
|
|
101
|
-
export { buildQuerySql } from './feature/pg/query/buildQuerySql.js';
|
|
102
|
-
export { parseQueryMethodName } from './feature/pg/query/parseQueryMethodName.js';
|
|
100
|
+
export { buildQuerySql } from './feature/pg/buildQuerySql.js';
|
|
103
101
|
export { getPgClient, withPgClient } from './feature/pg/withPgClient.js';
|
|
104
102
|
export { withPgTransaction } from './feature/pg/withPgTransaction.js';
|
|
103
|
+
export { memoryExtension } from './feature/repository/@memoryExtension.js';
|
|
104
|
+
export { query } from './feature/repository/@query.js';
|
|
105
|
+
export { queryExtension } from './feature/repository/@queryExtension.js';
|
|
106
|
+
export { repository } from './feature/repository/@repository.js';
|
|
107
|
+
export { evaluateQueryAst } from './feature/repository/evaluateQueryAst.js';
|
|
108
|
+
export { MEMORY_ADAPTER_ID, MemoryRepositoryAdapter, MemoryRepositoryExtension } from './feature/repository/MemoryRepositoryAdapter.js';
|
|
109
|
+
export { parseQueryMethodName } from './feature/repository/parseQueryMethodName.js';
|
|
110
|
+
export { RepositoryAdapterRegistry } from './feature/repository/RepositoryAdapterRegistry.js';
|
|
111
|
+
export { RepositoryMetadataStore } from './feature/repository/RepositoryMetadataStore.js';
|
|
105
112
|
export { onGet } from './feature/rest-controller/metadata/@onGet.js';
|
|
106
113
|
export { middleware } from './feature/rest-controller/metadata/@middleware.js';
|
|
107
114
|
export { onPost } from './feature/rest-controller/metadata/@onPost.js';
|
|
@@ -156,7 +163,11 @@ export { InMemoryChatRepository } from './addon/chat-bot/in-memory/InMemoryChatR
|
|
|
156
163
|
export { WabotChatAdapter } from './addon/chat-bot/wabot/WabotChatAdapter.js';
|
|
157
164
|
export { cmd } from './addon/chat-controller/cmd/@cmd.js';
|
|
158
165
|
export { CmdChannel, readJsonFromFile, writeJsonToFile } from './addon/chat-controller/cmd/CmdChannel.js';
|
|
166
|
+
export { CmdChannelConfig } from './addon/chat-controller/cmd/CmdChannelConfig.js';
|
|
167
|
+
export { CmdChannelServer } from './addon/chat-controller/cmd/CmdChannelServer.js';
|
|
159
168
|
export { cmdChannelName } from './addon/chat-controller/cmd/cmdChannelName.js';
|
|
169
|
+
export { cmdChannelSocketPath } from './addon/chat-controller/cmd/cmdChannelSocketPath.js';
|
|
170
|
+
export { runCmdClient } from './addon/chat-controller/cmd/runCmdClient.js';
|
|
160
171
|
export { socket } from './addon/chat-controller/socket/@socket.js';
|
|
161
172
|
export { SocketChannel, SocketChannelMessageFile, SocketChannelReceivedMessage } from './addon/chat-controller/socket/SocketChannel.js';
|
|
162
173
|
export { SocketChannelConfig } from './addon/chat-controller/socket/SocketChannelConfig.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wabot-dev/framework",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Framework for IA Chat Bots",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -49,7 +49,9 @@
|
|
|
49
49
|
"fmt": "prettier --write .",
|
|
50
50
|
"fmt:check": "prettier --check .",
|
|
51
51
|
"types:check": "tsc --noEmit",
|
|
52
|
-
"elia:dev": "node --import @yucacodes/ts --import ./env.mjs ./test/elia/run.ts"
|
|
52
|
+
"elia:dev": "node --import @yucacodes/ts --import ./env.mjs ./test/elia/run.ts",
|
|
53
|
+
"elia:watch": "node --watch --import @yucacodes/ts --import ./env.mjs ./test/elia/run.ts",
|
|
54
|
+
"cmd:channel": "node --import @yucacodes/ts ./test/cmd.ts"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@rollup/plugin-alias": "5.1.1",
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { container, singleton } from '../../../core/injection/index.js';
|
|
2
|
-
import { withPgClient } from '../withPgClient.js';
|
|
3
|
-
import { buildQuerySql } from './buildQuerySql.js';
|
|
4
|
-
import { parseQueryMethodName } from './parseQueryMethodName.js';
|
|
5
|
-
import { PgJsonRepository } from './PgJsonRepository.js';
|
|
6
|
-
import { PgRepositoryMetadataStore } from './PgRepositoryMetadataStore.js';
|
|
7
|
-
|
|
8
|
-
const QUERY_CACHE_KEY = Symbol('wabot:pgQueryCache');
|
|
9
|
-
function makeQueryImpl(methodName, ast) {
|
|
10
|
-
return async function (...args) {
|
|
11
|
-
let cache = this[QUERY_CACHE_KEY];
|
|
12
|
-
if (!cache) {
|
|
13
|
-
cache = new Map();
|
|
14
|
-
Object.defineProperty(this, QUERY_CACHE_KEY, { value: cache, enumerable: false });
|
|
15
|
-
}
|
|
16
|
-
let built = cache.get(methodName);
|
|
17
|
-
if (!built) {
|
|
18
|
-
built = buildQuerySql(ast, this.table, this.columns);
|
|
19
|
-
cache.set(methodName, built);
|
|
20
|
-
}
|
|
21
|
-
const params = built.buildParams(args);
|
|
22
|
-
switch (ast.prefix) {
|
|
23
|
-
case 'find': {
|
|
24
|
-
return await this.query(built.sql, params);
|
|
25
|
-
}
|
|
26
|
-
case 'findOne': {
|
|
27
|
-
const items = await this.query(built.sql, params);
|
|
28
|
-
return items[0] ?? null;
|
|
29
|
-
}
|
|
30
|
-
case 'count': {
|
|
31
|
-
return await withPgClient(this.pool, async (client) => {
|
|
32
|
-
await this.ensureTable(client);
|
|
33
|
-
const result = await client.query(built.sql, params);
|
|
34
|
-
return result.rows[0]?.count ?? 0;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
case 'exists': {
|
|
38
|
-
return await withPgClient(this.pool, async (client) => {
|
|
39
|
-
await this.ensureTable(client);
|
|
40
|
-
const result = await client.query(built.sql, params);
|
|
41
|
-
return Boolean(result.rows[0]?.exists);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
case 'delete': {
|
|
45
|
-
await this.exec(built.sql, params);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function pgJsonRepository(config) {
|
|
52
|
-
return function (target) {
|
|
53
|
-
if (target !== PgJsonRepository && !(target.prototype instanceof PgJsonRepository)) {
|
|
54
|
-
throw new Error(`@pgJsonRepository: ${target.name} must extend PgJsonRepository`);
|
|
55
|
-
}
|
|
56
|
-
const store = container.resolve(PgRepositoryMetadataStore);
|
|
57
|
-
store.saveRepositoryConfig(target, config);
|
|
58
|
-
const queryMethods = store.getQueryMethods(target);
|
|
59
|
-
for (const meta of queryMethods) {
|
|
60
|
-
if (Object.prototype.hasOwnProperty.call(target.prototype, meta.functionName)) {
|
|
61
|
-
const existing = target.prototype[meta.functionName];
|
|
62
|
-
if (typeof existing === 'function') {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const ast = parseQueryMethodName(meta.functionName);
|
|
67
|
-
target.prototype[meta.functionName] = makeQueryImpl(meta.functionName, ast);
|
|
68
|
-
}
|
|
69
|
-
singleton()(target);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { pgJsonRepository };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { container } from '../../../core/injection/index.js';
|
|
2
|
-
import { PgRepositoryMetadataStore } from './PgRepositoryMetadataStore.js';
|
|
3
|
-
|
|
4
|
-
function query() {
|
|
5
|
-
return function (target, propertyKey) {
|
|
6
|
-
const store = container.resolve(PgRepositoryMetadataStore);
|
|
7
|
-
store.saveQueryMethodMetadata({
|
|
8
|
-
repositoryConstructor: target.constructor,
|
|
9
|
-
functionName: propertyKey.toString(),
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { query };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { Pool } from 'pg';
|
|
3
|
-
import { injectable, container } from '../../../core/injection/index.js';
|
|
4
|
-
import { PgCrudRepository } from '../PgCrudRepository.js';
|
|
5
|
-
import { PgRepositoryMetadataStore } from './PgRepositoryMetadataStore.js';
|
|
6
|
-
|
|
7
|
-
let PgJsonRepository = class PgJsonRepository extends PgCrudRepository {
|
|
8
|
-
constructor(pool) {
|
|
9
|
-
const ctor = new.target;
|
|
10
|
-
const store = container.resolve(PgRepositoryMetadataStore);
|
|
11
|
-
const config = store.getRepositoryConfig(ctor);
|
|
12
|
-
if (!config) {
|
|
13
|
-
throw new Error(`${ctor.name} must be decorated with @pgJsonRepository`);
|
|
14
|
-
}
|
|
15
|
-
super(pool, config);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
PgJsonRepository = __decorate([
|
|
19
|
-
injectable(),
|
|
20
|
-
__metadata("design:paramtypes", [Pool])
|
|
21
|
-
], PgJsonRepository);
|
|
22
|
-
|
|
23
|
-
export { PgJsonRepository };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { __decorate } from 'tslib';
|
|
2
|
-
import { singleton } from '../../../core/injection/index.js';
|
|
3
|
-
|
|
4
|
-
let PgRepositoryMetadataStore = class PgRepositoryMetadataStore {
|
|
5
|
-
queryMethods = new Map();
|
|
6
|
-
repositoryConfigs = new Map();
|
|
7
|
-
saveQueryMethodMetadata(metadata) {
|
|
8
|
-
let perClass = this.queryMethods.get(metadata.repositoryConstructor);
|
|
9
|
-
if (!perClass) {
|
|
10
|
-
perClass = new Map();
|
|
11
|
-
this.queryMethods.set(metadata.repositoryConstructor, perClass);
|
|
12
|
-
}
|
|
13
|
-
perClass.set(metadata.functionName, metadata);
|
|
14
|
-
}
|
|
15
|
-
saveRepositoryConfig(ctor, config) {
|
|
16
|
-
this.repositoryConfigs.set(ctor, config);
|
|
17
|
-
}
|
|
18
|
-
getRepositoryConfig(ctor) {
|
|
19
|
-
return this.repositoryConfigs.get(ctor);
|
|
20
|
-
}
|
|
21
|
-
getQueryMethods(ctor) {
|
|
22
|
-
const collected = new Map();
|
|
23
|
-
const hierarchy = [];
|
|
24
|
-
let proto = ctor.prototype;
|
|
25
|
-
while (proto && proto.constructor !== Object) {
|
|
26
|
-
hierarchy.unshift(proto.constructor);
|
|
27
|
-
proto = Object.getPrototypeOf(proto);
|
|
28
|
-
}
|
|
29
|
-
for (const cls of hierarchy) {
|
|
30
|
-
const perClass = this.queryMethods.get(cls);
|
|
31
|
-
if (perClass) {
|
|
32
|
-
for (const [name, meta] of perClass) {
|
|
33
|
-
collected.set(name, meta);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return [...collected.values()];
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
PgRepositoryMetadataStore = __decorate([
|
|
41
|
-
singleton()
|
|
42
|
-
], PgRepositoryMetadataStore);
|
|
43
|
-
|
|
44
|
-
export { PgRepositoryMetadataStore };
|
|
File without changes
|
|
File without changes
|