@geekmidas/client 9.0.1 → 10.0.0-alpha.0

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.
Files changed (81) hide show
  1. package/dist/auth-fetcher-CBYuL6rx.d.cts +158 -0
  2. package/dist/auth-fetcher-CBYuL6rx.d.cts.map +1 -0
  3. package/dist/auth-fetcher-DOj0iz21.mjs +77 -0
  4. package/dist/auth-fetcher-DOj0iz21.mjs.map +1 -0
  5. package/dist/auth-fetcher-DxS8zOLc.d.mts +158 -0
  6. package/dist/auth-fetcher-DxS8zOLc.d.mts.map +1 -0
  7. package/dist/auth-fetcher-HILABmws.cjs +82 -0
  8. package/dist/auth-fetcher-HILABmws.cjs.map +1 -0
  9. package/dist/auth-fetcher.cjs +3 -76
  10. package/dist/auth-fetcher.d.cts +3 -158
  11. package/dist/auth-fetcher.d.mts +3 -158
  12. package/dist/auth-fetcher.mjs +3 -76
  13. package/dist/endpoint-hooks.d.mts +1 -1
  14. package/dist/fetcher-C1xtCKpT.d.mts +25 -0
  15. package/dist/fetcher-C1xtCKpT.d.mts.map +1 -0
  16. package/dist/fetcher-cDrfwN-Y.d.cts +25 -0
  17. package/dist/fetcher-cDrfwN-Y.d.cts.map +1 -0
  18. package/dist/fetcher.d.cts +3 -25
  19. package/dist/fetcher.d.mts +3 -25
  20. package/dist/index.cjs +8 -0
  21. package/dist/index.d.cts +5 -0
  22. package/dist/index.d.mts +5 -0
  23. package/dist/index.mjs +6 -0
  24. package/dist/infer-6KKCgmg1.cjs +0 -0
  25. package/{src/infer.ts → dist/infer-DfRq5kIb.d.cts} +54 -83
  26. package/dist/infer-DfRq5kIb.d.cts.map +1 -0
  27. package/dist/infer-bTirNeNW.d.mts +133 -0
  28. package/dist/infer-bTirNeNW.d.mts.map +1 -0
  29. package/dist/infer-uCUq1whM.mjs +0 -0
  30. package/dist/infer.cjs +1 -0
  31. package/dist/infer.d.cts +2 -133
  32. package/dist/infer.d.mts +2 -133
  33. package/dist/infer.mjs +1 -0
  34. package/dist/openapi-hooks.cjs.map +1 -1
  35. package/dist/openapi-hooks.d.cts +3 -3
  36. package/dist/openapi-hooks.d.cts.map +1 -1
  37. package/dist/openapi-hooks.d.mts +1 -1
  38. package/dist/openapi-hooks.d.mts.map +1 -1
  39. package/dist/openapi-hooks.mjs.map +1 -1
  40. package/dist/react-query.d.cts +7 -7
  41. package/dist/react-query.d.mts +1 -1
  42. package/dist/types-BH8WgGrm.mjs +0 -0
  43. package/dist/{types-D8Jrl4o3.d.mts → types-BMGM6sZc.d.mts} +1 -1
  44. package/dist/{types-D8Jrl4o3.d.mts.map → types-BMGM6sZc.d.mts.map} +1 -1
  45. package/dist/types-a8gm_IaQ.cjs +0 -0
  46. package/dist/types.cjs +1 -0
  47. package/dist/types.d.mts +1 -1
  48. package/dist/types.mjs +1 -0
  49. package/package.json +8 -5
  50. package/CHANGELOG.md +0 -124
  51. package/dist/auth-fetcher.cjs.map +0 -1
  52. package/dist/auth-fetcher.d.cts.map +0 -1
  53. package/dist/auth-fetcher.d.mts.map +0 -1
  54. package/dist/auth-fetcher.mjs.map +0 -1
  55. package/dist/fetcher.d.cts.map +0 -1
  56. package/dist/fetcher.d.mts.map +0 -1
  57. package/dist/infer.d.cts.map +0 -1
  58. package/dist/infer.d.mts.map +0 -1
  59. package/src/__tests__/auth-fetcher.spec.ts +0 -505
  60. package/src/__tests__/endpoint-hooks.spec.tsx +0 -374
  61. package/src/__tests__/fetcher.spec.ts +0 -580
  62. package/src/__tests__/infer.integration.spec.ts +0 -188
  63. package/src/__tests__/infer.spec.ts +0 -189
  64. package/src/__tests__/method-restrictions.spec.tsx +0 -227
  65. package/src/__tests__/mutation-inference.spec.tsx +0 -343
  66. package/src/__tests__/openapi-hooks.spec.tsx +0 -557
  67. package/src/__tests__/react-query-infinite.spec.tsx +0 -1003
  68. package/src/__tests__/react-query-invalidation.spec.tsx +0 -239
  69. package/src/__tests__/react-query.spec.tsx +0 -582
  70. package/src/__tests__/setup.ts +0 -281
  71. package/src/__tests__/types.spec.ts +0 -134
  72. package/src/__tests__/url-parsing.spec.ts +0 -196
  73. package/src/auth-fetcher.ts +0 -288
  74. package/src/endpoint-hooks.ts +0 -346
  75. package/src/fetcher.ts +0 -171
  76. package/src/openapi-hooks.ts +0 -193
  77. package/src/openapi-types.d.ts +0 -440
  78. package/src/openapi.json +0 -595
  79. package/src/react-query.ts +0 -341
  80. package/src/types.ts +0 -226
  81. package/tsconfig.json +0 -12
@@ -1,75 +1,56 @@
1
- import type {
2
- Endpoint,
3
- EndpointSchemas,
4
- } from '@geekmidas/constructs/endpoints';
5
- import type { HttpMethod } from '@geekmidas/constructs/types';
6
- import type { InferStandardSchema } from '@geekmidas/schema';
7
- import type { StandardSchemaV1 } from '@standard-schema/spec';
1
+ import { Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
2
+ import { HttpMethod } from "@geekmidas/constructs/types";
3
+ import { InferStandardSchema } from "@geekmidas/schema";
4
+ import { StandardSchemaV1 } from "@standard-schema/spec";
5
+
6
+ //#region src/infer.d.ts
8
7
 
9
8
  /**
10
9
  * Infers path parameters from a route string as an object
11
10
  * @example '/users/{id}/posts/{postId}' -> { id: string, postId: string }
12
11
  */
13
- type InferPathParams<TRoute extends string> =
14
- TRoute extends `${string}{${infer Param}}${infer Rest}`
15
- ? { [K in Param]: string } & InferPathParams<Rest>
16
- : {};
17
-
12
+ type InferPathParams<TRoute extends string> = TRoute extends `${string}{${infer Param}}${infer Rest}` ? { [K in Param]: string } & InferPathParams<Rest> : {};
18
13
  /**
19
14
  * Converts an HTTP method to lowercase for TypedFetcher compatibility
20
15
  */
21
16
  type LowercaseMethod<T extends HttpMethod> = Lowercase<T>;
22
-
23
17
  /**
24
18
  * Infers route-level parameters (path params)
25
19
  */
26
- type InferRouteParameters<TRoute extends string> =
27
- InferPathParams<TRoute> extends Record<string, never>
28
- ? {}
29
- : {
30
- parameters: {
31
- path: InferPathParams<TRoute>;
32
- };
33
- };
34
-
20
+ type InferRouteParameters<TRoute extends string> = InferPathParams<TRoute> extends Record<string, never> ? {} : {
21
+ parameters: {
22
+ path: InferPathParams<TRoute>;
23
+ };
24
+ };
35
25
  /**
36
26
  * Infers operation-level parameters (query params)
37
27
  */
38
28
  type InferOperationParameters<TInput extends EndpointSchemas> = TInput extends {
39
- query: infer Q;
40
- }
41
- ? {
42
- parameters: {
43
- query: InferStandardSchema<Q>;
44
- };
45
- }
46
- : {};
47
-
29
+ query: infer Q;
30
+ } ? {
31
+ parameters: {
32
+ query: InferStandardSchema<Q>;
33
+ };
34
+ } : {};
48
35
  /**
49
36
  * Infers the operation object compatible with TypedFetcher
50
37
  */
51
- type InferOperation<
52
- TInput extends EndpointSchemas,
53
- TOutput extends StandardSchemaV1 | undefined,
54
- > = InferOperationParameters<TInput> & {
55
- requestBody?: TInput extends { body: infer B }
56
- ? {
57
- content: {
58
- 'application/json': InferStandardSchema<B>;
59
- };
60
- }
61
- : never;
62
- responses: {
63
- 200: {
64
- content: TOutput extends StandardSchemaV1
65
- ? {
66
- 'application/json': InferStandardSchema<TOutput>;
67
- }
68
- : never;
69
- };
70
- };
38
+ type InferOperation<TInput extends EndpointSchemas, TOutput extends StandardSchemaV1 | undefined> = InferOperationParameters<TInput> & {
39
+ requestBody?: TInput extends {
40
+ body: infer B;
41
+ } ? {
42
+ content: {
43
+ 'application/json': InferStandardSchema<B>;
44
+ };
45
+ } : never;
46
+ responses: {
47
+ 200: {
48
+ content: TOutput extends StandardSchemaV1 ? {
49
+ 'application/json': InferStandardSchema<TOutput>;
50
+ } : never;
51
+ };
52
+ };
71
53
  };
72
-
73
54
  /**
74
55
  * Infers the TypedFetcher-compatible paths structure from a single endpoint
75
56
  *
@@ -79,7 +60,7 @@ type InferOperation<
79
60
  *
80
61
  * @example
81
62
  * ```typescript
82
- * import { e } from '@geekmidas/constructs';
63
+ * import { api } from './constructs/api.js';
83
64
  * import { createTypedFetcher, type InferOpenApiFromEndpoint } from '@geekmidas/client';
84
65
  * import { z } from 'zod';
85
66
  *
@@ -94,25 +75,9 @@ type InferOperation<
94
75
  * const user = await client('GET /users/{id}', { params: { id: '123' } });
95
76
  * ```
96
77
  */
97
- export type InferOpenApiFromEndpoint<T> =
98
- T extends Endpoint<
99
- infer TRoute,
100
- infer TMethod,
101
- infer TInput,
102
- infer TOutput,
103
- any,
104
- any,
105
- any
106
- >
107
- ? {
108
- paths: {
109
- [K in TRoute]: InferRouteParameters<TRoute> & {
110
- [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput>;
111
- };
112
- };
113
- }
114
- : never;
115
-
78
+ type InferOpenApiFromEndpoint<T> = T extends Endpoint<infer TRoute, infer TMethod, infer TInput, infer TOutput, any, any, any> ? {
79
+ paths: { [K in TRoute]: InferRouteParameters<TRoute> & { [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput> } };
80
+ } : never;
116
81
  /**
117
82
  * Infers TypedFetcher-compatible paths structure from multiple endpoints
118
83
  *
@@ -121,7 +86,7 @@ export type InferOpenApiFromEndpoint<T> =
121
86
  *
122
87
  * @example
123
88
  * ```typescript
124
- * import { e } from '@geekmidas/constructs';
89
+ * import { api } from './constructs/api.js';
125
90
  * import { createTypedFetcher, type InferOpenApi } from '@geekmidas/client';
126
91
  * import { z } from 'zod';
127
92
  *
@@ -150,13 +115,19 @@ export type InferOpenApiFromEndpoint<T> =
150
115
  * const newUser = await client('POST /users', { body: { name: 'Jane' } });
151
116
  * ```
152
117
  */
153
- export type InferOpenApi<TEndpoints extends readonly any[]> =
154
- TEndpoints extends readonly [infer First, ...infer Rest]
155
- ? InferOpenApiFromEndpoint<First> extends { paths: infer P1 }
156
- ? Rest extends []
157
- ? { paths: P1 }
158
- : InferOpenApi<Rest> extends { paths: infer P2 }
159
- ? { paths: P1 & P2 }
160
- : { paths: P1 }
161
- : InferOpenApi<Rest>
162
- : { paths: {} };
118
+ type InferOpenApi<TEndpoints extends readonly any[]> = TEndpoints extends readonly [infer First, ...infer Rest] ? InferOpenApiFromEndpoint<First> extends {
119
+ paths: infer P1;
120
+ } ? Rest extends [] ? {
121
+ paths: P1;
122
+ } : InferOpenApi<Rest> extends {
123
+ paths: infer P2;
124
+ } ? {
125
+ paths: P1 & P2;
126
+ } : {
127
+ paths: P1;
128
+ } : InferOpenApi<Rest> : {
129
+ paths: {};
130
+ };
131
+ //#endregion
132
+ export { InferOpenApi, InferOpenApiFromEndpoint };
133
+ //# sourceMappingURL=infer-DfRq5kIb.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer-DfRq5kIb.d.cts","names":[],"sources":["../src/infer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAM8D;;KAMzD,eACJ,CAAA,eAAA,MAAA,CAAA,GAAA,MAAA,SAAA,GAAA,MAAA,IAAA,KAAA,MAAA,IAAA,KAAA,KAAA,EAAA,GAAA,QACW,KAAA,GAAA,MAAA,EAAK,GAAc,eAAgB,CAAA,IAAA,CAAA,GAAA,CAAA,CAAA;;AAAD;AAAA;KAMzC,eAAe,CAAA,UAAW,UAAX,CAAA,GAAyB,SAAzB,CAAmC,CAAnC,CAAA;;;;AAAkC,KAKjD,oBALiD,CAAA,eAAA,MAAA,CAAA,GAMrD,eANqD,CAMrC,MANqC,CAAA,SAMrB,MANqB,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA;EAKjD,UAAA,EAAA;IAAoB,IAAA,EAKd,eALc,CAKE,MALF,CAAA;EAAA,CAAA;CACF;;;;AAIG,KAOrB,wBAPqB,CAAA,eAOmB,eAPnB,CAAA,GAOsC,MAPtC,SAAA;EAOrB,KAAA,EAAA,KAAA,EAAA;CAAwB,GAAA;EAAA,UAAgB,EAAA;IAAmB,KAAA,EAKrD,mBALqD,CAKjC,CALiC,CAAA;EAAM,CAAA;CAKtC,GAAA,CAAA,CAAA;AAAF;AAAA;;KAQzB,cACW,CAAA,eAAA,eAAA,EAAA,gBACC,gBADD,GAAA,SAAA,CAAA,GAEZ,wBAFY,CAEa,MAFb,CAAA,GAAA;EAAe,WACd,CAAA,EAEF,MAFE,SAAA;IACY,IAAA,EAAA,KAAA,EAAA;EAAM,CAAA,GAA/B;IACW,OAAA,EAAA;MAG8B,kBAAA,EAApB,mBAAoB,CAAA,CAAA,CAAA;IAApB,CAAA;EAAmB,CAAA,GAMhC,KAAA;EAAO,SAAS,EAAA;IAEkB,GAAA,EAAA;MAApB,OAAA,EAFd,OAEc,SAFE,gBAEF,GAAA;QAAmB,kBAAA,EAAnB,mBAAmB,CAAC,OAAD,CAAA;MA+BjC,CAAA,GAAA,KAAA;IAAwB,CAAA;EAAA,CAAA;CAClC;;;;;;;;;AAYmD;AA2CrD;;;;;;;;;;;;;;AAQiB;KAhEL,8BACX,UAAU;iBAWA,SAAS,qBAAqB,kBAC7B,gBAAgB,WAAW,eAAe,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2ClD,kDACX,2DACG,yBAAyB;;IACxB;SACU;IACT,aAAa;;;SACH,KAAK;;SACL;IACX,aAAa"}
@@ -0,0 +1,133 @@
1
+ import { Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
2
+ import { HttpMethod } from "@geekmidas/constructs/types";
3
+ import { InferStandardSchema } from "@geekmidas/schema";
4
+ import { StandardSchemaV1 } from "@standard-schema/spec";
5
+
6
+ //#region src/infer.d.ts
7
+
8
+ /**
9
+ * Infers path parameters from a route string as an object
10
+ * @example '/users/{id}/posts/{postId}' -> { id: string, postId: string }
11
+ */
12
+ type InferPathParams<TRoute extends string> = TRoute extends `${string}{${infer Param}}${infer Rest}` ? { [K in Param]: string } & InferPathParams<Rest> : {};
13
+ /**
14
+ * Converts an HTTP method to lowercase for TypedFetcher compatibility
15
+ */
16
+ type LowercaseMethod<T extends HttpMethod> = Lowercase<T>;
17
+ /**
18
+ * Infers route-level parameters (path params)
19
+ */
20
+ type InferRouteParameters<TRoute extends string> = InferPathParams<TRoute> extends Record<string, never> ? {} : {
21
+ parameters: {
22
+ path: InferPathParams<TRoute>;
23
+ };
24
+ };
25
+ /**
26
+ * Infers operation-level parameters (query params)
27
+ */
28
+ type InferOperationParameters<TInput extends EndpointSchemas> = TInput extends {
29
+ query: infer Q;
30
+ } ? {
31
+ parameters: {
32
+ query: InferStandardSchema<Q>;
33
+ };
34
+ } : {};
35
+ /**
36
+ * Infers the operation object compatible with TypedFetcher
37
+ */
38
+ type InferOperation<TInput extends EndpointSchemas, TOutput extends StandardSchemaV1 | undefined> = InferOperationParameters<TInput> & {
39
+ requestBody?: TInput extends {
40
+ body: infer B;
41
+ } ? {
42
+ content: {
43
+ 'application/json': InferStandardSchema<B>;
44
+ };
45
+ } : never;
46
+ responses: {
47
+ 200: {
48
+ content: TOutput extends StandardSchemaV1 ? {
49
+ 'application/json': InferStandardSchema<TOutput>;
50
+ } : never;
51
+ };
52
+ };
53
+ };
54
+ /**
55
+ * Infers the TypedFetcher-compatible paths structure from a single endpoint
56
+ *
57
+ * This generates a structure compatible with @geekmidas/client TypedFetcher,
58
+ * allowing you to create a typed client directly from endpoint definitions
59
+ * without needing OpenAPI JSON + codegen.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * import { api } from './constructs/api.js';
64
+ * import { createTypedFetcher, type InferOpenApiFromEndpoint } from '@geekmidas/client';
65
+ * import { z } from 'zod';
66
+ *
67
+ * const endpoint = e
68
+ * .get('/users/{id}')
69
+ * .params(z.object({ id: z.string() }))
70
+ * .output(z.object({ id: z.string(), name: z.string() }))
71
+ * .handle(async ({ params }) => ({ id: params.id, name: 'John' }));
72
+ *
73
+ * type Paths = InferOpenApiFromEndpoint<typeof endpoint>['paths'];
74
+ * const client = createTypedFetcher<Paths>({ baseURL: 'http://localhost:3000' });
75
+ * const user = await client('GET /users/{id}', { params: { id: '123' } });
76
+ * ```
77
+ */
78
+ type InferOpenApiFromEndpoint<T> = T extends Endpoint<infer TRoute, infer TMethod, infer TInput, infer TOutput, any, any, any> ? {
79
+ paths: { [K in TRoute]: InferRouteParameters<TRoute> & { [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput> } };
80
+ } : never;
81
+ /**
82
+ * Infers TypedFetcher-compatible paths structure from multiple endpoints
83
+ *
84
+ * Merges multiple endpoint definitions into a single paths object that can be
85
+ * used with @geekmidas/client TypedFetcher for fully type-safe API calls.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { api } from './constructs/api.js';
90
+ * import { createTypedFetcher, type InferOpenApi } from '@geekmidas/client';
91
+ * import { z } from 'zod';
92
+ *
93
+ * // Define endpoints
94
+ * const getUserEndpoint = e
95
+ * .get('/users/{id}')
96
+ * .params(z.object({ id: z.string() }))
97
+ * .output(z.object({ id: z.string(), name: z.string() }))
98
+ * .handle(async ({ params }) => ({ id: params.id, name: 'John' }));
99
+ *
100
+ * const createUserEndpoint = e
101
+ * .post('/users')
102
+ * .body(z.object({ name: z.string() }))
103
+ * .output(z.object({ id: z.string(), name: z.string() }))
104
+ * .handle(async ({ body }) => ({ id: '123', name: body.name }));
105
+ *
106
+ * // Export for client
107
+ * export const endpoints = [getUserEndpoint, createUserEndpoint] as const;
108
+ * export type Paths = InferOpenApi<typeof endpoints>['paths'];
109
+ *
110
+ * // Client usage
111
+ * import type { Paths } from './endpoints';
112
+ * const client = createTypedFetcher<Paths>({ baseURL: 'http://localhost:3000' });
113
+ *
114
+ * const user = await client('GET /users/{id}', { params: { id: '123' } });
115
+ * const newUser = await client('POST /users', { body: { name: 'Jane' } });
116
+ * ```
117
+ */
118
+ type InferOpenApi<TEndpoints extends readonly any[]> = TEndpoints extends readonly [infer First, ...infer Rest] ? InferOpenApiFromEndpoint<First> extends {
119
+ paths: infer P1;
120
+ } ? Rest extends [] ? {
121
+ paths: P1;
122
+ } : InferOpenApi<Rest> extends {
123
+ paths: infer P2;
124
+ } ? {
125
+ paths: P1 & P2;
126
+ } : {
127
+ paths: P1;
128
+ } : InferOpenApi<Rest> : {
129
+ paths: {};
130
+ };
131
+ //#endregion
132
+ export { InferOpenApi, InferOpenApiFromEndpoint };
133
+ //# sourceMappingURL=infer-bTirNeNW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer-bTirNeNW.d.mts","names":[],"sources":["../src/infer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAM8D;;KAMzD,eACJ,CAAA,eAAA,MAAA,CAAA,GAAA,MAAA,SAAA,GAAA,MAAA,IAAA,KAAA,MAAA,IAAA,KAAA,KAAA,EAAA,GAAA,QACW,KAAA,GAAA,MAAA,EAAK,GAAc,eAAgB,CAAA,IAAA,CAAA,GAAA,CAAA,CAAA;;AAAD;AAAA;KAMzC,eAAe,CAAA,UAAW,UAAX,CAAA,GAAyB,SAAzB,CAAmC,CAAnC,CAAA;;;;AAAkC,KAKjD,oBALiD,CAAA,eAAA,MAAA,CAAA,GAMrD,eANqD,CAMrC,MANqC,CAAA,SAMrB,MANqB,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA;EAKjD,UAAA,EAAA;IAAoB,IAAA,EAKd,eALc,CAKE,MALF,CAAA;EAAA,CAAA;CACF;;;;AAIG,KAOrB,wBAPqB,CAAA,eAOmB,eAPnB,CAAA,GAOsC,MAPtC,SAAA;EAOrB,KAAA,EAAA,KAAA,EAAA;CAAwB,GAAA;EAAA,UAAgB,EAAA;IAAmB,KAAA,EAKrD,mBALqD,CAKjC,CALiC,CAAA;EAAM,CAAA;CAKtC,GAAA,CAAA,CAAA;AAAF;AAAA;;KAQzB,cACW,CAAA,eAAA,eAAA,EAAA,gBACC,gBADD,GAAA,SAAA,CAAA,GAEZ,wBAFY,CAEa,MAFb,CAAA,GAAA;EAAe,WACd,CAAA,EAEF,MAFE,SAAA;IACY,IAAA,EAAA,KAAA,EAAA;EAAM,CAAA,GAA/B;IACW,OAAA,EAAA;MAG8B,kBAAA,EAApB,mBAAoB,CAAA,CAAA,CAAA;IAApB,CAAA;EAAmB,CAAA,GAMhC,KAAA;EAAO,SAAS,EAAA;IAEkB,GAAA,EAAA;MAApB,OAAA,EAFd,OAEc,SAFE,gBAEF,GAAA;QAAmB,kBAAA,EAAnB,mBAAmB,CAAC,OAAD,CAAA;MA+BjC,CAAA,GAAA,KAAA;IAAwB,CAAA;EAAA,CAAA;CAClC;;;;;;;;;AAYmD;AA2CrD;;;;;;;;;;;;;;AAQiB;KAhEL,8BACX,UAAU;iBAWA,SAAS,qBAAqB,kBAC7B,gBAAgB,WAAW,eAAe,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2ClD,kDACX,2DACG,yBAAyB;;IACxB;SACU;IACT,aAAa;;;SACH,KAAK;;SACL;IACX,aAAa"}
File without changes
package/dist/infer.cjs CHANGED
@@ -0,0 +1 @@
1
+ require('./infer-6KKCgmg1.cjs');
package/dist/infer.d.cts CHANGED
@@ -1,133 +1,2 @@
1
- import { Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
2
- import { HttpMethod } from "@geekmidas/constructs/types";
3
- import { InferStandardSchema } from "@geekmidas/schema";
4
- import { StandardSchemaV1 } from "@standard-schema/spec";
5
-
6
- //#region src/infer.d.ts
7
-
8
- /**
9
- * Infers path parameters from a route string as an object
10
- * @example '/users/{id}/posts/{postId}' -> { id: string, postId: string }
11
- */
12
- type InferPathParams<TRoute extends string> = TRoute extends `${string}{${infer Param}}${infer Rest}` ? { [K in Param]: string } & InferPathParams<Rest> : {};
13
- /**
14
- * Converts an HTTP method to lowercase for TypedFetcher compatibility
15
- */
16
- type LowercaseMethod<T extends HttpMethod> = Lowercase<T>;
17
- /**
18
- * Infers route-level parameters (path params)
19
- */
20
- type InferRouteParameters<TRoute extends string> = InferPathParams<TRoute> extends Record<string, never> ? {} : {
21
- parameters: {
22
- path: InferPathParams<TRoute>;
23
- };
24
- };
25
- /**
26
- * Infers operation-level parameters (query params)
27
- */
28
- type InferOperationParameters<TInput extends EndpointSchemas> = TInput extends {
29
- query: infer Q;
30
- } ? {
31
- parameters: {
32
- query: InferStandardSchema<Q>;
33
- };
34
- } : {};
35
- /**
36
- * Infers the operation object compatible with TypedFetcher
37
- */
38
- type InferOperation<TInput extends EndpointSchemas, TOutput extends StandardSchemaV1 | undefined> = InferOperationParameters<TInput> & {
39
- requestBody?: TInput extends {
40
- body: infer B;
41
- } ? {
42
- content: {
43
- 'application/json': InferStandardSchema<B>;
44
- };
45
- } : never;
46
- responses: {
47
- 200: {
48
- content: TOutput extends StandardSchemaV1 ? {
49
- 'application/json': InferStandardSchema<TOutput>;
50
- } : never;
51
- };
52
- };
53
- };
54
- /**
55
- * Infers the TypedFetcher-compatible paths structure from a single endpoint
56
- *
57
- * This generates a structure compatible with @geekmidas/client TypedFetcher,
58
- * allowing you to create a typed client directly from endpoint definitions
59
- * without needing OpenAPI JSON + codegen.
60
- *
61
- * @example
62
- * ```typescript
63
- * import { e } from '@geekmidas/constructs';
64
- * import { createTypedFetcher, type InferOpenApiFromEndpoint } from '@geekmidas/client';
65
- * import { z } from 'zod';
66
- *
67
- * const endpoint = e
68
- * .get('/users/{id}')
69
- * .params(z.object({ id: z.string() }))
70
- * .output(z.object({ id: z.string(), name: z.string() }))
71
- * .handle(async ({ params }) => ({ id: params.id, name: 'John' }));
72
- *
73
- * type Paths = InferOpenApiFromEndpoint<typeof endpoint>['paths'];
74
- * const client = createTypedFetcher<Paths>({ baseURL: 'http://localhost:3000' });
75
- * const user = await client('GET /users/{id}', { params: { id: '123' } });
76
- * ```
77
- */
78
- type InferOpenApiFromEndpoint<T> = T extends Endpoint<infer TRoute, infer TMethod, infer TInput, infer TOutput, any, any, any> ? {
79
- paths: { [K in TRoute]: InferRouteParameters<TRoute> & { [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput> } };
80
- } : never;
81
- /**
82
- * Infers TypedFetcher-compatible paths structure from multiple endpoints
83
- *
84
- * Merges multiple endpoint definitions into a single paths object that can be
85
- * used with @geekmidas/client TypedFetcher for fully type-safe API calls.
86
- *
87
- * @example
88
- * ```typescript
89
- * import { e } from '@geekmidas/constructs';
90
- * import { createTypedFetcher, type InferOpenApi } from '@geekmidas/client';
91
- * import { z } from 'zod';
92
- *
93
- * // Define endpoints
94
- * const getUserEndpoint = e
95
- * .get('/users/{id}')
96
- * .params(z.object({ id: z.string() }))
97
- * .output(z.object({ id: z.string(), name: z.string() }))
98
- * .handle(async ({ params }) => ({ id: params.id, name: 'John' }));
99
- *
100
- * const createUserEndpoint = e
101
- * .post('/users')
102
- * .body(z.object({ name: z.string() }))
103
- * .output(z.object({ id: z.string(), name: z.string() }))
104
- * .handle(async ({ body }) => ({ id: '123', name: body.name }));
105
- *
106
- * // Export for client
107
- * export const endpoints = [getUserEndpoint, createUserEndpoint] as const;
108
- * export type Paths = InferOpenApi<typeof endpoints>['paths'];
109
- *
110
- * // Client usage
111
- * import type { Paths } from './endpoints';
112
- * const client = createTypedFetcher<Paths>({ baseURL: 'http://localhost:3000' });
113
- *
114
- * const user = await client('GET /users/{id}', { params: { id: '123' } });
115
- * const newUser = await client('POST /users', { body: { name: 'Jane' } });
116
- * ```
117
- */
118
- type InferOpenApi<TEndpoints extends readonly any[]> = TEndpoints extends readonly [infer First, ...infer Rest] ? InferOpenApiFromEndpoint<First> extends {
119
- paths: infer P1;
120
- } ? Rest extends [] ? {
121
- paths: P1;
122
- } : InferOpenApi<Rest> extends {
123
- paths: infer P2;
124
- } ? {
125
- paths: P1 & P2;
126
- } : {
127
- paths: P1;
128
- } : InferOpenApi<Rest> : {
129
- paths: {};
130
- };
131
- //#endregion
132
- export { InferOpenApi, InferOpenApiFromEndpoint };
133
- //# sourceMappingURL=infer.d.cts.map
1
+ import { InferOpenApi, InferOpenApiFromEndpoint } from "./infer-DfRq5kIb.cjs";
2
+ export { InferOpenApi, InferOpenApiFromEndpoint };
package/dist/infer.d.mts CHANGED
@@ -1,133 +1,2 @@
1
- import { Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
2
- import { HttpMethod } from "@geekmidas/constructs/types";
3
- import { InferStandardSchema } from "@geekmidas/schema";
4
- import { StandardSchemaV1 } from "@standard-schema/spec";
5
-
6
- //#region src/infer.d.ts
7
-
8
- /**
9
- * Infers path parameters from a route string as an object
10
- * @example '/users/{id}/posts/{postId}' -> { id: string, postId: string }
11
- */
12
- type InferPathParams<TRoute extends string> = TRoute extends `${string}{${infer Param}}${infer Rest}` ? { [K in Param]: string } & InferPathParams<Rest> : {};
13
- /**
14
- * Converts an HTTP method to lowercase for TypedFetcher compatibility
15
- */
16
- type LowercaseMethod<T extends HttpMethod> = Lowercase<T>;
17
- /**
18
- * Infers route-level parameters (path params)
19
- */
20
- type InferRouteParameters<TRoute extends string> = InferPathParams<TRoute> extends Record<string, never> ? {} : {
21
- parameters: {
22
- path: InferPathParams<TRoute>;
23
- };
24
- };
25
- /**
26
- * Infers operation-level parameters (query params)
27
- */
28
- type InferOperationParameters<TInput extends EndpointSchemas> = TInput extends {
29
- query: infer Q;
30
- } ? {
31
- parameters: {
32
- query: InferStandardSchema<Q>;
33
- };
34
- } : {};
35
- /**
36
- * Infers the operation object compatible with TypedFetcher
37
- */
38
- type InferOperation<TInput extends EndpointSchemas, TOutput extends StandardSchemaV1 | undefined> = InferOperationParameters<TInput> & {
39
- requestBody?: TInput extends {
40
- body: infer B;
41
- } ? {
42
- content: {
43
- 'application/json': InferStandardSchema<B>;
44
- };
45
- } : never;
46
- responses: {
47
- 200: {
48
- content: TOutput extends StandardSchemaV1 ? {
49
- 'application/json': InferStandardSchema<TOutput>;
50
- } : never;
51
- };
52
- };
53
- };
54
- /**
55
- * Infers the TypedFetcher-compatible paths structure from a single endpoint
56
- *
57
- * This generates a structure compatible with @geekmidas/client TypedFetcher,
58
- * allowing you to create a typed client directly from endpoint definitions
59
- * without needing OpenAPI JSON + codegen.
60
- *
61
- * @example
62
- * ```typescript
63
- * import { e } from '@geekmidas/constructs';
64
- * import { createTypedFetcher, type InferOpenApiFromEndpoint } from '@geekmidas/client';
65
- * import { z } from 'zod';
66
- *
67
- * const endpoint = e
68
- * .get('/users/{id}')
69
- * .params(z.object({ id: z.string() }))
70
- * .output(z.object({ id: z.string(), name: z.string() }))
71
- * .handle(async ({ params }) => ({ id: params.id, name: 'John' }));
72
- *
73
- * type Paths = InferOpenApiFromEndpoint<typeof endpoint>['paths'];
74
- * const client = createTypedFetcher<Paths>({ baseURL: 'http://localhost:3000' });
75
- * const user = await client('GET /users/{id}', { params: { id: '123' } });
76
- * ```
77
- */
78
- type InferOpenApiFromEndpoint<T> = T extends Endpoint<infer TRoute, infer TMethod, infer TInput, infer TOutput, any, any, any> ? {
79
- paths: { [K in TRoute]: InferRouteParameters<TRoute> & { [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput> } };
80
- } : never;
81
- /**
82
- * Infers TypedFetcher-compatible paths structure from multiple endpoints
83
- *
84
- * Merges multiple endpoint definitions into a single paths object that can be
85
- * used with @geekmidas/client TypedFetcher for fully type-safe API calls.
86
- *
87
- * @example
88
- * ```typescript
89
- * import { e } from '@geekmidas/constructs';
90
- * import { createTypedFetcher, type InferOpenApi } from '@geekmidas/client';
91
- * import { z } from 'zod';
92
- *
93
- * // Define endpoints
94
- * const getUserEndpoint = e
95
- * .get('/users/{id}')
96
- * .params(z.object({ id: z.string() }))
97
- * .output(z.object({ id: z.string(), name: z.string() }))
98
- * .handle(async ({ params }) => ({ id: params.id, name: 'John' }));
99
- *
100
- * const createUserEndpoint = e
101
- * .post('/users')
102
- * .body(z.object({ name: z.string() }))
103
- * .output(z.object({ id: z.string(), name: z.string() }))
104
- * .handle(async ({ body }) => ({ id: '123', name: body.name }));
105
- *
106
- * // Export for client
107
- * export const endpoints = [getUserEndpoint, createUserEndpoint] as const;
108
- * export type Paths = InferOpenApi<typeof endpoints>['paths'];
109
- *
110
- * // Client usage
111
- * import type { Paths } from './endpoints';
112
- * const client = createTypedFetcher<Paths>({ baseURL: 'http://localhost:3000' });
113
- *
114
- * const user = await client('GET /users/{id}', { params: { id: '123' } });
115
- * const newUser = await client('POST /users', { body: { name: 'Jane' } });
116
- * ```
117
- */
118
- type InferOpenApi<TEndpoints extends readonly any[]> = TEndpoints extends readonly [infer First, ...infer Rest] ? InferOpenApiFromEndpoint<First> extends {
119
- paths: infer P1;
120
- } ? Rest extends [] ? {
121
- paths: P1;
122
- } : InferOpenApi<Rest> extends {
123
- paths: infer P2;
124
- } ? {
125
- paths: P1 & P2;
126
- } : {
127
- paths: P1;
128
- } : InferOpenApi<Rest> : {
129
- paths: {};
130
- };
131
- //#endregion
132
- export { InferOpenApi, InferOpenApiFromEndpoint };
133
- //# sourceMappingURL=infer.d.mts.map
1
+ import { InferOpenApi, InferOpenApiFromEndpoint } from "./infer-bTirNeNW.mjs";
2
+ export { InferOpenApi, InferOpenApiFromEndpoint };
package/dist/infer.mjs CHANGED
@@ -0,0 +1 @@
1
+ import "./infer-uCUq1whM.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-hooks.cjs","names":["options: FetcherOptions & { operations?: OperationRegistry }","operationId: OpId","config?: RemoveNever<OperationParams<Paths, OpId>>","options?: Omit<\n\t\t\t\tUseQueryOptions<OperationResponse<Paths, OpId>, Error>,\n\t\t\t\t'queryKey' | 'queryFn'\n\t\t\t>","options","options?: Omit<\n\t\t\t\tUseMutationOptions<\n\t\t\t\t\tOperationResponse<Paths, OpId>,\n\t\t\t\t\tError,\n\t\t\t\t\tRemoveNever<OperationParams<Paths, OpId>>\n\t\t\t\t>,\n\t\t\t\t'mutationFn'\n\t\t\t>"],"sources":["../src/openapi-hooks.ts"],"sourcesContent":["import type {\n\tUseMutationOptions,\n\tUseQueryOptions,\n} from '@tanstack/react-query';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { createTypedFetcher } from './fetcher';\nimport type { FetcherOptions } from './types';\n\n// Simplified type helpers for OpenAPI paths\ntype HttpMethods = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n// Extract all operations from paths\ntype AllOperations<Paths> = {\n\t[Path in keyof Paths]: {\n\t\t[Method in keyof Paths[Path] & HttpMethods]: Paths[Path][Method] extends {\n\t\t\toperationId: infer OpId;\n\t\t}\n\t\t\t? OpId extends string\n\t\t\t\t? {\n\t\t\t\t\t\toperationId: OpId;\n\t\t\t\t\t\tpath: Path;\n\t\t\t\t\t\tmethod: Method;\n\t\t\t\t\t\tspec: Paths[Path][Method] & {\n\t\t\t\t\t\t\t_pathParams?: Paths[Path] extends {\n\t\t\t\t\t\t\t\tparameters: { path: infer P };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t? P\n\t\t\t\t\t\t\t\t: never;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t: never\n\t\t\t: never;\n\t}[keyof Paths[Path] & HttpMethods];\n}[keyof Paths];\n\n// Create operation map\ntype OperationMap<Paths> = {\n\t[Op in AllOperations<Paths> as Op extends {\n\t\toperationId: infer Id extends string;\n\t}\n\t\t? Id\n\t\t: never]: Op;\n};\n\n// Get operation IDs\ntype OperationId<Paths> = keyof OperationMap<Paths>;\n\n// Get operations by method\ntype OperationsByMethod<Paths, Method extends HttpMethods> = {\n\t[K in OperationId<Paths>]: OperationMap<Paths>[K] extends { method: Method }\n\t\t? K\n\t\t: never;\n}[OperationId<Paths>];\n\n// Extract parameter types\ntype OperationParams<\n\tPaths,\n\tOpId extends OperationId<Paths>,\n> = OperationMap<Paths>[OpId] extends {\n\tpath: infer Path extends keyof Paths;\n\tspec: infer Spec;\n}\n\t? {\n\t\t\tparams?: Paths[Path] extends { parameters: { path: infer P } }\n\t\t\t\t? P\n\t\t\t\t: Spec extends { parameters: { path: infer P } }\n\t\t\t\t\t? P\n\t\t\t\t\t: never;\n\t\t\tquery?: Spec extends { parameters?: { query?: infer Q } } ? Q : never;\n\t\t\tbody?: Spec extends {\n\t\t\t\trequestBody: { content: { 'application/json': infer Body } };\n\t\t\t}\n\t\t\t\t? Body\n\t\t\t\t: Spec extends {\n\t\t\t\t\t\t\trequestBody: {\n\t\t\t\t\t\t\t\trequired: true;\n\t\t\t\t\t\t\t\tcontent: { 'application/json': infer Body };\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t? Body\n\t\t\t\t\t: never;\n\t\t}\n\t: never;\n\n// Extract response type\ntype OperationResponse<\n\tPaths,\n\tOpId extends OperationId<Paths>,\n> = OperationMap<Paths>[OpId] extends { spec: infer Spec }\n\t? Spec extends {\n\t\t\tresponses: { 200: { content: { 'application/json': infer R } } };\n\t\t}\n\t\t? R\n\t\t: Spec extends {\n\t\t\t\t\tresponses: { 201: { content: { 'application/json': infer R } } };\n\t\t\t\t}\n\t\t\t? R\n\t\t\t: Spec extends { responses: { 204: any } }\n\t\t\t\t? undefined\n\t\t\t\t: unknown\n\t: never;\n\n// Remove never properties\ntype RemoveNever<T> = Pick<\n\tT,\n\t{\n\t\t[K in keyof T]: T[K] extends never ? never : K;\n\t}[keyof T]\n>;\n\n// Check if type is empty\ntype IsEmpty<T> = keyof T extends never ? true : false;\n\n// Runtime operation registry (would be generated)\ninterface OperationRegistry {\n\t[operationId: string]: {\n\t\tpath: string;\n\t\tmethod: string;\n\t};\n}\n\nexport function createOpenAPIHooks<Paths>(\n\toptions: FetcherOptions & { operations?: OperationRegistry } = {},\n) {\n\tconst { operations, ...fetcherOptions } = options;\n\tconst fetcher = createTypedFetcher<Paths>(fetcherOptions);\n\n\tfunction buildEndpoint<OpId extends OperationId<Paths>>(\n\t\toperationId: OpId,\n\t): string {\n\t\t// Runtime lookup from registry\n\t\tconst op = operations?.[operationId as string];\n\t\tif (op) {\n\t\t\treturn `${op.method.toUpperCase()} ${op.path}`;\n\t\t}\n\t\t// Fallback for compile-time only usage\n\t\treturn operationId as string;\n\t}\n\n\treturn {\n\t\tuseQuery: <OpId extends OperationsByMethod<Paths, 'get'>>(\n\t\t\toperationId: OpId,\n\t\t\tconfig?: RemoveNever<OperationParams<Paths, OpId>>,\n\t\t\toptions?: Omit<\n\t\t\t\tUseQueryOptions<OperationResponse<Paths, OpId>, Error>,\n\t\t\t\t'queryKey' | 'queryFn'\n\t\t\t>,\n\t\t) => {\n\t\t\tconst endpoint = buildEndpoint(operationId);\n\t\t\tconst queryKey = [operationId, ...(config ? [config] : [])];\n\n\t\t\treturn useQuery<OperationResponse<Paths, OpId>, Error>({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: async () => {\n\t\t\t\t\tconst response = await fetcher(endpoint as any, config as any);\n\t\t\t\t\treturn response as OperationResponse<Paths, OpId>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t});\n\t\t},\n\n\t\tuseMutation: <\n\t\t\tOpId extends Exclude<\n\t\t\t\tOperationId<Paths>,\n\t\t\t\tOperationsByMethod<Paths, 'get'>\n\t\t\t>,\n\t\t>(\n\t\t\toperationId: OpId,\n\t\t\toptions?: Omit<\n\t\t\t\tUseMutationOptions<\n\t\t\t\t\tOperationResponse<Paths, OpId>,\n\t\t\t\t\tError,\n\t\t\t\t\tRemoveNever<OperationParams<Paths, OpId>>\n\t\t\t\t>,\n\t\t\t\t'mutationFn'\n\t\t\t>,\n\t\t) => {\n\t\t\tconst endpoint = buildEndpoint(operationId);\n\n\t\t\treturn useMutation<\n\t\t\t\tOperationResponse<Paths, OpId>,\n\t\t\t\tError,\n\t\t\t\tRemoveNever<OperationParams<Paths, OpId>>\n\t\t\t>({\n\t\t\t\tmutationFn: async (variables) => {\n\t\t\t\t\tconst response = await fetcher(endpoint as any, variables as any);\n\t\t\t\t\treturn response as OperationResponse<Paths, OpId>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;;AAyHA,SAAgB,mBACfA,UAA+D,CAAE,GAChE;CACD,MAAM,EAAE,WAAY,GAAG,gBAAgB,GAAG;CAC1C,MAAM,UAAU,mCAA0B,eAAe;CAEzD,SAAS,cACRC,aACS;EAET,MAAM,KAAK,aAAa;AACxB,MAAI,GACH,SAAQ,EAAE,GAAG,OAAO,aAAa,CAAC,GAAG,GAAG,KAAK;AAG9C,SAAO;CACP;AAED,QAAO;EACN,UAAU,CACTA,aACAC,QACAC,cAII;GACJ,MAAM,WAAW,cAAc,YAAY;GAC3C,MAAM,WAAW,CAAC,aAAa,GAAI,SAAS,CAAC,MAAO,IAAG,CAAE,CAAE;AAE3D,UAAO,qCAAgD;IACtD;IACA,SAAS,YAAY;KACpB,MAAM,WAAW,MAAM,QAAQ,UAAiB,OAAc;AAC9D,YAAO;IACP;IACD,GAAGC;GACH,EAAC;EACF;EAED,aAAa,CAMZH,aACAI,cAQI;GACJ,MAAM,WAAW,cAAc,YAAY;AAE3C,UAAO,wCAIL;IACD,YAAY,OAAO,cAAc;KAChC,MAAM,WAAW,MAAM,QAAQ,UAAiB,UAAiB;AACjE,YAAO;IACP;IACD,GAAGD;GACH,EAAC;EACF;CACD;AACD"}
1
+ {"version":3,"file":"openapi-hooks.cjs","names":["options: FetcherOptions & { operations?: OperationRegistry }","operationId: OpId","config?: RemoveNever<OperationParams<Paths, OpId>>","options?: Omit<\n\t\t\t\tUseQueryOptions<OperationResponse<Paths, OpId>, Error>,\n\t\t\t\t'queryKey' | 'queryFn'\n\t\t\t>","options","options?: Omit<\n\t\t\t\tUseMutationOptions<\n\t\t\t\t\tOperationResponse<Paths, OpId>,\n\t\t\t\t\tError,\n\t\t\t\t\tRemoveNever<OperationParams<Paths, OpId>>\n\t\t\t\t>,\n\t\t\t\t'mutationFn'\n\t\t\t>"],"sources":["../src/openapi-hooks.ts"],"sourcesContent":["import type {\n\tUseMutationOptions,\n\tUseQueryOptions,\n} from '@tanstack/react-query';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { createTypedFetcher } from './fetcher';\nimport type { FetcherOptions } from './types';\n\n// Simplified type helpers for OpenAPI paths\ntype HttpMethods = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n// Extract all operations from paths\ntype AllOperations<Paths> = {\n\t[Path in keyof Paths]: {\n\t\t[Method in keyof Paths[Path] & HttpMethods]: Paths[Path][Method] extends {\n\t\t\toperationId: infer OpId;\n\t\t}\n\t\t\t? OpId extends string\n\t\t\t\t? {\n\t\t\t\t\t\toperationId: OpId;\n\t\t\t\t\t\tpath: Path;\n\t\t\t\t\t\tmethod: Method;\n\t\t\t\t\t\tspec: Paths[Path][Method] & {\n\t\t\t\t\t\t\t_pathParams?: Paths[Path] extends {\n\t\t\t\t\t\t\t\tparameters: { path: infer P };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t? P\n\t\t\t\t\t\t\t\t: never;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t: never\n\t\t\t: never;\n\t}[keyof Paths[Path] & HttpMethods];\n}[keyof Paths];\n\n// Create operation map\ntype OperationMap<Paths> = {\n\t[Op in AllOperations<Paths> as Op extends {\n\t\toperationId: infer Id extends string;\n\t}\n\t\t? Id\n\t\t: never]: Op;\n};\n\n// Get operation IDs\ntype OperationId<Paths> = keyof OperationMap<Paths>;\n\n// Get operations by method\ntype OperationsByMethod<Paths, Method extends HttpMethods> = {\n\t[K in OperationId<Paths>]: OperationMap<Paths>[K] extends { method: Method }\n\t\t? K\n\t\t: never;\n}[OperationId<Paths>];\n\n// Extract parameter types\ntype OperationParams<\n\tPaths,\n\tOpId extends OperationId<Paths>,\n> = OperationMap<Paths>[OpId] extends {\n\tpath: infer Path extends keyof Paths;\n\tspec: infer Spec;\n}\n\t? {\n\t\t\tparams?: Paths[Path] extends { parameters: { path: infer P } }\n\t\t\t\t? P\n\t\t\t\t: Spec extends { parameters: { path: infer P } }\n\t\t\t\t\t? P\n\t\t\t\t\t: never;\n\t\t\tquery?: Spec extends { parameters?: { query?: infer Q } } ? Q : never;\n\t\t\tbody?: Spec extends {\n\t\t\t\trequestBody: { content: { 'application/json': infer Body } };\n\t\t\t}\n\t\t\t\t? Body\n\t\t\t\t: Spec extends {\n\t\t\t\t\t\t\trequestBody: {\n\t\t\t\t\t\t\t\trequired: true;\n\t\t\t\t\t\t\t\tcontent: { 'application/json': infer Body };\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t? Body\n\t\t\t\t\t: never;\n\t\t}\n\t: never;\n\n// Extract response type\ntype OperationResponse<\n\tPaths,\n\tOpId extends OperationId<Paths>,\n> = OperationMap<Paths>[OpId] extends { spec: infer Spec }\n\t? Spec extends {\n\t\t\tresponses: { 200: { content: { 'application/json': infer R } } };\n\t\t}\n\t\t? R\n\t\t: Spec extends {\n\t\t\t\t\tresponses: { 201: { content: { 'application/json': infer R } } };\n\t\t\t\t}\n\t\t\t? R\n\t\t\t: Spec extends { responses: { 204: any } }\n\t\t\t\t? undefined\n\t\t\t\t: unknown\n\t: never;\n\n// Remove never properties\ntype RemoveNever<T> = Pick<\n\tT,\n\t{\n\t\t[K in keyof T]: T[K] extends never ? never : K;\n\t}[keyof T]\n>;\n\n// Runtime operation registry (would be generated)\ninterface OperationRegistry {\n\t[operationId: string]: {\n\t\tpath: string;\n\t\tmethod: string;\n\t};\n}\n\nexport function createOpenAPIHooks<Paths>(\n\toptions: FetcherOptions & { operations?: OperationRegistry } = {},\n) {\n\tconst { operations, ...fetcherOptions } = options;\n\tconst fetcher = createTypedFetcher<Paths>(fetcherOptions);\n\n\tfunction buildEndpoint<OpId extends OperationId<Paths>>(\n\t\toperationId: OpId,\n\t): string {\n\t\t// Runtime lookup from registry\n\t\tconst op = operations?.[operationId as string];\n\t\tif (op) {\n\t\t\treturn `${op.method.toUpperCase()} ${op.path}`;\n\t\t}\n\t\t// Fallback for compile-time only usage\n\t\treturn operationId as string;\n\t}\n\n\treturn {\n\t\tuseQuery: <OpId extends OperationsByMethod<Paths, 'get'>>(\n\t\t\toperationId: OpId,\n\t\t\tconfig?: RemoveNever<OperationParams<Paths, OpId>>,\n\t\t\toptions?: Omit<\n\t\t\t\tUseQueryOptions<OperationResponse<Paths, OpId>, Error>,\n\t\t\t\t'queryKey' | 'queryFn'\n\t\t\t>,\n\t\t) => {\n\t\t\tconst endpoint = buildEndpoint(operationId);\n\t\t\tconst queryKey = [operationId, ...(config ? [config] : [])];\n\n\t\t\treturn useQuery<OperationResponse<Paths, OpId>, Error>({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: async () => {\n\t\t\t\t\tconst response = await fetcher(endpoint as any, config as any);\n\t\t\t\t\treturn response as OperationResponse<Paths, OpId>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t});\n\t\t},\n\n\t\tuseMutation: <\n\t\t\tOpId extends Exclude<\n\t\t\t\tOperationId<Paths>,\n\t\t\t\tOperationsByMethod<Paths, 'get'>\n\t\t\t>,\n\t\t>(\n\t\t\toperationId: OpId,\n\t\t\toptions?: Omit<\n\t\t\t\tUseMutationOptions<\n\t\t\t\t\tOperationResponse<Paths, OpId>,\n\t\t\t\t\tError,\n\t\t\t\t\tRemoveNever<OperationParams<Paths, OpId>>\n\t\t\t\t>,\n\t\t\t\t'mutationFn'\n\t\t\t>,\n\t\t) => {\n\t\t\tconst endpoint = buildEndpoint(operationId);\n\n\t\t\treturn useMutation<\n\t\t\t\tOperationResponse<Paths, OpId>,\n\t\t\t\tError,\n\t\t\t\tRemoveNever<OperationParams<Paths, OpId>>\n\t\t\t>({\n\t\t\t\tmutationFn: async (variables) => {\n\t\t\t\t\tconst response = await fetcher(endpoint as any, variables as any);\n\t\t\t\t\treturn response as OperationResponse<Paths, OpId>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;;AAsHA,SAAgB,mBACfA,UAA+D,CAAE,GAChE;CACD,MAAM,EAAE,WAAY,GAAG,gBAAgB,GAAG;CAC1C,MAAM,UAAU,mCAA0B,eAAe;CAEzD,SAAS,cACRC,aACS;EAET,MAAM,KAAK,aAAa;AACxB,MAAI,GACH,SAAQ,EAAE,GAAG,OAAO,aAAa,CAAC,GAAG,GAAG,KAAK;AAG9C,SAAO;CACP;AAED,QAAO;EACN,UAAU,CACTA,aACAC,QACAC,cAII;GACJ,MAAM,WAAW,cAAc,YAAY;GAC3C,MAAM,WAAW,CAAC,aAAa,GAAI,SAAS,CAAC,MAAO,IAAG,CAAE,CAAE;AAE3D,UAAO,qCAAgD;IACtD;IACA,SAAS,YAAY;KACpB,MAAM,WAAW,MAAM,QAAQ,UAAiB,OAAc;AAC9D,YAAO;IACP;IACD,GAAGC;GACH,EAAC;EACF;EAED,aAAa,CAMZH,aACAI,cAQI;GACJ,MAAM,WAAW,cAAc,YAAY;AAE3C,UAAO,wCAIL;IACD,YAAY,OAAO,cAAc;KAChC,MAAM,WAAW,MAAM,QAAQ,UAAiB,UAAiB;AACjE,YAAO;IACP;IACD,GAAGD;GACH,EAAC;EACF;CACD;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { FetcherOptions } from "./types-DMQMHePI.cjs";
2
- import * as _tanstack_react_query0 from "@tanstack/react-query";
2
+ import * as _tanstack_react_query8 from "@tanstack/react-query";
3
3
  import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
4
4
 
5
5
  //#region src/openapi-hooks.d.ts
@@ -91,8 +91,8 @@ interface OperationRegistry {
91
91
  declare function createOpenAPIHooks<Paths>(options?: FetcherOptions & {
92
92
  operations?: OperationRegistry;
93
93
  }): {
94
- useQuery: <OpId extends OperationsByMethod<Paths, "get">>(operationId: OpId, config?: RemoveNever<OperationParams<Paths, OpId>>, options?: Omit<UseQueryOptions<OperationResponse<Paths, OpId>, Error>, "queryKey" | "queryFn">) => _tanstack_react_query0.UseQueryResult<_tanstack_react_query0.NoInfer<OperationResponse<Paths, OpId>>, Error>;
95
- useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths, "get">>>(operationId: OpId, options?: Omit<UseMutationOptions<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>>, "mutationFn">) => _tanstack_react_query0.UseMutationResult<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>, unknown>;
94
+ useQuery: <OpId extends OperationsByMethod<Paths, "get">>(operationId: OpId, config?: RemoveNever<OperationParams<Paths, OpId>>, options?: Omit<UseQueryOptions<OperationResponse<Paths, OpId>, Error>, "queryKey" | "queryFn">) => _tanstack_react_query8.UseQueryResult<_tanstack_react_query8.NoInfer<OperationResponse<Paths, OpId>>, Error>;
95
+ useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths, "get">>>(operationId: OpId, options?: Omit<UseMutationOptions<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>>, "mutationFn">) => _tanstack_react_query8.UseMutationResult<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>, unknown>;
96
96
  };
97
97
  //#endregion
98
98
  export { createOpenAPIHooks };