@uns-kit/core 0.0.28 → 0.0.29
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface ProjectAppConfig {
|
|
2
2
|
uns: {
|
|
3
3
|
graphql: string;
|
|
4
4
|
rest: string;
|
|
@@ -10,174 +10,33 @@ export interface AppConfig {
|
|
|
10
10
|
env?: "dev" | "staging" | "test" | "prod";
|
|
11
11
|
};
|
|
12
12
|
input?: {
|
|
13
|
-
host: string
|
|
14
|
-
/** Use the supplied host or IP address. */
|
|
15
|
-
provider: "inline";
|
|
16
|
-
/** Host or IP address that should be used directly. */
|
|
17
|
-
value: string;
|
|
18
|
-
} | {
|
|
19
|
-
/** Resolve the host from an external mapping. */
|
|
20
|
-
provider: "external";
|
|
21
|
-
/** Identifier used when resolving the host from HostResolverOptions. */
|
|
22
|
-
key: string;
|
|
23
|
-
/** Allow the external host to be missing without throwing during resolution. */
|
|
24
|
-
optional?: boolean | undefined;
|
|
25
|
-
/** Fallback host when optional is true and the external entry is missing. */
|
|
26
|
-
default?: string | undefined;
|
|
27
|
-
} | {
|
|
28
|
-
/** Resolve the host from local network interfaces. */
|
|
29
|
-
provider: "system";
|
|
30
|
-
/** Address family to return when scanning interfaces. */
|
|
31
|
-
family?: "IPv4" | "IPv6";
|
|
32
|
-
/** Specific interface to read (falls back to the first match when omitted). */
|
|
33
|
-
interfaceName?: string | undefined;
|
|
34
|
-
/** Allow the interface lookup to fail without throwing during resolution. */
|
|
35
|
-
optional?: boolean | undefined;
|
|
36
|
-
/** Fallback host/IP when optional is true and no interface matches. */
|
|
37
|
-
default?: string | undefined;
|
|
38
|
-
});
|
|
13
|
+
host: string;
|
|
39
14
|
username?: string | undefined;
|
|
40
|
-
password?:
|
|
41
|
-
/** Load the secret from an environment variable. */
|
|
42
|
-
provider: "env";
|
|
43
|
-
/** Name of the environment variable to read. */
|
|
44
|
-
key: string;
|
|
45
|
-
/** Allow the variable to be absent without throwing during resolution. */
|
|
46
|
-
optional?: boolean | undefined;
|
|
47
|
-
/** Fallback value when optional is true and the variable is missing. */
|
|
48
|
-
default?: string | undefined;
|
|
49
|
-
} | {
|
|
50
|
-
/** Load the secret from Infisical. */
|
|
51
|
-
provider: "infisical";
|
|
52
|
-
/** Secret folder path in Infisical, e.g. '/app/database'. */
|
|
53
|
-
path: string;
|
|
54
|
-
/** Secret key/name inside the given path. */
|
|
55
|
-
key: string;
|
|
56
|
-
/** Allow the secret to be absent without throwing during resolution. */
|
|
57
|
-
optional?: boolean | undefined;
|
|
58
|
-
/** Infisical environment override (defaults to current mode if omitted). */
|
|
59
|
-
environment?: string | undefined;
|
|
60
|
-
/** Optional Infisical project identifier when not using the default. */
|
|
61
|
-
projectId?: string | undefined;
|
|
62
|
-
/** Fallback value when the secret is missing and optional resolution is allowed. */
|
|
63
|
-
default?: string | undefined;
|
|
64
|
-
})) | undefined;
|
|
15
|
+
password?: string | undefined;
|
|
65
16
|
clientId?: string | undefined;
|
|
66
17
|
} | undefined;
|
|
67
18
|
output?: {
|
|
68
|
-
host: string
|
|
69
|
-
/** Use the supplied host or IP address. */
|
|
70
|
-
provider: "inline";
|
|
71
|
-
/** Host or IP address that should be used directly. */
|
|
72
|
-
value: string;
|
|
73
|
-
} | {
|
|
74
|
-
/** Resolve the host from an external mapping. */
|
|
75
|
-
provider: "external";
|
|
76
|
-
/** Identifier used when resolving the host from HostResolverOptions. */
|
|
77
|
-
key: string;
|
|
78
|
-
/** Allow the external host to be missing without throwing during resolution. */
|
|
79
|
-
optional?: boolean | undefined;
|
|
80
|
-
/** Fallback host when optional is true and the external entry is missing. */
|
|
81
|
-
default?: string | undefined;
|
|
82
|
-
} | {
|
|
83
|
-
/** Resolve the host from local network interfaces. */
|
|
84
|
-
provider: "system";
|
|
85
|
-
/** Address family to return when scanning interfaces. */
|
|
86
|
-
family?: "IPv4" | "IPv6";
|
|
87
|
-
/** Specific interface to read (falls back to the first match when omitted). */
|
|
88
|
-
interfaceName?: string | undefined;
|
|
89
|
-
/** Allow the interface lookup to fail without throwing during resolution. */
|
|
90
|
-
optional?: boolean | undefined;
|
|
91
|
-
/** Fallback host/IP when optional is true and no interface matches. */
|
|
92
|
-
default?: string | undefined;
|
|
93
|
-
});
|
|
19
|
+
host: string;
|
|
94
20
|
username?: string | undefined;
|
|
95
|
-
password?:
|
|
96
|
-
/** Load the secret from an environment variable. */
|
|
97
|
-
provider: "env";
|
|
98
|
-
/** Name of the environment variable to read. */
|
|
99
|
-
key: string;
|
|
100
|
-
/** Allow the variable to be absent without throwing during resolution. */
|
|
101
|
-
optional?: boolean | undefined;
|
|
102
|
-
/** Fallback value when optional is true and the variable is missing. */
|
|
103
|
-
default?: string | undefined;
|
|
104
|
-
} | {
|
|
105
|
-
/** Load the secret from Infisical. */
|
|
106
|
-
provider: "infisical";
|
|
107
|
-
/** Secret folder path in Infisical, e.g. '/app/database'. */
|
|
108
|
-
path: string;
|
|
109
|
-
/** Secret key/name inside the given path. */
|
|
110
|
-
key: string;
|
|
111
|
-
/** Allow the secret to be absent without throwing during resolution. */
|
|
112
|
-
optional?: boolean | undefined;
|
|
113
|
-
/** Infisical environment override (defaults to current mode if omitted). */
|
|
114
|
-
environment?: string | undefined;
|
|
115
|
-
/** Optional Infisical project identifier when not using the default. */
|
|
116
|
-
projectId?: string | undefined;
|
|
117
|
-
/** Fallback value when the secret is missing and optional resolution is allowed. */
|
|
118
|
-
default?: string | undefined;
|
|
119
|
-
})) | undefined;
|
|
21
|
+
password?: string | undefined;
|
|
120
22
|
clientId?: string | undefined;
|
|
121
23
|
} | undefined;
|
|
122
24
|
infra: {
|
|
123
|
-
host: string
|
|
124
|
-
/** Use the supplied host or IP address. */
|
|
125
|
-
provider: "inline";
|
|
126
|
-
/** Host or IP address that should be used directly. */
|
|
127
|
-
value: string;
|
|
128
|
-
} | {
|
|
129
|
-
/** Resolve the host from an external mapping. */
|
|
130
|
-
provider: "external";
|
|
131
|
-
/** Identifier used when resolving the host from HostResolverOptions. */
|
|
132
|
-
key: string;
|
|
133
|
-
/** Allow the external host to be missing without throwing during resolution. */
|
|
134
|
-
optional?: boolean | undefined;
|
|
135
|
-
/** Fallback host when optional is true and the external entry is missing. */
|
|
136
|
-
default?: string | undefined;
|
|
137
|
-
} | {
|
|
138
|
-
/** Resolve the host from local network interfaces. */
|
|
139
|
-
provider: "system";
|
|
140
|
-
/** Address family to return when scanning interfaces. */
|
|
141
|
-
family?: "IPv4" | "IPv6";
|
|
142
|
-
/** Specific interface to read (falls back to the first match when omitted). */
|
|
143
|
-
interfaceName?: string | undefined;
|
|
144
|
-
/** Allow the interface lookup to fail without throwing during resolution. */
|
|
145
|
-
optional?: boolean | undefined;
|
|
146
|
-
/** Fallback host/IP when optional is true and no interface matches. */
|
|
147
|
-
default?: string | undefined;
|
|
148
|
-
});
|
|
25
|
+
host: string;
|
|
149
26
|
username?: string | undefined;
|
|
150
|
-
password?:
|
|
151
|
-
/** Load the secret from an environment variable. */
|
|
152
|
-
provider: "env";
|
|
153
|
-
/** Name of the environment variable to read. */
|
|
154
|
-
key: string;
|
|
155
|
-
/** Allow the variable to be absent without throwing during resolution. */
|
|
156
|
-
optional?: boolean | undefined;
|
|
157
|
-
/** Fallback value when optional is true and the variable is missing. */
|
|
158
|
-
default?: string | undefined;
|
|
159
|
-
} | {
|
|
160
|
-
/** Load the secret from Infisical. */
|
|
161
|
-
provider: "infisical";
|
|
162
|
-
/** Secret folder path in Infisical, e.g. '/app/database'. */
|
|
163
|
-
path: string;
|
|
164
|
-
/** Secret key/name inside the given path. */
|
|
165
|
-
key: string;
|
|
166
|
-
/** Allow the secret to be absent without throwing during resolution. */
|
|
167
|
-
optional?: boolean | undefined;
|
|
168
|
-
/** Infisical environment override (defaults to current mode if omitted). */
|
|
169
|
-
environment?: string | undefined;
|
|
170
|
-
/** Optional Infisical project identifier when not using the default. */
|
|
171
|
-
projectId?: string | undefined;
|
|
172
|
-
/** Fallback value when the secret is missing and optional resolution is allowed. */
|
|
173
|
-
default?: string | undefined;
|
|
174
|
-
})) | undefined;
|
|
27
|
+
password?: string | undefined;
|
|
175
28
|
clientId?: string | undefined;
|
|
176
29
|
};
|
|
177
30
|
devops?: {
|
|
178
|
-
provider?:
|
|
31
|
+
provider?: "azure-devops";
|
|
179
32
|
organization: string;
|
|
180
33
|
project?: string | undefined;
|
|
181
34
|
} | undefined;
|
|
182
35
|
}
|
|
36
|
+
export interface AppConfig extends ProjectAppConfig {
|
|
37
|
+
}
|
|
38
|
+
declare module "@uns-kit/core/config/app-config.js" {
|
|
39
|
+
interface AppConfig extends ProjectAppConfig {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
183
42
|
//# sourceMappingURL=app-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-config.d.ts","sourceRoot":"","sources":["../../src/config/app-config.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"app-config.d.ts","sourceRoot":"","sources":["../../src/config/app-config.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;QAC7C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACrC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;KAC7C,CAAC;IACF,KAAK,CAAC,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACjC,GAAG,SAAS,CAAC;IACd,MAAM,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACjC,GAAG,SAAS,CAAC;IACd,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACjC,CAAC;IACF,MAAM,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,GAAG,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,SAAU,SAAQ,gBAAgB;CAAG;AAEtD,OAAO,QAAQ,oCAAoC,CAAC;IAClD,UAAU,SAAU,SAAQ,gBAAgB;KAAG;CAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-config.js","sourceRoot":"","sources":["../../src/config/app-config.ts"],"names":[],"mappings":"","sourcesContent":["/* Auto-generated. Do not edit by hand. */\nexport interface
|
|
1
|
+
{"version":3,"file":"app-config.js","sourceRoot":"","sources":["../../src/config/app-config.ts"],"names":[],"mappings":"","sourcesContent":["/* Auto-generated. Do not edit by hand. */\nexport interface ProjectAppConfig {\n uns: {\n graphql: string;\n rest: string;\n instanceMode?: \"wait\" | \"force\" | \"handover\";\n processName?: string | undefined;\n handover?: boolean;\n jwksWellKnownUrl?: string | undefined;\n kidWellKnownUrl?: string | undefined;\n env?: \"dev\" | \"staging\" | \"test\" | \"prod\";\n };\n input?: {\n host: string;\n username?: string | undefined;\n password?: string | undefined;\n clientId?: string | undefined;\n } | undefined;\n output?: {\n host: string;\n username?: string | undefined;\n password?: string | undefined;\n clientId?: string | undefined;\n } | undefined;\n infra: {\n host: string;\n username?: string | undefined;\n password?: string | undefined;\n clientId?: string | undefined;\n };\n devops?: {\n provider?: \"azure-devops\";\n organization: string;\n project?: string | undefined;\n } | undefined;\n}\n\nexport interface AppConfig extends ProjectAppConfig {}\n\ndeclare module \"@uns-kit/core/config/app-config.js\" {\n interface AppConfig extends ProjectAppConfig {}\n}\n"]}
|
|
@@ -2,10 +2,12 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
5
|
-
import { zodToTs, printNode } from "zod-to-ts";
|
|
5
|
+
import { zodToTs, printNode, withGetType } from "zod-to-ts";
|
|
6
6
|
import { composeConfigSchema } from "../uns-config/schema-tools.js";
|
|
7
7
|
import { unsCoreSchema } from "../uns-config/uns-core-schema.js";
|
|
8
8
|
import { projectExtrasSchema as coreProjectExtrasSchema } from "../config/project.config.extension.js";
|
|
9
|
+
import { hostValueSchema } from "../uns-config/host-placeholders.js";
|
|
10
|
+
import { secretValueSchema } from "../uns-config/secret-placeholders.js";
|
|
9
11
|
function write(filePath, data) {
|
|
10
12
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
11
13
|
fs.writeFileSync(filePath, data);
|
|
@@ -55,9 +57,15 @@ const baseSchema = composeConfigSchema(unsCoreSchema, projectExtrasSchema).stric
|
|
|
55
57
|
const jsonSchema = zodToJsonSchema(baseSchema, "AppConfig");
|
|
56
58
|
write(path.resolve("config.schema.json"), JSON.stringify(jsonSchema, null, 2));
|
|
57
59
|
// 2) TypeScript `export type AppConfig = {...}`
|
|
60
|
+
// Keep placeholder-backed values as plain strings in the generated TypeScript typings so
|
|
61
|
+
// consuming code reflects the resolved shapes while the JSON schema still exposes full unions.
|
|
62
|
+
const renderAsString = (typescript) => typescript.factory.createKeywordTypeNode(typescript.SyntaxKind.StringKeyword);
|
|
63
|
+
for (const schema of [hostValueSchema, secretValueSchema]) {
|
|
64
|
+
withGetType(schema, renderAsString);
|
|
65
|
+
}
|
|
58
66
|
const { node } = zodToTs(baseSchema, "AppConfig");
|
|
59
67
|
const interfaceBody = printNode(node);
|
|
60
|
-
const tsContent = `/* Auto-generated. Do not edit by hand. */\nexport interface ProjectAppConfig ${interfaceBody}\n\nexport
|
|
68
|
+
const tsContent = `/* Auto-generated. Do not edit by hand. */\nexport interface ProjectAppConfig ${interfaceBody}\n\nexport interface AppConfig extends ProjectAppConfig {}\n\ndeclare module "@uns-kit/core/config/app-config.js" {\n interface AppConfig extends ProjectAppConfig {}\n}\n`;
|
|
61
69
|
write(path.resolve("./src/config/app-config.ts"), tsContent);
|
|
62
70
|
console.log("Generated config.schema.json and updated src/config/app-config.ts");
|
|
63
71
|
//# sourceMappingURL=generate-config-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-config-schema.js","sourceRoot":"","sources":["../../src/tools/generate-config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-config-schema.js","sourceRoot":"","sources":["../../src/tools/generate-config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UA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AC;AAC5D,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAE/E,gDAAgD;AAChD,yFAAyF;AACzF,+FAA+F;AAC/F,MAAM,cAAc,GAAG,CAAC,UAAe,EAAE,EAAE,CACzC,UAAU,CAAC,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAEhF,KAAK,MAAM,MAAM,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,EAAE,CAAC;IAC1D,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACtC,CAAC;AACD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAClD,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAEtC,MAAM,SAAS,GAAG,iFAAiF,aAAa,6KAA6K,CAAC;AAE9R,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC,EAAE,SAAS,CAAC,CAAC;AAE7D,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport { zodToTs, printNode, withGetType } from \"zod-to-ts\";\nimport { z } from \"zod\";\n\nimport { composeConfigSchema } from \"../uns-config/schema-tools.js\";\nimport { unsCoreSchema } from \"../uns-config/uns-core-schema.js\";\nimport { projectExtrasSchema as coreProjectExtrasSchema } from \"../config/project.config.extension.js\";\nimport { hostValueSchema } from \"../uns-config/host-placeholders.js\";\nimport { secretValueSchema } from \"../uns-config/secret-placeholders.js\";\n\nfunction write(filePath: string, data: string) {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n fs.writeFileSync(filePath, data);\n}\n\nlet tsLoaderReady = false;\n\nasync function ensureTsLoader(): Promise<void> {\n if (tsLoaderReady) {\n return;\n }\n tsLoaderReady = true;\n try {\n await import(\"tsx/esm\");\n } catch (error) {\n throw new Error(\n \"Unable to load TypeScript project.config.extension. Install 'tsx' (e.g. pnpm add -D tsx) or provide a compiled JavaScript file.\",\n );\n }\n}\n\nasync function loadProjectExtrasSchema(): Promise<z.AnyZodObject> {\n const base = path.resolve(process.cwd(), \"src/config/project.config.extension\");\n const extensions = [\"\", \".ts\", \".mts\", \".tsx\", \".js\", \".mjs\", \".cjs\"];\n\n for (const ext of extensions) {\n const candidate = ext ? `${base}${ext}` : base;\n if (!fs.existsSync(candidate)) {\n continue;\n }\n\n const lowerExt = path.extname(candidate).toLowerCase();\n try {\n if (lowerExt === \".ts\" || lowerExt === \".mts\" || lowerExt === \".tsx\") {\n await ensureTsLoader();\n }\n\n const module = await import(pathToFileURL(candidate).href);\n if (module?.projectExtrasSchema) {\n return module.projectExtrasSchema as z.AnyZodObject;\n }\n\n throw new Error(`Module '${candidate}' does not export projectExtrasSchema.`);\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to load project config extension at '${candidate}': ${reason}`);\n }\n }\n\n return coreProjectExtrasSchema as z.AnyZodObject;\n}\n\nconst projectExtrasSchema = await loadProjectExtrasSchema();\nconst baseSchema = composeConfigSchema(unsCoreSchema, projectExtrasSchema).strict();\n\n// 1) JSON Schema for VS Code $schema\nconst jsonSchema = zodToJsonSchema(baseSchema, \"AppConfig\");\nwrite(path.resolve(\"config.schema.json\"), JSON.stringify(jsonSchema, null, 2));\n\n// 2) TypeScript `export type AppConfig = {...}`\n// Keep placeholder-backed values as plain strings in the generated TypeScript typings so\n// consuming code reflects the resolved shapes while the JSON schema still exposes full unions.\nconst renderAsString = (typescript: any) =>\n typescript.factory.createKeywordTypeNode(typescript.SyntaxKind.StringKeyword);\n\nfor (const schema of [hostValueSchema, secretValueSchema]) {\n withGetType(schema, renderAsString);\n}\nconst { node } = zodToTs(baseSchema, \"AppConfig\");\nconst interfaceBody = printNode(node);\n\nconst tsContent = `/* Auto-generated. Do not edit by hand. */\\nexport interface ProjectAppConfig ${interfaceBody}\\n\\nexport interface AppConfig extends ProjectAppConfig {}\\n\\ndeclare module \"@uns-kit/core/config/app-config.js\" {\\n interface AppConfig extends ProjectAppConfig {}\\n}\\n`;\n\nwrite(path.resolve(\"./src/config/app-config.ts\"), tsContent);\n\nconsole.log(\"Generated config.schema.json and updated src/config/app-config.ts\");\n"]}
|