@openapi-qraft/react 2.0.0-next.2 → 2.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @openapi-qraft/react
2
2
 
3
+ ## 2.0.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 7e51026: Added the ability to call `getQueryKey`, `getMutationKey`, and similar non-request operations without providing `requestFn` or `baseUrl`
8
+
3
9
  ## 2.0.0-next.2
4
10
 
5
11
  ### Patch Changes
@@ -14,7 +14,7 @@ function qraftAPIClient(services, callbacks, options) {
14
14
  const serviceOperation = getByPath(services, path);
15
15
  if (!isServiceOperation(serviceOperation)) throw new Error(`Service operation not found: ${path.join('.')}`);
16
16
  if (callbackName !== 'operationInvokeFn' && callbackName !== 'getQueryKey' && callbackName !== 'getMutationKey') {
17
- if (!('queryClient' in options && options.queryClient)) throw new Error(`'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`);
17
+ if (!options || !('queryClient' in options && options.queryClient)) throw new Error(`'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`);
18
18
  }
19
19
  // @ts-expect-error - Too complex union type
20
20
  return callbacks[callbackName](options, serviceOperation.schema, args);
@@ -1 +1 @@
1
- {"version":3,"file":"qraftAPIClient.cjs","sources":["../../src/qraftAPIClient.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type * as callbacks from './callbacks/index.js';\nimport type * as operationInvokeModule from './callbacks/operationInvokeFn.js';\nimport type {\n OperationSchema,\n RequestFnInfo,\n RequestFnResponse,\n} from './lib/requestFn.js';\nimport type {\n ServiceOperationMutation,\n ServiceOperationQuery,\n} from './service-operation/index.js';\nimport type { ServiceOperationMutationFn } from './service-operation/ServiceOperationMutationFn.js';\nimport type { ServiceOperationQueryFn } from './service-operation/ServiceOperationQueryFn.js';\nimport { createRecursiveProxy } from './lib/createRecursiveProxy.js';\n\nexport interface CreateAPIBasicClientOptions {\n requestFn<TData, TError>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo\n ): Promise<RequestFnResponse<TData, TError>>;\n baseUrl: string;\n}\n\nexport interface CreateAPIQueryClientOptions\n extends CreateAPIBasicClientOptions {\n queryClient: QueryClient;\n}\n\n/**\n * @deprecated use `CreateAPIClientOptions` instead\n */\nexport type QraftClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport type CreateAPIClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIBasicClientOptions\n): APIBasicClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Required<Callbacks>,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): Services;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): APIQueryClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIClientOptions\n): APIQueryClientServices<Services, TCallbacks> | Services {\n return createRecursiveProxy(\n function getCallback(getPath, key) {\n if (getPath.length !== 2 || key !== 'schema') return; // todo::maybe return callback?\n\n const serviceOperation = getByPath(services, getPath);\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${getPath.join('.')}`);\n return serviceOperation.schema;\n },\n function applyCallback(applyPath, args) {\n const { path, callbackName } = extractCallbackDetails(applyPath);\n\n assertValidCallbackName(callbackName, callbacks);\n\n const serviceOperation = getByPath(services, path);\n\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${path.join('.')}`);\n\n if (\n callbackName !== 'operationInvokeFn' &&\n callbackName !== 'getQueryKey' &&\n callbackName !== 'getMutationKey'\n )\n if (!('queryClient' in options && options.queryClient))\n throw new Error(\n `'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`\n );\n\n // @ts-expect-error - Too complex union type\n return callbacks[callbackName](options, serviceOperation.schema, args);\n },\n []\n ) as never;\n}\n\nfunction assertValidCallbackName<\n TCallbacks extends Record<string, (...rest: any[]) => unknown>,\n>(\n callbackName: string | number | symbol,\n callbacks: TCallbacks\n): asserts callbackName is keyof TCallbacks {\n if (!(callbackName in callbacks)) {\n if ((callbackName as OperationInvokeFnName) === 'operationInvokeFn')\n throw new Error(\n `Callback 'operationInvokeFn' is required for executing 'qraft.<service>.<operation>()', but it is not provided in the 'callbacks' object.`\n );\n throw new Error(\n `Callback for 'qraft.<service>.<operation>.${String(callbackName)}()' is not provided in the 'callbacks' object.`\n );\n }\n}\n\n/**\n * Extracts Callback details from the applyPath\n * @param applyPath\n */\nfunction extractCallbackDetails(applyPath: string[]) {\n // <service>.<operation>()\n if (applyPath.length === 2) {\n return {\n path: applyPath,\n callbackName: 'operationInvokeFn' satisfies OperationInvokeFnName,\n };\n } else {\n // <service>.<operation>.<method>()\n return {\n path: applyPath.slice(0, -1),\n // The last arg is for instance `.useMutation` or `.useQuery()`\n callbackName: applyPath[applyPath.length - 1],\n };\n }\n}\n\nfunction isServiceOperation(\n input: unknown\n): input is { schema: OperationSchema } {\n return input !== null && typeof input === 'object' && 'schema' in input;\n}\n\nfunction getByPath(obj: Record<string, unknown>, path: string[]) {\n return path.reduce<unknown>((acc, key) => {\n if (acc && typeof acc === 'object' && key in acc)\n return acc[key as keyof typeof acc];\n }, obj);\n}\n\ntype Callbacks = Partial<typeof callbacks>;\n\ntype ServicesDeclaration<Services> = {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: OperationSchema;\n types: {\n parameters?: any;\n data?: any;\n error?: any;\n body?: any;\n };\n };\n };\n};\n\ntype ServiceSchemasDeclaration<Services extends ServicesDeclaration<Services>> =\n {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: Services[service][method]['schema'];\n };\n };\n };\n\ntype QueryOperationCallbacks = Extract<\n keyof Callbacks,\n | 'cancelQueries'\n | 'fetchInfiniteQuery'\n | 'fetchQuery'\n | 'getInfiniteQueryData'\n | 'getInfiniteQueryKey'\n | 'getInfiniteQueryState'\n | 'getQueriesData'\n | 'getQueryData'\n | 'getQueryKey'\n | 'getQueryState'\n | 'invalidateQueries'\n | 'isFetching'\n | 'prefetchInfiniteQuery'\n | 'prefetchQuery'\n | 'refetchQueries'\n | 'removeQueries'\n | 'resetQueries'\n | 'setInfiniteQueryData'\n | 'setQueriesData'\n | 'setQueryData'\n | 'useInfiniteQuery'\n | 'useIsFetching'\n | 'useQueries'\n | 'useQuery'\n | 'useSuspenseInfiniteQuery'\n | 'useSuspenseQueries'\n | 'useSuspenseQuery'\n>;\n\ntype MutationOperationCallbacks = Extract<\n keyof Callbacks,\n | 'getMutationKey'\n | 'isMutating'\n | 'useIsMutating'\n | 'useMutation'\n | 'useMutationState'\n>;\n\nexport type APIQueryClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n QueryOperationCallbacks,\n MutationOperationCallbacks\n>;\n\nexport type APIBasicClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n Extract<QueryOperationCallbacks, 'getQueryKey'>,\n Extract<MutationOperationCallbacks, 'getMutationKey'>\n>;\n\ntype ServicesFilteredByCallbacks<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n TQueryOperationCallbacks extends QueryOperationCallbacks,\n TMutationOperationCallbacks extends MutationOperationCallbacks,\n> = {\n [serviceName in keyof TServices]: {\n [method in keyof TServices[serviceName]]: TServices[serviceName][method]['schema']['method'] extends\n | 'get'\n | 'head'\n | 'options'\n ? Pick<\n ServiceOperationQuery<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TQueryOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationQueryFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {})\n : Pick<\n ServiceOperationMutation<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TMutationOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationMutationFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {});\n };\n};\n\ntype OperationInvokeFnName = Extract<\n keyof typeof operationInvokeModule,\n 'operationInvokeFn'\n>;\n"],"names":["qraftAPIClient","services","callbacks","options","createRecursiveProxy","getCallback","getPath","key","length","serviceOperation","getByPath","isServiceOperation","Error","join","schema","applyCallback","applyPath","args","path","callbackName","extractCallbackDetails","assertValidCallbackName","queryClient","String","slice","input","obj","reduce","acc"],"mappings":";;;;AAmEO,SAASA,cAIdC,CAAAA,QAA6C,EAC7CC,SAAqB,EACrBC,OAA+B,EAAA;AAE/B,IAAA,OAAOC,yCACL,CAAA,SAASC,W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wB,CAAA,CAAA;KACpCmB,EAAAA,GAAAA,CAAAA,CAAAA;AACL;;;;"}
1
+ {"version":3,"file":"qraftAPIClient.cjs","sources":["../../src/qraftAPIClient.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type * as callbacks from './callbacks/index.js';\nimport type * as operationInvokeModule from './callbacks/operationInvokeFn.js';\nimport type {\n OperationSchema,\n RequestFnInfo,\n RequestFnResponse,\n} from './lib/requestFn.js';\nimport type {\n ServiceOperationMutation,\n ServiceOperationQuery,\n} from './service-operation/index.js';\nimport type { ServiceOperationMutationFn } from './service-operation/ServiceOperationMutationFn.js';\nimport type { ServiceOperationQueryFn } from './service-operation/ServiceOperationQueryFn.js';\nimport { createRecursiveProxy } from './lib/createRecursiveProxy.js';\n\nexport interface CreateAPIBasicClientOptions {\n requestFn<TData, TError>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo\n ): Promise<RequestFnResponse<TData, TError>>;\n baseUrl: string;\n}\n\nexport interface CreateAPIQueryClientOptions\n extends CreateAPIBasicClientOptions {\n queryClient: QueryClient;\n}\n\n/**\n * @deprecated use `CreateAPIClientOptions` instead\n */\nexport type QraftClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport type CreateAPIClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIBasicClientOptions\n): APIBasicClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Required<Callbacks>,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): Services;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): APIQueryClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks\n): APIUtilityClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options?: CreateAPIClientOptions\n): APIQueryClientServices<Services, TCallbacks> | Services {\n return createRecursiveProxy(\n function getCallback(getPath, key) {\n if (getPath.length !== 2 || key !== 'schema') return; // todo::maybe return callback?\n\n const serviceOperation = getByPath(services, getPath);\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${getPath.join('.')}`);\n return serviceOperation.schema;\n },\n function applyCallback(applyPath, args) {\n const { path, callbackName } = extractCallbackDetails(applyPath);\n\n assertValidCallbackName(callbackName, callbacks);\n\n const serviceOperation = getByPath(services, path);\n\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${path.join('.')}`);\n\n if (\n callbackName !== 'operationInvokeFn' &&\n callbackName !== 'getQueryKey' &&\n callbackName !== 'getMutationKey'\n )\n if (!options || !('queryClient' in options && options.queryClient))\n throw new Error(\n `'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`\n );\n\n // @ts-expect-error - Too complex union type\n return callbacks[callbackName](options, serviceOperation.schema, args);\n },\n []\n ) as never;\n}\n\nfunction assertValidCallbackName<\n TCallbacks extends Record<string, (...rest: any[]) => unknown>,\n>(\n callbackName: string | number | symbol,\n callbacks: TCallbacks\n): asserts callbackName is keyof TCallbacks {\n if (!(callbackName in callbacks)) {\n if ((callbackName as OperationInvokeFnName) === 'operationInvokeFn')\n throw new Error(\n `Callback 'operationInvokeFn' is required for executing 'qraft.<service>.<operation>()', but it is not provided in the 'callbacks' object.`\n );\n throw new Error(\n `Callback for 'qraft.<service>.<operation>.${String(callbackName)}()' is not provided in the 'callbacks' object.`\n );\n }\n}\n\n/**\n * Extracts Callback details from the applyPath\n * @param applyPath\n */\nfunction extractCallbackDetails(applyPath: string[]) {\n // <service>.<operation>()\n if (applyPath.length === 2) {\n return {\n path: applyPath,\n callbackName: 'operationInvokeFn' satisfies OperationInvokeFnName,\n };\n } else {\n // <service>.<operation>.<method>()\n return {\n path: applyPath.slice(0, -1),\n // The last arg is for instance `.useMutation` or `.useQuery()`\n callbackName: applyPath[applyPath.length - 1],\n };\n }\n}\n\nfunction isServiceOperation(\n input: unknown\n): input is { schema: OperationSchema } {\n return input !== null && typeof input === 'object' && 'schema' in input;\n}\n\nfunction getByPath(obj: Record<string, unknown>, path: string[]) {\n return path.reduce<unknown>((acc, key) => {\n if (acc && typeof acc === 'object' && key in acc)\n return acc[key as keyof typeof acc];\n }, obj);\n}\n\ntype Callbacks = Partial<typeof callbacks>;\n\ntype ServicesDeclaration<Services> = {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: OperationSchema;\n types: {\n parameters?: any;\n data?: any;\n error?: any;\n body?: any;\n };\n };\n };\n};\n\ntype ServiceSchemasDeclaration<Services extends ServicesDeclaration<Services>> =\n {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: Services[service][method]['schema'];\n };\n };\n };\n\ntype QueryOperationCallbacks = Extract<\n keyof Callbacks,\n | 'cancelQueries'\n | 'fetchInfiniteQuery'\n | 'fetchQuery'\n | 'getInfiniteQueryData'\n | 'getInfiniteQueryKey'\n | 'getInfiniteQueryState'\n | 'getQueriesData'\n | 'getQueryData'\n | 'getQueryKey'\n | 'getQueryState'\n | 'invalidateQueries'\n | 'isFetching'\n | 'prefetchInfiniteQuery'\n | 'prefetchQuery'\n | 'refetchQueries'\n | 'removeQueries'\n | 'resetQueries'\n | 'setInfiniteQueryData'\n | 'setQueriesData'\n | 'setQueryData'\n | 'useInfiniteQuery'\n | 'useIsFetching'\n | 'useQueries'\n | 'useQuery'\n | 'useSuspenseInfiniteQuery'\n | 'useSuspenseQueries'\n | 'useSuspenseQuery'\n>;\n\ntype MutationOperationCallbacks = Extract<\n keyof Callbacks,\n | 'getMutationKey'\n | 'isMutating'\n | 'useIsMutating'\n | 'useMutation'\n | 'useMutationState'\n>;\n\nexport type APIQueryClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n QueryOperationCallbacks,\n MutationOperationCallbacks\n>;\n\nexport type APIUtilityClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n Omit<TCallbacks, 'operationInvokeFn'>,\n Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>,\n Extract<MutationOperationCallbacks, 'getMutationKey'>\n>;\n\nexport type APIBasicClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>,\n Extract<MutationOperationCallbacks, 'getMutationKey'>\n>;\n\ntype ServicesFilteredByCallbacks<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n TQueryOperationCallbacks extends QueryOperationCallbacks,\n TMutationOperationCallbacks extends MutationOperationCallbacks,\n> = {\n [serviceName in keyof TServices]: {\n [method in keyof TServices[serviceName]]: TServices[serviceName][method]['schema']['method'] extends\n | 'get'\n | 'head'\n | 'options'\n ? Pick<\n ServiceOperationQuery<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TQueryOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationQueryFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {})\n : Pick<\n ServiceOperationMutation<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TMutationOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationMutationFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {});\n };\n};\n\ntype OperationInvokeFnName = Extract<\n keyof typeof operationInvokeModule,\n 'operationInvokeFn'\n>;\n"],"names":["qraftAPIClient","services","callbacks","options","createRecursiveProxy","getCallback","getPath","key","length","serviceOperation","getByPath","isServiceOperation","Error","join","schema","applyCallback","applyPath","args","path","callbackName","extractCallbackDetails","assertValidCallbackName","queryClient","String","slice","input","obj","reduce","acc"],"mappings":";;;;AA2EO,SAASA,cAIdC,CAAAA,QAA6C,EAC7CC,SAAqB,EACrBC,OAAgC,EAAA;AAEhC,IAAA,OAAOC,yCACL,CAAA,SAASC,WAAYC,CAAAA,OAAO,EAAEC,GAAG,EAAA;AAC/B,QAAA,IAAID,QAAQE,MAAM,KAAK,KAAKD,GAAQ,KAAA,QAAA,EAAU;QAE9C,MAAME,gBAAAA,GAAmBC,UAAUT,QAAUK,EAAAA,OAAAA,CAAAA,CAAAA;AAC7C,QAAA,IAAI,CAACK,kBAAAA,CAAmBF,gBACtB,CAAA,EAAA,MAAM,IAAIG,KAAAA,CAAM,CAAC,6BAA6B,EAAEN,OAAAA,CAAQO,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;AACrE,QAAA,OAAOJ,iBAAiBK,M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CAAAA,CAAc,8CAA8C,CAAC,CAAA,CAAA;AAErH,KAAA;AACF,CAAA;AAEA;;;IAIA,SAASC,uBAAuBJ,SAAmB,EAAA;;IAEjD,IAAIA,SAAAA,CAAUR,MAAM,KAAK,CAAG,EAAA;QAC1B,OAAO;YACLU,IAAMF,EAAAA,SAAAA;YACNG,YAAc,EAAA,mBAAA;AAChB,SAAA,CAAA;KACK,MAAA;;QAEL,OAAO;AACLD,YAAAA,IAAAA,EAAMF,SAAUQ,CAAAA,KAAK,CAAC,CAAA,EAAG,CAAC,CAAA,CAAA;;AAE1BL,YAAAA,YAAAA,EAAcH,SAAS,CAACA,SAAUR,CAAAA,MAAM,GAAG,CAAE,CAAA;AAC/C,SAAA,CAAA;AACF,KAAA;AACF,CAAA;AAEA,SAASG,mBACPc,KAAc,EAAA;AAEd,IAAA,OAAOA,KAAU,KAAA,IAAA,IAAQ,OAAOA,KAAAA,KAAU,YAAY,QAAYA,IAAAA,KAAAA,CAAAA;AACpE,CAAA;AAEA,SAASf,SAAAA,CAAUgB,GAA4B,EAAER,IAAc,EAAA;AAC7D,IAAA,OAAOA,IAAKS,CAAAA,MAAM,CAAU,CAACC,GAAKrB,EAAAA,GAAAA,GAAAA;QAChC,IAAIqB,GAAAA,IAAO,OAAOA,GAAQ,KAAA,QAAA,IAAYrB,OAAOqB,GAC3C,EAAA,OAAOA,GAAG,CAACrB,GAAwB,CAAA,CAAA;KACpCmB,EAAAA,GAAAA,CAAAA,CAAAA;AACL;;;;"}
@@ -12,7 +12,7 @@ function qraftAPIClient(services, callbacks, options) {
12
12
  const serviceOperation = getByPath(services, path);
13
13
  if (!isServiceOperation(serviceOperation)) throw new Error(`Service operation not found: ${path.join('.')}`);
14
14
  if (callbackName !== 'operationInvokeFn' && callbackName !== 'getQueryKey' && callbackName !== 'getMutationKey') {
15
- if (!('queryClient' in options && options.queryClient)) throw new Error(`'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`);
15
+ if (!options || !('queryClient' in options && options.queryClient)) throw new Error(`'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`);
16
16
  }
17
17
  // @ts-expect-error - Too complex union type
18
18
  return callbacks[callbackName](options, serviceOperation.schema, args);
@@ -1 +1 @@
1
- {"version":3,"file":"qraftAPIClient.js","sources":["../../src/qraftAPIClient.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type * as callbacks from './callbacks/index.js';\nimport type * as operationInvokeModule from './callbacks/operationInvokeFn.js';\nimport type {\n OperationSchema,\n RequestFnInfo,\n RequestFnResponse,\n} from './lib/requestFn.js';\nimport type {\n ServiceOperationMutation,\n ServiceOperationQuery,\n} from './service-operation/index.js';\nimport type { ServiceOperationMutationFn } from './service-operation/ServiceOperationMutationFn.js';\nimport type { ServiceOperationQueryFn } from './service-operation/ServiceOperationQueryFn.js';\nimport { createRecursiveProxy } from './lib/createRecursiveProxy.js';\n\nexport interface CreateAPIBasicClientOptions {\n requestFn<TData, TError>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo\n ): Promise<RequestFnResponse<TData, TError>>;\n baseUrl: string;\n}\n\nexport interface CreateAPIQueryClientOptions\n extends CreateAPIBasicClientOptions {\n queryClient: QueryClient;\n}\n\n/**\n * @deprecated use `CreateAPIClientOptions` instead\n */\nexport type QraftClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport type CreateAPIClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIBasicClientOptions\n): APIBasicClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Required<Callbacks>,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): Services;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): APIQueryClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIClientOptions\n): APIQueryClientServices<Services, TCallbacks> | Services {\n return createRecursiveProxy(\n function getCallback(getPath, key) {\n if (getPath.length !== 2 || key !== 'schema') return; // todo::maybe return callback?\n\n const serviceOperation = getByPath(services, getPath);\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${getPath.join('.')}`);\n return serviceOperation.schema;\n },\n function applyCallback(applyPath, args) {\n const { path, callbackName } = extractCallbackDetails(applyPath);\n\n assertValidCallbackName(callbackName, callbacks);\n\n const serviceOperation = getByPath(services, path);\n\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${path.join('.')}`);\n\n if (\n callbackName !== 'operationInvokeFn' &&\n callbackName !== 'getQueryKey' &&\n callbackName !== 'getMutationKey'\n )\n if (!('queryClient' in options && options.queryClient))\n throw new Error(\n `'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`\n );\n\n // @ts-expect-error - Too complex union type\n return callbacks[callbackName](options, serviceOperation.schema, args);\n },\n []\n ) as never;\n}\n\nfunction assertValidCallbackName<\n TCallbacks extends Record<string, (...rest: any[]) => unknown>,\n>(\n callbackName: string | number | symbol,\n callbacks: TCallbacks\n): asserts callbackName is keyof TCallbacks {\n if (!(callbackName in callbacks)) {\n if ((callbackName as OperationInvokeFnName) === 'operationInvokeFn')\n throw new Error(\n `Callback 'operationInvokeFn' is required for executing 'qraft.<service>.<operation>()', but it is not provided in the 'callbacks' object.`\n );\n throw new Error(\n `Callback for 'qraft.<service>.<operation>.${String(callbackName)}()' is not provided in the 'callbacks' object.`\n );\n }\n}\n\n/**\n * Extracts Callback details from the applyPath\n * @param applyPath\n */\nfunction extractCallbackDetails(applyPath: string[]) {\n // <service>.<operation>()\n if (applyPath.length === 2) {\n return {\n path: applyPath,\n callbackName: 'operationInvokeFn' satisfies OperationInvokeFnName,\n };\n } else {\n // <service>.<operation>.<method>()\n return {\n path: applyPath.slice(0, -1),\n // The last arg is for instance `.useMutation` or `.useQuery()`\n callbackName: applyPath[applyPath.length - 1],\n };\n }\n}\n\nfunction isServiceOperation(\n input: unknown\n): input is { schema: OperationSchema } {\n return input !== null && typeof input === 'object' && 'schema' in input;\n}\n\nfunction getByPath(obj: Record<string, unknown>, path: string[]) {\n return path.reduce<unknown>((acc, key) => {\n if (acc && typeof acc === 'object' && key in acc)\n return acc[key as keyof typeof acc];\n }, obj);\n}\n\ntype Callbacks = Partial<typeof callbacks>;\n\ntype ServicesDeclaration<Services> = {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: OperationSchema;\n types: {\n parameters?: any;\n data?: any;\n error?: any;\n body?: any;\n };\n };\n };\n};\n\ntype ServiceSchemasDeclaration<Services extends ServicesDeclaration<Services>> =\n {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: Services[service][method]['schema'];\n };\n };\n };\n\ntype QueryOperationCallbacks = Extract<\n keyof Callbacks,\n | 'cancelQueries'\n | 'fetchInfiniteQuery'\n | 'fetchQuery'\n | 'getInfiniteQueryData'\n | 'getInfiniteQueryKey'\n | 'getInfiniteQueryState'\n | 'getQueriesData'\n | 'getQueryData'\n | 'getQueryKey'\n | 'getQueryState'\n | 'invalidateQueries'\n | 'isFetching'\n | 'prefetchInfiniteQuery'\n | 'prefetchQuery'\n | 'refetchQueries'\n | 'removeQueries'\n | 'resetQueries'\n | 'setInfiniteQueryData'\n | 'setQueriesData'\n | 'setQueryData'\n | 'useInfiniteQuery'\n | 'useIsFetching'\n | 'useQueries'\n | 'useQuery'\n | 'useSuspenseInfiniteQuery'\n | 'useSuspenseQueries'\n | 'useSuspenseQuery'\n>;\n\ntype MutationOperationCallbacks = Extract<\n keyof Callbacks,\n | 'getMutationKey'\n | 'isMutating'\n | 'useIsMutating'\n | 'useMutation'\n | 'useMutationState'\n>;\n\nexport type APIQueryClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n QueryOperationCallbacks,\n MutationOperationCallbacks\n>;\n\nexport type APIBasicClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n Extract<QueryOperationCallbacks, 'getQueryKey'>,\n Extract<MutationOperationCallbacks, 'getMutationKey'>\n>;\n\ntype ServicesFilteredByCallbacks<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n TQueryOperationCallbacks extends QueryOperationCallbacks,\n TMutationOperationCallbacks extends MutationOperationCallbacks,\n> = {\n [serviceName in keyof TServices]: {\n [method in keyof TServices[serviceName]]: TServices[serviceName][method]['schema']['method'] extends\n | 'get'\n | 'head'\n | 'options'\n ? Pick<\n ServiceOperationQuery<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TQueryOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationQueryFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {})\n : Pick<\n ServiceOperationMutation<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TMutationOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationMutationFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {});\n };\n};\n\ntype OperationInvokeFnName = Extract<\n keyof typeof operationInvokeModule,\n 'operationInvokeFn'\n>;\n"],"names":["qraftAPIClient","services","callbacks","options","createRecursiveProxy","getCallback","getPath","key","length","serviceOperation","getByPath","isServiceOperation","Error","join","schema","applyCallback","applyPath","args","path","callbackName","extractCallbackDetails","assertValidCallbackName","queryClient","String","slice","input","obj","reduce","acc"],"mappings":";;AAmEO,SAASA,cAIdC,CAAAA,QAA6C,EAC7CC,SAAqB,EACrBC,OAA+B,EAAA;AAE/B,IAAA,OAAOC,oBACL,CAAA,SAASC,WAAYC,CAAAA,OAAO,EAAEC,GAAG,EAAA;AAC/B,QAAA,IAAID,QAAQE,MAAM,KAAK,KAAKD,GAAQ,KAAA,QAAA,EAAU;QAE9C,MAAME,gBAAAA,GAAmBC,UAAUT,QAAUK,EAAAA,OAAAA,CAAAA,CAAAA;AAC7C,QAAA,IAAI,CAACK,kBAAAA,CAAmBF,gBACtB,CAAA,EAAA,MAAM,IAAIG,KAAAA,CAAM,CAAC,6BAA6B,EAAEN,OAAAA,CAAQO,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;AACrE,QAAA,OAAOJ,iBAAiBK,MAAM,CAAA;AAChC,KAAA,EACA,SAASC,aAAAA,CAAcC,SAAS,EAAEC,IAAI,EAAA;AACpC,QAAA,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGC,sBAAuBJ,CAAAA,SAAAA,CAAAA,CAAAA;AAEtDK,QAAAA,uBAAAA,CAAwBF,YAAcjB,EAAAA,SAAAA,CAAAA,CAAAA;QAEtC,MAAMO,gBAAAA,GAAmBC,UAAUT,QAAUiB,EAAAA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UQ,CAAAA,KAAK,CAAC,CAAA,EAAG,CAAC,CAAA,CAAA;;AAE1BL,YAAAA,YAAAA,EAAcH,SAAS,CAACA,SAAUR,CAAAA,MAAM,GAAG,CAAE,CAAA;AAC/C,SAAA,CAAA;AACF,KAAA;AACF,CAAA;AAEA,SAASG,mBACPc,KAAc,EAAA;AAEd,IAAA,OAAOA,KAAU,KAAA,IAAA,IAAQ,OAAOA,KAAAA,KAAU,YAAY,QAAYA,IAAAA,KAAAA,CAAAA;AACpE,CAAA;AAEA,SAASf,SAAAA,CAAUgB,GAA4B,EAAER,IAAc,EAAA;AAC7D,IAAA,OAAOA,IAAKS,CAAAA,MAAM,CAAU,CAACC,GAAKrB,EAAAA,GAAAA,GAAAA;QAChC,IAAIqB,GAAAA,IAAO,OAAOA,GAAQ,KAAA,QAAA,IAAYrB,OAAOqB,GAC3C,EAAA,OAAOA,GAAG,CAACrB,GAAwB,CAAA,CAAA;KACpCmB,EAAAA,GAAAA,CAAAA,CAAAA;AACL;;;;"}
1
+ {"version":3,"file":"qraftAPIClient.js","sources":["../../src/qraftAPIClient.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type * as callbacks from './callbacks/index.js';\nimport type * as operationInvokeModule from './callbacks/operationInvokeFn.js';\nimport type {\n OperationSchema,\n RequestFnInfo,\n RequestFnResponse,\n} from './lib/requestFn.js';\nimport type {\n ServiceOperationMutation,\n ServiceOperationQuery,\n} from './service-operation/index.js';\nimport type { ServiceOperationMutationFn } from './service-operation/ServiceOperationMutationFn.js';\nimport type { ServiceOperationQueryFn } from './service-operation/ServiceOperationQueryFn.js';\nimport { createRecursiveProxy } from './lib/createRecursiveProxy.js';\n\nexport interface CreateAPIBasicClientOptions {\n requestFn<TData, TError>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo\n ): Promise<RequestFnResponse<TData, TError>>;\n baseUrl: string;\n}\n\nexport interface CreateAPIQueryClientOptions\n extends CreateAPIBasicClientOptions {\n queryClient: QueryClient;\n}\n\n/**\n * @deprecated use `CreateAPIClientOptions` instead\n */\nexport type QraftClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport type CreateAPIClientOptions =\n | CreateAPIBasicClientOptions\n | CreateAPIQueryClientOptions;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIBasicClientOptions\n): APIBasicClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Required<Callbacks>,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): Services;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options: CreateAPIQueryClientOptions\n): APIQueryClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks\n): APIUtilityClientServices<Services, TCallbacks>;\n\nexport function qraftAPIClient<\n Services extends ServicesDeclaration<Services>,\n TCallbacks extends Callbacks,\n>(\n services: ServiceSchemasDeclaration<Services>,\n callbacks: TCallbacks,\n options?: CreateAPIClientOptions\n): APIQueryClientServices<Services, TCallbacks> | Services {\n return createRecursiveProxy(\n function getCallback(getPath, key) {\n if (getPath.length !== 2 || key !== 'schema') return; // todo::maybe return callback?\n\n const serviceOperation = getByPath(services, getPath);\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${getPath.join('.')}`);\n return serviceOperation.schema;\n },\n function applyCallback(applyPath, args) {\n const { path, callbackName } = extractCallbackDetails(applyPath);\n\n assertValidCallbackName(callbackName, callbacks);\n\n const serviceOperation = getByPath(services, path);\n\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${path.join('.')}`);\n\n if (\n callbackName !== 'operationInvokeFn' &&\n callbackName !== 'getQueryKey' &&\n callbackName !== 'getMutationKey'\n )\n if (!options || !('queryClient' in options && options.queryClient))\n throw new Error(\n `'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`\n );\n\n // @ts-expect-error - Too complex union type\n return callbacks[callbackName](options, serviceOperation.schema, args);\n },\n []\n ) as never;\n}\n\nfunction assertValidCallbackName<\n TCallbacks extends Record<string, (...rest: any[]) => unknown>,\n>(\n callbackName: string | number | symbol,\n callbacks: TCallbacks\n): asserts callbackName is keyof TCallbacks {\n if (!(callbackName in callbacks)) {\n if ((callbackName as OperationInvokeFnName) === 'operationInvokeFn')\n throw new Error(\n `Callback 'operationInvokeFn' is required for executing 'qraft.<service>.<operation>()', but it is not provided in the 'callbacks' object.`\n );\n throw new Error(\n `Callback for 'qraft.<service>.<operation>.${String(callbackName)}()' is not provided in the 'callbacks' object.`\n );\n }\n}\n\n/**\n * Extracts Callback details from the applyPath\n * @param applyPath\n */\nfunction extractCallbackDetails(applyPath: string[]) {\n // <service>.<operation>()\n if (applyPath.length === 2) {\n return {\n path: applyPath,\n callbackName: 'operationInvokeFn' satisfies OperationInvokeFnName,\n };\n } else {\n // <service>.<operation>.<method>()\n return {\n path: applyPath.slice(0, -1),\n // The last arg is for instance `.useMutation` or `.useQuery()`\n callbackName: applyPath[applyPath.length - 1],\n };\n }\n}\n\nfunction isServiceOperation(\n input: unknown\n): input is { schema: OperationSchema } {\n return input !== null && typeof input === 'object' && 'schema' in input;\n}\n\nfunction getByPath(obj: Record<string, unknown>, path: string[]) {\n return path.reduce<unknown>((acc, key) => {\n if (acc && typeof acc === 'object' && key in acc)\n return acc[key as keyof typeof acc];\n }, obj);\n}\n\ntype Callbacks = Partial<typeof callbacks>;\n\ntype ServicesDeclaration<Services> = {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: OperationSchema;\n types: {\n parameters?: any;\n data?: any;\n error?: any;\n body?: any;\n };\n };\n };\n};\n\ntype ServiceSchemasDeclaration<Services extends ServicesDeclaration<Services>> =\n {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: Services[service][method]['schema'];\n };\n };\n };\n\ntype QueryOperationCallbacks = Extract<\n keyof Callbacks,\n | 'cancelQueries'\n | 'fetchInfiniteQuery'\n | 'fetchQuery'\n | 'getInfiniteQueryData'\n | 'getInfiniteQueryKey'\n | 'getInfiniteQueryState'\n | 'getQueriesData'\n | 'getQueryData'\n | 'getQueryKey'\n | 'getQueryState'\n | 'invalidateQueries'\n | 'isFetching'\n | 'prefetchInfiniteQuery'\n | 'prefetchQuery'\n | 'refetchQueries'\n | 'removeQueries'\n | 'resetQueries'\n | 'setInfiniteQueryData'\n | 'setQueriesData'\n | 'setQueryData'\n | 'useInfiniteQuery'\n | 'useIsFetching'\n | 'useQueries'\n | 'useQuery'\n | 'useSuspenseInfiniteQuery'\n | 'useSuspenseQueries'\n | 'useSuspenseQuery'\n>;\n\ntype MutationOperationCallbacks = Extract<\n keyof Callbacks,\n | 'getMutationKey'\n | 'isMutating'\n | 'useIsMutating'\n | 'useMutation'\n | 'useMutationState'\n>;\n\nexport type APIQueryClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n QueryOperationCallbacks,\n MutationOperationCallbacks\n>;\n\nexport type APIUtilityClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n Omit<TCallbacks, 'operationInvokeFn'>,\n Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>,\n Extract<MutationOperationCallbacks, 'getMutationKey'>\n>;\n\nexport type APIBasicClientServices<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n> = ServicesFilteredByCallbacks<\n TServices,\n TCallbacks,\n Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>,\n Extract<MutationOperationCallbacks, 'getMutationKey'>\n>;\n\ntype ServicesFilteredByCallbacks<\n TServices extends ServicesDeclaration<TServices>,\n TCallbacks extends Callbacks,\n TQueryOperationCallbacks extends QueryOperationCallbacks,\n TMutationOperationCallbacks extends MutationOperationCallbacks,\n> = {\n [serviceName in keyof TServices]: {\n [method in keyof TServices[serviceName]]: TServices[serviceName][method]['schema']['method'] extends\n | 'get'\n | 'head'\n | 'options'\n ? Pick<\n ServiceOperationQuery<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TQueryOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationQueryFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {})\n : Pick<\n ServiceOperationMutation<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >,\n | Extract<keyof TCallbacks, TMutationOperationCallbacks>\n | 'types'\n | 'schema'\n > &\n (OperationInvokeFnName extends keyof TCallbacks\n ? ServiceOperationMutationFn<\n TServices[serviceName][method]['schema'],\n TServices[serviceName][method]['types']['body'],\n TServices[serviceName][method]['types']['data'],\n TServices[serviceName][method]['types']['parameters'],\n TServices[serviceName][method]['types']['error']\n >\n : {});\n };\n};\n\ntype OperationInvokeFnName = Extract<\n keyof typeof operationInvokeModule,\n 'operationInvokeFn'\n>;\n"],"names":["qraftAPIClient","services","callbacks","options","createRecursiveProxy","getCallback","getPath","key","length","serviceOperation","getByPath","isServiceOperation","Error","join","schema","applyCallback","applyPath","args","path","callbackName","extractCallbackDetails","assertValidCallbackName","queryClient","String","slice","input","obj","reduce","acc"],"mappings":";;AA2EO,SAASA,cAIdC,CAAAA,QAA6C,EAC7CC,SAAqB,EACrBC,OAAgC,EAAA;AAEhC,IAAA,OAAOC,oBACL,CAAA,SAASC,WAAYC,CAAAA,OAAO,EAAEC,GAAG,EAAA;AAC/B,QAAA,IAAID,QAAQE,MAAM,KAAK,KAAKD,GAAQ,KAAA,QAAA,EAAU;QAE9C,MAAME,gBAAAA,GAAmBC,UAAUT,QAAUK,EAAAA,OAAAA,CAAAA,CAAAA;AAC7C,QAAA,IAAI,CAACK,kBAAAA,CAAmBF,gBACtB,CAAA,EAAA,MAAM,IAAIG,KAAAA,CAAM,CAAC,6BAA6B,EAAEN,OAAAA,CAAQO,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;AACrE,QAAA,OAAOJ,iBAAiBK,MAAM,CAAA;AAChC,KAAA,EACA,SAASC,aAAAA,CAAcC,SAAS,EAAEC,IAAI,EAAA;AACpC,QAAA,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGC,sBAAuBJ,CAAAA,SAAAA,CAAAA,CAAAA;AAEtDK,QAAAA,uBAAAA,CAAwBF,YAAcjB,EAAAA,SAAAA,CAAAA,CAAAA;QAEtC,MAAMO,gBAAAA,GAAmBC,UAAUT,QAAUiB,EAAAA,IAAAA,CAAAA,CAAAA;AAE7C,QAAA,IAAI,CAACP,kBAAAA,CAAmBF,gBACtB,CAAA,EAAA,MAAM,IAAIG,KAAAA,CAAM,CAAC,6BAA6B,EAAEM,IAAAA,CAAKL,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;AAElE,QAAA,IACEM,YAAiB,KAAA,mBAAA,IACjBA,YAAiB,KAAA,aAAA,IACjBA,iBAAiB,gBAEjB,EAAA;AAAA,YAAA,IAAI,CAAChB,OAAW,IAAA,EAAE,aAAiBA,IAAAA,OAAAA,IAAWA,QAAQmB,WAAU,GAC9D,MAAM,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;AAC7D,IAAA,OAAOA,IAAKS,CAAAA,MAAM,CAAU,CAACC,GAAKrB,EAAAA,GAAAA,GAAAA;QAChC,IAAIqB,GAAAA,IAAO,OAAOA,GAAQ,KAAA,QAAA,IAAYrB,OAAOqB,GAC3C,EAAA,OAAOA,GAAG,CAACrB,GAAwB,CAAA,CAAA;KACpCmB,EAAAA,GAAAA,CAAAA,CAAAA;AACL;;;;"}
@@ -1,4 +1,4 @@
1
- export { qraftAPIClient, type CreateAPIClientOptions, type CreateAPIBasicClientOptions, type CreateAPIQueryClientOptions, type APIQueryClientServices, type APIBasicClientServices, type QraftClientOptions, } from './qraftAPIClient.js';
1
+ export { qraftAPIClient, type CreateAPIClientOptions, type CreateAPIBasicClientOptions, type CreateAPIQueryClientOptions, type APIQueryClientServices, type APIBasicClientServices, type APIUtilityClientServices, type QraftClientOptions, } from './qraftAPIClient.js';
2
2
  export { requestFn, baseRequestFn, urlSerializer, bodySerializer, mergeHeaders, type RequestFnResponse, } from './lib/requestFn.js';
3
3
  export type { RequestFnPayload, RequestFnOptions, HeadersOptions, OperationSchema, RequestFn, } from './lib/requestFn.js';
4
4
  export type * from './service-operation/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,SAAS,GACV,MAAM,oBAAoB,CAAC;AAE5B,mBAAmB,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,SAAS,GACV,MAAM,oBAAoB,CAAC;AAE5B,mBAAmB,8BAA8B,CAAC"}
@@ -20,6 +20,7 @@ export type CreateAPIClientOptions = CreateAPIBasicClientOptions | CreateAPIQuer
20
20
  export declare function qraftAPIClient<Services extends ServicesDeclaration<Services>, TCallbacks extends Callbacks>(services: ServiceSchemasDeclaration<Services>, callbacks: TCallbacks, options: CreateAPIBasicClientOptions): APIBasicClientServices<Services, TCallbacks>;
21
21
  export declare function qraftAPIClient<Services extends ServicesDeclaration<Services>, TCallbacks extends Required<Callbacks>>(services: ServiceSchemasDeclaration<Services>, callbacks: TCallbacks, options: CreateAPIQueryClientOptions): Services;
22
22
  export declare function qraftAPIClient<Services extends ServicesDeclaration<Services>, TCallbacks extends Callbacks>(services: ServiceSchemasDeclaration<Services>, callbacks: TCallbacks, options: CreateAPIQueryClientOptions): APIQueryClientServices<Services, TCallbacks>;
23
+ export declare function qraftAPIClient<Services extends ServicesDeclaration<Services>, TCallbacks extends Callbacks>(services: ServiceSchemasDeclaration<Services>, callbacks: TCallbacks): APIUtilityClientServices<Services, TCallbacks>;
23
24
  type Callbacks = Partial<typeof callbacks>;
24
25
  type ServicesDeclaration<Services> = {
25
26
  [service in keyof Services]: {
@@ -44,7 +45,8 @@ type ServiceSchemasDeclaration<Services extends ServicesDeclaration<Services>> =
44
45
  type QueryOperationCallbacks = Extract<keyof Callbacks, 'cancelQueries' | 'fetchInfiniteQuery' | 'fetchQuery' | 'getInfiniteQueryData' | 'getInfiniteQueryKey' | 'getInfiniteQueryState' | 'getQueriesData' | 'getQueryData' | 'getQueryKey' | 'getQueryState' | 'invalidateQueries' | 'isFetching' | 'prefetchInfiniteQuery' | 'prefetchQuery' | 'refetchQueries' | 'removeQueries' | 'resetQueries' | 'setInfiniteQueryData' | 'setQueriesData' | 'setQueryData' | 'useInfiniteQuery' | 'useIsFetching' | 'useQueries' | 'useQuery' | 'useSuspenseInfiniteQuery' | 'useSuspenseQueries' | 'useSuspenseQuery'>;
45
46
  type MutationOperationCallbacks = Extract<keyof Callbacks, 'getMutationKey' | 'isMutating' | 'useIsMutating' | 'useMutation' | 'useMutationState'>;
46
47
  export type APIQueryClientServices<TServices extends ServicesDeclaration<TServices>, TCallbacks extends Callbacks> = ServicesFilteredByCallbacks<TServices, TCallbacks, QueryOperationCallbacks, MutationOperationCallbacks>;
47
- export type APIBasicClientServices<TServices extends ServicesDeclaration<TServices>, TCallbacks extends Callbacks> = ServicesFilteredByCallbacks<TServices, TCallbacks, Extract<QueryOperationCallbacks, 'getQueryKey'>, Extract<MutationOperationCallbacks, 'getMutationKey'>>;
48
+ export type APIUtilityClientServices<TServices extends ServicesDeclaration<TServices>, TCallbacks extends Callbacks> = ServicesFilteredByCallbacks<TServices, Omit<TCallbacks, 'operationInvokeFn'>, Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>, Extract<MutationOperationCallbacks, 'getMutationKey'>>;
49
+ export type APIBasicClientServices<TServices extends ServicesDeclaration<TServices>, TCallbacks extends Callbacks> = ServicesFilteredByCallbacks<TServices, TCallbacks, Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>, Extract<MutationOperationCallbacks, 'getMutationKey'>>;
48
50
  type ServicesFilteredByCallbacks<TServices extends ServicesDeclaration<TServices>, TCallbacks extends Callbacks, TQueryOperationCallbacks extends QueryOperationCallbacks, TMutationOperationCallbacks extends MutationOperationCallbacks> = {
49
51
  [serviceName in keyof TServices]: {
50
52
  [method in keyof TServices[serviceName]]: TServices[serviceName][method]['schema']['method'] extends 'get' | 'head' | 'options' ? Pick<ServiceOperationQuery<TServices[serviceName][method]['schema'], TServices[serviceName][method]['types']['data'], TServices[serviceName][method]['types']['parameters'], TServices[serviceName][method]['types']['error']>, Extract<keyof TCallbacks, TQueryOperationCallbacks> | 'types' | 'schema'> & (OperationInvokeFnName extends keyof TCallbacks ? ServiceOperationQueryFn<TServices[serviceName][method]['schema'], TServices[serviceName][method]['types']['data'], TServices[serviceName][method]['types']['parameters'], TServices[serviceName][method]['types']['error']> : {}) : Pick<ServiceOperationMutation<TServices[serviceName][method]['schema'], TServices[serviceName][method]['types']['body'], TServices[serviceName][method]['types']['data'], TServices[serviceName][method]['types']['parameters'], TServices[serviceName][method]['types']['error']>, Extract<keyof TCallbacks, TMutationOperationCallbacks> | 'types' | 'schema'> & (OperationInvokeFnName extends keyof TCallbacks ? ServiceOperationMutationFn<TServices[serviceName][method]['schema'], TServices[serviceName][method]['types']['body'], TServices[serviceName][method]['types']['data'], TServices[serviceName][method]['types']['parameters'], TServices[serviceName][method]['types']['error']> : {});
@@ -1 +1 @@
1
- {"version":3,"file":"qraftAPIClient.d.ts","sourceRoot":"","sources":["../../src/qraftAPIClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,KAAK,SAAS,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,KAAK,qBAAqB,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,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C,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,EACrD,SAAS,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CACjD,GACD,EAAE,CAAC;KACd;CACF,CAAC;AAEF,KAAK,qBAAqB,GAAG,OAAO,CAClC,MAAM,OAAO,qBAAqB,EAClC,mBAAmB,CACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-qraft/react",
3
- "version": "2.0.0-next.2",
3
+ "version": "2.0.0-next.3",
4
4
  "description": "API client for React, providing type-safe requests and dynamic Tanstack Query React Hooks via a modular, Proxy-based architecture.",
5
5
  "scripts": {
6
6
  "build": "NODE_ENV=production rollup --config rollup.config.mjs && tsc --project tsconfig.build.json --emitDeclarationOnly",
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "sideEffects": false,
17
17
  "devDependencies": {
18
- "@openapi-qraft/cli": "2.0.0-next.2",
18
+ "@openapi-qraft/cli": "2.0.0-next.3",
19
19
  "@openapi-qraft/eslint-config": "1.0.0",
20
- "@openapi-qraft/openapi-typescript-plugin": "^1.2.0-next.2",
20
+ "@openapi-qraft/openapi-typescript-plugin": "^1.2.0-next.3",
21
21
  "@openapi-qraft/rollup-config": "1.1.0-next.0",
22
22
  "@openapi-qraft/test-fixtures": "1.0.0",
23
23
  "@tanstack/react-query": "^5.17.3",
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export {
5
5
  type CreateAPIQueryClientOptions,
6
6
  type APIQueryClientServices,
7
7
  type APIBasicClientServices,
8
+ type APIUtilityClientServices,
8
9
  type QraftClientOptions,
9
10
  } from './qraftAPIClient.js';
10
11
  export {
@@ -65,13 +65,21 @@ export function qraftAPIClient<
65
65
  options: CreateAPIQueryClientOptions
66
66
  ): APIQueryClientServices<Services, TCallbacks>;
67
67
 
68
+ export function qraftAPIClient<
69
+ Services extends ServicesDeclaration<Services>,
70
+ TCallbacks extends Callbacks,
71
+ >(
72
+ services: ServiceSchemasDeclaration<Services>,
73
+ callbacks: TCallbacks
74
+ ): APIUtilityClientServices<Services, TCallbacks>;
75
+
68
76
  export function qraftAPIClient<
69
77
  Services extends ServicesDeclaration<Services>,
70
78
  TCallbacks extends Callbacks,
71
79
  >(
72
80
  services: ServiceSchemasDeclaration<Services>,
73
81
  callbacks: TCallbacks,
74
- options: CreateAPIClientOptions
82
+ options?: CreateAPIClientOptions
75
83
  ): APIQueryClientServices<Services, TCallbacks> | Services {
76
84
  return createRecursiveProxy(
77
85
  function getCallback(getPath, key) {
@@ -97,7 +105,7 @@ export function qraftAPIClient<
97
105
  callbackName !== 'getQueryKey' &&
98
106
  callbackName !== 'getMutationKey'
99
107
  )
100
- if (!('queryClient' in options && options.queryClient))
108
+ if (!options || !('queryClient' in options && options.queryClient))
101
109
  throw new Error(
102
110
  `'qraft.<service>.<operation>.${String(callbackName)}()' requires 'queryClient' in options.`
103
111
  );
@@ -235,13 +243,23 @@ export type APIQueryClientServices<
235
243
  MutationOperationCallbacks
236
244
  >;
237
245
 
246
+ export type APIUtilityClientServices<
247
+ TServices extends ServicesDeclaration<TServices>,
248
+ TCallbacks extends Callbacks,
249
+ > = ServicesFilteredByCallbacks<
250
+ TServices,
251
+ Omit<TCallbacks, 'operationInvokeFn'>,
252
+ Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>,
253
+ Extract<MutationOperationCallbacks, 'getMutationKey'>
254
+ >;
255
+
238
256
  export type APIBasicClientServices<
239
257
  TServices extends ServicesDeclaration<TServices>,
240
258
  TCallbacks extends Callbacks,
241
259
  > = ServicesFilteredByCallbacks<
242
260
  TServices,
243
261
  TCallbacks,
244
- Extract<QueryOperationCallbacks, 'getQueryKey'>,
262
+ Extract<QueryOperationCallbacks, 'getQueryKey' | 'getInfiniteQueryKey'>,
245
263
  Extract<MutationOperationCallbacks, 'getMutationKey'>
246
264
  >;
247
265