@qualisero/openapi-endpoint 0.13.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -236
- package/dist/cli.js +748 -202
- package/dist/index.d.ts +9 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -58
- package/dist/openapi-helpers.d.ts +4 -17
- package/dist/openapi-helpers.d.ts.map +1 -1
- package/dist/openapi-helpers.js +3 -125
- package/dist/openapi-mutation.d.ts +28 -59
- package/dist/openapi-mutation.d.ts.map +1 -1
- package/dist/openapi-mutation.js +67 -83
- package/dist/openapi-query.d.ts +22 -50
- package/dist/openapi-query.d.ts.map +1 -1
- package/dist/openapi-query.js +22 -55
- package/dist/openapi-utils.d.ts +2 -1
- package/dist/openapi-utils.d.ts.map +1 -1
- package/dist/types.d.ts +218 -475
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -28
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @group Setup
|
|
11
|
-
* @template Ops - The operations type, typically generated from your OpenAPI spec
|
|
12
|
-
* @param config - Configuration object containing operations metadata and axios instance
|
|
13
|
-
* @returns {OpenApiInstance<Ops>} API instance with useQuery, useMutation, and debug methods
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { useOpenApi } from '@qualisero/openapi-endpoint'
|
|
18
|
-
* import { openApiOperations, type OpenApiOperations, QueryOperationId, MutationOperationId } from './generated/api-operations'
|
|
19
|
-
* import axios from 'axios'
|
|
20
|
-
*
|
|
21
|
-
* const api = useOpenApi<OpenApiOperations>({
|
|
22
|
-
* operations: openApiOperations,
|
|
23
|
-
* axios: axios.create({ baseURL: 'https://api.example.com' })
|
|
24
|
-
* })
|
|
25
|
-
*
|
|
26
|
-
* // Queries
|
|
27
|
-
* const listQuery = api.useQuery(QueryOperationId.listPets, {
|
|
28
|
-
* queryParams: { limit: 10 }
|
|
29
|
-
* })
|
|
30
|
-
*
|
|
31
|
-
* // Mutations
|
|
32
|
-
* const createPet = api.useMutation(MutationOperationId.createPet)
|
|
33
|
-
* createPet.mutate({ data: { name: 'Fluffy' } })
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function useOpenApi<Ops extends Operations<Ops>>(config: OpenApiConfig<Ops>): OpenApiInstance<Ops>;
|
|
1
|
+
export { useEndpointQuery } from './openapi-query';
|
|
2
|
+
export { useEndpointMutation } from './openapi-mutation';
|
|
3
|
+
export { defaultQueryClient } from './openapi-helpers';
|
|
4
|
+
export type { QueryReturn } from './openapi-query';
|
|
5
|
+
export type { MutationReturn } from './openapi-mutation';
|
|
6
|
+
export type { EndpointConfig, QueryOptions, MutationOptions, MutationVars, CacheInvalidationOptions, Refetchable, MutateFn, MutateAsyncFn, MutateAsyncReturn, ReactiveOr, NoExcessReturn, AxiosRequestConfigExtended, ApiResponse, ApiResponseSafe, ApiRequest, ApiPathParams, ApiPathParamsInput, ApiQueryParams, } from './types';
|
|
7
|
+
export { HttpMethod, QUERY_METHODS, MUTATION_METHODS, isQueryMethod, isMutationMethod } from './types';
|
|
8
|
+
export type { Ref, ComputedRef } from 'vue';
|
|
9
|
+
export type { MaybeRefOrGetter } from '@vue/reactivity';
|
|
37
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAKtD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAKxD,YAAY,EAEV,cAAc,EAGd,YAAY,EACZ,eAAe,EACf,YAAY,EAGZ,wBAAwB,EACxB,WAAW,EAGX,QAAQ,EACR,aAAa,EACb,iBAAiB,EAGjB,UAAU,EACV,cAAc,EAGd,0BAA0B,EAG1B,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAA;AAKhB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAKtG,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,58 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @group Setup
|
|
13
|
-
* @template Ops - The operations type, typically generated from your OpenAPI spec
|
|
14
|
-
* @param config - Configuration object containing operations metadata and axios instance
|
|
15
|
-
* @returns {OpenApiInstance<Ops>} API instance with useQuery, useMutation, and debug methods
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { useOpenApi } from '@qualisero/openapi-endpoint'
|
|
20
|
-
* import { openApiOperations, type OpenApiOperations, QueryOperationId, MutationOperationId } from './generated/api-operations'
|
|
21
|
-
* import axios from 'axios'
|
|
22
|
-
*
|
|
23
|
-
* const api = useOpenApi<OpenApiOperations>({
|
|
24
|
-
* operations: openApiOperations,
|
|
25
|
-
* axios: axios.create({ baseURL: 'https://api.example.com' })
|
|
26
|
-
* })
|
|
27
|
-
*
|
|
28
|
-
* // Queries
|
|
29
|
-
* const listQuery = api.useQuery(QueryOperationId.listPets, {
|
|
30
|
-
* queryParams: { limit: 10 }
|
|
31
|
-
* })
|
|
32
|
-
*
|
|
33
|
-
* // Mutations
|
|
34
|
-
* const createPet = api.useMutation(MutationOperationId.createPet)
|
|
35
|
-
* createPet.mutate({ data: { name: 'Fluffy' } })
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export function useOpenApi(config) {
|
|
39
|
-
function useQuery(operationId, pathParamsOrOptions, optionsOrNull) {
|
|
40
|
-
const helpers = getHelpers(config);
|
|
41
|
-
const { path } = helpers.getOperationInfo(operationId);
|
|
42
|
-
const hasPathParams = path.includes('{');
|
|
43
|
-
if (hasPathParams) {
|
|
44
|
-
return useEndpointQuery(operationId, helpers, pathParamsOrOptions, optionsOrNull);
|
|
45
|
-
}
|
|
46
|
-
return useEndpointQuery(operationId, helpers, undefined, pathParamsOrOptions);
|
|
47
|
-
}
|
|
48
|
-
function useMutation(operationId, pathParamsOrOptions, optionsOrNull) {
|
|
49
|
-
const helpers = getHelpers(config);
|
|
50
|
-
const { path } = helpers.getOperationInfo(operationId);
|
|
51
|
-
const hasPathParams = path.includes('{');
|
|
52
|
-
if (hasPathParams) {
|
|
53
|
-
return useEndpointMutation(operationId, helpers, pathParamsOrOptions, optionsOrNull);
|
|
54
|
-
}
|
|
55
|
-
return useEndpointMutation(operationId, helpers, undefined, pathParamsOrOptions);
|
|
56
|
-
}
|
|
57
|
-
return { useQuery, useMutation };
|
|
58
|
-
}
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Core primitives (called by generated api-client.ts)
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export { useEndpointQuery } from './openapi-query.js';
|
|
5
|
+
export { useEndpointMutation } from './openapi-mutation.js';
|
|
6
|
+
export { defaultQueryClient } from './openapi-helpers.js';
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// HTTP method utilities
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export { HttpMethod, QUERY_METHODS, MUTATION_METHODS, isQueryMethod, isMutationMethod } from './types.js';
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryClient } from '@tanstack/vue-query';
|
|
2
2
|
/**
|
|
3
|
-
* Default QueryClient
|
|
4
|
-
*
|
|
5
|
-
* This client is used by default when no custom QueryClient is provided to useOpenApi.
|
|
6
|
-
* It includes sensible defaults like 5-minute stale time for queries.
|
|
3
|
+
* Default QueryClient with sensible defaults (5-minute stale time).
|
|
4
|
+
* Used when no custom QueryClient is provided to the generated `createApiClient`.
|
|
7
5
|
*/
|
|
8
|
-
declare const defaultQueryClient:
|
|
9
|
-
export declare function getHelpers<Ops extends Operations<Ops>, Op extends keyof Ops>(config: OpenApiConfig<Ops>): {
|
|
10
|
-
getOperationInfo: (operationId: Op) => OperationInfo;
|
|
11
|
-
getListOperationPath: (operationId: Op) => string | null;
|
|
12
|
-
getCrudListPathPrefix: (operationId: Op) => string | null;
|
|
13
|
-
isQueryOperation: (operationId: Op) => boolean;
|
|
14
|
-
isMutationOperation: (operationId: Op) => boolean;
|
|
15
|
-
axios: import("axios").AxiosInstance;
|
|
16
|
-
queryClient: QueryClientLike;
|
|
17
|
-
};
|
|
18
|
-
export type OpenApiHelpers<Ops extends Operations<Ops>, Op extends keyof Ops> = ReturnType<typeof getHelpers<Ops, Op>>;
|
|
19
|
-
export { defaultQueryClient as queryClient };
|
|
6
|
+
export declare const defaultQueryClient: QueryClient;
|
|
20
7
|
//# sourceMappingURL=openapi-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-helpers.d.ts","sourceRoot":"","sources":["../src/openapi-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"openapi-helpers.d.ts","sourceRoot":"","sources":["../src/openapi-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAI/B,CAAA"}
|
package/dist/openapi-helpers.js
CHANGED
|
@@ -1,132 +1,10 @@
|
|
|
1
|
-
import { HttpMethod, isQueryMethod, isMutationMethod, } from './types.js';
|
|
2
1
|
import { QueryClient } from '@tanstack/vue-query';
|
|
3
2
|
/**
|
|
4
|
-
* Default QueryClient
|
|
5
|
-
*
|
|
6
|
-
* This client is used by default when no custom QueryClient is provided to useOpenApi.
|
|
7
|
-
* It includes sensible defaults like 5-minute stale time for queries.
|
|
3
|
+
* Default QueryClient with sensible defaults (5-minute stale time).
|
|
4
|
+
* Used when no custom QueryClient is provided to the generated `createApiClient`.
|
|
8
5
|
*/
|
|
9
|
-
const defaultQueryClient = new QueryClient({
|
|
6
|
+
export const defaultQueryClient = new QueryClient({
|
|
10
7
|
defaultOptions: {
|
|
11
8
|
queries: { staleTime: 1000 * 60 * 5 },
|
|
12
9
|
},
|
|
13
10
|
});
|
|
14
|
-
/**
|
|
15
|
-
* Suffixes that require adding 'es' for pluralization (e.g., 'box' -> 'boxes').
|
|
16
|
-
*/
|
|
17
|
-
const PLURAL_ES_SUFFIXES = ['s', 'x', 'z', 'ch', 'sh', 'o'];
|
|
18
|
-
/**
|
|
19
|
-
* Mapping of HTTP methods to their CRUD operation name prefixes.
|
|
20
|
-
* Used to infer resource names from operation IDs.
|
|
21
|
-
*/
|
|
22
|
-
const CRUD_PREFIXES = {
|
|
23
|
-
[HttpMethod.GET]: { singular: 'get', plural: 'list' },
|
|
24
|
-
[HttpMethod.POST]: { singular: 'create', plural: 'create' },
|
|
25
|
-
[HttpMethod.PUT]: { singular: 'update', plural: 'update' },
|
|
26
|
-
[HttpMethod.PATCH]: { singular: 'update', plural: 'update' },
|
|
27
|
-
[HttpMethod.DELETE]: { singular: 'delete', plural: 'delete' },
|
|
28
|
-
[HttpMethod.HEAD]: null,
|
|
29
|
-
[HttpMethod.OPTIONS]: null,
|
|
30
|
-
[HttpMethod.TRACE]: null,
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Extracts the resource name from an operation ID based on its HTTP method.
|
|
34
|
-
* @param operationId - The operation ID (e.g., 'createPet', 'updatePet')
|
|
35
|
-
* @param method - The HTTP method
|
|
36
|
-
* @returns The resource name (e.g., 'Pet') or null if not extractable
|
|
37
|
-
*/
|
|
38
|
-
function getResourceName(operationId, method) {
|
|
39
|
-
const prefixes = CRUD_PREFIXES[method];
|
|
40
|
-
if (!prefixes)
|
|
41
|
-
return null;
|
|
42
|
-
// Try singular prefix first (get, create, update, delete)
|
|
43
|
-
if (operationId.startsWith(prefixes.singular)) {
|
|
44
|
-
const remaining = operationId.slice(prefixes.singular.length);
|
|
45
|
-
if (remaining.length > 0 && /^[A-Z]/.test(remaining)) {
|
|
46
|
-
return remaining;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// Try plural prefix (list)
|
|
50
|
-
if (operationId.startsWith(prefixes.plural)) {
|
|
51
|
-
const remaining = operationId.slice(prefixes.plural.length);
|
|
52
|
-
if (remaining.length > 0 && /^[A-Z]/.test(remaining)) {
|
|
53
|
-
return remaining;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Pluralizes a resource name using common English rules.
|
|
60
|
-
* @param name - The singular resource name
|
|
61
|
-
* @returns The pluralized name
|
|
62
|
-
*/
|
|
63
|
-
function pluralizeResource(name) {
|
|
64
|
-
if (name.endsWith('y')) {
|
|
65
|
-
return name.slice(0, -1) + 'ies';
|
|
66
|
-
}
|
|
67
|
-
else if (PLURAL_ES_SUFFIXES.some((suffix) => name.endsWith(suffix))) {
|
|
68
|
-
return name + 'es';
|
|
69
|
-
}
|
|
70
|
-
return name + 's';
|
|
71
|
-
}
|
|
72
|
-
export function getHelpers(config) {
|
|
73
|
-
// Helper function to get operation info by ID
|
|
74
|
-
function getOperationInfo(operationId) {
|
|
75
|
-
return config.operations[operationId];
|
|
76
|
-
}
|
|
77
|
-
// Helper to return a url path for matching list endpoint (e.g. /items/123 -> /items/)
|
|
78
|
-
// Based on operationId prefix: createItem, updateItem -> listItem
|
|
79
|
-
function getListOperationPath(operationId) {
|
|
80
|
-
const opInfo = getOperationInfo(operationId);
|
|
81
|
-
const operationIdStr = operationId;
|
|
82
|
-
// Try to extract resource name from operation ID
|
|
83
|
-
const resourceName = getResourceName(operationIdStr, opInfo.method);
|
|
84
|
-
if (!resourceName) {
|
|
85
|
-
// Fallback to CRUD heuristic based on path structure
|
|
86
|
-
return getCrudListPathPrefix(operationId);
|
|
87
|
-
}
|
|
88
|
-
// Try to find list operation with same resource name
|
|
89
|
-
const listOperationId = `list${resourceName}`;
|
|
90
|
-
let listOperationInfo = getOperationInfo(listOperationId);
|
|
91
|
-
// If not found, try pluralized version
|
|
92
|
-
if (!listOperationInfo) {
|
|
93
|
-
const pluralName = pluralizeResource(resourceName);
|
|
94
|
-
listOperationInfo = getOperationInfo(`list${pluralName}`);
|
|
95
|
-
}
|
|
96
|
-
if (listOperationInfo && listOperationInfo.method === HttpMethod.GET) {
|
|
97
|
-
return listOperationInfo.path;
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
// Fallback to return a url path prefix matching list endpoint (e.g. /items/123 -> /items/)
|
|
102
|
-
// based on Assumes standard CRUD Restful patterns.
|
|
103
|
-
function getCrudListPathPrefix(operationId) {
|
|
104
|
-
const { path } = getOperationInfo(operationId);
|
|
105
|
-
// for PUT/PATCH/DELETE, strip last segment if it's a path parameter
|
|
106
|
-
const segments = path.split('/').filter((segment) => segment.length > 0);
|
|
107
|
-
if (segments.length >= 2 && /^{[^}]+}$/.test(segments.at(-1))) {
|
|
108
|
-
return '/' + segments.slice(0, -1).join('/') + '/';
|
|
109
|
-
}
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
// Helper to check if an operation is a query method at runtime
|
|
113
|
-
function isQueryOperation(operationId) {
|
|
114
|
-
const { method } = getOperationInfo(operationId);
|
|
115
|
-
return isQueryMethod(method);
|
|
116
|
-
}
|
|
117
|
-
// Helper to check if an operation is a mutation method at runtime
|
|
118
|
-
function isMutationOperation(operationId) {
|
|
119
|
-
const { method } = getOperationInfo(operationId);
|
|
120
|
-
return isMutationMethod(method);
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
getOperationInfo,
|
|
124
|
-
getListOperationPath,
|
|
125
|
-
getCrudListPathPrefix,
|
|
126
|
-
isQueryOperation,
|
|
127
|
-
isMutationOperation,
|
|
128
|
-
axios: config.axios,
|
|
129
|
-
queryClient: config.queryClient || defaultQueryClient,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
export { defaultQueryClient as queryClient };
|
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
import { type ComputedRef, type Ref
|
|
2
|
-
import
|
|
3
|
-
import { type OpenApiHelpers } from './openapi-helpers';
|
|
1
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
import type { MaybeRefOrGetter } from '@vue/reactivity';
|
|
4
3
|
import { type AxiosResponse } from 'axios';
|
|
4
|
+
import { type EndpointConfig, type MutationOptions, type MutateFn, type MutateAsyncFn } from './types';
|
|
5
5
|
/**
|
|
6
|
-
* Return type of `
|
|
6
|
+
* Return type of `useEndpointMutation` (the `useMutation` composable on a generated namespace).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @template Ops - The operations type from your OpenAPI specification
|
|
13
|
-
* @template Op - The operation key from your operations type
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const mutation = api.useMutation('createPet')
|
|
18
|
-
*
|
|
19
|
-
* // Reactive properties
|
|
20
|
-
* if (mutation.isPending.value) console.log('Saving...')
|
|
21
|
-
* if (mutation.isSuccess.value) console.log('Created:', mutation.data.value)
|
|
22
|
-
*
|
|
23
|
-
* // Execute
|
|
24
|
-
* mutation.mutate({ data: { name: 'Fluffy' } })
|
|
25
|
-
* await mutation.mutateAsync({ data: { name: 'Fluffy' } })
|
|
26
|
-
* ```
|
|
8
|
+
* @template TResponse Response data type
|
|
9
|
+
* @template TPathParams Path parameters type (concrete, required values)
|
|
10
|
+
* @template TRequest Request body type (`never` if none)
|
|
11
|
+
* @template TQueryParams Query parameters type
|
|
27
12
|
*
|
|
28
13
|
* @group Types
|
|
29
14
|
*/
|
|
30
|
-
export interface
|
|
15
|
+
export interface MutationReturn<TResponse, TPathParams extends Record<string, unknown> = Record<string, never>, TRequest = never, TQueryParams extends Record<string, unknown> = Record<string, never>> {
|
|
31
16
|
/** The Axios response (undefined until mutation completes). */
|
|
32
|
-
data: ComputedRef<AxiosResponse<
|
|
17
|
+
data: ComputedRef<AxiosResponse<TResponse> | undefined>;
|
|
33
18
|
/** The error if the mutation failed. */
|
|
34
19
|
error: Ref<Error | null>;
|
|
35
20
|
/** True while the mutation is in progress. */
|
|
@@ -39,48 +24,32 @@ export interface EndpointMutationReturn<Ops extends Operations<Ops>, Op extends
|
|
|
39
24
|
/** True when the mutation failed. */
|
|
40
25
|
isError: Ref<boolean>;
|
|
41
26
|
/** Execute the mutation (non-blocking). */
|
|
42
|
-
mutate: MutateFn<
|
|
43
|
-
/** Execute the mutation and
|
|
44
|
-
mutateAsync: MutateAsyncFn<
|
|
27
|
+
mutate: MutateFn<TPathParams, TRequest, TQueryParams>;
|
|
28
|
+
/** Execute the mutation and await the response. */
|
|
29
|
+
mutateAsync: MutateAsyncFn<TResponse, TPathParams, TRequest, TQueryParams>;
|
|
45
30
|
/** Reset the mutation state. */
|
|
46
31
|
reset: () => void;
|
|
47
|
-
/** Whether the mutation can execute (path
|
|
32
|
+
/** Whether the mutation can execute (all required path params are resolved). */
|
|
48
33
|
isEnabled: ComputedRef<boolean>;
|
|
49
34
|
/** The resolved path parameters. */
|
|
50
|
-
pathParams: ComputedRef<
|
|
51
|
-
/** Additional path
|
|
52
|
-
extraPathParams: Ref<
|
|
35
|
+
pathParams: ComputedRef<TPathParams>;
|
|
36
|
+
/** Additional path params that can be supplied at mutation time. */
|
|
37
|
+
extraPathParams: Ref<TPathParams>;
|
|
53
38
|
}
|
|
54
39
|
/**
|
|
55
|
-
* Execute a type-safe mutation (POST/PUT/PATCH/DELETE) with automatic cache
|
|
40
|
+
* Execute a type-safe mutation (POST/PUT/PATCH/DELETE) with automatic cache management.
|
|
56
41
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
42
|
+
* This is a low-level primitive — in normal usage it is called by the generated
|
|
43
|
+
* per-operation `useMutation` wrappers in `api-client.ts`, not directly.
|
|
59
44
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
45
|
+
* @template TResponse The response data type
|
|
46
|
+
* @template TPathParams The path parameters type (concrete, required values)
|
|
47
|
+
* @template TRequest The request body type (`never` if no body)
|
|
48
|
+
* @template TQueryParams The query parameters type
|
|
62
49
|
*
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
65
|
-
* @param
|
|
66
|
-
* @param h - OpenAPI helpers (internal), provided by useOpenApi
|
|
67
|
-
* @param pathParams - Path parameters (can be reactive). Omit for operations without path params.
|
|
68
|
-
* @param options - Mutation options (dontInvalidate, refetchEndpoints, etc.)
|
|
69
|
-
* - `dontUpdateCache`: Skip cache update for PUT/PATCH responses
|
|
70
|
-
* - `dontInvalidate`: Skip invalidating matching queries
|
|
71
|
-
* - `invalidateOperations`: Additional operation IDs to invalidate (array or map of params)
|
|
72
|
-
* - `refetchEndpoints`: Additional query results to refetch
|
|
73
|
-
* - `queryParams`: Query string parameters (operation-specific)
|
|
74
|
-
* - `axiosOptions`: Custom axios request options (headers, params, etc.)
|
|
75
|
-
* - Plus all {@link UseMutationOptions} from @tanstack/vue-query
|
|
76
|
-
* @throws Error if the operation is not a mutation operation
|
|
77
|
-
* @returns Mutation object with
|
|
78
|
-
* - `mutate(vars)` / `mutateAsync(vars)` to trigger the mutation
|
|
79
|
-
* - `data`: ComputedRef of Axios response data
|
|
80
|
-
* - `isEnabled`: ComputedRef indicating if mutation can execute (path resolved)
|
|
81
|
-
* - `extraPathParams`: Ref to set additional path params at call time
|
|
82
|
-
* - `pathParams`: Resolved path params as a computed ref
|
|
50
|
+
* @param config Endpoint config: axios instance, queryClient, path, method, listPath, operationsRegistry
|
|
51
|
+
* @param pathParams Path parameters (reactive). Pass `undefined` for operations without path params.
|
|
52
|
+
* @param options Mutation options (dontInvalidate, refetchEndpoints, etc.)
|
|
83
53
|
*/
|
|
84
|
-
export declare function useEndpointMutation<
|
|
85
|
-
pathParams?: MaybeRefOrGetter<ApiPathParamsInput<Ops, Op> | null | undefined>, options?: QMutationOptions<Ops, Op>): EndpointMutationReturn<Ops, Op>;
|
|
54
|
+
export declare function useEndpointMutation<TResponse, TPathParams extends Record<string, unknown> = Record<string, never>, TRequest = never, TQueryParams extends Record<string, unknown> = Record<string, never>>(config: EndpointConfig, pathParams?: MaybeRefOrGetter<Record<string, string | number | undefined> | null | undefined>, options?: MutationOptions<TResponse, TPathParams, TRequest, TQueryParams>): MutationReturn<TResponse, TPathParams, TRequest, TQueryParams>;
|
|
86
55
|
//# sourceMappingURL=openapi-mutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-mutation.d.ts","sourceRoot":"","sources":["../src/openapi-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"openapi-mutation.d.ts","sourceRoot":"","sources":["../src/openapi-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,K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