@southwind-ai/config 0.1.0 → 0.1.2
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/package.json +2 -2
- package/src/platform.ts +28 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@southwind-ai/config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"!src/**/*.test.ts"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@southwind-ai/shared": "
|
|
15
|
+
"@southwind-ai/shared": "0.1.2",
|
|
16
16
|
"zod": "^4.4.3"
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
package/src/platform.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DatabaseDialect,
|
|
3
|
+
LicenseCatalogDefinition,
|
|
4
|
+
} from "@southwind-ai/shared";
|
|
5
|
+
import {
|
|
6
|
+
parseLicenseCatalog,
|
|
7
|
+
parseLicenseCatalogJson,
|
|
8
|
+
} from "@southwind-ai/shared";
|
|
2
9
|
import { z } from "zod";
|
|
3
10
|
import { defineModuleConfig, ModuleConfigRegistry } from "./definition.js";
|
|
4
11
|
import {
|
|
@@ -33,6 +40,8 @@ export interface PlatformConfig {
|
|
|
33
40
|
publicKeyId?: string;
|
|
34
41
|
publicKey?: string;
|
|
35
42
|
machineCode?: string;
|
|
43
|
+
/** 宿主自定义 License 版本目录;未配置时回退 shared 默认三级目录。 */
|
|
44
|
+
versions?: LicenseCatalogDefinition[];
|
|
36
45
|
};
|
|
37
46
|
audit: { enabled: boolean; redactFields: string[] };
|
|
38
47
|
compatibility: {
|
|
@@ -75,6 +84,20 @@ const platformSchema: z.ZodType<PlatformConfig> = z.strictObject({
|
|
|
75
84
|
publicKeyId: z.string().trim().min(1).optional(),
|
|
76
85
|
publicKey: z.string().trim().min(1).optional(),
|
|
77
86
|
machineCode: z.string().trim().min(1).optional(),
|
|
87
|
+
versions: z
|
|
88
|
+
.unknown()
|
|
89
|
+
.transform((value, context) => {
|
|
90
|
+
try {
|
|
91
|
+
return parseLicenseCatalog(value);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
context.addIssue({
|
|
94
|
+
code: "custom",
|
|
95
|
+
message: error instanceof Error ? error.message : "版本目录无效",
|
|
96
|
+
});
|
|
97
|
+
return z.NEVER;
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.optional(),
|
|
78
101
|
}),
|
|
79
102
|
audit: z.strictObject({
|
|
80
103
|
enabled: z.boolean(),
|
|
@@ -105,6 +128,7 @@ export const platformConfigDefinition = defineModuleConfig<PlatformConfig>({
|
|
|
105
128
|
"LICENSE_PUBLIC_KEY_ID",
|
|
106
129
|
"LICENSE_PUBLIC_KEY",
|
|
107
130
|
"LICENSE_MACHINE_CODE",
|
|
131
|
+
"WINDY_LICENSE_VERSIONS",
|
|
108
132
|
],
|
|
109
133
|
environment: [
|
|
110
134
|
value("PLATFORM_NAME", "name", "Windy Platform"),
|
|
@@ -133,6 +157,9 @@ export const platformConfigDefinition = defineModuleConfig<PlatformConfig>({
|
|
|
133
157
|
value("LICENSE_PUBLIC_KEY_ID", "license.publicKeyId"),
|
|
134
158
|
value("LICENSE_PUBLIC_KEY", "license.publicKey"),
|
|
135
159
|
secret("LICENSE_MACHINE_CODE", "license.machineCode"),
|
|
160
|
+
value("WINDY_LICENSE_VERSIONS", "license.versions", undefined, (raw) =>
|
|
161
|
+
parseLicenseCatalogJson(raw, "WINDY_LICENSE_VERSIONS"),
|
|
162
|
+
),
|
|
136
163
|
value("AUDIT_ENABLED", "audit.enabled", true, strictBoolean),
|
|
137
164
|
value(
|
|
138
165
|
"AUDIT_REDACT_FIELDS",
|