@kcuf/sls-logger-base 0.0.5 → 0.0.6

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/cjs/util/convert-log-info.js +1 -1
  3. package/dist/cjs/util/flatten-object.js +1 -1
  4. package/dist/cjs/util/merge-dont-send.js +1 -1
  5. package/dist/cjs/util/{normalize-error.js → normalize-payload-error.js} +2 -2
  6. package/dist/cjs/util/{normalize-file.js → normalize-payload-file.js} +2 -2
  7. package/dist/cjs/util/{normalize-form-data.js → normalize-payload-form-data.js} +4 -4
  8. package/dist/cjs/util/{normalize-headers.js → normalize-payload-headers.js} +2 -2
  9. package/dist/cjs/util/{normalize-search-params.js → normalize-payload-search-params.js} +2 -2
  10. package/dist/cjs/util/normalize-payload.js +15 -14
  11. package/dist/esm/class/index.js.map +1 -1
  12. package/dist/esm/class/sls-logger.js.map +1 -1
  13. package/dist/esm/class/sls-pipe.js.map +1 -1
  14. package/dist/esm/const/index.js.map +1 -1
  15. package/dist/esm/factory/create-logger.js.map +1 -1
  16. package/dist/esm/factory/generate-create-logger.js.map +1 -1
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/types/common.js.map +1 -1
  19. package/dist/esm/types/factory.js.map +1 -1
  20. package/dist/esm/types/options.js.map +1 -1
  21. package/dist/esm/util/build-post-body.js.map +1 -1
  22. package/dist/esm/util/convert-log-info.js +1 -1
  23. package/dist/esm/util/convert-log-info.js.map +1 -1
  24. package/dist/esm/util/create-sls-log-quick.js.map +1 -1
  25. package/dist/esm/util/flatten-object.js +1 -1
  26. package/dist/esm/util/flatten-object.js.map +1 -1
  27. package/dist/esm/util/flatten-test-path.js.map +1 -1
  28. package/dist/esm/util/get-log-once-key.js.map +1 -1
  29. package/dist/esm/util/get-silent-countdown.js.map +1 -1
  30. package/dist/esm/util/merge-default-params.js.map +1 -1
  31. package/dist/esm/util/merge-dont-send.js +1 -1
  32. package/dist/esm/util/merge-dont-send.js.map +1 -1
  33. package/dist/esm/util/{normalize-error.js → normalize-payload-error.js} +2 -2
  34. package/dist/esm/util/normalize-payload-error.js.map +1 -0
  35. package/dist/esm/util/{normalize-file.js → normalize-payload-file.js} +2 -2
  36. package/dist/esm/util/normalize-payload-file.js.map +1 -0
  37. package/dist/esm/util/{normalize-form-data.js → normalize-payload-form-data.js} +4 -4
  38. package/dist/esm/util/normalize-payload-form-data.js.map +1 -0
  39. package/dist/esm/util/normalize-payload-headers.js +8 -0
  40. package/dist/esm/util/normalize-payload-headers.js.map +1 -0
  41. package/dist/esm/util/{normalize-search-params.js → normalize-payload-search-params.js} +2 -2
  42. package/dist/esm/util/normalize-payload-search-params.js.map +1 -0
  43. package/dist/esm/util/normalize-payload.js +15 -14
  44. package/dist/esm/util/normalize-payload.js.map +1 -1
  45. package/dist/esm/util/resolve-default-params.js.map +1 -1
  46. package/dist/types/class/sls-logger.d.ts +2 -2
  47. package/dist/types/class/sls-pipe.d.ts +2 -2
  48. package/dist/types/factory/create-logger.d.ts +2 -2
  49. package/dist/types/factory/generate-create-logger.d.ts +2 -2
  50. package/dist/types/types/common.d.ts +5 -11
  51. package/dist/types/types/factory.d.ts +1 -3
  52. package/dist/types/types/options.d.ts +3 -3
  53. package/dist/types/util/build-post-body.d.ts +1 -1
  54. package/dist/types/util/convert-log-info.d.ts +1 -1
  55. package/dist/types/util/flatten-object.d.ts +1 -1
  56. package/dist/types/util/flatten-test-path.d.ts +1 -1
  57. package/dist/types/util/merge-default-params.d.ts +1 -1
  58. package/dist/types/util/merge-dont-send.d.ts +2 -2
  59. package/dist/types/util/{normalize-error.d.ts → normalize-payload-error.d.ts} +1 -1
  60. package/dist/types/util/{normalize-file.d.ts → normalize-payload-file.d.ts} +1 -1
  61. package/dist/types/util/normalize-payload-form-data.d.ts +1 -0
  62. package/dist/types/util/normalize-payload-headers.d.ts +1 -0
  63. package/dist/types/util/normalize-payload-search-params.d.ts +1 -0
  64. package/package.json +17 -17
  65. package/dist/esm/util/normalize-error.js.map +0 -1
  66. package/dist/esm/util/normalize-file.js.map +0 -1
  67. package/dist/esm/util/normalize-form-data.js.map +0 -1
  68. package/dist/esm/util/normalize-headers.js +0 -8
  69. package/dist/esm/util/normalize-headers.js.map +0 -1
  70. package/dist/esm/util/normalize-search-params.js.map +0 -1
  71. package/dist/types/util/normalize-form-data.d.ts +0 -1
  72. package/dist/types/util/normalize-headers.d.ts +0 -1
  73. package/dist/types/util/normalize-search-params.d.ts +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.0.6 2026/06/25 @驳是
4
+
5
+ * FIX 修复小程序下使用报错的问题
@@ -25,7 +25,7 @@ function convertLogInfo(info) {
25
25
  try {
26
26
  // 避免 cyclic error
27
27
  o[k] = JSON.stringify(v);
28
- } catch (err) {
28
+ } catch (_err) {
29
29
  o[k] = 'TypeError: cyclic object value';
30
30
  }
31
31
  }
@@ -39,7 +39,7 @@ function flattenObject(o, options) {
39
39
  var scopedPathKey = scope ? "".concat(scope, ".").concat(pathKey) : pathKey;
40
40
 
41
41
  // 可以忽略不重要的信息,不记录方法,不记录 `_` 打头的数据
42
- if (/^_/.test(k) || typeof v === 'function' || omit && (0, _flattenTestPath.default)(pathKey, omit)) {
42
+ if (k.startsWith('_') || typeof v === 'function' || omit && (0, _flattenTestPath.default)(pathKey, omit)) {
43
43
  return;
44
44
  }
45
45
  var normalizedV = (0, _normalizePayload.default)(v);
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = mergeDontSend;
7
7
  function mergeDontSend(factoryDontSend, dontSend) {
8
8
  if (!factoryDontSend || !dontSend) {
9
- return dontSend || factoryDontSend;
9
+ return dontSend !== null && dontSend !== void 0 ? dontSend : factoryDontSend;
10
10
  }
11
11
  return function () {
12
12
  return factoryDontSend() || dontSend();
@@ -4,12 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = normalizeError;
7
+ exports.default = normalizePayloadError;
8
8
  var _forEach2 = _interopRequireDefault(require("lodash/forEach"));
9
9
  /**
10
10
  * Error 身上的 name、message、stack 等信息用 _forEach 遍历不到,故需要转成普通对象
11
11
  */
12
- function normalizeError(err) {
12
+ function normalizePayloadError(err) {
13
13
  var normalized = {
14
14
  name: err.name,
15
15
  message: err.message
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = normalizeFile;
6
+ exports.default = normalizePayloadFile;
7
7
  /**
8
8
  * 文件不可能直接记录
9
9
  */
10
- function normalizeFile(file) {
10
+ function normalizePayloadFile(file) {
11
11
  return {
12
12
  name: file.name,
13
13
  size: file.size,
@@ -4,12 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = normalizeFormData;
8
- var _normalizeFile = _interopRequireDefault(require("./normalize-file"));
9
- function normalizeFormData(formData) {
7
+ exports.default = normalizePayloadFormData;
8
+ var _normalizePayloadFile = _interopRequireDefault(require("./normalize-payload-file"));
9
+ function normalizePayloadFormData(formData) {
10
10
  var normalized = {};
11
11
  formData.forEach(function (v, k) {
12
- var value = v instanceof File ? (0, _normalizeFile.default)(v) : v;
12
+ var value = v instanceof File ? (0, _normalizePayloadFile.default)(v) : v;
13
13
  var exist = normalized[k];
14
14
  if (Array.isArray(exist)) {
15
15
  exist.push(value);
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = normalizeHeaders;
7
- function normalizeHeaders(headers) {
6
+ exports.default = normalizePayloadHeaders;
7
+ function normalizePayloadHeaders(headers) {
8
8
  var normalized = {};
9
9
  headers.forEach(function (v, k) {
10
10
  normalized[k] = v;
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = normalizeSearchParams;
7
- function normalizeSearchParams(searchParams) {
6
+ exports.default = normalizePayloadSearchParams;
7
+ function normalizePayloadSearchParams(searchParams) {
8
8
  var normalized = {};
9
9
  searchParams.forEach(function (v, k) {
10
10
  var exist = normalized[k];
@@ -6,26 +6,27 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = normalizePayload;
8
8
  var _isError2 = _interopRequireDefault(require("lodash/isError"));
9
- var _normalizeError = _interopRequireDefault(require("./normalize-error"));
10
- var _normalizeHeaders = _interopRequireDefault(require("./normalize-headers"));
11
- var _normalizeFile = _interopRequireDefault(require("./normalize-file"));
12
- var _normalizeFormData = _interopRequireDefault(require("./normalize-form-data"));
13
- var _normalizeSearchParams = _interopRequireDefault(require("./normalize-search-params"));
9
+ var _normalizePayloadError = _interopRequireDefault(require("./normalize-payload-error"));
10
+ var _normalizePayloadHeaders = _interopRequireDefault(require("./normalize-payload-headers"));
11
+ var _normalizePayloadFile = _interopRequireDefault(require("./normalize-payload-file"));
12
+ var _normalizePayloadFormData = _interopRequireDefault(require("./normalize-payload-form-data"));
13
+ var _normalizePayloadSearchParams = _interopRequireDefault(require("./normalize-payload-search-params"));
14
14
  function normalizePayload(o) {
15
15
  if ((0, _isError2.default)(o)) {
16
- return (0, _normalizeError.default)(o);
16
+ return (0, _normalizePayloadError.default)(o);
17
17
  }
18
- if (o instanceof Headers) {
19
- return (0, _normalizeHeaders.default)(o);
18
+ if (typeof Headers !== 'undefined' && o instanceof Headers) {
19
+ // 使用 typeof 以免在小程序等环境下崩坏
20
+ return (0, _normalizePayloadHeaders.default)(o);
20
21
  }
21
- if (o instanceof File) {
22
- return (0, _normalizeFile.default)(o);
22
+ if (typeof File !== 'undefined' && o instanceof File) {
23
+ return (0, _normalizePayloadFile.default)(o);
23
24
  }
24
- if (o instanceof FormData) {
25
- return (0, _normalizeFormData.default)(o);
25
+ if (typeof FormData !== 'undefined' && o instanceof FormData) {
26
+ return (0, _normalizePayloadFormData.default)(o);
26
27
  }
27
- if (o instanceof URLSearchParams) {
28
- return (0, _normalizeSearchParams.default)(o);
28
+ if (typeof URLSearchParams !== 'undefined' && o instanceof URLSearchParams) {
29
+ return (0, _normalizePayloadSearchParams.default)(o);
29
30
  }
30
31
  return o;
31
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","SlsLogger"],"sources":["../../../src/class/index.ts"],"sourcesContent":["export { default as SlsLogger } from './sls-logger';"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","SlsLogger"],"sources":["../../../src/class/index.ts"],"sourcesContent":["export { default as SlsLogger } from './sls-logger';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,cAAc","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"sls-logger.js","names":["API_VERSION","PIPE_SILENT_TIME","PIPE_WAIT_TIME","PIPE_MAX_CHUNK","getLogOnceKey","flattenObject","normalizePayload","resolveDefaultParams","SlsPipe","SlsLogger","sender","options","_this","_options$silentTime","_options$waitTime","_options$maxChunk","_classCallCheck","_defineProperty","topic","payload","_len","arguments","length","args","Array","_key","_ref","_ref2","_slicedToArray","_ref3","_ref4","_this$options","factoryPrefix","prefix","factorySampling","sampling","defaultParams","_options2","_options2$group","group","_options2$prefix","_options2$sampling","instant","once","flatten","finalTopic","concat","onceKey","dontSend","plainInfo","slsPipe","pipe","_objectSpread","__topic__","_GROUP","trackUrl","project","endpoint","logstore","apiVersion","silentTime","waitTime","maxChunk","_createClass","key","value","_dontSend","Math","random","default"],"sources":["../../../src/class/sls-logger.ts"],"sourcesContent":["import {\n TLogArgs,\n ICreateLoggerOptions,\n ILogSender,\n ISlsLogOptions,\n ISlsLogFn\n} from '../types';\nimport {\n API_VERSION,\n PIPE_SILENT_TIME,\n PIPE_WAIT_TIME,\n PIPE_MAX_CHUNK\n} from '../const';\nimport {\n getLogOnceKey,\n flattenObject,\n normalizePayload,\n resolveDefaultParams\n} from '../util';\n\nimport SlsPipe from './sls-pipe';\n\n/**\n * 创建 SLS 日志方法\n */\nexport default class SlsLogger {\n private readonly options: ICreateLoggerOptions;\n private readonly slsPipe: SlsPipe;\n private once: Record<string, 1> = {};\n \n constructor(sender: ILogSender, options: ICreateLoggerOptions) {\n this.options = options;\n this.slsPipe = new SlsPipe(sender, {\n trackUrl: `https://${options.project}.${options.endpoint}/logstores/${options.logstore}/track`,\n apiVersion: options.apiVersion || API_VERSION,\n silentTime: options.silentTime ?? PIPE_SILENT_TIME,\n waitTime: options.waitTime ?? PIPE_WAIT_TIME,\n maxChunk: options.maxChunk ?? PIPE_MAX_CHUNK\n });\n }\n \n log: ISlsLogFn = (...args: TLogArgs): void => {\n let options: ISlsLogOptions = {};\n let topic: string;\n let payload: object | undefined;\n \n if (typeof args[0] === 'string') {\n [topic, payload] = args as [string, object?];\n } else {\n [options, topic, payload] = args as [ISlsLogOptions, string, object?];\n }\n \n const {\n options: {\n prefix: factoryPrefix,\n sampling: factorySampling,\n defaultParams\n }\n } = this;\n const {\n group = 'LOG',\n prefix = factoryPrefix,\n sampling = factorySampling,\n instant,\n once,\n flatten\n } = options;\n const finalTopic = prefix ? `${prefix}${topic}` : topic;\n const onceKey: string | undefined = getLogOnceKey(finalTopic, once);\n \n if (this.dontSend(sampling, onceKey)) {\n return;\n }\n \n if (onceKey) {\n this.once[onceKey] = 1;\n }\n \n let plainInfo: object | undefined = payload ? normalizePayload(payload) : payload;\n \n if (plainInfo && flatten) {\n plainInfo = flattenObject(plainInfo, flatten === true ? '' : flatten);\n }\n \n this.slsPipe.pipe({\n ...resolveDefaultParams(defaultParams),\n ...plainInfo,\n __topic__: finalTopic,\n _GROUP: group\n }, instant);\n };\n \n /**\n * 检查是否需要忽略\n */\n private dontSend(sampling?: number, onceKey?: string): boolean {\n const {\n options: {\n dontSend\n }\n } = this;\n \n if (onceKey && this.once[onceKey]) { // 只需发送一次,已发送过,忽略\n return true;\n }\n \n if (dontSend?.() === true) { // dontSend 阻止发送\n return true;\n }\n \n if (typeof sampling === 'number' && sampling > 0 && sampling < 1) { // 采样,`(0, 1)` 开区间\n return Math.random() > sampling;\n }\n \n return false;\n }\n}"],"mappings":";;;;;;AAOA,SACEA,WAAW,EACXC,gBAAgB,EAChBC,cAAc,EACdC,cAAc,QACT,UAAU;AACjB,SACEC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,oBAAoB,QACf,SAAS;AAEhB,OAAOC,OAAO,MAAM,YAAY;;AAEhC;AACA;AACA;AAFA,IAGqBC,SAAS;EAK5B,SAAAA,UAAYC,MAAkB,EAAEC,QAA6B,EAAE;IAAA,IAAAC,KAAA;MAAAC,mBAAA;MAAAC,iBAAA;MAAAC,iBAAA;IAAAC,eAAA,OAAAP,SAAA;IAAAQ,eAAA,eAF7B,CAAC,CAAC;IAAAA,eAAA,cAanB,YAA6B;MAC5C,IAAIN,OAAuB,GAAG,CAAC,CAAC;MAChC,IAAIO,KAAa;MACjB,IAAIC,OAA2B;MAAC,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAHbC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;QAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;MAAA;MAKvB,IAAI,OAAOF,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QAAA,IAAAG,IAAA,GACZH,IAAI;QAAA,IAAAI,KAAA,GAAAC,cAAA,CAAAF,IAAA;QAAtBR,KAAK,GAAAS,KAAA;QAAER,OAAO,GAAAQ,KAAA;MACjB,CAAC,MAAM;QAAA,IAAAE,KAAA,GACuBN,IAAI;QAAA,IAAAO,KAAA,GAAAF,cAAA,CAAAC,KAAA;QAA/BlB,OAAO,GAAAmB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BAARA,SAAA,CAAW,CAAC,MAAK,IAAI,EAAE;QAAE;QAC3B,OAAO,IAAI;MACb;MAEA,IAAI,OAAO/B,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,GAAG,CAAC,IAAIA,QAAQ,GAAG,CAAC,EAAE;QAAE;QAClE,OAAOgC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAGjC,QAAQ;MACjC;MAEA,OAAO,KAAK;IACd;EAAC;AAAA;AAAA,SA1FkB1B,SAAS,IAAA4D,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"sls-logger.js","names":["API_VERSION","PIPE_SILENT_TIME","PIPE_WAIT_TIME","PIPE_MAX_CHUNK","getLogOnceKey","flattenObject","normalizePayload","resolveDefaultParams","SlsPipe","SlsLogger","sender","options","_this","_options$silentTime","_options$waitTime","_options$maxChunk","_classCallCheck","_defineProperty","topic","payload","_len","arguments","length","args","Array","_key","_ref","_ref2","_slicedToArray","_ref3","_ref4","_this$options","factoryPrefix","prefix","factorySampling","sampling","defaultParams","_options2","_options2$group","group","_options2$prefix","_options2$sampling","instant","once","flatten","finalTopic","concat","onceKey","dontSend","plainInfo","slsPipe","pipe","_objectSpread","__topic__","_GROUP","trackUrl","project","endpoint","logstore","apiVersion","silentTime","waitTime","maxChunk","_createClass","key","value","_dontSend","Math","random","default"],"sources":["../../../src/class/sls-logger.ts"],"sourcesContent":["import {\n TLogArgs,\n ICreateLoggerOptions,\n TLogSender,\n ISlsLogOptions,\n ISlsLogFn\n} from '../types';\nimport {\n API_VERSION,\n PIPE_SILENT_TIME,\n PIPE_WAIT_TIME,\n PIPE_MAX_CHUNK\n} from '../const';\nimport {\n getLogOnceKey,\n flattenObject,\n normalizePayload,\n resolveDefaultParams\n} from '../util';\n\nimport SlsPipe from './sls-pipe';\n\n/**\n * 创建 SLS 日志方法\n */\nexport default class SlsLogger {\n private readonly options: ICreateLoggerOptions;\n private readonly slsPipe: SlsPipe;\n private once: Record<string, 1> = {};\n \n constructor(sender: TLogSender, options: ICreateLoggerOptions) {\n this.options = options;\n this.slsPipe = new SlsPipe(sender, {\n trackUrl: `https://${options.project}.${options.endpoint}/logstores/${options.logstore}/track`,\n apiVersion: options.apiVersion || API_VERSION,\n silentTime: options.silentTime ?? PIPE_SILENT_TIME,\n waitTime: options.waitTime ?? PIPE_WAIT_TIME,\n maxChunk: options.maxChunk ?? PIPE_MAX_CHUNK\n });\n }\n \n log: ISlsLogFn = (...args: TLogArgs): void => {\n let options: ISlsLogOptions = {};\n let topic: string;\n let payload: object | undefined;\n \n if (typeof args[0] === 'string') {\n [topic, payload] = args as [string, object?];\n } else {\n [options, topic, payload] = args as [ISlsLogOptions, string, object?];\n }\n \n const {\n options: {\n prefix: factoryPrefix,\n sampling: factorySampling,\n defaultParams\n }\n } = this;\n const {\n group = 'LOG',\n prefix = factoryPrefix,\n sampling = factorySampling,\n instant,\n once,\n flatten\n } = options;\n const finalTopic = prefix ? `${prefix}${topic}` : topic;\n const onceKey: string | undefined = getLogOnceKey(finalTopic, once);\n \n if (this.dontSend(sampling, onceKey)) {\n return;\n }\n \n if (onceKey) {\n this.once[onceKey] = 1;\n }\n \n let plainInfo: object | undefined = payload ? normalizePayload(payload) : payload;\n \n if (plainInfo && flatten) {\n plainInfo = flattenObject(plainInfo, flatten === true ? '' : flatten);\n }\n \n this.slsPipe.pipe({\n ...resolveDefaultParams(defaultParams),\n ...plainInfo,\n __topic__: finalTopic,\n _GROUP: group\n }, instant);\n };\n \n /**\n * 检查是否需要忽略\n */\n private dontSend(sampling?: number, onceKey?: string): boolean {\n const {\n options: {\n dontSend\n }\n } = this;\n \n if (onceKey && this.once[onceKey]) { // 只需发送一次,已发送过,忽略\n return true;\n }\n \n if (dontSend?.() === true) { // dontSend 阻止发送\n return true;\n }\n \n if (typeof sampling === 'number' && sampling > 0 && sampling < 1) { // 采样,`(0, 1)` 开区间\n return Math.random() > sampling;\n }\n \n return false;\n }\n}\n"],"mappings":";;;;;;AAOA,SACEA,WAAW,EACXC,gBAAg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K;IACd;EAAC;AAAA;AAAA,SA1FkB1B,SAAS,IAAA4D,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"sls-pipe.js","names":["_chunk","getSilentCountdown","buildPostBody","SlsPipe","sender","options","_this","_classCallCheck","_defineProperty","silentCountdown","silentTime","silent","setTimeout","clearQueue","_createClass","key","value","pipe","payload","instant","sendLogs","queue","push","signalSend","length","refreshTimer","payloads","_this2","_this$options","trackUrl","apiVersion","maxChunk","forEach","v","body","JSON","stringify","String","clearTimer","timer","clearTimeout","_this3","waitTime","default"],"sources":["../../../src/class/sls-pipe.ts"],"sourcesContent":["import _chunk from 'lodash/chunk';\n\nimport {\n ISlsLogPayload,\n ISlsPipeOptions,\n ILogSender\n} from '../types';\nimport {\n getSilentCountdown,\n buildPostBody\n} from '../util';\n\n/**\n * SLS 日志管道,用于在一定的时间内积压日志,以避免造成业务请求性能问题\n */\nexport default class SlsPipe {\n private readonly sender: ILogSender;\n private readonly options: ISlsPipeOptions;\n private queue: ISlsLogPayload[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private silent = false;\n \n constructor(sender: ILogSender, options: ISlsPipeOptions) {\n this.sender = sender;\n this.options = options;\n \n const silentCountdown = getSilentCountdown(options.silentTime);\n \n if (silentCountdown > 0) {\n this.silent = true;\n \n setTimeout(() => {\n this.silent = false;\n this.clearQueue();\n }, silentCountdown);\n }\n }\n \n /**\n * 将日志推入队列,并通知发送\n */\n pipe(payload: ISlsLogPayload, instant?: boolean): void {\n if (instant) { // 即时发送\n this.sendLogs([payload]);\n \n return;\n }\n \n this.queue.push(payload);\n this.signalSend();\n }\n \n private signalSend(): void {\n if (!this.queue.length || this.silent) {\n return;\n }\n \n this.refreshTimer();\n }\n \n /**\n * 真正发送日志\n */\n private sendLogs(payloads: ISlsLogPayload[]): void {\n const {\n options: {\n trackUrl,\n apiVersion,\n maxChunk\n }\n } = this;\n \n _chunk(payloads, maxChunk).forEach(v => {\n const body = JSON.stringify(buildPostBody(v)); // buildPostBody 可以保证外边不会出 JSON 错误\n \n this.sender(trackUrl, body, {\n 'Content-Type': 'application/json',\n // 'x-log-compresstype': 'lz4'\n 'x-log-apiversion': apiVersion,\n 'x-log-bodyrawsize': String(body.length)\n });\n });\n }\n \n /**\n * 把队列中的日志全部发送并重置队列\n */\n private clearQueue(): void { // 必须是箭头函数,可以脱离 this\n this.clearTimer();\n this.sendLogs(this.queue);\n this.queue = [];\n }\n \n private clearTimer(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n \n private refreshTimer(): void {\n this.clearTimer();\n this.timer = setTimeout(() => this.clearQueue(), this.options.waitTime);\n }\n}\n"],"mappings":";;;AAAA,OAAOA,MAAM,MAAM,cAAc;AAOjC,SACEC,kBAAkB,EAClBC,aAAa,QACR,SAAS;;AAEhB;AACA;AACA;AAFA,IAGqBC,OAAO;EAO1B,SAAAA,QAAYC,MAAkB,EAAEC,OAAwB,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,OAAA;IAAAK,eAAA,gBAJxB,EAAE;IAAAA,eAAA,gBACkB,IAAI;IAAAA,eAAA,iBACzC,KAAK;IAGpB,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;IAEtB,IAAMI,eAAe,GAAGR,kBAAkB,CAACI,OAAO,CAACK,UAAU,CAAC;IAE9D,IAAID,eAAe,GAAG,CAAC,EAAE;MACvB,IAAI,CAACE,MAAM,GAAG,IAAI;MAElBC,UAAU,CAAC,YAAM;QACfN,KAAI,CAACK,MAAM,GAAG,KAAK;QACnBL,KAAI,CAACO,UAAU,CAAC,CAAC;MACnB,CAAC,EAAEJ,eAAe,CAAC;IACrB;EACF;;EAEA;AACF;AACA;EAFE,OAAAK,YAAA,CAAAX,OAAA;IAAAY,GAAA;IAAAC,KAAA,EAGA,SAAAC,IAAIA,CAACC,OAAuB,EAAEC,OAAiB,EAAQ;MACrD,IAAIA,OAAO,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zB,IAAI,CAACA,KAAK,GAAG,EAAE;IACjB;EAAC;IAAAN,GAAA;IAAAC,KAAA,EAED,SAAQsB,UAAUA,CAAA,EAAS;MACzB,IAAI,IAAI,CAACC,KAAK,EAAE;QACdC,YAAY,CAAC,IAAI,CAACD,KAAK,CAAC;QACxB,IAAI,CAACA,KAAK,GAAG,IAAI;MACnB;IACF;EAAC;IAAAxB,GAAA;IAAAC,KAAA,EAED,SAAQS,YAAYA,CAAA,EAAS;MAAA,IAAAgB,MAAA;MAC3B,IAAI,CAACH,UAAU,CAAC,CAAC;MACjB,IAAI,CAACC,KAAK,GAAG3B,UAAU,CAAC;QAAA,OAAM6B,MAAI,CAAC5B,UAAU,CAAC,CAAC;MAAA,GAAE,IAAI,CAACR,OAAO,CAACqC,QAAQ,CAAC;IACzE;EAAC;AAAA;AAAA,SAxFkBvC,OAAO,IAAAwC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"sls-pipe.js","names":["_chunk","getSilentCountdown","buildPostBody","SlsPipe","sender","options","_this","_classCallCheck","_defineProperty","silentCountdown","silentTime","silent","setTimeout","clearQueue","_createClass","key","value","pipe","payload","instant","sendLogs","queue","push","signalSend","length","refreshTimer","payloads","_this2","_this$options","trackUrl","apiVersion","maxChunk","forEach","v","body","JSON","stringify","String","clearTimer","timer","clearTimeout","_this3","waitTime","default"],"sources":["../../../src/class/sls-pipe.ts"],"sourcesContent":["import _chunk from 'lodash/chunk';\n\nimport {\n ISlsLogPayload,\n ISlsPipeOptions,\n TLogSender\n} from '../types';\nimport {\n getSilentCountdown,\n buildPostBody\n} from '../util';\n\n/**\n * SLS 日志管道,用于在一定的时间内积压日志,以避免造成业务请求性能问题\n */\nexport default class SlsPipe {\n private readonly sender: TLogSender;\n private readonly options: ISlsPipeOptions;\n private queue: ISlsLogPayload[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private silent = false;\n \n constructor(sender: TLogSender, options: ISlsPipeOptions) {\n this.sender = sender;\n this.options = options;\n \n const silentCountdown = getSilentCountdown(options.silentTime);\n \n if (silentCountdown > 0) {\n this.silent = true;\n \n setTimeout(() => {\n this.silent = false;\n this.clearQueue();\n }, silentCountdown);\n }\n }\n \n /**\n * 将日志推入队列,并通知发送\n */\n pipe(payload: ISlsLogPayload, instant?: boolean): void {\n if (instant) { // 即时发送\n this.sendLogs([payload]);\n \n return;\n }\n \n this.queue.push(payload);\n this.signalSend();\n }\n \n private signalSend(): void {\n if (!this.queue.length || this.silent) {\n return;\n }\n \n this.refreshTimer();\n }\n \n /**\n * 真正发送日志\n */\n private sendLogs(payloads: ISlsLogPayload[]): void {\n const {\n options: {\n trackUrl,\n apiVersion,\n maxChunk\n }\n } = this;\n \n _chunk(payloads, maxChunk).forEach(v => {\n const body = JSON.stringify(buildPostBody(v)); // buildPostBody 可以保证外边不会出 JSON 错误\n \n this.sender(trackUrl, body, {\n 'Content-Type': 'application/json',\n // 'x-log-compresstype': 'lz4'\n 'x-log-apiversion': apiVersion,\n 'x-log-bodyrawsize': String(body.length)\n });\n });\n }\n \n /**\n * 把队列中的日志全部发送并重置队列\n */\n private clearQueue(): void { // 必须是箭头函数,可以脱离 this\n this.clearTimer();\n this.sendLogs(this.queue);\n this.queue = [];\n }\n \n private clearTimer(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n \n private refreshTimer(): void {\n this.clearTimer();\n this.timer = setTimeout(() => this.clearQueue(), this.options.waitTime);\n }\n}\n"],"mappings":";;;AAAA,OAAOA,MAAM,MAAM,cAAc;AAOjC,SACEC,kBAAkB,EAClBC,aAAa,QACR,SAAS;;AAEhB;AACA;AACA;AAFA,IAGqBC,OAAO;EAO1B,SAAAA,QAAYC,MAAkB,EAAEC,OAAwB,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,OAAA;IAAAK,eAAA,gBAJxB,EAAE;IAAAA,eAAA,gBACkB,IAAI;IAAAA,eAAA,iBACzC,KAAK;IAGpB,IAAI,CAACJ,MAAM,GA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AAGC,IAAI,CAACC,SAAS,CAAClC,aAAa,CAAC+B,CAAC,CAAC,CAAC,CAAC,CAAC;;QAE/CN,MAAI,CAACvB,MAAM,CAACyB,QAAQ,EAAEK,IAAI,EAAE;UAC1B,cAAc,EAAE,kBAAkB;UAClC;UACA,kBAAkB,EAAEJ,UAAU;UAC9B,mBAAmB,EAAEO,MAAM,CAACH,IAAI,CAACV,MAAM;QACzC,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ;;IAEA;AACF;AACA;EAFE;IAAAT,GAAA;IAAAC,KAAA,EAGA,SAAQH,UAAUA,CAAA,EAAS;MAAE;MAC3B,IAAI,CAACyB,UAAU,CAAC,CAAC;MACjB,IAAI,CAAClB,QAAQ,CAAC,IAAI,CAACC,KAAK,CAAC;MACzB,IAAI,CAACA,KAAK,GAAG,EAAE;IACjB;EAAC;IAAAN,GAAA;IAAAC,KAAA,EAED,SAAQsB,UAAUA,CAAA,EAAS;MACzB,IAAI,IAAI,CAACC,KAAK,EAAE;QACdC,YAAY,CAAC,IAAI,CAACD,KAAK,CAAC;QACxB,IAAI,CAACA,KAAK,GAAG,IAAI;MACnB;IACF;EAAC;IAAAxB,GAAA;IAAAC,KAAA,EAED,SAAQS,YAAYA,CAAA,EAAS;MAAA,IAAAgB,MAAA;MAC3B,IAAI,CAACH,UAAU,CAAC,CAAC;MACjB,IAAI,CAACC,KAAK,GAAG3B,UAAU,CAAC;QAAA,OAAM6B,MAAI,CAAC5B,UAAU,CAAC,CAAC;MAAA,GAAE,IAAI,CAACR,OAAO,CAACqC,QAAQ,CAAC;IACzE;EAAC;AAAA;AAAA,SAxFkBvC,OAAO,IAAAwC,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["TOPIC_MERGED","API_VERSION","PIPE_SILENT_TIME","PIPE_WAIT_TIME","PIPE_MAX_CHUNK"],"sources":["../../../src/const/index.ts"],"sourcesContent":["/**\n * 合并日志的最外层的 topic\n */\nexport const TOPIC_MERGED = 'SLS_MERGED';\n\n/**\n * 定死的 API 版本,GET 的时候为参数 `APIVersion`,POST 的时候为 header `x-log-apiversion`\n */\nexport const API_VERSION = '0.6.0';\n\nexport const PIPE_SILENT_TIME = 5000;\n\nexport const PIPE_WAIT_TIME = 200;\n\nexport const PIPE_MAX_CHUNK = 50;"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,YAAY;;AAExC;AACA;AACA;AACA,OAAO,IAAMC,WAAW,GAAG,OAAO;AAElC,OAAO,IAAMC,gBAAgB,GAAG,IAAI;AAEpC,OAAO,IAAMC,cAAc,GAAG,GAAG;AAEjC,OAAO,IAAMC,cAAc,GAAG,EAAE","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["TOPIC_MERGED","API_VERSION","PIPE_SILENT_TIME","PIPE_WAIT_TIME","PIPE_MAX_CHUNK"],"sources":["../../../src/const/index.ts"],"sourcesContent":["/**\n * 合并日志的最外层的 topic\n */\nexport const TOPIC_MERGED = 'SLS_MERGED';\n\n/**\n * 定死的 API 版本,GET 的时候为参数 `APIVersion`,POST 的时候为 header `x-log-apiversion`\n */\nexport const API_VERSION = '0.6.0';\n\nexport const PIPE_SILENT_TIME = 5000;\n\nexport const PIPE_WAIT_TIME = 200;\n\nexport const PIPE_MAX_CHUNK = 50;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,YAAY;;AAExC;AACA;AACA;AACA,OAAO,IAAMC,WAAW,GAAG,OAAO;AAElC,OAAO,IAAMC,gBAAgB,GAAG,IAAI;AAEpC,OAAO,IAAMC,cAAc,GAAG,GAAG;AAEjC,OAAO,IAAMC,cAAc,GAAG,EAAE","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"create-logger.js","names":["SlsLogger","createSlsLogQuick","createLogger","sender","options","logger","sls","log","debug","info","warn","error","fatal"],"sources":["../../../src/factory/create-logger.ts"],"sourcesContent":["import {\n ICreateLoggerOptions,\n ISlsLogger,\n ILogSender\n} from '../types';\nimport {\n SlsLogger\n} from '../class';\nimport {\n createSlsLogQuick\n} from '../util';\n\n/**\n * 创建 Logger 方法\n */\nexport default function createLogger(sender: ILogSender, options: ICreateLoggerOptions): ISlsLogger {\n const logger = new SlsLogger(sender, options);\n const sls = logger.log as ISlsLogger;\n \n sls.debug = createSlsLogQuick(sls, 'DEBUG');\n sls.log = createSlsLogQuick(sls, 'LOG');\n sls.info = createSlsLogQuick(sls, 'INFO');\n sls.warn = createSlsLogQuick(sls, 'WARN');\n sls.error = createSlsLogQuick(sls, 'ERROR');\n sls.fatal = createSlsLogQuick(sls, 'FATAL');\n \n return sls;\n}"],"mappings":"AAKA,SACEA,SAAS,QACJ,UAAU;AACjB,SACEC,iBAAiB,QACZ,SAAS;;AAEhB;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,MAAkB,EAAEC,OAA6B,EAAc;EAClG,IAAMC,MAAM,GAAG,IAAIL,SAAS,CAACG,MAAM,EAAEC,OAAO,CAAC;EAC7C,IAAME,GAAG,GAAGD,MAAM,CAACE,GAAiB;EAEpCD,GAAG,CAACE,KAAK,GAAGP,iBAAiB,CAACK,GAAG,EAAE,OAAO,CAAC;EAC3CA,GAAG,CAACC,GAAG,GAAGN,iBAAiB,CAACK,GAAG,EAAE,KAAK,CAAC;EACvCA,GAAG,CAACG,IAAI,GAAGR,iBAAiB,CAACK,GAAG,EAAE,MAAM,CAAC;EACzCA,GAAG,CAACI,IAAI,GAAGT,iBAAiB,CAACK,GAAG,EAAE,MAAM,CAAC;EACzCA,GAAG,CAACK,KAAK,GAAGV,iBAAiB,CAACK,GAAG,EAAE,OAAO,CAAC;EAC3CA,GAAG,CAACM,KAAK,GAAGX,iBAAiB,CAACK,GAAG,EAAE,OAAO,CAAC;EAE3C,OAAOA,GAAG;AACZ","ignoreList":[]}
1
+ {"version":3,"file":"create-logger.js","names":["SlsLogger","createSlsLogQuick","createLogger","sender","options","logger","sls","log","debug","info","warn","error","fatal"],"sources":["../../../src/factory/create-logger.ts"],"sourcesContent":["import {\n ICreateLoggerOptions,\n ISlsLogger,\n TLogSender\n} from '../types';\nimport {\n SlsLogger\n} from '../class';\nimport {\n createSlsLogQuick\n} from '../util';\n\n/**\n * 创建 Logger 方法\n */\nexport default function createLogger(sender: TLogSender, options: ICreateLoggerOptions): ISlsLogger {\n const logger = new SlsLogger(sender, options);\n const sls = logger.log as ISlsLogger;\n \n sls.debug = createSlsLogQuick(sls, 'DEBUG');\n sls.log = createSlsLogQuick(sls, 'LOG');\n sls.info = createSlsLogQuick(sls, 'INFO');\n sls.warn = createSlsLogQuick(sls, 'WARN');\n sls.error = createSlsLogQuick(sls, 'ERROR');\n sls.fatal = createSlsLogQuick(sls, 'FATAL');\n \n return sls;\n}\n"],"mappings":"AAKA,SACEA,SAAS,QACJ,UAAU;AACjB,SACEC,iBAAiB,QACZ,SAAS;;AAEhB;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,MAAkB,EAAEC,OAA6B,EAAc;EAClG,IAAMC,MAAM,GAAG,IAAIL,SAAS,CAACG,MAAM,EAAEC,OAAO,CAAC;EAC7C,IAAME,GAAG,GAAGD,MAAM,CAACE,GAAiB;EAEpCD,GAAG,CAACE,KAAK,GAAGP,iBAAiB,CAACK,GAAG,EAAE,OAAO,CAAC;EAC3CA,GAAG,CAACC,GAAG,GAAGN,iBAAiB,CAACK,GAAG,EAAE,KAAK,CAAC;EACvCA,GAAG,CAACG,IAAI,GAAGR,iBAAiB,CAACK,GAAG,EAAE,MAAM,CAAC;EACzCA,GAAG,CAACI,IAAI,GAAGT,iBAAiB,CAACK,GAAG,EAAE,MAAM,CAAC;EACzCA,GAAG,CAACK,KAAK,GAAGV,iBAAiB,CAACK,GAAG,EAAE,OAAO,CAAC;EAC3CA,GAAG,CAACM,KAAK,GAAGX,iBAAiB,CAACK,GAAG,EAAE,OAAO,CAAC;EAE3C,OAAOA,GAAG;AACZ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-create-logger.js","names":["mergeDefaultParams","mergeDontSend","createLogger","generateCreateLogger","sender","_ref","factoryDefaultParams","defaultParams","factoryDontSend","dontSend","_ref2","options","_objectWithoutProperties","_excluded","_objectSpread"],"sources":["../../../src/factory/generate-create-logger.ts"],"sourcesContent":["import {\n ILogSender,\n ICreateLogger,\n ICreateLoggerOptions,\n IGenerateCreateLoggerOptions\n} from '../types';\nimport {\n mergeDefaultParams,\n mergeDontSend\n} from '../util';\n\nimport createLogger from './create-logger';\n\n/**\n * 创建 `createLogger` 方法的方法,对期望扩展默认参数的场景做了规范。\n *\n * 一般不会在项目中直接使用,而是用来写可复用 npm 包。\n */\nexport default function generateCreateLogger(sender: ILogSender, {\n defaultParams: factoryDefaultParams,\n dontSend: factoryDontSend\n}: IGenerateCreateLoggerOptions): ICreateLogger {\n return ({\n defaultParams,\n dontSend,\n ...options\n }: ICreateLoggerOptions) => createLogger(sender, {\n defaultParams: mergeDefaultParams(factoryDefaultParams, defaultParams),\n dontSend: mergeDontSend(factoryDontSend, dontSend),\n ...options\n });\n}"],"mappings":";;;AAMA,SACEA,kBAAkB,EAClBC,aAAa,QACR,SAAS;AAEhB,OAAOC,YAAY,MAAM,iBAAiB;;AAE1C;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,oBAAoBA,CAACC,MAAkB,EAAAC,IAAA,EAGf;EAAA,IAF/BC,oBAAoB,GAAAD,IAAA,CAAnCE,aAAa;IACHC,eAAe,GAAAH,IAAA,CAAzBI,QAAQ;EAER,OAAO,UAAAC,KAAA;IAAA,IACLH,aAAa,GAAAG,KAAA,CAAbH,aAAa;MACbE,QAAQ,GAAAC,KAAA,CAARD,QAAQ;MACLE,OAAO,GAAAC,wBAAA,CAAAF,KAAA,EAAAG,SAAA;IAAA,OACgBX,YAAY,CAACE,MAAM,EAAAU,aAAA;MAC7CP,aAAa,EAAEP,kBAAkB,CAACM,oBAAoB,EAAEC,aAAa,CAAC;MACtEE,QAAQ,EAAER,aAAa,CAACO,eAAe,EAAEC,QAAQ;IAAC,GAC/CE,OAAO,CACX,CAAC;EAAA;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"generate-create-logger.js","names":["mergeDefaultParams","mergeDontSend","createLogger","generateCreateLogger","sender","_ref","factoryDefaultParams","defaultParams","factoryDontSend","dontSend","_ref2","options","_objectWithoutProperties","_excluded","_objectSpread"],"sources":["../../../src/factory/generate-create-logger.ts"],"sourcesContent":["import {\n TLogSender,\n ICreateLogger,\n ICreateLoggerOptions,\n IGenerateCreateLoggerOptions\n} from '../types';\nimport {\n mergeDefaultParams,\n mergeDontSend\n} from '../util';\n\nimport createLogger from './create-logger';\n\n/**\n * 创建 `createLogger` 方法的方法,对期望扩展默认参数的场景做了规范。\n *\n * 一般不会在项目中直接使用,而是用来写可复用 npm 包。\n */\nexport default function generateCreateLogger(sender: TLogSender, {\n defaultParams: factoryDefaultParams,\n dontSend: factoryDontSend\n}: IGenerateCreateLoggerOptions): ICreateLogger {\n return ({\n defaultParams,\n dontSend,\n ...options\n }: ICreateLoggerOptions) => createLogger(sender, {\n defaultParams: mergeDefaultParams(factoryDefaultParams, defaultParams),\n dontSend: mergeDontSend(factoryDontSend, dontSend),\n ...options\n });\n}\n"],"mappings":";;;AAMA,SACEA,kBAAkB,EAClBC,aAAa,QACR,SAAS;AAEhB,OAAOC,YAAY,MAAM,iBAAiB;;AAE1C;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,oBAAoBA,CAACC,MAAkB,EAAAC,IAAA,EAGf;EAAA,IAF/BC,oBAAoB,GAAAD,IAAA,CAAnCE,aAAa;IACHC,eAAe,GAAAH,IAAA,CAAzBI,QAAQ;EAER,OAAO,UAAAC,KAAA;IAAA,IACLH,aAAa,GAAAG,KAAA,CAAbH,aAAa;MACbE,QAAQ,GAAAC,KAAA,CAARD,QAAQ;MACLE,OAAO,GAAAC,wBAAA,CAAAF,KAAA,EAAAG,SAAA;IAAA,OACgBX,YAAY,CAACE,MAAM,EAAAU,aAAA;MAC7CP,aAAa,EAAEP,kBAAkB,CAACM,oBAAoB,EAAEC,aAAa,CAAC;MACtEE,QAAQ,EAAER,aAAa,CAACO,eAAe,EAAEC,QAAQ;IAAC,GAC/CE,OAAO,CACX,CAAC;EAAA;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","generateCreateLoggerBase"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './factory/create-logger';\nexport { default as generateCreateLoggerBase } from './factory/generate-create-logger';\n\nexport type {\n ICreateLogger as CreateLogger,\n ICreateLoggerOptions as CreateLoggerOptions,\n IGenerateCreateLoggerOptions as GenerateCreateLoggerOptions,\n ISlsLogger as SlsLogger,\n ISlsLogOptions as SlsLogOptions,\n ISlsLogOptionsQuick as SlsLogOptionsQuick,\n ISlsPostBody as SlsPostBody\n} from './types';"],"mappings":"AAAA,SAASA,OAAO,QAAQ,yBAAyB;AACjD,SAASA,OAAO,IAAIC,wBAAwB,QAAQ,kCAAkC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","generateCreateLoggerBase"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './factory/create-logger';\nexport { default as generateCreateLoggerBase } from './factory/generate-create-logger';\n\nexport type {\n ICreateLogger as CreateLogger,\n ICreateLoggerOptions as CreateLoggerOptions,\n IGenerateCreateLoggerOptions as GenerateCreateLoggerOptions,\n ISlsLogger as SlsLogger,\n ISlsLogOptions as SlsLogOptions,\n ISlsLogOptionsQuick as SlsLogOptionsQuick,\n ISlsPostBody as SlsPostBody\n} from './types';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,yBAAyB;AACjD,SAASA,OAAO,IAAIC,wBAAwB,QAAQ,kCAAkC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":[],"sources":["../../../src/types/common.ts"],"sourcesContent":["export interface IDefaultParams {\n (): Record<string, unknown>;\n}\n\nexport type TDefaultParams = Record<string, unknown> | IDefaultParams;\n\nexport interface IDontSend {\n (): void | boolean;\n}\n\n/**\n * 真正发送请求的实现逻辑(以支持多平台的需求),注意必需用 POST\n */\nexport interface ILogSender {\n (trackUrl: string, body: string, headers: Record<string, string>): void;\n}\n\nexport type TFlattenPathTester = string | RegExp | Array<string | RegExp>;\n\nexport interface ISlsLogPayload {\n __topic__: string;\n [k: string]: unknown;\n}\n\nexport interface ISlsPostBody {\n __topic__: string;\n __logs__: Record<string, string>[];\n // __source__?: string;\n // __tags__?: Record<string, string>;\n}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"common.js","names":[],"sources":["../../../src/types/common.ts"],"sourcesContent":["export type TFnDefaultParams = () => Record<string, unknown>;\n\nexport type TDefaultParams = Record<string, unknown> | TFnDefaultParams;\n\nexport type TDontSend = () => undefined | boolean;\n\n/**\n * 真正发送请求的实现逻辑(以支持多平台的需求),注意必需用 POST\n */\nexport type TLogSender = (trackUrl: string, body: string, headers: Record<string, string>) => void;\n\nexport type TFlattenPathTester = string | RegExp | (string | RegExp)[];\n\nexport interface ISlsLogPayload {\n __topic__: string;\n [k: string]: unknown;\n}\n\nexport interface ISlsPostBody {\n __topic__: string;\n __logs__: Record<string, string>[];\n // __source__?: string;\n // __tags__?: Record<string, string>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","names":[],"sources":["../../../src/types/factory.ts"],"sourcesContent":["import {\n ICreateLoggerOptions,\n ISlsLogOptionsQuick,\n ISlsLogOptions\n} from './options';\n\nexport type TLogArgs = [string, Record<string, unknown>?] | [ISlsLogOptions, string, Record<string, unknown>?];\nexport type TLogQuickArgs = [string, Record<string, unknown>?] | [ISlsLogOptionsQuick, string, Record<string, unknown>?];\n\nexport interface ISlsLogFn {\n (topic: string): void;\n <P extends object>(topic: string, payload: P): void;\n (options: ISlsLogOptions, topic: string): void;\n <P extends object>(options: ISlsLogOptions, topic: string, payload: P): void;\n}\n\nexport interface ISlsLogFnQuick {\n (topic: string): void;\n <P extends object>(topic: string, payload: P): void;\n (options: ISlsLogOptionsQuick, topic: string): void;\n <P extends object>(options: ISlsLogOptionsQuick, topic: string, payload: P): void;\n}\n\nexport interface ISlsLogger {\n (topic: string): void;\n <P extends object>(topic: string, payload: P): void;\n (options: ISlsLogOptions, topic: string): void;\n <P extends object>(options: ISlsLogOptions, topic: string, payload: P): void;\n debug: ISlsLogFnQuick;\n log: ISlsLogFnQuick;\n info: ISlsLogFnQuick;\n warn: ISlsLogFnQuick;\n error: ISlsLogFnQuick;\n fatal: ISlsLogFnQuick;\n}\n\nexport interface ICreateLogger {\n (options: ICreateLoggerOptions): ISlsLogger;\n}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"factory.js","names":[],"sources":["../../../src/types/factory.ts"],"sourcesContent":["import {\n ICreateLoggerOptions,\n ISlsLogOptionsQuick,\n ISlsLogOptions\n} from './options';\n\nexport type TLogArgs = [string, Record<string, unknown>?] | [ISlsLogOptions, string, Record<string, unknown>?];\nexport type TLogQuickArgs = [string, Record<string, unknown>?] | [ISlsLogOptionsQuick, string, Record<string, unknown>?];\n\nexport interface ISlsLogFn {\n (topic: string): void;\n <P extends object>(topic: string, payload: P): void;\n (options: ISlsLogOptions, topic: string): void;\n <P extends object>(options: ISlsLogOptions, topic: string, payload: P): void;\n}\n\nexport interface ISlsLogFnQuick {\n (topic: string): void;\n <P extends object>(topic: string, payload: P): void;\n (options: ISlsLogOptionsQuick, topic: string): void;\n <P extends object>(options: ISlsLogOptionsQuick, topic: string, payload: P): void;\n}\n\nexport interface ISlsLogger {\n (topic: string): void;\n <P extends object>(topic: string, payload: P): void;\n (options: ISlsLogOptions, topic: string): void;\n <P extends object>(options: ISlsLogOptions, topic: string, payload: P): void;\n debug: ISlsLogFnQuick;\n log: ISlsLogFnQuick;\n info: ISlsLogFnQuick;\n warn: ISlsLogFnQuick;\n error: ISlsLogFnQuick;\n fatal: ISlsLogFnQuick;\n}\n\nexport type ICreateLogger = (options: ICreateLoggerOptions) => ISlsLogger;\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","names":[],"sources":["../../../src/types/options.ts"],"sourcesContent":["import {\n TDefaultParams,\n TFlattenPathTester,\n IDontSend\n} from './common';\n\nexport interface ISlsPipeOptions {\n trackUrl: string;\n /**\n * 不知所谓的参数,但必需,说是保留字段,默认 `0.6.0`(文档中的版本号),请不要使用\n */\n apiVersion: string;\n /**\n * 应用初始化后,多少时间内对日志请求进行冷冻处理,以让行业务请求,提升业务性能\n *\n * 默认 5000ms\n */\n silentTime: number;\n /**\n * 调用方法到日志被真正发送的等待时间,这段时间内,若有新的日志进来,会被合并并重新计时\n *\n * 默认 200ms\n */\n waitTime: number;\n /**\n * 一次最多发送日志条数,若积累的日志数超过,将切成多个请求发送\n *\n * 默认 50\n */\n maxChunk: number;\n}\n\nexport interface ICreateLoggerOptions extends Partial<ISlsPipeOptions> {\n /**\n * logstore 所在的 SLS project\n */\n project: string;\n /**\n * project 的外网访问域名,在 SLS 控制台 project 概览页可以找到,\n * 如 `cn-hangzhou.log.aliyuncs.com`(仅跟 project 所在地域有关)\n */\n endpoint: string;\n /**\n * SLS project 下的 logstore,必须开通 Web Tracking 功能,日志记录的存储点\n */\n logstore: string;\n /**\n * 当希望同一个模块的日志使用统一的前缀,又不想每次调用的时候写,可以用这个\n */\n prefix?: string;\n /**\n * 生产出的日志方法的整体采样率,可在调用时由方法参数覆盖,范围为 (0, 1],默认 1\n */\n sampling?: number;\n /**\n * 默认参数,避免每次都要传,可以是静态数据或产生动态数据的方法,这些参数可以覆盖自动记录的参数,\n * 但会被日志方法的第二个参数 `params` 中对应的字段覆盖\n */\n defaultParams?: TDefaultParams;\n /**\n * 上报之前进行判断是否继续,返回 true 以阻止上报\n *\n * 在某些场景下需要禁用日志上报功能,比如可能禁止日志跨境\n */\n dontSend?: IDontSend;\n}\n\n/**\n * 生成 `createLogger` 方法的工厂方法的 options,用于制定工厂级别的参数的忽略方法\n */\nexport interface IGenerateCreateLoggerOptions {\n defaultParams?: TDefaultParams;\n dontSend?: IDontSend;\n}\n\nexport interface IFlattenOptions {\n scope?: string;\n depth?: number;\n /**\n * 将属性从结果中剔除\n */\n omit?: TFlattenPathTester;\n /**\n * 将属性直接输出,提前结束该属性深度\n */\n direct?: TFlattenPathTester;\n}\n\n/**\n * SLS 日志方法 Options\n */\nexport interface ISlsLogOptions {\n /**\n * 覆盖 IFactoryOptions 的 prefix 设置,仅针对当前日志\n */\n prefix?: string;\n /**\n * 覆盖 IFactoryOptions 的 sampling 设置,仅针对当前日志\n */\n sampling?: number;\n /**\n * 有日志只需要在应用起来后记录一次,后续的将被丢弃\n *\n * - true 表示以该 topic 做判断,针对该 topic 只记录一次\n * - 如果是字符串,则以「topic + 此字符串」做判断\n */\n once?: true | string;\n /**\n * 日志不是强需求,不能压过业务,要业务先行。网络请求一般在页面的一开始最密集,如果日志在这时上报会造成网络阻塞而产生性能问题。\n *\n * 办法是先积压着,等到时间到了,再把积压着的日志一起上报。\n *\n * 所以,为了提升性能,做了以下事情:\n *\n * 1. 应用起来后,有一定的静默时间,这段时间的日志会被积压,用于给应用的请求让路\n * 2. 整体或单个日志的延时时间\n * 3. 整体或单个日志的采样率\n * 4. 有的日志只会发送一次\n * 5. 日志发送前也有一个很短的等待时间,在这段时间内,如果有新的日志进来,也将被积压,并重新计时\n * 6. 最后,积压的日志利用 POST 请求对日志进行合并发送\n *\n * 然而,总有例外,有的日志希望是即时的,比如需要拿它来算 PvUv,instant 就是为此而生。\n * 注意:instant 会忽略延时,但不会忽略采样率\n */\n instant?: boolean;\n /**\n * 是否对 info 进行 flatten 操作\n */\n flatten?: boolean | string | IFlattenOptions;\n /**\n * 为日志增加默认参数 `_GROUP`,可用于数据分析分组\n */\n group?: string;\n}\n\n/**\n * SLS 快捷方法 Options\n */\nexport interface ISlsLogOptionsQuick extends Omit<ISlsLogOptions, 'group'> {}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"options.js","names":[],"sources":["../../../src/types/options.ts"],"sourcesContent":["import {\n TDefaultParams,\n TFlattenPathTester,\n TDontSend\n} from './common';\n\nexport interface ISlsPipeOptions {\n trackUrl: string;\n /**\n * 不知所谓的参数,但必需,说是保留字段,默认 `0.6.0`(文档中的版本号),请不要使用\n */\n apiVersion: string;\n /**\n * 应用初始化后,多少时间内对日志请求进行冷冻处理,以让行业务请求,提升业务性能\n *\n * 默认 5000ms\n */\n silentTime: number;\n /**\n * 调用方法到日志被真正发送的等待时间,这段时间内,若有新的日志进来,会被合并并重新计时\n *\n * 默认 200ms\n */\n waitTime: number;\n /**\n * 一次最多发送日志条数,若积累的日志数超过,将切成多个请求发送\n *\n * 默认 50\n */\n maxChunk: number;\n}\n\nexport interface ICreateLoggerOptions extends Partial<ISlsPipeOptions> {\n /**\n * logstore 所在的 SLS project\n */\n project: string;\n /**\n * project 的外网访问域名,在 SLS 控制台 project 概览页可以找到,\n * 如 `cn-hangzhou.log.aliyuncs.com`(仅跟 project 所在地域有关)\n */\n endpoint: string;\n /**\n * SLS project 下的 logstore,必须开通 Web Tracking 功能,日志记录的存储点\n */\n logstore: string;\n /**\n * 当希望同一个模块的日志使用统一的前缀,又不想每次调用的时候写,可以用这个\n */\n prefix?: string;\n /**\n * 生产出的日志方法的整体采样率,可在调用时由方法参数覆盖,范围为 (0, 1],默认 1\n */\n sampling?: number;\n /**\n * 默认参数,避免每次都要传,可以是静态数据或产生动态数据的方法,这些参数可以覆盖自动记录的参数,\n * 但会被日志方法的第二个参数 `params` 中对应的字段覆盖\n */\n defaultParams?: TDefaultParams;\n /**\n * 上报之前进行判断是否继续,返回 true 以阻止上报\n *\n * 在某些场景下需要禁用日志上报功能,比如可能禁止日志跨境\n */\n dontSend?: TDontSend;\n}\n\n/**\n * 生成 `createLogger` 方法的工厂方法的 options,用于制定工厂级别的参数的忽略方法\n */\nexport interface IGenerateCreateLoggerOptions {\n defaultParams?: TDefaultParams;\n dontSend?: TDontSend;\n}\n\nexport interface IFlattenOptions {\n scope?: string;\n depth?: number;\n /**\n * 将属性从结果中剔除\n */\n omit?: TFlattenPathTester;\n /**\n * 将属性直接输出,提前结束该属性深度\n */\n direct?: TFlattenPathTester;\n}\n\n/**\n * SLS 日志方法 Options\n */\nexport interface ISlsLogOptions {\n /**\n * 覆盖 IFactoryOptions 的 prefix 设置,仅针对当前日志\n */\n prefix?: string;\n /**\n * 覆盖 IFactoryOptions 的 sampling 设置,仅针对当前日志\n */\n sampling?: number;\n /**\n * 有日志只需要在应用起来后记录一次,后续的将被丢弃\n *\n * - true 表示以该 topic 做判断,针对该 topic 只记录一次\n * - 如果是字符串,则以「topic + 此字符串」做判断\n */\n once?: true | string;\n /**\n * 日志不是强需求,不能压过业务,要业务先行。网络请求一般在页面的一开始最密集,如果日志在这时上报会造成网络阻塞而产生性能问题。\n *\n * 办法是先积压着,等到时间到了,再把积压着的日志一起上报。\n *\n * 所以,为了提升性能,做了以下事情:\n *\n * 1. 应用起来后,有一定的静默时间,这段时间的日志会被积压,用于给应用的请求让路\n * 2. 整体或单个日志的延时时间\n * 3. 整体或单个日志的采样率\n * 4. 有的日志只会发送一次\n * 5. 日志发送前也有一个很短的等待时间,在这段时间内,如果有新的日志进来,也将被积压,并重新计时\n * 6. 最后,积压的日志利用 POST 请求对日志进行合并发送\n *\n * 然而,总有例外,有的日志希望是即时的,比如需要拿它来算 PvUv,instant 就是为此而生。\n * 注意:instant 会忽略延时,但不会忽略采样率\n */\n instant?: boolean;\n /**\n * 是否对 info 进行 flatten 操作\n */\n flatten?: boolean | string | IFlattenOptions;\n /**\n * 为日志增加默认参数 `_GROUP`,可用于数据分析分组\n */\n group?: string;\n}\n\n/**\n * SLS 快捷方法 Options\n */\nexport interface ISlsLogOptionsQuick extends Omit<ISlsLogOptions, 'group'> {}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"build-post-body.js","names":["TOPIC_MERGED","convertLogInfo","buildPostBody","payloads","topic","length","__topic__","__logs__","map"],"sources":["../../../src/util/build-post-body.ts"],"sourcesContent":["import type {\n ISlsLogPayload,\n ISlsPostBody\n} from '../types';\nimport {\n TOPIC_MERGED\n} from '../const';\n\nimport convertLogInfo from './convert-log-info';\n\n/**\n * 利用 PutWebTracking 发送日志,如果 `__logs__` 里含有 `__topic__` 则,外部的这个 `__topic__` 将被改为 `__topic__0`,\n * 为了干净,在仅发送一条日志的时候,将 `__logs__` 里的 `__topic__` 往上提。\n *\n * 但是,POST 的时候 `__source__` 不会被默认填充成 IP,IP 在 `__tag__:__client_ip__`(GET 方式也有)\n */\nexport default function buildPostBody(payloads: ISlsLogPayload[]): ISlsPostBody {\n let topic = TOPIC_MERGED;\n \n if (payloads.length === 1) {\n topic = payloads[0]!.__topic__; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n \n return {\n __topic__: topic,\n __logs__: payloads.map(convertLogInfo)\n };\n}"],"mappings":"AAIA,SACEA,YAAY,QACP,UAAU;AAEjB,OAAOC,cAAc,MAAM,oBAAoB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAACC,QAA0B,EAAgB;EAC9E,IAAIC,KAAK,GAAGJ,YAAY;EAExB,IAAIG,QAAQ,CAACE,MAAM,KAAK,CAAC,EAAE;IACzBD,KAAK,GAAGD,QAAQ,CAAC,CAAC,CAAC,CAAEG,SAAS,CAAC,CAAC;EAClC;EAEA,OAAO;IACLA,SAAS,EAAEF,KAAK;IAChBG,QAAQ,EAAEJ,QAAQ,CAACK,GAAG,CAACP,cAAc;EACvC,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"build-post-body.js","names":["TOPIC_MERGED","convertLogInfo","buildPostBody","payloads","topic","length","__topic__","__logs__","map"],"sources":["../../../src/util/build-post-body.ts"],"sourcesContent":["import {\n ISlsLogPayload,\n ISlsPostBody\n} from '../types';\nimport {\n TOPIC_MERGED\n} from '../const';\n\nimport convertLogInfo from './convert-log-info';\n\n/**\n * 利用 PutWebTracking 发送日志,如果 `__logs__` 里含有 `__topic__` 则,外部的这个 `__topic__` 将被改为 `__topic__0`,\n * 为了干净,在仅发送一条日志的时候,将 `__logs__` 里的 `__topic__` 往上提。\n *\n * 但是,POST 的时候 `__source__` 不会被默认填充成 IP,IP 在 `__tag__:__client_ip__`(GET 方式也有)\n */\nexport default function buildPostBody(payloads: ISlsLogPayload[]): ISlsPostBody {\n let topic = TOPIC_MERGED;\n \n if (payloads.length === 1) {\n topic = payloads[0]!.__topic__; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n \n return {\n __topic__: topic,\n __logs__: payloads.map(convertLogInfo)\n };\n}\n"],"mappings":"AAIA,SACEA,YAAY,QACP,UAAU;AAEjB,OAAOC,cAAc,MAAM,oBAAoB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAACC,QAA0B,EAAgB;EAC9E,IAAIC,KAAK,GAAGJ,YAAY;EAExB,IAAIG,QAAQ,CAACE,MAAM,KAAK,CAAC,EAAE;IACzBD,KAAK,GAAGD,QAAQ,CAAC,CAAC,CAAC,CAAEG,SAAS,CAAC,CAAC;EAClC;EAEA,OAAO;IACLA,SAAS,EAAEF,KAAK;IAChBG,QAAQ,EAAEJ,QAAQ,CAACK,GAAG,CAACP,cAAc;EACvC,CAAC;AACH","ignoreList":[]}
@@ -19,7 +19,7 @@ export default function convertLogInfo(info) {
19
19
  try {
20
20
  // 避免 cyclic error
21
21
  o[k] = JSON.stringify(v);
22
- } catch (err) {
22
+ } catch (_err) {
23
23
  o[k] = 'TypeError: cyclic object value';
24
24
  }
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"convert-log-info.js","names":["convertLogInfo","info","o","Object","keys","forEach","k","v","undefined","toString","JSON","stringify","err","_TOPIC","__topic__"],"sources":["../../../src/util/convert-log-info.ts"],"sourcesContent":["import type {\n ISlsLogPayload\n} from '../types';\n\n/**\n * 发送的 JSON 里边不可以有除了字符串以外的值,否则报错\n *\n * - code = PostBodyInvalid\n * - message = Value in log is not string data type\n */\nexport default function convertLogInfo(info: ISlsLogPayload): Record<string, string> {\n const o: Record<string, string> = {};\n \n Object.keys(info).forEach(k => {\n const v = info[k];\n \n if (v === '' || v === null || v === undefined) {\n return;\n }\n \n if (typeof v === 'string') {\n o[k] = v;\n } else if (typeof v === 'number' || typeof v === 'boolean') {\n o[k] = v.toString();\n } else {\n try { // 避免 cyclic error\n o[k] = JSON.stringify(v);\n } catch (err) {\n o[k] = 'TypeError: cyclic object value';\n }\n }\n });\n \n /**\n * SLS 说不要用 __topic__ 做检索... ~~但又必须每条日志有个 __topic__...~~ <- 刚看了文档 __topic__ 非必填\n * 在发送多条日志的时候,无法通过内部的 __topic__ 检索到相关的内容,这是一个很奇葩的设定,所以这里给每条日志\n * 增加一个 _TOPIC 属性用来检索的时候替代 __topic__\n *\n * 详情 https://aone.alibaba-inc.com/issue/34492769\n */\n o._TOPIC = o.__topic__!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n \n return o;\n}"],"mappings":"AAIA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAcA,CAACC,IAAoB,EAA0B;EACnF,IAAMC,CAAyB,GAAG,CAAC,CAAC;EAEpCC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,OAAO,CAAC,UAAAC,CAAC,EAAI;IAC7B,IAAMC,CAAC,GAAGN,IAAI,CAACK,CAAC,CAAC;IAEjB,IAAIC,CAAC,KAAK,EAAE,IAAIA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS,EAAE;MAC7C;IACF;IAEA,IAAI,OAAOD,CAAC,KAAK,QAAQ,EAAE;MACzBL,CAAC,CAACI,CAAC,CAAC,GAAGC,CAAC;IACV,CAAC,MAAM,IAAI,OAAOA,CAAC,KAAK,QAAQ,IAAI,OAAOA,CAAC,KAAK,SAAS,EAAE;MAC1DL,CAAC,CAACI,CAAC,CAAC,GAAGC,CAAC,CAACE,QAAQ,CAAC,CAAC;IACrB,CAAC,MAAM;MACL,IAAI;QAAE;QACJP,CAAC,CAACI,CAAC,CAAC,GAAGI,IAAI,CAACC,SAAS,CAACJ,CAAC,CAAC;MAC1B,CAAC,CAAC,OAAOK,GAAG,EAAE;QACZV,CAAC,CAACI,CAAC,CAAC,GAAG,gCAAgC;MACzC;IACF;EACF,CAAC,CAAC;;EAEF;AACF;AACA;AACA;AACA;AACA;AACA;EACEJ,CAAC,CAACW,MAAM,GAAGX,CAAC,CAACY,SAAU,CAAC,CAAC;;EAEzB,OAAOZ,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"file":"convert-log-info.js","names":["convertLogInfo","info","o","Object","keys","forEach","k","v","undefined","toString","JSON","stringify","_err","_TOPIC","__topic__"],"sources":["../../../src/util/convert-log-info.ts"],"sourcesContent":["import {\n ISlsLogPayload\n} from '../types';\n\n/**\n * 发送的 JSON 里边不可以有除了字符串以外的值,否则报错\n *\n * - code = PostBodyInvalid\n * - message = Value in log is not string data type\n */\nexport default function convertLogInfo(info: ISlsLogPayload): Record<string, string> {\n const o: Record<string, string> = {};\n \n Object.keys(info).forEach(k => {\n const v = info[k];\n \n if (v === '' || v === null || v === undefined) {\n return;\n }\n \n if (typeof v === 'string') {\n o[k] = v;\n } else if (typeof v === 'number' || typeof v === 'boolean') {\n o[k] = v.toString();\n } else {\n try { // 避免 cyclic error\n o[k] = JSON.stringify(v);\n } catch (_err) {\n o[k] = 'TypeError: cyclic object value';\n }\n }\n });\n \n /**\n * SLS 说不要用 __topic__ 做检索... ~~但又必须每条日志有个 __topic__...~~ <- 刚看了文档 __topic__ 非必填\n * 在发送多条日志的时候,无法通过内部的 __topic__ 检索到相关的内容,这是一个很奇葩的设定,所以这里给每条日志\n * 增加一个 _TOPIC 属性用来检索的时候替代 __topic__\n *\n * 详情 https://aone.alibaba-inc.com/issue/34492769\n */\n o._TOPIC = o.__topic__!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n \n return o;\n}\n"],"mappings":"AAIA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAcA,CAACC,IAAoB,EAA0B;EACnF,IAAMC,CAAyB,GAAG,CAAC,CAAC;EAEpCC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,OAAO,CAAC,UAAAC,CAAC,EAAI;IAC7B,IAAMC,CAAC,GAAGN,IAAI,CAACK,CAAC,CAAC;IAEjB,IAAIC,CAAC,KAAK,EAAE,IAAIA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS,EAAE;MAC7C;IACF;IAEA,IAAI,OAAOD,CAAC,KAAK,QAAQ,EAAE;MACzBL,CAAC,CAACI,CAAC,CAAC,GAAGC,CAAC;IACV,CAAC,MAAM,IAAI,OAAOA,CAAC,KAAK,QAAQ,IAAI,OAAOA,CAAC,KAAK,SAAS,EAAE;MAC1DL,CAAC,CAACI,CAAC,CAAC,GAAGC,CAAC,CAACE,QAAQ,CAAC,CAAC;IACrB,CAAC,MAAM;MACL,IAAI;QAAE;QACJP,CAAC,CAACI,CAAC,CAAC,GAAGI,IAAI,CAACC,SAAS,CAACJ,CAAC,CAAC;MAC1B,CAAC,CAAC,OAAOK,IAAI,EAAE;QACbV,CAAC,CAACI,CAAC,CAAC,GAAG,gCAAgC;MACzC;IACF;EACF,CAAC,CAAC;;EAEF;AACF;AACA;AACA;AACA;AACA;AACA;EACEJ,CAAC,CAACW,MAAM,GAAGX,CAAC,CAACY,SAAU,CAAC,CAAC;;EAEzB,OAAOZ,CAAC;AACV","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"create-sls-log-quick.js","names":["createSlsLogQuick","sls","group","options","topic","payload","_len","arguments","length","args","Array","_key","_ref","_ref2","_slicedToArray","_ref3","_ref4","_objectSpread"],"sources":["../../../src/util/create-sls-log-quick.ts"],"sourcesContent":["import {\n ISlsLogFn,\n ISlsLogFnQuick,\n ISlsLogOptions,\n TLogQuickArgs\n} from '../types';\n\nexport default function createSlsLogQuick(sls: ISlsLogFn, group: string): ISlsLogFnQuick {\n return (...args: TLogQuickArgs): void => {\n let options: ISlsLogOptions = {};\n let topic: string;\n let payload: object | undefined;\n \n if (typeof args[0] === 'string') {\n [topic, payload] = args as [string, object?];\n } else {\n [options, topic, payload] = args as [ISlsLogOptions, string, object?];\n }\n \n sls({\n ...options,\n group\n }, topic, payload as object);\n };\n}"],"mappings":";;AAOA,eAAe,SAASA,iBAAiBA,CAACC,GAAc,EAAEC,KAAa,EAAkB;EACvF,OAAO,YAAkC;IACvC,IAAIC,OAAuB,GAAG,CAAC,CAAC;IAChC,IAAIC,KAAa;IACjB,IAAIC,OAA2B;IAAC,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAHvBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAKb,IAAI,OAAOF,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;MAAA,IAAAG,IAAA,GACZH,IAAI;MAAA,IAAAI,KAAA,GAAAC,cAAA,CAAAF,IAAA;MAAtBR,KAAK,GAAAS,KAAA;MAAER,OAAO,GAAAQ,KAAA;IACjB,CAAC,MAAM;MAAA,IAAAE,KAAA,GACuBN,IAAI;MAAA,IAAAO,KAAA,GAAAF,cAAA,CAAAC,KAAA;MAA/BZ,OAAO,GAAAa,KAAA;MAAEZ,KAAK,GAAAY,KAAA;MAAEX,OAAO,GAAAW,KAAA;IAC1B;IAEAf,GAAG,CAAAgB,aAAA,CAAAA,aAAA,KACEd,OAAO;MACVD,KAAK,EAALA;IAAK,IACJE,KAAK,EAAEC,OAAiB,CAAC;EAC9B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"create-sls-log-quick.js","names":["createSlsLogQuick","sls","group","options","topic","payload","_len","arguments","length","args","Array","_key","_ref","_ref2","_slicedToArray","_ref3","_ref4","_objectSpread"],"sources":["../../../src/util/create-sls-log-quick.ts"],"sourcesContent":["import {\n ISlsLogFn,\n ISlsLogFnQuick,\n ISlsLogOptions,\n TLogQuickArgs\n} from '../types';\n\nexport default function createSlsLogQuick(sls: ISlsLogFn, group: string): ISlsLogFnQuick {\n return (...args: TLogQuickArgs): void => {\n let options: ISlsLogOptions = {};\n let topic: string;\n let payload: object | undefined;\n \n if (typeof args[0] === 'string') {\n [topic, payload] = args as [string, object?];\n } else {\n [options, topic, payload] = args as [ISlsLogOptions, string, object?];\n }\n \n sls({\n ...options,\n group\n }, topic, payload as object);\n };\n}\n"],"mappings":";;AAOA,eAAe,SAASA,iBAAiBA,CAACC,GAAc,EAAEC,KAAa,EAAkB;EACvF,OAAO,YAAkC;IACvC,IAAIC,OAAuB,GAAG,CAAC,CAAC;IAChC,IAAIC,KAAa;IACjB,IAAIC,OAA2B;IAAC,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAHvBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAKb,IAAI,OAAOF,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;MAAA,IAAAG,IAAA,GACZH,IAAI;MAAA,IAAAI,KAAA,GAAAC,cAAA,CAAAF,IAAA;MAAtBR,KAAK,GAAAS,KAAA;MAAER,OAAO,GAAAQ,KAAA;IACjB,CAAC,MAAM;MAAA,IAAAE,KAAA,GACuBN,IAAI;MAAA,IAAAO,KAAA,GAAAF,cAAA,CAAAC,KAAA;MAA/BZ,OAAO,GAAAa,KAAA;MAAEZ,KAAK,GAAAY,KAAA;MAAEX,OAAO,GAAAW,KAAA;IAC1B;IAEAf,GAAG,CAAAgB,aAAA,CAAAA,aAAA,KACEd,OAAO;MACVD,KAAK,EAALA;IAAK,IACJE,KAAK,EAAEC,OAAiB,CAAC;EAC9B,CAAC;AACH","ignoreList":[]}
@@ -33,7 +33,7 @@ export default function flattenObject(o, options) {
33
33
  var scopedPathKey = scope ? "".concat(scope, ".").concat(pathKey) : pathKey;
34
34
 
35
35
  // 可以忽略不重要的信息,不记录方法,不记录 `_` 打头的数据
36
- if (/^_/.test(k) || typeof v === 'function' || omit && flattenTestPath(pathKey, omit)) {
36
+ if (k.startsWith('_') || typeof v === 'function' || omit && flattenTestPath(pathKey, omit)) {
37
37
  return;
38
38
  }
39
39
  var normalizedV = normalizePayload(v);
@@ -1 +1 @@
1
- {"version":3,"file":"flatten-object.js","names":["_isEmpty","_isPlainObject","_forEach","flattenTestPath","normalizePayload","flattenObject","o","options","resolvedOptions","scope","_resolvedOptions$dept","depth","omit","direct","result","loop","currentObj","parentPaths","depthFull","length","v","k","pathKey","concat","_toConsumableArray","join","scopedPathKey","test","normalizedV"],"sources":["../../../src/util/flatten-object.ts"],"sourcesContent":["import _isEmpty from 'lodash/isEmpty';\nimport _isPlainObject from 'lodash/isPlainObject';\nimport _forEach from 'lodash/forEach';\n\nimport type {\n IFlattenOptions\n} from '../types';\n\nimport flattenTestPath from './flatten-test-path';\nimport normalizePayload from './normalize-payload';\n\n/**\n * 有时候为了统计方便,需要把传入的对象展平,比如 error 对象,可能会展平成如下形状:\n *\n * ```\n * {\n * \"error.name\": \"..\",\n * \"error.message\": \"..\",\n * \"error.stack\": \"..\"\n * }\n * ```\n */\nexport default function flattenObject(o: object, options: string | IFlattenOptions): Record<string, unknown> {\n const resolvedOptions = typeof options === 'string' ? {\n scope: options\n } : options;\n const {\n scope,\n depth = 5,\n omit,\n direct\n } = resolvedOptions;\n const result: Record<string, unknown> = {};\n \n function loop(currentObj: object, parentPaths: string[]): void {\n const depthFull = depth > 0 && parentPaths.length + 1 >= depth;\n \n _forEach(currentObj, (v: unknown, k: string) => {\n const pathKey = [...parentPaths, k].join('.');\n const scopedPathKey = scope ? `${scope}.${pathKey}` : pathKey;\n \n // 可以忽略不重要的信息,不记录方法,不记录 `_` 打头的数据\n if (/^_/.test(k) || typeof v === 'function' || (omit && flattenTestPath(pathKey, omit))) {\n return;\n }\n \n const normalizedV = normalizePayload(v as object);\n \n // 不继续 loop:\n // 1. 深度满了\n // 2. 不是对象(已经 normalize 掉了一部分)\n // 3. 空对象,或空数组\n // 4. 命中 `direct` 规则\n if (depthFull || !_isPlainObject(normalizedV) || _isEmpty(normalizedV) || (direct && flattenTestPath(pathKey, direct))) {\n result[scopedPathKey] = normalizedV;\n \n return;\n }\n \n loop(normalizedV, [...parentPaths, k]);\n });\n }\n \n loop(o, []);\n \n return result;\n}"],"mappings":";AAAA,OAAOA,QAAQ,MAAM,gBAAgB;AACrC,OAAOC,cAAc,MAAM,sBAAsB;AACjD,OAAOC,QAAQ,MAAM,gBAAgB;AAMrC,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,gBAAgB,MAAM,qBAAqB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAACC,CAAS,EAAEC,OAAiC,EAA2B;EAC3G,IAAMC,eAAe,GAAG,OAAOD,OAAO,KAAK,QAAQ,GAAG;IACpDE,KAAK,EAAEF;EACT,CAAC,GAAGA,OAAO;EACX,IACEE,KAAK,GAIHD,eAAe,CAJjBC,KAAK;IAAAC,qBAAA,GAIHF,eAAe,CAHjBG,KAAK;IAALA,KAAK,GAAAD,qBAAA,cAAG,CAAC,GAAAA,qBAAA;IACTE,IAAI,GAEFJ,eAAe,CAFjBI,IAAI;IACJC,MAAM,GACJL,eAAe,CADjBK,MAAM;EAER,IAAMC,MAA+B,GAAG,CAAC,CAAC;EAE1C,SAASC,IAAIA,CAACC,UAAkB,EAAEC,WAAqB,EAAQ;IAC7D,IAAMC,SAAS,GAAGP,KAAK,GAAG,CAAC,IAAIM,WAAW,CAACE,MAAM,GAAG,CAAC,IAAIR,KAAK;IAE9DT,QAAQ,CAACc,UAAU,EAAE,UAACI,CAAU,EAAEC,CAAS,EAAK;MAC9C,IAAMC,OAAO,GAAG,GAAAC,MAAA,CAAAC,kBAAA,CAAIP,WAAW,IAAEI,CAAC,GAAEI,IAAI,CAAC,GAAG,CAAC;MAC7C,IAAMC,aAAa,GAAGjB,KAAK,MAAAc,MAAA,CAAMd,KAAK,OAAAc,MAAA,CAAID,OAAO,IAAKA,OAAO;;MAE7D;MACA,IAAI,IAAI,CAACK,IAAI,CAACN,CAAC,CAAC,IAAI,OAAOD,CAAC,KAAK,UAAU,IAAKR,IAAI,IAAIT,eAAe,CAACmB,OAAO,EAAEV,IAAI,CAAE,EAAE;QACvF;MACF;MAEA,IAAMgB,WAAW,GAAGxB,gBAAgB,CAACgB,CAAW,CAAC;;MAEjD;MACA;MACA;MACA;MACA;MACA,IAAIF,SAAS,IAAI,CAACjB,cAAc,CAAC2B,WAAW,CAAC,IAAI5B,QAAQ,CAAC4B,WAAW,CAAC,IAAKf,MAAM,IAAIV,eAAe,CAACmB,OAAO,EAAET,MAAM,CAAE,EAAE;QACtHC,MAAM,CAACY,aAAa,CAAC,GAAGE,WAAW;QAEnC;MACF;MAEAb,IAAI,CAACa,WAAW,KAAAL,MAAA,CAAAC,kBAAA,CAAMP,WAAW,IAAEI,CAAC,EAAC,CAAC;IACxC,CAAC,CAAC;EACJ;EAEAN,IAAI,CAACT,CAAC,EAAE,EAAE,CAAC;EAEX,OAAOQ,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"flatten-object.js","names":["_isEmpty","_isPlainObject","_forEach","flattenTestPath","normalizePayload","flattenObject","o","options","resolvedOptions","scope","_resolvedOptions$dept","depth","omit","direct","result","loop","currentObj","parentPaths","depthFull","length","v","k","pathKey","concat","_toConsumableArray","join","scopedPathKey","startsWith","normalizedV"],"sources":["../../../src/util/flatten-object.ts"],"sourcesContent":["import _isEmpty from 'lodash/isEmpty';\nimport _isPlainObject from 'lodash/isPlainObject';\nimport _forEach from 'lodash/forEach';\n\nimport {\n IFlattenOptions\n} from '../types';\n\nimport flattenTestPath from './flatten-test-path';\nimport normalizePayload from './normalize-payload';\n\n/**\n * 有时候为了统计方便,需要把传入的对象展平,比如 error 对象,可能会展平成如下形状:\n *\n * ```\n * {\n * \"error.name\": \"..\",\n * \"error.message\": \"..\",\n * \"error.stack\": \"..\"\n * }\n * ```\n */\nexport default function flattenObject(o: object, options: string | IFlattenOptions): Record<string, unknown> {\n const resolvedOptions = typeof options === 'string' ? {\n scope: options\n } : options;\n const {\n scope,\n depth = 5,\n omit,\n direct\n } = resolvedOptions;\n const result: Record<string, unknown> = {};\n \n function loop(currentObj: object, parentPaths: string[]): void {\n const depthFull = depth > 0 && parentPaths.length + 1 >= depth;\n \n _forEach(currentObj, (v: unknown, k: string) => {\n const pathKey = [...parentPaths, k].join('.');\n const scopedPathKey = scope ? `${scope}.${pathKey}` : pathKey;\n \n // 可以忽略不重要的信息,不记录方法,不记录 `_` 打头的数据\n if (k.startsWith('_') || typeof v === 'function' || (omit && flattenTestPath(pathKey, omit))) {\n return;\n }\n \n const normalizedV = normalizePayload(v as object);\n \n // 不继续 loop:\n // 1. 深度满了\n // 2. 不是对象(已经 normalize 掉了一部分)\n // 3. 空对象,或空数组\n // 4. 命中 `direct` 规则\n if (depthFull || !_isPlainObject(normalizedV) || _isEmpty(normalizedV) || (direct && flattenTestPath(pathKey, direct))) {\n result[scopedPathKey] = normalizedV;\n \n return;\n }\n \n loop(normalizedV, [...parentPaths, k]);\n });\n }\n \n loop(o, []);\n \n return result;\n}\n"],"mappings":";AAAA,OAAOA,QAAQ,MAAM,gBAAgB;AACrC,OAAOC,cAAc,MAAM,sBAAsB;AACjD,OAAOC,QAAQ,MAAM,gBAAgB;AAMrC,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,gBAAgB,MAAM,qBAAqB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAACC,CAAS,EAAEC,OAAiC,EAA2B;EAC3G,IAAMC,eAAe,GAAG,OAAOD,OAA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AAW,KAAAL,MAAA,CAAAC,kBAAA,CAAMP,WAAW,IAAEI,CAAC,EAAC,CAAC;IACxC,CAAC,CAAC;EACJ;EAEAN,IAAI,CAACT,CAAC,EAAE,EAAE,CAAC;EAEX,OAAOQ,MAAM;AACf","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"flatten-test-path.js","names":["flattenTestPath","path","tester","Array","isArray","some","v","test"],"sources":["../../../src/util/flatten-test-path.ts"],"sourcesContent":["import type {\n TFlattenPathTester\n} from '../types';\n\nexport default function flattenTestPath(path: string, tester: TFlattenPathTester): boolean {\n return (Array.isArray(tester) ? tester : [tester]).some(v => {\n return typeof v === 'string' ? v === path : v.test(path);\n });\n}"],"mappings":"AAIA,eAAe,SAASA,eAAeA,CAACC,IAAY,EAAEC,MAA0B,EAAW;EACzF,OAAO,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,GAAGA,MAAM,GAAG,CAACA,MAAM,CAAC,EAAEG,IAAI,CAAC,UAAAC,CAAC,EAAI;IAC3D,OAAO,OAAOA,CAAC,KAAK,QAAQ,GAAGA,CAAC,KAAKL,IAAI,GAAGK,CAAC,CAACC,IAAI,CAACN,IAAI,CAAC;EAC1D,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"flatten-test-path.js","names":["flattenTestPath","path","tester","Array","isArray","some","v","test"],"sources":["../../../src/util/flatten-test-path.ts"],"sourcesContent":["import {\n TFlattenPathTester\n} from '../types';\n\nexport default function flattenTestPath(path: string, tester: TFlattenPathTester): boolean {\n return (Array.isArray(tester) ? tester : [tester]).some(v => {\n return typeof v === 'string' ? v === path : v.test(path);\n });\n}\n"],"mappings":"AAIA,eAAe,SAASA,eAAeA,CAACC,IAAY,EAAEC,MAA0B,EAAW;EACzF,OAAO,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,GAAGA,MAAM,GAAG,CAACA,MAAM,CAAC,EAAEG,IAAI,CAAC,UAAAC,CAAC,EAAI;IAC3D,OAAO,OAAOA,CAAC,KAAK,QAAQ,GAAGA,CAAC,KAAKL,IAAI,GAAGK,CAAC,CAACC,IAAI,CAACN,IAAI,CAAC;EAC1D,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"get-log-once-key.js","names":["getLogOnceKey","topic","once","concat"],"sources":["../../../src/util/get-log-once-key.ts"],"sourcesContent":["export default function getLogOnceKey(topic: string, once?: true | string): string | undefined {\n if (!once) {\n return;\n }\n \n if (once === true) {\n return topic;\n }\n \n return `${topic}~${once}`;\n}"],"mappings":"AAAA,eAAe,SAASA,aAAaA,CAACC,KAAa,EAAEC,IAAoB,EAAsB;EAC7F,IAAI,CAACA,IAAI,EAAE;IACT;EACF;EAEA,IAAIA,IAAI,KAAK,IAAI,EAAE;IACjB,OAAOD,KAAK;EACd;EAEA,UAAAE,MAAA,CAAUF,KAAK,OAAAE,MAAA,CAAID,IAAI;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"get-log-once-key.js","names":["getLogOnceKey","topic","once","concat"],"sources":["../../../src/util/get-log-once-key.ts"],"sourcesContent":["export default function getLogOnceKey(topic: string, once?: true | string): string | undefined {\n if (!once) {\n return;\n }\n \n if (once === true) {\n return topic;\n }\n \n return `${topic}~${once}`;\n}\n"],"mappings":"AAAA,eAAe,SAASA,aAAaA,CAACC,KAAa,EAAEC,IAAoB,EAAsB;EAC7F,IAAI,CAACA,IAAI,EAAE;IACT;EACF;EAEA,IAAIA,IAAI,KAAK,IAAI,EAAE;IACjB,OAAOD,KAAK;EACd;EAEA,UAAAE,MAAA,CAAUF,KAAK,OAAAE,MAAA,CAAID,IAAI;AACzB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"get-silent-countdown.js","names":["START","Date","now","getSilentCountdown","silentTime"],"sources":["../../../src/util/get-silent-countdown.ts"],"sourcesContent":["const START = Date.now();\n\nexport default function getSilentCountdown(silentTime: number): number {\n return START + silentTime - Date.now();\n}"],"mappings":"AAAA,IAAMA,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;AAExB,eAAe,SAASC,kBAAkBA,CAACC,UAAkB,EAAU;EACrE,OAAOJ,KAAK,GAAGI,UAAU,GAAGH,IAAI,CAACC,GAAG,CAAC,CAAC;AACxC","ignoreList":[]}
1
+ {"version":3,"file":"get-silent-countdown.js","names":["START","Date","now","getSilentCountdown","silentTime"],"sources":["../../../src/util/get-silent-countdown.ts"],"sourcesContent":["const START = Date.now();\n\nexport default function getSilentCountdown(silentTime: number): number {\n return START + silentTime - Date.now();\n}\n"],"mappings":"AAAA,IAAMA,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;AAExB,eAAe,SAASC,kBAAkBA,CAACC,UAAkB,EAAU;EACrE,OAAOJ,KAAK,GAAGI,UAAU,GAAGH,IAAI,CAACC,GAAG,CAAC,CAAC;AACxC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"merge-default-params.js","names":["resolveDefaultParams","mergeDefaultParams","factoryDefaultParams","defaultParams","_objectSpread"],"sources":["../../../src/util/merge-default-params.ts"],"sourcesContent":["import type {\n TDefaultParams\n} from '../types';\n\nimport resolveDefaultParams from './resolve-default-params';\n\n/**\n * 合并默认参数\n */\nexport default function mergeDefaultParams(factoryDefaultParams?: TDefaultParams, defaultParams?: TDefaultParams): TDefaultParams | undefined {\n if (typeof factoryDefaultParams === 'function' || typeof defaultParams === 'function') { // 任意一者为方法,则返回方法\n return () => ({\n ...resolveDefaultParams(factoryDefaultParams),\n ...resolveDefaultParams(defaultParams)\n });\n }\n \n return {\n ...factoryDefaultParams,\n ...defaultParams\n };\n}"],"mappings":";AAIA,OAAOA,oBAAoB,MAAM,0BAA0B;;AAE3D;AACA;AACA;AACA,eAAe,SAASC,kBAAkBA,CAACC,oBAAqC,EAAEC,aAA8B,EAA8B;EAC5I,IAAI,OAAOD,oBAAoB,KAAK,UAAU,IAAI,OAAOC,aAAa,KAAK,UAAU,EAAE;IAAE;IACvF,OAAO;MAAA,OAAAC,aAAA,CAAAA,aAAA,KACFJ,oBAAoB,CAACE,oBAAoB,CAAC,GAC1CF,oBAAoB,CAACG,aAAa,CAAC;IAAA,CACtC;EACJ;EAEA,OAAAC,aAAA,CAAAA,aAAA,KACKF,oBAAoB,GACpBC,aAAa;AAEpB","ignoreList":[]}
1
+ {"version":3,"file":"merge-default-params.js","names":["resolveDefaultParams","mergeDefaultParams","factoryDefaultParams","defaultParams","_objectSpread"],"sources":["../../../src/util/merge-default-params.ts"],"sourcesContent":["import {\n TDefaultParams\n} from '../types';\n\nimport resolveDefaultParams from './resolve-default-params';\n\n/**\n * 合并默认参数\n */\nexport default function mergeDefaultParams(factoryDefaultParams?: TDefaultParams, defaultParams?: TDefaultParams): TDefaultParams | undefined {\n if (typeof factoryDefaultParams === 'function' || typeof defaultParams === 'function') { // 任意一者为方法,则返回方法\n return () => ({\n ...resolveDefaultParams(factoryDefaultParams),\n ...resolveDefaultParams(defaultParams)\n });\n }\n \n return {\n ...factoryDefaultParams,\n ...defaultParams\n };\n}\n"],"mappings":";AAIA,OAAOA,oBAAoB,MAAM,0BAA0B;;AAE3D;AACA;AACA;AACA,eAAe,SAASC,kBAAkBA,CAACC,oBAAqC,EAAEC,aAA8B,EAA8B;EAC5I,IAAI,OAAOD,oBAAoB,KAAK,UAAU,IAAI,OAAOC,aAAa,KAAK,UAAU,EAAE;IAAE;IACvF,OAAO;MAAA,OAAAC,aAAA,CAAAA,aAAA,KACFJ,oBAAoB,CAACE,oBAAoB,CAAC,GAC1CF,oBAAoB,CAACG,aAAa,CAAC;IAAA,CACtC;EACJ;EAEA,OAAAC,aAAA,CAAAA,aAAA,KACKF,oBAAoB,GACpBC,aAAa;AAEpB","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  export default function mergeDontSend(factoryDontSend, dontSend) {
2
2
  if (!factoryDontSend || !dontSend) {
3
- return dontSend || factoryDontSend;
3
+ return dontSend !== null && dontSend !== void 0 ? dontSend : factoryDontSend;
4
4
  }
5
5
  return function () {
6
6
  return factoryDontSend() || dontSend();
@@ -1 +1 @@
1
- {"version":3,"file":"merge-dont-send.js","names":["mergeDontSend","factoryDontSend","dontSend"],"sources":["../../../src/util/merge-dont-send.ts"],"sourcesContent":["import type {\n IDontSend\n} from '../types';\n\nexport default function mergeDontSend(factoryDontSend?: IDontSend, dontSend?: IDontSend): IDontSend | undefined {\n if (!factoryDontSend || !dontSend) {\n return dontSend || factoryDontSend;\n }\n \n return (): boolean | void => factoryDontSend() || dontSend();\n}"],"mappings":"AAIA,eAAe,SAASA,aAAaA,CAACC,eAA2B,EAAEC,QAAoB,EAAyB;EAC9G,IAAI,CAACD,eAAe,IAAI,CAACC,QAAQ,EAAE;IACjC,OAAOA,QAAQ,IAAID,eAAe;EACpC;EAEA,OAAO;IAAA,OAAsBA,eAAe,CAAC,CAAC,IAAIC,QAAQ,CAAC,CAAC;EAAA;AAC9D","ignoreList":[]}
1
+ {"version":3,"file":"merge-dont-send.js","names":["mergeDontSend","factoryDontSend","dontSend"],"sources":["../../../src/util/merge-dont-send.ts"],"sourcesContent":["import {\n TDontSend\n} from '../types';\n\nexport default function mergeDontSend(factoryDontSend?: TDontSend, dontSend?: TDontSend): TDontSend | undefined {\n if (!factoryDontSend || !dontSend) {\n return dontSend ?? factoryDontSend;\n }\n \n return (): boolean | undefined => factoryDontSend() || dontSend();\n}\n"],"mappings":"AAIA,eAAe,SAASA,aAAaA,CAACC,eAA2B,EAAEC,QAAoB,EAAyB;EAC9G,IAAI,CAACD,eAAe,IAAI,CAACC,QAAQ,EAAE;IACjC,OAAOA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAID,eAAe;EACpC;EAEA,OAAO;IAAA,OAA2BA,eAAe,CAAC,CAAC,IAAIC,QAAQ,CAAC,CAAC;EAAA;AACnE","ignoreList":[]}
@@ -3,7 +3,7 @@ import _forEach from 'lodash/forEach';
3
3
  /**
4
4
  * Error 身上的 name、message、stack 等信息用 _forEach 遍历不到,故需要转成普通对象
5
5
  */
6
- export default function normalizeError(err) {
6
+ export default function normalizePayloadError(err) {
7
7
  var normalized = {
8
8
  name: err.name,
9
9
  message: err.message
@@ -13,4 +13,4 @@ export default function normalizeError(err) {
13
13
  });
14
14
  return normalized;
15
15
  }
16
- //# sourceMappingURL=normalize-error.js.map
16
+ //# sourceMappingURL=normalize-payload-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-payload-error.js","names":["_forEach","normalizePayloadError","err","normalized","name","message","v","k"],"sources":["../../../src/util/normalize-payload-error.ts"],"sourcesContent":["import _forEach from 'lodash/forEach';\n\n/**\n * Error 身上的 name、message、stack 等信息用 _forEach 遍历不到,故需要转成普通对象\n */\nexport default function normalizePayloadError(err: Error): Record<string, unknown> {\n const normalized: Record<string, unknown> = {\n name: err.name,\n message: err.message\n };\n \n _forEach(err, (v, k) => {\n normalized[k] = v;\n });\n \n return normalized;\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,gBAAgB;;AAErC;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAACC,GAAU,EAA2B;EACjF,IAAMC,UAAmC,GAAG;IAC1CC,IAAI,EAAEF,GAAG,CAACE,IAAI;IACdC,OAAO,EAAEH,GAAG,CAACG;EACf,CAAC;EAEDL,QAAQ,CAACE,GAAG,EAAE,UAACI,CAAC,EAAEC,CAAC,EAAK;IACtBJ,UAAU,CAACI,CAAC,CAAC,GAAGD,CAAC;EACnB,CAAC,CAAC;EAEF,OAAOH,UAAU;AACnB","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * 文件不可能直接记录
3
3
  */
4
- export default function normalizeFile(file) {
4
+ export default function normalizePayloadFile(file) {
5
5
  return {
6
6
  name: file.name,
7
7
  size: file.size,
8
8
  type: file.type
9
9
  };
10
10
  }
11
- //# sourceMappingURL=normalize-file.js.map
11
+ //# sourceMappingURL=normalize-payload-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-payload-file.js","names":["normalizePayloadFile","file","name","size","type"],"sources":["../../../src/util/normalize-payload-file.ts"],"sourcesContent":["interface IPlainFile {\n name: string;\n size: number;\n type: string;\n}\n\n/**\n * 文件不可能直接记录\n */\nexport default function normalizePayloadFile(file: File): IPlainFile {\n return {\n name: file.name,\n size: file.size,\n type: file.type\n };\n}\n"],"mappings":"AAMA;AACA;AACA;AACA,eAAe,SAASA,oBAAoBA,CAACC,IAAU,EAAc;EACnE,OAAO;IACLC,IAAI,EAAED,IAAI,CAACC,IAAI;IACfC,IAAI,EAAEF,IAAI,CAACE,IAAI;IACfC,IAAI,EAAEH,IAAI,CAACG;EACb,CAAC;AACH","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import normalizeFile from './normalize-file';
2
- export default function normalizeFormData(formData) {
1
+ import normalizePayloadFile from './normalize-payload-file';
2
+ export default function normalizePayloadFormData(formData) {
3
3
  var normalized = {};
4
4
  formData.forEach(function (v, k) {
5
- var value = v instanceof File ? normalizeFile(v) : v;
5
+ var value = v instanceof File ? normalizePayloadFile(v) : v;
6
6
  var exist = normalized[k];
7
7
  if (Array.isArray(exist)) {
8
8
  exist.push(value);
@@ -14,4 +14,4 @@ export default function normalizeFormData(formData) {
14
14
  });
15
15
  return normalized;
16
16
  }
17
- //# sourceMappingURL=normalize-form-data.js.map
17
+ //# sourceMappingURL=normalize-payload-form-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-payload-form-data.js","names":["normalizePayloadFile","normalizePayloadFormData","formData","normalized","forEach","v","k","value","File","exist","Array","isArray","push"],"sources":["../../../src/util/normalize-payload-form-data.ts"],"sourcesContent":["import normalizePayloadFile from './normalize-payload-file';\n\nexport default function normalizePayloadFormData(formData: FormData): Record<string, unknown> {\n const normalized: Record<string, unknown> = {};\n \n formData.forEach((v, k) => {\n const value = v instanceof File ? normalizePayloadFile(v) : v;\n const exist = normalized[k];\n \n if (Array.isArray(exist)) {\n exist.push(value);\n } else if (exist) {\n normalized[k] = [exist, value];\n } else {\n normalized[k] = value;\n }\n });\n \n return normalized;\n}\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,0BAA0B;AAE3D,eAAe,SAASC,wBAAwBA,CAACC,QAAkB,EAA2B;EAC5F,IAAMC,UAAmC,GAAG,CAAC,CAAC;EAE9CD,QAAQ,CAACE,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IACzB,IAAMC,KAAK,GAAGF,CAAC,YAAYG,IAAI,GAAGR,oBAAoB,CAACK,CAAC,CAAC,GAAGA,CAAC;IAC7D,IAAMI,KAAK,GAAGN,UAAU,CAACG,CAAC,CAAC;IAE3B,IAAII,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACG,IAAI,CAACL,KAAK,CAAC;IACnB,CAAC,MAAM,IAAIE,KAAK,EAAE;MAChBN,UAAU,CAACG,CAAC,CAAC,GAAG,CAACG,KAAK,EAAEF,KAAK,CAAC;IAChC,CAAC,MAAM;MACLJ,UAAU,CAACG,CAAC,CAAC,GAAGC,KAAK;IACvB;EACF,CAAC,CAAC;EAEF,OAAOJ,UAAU;AACnB","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ export default function normalizePayloadHeaders(headers) {
2
+ var normalized = {};
3
+ headers.forEach(function (v, k) {
4
+ normalized[k] = v;
5
+ });
6
+ return normalized;
7
+ }
8
+ //# sourceMappingURL=normalize-payload-headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-payload-headers.js","names":["normalizePayloadHeaders","headers","normalized","forEach","v","k"],"sources":["../../../src/util/normalize-payload-headers.ts"],"sourcesContent":["export default function normalizePayloadHeaders(headers: Headers): Record<string, unknown> {\n const normalized: Record<string, unknown> = {};\n \n headers.forEach((v, k) => {\n normalized[k] = v;\n });\n \n return normalized;\n}\n"],"mappings":"AAAA,eAAe,SAASA,uBAAuBA,CAACC,OAAgB,EAA2B;EACzF,IAAMC,UAAmC,GAAG,CAAC,CAAC;EAE9CD,OAAO,CAACE,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IACxBH,UAAU,CAACG,CAAC,CAAC,GAAGD,CAAC;EACnB,CAAC,CAAC;EAEF,OAAOF,UAAU;AACnB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- export default function normalizeSearchParams(searchParams) {
1
+ export default function normalizePayloadSearchParams(searchParams) {
2
2
  var normalized = {};
3
3
  searchParams.forEach(function (v, k) {
4
4
  var exist = normalized[k];
@@ -12,4 +12,4 @@ export default function normalizeSearchParams(searchParams) {
12
12
  });
13
13
  return normalized;
14
14
  }
15
- //# sourceMappingURL=normalize-search-params.js.map
15
+ //# sourceMappingURL=normalize-payload-search-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-payload-search-params.js","names":["normalizePayloadSearchParams","searchParams","normalized","forEach","v","k","exist","Array","isArray","push"],"sources":["../../../src/util/normalize-payload-search-params.ts"],"sourcesContent":["export default function normalizePayloadSearchParams(searchParams: URLSearchParams): Record<string, unknown> {\n const normalized: Record<string, unknown> = {};\n \n searchParams.forEach((v, k) => {\n const exist = normalized[k];\n \n if (Array.isArray(exist)) {\n exist.push(v);\n } else if (exist) {\n normalized[k] = [exist, v];\n } else {\n normalized[k] = v;\n }\n });\n \n return normalized;\n}\n"],"mappings":"AAAA,eAAe,SAASA,4BAA4BA,CAACC,YAA6B,EAA2B;EAC3G,IAAMC,UAAmC,GAAG,CAAC,CAAC;EAE9CD,YAAY,CAACE,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IAC7B,IAAMC,KAAK,GAAGJ,UAAU,CAACG,CAAC,CAAC;IAE3B,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACG,IAAI,CAACL,CAAC,CAAC;IACf,CAAC,MAAM,IAAIE,KAAK,EAAE;MAChBJ,UAAU,CAACG,CAAC,CAAC,GAAG,CAACC,KAAK,EAAEF,CAAC,CAAC;IAC5B,CAAC,MAAM;MACLF,UAAU,CAACG,CAAC,CAAC,GAAGD,CAAC;IACnB;EACF,CAAC,CAAC;EAEF,OAAOF,UAAU;AACnB","ignoreList":[]}
@@ -1,24 +1,25 @@
1
1
  import _isError from 'lodash/isError';
2
- import normalizeError from './normalize-error';
3
- import normalizeHeaders from './normalize-headers';
4
- import normalizeFile from './normalize-file';
5
- import normalizeFormData from './normalize-form-data';
6
- import normalizeSearchParams from './normalize-search-params';
2
+ import normalizePayloadError from './normalize-payload-error';
3
+ import normalizePayloadHeaders from './normalize-payload-headers';
4
+ import normalizePayloadFile from './normalize-payload-file';
5
+ import normalizePayloadFormData from './normalize-payload-form-data';
6
+ import normalizePayloadSearchParams from './normalize-payload-search-params';
7
7
  export default function normalizePayload(o) {
8
8
  if (_isError(o)) {
9
- return normalizeError(o);
9
+ return normalizePayloadError(o);
10
10
  }
11
- if (o instanceof Headers) {
12
- return normalizeHeaders(o);
11
+ if (typeof Headers !== 'undefined' && o instanceof Headers) {
12
+ // 使用 typeof 以免在小程序等环境下崩坏
13
+ return normalizePayloadHeaders(o);
13
14
  }
14
- if (o instanceof File) {
15
- return normalizeFile(o);
15
+ if (typeof File !== 'undefined' && o instanceof File) {
16
+ return normalizePayloadFile(o);
16
17
  }
17
- if (o instanceof FormData) {
18
- return normalizeFormData(o);
18
+ if (typeof FormData !== 'undefined' && o instanceof FormData) {
19
+ return normalizePayloadFormData(o);
19
20
  }
20
- if (o instanceof URLSearchParams) {
21
- return normalizeSearchParams(o);
21
+ if (typeof URLSearchParams !== 'undefined' && o instanceof URLSearchParams) {
22
+ return normalizePayloadSearchParams(o);
22
23
  }
23
24
  return o;
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-payload.js","names":["_isError","normalizeError","normalizeHeaders","normalizeFile","normalizeFormData","normalizeSearchParams","normalizePayload","o","Headers","File","FormData","URLSearchParams"],"sources":["../../../src/util/normalize-payload.ts"],"sourcesContent":["import _isError from 'lodash/isError';\n\nimport normalizeError from './normalize-error';\nimport normalizeHeaders from './normalize-headers';\nimport normalizeFile from './normalize-file';\nimport normalizeFormData from './normalize-form-data';\nimport normalizeSearchParams from './normalize-search-params';\n\nexport default function normalizePayload(o: object): object {\n if (_isError(o)) {\n return normalizeError(o);\n }\n \n if (o instanceof Headers) {\n return normalizeHeaders(o);\n }\n \n if (o instanceof File) {\n return normalizeFile(o);\n }\n \n if (o instanceof FormData) {\n return normalizeFormData(o);\n }\n \n if (o instanceof URLSearchParams) {\n return normalizeSearchParams(o);\n }\n \n return o;\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,gBAAgB;AAErC,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,OAAOC,qBAAqB,MAAM,2BAA2B;AAE7D,eAAe,SAASC,gBAAgBA,CAACC,CAAS,EAAU;EAC1D,IAAIP,QAAQ,CAACO,CAAC,CAAC,EAAE;IACf,OAAON,cAAc,CAACM,CAAC,CAAC;EAC1B;EAEA,IAAIA,CAAC,YAAYC,OAAO,EAAE;IACxB,OAAON,gBAAgB,CAACK,CAAC,CAAC;EAC5B;EAEA,IAAIA,CAAC,YAAYE,IAAI,EAAE;IACrB,OAAON,aAAa,CAACI,CAAC,CAAC;EACzB;EAEA,IAAIA,CAAC,YAAYG,QAAQ,EAAE;IACzB,OAAON,iBAAiB,CAACG,CAAC,CAAC;EAC7B;EAEA,IAAIA,CAAC,YAAYI,eAAe,EAAE;IAChC,OAAON,qBAAqB,CAACE,CAAC,CAAC;EACjC;EAEA,OAAOA,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"file":"normalize-payload.js","names":["_isError","normalizePayloadError","normalizePayloadHeaders","normalizePayloadFile","normalizePayloadFormData","normalizePayloadSearchParams","normalizePayload","o","Headers","File","FormData","URLSearchParams"],"sources":["../../../src/util/normalize-payload.ts"],"sourcesContent":["import _isError from 'lodash/isError';\n\nimport normalizePayloadError from './normalize-payload-error';\nimport normalizePayloadHeaders from './normalize-payload-headers';\nimport normalizePayloadFile from './normalize-payload-file';\nimport normalizePayloadFormData from './normalize-payload-form-data';\nimport normalizePayloadSearchParams from './normalize-payload-search-params';\n\nexport default function normalizePayload(o: object): object {\n if (_isError(o)) {\n return normalizePayloadError(o);\n }\n \n if (typeof Headers !== 'undefined' && o instanceof Headers) { // 使用 typeof 以免在小程序等环境下崩坏\n return normalizePayloadHeaders(o);\n }\n \n if (typeof File !== 'undefined' && o instanceof File) {\n return normalizePayloadFile(o);\n }\n \n if (typeof FormData !== 'undefined' && o instanceof FormData) {\n return normalizePayloadFormData(o);\n }\n \n if (typeof URLSearchParams !== 'undefined' && o instanceof URLSearchParams) {\n return normalizePayloadSearchParams(o);\n }\n \n return o;\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,gBAAgB;AAErC,OAAOC,qBAAqB,MAAM,2BAA2B;AAC7D,OAAOC,uBAAuB,MAAM,6BAA6B;AACjE,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,4BAA4B,MAAM,mCAAmC;AAE5E,eAAe,SAASC,gBAAgBA,CAACC,CAAS,EAAU;EAC1D,IAAIP,QAAQ,CAACO,CAAC,CAAC,EAAE;IACf,OAAON,qBAAqB,CAACM,CAAC,CAAC;EACjC;EAEA,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAID,CAAC,YAAYC,OAAO,EAAE;IAAE;IAC5D,OAAON,uBAAuB,CAACK,CAAC,CAAC;EACnC;EAEA,IAAI,OAAOE,IAAI,KAAK,WAAW,IAAIF,CAAC,YAAYE,IAAI,EAAE;IACpD,OAAON,oBAAoB,CAACI,CAAC,CAAC;EAChC;EAEA,IAAI,OAAOG,QAAQ,KAAK,WAAW,IAAIH,CAAC,YAAYG,QAAQ,EAAE;IAC5D,OAAON,wBAAwB,CAACG,CAAC,CAAC;EACpC;EAEA,IAAI,OAAOI,eAAe,KAAK,WAAW,IAAIJ,CAAC,YAAYI,eAAe,EAAE;IAC1E,OAAON,4BAA4B,CAACE,CAAC,CAAC;EACxC;EAEA,OAAOA,CAAC;AACV","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-default-params.js","names":["resolveDefaultParams","defaultParams"],"sources":["../../../src/util/resolve-default-params.ts"],"sourcesContent":["import {\n TDefaultParams\n} from '../types';\n\nexport default function resolveDefaultParams(defaultParams?: TDefaultParams): Record<string, unknown> | undefined {\n return typeof defaultParams === 'function' ? defaultParams() : defaultParams;\n}"],"mappings":"AAIA,eAAe,SAASA,oBAAoBA,CAACC,aAA8B,EAAuC;EAChH,OAAO,OAAOA,aAAa,KAAK,UAAU,GAAGA,aAAa,CAAC,CAAC,GAAGA,aAAa;AAC9E","ignoreList":[]}
1
+ {"version":3,"file":"resolve-default-params.js","names":["resolveDefaultParams","defaultParams"],"sources":["../../../src/util/resolve-default-params.ts"],"sourcesContent":["import {\n TDefaultParams\n} from '../types';\n\nexport default function resolveDefaultParams(defaultParams?: TDefaultParams): Record<string, unknown> | undefined {\n return typeof defaultParams === 'function' ? defaultParams() : defaultParams;\n}\n"],"mappings":"AAIA,eAAe,SAASA,oBAAoBA,CAACC,aAA8B,EAAuC;EAChH,OAAO,OAAOA,aAAa,KAAK,UAAU,GAAGA,aAAa,CAAC,CAAC,GAAGA,aAAa;AAC9E","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ICreateLoggerOptions, ILogSender, ISlsLogFn } from '../types';
1
+ import { ICreateLoggerOptions, TLogSender, ISlsLogFn } from '../types';
2
2
  /**
3
3
  * 创建 SLS 日志方法
4
4
  */
@@ -6,7 +6,7 @@ export default class SlsLogger {
6
6
  private readonly options;
7
7
  private readonly slsPipe;
8
8
  private once;
9
- constructor(sender: ILogSender, options: ICreateLoggerOptions);
9
+ constructor(sender: TLogSender, options: ICreateLoggerOptions);
10
10
  log: ISlsLogFn;
11
11
  /**
12
12
  * 检查是否需要忽略
@@ -1,4 +1,4 @@
1
- import { ISlsLogPayload, ISlsPipeOptions, ILogSender } from '../types';
1
+ import { ISlsLogPayload, ISlsPipeOptions, TLogSender } from '../types';
2
2
  /**
3
3
  * SLS 日志管道,用于在一定的时间内积压日志,以避免造成业务请求性能问题
4
4
  */
@@ -8,7 +8,7 @@ export default class SlsPipe {
8
8
  private queue;
9
9
  private timer;
10
10
  private silent;
11
- constructor(sender: ILogSender, options: ISlsPipeOptions);
11
+ constructor(sender: TLogSender, options: ISlsPipeOptions);
12
12
  /**
13
13
  * 将日志推入队列,并通知发送
14
14
  */
@@ -1,5 +1,5 @@
1
- import { ICreateLoggerOptions, ISlsLogger, ILogSender } from '../types';
1
+ import { ICreateLoggerOptions, ISlsLogger, TLogSender } from '../types';
2
2
  /**
3
3
  * 创建 Logger 方法
4
4
  */
5
- export default function createLogger(sender: ILogSender, options: ICreateLoggerOptions): ISlsLogger;
5
+ export default function createLogger(sender: TLogSender, options: ICreateLoggerOptions): ISlsLogger;
@@ -1,7 +1,7 @@
1
- import { ILogSender, ICreateLogger, IGenerateCreateLoggerOptions } from '../types';
1
+ import { TLogSender, ICreateLogger, IGenerateCreateLoggerOptions } from '../types';
2
2
  /**
3
3
  * 创建 `createLogger` 方法的方法,对期望扩展默认参数的场景做了规范。
4
4
  *
5
5
  * 一般不会在项目中直接使用,而是用来写可复用 npm 包。
6
6
  */
7
- export default function generateCreateLogger(sender: ILogSender, { defaultParams: factoryDefaultParams, dontSend: factoryDontSend }: IGenerateCreateLoggerOptions): ICreateLogger;
7
+ export default function generateCreateLogger(sender: TLogSender, { defaultParams: factoryDefaultParams, dontSend: factoryDontSend }: IGenerateCreateLoggerOptions): ICreateLogger;
@@ -1,17 +1,11 @@
1
- export interface IDefaultParams {
2
- (): Record<string, unknown>;
3
- }
4
- export type TDefaultParams = Record<string, unknown> | IDefaultParams;
5
- export interface IDontSend {
6
- (): void | boolean;
7
- }
1
+ export type TFnDefaultParams = () => Record<string, unknown>;
2
+ export type TDefaultParams = Record<string, unknown> | TFnDefaultParams;
3
+ export type TDontSend = () => undefined | boolean;
8
4
  /**
9
5
  * 真正发送请求的实现逻辑(以支持多平台的需求),注意必需用 POST
10
6
  */
11
- export interface ILogSender {
12
- (trackUrl: string, body: string, headers: Record<string, string>): void;
13
- }
14
- export type TFlattenPathTester = string | RegExp | Array<string | RegExp>;
7
+ export type TLogSender = (trackUrl: string, body: string, headers: Record<string, string>) => void;
8
+ export type TFlattenPathTester = string | RegExp | (string | RegExp)[];
15
9
  export interface ISlsLogPayload {
16
10
  __topic__: string;
17
11
  [k: string]: unknown;
@@ -25,6 +25,4 @@ export interface ISlsLogger {
25
25
  error: ISlsLogFnQuick;
26
26
  fatal: ISlsLogFnQuick;
27
27
  }
28
- export interface ICreateLogger {
29
- (options: ICreateLoggerOptions): ISlsLogger;
30
- }
28
+ export type ICreateLogger = (options: ICreateLoggerOptions) => ISlsLogger;
@@ -1,4 +1,4 @@
1
- import { TDefaultParams, TFlattenPathTester, IDontSend } from './common';
1
+ import { TDefaultParams, TFlattenPathTester, TDontSend } from './common';
2
2
  export interface ISlsPipeOptions {
3
3
  trackUrl: string;
4
4
  /**
@@ -56,14 +56,14 @@ export interface ICreateLoggerOptions extends Partial<ISlsPipeOptions> {
56
56
  *
57
57
  * 在某些场景下需要禁用日志上报功能,比如可能禁止日志跨境
58
58
  */
59
- dontSend?: IDontSend;
59
+ dontSend?: TDontSend;
60
60
  }
61
61
  /**
62
62
  * 生成 `createLogger` 方法的工厂方法的 options,用于制定工厂级别的参数的忽略方法
63
63
  */
64
64
  export interface IGenerateCreateLoggerOptions {
65
65
  defaultParams?: TDefaultParams;
66
- dontSend?: IDontSend;
66
+ dontSend?: TDontSend;
67
67
  }
68
68
  export interface IFlattenOptions {
69
69
  scope?: string;
@@ -1,4 +1,4 @@
1
- import type { ISlsLogPayload, ISlsPostBody } from '../types';
1
+ import { ISlsLogPayload, ISlsPostBody } from '../types';
2
2
  /**
3
3
  * 利用 PutWebTracking 发送日志,如果 `__logs__` 里含有 `__topic__` 则,外部的这个 `__topic__` 将被改为 `__topic__0`,
4
4
  * 为了干净,在仅发送一条日志的时候,将 `__logs__` 里的 `__topic__` 往上提。
@@ -1,4 +1,4 @@
1
- import type { ISlsLogPayload } from '../types';
1
+ import { ISlsLogPayload } from '../types';
2
2
  /**
3
3
  * 发送的 JSON 里边不可以有除了字符串以外的值,否则报错
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { IFlattenOptions } from '../types';
1
+ import { IFlattenOptions } from '../types';
2
2
  /**
3
3
  * 有时候为了统计方便,需要把传入的对象展平,比如 error 对象,可能会展平成如下形状:
4
4
  *
@@ -1,2 +1,2 @@
1
- import type { TFlattenPathTester } from '../types';
1
+ import { TFlattenPathTester } from '../types';
2
2
  export default function flattenTestPath(path: string, tester: TFlattenPathTester): boolean;
@@ -1,4 +1,4 @@
1
- import type { TDefaultParams } from '../types';
1
+ import { TDefaultParams } from '../types';
2
2
  /**
3
3
  * 合并默认参数
4
4
  */
@@ -1,2 +1,2 @@
1
- import type { IDontSend } from '../types';
2
- export default function mergeDontSend(factoryDontSend?: IDontSend, dontSend?: IDontSend): IDontSend | undefined;
1
+ import { TDontSend } from '../types';
2
+ export default function mergeDontSend(factoryDontSend?: TDontSend, dontSend?: TDontSend): TDontSend | undefined;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Error 身上的 name、message、stack 等信息用 _forEach 遍历不到,故需要转成普通对象
3
3
  */
4
- export default function normalizeError(err: Error): Record<string, unknown>;
4
+ export default function normalizePayloadError(err: Error): Record<string, unknown>;
@@ -6,5 +6,5 @@ interface IPlainFile {
6
6
  /**
7
7
  * 文件不可能直接记录
8
8
  */
9
- export default function normalizeFile(file: File): IPlainFile;
9
+ export default function normalizePayloadFile(file: File): IPlainFile;
10
10
  export {};
@@ -0,0 +1 @@
1
+ export default function normalizePayloadFormData(formData: FormData): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ export default function normalizePayloadHeaders(headers: Headers): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ export default function normalizePayloadSearchParams(searchParams: URLSearchParams): Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kcuf/sls-logger-base",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Aliyun SLS logger without transport implementation.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/justnewbee/kcuf.git"
14
14
  },
15
- "homepage": "https://github.com/justnewbee/kcuf/tree/master/packages-fetcher/sls-logger-base",
15
+ "homepage": "https://github.com/justnewbee/kcuf/tree/main/packages-fetcher/sls-logger-base",
16
16
  "bugs": "https://github.com/justnewbee/kcuf/issues",
17
17
  "author": {
18
18
  "name": "Jianchun Wang",
@@ -22,25 +22,25 @@
22
22
  "access": "public"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/cli": "^7.25.7",
26
- "@babel/core": "^7.25.8",
27
- "@babel/plugin-transform-runtime": "^7.25.7",
28
- "@babel/preset-env": "^7.25.8",
29
- "@babel/preset-typescript": "^7.25.7",
30
- "@types/lodash": "^4.17.10",
31
- "@vitest/coverage-v8": "^2.1.3",
32
- "fetch-mock": "^11.1.5",
33
- "jsdom": "^25.0.1",
34
- "rimraf": "^6.0.1",
35
- "typescript": "^5.6.3",
36
- "vitest": "^2.1.3",
37
- "@kcuf/ts-config": "^0.0.1"
25
+ "@babel/cli": "^7.29.7",
26
+ "@babel/core": "^7.29.7",
27
+ "@babel/plugin-transform-runtime": "^7.29.7",
28
+ "@babel/preset-env": "^7.29.7",
29
+ "@babel/preset-typescript": "^7.29.7",
30
+ "@types/lodash": "^4.17.24",
31
+ "@vitest/coverage-v8": "^4.1.9",
32
+ "fetch-mock": "^12.6.0",
33
+ "jsdom": "^29.1.1",
34
+ "rimraf": "^6.1.3",
35
+ "typescript": "^6.0.3",
36
+ "vitest": "^4.1.9",
37
+ "@kcuf/ts-config": "^0.2.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@babel/runtime": "^7.24.8"
40
+ "@babel/runtime": ">=7.0.0"
41
41
  },
42
42
  "dependencies": {
43
- "lodash": "^4.17.21"
43
+ "lodash": "^4.18.1"
44
44
  },
45
45
  "scripts": {
46
46
  "build:clean": "rimraf dist",
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-error.js","names":["_forEach","normalizeError","err","normalized","name","message","v","k"],"sources":["../../../src/util/normalize-error.ts"],"sourcesContent":["import _forEach from 'lodash/forEach';\n\n/**\n * Error 身上的 name、message、stack 等信息用 _forEach 遍历不到,故需要转成普通对象\n */\nexport default function normalizeError(err: Error): Record<string, unknown> {\n const normalized: Record<string, unknown> = {\n name: err.name,\n message: err.message\n };\n \n _forEach(err, (v, k) => {\n normalized[k] = v;\n });\n \n return normalized;\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,gBAAgB;;AAErC;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAACC,GAAU,EAA2B;EAC1E,IAAMC,UAAmC,GAAG;IAC1CC,IAAI,EAAEF,GAAG,CAACE,IAAI;IACdC,OAAO,EAAEH,GAAG,CAACG;EACf,CAAC;EAEDL,QAAQ,CAACE,GAAG,EAAE,UAACI,CAAC,EAAEC,CAAC,EAAK;IACtBJ,UAAU,CAACI,CAAC,CAAC,GAAGD,CAAC;EACnB,CAAC,CAAC;EAEF,OAAOH,UAAU;AACnB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-file.js","names":["normalizeFile","file","name","size","type"],"sources":["../../../src/util/normalize-file.ts"],"sourcesContent":["interface IPlainFile {\n name: string;\n size: number;\n type: string;\n}\n\n/**\n * 文件不可能直接记录\n */\nexport default function normalizeFile(file: File): IPlainFile {\n return {\n name: file.name,\n size: file.size,\n type: file.type\n };\n}"],"mappings":"AAMA;AACA;AACA;AACA,eAAe,SAASA,aAAaA,CAACC,IAAU,EAAc;EAC5D,OAAO;IACLC,IAAI,EAAED,IAAI,CAACC,IAAI;IACfC,IAAI,EAAEF,IAAI,CAACE,IAAI;IACfC,IAAI,EAAEH,IAAI,CAACG;EACb,CAAC;AACH","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-form-data.js","names":["normalizeFile","normalizeFormData","formData","normalized","forEach","v","k","value","File","exist","Array","isArray","push"],"sources":["../../../src/util/normalize-form-data.ts"],"sourcesContent":["import normalizeFile from './normalize-file';\n\nexport default function normalizeFormData(formData: FormData): Record<string, unknown> {\n const normalized: Record<string, unknown> = {};\n \n formData.forEach((v, k) => {\n const value = v instanceof File ? normalizeFile(v) : v;\n const exist = normalized[k];\n \n if (Array.isArray(exist)) {\n exist.push(value);\n } else if (exist) {\n normalized[k] = [exist, value];\n } else {\n normalized[k] = value;\n }\n });\n \n return normalized;\n}"],"mappings":"AAAA,OAAOA,aAAa,MAAM,kBAAkB;AAE5C,eAAe,SAASC,iBAAiBA,CAACC,QAAkB,EAA2B;EACrF,IAAMC,UAAmC,GAAG,CAAC,CAAC;EAE9CD,QAAQ,CAACE,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IACzB,IAAMC,KAAK,GAAGF,CAAC,YAAYG,IAAI,GAAGR,aAAa,CAACK,CAAC,CAAC,GAAGA,CAAC;IACtD,IAAMI,KAAK,GAAGN,UAAU,CAACG,CAAC,CAAC;IAE3B,IAAII,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACG,IAAI,CAACL,KAAK,CAAC;IACnB,CAAC,MAAM,IAAIE,KAAK,EAAE;MAChBN,UAAU,CAACG,CAAC,CAAC,GAAG,CAACG,KAAK,EAAEF,KAAK,CAAC;IAChC,CAAC,MAAM;MACLJ,UAAU,CAACG,CAAC,CAAC,GAAGC,KAAK;IACvB;EACF,CAAC,CAAC;EAEF,OAAOJ,UAAU;AACnB","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- export default function normalizeHeaders(headers) {
2
- var normalized = {};
3
- headers.forEach(function (v, k) {
4
- normalized[k] = v;
5
- });
6
- return normalized;
7
- }
8
- //# sourceMappingURL=normalize-headers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-headers.js","names":["normalizeHeaders","headers","normalized","forEach","v","k"],"sources":["../../../src/util/normalize-headers.ts"],"sourcesContent":["export default function normalizeHeaders(headers: Headers): Record<string, unknown> {\n const normalized: Record<string, unknown> = {};\n \n headers.forEach((v, k) => {\n normalized[k] = v;\n });\n \n return normalized;\n}"],"mappings":"AAAA,eAAe,SAASA,gBAAgBA,CAACC,OAAgB,EAA2B;EAClF,IAAMC,UAAmC,GAAG,CAAC,CAAC;EAE9CD,OAAO,CAACE,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IACxBH,UAAU,CAACG,CAAC,CAAC,GAAGD,CAAC;EACnB,CAAC,CAAC;EAEF,OAAOF,UAAU;AACnB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-search-params.js","names":["normalizeSearchParams","searchParams","normalized","forEach","v","k","exist","Array","isArray","push"],"sources":["../../../src/util/normalize-search-params.ts"],"sourcesContent":["export default function normalizeSearchParams(searchParams: URLSearchParams): Record<string, unknown> {\n const normalized: Record<string, unknown> = {};\n \n searchParams.forEach((v, k) => {\n const exist = normalized[k];\n \n if (Array.isArray(exist)) {\n exist.push(v);\n } else if (exist) {\n normalized[k] = [exist, v];\n } else {\n normalized[k] = v;\n }\n });\n \n return normalized;\n}"],"mappings":"AAAA,eAAe,SAASA,qBAAqBA,CAACC,YAA6B,EAA2B;EACpG,IAAMC,UAAmC,GAAG,CAAC,CAAC;EAE9CD,YAAY,CAACE,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IAC7B,IAAMC,KAAK,GAAGJ,UAAU,CAACG,CAAC,CAAC;IAE3B,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACG,IAAI,CAACL,CAAC,CAAC;IACf,CAAC,MAAM,IAAIE,KAAK,EAAE;MAChBJ,UAAU,CAACG,CAAC,CAAC,GAAG,CAACC,KAAK,EAAEF,CAAC,CAAC;IAC5B,CAAC,MAAM;MACLF,UAAU,CAACG,CAAC,CAAC,GAAGD,CAAC;IACnB;EACF,CAAC,CAAC;EAEF,OAAOF,UAAU;AACnB","ignoreList":[]}
@@ -1 +0,0 @@
1
- export default function normalizeFormData(formData: FormData): Record<string, unknown>;
@@ -1 +0,0 @@
1
- export default function normalizeHeaders(headers: Headers): Record<string, unknown>;
@@ -1 +0,0 @@
1
- export default function normalizeSearchParams(searchParams: URLSearchParams): Record<string, unknown>;