@geekmidas/client 10.0.0-alpha.2 → 10.0.0-alpha.21

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 (103) hide show
  1. package/README.md +39 -57
  2. package/dist/auth-fetcher.cjs +78 -3
  3. package/dist/auth-fetcher.cjs.map +1 -0
  4. package/dist/auth-fetcher.d.cts +155 -3
  5. package/dist/auth-fetcher.d.cts.map +1 -0
  6. package/dist/auth-fetcher.d.mts +155 -3
  7. package/dist/auth-fetcher.d.mts.map +1 -0
  8. package/dist/auth-fetcher.mjs +77 -3
  9. package/dist/auth-fetcher.mjs.map +1 -0
  10. package/dist/endpoint-hooks.cjs +11 -15
  11. package/dist/endpoint-hooks.cjs.map +1 -1
  12. package/dist/endpoint-hooks.d.cts +4 -7
  13. package/dist/endpoint-hooks.d.cts.map +1 -1
  14. package/dist/endpoint-hooks.d.mts +4 -7
  15. package/dist/endpoint-hooks.d.mts.map +1 -1
  16. package/dist/endpoint-hooks.mjs +5 -9
  17. package/dist/endpoint-hooks.mjs.map +1 -1
  18. package/dist/fetcher.cjs +111 -3
  19. package/dist/fetcher.cjs.map +1 -0
  20. package/dist/fetcher.d.cts +23 -3
  21. package/dist/fetcher.d.cts.map +1 -0
  22. package/dist/fetcher.d.mts +23 -3
  23. package/dist/fetcher.d.mts.map +1 -0
  24. package/dist/fetcher.mjs +86 -2
  25. package/dist/fetcher.mjs.map +1 -0
  26. package/dist/index.cjs +9 -6
  27. package/dist/index.d.cts +6 -5
  28. package/dist/index.d.mts +6 -5
  29. package/dist/index.mjs +6 -6
  30. package/dist/infer.cjs +0 -1
  31. package/dist/infer.d.cts +130 -2
  32. package/dist/infer.d.cts.map +1 -0
  33. package/dist/infer.d.mts +130 -2
  34. package/dist/infer.d.mts.map +1 -0
  35. package/dist/infer.mjs +1 -1
  36. package/dist/methods.cjs +21 -0
  37. package/dist/methods.cjs.map +1 -0
  38. package/dist/methods.d.cts +23 -0
  39. package/dist/methods.d.cts.map +1 -0
  40. package/dist/methods.d.mts +23 -0
  41. package/dist/methods.d.mts.map +1 -0
  42. package/dist/methods.mjs +19 -0
  43. package/dist/methods.mjs.map +1 -0
  44. package/dist/openapi-hooks.cjs +13 -16
  45. package/dist/openapi-hooks.cjs.map +1 -1
  46. package/dist/openapi-hooks.d.cts +8 -11
  47. package/dist/openapi-hooks.d.cts.map +1 -1
  48. package/dist/openapi-hooks.d.mts +8 -11
  49. package/dist/openapi-hooks.d.mts.map +1 -1
  50. package/dist/openapi-hooks.mjs +9 -12
  51. package/dist/openapi-hooks.mjs.map +1 -1
  52. package/dist/openapi-types.d.cts +5 -6
  53. package/dist/openapi-types.d.cts.map +1 -1
  54. package/dist/openapi-types.d.mts +5 -6
  55. package/dist/openapi-types.d.mts.map +1 -1
  56. package/dist/react-query.cjs +17 -16
  57. package/dist/react-query.cjs.map +1 -1
  58. package/dist/react-query.d.cts +12 -17
  59. package/dist/react-query.d.cts.map +1 -1
  60. package/dist/react-query.d.mts +12 -17
  61. package/dist/react-query.d.mts.map +1 -1
  62. package/dist/react-query.mjs +10 -9
  63. package/dist/react-query.mjs.map +1 -1
  64. package/dist/types.cjs +0 -1
  65. package/dist/types.d.cts +114 -2
  66. package/dist/types.d.cts.map +1 -0
  67. package/dist/types.d.mts +114 -2
  68. package/dist/types.d.mts.map +1 -0
  69. package/dist/types.mjs +1 -1
  70. package/package.json +14 -14
  71. package/dist/auth-fetcher-CBYuL6rx.d.cts +0 -158
  72. package/dist/auth-fetcher-CBYuL6rx.d.cts.map +0 -1
  73. package/dist/auth-fetcher-DOj0iz21.mjs +0 -77
  74. package/dist/auth-fetcher-DOj0iz21.mjs.map +0 -1
  75. package/dist/auth-fetcher-DxS8zOLc.d.mts +0 -158
  76. package/dist/auth-fetcher-DxS8zOLc.d.mts.map +0 -1
  77. package/dist/auth-fetcher-HILABmws.cjs +0 -82
  78. package/dist/auth-fetcher-HILABmws.cjs.map +0 -1
  79. package/dist/chunk-CUT6urMc.cjs +0 -30
  80. package/dist/fetcher-C1xtCKpT.d.mts +0 -25
  81. package/dist/fetcher-C1xtCKpT.d.mts.map +0 -1
  82. package/dist/fetcher-CakjC9C7.mjs +0 -88
  83. package/dist/fetcher-CakjC9C7.mjs.map +0 -1
  84. package/dist/fetcher-CwnSqc4D.cjs +0 -100
  85. package/dist/fetcher-CwnSqc4D.cjs.map +0 -1
  86. package/dist/fetcher-cDrfwN-Y.d.cts +0 -25
  87. package/dist/fetcher-cDrfwN-Y.d.cts.map +0 -1
  88. package/dist/infer-6KKCgmg1.cjs +0 -0
  89. package/dist/infer-DfRq5kIb.d.cts +0 -133
  90. package/dist/infer-DfRq5kIb.d.cts.map +0 -1
  91. package/dist/infer-bTirNeNW.d.mts +0 -133
  92. package/dist/infer-bTirNeNW.d.mts.map +0 -1
  93. package/dist/infer-uCUq1whM.mjs +0 -0
  94. package/dist/openapi.cjs +0 -526
  95. package/dist/openapi.cjs.map +0 -1
  96. package/dist/openapi.mjs +0 -501
  97. package/dist/openapi.mjs.map +0 -1
  98. package/dist/types-BH8WgGrm.mjs +0 -0
  99. package/dist/types-BMGM6sZc.d.mts +0 -110
  100. package/dist/types-BMGM6sZc.d.mts.map +0 -1
  101. package/dist/types-DMQMHePI.d.cts +0 -110
  102. package/dist/types-DMQMHePI.d.cts.map +0 -1
  103. package/dist/types-a8gm_IaQ.cjs +0 -0
@@ -1,82 +0,0 @@
1
- const require_fetcher = require('./fetcher-CwnSqc4D.cjs');
2
-
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 require_fetcher.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
- Object.defineProperty(exports, 'createAuthAwareFetcher', {
77
- enumerable: true,
78
- get: function () {
79
- return createAuthAwareFetcher;
80
- }
81
- });
82
- //# sourceMappingURL=auth-fetcher-HILABmws.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-fetcher-HILABmws.cjs","names":["options: AuthFetcherOptions<EndpointAuth, SecuritySchemes> & {\n\t\tbaseURL: string;\n\t}","TypedFetcher","endpoint: T","config?: FilteredRequestConfig<Paths, T>","authHeaders: Record<string, string>","strategy: AuthStrategy","scheme: SecuritySchemeObject"],"sources":["../src/auth-fetcher.ts"],"sourcesContent":["import { TypedFetcher } from './fetcher';\nimport type {\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tTypedApiFunction,\n\tTypedEndpoint,\n} from './types';\n\nexport type { FetcherOptions } from './types';\n\n/**\n * Security scheme object matching OpenAPI 3.1 specification.\n */\nexport interface SecuritySchemeObject {\n\ttype: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';\n\tdescription?: string;\n\tname?: string;\n\tin?: 'query' | 'header' | 'cookie';\n\tscheme?: string;\n\tbearerFormat?: string;\n\tflows?: Record<string, unknown>;\n\topenIdConnectUrl?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Extract all non-null security scheme IDs that are actually used in the API.\n * This gives us the union of scheme names that endpoints require.\n */\nexport type UsedSecuritySchemes<\n\tEndpointAuth extends Record<string, string | null>,\n> = NonNullable<EndpointAuth[keyof EndpointAuth]>;\n\n/**\n * Interface for token storage and retrieval.\n * Compatible with @geekmidas/auth TokenClient.\n */\nexport interface TokenProvider {\n\t/**\n\t * Get a valid access token, refreshing if necessary.\n\t */\n\tgetValidAccessToken(): Promise<string | null>;\n\n\t/**\n\t * Create Authorization headers from the current token.\n\t */\n\tcreateValidAuthHeaders(): Promise<Record<string, string>>;\n}\n\n/**\n * Interface for API key providers.\n */\nexport interface ApiKeyProvider {\n\t/**\n\t * Get the API key value.\n\t */\n\tgetApiKey(): Promise<string> | string;\n}\n\n/**\n * Interface for AWS SigV4 request signing.\n */\nexport interface AwsSigner {\n\t/**\n\t * Sign a request with AWS SigV4.\n\t * @param url - The request URL\n\t * @param init - The request init object\n\t * @returns Headers to add to the request\n\t */\n\tsign(url: string, init: RequestInit): Promise<Record<string, string>>;\n}\n\n/**\n * Auth strategy configuration for a specific security scheme type.\n */\nexport type AuthStrategy =\n\t| { type: 'bearer'; tokenProvider: TokenProvider }\n\t| { type: 'apiKey'; apiKeyProvider: ApiKeyProvider; headerName?: string }\n\t| { type: 'iam'; signer: AwsSigner }\n\t| { type: 'none' };\n\n/**\n * Options for creating an auth-aware fetcher.\n *\n * @template EndpointAuth - Map of endpoint strings to their auth scheme (or null for public)\n * @template SecuritySchemes - Available security scheme definitions\n */\nexport interface AuthFetcherOptions<\n\tEndpointAuth extends Record<string, string | null>,\n\tSecuritySchemes extends Record<string, SecuritySchemeObject>,\n> extends Omit<FetcherOptions, 'onRequest'> {\n\t/**\n\t * Runtime map of endpoints to their required auth scheme.\n\t * Generated by `gkm openapi --ts`.\n\t */\n\tendpointAuth: EndpointAuth;\n\n\t/**\n\t * Security scheme definitions.\n\t * Generated by `gkm openapi --ts`.\n\t */\n\tsecuritySchemes: SecuritySchemes;\n\n\t/**\n\t * Auth strategies for security schemes that are actually used.\n\t * Only schemes referenced in endpointAuth are required.\n\t *\n\t * @example\n\t * ```typescript\n\t * // If endpointAuth has: { 'GET /users': 'jwt', 'POST /data': 'iam', 'GET /public': null }\n\t * // Then authStrategies must include strategies for 'jwt' and 'iam'\n\t * authStrategies: {\n\t * jwt: { type: 'bearer', tokenProvider },\n\t * iam: { type: 'iam', signer: awsSigner },\n\t * }\n\t * ```\n\t */\n\tauthStrategies: Record<UsedSecuritySchemes<EndpointAuth>, AuthStrategy>;\n\n\t/**\n\t * Optional request interceptor (runs after auth headers are added).\n\t */\n\tonRequest?: (config: RequestInit) => RequestInit | Promise<RequestInit>;\n}\n\n/**\n * Creates an auth-aware fetcher that automatically applies the correct\n * authentication based on the endpoint being called.\n *\n * @example\n * ```typescript\n * import { endpointAuth, securitySchemes, paths } from './openapi';\n * import { TokenClient } from '@geekmidas/auth/client';\n *\n * const tokenClient = new TokenClient({ ... });\n *\n * const api = createAuthAwareFetcher<paths>({\n * baseURL: 'https://api.example.com',\n * endpointAuth,\n * securitySchemes,\n * authStrategies: {\n * bearer: { type: 'bearer', tokenProvider: tokenClient },\n * iam: { type: 'iam', signer: awsSigner },\n * },\n * });\n *\n * // Bearer auth automatically applied\n * const user = await api('GET /users/{id}', { params: { id: '123' } });\n *\n * // IAM SigV4 auth automatically applied\n * const tenant = await api('POST /tenants', { body: { name: 'Acme' } });\n * ```\n */\nexport function createAuthAwareFetcher<\n\tPaths,\n\tEndpointAuth extends Record<string, string | null> = Record<\n\t\tstring,\n\t\tstring | null\n\t>,\n\tSecuritySchemes extends Record<string, SecuritySchemeObject> = Record<\n\t\tstring,\n\t\tSecuritySchemeObject\n\t>,\n>(\n\toptions: AuthFetcherOptions<EndpointAuth, SecuritySchemes> & {\n\t\tbaseURL: string;\n\t},\n): TypedApiFunction<Paths> {\n\tconst {\n\t\tendpointAuth,\n\t\tsecuritySchemes,\n\t\tauthStrategies,\n\t\tonRequest: userOnRequest,\n\t\t...fetcherOptions\n\t} = options;\n\n\t// Create base fetcher with user's onRequest if provided\n\tconst baseFetcher = new TypedFetcher<Paths>({\n\t\t...fetcherOptions,\n\t\tonRequest: userOnRequest,\n\t});\n\n\tconst fetcher = async <T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<ExtractEndpointResponse<Paths, T>> => {\n\t\t// Look up auth requirement for this endpoint\n\t\tconst schemeName = endpointAuth[endpoint as keyof EndpointAuth] as\n\t\t\t| string\n\t\t\t| null;\n\n\t\tlet authHeaders: Record<string, string> = {};\n\n\t\tif (schemeName) {\n\t\t\tconst scheme = securitySchemes[schemeName as keyof SecuritySchemes];\n\t\t\t// Since authStrategies is now required to have all used schemes,\n\t\t\t// we can safely access it - TypeScript ensures the strategy exists\n\t\t\tconst strategy =\n\t\t\t\tauthStrategies[schemeName as UsedSecuritySchemes<EndpointAuth>];\n\n\t\t\tif (strategy && scheme) {\n\t\t\t\tauthHeaders = await resolveAuthHeaders(strategy, scheme);\n\t\t\t}\n\t\t}\n\n\t\t// Merge auth headers with config headers\n\t\tconst existingHeaders =\n\t\t\tconfig && 'headers' in config && config.headers\n\t\t\t\t? (config.headers as Record<string, string>)\n\t\t\t\t: {};\n\n\t\tconst mergedConfig = {\n\t\t\t...config,\n\t\t\theaders: {\n\t\t\t\t...authHeaders,\n\t\t\t\t...existingHeaders,\n\t\t\t},\n\t\t} as unknown as FilteredRequestConfig<Paths, T>;\n\n\t\treturn baseFetcher.request(endpoint, mergedConfig);\n\t};\n\n\treturn fetcher as TypedApiFunction<Paths>;\n}\n\n/**\n * Resolves auth headers based on the strategy and scheme.\n */\nasync function resolveAuthHeaders(\n\tstrategy: AuthStrategy,\n\tscheme: SecuritySchemeObject,\n): Promise<Record<string, string>> {\n\tswitch (strategy.type) {\n\t\tcase 'bearer': {\n\t\t\treturn strategy.tokenProvider.createValidAuthHeaders();\n\t\t}\n\n\t\tcase 'apiKey': {\n\t\t\tconst apiKey = await strategy.apiKeyProvider.getApiKey();\n\t\t\tconst headerName = strategy.headerName || scheme.name || 'X-API-Key';\n\n\t\t\tif (scheme.in === 'header' || !scheme.in) {\n\t\t\t\treturn { [headerName]: apiKey };\n\t\t\t}\n\t\t\t// Note: query and cookie API keys are handled differently\n\t\t\t// For now, we only support header-based API keys\n\t\t\treturn {};\n\t\t}\n\n\t\tcase 'iam': {\n\t\t\t// IAM signing requires the full URL and request config\n\t\t\t// This is a simplified version - full implementation would need\n\t\t\t// access to the complete request\n\t\t\t// For now, return empty - the actual signing should be done\n\t\t\t// in a custom onRequest interceptor if needed\n\t\t\treturn {};\n\t\t}\n\t\tdefault:\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Type helper to extract the security scheme ID from an endpoint.\n */\nexport type GetEndpointAuth<\n\tEndpointAuth extends Record<string, string | null>,\n\tEndpoint extends keyof EndpointAuth,\n> = EndpointAuth[Endpoint];\n\n/**\n * Type helper to get all authenticated endpoints.\n */\nexport type AuthenticatedEndpoints<\n\tEndpointAuth extends Record<string, string | null>,\n> = {\n\t[K in keyof EndpointAuth]: EndpointAuth[K] extends null ? never : K;\n}[keyof EndpointAuth];\n\n/**\n * Type helper to get all public endpoints.\n */\nexport type PublicEndpoints<\n\tEndpointAuth extends Record<string, string | null>,\n> = {\n\t[K in keyof EndpointAuth]: EndpointAuth[K] extends null ? K : never;\n}[keyof EndpointAuth];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0JA,SAAgB,uBAWfA,SAG0B;CAC1B,MAAM,EACL,cACA,iBACA,gBACA,WAAW,cACX,GAAG,gBACH,GAAG;CAGJ,MAAM,cAAc,IAAIC,6BAAoB;EAC3C,GAAG;EACH,WAAW;CACX;CAED,MAAM,UAAU,OACfC,UACAC,WACgD;EAEhD,MAAM,aAAa,aAAa;EAIhC,IAAIC,cAAsC,CAAE;AAE5C,MAAI,YAAY;GACf,MAAM,SAAS,gBAAgB;GAG/B,MAAM,WACL,eAAe;AAEhB,OAAI,YAAY,OACf,eAAc,MAAM,mBAAmB,UAAU,OAAO;EAEzD;EAGD,MAAM,kBACL,UAAU,aAAa,UAAU,OAAO,UACpC,OAAO,UACR,CAAE;EAEN,MAAM,eAAe;GACpB,GAAG;GACH,SAAS;IACR,GAAG;IACH,GAAG;GACH;EACD;AAED,SAAO,YAAY,QAAQ,UAAU,aAAa;CAClD;AAED,QAAO;AACP;;;;AAKD,eAAe,mBACdC,UACAC,QACkC;AAClC,SAAQ,SAAS,MAAjB;EACC,KAAK,SACJ,QAAO,SAAS,cAAc,wBAAwB;EAGvD,KAAK,UAAU;GACd,MAAM,SAAS,MAAM,SAAS,eAAe,WAAW;GACxD,MAAM,aAAa,SAAS,cAAc,OAAO,QAAQ;AAEzD,OAAI,OAAO,OAAO,aAAa,OAAO,GACrC,QAAO,GAAG,aAAa,OAAQ;AAIhC,UAAO,CAAE;EACT;EAED,KAAK,MAMJ,QAAO,CAAE;EAEV,QACC,QAAO,CAAE;CACV;AACD"}
@@ -1,30 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
-
25
- Object.defineProperty(exports, '__toESM', {
26
- enumerable: true,
27
- get: function () {
28
- return __toESM;
29
- }
30
- });
@@ -1,25 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher-C1xtCKpT.d.mts","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,aAtF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GM,CA9GN,CAAA,CAAA,CAAA,GAAA;IAAO,IAAA,EAAA,SAAA;EAAC,CAAA;CAAT;AAmFW,KAsClC,OAAA,GAtCkC,OAsCjB,KAtCiB"}
@@ -1,88 +0,0 @@
1
- import qs from "qs";
2
-
3
- //#region src/fetcher.ts
4
- var TypedFetcher = class TypedFetcher {
5
- baseURL;
6
- defaultHeaders;
7
- options;
8
- fetchFn;
9
- static getFetchFn(fn) {
10
- if (fn) return fn;
11
- if (typeof window !== "undefined" && typeof window.fetch === "function") return window.fetch.bind(window);
12
- if (typeof globalThis !== "undefined" && typeof globalThis.fetch === "function") return globalThis.fetch.bind(globalThis);
13
- throw new Error("No fetch implementation found");
14
- }
15
- constructor(options = {}) {
16
- this.baseURL = options.baseURL || "";
17
- this.defaultHeaders = options.headers || {};
18
- this.options = options;
19
- this.fetchFn = TypedFetcher.getFetchFn(options.fetch);
20
- }
21
- async request(endpoint, config) {
22
- const { method, route } = this.parseEndpoint(endpoint);
23
- let url = route;
24
- if (config && "params" in config && config.params) Object.entries(config.params).forEach(([key, value]) => {
25
- url = url.replace(`{${key}}`, encodeURIComponent(String(value)));
26
- });
27
- if (config && "query" in config && config.query) {
28
- const queryString = qs.stringify(config.query, {
29
- encode: true,
30
- arrayFormat: "brackets",
31
- skipNulls: true
32
- });
33
- if (queryString) url += `?${queryString}`;
34
- }
35
- let requestConfig = {
36
- method: method.toUpperCase(),
37
- headers: {
38
- ...this.defaultHeaders,
39
- ...config && "headers" in config && config.headers || {}
40
- }
41
- };
42
- if (config && "body" in config && config.body) {
43
- requestConfig.body = JSON.stringify(config.body);
44
- requestConfig.headers = {
45
- ...requestConfig.headers,
46
- "Content-Type": "application/json"
47
- };
48
- }
49
- if (this.options.onRequest) requestConfig = await this.options.onRequest(requestConfig);
50
- try {
51
- let response = await this.fetchFn(`${this.baseURL}${url}`, requestConfig);
52
- if (this.options.onResponse) response = await this.options.onResponse(response);
53
- if (!response.ok) throw response;
54
- if (response.status === 204 || response.headers.get("content-length") === "0") return void 0;
55
- const data = await response.json();
56
- return data;
57
- } catch (error) {
58
- if (this.options.onError) await this.options.onError(error);
59
- throw error;
60
- }
61
- }
62
- wrap(onError) {
63
- return (endpoint, config) => this.request(endpoint, config).then((data) => ({
64
- ok: true,
65
- data
66
- }), async (error) => ({
67
- ok: false,
68
- error: onError ? await onError(error) : error
69
- }));
70
- }
71
- parseEndpoint(endpoint) {
72
- const [method, ...routeParts] = endpoint.split(" ");
73
- const route = routeParts.join(" ");
74
- return {
75
- method: method?.toLowerCase() ?? "",
76
- route
77
- };
78
- }
79
- };
80
- function createTypedFetcher(options) {
81
- const fetcher = new TypedFetcher(options);
82
- const fn = (endpoint, config) => fetcher.request(endpoint, config);
83
- return Object.assign(fn, { wrap: (onError) => Object.assign(fetcher.wrap(onError), fn, { wrap: void 0 }) });
84
- }
85
-
86
- //#endregion
87
- export { TypedFetcher, createTypedFetcher };
88
- //# sourceMappingURL=fetcher-CakjC9C7.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher-CakjC9C7.mjs","names":["fn?: FetchFn","options: FetcherOptions","endpoint: T","config?: FilteredRequestConfig<Paths, T>","requestConfig: RequestInit","onError?: ErrorTransformer<E>","options?: FetcherOptions"],"sources":["../src/fetcher.ts"],"sourcesContent":["import qs from 'qs';\nimport type {\n\tEndpointString,\n\tErrorTransformer,\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tParseEndpoint,\n\tTypedEndpoint,\n\tWrappedResult,\n} from './types';\n\nexport type { FetcherOptions, WrappedResult } from './types';\n\nexport class TypedFetcher<Paths> {\n\tprivate baseURL: string;\n\tprivate defaultHeaders: Record<string, string>;\n\tprivate options: FetcherOptions;\n\tprivate fetchFn: FetchFn;\n\n\tstatic getFetchFn(fn?: FetchFn): FetchFn {\n\t\tif (fn) {\n\t\t\treturn fn;\n\t\t}\n\n\t\tif (typeof window !== 'undefined' && typeof window.fetch === 'function') {\n\t\t\treturn window.fetch.bind(window);\n\t\t}\n\n\t\tif (\n\t\t\ttypeof globalThis !== 'undefined' &&\n\t\t\ttypeof globalThis.fetch === 'function'\n\t\t) {\n\t\t\treturn globalThis.fetch.bind(globalThis);\n\t\t}\n\n\t\tthrow new Error('No fetch implementation found');\n\t}\n\n\tconstructor(options: FetcherOptions = {}) {\n\t\tthis.baseURL = options.baseURL || '';\n\t\tthis.defaultHeaders = options.headers || {};\n\t\tthis.options = options;\n\t\tthis.fetchFn = TypedFetcher.getFetchFn(options.fetch);\n\t}\n\n\tasync request<T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<ExtractEndpointResponse<Paths, T>> {\n\t\tconst { method, route } = this.parseEndpoint(endpoint);\n\n\t\t// Replace path parameters\n\t\tlet url = route;\n\t\tif (config && 'params' in config && config.params) {\n\t\t\tObject.entries(config.params as Record<string, unknown>).forEach(\n\t\t\t\t([key, value]) => {\n\t\t\t\t\turl = url.replace(`{${key}}`, encodeURIComponent(String(value)));\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\t// Add query parameters\n\t\tif (config && 'query' in config && config.query) {\n\t\t\tconst queryString = qs.stringify(config.query, {\n\t\t\t\tencode: true,\n\t\t\t\tarrayFormat: 'brackets',\n\t\t\t\tskipNulls: true,\n\t\t\t});\n\t\t\tif (queryString) {\n\t\t\t\turl += `?${queryString}`;\n\t\t\t}\n\t\t}\n\n\t\t// Build request configuration\n\t\tlet requestConfig: RequestInit = {\n\t\t\tmethod: method.toUpperCase(),\n\t\t\theaders: {\n\t\t\t\t...this.defaultHeaders,\n\t\t\t\t...((config && 'headers' in config && config.headers) || {}),\n\t\t\t},\n\t\t};\n\n\t\t// Add body if present\n\t\tif (config && 'body' in config && config.body) {\n\t\t\trequestConfig.body = JSON.stringify(config.body);\n\t\t\trequestConfig.headers = {\n\t\t\t\t...requestConfig.headers,\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t};\n\t\t}\n\n\t\t// Apply request interceptor\n\t\tif (this.options.onRequest) {\n\t\t\trequestConfig = await this.options.onRequest(requestConfig);\n\t\t}\n\n\t\ttry {\n\t\t\t// Make the request\n\t\t\tlet response = await this.fetchFn(`${this.baseURL}${url}`, requestConfig);\n\n\t\t\t// Apply response interceptor\n\t\t\tif (this.options.onResponse) {\n\t\t\t\tresponse = await this.options.onResponse(response);\n\t\t\t}\n\n\t\t\t// Handle errors\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow response;\n\t\t\t}\n\n\t\t\t// Handle empty responses (204 No Content, etc.)\n\t\t\tif (\n\t\t\t\tresponse.status === 204 ||\n\t\t\t\tresponse.headers.get('content-length') === '0'\n\t\t\t) {\n\t\t\t\treturn undefined as ExtractEndpointResponse<Paths, T>;\n\t\t\t}\n\n\t\t\t// Parse JSON response\n\t\t\tconst data = await response.json();\n\t\t\treturn data as ExtractEndpointResponse<Paths, T>;\n\t\t} catch (error) {\n\t\t\t// Apply error handler\n\t\t\tif (this.options.onError) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tawait this.options.onError(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\twrap<E = unknown>(onError?: ErrorTransformer<E>) {\n\t\treturn <T extends TypedEndpoint<Paths>>(\n\t\t\tendpoint: T,\n\t\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\t): Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>> =>\n\t\t\tthis.request(endpoint, config).then(\n\t\t\t\t(data) => ({ ok: true as const, data }),\n\t\t\t\tasync (error) => ({\n\t\t\t\t\tok: false as const,\n\t\t\t\t\terror: onError ? await onError(error) : (error as E),\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\tprivate parseEndpoint<T extends EndpointString>(\n\t\tendpoint: T,\n\t): ParseEndpoint<T> {\n\t\tconst [method, ...routeParts] = endpoint.split(' ');\n\t\tconst route = routeParts.join(' ');\n\t\treturn { method: method?.toLowerCase() ?? '', route } as ParseEndpoint<T>;\n\t}\n}\n\nexport function createTypedFetcher<Paths>(options?: FetcherOptions) {\n\tconst fetcher = new TypedFetcher<Paths>(options);\n\tconst fn = <T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t) => fetcher.request(endpoint, config);\n\n\treturn Object.assign(fn, {\n\t\twrap: <E = unknown>(onError?: ErrorTransformer<E>) =>\n\t\t\tObject.assign(fetcher.wrap(onError), fn, {\n\t\t\t\twrap: undefined,\n\t\t\t}),\n\t});\n}\n\nexport type FetchFn = typeof fetch;\n"],"mappings":";;;AAcA,IAAa,eAAb,MAAa,aAAoB;CAChC,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,OAAO,WAAWA,IAAuB;AACxC,MAAI,GACH,QAAO;AAGR,aAAW,WAAW,sBAAsB,OAAO,UAAU,WAC5D,QAAO,OAAO,MAAM,KAAK,OAAO;AAGjC,aACQ,eAAe,sBACf,WAAW,UAAU,WAE5B,QAAO,WAAW,MAAM,KAAK,WAAW;AAGzC,QAAM,IAAI,MAAM;CAChB;CAED,YAAYC,UAA0B,CAAE,GAAE;AACzC,OAAK,UAAU,QAAQ,WAAW;AAClC,OAAK,iBAAiB,QAAQ,WAAW,CAAE;AAC3C,OAAK,UAAU;AACf,OAAK,UAAU,aAAa,WAAW,QAAQ,MAAM;CACrD;CAED,MAAM,QACLC,UACAC,QAC6C;EAC7C,MAAM,EAAE,QAAQ,OAAO,GAAG,KAAK,cAAc,SAAS;EAGtD,IAAI,MAAM;AACV,MAAI,UAAU,YAAY,UAAU,OAAO,OAC1C,QAAO,QAAQ,OAAO,OAAkC,CAAC,QACxD,CAAC,CAAC,KAAK,MAAM,KAAK;AACjB,SAAM,IAAI,SAAS,GAAG,IAAI,IAAI,mBAAmB,OAAO,MAAM,CAAC,CAAC;EAChE,EACD;AAIF,MAAI,UAAU,WAAW,UAAU,OAAO,OAAO;GAChD,MAAM,cAAc,GAAG,UAAU,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AAQ,aAAa,IAAI;GAAI;EAAO;CACrD;AACD;AAED,SAAgB,mBAA0BI,SAA0B;CACnE,MAAM,UAAU,IAAI,aAAoB;CACxC,MAAM,KAAK,CACVJ,UACAC,WACI,QAAQ,QAAQ,UAAU,OAAO;AAEtC,QAAO,OAAO,OAAO,IAAI,EACxB,MAAM,CAAcE,YACnB,OAAO,OAAO,QAAQ,KAAK,QAAQ,EAAE,IAAI,EACxC,aACA,EAAC,CACH,EAAC;AACF"}
@@ -1,100 +0,0 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const qs = require_chunk.__toESM(require("qs"));
3
-
4
- //#region src/fetcher.ts
5
- var TypedFetcher = class TypedFetcher {
6
- baseURL;
7
- defaultHeaders;
8
- options;
9
- fetchFn;
10
- static getFetchFn(fn) {
11
- if (fn) return fn;
12
- if (typeof window !== "undefined" && typeof window.fetch === "function") return window.fetch.bind(window);
13
- if (typeof globalThis !== "undefined" && typeof globalThis.fetch === "function") return globalThis.fetch.bind(globalThis);
14
- throw new Error("No fetch implementation found");
15
- }
16
- constructor(options = {}) {
17
- this.baseURL = options.baseURL || "";
18
- this.defaultHeaders = options.headers || {};
19
- this.options = options;
20
- this.fetchFn = TypedFetcher.getFetchFn(options.fetch);
21
- }
22
- async request(endpoint, config) {
23
- const { method, route } = this.parseEndpoint(endpoint);
24
- let url = route;
25
- if (config && "params" in config && config.params) Object.entries(config.params).forEach(([key, value]) => {
26
- url = url.replace(`{${key}}`, encodeURIComponent(String(value)));
27
- });
28
- if (config && "query" in config && config.query) {
29
- const queryString = qs.default.stringify(config.query, {
30
- encode: true,
31
- arrayFormat: "brackets",
32
- skipNulls: true
33
- });
34
- if (queryString) url += `?${queryString}`;
35
- }
36
- let requestConfig = {
37
- method: method.toUpperCase(),
38
- headers: {
39
- ...this.defaultHeaders,
40
- ...config && "headers" in config && config.headers || {}
41
- }
42
- };
43
- if (config && "body" in config && config.body) {
44
- requestConfig.body = JSON.stringify(config.body);
45
- requestConfig.headers = {
46
- ...requestConfig.headers,
47
- "Content-Type": "application/json"
48
- };
49
- }
50
- if (this.options.onRequest) requestConfig = await this.options.onRequest(requestConfig);
51
- try {
52
- let response = await this.fetchFn(`${this.baseURL}${url}`, requestConfig);
53
- if (this.options.onResponse) response = await this.options.onResponse(response);
54
- if (!response.ok) throw response;
55
- if (response.status === 204 || response.headers.get("content-length") === "0") return void 0;
56
- const data = await response.json();
57
- return data;
58
- } catch (error) {
59
- if (this.options.onError) await this.options.onError(error);
60
- throw error;
61
- }
62
- }
63
- wrap(onError) {
64
- return (endpoint, config) => this.request(endpoint, config).then((data) => ({
65
- ok: true,
66
- data
67
- }), async (error) => ({
68
- ok: false,
69
- error: onError ? await onError(error) : error
70
- }));
71
- }
72
- parseEndpoint(endpoint) {
73
- const [method, ...routeParts] = endpoint.split(" ");
74
- const route = routeParts.join(" ");
75
- return {
76
- method: method?.toLowerCase() ?? "",
77
- route
78
- };
79
- }
80
- };
81
- function createTypedFetcher(options) {
82
- const fetcher = new TypedFetcher(options);
83
- const fn = (endpoint, config) => fetcher.request(endpoint, config);
84
- return Object.assign(fn, { wrap: (onError) => Object.assign(fetcher.wrap(onError), fn, { wrap: void 0 }) });
85
- }
86
-
87
- //#endregion
88
- Object.defineProperty(exports, 'TypedFetcher', {
89
- enumerable: true,
90
- get: function () {
91
- return TypedFetcher;
92
- }
93
- });
94
- Object.defineProperty(exports, 'createTypedFetcher', {
95
- enumerable: true,
96
- get: function () {
97
- return createTypedFetcher;
98
- }
99
- });
100
- //# sourceMappingURL=fetcher-CwnSqc4D.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher-CwnSqc4D.cjs","names":["fn?: FetchFn","options: FetcherOptions","endpoint: T","config?: FilteredRequestConfig<Paths, T>","requestConfig: RequestInit","onError?: ErrorTransformer<E>","options?: FetcherOptions"],"sources":["../src/fetcher.ts"],"sourcesContent":["import qs from 'qs';\nimport type {\n\tEndpointString,\n\tErrorTransformer,\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tParseEndpoint,\n\tTypedEndpoint,\n\tWrappedResult,\n} from './types';\n\nexport type { FetcherOptions, WrappedResult } from './types';\n\nexport class TypedFetcher<Paths> {\n\tprivate baseURL: string;\n\tprivate defaultHeaders: Record<string, string>;\n\tprivate options: FetcherOptions;\n\tprivate fetchFn: FetchFn;\n\n\tstatic getFetchFn(fn?: FetchFn): FetchFn {\n\t\tif (fn) {\n\t\t\treturn fn;\n\t\t}\n\n\t\tif (typeof window !== 'undefined' && typeof window.fetch === 'function') {\n\t\t\treturn window.fetch.bind(window);\n\t\t}\n\n\t\tif (\n\t\t\ttypeof globalThis !== 'undefined' &&\n\t\t\ttypeof globalThis.fetch === 'function'\n\t\t) {\n\t\t\treturn globalThis.fetch.bind(globalThis);\n\t\t}\n\n\t\tthrow new Error('No fetch implementation found');\n\t}\n\n\tconstructor(options: FetcherOptions = {}) {\n\t\tthis.baseURL = options.baseURL || '';\n\t\tthis.defaultHeaders = options.headers || {};\n\t\tthis.options = options;\n\t\tthis.fetchFn = TypedFetcher.getFetchFn(options.fetch);\n\t}\n\n\tasync request<T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<ExtractEndpointResponse<Paths, T>> {\n\t\tconst { method, route } = this.parseEndpoint(endpoint);\n\n\t\t// Replace path parameters\n\t\tlet url = route;\n\t\tif (config && 'params' in config && config.params) {\n\t\t\tObject.entries(config.params as Record<string, unknown>).forEach(\n\t\t\t\t([key, value]) => {\n\t\t\t\t\turl = url.replace(`{${key}}`, encodeURIComponent(String(value)));\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\t// Add query parameters\n\t\tif (config && 'query' in config && config.query) {\n\t\t\tconst queryString = qs.stringify(config.query, {\n\t\t\t\tencode: true,\n\t\t\t\tarrayFormat: 'brackets',\n\t\t\t\tskipNulls: true,\n\t\t\t});\n\t\t\tif (queryString) {\n\t\t\t\turl += `?${queryString}`;\n\t\t\t}\n\t\t}\n\n\t\t// Build request configuration\n\t\tlet requestConfig: RequestInit = {\n\t\t\tmethod: method.toUpperCase(),\n\t\t\theaders: {\n\t\t\t\t...this.defaultHeaders,\n\t\t\t\t...((config && 'headers' in config && config.headers) || {}),\n\t\t\t},\n\t\t};\n\n\t\t// Add body if present\n\t\tif (config && 'body' in config && config.body) {\n\t\t\trequestConfig.body = JSON.stringify(config.body);\n\t\t\trequestConfig.headers = {\n\t\t\t\t...requestConfig.headers,\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t};\n\t\t}\n\n\t\t// Apply request interceptor\n\t\tif (this.options.onRequest) {\n\t\t\trequestConfig = await this.options.onRequest(requestConfig);\n\t\t}\n\n\t\ttry {\n\t\t\t// Make the request\n\t\t\tlet response = await this.fetchFn(`${this.baseURL}${url}`, requestConfig);\n\n\t\t\t// Apply response interceptor\n\t\t\tif (this.options.onResponse) {\n\t\t\t\tresponse = await this.options.onResponse(response);\n\t\t\t}\n\n\t\t\t// Handle errors\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow response;\n\t\t\t}\n\n\t\t\t// Handle empty responses (204 No Content, etc.)\n\t\t\tif (\n\t\t\t\tresponse.status === 204 ||\n\t\t\t\tresponse.headers.get('content-length') === '0'\n\t\t\t) {\n\t\t\t\treturn undefined as ExtractEndpointResponse<Paths, T>;\n\t\t\t}\n\n\t\t\t// Parse JSON response\n\t\t\tconst data = await response.json();\n\t\t\treturn data as ExtractEndpointResponse<Paths, T>;\n\t\t} catch (error) {\n\t\t\t// Apply error handler\n\t\t\tif (this.options.onError) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tawait this.options.onError(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\twrap<E = unknown>(onError?: ErrorTransformer<E>) {\n\t\treturn <T extends TypedEndpoint<Paths>>(\n\t\t\tendpoint: T,\n\t\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\t): Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>> =>\n\t\t\tthis.request(endpoint, config).then(\n\t\t\t\t(data) => ({ ok: true as const, data }),\n\t\t\t\tasync (error) => ({\n\t\t\t\t\tok: false as const,\n\t\t\t\t\terror: onError ? await onError(error) : (error as E),\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\tprivate parseEndpoint<T extends EndpointString>(\n\t\tendpoint: T,\n\t): ParseEndpoint<T> {\n\t\tconst [method, ...routeParts] = endpoint.split(' ');\n\t\tconst route = routeParts.join(' ');\n\t\treturn { method: method?.toLowerCase() ?? '', route } as ParseEndpoint<T>;\n\t}\n}\n\nexport function createTypedFetcher<Paths>(options?: FetcherOptions) {\n\tconst fetcher = new TypedFetcher<Paths>(options);\n\tconst fn = <T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t) => fetcher.request(endpoint, config);\n\n\treturn Object.assign(fn, {\n\t\twrap: <E = unknown>(onError?: ErrorTransformer<E>) =>\n\t\t\tObject.assign(fetcher.wrap(onError), fn, {\n\t\t\t\twrap: undefined,\n\t\t\t}),\n\t});\n}\n\nexport type FetchFn = typeof fetch;\n"],"mappings":";;;;AAcA,IAAa,eAAb,MAAa,aAAoB;CAChC,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,OAAO,WAAWA,IAAuB;AACxC,MAAI,GACH,QAAO;AAGR,aAAW,WAAW,sBAAsB,OAAO,UAAU,WAC5D,QAAO,OAAO,MAAM,KAAK,OAAO;AAGjC,aACQ,eAAe,sBACf,WAAW,UAAU,WAE5B,QAAO,WAAW,MAAM,KAAK,WAAW;AAGzC,QAAM,IAAI,MAAM;CAChB;CAED,YAAYC,UAA0B,CAAE,GAAE;AACzC,OAAK,UAAU,QAAQ,WAAW;AAClC,OAAK,iBAAiB,QAAQ,WAAW,CAAE;AAC3C,OAAK,UAAU;AACf,OAAK,UAAU,aAAa,WAAW,QAAQ,MAAM;CACrD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M;EACN;CACD;CAED,KAAkBC,SAA+B;AAChD,SAAO,CACNH,UACAC,WAEA,KAAK,QAAQ,UAAU,OAAO,CAAC,KAC9B,CAAC,UAAU;GAAE,IAAI;GAAe;EAAM,IACtC,OAAO,WAAW;GACjB,IAAI;GACJ,OAAO,UAAU,MAAM,QAAQ,MAAM,GAAI;EACzC,GACD;CACF;CAED,AAAQ,cACPD,UACmB;EACnB,MAAM,CAAC,QAAQ,GAAG,WAAW,GAAG,SAAS,MAAM,IAAI;EACnD,MAAM,QAAQ,WAAW,KAAK,IAAI;AAClC,SAAO;GAAE,QAAQ,QAAQ,aAAa,IAAI;GAAI;EAAO;CACrD;AACD;AAED,SAAgB,mBAA0BI,SAA0B;CACnE,MAAM,UAAU,IAAI,aAAoB;CACxC,MAAM,KAAK,CACVJ,UACAC,WACI,QAAQ,QAAQ,UAAU,OAAO;AAEtC,QAAO,OAAO,OAAO,IAAI,EACxB,MAAM,CAAcE,YACnB,OAAO,OAAO,QAAQ,KAAK,QAAQ,EAAE,IAAI,EACxC,aACA,EAAC,CACH,EAAC;AACF"}
@@ -1,25 +0,0 @@
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
@@ -1 +0,0 @@
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,CA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AA,GAtCkC,OAsCjB,KAtCiB"}
File without changes
@@ -1,133 +0,0 @@
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-DfRq5kIb.d.cts.map
@@ -1 +0,0 @@
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,K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