Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enhance type about ORM model #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Typo/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export namespace FibApp {

export interface FibAppORMModel<
PropertyTypes extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>,
Methods extends Record<string, (...args: any) => any> = Record<string, (...args: any) => any>
> extends FxOrmModel.Model<PropertyTypes, Methods> {
Methods extends Record<string, (...args: any) => any> | unknown = Record<string, (...args: any) => any>
> extends FxOrmModel.Model<PropertyTypes, Methods extends unknown ? any : Methods> {
$webx: {
// globally unique class id
readonly cid: number
Expand Down Expand Up @@ -393,7 +393,7 @@ export namespace FibApp {
name: string,
properties: T,
opts?: U
) => FibAppORMModel<FxOrmModel.GetPropertiesType<T>, Exclude<U['methods'], void>>;
) => FibAppORMModel<FxOrmModel.GetPropertiesType<T>, Exclude<U['methods'], void> & Record<string, (...args: any) => any>>;
}
// compatible
export type FibAppDb = FibAppORM
Expand Down
4 changes: 2 additions & 2 deletions typings/Typo/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export declare namespace FibApp {
};
};
};
interface FibAppORMModel<PropertyTypes extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>, Methods extends Record<string, (...args: any) => any> = Record<string, (...args: any) => any>> extends FxOrmModel.Model<PropertyTypes, Methods> {
interface FibAppORMModel<PropertyTypes extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>, Methods extends Record<string, (...args: any) => any> | unknown = Record<string, (...args: any) => any>> extends FxOrmModel.Model<PropertyTypes, Methods extends unknown ? any : Methods> {
$webx: {
readonly cid: number;
readonly model_name: string;
Expand Down Expand Up @@ -311,7 +311,7 @@ export declare namespace FibApp {
app: FibAppClass;
models: GlobalAppModels;
graphql<T = any>(query: FibApp.GraphQLQueryString, req: FibApp.FibAppHttpRequest): T;
define: <T extends Record<string, FxOrmModel.ComplexModelPropertyDefinition>, U extends FibAppOrmModelDefOptions<FxOrmModel.GetPropertiesType<T>>>(name: string, properties: T, opts?: U) => FibAppORMModel<FxOrmModel.GetPropertiesType<T>, Exclude<U['methods'], void>>;
define: <T extends Record<string, FxOrmModel.ComplexModelPropertyDefinition>, U extends FibAppOrmModelDefOptions<FxOrmModel.GetPropertiesType<T>>>(name: string, properties: T, opts?: U) => FibAppORMModel<FxOrmModel.GetPropertiesType<T>, Exclude<U['methods'], void> & Record<string, (...args: any) => any>>;
}
export type FibAppDb = FibAppORM;
export type FibAppFunctionToBeFilter = (FibAppFilterableApiFunction__WithModel | FibAppFilterableApiFunction__NullModel | FibAppOrmModelFunction | FibAppInternalApiFunction);
Expand Down