litestar-vite-plugin 0.15.0-rc.5 → 0.16.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/js/astro.d.ts +17 -8
- package/dist/js/astro.js +43 -18
- package/dist/js/dev-server-index.html +115 -163
- package/dist/js/index.d.ts +19 -5
- package/dist/js/index.js +41 -18
- package/dist/js/nuxt.d.ts +16 -7
- package/dist/js/nuxt.js +42 -25
- package/dist/js/shared/bridge-schema.d.ts +3 -0
- package/dist/js/shared/bridge-schema.js +22 -0
- package/dist/js/shared/constants.d.ts +33 -0
- package/dist/js/shared/constants.js +10 -0
- package/dist/js/shared/emit-schemas-types.d.ts +8 -0
- package/dist/js/shared/emit-schemas-types.js +341 -0
- package/dist/js/shared/network.d.ts +30 -0
- package/dist/js/shared/network.js +25 -0
- package/dist/js/shared/typegen-core.d.ts +6 -0
- package/dist/js/shared/typegen-core.js +21 -0
- package/dist/js/shared/typegen-plugin.d.ts +2 -0
- package/dist/js/shared/typegen-plugin.js +17 -0
- package/dist/js/sveltekit.d.ts +16 -7
- package/dist/js/sveltekit.js +43 -22
- package/dist/js/typegen-cli.js +6 -2
- package/package.json +9 -4
package/dist/js/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { loadEnv } from "vite";
|
|
|
6
6
|
import fullReload from "vite-plugin-full-reload";
|
|
7
7
|
import { checkBackendAvailability, loadLitestarMeta } from "./litestar-meta.js";
|
|
8
8
|
import { readBridgeConfig } from "./shared/bridge-schema.js";
|
|
9
|
+
import { DEBOUNCE_MS } from "./shared/constants.js";
|
|
9
10
|
import { createLogger } from "./shared/logger.js";
|
|
10
11
|
import { createLitestarTypeGenPlugin } from "./shared/typegen-plugin.js";
|
|
11
12
|
let exitHandlersBound = false;
|
|
@@ -222,7 +223,11 @@ function resolveLitestarPlugin(pluginConfig) {
|
|
|
222
223
|
const normalizedAppUrl = normalizeAppUrl(rawAppUrl, envWithApp.LITESTAR_PORT);
|
|
223
224
|
const appUrl = normalizedAppUrl.url ?? rawAppUrl;
|
|
224
225
|
if (pluginConfig.hotFile && !path.isAbsolute(pluginConfig.hotFile)) {
|
|
225
|
-
|
|
226
|
+
const normalizedHot = pluginConfig.hotFile.replace(/^\/+/, "");
|
|
227
|
+
const normalizedBundle = pluginConfig.bundleDir?.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
228
|
+
const hotUnderBundle = normalizedBundle ? normalizedHot.startsWith(`${normalizedBundle}/`) : false;
|
|
229
|
+
const baseDir = hotUnderBundle ? server.config.root : path.resolve(server.config.root, normalizedBundle ?? "");
|
|
230
|
+
pluginConfig.hotFile = path.resolve(baseDir, normalizedHot);
|
|
226
231
|
}
|
|
227
232
|
const initialIndexPath = await findIndexHtmlPath(server, pluginConfig);
|
|
228
233
|
server.httpServer?.once("listening", () => {
|
|
@@ -509,20 +514,27 @@ function resolvePluginConfig(config) {
|
|
|
509
514
|
resolvedConfig.refresh = [{ paths: refreshPaths }];
|
|
510
515
|
}
|
|
511
516
|
let typesConfig = false;
|
|
517
|
+
const defaultTypesOutput = "src/generated";
|
|
518
|
+
const defaultOpenapiPath = path.join(defaultTypesOutput, "openapi.json");
|
|
519
|
+
const defaultRoutesPath = path.join(defaultTypesOutput, "routes.json");
|
|
520
|
+
const defaultSchemasTsPath = path.join(defaultTypesOutput, "schemas.ts");
|
|
521
|
+
const defaultPagePropsPath = path.join(defaultTypesOutput, "inertia-pages.json");
|
|
512
522
|
if (resolvedConfig.types === false) {
|
|
513
523
|
} else if (resolvedConfig.types === true) {
|
|
514
524
|
typesConfig = {
|
|
515
525
|
enabled: true,
|
|
516
|
-
output:
|
|
517
|
-
openapiPath:
|
|
518
|
-
routesPath:
|
|
519
|
-
pagePropsPath:
|
|
526
|
+
output: defaultTypesOutput,
|
|
527
|
+
openapiPath: defaultOpenapiPath,
|
|
528
|
+
routesPath: defaultRoutesPath,
|
|
529
|
+
pagePropsPath: defaultPagePropsPath,
|
|
530
|
+
schemasTsPath: defaultSchemasTsPath,
|
|
520
531
|
generateZod: false,
|
|
521
|
-
generateSdk:
|
|
532
|
+
generateSdk: true,
|
|
522
533
|
generateRoutes: true,
|
|
523
534
|
generatePageProps: true,
|
|
535
|
+
generateSchemas: true,
|
|
524
536
|
globalRoute: false,
|
|
525
|
-
debounce:
|
|
537
|
+
debounce: DEBOUNCE_MS
|
|
526
538
|
};
|
|
527
539
|
} else if (resolvedConfig.types === "auto" || typeof resolvedConfig.types === "undefined") {
|
|
528
540
|
if (pythonDefaults?.types) {
|
|
@@ -532,30 +544,35 @@ function resolvePluginConfig(config) {
|
|
|
532
544
|
openapiPath: pythonDefaults.types.openapiPath,
|
|
533
545
|
routesPath: pythonDefaults.types.routesPath,
|
|
534
546
|
pagePropsPath: pythonDefaults.types.pagePropsPath,
|
|
547
|
+
schemasTsPath: pythonDefaults.types.schemasTsPath ?? path.join(pythonDefaults.types.output, "schemas.ts"),
|
|
535
548
|
generateZod: pythonDefaults.types.generateZod,
|
|
536
549
|
generateSdk: pythonDefaults.types.generateSdk,
|
|
537
550
|
generateRoutes: pythonDefaults.types.generateRoutes,
|
|
538
551
|
generatePageProps: pythonDefaults.types.generatePageProps,
|
|
552
|
+
generateSchemas: pythonDefaults.types.generateSchemas ?? true,
|
|
539
553
|
globalRoute: pythonDefaults.types.globalRoute,
|
|
540
|
-
debounce:
|
|
554
|
+
debounce: DEBOUNCE_MS
|
|
541
555
|
};
|
|
542
556
|
}
|
|
543
557
|
} else if (typeof resolvedConfig.types === "object" && resolvedConfig.types !== null) {
|
|
544
558
|
const userProvidedOpenapi = Object.hasOwn(resolvedConfig.types, "openapiPath");
|
|
545
559
|
const userProvidedRoutes = Object.hasOwn(resolvedConfig.types, "routesPath");
|
|
546
560
|
const userProvidedPageProps = Object.hasOwn(resolvedConfig.types, "pagePropsPath");
|
|
561
|
+
const userProvidedSchemasTs = Object.hasOwn(resolvedConfig.types, "schemasTsPath");
|
|
547
562
|
typesConfig = {
|
|
548
563
|
enabled: resolvedConfig.types.enabled ?? true,
|
|
549
|
-
output: resolvedConfig.types.output ??
|
|
550
|
-
openapiPath: resolvedConfig.types.openapiPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "openapi.json") :
|
|
551
|
-
routesPath: resolvedConfig.types.routesPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "routes.json") :
|
|
552
|
-
pagePropsPath: resolvedConfig.types.pagePropsPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "inertia-pages.json") :
|
|
564
|
+
output: resolvedConfig.types.output ?? defaultTypesOutput,
|
|
565
|
+
openapiPath: resolvedConfig.types.openapiPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "openapi.json") : defaultOpenapiPath),
|
|
566
|
+
routesPath: resolvedConfig.types.routesPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "routes.json") : defaultRoutesPath),
|
|
567
|
+
pagePropsPath: resolvedConfig.types.pagePropsPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "inertia-pages.json") : defaultPagePropsPath),
|
|
568
|
+
schemasTsPath: resolvedConfig.types.schemasTsPath ?? (resolvedConfig.types.output ? path.join(resolvedConfig.types.output, "schemas.ts") : defaultSchemasTsPath),
|
|
553
569
|
generateZod: resolvedConfig.types.generateZod ?? false,
|
|
554
|
-
generateSdk: resolvedConfig.types.generateSdk ??
|
|
570
|
+
generateSdk: resolvedConfig.types.generateSdk ?? true,
|
|
555
571
|
generateRoutes: resolvedConfig.types.generateRoutes ?? true,
|
|
556
572
|
generatePageProps: resolvedConfig.types.generatePageProps ?? true,
|
|
573
|
+
generateSchemas: resolvedConfig.types.generateSchemas ?? true,
|
|
557
574
|
globalRoute: resolvedConfig.types.globalRoute ?? false,
|
|
558
|
-
debounce: resolvedConfig.types.debounce ??
|
|
575
|
+
debounce: resolvedConfig.types.debounce ?? DEBOUNCE_MS
|
|
559
576
|
};
|
|
560
577
|
if (!userProvidedOpenapi && resolvedConfig.types.output) {
|
|
561
578
|
typesConfig.openapiPath = path.join(typesConfig.output, "openapi.json");
|
|
@@ -566,21 +583,27 @@ function resolvePluginConfig(config) {
|
|
|
566
583
|
if (!userProvidedPageProps && resolvedConfig.types.output) {
|
|
567
584
|
typesConfig.pagePropsPath = path.join(typesConfig.output, "inertia-pages.json");
|
|
568
585
|
}
|
|
586
|
+
if (!userProvidedSchemasTs && resolvedConfig.types.output) {
|
|
587
|
+
typesConfig.schemasTsPath = path.join(typesConfig.output, "schemas.ts");
|
|
588
|
+
}
|
|
569
589
|
}
|
|
570
590
|
const inertiaMode = resolvedConfig.inertiaMode ?? (pythonDefaults?.mode === "hybrid" || pythonDefaults?.mode === "inertia");
|
|
571
591
|
const effectiveResourceDir = resolvedConfig.resourceDir ?? pythonDefaults?.resourceDir ?? "src";
|
|
592
|
+
const resolvedBundleDir = resolvedConfig.bundleDir ?? pythonDefaults?.bundleDir ?? "public";
|
|
593
|
+
const resolvedStaticDir = resolvedConfig.staticDir ?? pythonDefaults?.staticDir ?? path.join(effectiveResourceDir, "public");
|
|
594
|
+
const resolvedHotFile = resolvedConfig.hotFile ?? pythonDefaults?.hotFile ?? path.join(resolvedBundleDir, "hot");
|
|
572
595
|
const deployAssetUrlRaw = resolvedConfig.deployAssetUrl ?? pythonDefaults?.deployAssetUrl ?? void 0;
|
|
573
596
|
const result = {
|
|
574
597
|
input: resolvedConfig.input,
|
|
575
598
|
assetUrl: normalizeAssetUrl(resolvedConfig.assetUrl ?? pythonDefaults?.assetUrl ?? "/static/"),
|
|
576
599
|
deployAssetUrl: typeof deployAssetUrlRaw === "string" ? normalizeAssetUrl(deployAssetUrlRaw) : void 0,
|
|
577
600
|
resourceDir: effectiveResourceDir,
|
|
578
|
-
bundleDir:
|
|
579
|
-
staticDir:
|
|
601
|
+
bundleDir: resolvedBundleDir,
|
|
602
|
+
staticDir: resolvedStaticDir,
|
|
580
603
|
ssr: resolvedConfig.ssr ?? resolvedConfig.input,
|
|
581
604
|
ssrOutDir: resolvedConfig.ssrOutDir ?? pythonDefaults?.ssrOutDir ?? path.join(effectiveResourceDir, "bootstrap/ssr"),
|
|
582
605
|
refresh: resolvedConfig.refresh ?? false,
|
|
583
|
-
hotFile:
|
|
606
|
+
hotFile: resolvedHotFile,
|
|
584
607
|
detectTls: resolvedConfig.detectTls ?? false,
|
|
585
608
|
autoDetectIndex: resolvedConfig.autoDetectIndex ?? true,
|
|
586
609
|
inertiaMode,
|
|
@@ -771,7 +794,7 @@ function dirname() {
|
|
|
771
794
|
try {
|
|
772
795
|
return fileURLToPath(new URL(".", import.meta.url));
|
|
773
796
|
} catch {
|
|
774
|
-
return path.resolve(process.cwd(), "
|
|
797
|
+
return path.resolve(process.cwd(), "dist/js");
|
|
775
798
|
}
|
|
776
799
|
}
|
|
777
800
|
function normalizeAssetUrl(url) {
|
package/dist/js/nuxt.d.ts
CHANGED
|
@@ -15,10 +15,7 @@
|
|
|
15
15
|
* litestar: {
|
|
16
16
|
* apiProxy: 'http://localhost:8000',
|
|
17
17
|
* apiPrefix: '/api',
|
|
18
|
-
* types:
|
|
19
|
-
* enabled: true,
|
|
20
|
-
* output: 'generated',
|
|
21
|
-
* },
|
|
18
|
+
* types: true,
|
|
22
19
|
* },
|
|
23
20
|
* });
|
|
24
21
|
* ```
|
|
@@ -46,19 +43,25 @@ export interface NuxtTypesConfig {
|
|
|
46
43
|
/**
|
|
47
44
|
* Path where the OpenAPI schema is exported by Litestar.
|
|
48
45
|
*
|
|
49
|
-
* @default
|
|
46
|
+
* @default `${output}/openapi.json`
|
|
50
47
|
*/
|
|
51
48
|
openapiPath?: string;
|
|
52
49
|
/**
|
|
53
50
|
* Path where route metadata is exported by Litestar.
|
|
54
51
|
*
|
|
55
|
-
* @default
|
|
52
|
+
* @default `${output}/routes.json`
|
|
56
53
|
*/
|
|
57
54
|
routesPath?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Optional path for the generated schemas.ts helper file.
|
|
57
|
+
*
|
|
58
|
+
* @default `${output}/schemas.ts`
|
|
59
|
+
*/
|
|
60
|
+
schemasTsPath?: string;
|
|
58
61
|
/**
|
|
59
62
|
* Path where Inertia page props metadata is exported by Litestar.
|
|
60
63
|
*
|
|
61
|
-
* @default
|
|
64
|
+
* @default `${output}/inertia-pages.json`
|
|
62
65
|
*/
|
|
63
66
|
pagePropsPath?: string;
|
|
64
67
|
/**
|
|
@@ -85,6 +88,12 @@ export interface NuxtTypesConfig {
|
|
|
85
88
|
* @default true
|
|
86
89
|
*/
|
|
87
90
|
generatePageProps?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Generate schemas.ts with ergonomic form/response type helpers.
|
|
93
|
+
*
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
generateSchemas?: boolean;
|
|
88
97
|
/**
|
|
89
98
|
* Register route() globally on window object.
|
|
90
99
|
*
|
package/dist/js/nuxt.js
CHANGED
|
@@ -2,16 +2,9 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import colors from "picocolors";
|
|
4
4
|
import { readBridgeConfig } from "./shared/bridge-schema.js";
|
|
5
|
+
import { DEBOUNCE_MS } from "./shared/constants.js";
|
|
6
|
+
import { normalizeHost, resolveHotFilePath } from "./shared/network.js";
|
|
5
7
|
import { createLitestarTypeGenPlugin } from "./shared/typegen-plugin.js";
|
|
6
|
-
function normalizeHost(host) {
|
|
7
|
-
if (host === "::" || host === "::1" || host === "0.0.0.0") {
|
|
8
|
-
return "localhost";
|
|
9
|
-
}
|
|
10
|
-
if (host.includes(":") && !host.startsWith("[")) {
|
|
11
|
-
return `[${host}]`;
|
|
12
|
-
}
|
|
13
|
-
return host;
|
|
14
|
-
}
|
|
15
8
|
function resolveConfig(config = {}) {
|
|
16
9
|
let hotFile;
|
|
17
10
|
let proxyMode = "vite";
|
|
@@ -30,7 +23,7 @@ function resolveConfig(config = {}) {
|
|
|
30
23
|
if (runtime) {
|
|
31
24
|
hasPythonConfig = true;
|
|
32
25
|
const hot = runtime.hotFile;
|
|
33
|
-
hotFile =
|
|
26
|
+
hotFile = resolveHotFilePath(runtime.bundleDir, hot);
|
|
34
27
|
proxyMode = runtime.proxyMode;
|
|
35
28
|
devPort = runtime.port;
|
|
36
29
|
pythonExecutor = runtime.executor;
|
|
@@ -39,47 +32,71 @@ function resolveConfig(config = {}) {
|
|
|
39
32
|
}
|
|
40
33
|
}
|
|
41
34
|
let typesConfig = false;
|
|
35
|
+
const defaultTypesOutput = "generated";
|
|
36
|
+
const buildTypeDefaults = (output) => ({
|
|
37
|
+
openapiPath: path.join(output, "openapi.json"),
|
|
38
|
+
routesPath: path.join(output, "routes.json"),
|
|
39
|
+
pagePropsPath: path.join(output, "inertia-pages.json"),
|
|
40
|
+
schemasTsPath: path.join(output, "schemas.ts")
|
|
41
|
+
});
|
|
42
42
|
if (config.types === true) {
|
|
43
|
+
const output = pythonTypesConfig?.output ?? defaultTypesOutput;
|
|
44
|
+
const defaults = buildTypeDefaults(output);
|
|
43
45
|
typesConfig = {
|
|
44
46
|
enabled: true,
|
|
45
|
-
output
|
|
46
|
-
openapiPath: pythonTypesConfig?.openapiPath ??
|
|
47
|
-
routesPath: pythonTypesConfig?.routesPath ??
|
|
48
|
-
pagePropsPath: pythonTypesConfig?.pagePropsPath ??
|
|
47
|
+
output,
|
|
48
|
+
openapiPath: pythonTypesConfig?.openapiPath ?? defaults.openapiPath,
|
|
49
|
+
routesPath: pythonTypesConfig?.routesPath ?? defaults.routesPath,
|
|
50
|
+
pagePropsPath: pythonTypesConfig?.pagePropsPath ?? defaults.pagePropsPath,
|
|
51
|
+
schemasTsPath: pythonTypesConfig?.schemasTsPath ?? defaults.schemasTsPath,
|
|
49
52
|
generateZod: pythonTypesConfig?.generateZod ?? false,
|
|
50
53
|
generateSdk: pythonTypesConfig?.generateSdk ?? true,
|
|
51
54
|
generateRoutes: pythonTypesConfig?.generateRoutes ?? true,
|
|
52
55
|
generatePageProps: pythonTypesConfig?.generatePageProps ?? true,
|
|
56
|
+
generateSchemas: pythonTypesConfig?.generateSchemas ?? true,
|
|
53
57
|
globalRoute: pythonTypesConfig?.globalRoute ?? false,
|
|
54
|
-
debounce:
|
|
58
|
+
debounce: DEBOUNCE_MS
|
|
55
59
|
};
|
|
56
60
|
} else if (typeof config.types === "object" && config.types !== null) {
|
|
61
|
+
const userProvidedOutput = Object.hasOwn(config.types, "output");
|
|
62
|
+
const output = config.types.output ?? pythonTypesConfig?.output ?? defaultTypesOutput;
|
|
63
|
+
const defaults = buildTypeDefaults(output);
|
|
64
|
+
const openapiFallback = userProvidedOutput ? defaults.openapiPath : pythonTypesConfig?.openapiPath ?? defaults.openapiPath;
|
|
65
|
+
const routesFallback = userProvidedOutput ? defaults.routesPath : pythonTypesConfig?.routesPath ?? defaults.routesPath;
|
|
66
|
+
const pagePropsFallback = userProvidedOutput ? defaults.pagePropsPath : pythonTypesConfig?.pagePropsPath ?? defaults.pagePropsPath;
|
|
67
|
+
const schemasFallback = userProvidedOutput ? defaults.schemasTsPath : pythonTypesConfig?.schemasTsPath ?? defaults.schemasTsPath;
|
|
57
68
|
typesConfig = {
|
|
58
69
|
enabled: config.types.enabled ?? true,
|
|
59
|
-
output
|
|
60
|
-
openapiPath: config.types.openapiPath ??
|
|
61
|
-
routesPath: config.types.routesPath ??
|
|
62
|
-
pagePropsPath: config.types.pagePropsPath ??
|
|
70
|
+
output,
|
|
71
|
+
openapiPath: config.types.openapiPath ?? openapiFallback,
|
|
72
|
+
routesPath: config.types.routesPath ?? routesFallback,
|
|
73
|
+
pagePropsPath: config.types.pagePropsPath ?? pagePropsFallback,
|
|
74
|
+
schemasTsPath: config.types.schemasTsPath ?? schemasFallback,
|
|
63
75
|
generateZod: config.types.generateZod ?? pythonTypesConfig?.generateZod ?? false,
|
|
64
76
|
generateSdk: config.types.generateSdk ?? pythonTypesConfig?.generateSdk ?? true,
|
|
65
77
|
generateRoutes: config.types.generateRoutes ?? pythonTypesConfig?.generateRoutes ?? true,
|
|
66
78
|
generatePageProps: config.types.generatePageProps ?? pythonTypesConfig?.generatePageProps ?? true,
|
|
79
|
+
generateSchemas: config.types.generateSchemas ?? pythonTypesConfig?.generateSchemas ?? true,
|
|
67
80
|
globalRoute: config.types.globalRoute ?? pythonTypesConfig?.globalRoute ?? false,
|
|
68
|
-
debounce: config.types.debounce ??
|
|
81
|
+
debounce: config.types.debounce ?? DEBOUNCE_MS
|
|
69
82
|
};
|
|
70
83
|
} else if (config.types !== false && pythonTypesConfig?.enabled) {
|
|
84
|
+
const output = pythonTypesConfig.output ?? defaultTypesOutput;
|
|
85
|
+
const defaults = buildTypeDefaults(output);
|
|
71
86
|
typesConfig = {
|
|
72
87
|
enabled: true,
|
|
73
|
-
output
|
|
74
|
-
openapiPath: pythonTypesConfig.openapiPath ??
|
|
75
|
-
routesPath: pythonTypesConfig.routesPath ??
|
|
76
|
-
pagePropsPath: pythonTypesConfig.pagePropsPath ??
|
|
88
|
+
output,
|
|
89
|
+
openapiPath: pythonTypesConfig.openapiPath ?? defaults.openapiPath,
|
|
90
|
+
routesPath: pythonTypesConfig.routesPath ?? defaults.routesPath,
|
|
91
|
+
pagePropsPath: pythonTypesConfig.pagePropsPath ?? defaults.pagePropsPath,
|
|
92
|
+
schemasTsPath: pythonTypesConfig.schemasTsPath ?? defaults.schemasTsPath,
|
|
77
93
|
generateZod: pythonTypesConfig.generateZod ?? false,
|
|
78
94
|
generateSdk: pythonTypesConfig.generateSdk ?? true,
|
|
79
95
|
generateRoutes: pythonTypesConfig.generateRoutes ?? true,
|
|
80
96
|
generatePageProps: pythonTypesConfig.generatePageProps ?? true,
|
|
97
|
+
generateSchemas: pythonTypesConfig.generateSchemas ?? true,
|
|
81
98
|
globalRoute: pythonTypesConfig.globalRoute ?? false,
|
|
82
|
-
debounce:
|
|
99
|
+
debounce: DEBOUNCE_MS
|
|
83
100
|
};
|
|
84
101
|
}
|
|
85
102
|
return {
|
|
@@ -17,10 +17,13 @@ export interface BridgeTypesConfig {
|
|
|
17
17
|
openapiPath: string;
|
|
18
18
|
routesPath: string;
|
|
19
19
|
pagePropsPath: string;
|
|
20
|
+
routesTsPath?: string;
|
|
21
|
+
schemasTsPath?: string;
|
|
20
22
|
generateZod: boolean;
|
|
21
23
|
generateSdk: boolean;
|
|
22
24
|
generateRoutes: boolean;
|
|
23
25
|
generatePageProps: boolean;
|
|
26
|
+
generateSchemas: boolean;
|
|
24
27
|
globalRoute: boolean;
|
|
25
28
|
}
|
|
26
29
|
export interface BridgeSpaConfig {
|
|
@@ -61,6 +61,14 @@ function assertNullableString(obj, key) {
|
|
|
61
61
|
}
|
|
62
62
|
return value;
|
|
63
63
|
}
|
|
64
|
+
function assertOptionalString(obj, key) {
|
|
65
|
+
const value = obj[key];
|
|
66
|
+
if (value === void 0) return void 0;
|
|
67
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
68
|
+
fail(`"${key}" must be a non-empty string`);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
64
72
|
function assertEnum(value, key, allowed) {
|
|
65
73
|
if (typeof value !== "string" || !allowed.has(value)) {
|
|
66
74
|
fail(`"${key}" must be one of: ${Array.from(allowed).join(", ")}`);
|
|
@@ -71,6 +79,14 @@ function assertProxyMode(value) {
|
|
|
71
79
|
if (value === null) return null;
|
|
72
80
|
return assertEnum(value, "proxyMode", allowedProxyModes);
|
|
73
81
|
}
|
|
82
|
+
function assertOptionalBoolean(obj, key, defaultValue) {
|
|
83
|
+
const value = obj[key];
|
|
84
|
+
if (value === void 0) return defaultValue;
|
|
85
|
+
if (typeof value !== "boolean") {
|
|
86
|
+
fail(`"${key}" must be a boolean`);
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
74
90
|
function parseTypesConfig(value) {
|
|
75
91
|
if (value === null) return null;
|
|
76
92
|
const obj = assertObject(value, "types");
|
|
@@ -79,10 +95,13 @@ function parseTypesConfig(value) {
|
|
|
79
95
|
const openapiPath = assertString(obj, "openapiPath");
|
|
80
96
|
const routesPath = assertString(obj, "routesPath");
|
|
81
97
|
const pagePropsPath = assertString(obj, "pagePropsPath");
|
|
98
|
+
const routesTsPath = assertOptionalString(obj, "routesTsPath");
|
|
99
|
+
const schemasTsPath = assertOptionalString(obj, "schemasTsPath");
|
|
82
100
|
const generateZod = assertBoolean(obj, "generateZod");
|
|
83
101
|
const generateSdk = assertBoolean(obj, "generateSdk");
|
|
84
102
|
const generateRoutes = assertBoolean(obj, "generateRoutes");
|
|
85
103
|
const generatePageProps = assertBoolean(obj, "generatePageProps");
|
|
104
|
+
const generateSchemas = assertOptionalBoolean(obj, "generateSchemas", true);
|
|
86
105
|
const globalRoute = assertBoolean(obj, "globalRoute");
|
|
87
106
|
return {
|
|
88
107
|
enabled,
|
|
@@ -90,10 +109,13 @@ function parseTypesConfig(value) {
|
|
|
90
109
|
openapiPath,
|
|
91
110
|
routesPath,
|
|
92
111
|
pagePropsPath,
|
|
112
|
+
routesTsPath,
|
|
113
|
+
schemasTsPath,
|
|
93
114
|
generateZod,
|
|
94
115
|
generateSdk,
|
|
95
116
|
generateRoutes,
|
|
96
117
|
generatePageProps,
|
|
118
|
+
generateSchemas,
|
|
97
119
|
globalRoute
|
|
98
120
|
};
|
|
99
121
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for litestar-vite plugin.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes magic values that are reused across multiple modules.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default debounce time in milliseconds for type regeneration.
|
|
8
|
+
*
|
|
9
|
+
* Used across all framework integrations (Vite, Nuxt, Astro, SvelteKit)
|
|
10
|
+
* to avoid excessive regeneration during rapid file changes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEBOUNCE_MS = 300;
|
|
13
|
+
/**
|
|
14
|
+
* Timeout in milliseconds for backend health checks.
|
|
15
|
+
*
|
|
16
|
+
* Used when checking if the Litestar backend is available
|
|
17
|
+
* before attempting to fetch OpenAPI schema.
|
|
18
|
+
*/
|
|
19
|
+
export declare const BACKEND_CHECK_TIMEOUT_MS = 2000;
|
|
20
|
+
/**
|
|
21
|
+
* Default asset URL path.
|
|
22
|
+
*
|
|
23
|
+
* Used as fallback when no explicit assetUrl is configured.
|
|
24
|
+
* Should match the default in Python ViteConfig.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DEFAULT_ASSET_URL = "/static/";
|
|
27
|
+
/**
|
|
28
|
+
* Default output directory for generated TypeScript types.
|
|
29
|
+
*
|
|
30
|
+
* Used by framework integrations as fallback when no output
|
|
31
|
+
* is specified in Python bridge config or plugin options.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_TYPES_OUTPUT = "src/generated";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schemas.ts from routes.json and hey-api types.gen.ts.
|
|
3
|
+
*
|
|
4
|
+
* @param routesJsonPath - Path to routes.json
|
|
5
|
+
* @param outputDir - Output directory (contains api/types.gen.ts)
|
|
6
|
+
* @returns true if file was changed, false if unchanged
|
|
7
|
+
*/
|
|
8
|
+
export declare function emitSchemasTypes(routesJsonPath: string, outputDir: string, schemasOutputPath?: string): Promise<boolean>;
|