@kevisual/query 0.0.47 → 0.0.48
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 +10 -5
- package/dist/query-api.js +13757 -0
- package/package.json +2 -2
- package/src/create-query/index.ts +9 -0
- package/src/query-api.ts +14 -5
package/dist/query-api.d.ts
CHANGED
|
@@ -291,20 +291,25 @@ type InferType<T> = T extends z.ZodType<infer U> ? U : T extends {
|
|
|
291
291
|
} ? InferFromJSONSchema<T> : T extends {
|
|
292
292
|
properties: infer P;
|
|
293
293
|
} ? InferFromJSONSchema<T> : T;
|
|
294
|
+
type IsOptional<T> = T extends {
|
|
295
|
+
optional: true;
|
|
296
|
+
} ? true : false;
|
|
294
297
|
type ExtractArgsFromMetadata<T> = T extends {
|
|
295
298
|
metadata?: {
|
|
296
299
|
args?: infer A;
|
|
297
300
|
};
|
|
298
|
-
} ? A extends Record<string, any> ? {
|
|
299
|
-
[K in keyof A]: InferType<A[K]>;
|
|
300
|
-
}
|
|
301
|
+
} ? A extends Record<string, any> ? ({
|
|
302
|
+
[K in keyof A as IsOptional<A[K]> extends true ? never : K]: InferType<A[K]>;
|
|
303
|
+
} & {
|
|
304
|
+
[K in keyof A as IsOptional<A[K]> extends true ? K : never]?: InferType<A[K]>;
|
|
305
|
+
}) : never : never;
|
|
301
306
|
type ApiMethods<P extends {
|
|
302
307
|
[path: string]: {
|
|
303
308
|
[key: string]: Pos;
|
|
304
309
|
};
|
|
305
310
|
}> = {
|
|
306
311
|
[Path in keyof P]: {
|
|
307
|
-
[Key in keyof P[Path]]: (data?:
|
|
312
|
+
[Key in keyof P[Path]]: (data?: ExtractArgsFromMetadata<P[Path][Key]>, opts?: DataOpts) => ReturnType<Query['post']>;
|
|
308
313
|
};
|
|
309
314
|
};
|
|
310
315
|
type QueryApiOpts<P extends {
|
|
@@ -322,7 +327,7 @@ declare class QueryApi<P extends {
|
|
|
322
327
|
} = {}> {
|
|
323
328
|
query: Query;
|
|
324
329
|
constructor(opts?: QueryApiOpts<P>);
|
|
325
|
-
post<T extends Pos>(pos: T, data?:
|
|
330
|
+
post<T extends Pos>(pos: T, data?: ExtractArgsFromMetadata<T>, opts?: DataOpts): Promise<{
|
|
326
331
|
code: number;
|
|
327
332
|
data?: any;
|
|
328
333
|
message?: string;
|