@signal24/vue-foundation 4.2.2 → 4.3.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/src/directives/infinite-scroll.d.ts +3 -2
- package/dist/src/vite-plugins/vite-openapi-plugin.cli.js +11 -7
- package/dist/src/vite-plugins/vite-openapi-plugin.d.ts +3 -2
- package/dist/src/vite-plugins/vite-openapi-plugin.js +49 -16
- package/dist/vue-foundation.es.js +301 -293
- package/package.json +1 -1
- package/src/components/alert-modal.vue +1 -1
- package/src/directives/infinite-scroll.ts +18 -4
- package/src/hooks/infinite-scroll.ts +4 -5
- package/src/vite-plugins/vite-openapi-plugin.cli.ts +12 -9
- package/src/vite-plugins/vite-openapi-plugin.ts +54 -20
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ObjectDirective } from 'vue';
|
|
2
|
-
|
|
3
|
-
export declare const vInfiniteScroll: ObjectDirective<Element,
|
|
2
|
+
type InfiniteScrollBindingValue = () => void;
|
|
3
|
+
export declare const vInfiniteScroll: ObjectDirective<Element, InfiniteScrollBindingValue>;
|
|
4
|
+
export {};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import {
|
|
4
|
-
if (
|
|
5
|
-
|
|
3
|
+
import { generateConfiguredOpenapiClients, generateOpenapiClient } from './vite-openapi-plugin.js';
|
|
4
|
+
if (process.argv[2]) {
|
|
5
|
+
if (process.argv[2] === '--help') {
|
|
6
|
+
throw new Error('Usage: vf-generate-openapi-client [<openapi-yaml-path> [<openapi-output-path>]]');
|
|
7
|
+
}
|
|
8
|
+
if (!existsSync(process.argv[2])) {
|
|
9
|
+
throw new Error(`OpenAPI YAML file not found: ${process.argv[2]}`);
|
|
10
|
+
}
|
|
11
|
+
await generateOpenapiClient(process.argv[2], process.argv[3]);
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
else {
|
|
14
|
+
generateConfiguredOpenapiClients();
|
|
9
15
|
}
|
|
10
|
-
loadOpenapiOverrides();
|
|
11
|
-
await generateOpenapiClient(process.argv[2], process.argv[3]);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
export declare function openapiClientGeneratorPlugin(
|
|
1
|
+
export declare function loadOpenapiConfig(): void;
|
|
2
|
+
export declare function openapiClientGeneratorPlugin(): {
|
|
3
3
|
name: string;
|
|
4
4
|
apply: 'serve';
|
|
5
5
|
buildStart(): void;
|
|
6
6
|
closeBundle(): void;
|
|
7
7
|
};
|
|
8
|
+
export declare function generateConfiguredOpenapiClients(): Promise<void>;
|
|
8
9
|
export declare function generateOpenapiClient(openapiYamlPath: string, outPath?: string): Promise<void>;
|
|
@@ -1,40 +1,67 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { existsSync, readFileSync, watch } from 'node:fs';
|
|
2
|
+
import { copyFileSync, existsSync, readFileSync, watch } from 'node:fs';
|
|
3
3
|
import { rm } from 'node:fs/promises';
|
|
4
4
|
import * as OpenAPI from 'openapi-typescript-codegen';
|
|
5
5
|
const DEFAULT_OUT_PATH = './src/openapi-client-generated';
|
|
6
6
|
let generatedHash = null;
|
|
7
|
+
let generatorMap = {};
|
|
7
8
|
let overridesMap = null;
|
|
8
|
-
|
|
9
|
-
|
|
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')) {
|
|
10
29
|
return;
|
|
11
30
|
}
|
|
12
31
|
try {
|
|
13
|
-
const overridesContent = readFileSync('./openapi-specs.
|
|
32
|
+
const overridesContent = readFileSync('./openapi-specs.dev.json', 'utf8');
|
|
14
33
|
overridesMap = JSON.parse(overridesContent);
|
|
34
|
+
overridesInverseMap = Object.fromEntries(Object.entries(overridesMap).map(([k, v]) => [v, k]));
|
|
15
35
|
}
|
|
16
36
|
catch (e) {
|
|
17
|
-
console.error('Failed to load openapi-specs.
|
|
37
|
+
console.error('Failed to load openapi-specs.dev.json:', e);
|
|
18
38
|
}
|
|
19
39
|
}
|
|
20
|
-
export function openapiClientGeneratorPlugin(
|
|
21
|
-
let
|
|
40
|
+
export function openapiClientGeneratorPlugin() {
|
|
41
|
+
let generators = null;
|
|
22
42
|
return {
|
|
23
43
|
name: 'openapi-types-generator',
|
|
24
44
|
apply: 'serve',
|
|
25
45
|
buildStart() {
|
|
26
46
|
// apply a slight delay so any output doesn't get pushed off screen
|
|
27
47
|
setTimeout(() => {
|
|
28
|
-
|
|
29
|
-
generator = getGenerator(openapiYamlPath, outPath);
|
|
48
|
+
generators = createWatchfulGenerators();
|
|
30
49
|
}, 250);
|
|
31
50
|
},
|
|
32
51
|
closeBundle() {
|
|
33
|
-
|
|
52
|
+
if (generators) {
|
|
53
|
+
for (const generator of generators) {
|
|
54
|
+
generator?.close();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
34
57
|
}
|
|
35
58
|
};
|
|
36
59
|
}
|
|
37
|
-
function
|
|
60
|
+
function createWatchfulGenerators() {
|
|
61
|
+
loadOpenapiConfig();
|
|
62
|
+
return Object.entries(generatorMap).map(([openapiYamlPath, outPath]) => createWatchfulGenerator(openapiYamlPath, outPath));
|
|
63
|
+
}
|
|
64
|
+
function createWatchfulGenerator(openapiYamlPath, outPath) {
|
|
38
65
|
const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
|
|
39
66
|
if (!existsSync(resolvedPath)) {
|
|
40
67
|
console.log(`OpenAPI YAML file not found: ${resolvedPath}`);
|
|
@@ -52,7 +79,14 @@ function getGenerator(openapiYamlPath, outPath) {
|
|
|
52
79
|
}
|
|
53
80
|
};
|
|
54
81
|
}
|
|
55
|
-
async function
|
|
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) {
|
|
56
90
|
const yaml = readFileSync(openapiYamlPath, 'utf8');
|
|
57
91
|
const hash = createHash('sha256').update(yaml).digest('hex');
|
|
58
92
|
if (hash === generatedHash) {
|
|
@@ -73,13 +107,12 @@ async function generateOpenapiClientInternal(openapiYamlPath, outPath = DEFAULT_
|
|
|
73
107
|
useOptions: true,
|
|
74
108
|
useUnionTypes: true
|
|
75
109
|
});
|
|
110
|
+
if (overridesInverseMap?.[openapiYamlPath]) {
|
|
111
|
+
copyFileSync(openapiYamlPath, overridesInverseMap[openapiYamlPath]);
|
|
112
|
+
}
|
|
76
113
|
console.log(`[${new Date().toISOString()}] Generated client from ${openapiYamlPath} to ${outPath}/`);
|
|
77
114
|
}
|
|
78
115
|
catch (err) {
|
|
79
116
|
console.error(`[${new Date().toISOString()}] Error generating client from ${openapiYamlPath}:`, err);
|
|
80
117
|
}
|
|
81
118
|
}
|
|
82
|
-
export async function generateOpenapiClient(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
|
|
83
|
-
const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
|
|
84
|
-
return generateOpenapiClientInternal(resolvedPath, outPath);
|
|
85
|
-
}
|