@wabot-dev/framework 0.9.2 → 0.9.5
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 +33 -10
- 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 +195 -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[]>;
|
|
@@ -1283,6 +1294,10 @@ declare class PgRepositoryBase<P extends Entity<IEntityData>> {
|
|
|
1283
1294
|
protected ensureColumns(client: PoolClient): Promise<void>;
|
|
1284
1295
|
}
|
|
1285
1296
|
|
|
1297
|
+
declare const PG_ADAPTER_ID: unique symbol;
|
|
1298
|
+
type ExtensionOf$1<R> = R extends CrudRepository<any, infer Ext> ? Ext : never;
|
|
1299
|
+
declare function pgExtension<R extends CrudRepository<any, any>>(repositoryClass: IConstructor<R>): <E extends PgRepositoryBase<any> & ExtensionOf$1<R>>(target: IConstructor<E>) => void;
|
|
1300
|
+
|
|
1286
1301
|
declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
1287
1302
|
protected readonly config: IPgRepositoryConfig<P>;
|
|
1288
1303
|
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
@@ -1295,6 +1310,116 @@ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgReposito
|
|
|
1295
1310
|
delete(item: P): Promise<void>;
|
|
1296
1311
|
}
|
|
1297
1312
|
|
|
1313
|
+
interface IRepositoryConfig<P extends Entity<IEntityData>> {
|
|
1314
|
+
table: string;
|
|
1315
|
+
constructor: IConstructor<P>;
|
|
1316
|
+
schema?: string;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
type QueryPrefix = 'find' | 'findOne' | 'count' | 'exists' | 'delete';
|
|
1320
|
+
type QueryOperator = 'Equals' | 'Not' | 'Like' | 'NotLike' | 'In' | 'NotIn' | 'Gt' | 'Gte' | 'Lt' | 'Lte' | 'IsNull' | 'IsNotNull';
|
|
1321
|
+
type QueryConnector = 'And' | 'Or';
|
|
1322
|
+
interface IQueryCondition {
|
|
1323
|
+
field: string;
|
|
1324
|
+
operator: QueryOperator;
|
|
1325
|
+
connector?: QueryConnector;
|
|
1326
|
+
}
|
|
1327
|
+
interface IQueryOrderBy {
|
|
1328
|
+
field: string;
|
|
1329
|
+
direction: 'ASC' | 'DESC';
|
|
1330
|
+
}
|
|
1331
|
+
interface IQueryAst {
|
|
1332
|
+
prefix: QueryPrefix;
|
|
1333
|
+
conditions: IQueryCondition[];
|
|
1334
|
+
orderBy: IQueryOrderBy[];
|
|
1335
|
+
limit?: number;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
interface IRepositoryRuntime<P extends Entity<IEntityData>> {
|
|
1339
|
+
find(id: string): Promise<P | null>;
|
|
1340
|
+
findOrThrow(id: string): Promise<P>;
|
|
1341
|
+
findByIds(ids: string[]): Promise<P[]>;
|
|
1342
|
+
findAll(): Promise<P[]>;
|
|
1343
|
+
create(item: P): Promise<void>;
|
|
1344
|
+
update(item: P): Promise<void>;
|
|
1345
|
+
delete(item: P): Promise<void>;
|
|
1346
|
+
runQuery(ast: IQueryAst, args: unknown[]): Promise<P[]>;
|
|
1347
|
+
runCount(ast: IQueryAst, args: unknown[]): Promise<number>;
|
|
1348
|
+
runExists(ast: IQueryAst, args: unknown[]): Promise<boolean>;
|
|
1349
|
+
runDelete(ast: IQueryAst, args: unknown[]): Promise<void>;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
interface IRepositoryAdapter {
|
|
1353
|
+
readonly id: symbol;
|
|
1354
|
+
build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
|
|
1355
|
+
buildExtension?<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
declare class MemoryRepositoryExtension<P extends Entity<IEntityData>> {
|
|
1359
|
+
protected readonly items: Map<string, P>;
|
|
1360
|
+
protected readonly config: IRepositoryConfig<P>;
|
|
1361
|
+
constructor(items: Map<string, P>, config: IRepositoryConfig<P>);
|
|
1362
|
+
protected clone(item: P): P;
|
|
1363
|
+
}
|
|
1364
|
+
declare const MEMORY_ADAPTER_ID: unique symbol;
|
|
1365
|
+
declare class MemoryRepositoryAdapter implements IRepositoryAdapter {
|
|
1366
|
+
readonly id: symbol;
|
|
1367
|
+
private stores;
|
|
1368
|
+
private getStore;
|
|
1369
|
+
build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
|
|
1370
|
+
buildExtension<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
type ExtensionOf<R> = R extends CrudRepository<any, infer Ext> ? Ext : never;
|
|
1374
|
+
declare function memoryExtension<R extends CrudRepository<any, any>>(repositoryClass: IConstructor<R>): <E extends MemoryRepositoryExtension<any> & ExtensionOf<R>>(target: IConstructor<E>) => void;
|
|
1375
|
+
|
|
1376
|
+
declare function query(): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
1377
|
+
|
|
1378
|
+
declare function queryExtension(): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
1379
|
+
|
|
1380
|
+
declare function repository<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): (target: IConstructor<any>) => void;
|
|
1381
|
+
|
|
1382
|
+
declare function evaluateQueryAst<P extends Entity<IEntityData>>(items: Iterable<P>, ast: IQueryAst, args: unknown[]): P[];
|
|
1383
|
+
|
|
1384
|
+
declare function parseQueryMethodName(name: string): IQueryAst;
|
|
1385
|
+
|
|
1386
|
+
declare class RepositoryAdapterRegistry {
|
|
1387
|
+
private adapter;
|
|
1388
|
+
setDefault(adapter: IRepositoryAdapter): void;
|
|
1389
|
+
getDefault(): IRepositoryAdapter;
|
|
1390
|
+
hasDefault(): boolean;
|
|
1391
|
+
clear(): void;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
interface IQueryMethodMetadata {
|
|
1395
|
+
repositoryConstructor: IConstructor<any>;
|
|
1396
|
+
functionName: string;
|
|
1397
|
+
}
|
|
1398
|
+
declare class RepositoryMetadataStore {
|
|
1399
|
+
private queryMethods;
|
|
1400
|
+
private extensionMethods;
|
|
1401
|
+
private repositoryConfigs;
|
|
1402
|
+
private extensions;
|
|
1403
|
+
saveQueryMethodMetadata(metadata: IQueryMethodMetadata): void;
|
|
1404
|
+
saveExtensionMethodMetadata(metadata: IQueryMethodMetadata): void;
|
|
1405
|
+
saveRepositoryConfig<P extends Entity<IEntityData>>(ctor: IConstructor<any>, config: IRepositoryConfig<P>): void;
|
|
1406
|
+
getRepositoryConfig(ctor: IConstructor<any>): IRepositoryConfig<any> | undefined;
|
|
1407
|
+
getQueryMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
|
|
1408
|
+
getExtensionMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
|
|
1409
|
+
private collectMethodsFromHierarchy;
|
|
1410
|
+
saveExtension(repositoryConstructor: IConstructor<any>, adapterId: symbol, extensionConstructor: IConstructor<any>): void;
|
|
1411
|
+
getExtension(ctor: IConstructor<any>, adapterId: symbol): IConstructor<any> | undefined;
|
|
1412
|
+
validateExtensionsRegistered(adapterId: symbol): void;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
declare class PgJsonRepositoryAdapter implements IRepositoryAdapter {
|
|
1416
|
+
private readonly pool;
|
|
1417
|
+
readonly id: symbol;
|
|
1418
|
+
constructor(pool: Pool);
|
|
1419
|
+
build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
|
|
1420
|
+
buildExtension<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1298
1423
|
declare class PgLocker implements ILocker {
|
|
1299
1424
|
private readonly pool;
|
|
1300
1425
|
constructor(pool: Pool);
|
|
@@ -1320,46 +1445,6 @@ declare const pgStorage: AsyncLocalStorage<ClientMap>;
|
|
|
1320
1445
|
*/
|
|
1321
1446
|
declare function getClientMap(): ClientMap;
|
|
1322
1447
|
|
|
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
1448
|
interface IBuiltQuery {
|
|
1364
1449
|
sql: string;
|
|
1365
1450
|
argCount: number;
|
|
@@ -1367,8 +1452,6 @@ interface IBuiltQuery {
|
|
|
1367
1452
|
}
|
|
1368
1453
|
declare function buildQuerySql(ast: IQueryAst, table: string, columns: string): IBuiltQuery;
|
|
1369
1454
|
|
|
1370
|
-
declare function parseQueryMethodName(name: string): IQueryAst;
|
|
1371
|
-
|
|
1372
1455
|
/**
|
|
1373
1456
|
* Runs a function with a shared Postgres client for the given pool.
|
|
1374
1457
|
* Reuses the client if already present in the async context.
|
|
@@ -1872,6 +1955,34 @@ declare class WabotChatAdapter implements IChatAdapter {
|
|
|
1872
1955
|
|
|
1873
1956
|
declare function cmd(): (target: object, propertyKey: string | symbol) => void;
|
|
1874
1957
|
|
|
1958
|
+
declare class CmdChannelConfig {
|
|
1959
|
+
readonly route: string;
|
|
1960
|
+
constructor(route: string);
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
interface ICmdChannelHandlers {
|
|
1964
|
+
onMessage: (text: string, reply: (response: {
|
|
1965
|
+
senderName?: string;
|
|
1966
|
+
text: string;
|
|
1967
|
+
}) => void) => Promise<void> | void;
|
|
1968
|
+
}
|
|
1969
|
+
declare class CmdChannelServer {
|
|
1970
|
+
private server;
|
|
1971
|
+
private channels;
|
|
1972
|
+
private client;
|
|
1973
|
+
private buffer;
|
|
1974
|
+
private activeRoute;
|
|
1975
|
+
register(route: string, handlers: ICmdChannelHandlers): void;
|
|
1976
|
+
unregister(route: string): void;
|
|
1977
|
+
private ensureStarted;
|
|
1978
|
+
private shutdown;
|
|
1979
|
+
private handleConnection;
|
|
1980
|
+
private handleData;
|
|
1981
|
+
private handleMessage;
|
|
1982
|
+
private sendToClient;
|
|
1983
|
+
private send;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1875
1986
|
declare const cmdChannelName: "CmdChannel";
|
|
1876
1987
|
|
|
1877
1988
|
interface ICmdReceivedMessage extends IReceivedMessage {
|
|
@@ -1885,18 +1996,55 @@ interface ICmdChannelMessage extends ICmdReceivedMessage {
|
|
|
1885
1996
|
|
|
1886
1997
|
declare class CmdChannel implements IChatChannel {
|
|
1887
1998
|
private auth;
|
|
1888
|
-
private
|
|
1889
|
-
private
|
|
1999
|
+
private server;
|
|
2000
|
+
private config;
|
|
1890
2001
|
static channelName: "CmdChannel";
|
|
2002
|
+
private chatId;
|
|
1891
2003
|
private callBack;
|
|
1892
|
-
constructor(auth: Auth<any
|
|
2004
|
+
constructor(auth: Auth<any>, server: CmdChannelServer, config: CmdChannelConfig);
|
|
1893
2005
|
listen(callback: (message: ICmdChannelMessage) => Promise<void>): void;
|
|
1894
2006
|
disconnect(): void;
|
|
1895
2007
|
connect(): void;
|
|
2008
|
+
private routeSlug;
|
|
2009
|
+
private chatIdPath;
|
|
2010
|
+
private authInfoPath;
|
|
2011
|
+
private ensureChatId;
|
|
2012
|
+
private ensureAuthLoaded;
|
|
1896
2013
|
}
|
|
1897
2014
|
declare function writeJsonToFile<T>(filename: string, data: T): void;
|
|
1898
2015
|
declare function readJsonFromFile<T>(filename: string): T | null;
|
|
1899
2016
|
|
|
2017
|
+
declare function cmdChannelSocketPath(): string;
|
|
2018
|
+
|
|
2019
|
+
interface ICmdChannelEntry {
|
|
2020
|
+
route: string;
|
|
2021
|
+
}
|
|
2022
|
+
type CmdClientMessage = {
|
|
2023
|
+
type: 'hello';
|
|
2024
|
+
} | {
|
|
2025
|
+
type: 'select';
|
|
2026
|
+
route: string;
|
|
2027
|
+
} | {
|
|
2028
|
+
type: 'message';
|
|
2029
|
+
text: string;
|
|
2030
|
+
};
|
|
2031
|
+
type CmdServerMessage = {
|
|
2032
|
+
type: 'channels';
|
|
2033
|
+
list: ICmdChannelEntry[];
|
|
2034
|
+
} | {
|
|
2035
|
+
type: 'selected';
|
|
2036
|
+
route: string;
|
|
2037
|
+
} | {
|
|
2038
|
+
type: 'reply';
|
|
2039
|
+
senderName?: string;
|
|
2040
|
+
text: string;
|
|
2041
|
+
} | {
|
|
2042
|
+
type: 'error';
|
|
2043
|
+
message: string;
|
|
2044
|
+
};
|
|
2045
|
+
|
|
2046
|
+
declare function runCmdClient(): void;
|
|
2047
|
+
|
|
1900
2048
|
interface ISocketChannelConfig {
|
|
1901
2049
|
namespace: string | ConfigReference<string>;
|
|
1902
2050
|
handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
|
|
@@ -2307,4 +2455,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
|
2307
2455
|
new (): {};
|
|
2308
2456
|
};
|
|
2309
2457
|
|
|
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,
|
|
2458
|
+
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.5",
|
|
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
|