@qualisero/openapi-endpoint 0.12.3 → 0.14.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 -252
- package/dist/cli.js +1318 -58
- package/dist/index.d.ts +9 -213
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -143
- package/dist/openapi-helpers.d.ts +4 -17
- package/dist/openapi-helpers.d.ts.map +1 -1
- package/dist/openapi-helpers.js +3 -93
- package/dist/openapi-mutation.d.ts +48 -111
- package/dist/openapi-mutation.d.ts.map +1 -1
- package/dist/openapi-mutation.js +75 -104
- package/dist/openapi-query.d.ts +46 -209
- package/dist/openapi-query.d.ts.map +1 -1
- package/dist/openapi-query.js +50 -88
- package/dist/openapi-utils.d.ts +31 -4
- package/dist/openapi-utils.d.ts.map +1 -1
- package/dist/openapi-utils.js +45 -56
- package/dist/types.d.ts +250 -280
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -0
- package/package.json +3 -2
- package/dist/openapi-endpoint.d.ts +0 -18
- package/dist/openapi-endpoint.d.ts.map +0 -1
- package/dist/openapi-endpoint.js +0 -24
- package/dist/types-documentation.d.ts +0 -158
- package/dist/types-documentation.d.ts.map +0 -1
- package/dist/types-documentation.js +0 -9
package/dist/openapi-utils.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
];
|
|
1
|
+
import { computed, toValue } from 'vue';
|
|
25
2
|
// Helper to resolve path parameters in a URL path
|
|
26
3
|
export function resolvePath(path, pathParams) {
|
|
27
4
|
if (pathParams === null || pathParams === undefined)
|
|
@@ -31,22 +8,12 @@ export function resolvePath(path, pathParams) {
|
|
|
31
8
|
return path;
|
|
32
9
|
let resolvedPath = path;
|
|
33
10
|
Object.entries(pathParamsValue).forEach(([key, value]) => {
|
|
34
|
-
if (value !==
|
|
11
|
+
if (value !== null && value !== undefined) {
|
|
35
12
|
resolvedPath = resolvedPath.replace(`{${key}}`, String(value));
|
|
36
13
|
}
|
|
37
14
|
});
|
|
38
15
|
return resolvedPath;
|
|
39
16
|
}
|
|
40
|
-
function isPathParams(path, pathParams) {
|
|
41
|
-
if (!pathParams)
|
|
42
|
-
return false;
|
|
43
|
-
const paramNames = Object.keys(pathParams);
|
|
44
|
-
// If any option-like property is present, it's not path params
|
|
45
|
-
if (paramNames.some((name) => OPTION_PROPERTIES.includes(name))) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return paramNames.every((paramName) => path.includes(`{${paramName}}`));
|
|
49
|
-
}
|
|
50
17
|
// Helper to check if all required path parameters are provided
|
|
51
18
|
export function isPathResolved(path) {
|
|
52
19
|
return !/{[^}]+}/.test(path);
|
|
@@ -55,29 +22,51 @@ export function isPathResolved(path) {
|
|
|
55
22
|
export function generateQueryKey(resolvedPath) {
|
|
56
23
|
return resolvedPath.split('/').filter((segment) => segment.length > 0);
|
|
57
24
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Composable for resolving operation paths and parameters.
|
|
27
|
+
* Consolidates the common pattern of computing resolved paths, query keys, and parameters.
|
|
28
|
+
*
|
|
29
|
+
* @param path - The OpenAPI path template (e.g., '/pets/{petId}')
|
|
30
|
+
* @param pathParams - Reactive path parameters
|
|
31
|
+
* @param queryParams - Optional reactive query parameters
|
|
32
|
+
* @param extraPathParams - Optional ref for additional path params (used by mutations)
|
|
33
|
+
*/
|
|
34
|
+
export function useResolvedOperation(path, pathParams, queryParams, extraPathParams) {
|
|
35
|
+
// Compute all path params (base + extra for mutations)
|
|
36
|
+
const allPathParams = computed(() => {
|
|
37
|
+
const base = toValue(pathParams) || {};
|
|
38
|
+
if (extraPathParams?.value) {
|
|
39
|
+
return { ...base, ...extraPathParams.value };
|
|
70
40
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
return base;
|
|
42
|
+
});
|
|
43
|
+
// Compute resolved path
|
|
44
|
+
const resolvedPath = computed(() => resolvePath(path, allPathParams.value));
|
|
45
|
+
// Compute query params
|
|
46
|
+
const allQueryParams = computed(() => {
|
|
47
|
+
const result = toValue(queryParams);
|
|
48
|
+
return (result || {});
|
|
49
|
+
});
|
|
50
|
+
// Generate query key including query params if present
|
|
51
|
+
const queryKey = computed(() => {
|
|
52
|
+
const baseKey = generateQueryKey(resolvedPath.value);
|
|
53
|
+
const qParams = allQueryParams.value;
|
|
54
|
+
if (qParams && Object.keys(qParams).length > 0) {
|
|
55
|
+
return [...baseKey, qParams];
|
|
74
56
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
return baseKey;
|
|
58
|
+
});
|
|
59
|
+
// Check if path is resolved
|
|
60
|
+
const isResolved = computed(() => isPathResolved(resolvedPath.value));
|
|
61
|
+
return {
|
|
62
|
+
pathParams: allPathParams,
|
|
63
|
+
resolvedPath,
|
|
64
|
+
queryParams: allQueryParams,
|
|
65
|
+
queryKey: queryKey,
|
|
66
|
+
isResolved,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function normalizeParamsOptions(pathParams, options) {
|
|
81
70
|
return {
|
|
82
71
|
pathParams: pathParams ?? {},
|
|
83
72
|
options: options ?? {},
|