Skip to content

Commit 78cae45

Browse files
committed
feat: rename qraftAPIClient to qraftReactAPIClient in API client creation
1 parent d081dc1 commit 78cae45

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

packages/tanstack-query-react-plugin/src/__snapshots__/create-api-client-fn/context-all-createAPIClient.ts.snapshot.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { APIBasicClientServices, APIBasicQueryClientServices, APIDefaultQueryClientServices, APIContextQueryClientServices, CreateAPIBasicClientOptions, CreateAPIBasicQueryClientOptions, CreateAPIClientOptions, CreateAPIQueryClientOptions } from "@openapi-qraft/react";
77
import { APIClientContext } from "./APIClientContext";
88
import * as allCallbacks from "@openapi-qraft/react/callbacks/index";
9-
import { qraftAPIClient } from "@openapi-qraft/react";
9+
import { qraftReactAPIClient } from "@openapi-qraft/react";
1010
import { services } from "./services/index";
1111
export function createAPIClient(options: CreateAPIQueryClientOptions): APIDefaultQueryClientServices<Services>;
1212
export function createAPIClient(options: CreateAPIBasicQueryClientOptions): APIBasicQueryClientServices<Services, AllCallbacks>;
@@ -15,11 +15,11 @@ export function createAPIClient(): APIContextQueryClientServices<Services, AllCa
1515
export function createAPIClient(options?: CreateAPIClientOptions): APIDefaultQueryClientServices<Services> | APIContextQueryClientServices<Services, AllCallbacks> | APIBasicQueryClientServices<Services, AllCallbacks> | APIBasicClientServices<Services, AllCallbacks> {
1616
if (options) {
1717
if ("requestFn" in options)
18-
return qraftAPIClient(services, allCallbacks, options);
18+
return qraftReactAPIClient(services, allCallbacks, options);
1919
if ("queryClient" in options)
20-
return qraftAPIClient(services, allCallbacks, options);
20+
return qraftReactAPIClient(services, allCallbacks, options);
2121
}
22-
return qraftAPIClient(services, allCallbacks, APIClientContext);
22+
return qraftReactAPIClient(services, allCallbacks, APIClientContext);
2323
}
2424
type AllCallbacks = typeof allCallbacks;
2525
type Services = typeof services;

packages/tanstack-query-react-plugin/src/__snapshots__/create-api-client-fn/context-createAPIClient.ts.snapshot.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { APIBasicClientServices, APIBasicQueryClientServices, APIDefaultQueryClientServices, APIContextQueryClientServices, APIQueryClientServices, CreateAPIBasicClientOptions, CreateAPIBasicQueryClientOptions, CreateAPIClientOptions, CreateAPIQueryClientOptions } from "@openapi-qraft/react";
77
import { APIClientContext } from "./APIClientContext";
88
import type * as allCallbacks from "@openapi-qraft/react/callbacks/index";
9-
import { qraftAPIClient } from "@openapi-qraft/react";
9+
import { qraftReactAPIClient } from "@openapi-qraft/react";
1010
import { useQuery, useMutation } from "@openapi-qraft/react/callbacks/index";
1111
const defaultCallbacks = {
1212
useQuery,
@@ -21,11 +21,11 @@ export function createAPIClient<Callbacks extends Partial<AllCallbacks> = Defaul
2121
export function createAPIClient<Callbacks extends Partial<AllCallbacks> = DefaultCallbacks>(callbacksOrOptions?: CreateAPIClientOptions | Callbacks, callbacks: Callbacks = defaultCallbacks as Callbacks): APIDefaultQueryClientServices<Services> | APIQueryClientServices<Services, Callbacks> | APIContextQueryClientServices<Services, Callbacks> | APIBasicQueryClientServices<Services, Callbacks> | APIBasicClientServices<Services, Callbacks> {
2222
if (callbacksOrOptions) {
2323
if ("requestFn" in callbacksOrOptions)
24-
return qraftAPIClient(services, callbacks, callbacksOrOptions);
24+
return qraftReactAPIClient(services, callbacks, callbacksOrOptions);
2525
if ("queryClient" in callbacksOrOptions)
26-
return qraftAPIClient(services, callbacks, callbacksOrOptions);
26+
return qraftReactAPIClient(services, callbacks, callbacksOrOptions);
2727
}
28-
return qraftAPIClient(services, callbacksOrOptions ?? callbacks, APIClientContext);
28+
return qraftReactAPIClient(services, callbacksOrOptions ?? callbacks, APIClientContext);
2929
}
3030
type DefaultCallbacks = typeof defaultCallbacks;
3131
type AllCallbacks = typeof allCallbacks;

packages/tanstack-query-react-plugin/src/__snapshots__/create-api-client-fn/context-none-createAPIClient.ts.snapshot.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { APIBasicClientServices, APIBasicQueryClientServices, APIDefaultQueryClientServices, APIContextQueryClientServices, APIQueryClientServices, CreateAPIBasicClientOptions, CreateAPIBasicQueryClientOptions, CreateAPIClientOptions, CreateAPIQueryClientOptions, UnionServiceOperationsDeclaration } from "@openapi-qraft/react";
77
import { APIClientContext } from "./APIClientContext";
88
import type * as allCallbacks from "@openapi-qraft/react/callbacks/index";
9-
import { qraftAPIClient } from "@openapi-qraft/react";
9+
import { qraftReactAPIClient } from "@openapi-qraft/react";
1010
const defaultCallbacks = {} as const;
1111
export function createAPIClient<Services extends UnionServiceOperationsDeclaration<Services>>(services: Services, options: CreateAPIQueryClientOptions, callbacks: AllCallbacks): APIDefaultQueryClientServices<Services>;
1212
export function createAPIClient<Services extends UnionServiceOperationsDeclaration<Services>, Callbacks extends Partial<AllCallbacks> = DefaultCallbacks>(services: Services, options: CreateAPIQueryClientOptions, callbacks: Callbacks): APIQueryClientServices<Services, Callbacks>;
@@ -16,11 +16,11 @@ export function createAPIClient<Services extends UnionServiceOperationsDeclarati
1616
export function createAPIClient<Services extends UnionServiceOperationsDeclaration<Services>, Callbacks extends Partial<AllCallbacks> = DefaultCallbacks>(services: Services, callbacksOrOptions: CreateAPIClientOptions | Callbacks, callbacks: Callbacks = defaultCallbacks as Callbacks): APIDefaultQueryClientServices<Services> | APIQueryClientServices<Services, Callbacks> | APIContextQueryClientServices<Services, Callbacks> | APIBasicQueryClientServices<Services, Callbacks> | APIBasicClientServices<Services, Callbacks> {
1717
if (callbacksOrOptions) {
1818
if ("requestFn" in callbacksOrOptions)
19-
return qraftAPIClient(services, callbacks, callbacksOrOptions);
19+
return qraftReactAPIClient(services, callbacks, callbacksOrOptions);
2020
if ("queryClient" in callbacksOrOptions)
21-
return qraftAPIClient(services, callbacks, callbacksOrOptions);
21+
return qraftReactAPIClient(services, callbacks, callbacksOrOptions);
2222
}
23-
return qraftAPIClient(services, callbacksOrOptions ?? callbacks, APIClientContext);
23+
return qraftReactAPIClient(services, callbacksOrOptions ?? callbacks, APIClientContext);
2424
}
2525
type DefaultCallbacks = typeof defaultCallbacks;
2626
type AllCallbacks = typeof allCallbacks;

packages/tanstack-query-react-plugin/src/ts-factory/getCreateAPIClientFactory.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const getOperationClientImportsFactory = ({
4545

4646
const qraftImportTypeOverrides =
4747
createAPIClientFnImportTypeOverrides?.['@openapi-qraft/react'];
48+
const qraftClientFactoryName = contextName
49+
? 'qraftReactAPIClient'
50+
: 'qraftAPIClient';
4851

4952
const availableQraftImportedTypes = [
5053
'APIBasicClientServices',
@@ -144,7 +147,7 @@ const getOperationClientImportsFactory = ({
144147
factory.createImportSpecifier(
145148
false,
146149
undefined,
147-
factory.createIdentifier('qraftAPIClient')
150+
factory.createIdentifier(qraftClientFactoryName)
148151
),
149152
])
150153
),
@@ -242,6 +245,9 @@ const getCreateOperationClientFunctionFactory = ({
242245
contextName,
243246
}: Options) => {
244247
const factory = ts.factory;
248+
const qraftClientFactoryName = contextName
249+
? 'qraftReactAPIClient'
250+
: 'qraftAPIClient';
245251

246252
const shouldImportAllCallbacks = defaultClientCallbacks?.some(
247253
(name) => name === 'all'
@@ -940,7 +946,7 @@ const getCreateOperationClientFunctionFactory = ({
940946
),
941947
factory.createReturnStatement(
942948
factory.createCallExpression(
943-
factory.createIdentifier('qraftAPIClient'),
949+
factory.createIdentifier(qraftClientFactoryName),
944950
undefined,
945951
[
946952
factory.createIdentifier('services'),
@@ -971,7 +977,7 @@ const getCreateOperationClientFunctionFactory = ({
971977
),
972978
factory.createReturnStatement(
973979
factory.createCallExpression(
974-
factory.createIdentifier('qraftAPIClient'),
980+
factory.createIdentifier(qraftClientFactoryName),
975981
undefined,
976982
[
977983
factory.createIdentifier('services'),
@@ -997,7 +1003,7 @@ const getCreateOperationClientFunctionFactory = ({
9971003
),
9981004
factory.createReturnStatement(
9991005
factory.createCallExpression(
1000-
factory.createIdentifier('qraftAPIClient'),
1006+
factory.createIdentifier(qraftClientFactoryName),
10011007
undefined,
10021008
[
10031009
factory.createIdentifier('services'),

0 commit comments

Comments
 (0)