tag-rpc 1.0.1 → 1.0.2
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/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -32,9 +32,9 @@ declare class TAG_API_ERROR extends Error {
|
|
|
32
32
|
url: string;
|
|
33
33
|
constructor(status: number, statusText: string, body: any, url: string);
|
|
34
34
|
}
|
|
35
|
-
declare function createTagRPC<T extends BaseApiRoutes, N extends BaseNamedRoutes>(namedRoutes: N): { [K in keyof N]: (options: TagRPCOptions<T, N[K]["path"]
|
|
35
|
+
declare function createTagRPC<T extends BaseApiRoutes, N extends BaseNamedRoutes>(namedRoutes: N): { [K in keyof N]: (options: TagRPCOptions<T, N[K]["path"] extends keyof T ? N[K]["path"] : keyof T, N[K]["method"] extends string ? N[K]["method"] : any>) => Promise<any>; } & {
|
|
36
36
|
fetch: <P extends keyof T, M extends keyof T[P]["Methods"] & string>(path: P, method: M, options: TagRPCOptions<T, P, M>) => Promise<T[P]["Methods"][M]["Response"]>;
|
|
37
|
-
call: <K_1 extends keyof N>(route: N[K_1], options: TagRPCOptions<T, N[K_1]["path"]
|
|
37
|
+
call: <K_1 extends keyof N>(route: N[K_1], options: TagRPCOptions<T, N[K_1]["path"] extends keyof T ? N[K_1]["path"] : keyof T, N[K_1]["method"] extends string ? N[K_1]["method"] : any>) => Promise<any>;
|
|
38
38
|
routes: N;
|
|
39
39
|
};
|
|
40
40
|
|
package/dist/index.js
CHANGED
|
@@ -46,8 +46,8 @@ function createTagRPC(namedRoutes) {
|
|
|
46
46
|
return new Proxy(baseFetcher, {
|
|
47
47
|
get(target, prop) {
|
|
48
48
|
if (prop in target) return target[prop];
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if (typeof prop === "string" && prop in namedRoutes) {
|
|
50
|
+
const route = namedRoutes[prop];
|
|
51
51
|
return (options) => fetchData(route.path, route.method, options);
|
|
52
52
|
}
|
|
53
53
|
return void 0;
|