Skip to content

Commit

Permalink
implement closure parser (#185)
Browse files Browse the repository at this point in the history
* implement closure parser

* update data configuration type definition

* 2.6.72
  • Loading branch information
kbarbounakis authored Jan 14, 2025
1 parent 4fe462f commit 7a907b5
Show file tree
Hide file tree
Showing 8 changed files with 580 additions and 110 deletions.
16 changes: 15 additions & 1 deletion data-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ export declare interface AuthSettingsConfiguration {
loginPage?: string;
}

export declare type DataAdapterConstructor<T> = Function & { prototype: T };

export declare interface CreateDataAdapterInstance {
name: string;
invariantName?: string;
createInstance?(options: any): any;
}

export declare interface DataAdapterType {
name: string;
invariantName?: string;
type?: DataAdapterConstructor<any>;
}

export declare class DataConfiguration {
constructor(configPath: string);
static getCurrent(): DataConfiguration;
Expand All @@ -58,7 +72,7 @@ export declare class DataConfigurationStrategy extends ConfigurationStrategy{

readonly dataTypes: Map<string, DataTypeConfiguration>;
readonly adapters: Array<DataAdapterConfiguration>;
readonly adapterTypes: Array<DataAdapterTypeConfiguration>;
readonly adapterTypes: Map<string, (DataAdapterType | CreateDataAdapterInstance)>;
getAuthSettings(): AuthSettingsConfiguration;
getAdapterType(invariantName: string): DataAdapterTypeConfiguration;
hasDataType(name: string): boolean;
Expand Down
8 changes: 6 additions & 2 deletions data-model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ export declare class DataModel extends SequentialEventEmitter{
filter(params: any, callback?: (err?: Error, res?: any) => void): void;
filterAsync(params: any): Promise<DataQueryable>;
find(obj: any):DataQueryable;
select<T>(expr: (value: T, ...param: any) => any, ...params: any[]): DataQueryable;
select<T,J>(expr: (value1: T, value2: J, ...param: any) => any, ...params: any[]): DataQueryable;
select(...attr: any[]): DataQueryable;
orderBy(attr: any): DataQueryable;
orderByDescending(attr: any): DataQueryable;
orderBy(attr: any): this;
orderBy<T>(expr: (value: T, ...params: any[]) => any): this;
orderByDescending(attr: any): this;
orderByDescending<T>(expr: (value: T) => any, ...params: any[]): this;
take(n: number): DataQueryable;
getList():Promise<any>;
skip(n: number): DataQueryable;
Expand Down
20 changes: 19 additions & 1 deletion data-queryable.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// MOST Web Framework 2.0 Codename Blueshift BSD-3-Clause license Copyright (c) 2017-2022, THEMOST LP All rights reserved
import {DataModel} from "./data-model";
import {DataContextEmitter} from "./types";
import {QueryExpression} from '@themost/query';
import {QueryExpression, QueryFunc, QueryJoinFunc} from '@themost/query';

export declare class DataQueryable implements DataContextEmitter {
constructor(model: DataModel);
readonly model: DataModel;
readonly query: QueryExpression;
clone(): this;
where(attr: string): this;
where<T>(expr: QueryFunc<T>, ...params: unknown[]): this;
search(text: string): this;
join(model: string): this;
and(attr: string): this;
Expand All @@ -29,12 +30,29 @@ export declare class DataQueryable implements DataContextEmitter {
contains(value: any): this;
notContains(value: any): this;
between(value1: any, value2: any): this;
select<T>(expr: (value: T, ...param: any) => any, ...params: any[]): this;
select<T,J>(expr: (value1: T, value2: J, ...param: any) => any, ...params: any[]): this;
select(...attr: any[]): this;
orderBy(attr: any): this;
orderBy<T>(expr: (value: T, ...params: any[]) => any): this;
orderByDescending(attr: any): this;
orderByDescending<T>(expr: (value: T) => any, ...params: any[]): this;
thenBy(attr: any): this;
thenBy<T>(expr: (value: T) => any, ...params: any[]): this;
thenByDescending(attr: any): this;
thenByDescending<T>(expr: (value: T) => any, ...params: any[]): this;
groupBy(...attr: any[]): this;
groupBy<T>(...args: [...expr:[(value: T) => any], ...params: any[]]): this;
groupBy<T>(arg1: QueryFunc<T>, arg2: QueryFunc<T>, ...params: any[]): this;
groupBy<T>(arg1: QueryFunc<T>, arg2: QueryFunc<T>, arg3: QueryFunc<T>, ...params: any[]): this;
groupBy<T>(arg1: QueryFunc<T>, arg2: QueryFunc<T>, arg3: QueryFunc<T>,
arg4: QueryFunc<T>, ...params: any[]): this;
groupBy<T>(arg1: QueryFunc<T>, arg2: QueryFunc<T>, arg3: QueryFunc<T>,
arg4: QueryFunc<T>, arg5: QueryFunc<T>, ...params: any[]): this;
groupBy<T>(arg1: QueryFunc<T>, arg2: QueryFunc<T>, arg3: QueryFunc<T>,
arg4: QueryFunc<T>, arg5: QueryFunc<T>, arg6: QueryFunc<T>, ...params: any[]): this;
groupBy<T>(arg1: QueryFunc<T>, arg2: QueryFunc<T>, arg3: QueryFunc<T>,
arg4: QueryFunc<T>, arg5: QueryFunc<T>, arg6: QueryFunc<T> , arg7: QueryFunc<T>, ...params: any[]): this;
skip(n:number): this;
take(n:number): this;
getItem(): Promise<any>;
Expand Down
Loading

0 comments on commit 7a907b5

Please sign in to comment.