mirror of
https://github.com/hexastack/hexabot
synced 2025-05-02 03:55:57 +00:00
fix: mongoose
This commit is contained in:
parent
6b387b826b
commit
1b1a0b4b35
22
api/src/index.d.ts
vendored
22
api/src/index.d.ts
vendored
@ -8,14 +8,7 @@
|
|||||||
|
|
||||||
import 'mongoose';
|
import 'mongoose';
|
||||||
import { SubscriberStub } from './chat/schemas/subscriber.schema';
|
import { SubscriberStub } from './chat/schemas/subscriber.schema';
|
||||||
import {
|
|
||||||
ObjectWithNestedKeys,
|
|
||||||
RecursivePartial,
|
|
||||||
WithoutGenericAny,
|
|
||||||
} from './utils/types/filter.types';
|
|
||||||
|
|
||||||
type TOmitId<T> = Omit<T, 'id'>;
|
|
||||||
type TReplaceId<T> = TOmitId<T> & { _id?: string };
|
|
||||||
declare module 'express-session' {
|
declare module 'express-session' {
|
||||||
interface SessionUser {
|
interface SessionUser {
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -49,21 +42,6 @@ declare module 'express-session' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'mongoose' {
|
|
||||||
// Enforce the typing with an alternative type to FilterQuery compatible with mongoose: version 8.0.0
|
|
||||||
type TFilterQuery<T, S = TReplaceId<T>> = (
|
|
||||||
| RecursivePartial<{
|
|
||||||
[P in keyof S]?:
|
|
||||||
| (S[P] extends string ? S[P] | RegExp : S[P])
|
|
||||||
| QuerySelector<S[P]>;
|
|
||||||
}>
|
|
||||||
| Partial<ObjectWithNestedKeys<S>>
|
|
||||||
) &
|
|
||||||
WithoutGenericAny<RootQuerySelector<S>>;
|
|
||||||
|
|
||||||
type THydratedDocument<T> = TOmitId<HydratedDocument<T>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
type HyphenToUnderscore<S extends string> = S extends `${infer P}-${infer Q}`
|
type HyphenToUnderscore<S extends string> = S extends `${infer P}-${infer Q}`
|
||||||
? `${P}_${HyphenToUnderscore<Q>}`
|
? `${P}_${HyphenToUnderscore<Q>}`
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"typeRoots": ["./node_modules/@types", "./types"],
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
@ -25,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
|
"types/**/*.d.ts",
|
||||||
"src/**/*.json",
|
"src/**/*.json",
|
||||||
"test/**/*.ts",
|
"test/**/*.ts",
|
||||||
"src/.hexabot/**/*.ts",
|
"src/.hexabot/**/*.ts",
|
||||||
|
32
api/types/mongoose.d.ts
vendored
Normal file
32
api/types/mongoose.d.ts
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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).
|
||||||
|
*/
|
||||||
|
|
||||||
|
import 'mongoose';
|
||||||
|
import {
|
||||||
|
ObjectWithNestedKeys,
|
||||||
|
RecursivePartial,
|
||||||
|
WithoutGenericAny,
|
||||||
|
} from '../src/utils/types/filter.types';
|
||||||
|
|
||||||
|
declare module 'mongoose' {
|
||||||
|
type TOmitId<T> = Omit<T, 'id'>;
|
||||||
|
type TReplaceId<T> = TOmitId<T> & { _id?: string };
|
||||||
|
|
||||||
|
// Enforce the typing with an alternative type to FilterQuery compatible with mongoose: version 8.0.0
|
||||||
|
export type TFilterQuery<T, S = TReplaceId<T>> = (
|
||||||
|
| RecursivePartial<{
|
||||||
|
[P in keyof S]?:
|
||||||
|
| (S[P] extends string ? S[P] | RegExp : S[P])
|
||||||
|
| QuerySelector<S[P]>;
|
||||||
|
}>
|
||||||
|
| Partial<ObjectWithNestedKeys<S>>
|
||||||
|
) &
|
||||||
|
WithoutGenericAny<RootQuerySelector<S>>;
|
||||||
|
|
||||||
|
export type THydratedDocument<T> = TOmitId<HydratedDocument<T>>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user