mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: event emitter + misc typings
This commit is contained in:
parent
c722b85d5d
commit
acc6fcaa88
8134
api/package-lock.json
generated
8134
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,8 @@
|
|||||||
"build:plugins": "mkdir -p src/.hexabot/extensions/plugins && find node_modules/ -name 'hexabot-plugin-*' -exec cp -R {} src/.hexabot/extensions/plugins/ \\;",
|
"build:plugins": "mkdir -p src/.hexabot/extensions/plugins && find node_modules/ -name 'hexabot-plugin-*' -exec cp -R {} src/.hexabot/extensions/plugins/ \\;",
|
||||||
"build:extensions": "npm run build:channels && npm run build:helpers && npm run build:plugins",
|
"build:extensions": "npm run build:channels && npm run build:helpers && npm run build:plugins",
|
||||||
"build:prepare": "npm run build:clean && npm run build:extensions",
|
"build:prepare": "npm run build:clean && npm run build:extensions",
|
||||||
"build": "npm run build:prepare && nest build",
|
"build": "npm run build:prepare && nest build && npm run copy-types",
|
||||||
|
"copy-types": "cp -R types dist/types",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"libs/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"libs/**/*.ts\"",
|
||||||
"start": "nest start",
|
"start": "nest start",
|
||||||
"doc": "npx @compodoc/compodoc --hideGenerator -p tsconfig.doc.json -s -r 9003 -w",
|
"doc": "npx @compodoc/compodoc --hideGenerator -p tsconfig.doc.json -s -r 9003 -w",
|
||||||
@ -59,6 +60,7 @@
|
|||||||
"@tekuconcept/nestjs-csrf": "^1.1.0",
|
"@tekuconcept/nestjs-csrf": "^1.1.0",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"cache-manager": "^5.3.2",
|
"cache-manager": "^5.3.2",
|
||||||
|
"class-transformer": "^0.5.1",
|
||||||
"connect-mongo": "^5.1.0",
|
"connect-mongo": "^5.1.0",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
@ -172,4 +174,4 @@
|
|||||||
"@/(.*)": "<rootDir>/$1"
|
"@/(.*)": "<rootDir>/$1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,4 +136,4 @@ const i18nOptions: I18nOptions = {
|
|||||||
AppService,
|
AppService,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class HexabotModule {}
|
||||||
|
9
api/src/index.ts
Normal file
9
api/src/index.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2024 Hexastack. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from './app.module';
|
@ -18,7 +18,7 @@ moduleAlias.addAliases({
|
|||||||
'@': __dirname,
|
'@': __dirname,
|
||||||
});
|
});
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { HexabotModule } from './app.module';
|
||||||
import { config } from './config';
|
import { config } from './config';
|
||||||
import { LoggerService } from './logger/logger.service';
|
import { LoggerService } from './logger/logger.service';
|
||||||
import { seedDatabase } from './seeder';
|
import { seedDatabase } from './seeder';
|
||||||
@ -30,7 +30,7 @@ async function bootstrap() {
|
|||||||
const isProduction = config.env.toLowerCase().includes('prod');
|
const isProduction = config.env.toLowerCase().includes('prod');
|
||||||
|
|
||||||
await resolveDynamicProviders();
|
await resolveDynamicProviders();
|
||||||
const app = await NestFactory.create(AppModule, {
|
const app = await NestFactory.create(HexabotModule, {
|
||||||
bodyParser: false,
|
bodyParser: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { DeleteResult } from '@/utils/generics/base-repository';
|
||||||
import { BaseService } from '@/utils/generics/base-service';
|
import { BaseService } from '@/utils/generics/base-service';
|
||||||
|
|
||||||
import { NlpValueCreateDto, NlpValueUpdateDto } from '../dto/nlp-value.dto';
|
import { NlpValueCreateDto, NlpValueUpdateDto } from '../dto/nlp-value.dto';
|
||||||
@ -43,7 +44,7 @@ export class NlpValueService extends BaseService<
|
|||||||
*
|
*
|
||||||
* @returns A promise that resolves when the deletion is complete.
|
* @returns A promise that resolves when the deletion is complete.
|
||||||
*/
|
*/
|
||||||
async deleteCascadeOne(id: string) {
|
async deleteCascadeOne(id: string): Promise<DeleteResult> {
|
||||||
return await this.repository.deleteOne(id);
|
return await this.repository.deleteOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
|
|||||||
import { InjectModel } from '@nestjs/mongoose';
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
import { Model as MongooseModel } from 'mongoose';
|
import { Model as MongooseModel } from 'mongoose';
|
||||||
|
|
||||||
import { BaseRepository } from '@/utils/generics/base-repository';
|
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Model,
|
Model,
|
||||||
@ -43,7 +43,7 @@ export class ModelRepository extends BaseRepository<
|
|||||||
*
|
*
|
||||||
* @returns The result of the delete operation.
|
* @returns The result of the delete operation.
|
||||||
*/
|
*/
|
||||||
async deleteOne(id: string) {
|
async deleteOne(id: string): Promise<DeleteResult> {
|
||||||
const result = await this.model.deleteOne({ _id: id }).exec();
|
const result = await this.model.deleteOne({ _id: id }).exec();
|
||||||
if (result.deletedCount > 0) {
|
if (result.deletedCount > 0) {
|
||||||
await this.permissionModel.deleteMany({ model: id });
|
await this.permissionModel.deleteMany({ model: id });
|
||||||
|
@ -11,7 +11,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
|
|||||||
import { InjectModel } from '@nestjs/mongoose';
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
import { Model } from 'mongoose';
|
import { Model } from 'mongoose';
|
||||||
|
|
||||||
import { BaseRepository } from '@/utils/generics/base-repository';
|
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
||||||
|
|
||||||
import { Permission } from '../schemas/permission.schema';
|
import { Permission } from '../schemas/permission.schema';
|
||||||
import {
|
import {
|
||||||
@ -43,7 +43,7 @@ export class RoleRepository extends BaseRepository<
|
|||||||
*
|
*
|
||||||
* @returns The result of the delete operation.
|
* @returns The result of the delete operation.
|
||||||
*/
|
*/
|
||||||
async deleteOne(id: string) {
|
async deleteOne(id: string): Promise<DeleteResult> {
|
||||||
const result = await this.model.deleteOne({ _id: id }).exec();
|
const result = await this.model.deleteOne({ _id: id }).exec();
|
||||||
if (result.deletedCount > 0) {
|
if (result.deletedCount > 0) {
|
||||||
await this.permissionModel.deleteMany({ role: id });
|
await this.permissionModel.deleteMany({ role: id });
|
||||||
|
@ -18,15 +18,4 @@ export class ModelService extends BaseService<Model, ModelPopulate, ModelFull> {
|
|||||||
constructor(readonly repository: ModelRepository) {
|
constructor(readonly repository: ModelRepository) {
|
||||||
super(repository);
|
super(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a Model entity by its unique identifier.
|
|
||||||
*
|
|
||||||
* @param id - The unique identifier of the Model entity to delete.
|
|
||||||
*
|
|
||||||
* @returns A promise that resolves to the result of the deletion operation.
|
|
||||||
*/
|
|
||||||
async deleteOne(id: string) {
|
|
||||||
return await this.repository.deleteOne(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -340,13 +340,13 @@ export abstract class BaseRepository<
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteOne(criteria: string | TFilterQuery<T>) {
|
async deleteOne(criteria: string | TFilterQuery<T>): Promise<DeleteResult> {
|
||||||
return await this.model
|
return await this.model
|
||||||
.deleteOne(typeof criteria === 'string' ? { _id: criteria } : criteria)
|
.deleteOne(typeof criteria === 'string' ? { _id: criteria } : criteria)
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteMany(criteria: TFilterQuery<T>) {
|
async deleteMany(criteria: TFilterQuery<T>): Promise<DeleteResult> {
|
||||||
return await this.model.deleteMany(criteria);
|
return await this.model.deleteMany(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,14 +10,14 @@ import { INestApplication } from '@nestjs/common';
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
|
|
||||||
import { AppModule } from './../src/app.module';
|
import { HexabotModule } from './../src/app.module';
|
||||||
|
|
||||||
describe('AppController (e2e)', () => {
|
describe('AppController (e2e)', () => {
|
||||||
let app: INestApplication;
|
let app: INestApplication;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
imports: [AppModule],
|
imports: [HexabotModule],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
app = moduleFixture.createNestApplication();
|
app = moduleFixture.createNestApplication();
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
|
||||||
"src/global.d.ts",
|
|
||||||
"types/**/*.d.ts",
|
"types/**/*.d.ts",
|
||||||
|
"src/global.d.ts",
|
||||||
|
"src/**/*.ts",
|
||||||
"src/**/*.json",
|
"src/**/*.json",
|
||||||
"test/**/*.ts",
|
"test/**/*.ts",
|
||||||
"src/.hexabot/**/*.ts",
|
"src/.hexabot/**/*.ts",
|
||||||
|
@ -19,6 +19,7 @@ import { type Socket } from 'socket.io';
|
|||||||
import { type BotStats } from '@/analytics/schemas/bot-stats.schema';
|
import { type BotStats } from '@/analytics/schemas/bot-stats.schema';
|
||||||
import { type Attachment } from '@/attachment/schemas/attachment.schema';
|
import { type Attachment } from '@/attachment/schemas/attachment.schema';
|
||||||
import type EventWrapper from '@/channel/lib/EventWrapper';
|
import type EventWrapper from '@/channel/lib/EventWrapper';
|
||||||
|
import { type SubscriberUpdateDto } from '@/chat/dto/subscriber.dto';
|
||||||
import type { Block, BlockFull } from '@/chat/schemas/block.schema';
|
import type { Block, BlockFull } from '@/chat/schemas/block.schema';
|
||||||
import { type Category } from '@/chat/schemas/category.schema';
|
import { type Category } from '@/chat/schemas/category.schema';
|
||||||
import { type ContextVar } from '@/chat/schemas/context-var.schema';
|
import { type ContextVar } from '@/chat/schemas/context-var.schema';
|
||||||
@ -49,21 +50,19 @@ import { type Role } from '@/user/schemas/role.schema';
|
|||||||
import { type User } from '@/user/schemas/user.schema';
|
import { type User } from '@/user/schemas/user.schema';
|
||||||
import { EHook, type DeleteResult } from '@/utils/generics/base-repository';
|
import { EHook, type DeleteResult } from '@/utils/generics/base-repository';
|
||||||
|
|
||||||
import { type SubscriberUpdateDto } from './chat/dto/subscriber.dto';
|
|
||||||
|
|
||||||
import '@nestjs/event-emitter';
|
import '@nestjs/event-emitter';
|
||||||
/**
|
/**
|
||||||
* @description Module declaration that extends the NestJS EventEmitter with custom event types and methods.
|
* @description Module declaration that extends the NestJS EventEmitter with custom event types and methods.
|
||||||
*/
|
*/
|
||||||
declare module '@nestjs/event-emitter' {
|
declare module '@nestjs/event-emitter' {
|
||||||
interface TDefinition<S, O = object> {
|
export interface TDefinition<S, O = object> {
|
||||||
schema: S;
|
schema: S;
|
||||||
operations: O;
|
operations: O;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IHookExtensionsOperationMap {}
|
export interface IHookExtensionsOperationMap {}
|
||||||
|
|
||||||
interface IHookSettingsGroupLabelOperationMap {
|
export interface IHookSettingsGroupLabelOperationMap {
|
||||||
chatbot_settings: TDefinition<
|
chatbot_settings: TDefinition<
|
||||||
object,
|
object,
|
||||||
{
|
{
|
||||||
@ -99,7 +98,7 @@ declare module '@nestjs/event-emitter' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* custom hooks */
|
/* custom hooks */
|
||||||
interface IHookOperationMap
|
export interface IHookOperationMap
|
||||||
extends IHookSettingsGroupLabelOperationMap,
|
extends IHookSettingsGroupLabelOperationMap,
|
||||||
IHookExtensionsOperationMap {
|
IHookExtensionsOperationMap {
|
||||||
analytics: TDefinition<
|
analytics: TDefinition<
|
||||||
@ -133,7 +132,7 @@ declare module '@nestjs/event-emitter' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* hooks */
|
/* hooks */
|
||||||
interface IHookEntityOperationMap extends IHookOperationMap {
|
export interface IHookEntityOperationMap extends IHookOperationMap {
|
||||||
stats: TDefinition<BotStats, { entry: string }>;
|
stats: TDefinition<BotStats, { entry: string }>;
|
||||||
attachment: TDefinition<Attachment>;
|
attachment: TDefinition<Attachment>;
|
||||||
block: TDefinition<Block>;
|
block: TDefinition<Block>;
|
||||||
@ -178,7 +177,7 @@ declare module '@nestjs/event-emitter' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* entities hooks having schemas */
|
/* entities hooks having schemas */
|
||||||
type IHookEntities = keyof Omit<
|
export type IHookEntities = keyof Omit<
|
||||||
IHookEntityOperationMap,
|
IHookEntityOperationMap,
|
||||||
keyof IHookOperationMap
|
keyof IHookOperationMap
|
||||||
>;
|
>;
|
||||||
@ -186,14 +185,18 @@ declare module '@nestjs/event-emitter' {
|
|||||||
/**
|
/**
|
||||||
* @description A constrained string type that allows specific string values while preserving type safety.
|
* @description A constrained string type that allows specific string values while preserving type safety.
|
||||||
*/
|
*/
|
||||||
type ConstrainedString = string & Record<never, never>;
|
export type ConstrainedString = string & Record<never, never>;
|
||||||
type EventNamespaces = keyof IHookEntityOperationMap;
|
|
||||||
|
export type EventNamespaces = keyof IHookEntityOperationMap;
|
||||||
|
|
||||||
/* pre hooks */
|
/* pre hooks */
|
||||||
type TPreValidate<T> = THydratedDocument<T>;
|
export type TPreValidate<T> = THydratedDocument<T>;
|
||||||
type TPreCreate<T> = THydratedDocument<T>;
|
|
||||||
type TPreUpdate<T> = TFilterQuery<T> & object;
|
export type TPreCreate<T> = THydratedDocument<T>;
|
||||||
type TPreDelete<T> = Query<
|
|
||||||
|
export type TPreUpdate<T> = TFilterQuery<T> & object;
|
||||||
|
|
||||||
|
export type TPreDelete<T> = Query<
|
||||||
DeleteResult,
|
DeleteResult,
|
||||||
Document<T>,
|
Document<T>,
|
||||||
unknown,
|
unknown,
|
||||||
@ -201,50 +204,56 @@ declare module '@nestjs/event-emitter' {
|
|||||||
'deleteOne',
|
'deleteOne',
|
||||||
Record<string, never>
|
Record<string, never>
|
||||||
>;
|
>;
|
||||||
type TPreUnion<T> =
|
|
||||||
|
export type TPreUnion<T> =
|
||||||
| TPreValidate<T>
|
| TPreValidate<T>
|
||||||
| TPreCreate<T>
|
| TPreCreate<T>
|
||||||
| TPreUpdate<T>
|
| TPreUpdate<T>
|
||||||
| TPreDelete<T>;
|
| TPreDelete<T>;
|
||||||
|
|
||||||
/* post hooks */
|
/* post hooks */
|
||||||
type TPostValidate<T> = THydratedDocument<T>;
|
export type TPostValidate<T> = THydratedDocument<T>;
|
||||||
type TPostCreate<T> = THydratedDocument<T>;
|
|
||||||
type TPostUpdate<T> = THydratedDocument<T>;
|
export type TPostCreate<T> = THydratedDocument<T>;
|
||||||
type TPostDelete = DeleteResult;
|
|
||||||
type TPostUnion<T> =
|
export type TPostUpdate<T> = THydratedDocument<T>;
|
||||||
|
|
||||||
|
export type TPostDelete = DeleteResult;
|
||||||
|
|
||||||
|
export type TPostUnion<T> =
|
||||||
| TPostValidate<T>
|
| TPostValidate<T>
|
||||||
| TPostCreate<T>
|
| TPostCreate<T>
|
||||||
| TPostUpdate<T>
|
| TPostUpdate<T>
|
||||||
| TPostDelete;
|
| TPostDelete;
|
||||||
|
|
||||||
type TCustomOperations<E extends keyof IHookEntityOperationMap> =
|
export type TCustomOperations<E extends keyof IHookEntityOperationMap> =
|
||||||
IHookEntityOperationMap[E]['operations'][keyof IHookEntityOperationMap[E]['operations']];
|
IHookEntityOperationMap[E]['operations'][keyof IHookEntityOperationMap[E]['operations']];
|
||||||
|
|
||||||
/* union hooks */
|
/* union hooks */
|
||||||
type TUnion<G, E> = E extends keyof IHookEntityOperationMap
|
export type TUnion<G, E> = E extends keyof IHookEntityOperationMap
|
||||||
? E extends keyof IHookOperationMap
|
? E extends keyof IHookOperationMap
|
||||||
? TCustomOperations<E>
|
? TCustomOperations<E>
|
||||||
: TPreUnion<G> | TPostUnion<G> | TCustomOperations<E>
|
: TPreUnion<G> | TPostUnion<G> | TCustomOperations<E>
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
/* Normalized hook */
|
/* Normalized hook */
|
||||||
enum EHookPrefix {
|
export enum EHookPrefix {
|
||||||
pre = 'pre',
|
pre = 'pre',
|
||||||
post = 'post',
|
post = 'post',
|
||||||
}
|
}
|
||||||
|
|
||||||
type TCompatibleHook<
|
export type TCompatibleHook<
|
||||||
P extends `${EHookPrefix}`,
|
P extends `${EHookPrefix}`,
|
||||||
T = `${EHook}`,
|
T = `${EHook}`,
|
||||||
> = T extends `${P}${infer I}` ? `${P}${I}` : never;
|
> = T extends `${P}${infer I}` ? `${P}${I}` : never;
|
||||||
|
|
||||||
type TPreHook = TCompatibleHook<EHookPrefix.pre>;
|
export type TPreHook = TCompatibleHook<EHookPrefix.pre>;
|
||||||
type TPostHook = TCompatibleHook<EHookPrefix.post>;
|
|
||||||
|
|
||||||
type TNormalizedEvents = '*' | TPreHook | TPostHook;
|
export type TPostHook = TCompatibleHook<EHookPrefix.post>;
|
||||||
|
|
||||||
type TNormalizedHooks<
|
export type TNormalizedEvents = '*' | TPreHook | TPostHook;
|
||||||
|
|
||||||
|
export type TNormalizedHooks<
|
||||||
E extends keyof IHookEntityOperationMap,
|
E extends keyof IHookEntityOperationMap,
|
||||||
T = IHookEntityOperationMap[E]['schema'],
|
T = IHookEntityOperationMap[E]['schema'],
|
||||||
> =
|
> =
|
||||||
@ -273,18 +282,18 @@ declare module '@nestjs/event-emitter' {
|
|||||||
[EHook.postDelete]: TPostDelete;
|
[EHook.postDelete]: TPostDelete;
|
||||||
};
|
};
|
||||||
|
|
||||||
type TNormalizedHook<E extends keyof IHookEntityOperationMap, O> = Extract<
|
export type TNormalizedHook<
|
||||||
TNormalizedHooks<E>,
|
E extends keyof IHookEntityOperationMap,
|
||||||
{ [key in O]: unknown }
|
O,
|
||||||
>[O];
|
> = Extract<TNormalizedHooks<E>, { [key in O]: unknown }>[O];
|
||||||
|
|
||||||
/* Extended hook */
|
/* Extended hook */
|
||||||
type TExtendedHook<
|
export type TExtendedHook<
|
||||||
E extends keyof IHookEntityOperationMap,
|
E extends keyof IHookEntityOperationMap,
|
||||||
O extends keyof IHookEntityOperationMap[E]['operations'],
|
O extends keyof IHookEntityOperationMap[E]['operations'],
|
||||||
> = IHookEntityOperationMap[E]['operations'][O];
|
> = IHookEntityOperationMap[E]['operations'][O];
|
||||||
|
|
||||||
type EventValueOf<G> = G extends `hook:${infer E}:${infer O}`
|
export type EventValueOf<G> = G extends `hook:${infer E}:${infer O}`
|
||||||
? O extends '*'
|
? O extends '*'
|
||||||
? TUnion<G, E>
|
? TUnion<G, E>
|
||||||
: E extends keyof IHookEntityOperationMap
|
: E extends keyof IHookEntityOperationMap
|
||||||
@ -294,7 +303,7 @@ declare module '@nestjs/event-emitter' {
|
|||||||
: never
|
: never
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
type IsHookEvent<G extends EventNamespaces | ConstrainedString> =
|
export type IsHookEvent<G extends EventNamespaces | ConstrainedString> =
|
||||||
G extends EventNamespaces
|
G extends EventNamespaces
|
||||||
? true
|
? true
|
||||||
: G extends `hook:${infer N}:${string}`
|
: G extends `hook:${infer N}:${string}`
|
||||||
@ -303,10 +312,10 @@ declare module '@nestjs/event-emitter' {
|
|||||||
: false
|
: false
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
type TCustomEvents<G extends keyof IHookEntityOperationMap> =
|
export type TCustomEvents<G extends keyof IHookEntityOperationMap> =
|
||||||
keyof IHookEntityOperationMap[G]['operations'] & string;
|
keyof IHookEntityOperationMap[G]['operations'] & string;
|
||||||
|
|
||||||
type customEvent<G extends EventNamespaces | ConstrainedString> =
|
export type customEvent<G extends EventNamespaces | ConstrainedString> =
|
||||||
G extends EventNamespaces
|
G extends EventNamespaces
|
||||||
? G extends `hook:${string}`
|
? G extends `hook:${string}`
|
||||||
? G
|
? G
|
8
api/types/mongoose.d.ts
vendored
8
api/types/mongoose.d.ts
vendored
@ -6,19 +6,19 @@
|
|||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'mongoose';
|
|
||||||
import {
|
import {
|
||||||
ObjectWithNestedKeys,
|
ObjectWithNestedKeys,
|
||||||
RecursivePartial,
|
RecursivePartial,
|
||||||
WithoutGenericAny,
|
WithoutGenericAny,
|
||||||
} from '../src/utils/types/filter.types';
|
} from '@/utils/types/filter.types';
|
||||||
|
import 'mongoose';
|
||||||
|
|
||||||
declare module 'mongoose' {
|
declare module 'mongoose' {
|
||||||
type TOmitId<T> = Omit<T, 'id'>;
|
type TOmitId<T> = Omit<T, 'id'>;
|
||||||
type TReplaceId<T> = TOmitId<T> & { _id?: string };
|
type TReplaceId<T> = TOmitId<T> & { _id?: string };
|
||||||
|
|
||||||
// Enforce the typing with an alternative type to FilterQuery compatible with mongoose: version 8.0.0
|
// Enforce the typing with an alternative type to FilterQuery compatible with mongoose: version 8.0.0
|
||||||
export type TFilterQuery<T, S = TReplaceId<T>> = (
|
type TFilterQuery<T, S = TReplaceId<T>> = (
|
||||||
| RecursivePartial<{
|
| RecursivePartial<{
|
||||||
[P in keyof S]?:
|
[P in keyof S]?:
|
||||||
| (S[P] extends string ? S[P] | RegExp : S[P])
|
| (S[P] extends string ? S[P] | RegExp : S[P])
|
||||||
@ -28,5 +28,5 @@ declare module 'mongoose' {
|
|||||||
) &
|
) &
|
||||||
WithoutGenericAny<RootQuerySelector<S>>;
|
WithoutGenericAny<RootQuerySelector<S>>;
|
||||||
|
|
||||||
export type THydratedDocument<T> = TOmitId<HydratedDocument<T>>;
|
type THydratedDocument<T> = TOmitId<HydratedDocument<T>>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user