update
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { adapter } from './adapter.ts';
|
||||
import { QueryWs, QueryWsOpts } from './ws.ts';
|
||||
import { Query } from './query.ts';
|
||||
import { wrapperError } from './query.ts';
|
||||
import { Query, ClientQuery } from './query.ts';
|
||||
import { BaseQuery, wrapperError } from './query.ts';
|
||||
|
||||
export { QueryOpts, QueryWs, Query, QueryWsOpts, adapter, wrapperError };
|
||||
export { QueryOpts, QueryWs, ClientQuery, Query, QueryWsOpts, adapter, BaseQuery, wrapperError };
|
||||
|
||||
export type { DataOpts, Result, Data } from './query.ts';
|
||||
|
||||
|
||||
35
src/query.ts
35
src/query.ts
@@ -254,4 +254,37 @@ export class Query {
|
||||
}
|
||||
}
|
||||
|
||||
export { adapter };
|
||||
export { adapter };
|
||||
|
||||
|
||||
/** @deprecated */
|
||||
export class BaseQuery<T extends Query = Query, R extends { queryChain?: any; query?: any } = { queryChain: any; query?: T }> {
|
||||
query: T;
|
||||
queryDefine: R;
|
||||
constructor(opts?: { query?: T; queryDefine?: R; clientQuery?: T }) {
|
||||
if (opts?.clientQuery) {
|
||||
this.query = opts.clientQuery;
|
||||
} else {
|
||||
this.query = opts?.query;
|
||||
}
|
||||
if (opts.queryDefine) {
|
||||
this.queryDefine = opts.queryDefine;
|
||||
this.queryDefine.query = this.query;
|
||||
}
|
||||
}
|
||||
get chain(): R['queryChain'] {
|
||||
return this.queryDefine.queryChain;
|
||||
}
|
||||
post<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> {
|
||||
return this.query.post(data, options);
|
||||
}
|
||||
get<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> {
|
||||
return this.query.get(data, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class ClientQuery extends Query {
|
||||
constructor(opts?: QueryOpts) {
|
||||
super({ ...opts, url: opts?.url || '/client/router' });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user