@siming-org/core 0.5.1 → 0.6.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/index.d.ts +2 -1
- package/dist/index.js +23 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3297,11 +3297,12 @@ declare const SimingConfigSchema: z.ZodObject<{
|
|
|
3297
3297
|
auth: z.ZodPrefault<z.ZodObject<{
|
|
3298
3298
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
3299
3299
|
}, z.core.$strip>>;
|
|
3300
|
+
publicUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
3300
3301
|
cors: z.ZodOptional<z.ZodUnknown>;
|
|
3301
3302
|
}, z.core.$strip>;
|
|
3302
3303
|
type SimingConfig = z.infer<typeof SimingConfigSchema>;
|
|
3303
3304
|
/** 可经环境变量/CLI 参数/配置文件配置的 key(cors 仍为预留字段) */
|
|
3304
|
-
declare const SIMING_CONFIG_KEYS: readonly ["mongoUri", "port", "host", "logLevel", "auth"];
|
|
3305
|
+
declare const SIMING_CONFIG_KEYS: readonly ["mongoUri", "port", "host", "logLevel", "auth", "publicUrl"];
|
|
3305
3306
|
type SimingConfigKey = (typeof SIMING_CONFIG_KEYS)[number];
|
|
3306
3307
|
/**
|
|
3307
3308
|
* env 键映射单源(N018 D5):server env resolver 与 cli loader 共用,
|
package/dist/index.js
CHANGED
|
@@ -3213,6 +3213,19 @@ var UpgradeApplyRequestSchema = z18.object({
|
|
|
3213
3213
|
// src/config/server-config.ts
|
|
3214
3214
|
import { z as z19 } from "zod";
|
|
3215
3215
|
var SimingLogLevelSchema = z19.enum(["debug", "info", "warn", "error"]);
|
|
3216
|
+
var HttpOriginSchema = z19.string().transform((value, ctx) => {
|
|
3217
|
+
let origin = null;
|
|
3218
|
+
try {
|
|
3219
|
+
const url = new URL(value);
|
|
3220
|
+
if (url.protocol === "http:" || url.protocol === "https:") origin = url.origin;
|
|
3221
|
+
} catch {
|
|
3222
|
+
}
|
|
3223
|
+
if (origin === null) {
|
|
3224
|
+
ctx.addIssue({ code: "custom", message: "must be an http(s):// URL" });
|
|
3225
|
+
return z19.NEVER;
|
|
3226
|
+
}
|
|
3227
|
+
return origin;
|
|
3228
|
+
});
|
|
3216
3229
|
var SimingConfigSchema = z19.object({
|
|
3217
3230
|
mongoUri: z19.string().min(1).default("mongodb://localhost:27017"),
|
|
3218
3231
|
port: z19.coerce.number().int().min(1).max(65535).default(7777),
|
|
@@ -3229,15 +3242,23 @@ var SimingConfigSchema = z19.object({
|
|
|
3229
3242
|
auth: z19.object({
|
|
3230
3243
|
enabled: z19.boolean().default(false)
|
|
3231
3244
|
}).prefault({}),
|
|
3245
|
+
/**
|
|
3246
|
+
* T202609070001:服务对外可达基础地址(whoami 自报 server.url 用)——反代终止 TLS 后
|
|
3247
|
+
* 请求推导结构性失真(到进程为明文 → 恒 http,Host 头无端口),由部署显式声明。
|
|
3248
|
+
* optional 无内置默认:未配置 = whoami 维持请求推导现状(本地直连形态零破坏),
|
|
3249
|
+
* 消费侧来源/摘要逻辑对 undefined 的 optional 键不补「内置默认值」来源。
|
|
3250
|
+
*/
|
|
3251
|
+
publicUrl: HttpOriginSchema.optional(),
|
|
3232
3252
|
cors: z19.unknown().optional()
|
|
3233
3253
|
});
|
|
3234
|
-
var SIMING_CONFIG_KEYS = ["mongoUri", "port", "host", "logLevel", "auth"];
|
|
3254
|
+
var SIMING_CONFIG_KEYS = ["mongoUri", "port", "host", "logLevel", "auth", "publicUrl"];
|
|
3235
3255
|
var SIMING_CONFIG_ENV_KEYS = {
|
|
3236
3256
|
mongoUri: "SIMING_MONGO_URI",
|
|
3237
3257
|
port: "PORT",
|
|
3238
3258
|
host: "SIMING_HOST",
|
|
3239
3259
|
logLevel: "SIMING_LOG_LEVEL",
|
|
3240
|
-
auth: "SIMING_AUTH_ENABLED"
|
|
3260
|
+
auth: "SIMING_AUTH_ENABLED",
|
|
3261
|
+
publicUrl: "SIMING_PUBLIC_URL"
|
|
3241
3262
|
};
|
|
3242
3263
|
function parseAuthEnabledEnvValue(raw) {
|
|
3243
3264
|
if (raw === "true") return true;
|