@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/dist/index.d.ts CHANGED
@@ -1,37 +1,10 @@
1
- import { Operations, OpenApiConfig, OpenApiInstance } from './types';
2
- export type { OpenApiConfig, OpenApiInstance, ApiResponse, ApiResponseSafe, ApiRequest, ApiPathParams, ApiPathParamsInput, ApiQueryParams, QueryClientLike, QQueryOptions, QMutationOptions, QMutationVars, CacheInvalidationOptions, EndpointQueryReturn, EndpointMutationReturn, RequiresPathParameters, HasExcessPathParams, NoPathParams, WithPathParams, QueryOpsNoPathParams, QueryOpsWithPathParams, MutationOpsNoPathParams, MutationOpsWithPathParams, AxiosRequestConfigExtended, ReactiveOr, ReactiveValue, MutateFn, MutateAsyncFn, MutateAsyncReturn, } from './types';
3
- export { validateMutationParams } from './types';
4
- /**
5
- * Create a type-safe OpenAPI client with Vue Query integration.
6
- *
7
- * This is the main entry point for the library. It provides reactive composables
8
- * for API operations with full TypeScript type safety based on your OpenAPI specification.
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EAGV,aAAa,EACb,eAAe,EAShB,MAAM,SAAS,CAAA;AAIhB,YAAY,EACV,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,UAAU,EACV,aAAa,EACb,QAAQ,EACR,aAAa,EACb,iBAAiB,GAClB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CA2JxG"}
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
- import { useEndpointQuery } from './openapi-query.js';
2
- import { useEndpointMutation } from './openapi-mutation.js';
3
- import { getHelpers } from './openapi-helpers.js';
4
- // Public function exports
5
- export { validateMutationParams } from './types.js';
6
- /**
7
- * Create a type-safe OpenAPI client with Vue Query integration.
8
- *
9
- * This is the main entry point for the library. It provides reactive composables
10
- * for API operations with full TypeScript type safety based on your OpenAPI specification.
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 { type OperationInfo, OpenApiConfig, Operations, QueryClientLike } from './types';
1
+ import { QueryClient } from '@tanstack/vue-query';
2
2
  /**
3
- * Default QueryClient instance with pre-configured options.
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: QueryClientLike;
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,EAEL,KAAK,aAAa,EAClB,aAAa,EACb,UAAU,EACV,eAAe,EAGhB,MAAM,SAAS,CAAA;AAGhB;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,EAAE,eAIxB,CAAA;AAiEF,wBAAgB,UAAU,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC;oCAE/D,EAAE,KAAG,aAAa;wCAMd,EAAE,KAAG,MAAM,GAAG,IAAI;yCA6BjB,EAAE,KAAG,MAAM,GAAG,IAAI;oCAWvB,EAAE,KAAG,OAAO;uCAMT,EAAE,KAAG,OAAO;;;EAcvD;AAED,MAAM,MAAM,cAAc,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAA;AAEtH,OAAO,EAAE,kBAAkB,IAAI,WAAW,EAAE,CAAA"}
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"}
@@ -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 instance with pre-configured options.
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, type MaybeRefOrGetter } from 'vue';
2
- import { type ApiPathParams, type ApiPathParamsInput, type ApiResponse, type QMutationOptions, type MutateFn, type MutateAsyncFn, Operations } from './types';
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 `useMutation` (created via `useOpenApi`).
6
+ * Return type of `useEndpointMutation` (the `useMutation` composable on a generated namespace).
7
7
  *
8
- * Reactive mutation result with automatic cache management and helpers.
9
- *
10
- * All properties are reactive (ComputedRef/Ref) and auto-unwrap in Vue templates.
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 EndpointMutationReturn<Ops extends Operations<Ops>, Op extends keyof Ops> {
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<ApiResponse<Ops, Op>> | undefined>;
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<Ops, Op>;
43
- /** Execute the mutation and wait for the response. */
44
- mutateAsync: MutateAsyncFn<Ops, Op>;
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 parameters resolved). */
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<ApiPathParams<Ops, Op>>;
51
- /** Additional path parameters that can be provided at mutation time. */
52
- extraPathParams: Ref<ApiPathParams<Ops, Op>>;
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 updates.
40
+ * Execute a type-safe mutation (POST/PUT/PATCH/DELETE) with automatic cache management.
56
41
  *
57
- * Ensures the operation is a mutation at runtime and returns a reactive mutation object
58
- * with helpers for path resolution and cache invalidation.
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
- * NOTE: By default, the mutation updates cache for PUT/PATCH and invalidates matching
61
- * GET queries for the same path.
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
- * @template Ops - The operations type from your OpenAPI specification
64
- * @template Op - The operation key from your operations type
65
- * @param operationId - The OpenAPI operation ID to mutate
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<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, h: OpenApiHelpers<Ops, Op>, // helpers
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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