logixia 1.13.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -44
- package/dist/async-context-B05ArHgM.mjs +134 -0
- package/dist/async-context-B05ArHgM.mjs.map +1 -0
- package/dist/async-context-DTQgi8f7.js +150 -0
- package/dist/async-context-DTQgi8f7.js.map +1 -0
- package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
- package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
- package/dist/{azure-monitor.transport-BDFO4F-i.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
- package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
- package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
- package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
- package/dist/{azure-monitor.transport-D5wQEH04.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
- package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
- package/dist/azure.d.mts +1 -2
- package/dist/azure.d.ts +1 -2
- package/dist/azure.js +3 -6
- package/dist/azure.mjs +1 -6
- package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
- package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
- package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
- package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
- package/dist/browser.d.mts +52 -23
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +52 -23
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +460 -62
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +461 -65
- package/dist/browser.mjs.map +1 -1
- package/dist/{nestjs-extras-ImbuDhs1.mjs → builder-D70z6kjj.mjs} +279 -965
- package/dist/builder-D70z6kjj.mjs.map +1 -0
- package/dist/{nestjs-extras-DnJ6vrIC.js → builder-M7NoaugM.js} +421 -1177
- package/dist/builder-M7NoaugM.js.map +1 -0
- package/dist/cli/index.js +86 -67
- package/dist/cloudwatch.d.mts +1 -2
- package/dist/cloudwatch.d.ts +1 -2
- package/dist/cloudwatch.js +3 -7
- package/dist/cloudwatch.mjs +1 -7
- package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
- package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
- package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
- package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
- package/dist/{cloudwatch.transport-B00st6Xv.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
- package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-Blc7Gtxt.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
- package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
- package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
- package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
- package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
- package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
- package/dist/correlation.d.mts +13 -16
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +13 -16
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +58 -9
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +56 -6
- package/dist/correlation.mjs.map +1 -1
- package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
- package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
- package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
- package/dist/entry-fields-RLd1jCoR.js.map +1 -0
- package/dist/gcp.d.mts +1 -2
- package/dist/gcp.d.ts +1 -2
- package/dist/gcp.js +3 -7
- package/dist/gcp.mjs +1 -7
- package/dist/{gcp.transport-m4fVw0b1.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
- package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
- package/dist/{gcp.transport-zzNyIoih.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
- package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
- package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
- package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
- package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
- package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
- package/dist/{index-nZEeCr3X.d.ts → index-DwozbmB4.d.ts} +3 -8
- package/dist/index-DwozbmB4.d.ts.map +1 -0
- package/dist/{index-BPwEisy4.d.mts → index-xqaJtAZn.d.mts} +3 -8
- package/dist/index-xqaJtAZn.d.mts.map +1 -0
- package/dist/index.d.mts +141 -203
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +140 -202
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +196 -381
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -294
- package/dist/index.mjs.map +1 -1
- package/dist/internal-log-b0Vp4qrB.js +183 -0
- package/dist/internal-log-b0Vp4qrB.js.map +1 -0
- package/dist/internal-log-uCSd1PMc.mjs +142 -0
- package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts +365 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts +365 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
- package/dist/middleware.d.mts +10 -12
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +10 -12
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +16 -47
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +13 -45
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +467 -10
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +467 -10
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +889 -43
- package/dist/nest.js.map +1 -0
- package/dist/nest.mjs +850 -9
- package/dist/nest.mjs.map +1 -0
- package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
- package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
- package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
- package/dist/request-trace-wTJdKp6-.js.map +1 -0
- package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
- package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
- package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
- package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
- package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
- package/dist/{search-CHUZPl0h.d.ts → search-BH33XhuU.d.mts} +2 -22
- package/dist/search-BH33XhuU.d.mts.map +1 -0
- package/dist/{search-DjXSn6v5.mjs → search-CWMVYC-R.mjs} +34 -41
- package/dist/search-CWMVYC-R.mjs.map +1 -0
- package/dist/{search-BfBzDIT9.d.mts → search-CazwyX5Z.d.ts} +2 -22
- package/dist/search-CazwyX5Z.d.ts.map +1 -0
- package/dist/{search-B0MH1SJJ.js → search-DUfWuzFP.js} +64 -71
- package/dist/search-DUfWuzFP.js.map +1 -0
- package/dist/search.d.mts +2 -4
- package/dist/search.d.ts +2 -4
- package/dist/search.js +3 -4
- package/dist/search.mjs +1 -4
- package/dist/secret-config-BegMLkYl.mjs +209 -0
- package/dist/secret-config-BegMLkYl.mjs.map +1 -0
- package/dist/secret-config-CBZBs0p1.js +271 -0
- package/dist/secret-config-CBZBs0p1.js.map +1 -0
- package/dist/slack.transport-Ce96JBDk.mjs +824 -0
- package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
- package/dist/slack.transport-Dlx3xvb7.js +847 -0
- package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
- package/dist/slack.transport-DrirgDNy.d.ts +159 -0
- package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
- package/dist/slack.transport-DxHOXlLu.d.mts +159 -0
- package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
- package/dist/testing.d.mts +3 -8
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.d.ts +3 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -4
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +2 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.manager-Crau3Rle.js → transport.manager-DkcEOlqV.js} +331 -234
- package/dist/transport.manager-DkcEOlqV.js.map +1 -0
- package/dist/{transport.manager-CpdVHEGP.mjs → transport.manager-eZ_EeC00.mjs} +274 -178
- package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
- package/dist/{transport.types-CtNr3D7S.d.mts → transport.types-BJVL1QQl.d.mts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
- package/dist/{transport.types-DqVLZTyf.d.ts → transport.types-BJVL1QQl.d.ts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
- package/dist/transports.d.mts +32 -41
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +32 -41
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +12 -12
- package/dist/transports.mjs +7 -12
- package/dist/worker-entry.js +337 -87
- package/dist/worker.d.mts +1 -2
- package/dist/worker.d.ts +1 -2
- package/dist/worker.js +3 -4
- package/dist/worker.mjs +1 -4
- package/dist/{worker.transport-Bj-i0P9V.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
- package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
- package/dist/{worker.transport-JP8YHBuU.js → worker.transport-C6GNl_r2.js} +44 -14
- package/dist/worker.transport-C6GNl_r2.js.map +1 -0
- package/dist/{worker.transport-otwhJ_Et.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
- package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
- package/dist/{worker.transport-Bgv9heDI.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
- package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
- package/package.json +36 -19
- package/dist/async-context-BzJrbfQs.mjs +0 -72
- package/dist/async-context-BzJrbfQs.mjs.map +0 -1
- package/dist/async-context-DyQQYq3I.js +0 -92
- package/dist/async-context-DyQQYq3I.js.map +0 -1
- package/dist/azure-monitor.transport-BDFO4F-i.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D5wQEH04.d.mts.map +0 -1
- package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
- package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-B00st6Xv.d.ts.map +0 -1
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-Blc7Gtxt.d.mts.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
- package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
- package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
- package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
- package/dist/gcp.transport-m4fVw0b1.d.ts.map +0 -1
- package/dist/gcp.transport-zzNyIoih.d.mts.map +0 -1
- package/dist/index-BPwEisy4.d.mts.map +0 -1
- package/dist/index-nZEeCr3X.d.ts.map +0 -1
- package/dist/internal-log-BUJYMZbE.js +0 -70
- package/dist/internal-log-BUJYMZbE.js.map +0 -1
- package/dist/internal-log-Cm8SOWSV.mjs +0 -52
- package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
- package/dist/nestjs-extras-DnJ6vrIC.js.map +0 -1
- package/dist/nestjs-extras-ImbuDhs1.mjs.map +0 -1
- package/dist/nestjs-extras-OkC796py.d.mts +0 -725
- package/dist/nestjs-extras-OkC796py.d.mts.map +0 -1
- package/dist/nestjs-extras-mKrHE9S6.d.ts +0 -725
- package/dist/nestjs-extras-mKrHE9S6.d.ts.map +0 -1
- package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
- package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
- package/dist/search-B0MH1SJJ.js.map +0 -1
- package/dist/search-BfBzDIT9.d.mts.map +0 -1
- package/dist/search-CHUZPl0h.d.ts.map +0 -1
- package/dist/search-DjXSn6v5.mjs.map +0 -1
- package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
- package/dist/trace.utils-DpBOLDtq.js.map +0 -1
- package/dist/transport.manager-CpdVHEGP.mjs.map +0 -1
- package/dist/transport.manager-Crau3Rle.js.map +0 -1
- package/dist/transport.types-CtNr3D7S.d.mts.map +0 -1
- package/dist/transport.types-DqVLZTyf.d.ts.map +0 -1
- package/dist/worker.transport-Bgv9heDI.d.mts.map +0 -1
- package/dist/worker.transport-Bj-i0P9V.d.ts.map +0 -1
- package/dist/worker.transport-JP8YHBuU.js.map +0 -1
- package/dist/worker.transport-otwhJ_Et.mjs.map +0 -1
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { r as internalWarn } from "./internal-log-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as mergeCoreFields } from "./entry-fields-
|
|
5
|
-
import
|
|
1
|
+
import { r as internalWarn } from "./internal-log-uCSd1PMc.mjs";
|
|
2
|
+
import { n as protectSecrets, o as urlSecrets } from "./secret-config-BegMLkYl.mjs";
|
|
3
|
+
import { i as stringifyForLog } from "./safe-stringify-BMRl3EX3.mjs";
|
|
4
|
+
import { t as mergeCoreFields } from "./entry-fields-CGuvT2R0.mjs";
|
|
5
|
+
import { a as httpRequest, i as HttpError, o as isPermanentHttpError, t as BatchBuffer } from "./batch-buffer-0fgLmIPn.mjs";
|
|
6
|
+
import * as crypto from "node:crypto";
|
|
6
7
|
import * as os from "node:os";
|
|
8
|
+
import * as fs from "node:fs";
|
|
7
9
|
import * as path$1 from "node:path";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// src/transports/aws-credentials.ts
|
|
11
|
+
/**
|
|
12
|
+
* AWS credential resolution without the SDK.
|
|
13
|
+
*
|
|
14
|
+
* Order: explicit config, environment variables, shared credentials file,
|
|
15
|
+
* ECS/container credentials, EC2 instance metadata (IMDSv2).
|
|
16
|
+
* Not supported: SSO, assume-role profiles, credential_process, web identity.
|
|
17
|
+
*/
|
|
18
|
+
const REFRESH_MARGIN_MS = 3e5;
|
|
19
|
+
const FAILURE_BACKOFF_MS = 3e4;
|
|
13
20
|
const METADATA_TIMEOUT_MS = 2e3;
|
|
14
21
|
/** Parse the sections of an AWS ini file into `{ section: { key: value } }`. */
|
|
15
22
|
function parseIni(text) {
|
|
@@ -68,7 +75,7 @@ function fromDocument(raw) {
|
|
|
68
75
|
expiresAt: Number.isNaN(expiresAt) ? void 0 : expiresAt
|
|
69
76
|
};
|
|
70
77
|
}
|
|
71
|
-
const CONTAINER_HOSTS = new Set([
|
|
78
|
+
const CONTAINER_HOSTS = /* @__PURE__ */ new Set([
|
|
72
79
|
"169.254.170.2",
|
|
73
80
|
"169.254.170.23",
|
|
74
81
|
"[fd00:ec2::23]",
|
|
@@ -113,8 +120,7 @@ async function fromInstanceMetadata() {
|
|
|
113
120
|
timeoutMs: METADATA_TIMEOUT_MS,
|
|
114
121
|
label: "EC2 instance metadata"
|
|
115
122
|
});
|
|
116
|
-
const
|
|
117
|
-
const auth = { "X-aws-ec2-metadata-token": session.body.trim() };
|
|
123
|
+
const auth = { "X-aws-ec2-metadata-token": (await get("/latest/api/token", "PUT", { "X-aws-ec2-metadata-token-ttl-seconds": "21600" })).body.trim() };
|
|
118
124
|
const role = (_roles$body$split$ = (await get("/latest/meta-data/iam/security-credentials/", "GET", auth)).body.split("\n")[0]) === null || _roles$body$split$ === void 0 ? void 0 : _roles$body$split$.trim();
|
|
119
125
|
if (!role) return void 0;
|
|
120
126
|
return fromDocument((await get(`/latest/meta-data/iam/security-credentials/${encodeURIComponent(role)}`, "GET", auth)).body);
|
|
@@ -122,6 +128,7 @@ async function fromInstanceMetadata() {
|
|
|
122
128
|
var AwsCredentialProvider = class {
|
|
123
129
|
constructor(config) {
|
|
124
130
|
this.failedAt = 0;
|
|
131
|
+
protectSecrets(this, ["cached", "explicit"]);
|
|
125
132
|
if (config.accessKeyId && config.secretAccessKey) this.explicit = {
|
|
126
133
|
accessKeyId: config.accessKeyId,
|
|
127
134
|
secretAccessKey: config.secretAccessKey,
|
|
@@ -149,6 +156,19 @@ var AwsCredentialProvider = class {
|
|
|
149
156
|
this.cached = found;
|
|
150
157
|
return found;
|
|
151
158
|
}
|
|
159
|
+
/** Secret values this provider may hold, for scrubbing error text. */
|
|
160
|
+
secretValues() {
|
|
161
|
+
var _this$explicit, _this$explicit2, _this$cached, _this$cached2;
|
|
162
|
+
const env = process.env;
|
|
163
|
+
return [
|
|
164
|
+
(_this$explicit = this.explicit) === null || _this$explicit === void 0 ? void 0 : _this$explicit.secretAccessKey,
|
|
165
|
+
(_this$explicit2 = this.explicit) === null || _this$explicit2 === void 0 ? void 0 : _this$explicit2.sessionToken,
|
|
166
|
+
(_this$cached = this.cached) === null || _this$cached === void 0 ? void 0 : _this$cached.secretAccessKey,
|
|
167
|
+
(_this$cached2 = this.cached) === null || _this$cached2 === void 0 ? void 0 : _this$cached2.sessionToken,
|
|
168
|
+
env["AWS_SECRET_ACCESS_KEY"],
|
|
169
|
+
env["AWS_SESSION_TOKEN"]
|
|
170
|
+
];
|
|
171
|
+
}
|
|
152
172
|
invalidate() {
|
|
153
173
|
this.cached = void 0;
|
|
154
174
|
this.failedAt = 0;
|
|
@@ -157,14 +177,15 @@ var AwsCredentialProvider = class {
|
|
|
157
177
|
return c.expiresAt !== void 0 && c.expiresAt - Date.now() < REFRESH_MARGIN_MS;
|
|
158
178
|
}
|
|
159
179
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
180
|
+
// src/transports/aws-sigv4.ts
|
|
181
|
+
/**
|
|
182
|
+
* AWS Signature Version 4 request signing, dependency-free.
|
|
183
|
+
*/
|
|
163
184
|
const sha256Hex = (data) => crypto.createHash("sha256").update(data).digest("hex");
|
|
164
185
|
const hmac = (key, msg) => crypto.createHmac("sha256", key).update(msg).digest();
|
|
165
186
|
/** Returns the request headers (lowercase names) with `x-amz-date` and `authorization` added. */
|
|
166
187
|
function signV4(opts) {
|
|
167
|
-
const { method, path
|
|
188
|
+
const { method, path, query = "", body, region, service, credentials, headers: input, date } = opts;
|
|
168
189
|
const amzDate = (date ?? /* @__PURE__ */ new Date()).toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
169
190
|
const dateStamp = amzDate.slice(0, 8);
|
|
170
191
|
const headers = {};
|
|
@@ -176,7 +197,7 @@ function signV4(opts) {
|
|
|
176
197
|
const signedHeaders = names.join(";");
|
|
177
198
|
const canonicalRequest = [
|
|
178
199
|
method,
|
|
179
|
-
path
|
|
200
|
+
path,
|
|
180
201
|
query,
|
|
181
202
|
canonicalHeaders,
|
|
182
203
|
signedHeaders,
|
|
@@ -194,13 +215,11 @@ function signV4(opts) {
|
|
|
194
215
|
headers["authorization"] = `AWS4-HMAC-SHA256 Credential=${credentials.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;
|
|
195
216
|
return headers;
|
|
196
217
|
}
|
|
197
|
-
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region src/transports/cloudwatch.transport.ts
|
|
218
|
+
// src/transports/cloudwatch.transport.ts
|
|
200
219
|
const MAX_EVENTS_PER_PUT = 1e4;
|
|
201
220
|
const EMF_MAX_METRICS = 100;
|
|
202
221
|
/** Error types worth retrying even though CloudWatch reports them as HTTP 400. */
|
|
203
|
-
const RETRYABLE_TYPES = new Set([
|
|
222
|
+
const RETRYABLE_TYPES = /* @__PURE__ */ new Set([
|
|
204
223
|
"ThrottlingException",
|
|
205
224
|
"ThrottledException",
|
|
206
225
|
"LimitExceededException",
|
|
@@ -236,18 +255,20 @@ var CloudWatchTransport = class {
|
|
|
236
255
|
this.emf = config.emf ?? false;
|
|
237
256
|
this.emfMetrics = config.emfMetrics ? new Set(config.emfMetrics) : void 0;
|
|
238
257
|
this.level = config.level;
|
|
239
|
-
this.requestTimeoutMs = config.requestTimeoutMs ??
|
|
258
|
+
this.requestTimeoutMs = config.requestTimeoutMs ?? 1e4;
|
|
240
259
|
this.buffer = new BatchBuffer({
|
|
241
260
|
name: "CloudWatchTransport",
|
|
242
261
|
batchSize: this.batchSize,
|
|
243
|
-
maxBufferSize: config.maxBufferSize ??
|
|
262
|
+
maxBufferSize: config.maxBufferSize ?? 1e4,
|
|
244
263
|
send: (events) => this.putLogEvents(events),
|
|
264
|
+
secrets: () => [...this.credentials.secretValues(), ...urlSecrets(this.endpoint)],
|
|
245
265
|
shouldRetry: (err) => !isPermanentHttpError(err) || RETRYABLE_TYPES.has(awsErrorType(err) ?? "")
|
|
246
266
|
});
|
|
247
267
|
this.flushTimer = setInterval(() => {
|
|
248
268
|
this.flush().catch(() => {});
|
|
249
269
|
}, this.flushInterval);
|
|
250
270
|
if (this.flushTimer.unref) this.flushTimer.unref();
|
|
271
|
+
protectSecrets(this, ["credentials", "endpoint"]);
|
|
251
272
|
}
|
|
252
273
|
write(entry) {
|
|
253
274
|
const timestamp = entry.timestamp ? new Date(entry.timestamp).getTime() : Date.now();
|
|
@@ -357,11 +378,16 @@ var CloudWatchTransport = class {
|
|
|
357
378
|
headers,
|
|
358
379
|
body,
|
|
359
380
|
timeoutMs: this.requestTimeoutMs,
|
|
360
|
-
label: `CloudWatch ${action}
|
|
381
|
+
label: `CloudWatch ${action}`,
|
|
382
|
+
secrets: () => [
|
|
383
|
+
...this.credentials.secretValues(),
|
|
384
|
+
headers["authorization"],
|
|
385
|
+
headers["x-amz-security-token"],
|
|
386
|
+
...urlSecrets(this.endpoint)
|
|
387
|
+
]
|
|
361
388
|
});
|
|
362
389
|
}
|
|
363
390
|
};
|
|
364
|
-
|
|
365
|
-
//#endregion
|
|
366
391
|
export { CloudWatchTransport as t };
|
|
367
|
-
|
|
392
|
+
|
|
393
|
+
//# sourceMappingURL=cloudwatch.transport-BTvYfLs9.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudwatch.transport-BTvYfLs9.mjs","names":["path"],"sources":["../src/transports/aws-credentials.ts","../src/transports/aws-sigv4.ts","../src/transports/cloudwatch.transport.ts"],"sourcesContent":["/**\n * AWS credential resolution without the SDK.\n *\n * Order: explicit config, environment variables, shared credentials file,\n * ECS/container credentials, EC2 instance metadata (IMDSv2).\n * Not supported: SSO, assume-role profiles, credential_process, web identity.\n */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\nimport { internalWarn } from '../utils/internal-log';\nimport { type AwsCredentials } from './aws-sigv4';\nimport { httpRequest } from './batch-buffer';\nimport { protectSecrets } from './secret-config';\n\nconst REFRESH_MARGIN_MS = 5 * 60 * 1000;\nconst FAILURE_BACKOFF_MS = 30 * 1000;\nconst METADATA_TIMEOUT_MS = 2000;\n\nexport interface AwsCredentialConfig {\n accessKeyId?: string | undefined;\n secretAccessKey?: string | undefined;\n sessionToken?: string | undefined;\n}\n\n/** Parse the sections of an AWS ini file into `{ section: { key: value } }`. */\nexport function parseIni(text: string): Record<string, Record<string, string>> {\n const out: Record<string, Record<string, string>> = {};\n let section: Record<string, string> | undefined;\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.trim();\n if (!line || line.startsWith('#') || line.startsWith(';')) continue;\n const header = /^\\[(.+)\\]$/.exec(line);\n if (header) {\n section = out[header[1]!.trim()] = out[header[1]!.trim()] ?? {};\n continue;\n }\n const eq = line.indexOf('=');\n if (eq > 0 && section) section[line.slice(0, eq).trim()] = line.slice(eq + 1).trim();\n }\n return out;\n}\n\nfunction fromEnv(): AwsCredentials | undefined {\n const accessKeyId = process.env['AWS_ACCESS_KEY_ID'];\n const secretAccessKey = process.env['AWS_SECRET_ACCESS_KEY'];\n if (!accessKeyId || !secretAccessKey) return undefined;\n return { accessKeyId, secretAccessKey, sessionToken: process.env['AWS_SESSION_TOKEN'] };\n}\n\nfunction fromSharedFile(): AwsCredentials | undefined {\n const file =\n process.env['AWS_SHARED_CREDENTIALS_FILE'] ?? path.join(os.homedir(), '.aws', 'credentials');\n const profile = process.env['AWS_PROFILE'] ?? 'default';\n let text: string;\n try {\n text = fs.readFileSync(file, 'utf8');\n } catch {\n return undefined;\n }\n const section = parseIni(text)[profile];\n const accessKeyId = section?.['aws_access_key_id'];\n const secretAccessKey = section?.['aws_secret_access_key'];\n if (!accessKeyId || !secretAccessKey) return undefined;\n return { accessKeyId, secretAccessKey, sessionToken: section?.['aws_session_token'] };\n}\n\ninterface CredentialDocument {\n AccessKeyId?: string;\n SecretAccessKey?: string;\n Token?: string;\n Expiration?: string;\n}\n\nfunction fromDocument(raw: string): AwsCredentials | undefined {\n const doc = JSON.parse(raw) as CredentialDocument;\n if (!doc.AccessKeyId || !doc.SecretAccessKey) return undefined;\n const expiresAt = doc.Expiration ? Date.parse(doc.Expiration) : Number.NaN;\n return {\n accessKeyId: doc.AccessKeyId,\n secretAccessKey: doc.SecretAccessKey,\n sessionToken: doc.Token,\n expiresAt: Number.isNaN(expiresAt) ? undefined : expiresAt,\n };\n}\n\nconst CONTAINER_HOSTS = new Set([\n // eslint-disable-next-line sonarjs/no-hardcoded-ip -- fixed ECS credentials endpoint\n '169.254.170.2',\n // eslint-disable-next-line sonarjs/no-hardcoded-ip -- fixed EKS pod identity endpoint\n '169.254.170.23',\n '[fd00:ec2::23]',\n 'localhost',\n '[::1]',\n]);\n\n/** Same rule as the AWS SDKs: never send the container token to an arbitrary http host. */\nfunction isAllowedContainerHost(url: URL): boolean {\n if (url.protocol === 'https:') return true;\n if (url.protocol !== 'http:') return false;\n return CONTAINER_HOSTS.has(url.hostname) || /^127(?:\\.\\d{1,3}){3}$/.test(url.hostname);\n}\n\nasync function fromContainer(): Promise<AwsCredentials | undefined> {\n const relative = process.env['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'];\n const full = process.env['AWS_CONTAINER_CREDENTIALS_FULL_URI'];\n if (!relative && !full) return undefined;\n const url = new URL(relative ? `http://169.254.170.2${relative}` : (full as string));\n if (!relative && !isAllowedContainerHost(url)) {\n internalWarn(\n `ignoring AWS_CONTAINER_CREDENTIALS_FULL_URI: ${url.host} is not https or a loopback / ECS / EKS address`\n );\n return undefined;\n }\n const headers: Record<string, string> = {};\n const tokenFile = process.env['AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE'];\n const token = tokenFile\n ? fs.readFileSync(tokenFile, 'utf8').trim()\n : process.env['AWS_CONTAINER_AUTHORIZATION_TOKEN'];\n if (token) headers['Authorization'] = token;\n const res = await httpRequest({\n url,\n method: 'GET',\n headers,\n timeoutMs: METADATA_TIMEOUT_MS,\n label: 'AWS container credentials',\n });\n return fromDocument(res.body);\n}\n\nasync function fromInstanceMetadata(): Promise<AwsCredentials | undefined> {\n if (process.env['AWS_EC2_METADATA_DISABLED'] === 'true') return undefined;\n const base = process.env['AWS_EC2_METADATA_SERVICE_ENDPOINT'] ?? 'http://169.254.169.254';\n const get = (p: string, method: string, headers: Record<string, string>) =>\n httpRequest({\n url: new URL(p, base),\n method,\n headers,\n timeoutMs: METADATA_TIMEOUT_MS,\n label: 'EC2 instance metadata',\n });\n const session = await get('/latest/api/token', 'PUT', {\n 'X-aws-ec2-metadata-token-ttl-seconds': '21600',\n });\n const auth = { 'X-aws-ec2-metadata-token': session.body.trim() };\n const roles = await get('/latest/meta-data/iam/security-credentials/', 'GET', auth);\n const role = roles.body.split('\\n')[0]?.trim();\n if (!role) return undefined;\n const creds = await get(\n `/latest/meta-data/iam/security-credentials/${encodeURIComponent(role)}`,\n 'GET',\n auth\n );\n return fromDocument(creds.body);\n}\n\nexport class AwsCredentialProvider {\n private cached: AwsCredentials | undefined;\n private failedAt = 0;\n private readonly explicit: AwsCredentials | undefined;\n\n constructor(config: AwsCredentialConfig) {\n protectSecrets(this, ['cached', 'explicit']);\n if (config.accessKeyId && config.secretAccessKey) {\n this.explicit = {\n accessKeyId: config.accessKeyId,\n secretAccessKey: config.secretAccessKey,\n sessionToken: config.sessionToken,\n };\n }\n }\n\n /** Throws when no source yields credentials, so the caller keeps its buffer. */\n async get(): Promise<AwsCredentials> {\n if (this.explicit) return this.explicit;\n const env = fromEnv();\n if (env) return env;\n if (this.cached && !this.isExpiring(this.cached)) return this.cached;\n if (Date.now() - this.failedAt < FAILURE_BACKOFF_MS) {\n throw new Error('no AWS credentials found (retrying shortly)');\n }\n\n let found = fromSharedFile();\n for (const source of [fromContainer, fromInstanceMetadata]) {\n if (found) break;\n try {\n found = await source();\n } catch {\n /* source not available here; try the next */\n }\n }\n if (!found) {\n this.failedAt = Date.now();\n throw new Error(\n 'no AWS credentials found: set AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, a shared credentials file, container credentials, or run on EC2 with an instance role'\n );\n }\n this.cached = found;\n return found;\n }\n\n /** Secret values this provider may hold, for scrubbing error text. */\n secretValues(): (string | undefined)[] {\n const env = process.env;\n return [\n this.explicit?.secretAccessKey,\n this.explicit?.sessionToken,\n this.cached?.secretAccessKey,\n this.cached?.sessionToken,\n env['AWS_SECRET_ACCESS_KEY'],\n env['AWS_SESSION_TOKEN'],\n ];\n }\n\n invalidate(): void {\n this.cached = undefined;\n this.failedAt = 0;\n }\n\n private isExpiring(c: AwsCredentials): boolean {\n return c.expiresAt !== undefined && c.expiresAt - Date.now() < REFRESH_MARGIN_MS;\n }\n}\n","/**\n * AWS Signature Version 4 request signing, dependency-free.\n */\n\nimport * as crypto from 'node:crypto';\n\nexport interface AwsCredentials {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken?: string | undefined;\n /** Epoch ms after which the credentials are no longer valid. */\n expiresAt?: number | undefined;\n}\n\nexport interface SignV4Options {\n method: string;\n path: string;\n query?: string;\n /** Must include `host`. Names are lowercased before signing. */\n headers: Record<string, string>;\n body: string;\n region: string;\n service: string;\n credentials: AwsCredentials;\n date?: Date;\n}\n\nconst sha256Hex = (data: string): string => crypto.createHash('sha256').update(data).digest('hex');\n\nconst hmac = (key: Buffer | string, msg: string): Buffer =>\n crypto.createHmac('sha256', key).update(msg).digest();\n\n/** Returns the request headers (lowercase names) with `x-amz-date` and `authorization` added. */\nexport function signV4(opts: SignV4Options): Record<string, string> {\n const {\n method,\n path,\n query = '',\n body,\n region,\n service,\n credentials,\n headers: input,\n date,\n } = opts;\n const amzDate = (date ?? new Date()).toISOString().replace(/[:-]|\\.\\d{3}/g, '');\n const dateStamp = amzDate.slice(0, 8);\n\n const headers: Record<string, string> = {};\n for (const [k, v] of Object.entries(input)) headers[k.toLowerCase()] = v;\n headers['x-amz-date'] = amzDate;\n if (credentials.sessionToken) headers['x-amz-security-token'] = credentials.sessionToken;\n\n const names = Object.keys(headers).sort();\n const canonicalHeaders = names\n .map((n) => `${n}:${headers[n]!.trim().replace(/\\s+/g, ' ')}\\n`)\n .join('');\n const signedHeaders = names.join(';');\n\n const canonicalRequest = [\n method,\n path,\n query,\n canonicalHeaders,\n signedHeaders,\n sha256Hex(body),\n ].join('\\n');\n const scope = `${dateStamp}/${region}/${service}/aws4_request`;\n const stringToSign = ['AWS4-HMAC-SHA256', amzDate, scope, sha256Hex(canonicalRequest)].join('\\n');\n\n const signingKey = hmac(\n hmac(hmac(hmac(`AWS4${credentials.secretAccessKey}`, dateStamp), region), service),\n 'aws4_request'\n );\n const signature = crypto.createHmac('sha256', signingKey).update(stringToSign).digest('hex');\n\n headers['authorization'] =\n `AWS4-HMAC-SHA256 Credential=${credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${signedHeaders}, Signature=${signature}`;\n return headers;\n}\n","/**\n * logixia — AWS CloudWatch Logs transport\n *\n * Sends log entries to AWS CloudWatch Logs via the PutLogEvents API.\n * Supports EMF (Embedded Metric Format) for automatic metric extraction.\n *\n * Auth, in order: explicit config, environment variables, the shared\n * credentials file (AWS_PROFILE, AWS_SHARED_CREDENTIALS_FILE), ECS container\n * credentials, then EC2 instance metadata (IMDSv2). SSO, assume-role profiles\n * and credential_process are not supported. No SDK dependency — raw HTTPS with\n * AWS Signature Version 4.\n *\n * The log group and stream are created on first use if they do not exist.\n *\n * @example\n * ```ts\n * import { CloudWatchTransport } from 'logixia';\n *\n * const logger = createLogger({\n * transports: {\n * cloudwatch: new CloudWatchTransport({\n * region: 'us-east-1',\n * logGroupName: '/myapp/production',\n * logStreamName: `api-${process.env.HOSTNAME}`,\n * batchSize: 100,\n * flushIntervalMs: 5000,\n * }),\n * },\n * });\n * ```\n */\n\nimport type { IAsyncTransport, TransportLogEntry } from '../types/transport.types';\nimport { internalWarn } from '../utils/internal-log';\nimport { stringifyForLog } from '../utils/safe-stringify';\nimport { AwsCredentialProvider } from './aws-credentials';\nimport { signV4 } from './aws-sigv4';\nimport {\n BatchBuffer,\n DEFAULT_MAX_BUFFER_SIZE,\n DEFAULT_REQUEST_TIMEOUT_MS,\n HttpError,\n httpRequest,\n isPermanentHttpError,\n} from './batch-buffer';\nimport { mergeCoreFields } from './entry-fields';\nimport { protectSecrets, urlSecrets } from './secret-config';\n\nexport interface CloudWatchTransportConfig {\n /** AWS region, e.g. `'us-east-1'`. Falls back to `AWS_REGION` env var. */\n region?: string;\n /** CloudWatch Logs group name. Created automatically if it does not exist. */\n logGroupName: string;\n /** CloudWatch Logs stream name. Defaults to hostname + process PID. */\n logStreamName?: string;\n /** Override the Logs endpoint, e.g. for LocalStack. Default: `https://logs.<region>.amazonaws.com`. */\n endpoint?: string;\n /** AWS access key ID. Falls back to the credential chain described above. */\n accessKeyId?: string;\n /** AWS secret access key. Used together with `accessKeyId`. */\n secretAccessKey?: string;\n /** AWS session token for temporary credentials. Used together with `accessKeyId`. */\n sessionToken?: string;\n /**\n * Number of log events to batch before flushing.\n * CloudWatch allows max 10,000 events per PutLogEvents call; larger values are capped.\n * @default 100\n */\n batchSize?: number;\n /**\n * Max ms between flushes even if batchSize is not reached.\n * @default 5000\n */\n flushIntervalMs?: number;\n /**\n * Enable EMF (Embedded Metric Format) — wraps log entries as CloudWatch\n * metric namespaces so numeric fields become CloudWatch Metrics automatically.\n * @default false\n */\n emf?: boolean;\n /** CloudWatch Metrics namespace used by EMF. @default 'Logixia' */\n emfNamespace?: string;\n /**\n * Payload fields published as EMF metrics. When set, only these numeric\n * fields become metrics; when unset every numeric payload field does (up to\n * the EMF limit of 100 per entry).\n */\n emfMetrics?: string[];\n /** Abort a request that has not finished after this many ms. @default 10000 */\n requestTimeoutMs?: number;\n /** Max buffered events; the oldest are dropped past this. @default 10000 */\n maxBufferSize?: number;\n /** Minimum log level to forward. */\n level?: string;\n}\n\nconst MAX_EVENTS_PER_PUT = 10_000;\nconst EMF_MAX_METRICS = 100;\n\n/** Error types worth retrying even though CloudWatch reports them as HTTP 400. */\nconst RETRYABLE_TYPES = new Set([\n 'ThrottlingException',\n 'ThrottledException',\n 'LimitExceededException',\n 'ServiceUnavailableException',\n 'ExpiredTokenException',\n 'ResourceNotFoundException',\n]);\n\nfunction awsErrorType(err: unknown): string | undefined {\n if (!(err instanceof HttpError)) return undefined;\n try {\n const type = (JSON.parse(err.body) as { __type?: string }).__type;\n return type?.split('#').pop();\n } catch {\n return undefined;\n }\n}\n\ninterface CwLogEvent {\n timestamp: number;\n message: string;\n}\n\n/**\n * AWS CloudWatch Logs transport with EMF support and batched PutLogEvents calls.\n */\nexport class CloudWatchTransport implements IAsyncTransport {\n public readonly name = 'cloudwatch';\n public readonly batchSize: number;\n public readonly flushInterval: number;\n public readonly level: string | undefined;\n\n private readonly buffer: BatchBuffer<CwLogEvent>;\n private readonly requestTimeoutMs: number;\n private flushTimer: NodeJS.Timeout | null = null;\n private readonly credentials: AwsCredentialProvider;\n private readonly endpoint: URL;\n private streamReady = false;\n\n private readonly region: string;\n private readonly logGroupName: string;\n private readonly logStreamName: string;\n private readonly emf: boolean;\n private readonly emfNamespace: string;\n private readonly emfMetrics: ReadonlySet<string> | undefined;\n\n constructor(config: CloudWatchTransportConfig) {\n this.region =\n config.region ??\n process.env['AWS_REGION'] ??\n process.env['AWS_DEFAULT_REGION'] ??\n 'us-east-1';\n this.logGroupName = config.logGroupName;\n this.logStreamName =\n config.logStreamName ?? `${process.env['HOSTNAME'] ?? 'node'}-${process.pid}`;\n this.credentials = new AwsCredentialProvider(config);\n this.endpoint = new URL(config.endpoint ?? `https://logs.${this.region}.amazonaws.com`);\n this.batchSize = Math.min(config.batchSize ?? 100, MAX_EVENTS_PER_PUT);\n this.emfNamespace = config.emfNamespace ?? 'Logixia';\n this.flushInterval = config.flushIntervalMs ?? 5000;\n this.emf = config.emf ?? false;\n this.emfMetrics = config.emfMetrics ? new Set(config.emfMetrics) : undefined;\n this.level = config.level;\n this.requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n this.buffer = new BatchBuffer<CwLogEvent>({\n name: 'CloudWatchTransport',\n batchSize: this.batchSize,\n maxBufferSize: config.maxBufferSize ?? DEFAULT_MAX_BUFFER_SIZE,\n send: (events) => this.putLogEvents(events),\n secrets: () => [...this.credentials.secretValues(), ...urlSecrets(this.endpoint)],\n shouldRetry: (err) =>\n !isPermanentHttpError(err) || RETRYABLE_TYPES.has(awsErrorType(err) ?? ''),\n });\n\n this.flushTimer = setInterval(() => {\n this.flush().catch(() => {});\n }, this.flushInterval);\n if (this.flushTimer.unref) this.flushTimer.unref();\n protectSecrets(this, ['credentials', 'endpoint']);\n }\n\n write(entry: TransportLogEntry): void {\n const timestamp = entry.timestamp ? new Date(entry.timestamp).getTime() : Date.now();\n const message = this.emf ? this.toEmf(entry) : stringifyForLog(entry);\n this.buffer.push({ timestamp, message });\n this.buffer.flushIfFull();\n }\n\n flush(): Promise<void> {\n return this.buffer.flush();\n }\n\n /**\n * Flush remaining events and stop the interval timer on shutdown. Without this\n * the manager's close() skips the transport (close was undefined) and any\n * buffered events were lost on deploy. Waits for any in-flight send first.\n */\n async close(): Promise<void> {\n if (this.flushTimer) {\n clearInterval(this.flushTimer);\n this.flushTimer = null;\n }\n await this.buffer.close();\n }\n\n private toEmf(entry: TransportLogEntry): string {\n const { level, message, data: payload, timestamp } = entry;\n const fields = mergeCoreFields({ _aws: undefined, level, message }, payload);\n const metricNames: string[] = [];\n for (const [k, v] of Object.entries(fields)) {\n if (k === '_aws' || k === 'level' || k === 'message' || typeof v !== 'number') continue;\n if (this.emfMetrics && !this.emfMetrics.has(k)) continue;\n if (metricNames.length < EMF_MAX_METRICS) metricNames.push(k);\n }\n fields['_aws'] = {\n Timestamp: timestamp ? new Date(timestamp).getTime() : Date.now(),\n CloudWatchMetrics:\n metricNames.length > 0\n ? [\n {\n Namespace: this.emfNamespace,\n Dimensions: [['level']],\n Metrics: metricNames.map((n) => ({ Name: n, Unit: 'None' })),\n },\n ]\n : [],\n };\n return stringifyForLog(fields);\n }\n\n private async putLogEvents(events: CwLogEvent[]): Promise<void> {\n await this.ensureStream();\n const logEvents = [...events].sort((a, b) => a.timestamp - b.timestamp);\n try {\n await this.call('PutLogEvents', {\n logGroupName: this.logGroupName,\n logStreamName: this.logStreamName,\n logEvents,\n });\n } catch (err) {\n const type = awsErrorType(err);\n if (type === 'DataAlreadyAcceptedException') return;\n if (type === 'ResourceNotFoundException') this.streamReady = false;\n if (type === 'ExpiredTokenException') this.credentials.invalidate();\n throw err;\n }\n }\n\n private async ensureStream(): Promise<void> {\n if (this.streamReady) return;\n try {\n await this.call('CreateLogGroup', { logGroupName: this.logGroupName });\n } catch (err) {\n if (awsErrorType(err) === 'ExpiredTokenException') this.credentials.invalidate();\n if (!(err instanceof HttpError)) throw err;\n if (awsErrorType(err) !== 'ResourceAlreadyExistsException') {\n internalWarn(`CloudWatchTransport: CreateLogGroup failed, continuing (${err.message})`);\n }\n }\n try {\n await this.call('CreateLogStream', {\n logGroupName: this.logGroupName,\n logStreamName: this.logStreamName,\n });\n } catch (err) {\n if (awsErrorType(err) !== 'ResourceAlreadyExistsException') throw err;\n }\n this.streamReady = true;\n }\n\n private async call(action: string, payload: Record<string, unknown>): Promise<void> {\n const credentials = await this.credentials.get();\n const body = stringifyForLog(payload);\n const { host } = this.endpoint;\n const headers = signV4({\n method: 'POST',\n path: '/',\n headers: {\n host,\n 'content-type': 'application/x-amz-json-1.1',\n 'x-amz-target': `Logs_20140328.${action}`,\n },\n body,\n region: this.region,\n service: 'logs',\n credentials,\n });\n await httpRequest({\n url: this.endpoint,\n headers,\n body,\n timeoutMs: this.requestTimeoutMs,\n label: `CloudWatch ${action}`,\n secrets: () => [\n ...this.credentials.secretValues(),\n headers['authorization'],\n headers['x-amz-security-token'],\n ...urlSecrets(this.endpoint),\n ],\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;;AAS5B,SAAgB,SAAS,MAAsD;CAC7E,MAAM,MAA8C,CAAC;CACrD,IAAI;CACJ,KAAK,MAAM,OAAO,KAAK,MAAM,OAAO,GAAG;EACrC,MAAM,OAAO,IAAI,KAAK;EACtB,IAAI,CAAC,QAAQ,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAAG;EAC3D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S,yBAAyB,KAAK,YAAY,WAAW;GAClE,MAAM;EACR;CACF;CAEA,MAAc,eAA8B;EAC1C,IAAI,KAAK,aAAa;EACtB,IAAI;GACF,MAAM,KAAK,KAAK,kBAAkB,EAAE,cAAc,KAAK,aAAa,CAAC;EACvE,SAAS,KAAK;GACZ,IAAI,aAAa,GAAG,MAAM,yBAAyB,KAAK,YAAY,WAAW;GAC/E,IAAI,EAAE,eAAe,YAAY,MAAM;GACvC,IAAI,aAAa,GAAG,MAAM,kCACxB,aAAa,2DAA2D,IAAI,QAAQ,EAAE;EAE1F;EACA,IAAI;GACF,MAAM,KAAK,KAAK,mBAAmB;IACjC,cAAc,KAAK;IACnB,eAAe,KAAK;GACtB,CAAC;EACH,SAAS,KAAK;GACZ,IAAI,aAAa,GAAG,MAAM,kCAAkC,MAAM;EACpE;EACA,KAAK,cAAc;CACrB;CAEA,MAAc,KAAK,QAAgB,SAAiD;EAClF,MAAM,cAAc,MAAM,KAAK,YAAY,IAAI;EAC/C,MAAM,OAAO,gBAAgB,OAAO;EACpC,MAAM,EAAE,SAAS,KAAK;EACtB,MAAM,UAAU,OAAO;GACrB,QAAQ;GACR,MAAM;GACN,SAAS;IACP;IACA,gBAAgB;IAChB,gBAAgB,iBAAiB;GACnC;GACA;GACA,QAAQ,KAAK;GACb,SAAS;GACT;EACF,CAAC;EACD,MAAM,YAAY;GAChB,KAAK,KAAK;GACV;GACA;GACA,WAAW,KAAK;GAChB,OAAO,cAAc;GACrB,eAAe;IACb,GAAG,KAAK,YAAY,aAAa;IACjC,QAAQ;IACR,QAAQ;IACR,GAAG,WAAW,KAAK,QAAQ;GAC7B;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-
|
|
2
|
-
|
|
3
|
-
//#region src/transports/cloudwatch.transport.d.ts
|
|
4
|
-
|
|
1
|
+
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-BJVL1QQl.js";
|
|
5
2
|
interface CloudWatchTransportConfig {
|
|
6
3
|
/** AWS region, e.g. `'us-east-1'`. Falls back to `AWS_REGION` env var. */
|
|
7
4
|
region?: string;
|
|
@@ -83,6 +80,5 @@ declare class CloudWatchTransport implements IAsyncTransport {
|
|
|
83
80
|
private ensureStream;
|
|
84
81
|
private call;
|
|
85
82
|
}
|
|
86
|
-
//#endregion
|
|
87
83
|
export { CloudWatchTransportConfig as n, CloudWatchTransport as t };
|
|
88
|
-
//# sourceMappingURL=cloudwatch.transport-
|
|
84
|
+
//# sourceMappingURL=cloudwatch.transport-Bf7L4I59.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudwatch.transport-Bf7L4I59.d.ts","names":[],"sources":["../src/transports/cloudwatch.transport.ts"],"mappings":";UAgDiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;EAKA;;;;;;EAMA;;EAEA;;;;;;EAMA;;EAEA;;EAEA;;EAEA;;;;;cAkCW,+BAA+B;WAC1B;WACA;WACA;WACA;mBAEC;mBACA;UACT;mBACS;mBACA;UACT;mBAES;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;EAmCpB,MAAM,OAAO;EAOb,SAAS;;;;;;EASH,SAAS;UAQP;UAyBM;UAkBA;UAsBA"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-
|
|
2
|
-
|
|
3
|
-
//#region src/transports/cloudwatch.transport.d.ts
|
|
4
|
-
|
|
1
|
+
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-BJVL1QQl.mjs";
|
|
5
2
|
interface CloudWatchTransportConfig {
|
|
6
3
|
/** AWS region, e.g. `'us-east-1'`. Falls back to `AWS_REGION` env var. */
|
|
7
4
|
region?: string;
|
|
@@ -83,6 +80,5 @@ declare class CloudWatchTransport implements IAsyncTransport {
|
|
|
83
80
|
private ensureStream;
|
|
84
81
|
private call;
|
|
85
82
|
}
|
|
86
|
-
//#endregion
|
|
87
83
|
export { CloudWatchTransportConfig as n, CloudWatchTransport as t };
|
|
88
|
-
//# sourceMappingURL=cloudwatch.transport-
|
|
84
|
+
//# sourceMappingURL=cloudwatch.transport-Rj4yTpRn.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudwatch.transport-Rj4yTpRn.d.mts","names":[],"sources":["../src/transports/cloudwatch.transport.ts"],"mappings":";UAgDiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;EAKA;;;;;;EAMA;;EAEA;;;;;;EAMA;;EAEA;;EAEA;;EAEA;;;;;cAkCW,+BAA+B;WAC1B;WACA;WACA;WACA;mBAEC;mBACA;UACT;mBACS;mBACA;UACT;mBAES;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;EAmCpB,MAAM,OAAO;EAOb,SAAS;;;;;;EASH,SAAS;UAQP;UAyBM;UAkBA;UAsBA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/utils/coerce.utils.ts
|
|
2
2
|
/**
|
|
3
3
|
* Defensive value coercion helpers for Logixia.
|
|
4
4
|
*
|
|
@@ -32,7 +32,6 @@ function safeToString(value) {
|
|
|
32
32
|
} catch {}
|
|
33
33
|
return `[${((_constructor = value.constructor) === null || _constructor === void 0 ? void 0 : _constructor.name) ?? "object"}]`;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
35
|
export { safeToString as t };
|
|
38
|
-
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=coerce.utils-B_rEudCn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce.utils-
|
|
1
|
+
{"version":3,"file":"coerce.utils-B_rEudCn.mjs","names":[],"sources":["../src/utils/coerce.utils.ts"],"sourcesContent":["/**\n * Defensive value coercion helpers for Logixia.\n *\n * Logger inputs come from third-party code (NestJS framework internals,\n * user payloads, error objects) where the runtime type is not always what\n * the TypeScript signature promises. The formatter / transport hot paths\n * call `.replace()` on string fields and crash if the field is anything\n * else. Use these helpers anywhere a downstream consumer assumes a string.\n */\n\n/**\n * Coerce any value to a string without throwing.\n *\n * - `undefined` / `null` → `''` (so the field is rendered as empty rather\n * than the literal string \"undefined\")\n * - strings → returned as-is (zero allocation on the hot path)\n * - Errors → `error.message` (matches what users would expect to see)\n * - everything else → `JSON.stringify` if possible, falling back to\n * `String(value)` for circular refs / values without a stringifier.\n */\nexport function safeToString(value: unknown): string {\n if (typeof value === 'string') return value;\n if (value === undefined || value === null) return '';\n if (value instanceof Error) return value.message;\n if (typeof value === 'number' || typeof value === 'bigint' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'symbol') return value.toString();\n if (typeof value === 'function') {\n return `[Function: ${(value as { name?: string }).name || 'anonymous'}]`;\n }\n // value is now narrowed to object — JSON-stringify, falling back to a\n // constructor-name tag for circular refs / throwing toJSON.\n try {\n const json = JSON.stringify(value);\n // JSON.stringify returns undefined for values it can't represent (e.g. an\n // object whose toJSON() returns undefined). Returning that would defeat the\n // whole point of this helper — a downstream .replace() on `undefined` throws.\n if (json !== undefined) return json;\n } catch {\n /* fall through to the constructor-name tag below */\n }\n const ctor = (value as { constructor?: { name?: string } }).constructor?.name;\n return `[${ctor ?? 'object'}]`;\n}\n\n/**\n * String-replace on a value that may not be a string.\n * Coerces non-strings before delegating to `String.prototype.replace`.\n */\nexport function safeReplace(value: unknown, pattern: string | RegExp, replacement: string): string {\n return safeToString(value).replace(pattern, replacement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,aAAa,OAAwB;;CACnD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,UAAU,OAAO,MAAM,SAAS;CACrD,IAAI,OAAO,UAAU,YACnB,OAAO,cAAe,MAA4B,QAAQ,YAAY;CAIxE,IAAI;EACF,MAAM,OAAO,KAAK,UAAU,KAAK;EAIjC,IAAI,SAAS,KAAA,GAAW,OAAO;CACjC,QAAQ,CAER;CAEA,OAAO,MAAA,eADO,MAA8C,iBAAA,QAAA,iBAAA,KAAA,IAAA,KAAA,IAAA,aAAa,SACtD,SAAS;AAC9B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/utils/coerce.utils.ts
|
|
1
|
+
// src/utils/coerce.utils.ts
|
|
3
2
|
/**
|
|
4
3
|
* Defensive value coercion helpers for Logixia.
|
|
5
4
|
*
|
|
@@ -33,12 +32,11 @@ function safeToString(value) {
|
|
|
33
32
|
} catch {}
|
|
34
33
|
return `[${((_constructor = value.constructor) === null || _constructor === void 0 ? void 0 : _constructor.name) ?? "object"}]`;
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return safeToString;
|
|
42
|
-
}
|
|
35
|
+
Object.defineProperty(exports, "safeToString", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function() {
|
|
38
|
+
return safeToString;
|
|
39
|
+
}
|
|
43
40
|
});
|
|
44
|
-
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=coerce.utils-C1C5sIX0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce.utils-
|
|
1
|
+
{"version":3,"file":"coerce.utils-C1C5sIX0.js","names":[],"sources":["../src/utils/coerce.utils.ts"],"sourcesContent":["/**\n * Defensive value coercion helpers for Logixia.\n *\n * Logger inputs come from third-party code (NestJS framework internals,\n * user payloads, error objects) where the runtime type is not always what\n * the TypeScript signature promises. The formatter / transport hot paths\n * call `.replace()` on string fields and crash if the field is anything\n * else. Use these helpers anywhere a downstream consumer assumes a string.\n */\n\n/**\n * Coerce any value to a string without throwing.\n *\n * - `undefined` / `null` → `''` (so the field is rendered as empty rather\n * than the literal string \"undefined\")\n * - strings → returned as-is (zero allocation on the hot path)\n * - Errors → `error.message` (matches what users would expect to see)\n * - everything else → `JSON.stringify` if possible, falling back to\n * `String(value)` for circular refs / values without a stringifier.\n */\nexport function safeToString(value: unknown): string {\n if (typeof value === 'string') return value;\n if (value === undefined || value === null) return '';\n if (value instanceof Error) return value.message;\n if (typeof value === 'number' || typeof value === 'bigint' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'symbol') return value.toString();\n if (typeof value === 'function') {\n return `[Function: ${(value as { name?: string }).name || 'anonymous'}]`;\n }\n // value is now narrowed to object — JSON-stringify, falling back to a\n // constructor-name tag for circular refs / throwing toJSON.\n try {\n const json = JSON.stringify(value);\n // JSON.stringify returns undefined for values it can't represent (e.g. an\n // object whose toJSON() returns undefined). Returning that would defeat the\n // whole point of this helper — a downstream .replace() on `undefined` throws.\n if (json !== undefined) return json;\n } catch {\n /* fall through to the constructor-name tag below */\n }\n const ctor = (value as { constructor?: { name?: string } }).constructor?.name;\n return `[${ctor ?? 'object'}]`;\n}\n\n/**\n * String-replace on a value that may not be a string.\n * Coerces non-strings before delegating to `String.prototype.replace`.\n */\nexport function safeReplace(value: unknown, pattern: string | RegExp, replacement: string): string {\n return safeToString(value).replace(pattern, replacement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,aAAa,OAAwB;;CACnD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,UAAU,OAAO,MAAM,SAAS;CACrD,IAAI,OAAO,UAAU,YACnB,OAAO,cAAe,MAA4B,QAAQ,YAAY;CAIxE,IAAI;EACF,MAAM,OAAO,KAAK,UAAU,KAAK;EAIjC,IAAI,SAAS,KAAA,GAAW,OAAO;CACjC,QAAQ,CAER;CAEA,OAAO,MAAA,eADO,MAA8C,iBAAA,QAAA,iBAAA,KAAA,IAAA,KAAA,IAAA,aAAa,SACtD,SAAS;AAC9B"}
|
package/dist/correlation.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/correlation.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* logixia — Microservices Correlation ID Propagation
|
|
4
3
|
*
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
* ```
|
|
53
52
|
*/
|
|
54
53
|
/** Fields injected into the log context by the correlation middleware. */
|
|
55
|
-
interface CorrelationContext {
|
|
54
|
+
export interface CorrelationContext {
|
|
56
55
|
correlationId: string;
|
|
57
56
|
traceId?: string;
|
|
58
57
|
/** Service that originated the request (from `X-Origin-Service` header). */
|
|
@@ -60,7 +59,7 @@ interface CorrelationContext {
|
|
|
60
59
|
/** Index signature so CorrelationContext is assignable to LogContext. */
|
|
61
60
|
[key: string]: unknown;
|
|
62
61
|
}
|
|
63
|
-
interface CorrelationMiddlewareOptions {
|
|
62
|
+
export interface CorrelationMiddlewareOptions {
|
|
64
63
|
/**
|
|
65
64
|
* HTTP header to read/write the correlation ID from/to.
|
|
66
65
|
* @default 'x-correlation-id'
|
|
@@ -100,12 +99,12 @@ interface CorrelationMiddlewareOptions {
|
|
|
100
99
|
* function's JSDoc and README promise. `logixia/correlation` is Node-only
|
|
101
100
|
* (it builds on `AsyncLocalStorage`), so importing `node:crypto` is safe here.
|
|
102
101
|
*/
|
|
103
|
-
declare function generateCorrelationId(): string;
|
|
102
|
+
export declare function generateCorrelationId(): string;
|
|
104
103
|
/**
|
|
105
104
|
* Return the correlation ID from the current `LogixiaContext`, or `undefined`
|
|
106
105
|
* when called outside any context scope.
|
|
107
106
|
*/
|
|
108
|
-
declare function getCurrentCorrelationId(): string | undefined;
|
|
107
|
+
export declare function getCurrentCorrelationId(): string | undefined;
|
|
109
108
|
/**
|
|
110
109
|
* Run `callback` inside a correlation context scope.
|
|
111
110
|
*
|
|
@@ -119,7 +118,7 @@ declare function getCurrentCorrelationId(): string | undefined;
|
|
|
119
118
|
* });
|
|
120
119
|
* ```
|
|
121
120
|
*/
|
|
122
|
-
declare function withCorrelationId<T>(correlationId: string | undefined, callback: () => T): T;
|
|
121
|
+
export declare function withCorrelationId<T>(correlationId: string | undefined, callback: () => T): T;
|
|
123
122
|
/**
|
|
124
123
|
* Express-compatible middleware that:
|
|
125
124
|
* 1. Reads `X-Correlation-ID` from the incoming request (or generates a new one)
|
|
@@ -133,7 +132,7 @@ declare function withCorrelationId<T>(correlationId: string | undefined, callbac
|
|
|
133
132
|
* app.use(correlationMiddleware());
|
|
134
133
|
* ```
|
|
135
134
|
*/
|
|
136
|
-
declare function correlationMiddleware(options?: CorrelationMiddlewareOptions): (req: Record<string, unknown>, res: Record<string, unknown>, next: () => void) => void;
|
|
135
|
+
export declare function correlationMiddleware(options?: CorrelationMiddlewareOptions): (req: Record<string, unknown>, res: Record<string, unknown>, next: () => void) => void;
|
|
137
136
|
/**
|
|
138
137
|
* Fastify `onRequest` lifecycle hook — same functionality as `correlationMiddleware`
|
|
139
138
|
* but adapted to Fastify's hook API.
|
|
@@ -144,7 +143,7 @@ declare function correlationMiddleware(options?: CorrelationMiddlewareOptions):
|
|
|
144
143
|
* fastify.addHook('onRequest', correlationFastifyHook());
|
|
145
144
|
* ```
|
|
146
145
|
*/
|
|
147
|
-
declare function correlationFastifyHook(options?: CorrelationMiddlewareOptions): (request: Record<string, unknown>, reply: Record<string, unknown>, done: () => void) => void;
|
|
146
|
+
export declare function correlationFastifyHook(options?: CorrelationMiddlewareOptions): (request: Record<string, unknown>, reply: Record<string, unknown>, done: () => void) => void;
|
|
148
147
|
/**
|
|
149
148
|
* A drop-in replacement for `fetch` that automatically injects the current
|
|
150
149
|
* `correlationId` from `LogixiaContext` as an `X-Correlation-ID` request header.
|
|
@@ -162,7 +161,7 @@ declare function correlationFastifyHook(options?: CorrelationMiddlewareOptions):
|
|
|
162
161
|
* });
|
|
163
162
|
* ```
|
|
164
163
|
*/
|
|
165
|
-
declare function correlationFetch(input: string | URL | Request, init?: RequestInit, options?: {
|
|
164
|
+
export declare function correlationFetch(input: string | URL | Request, init?: RequestInit, options?: {
|
|
166
165
|
header?: string;
|
|
167
166
|
}): Promise<Response>;
|
|
168
167
|
/**
|
|
@@ -177,10 +176,10 @@ declare function correlationFetch(input: string | URL | Request, init?: RequestI
|
|
|
177
176
|
* axios.interceptors.request.use(createCorrelationAxiosInterceptor());
|
|
178
177
|
* ```
|
|
179
178
|
*/
|
|
180
|
-
declare function createCorrelationAxiosInterceptor(options?: {
|
|
179
|
+
export declare function createCorrelationAxiosInterceptor(options?: {
|
|
181
180
|
header?: string;
|
|
182
181
|
}): (config: Record<string, unknown>) => Record<string, unknown>;
|
|
183
|
-
interface ChildFromRequestOptions {
|
|
182
|
+
export interface ChildFromRequestOptions {
|
|
184
183
|
/** Header to read the correlation ID from. @default 'x-correlation-id' */
|
|
185
184
|
correlationHeader?: string;
|
|
186
185
|
/**
|
|
@@ -222,7 +221,7 @@ interface ChildFromRequestOptions {
|
|
|
222
221
|
* });
|
|
223
222
|
* ```
|
|
224
223
|
*/
|
|
225
|
-
declare function childFromRequest<TLogger extends {
|
|
224
|
+
export declare function childFromRequest<TLogger extends {
|
|
226
225
|
child(...args: never[]): TLogger;
|
|
227
226
|
}>(req: Record<string, unknown>, logger: TLogger, options?: ChildFromRequestOptions): TLogger;
|
|
228
227
|
/**
|
|
@@ -243,7 +242,7 @@ declare function childFromRequest<TLogger extends {
|
|
|
243
242
|
* });
|
|
244
243
|
* ```
|
|
245
244
|
*/
|
|
246
|
-
declare function extractMessageCorrelationId(message: Record<string, unknown>): string | undefined;
|
|
245
|
+
export declare function extractMessageCorrelationId(message: Record<string, unknown>): string | undefined;
|
|
247
246
|
/**
|
|
248
247
|
* Build Kafka message headers containing the current correlation context.
|
|
249
248
|
*
|
|
@@ -257,7 +256,5 @@ declare function extractMessageCorrelationId(message: Record<string, unknown>):
|
|
|
257
256
|
* });
|
|
258
257
|
* ```
|
|
259
258
|
*/
|
|
260
|
-
declare function buildKafkaCorrelationHeaders(): Record<string, string>;
|
|
261
|
-
//#endregion
|
|
262
|
-
export { ChildFromRequestOptions, CorrelationContext, CorrelationMiddlewareOptions, buildKafkaCorrelationHeaders, childFromRequest, correlationFastifyHook, correlationFetch, correlationMiddleware, createCorrelationAxiosInterceptor, extractMessageCorrelationId, generateCorrelationId, getCurrentCorrelationId, withCorrelationId };
|
|
259
|
+
export declare function buildKafkaCorrelationHeaders(): Record<string, string>;
|
|
263
260
|
//# sourceMappingURL=correlation.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correlation.d.mts","names":[],"sources":["../src/correlation.ts"],"
|
|
1
|
+
{"version":3,"file":"correlation.d.mts","names":[],"sources":["../src/correlation.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DiB;EACf;EACA;;EAEA;;GAEC;;iBAGc;;;;;EAKf;;;;;EAKA;;;;;EAKA;;;;;;;EAOA;;;;;;EAMA;;;;;;;;;;;;wBAec;;;;;wBAwBA;;;;;;;;;;;;;;wBAkBA,kBAAkB,GAAG,mCAAmC,gBAAgB,IAAI;;;;;;;;;;;;;;wBAoB5E,sBAAsB,UAAS,gCAU3C,KAAK,yBACL,KAAK,yBACL;;;;;;;;;;;wBAqCY,uBAAuB,UAAS,gCAU5C,SAAS,yBACT,OAAO,yBACP;;;;;;;;;;;;;;;;;;wBA4CkB,iBACpB,gBAAgB,MAAM,SACtB,OAAM,aACN;EAAW;IACV,QAAQ;;;;;;;;;;;;;wBAwCK,kCACd;EAAW;KACT,QAAQ,4BAA4B;iBAuBvB;;EAEf;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2Bc,iBAAiB;EAAkB,SAAS,gBAAgB;GAC1E,KAAK,yBACL,QAAQ,SACR,UAAS,0BACR;;;;;;;;;;;;;;;;;;;wBA+Ea,4BAA4B,SAAS;;;;;;;;;;;;;;wBAyCrC,gCAAgC"}
|
package/dist/correlation.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/correlation.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* logixia — Microservices Correlation ID Propagation
|
|
4
3
|
*
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
* ```
|
|
53
52
|
*/
|
|
54
53
|
/** Fields injected into the log context by the correlation middleware. */
|
|
55
|
-
interface CorrelationContext {
|
|
54
|
+
export interface CorrelationContext {
|
|
56
55
|
correlationId: string;
|
|
57
56
|
traceId?: string;
|
|
58
57
|
/** Service that originated the request (from `X-Origin-Service` header). */
|
|
@@ -60,7 +59,7 @@ interface CorrelationContext {
|
|
|
60
59
|
/** Index signature so CorrelationContext is assignable to LogContext. */
|
|
61
60
|
[key: string]: unknown;
|
|
62
61
|
}
|
|
63
|
-
interface CorrelationMiddlewareOptions {
|
|
62
|
+
export interface CorrelationMiddlewareOptions {
|
|
64
63
|
/**
|
|
65
64
|
* HTTP header to read/write the correlation ID from/to.
|
|
66
65
|
* @default 'x-correlation-id'
|
|
@@ -100,12 +99,12 @@ interface CorrelationMiddlewareOptions {
|
|
|
100
99
|
* function's JSDoc and README promise. `logixia/correlation` is Node-only
|
|
101
100
|
* (it builds on `AsyncLocalStorage`), so importing `node:crypto` is safe here.
|
|
102
101
|
*/
|
|
103
|
-
declare function generateCorrelationId(): string;
|
|
102
|
+
export declare function generateCorrelationId(): string;
|
|
104
103
|
/**
|
|
105
104
|
* Return the correlation ID from the current `LogixiaContext`, or `undefined`
|
|
106
105
|
* when called outside any context scope.
|
|
107
106
|
*/
|
|
108
|
-
declare function getCurrentCorrelationId(): string | undefined;
|
|
107
|
+
export declare function getCurrentCorrelationId(): string | undefined;
|
|
109
108
|
/**
|
|
110
109
|
* Run `callback` inside a correlation context scope.
|
|
111
110
|
*
|
|
@@ -119,7 +118,7 @@ declare function getCurrentCorrelationId(): string | undefined;
|
|
|
119
118
|
* });
|
|
120
119
|
* ```
|
|
121
120
|
*/
|
|
122
|
-
declare function withCorrelationId<T>(correlationId: string | undefined, callback: () => T): T;
|
|
121
|
+
export declare function withCorrelationId<T>(correlationId: string | undefined, callback: () => T): T;
|
|
123
122
|
/**
|
|
124
123
|
* Express-compatible middleware that:
|
|
125
124
|
* 1. Reads `X-Correlation-ID` from the incoming request (or generates a new one)
|
|
@@ -133,7 +132,7 @@ declare function withCorrelationId<T>(correlationId: string | undefined, callbac
|
|
|
133
132
|
* app.use(correlationMiddleware());
|
|
134
133
|
* ```
|
|
135
134
|
*/
|
|
136
|
-
declare function correlationMiddleware(options?: CorrelationMiddlewareOptions): (req: Record<string, unknown>, res: Record<string, unknown>, next: () => void) => void;
|
|
135
|
+
export declare function correlationMiddleware(options?: CorrelationMiddlewareOptions): (req: Record<string, unknown>, res: Record<string, unknown>, next: () => void) => void;
|
|
137
136
|
/**
|
|
138
137
|
* Fastify `onRequest` lifecycle hook — same functionality as `correlationMiddleware`
|
|
139
138
|
* but adapted to Fastify's hook API.
|
|
@@ -144,7 +143,7 @@ declare function correlationMiddleware(options?: CorrelationMiddlewareOptions):
|
|
|
144
143
|
* fastify.addHook('onRequest', correlationFastifyHook());
|
|
145
144
|
* ```
|
|
146
145
|
*/
|
|
147
|
-
declare function correlationFastifyHook(options?: CorrelationMiddlewareOptions): (request: Record<string, unknown>, reply: Record<string, unknown>, done: () => void) => void;
|
|
146
|
+
export declare function correlationFastifyHook(options?: CorrelationMiddlewareOptions): (request: Record<string, unknown>, reply: Record<string, unknown>, done: () => void) => void;
|
|
148
147
|
/**
|
|
149
148
|
* A drop-in replacement for `fetch` that automatically injects the current
|
|
150
149
|
* `correlationId` from `LogixiaContext` as an `X-Correlation-ID` request header.
|
|
@@ -162,7 +161,7 @@ declare function correlationFastifyHook(options?: CorrelationMiddlewareOptions):
|
|
|
162
161
|
* });
|
|
163
162
|
* ```
|
|
164
163
|
*/
|
|
165
|
-
declare function correlationFetch(input: string | URL | Request, init?: RequestInit, options?: {
|
|
164
|
+
export declare function correlationFetch(input: string | URL | Request, init?: RequestInit, options?: {
|
|
166
165
|
header?: string;
|
|
167
166
|
}): Promise<Response>;
|
|
168
167
|
/**
|
|
@@ -177,10 +176,10 @@ declare function correlationFetch(input: string | URL | Request, init?: RequestI
|
|
|
177
176
|
* axios.interceptors.request.use(createCorrelationAxiosInterceptor());
|
|
178
177
|
* ```
|
|
179
178
|
*/
|
|
180
|
-
declare function createCorrelationAxiosInterceptor(options?: {
|
|
179
|
+
export declare function createCorrelationAxiosInterceptor(options?: {
|
|
181
180
|
header?: string;
|
|
182
181
|
}): (config: Record<string, unknown>) => Record<string, unknown>;
|
|
183
|
-
interface ChildFromRequestOptions {
|
|
182
|
+
export interface ChildFromRequestOptions {
|
|
184
183
|
/** Header to read the correlation ID from. @default 'x-correlation-id' */
|
|
185
184
|
correlationHeader?: string;
|
|
186
185
|
/**
|
|
@@ -222,7 +221,7 @@ interface ChildFromRequestOptions {
|
|
|
222
221
|
* });
|
|
223
222
|
* ```
|
|
224
223
|
*/
|
|
225
|
-
declare function childFromRequest<TLogger extends {
|
|
224
|
+
export declare function childFromRequest<TLogger extends {
|
|
226
225
|
child(...args: never[]): TLogger;
|
|
227
226
|
}>(req: Record<string, unknown>, logger: TLogger, options?: ChildFromRequestOptions): TLogger;
|
|
228
227
|
/**
|
|
@@ -243,7 +242,7 @@ declare function childFromRequest<TLogger extends {
|
|
|
243
242
|
* });
|
|
244
243
|
* ```
|
|
245
244
|
*/
|
|
246
|
-
declare function extractMessageCorrelationId(message: Record<string, unknown>): string | undefined;
|
|
245
|
+
export declare function extractMessageCorrelationId(message: Record<string, unknown>): string | undefined;
|
|
247
246
|
/**
|
|
248
247
|
* Build Kafka message headers containing the current correlation context.
|
|
249
248
|
*
|
|
@@ -257,7 +256,5 @@ declare function extractMessageCorrelationId(message: Record<string, unknown>):
|
|
|
257
256
|
* });
|
|
258
257
|
* ```
|
|
259
258
|
*/
|
|
260
|
-
declare function buildKafkaCorrelationHeaders(): Record<string, string>;
|
|
261
|
-
//#endregion
|
|
262
|
-
export { ChildFromRequestOptions, CorrelationContext, CorrelationMiddlewareOptions, buildKafkaCorrelationHeaders, childFromRequest, correlationFastifyHook, correlationFetch, correlationMiddleware, createCorrelationAxiosInterceptor, extractMessageCorrelationId, generateCorrelationId, getCurrentCorrelationId, withCorrelationId };
|
|
259
|
+
export declare function buildKafkaCorrelationHeaders(): Record<string, string>;
|
|
263
260
|
//# sourceMappingURL=correlation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correlation.d.ts","names":[],"sources":["../src/correlation.ts"],"
|
|
1
|
+
{"version":3,"file":"correlation.d.ts","names":[],"sources":["../src/correlation.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DiB;EACf;EACA;;EAEA;;GAEC;;iBAGc;;;;;EAKf;;;;;EAKA;;;;;EAKA;;;;;;;EAOA;;;;;;EAMA;;;;;;;;;;;;wBAec;;;;;wBAwBA;;;;;;;;;;;;;;wBAkBA,kBAAkB,GAAG,mCAAmC,gBAAgB,IAAI;;;;;;;;;;;;;;wBAoB5E,sBAAsB,UAAS,gCAU3C,KAAK,yBACL,KAAK,yBACL;;;;;;;;;;;wBAqCY,uBAAuB,UAAS,gCAU5C,SAAS,yBACT,OAAO,yBACP;;;;;;;;;;;;;;;;;;wBA4CkB,iBACpB,gBAAgB,MAAM,SACtB,OAAM,aACN;EAAW;IACV,QAAQ;;;;;;;;;;;;;wBAwCK,kCACd;EAAW;KACT,QAAQ,4BAA4B;iBAuBvB;;EAEf;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2Bc,iBAAiB;EAAkB,SAAS,gBAAgB;GAC1E,KAAK,yBACL,QAAQ,SACR,UAAS,0BACR;;;;;;;;;;;;;;;;;;;wBA+Ea,4BAA4B,SAAS;;;;;;;;;;;;;;wBAyCrC,gCAAgC"}
|