@qualisero/openapi-endpoint 0.4.1 → 0.6.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 +122 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/openapi-endpoint.d.ts +2 -2
- package/dist/openapi-endpoint.d.ts.map +1 -1
- package/dist/openapi-helpers.d.ts +1 -0
- package/dist/openapi-helpers.d.ts.map +1 -1
- package/dist/openapi-helpers.js +10 -13
- package/dist/openapi-mutation.d.ts +14 -14
- package/dist/openapi-mutation.d.ts.map +1 -1
- package/dist/openapi-mutation.js +6 -6
- package/dist/openapi-query.d.ts +2 -2
- package/dist/openapi-query.d.ts.map +1 -1
- package/dist/openapi-query.js +2 -3
- package/dist/openapi-utils.d.ts.map +1 -1
- package/dist/openapi-utils.js +24 -27
- package/dist/types.d.ts +4 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
Type-safe OpenAPI integration for Vue Query (TanStack Query).
|
|
9
9
|
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Let's you get TanStack Vue Query composables that enforce consistency (name of endpoints, typing) with your API's `openapi.json` file:
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
const { data, isLoading } = api.useQuery(OperationId.getPet, { petId: '123' })
|
|
16
|
+
|
|
17
|
+
const createPetMutation = api.useMutation(OperationId.createPet)
|
|
18
|
+
createPetMutation.mutate({ data: { name: 'Fluffy', species: 'cat' } })
|
|
19
|
+
```
|
|
20
|
+
|
|
10
21
|
## Installation
|
|
11
22
|
|
|
12
23
|
```bash
|
|
@@ -75,3 +86,114 @@ await createPetMutation.mutateAsync({
|
|
|
75
86
|
data: { name: 'Fluffy', species: 'cat' },
|
|
76
87
|
})
|
|
77
88
|
```
|
|
89
|
+
|
|
90
|
+
## Advanced Usage
|
|
91
|
+
|
|
92
|
+
### Automatic Operation Type Detection with `api.useEndpoint`
|
|
93
|
+
|
|
94
|
+
The `api.useEndpoint` method automatically detects whether an operation is a query (GET/HEAD/OPTIONS) or mutation (POST/PUT/PATCH/DELETE) based on the HTTP method defined in your OpenAPI specification:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { ref, computed } from 'vue'
|
|
98
|
+
import { api, OperationId } from './api/init'
|
|
99
|
+
|
|
100
|
+
// Automatically becomes a query for GET operations
|
|
101
|
+
const listEndpoint = api.useEndpoint(OperationId.listPets)
|
|
102
|
+
// TypeScript knows this has query properties like .data, .isLoading, .refetch()
|
|
103
|
+
|
|
104
|
+
// Automatically becomes a mutation for POST operations
|
|
105
|
+
const createEndpoint = api.useEndpoint(OperationId.createPet)
|
|
106
|
+
// TypeScript knows this has mutation properties like .mutate(), .mutateAsync()
|
|
107
|
+
|
|
108
|
+
// Use the endpoints according to their detected type
|
|
109
|
+
const petData = listEndpoint.data // Query data
|
|
110
|
+
await createEndpoint.mutateAsync({ data: { name: 'Fluffy' } }) // Mutation execution
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Automatic Cache Management and Refetching
|
|
114
|
+
|
|
115
|
+
By default, mutations automatically:
|
|
116
|
+
|
|
117
|
+
1. Update cache for matching queries with returned data
|
|
118
|
+
2. Invalidate them to trigger a reload
|
|
119
|
+
3. Invalidate matching list endpoints
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Default behavior: automatic cache management
|
|
123
|
+
const createPet = api.useMutation(OperationId.createPet)
|
|
124
|
+
// No additional configuration needed - cache management is automatic
|
|
125
|
+
|
|
126
|
+
// Manual control over cache invalidation
|
|
127
|
+
const updatePet = api.useMutation(OperationId.updatePet, {
|
|
128
|
+
dontInvalidate: true, // Disable automatic invalidation
|
|
129
|
+
dontUpdateCache: true, // Disable automatic cache updates
|
|
130
|
+
invalidateOperations: [OperationId.listPets], // Manually specify operations to invalidate
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
// Refetch specific endpoints after mutation
|
|
134
|
+
const petListQuery = api.useQuery(OperationId.listPets)
|
|
135
|
+
const createPetWithRefetch = api.useMutation(OperationId.createPet, {
|
|
136
|
+
refetchEndpoints: [petListQuery], // Manually refetch these endpoints
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Reactive Enabling/Disabling Based on Path Parameters
|
|
141
|
+
|
|
142
|
+
One powerful feature is chaining queries where one query provides the parameters for another:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { ref, computed } from 'vue'
|
|
146
|
+
|
|
147
|
+
// First query to get user information
|
|
148
|
+
const userQuery = api.useQuery(OperationId.getUser, { userId: 123 })
|
|
149
|
+
|
|
150
|
+
// Second query that depends on the first query's result
|
|
151
|
+
const userPetsQuery = api.useQuery(
|
|
152
|
+
OperationId.listUserPets,
|
|
153
|
+
computed(() => ({
|
|
154
|
+
userId: userQuery.data.value?.id, // Chain: use ID from first query
|
|
155
|
+
})),
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
// Reactive parameter example
|
|
159
|
+
const selectedPetId = ref<string | undefined>(undefined)
|
|
160
|
+
|
|
161
|
+
// Query automatically enables/disables based on parameter availability
|
|
162
|
+
const petQuery = api.useQuery(
|
|
163
|
+
OperationId.getPet,
|
|
164
|
+
computed(() => ({ petId: selectedPetId.value })),
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
// Query is automatically disabled when petId is null/undefined
|
|
168
|
+
console.log(petQuery.isEnabled.value) // false when selectedPetId.value is null
|
|
169
|
+
|
|
170
|
+
// Enable the query by setting the parameter
|
|
171
|
+
selectedPetId.value = '123'
|
|
172
|
+
console.log(petQuery.isEnabled.value) // true when selectedPetId.value is set
|
|
173
|
+
|
|
174
|
+
// Complex conditional enabling
|
|
175
|
+
const userId = ref<string>('user1')
|
|
176
|
+
const shouldFetchPets = ref(true)
|
|
177
|
+
|
|
178
|
+
const userPetsQuery = api.useQuery(
|
|
179
|
+
OperationId.listUserPets,
|
|
180
|
+
computed(() => ({ userId: userId.value })),
|
|
181
|
+
{
|
|
182
|
+
enabled: computed(
|
|
183
|
+
() => shouldFetchPets.value, // Additional business logic
|
|
184
|
+
),
|
|
185
|
+
},
|
|
186
|
+
)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## API Documentation
|
|
190
|
+
|
|
191
|
+
Full API documentation is available at [https://qualisero.github.io/openapi-endpoint/](https://qualisero.github.io/openapi-endpoint/). The documentation includes detailed information about all methods, types, and configuration options.
|
|
192
|
+
|
|
193
|
+
## Contributing
|
|
194
|
+
|
|
195
|
+
Contributions are welcome! Please read our contributing guidelines and ensure all tests pass.
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { QueryClient } from '@tanstack/vue-query';
|
|
|
3
3
|
import { EndpointQueryReturn } from './openapi-query';
|
|
4
4
|
import { EndpointMutationReturn } from './openapi-mutation';
|
|
5
5
|
import { Operations, GetPathParameters, OpenApiConfig, QQueryOptions, QMutationOptions, IsQueryOperation } from './types';
|
|
6
|
-
export type {
|
|
6
|
+
export type { OpenApiConfig, OpenApiInstance } from './types';
|
|
7
7
|
export { type EndpointQueryReturn, useEndpointQuery } from './openapi-query';
|
|
8
8
|
export { type EndpointMutationReturn, useEndpointMutation } from './openapi-mutation';
|
|
9
9
|
/**
|
|
@@ -121,8 +121,8 @@ export declare function useOpenApi<Ops extends Operations<Ops>>(config: OpenApiC
|
|
|
121
121
|
variables: import("vue").Ref<undefined, undefined>;
|
|
122
122
|
isIdle: import("vue").Ref<true, true>;
|
|
123
123
|
submittedAt: import("vue").Ref<number, number>;
|
|
124
|
-
mutate: (variables: import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
125
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
124
|
+
mutate: (variables: import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
125
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
126
126
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
127
127
|
} | {
|
|
128
128
|
data: import("vue").ComputedRef<import("./types").GetResponseData<Ops, Op> | undefined>;
|
|
@@ -137,11 +137,11 @@ export declare function useOpenApi<Ops extends Operations<Ops>>(config: OpenApiC
|
|
|
137
137
|
failureCount: import("vue").Ref<number, number>;
|
|
138
138
|
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
139
139
|
isPaused: import("vue").Ref<boolean, boolean>;
|
|
140
|
-
variables: import("vue").Ref<import("./types").QMutationVars<Ops, Op>, import("./types").QMutationVars<Ops, Op
|
|
140
|
+
variables: import("@vue/shared").IfAny<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("vue").Ref<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>>, [import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>] extends [import("vue").Ref<any, any>] ? import("vue").Ref<any, any> & (import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>) : import("vue").Ref<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>>>;
|
|
141
141
|
isIdle: import("vue").Ref<false, false>;
|
|
142
142
|
submittedAt: import("vue").Ref<number, number>;
|
|
143
|
-
mutate: (variables: import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
144
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
143
|
+
mutate: (variables: import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
144
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
145
145
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
146
146
|
} | {
|
|
147
147
|
data: import("vue").ComputedRef<import("./types").GetResponseData<Ops, Op> | undefined>;
|
|
@@ -156,11 +156,11 @@ export declare function useOpenApi<Ops extends Operations<Ops>>(config: OpenApiC
|
|
|
156
156
|
failureCount: import("vue").Ref<number, number>;
|
|
157
157
|
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
158
158
|
isPaused: import("vue").Ref<boolean, boolean>;
|
|
159
|
-
variables: import("vue").Ref<import("./types").QMutationVars<Ops, Op>, import("./types").QMutationVars<Ops, Op
|
|
159
|
+
variables: import("@vue/shared").IfAny<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("vue").Ref<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>>, [import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>] extends [import("vue").Ref<any, any>] ? import("vue").Ref<any, any> & (import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>) : import("vue").Ref<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>>>;
|
|
160
160
|
isIdle: import("vue").Ref<false, false>;
|
|
161
161
|
submittedAt: import("vue").Ref<number, number>;
|
|
162
|
-
mutate: (variables: import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
163
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
162
|
+
mutate: (variables: import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
163
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
164
164
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
165
165
|
} | {
|
|
166
166
|
data: import("vue").ComputedRef<import("./types").GetResponseData<Ops, Op> | undefined>;
|
|
@@ -175,11 +175,11 @@ export declare function useOpenApi<Ops extends Operations<Ops>>(config: OpenApiC
|
|
|
175
175
|
failureCount: import("vue").Ref<number, number>;
|
|
176
176
|
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
177
177
|
isPaused: import("vue").Ref<boolean, boolean>;
|
|
178
|
-
variables: import("vue").Ref<import("./types").QMutationVars<Ops, Op>, import("./types").QMutationVars<Ops, Op
|
|
178
|
+
variables: import("@vue/shared").IfAny<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("vue").Ref<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>>, [import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>] extends [import("vue").Ref<any, any>] ? import("vue").Ref<any, any> & (import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>) : import("vue").Ref<import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>>>;
|
|
179
179
|
isIdle: import("vue").Ref<false, false>;
|
|
180
180
|
submittedAt: import("vue").Ref<number, number>;
|
|
181
|
-
mutate: (variables: import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
182
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
181
|
+
mutate: (variables: import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
182
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<import("./types").GetResponseData<Ops, Op>, Error, import("./types").GetRequestBody<Ops, Op> extends never ? void | import("./types").QMutationVars<Ops, Op> : import("./types").QMutationVars<Ops, Op>, unknown>;
|
|
183
183
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
184
184
|
};
|
|
185
185
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC1E,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GACpC,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GACtB,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,GAEvB,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC/D,CAAC,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,kBACrF,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,KAC1G,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,mBAAmB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,CAAC;EAM7G"}
|
|
@@ -2,7 +2,7 @@ import { type MaybeRefOrGetter } from 'vue';
|
|
|
2
2
|
import { EndpointQueryReturn } from './openapi-query';
|
|
3
3
|
import { EndpointMutationReturn } from './openapi-mutation';
|
|
4
4
|
import type { GetPathParameters, QQueryOptions, QMutationOptions, Operations, IsQueryOperation } from './types';
|
|
5
|
-
import {
|
|
5
|
+
import { type OpenApiHelpers } from './openapi-helpers';
|
|
6
6
|
/**
|
|
7
7
|
* Composable for performing a strictly typed OpenAPI operation (query or mutation) using Vue Query.
|
|
8
8
|
* Automatically detects whether the operation is a query or mutation and delegates to the appropriate composable.
|
|
@@ -14,5 +14,5 @@ import { getHelpers } from './openapi-helpers';
|
|
|
14
14
|
* @param optionsOrNull Optional query or mutation options, including Vue Query options.
|
|
15
15
|
* @returns Query or mutation object with strict typing and helpers.
|
|
16
16
|
*/
|
|
17
|
-
export declare function useEndpoint<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, helpers:
|
|
17
|
+
export declare function useEndpoint<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, helpers: OpenApiHelpers<Ops, Op>, pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undefined> | (IsQueryOperation<Ops, Op> extends true ? QQueryOptions<Ops, Op> : QMutationOptions<Ops, Op>), optionsOrNull?: IsQueryOperation<Ops, Op> extends true ? QQueryOptions<Ops, Op> : QMutationOptions<Ops, Op>): IsQueryOperation<Ops, Op> extends true ? EndpointQueryReturn<Ops, Op> : EndpointMutationReturn<Ops, Op>;
|
|
18
18
|
//# sourceMappingURL=openapi-endpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-endpoint.d.ts","sourceRoot":"","sources":["../src/openapi-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAuB,MAAM,oBAAoB,CAAA;AAChF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"openapi-endpoint.d.ts","sourceRoot":"","sources":["../src/openapi-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAuB,MAAM,oBAAoB,CAAA;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC/G,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,EAC3E,WAAW,EAAE,EAAE,EACf,OAAO,EAAE,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,EAChC,mBAAmB,CAAC,EAChB,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC/D,CAAC,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EACjG,aAAa,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,GAC1G,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,mBAAmB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,CAAC,CAuBzG"}
|
|
@@ -8,4 +8,5 @@ export declare function getHelpers<Ops extends Operations<Ops>, Op extends keyof
|
|
|
8
8
|
axios: import("axios").AxiosInstance;
|
|
9
9
|
queryClient: import("@tanstack/vue-query").QueryClient;
|
|
10
10
|
};
|
|
11
|
+
export type OpenApiHelpers<Ops extends Operations<Ops>, Op extends keyof Ops> = ReturnType<typeof getHelpers<Ops, Op>>;
|
|
11
12
|
//# 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,EAAc,KAAK,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAkBnF,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;yCAiCjB,EAAE,KAAG,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"openapi-helpers.d.ts","sourceRoot":"","sources":["../src/openapi-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAkBnF,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;yCAiCjB,EAAE,KAAG,MAAM,GAAG,IAAI;oCAevB,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"}
|
package/dist/openapi-helpers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpMethod } from './types';
|
|
2
2
|
import { queryClient as defaultQueryClient } from './index';
|
|
3
|
-
//
|
|
4
|
-
function
|
|
5
|
-
const
|
|
3
|
+
// Helper returning the operationId prefix given an http method
|
|
4
|
+
function getMethodPrefix(method) {
|
|
5
|
+
const METHOD_PREFIXES = {
|
|
6
6
|
[HttpMethod.GET]: 'get', // or 'list' depending on the operationId
|
|
7
7
|
[HttpMethod.POST]: 'create',
|
|
8
8
|
[HttpMethod.PUT]: 'update',
|
|
@@ -12,7 +12,7 @@ function _getMethodPrefix(method) {
|
|
|
12
12
|
[HttpMethod.OPTIONS]: null,
|
|
13
13
|
[HttpMethod.TRACE]: null,
|
|
14
14
|
};
|
|
15
|
-
return
|
|
15
|
+
return METHOD_PREFIXES[method];
|
|
16
16
|
}
|
|
17
17
|
export function getHelpers(config) {
|
|
18
18
|
// Helper function to get operation info by ID
|
|
@@ -24,7 +24,7 @@ export function getHelpers(config) {
|
|
|
24
24
|
function getListOperationPath(operationId) {
|
|
25
25
|
const opInfo = getOperationInfo(operationId);
|
|
26
26
|
const operationIdStr = operationId;
|
|
27
|
-
const operationPrefix = opInfo ?
|
|
27
|
+
const operationPrefix = opInfo ? getMethodPrefix(opInfo.method) : null;
|
|
28
28
|
// Make sure operationId matches `<operationPrefix><upercase resourceName>` pattern
|
|
29
29
|
if (!operationPrefix || !/^[A-Z]/.test(operationIdStr.charAt(operationPrefix.length)))
|
|
30
30
|
// If not, fallback to CRUD heuristic
|
|
@@ -63,21 +63,18 @@ export function getHelpers(config) {
|
|
|
63
63
|
}
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// }
|
|
66
|
+
// Constants for HTTP method categorization
|
|
67
|
+
const QUERY_METHODS = [HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS];
|
|
68
|
+
const MUTATION_METHODS = [HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH, HttpMethod.DELETE];
|
|
70
69
|
// Helper to check if an operation is a query method at runtime
|
|
71
70
|
function isQueryOperation(operationId) {
|
|
72
71
|
const { method } = getOperationInfo(operationId);
|
|
73
|
-
|
|
74
|
-
return queryMethods.includes(method);
|
|
72
|
+
return QUERY_METHODS.includes(method);
|
|
75
73
|
}
|
|
76
74
|
// Helper to check if an operation is a mutation method at runtime
|
|
77
75
|
function isMutationOperation(operationId) {
|
|
78
76
|
const { method } = getOperationInfo(operationId);
|
|
79
|
-
|
|
80
|
-
return mutationMethods.includes(method);
|
|
77
|
+
return MUTATION_METHODS.includes(method);
|
|
81
78
|
}
|
|
82
79
|
return {
|
|
83
80
|
getOperationInfo,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComputedRef, type Ref, type MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import { type GetPathParameters, type QMutationVars, type GetResponseData, type QMutationOptions, Operations } from './types';
|
|
3
|
-
import {
|
|
2
|
+
import { type GetPathParameters, type QMutationVars, type GetResponseData, type QMutationOptions, Operations, GetRequestBody } from './types';
|
|
3
|
+
import { type OpenApiHelpers } from './openapi-helpers';
|
|
4
4
|
export type EndpointMutationReturn<Ops extends Operations<Ops>, Op extends keyof Ops> = ReturnType<typeof useEndpointMutation<Ops, Op>>;
|
|
5
5
|
/**
|
|
6
6
|
* Composable for performing a strictly typed OpenAPI mutation operation using Vue Query.
|
|
@@ -31,7 +31,7 @@ export type EndpointMutationReturn<Ops extends Operations<Ops>, Op extends keyof
|
|
|
31
31
|
* - `dontUpdateCache`, `dontInvalidate`, `invalidateOperations`, `refetchEndpoints`: Same as options, but can be set per-mutation.
|
|
32
32
|
* - All other properties and methods from the underlying Vue Query mutation object.
|
|
33
33
|
*/
|
|
34
|
-
export declare function useEndpointMutation<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, h:
|
|
34
|
+
export declare function useEndpointMutation<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, h: OpenApiHelpers<Ops, Op>, // helpers
|
|
35
35
|
pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undefined> | QMutationOptions<Ops, Op>, optionsOrNull?: QMutationOptions<Ops, Op>): {
|
|
36
36
|
data: ComputedRef<GetResponseData<Ops, Op> | undefined>;
|
|
37
37
|
isEnabled: ComputedRef<boolean>;
|
|
@@ -48,8 +48,8 @@ pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undef
|
|
|
48
48
|
variables: Ref<undefined, undefined>;
|
|
49
49
|
isIdle: Ref<true, true>;
|
|
50
50
|
submittedAt: Ref<number, number>;
|
|
51
|
-
mutate: (variables: QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
52
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown>;
|
|
51
|
+
mutate: (variables: GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
52
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown>;
|
|
53
53
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
54
54
|
} | {
|
|
55
55
|
data: ComputedRef<GetResponseData<Ops, Op> | undefined>;
|
|
@@ -64,11 +64,11 @@ pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undef
|
|
|
64
64
|
failureCount: Ref<number, number>;
|
|
65
65
|
failureReason: Ref<Error | null, Error | null>;
|
|
66
66
|
isPaused: Ref<boolean, boolean>;
|
|
67
|
-
variables: Ref<QMutationVars<Ops, Op>, QMutationVars<Ops, Op
|
|
67
|
+
variables: import("@vue/shared").IfAny<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, Ref<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>>, [GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>] extends [Ref<any, any>] ? Ref<any, any> & (GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>) : Ref<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>>>;
|
|
68
68
|
isIdle: Ref<false, false>;
|
|
69
69
|
submittedAt: Ref<number, number>;
|
|
70
|
-
mutate: (variables: QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
71
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown>;
|
|
70
|
+
mutate: (variables: GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
71
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown>;
|
|
72
72
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
73
73
|
} | {
|
|
74
74
|
data: ComputedRef<GetResponseData<Ops, Op> | undefined>;
|
|
@@ -83,11 +83,11 @@ pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undef
|
|
|
83
83
|
failureCount: Ref<number, number>;
|
|
84
84
|
failureReason: Ref<Error | null, Error | null>;
|
|
85
85
|
isPaused: Ref<boolean, boolean>;
|
|
86
|
-
variables: Ref<QMutationVars<Ops, Op>, QMutationVars<Ops, Op
|
|
86
|
+
variables: import("@vue/shared").IfAny<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, Ref<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>>, [GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>] extends [Ref<any, any>] ? Ref<any, any> & (GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>) : Ref<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>>>;
|
|
87
87
|
isIdle: Ref<false, false>;
|
|
88
88
|
submittedAt: Ref<number, number>;
|
|
89
|
-
mutate: (variables: QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
90
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown>;
|
|
89
|
+
mutate: (variables: GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
90
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown>;
|
|
91
91
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
92
92
|
} | {
|
|
93
93
|
data: ComputedRef<GetResponseData<Ops, Op> | undefined>;
|
|
@@ -102,11 +102,11 @@ pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undef
|
|
|
102
102
|
failureCount: Ref<number, number>;
|
|
103
103
|
failureReason: Ref<Error | null, Error | null>;
|
|
104
104
|
isPaused: Ref<boolean, boolean>;
|
|
105
|
-
variables: Ref<QMutationVars<Ops, Op>, QMutationVars<Ops, Op
|
|
105
|
+
variables: import("@vue/shared").IfAny<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, Ref<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>>, [GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>] extends [Ref<any, any>] ? Ref<any, any> & (GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>) : Ref<GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>>>;
|
|
106
106
|
isIdle: Ref<false, false>;
|
|
107
107
|
submittedAt: Ref<number, number>;
|
|
108
|
-
mutate: (variables: QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
109
|
-
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>, unknown>;
|
|
108
|
+
mutate: (variables: GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, options?: import("@tanstack/query-core").MutateOptions<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown> | undefined) => void;
|
|
109
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? void | QMutationVars<Ops, Op> : QMutationVars<Ops, Op>, unknown>;
|
|
110
110
|
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
111
111
|
};
|
|
112
112
|
//# 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,EAA0B,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAG/F,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,UAAU,
|
|
1
|
+
{"version":3,"file":"openapi-mutation.d.ts","sourceRoot":"","sources":["../src/openapi-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAG/F,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,UAAU,EACV,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGvD,MAAM,MAAM,sBAAsB,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,IAAI,UAAU,CAChG,OAAO,mBAAmB,CAAC,GAAG,EAAE,EAAE,CAAC,CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,EACnF,WAAW,EAAE,EAAE,EACf,CAAC,EAAE,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,UAAU;AACtC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,EACjH,aAAa,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC;UAyJhB,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;UAAjD,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;UAAjD,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;UAAjD,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;EAI3E"}
|
package/dist/openapi-mutation.js
CHANGED
|
@@ -63,8 +63,8 @@ pathParamsOrOptions, optionsOrNull) {
|
|
|
63
63
|
const response = await h.axios({
|
|
64
64
|
method: method.toLowerCase(),
|
|
65
65
|
url: resolvedPath.value,
|
|
66
|
-
data
|
|
67
|
-
...
|
|
66
|
+
...(data !== undefined && { data }),
|
|
67
|
+
...axiosOptions,
|
|
68
68
|
});
|
|
69
69
|
return response.data;
|
|
70
70
|
}
|
|
@@ -85,17 +85,17 @@ pathParamsOrOptions, optionsOrNull) {
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
onSuccess: async (data, vars, _context) => {
|
|
88
|
-
const { dontInvalidate: dontInvalidateMutate, dontUpdateCache: dontUpdateCacheMutate, invalidateOperations: invalidateOperationsMutate, refetchEndpoints: refetchEndpointsMutate, } = vars;
|
|
89
|
-
//
|
|
88
|
+
const { dontInvalidate: dontInvalidateMutate, dontUpdateCache: dontUpdateCacheMutate, invalidateOperations: invalidateOperationsMutate, refetchEndpoints: refetchEndpointsMutate, } = vars || {};
|
|
89
|
+
// update cache with returned data for PUT/PATCH requests
|
|
90
90
|
if (
|
|
91
91
|
// dontUpdateCacheMutate supersedes dontUpdateCache from options
|
|
92
|
-
(
|
|
92
|
+
(dontUpdateCacheMutate !== undefined ? !dontUpdateCacheMutate : !dontUpdateCache) &&
|
|
93
93
|
data &&
|
|
94
94
|
[HttpMethod.PUT, HttpMethod.PATCH].includes(method)) {
|
|
95
95
|
await h.queryClient.setQueryData(queryKey.value, data);
|
|
96
96
|
}
|
|
97
97
|
// Invalidate queries for this path, and any additional specified operations
|
|
98
|
-
if (
|
|
98
|
+
if (dontInvalidateMutate !== undefined ? !dontInvalidateMutate : !dontInvalidate) {
|
|
99
99
|
// Invalidate all queries for this path (exact for POST, prefix for others):
|
|
100
100
|
await h.queryClient.invalidateQueries({ queryKey: queryKey.value, exact: method !== HttpMethod.POST });
|
|
101
101
|
const listPath = h.getListOperationPath(operationId);
|
package/dist/openapi-query.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import { Operations, type GetPathParameters, type GetResponseData, type QQueryOptions } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { type OpenApiHelpers } from './openapi-helpers';
|
|
4
4
|
export type EndpointQueryReturn<Ops extends Operations<Ops>, Op extends keyof Ops> = ReturnType<typeof useEndpointQuery<Ops, Op>> & {
|
|
5
5
|
onLoad: (callback: (data: GetResponseData<Ops, Op>) => void) => void;
|
|
6
6
|
};
|
|
@@ -24,7 +24,7 @@ export type EndpointQueryReturn<Ops extends Operations<Ops>, Op extends keyof Op
|
|
|
24
24
|
* - `queryKey`: ComputedRef of the query key.
|
|
25
25
|
* - `onLoad`: Method to register a callback for when data is loaded.
|
|
26
26
|
*/
|
|
27
|
-
export declare function useEndpointQuery<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, h:
|
|
27
|
+
export declare function useEndpointQuery<Ops extends Operations<Ops>, Op extends keyof Ops>(operationId: Op, h: OpenApiHelpers<Ops, Op>, pathParamsOrOptions?: MaybeRefOrGetter<GetPathParameters<Ops, Op> | null | undefined> | QQueryOptions<Ops, Op>, optionsOrNull?: QQueryOptions<Ops, Op>): {
|
|
28
28
|
data: ComputedRef<GetResponseData<Ops, Op> | undefined>;
|
|
29
29
|
isEnabled: ComputedRef<boolean>;
|
|
30
30
|
queryKey: ComputedRef<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-query.d.ts","sourceRoot":"","sources":["../src/openapi-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAEvF,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAGtG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"openapi-query.d.ts","sourceRoot":"","sources":["../src/openapi-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAEvF,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAGtG,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,MAAM,mBAAmB,CAAC,GAAG,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,E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,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;uBAN7C,CAAC,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;UAM5C,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;uBAN7C,CAAC,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;UAM5C,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;;;uBAN7C,CAAC,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnE"}
|
package/dist/openapi-query.js
CHANGED
|
@@ -34,18 +34,17 @@ export function useEndpointQuery(operationId, h, pathParamsOrOptions, optionsOrN
|
|
|
34
34
|
const queryKey = computed(() => generateQueryKey(resolvedPath.value));
|
|
35
35
|
// Check if path is fully resolved for enabling the query
|
|
36
36
|
const isEnabled = computed(() => {
|
|
37
|
-
// can be explicitly disabled via options
|
|
38
37
|
const baseEnabled = enabledInit !== undefined ? toValue(enabledInit) : true;
|
|
39
38
|
return baseEnabled && isPathResolved(resolvedPath.value);
|
|
40
39
|
});
|
|
41
40
|
const query = useQuery({
|
|
42
|
-
queryKey
|
|
41
|
+
queryKey,
|
|
43
42
|
queryFn: async () => {
|
|
44
43
|
try {
|
|
45
44
|
const response = await h.axios({
|
|
46
45
|
method: method.toLowerCase(),
|
|
47
46
|
url: resolvedPath.value,
|
|
48
|
-
...
|
|
47
|
+
...axiosOptions,
|
|
49
48
|
});
|
|
50
49
|
return response.data;
|
|
51
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-utils.d.ts","sourceRoot":"","sources":["../src/openapi-utils.ts"],"names":[],"mappings":"AAAA,O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EAAE,OAAO,CAAA;CACjB,CA+BA"}
|
package/dist/openapi-utils.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import { toValue } from 'vue';
|
|
2
|
+
// Known option-like properties to distinguish from path parameters
|
|
3
|
+
const OPTION_PROPERTIES = [
|
|
4
|
+
'enabled',
|
|
5
|
+
'onSuccess',
|
|
6
|
+
'onError',
|
|
7
|
+
'onSettled',
|
|
8
|
+
'select',
|
|
9
|
+
'retry',
|
|
10
|
+
'staleTime',
|
|
11
|
+
'cacheTime',
|
|
12
|
+
'refetchOnWindowFocus',
|
|
13
|
+
'refetchOnReconnect',
|
|
14
|
+
'refetchOnMount',
|
|
15
|
+
'suspense',
|
|
16
|
+
'useErrorBoundary',
|
|
17
|
+
'meta',
|
|
18
|
+
'mutationKey',
|
|
19
|
+
'mutationFn',
|
|
20
|
+
'queryKey',
|
|
21
|
+
'queryFn',
|
|
22
|
+
'initialData',
|
|
23
|
+
'context',
|
|
24
|
+
];
|
|
2
25
|
// Helper to resolve path parameters in a URL path
|
|
3
26
|
export function resolvePath(path, pathParams) {
|
|
4
27
|
if (pathParams === null || pathParams === undefined)
|
|
@@ -18,32 +41,8 @@ function isPathParams(path, pathParams) {
|
|
|
18
41
|
if (!pathParams)
|
|
19
42
|
return false;
|
|
20
43
|
const paramNames = Object.keys(pathParams);
|
|
21
|
-
// List of known option-like properties to exclude
|
|
22
|
-
const optionProps = [
|
|
23
|
-
'enabled',
|
|
24
|
-
'onSuccess',
|
|
25
|
-
'onError',
|
|
26
|
-
'onSettled',
|
|
27
|
-
'select',
|
|
28
|
-
'retry',
|
|
29
|
-
'staleTime',
|
|
30
|
-
'cacheTime',
|
|
31
|
-
'refetchOnWindowFocus',
|
|
32
|
-
'refetchOnReconnect',
|
|
33
|
-
'refetchOnMount',
|
|
34
|
-
'suspense',
|
|
35
|
-
'useErrorBoundary',
|
|
36
|
-
'meta',
|
|
37
|
-
'mutationKey',
|
|
38
|
-
'mutationFn',
|
|
39
|
-
'queryKey',
|
|
40
|
-
'queryFn',
|
|
41
|
-
'initialData',
|
|
42
|
-
'context',
|
|
43
|
-
// Add more as needed
|
|
44
|
-
];
|
|
45
44
|
// If any option-like property is present, it's not path params
|
|
46
|
-
if (paramNames.some((name) =>
|
|
45
|
+
if (paramNames.some((name) => OPTION_PROPERTIES.includes(name))) {
|
|
47
46
|
return false;
|
|
48
47
|
}
|
|
49
48
|
return paramNames.every((paramName) => path.includes(`{${paramName}}`));
|
|
@@ -57,8 +56,6 @@ export function generateQueryKey(resolvedPath) {
|
|
|
57
56
|
return resolvedPath.split('/').filter((segment) => segment.length > 0);
|
|
58
57
|
}
|
|
59
58
|
export function getParamsOptionsFrom(path, pathParamsOrOptions, optionsOrNull) {
|
|
60
|
-
// Check if pathParamsOrOptions is MutationOptions or QueryOptions by checking if options is undefined
|
|
61
|
-
// and pathParamsOrOptions has MutationOptions properties
|
|
62
59
|
let pathParams = undefined;
|
|
63
60
|
let options = undefined;
|
|
64
61
|
if (optionsOrNull === undefined) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { type AxiosInstance, type AxiosError } from 'axios';
|
|
1
|
+
import { type AxiosInstance, type AxiosError, type AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { UseMutationOptions, type UseQueryOptions, QueryClient } from '@tanstack/vue-query';
|
|
3
3
|
import type { MaybeRef, MaybeRefOrGetter } from 'vue';
|
|
4
|
-
import { type AxiosRequestConfig } from 'axios';
|
|
5
4
|
import type { EndpointQueryReturn } from './openapi-query';
|
|
6
5
|
import type { EndpointMutationReturn } from './openapi-mutation';
|
|
7
|
-
export type { EndpointQueryReturn }
|
|
8
|
-
export type { EndpointMutationReturn } from './openapi-mutation';
|
|
6
|
+
export type { EndpointQueryReturn, EndpointMutationReturn };
|
|
9
7
|
export type OperationId = string;
|
|
10
8
|
export type Operations<Ops> = object & {
|
|
11
9
|
[K in keyof Ops]: {
|
|
@@ -57,10 +55,10 @@ type MutationOnSuccessOptions<Ops extends Operations<Ops>> = {
|
|
|
57
55
|
refetchEndpoints?: EndpointQueryReturn<Ops, keyof Ops>[];
|
|
58
56
|
};
|
|
59
57
|
export type QMutationVars<Ops extends Operations<Ops>, Op extends keyof Ops> = MutationOnSuccessOptions<Ops> & {
|
|
60
|
-
data
|
|
58
|
+
data?: GetRequestBody<Ops, Op>;
|
|
61
59
|
pathParams?: GetPathParameters<Ops, Op>;
|
|
62
60
|
};
|
|
63
|
-
export type QMutationOptions<Ops extends Operations<Ops>, Op extends keyof Ops> = OmitMaybeRef<UseMutationOptions<GetResponseData<Ops, Op>, Error, QMutationVars<Ops, Op>>, 'mutationFn' | 'mutationKey'> & MutationOnSuccessOptions<Ops> & {
|
|
61
|
+
export type QMutationOptions<Ops extends Operations<Ops>, Op extends keyof Ops> = OmitMaybeRef<UseMutationOptions<GetResponseData<Ops, Op>, Error, GetRequestBody<Ops, Op> extends never ? QMutationVars<Ops, Op> | void : QMutationVars<Ops, Op>>, 'mutationFn' | 'mutationKey'> & MutationOnSuccessOptions<Ops> & {
|
|
64
62
|
axiosOptions?: AxiosRequestConfig;
|
|
65
63
|
errorHandler?: (error: AxiosError) => GetResponseData<Ops, Op> | void | Promise<GetResponseData<Ops, Op> | void>;
|
|
66
64
|
};
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,OAAO,CAAA;AACpF,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,C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SAAS,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EACrG,aAAa,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,KACxG,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,IAAI,GAAG,mBAAmB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;CAC7G,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qualisero/openapi-endpoint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/qualisero/openapi-endpoint.git"
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"lint:fix": "eslint . --fix",
|
|
38
38
|
"format": "prettier --write .",
|
|
39
39
|
"format:check": "prettier --check .",
|
|
40
|
+
"docs": "typedoc",
|
|
41
|
+
"docs:publish": "npm run docs && gh-pages -d docs",
|
|
40
42
|
"prepublishOnly": "npm run build && npm run check"
|
|
41
43
|
},
|
|
42
44
|
"keywords": [
|
|
@@ -67,10 +69,12 @@
|
|
|
67
69
|
"@vue/test-utils": "^2.4.6",
|
|
68
70
|
"eslint": "^9.37.0",
|
|
69
71
|
"eslint-plugin-prettier": "^5.5.4",
|
|
72
|
+
"gh-pages": "^6.3.0",
|
|
70
73
|
"globals": "^16.4.0",
|
|
71
74
|
"jsdom": "^27.0.0",
|
|
72
75
|
"openapi-typescript": "^7.9.1",
|
|
73
76
|
"prettier": "^3.6.2",
|
|
77
|
+
"typedoc": "^0.28.14",
|
|
74
78
|
"typescript": "^5.9.2",
|
|
75
79
|
"vitest": "^3.2.4"
|
|
76
80
|
},
|