@h-ai/core 1.0.0-beta.18 → 1.0.0-beta.19
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 +85 -19
- package/README.ja.md +85 -19
- package/README.md +85 -19
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +39 -11
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-MYNB4HIZ.js → chunk-WU6HUTBO.js} +224 -44
- package/dist/chunk-WU6HUTBO.js.map +1 -0
- package/dist/{core-types-n2KjBtto.d.ts → core-types-Dp3Vr2uI.d.ts} +7 -4
- package/dist/node.d.ts +2 -2
- package/dist/node.js +195 -49
- package/dist/node.js.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-MYNB4HIZ.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') */
|
|
@@ -19996,7 +20082,9 @@ function setGlobalLocale(locale) {
|
|
|
19996
20082
|
function runWithLocale(locale, operation) {
|
|
19997
20083
|
if (!requestLocales)
|
|
19998
20084
|
throw new Error("Request locale context requires the Node.js entry");
|
|
19999
|
-
return requestLocales.run({
|
|
20085
|
+
return requestLocales.run({
|
|
20086
|
+
locale: normalizeLocale(locale)
|
|
20087
|
+
}, operation);
|
|
20000
20088
|
}
|
|
20001
20089
|
function createMessageGetter(messages) {
|
|
20002
20090
|
return (key, options) => {
|
|
@@ -20078,7 +20166,9 @@ var typeUtils = {
|
|
|
20078
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;
|
|
20079
20167
|
function sanitizeText(text, secretValues = []) {
|
|
20080
20168
|
let result = text;
|
|
20081
|
-
for (const value of [
|
|
20169
|
+
for (const value of [
|
|
20170
|
+
...new Set(secretValues)
|
|
20171
|
+
].filter(Boolean).sort((a, b) => b.length - a.length))
|
|
20082
20172
|
result = result.replaceAll(value, "[REDACTED]");
|
|
20083
20173
|
return result.replace(/\b[a-z][a-z\d+.-]*:\/\/[^\s<>"']+/gi, (url2) => sanitizeUrl(url2)).replace(CREDENTIAL_TEXT, (match) => match.includes("[REDACTED") ? match : "[REDACTED]");
|
|
20084
20174
|
}
|
|
@@ -20205,8 +20295,9 @@ function sanitizeSensitiveValueWithContext(value, key, context, cache, errorPath
|
|
|
20205
20295
|
if (isErrorDiagnostic) {
|
|
20206
20296
|
if (typeof value === "bigint")
|
|
20207
20297
|
return value.toString();
|
|
20208
|
-
if (value === null || typeof value !== "object")
|
|
20298
|
+
if (value === null || typeof value !== "object") {
|
|
20209
20299
|
return typeof value === "string" ? sanitizeText(value) : value;
|
|
20300
|
+
}
|
|
20210
20301
|
const activePath = errorPath ?? /* @__PURE__ */ new WeakSet();
|
|
20211
20302
|
if (activePath.has(value))
|
|
20212
20303
|
return "[Circular]";
|
|
@@ -20447,18 +20538,24 @@ function toPublic(error63, traceId, locale) {
|
|
|
20447
20538
|
const context = requestContext.get();
|
|
20448
20539
|
const candidate = traceId ?? context.traceId ?? context.requestId ?? error63.traceId;
|
|
20449
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;
|
|
20450
20542
|
const result = {
|
|
20451
20543
|
code: error63.code,
|
|
20452
|
-
message:
|
|
20544
|
+
message: httpStatus >= 500 ? i18n.coreM("core_errorInternal", { locale }) : sanitize.sanitizeText(error63.message),
|
|
20453
20545
|
traceId: safeTraceId,
|
|
20454
|
-
|
|
20546
|
+
httpStatus,
|
|
20455
20547
|
...error63.system ? { system: error63.system } : {},
|
|
20456
20548
|
...error63.module ? { module: error63.module } : {}
|
|
20457
20549
|
};
|
|
20458
20550
|
if (error63.publicExt)
|
|
20459
20551
|
result.ext = sanitize.sanitizeSensitiveFields(error63.publicExt);
|
|
20460
|
-
if ((
|
|
20461
|
-
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
|
+
] : []);
|
|
20462
20559
|
}
|
|
20463
20560
|
result.message = formatMessage(result);
|
|
20464
20561
|
return result;
|
|
@@ -20540,6 +20637,7 @@ var CommonErrorInfo = {
|
|
|
20540
20637
|
VALIDATION_ERROR: "200:400",
|
|
20541
20638
|
INVALID_REQUEST: "201:400",
|
|
20542
20639
|
PARAMETER_MISSING: "202:400",
|
|
20640
|
+
RATE_LIMIT_EXCEEDED: "203:429",
|
|
20543
20641
|
// 300-399: 资源操作
|
|
20544
20642
|
NOT_FOUND: "300:404",
|
|
20545
20643
|
ALREADY_EXISTS: "301:409",
|
|
@@ -20580,7 +20678,10 @@ function emitLogRecord(record2) {
|
|
|
20580
20678
|
try {
|
|
20581
20679
|
for (const observer of observers) {
|
|
20582
20680
|
try {
|
|
20583
|
-
const result = observer({
|
|
20681
|
+
const result = observer({
|
|
20682
|
+
...record2,
|
|
20683
|
+
context: sanitize.sanitizeSensitiveFields(record2.context)
|
|
20684
|
+
});
|
|
20584
20685
|
if (result instanceof Promise)
|
|
20585
20686
|
void result.catch(() => {
|
|
20586
20687
|
});
|
|
@@ -20736,14 +20837,22 @@ var zodValidation = {
|
|
|
20736
20837
|
|
|
20737
20838
|
// src/utils/core-util-array.ts
|
|
20738
20839
|
function unique(arr) {
|
|
20739
|
-
return [
|
|
20840
|
+
return [
|
|
20841
|
+
...new Set(arr)
|
|
20842
|
+
];
|
|
20740
20843
|
}
|
|
20741
20844
|
function groupBy(arr, fn) {
|
|
20742
20845
|
const result = {};
|
|
20743
20846
|
for (const item of arr) {
|
|
20744
20847
|
const key = fn(item);
|
|
20745
|
-
if (!Object.hasOwn(result, key))
|
|
20746
|
-
Object.defineProperty(result, key, {
|
|
20848
|
+
if (!Object.hasOwn(result, key)) {
|
|
20849
|
+
Object.defineProperty(result, key, {
|
|
20850
|
+
value: [],
|
|
20851
|
+
enumerable: true,
|
|
20852
|
+
writable: true,
|
|
20853
|
+
configurable: true
|
|
20854
|
+
});
|
|
20855
|
+
}
|
|
20747
20856
|
result[key].push(item);
|
|
20748
20857
|
}
|
|
20749
20858
|
return result;
|
|
@@ -20841,7 +20950,9 @@ async function parallel(items, fn, concurrency = 5) {
|
|
|
20841
20950
|
}
|
|
20842
20951
|
}
|
|
20843
20952
|
const workers = Array.from(
|
|
20844
|
-
{
|
|
20953
|
+
{
|
|
20954
|
+
length: Math.min(concurrency, items.length)
|
|
20955
|
+
},
|
|
20845
20956
|
() => worker()
|
|
20846
20957
|
);
|
|
20847
20958
|
await Promise.all(workers);
|
|
@@ -20891,12 +21002,26 @@ function createNotInitializedKit(codeOrDef, messageFn) {
|
|
|
20891
21002
|
if (isHaiErrorDef(codeOrDef)) {
|
|
20892
21003
|
return error62.buildHaiErrorInst(codeOrDef, messageFn());
|
|
20893
21004
|
}
|
|
20894
|
-
return {
|
|
21005
|
+
return {
|
|
21006
|
+
code: codeOrDef,
|
|
21007
|
+
message: messageFn()
|
|
21008
|
+
};
|
|
20895
21009
|
};
|
|
20896
|
-
const result = () => ({
|
|
20897
|
-
|
|
20898
|
-
|
|
20899
|
-
|
|
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
|
+
});
|
|
20900
21025
|
return { error: error63, result, proxy };
|
|
20901
21026
|
}
|
|
20902
21027
|
function requiresSharedState(environment) {
|
|
@@ -20989,17 +21114,42 @@ function failure2(module, phase, detail) {
|
|
|
20989
21114
|
}
|
|
20990
21115
|
}
|
|
20991
21116
|
const code = detail && typeof detail === "object" && "code" in detail && (typeof detail.code === "number" || typeof detail.code === "string") ? detail.code : void 0;
|
|
20992
|
-
const uniqueFields = [
|
|
20993
|
-
|
|
21117
|
+
const uniqueFields = [
|
|
21118
|
+
...new Set(fields)
|
|
21119
|
+
];
|
|
21120
|
+
let message = i18n.coreM(phase === "start" ? "core_runtimeStartFailed" : "core_runtimeCloseFailed", {
|
|
21121
|
+
params: { module }
|
|
21122
|
+
});
|
|
20994
21123
|
if (phase === "start" && uniqueFields.length) {
|
|
20995
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";
|
|
20996
|
-
message = i18n.coreM(configMessage, {
|
|
21125
|
+
message = i18n.coreM(configMessage, {
|
|
21126
|
+
params: {
|
|
21127
|
+
message,
|
|
21128
|
+
fields: uniqueFields.join(", ")
|
|
21129
|
+
}
|
|
21130
|
+
});
|
|
20997
21131
|
}
|
|
20998
21132
|
const diagnostics = [
|
|
20999
|
-
...code !== void 0 ? [
|
|
21133
|
+
...code !== void 0 ? [
|
|
21134
|
+
i18n.coreM("core_runtimeErrorCode", {
|
|
21135
|
+
params: { code }
|
|
21136
|
+
})
|
|
21137
|
+
] : [],
|
|
21000
21138
|
...phase === "close" ? uniqueFields : []
|
|
21001
21139
|
].join(", ");
|
|
21002
|
-
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
|
+
};
|
|
21003
21153
|
}
|
|
21004
21154
|
function createRuntime(definitions) {
|
|
21005
21155
|
const steps = definitions.map((step) => ({ ...step }));
|
|
@@ -21150,20 +21300,50 @@ function timeAgo(date5) {
|
|
|
21150
21300
|
const seconds = Math.floor((Date.now() - date5.getTime()) / 1e3);
|
|
21151
21301
|
if (seconds < 5)
|
|
21152
21302
|
return i18n.coreM("core_timeJustNow");
|
|
21153
|
-
if (seconds < 60)
|
|
21154
|
-
return i18n.coreM("core_timeSecondsAgo", {
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
|
|
21158
|
-
|
|
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
|
+
}
|
|
21159
21322
|
const days = Math.floor(seconds / 86400);
|
|
21160
|
-
if (days < 7)
|
|
21161
|
-
return i18n.coreM("core_timeDaysAgo", {
|
|
21162
|
-
|
|
21163
|
-
|
|
21164
|
-
|
|
21165
|
-
|
|
21166
|
-
|
|
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
|
+
});
|
|
21167
21347
|
}
|
|
21168
21348
|
function now() {
|
|
21169
21349
|
return Date.now();
|
|
@@ -21404,5 +21584,5 @@ function createCore(loggerFns) {
|
|
|
21404
21584
|
}
|
|
21405
21585
|
|
|
21406
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 };
|
|
21407
|
-
//# sourceMappingURL=chunk-
|
|
21408
|
-
//# sourceMappingURL=chunk-
|
|
21587
|
+
//# sourceMappingURL=chunk-WU6HUTBO.js.map
|
|
21588
|
+
//# sourceMappingURL=chunk-WU6HUTBO.js.map
|