@h-ai/core 0.1.0-alpha.67 → 0.1.0-alpha.69
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 +55 -8
- package/README.ja.md +55 -8
- package/README.md +55 -8
- package/dist/browser.d.ts +9 -5
- package/dist/browser.js +21 -9
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-RXNSRXYF.js → chunk-MUQFCAQ5.js} +552 -354
- package/dist/{chunk-RXNSRXYF.js.map → chunk-MUQFCAQ5.js.map} +1 -1
- package/dist/{core-function-config.node-7KVlEiFk.d.ts → core-function-config.node-CGXWsohk.d.ts} +568 -175
- package/dist/node.d.ts +23 -7
- package/dist/node.js +41 -12
- package/dist/node.js.map +1 -1
- package/package.json +6 -3
|
@@ -19705,25 +19705,15 @@ var LoggingConfigSchema = external_exports.object({
|
|
|
19705
19705
|
/** 要脱敏的字段路径列表(如 ['password', 'token'],默认 []) */
|
|
19706
19706
|
redact: external_exports.array(external_exports.string()).default([])
|
|
19707
19707
|
});
|
|
19708
|
-
var
|
|
19709
|
-
/** ID 前缀(可选,生成时自动拼接) */
|
|
19710
|
-
prefix: external_exports.string().optional(),
|
|
19711
|
-
/** ID 长度(范围 6-64,默认 21) */
|
|
19712
|
-
length: external_exports.number().int().min(6).max(64).default(21)
|
|
19713
|
-
});
|
|
19714
|
-
var CoreConfigSchema = external_exports.object({
|
|
19708
|
+
var CoreConfigSchema = external_exports.strictObject({
|
|
19715
19709
|
/** 应用名称(默认 'hai Admin') */
|
|
19716
19710
|
name: external_exports.string().default("hai Admin"),
|
|
19717
19711
|
/** 应用版本(默认 '0.1.0') */
|
|
19718
19712
|
version: external_exports.string().default("0.1.0"),
|
|
19719
19713
|
/** 运行环境(默认 'development') */
|
|
19720
19714
|
env: EnvSchema.default("development"),
|
|
19721
|
-
/** 是否调试模式(默认 false) */
|
|
19722
|
-
debug: external_exports.boolean().default(false),
|
|
19723
19715
|
/** 日志配置(可选) */
|
|
19724
19716
|
logging: LoggingConfigSchema.optional(),
|
|
19725
|
-
/** ID 生成器配置(可选) */
|
|
19726
|
-
id: IdConfigSchema.optional(),
|
|
19727
19717
|
/** 默认语言(默认 'zh-CN') */
|
|
19728
19718
|
defaultLocale: external_exports.string().default("zh-CN")
|
|
19729
19719
|
});
|
|
@@ -19826,21 +19816,283 @@ var ConfigErrorInfo = {
|
|
|
19826
19816
|
CONFIG_NOT_LOADED: "014:500"
|
|
19827
19817
|
};
|
|
19828
19818
|
var HaiConfigError = error62.buildHaiErrorsDef("core", ConfigErrorInfo);
|
|
19819
|
+
|
|
19820
|
+
// src/functions/core-function-context.ts
|
|
19821
|
+
var storage;
|
|
19822
|
+
var synchronousContext = Object.freeze({});
|
|
19823
|
+
function installRequestContext(value) {
|
|
19824
|
+
storage = value;
|
|
19825
|
+
}
|
|
19826
|
+
var requestContext = {
|
|
19827
|
+
get() {
|
|
19828
|
+
return storage?.getStore() ?? synchronousContext;
|
|
19829
|
+
},
|
|
19830
|
+
run(value, operation) {
|
|
19831
|
+
const previousValue = requestContext.get();
|
|
19832
|
+
const merged = Object.freeze({
|
|
19833
|
+
requestId: Object.hasOwn(value, "requestId") ? value.requestId : previousValue.requestId,
|
|
19834
|
+
scopeId: Object.hasOwn(value, "scopeId") ? value.scopeId : previousValue.scopeId,
|
|
19835
|
+
userId: Object.hasOwn(value, "userId") ? value.userId : previousValue.userId,
|
|
19836
|
+
jobId: Object.hasOwn(value, "jobId") ? value.jobId : previousValue.jobId,
|
|
19837
|
+
suppressLogObservers: Object.hasOwn(value, "suppressLogObservers") ? value.suppressLogObservers : previousValue.suppressLogObservers
|
|
19838
|
+
});
|
|
19839
|
+
if (storage)
|
|
19840
|
+
return storage.run(merged, operation);
|
|
19841
|
+
const previous = synchronousContext;
|
|
19842
|
+
synchronousContext = merged;
|
|
19843
|
+
try {
|
|
19844
|
+
return operation();
|
|
19845
|
+
} finally {
|
|
19846
|
+
synchronousContext = previous;
|
|
19847
|
+
}
|
|
19848
|
+
}
|
|
19849
|
+
};
|
|
19850
|
+
|
|
19851
|
+
// messages/en-US.json
|
|
19852
|
+
var en_US_default = {
|
|
19853
|
+
$schema: "https://inlang.com/schema/inlang-message-format",
|
|
19854
|
+
core_errorUnknown: "Unknown error",
|
|
19855
|
+
core_errorNetwork: "Network error",
|
|
19856
|
+
core_errorTimeout: "Request timeout",
|
|
19857
|
+
core_errorNotFound: "Resource not found",
|
|
19858
|
+
core_errorUnauthorized: "Unauthorized",
|
|
19859
|
+
core_errorForbidden: "Forbidden",
|
|
19860
|
+
core_errorValidation: "Validation failed",
|
|
19861
|
+
core_errorInternal: "Internal error",
|
|
19862
|
+
core_actionConfirm: "Confirm",
|
|
19863
|
+
core_actionCancel: "Cancel",
|
|
19864
|
+
core_actionSave: "Save",
|
|
19865
|
+
core_actionDelete: "Delete",
|
|
19866
|
+
core_actionEdit: "Edit",
|
|
19867
|
+
core_actionCreate: "Create",
|
|
19868
|
+
core_actionUpdate: "Update",
|
|
19869
|
+
core_actionSearch: "Search",
|
|
19870
|
+
core_actionReset: "Reset",
|
|
19871
|
+
core_actionSubmit: "Submit",
|
|
19872
|
+
core_actionLoading: "Loading...",
|
|
19873
|
+
core_actionRetry: "Retry",
|
|
19874
|
+
core_statusSuccess: "Success",
|
|
19875
|
+
core_statusFailed: "Failed",
|
|
19876
|
+
core_statusPending: "Pending",
|
|
19877
|
+
core_statusProcessing: "Processing",
|
|
19878
|
+
core_statusCompleted: "Completed",
|
|
19879
|
+
core_statusCancelled: "Cancelled",
|
|
19880
|
+
core_validationRequired: "{field} is required",
|
|
19881
|
+
core_validationMinLength: "{field} must be at least {min} characters",
|
|
19882
|
+
core_validationMaxLength: "{field} must not exceed {max} characters",
|
|
19883
|
+
core_validationEmail: "Please enter a valid email address",
|
|
19884
|
+
core_validationUrl: "Please enter a valid URL",
|
|
19885
|
+
core_validationNumber: "Please enter a valid number",
|
|
19886
|
+
core_validationInteger: "Please enter an integer",
|
|
19887
|
+
core_validationPositive: "Please enter a positive number",
|
|
19888
|
+
core_validationPattern: "{field} format is invalid",
|
|
19889
|
+
core_timeJustNow: "Just now",
|
|
19890
|
+
core_timeSecondsAgo: "{n} seconds ago",
|
|
19891
|
+
core_timeMinutesAgo: "{n} minutes ago",
|
|
19892
|
+
core_timeHoursAgo: "{n} hours ago",
|
|
19893
|
+
core_timeDaysAgo: "{n} days ago",
|
|
19894
|
+
core_timeWeeksAgo: "{n} weeks ago",
|
|
19895
|
+
core_timeMonthsAgo: "{n} months ago",
|
|
19896
|
+
core_timeYearsAgo: "{n} years ago",
|
|
19897
|
+
core_browserFeatureUnsupported: "Browser does not support {feature}.",
|
|
19898
|
+
core_configEnvVarMissing: "Environment variable '{varName}' is not set and has no default value",
|
|
19899
|
+
core_configFileNotExist: "Config file does not exist: {filePath}",
|
|
19900
|
+
core_configParseFailed: "Failed to parse config file: {filePath}",
|
|
19901
|
+
core_configValidationFailed: "Config validation failed",
|
|
19902
|
+
core_configNotLoaded: "Config '{name}' is not loaded",
|
|
19903
|
+
core_configUnsupportedInBrowser: "Browser does not support file-based config; use core.config on the server or pass browser options through core.init({ logging })",
|
|
19904
|
+
core_cryptoRandomUnavailable: "Cryptographic random source is unavailable"
|
|
19905
|
+
};
|
|
19906
|
+
|
|
19907
|
+
// messages/ja-JP.json
|
|
19908
|
+
var ja_JP_default = {
|
|
19909
|
+
$schema: "https://inlang.com/schema/inlang-message-format",
|
|
19910
|
+
core_errorUnknown: "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC",
|
|
19911
|
+
core_errorNetwork: "\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u30A8\u30E9\u30FC",
|
|
19912
|
+
core_errorTimeout: "\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F",
|
|
19913
|
+
core_errorNotFound: "\u30EA\u30BD\u30FC\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
|
|
19914
|
+
core_errorUnauthorized: "\u8A8D\u8A3C\u3055\u308C\u3066\u3044\u307E\u305B\u3093",
|
|
19915
|
+
core_errorForbidden: "\u30A2\u30AF\u30BB\u30B9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F",
|
|
19916
|
+
core_errorValidation: "\u5165\u529B\u5185\u5BB9\u306E\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
19917
|
+
core_errorInternal: "\u5185\u90E8\u30A8\u30E9\u30FC",
|
|
19918
|
+
core_actionConfirm: "\u78BA\u8A8D",
|
|
19919
|
+
core_actionCancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
|
|
19920
|
+
core_actionSave: "\u4FDD\u5B58",
|
|
19921
|
+
core_actionDelete: "\u524A\u9664",
|
|
19922
|
+
core_actionEdit: "\u7DE8\u96C6",
|
|
19923
|
+
core_actionCreate: "\u4F5C\u6210",
|
|
19924
|
+
core_actionUpdate: "\u66F4\u65B0",
|
|
19925
|
+
core_actionSearch: "\u691C\u7D22",
|
|
19926
|
+
core_actionReset: "\u30EA\u30BB\u30C3\u30C8",
|
|
19927
|
+
core_actionSubmit: "\u9001\u4FE1",
|
|
19928
|
+
core_actionLoading: "\u8AAD\u307F\u8FBC\u307F\u4E2D...",
|
|
19929
|
+
core_actionRetry: "\u518D\u8A66\u884C",
|
|
19930
|
+
core_statusSuccess: "\u6210\u529F",
|
|
19931
|
+
core_statusFailed: "\u5931\u6557",
|
|
19932
|
+
core_statusPending: "\u4FDD\u7559\u4E2D",
|
|
19933
|
+
core_statusProcessing: "\u51E6\u7406\u4E2D",
|
|
19934
|
+
core_statusCompleted: "\u5B8C\u4E86",
|
|
19935
|
+
core_statusCancelled: "\u30AD\u30E3\u30F3\u30BB\u30EB\u6E08\u307F",
|
|
19936
|
+
core_validationRequired: "{field}\u306F\u5FC5\u9808\u3067\u3059",
|
|
19937
|
+
core_validationMinLength: "{field}\u306F{min}\u6587\u5B57\u4EE5\u4E0A\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19938
|
+
core_validationMaxLength: "{field}\u306F{max}\u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19939
|
+
core_validationEmail: "\u6709\u52B9\u306A\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19940
|
+
core_validationUrl: "\u6709\u52B9\u306AURL\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19941
|
+
core_validationNumber: "\u6709\u52B9\u306A\u6570\u5024\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19942
|
+
core_validationInteger: "\u6574\u6570\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19943
|
+
core_validationPositive: "\u6B63\u306E\u6570\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
19944
|
+
core_validationPattern: "{field}\u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",
|
|
19945
|
+
core_timeJustNow: "\u305F\u3063\u305F\u4ECA",
|
|
19946
|
+
core_timeSecondsAgo: "{n}\u79D2\u524D",
|
|
19947
|
+
core_timeMinutesAgo: "{n}\u5206\u524D",
|
|
19948
|
+
core_timeHoursAgo: "{n}\u6642\u9593\u524D",
|
|
19949
|
+
core_timeDaysAgo: "{n}\u65E5\u524D",
|
|
19950
|
+
core_timeWeeksAgo: "{n}\u9031\u9593\u524D",
|
|
19951
|
+
core_timeMonthsAgo: "{n}\u304B\u6708\u524D",
|
|
19952
|
+
core_timeYearsAgo: "{n}\u5E74\u524D",
|
|
19953
|
+
core_browserFeatureUnsupported: "\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u30FC\u306F{feature}\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
|
|
19954
|
+
core_configEnvVarMissing: "\u74B0\u5883\u5909\u6570\u300C{varName}\u300D\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u65E2\u5B9A\u5024\u3082\u3042\u308A\u307E\u305B\u3093",
|
|
19955
|
+
core_configFileNotExist: "\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {filePath}",
|
|
19956
|
+
core_configParseFailed: "\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306E\u89E3\u6790\u306B\u5931\u6557\u3057\u307E\u3057\u305F: {filePath}",
|
|
19957
|
+
core_configValidationFailed: "\u8A2D\u5B9A\u306E\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
19958
|
+
core_configNotLoaded: "\u8A2D\u5B9A\u300C{name}\u300D\u304C\u8AAD\u307F\u8FBC\u307E\u308C\u3066\u3044\u307E\u305B\u3093",
|
|
19959
|
+
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",
|
|
19960
|
+
core_cryptoRandomUnavailable: "\u6697\u53F7\u5B66\u7684\u4E71\u6570\u306E\u751F\u6210\u5143\u3092\u5229\u7528\u3067\u304D\u307E\u305B\u3093"
|
|
19961
|
+
};
|
|
19962
|
+
|
|
19963
|
+
// messages/zh-CN.json
|
|
19964
|
+
var zh_CN_default2 = {
|
|
19965
|
+
$schema: "https://inlang.com/schema/inlang-message-format",
|
|
19966
|
+
core_errorUnknown: "\u672A\u77E5\u9519\u8BEF",
|
|
19967
|
+
core_errorNetwork: "\u7F51\u7EDC\u9519\u8BEF",
|
|
19968
|
+
core_errorTimeout: "\u8BF7\u6C42\u8D85\u65F6",
|
|
19969
|
+
core_errorNotFound: "\u8D44\u6E90\u4E0D\u5B58\u5728",
|
|
19970
|
+
core_errorUnauthorized: "\u672A\u6388\u6743",
|
|
19971
|
+
core_errorForbidden: "\u65E0\u6743\u9650",
|
|
19972
|
+
core_errorValidation: "\u9A8C\u8BC1\u5931\u8D25",
|
|
19973
|
+
core_errorInternal: "\u5185\u90E8\u9519\u8BEF",
|
|
19974
|
+
core_actionConfirm: "\u786E\u8BA4",
|
|
19975
|
+
core_actionCancel: "\u53D6\u6D88",
|
|
19976
|
+
core_actionSave: "\u4FDD\u5B58",
|
|
19977
|
+
core_actionDelete: "\u5220\u9664",
|
|
19978
|
+
core_actionEdit: "\u7F16\u8F91",
|
|
19979
|
+
core_actionCreate: "\u521B\u5EFA",
|
|
19980
|
+
core_actionUpdate: "\u66F4\u65B0",
|
|
19981
|
+
core_actionSearch: "\u641C\u7D22",
|
|
19982
|
+
core_actionReset: "\u91CD\u7F6E",
|
|
19983
|
+
core_actionSubmit: "\u63D0\u4EA4",
|
|
19984
|
+
core_actionLoading: "\u52A0\u8F7D\u4E2D...",
|
|
19985
|
+
core_actionRetry: "\u91CD\u8BD5",
|
|
19986
|
+
core_statusSuccess: "\u6210\u529F",
|
|
19987
|
+
core_statusFailed: "\u5931\u8D25",
|
|
19988
|
+
core_statusPending: "\u7B49\u5F85\u4E2D",
|
|
19989
|
+
core_statusProcessing: "\u5904\u7406\u4E2D",
|
|
19990
|
+
core_statusCompleted: "\u5DF2\u5B8C\u6210",
|
|
19991
|
+
core_statusCancelled: "\u5DF2\u53D6\u6D88",
|
|
19992
|
+
core_validationRequired: "{field} \u4E0D\u80FD\u4E3A\u7A7A",
|
|
19993
|
+
core_validationMinLength: "{field} \u81F3\u5C11\u9700\u8981 {min} \u4E2A\u5B57\u7B26",
|
|
19994
|
+
core_validationMaxLength: "{field} \u4E0D\u80FD\u8D85\u8FC7 {max} \u4E2A\u5B57\u7B26",
|
|
19995
|
+
core_validationEmail: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u5730\u5740",
|
|
19996
|
+
core_validationUrl: "\u8BF7\u8F93\u5165\u6709\u6548\u7684 URL",
|
|
19997
|
+
core_validationNumber: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u6570\u5B57",
|
|
19998
|
+
core_validationInteger: "\u8BF7\u8F93\u5165\u6574\u6570",
|
|
19999
|
+
core_validationPositive: "\u8BF7\u8F93\u5165\u6B63\u6570",
|
|
20000
|
+
core_validationPattern: "{field} \u683C\u5F0F\u4E0D\u6B63\u786E",
|
|
20001
|
+
core_timeJustNow: "\u521A\u521A",
|
|
20002
|
+
core_timeSecondsAgo: "{n} \u79D2\u524D",
|
|
20003
|
+
core_timeMinutesAgo: "{n} \u5206\u949F\u524D",
|
|
20004
|
+
core_timeHoursAgo: "{n} \u5C0F\u65F6\u524D",
|
|
20005
|
+
core_timeDaysAgo: "{n} \u5929\u524D",
|
|
20006
|
+
core_timeWeeksAgo: "{n} \u5468\u524D",
|
|
20007
|
+
core_timeMonthsAgo: "{n} \u4E2A\u6708\u524D",
|
|
20008
|
+
core_timeYearsAgo: "{n} \u5E74\u524D",
|
|
20009
|
+
core_browserFeatureUnsupported: "\u6D4F\u89C8\u5668\u73AF\u5883\u4E0D\u652F\u6301 {feature}\u3002",
|
|
20010
|
+
core_configEnvVarMissing: "\u73AF\u5883\u53D8\u91CF '{varName}' \u672A\u8BBE\u7F6E\u4E14\u65E0\u9ED8\u8BA4\u503C",
|
|
20011
|
+
core_configFileNotExist: "\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728: {filePath}",
|
|
20012
|
+
core_configParseFailed: "\u914D\u7F6E\u6587\u4EF6\u89E3\u6790\u5931\u8D25: {filePath}",
|
|
20013
|
+
core_configValidationFailed: "\u914D\u7F6E\u9A8C\u8BC1\u5931\u8D25",
|
|
20014
|
+
core_configNotLoaded: "\u914D\u7F6E '{name}' \u672A\u52A0\u8F7D",
|
|
20015
|
+
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",
|
|
20016
|
+
core_cryptoRandomUnavailable: "\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u7F3A\u5C11\u5BC6\u7801\u5B66\u5B89\u5168\u7684\u968F\u673A\u6E90"
|
|
20017
|
+
};
|
|
20018
|
+
|
|
20019
|
+
// src/i18n/core-i18n-utils.ts
|
|
20020
|
+
var DEFAULT_LOCALES = [
|
|
20021
|
+
{ code: "zh-CN", label: "\u7B80\u4F53\u4E2D\u6587" },
|
|
20022
|
+
{ code: "en-US", label: "English" },
|
|
20023
|
+
{ code: "ja-JP", label: "\u65E5\u672C\u8A9E" }
|
|
20024
|
+
];
|
|
20025
|
+
var DEFAULT_LOCALE = "zh-CN";
|
|
20026
|
+
var currentLocale = DEFAULT_LOCALE;
|
|
20027
|
+
var requestLocales;
|
|
20028
|
+
function installRequestLocales(storage2) {
|
|
20029
|
+
requestLocales = storage2;
|
|
20030
|
+
}
|
|
20031
|
+
function normalizeLocale(locale) {
|
|
20032
|
+
return locale === "en" ? "en-US" : locale === "zh" ? "zh-CN" : locale === "ja" ? "ja-JP" : locale;
|
|
20033
|
+
}
|
|
20034
|
+
function getGlobalLocale() {
|
|
20035
|
+
return requestLocales?.getStore()?.locale ?? currentLocale;
|
|
20036
|
+
}
|
|
20037
|
+
function setGlobalLocale(locale) {
|
|
20038
|
+
const normalized = normalizeLocale(locale);
|
|
20039
|
+
const request = requestLocales?.getStore();
|
|
20040
|
+
if (request)
|
|
20041
|
+
request.locale = normalized;
|
|
20042
|
+
else
|
|
20043
|
+
currentLocale = normalized;
|
|
20044
|
+
}
|
|
20045
|
+
function runWithLocale(locale, operation) {
|
|
20046
|
+
if (!requestLocales)
|
|
20047
|
+
throw new Error("Request locale context requires the Node.js entry");
|
|
20048
|
+
return requestLocales.run({ locale: normalizeLocale(locale) }, operation);
|
|
20049
|
+
}
|
|
20050
|
+
function createMessageGetter(messages) {
|
|
20051
|
+
return (key, options) => {
|
|
20052
|
+
const requestLocale = normalizeLocale(options?.locale ?? getGlobalLocale());
|
|
20053
|
+
const isSupported = DEFAULT_LOCALES.some((l) => l.code === requestLocale);
|
|
20054
|
+
const locale = isSupported ? requestLocale : DEFAULT_LOCALE;
|
|
20055
|
+
const dict = messages[locale] ?? messages[DEFAULT_LOCALE];
|
|
20056
|
+
const template = dict?.[key];
|
|
20057
|
+
if (!template) {
|
|
20058
|
+
return String(key);
|
|
20059
|
+
}
|
|
20060
|
+
if (options?.params) {
|
|
20061
|
+
return template.replace(/\{(\w+)\}/g, (_, paramKey) => {
|
|
20062
|
+
const value = options.params[paramKey];
|
|
20063
|
+
return value !== void 0 ? String(value) : `{${paramKey}}`;
|
|
20064
|
+
});
|
|
20065
|
+
}
|
|
20066
|
+
return template;
|
|
20067
|
+
};
|
|
20068
|
+
}
|
|
20069
|
+
var coreM = createMessageGetter({
|
|
20070
|
+
"zh-CN": zh_CN_default2,
|
|
20071
|
+
"en-US": en_US_default,
|
|
20072
|
+
"ja-JP": ja_JP_default
|
|
20073
|
+
});
|
|
20074
|
+
var i18n = {
|
|
20075
|
+
DEFAULT_LOCALES,
|
|
20076
|
+
DEFAULT_LOCALE,
|
|
20077
|
+
setGlobalLocale,
|
|
20078
|
+
getGlobalLocale,
|
|
20079
|
+
runWithLocale,
|
|
20080
|
+
createMessageGetter,
|
|
20081
|
+
coreM
|
|
20082
|
+
};
|
|
19829
20083
|
var DEFAULT_LENGTH = 21;
|
|
19830
20084
|
var SHORT_LENGTH = 10;
|
|
19831
20085
|
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
19832
20086
|
var NANOID_REGEX_CACHE = /* @__PURE__ */ new Map();
|
|
19833
20087
|
function generateUUID() {
|
|
19834
|
-
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
20088
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
19835
20089
|
return crypto.randomUUID();
|
|
19836
20090
|
}
|
|
19837
20091
|
const bytes = new Uint8Array(16);
|
|
19838
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
20092
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
19839
20093
|
crypto.getRandomValues(bytes);
|
|
19840
20094
|
} else {
|
|
19841
|
-
|
|
19842
|
-
bytes[i] = Math.floor(Math.random() * 256);
|
|
19843
|
-
}
|
|
20095
|
+
throw new Error(i18n.coreM("core_cryptoRandomUnavailable"));
|
|
19844
20096
|
}
|
|
19845
20097
|
bytes[6] = bytes[6] & 15 | 64;
|
|
19846
20098
|
bytes[8] = bytes[8] & 63 | 128;
|
|
@@ -19952,163 +20204,282 @@ var id = {
|
|
|
19952
20204
|
}
|
|
19953
20205
|
};
|
|
19954
20206
|
|
|
19955
|
-
//
|
|
19956
|
-
|
|
19957
|
-
|
|
19958
|
-
|
|
19959
|
-
|
|
19960
|
-
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19968
|
-
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19973
|
-
|
|
19974
|
-
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
core_timeMinutesAgo: "{n} minutes ago",
|
|
19996
|
-
core_timeHoursAgo: "{n} hours ago",
|
|
19997
|
-
core_timeDaysAgo: "{n} days ago",
|
|
19998
|
-
core_timeWeeksAgo: "{n} weeks ago",
|
|
19999
|
-
core_timeMonthsAgo: "{n} months ago",
|
|
20000
|
-
core_timeYearsAgo: "{n} years ago",
|
|
20001
|
-
core_browserFeatureUnsupported: "Browser does not support {feature}.",
|
|
20002
|
-
core_configEnvVarMissing: "Environment variable '{varName}' is not set and has no default value",
|
|
20003
|
-
core_configFileNotExist: "Config file does not exist: {filePath}",
|
|
20004
|
-
core_configParseFailed: "Failed to parse config file: {filePath}",
|
|
20005
|
-
core_configValidationFailed: "Config validation failed",
|
|
20006
|
-
core_configNotLoaded: "Config '{name}' is not loaded",
|
|
20007
|
-
core_configUnsupportedInBrowser: "Browser does not support file-based config; use core.config on the server or pass browser options through core.init({ logging })"
|
|
20207
|
+
// src/utils/core-util-type.ts
|
|
20208
|
+
function isDefined(value) {
|
|
20209
|
+
return value !== void 0 && value !== null;
|
|
20210
|
+
}
|
|
20211
|
+
function isObject2(value) {
|
|
20212
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20213
|
+
}
|
|
20214
|
+
function isFunction(value) {
|
|
20215
|
+
return typeof value === "function";
|
|
20216
|
+
}
|
|
20217
|
+
function isPromise(value) {
|
|
20218
|
+
if (value instanceof Promise) {
|
|
20219
|
+
return true;
|
|
20220
|
+
}
|
|
20221
|
+
if (!isObject2(value)) {
|
|
20222
|
+
return false;
|
|
20223
|
+
}
|
|
20224
|
+
return isFunction(value.then);
|
|
20225
|
+
}
|
|
20226
|
+
function isString(value) {
|
|
20227
|
+
return typeof value === "string";
|
|
20228
|
+
}
|
|
20229
|
+
function isNumber(value) {
|
|
20230
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
20231
|
+
}
|
|
20232
|
+
function isBoolean(value) {
|
|
20233
|
+
return typeof value === "boolean";
|
|
20234
|
+
}
|
|
20235
|
+
function isArray(value) {
|
|
20236
|
+
return Array.isArray(value);
|
|
20237
|
+
}
|
|
20238
|
+
var typeUtils = {
|
|
20239
|
+
isDefined,
|
|
20240
|
+
isObject: isObject2,
|
|
20241
|
+
isFunction,
|
|
20242
|
+
isPromise,
|
|
20243
|
+
isString,
|
|
20244
|
+
isNumber,
|
|
20245
|
+
isBoolean,
|
|
20246
|
+
isArray
|
|
20008
20247
|
};
|
|
20009
20248
|
|
|
20010
|
-
//
|
|
20011
|
-
var
|
|
20012
|
-
|
|
20013
|
-
|
|
20014
|
-
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20048
|
-
|
|
20049
|
-
|
|
20050
|
-
|
|
20051
|
-
|
|
20052
|
-
|
|
20053
|
-
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
|
|
20249
|
+
// src/utils/core-util-sanitize.ts
|
|
20250
|
+
var DEFAULT_SENSITIVE_KEY_REGEX = /(?:^|_)(?:pass|passcode|password|secret|authorization|cookie|otp|session|token)$|(?:^|_)otp_code$|(?:^|_)private_key$|(?:^|_)access_key(?:_id|_secret)?$|(?:^|_)secret_access_key$|(?:^|_)api(?:_[a-z0-9]+)*_key$|^apikey$/i;
|
|
20251
|
+
var DEFAULT_SENSITIVE_REPLACEMENT = "[REDACTED]";
|
|
20252
|
+
var URL_LIKE_KEY_REGEX = /(?:^|_)(?:url|uri|endpoint)(?:_|$)/;
|
|
20253
|
+
var SENSITIVE_KEY_CACHE_LIMIT = 512;
|
|
20254
|
+
var ERROR_DIAGNOSTIC_MAX_DEPTH = 32;
|
|
20255
|
+
var normalizedKeyCache = /* @__PURE__ */ new Map();
|
|
20256
|
+
var urlLikeKeyCache = /* @__PURE__ */ new Map();
|
|
20257
|
+
var defaultSensitiveKeyCache = /* @__PURE__ */ new Map();
|
|
20258
|
+
function getCachedValue(cache, key, createValue) {
|
|
20259
|
+
const cachedValue = cache.get(key);
|
|
20260
|
+
if (cachedValue !== void 0) {
|
|
20261
|
+
return cachedValue;
|
|
20262
|
+
}
|
|
20263
|
+
const value = createValue();
|
|
20264
|
+
if (cache.size >= SENSITIVE_KEY_CACHE_LIMIT) {
|
|
20265
|
+
cache.clear();
|
|
20266
|
+
}
|
|
20267
|
+
cache.set(key, value);
|
|
20268
|
+
return value;
|
|
20269
|
+
}
|
|
20270
|
+
function normalizeKeyForMatching(key) {
|
|
20271
|
+
return getCachedValue(normalizedKeyCache, key, () => {
|
|
20272
|
+
return key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").replace(/_+/g, "_").toLowerCase();
|
|
20273
|
+
});
|
|
20274
|
+
}
|
|
20275
|
+
function matchesDefaultSensitiveKey(normalizedKey) {
|
|
20276
|
+
return getCachedValue(defaultSensitiveKeyCache, normalizedKey, () => {
|
|
20277
|
+
return DEFAULT_SENSITIVE_KEY_REGEX.test(normalizedKey);
|
|
20278
|
+
});
|
|
20279
|
+
}
|
|
20280
|
+
function isPlainRecord(value) {
|
|
20281
|
+
if (!typeUtils.isObject(value)) {
|
|
20282
|
+
return false;
|
|
20283
|
+
}
|
|
20284
|
+
const prototype = Object.getPrototypeOf(value);
|
|
20285
|
+
return prototype === Object.prototype || prototype === null;
|
|
20286
|
+
}
|
|
20287
|
+
function compileSensitiveKeyMatcher(matcher) {
|
|
20288
|
+
if (matcher instanceof RegExp) {
|
|
20289
|
+
if (matcher === DEFAULT_SENSITIVE_KEY_REGEX) {
|
|
20290
|
+
return (_key, normalizedKey) => matchesDefaultSensitiveKey(normalizedKey);
|
|
20291
|
+
}
|
|
20292
|
+
const safeMatcher = matcher.global || matcher.sticky ? new RegExp(matcher.source, matcher.flags.replace(/[gy]/g, "")) : matcher;
|
|
20293
|
+
return (_key, normalizedKey) => safeMatcher.test(normalizedKey);
|
|
20294
|
+
}
|
|
20295
|
+
if (Array.isArray(matcher)) {
|
|
20296
|
+
const normalizedKeys = new Set(matcher.map(normalizeKeyForMatching));
|
|
20297
|
+
return (_key, normalizedKey) => normalizedKeys.has(normalizedKey);
|
|
20298
|
+
}
|
|
20299
|
+
return (key) => matcher(key);
|
|
20300
|
+
}
|
|
20301
|
+
function isSensitiveKey(key, matcher = DEFAULT_SENSITIVE_KEY_REGEX) {
|
|
20302
|
+
const normalizedKey = normalizeKeyForMatching(key);
|
|
20303
|
+
return compileSensitiveKeyMatcher(matcher)(key, normalizedKey);
|
|
20304
|
+
}
|
|
20305
|
+
function isUrlLikeNormalizedKey(normalizedKey) {
|
|
20306
|
+
return getCachedValue(urlLikeKeyCache, normalizedKey, () => URL_LIKE_KEY_REGEX.test(normalizedKey));
|
|
20307
|
+
}
|
|
20308
|
+
function sanitizeUrl(url2, options = {}) {
|
|
20309
|
+
return sanitizeUrlWithContext(url2, createSanitizeSensitiveContext(options));
|
|
20310
|
+
}
|
|
20311
|
+
function sanitizeUrlParameters(parameters, context) {
|
|
20312
|
+
const sanitized = new URLSearchParams();
|
|
20313
|
+
for (const [key, value] of parameters) {
|
|
20314
|
+
sanitized.append(key, context.isSensitiveKey(key, normalizeKeyForMatching(key)) ? context.urlReplacement : value);
|
|
20315
|
+
}
|
|
20316
|
+
return sanitized;
|
|
20317
|
+
}
|
|
20318
|
+
function sanitizeUrlWithContext(url2, context) {
|
|
20319
|
+
try {
|
|
20320
|
+
const parsed = new URL(url2);
|
|
20321
|
+
if (parsed.username) {
|
|
20322
|
+
parsed.username = context.urlReplacement;
|
|
20323
|
+
}
|
|
20324
|
+
if (parsed.password) {
|
|
20325
|
+
parsed.password = context.urlReplacement;
|
|
20326
|
+
}
|
|
20327
|
+
parsed.search = sanitizeUrlParameters(parsed.searchParams, context).toString();
|
|
20328
|
+
if (parsed.hash.includes("="))
|
|
20329
|
+
parsed.hash = sanitizeUrlParameters(new URLSearchParams(parsed.hash.slice(1)), context).toString();
|
|
20330
|
+
return parsed.toString().replaceAll(encodeURIComponent(context.urlReplacement), context.urlReplacement);
|
|
20331
|
+
} catch {
|
|
20332
|
+
return "(invalid url)";
|
|
20333
|
+
}
|
|
20334
|
+
}
|
|
20335
|
+
function isProtectedPropertyKey(key) {
|
|
20336
|
+
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
20337
|
+
}
|
|
20338
|
+
function createSanitizeSensitiveContext(options = {}) {
|
|
20339
|
+
const replacement = options.replacement ?? DEFAULT_SENSITIVE_REPLACEMENT;
|
|
20340
|
+
return {
|
|
20341
|
+
replacement,
|
|
20342
|
+
urlReplacement: typeof replacement === "string" ? replacement : DEFAULT_SENSITIVE_REPLACEMENT,
|
|
20343
|
+
isSensitiveKey: compileSensitiveKeyMatcher(options.matcher ?? DEFAULT_SENSITIVE_KEY_REGEX)
|
|
20344
|
+
};
|
|
20345
|
+
}
|
|
20346
|
+
function sanitizeSensitiveValueWithContext(value, key, context, cache, errorPath, errorDepth = 0) {
|
|
20347
|
+
const isPlainObjectValue = isPlainRecord(value);
|
|
20348
|
+
const isErrorDiagnostic = errorPath !== void 0 || value instanceof Error;
|
|
20349
|
+
if (key !== null) {
|
|
20350
|
+
const normalizedKey = normalizeKeyForMatching(key);
|
|
20351
|
+
if (typeof value === "string" && isUrlLikeNormalizedKey(normalizedKey)) {
|
|
20352
|
+
return sanitizeUrlWithContext(value, context);
|
|
20353
|
+
}
|
|
20354
|
+
if (context.isSensitiveKey(key, normalizedKey) && !isPlainObjectValue) {
|
|
20355
|
+
return isErrorDiagnostic ? sanitizeSensitiveValueWithContext(context.replacement, null, context, cache, errorPath ?? /* @__PURE__ */ new WeakSet(), errorDepth) : context.replacement;
|
|
20356
|
+
}
|
|
20357
|
+
}
|
|
20358
|
+
if (isErrorDiagnostic) {
|
|
20359
|
+
if (typeof value === "bigint")
|
|
20360
|
+
return value.toString();
|
|
20361
|
+
if (typeof value === "function" || typeof value === "symbol")
|
|
20362
|
+
return void 0;
|
|
20363
|
+
if (value === null || typeof value !== "object")
|
|
20364
|
+
return value;
|
|
20365
|
+
const activePath = errorPath ?? /* @__PURE__ */ new WeakSet();
|
|
20366
|
+
if (activePath.has(value))
|
|
20367
|
+
return "[Circular]";
|
|
20368
|
+
if (errorDepth >= ERROR_DIAGNOSTIC_MAX_DEPTH)
|
|
20369
|
+
return "[MaxDepth]";
|
|
20370
|
+
activePath.add(value);
|
|
20371
|
+
try {
|
|
20372
|
+
if (Array.isArray(value)) {
|
|
20373
|
+
return value.map((item) => sanitizeSensitiveValueWithContext(item, null, context, cache, activePath, errorDepth + 1));
|
|
20374
|
+
}
|
|
20375
|
+
const fields = { ...value };
|
|
20376
|
+
if (value instanceof Error) {
|
|
20377
|
+
fields.name = value.name;
|
|
20378
|
+
fields.message = value.message;
|
|
20379
|
+
fields.stack = value.stack;
|
|
20380
|
+
if (Object.hasOwn(value, "cause"))
|
|
20381
|
+
fields.cause = value.cause;
|
|
20382
|
+
if (value instanceof AggregateError)
|
|
20383
|
+
fields.errors = value.errors;
|
|
20384
|
+
}
|
|
20385
|
+
const sanitized = {};
|
|
20386
|
+
for (const [childKey, childValue] of Object.entries(fields)) {
|
|
20387
|
+
if (!isProtectedPropertyKey(childKey))
|
|
20388
|
+
sanitized[childKey] = sanitizeSensitiveValueWithContext(childValue, childKey, context, cache, activePath, errorDepth + 1);
|
|
20389
|
+
}
|
|
20390
|
+
return sanitized;
|
|
20391
|
+
} finally {
|
|
20392
|
+
activePath.delete(value);
|
|
20393
|
+
}
|
|
20394
|
+
}
|
|
20395
|
+
if (Array.isArray(value)) {
|
|
20396
|
+
if (cache.has(value)) {
|
|
20397
|
+
return cache.get(value);
|
|
20398
|
+
}
|
|
20399
|
+
const sanitizedArray = [];
|
|
20400
|
+
cache.set(value, sanitizedArray);
|
|
20401
|
+
for (let index = 0; index < value.length; index++) {
|
|
20402
|
+
sanitizedArray[index] = sanitizeSensitiveValueWithContext(value[index], null, context, cache);
|
|
20403
|
+
}
|
|
20404
|
+
return sanitizedArray;
|
|
20405
|
+
}
|
|
20406
|
+
if (isPlainObjectValue) {
|
|
20407
|
+
if (cache.has(value)) {
|
|
20408
|
+
return cache.get(value);
|
|
20409
|
+
}
|
|
20410
|
+
const sanitized = {};
|
|
20411
|
+
cache.set(value, sanitized);
|
|
20412
|
+
for (const childKey in value) {
|
|
20413
|
+
if (!Object.hasOwn(value, childKey) || isProtectedPropertyKey(childKey)) {
|
|
20414
|
+
continue;
|
|
20415
|
+
}
|
|
20416
|
+
sanitized[childKey] = sanitizeSensitiveValueWithContext(value[childKey], childKey, context, cache);
|
|
20417
|
+
}
|
|
20418
|
+
return sanitized;
|
|
20419
|
+
}
|
|
20420
|
+
return value;
|
|
20421
|
+
}
|
|
20422
|
+
function sanitizeSensitiveValue(value, key, options = {}, cache = /* @__PURE__ */ new WeakMap()) {
|
|
20423
|
+
return sanitizeSensitiveValueWithContext(value, key, createSanitizeSensitiveContext(options), cache);
|
|
20424
|
+
}
|
|
20425
|
+
function sanitizeSensitiveFields(value, options = {}) {
|
|
20426
|
+
return sanitizeSensitiveValue(value, null, options);
|
|
20427
|
+
}
|
|
20428
|
+
var sanitize = {
|
|
20429
|
+
defaultSensitiveKeyRegex: DEFAULT_SENSITIVE_KEY_REGEX,
|
|
20430
|
+
defaultSensitiveReplacement: DEFAULT_SENSITIVE_REPLACEMENT,
|
|
20431
|
+
isSensitiveKey,
|
|
20432
|
+
sanitizeUrl,
|
|
20433
|
+
sanitizeSensitiveValue,
|
|
20434
|
+
sanitizeSensitiveFields
|
|
20063
20435
|
};
|
|
20064
20436
|
|
|
20065
|
-
// src/
|
|
20066
|
-
var
|
|
20067
|
-
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
|
|
20073
|
-
return currentLocale;
|
|
20437
|
+
// src/functions/core-function-log-observer.ts
|
|
20438
|
+
var observers = /* @__PURE__ */ new Set();
|
|
20439
|
+
var emitting = false;
|
|
20440
|
+
function observeLogs(observer) {
|
|
20441
|
+
observers.add(observer);
|
|
20442
|
+
return () => {
|
|
20443
|
+
observers.delete(observer);
|
|
20444
|
+
};
|
|
20074
20445
|
}
|
|
20075
|
-
function
|
|
20076
|
-
|
|
20077
|
-
|
|
20078
|
-
|
|
20446
|
+
function emitLogRecord(record2) {
|
|
20447
|
+
if (emitting || observers.size === 0)
|
|
20448
|
+
return;
|
|
20449
|
+
emitting = true;
|
|
20450
|
+
try {
|
|
20451
|
+
for (const observer of observers) {
|
|
20452
|
+
try {
|
|
20453
|
+
const result = observer({ ...record2, context: sanitize.sanitizeSensitiveFields(record2.context) });
|
|
20454
|
+
if (result instanceof Promise)
|
|
20455
|
+
void result.catch(() => {
|
|
20456
|
+
});
|
|
20457
|
+
} catch {
|
|
20458
|
+
}
|
|
20459
|
+
}
|
|
20460
|
+
} finally {
|
|
20461
|
+
emitting = false;
|
|
20079
20462
|
}
|
|
20080
20463
|
}
|
|
20081
|
-
function
|
|
20082
|
-
|
|
20083
|
-
|
|
20084
|
-
|
|
20085
|
-
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
|
|
20089
|
-
|
|
20090
|
-
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
|
|
20094
|
-
|
|
20095
|
-
|
|
20096
|
-
|
|
20097
|
-
|
|
20098
|
-
}
|
|
20464
|
+
function sanitizeLogFields(value, paths) {
|
|
20465
|
+
const result = sanitize.sanitizeSensitiveFields(value);
|
|
20466
|
+
for (const path of paths)
|
|
20467
|
+
redactPath(result, path.match(/\*|[^.[\]"']+/g) ?? []);
|
|
20468
|
+
return result;
|
|
20469
|
+
}
|
|
20470
|
+
function redactPath(value, segments) {
|
|
20471
|
+
if (!value || typeof value !== "object" || segments.length === 0)
|
|
20472
|
+
return;
|
|
20473
|
+
const record2 = value;
|
|
20474
|
+
const [segment, ...rest] = segments;
|
|
20475
|
+
for (const key of segment === "*" ? Object.keys(record2) : [segment]) {
|
|
20476
|
+
if (!Object.hasOwn(record2, key) || ["__proto__", "constructor", "prototype"].includes(key))
|
|
20477
|
+
continue;
|
|
20478
|
+
if (rest.length === 0)
|
|
20479
|
+
record2[key] = "[REDACTED]";
|
|
20480
|
+
else redactPath(record2[key], rest);
|
|
20481
|
+
}
|
|
20099
20482
|
}
|
|
20100
|
-
var coreM = createMessageGetter({
|
|
20101
|
-
"zh-CN": zh_CN_default2,
|
|
20102
|
-
"en-US": en_US_default
|
|
20103
|
-
});
|
|
20104
|
-
var i18n = {
|
|
20105
|
-
DEFAULT_LOCALES,
|
|
20106
|
-
DEFAULT_LOCALE,
|
|
20107
|
-
setGlobalLocale,
|
|
20108
|
-
getGlobalLocale,
|
|
20109
|
-
createMessageGetter,
|
|
20110
|
-
coreM
|
|
20111
|
-
};
|
|
20112
20483
|
|
|
20113
20484
|
// src/i18n/core-zod-mapper.ts
|
|
20114
20485
|
function createPrefixedZodMessageGetter(prefix, getMessage) {
|
|
@@ -20118,6 +20489,8 @@ var ZOD_DEFAULT_MESSAGE_PATTERNS = [
|
|
|
20118
20489
|
/^Too small:/,
|
|
20119
20490
|
/^Too big:/,
|
|
20120
20491
|
/^Invalid input:/,
|
|
20492
|
+
/^Invalid input$/,
|
|
20493
|
+
// Zod 4 custom/refine 未提供业务消息时的默认文案。
|
|
20121
20494
|
/^Invalid option:/,
|
|
20122
20495
|
/^Invalid string:/,
|
|
20123
20496
|
/^Invalid email$/,
|
|
@@ -20376,48 +20749,9 @@ function createNotInitializedKit(codeOrDef, messageFn) {
|
|
|
20376
20749
|
const proxy = (mode = "async") => new Proxy({}, { get: () => mode === "sync" ? syncOp : asyncOp });
|
|
20377
20750
|
return { error: error63, result, proxy };
|
|
20378
20751
|
}
|
|
20379
|
-
|
|
20380
|
-
|
|
20381
|
-
function isDefined(value) {
|
|
20382
|
-
return value !== void 0 && value !== null;
|
|
20383
|
-
}
|
|
20384
|
-
function isObject2(value) {
|
|
20385
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20386
|
-
}
|
|
20387
|
-
function isFunction(value) {
|
|
20388
|
-
return typeof value === "function";
|
|
20389
|
-
}
|
|
20390
|
-
function isPromise(value) {
|
|
20391
|
-
if (value instanceof Promise) {
|
|
20392
|
-
return true;
|
|
20393
|
-
}
|
|
20394
|
-
if (!isObject2(value)) {
|
|
20395
|
-
return false;
|
|
20396
|
-
}
|
|
20397
|
-
return isFunction(value.then);
|
|
20398
|
-
}
|
|
20399
|
-
function isString(value) {
|
|
20400
|
-
return typeof value === "string";
|
|
20401
|
-
}
|
|
20402
|
-
function isNumber(value) {
|
|
20403
|
-
return typeof value === "number" && !Number.isNaN(value);
|
|
20404
|
-
}
|
|
20405
|
-
function isBoolean(value) {
|
|
20406
|
-
return typeof value === "boolean";
|
|
20407
|
-
}
|
|
20408
|
-
function isArray(value) {
|
|
20409
|
-
return Array.isArray(value);
|
|
20752
|
+
function requiresSharedState(environment) {
|
|
20753
|
+
return (environment.NODE_ENV === "production" || environment.HAI_CORE_ENV === "production") && environment.HAI_E2E !== "1" && environment.HAI_E2E_MOCK !== "1";
|
|
20410
20754
|
}
|
|
20411
|
-
var typeUtils = {
|
|
20412
|
-
isDefined,
|
|
20413
|
-
isObject: isObject2,
|
|
20414
|
-
isFunction,
|
|
20415
|
-
isPromise,
|
|
20416
|
-
isString,
|
|
20417
|
-
isNumber,
|
|
20418
|
-
isBoolean,
|
|
20419
|
-
isArray
|
|
20420
|
-
};
|
|
20421
20755
|
|
|
20422
20756
|
// src/utils/core-util-object.ts
|
|
20423
20757
|
function deepClone(obj) {
|
|
@@ -20483,147 +20817,6 @@ var object2 = {
|
|
|
20483
20817
|
fromEntries
|
|
20484
20818
|
};
|
|
20485
20819
|
|
|
20486
|
-
// src/utils/core-util-sanitize.ts
|
|
20487
|
-
var DEFAULT_SENSITIVE_KEY_REGEX = /(?:^|_)(?:pass|passcode|password|secret|authorization|cookie|otp|session|token)$|(?:^|_)otp_code$|(?:^|_)private_key$|(?:^|_)access_key(?:_id|_secret)?$|(?:^|_)secret_access_key$|(?:^|_)api(?:_[a-z0-9]+)*_key$|^apikey$/i;
|
|
20488
|
-
var DEFAULT_SENSITIVE_REPLACEMENT = "[REDACTED]";
|
|
20489
|
-
var URL_LIKE_KEY_REGEX = /(?:^|_)(?:url|uri|endpoint)(?:_|$)/;
|
|
20490
|
-
var SENSITIVE_KEY_CACHE_LIMIT = 512;
|
|
20491
|
-
var normalizedKeyCache = /* @__PURE__ */ new Map();
|
|
20492
|
-
var urlLikeKeyCache = /* @__PURE__ */ new Map();
|
|
20493
|
-
var defaultSensitiveKeyCache = /* @__PURE__ */ new Map();
|
|
20494
|
-
function getCachedValue(cache, key, createValue) {
|
|
20495
|
-
const cachedValue = cache.get(key);
|
|
20496
|
-
if (cachedValue !== void 0) {
|
|
20497
|
-
return cachedValue;
|
|
20498
|
-
}
|
|
20499
|
-
const value = createValue();
|
|
20500
|
-
if (cache.size >= SENSITIVE_KEY_CACHE_LIMIT) {
|
|
20501
|
-
cache.clear();
|
|
20502
|
-
}
|
|
20503
|
-
cache.set(key, value);
|
|
20504
|
-
return value;
|
|
20505
|
-
}
|
|
20506
|
-
function normalizeKeyForMatching(key) {
|
|
20507
|
-
return getCachedValue(normalizedKeyCache, key, () => {
|
|
20508
|
-
return key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").replace(/_+/g, "_").toLowerCase();
|
|
20509
|
-
});
|
|
20510
|
-
}
|
|
20511
|
-
function matchesDefaultSensitiveKey(normalizedKey) {
|
|
20512
|
-
return getCachedValue(defaultSensitiveKeyCache, normalizedKey, () => {
|
|
20513
|
-
return DEFAULT_SENSITIVE_KEY_REGEX.test(normalizedKey);
|
|
20514
|
-
});
|
|
20515
|
-
}
|
|
20516
|
-
function isPlainRecord(value) {
|
|
20517
|
-
if (!typeUtils.isObject(value)) {
|
|
20518
|
-
return false;
|
|
20519
|
-
}
|
|
20520
|
-
const prototype = Object.getPrototypeOf(value);
|
|
20521
|
-
return prototype === Object.prototype || prototype === null;
|
|
20522
|
-
}
|
|
20523
|
-
function compileSensitiveKeyMatcher(matcher) {
|
|
20524
|
-
if (matcher instanceof RegExp) {
|
|
20525
|
-
if (matcher === DEFAULT_SENSITIVE_KEY_REGEX) {
|
|
20526
|
-
return (_key, normalizedKey) => matchesDefaultSensitiveKey(normalizedKey);
|
|
20527
|
-
}
|
|
20528
|
-
const safeMatcher = matcher.global || matcher.sticky ? new RegExp(matcher.source, matcher.flags.replace(/[gy]/g, "")) : matcher;
|
|
20529
|
-
return (_key, normalizedKey) => safeMatcher.test(normalizedKey);
|
|
20530
|
-
}
|
|
20531
|
-
if (Array.isArray(matcher)) {
|
|
20532
|
-
const normalizedKeys = new Set(matcher.map(normalizeKeyForMatching));
|
|
20533
|
-
return (_key, normalizedKey) => normalizedKeys.has(normalizedKey);
|
|
20534
|
-
}
|
|
20535
|
-
return (key) => matcher(key);
|
|
20536
|
-
}
|
|
20537
|
-
function isSensitiveKey(key, matcher = DEFAULT_SENSITIVE_KEY_REGEX) {
|
|
20538
|
-
const normalizedKey = normalizeKeyForMatching(key);
|
|
20539
|
-
return compileSensitiveKeyMatcher(matcher)(key, normalizedKey);
|
|
20540
|
-
}
|
|
20541
|
-
function isUrlLikeNormalizedKey(normalizedKey) {
|
|
20542
|
-
return getCachedValue(urlLikeKeyCache, normalizedKey, () => URL_LIKE_KEY_REGEX.test(normalizedKey));
|
|
20543
|
-
}
|
|
20544
|
-
function sanitizeUrlCredentials(url2, replacement = DEFAULT_SENSITIVE_REPLACEMENT) {
|
|
20545
|
-
try {
|
|
20546
|
-
const parsed = new URL(url2);
|
|
20547
|
-
let changed = false;
|
|
20548
|
-
if (parsed.username) {
|
|
20549
|
-
parsed.username = replacement;
|
|
20550
|
-
changed = true;
|
|
20551
|
-
}
|
|
20552
|
-
if (parsed.password) {
|
|
20553
|
-
parsed.password = replacement;
|
|
20554
|
-
changed = true;
|
|
20555
|
-
}
|
|
20556
|
-
if (!changed) {
|
|
20557
|
-
return parsed.toString();
|
|
20558
|
-
}
|
|
20559
|
-
return parsed.toString().replaceAll(encodeURIComponent(replacement), replacement);
|
|
20560
|
-
} catch {
|
|
20561
|
-
return url2;
|
|
20562
|
-
}
|
|
20563
|
-
}
|
|
20564
|
-
function isProtectedPropertyKey(key) {
|
|
20565
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
20566
|
-
}
|
|
20567
|
-
function createSanitizeSensitiveContext(options = {}) {
|
|
20568
|
-
const replacement = options.replacement ?? DEFAULT_SENSITIVE_REPLACEMENT;
|
|
20569
|
-
return {
|
|
20570
|
-
replacement,
|
|
20571
|
-
urlReplacement: typeof replacement === "string" ? replacement : DEFAULT_SENSITIVE_REPLACEMENT,
|
|
20572
|
-
isSensitiveKey: compileSensitiveKeyMatcher(options.matcher ?? DEFAULT_SENSITIVE_KEY_REGEX)
|
|
20573
|
-
};
|
|
20574
|
-
}
|
|
20575
|
-
function sanitizeSensitiveValueWithContext(value, key, context, cache) {
|
|
20576
|
-
const isPlainObjectValue = isPlainRecord(value);
|
|
20577
|
-
if (key !== null) {
|
|
20578
|
-
const normalizedKey = normalizeKeyForMatching(key);
|
|
20579
|
-
if (typeof value === "string" && isUrlLikeNormalizedKey(normalizedKey)) {
|
|
20580
|
-
return sanitizeUrlCredentials(value, context.urlReplacement);
|
|
20581
|
-
}
|
|
20582
|
-
if (context.isSensitiveKey(key, normalizedKey) && !isPlainObjectValue) {
|
|
20583
|
-
return context.replacement;
|
|
20584
|
-
}
|
|
20585
|
-
}
|
|
20586
|
-
if (Array.isArray(value)) {
|
|
20587
|
-
if (cache.has(value)) {
|
|
20588
|
-
return cache.get(value);
|
|
20589
|
-
}
|
|
20590
|
-
const sanitizedArray = [];
|
|
20591
|
-
cache.set(value, sanitizedArray);
|
|
20592
|
-
for (let index = 0; index < value.length; index++) {
|
|
20593
|
-
sanitizedArray[index] = sanitizeSensitiveValueWithContext(value[index], null, context, cache);
|
|
20594
|
-
}
|
|
20595
|
-
return sanitizedArray;
|
|
20596
|
-
}
|
|
20597
|
-
if (isPlainObjectValue) {
|
|
20598
|
-
if (cache.has(value)) {
|
|
20599
|
-
return cache.get(value);
|
|
20600
|
-
}
|
|
20601
|
-
const sanitized = {};
|
|
20602
|
-
cache.set(value, sanitized);
|
|
20603
|
-
for (const childKey in value) {
|
|
20604
|
-
if (!Object.hasOwn(value, childKey) || isProtectedPropertyKey(childKey)) {
|
|
20605
|
-
continue;
|
|
20606
|
-
}
|
|
20607
|
-
sanitized[childKey] = sanitizeSensitiveValueWithContext(value[childKey], childKey, context, cache);
|
|
20608
|
-
}
|
|
20609
|
-
return sanitized;
|
|
20610
|
-
}
|
|
20611
|
-
return value;
|
|
20612
|
-
}
|
|
20613
|
-
function sanitizeSensitiveValue(value, key, options = {}, cache = /* @__PURE__ */ new WeakMap()) {
|
|
20614
|
-
return sanitizeSensitiveValueWithContext(value, key, createSanitizeSensitiveContext(options), cache);
|
|
20615
|
-
}
|
|
20616
|
-
function sanitizeSensitiveFields(value, options = {}) {
|
|
20617
|
-
return sanitizeSensitiveValue(value, null, options);
|
|
20618
|
-
}
|
|
20619
|
-
var sanitize = {
|
|
20620
|
-
defaultSensitiveKeyRegex: DEFAULT_SENSITIVE_KEY_REGEX,
|
|
20621
|
-
defaultSensitiveReplacement: DEFAULT_SENSITIVE_REPLACEMENT,
|
|
20622
|
-
isSensitiveKey,
|
|
20623
|
-
sanitizeSensitiveValue,
|
|
20624
|
-
sanitizeSensitiveFields
|
|
20625
|
-
};
|
|
20626
|
-
|
|
20627
20820
|
// src/utils/core-util-string.ts
|
|
20628
20821
|
var LEADING_LOWERCASE_REGEX = /^[a-z]/;
|
|
20629
20822
|
function capitalize(str) {
|
|
@@ -20773,10 +20966,12 @@ function createCore(loggerFns) {
|
|
|
20773
20966
|
create: loggerFns.createLogger,
|
|
20774
20967
|
configure: loggerFns.configureLogger,
|
|
20775
20968
|
setLevel: loggerFns.setLogLevel,
|
|
20776
|
-
getLevel: loggerFns.getLogLevel
|
|
20969
|
+
getLevel: loggerFns.getLogLevel,
|
|
20970
|
+
observe: observeLogs
|
|
20777
20971
|
};
|
|
20778
20972
|
};
|
|
20779
20973
|
return {
|
|
20974
|
+
context: requestContext,
|
|
20780
20975
|
// ─── Logger ───
|
|
20781
20976
|
/**
|
|
20782
20977
|
* 默认 Logger(懒加载单例),同时提供 create / configure / setLevel / getLevel 管理方法。
|
|
@@ -20802,10 +20997,12 @@ function createCore(loggerFns) {
|
|
|
20802
20997
|
*
|
|
20803
20998
|
* @example
|
|
20804
20999
|
* ```ts
|
|
20805
|
-
* //
|
|
21000
|
+
* // 配置浏览器语言或服务端启动默认值
|
|
20806
21001
|
* core.i18n.setGlobalLocale('en-US')
|
|
20807
21002
|
*
|
|
20808
|
-
* //
|
|
21003
|
+
* // Node 请求应包裹实际异步处理过程
|
|
21004
|
+
* await core.i18n.runWithLocale('zh-CN', () => handleRequest())
|
|
21005
|
+
* // 获取当前请求语言或应用默认语言
|
|
20809
21006
|
* core.i18n.getGlobalLocale()
|
|
20810
21007
|
*
|
|
20811
21008
|
* // 创建消息获取器(读取全局 locale)
|
|
@@ -20940,11 +21137,12 @@ function createCore(loggerFns) {
|
|
|
20940
21137
|
* ```
|
|
20941
21138
|
*/
|
|
20942
21139
|
module: {
|
|
20943
|
-
createNotInitializedKit
|
|
21140
|
+
createNotInitializedKit,
|
|
21141
|
+
requiresSharedState
|
|
20944
21142
|
}
|
|
20945
21143
|
};
|
|
20946
21144
|
}
|
|
20947
21145
|
|
|
20948
|
-
export { CoreConfigSchema, EnvSchema, HaiCommonError, HaiConfigError,
|
|
20949
|
-
//# sourceMappingURL=chunk-
|
|
20950
|
-
//# sourceMappingURL=chunk-
|
|
21146
|
+
export { CoreConfigSchema, EnvSchema, HaiCommonError, HaiConfigError, LogFormatSchema, LogLevelSchema, LoggingConfigSchema, __commonJS, __toESM, createCore, emitLogRecord, err, i18n, installRequestContext, installRequestLocales, ok, requestContext, sanitize, sanitizeLogFields, typeUtils };
|
|
21147
|
+
//# sourceMappingURL=chunk-MUQFCAQ5.js.map
|
|
21148
|
+
//# sourceMappingURL=chunk-MUQFCAQ5.js.map
|