lemon-core 5.0.4 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lemon-fields-types.mjs +12 -0
- package/bin/lib/fields-types.mjs +629 -0
- package/dist/common/test-helper.js +6 -3
- package/dist/common/test-helper.js.map +1 -1
- package/dist/cores/aws/aws-sns-service.d.ts +6 -0
- package/dist/cores/aws/aws-sns-service.js +22 -3
- package/dist/cores/aws/aws-sns-service.js.map +1 -1
- package/dist/cores/aws/aws-sqs-service.js +5 -0
- package/dist/cores/aws/aws-sqs-service.js.map +1 -1
- package/dist/cores/config/config-service.js +3 -1
- package/dist/cores/config/config-service.js.map +1 -1
- package/dist/cores/lambda/lambda-handler.js +4 -1
- package/dist/cores/lambda/lambda-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-notification-handler.js +4 -1
- package/dist/cores/lambda/lambda-notification-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-web-handler.js +16 -9
- package/dist/cores/lambda/lambda-web-handler.js.map +1 -1
- package/dist/cores/protocol/aws-lambda-helper.d.ts +13 -0
- package/dist/cores/protocol/aws-lambda-helper.js +64 -41
- package/dist/cores/protocol/aws-lambda-helper.js.map +1 -1
- package/dist/cores/protocol/local-transport.d.ts +135 -0
- package/dist/cores/protocol/local-transport.js +392 -0
- package/dist/cores/protocol/local-transport.js.map +1 -0
- package/dist/cores/protocol/protocol-service.d.ts +3 -2
- package/dist/cores/protocol/protocol-service.js +33 -10
- package/dist/cores/protocol/protocol-service.js.map +1 -1
- package/dist/cores/protocol/protocol-sign.d.ts +12 -0
- package/dist/cores/protocol/protocol-sign.js +17 -1
- package/dist/cores/protocol/protocol-sign.js.map +1 -1
- package/dist/engine/engine.js +26 -13
- package/dist/engine/engine.js.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/log-mask.d.ts +19 -0
- package/dist/lib/log-mask.js +55 -0
- package/dist/lib/log-mask.js.map +1 -0
- package/dist/lib/safe-json.d.ts +23 -0
- package/dist/lib/safe-json.js +78 -0
- package/dist/lib/safe-json.js.map +1 -0
- package/package.json +13 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `safe-json.ts`
|
|
4
|
+
* - internal `JSON.stringify()` for error reports, which never throws.
|
|
5
|
+
* - a back-reference to an ancestor (circular structure) becomes `'[Circular]'`.
|
|
6
|
+
* - an `Error` instance is expanded to `{ name, message, stack?, ...own props, errors?, cause? }` (plain `JSON.stringify()` gives `{}`).
|
|
7
|
+
* - a `BigInt` becomes its decimal string.
|
|
8
|
+
* - otherwise the output is the same as `JSON.stringify()` (key order, `toJSON()`, omitted `undefined`/function values).
|
|
9
|
+
* - used by `asErrorPayload()`·`GETERR()` (`common/test-helper.ts`), `doReportError()`·`do_parallel()` (`engine/engine.ts`) and `AWSSNSService.publish()`.
|
|
10
|
+
* - NOTE: internal only. do not export from `lib/index.ts` or any other barrel.
|
|
11
|
+
*
|
|
12
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
13
|
+
* @date 2026-10-29 initial version (v5 B10-2: circular structure in `doReportError()`)
|
|
14
|
+
*
|
|
15
|
+
* @copyright (C) lemoncloud.io 2026 - All Rights Reserved.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.safeStringify = void 0;
|
|
19
|
+
//* v5 B10-2: expand an `Error` to a plain object, so that `name`·`message`·`stack` and non-enumerable `errors`·`cause` are kept.
|
|
20
|
+
const expandError = (e) => {
|
|
21
|
+
const out = { name: e.name, message: e.message };
|
|
22
|
+
if (e.stack !== undefined)
|
|
23
|
+
out.stack = e.stack;
|
|
24
|
+
// own enumerable props (e.g. `code`, `statusCode`, `errors` set by assignment).
|
|
25
|
+
for (const key of Object.keys(e))
|
|
26
|
+
out[key] = e[key];
|
|
27
|
+
// `AggregateError.errors` and `new Error(m, { cause })` are own but non-enumerable.
|
|
28
|
+
if (!('errors' in out) && e.errors !== undefined)
|
|
29
|
+
out.errors = e.errors;
|
|
30
|
+
if (!('cause' in out) && e.cause !== undefined)
|
|
31
|
+
out.cause = e.cause;
|
|
32
|
+
return out;
|
|
33
|
+
};
|
|
34
|
+
//* v5 B10-2: build a replacer, which tracks only the ancestors (a shared but non-circular reference is printed as is).
|
|
35
|
+
const circularReplacer = () => {
|
|
36
|
+
const stack = [];
|
|
37
|
+
return function (_key, value) {
|
|
38
|
+
if (typeof value === 'bigint')
|
|
39
|
+
return value.toString();
|
|
40
|
+
if (value === null || typeof value !== 'object')
|
|
41
|
+
return value;
|
|
42
|
+
// drop the finished siblings: the top of the stack must be the current holder.
|
|
43
|
+
while (stack.length > 0 && stack[stack.length - 1].holder !== this)
|
|
44
|
+
stack.pop();
|
|
45
|
+
if (stack.some(a => a.origin === value))
|
|
46
|
+
return '[Circular]';
|
|
47
|
+
const holder = value instanceof Error ? expandError(value) : value;
|
|
48
|
+
stack.push({ holder, origin: value });
|
|
49
|
+
return holder;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* `JSON.stringify()` which never throws (v5 B10-2).
|
|
54
|
+
* - on any failure (e.g. a throwing getter or `toJSON()`), it falls back to `String(value)`.
|
|
55
|
+
*
|
|
56
|
+
* @param value any value to print.
|
|
57
|
+
* @param space (optional) same as `JSON.stringify()`.
|
|
58
|
+
*/
|
|
59
|
+
const safeStringify = (value, space) => {
|
|
60
|
+
//* v5 B10-2: main path — `JSON.stringify()` with the circular-safe replacer.
|
|
61
|
+
try {
|
|
62
|
+
const text = JSON.stringify(value, circularReplacer(), space);
|
|
63
|
+
if (typeof text === 'string')
|
|
64
|
+
return text;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
// fall through to the last resort.
|
|
68
|
+
}
|
|
69
|
+
//* v5 B10-2: last resort — `String()` may throw too (e.g. `Object.create(null)`).
|
|
70
|
+
try {
|
|
71
|
+
return String(value);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return '[Unserializable]';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.safeStringify = safeStringify;
|
|
78
|
+
//# sourceMappingURL=safe-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-json.js","sourceRoot":"","sources":["../../src/lib/safe-json.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAQH,iIAAiI;AACjI,MAAM,WAAW,GAAG,CAAC,CAAQ,EAA2B,EAAE;IACtD,MAAM,GAAG,GAA4B,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1E,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;QAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAC/C,gFAAgF;IAChF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,GAAG,CAAC,GAAG,CAAC,GAAI,CAAS,CAAC,GAAG,CAAC,CAAC;IAC7D,oFAAoF;IACpF,IAAI,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAK,CAAS,CAAC,MAAM,KAAK,SAAS;QAAE,GAAG,CAAC,MAAM,GAAI,CAAS,CAAC,MAAM,CAAC;IAC1F,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,IAAK,CAAS,CAAC,KAAK,KAAK,SAAS;QAAE,GAAG,CAAC,KAAK,GAAI,CAAS,CAAC,KAAK,CAAC;IACtF,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEF,uHAAuH;AACvH,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC1B,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,OAAO,UAAwB,IAAY,EAAE,KAAc;Q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W,QAAA,aAAa,iBAcxB"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lemon-core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"description": "Lemon Serverless Micro-Service Platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"lemon-fields-types": "bin/lemon-fields-types.mjs"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"types": "./dist/index.d.ts",
|
|
@@ -52,6 +55,7 @@
|
|
|
52
55
|
"api:check": "node scripts/api-check.cjs",
|
|
53
56
|
"dup:check": "node scripts/dup-decls.cjs",
|
|
54
57
|
"l1l2:probe": "node scripts/l1l2-probe.cjs",
|
|
58
|
+
"fields:types": "node bin/lemon-fields-types.mjs",
|
|
55
59
|
"watch-ts": "tsc -w",
|
|
56
60
|
"lint": "tsc --noEmit && eslint '*/**/*.{js,ts,jsx,tsx}' --fix",
|
|
57
61
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
@@ -81,7 +85,9 @@
|
|
|
81
85
|
]
|
|
82
86
|
},
|
|
83
87
|
"files": [
|
|
84
|
-
"dist/**/*"
|
|
88
|
+
"dist/**/*",
|
|
89
|
+
"bin/lemon-fields-types.mjs",
|
|
90
|
+
"bin/lib/fields-types.mjs"
|
|
85
91
|
],
|
|
86
92
|
"engines": {
|
|
87
93
|
"node": ">=24.0.0"
|
|
@@ -145,7 +151,8 @@
|
|
|
145
151
|
"@aws-sdk/client-sns": "^3.1159.0",
|
|
146
152
|
"@aws-sdk/client-sqs": "^3.1159.0",
|
|
147
153
|
"@aws-sdk/client-sts": "^3.1159.0",
|
|
148
|
-
"@aws-sdk/credential-providers": "^3.1159.0"
|
|
154
|
+
"@aws-sdk/credential-providers": "^3.1159.0",
|
|
155
|
+
"typescript": ">=4.7"
|
|
149
156
|
},
|
|
150
157
|
"peerDependenciesMeta": {
|
|
151
158
|
"@aws-sdk/client-iam": {
|
|
@@ -171,6 +178,9 @@
|
|
|
171
178
|
},
|
|
172
179
|
"@aws-sdk/credential-providers": {
|
|
173
180
|
"optional": true
|
|
181
|
+
},
|
|
182
|
+
"typescript": {
|
|
183
|
+
"optional": true
|
|
174
184
|
}
|
|
175
185
|
},
|
|
176
186
|
"private": false,
|