@kevisual/query 0.0.45 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/query-api.d.ts +2 -2
- package/package.json +1 -1
- package/src/query-api.ts +3 -3
package/dist/query-api.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ type ApiMethods<P extends {
|
|
|
311
311
|
};
|
|
312
312
|
}> = {
|
|
313
313
|
[Path in keyof P]: {
|
|
314
|
-
[Key in keyof P[Path]]: (data?: ExtractArgsFromMetadata<P[Path][Key]
|
|
314
|
+
[Key in keyof P[Path]]: (data?: Partial<ExtractArgsFromMetadata<P[Path][Key]>>, opts?: DataOpts) => ReturnType<Query['post']>;
|
|
315
315
|
};
|
|
316
316
|
};
|
|
317
317
|
type QueryApiOpts<P extends {
|
|
@@ -329,7 +329,7 @@ declare class QueryApi<P extends {
|
|
|
329
329
|
} = {}> {
|
|
330
330
|
query: Query;
|
|
331
331
|
constructor(opts?: QueryApiOpts<P>);
|
|
332
|
-
post<T extends Pos>(pos: T, data?: ExtractArgsFromMetadata<T
|
|
332
|
+
post<T extends Pos>(pos: T, data?: Partial<ExtractArgsFromMetadata<T>>, opts?: DataOpts): Promise<{
|
|
333
333
|
code: number;
|
|
334
334
|
data?: any;
|
|
335
335
|
message?: string;
|
package/package.json
CHANGED
package/src/query-api.ts
CHANGED
|
@@ -75,7 +75,7 @@ type ExtractArgsFromMetadata<T> = T extends { metadata?: { args?: infer A } }
|
|
|
75
75
|
type ApiMethods<P extends { [path: string]: { [key: string]: Pos } }> = {
|
|
76
76
|
[Path in keyof P]: {
|
|
77
77
|
[Key in keyof P[Path]]: (
|
|
78
|
-
data?: ExtractArgsFromMetadata<P[Path][Key]
|
|
78
|
+
data?: Partial<ExtractArgsFromMetadata<P[Path][Key]>>,
|
|
79
79
|
opts?: DataOpts
|
|
80
80
|
) => ReturnType<Query['post']>
|
|
81
81
|
}
|
|
@@ -97,7 +97,7 @@ export class QueryApi<P extends { [path: string]: { [key: string]: Pos } } = {}>
|
|
|
97
97
|
// 使用泛型来推断类型
|
|
98
98
|
post<T extends Pos>(
|
|
99
99
|
pos: T,
|
|
100
|
-
data?: ExtractArgsFromMetadata<T
|
|
100
|
+
data?: Partial<ExtractArgsFromMetadata<T>>,
|
|
101
101
|
opts?: DataOpts
|
|
102
102
|
) {
|
|
103
103
|
const _pos = pick(pos, ['path', 'key', 'id']);
|
|
@@ -121,7 +121,7 @@ export class QueryApi<P extends { [path: string]: { [key: string]: Pos } } = {}>
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
for (const [key, pos] of Object.entries(methods)) {
|
|
124
|
-
that[path][key] = (data?: ExtractArgsFromMetadata<typeof pos
|
|
124
|
+
that[path][key] = (data?: Partial<ExtractArgsFromMetadata<typeof pos>>, opts?: DataOpts) => {
|
|
125
125
|
const _pos = pick(pos, ['path', 'key', 'id']);
|
|
126
126
|
return that.query.post({
|
|
127
127
|
..._pos,
|