@signal24/vue-foundation 4.7.3 → 4.7.4
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/src/helpers/openapi.d.ts +2 -52
- package/dist/src/vite-plugins/vite-openapi-plugin.d.ts +0 -3
- package/dist/src/vite-plugins/vite-openapi-plugin.js +2 -99
- package/dist/vue-foundation.es.js +255 -253
- package/package.json +3 -6
- package/src/helpers/openapi.ts +10 -124
- package/src/vite-plugins/vite-openapi-plugin.ts +3 -118
- package/dist/src/vite-plugins/vite-openapi-plugin.cli.d.ts +0 -2
- package/dist/src/vite-plugins/vite-openapi-plugin.cli.js +0 -15
- package/src/vite-plugins/vite-openapi-plugin.cli.ts +0 -19
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly url: string;
|
|
4
|
-
readonly path?: Record<string, any>;
|
|
5
|
-
readonly cookies?: Record<string, any>;
|
|
6
|
-
readonly headers?: Record<string, any>;
|
|
7
|
-
readonly query?: Record<string, any>;
|
|
8
|
-
readonly formData?: Record<string, any>;
|
|
9
|
-
readonly body?: any;
|
|
10
|
-
readonly mediaType?: string;
|
|
11
|
-
readonly responseHeader?: string;
|
|
12
|
-
readonly errors?: Record<number, string>;
|
|
13
|
-
}
|
|
14
|
-
interface IBaseHttpRequest {
|
|
15
|
-
request<T>(options: IRequestOptions): ICancelablePromise<T>;
|
|
16
|
-
}
|
|
17
|
-
export interface IApiClient {
|
|
18
|
-
request: IBaseHttpRequest;
|
|
19
|
-
}
|
|
20
|
-
export interface IApiError extends Error {
|
|
21
|
-
status: number;
|
|
22
|
-
statusText: string;
|
|
23
|
-
body: any;
|
|
24
|
-
}
|
|
25
|
-
export declare class ICancelablePromise<T = any> {
|
|
26
|
-
constructor(executor: (resolve: (value: any) => void, reject: (reason: any) => void, onCancel: (cancel: () => void) => void) => void);
|
|
27
|
-
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
28
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
|
|
29
|
-
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
30
|
-
cancel(): void;
|
|
31
|
-
}
|
|
32
|
-
interface IWrappedApiClientOptions<P extends ICancelablePromise = ICancelablePromise, Arguments extends unknown[] = any[]> {
|
|
33
|
-
apiClient: IApiClient;
|
|
34
|
-
wrapper?: (options: IRequestOptions, fn: (options: IRequestOptions) => P) => P;
|
|
35
|
-
onRequest?: (options: IRequestOptions) => IRequestOptions;
|
|
36
|
-
onError?: (err: Error, options: IRequestOptions) => Error | null | void;
|
|
37
|
-
afterRequest?: (options: IRequestOptions) => void;
|
|
38
|
-
CancelablePromise: new (...arguments_: Arguments) => P;
|
|
39
|
-
}
|
|
40
|
-
export declare function isApiError(err: any): err is IApiError;
|
|
41
|
-
export declare function installApiClientInterceptors({ apiClient, wrapper, onRequest, onError, afterRequest, CancelablePromise }: IWrappedApiClientOptions): void;
|
|
42
|
-
export declare class FileUploadRequest {
|
|
43
|
-
constructor(blob: Blob);
|
|
44
|
-
validator: null;
|
|
45
|
-
lastModifiedDate: null;
|
|
46
|
-
size: number;
|
|
47
|
-
path: string;
|
|
48
|
-
name: string;
|
|
49
|
-
type: string;
|
|
50
|
-
blob: Blob;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
1
|
+
import { installOpenApiClientInterceptors } from '@signal24/openapi-client-codegen/helpers';
|
|
2
|
+
export declare function installApiClientInterceptors(clientOptions: Parameters<typeof installOpenApiClientInterceptors>[0]): void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
export declare function loadOpenapiConfig(): void;
|
|
2
1
|
export declare function openapiClientGeneratorPlugin(): {
|
|
3
2
|
name: string;
|
|
4
3
|
apply: 'serve';
|
|
5
4
|
buildStart(): void;
|
|
6
5
|
closeBundle(): void;
|
|
7
6
|
};
|
|
8
|
-
export declare function generateConfiguredOpenapiClients(): Promise<void>;
|
|
9
|
-
export declare function generateOpenapiClient(openapiYamlPath: string, outPath?: string): Promise<void>;
|
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { copyFileSync, existsSync, readFileSync, watch } from 'node:fs';
|
|
3
|
-
import { rm } from 'node:fs/promises';
|
|
4
|
-
import * as OpenAPI from 'openapi-typescript-codegen';
|
|
5
|
-
const DEFAULT_OUT_PATH = './src/openapi-client-generated';
|
|
6
|
-
let generatedHash = null;
|
|
7
|
-
let generatorMap = {};
|
|
8
|
-
let overridesMap = null;
|
|
9
|
-
let overridesInverseMap = null;
|
|
10
|
-
export function loadOpenapiConfig() {
|
|
11
|
-
loadGeneratorMap();
|
|
12
|
-
loadOverridesMap();
|
|
13
|
-
}
|
|
14
|
-
function loadGeneratorMap() {
|
|
15
|
-
if (!existsSync('./openapi-specs.json')) {
|
|
16
|
-
console.error('openapi-specs.json not found. Cannot generate OpenAPI client.');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const specsContent = readFileSync('./openapi-specs.json', 'utf8');
|
|
21
|
-
generatorMap = JSON.parse(specsContent);
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
console.error('Failed to load openapi-specs.json:', e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function loadOverridesMap() {
|
|
28
|
-
if (!existsSync('./openapi-specs.dev.json')) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const overridesContent = readFileSync('./openapi-specs.dev.json', 'utf8');
|
|
33
|
-
overridesMap = JSON.parse(overridesContent);
|
|
34
|
-
overridesInverseMap = Object.fromEntries(Object.entries(overridesMap).map(([k, v]) => [v, k]));
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
console.error('Failed to load openapi-specs.dev.json:', e);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
import { createWatchfulOpenapiClientGenerators } from '@signal24/openapi-client-codegen/generator';
|
|
40
2
|
export function openapiClientGeneratorPlugin() {
|
|
41
3
|
let generators = null;
|
|
42
4
|
return {
|
|
@@ -45,7 +7,7 @@ export function openapiClientGeneratorPlugin() {
|
|
|
45
7
|
buildStart() {
|
|
46
8
|
// apply a slight delay so any output doesn't get pushed off screen
|
|
47
9
|
setTimeout(() => {
|
|
48
|
-
generators =
|
|
10
|
+
generators = createWatchfulOpenapiClientGenerators();
|
|
49
11
|
}, 250);
|
|
50
12
|
},
|
|
51
13
|
closeBundle() {
|
|
@@ -57,62 +19,3 @@ export function openapiClientGeneratorPlugin() {
|
|
|
57
19
|
}
|
|
58
20
|
};
|
|
59
21
|
}
|
|
60
|
-
function createWatchfulGenerators() {
|
|
61
|
-
loadOpenapiConfig();
|
|
62
|
-
return Object.entries(generatorMap).map(([openapiYamlPath, outPath]) => createWatchfulGenerator(openapiYamlPath, outPath));
|
|
63
|
-
}
|
|
64
|
-
function createWatchfulGenerator(openapiYamlPath, outPath) {
|
|
65
|
-
const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
|
|
66
|
-
if (!existsSync(resolvedPath)) {
|
|
67
|
-
console.log(`OpenAPI YAML file not found: ${resolvedPath}`);
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
const watcher = watch(resolvedPath);
|
|
71
|
-
watcher.on('change', () => {
|
|
72
|
-
// give the writes a moment to settle
|
|
73
|
-
setTimeout(() => generateOpenapiClient(resolvedPath, outPath), 100);
|
|
74
|
-
});
|
|
75
|
-
generateOpenapiClient(resolvedPath, outPath);
|
|
76
|
-
return {
|
|
77
|
-
close() {
|
|
78
|
-
watcher.close();
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export async function generateConfiguredOpenapiClients() {
|
|
83
|
-
loadOpenapiConfig();
|
|
84
|
-
for (const [openapiYamlPath, outPath] of Object.entries(generatorMap)) {
|
|
85
|
-
const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
|
|
86
|
-
await generateOpenapiClient(resolvedPath, outPath);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export async function generateOpenapiClient(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
|
|
90
|
-
const yaml = readFileSync(openapiYamlPath, 'utf8');
|
|
91
|
-
const hash = createHash('sha256').update(yaml).digest('hex');
|
|
92
|
-
if (hash === generatedHash) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
generatedHash = hash;
|
|
96
|
-
try {
|
|
97
|
-
try {
|
|
98
|
-
await rm(outPath, { recursive: true });
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
// ignore
|
|
102
|
-
}
|
|
103
|
-
await OpenAPI.generate({
|
|
104
|
-
input: openapiYamlPath,
|
|
105
|
-
output: outPath,
|
|
106
|
-
clientName: 'ApiClient',
|
|
107
|
-
useOptions: true,
|
|
108
|
-
useUnionTypes: true
|
|
109
|
-
});
|
|
110
|
-
if (overridesInverseMap?.[openapiYamlPath]) {
|
|
111
|
-
copyFileSync(openapiYamlPath, overridesInverseMap[openapiYamlPath]);
|
|
112
|
-
}
|
|
113
|
-
console.log(`[${new Date().toISOString()}] Generated client from ${openapiYamlPath} to ${outPath}/`);
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
console.error(`[${new Date().toISOString()}] Error generating client from ${openapiYamlPath}:`, err);
|
|
117
|
-
}
|
|
118
|
-
}
|