@h-ai/core 1.0.0-beta.2 → 1.0.0-beta.21
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/README.en.md +715 -474
- package/README.ja.md +714 -473
- package/README.md +714 -473
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +39 -11
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-BEGTB6GL.js → chunk-WU6HUTBO.js} +262 -59
- package/dist/chunk-WU6HUTBO.js.map +1 -0
- package/dist/{core-types-_JqVAGGT.d.ts → core-types-Dp3Vr2uI.d.ts} +161 -15
- package/dist/node.d.ts +2 -2
- package/dist/node.js +495 -123
- package/dist/node.js.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-BEGTB6GL.js.map +0 -1
|
@@ -685,6 +685,7 @@ __export(util_exports, {
|
|
|
685
685
|
required: () => required,
|
|
686
686
|
safeExtend: () => safeExtend,
|
|
687
687
|
shallowClone: () => shallowClone,
|
|
688
|
+
sizeCaps: () => sizeCaps,
|
|
688
689
|
slugify: () => slugify,
|
|
689
690
|
stringifyPrimitive: () => stringifyPrimitive,
|
|
690
691
|
toZod: () => toZod,
|
|
@@ -1204,6 +1205,18 @@ function prefixIssues(path, issues) {
|
|
|
1204
1205
|
function unwrapMessage(message) {
|
|
1205
1206
|
return typeof message === "string" ? message : message?.message;
|
|
1206
1207
|
}
|
|
1208
|
+
function sizeCaps(defChecks) {
|
|
1209
|
+
const caps = [];
|
|
1210
|
+
for (const ch of defChecks ?? []) {
|
|
1211
|
+
const d = ch._zod.def;
|
|
1212
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
1213
|
+
break;
|
|
1214
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
1215
|
+
if (max >= 0)
|
|
1216
|
+
caps.push([max, ch]);
|
|
1217
|
+
}
|
|
1218
|
+
return caps;
|
|
1219
|
+
}
|
|
1207
1220
|
function attachSchema(issues, start, inst) {
|
|
1208
1221
|
var _a3;
|
|
1209
1222
|
for (let i = start; i < issues.length; i++) {
|
|
@@ -2624,7 +2637,7 @@ ${content.join("\n")}
|
|
|
2624
2637
|
var version = {
|
|
2625
2638
|
major: 4,
|
|
2626
2639
|
minor: 6,
|
|
2627
|
-
patch:
|
|
2640
|
+
patch: 7
|
|
2628
2641
|
};
|
|
2629
2642
|
|
|
2630
2643
|
// ../../node_modules/zod/v4/core/schemas.js
|
|
@@ -3380,6 +3393,31 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
3380
3393
|
return payload;
|
|
3381
3394
|
};
|
|
3382
3395
|
});
|
|
3396
|
+
function capSize(inst, size) {
|
|
3397
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
3398
|
+
if (!caps.length)
|
|
3399
|
+
return;
|
|
3400
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
3401
|
+
const parse3 = inst._zod.parse;
|
|
3402
|
+
inst._zod.parse = (payload, ctx) => {
|
|
3403
|
+
const n = size(payload.value);
|
|
3404
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
3405
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
3406
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
3407
|
+
const start = payload.issues.length;
|
|
3408
|
+
ch._zod.check(payload);
|
|
3409
|
+
payload.issues[start].continue = false;
|
|
3410
|
+
attachSchema(payload.issues, start, inst);
|
|
3411
|
+
return payload;
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
return parse3(payload, ctx);
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
|
|
3419
|
+
var mapSize = (input2) => input2 instanceof Map ? input2.size : -1;
|
|
3420
|
+
var setSize = (input2) => input2 instanceof Set ? input2.size : -1;
|
|
3383
3421
|
function handleArrayResult(result, final, index) {
|
|
3384
3422
|
if (result.issues.length) {
|
|
3385
3423
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -3423,6 +3461,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
3423
3461
|
}
|
|
3424
3462
|
return payload;
|
|
3425
3463
|
};
|
|
3464
|
+
capSize(inst, arraySize);
|
|
3426
3465
|
});
|
|
3427
3466
|
function handlePropertyResult(result, final, key, input2, optin, optout) {
|
|
3428
3467
|
const isPresent = key in input2;
|
|
@@ -4379,6 +4418,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
4379
4418
|
return Promise.all(proms).then(() => payload);
|
|
4380
4419
|
return payload;
|
|
4381
4420
|
};
|
|
4421
|
+
capSize(inst, mapSize);
|
|
4382
4422
|
});
|
|
4383
4423
|
function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
|
|
4384
4424
|
if (keyResult.issues.length) {
|
|
@@ -4445,6 +4485,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
|
4445
4485
|
return Promise.all(proms).then(() => payload);
|
|
4446
4486
|
return payload;
|
|
4447
4487
|
};
|
|
4488
|
+
capSize(inst, setSize);
|
|
4448
4489
|
});
|
|
4449
4490
|
function handleSetResult(result, final) {
|
|
4450
4491
|
if (result.issues.length) {
|
|
@@ -13969,9 +14010,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
13969
14010
|
doc.write(`}`);
|
|
13970
14011
|
return outputVar;
|
|
13971
14012
|
}
|
|
14013
|
+
function generateSizeGate(doc, schema, size) {
|
|
14014
|
+
for (const [max, check2] of sizeCaps(schema._zod.def.checks)) {
|
|
14015
|
+
doc.write(`if (${size} > ${numericOperand(max, check2._zod.def.check)}) return INVALID;`);
|
|
14016
|
+
}
|
|
14017
|
+
}
|
|
13972
14018
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
13973
14019
|
const def = schema._zod.def;
|
|
13974
14020
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
14021
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
13975
14022
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
13976
14023
|
const iVar = newVar(ctx);
|
|
13977
14024
|
const elemVar = newVar(ctx);
|
|
@@ -14371,6 +14418,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
14371
14418
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
14372
14419
|
const def = schema._zod.def;
|
|
14373
14420
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
14421
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
14374
14422
|
const outputVar = newVar(ctx);
|
|
14375
14423
|
const kVar = newVar(ctx);
|
|
14376
14424
|
const valVar = newVar(ctx);
|
|
@@ -14387,6 +14435,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
14387
14435
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
14388
14436
|
const def = schema._zod.def;
|
|
14389
14437
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
14438
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
14390
14439
|
const outputVar = newVar(ctx);
|
|
14391
14440
|
const valVar = newVar(ctx);
|
|
14392
14441
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -19694,13 +19743,28 @@ function date4(params) {
|
|
|
19694
19743
|
// src/core-access-config.ts
|
|
19695
19744
|
var TrustedProxiesSchema = external_exports.union([
|
|
19696
19745
|
external_exports.literal("auto"),
|
|
19697
|
-
external_exports.array(external_exports.union([
|
|
19746
|
+
external_exports.array(external_exports.union([
|
|
19747
|
+
external_exports.ipv4(),
|
|
19748
|
+
external_exports.ipv6(),
|
|
19749
|
+
external_exports.cidrv4(),
|
|
19750
|
+
external_exports.cidrv6()
|
|
19751
|
+
])).max(1e3)
|
|
19698
19752
|
]).describe("\u53EF\u4FE1\u4EE3\u7406 IP/CIDR\uFF1B\u9ED8\u8BA4 auto \u5728\u666E\u901A\u5BBF\u4E3B\u5FFD\u7565\u8F6C\u53D1\u5934\uFF0C\u4EC5\u53D7\u7BA1\u79C1\u6709 Compose \u91C7\u7528\u5BB9\u5668\u7F51\u6BB5");
|
|
19699
19753
|
var AccessConditionSchema = external_exports.strictObject({
|
|
19700
19754
|
/** 允许的 IPv4/IPv6 地址或 CIDR;非空时只允许匹配的可信客户端地址。 */
|
|
19701
|
-
allowIps: external_exports.array(external_exports.union([
|
|
19755
|
+
allowIps: external_exports.array(external_exports.union([
|
|
19756
|
+
external_exports.ipv4(),
|
|
19757
|
+
external_exports.ipv6(),
|
|
19758
|
+
external_exports.cidrv4(),
|
|
19759
|
+
external_exports.cidrv6()
|
|
19760
|
+
])).max(1e3).default([]).describe("\u5141\u8BB8\u7684 IPv4/IPv6 \u5730\u5740\u6216 CIDR\uFF1B\u7A7A\u6570\u7EC4\u4E0D\u9650\uFF0C\u6700\u591A 1000 \u9879"),
|
|
19702
19761
|
/** 拒绝的 IP/CIDR;与 allowIps 同时命中时拒绝优先。 */
|
|
19703
|
-
denyIps: external_exports.array(external_exports.union([
|
|
19762
|
+
denyIps: external_exports.array(external_exports.union([
|
|
19763
|
+
external_exports.ipv4(),
|
|
19764
|
+
external_exports.ipv6(),
|
|
19765
|
+
external_exports.cidrv4(),
|
|
19766
|
+
external_exports.cidrv6()
|
|
19767
|
+
])).max(1e3).default([]).describe("\u62D2\u7EDD\u7684 IP/CIDR\uFF1B\u62D2\u7EDD\u4F18\u5148\uFF0C\u7A7A\u6570\u7EC4\u4E0D\u9650\uFF0C\u6700\u591A 1000 \u9879"),
|
|
19704
19768
|
/** 时间窗口的 IANA 时区,默认 UTC;不使用客户端时钟。 */
|
|
19705
19769
|
timezone: external_exports.string().default("UTC").refine((value) => {
|
|
19706
19770
|
try {
|
|
@@ -19734,7 +19798,17 @@ var RequestAccessPolicySchema = external_exports.strictObject({
|
|
|
19734
19798
|
/** 完整请求路径;末尾 /** 同时匹配该路径及子路径,大小写敏感。 */
|
|
19735
19799
|
paths: external_exports.array(requestPathSchema).min(1).max(100).describe("\u5B8C\u6574\u8BF7\u6C42\u8DEF\u5F84\u5217\u8868\uFF0C\u5305\u542B\u90E8\u7F72\u524D\u7F00\uFF1B\u7CBE\u786E\u6216\u672B\u5C3E /**\uFF0C\u6700\u591A 100 \u9879"),
|
|
19736
19800
|
/** HTTP 方法,空数组表示所有方法;GET 不隐含 HEAD。 */
|
|
19737
|
-
methods: external_exports.array(external_exports.enum([
|
|
19801
|
+
methods: external_exports.array(external_exports.enum([
|
|
19802
|
+
"GET",
|
|
19803
|
+
"HEAD",
|
|
19804
|
+
"POST",
|
|
19805
|
+
"PUT",
|
|
19806
|
+
"PATCH",
|
|
19807
|
+
"DELETE",
|
|
19808
|
+
"OPTIONS",
|
|
19809
|
+
"CONNECT",
|
|
19810
|
+
"TRACE"
|
|
19811
|
+
])).max(9).default([]).describe("\u53D7\u8BE5\u89C4\u5219\u7EA6\u675F\u7684 HTTP \u65B9\u6CD5\uFF1B\u7A7A\u6570\u7EC4\u5168\u90E8\u65B9\u6CD5\uFF0CGET \u4E0D\u9690\u542B HEAD"),
|
|
19738
19812
|
/** 省略沿用宿主;required 强制应用层加密,disabled 要求普通明文请求,HTTPS 仍须启用。 */
|
|
19739
19813
|
encryption: external_exports.enum(["required", "disabled"]).optional().describe("\u8DEF\u5F84\u7684\u5E94\u7528\u5C42\u52A0\u89E3\u5BC6\u6A21\u5F0F\uFF1B\u7701\u7565\u6CBF\u7528\u5BBF\u4E3B\uFF0Crequired \u5F3A\u5236\u52A0\u5BC6\uFF0Cdisabled \u660E\u6587\uFF1B\u91CD\u53E0\u8DEF\u5F84\u548C\u65B9\u6CD5\u4E0D\u5F97\u51B2\u7A81")
|
|
19740
19814
|
})).max(1e3).default([]).describe("\u8DEF\u5F84\u8BBF\u95EE\u89C4\u5219\uFF0C\u6700\u591A 1000 \u6761\uFF1B\u5168\u5C40\u548C\u6240\u6709\u5339\u914D\u89C4\u5219\u90FD\u5FC5\u987B\u901A\u8FC7")
|
|
@@ -19749,8 +19823,20 @@ var RequestAccessConfigSchema = external_exports.union([
|
|
|
19749
19823
|
]).describe("\u6BCF\u6B21\u8BF7\u6C42\u7684\u8DEF\u5F84/IP/\u65F6\u95F4\u7B56\u7565\uFF1Bfalse \u5173\u95ED\uFF0C\u5185\u8054\u89C4\u5219\u4E0E\u72EC\u7ACB YAML \u6587\u4EF6\u5F15\u7528\u4E0D\u80FD\u6DF7\u7528");
|
|
19750
19824
|
|
|
19751
19825
|
// src/core-config.ts
|
|
19752
|
-
var EnvSchema = external_exports.enum([
|
|
19753
|
-
|
|
19826
|
+
var EnvSchema = external_exports.enum([
|
|
19827
|
+
"development",
|
|
19828
|
+
"production",
|
|
19829
|
+
"test",
|
|
19830
|
+
"staging"
|
|
19831
|
+
]);
|
|
19832
|
+
var LogLevelSchema = external_exports.enum([
|
|
19833
|
+
"trace",
|
|
19834
|
+
"debug",
|
|
19835
|
+
"info",
|
|
19836
|
+
"warn",
|
|
19837
|
+
"error",
|
|
19838
|
+
"fatal"
|
|
19839
|
+
]);
|
|
19754
19840
|
var LogFormatSchema = external_exports.enum(["json", "pretty"]);
|
|
19755
19841
|
var LoggingConfigSchema = external_exports.object({
|
|
19756
19842
|
/** 日志级别(默认 'info') */
|
|
@@ -19759,7 +19845,7 @@ var LoggingConfigSchema = external_exports.object({
|
|
|
19759
19845
|
format: LogFormatSchema.default("json"),
|
|
19760
19846
|
/** 默认上下文,会自动添加到每条日志 */
|
|
19761
19847
|
context: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
19762
|
-
/**
|
|
19848
|
+
/** 额外业务隐私的日志字段路径,如 customer.email、recipients[*].phone;* 匹配一层,区分大小写,默认 []。已知密码/令牌始终脱敏。 */
|
|
19763
19849
|
redact: external_exports.array(external_exports.string()).default([])
|
|
19764
19850
|
});
|
|
19765
19851
|
var CoreConfigSchema = external_exports.strictObject({
|
|
@@ -19829,6 +19915,7 @@ var en_US_default = {
|
|
|
19829
19915
|
core_configNotLoaded: "Config '{name}' is not loaded",
|
|
19830
19916
|
core_configUnsupportedInBrowser: "Browser does not support file-based config; use core.config on the server or pass browser options through core.init({ logging })",
|
|
19831
19917
|
core_cryptoRandomUnavailable: "Cryptographic random source is unavailable",
|
|
19918
|
+
core_parallelConcurrencyInvalid: "Concurrency must be a positive safe integer",
|
|
19832
19919
|
core_runtimeStartFailed: "Module {module} failed to start",
|
|
19833
19920
|
core_runtimeCloseFailed: "Module {module} failed to close; retry cleanup",
|
|
19834
19921
|
core_runtimeEnvMissing: "{message}: Required environment variables are not set: {fields}. Please set valid values in the current environment's .env files or process environment, then restart the application.",
|
|
@@ -19892,6 +19979,7 @@ var ja_JP_default = {
|
|
|
19892
19979
|
core_configNotLoaded: "\u8A2D\u5B9A\u300C{name}\u300D\u304C\u8AAD\u307F\u8FBC\u307E\u308C\u3066\u3044\u307E\u305B\u3093",
|
|
19893
19980
|
core_configUnsupportedInBrowser: "\u30D6\u30E9\u30A6\u30B6\u30FC\u306F\u30D5\u30A1\u30A4\u30EB\u30D9\u30FC\u30B9\u306E\u8A2D\u5B9A\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30B5\u30FC\u30D0\u30FC\u5074\u3067core.config\u3092\u4F7F\u7528\u3059\u308B\u304B\u3001core.init({ logging })\u3067\u30D6\u30E9\u30A6\u30B6\u30FC\u7528\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19894
19981
|
core_cryptoRandomUnavailable: "\u6697\u53F7\u5B66\u7684\u4E71\u6570\u306E\u751F\u6210\u5143\u3092\u5229\u7528\u3067\u304D\u307E\u305B\u3093",
|
|
19982
|
+
core_parallelConcurrencyInvalid: "\u4E26\u884C\u6570\u306F 0 \u3088\u308A\u5927\u304D\u3044\u5B89\u5168\u306A\u6574\u6570\u306B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19895
19983
|
core_runtimeStartFailed: "\u30E2\u30B8\u30E5\u30FC\u30EB {module} \u306E\u8D77\u52D5\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
19896
19984
|
core_runtimeCloseFailed: "\u30E2\u30B8\u30E5\u30FC\u30EB {module} \u306E\u7D42\u4E86\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u5F8C\u51E6\u7406\u3092\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19897
19985
|
core_runtimeEnvMissing: "{message}\uFF1A\u5FC5\u9808\u306E\u74B0\u5883\u5909\u6570\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF1A{fields}\u3002\u73FE\u5728\u306E\u74B0\u5883\u306E .env \u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30D7\u30ED\u30BB\u30B9\u74B0\u5883\u306B\u6709\u52B9\u306A\u5024\u3092\u8A2D\u5B9A\u3057\u3066\u3001\u30A2\u30D7\u30EA\u3092\u518D\u8D77\u52D5\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
@@ -19955,6 +20043,7 @@ var zh_CN_default2 = {
|
|
|
19955
20043
|
core_configNotLoaded: "\u914D\u7F6E '{name}' \u672A\u52A0\u8F7D",
|
|
19956
20044
|
core_configUnsupportedInBrowser: "\u6D4F\u89C8\u5668\u73AF\u5883\u4E0D\u652F\u6301\u6587\u4EF6\u914D\u7F6E\uFF0C\u8BF7\u5728\u670D\u52A1\u7AEF\u4F7F\u7528 core.config \u6216\u901A\u8FC7 core.init({ logging }) \u4F20\u5165\u6D4F\u89C8\u5668\u7AEF\u9009\u9879",
|
|
19957
20045
|
core_cryptoRandomUnavailable: "\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u7F3A\u5C11\u5BC6\u7801\u5B66\u5B89\u5168\u7684\u968F\u673A\u6E90",
|
|
20046
|
+
core_parallelConcurrencyInvalid: "\u5E76\u53D1\u6570\u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u5B89\u5168\u6574\u6570",
|
|
19958
20047
|
core_runtimeStartFailed: "\u6A21\u5757 {module} \u542F\u52A8\u5931\u8D25",
|
|
19959
20048
|
core_runtimeCloseFailed: "\u6A21\u5757 {module} \u5173\u95ED\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u6E05\u7406",
|
|
19960
20049
|
core_runtimeEnvMissing: "{message}\uFF1A\u672A\u8BBE\u7F6E\u5FC5\u9700\u7684\u73AF\u5883\u53D8\u91CF {fields}\u3002\u8BF7\u5728\u5F53\u524D\u73AF\u5883\u7684 .env \u6587\u4EF6\u6216\u8FDB\u7A0B\u73AF\u5883\u4E2D\u8BBE\u7F6E\u6709\u6548\u503C\u540E\u91CD\u65B0\u542F\u52A8\u5E94\u7528\u3002",
|
|
@@ -19993,7 +20082,9 @@ function setGlobalLocale(locale) {
|
|
|
19993
20082
|
function runWithLocale(locale, operation) {
|
|
19994
20083
|
if (!requestLocales)
|
|
19995
20084
|
throw new Error("Request locale context requires the Node.js entry");
|
|
19996
|
-
return requestLocales.run({
|
|
20085
|
+
return requestLocales.run({
|
|
20086
|
+
locale: normalizeLocale(locale)
|
|
20087
|
+
}, operation);
|
|
19997
20088
|
}
|
|
19998
20089
|
function createMessageGetter(messages) {
|
|
19999
20090
|
return (key, options) => {
|
|
@@ -20075,7 +20166,9 @@ var typeUtils = {
|
|
|
20075
20166
|
var CREDENTIAL_TEXT = /\b(?:Bearer|Basic)\s+[\w.~+/-]+=*|\b(?:[\w-]*[_-])?(?:password(?:[_-]?hash)?|passwd|passcode|secret(?:[_-]?key)?|token|session(?:[_-]?id)?|authorization|cookie|csrf|credential|captcha|reauthentication|ticket|api[_-]?key|private[_-]?key|(?:access|refresh|id|csrf)token|(?:otp|totp|verification|verify|captcha|sms|email|auth|one[_-]?time|two[_-]?factor)[_-]?code)(?:\\?["'])?\s*[:=]\s*(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\\"(?:[^\\]|\\\\\\\\|\\\\\\"|\\\\[^"\\])*\\"|[^\s,;&}\]]+)/gi;
|
|
20076
20167
|
function sanitizeText(text, secretValues = []) {
|
|
20077
20168
|
let result = text;
|
|
20078
|
-
for (const value of [
|
|
20169
|
+
for (const value of [
|
|
20170
|
+
...new Set(secretValues)
|
|
20171
|
+
].filter(Boolean).sort((a, b) => b.length - a.length))
|
|
20079
20172
|
result = result.replaceAll(value, "[REDACTED]");
|
|
20080
20173
|
return result.replace(/\b[a-z][a-z\d+.-]*:\/\/[^\s<>"']+/gi, (url2) => sanitizeUrl(url2)).replace(CREDENTIAL_TEXT, (match) => match.includes("[REDACTED") ? match : "[REDACTED]");
|
|
20081
20174
|
}
|
|
@@ -20165,7 +20258,10 @@ function sanitizeUrlWithContext(url2, context) {
|
|
|
20165
20258
|
}
|
|
20166
20259
|
}
|
|
20167
20260
|
function isProtectedPropertyKey(key) {
|
|
20168
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
20261
|
+
return key === "__proto__" || key === "constructor" || key === "prototype" || key === "toJSON";
|
|
20262
|
+
}
|
|
20263
|
+
function enumerableDataEntries(value) {
|
|
20264
|
+
return Object.entries(Object.getOwnPropertyDescriptors(value)).filter(([key, descriptor]) => descriptor.enumerable && "value" in descriptor && !isProtectedPropertyKey(key)).map(([key, descriptor]) => [key, descriptor.value]);
|
|
20169
20265
|
}
|
|
20170
20266
|
function createSanitizeSensitiveContext(options = {}) {
|
|
20171
20267
|
const replacement = options.replacement ?? DEFAULT_SENSITIVE_REPLACEMENT;
|
|
@@ -20188,13 +20284,20 @@ function sanitizeSensitiveValueWithContext(value, key, context, cache, errorPath
|
|
|
20188
20284
|
return isErrorDiagnostic ? sanitizeSensitiveValueWithContext(context.replacement, null, context, cache, errorPath ?? /* @__PURE__ */ new WeakSet(), errorDepth) : context.replacement;
|
|
20189
20285
|
}
|
|
20190
20286
|
}
|
|
20287
|
+
if (typeof value === "function" || typeof value === "symbol")
|
|
20288
|
+
return void 0;
|
|
20289
|
+
if (value instanceof Date) {
|
|
20290
|
+
const timestamp = Date.prototype.getTime.call(value);
|
|
20291
|
+
return Number.isFinite(timestamp) ? Date.prototype.toISOString.call(value) : null;
|
|
20292
|
+
}
|
|
20293
|
+
if (value instanceof URL)
|
|
20294
|
+
return sanitizeUrlWithContext(URL.prototype.toString.call(value), context);
|
|
20191
20295
|
if (isErrorDiagnostic) {
|
|
20192
20296
|
if (typeof value === "bigint")
|
|
20193
20297
|
return value.toString();
|
|
20194
|
-
if (
|
|
20195
|
-
return void 0;
|
|
20196
|
-
if (value === null || typeof value !== "object")
|
|
20298
|
+
if (value === null || typeof value !== "object") {
|
|
20197
20299
|
return typeof value === "string" ? sanitizeText(value) : value;
|
|
20300
|
+
}
|
|
20198
20301
|
const activePath = errorPath ?? /* @__PURE__ */ new WeakSet();
|
|
20199
20302
|
if (activePath.has(value))
|
|
20200
20303
|
return "[Circular]";
|
|
@@ -20203,9 +20306,13 @@ function sanitizeSensitiveValueWithContext(value, key, context, cache, errorPath
|
|
|
20203
20306
|
activePath.add(value);
|
|
20204
20307
|
try {
|
|
20205
20308
|
if (Array.isArray(value)) {
|
|
20206
|
-
return
|
|
20309
|
+
return Array.from({ length: value.length }, (_, index) => {
|
|
20310
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, index);
|
|
20311
|
+
const item = descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
20312
|
+
return sanitizeSensitiveValueWithContext(item, null, context, cache, activePath, errorDepth + 1);
|
|
20313
|
+
});
|
|
20207
20314
|
}
|
|
20208
|
-
const fields =
|
|
20315
|
+
const fields = Object.fromEntries(enumerableDataEntries(value));
|
|
20209
20316
|
if (errorValue) {
|
|
20210
20317
|
fields.name = errorValue.name;
|
|
20211
20318
|
fields.message = errorValue.message;
|
|
@@ -20233,21 +20340,20 @@ function sanitizeSensitiveValueWithContext(value, key, context, cache, errorPath
|
|
|
20233
20340
|
const sanitizedArray = [];
|
|
20234
20341
|
cache.set(value, sanitizedArray);
|
|
20235
20342
|
for (let index = 0; index < value.length; index++) {
|
|
20236
|
-
|
|
20343
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, index);
|
|
20344
|
+
const item = descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
20345
|
+
sanitizedArray[index] = sanitizeSensitiveValueWithContext(item, null, context, cache);
|
|
20237
20346
|
}
|
|
20238
20347
|
return sanitizedArray;
|
|
20239
20348
|
}
|
|
20240
|
-
if (
|
|
20349
|
+
if (value !== null && typeof value === "object") {
|
|
20241
20350
|
if (cache.has(value)) {
|
|
20242
20351
|
return cache.get(value);
|
|
20243
20352
|
}
|
|
20244
20353
|
const sanitized = {};
|
|
20245
20354
|
cache.set(value, sanitized);
|
|
20246
|
-
for (const childKey
|
|
20247
|
-
|
|
20248
|
-
continue;
|
|
20249
|
-
}
|
|
20250
|
-
sanitized[childKey] = sanitizeSensitiveValueWithContext(value[childKey], childKey, context, cache);
|
|
20355
|
+
for (const [childKey, childValue] of enumerableDataEntries(value)) {
|
|
20356
|
+
sanitized[childKey] = sanitizeSensitiveValueWithContext(childValue, childKey, context, cache);
|
|
20251
20357
|
}
|
|
20252
20358
|
return sanitized;
|
|
20253
20359
|
}
|
|
@@ -20432,18 +20538,24 @@ function toPublic(error63, traceId, locale) {
|
|
|
20432
20538
|
const context = requestContext.get();
|
|
20433
20539
|
const candidate = traceId ?? context.traceId ?? context.requestId ?? error63.traceId;
|
|
20434
20540
|
const safeTraceId = candidate && /^[\w.:-]{1,128}$/.test(candidate) ? candidate : id.uuid();
|
|
20541
|
+
const httpStatus = typeof error63.httpStatus === "number" && Number.isInteger(error63.httpStatus) && error63.httpStatus >= 400 && error63.httpStatus <= 599 ? error63.httpStatus : 500;
|
|
20435
20542
|
const result = {
|
|
20436
20543
|
code: error63.code,
|
|
20437
|
-
message:
|
|
20544
|
+
message: httpStatus >= 500 ? i18n.coreM("core_errorInternal", { locale }) : sanitize.sanitizeText(error63.message),
|
|
20438
20545
|
traceId: safeTraceId,
|
|
20439
|
-
|
|
20546
|
+
httpStatus,
|
|
20440
20547
|
...error63.system ? { system: error63.system } : {},
|
|
20441
20548
|
...error63.module ? { module: error63.module } : {}
|
|
20442
20549
|
};
|
|
20443
20550
|
if (error63.publicExt)
|
|
20444
20551
|
result.ext = sanitize.sanitizeSensitiveFields(error63.publicExt);
|
|
20445
|
-
if ((
|
|
20446
|
-
result.cause = error63.cause.flatMap((item) => item && typeof item === "object" && "field" in item && typeof item.field === "string" && "message" in item && typeof item.message === "string" ? [
|
|
20552
|
+
if ((httpStatus === 400 || httpStatus === 422) && Array.isArray(error63.cause)) {
|
|
20553
|
+
result.cause = error63.cause.flatMap((item) => item && typeof item === "object" && "field" in item && typeof item.field === "string" && "message" in item && typeof item.message === "string" ? [
|
|
20554
|
+
{
|
|
20555
|
+
field: item.field,
|
|
20556
|
+
message: sanitize.sanitizeText(item.message)
|
|
20557
|
+
}
|
|
20558
|
+
] : []);
|
|
20447
20559
|
}
|
|
20448
20560
|
result.message = formatMessage(result);
|
|
20449
20561
|
return result;
|
|
@@ -20525,6 +20637,7 @@ var CommonErrorInfo = {
|
|
|
20525
20637
|
VALIDATION_ERROR: "200:400",
|
|
20526
20638
|
INVALID_REQUEST: "201:400",
|
|
20527
20639
|
PARAMETER_MISSING: "202:400",
|
|
20640
|
+
RATE_LIMIT_EXCEEDED: "203:429",
|
|
20528
20641
|
// 300-399: 资源操作
|
|
20529
20642
|
NOT_FOUND: "300:404",
|
|
20530
20643
|
ALREADY_EXISTS: "301:409",
|
|
@@ -20565,7 +20678,10 @@ function emitLogRecord(record2) {
|
|
|
20565
20678
|
try {
|
|
20566
20679
|
for (const observer of observers) {
|
|
20567
20680
|
try {
|
|
20568
|
-
const result = observer({
|
|
20681
|
+
const result = observer({
|
|
20682
|
+
...record2,
|
|
20683
|
+
context: sanitize.sanitizeSensitiveFields(record2.context)
|
|
20684
|
+
});
|
|
20569
20685
|
if (result instanceof Promise)
|
|
20570
20686
|
void result.catch(() => {
|
|
20571
20687
|
});
|
|
@@ -20721,14 +20837,22 @@ var zodValidation = {
|
|
|
20721
20837
|
|
|
20722
20838
|
// src/utils/core-util-array.ts
|
|
20723
20839
|
function unique(arr) {
|
|
20724
|
-
return [
|
|
20840
|
+
return [
|
|
20841
|
+
...new Set(arr)
|
|
20842
|
+
];
|
|
20725
20843
|
}
|
|
20726
20844
|
function groupBy(arr, fn) {
|
|
20727
20845
|
const result = {};
|
|
20728
20846
|
for (const item of arr) {
|
|
20729
20847
|
const key = fn(item);
|
|
20730
|
-
if (!result
|
|
20731
|
-
result
|
|
20848
|
+
if (!Object.hasOwn(result, key)) {
|
|
20849
|
+
Object.defineProperty(result, key, {
|
|
20850
|
+
value: [],
|
|
20851
|
+
enumerable: true,
|
|
20852
|
+
writable: true,
|
|
20853
|
+
configurable: true
|
|
20854
|
+
});
|
|
20855
|
+
}
|
|
20732
20856
|
result[key].push(item);
|
|
20733
20857
|
}
|
|
20734
20858
|
return result;
|
|
@@ -20815,6 +20939,8 @@ async function retry(fn, options = {}) {
|
|
|
20815
20939
|
throw lastError;
|
|
20816
20940
|
}
|
|
20817
20941
|
async function parallel(items, fn, concurrency = 5) {
|
|
20942
|
+
if (!Number.isSafeInteger(concurrency) || concurrency <= 0)
|
|
20943
|
+
throw new RangeError(i18n.coreM("core_parallelConcurrencyInvalid"));
|
|
20818
20944
|
const results = [];
|
|
20819
20945
|
let index = 0;
|
|
20820
20946
|
async function worker() {
|
|
@@ -20824,7 +20950,9 @@ async function parallel(items, fn, concurrency = 5) {
|
|
|
20824
20950
|
}
|
|
20825
20951
|
}
|
|
20826
20952
|
const workers = Array.from(
|
|
20827
|
-
{
|
|
20953
|
+
{
|
|
20954
|
+
length: Math.min(concurrency, items.length)
|
|
20955
|
+
},
|
|
20828
20956
|
() => worker()
|
|
20829
20957
|
);
|
|
20830
20958
|
await Promise.all(workers);
|
|
@@ -20874,12 +21002,26 @@ function createNotInitializedKit(codeOrDef, messageFn) {
|
|
|
20874
21002
|
if (isHaiErrorDef(codeOrDef)) {
|
|
20875
21003
|
return error62.buildHaiErrorInst(codeOrDef, messageFn());
|
|
20876
21004
|
}
|
|
20877
|
-
return {
|
|
21005
|
+
return {
|
|
21006
|
+
code: codeOrDef,
|
|
21007
|
+
message: messageFn()
|
|
21008
|
+
};
|
|
20878
21009
|
};
|
|
20879
|
-
const result = () => ({
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
21010
|
+
const result = () => ({
|
|
21011
|
+
success: false,
|
|
21012
|
+
error: error63()
|
|
21013
|
+
});
|
|
21014
|
+
const asyncOp = async () => ({
|
|
21015
|
+
success: false,
|
|
21016
|
+
error: error63()
|
|
21017
|
+
});
|
|
21018
|
+
const syncOp = () => ({
|
|
21019
|
+
success: false,
|
|
21020
|
+
error: error63()
|
|
21021
|
+
});
|
|
21022
|
+
const proxy = (mode = "async") => new Proxy({}, {
|
|
21023
|
+
get: () => mode === "sync" ? syncOp : asyncOp
|
|
21024
|
+
});
|
|
20883
21025
|
return { error: error63, result, proxy };
|
|
20884
21026
|
}
|
|
20885
21027
|
function requiresSharedState(environment) {
|
|
@@ -20887,6 +21029,12 @@ function requiresSharedState(environment) {
|
|
|
20887
21029
|
}
|
|
20888
21030
|
|
|
20889
21031
|
// src/utils/core-util-object.ts
|
|
21032
|
+
function isPlainRecord2(value) {
|
|
21033
|
+
if (!typeUtils.isObject(value))
|
|
21034
|
+
return false;
|
|
21035
|
+
const prototype = Object.getPrototypeOf(value);
|
|
21036
|
+
return prototype === Object.prototype || prototype === null;
|
|
21037
|
+
}
|
|
20890
21038
|
function deepClone(obj) {
|
|
20891
21039
|
return structuredClone(obj);
|
|
20892
21040
|
}
|
|
@@ -20899,7 +21047,7 @@ function deepMerge(...objects) {
|
|
|
20899
21047
|
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
20900
21048
|
continue;
|
|
20901
21049
|
const val = obj[key];
|
|
20902
|
-
if (
|
|
21050
|
+
if (isPlainRecord2(val) && isPlainRecord2(result[key])) {
|
|
20903
21051
|
result[key] = deepMerge(
|
|
20904
21052
|
result[key],
|
|
20905
21053
|
val
|
|
@@ -20966,17 +21114,42 @@ function failure2(module, phase, detail) {
|
|
|
20966
21114
|
}
|
|
20967
21115
|
}
|
|
20968
21116
|
const code = detail && typeof detail === "object" && "code" in detail && (typeof detail.code === "number" || typeof detail.code === "string") ? detail.code : void 0;
|
|
20969
|
-
const uniqueFields = [
|
|
20970
|
-
|
|
21117
|
+
const uniqueFields = [
|
|
21118
|
+
...new Set(fields)
|
|
21119
|
+
];
|
|
21120
|
+
let message = i18n.coreM(phase === "start" ? "core_runtimeStartFailed" : "core_runtimeCloseFailed", {
|
|
21121
|
+
params: { module }
|
|
21122
|
+
});
|
|
20971
21123
|
if (phase === "start" && uniqueFields.length) {
|
|
20972
21124
|
const configMessage = code === HaiConfigError.CONFIG_ENV_VAR_MISSING.code ? "core_runtimeEnvMissing" : code === HaiConfigError.CONFIG_VALIDATION_ERROR.code || detail && typeof detail === "object" && "issues" in detail && Array.isArray(detail.issues) ? "core_runtimeConfigInvalid" : "core_runtimeConfigProblem";
|
|
20973
|
-
message = i18n.coreM(configMessage, {
|
|
21125
|
+
message = i18n.coreM(configMessage, {
|
|
21126
|
+
params: {
|
|
21127
|
+
message,
|
|
21128
|
+
fields: uniqueFields.join(", ")
|
|
21129
|
+
}
|
|
21130
|
+
});
|
|
20974
21131
|
}
|
|
20975
21132
|
const diagnostics = [
|
|
20976
|
-
...code !== void 0 ? [
|
|
21133
|
+
...code !== void 0 ? [
|
|
21134
|
+
i18n.coreM("core_runtimeErrorCode", {
|
|
21135
|
+
params: { code }
|
|
21136
|
+
})
|
|
21137
|
+
] : [],
|
|
20977
21138
|
...phase === "close" ? uniqueFields : []
|
|
20978
21139
|
].join(", ");
|
|
20979
|
-
return {
|
|
21140
|
+
return {
|
|
21141
|
+
success: false,
|
|
21142
|
+
error: {
|
|
21143
|
+
...HaiCommonError.INIT_FAILED,
|
|
21144
|
+
message: diagnostics ? `${message} (${diagnostics})` : message,
|
|
21145
|
+
ext: {
|
|
21146
|
+
module,
|
|
21147
|
+
phase,
|
|
21148
|
+
...code !== void 0 ? { code } : {},
|
|
21149
|
+
...uniqueFields.length ? { fields: uniqueFields } : {}
|
|
21150
|
+
}
|
|
21151
|
+
}
|
|
21152
|
+
};
|
|
20980
21153
|
}
|
|
20981
21154
|
function createRuntime(definitions) {
|
|
20982
21155
|
const steps = definitions.map((step) => ({ ...step }));
|
|
@@ -21127,20 +21300,50 @@ function timeAgo(date5) {
|
|
|
21127
21300
|
const seconds = Math.floor((Date.now() - date5.getTime()) / 1e3);
|
|
21128
21301
|
if (seconds < 5)
|
|
21129
21302
|
return i18n.coreM("core_timeJustNow");
|
|
21130
|
-
if (seconds < 60)
|
|
21131
|
-
return i18n.coreM("core_timeSecondsAgo", {
|
|
21132
|
-
|
|
21133
|
-
|
|
21134
|
-
|
|
21135
|
-
|
|
21303
|
+
if (seconds < 60) {
|
|
21304
|
+
return i18n.coreM("core_timeSecondsAgo", {
|
|
21305
|
+
params: { n: seconds }
|
|
21306
|
+
});
|
|
21307
|
+
}
|
|
21308
|
+
if (seconds < 3600) {
|
|
21309
|
+
return i18n.coreM("core_timeMinutesAgo", {
|
|
21310
|
+
params: {
|
|
21311
|
+
n: Math.floor(seconds / 60)
|
|
21312
|
+
}
|
|
21313
|
+
});
|
|
21314
|
+
}
|
|
21315
|
+
if (seconds < 86400) {
|
|
21316
|
+
return i18n.coreM("core_timeHoursAgo", {
|
|
21317
|
+
params: {
|
|
21318
|
+
n: Math.floor(seconds / 3600)
|
|
21319
|
+
}
|
|
21320
|
+
});
|
|
21321
|
+
}
|
|
21136
21322
|
const days = Math.floor(seconds / 86400);
|
|
21137
|
-
if (days < 7)
|
|
21138
|
-
return i18n.coreM("core_timeDaysAgo", {
|
|
21139
|
-
|
|
21140
|
-
|
|
21141
|
-
|
|
21142
|
-
|
|
21143
|
-
|
|
21323
|
+
if (days < 7) {
|
|
21324
|
+
return i18n.coreM("core_timeDaysAgo", {
|
|
21325
|
+
params: { n: days }
|
|
21326
|
+
});
|
|
21327
|
+
}
|
|
21328
|
+
if (days < 30) {
|
|
21329
|
+
return i18n.coreM("core_timeWeeksAgo", {
|
|
21330
|
+
params: {
|
|
21331
|
+
n: Math.floor(days / 7)
|
|
21332
|
+
}
|
|
21333
|
+
});
|
|
21334
|
+
}
|
|
21335
|
+
if (days < 365) {
|
|
21336
|
+
return i18n.coreM("core_timeMonthsAgo", {
|
|
21337
|
+
params: {
|
|
21338
|
+
n: Math.floor(days / 30)
|
|
21339
|
+
}
|
|
21340
|
+
});
|
|
21341
|
+
}
|
|
21342
|
+
return i18n.coreM("core_timeYearsAgo", {
|
|
21343
|
+
params: {
|
|
21344
|
+
n: Math.floor(days / 365)
|
|
21345
|
+
}
|
|
21346
|
+
});
|
|
21144
21347
|
}
|
|
21145
21348
|
function now() {
|
|
21146
21349
|
return Date.now();
|
|
@@ -21380,6 +21583,6 @@ function createCore(loggerFns) {
|
|
|
21380
21583
|
};
|
|
21381
21584
|
}
|
|
21382
21585
|
|
|
21383
|
-
export { AccessConditionSchema, CoreConfigSchema, EnvSchema, HaiCommonError, HaiConfigError, LogFormatSchema, LogLevelSchema, LoggingConfigSchema, RequestAccessConfigSchema, RequestAccessPolicySchema, TrustedProxiesSchema, __commonJS, __toESM, createCore, emitLogRecord, err, i18n, installRequestContext, installRequestLocales, ok, requestContext, sanitize, sanitizeLogFields
|
|
21384
|
-
//# sourceMappingURL=chunk-
|
|
21385
|
-
//# sourceMappingURL=chunk-
|
|
21586
|
+
export { AccessConditionSchema, CoreConfigSchema, EnvSchema, HaiCommonError, HaiConfigError, LogFormatSchema, LogLevelSchema, LoggingConfigSchema, RequestAccessConfigSchema, RequestAccessPolicySchema, TrustedProxiesSchema, __commonJS, __toESM, createCore, emitLogRecord, err, i18n, installRequestContext, installRequestLocales, ok, requestContext, sanitize, sanitizeLogFields };
|
|
21587
|
+
//# sourceMappingURL=chunk-WU6HUTBO.js.map
|
|
21588
|
+
//# sourceMappingURL=chunk-WU6HUTBO.js.map
|