@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,158 +1,3 @@
1
- import { FetcherOptions, TypedApiFunction } from "./types-DMQMHePI.cjs";
2
-
3
- //#region src/auth-fetcher.d.ts
4
-
5
- /**
6
- * Security scheme object matching OpenAPI 3.1 specification.
7
- */
8
- interface SecuritySchemeObject {
9
- type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';
10
- description?: string;
11
- name?: string;
12
- in?: 'query' | 'header' | 'cookie';
13
- scheme?: string;
14
- bearerFormat?: string;
15
- flows?: Record<string, unknown>;
16
- openIdConnectUrl?: string;
17
- [key: string]: unknown;
18
- }
19
- /**
20
- * Extract all non-null security scheme IDs that are actually used in the API.
21
- * This gives us the union of scheme names that endpoints require.
22
- */
23
- type UsedSecuritySchemes<EndpointAuth extends Record<string, string | null>> = NonNullable<EndpointAuth[keyof EndpointAuth]>;
24
- /**
25
- * Interface for token storage and retrieval.
26
- * Compatible with @geekmidas/auth TokenClient.
27
- */
28
- interface TokenProvider {
29
- /**
30
- * Get a valid access token, refreshing if necessary.
31
- */
32
- getValidAccessToken(): Promise<string | null>;
33
- /**
34
- * Create Authorization headers from the current token.
35
- */
36
- createValidAuthHeaders(): Promise<Record<string, string>>;
37
- }
38
- /**
39
- * Interface for API key providers.
40
- */
41
- interface ApiKeyProvider {
42
- /**
43
- * Get the API key value.
44
- */
45
- getApiKey(): Promise<string> | string;
46
- }
47
- /**
48
- * Interface for AWS SigV4 request signing.
49
- */
50
- interface AwsSigner {
51
- /**
52
- * Sign a request with AWS SigV4.
53
- * @param url - The request URL
54
- * @param init - The request init object
55
- * @returns Headers to add to the request
56
- */
57
- sign(url: string, init: RequestInit): Promise<Record<string, string>>;
58
- }
59
- /**
60
- * Auth strategy configuration for a specific security scheme type.
61
- */
62
- type AuthStrategy = {
63
- type: 'bearer';
64
- tokenProvider: TokenProvider;
65
- } | {
66
- type: 'apiKey';
67
- apiKeyProvider: ApiKeyProvider;
68
- headerName?: string;
69
- } | {
70
- type: 'iam';
71
- signer: AwsSigner;
72
- } | {
73
- type: 'none';
74
- };
75
- /**
76
- * Options for creating an auth-aware fetcher.
77
- *
78
- * @template EndpointAuth - Map of endpoint strings to their auth scheme (or null for public)
79
- * @template SecuritySchemes - Available security scheme definitions
80
- */
81
- interface AuthFetcherOptions<EndpointAuth extends Record<string, string | null>, SecuritySchemes extends Record<string, SecuritySchemeObject>> extends Omit<FetcherOptions, 'onRequest'> {
82
- /**
83
- * Runtime map of endpoints to their required auth scheme.
84
- * Generated by `gkm openapi --ts`.
85
- */
86
- endpointAuth: EndpointAuth;
87
- /**
88
- * Security scheme definitions.
89
- * Generated by `gkm openapi --ts`.
90
- */
91
- securitySchemes: SecuritySchemes;
92
- /**
93
- * Auth strategies for security schemes that are actually used.
94
- * Only schemes referenced in endpointAuth are required.
95
- *
96
- * @example
97
- * ```typescript
98
- * // If endpointAuth has: { 'GET /users': 'jwt', 'POST /data': 'iam', 'GET /public': null }
99
- * // Then authStrategies must include strategies for 'jwt' and 'iam'
100
- * authStrategies: {
101
- * jwt: { type: 'bearer', tokenProvider },
102
- * iam: { type: 'iam', signer: awsSigner },
103
- * }
104
- * ```
105
- */
106
- authStrategies: Record<UsedSecuritySchemes<EndpointAuth>, AuthStrategy>;
107
- /**
108
- * Optional request interceptor (runs after auth headers are added).
109
- */
110
- onRequest?: (config: RequestInit) => RequestInit | Promise<RequestInit>;
111
- }
112
- /**
113
- * Creates an auth-aware fetcher that automatically applies the correct
114
- * authentication based on the endpoint being called.
115
- *
116
- * @example
117
- * ```typescript
118
- * import { endpointAuth, securitySchemes, paths } from './openapi';
119
- * import { TokenClient } from '@geekmidas/auth/client';
120
- *
121
- * const tokenClient = new TokenClient({ ... });
122
- *
123
- * const api = createAuthAwareFetcher<paths>({
124
- * baseURL: 'https://api.example.com',
125
- * endpointAuth,
126
- * securitySchemes,
127
- * authStrategies: {
128
- * bearer: { type: 'bearer', tokenProvider: tokenClient },
129
- * iam: { type: 'iam', signer: awsSigner },
130
- * },
131
- * });
132
- *
133
- * // Bearer auth automatically applied
134
- * const user = await api('GET /users/{id}', { params: { id: '123' } });
135
- *
136
- * // IAM SigV4 auth automatically applied
137
- * const tenant = await api('POST /tenants', { body: { name: 'Acme' } });
138
- * ```
139
- */
140
- declare function createAuthAwareFetcher<Paths, EndpointAuth extends Record<string, string | null> = Record<string, string | null>, SecuritySchemes extends Record<string, SecuritySchemeObject> = Record<string, SecuritySchemeObject>>(options: AuthFetcherOptions<EndpointAuth, SecuritySchemes> & {
141
- baseURL: string;
142
- }): TypedApiFunction<Paths>;
143
- /**
144
- * Type helper to extract the security scheme ID from an endpoint.
145
- */
146
- type GetEndpointAuth<EndpointAuth extends Record<string, string | null>, Endpoint extends keyof EndpointAuth> = EndpointAuth[Endpoint];
147
- /**
148
- * Type helper to get all authenticated endpoints.
149
- */
150
- type AuthenticatedEndpoints<EndpointAuth extends Record<string, string | null>> = { [K in keyof EndpointAuth]: EndpointAuth[K] extends null ? never : K }[keyof EndpointAuth];
151
- /**
152
- * Type helper to get all public endpoints.
153
- */
154
- type PublicEndpoints<EndpointAuth extends Record<string, string | null>> = { [K in keyof EndpointAuth]: EndpointAuth[K] extends null ? K : never }[keyof EndpointAuth];
155
- //# sourceMappingURL=auth-fetcher.d.ts.map
156
- //#endregion
157
- export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, FetcherOptions, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher };
158
- //# sourceMappingURL=auth-fetcher.d.cts.map
1
+ import { FetcherOptions } from "./types-DMQMHePI.cjs";
2
+ import { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher } from "./auth-fetcher-CBYuL6rx.cjs";
3
+ export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, FetcherOptions, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher };
@@ -1,158 +1,3 @@
1
- import { FetcherOptions, TypedApiFunction } from "./types-D8Jrl4o3.mjs";
2
-
3
- //#region src/auth-fetcher.d.ts
4
-
5
- /**
6
- * Security scheme object matching OpenAPI 3.1 specification.
7
- */
8
- interface SecuritySchemeObject {
9
- type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';
10
- description?: string;
11
- name?: string;
12
- in?: 'query' | 'header' | 'cookie';
13
- scheme?: string;
14
- bearerFormat?: string;
15
- flows?: Record<string, unknown>;
16
- openIdConnectUrl?: string;
17
- [key: string]: unknown;
18
- }
19
- /**
20
- * Extract all non-null security scheme IDs that are actually used in the API.
21
- * This gives us the union of scheme names that endpoints require.
22
- */
23
- type UsedSecuritySchemes<EndpointAuth extends Record<string, string | null>> = NonNullable<EndpointAuth[keyof EndpointAuth]>;
24
- /**
25
- * Interface for token storage and retrieval.
26
- * Compatible with @geekmidas/auth TokenClient.
27
- */
28
- interface TokenProvider {
29
- /**
30
- * Get a valid access token, refreshing if necessary.
31
- */
32
- getValidAccessToken(): Promise<string | null>;
33
- /**
34
- * Create Authorization headers from the current token.
35
- */
36
- createValidAuthHeaders(): Promise<Record<string, string>>;
37
- }
38
- /**
39
- * Interface for API key providers.
40
- */
41
- interface ApiKeyProvider {
42
- /**
43
- * Get the API key value.
44
- */
45
- getApiKey(): Promise<string> | string;
46
- }
47
- /**
48
- * Interface for AWS SigV4 request signing.
49
- */
50
- interface AwsSigner {
51
- /**
52
- * Sign a request with AWS SigV4.
53
- * @param url - The request URL
54
- * @param init - The request init object
55
- * @returns Headers to add to the request
56
- */
57
- sign(url: string, init: RequestInit): Promise<Record<string, string>>;
58
- }
59
- /**
60
- * Auth strategy configuration for a specific security scheme type.
61
- */
62
- type AuthStrategy = {
63
- type: 'bearer';
64
- tokenProvider: TokenProvider;
65
- } | {
66
- type: 'apiKey';
67
- apiKeyProvider: ApiKeyProvider;
68
- headerName?: string;
69
- } | {
70
- type: 'iam';
71
- signer: AwsSigner;
72
- } | {
73
- type: 'none';
74
- };
75
- /**
76
- * Options for creating an auth-aware fetcher.
77
- *
78
- * @template EndpointAuth - Map of endpoint strings to their auth scheme (or null for public)
79
- * @template SecuritySchemes - Available security scheme definitions
80
- */
81
- interface AuthFetcherOptions<EndpointAuth extends Record<string, string | null>, SecuritySchemes extends Record<string, SecuritySchemeObject>> extends Omit<FetcherOptions, 'onRequest'> {
82
- /**
83
- * Runtime map of endpoints to their required auth scheme.
84
- * Generated by `gkm openapi --ts`.
85
- */
86
- endpointAuth: EndpointAuth;
87
- /**
88
- * Security scheme definitions.
89
- * Generated by `gkm openapi --ts`.
90
- */
91
- securitySchemes: SecuritySchemes;
92
- /**
93
- * Auth strategies for security schemes that are actually used.
94
- * Only schemes referenced in endpointAuth are required.
95
- *
96
- * @example
97
- * ```typescript
98
- * // If endpointAuth has: { 'GET /users': 'jwt', 'POST /data': 'iam', 'GET /public': null }
99
- * // Then authStrategies must include strategies for 'jwt' and 'iam'
100
- * authStrategies: {
101
- * jwt: { type: 'bearer', tokenProvider },
102
- * iam: { type: 'iam', signer: awsSigner },
103
- * }
104
- * ```
105
- */
106
- authStrategies: Record<UsedSecuritySchemes<EndpointAuth>, AuthStrategy>;
107
- /**
108
- * Optional request interceptor (runs after auth headers are added).
109
- */
110
- onRequest?: (config: RequestInit) => RequestInit | Promise<RequestInit>;
111
- }
112
- /**
113
- * Creates an auth-aware fetcher that automatically applies the correct
114
- * authentication based on the endpoint being called.
115
- *
116
- * @example
117
- * ```typescript
118
- * import { endpointAuth, securitySchemes, paths } from './openapi';
119
- * import { TokenClient } from '@geekmidas/auth/client';
120
- *
121
- * const tokenClient = new TokenClient({ ... });
122
- *
123
- * const api = createAuthAwareFetcher<paths>({
124
- * baseURL: 'https://api.example.com',
125
- * endpointAuth,
126
- * securitySchemes,
127
- * authStrategies: {
128
- * bearer: { type: 'bearer', tokenProvider: tokenClient },
129
- * iam: { type: 'iam', signer: awsSigner },
130
- * },
131
- * });
132
- *
133
- * // Bearer auth automatically applied
134
- * const user = await api('GET /users/{id}', { params: { id: '123' } });
135
- *
136
- * // IAM SigV4 auth automatically applied
137
- * const tenant = await api('POST /tenants', { body: { name: 'Acme' } });
138
- * ```
139
- */
140
- declare function createAuthAwareFetcher<Paths, EndpointAuth extends Record<string, string | null> = Record<string, string | null>, SecuritySchemes extends Record<string, SecuritySchemeObject> = Record<string, SecuritySchemeObject>>(options: AuthFetcherOptions<EndpointAuth, SecuritySchemes> & {
141
- baseURL: string;
142
- }): TypedApiFunction<Paths>;
143
- /**
144
- * Type helper to extract the security scheme ID from an endpoint.
145
- */
146
- type GetEndpointAuth<EndpointAuth extends Record<string, string | null>, Endpoint extends keyof EndpointAuth> = EndpointAuth[Endpoint];
147
- /**
148
- * Type helper to get all authenticated endpoints.
149
- */
150
- type AuthenticatedEndpoints<EndpointAuth extends Record<string, string | null>> = { [K in keyof EndpointAuth]: EndpointAuth[K] extends null ? never : K }[keyof EndpointAuth];
151
- /**
152
- * Type helper to get all public endpoints.
153
- */
154
- type PublicEndpoints<EndpointAuth extends Record<string, string | null>> = { [K in keyof EndpointAuth]: EndpointAuth[K] extends null ? K : never }[keyof EndpointAuth];
155
- //# sourceMappingURL=auth-fetcher.d.ts.map
156
- //#endregion
157
- export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, FetcherOptions, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher };
158
- //# sourceMappingURL=auth-fetcher.d.mts.map
1
+ import { FetcherOptions } from "./types-BMGM6sZc.mjs";
2
+ import { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher } from "./auth-fetcher-DxS8zOLc.mjs";
3
+ export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, FetcherOptions, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher };
@@ -1,77 +1,4 @@
1
- import { TypedFetcher } from "./fetcher-CakjC9C7.mjs";
1
+ import "./fetcher-CakjC9C7.mjs";
2
+ import { createAuthAwareFetcher } from "./auth-fetcher-DOj0iz21.mjs";
2
3
 
3
- //#region src/auth-fetcher.ts
4
- /**
5
- * Creates an auth-aware fetcher that automatically applies the correct
6
- * authentication based on the endpoint being called.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { endpointAuth, securitySchemes, paths } from './openapi';
11
- * import { TokenClient } from '@geekmidas/auth/client';
12
- *
13
- * const tokenClient = new TokenClient({ ... });
14
- *
15
- * const api = createAuthAwareFetcher<paths>({
16
- * baseURL: 'https://api.example.com',
17
- * endpointAuth,
18
- * securitySchemes,
19
- * authStrategies: {
20
- * bearer: { type: 'bearer', tokenProvider: tokenClient },
21
- * iam: { type: 'iam', signer: awsSigner },
22
- * },
23
- * });
24
- *
25
- * // Bearer auth automatically applied
26
- * const user = await api('GET /users/{id}', { params: { id: '123' } });
27
- *
28
- * // IAM SigV4 auth automatically applied
29
- * const tenant = await api('POST /tenants', { body: { name: 'Acme' } });
30
- * ```
31
- */
32
- function createAuthAwareFetcher(options) {
33
- const { endpointAuth, securitySchemes, authStrategies, onRequest: userOnRequest,...fetcherOptions } = options;
34
- const baseFetcher = new TypedFetcher({
35
- ...fetcherOptions,
36
- onRequest: userOnRequest
37
- });
38
- const fetcher = async (endpoint, config) => {
39
- const schemeName = endpointAuth[endpoint];
40
- let authHeaders = {};
41
- if (schemeName) {
42
- const scheme = securitySchemes[schemeName];
43
- const strategy = authStrategies[schemeName];
44
- if (strategy && scheme) authHeaders = await resolveAuthHeaders(strategy, scheme);
45
- }
46
- const existingHeaders = config && "headers" in config && config.headers ? config.headers : {};
47
- const mergedConfig = {
48
- ...config,
49
- headers: {
50
- ...authHeaders,
51
- ...existingHeaders
52
- }
53
- };
54
- return baseFetcher.request(endpoint, mergedConfig);
55
- };
56
- return fetcher;
57
- }
58
- /**
59
- * Resolves auth headers based on the strategy and scheme.
60
- */
61
- async function resolveAuthHeaders(strategy, scheme) {
62
- switch (strategy.type) {
63
- case "bearer": return strategy.tokenProvider.createValidAuthHeaders();
64
- case "apiKey": {
65
- const apiKey = await strategy.apiKeyProvider.getApiKey();
66
- const headerName = strategy.headerName || scheme.name || "X-API-Key";
67
- if (scheme.in === "header" || !scheme.in) return { [headerName]: apiKey };
68
- return {};
69
- }
70
- case "iam": return {};
71
- default: return {};
72
- }
73
- }
74
-
75
- //#endregion
76
- export { createAuthAwareFetcher };
77
- //# sourceMappingURL=auth-fetcher.mjs.map
4
+ export { createAuthAwareFetcher };
@@ -1,4 +1,4 @@
1
- import { ExtractEndpointResponse, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, QueryEndpoint, TypedApiFunction } from "./types-D8Jrl4o3.mjs";
1
+ import { ExtractEndpointResponse, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, QueryEndpoint, TypedApiFunction } from "./types-BMGM6sZc.mjs";
2
2
  import { QueryClient, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
3
3
 
4
4
  //#region src/endpoint-hooks.d.ts
@@ -0,0 +1,25 @@
1
+ import { ErrorTransformer, ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint, WrappedResult } from "./types-BMGM6sZc.mjs";
2
+
3
+ //#region src/fetcher.d.ts
4
+ declare class TypedFetcher<Paths> {
5
+ private baseURL;
6
+ private defaultHeaders;
7
+ private options;
8
+ private fetchFn;
9
+ static getFetchFn(fn?: FetchFn): FetchFn;
10
+ constructor(options?: FetcherOptions);
11
+ request<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>): Promise<ExtractEndpointResponse<Paths, T>>;
12
+ wrap<E = unknown>(onError?: ErrorTransformer<E>): <T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
13
+ private parseEndpoint;
14
+ }
15
+ declare function createTypedFetcher<Paths>(options?: FetcherOptions): (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
16
+ wrap: <E = unknown>(onError?: ErrorTransformer<E>) => (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T> | undefined) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>) & (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
17
+ wrap: undefined;
18
+ };
19
+ };
20
+ type FetchFn = typeof fetch;
21
+ //# sourceMappingURL=fetcher.d.ts.map
22
+
23
+ //#endregion
24
+ export { FetchFn, TypedFetcher, createTypedFetcher };
25
+ //# sourceMappingURL=fetcher-C1xtCKpT.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher-C1xtCKpT.d.mts","names":[],"sources":["../src/fetcher.ts"],"sourcesContent":[],"mappings":";;;cAca;EAAA,QAAA,OAAY;EAAA,QAAA,cAAA;EAAA,QAMD,O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AoFzB,KApFyB,CAAA,CAAA,CAAA,QAAA,EAoFzB,CApFyB,EAAA,MAAA,CAAA,EAoFzB,qBApFyB,CAoFzB,KApFyB,EAoFzB,CApFyB,CAAA,GAAA,SAAA,EAAA,GAoFzB,OApFyB,CAoFzB,aApFyB,CAoFzB,uBApFyB,CAoFzB,KApFyB,EAoFzB,CApFyB,CAAA,EAoFzB,CApFyB,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,UA4Gb,aA5Ga,CA4GC,KA5GD,CAAA,CAAA,CAAA,QAAA,EA6GxB,CA7GwB,EAAA,MAAA,CAAA,EA8GzB,qBA9GyB,CA8GH,KA9GG,EA8GI,CA9GJ,CAAA,EAAA,GA8GM,OA9GN,CA8GM,uBA9GN,CA8GM,KA9GN,EA8GM,CA9GN,CAAA,CAAA,CAAA,GAAA;IAAO,IAAA,EAAA,SAAA;EAAC,CAAA;CAAT;AAmFW,KAsClC,OAAA,GAtCkC,OAsCjB,KAtCiB"}
@@ -0,0 +1,25 @@
1
+ import { ErrorTransformer, ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint, WrappedResult } from "./types-DMQMHePI.cjs";
2
+
3
+ //#region src/fetcher.d.ts
4
+ declare class TypedFetcher<Paths> {
5
+ private baseURL;
6
+ private defaultHeaders;
7
+ private options;
8
+ private fetchFn;
9
+ static getFetchFn(fn?: FetchFn): FetchFn;
10
+ constructor(options?: FetcherOptions);
11
+ request<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>): Promise<ExtractEndpointResponse<Paths, T>>;
12
+ wrap<E = unknown>(onError?: ErrorTransformer<E>): <T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
13
+ private parseEndpoint;
14
+ }
15
+ declare function createTypedFetcher<Paths>(options?: FetcherOptions): (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
16
+ wrap: <E = unknown>(onError?: ErrorTransformer<E>) => (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T> | undefined) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>) & (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
17
+ wrap: undefined;
18
+ };
19
+ };
20
+ type FetchFn = typeof fetch;
21
+ //# sourceMappingURL=fetcher.d.ts.map
22
+
23
+ //#endregion
24
+ export { FetchFn, TypedFetcher, createTypedFetcher };
25
+ //# sourceMappingURL=fetcher-cDrfwN-Y.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher-cDrfwN-Y.d.cts","names":[],"sources":["../src/fetcher.ts"],"sourcesContent":[],"mappings":";;;cAca;EAAA,QAAA,OAAY;EAAA,QAAA,cAAA;EAAA,QAMD,OAAA;EAAO,QAAG,OAAA;EAAO,OAmBnB,UAAA,CAAA,EAAA,CAAA,EAnBE,OAmBF,CAAA,EAnBY,OAmBZ;EAAmB,WAOF,CAAA,OAAA,CAAA,EAPjB,cAOiB;EAAK,OAAnB,CAAA,UAAA,aAAA,CAAc,KAAd,CAAA,CAAA,CAAA,QAAA,EACb,CADa,EAAA,MAAA,CAAA,EAEd,qBAFc,CAEQ,KAFR,EAEe,CAFf,CAAA,CAAA,EAGrB,OAHqB,CAGb,uBAHa,CAGW,KAHX,EAGkB,CAHlB,CAAA,CAAA;EAAa,IAC1B,CAAA,IAAA,OAAA,CAAA,CAAA,OAAA,CAAA,EAqFiB,gBArFjB,CAqFkC,CArFlC,CAAA,CAAA,EAAA,CAAA,UAsFQ,aAtFR,CAsFsB,KAtFtB,CAAA,CAAA,CAAA,QAAA,EAuFC,CAvFD,EAAA,MAAA,CAAA,EAwFA,qBAxFA,CAwFsB,KAxFtB,EAwF6B,CAxF7B,CAAA,EAA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+1,3 @@
1
- import { ErrorTransformer, ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint, WrappedResult } from "./types-DMQMHePI.cjs";
2
-
3
- //#region src/fetcher.d.ts
4
- declare class TypedFetcher<Paths> {
5
- private baseURL;
6
- private defaultHeaders;
7
- private options;
8
- private fetchFn;
9
- static getFetchFn(fn?: FetchFn): FetchFn;
10
- constructor(options?: FetcherOptions);
11
- request<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>): Promise<ExtractEndpointResponse<Paths, T>>;
12
- wrap<E = unknown>(onError?: ErrorTransformer<E>): <T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
13
- private parseEndpoint;
14
- }
15
- declare function createTypedFetcher<Paths>(options?: FetcherOptions): (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
16
- wrap: <E = unknown>(onError?: ErrorTransformer<E>) => (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T> | undefined) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>) & (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
17
- wrap: undefined;
18
- };
19
- };
20
- type FetchFn = typeof fetch;
21
- //# sourceMappingURL=fetcher.d.ts.map
22
-
23
- //#endregion
24
- export { FetchFn, FetcherOptions, TypedFetcher, WrappedResult, createTypedFetcher };
25
- //# sourceMappingURL=fetcher.d.cts.map
1
+ import { FetcherOptions, WrappedResult } from "./types-DMQMHePI.cjs";
2
+ import { FetchFn, TypedFetcher, createTypedFetcher } from "./fetcher-cDrfwN-Y.cjs";
3
+ export { FetchFn, FetcherOptions, TypedFetcher, WrappedResult, createTypedFetcher };
@@ -1,25 +1,3 @@
1
- import { ErrorTransformer, ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint, WrappedResult } from "./types-D8Jrl4o3.mjs";
2
-
3
- //#region src/fetcher.d.ts
4
- declare class TypedFetcher<Paths> {
5
- private baseURL;
6
- private defaultHeaders;
7
- private options;
8
- private fetchFn;
9
- static getFetchFn(fn?: FetchFn): FetchFn;
10
- constructor(options?: FetcherOptions);
11
- request<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>): Promise<ExtractEndpointResponse<Paths, T>>;
12
- wrap<E = unknown>(onError?: ErrorTransformer<E>): <T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
13
- private parseEndpoint;
14
- }
15
- declare function createTypedFetcher<Paths>(options?: FetcherOptions): (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
16
- wrap: <E = unknown>(onError?: ErrorTransformer<E>) => (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T> | undefined) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>) & (<T extends TypedEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>) => Promise<ExtractEndpointResponse<Paths, T>>) & {
17
- wrap: undefined;
18
- };
19
- };
20
- type FetchFn = typeof fetch;
21
- //# sourceMappingURL=fetcher.d.ts.map
22
-
23
- //#endregion
24
- export { FetchFn, FetcherOptions, TypedFetcher, WrappedResult, createTypedFetcher };
25
- //# sourceMappingURL=fetcher.d.mts.map
1
+ import { FetcherOptions, WrappedResult } from "./types-BMGM6sZc.mjs";
2
+ import { FetchFn, TypedFetcher, createTypedFetcher } from "./fetcher-C1xtCKpT.mjs";
3
+ export { FetchFn, FetcherOptions, TypedFetcher, WrappedResult, createTypedFetcher };
package/dist/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+ const require_fetcher = require('./fetcher-CwnSqc4D.cjs');
2
+ const require_auth_fetcher = require('./auth-fetcher-HILABmws.cjs');
3
+ require('./infer-6KKCgmg1.cjs');
4
+ require('./types-a8gm_IaQ.cjs');
5
+
6
+ exports.TypedFetcher = require_fetcher.TypedFetcher;
7
+ exports.createAuthAwareFetcher = require_auth_fetcher.createAuthAwareFetcher;
8
+ exports.createTypedFetcher = require_fetcher.createTypedFetcher;
@@ -0,0 +1,5 @@
1
+ import { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult } from "./types-DMQMHePI.cjs";
2
+ import { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher } from "./auth-fetcher-CBYuL6rx.cjs";
3
+ import { FetchFn, TypedFetcher, createTypedFetcher } from "./fetcher-cDrfwN-Y.cjs";
4
+ import { InferOpenApi, InferOpenApiFromEndpoint } from "./infer-DfRq5kIb.cjs";
5
+ export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetchFn, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, GetEndpointAuth, InferOpenApi, InferOpenApiFromEndpoint, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, PublicEndpoints, QueryEndpoint, RequestConfig, SecuritySchemeObject, TokenProvider, TypedApiFunction, TypedEndpoint, TypedFetcher, UsedSecuritySchemes, ValidEndpoint, WrappedApiFunction, WrappedResult, createAuthAwareFetcher, createTypedFetcher };
@@ -0,0 +1,5 @@
1
+ import { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult } from "./types-BMGM6sZc.mjs";
2
+ import { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher } from "./auth-fetcher-DxS8zOLc.mjs";
3
+ import { FetchFn, TypedFetcher, createTypedFetcher } from "./fetcher-C1xtCKpT.mjs";
4
+ import { InferOpenApi, InferOpenApiFromEndpoint } from "./infer-bTirNeNW.mjs";
5
+ export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetchFn, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, GetEndpointAuth, InferOpenApi, InferOpenApiFromEndpoint, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, PublicEndpoints, QueryEndpoint, RequestConfig, SecuritySchemeObject, TokenProvider, TypedApiFunction, TypedEndpoint, TypedFetcher, UsedSecuritySchemes, ValidEndpoint, WrappedApiFunction, WrappedResult, createAuthAwareFetcher, createTypedFetcher };
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import { TypedFetcher, createTypedFetcher } from "./fetcher-CakjC9C7.mjs";
2
+ import { createAuthAwareFetcher } from "./auth-fetcher-DOj0iz21.mjs";
3
+ import "./infer-uCUq1whM.mjs";
4
+ import "./types-BH8WgGrm.mjs";
5
+
6
+ export { TypedFetcher, createAuthAwareFetcher, createTypedFetcher };
File without changes