@c9up/spectrum 0.1.11 → 0.1.13
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 +30 -7
- package/dist/Logger.d.ts +14 -4
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +83 -49
- package/dist/Logger.js.map +1 -1
- package/dist/LoggerManager.d.ts.map +1 -1
- package/dist/LoggerManager.js +7 -1
- package/dist/LoggerManager.js.map +1 -1
- package/dist/RustLogBridge.d.ts.map +1 -1
- package/dist/RustLogBridge.js +76 -16
- package/dist/RustLogBridge.js.map +1 -1
- package/dist/SpectrumProvider.d.ts +1 -0
- package/dist/SpectrumProvider.d.ts.map +1 -1
- package/dist/SpectrumProvider.js +30 -21
- package/dist/SpectrumProvider.js.map +1 -1
- package/dist/augmentations.d.ts +29 -0
- package/dist/augmentations.d.ts.map +1 -0
- package/dist/augmentations.js +18 -0
- package/dist/augmentations.js.map +1 -0
- package/dist/channels/FileChannel.d.ts +8 -0
- package/dist/channels/FileChannel.d.ts.map +1 -1
- package/dist/channels/FileChannel.js +79 -7
- package/dist/channels/FileChannel.js.map +1 -1
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +19 -7
- package/dist/configure.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/redact.d.ts +29 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +90 -0
- package/dist/redact.js.map +1 -0
- package/dist/targets.d.ts +6 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +59 -5
- package/dist/targets.js.map +1 -1
- package/dist/types.d.ts +28 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +33 -6
- package/dist/types.js.map +1 -1
- package/package.json +4 -2
- package/src/Logger.ts +113 -51
- package/src/LoggerManager.ts +9 -1
- package/src/RustLogBridge.ts +95 -20
- package/src/SpectrumProvider.ts +34 -25
- package/src/augmentations.ts +32 -0
- package/src/channels/FileChannel.ts +80 -7
- package/src/configure.ts +19 -7
- package/src/index.ts +4 -0
- package/src/redact.ts +100 -0
- package/src/targets.ts +78 -12
- package/src/types.ts +50 -7
package/dist/SpectrumProvider.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import "./augmentations.js";
|
|
1
2
|
import { ConsoleChannel } from "./channels/ConsoleChannel.js";
|
|
2
3
|
import { Logger } from "./Logger.js";
|
|
3
4
|
import { LoggerManager } from "./LoggerManager.js";
|
|
4
5
|
import { setLogger } from "./services/main.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
...Object.keys(LOG_LEVEL_ORDER),
|
|
8
|
-
"silent",
|
|
9
|
-
]);
|
|
10
|
-
function isValidLevel(raw) {
|
|
11
|
-
return typeof raw === "string" && VALID_LEVELS.has(raw);
|
|
12
|
-
}
|
|
13
|
-
function resolveLogLevel(raw) {
|
|
14
|
-
return isValidLevel(raw) ? raw : "info";
|
|
15
|
-
}
|
|
6
|
+
import { channelsFromTargets } from "./targets.js";
|
|
7
|
+
import { isLogLevelWithSilent, logLevel } from "./types.js";
|
|
16
8
|
/** A channel that owns a resource (e.g. a FileChannel WriteStream) to release on shutdown. */
|
|
17
9
|
function hasClose(ch) {
|
|
18
10
|
return "close" in ch && typeof ch.close === "function";
|
|
@@ -39,9 +31,14 @@ export default class SpectrumProvider {
|
|
|
39
31
|
this.#channels = Object.values(managerConfig.loggers).flatMap((logger) => logger.channels ?? []);
|
|
40
32
|
const manager = new LoggerManager(managerConfig);
|
|
41
33
|
this.app.container.singleton(Logger, () => manager);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
// Namespaced by the package that owns it, the way upstream namespaces
|
|
35
|
+
// `lucid.db`, `auth.manager` and `drive.manager` by theirs. The bare
|
|
36
|
+
// token stays bound beside it: it is what every existing
|
|
37
|
+
// `container.make(...)` asks for, and a token is not worth breaking an
|
|
38
|
+
// application over.
|
|
39
|
+
const logger = () => this.app.container.resolve(Logger);
|
|
40
|
+
this.app.container.singleton("spectrum.logger", logger);
|
|
41
|
+
this.app.container.singleton("logger", logger);
|
|
45
42
|
}
|
|
46
43
|
async boot() {
|
|
47
44
|
setLogger(await this.app.container.resolve(Logger));
|
|
@@ -76,15 +73,27 @@ export default class SpectrumProvider {
|
|
|
76
73
|
return { default: "app", loggers: { app: this.#normalizeLogger(flat) } };
|
|
77
74
|
}
|
|
78
75
|
#normalizeLogger(cfg) {
|
|
79
|
-
|
|
80
|
-
// only when none are supplied.
|
|
81
|
-
const channels = cfg.channels && cfg.channels.length > 0
|
|
82
|
-
? cfg.channels
|
|
83
|
-
: [new ConsoleChannel("pretty")];
|
|
84
|
-
const level = isValidLevel(cfg.level)
|
|
76
|
+
const level = isLogLevelWithSilent(cfg.level)
|
|
85
77
|
? cfg.level
|
|
86
|
-
:
|
|
78
|
+
: logLevel(process.env.LOG_LEVEL);
|
|
79
|
+
// An AdonisJS `config/logger.ts` declares its output as
|
|
80
|
+
// `transport.targets`, not as channels. It has to be converted HERE:
|
|
81
|
+
// filling `channels` in with the console fallback below is what stopped
|
|
82
|
+
// the Logger's own conversion from ever running (it only fires when
|
|
83
|
+
// `channels` is absent), so a config that declared a file target reached
|
|
84
|
+
// production writing to a console and nothing to the file it named.
|
|
85
|
+
const channels = this.#channelsFor(cfg, level);
|
|
87
86
|
return { ...cfg, level, channels };
|
|
88
87
|
}
|
|
88
|
+
/** Explicit channels, else the declared targets, else a pretty console. */
|
|
89
|
+
#channelsFor(cfg, level) {
|
|
90
|
+
if (cfg.channels && cfg.channels.length > 0)
|
|
91
|
+
return cfg.channels;
|
|
92
|
+
const declared = cfg.transport?.targets;
|
|
93
|
+
if (declared && declared.length > 0) {
|
|
94
|
+
return channelsFromTargets(declared, level);
|
|
95
|
+
}
|
|
96
|
+
return [new ConsoleChannel("pretty")];
|
|
97
|
+
}
|
|
89
98
|
}
|
|
90
99
|
//# sourceMappingURL=SpectrumProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpectrumProvider.js","sourceRoot":"","sources":["../src/SpectrumProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"SpectrumProvider.js","sourceRoot":"","sources":["../src/SpectrumProvider.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOnD,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5D,8FAA8F;AAC9F,SAAS,QAAQ,CAAC,EAAc;IAC/B,OAAO,OAAO,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC,KAAK,KAAK,UAAU,CAAC;AACxD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACtC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,SAAS,IAAI,KAAK,CAClB,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAgBD,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAGd;IAFtB,SAAS,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,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC;IAED,2EAA2E;IAC3E,YAAY,CACX,GAAuB,EACvB,KAAyB;QAEzB,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC,QAAQ,CAAC;QACjE,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC;QACxC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,OAAO,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teach ream's `ContainerBindings` what `container.make('logger')` returns.
|
|
3
|
+
*
|
|
4
|
+
* ream declares that interface open on purpose: it registers its own entries
|
|
5
|
+
* and expects each package to contribute the one it owns — the comment on the
|
|
6
|
+
* interface names `logger` (spectrum) as exactly this. Nothing filled it in,
|
|
7
|
+
* so resolving by the string token answered `unknown` and every call site had
|
|
8
|
+
* to assert a type it could not prove.
|
|
9
|
+
*
|
|
10
|
+
* Loaded from the package barrel and from the provider, so registering
|
|
11
|
+
* spectrum is enough — an application writes no `declare module` of its own.
|
|
12
|
+
*
|
|
13
|
+
* Type-only, and ream stays an OPTIONAL peer: nothing here reaches a runtime
|
|
14
|
+
* import, and a `declare module` for a specifier that does not resolve is
|
|
15
|
+
* simply inert.
|
|
16
|
+
*/
|
|
17
|
+
import type { Logger } from "./Logger.js";
|
|
18
|
+
declare module "@c9up/ream/types" {
|
|
19
|
+
interface ContainerBindings {
|
|
20
|
+
/** The logger, bound by `SpectrumProvider`. */
|
|
21
|
+
"spectrum.logger": Logger;
|
|
22
|
+
/**
|
|
23
|
+
* The same binding under the name it had before the token carried its
|
|
24
|
+
* package. Kept bound so an existing `container.make(...)` resolves.
|
|
25
|
+
*/
|
|
26
|
+
logger: Logger;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=augmentations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augmentations.d.ts","sourceRoot":"","sources":["../src/augmentations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,QAAQ,kBAAkB,CAAC;IACjC,UAAU,iBAAiB;QAC1B,+CAA+C;QAC/C,iBAAiB,EAAE,MAAM,CAAC;QAC1B;;;WAGG;QACH,MAAM,EAAE,MAAM,CAAC;KACf;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teach ream's `ContainerBindings` what `container.make('logger')` returns.
|
|
3
|
+
*
|
|
4
|
+
* ream declares that interface open on purpose: it registers its own entries
|
|
5
|
+
* and expects each package to contribute the one it owns — the comment on the
|
|
6
|
+
* interface names `logger` (spectrum) as exactly this. Nothing filled it in,
|
|
7
|
+
* so resolving by the string token answered `unknown` and every call site had
|
|
8
|
+
* to assert a type it could not prove.
|
|
9
|
+
*
|
|
10
|
+
* Loaded from the package barrel and from the provider, so registering
|
|
11
|
+
* spectrum is enough — an application writes no `declare module` of its own.
|
|
12
|
+
*
|
|
13
|
+
* Type-only, and ream stays an OPTIONAL peer: nothing here reaches a runtime
|
|
14
|
+
* import, and a `declare module` for a specifier that does not resolve is
|
|
15
|
+
* simply inert.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=augmentations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augmentations.js","sourceRoot":"","sources":["../src/augmentations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -18,6 +18,14 @@ export declare class FileChannel implements LogChannel {
|
|
|
18
18
|
name: string;
|
|
19
19
|
constructor(config: FileChannelConfig);
|
|
20
20
|
write(entry: LogEntry): void;
|
|
21
|
+
/**
|
|
22
|
+
* Stop writing, for good.
|
|
23
|
+
*
|
|
24
|
+
* Anything buffered by a rotation goes out first — those lines were accepted
|
|
25
|
+
* and dropping them at close loses log the caller believed was written — and
|
|
26
|
+
* the flag is set before the flush so nothing the flush triggers can reopen
|
|
27
|
+
* the file.
|
|
28
|
+
*/
|
|
21
29
|
close(): void;
|
|
22
30
|
}
|
|
23
31
|
//# sourceMappingURL=FileChannel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileChannel.d.ts","sourceRoot":"","sources":["../../src/channels/FileChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAY,YAAW,UAAU;;IAC7C,IAAI,SAAU;
|
|
1
|
+
{"version":3,"file":"FileChannel.d.ts","sourceRoot":"","sources":["../../src/channels/FileChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAY,YAAW,UAAU;;IAC7C,IAAI,SAAU;gBAkBF,MAAM,EAAE,iBAAiB;IAMrC,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAmK5B;;;;;;;OAOG;IACH,KAAK,IAAI,IAAI;CAoCb"}
|
|
@@ -19,6 +19,14 @@ export class FileChannel {
|
|
|
19
19
|
#currentSize = 0;
|
|
20
20
|
#dirReady = false;
|
|
21
21
|
#rotating = false;
|
|
22
|
+
/**
|
|
23
|
+
* Terminal once `close()` has run.
|
|
24
|
+
*
|
|
25
|
+
* Nulling the stream was not enough: `write()` reopens a null stream, and so
|
|
26
|
+
* does a rotation, so a line written after close silently reopened the file
|
|
27
|
+
* and appended to it. A closed channel stays closed.
|
|
28
|
+
*/
|
|
29
|
+
#closed = false;
|
|
22
30
|
#pending = [];
|
|
23
31
|
constructor(config) {
|
|
24
32
|
this.#filePath = config.path;
|
|
@@ -26,6 +34,8 @@ export class FileChannel {
|
|
|
26
34
|
this.#maxFiles = config.maxFiles ?? 5;
|
|
27
35
|
}
|
|
28
36
|
write(entry) {
|
|
37
|
+
if (this.#closed)
|
|
38
|
+
return;
|
|
29
39
|
const line = `${JSON.stringify(entry)}\n`;
|
|
30
40
|
const bytes = Buffer.byteLength(line, "utf8");
|
|
31
41
|
if (this.#rotating) {
|
|
@@ -52,7 +62,7 @@ export class FileChannel {
|
|
|
52
62
|
return;
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
|
-
if (this.#
|
|
65
|
+
if (this.#needsRotation(bytes)) {
|
|
56
66
|
this.#pending.push(line);
|
|
57
67
|
this.#scheduleRotation();
|
|
58
68
|
return;
|
|
@@ -63,6 +73,9 @@ export class FileChannel {
|
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
75
|
#openStream() {
|
|
76
|
+
// A rotation in flight when `close()` lands must not bring the file back.
|
|
77
|
+
if (this.#closed)
|
|
78
|
+
return;
|
|
66
79
|
// mkdirSync + statSync only on first open (boot) — never on the hot path.
|
|
67
80
|
// The fast write path goes straight through this.#stream.write() (non-blocking).
|
|
68
81
|
if (!this.#dirReady) {
|
|
@@ -81,8 +94,24 @@ export class FileChannel {
|
|
|
81
94
|
process.stderr.write(`[Spectrum] FileChannel stream error: ${err.message}\n`);
|
|
82
95
|
});
|
|
83
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Whether this line has to wait for a rotation.
|
|
99
|
+
*
|
|
100
|
+
* The empty-file test is what stops an entry LARGER than `maxSizeBytes`
|
|
101
|
+
* from spinning forever: a fresh file starts at zero, so `0 + bytes > max`
|
|
102
|
+
* was still true and the line went back on the buffer, scheduled another
|
|
103
|
+
* rotation, and came back to the same answer — churning through a
|
|
104
|
+
* generation each time and never being written.
|
|
105
|
+
*
|
|
106
|
+
* A log line cannot be split, so an oversized one is written whole into a
|
|
107
|
+
* file of its own and the next line rotates. Bigger than the limit once
|
|
108
|
+
* beats absent.
|
|
109
|
+
*/
|
|
110
|
+
#needsRotation(bytes) {
|
|
111
|
+
return this.#currentSize > 0 && this.#currentSize + bytes > this.#maxSize;
|
|
112
|
+
}
|
|
84
113
|
#scheduleRotation() {
|
|
85
|
-
if (this.#rotating)
|
|
114
|
+
if (this.#rotating || this.#closed)
|
|
86
115
|
return;
|
|
87
116
|
this.#rotating = true;
|
|
88
117
|
queueMicrotask(() => {
|
|
@@ -97,14 +126,18 @@ export class FileChannel {
|
|
|
97
126
|
await this.#closeStream();
|
|
98
127
|
const oldest = `${this.#filePath}.${this.#maxFiles - 1}`;
|
|
99
128
|
await fsp.rm(oldest, { force: true });
|
|
129
|
+
// Shift the numbered generations up, oldest first: .1 → .2, .2 → .3…
|
|
130
|
+
//
|
|
131
|
+
// The i===1 pass used to take the LIVE file rather than `.1`, so `.1`
|
|
132
|
+
// was never written and the rename below found nothing left to move.
|
|
133
|
+
// With maxFiles=3 that kept one generation where two were configured,
|
|
134
|
+
// and every rotation destroyed the one before it.
|
|
100
135
|
for (let i = this.#maxFiles - 2; i >= 1; i--) {
|
|
101
|
-
const from = i === 1 ? this.#filePath : `${this.#filePath}.${i}`;
|
|
102
|
-
const to = `${this.#filePath}.${i + 1}`;
|
|
103
136
|
try {
|
|
104
|
-
await fsp.rename(
|
|
137
|
+
await fsp.rename(`${this.#filePath}.${i}`, `${this.#filePath}.${i + 1}`);
|
|
105
138
|
}
|
|
106
139
|
catch {
|
|
107
|
-
//
|
|
140
|
+
// That generation does not exist yet — skip
|
|
108
141
|
}
|
|
109
142
|
}
|
|
110
143
|
try {
|
|
@@ -133,7 +166,7 @@ export class FileChannel {
|
|
|
133
166
|
if (!line)
|
|
134
167
|
continue;
|
|
135
168
|
const bytes = Buffer.byteLength(line, "utf8");
|
|
136
|
-
if (this.#
|
|
169
|
+
if (this.#needsRotation(bytes)) {
|
|
137
170
|
this.#pending.unshift(line);
|
|
138
171
|
this.#scheduleRotation();
|
|
139
172
|
return;
|
|
@@ -151,10 +184,49 @@ export class FileChannel {
|
|
|
151
184
|
stream.end(() => resolve());
|
|
152
185
|
});
|
|
153
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Stop writing, for good.
|
|
189
|
+
*
|
|
190
|
+
* Anything buffered by a rotation goes out first — those lines were accepted
|
|
191
|
+
* and dropping them at close loses log the caller believed was written — and
|
|
192
|
+
* the flag is set before the flush so nothing the flush triggers can reopen
|
|
193
|
+
* the file.
|
|
194
|
+
*/
|
|
154
195
|
close() {
|
|
196
|
+
if (this.#closed)
|
|
197
|
+
return;
|
|
198
|
+
const pending = this.#pending.splice(0);
|
|
199
|
+
this.#closed = true;
|
|
155
200
|
if (this.#stream) {
|
|
201
|
+
for (const line of pending)
|
|
202
|
+
this.#stream.write(line);
|
|
156
203
|
this.#stream.end();
|
|
157
204
|
this.#stream = null;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
// No stream, because a rotation is in flight: it nulls the stream before
|
|
208
|
+
// awaiting the old one's end, and it will not reopen now that #closed is
|
|
209
|
+
// set. Writing the buffer to the stream that no longer exists is how
|
|
210
|
+
// those lines used to disappear — accepted by write(), then dropped.
|
|
211
|
+
//
|
|
212
|
+
// Appended directly instead, and synchronously, because close() is: the
|
|
213
|
+
// path is the current log either way, whether the rotation has renamed
|
|
214
|
+
// it yet or not.
|
|
215
|
+
this.#appendDirectly(pending);
|
|
216
|
+
}
|
|
217
|
+
/** Last-resort write for lines with no stream left to carry them. */
|
|
218
|
+
#appendDirectly(lines) {
|
|
219
|
+
if (lines.length === 0)
|
|
220
|
+
return;
|
|
221
|
+
try {
|
|
222
|
+
if (!this.#dirReady) {
|
|
223
|
+
fs.mkdirSync(path.dirname(this.#filePath), { recursive: true });
|
|
224
|
+
this.#dirReady = true;
|
|
225
|
+
}
|
|
226
|
+
fs.appendFileSync(this.#filePath, lines.join(""));
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
process.stderr.write(`[Spectrum] FileChannel: ${lines.length} buffered line(s) lost closing '${this.#filePath}'\n`);
|
|
158
230
|
}
|
|
159
231
|
}
|
|
160
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileChannel.js","sourceRoot":"","sources":["../../src/channels/FileChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AASlC,MAAM,OAAO,WAAW;IACvB,IAAI,GAAG,MAAM,CAAC;IACd,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,OAAO,GAA0B,IAAI,CAAC;IACtC,YAAY,GAAG,CAAC,CAAC;IACjB,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,KAAK,CAAC;IAClB,QAAQ,GAAa,EAAE,CAAC;IAExB,YAAY,MAAyB;QACpC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE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CAAC,CAAC;gBAChE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACvB,CAAC;YACD,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB,2BAA2B,KAAK,CAAC,MAAM,mCAAmC,IAAI,CAAC,SAAS,KAAK,CAC7F,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
|
package/dist/configure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BjE"}
|
package/dist/configure.js
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
export async function configure(codemods) {
|
|
2
2
|
await codemods.addProvider("@c9up/spectrum/provider");
|
|
3
|
-
await codemods.writeFile("config/logger.ts", `import {
|
|
3
|
+
await codemods.writeFile("config/logger.ts", `import { defineConfig, logLevel, targets } from '@c9up/spectrum'
|
|
4
|
+
|
|
5
|
+
const inProduction = process.env.NODE_ENV === 'production'
|
|
4
6
|
|
|
5
7
|
export default defineConfig({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
default: 'app',
|
|
9
|
+
loggers: {
|
|
10
|
+
app: {
|
|
11
|
+
enabled: true,
|
|
12
|
+
name: process.env.APP_NAME ?? 'app',
|
|
13
|
+
// LOG_LEVEL comes from outside the program, so it is checked rather than
|
|
14
|
+
// asserted: anything that is not a level reads as 'info'.
|
|
15
|
+
level: logLevel(process.env.LOG_LEVEL),
|
|
16
|
+
transport: {
|
|
17
|
+
targets: targets()
|
|
18
|
+
.pushIf(!inProduction, targets.pretty())
|
|
19
|
+
.pushIf(inProduction, targets.file({ destination: 1 }))
|
|
20
|
+
.toArray(),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
12
24
|
})
|
|
13
25
|
`);
|
|
14
26
|
}
|
package/dist/configure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,MAAM,QAAQ,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IACtD,MAAM,QAAQ,CAAC,SAAS,CACvB,kBAAkB,EAClB
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,MAAM,QAAQ,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IACtD,MAAM,QAAQ,CAAC,SAAS,CACvB,kBAAkB,EAClB;;;;;;;;;;;;;;;;;;;;;;CAsBD,CACC,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @description Spectrum — structured logging for the Ream framework
|
|
4
4
|
* @implements FR54, FR55, FR56, FR57, FR58
|
|
5
5
|
*/
|
|
6
|
+
import "./augmentations.js";
|
|
6
7
|
export { ConsoleChannel } from "./channels/ConsoleChannel.js";
|
|
7
8
|
export { FileChannel } from "./channels/FileChannel.js";
|
|
8
9
|
export { defineConfig } from "./config.js";
|
|
@@ -12,5 +13,5 @@ export { LoggerManager } from "./LoggerManager.js";
|
|
|
12
13
|
export { createRustLogBridge, parseRustLog } from "./RustLogBridge.js";
|
|
13
14
|
export type { FileTargetOptions, PrettyTargetOptions, TransportTargetOptions, } from "./targets.js";
|
|
14
15
|
export { channelsFromTargets, Targets, targets } from "./targets.js";
|
|
15
|
-
export { type LogChannel, type LogConfig, type LogEntry, type LoggerManagerConfig, type LogLevelWithSilent, type LogSerializer, logEntryExtras, type RedactOptions, } from "./types.js";
|
|
16
|
+
export { isLogLevelWithSilent, type LogChannel, type LogConfig, type LogEntry, type LoggerManagerConfig, type LogLevelWithSilent, type LogSerializer, logEntryExtras, logLevel, type RedactOptions, } from "./types.js";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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AAM,oBAAoB,CAAC;AACvE,YAAY,EACX,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACN,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,cAAc,EACd,QAAQ,EACR,KAAK,aAAa,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @description Spectrum — structured logging for the Ream framework
|
|
4
4
|
* @implements FR54, FR55, FR56, FR57, FR58
|
|
5
5
|
*/
|
|
6
|
+
import "./augmentations.js";
|
|
6
7
|
export { ConsoleChannel } from "./channels/ConsoleChannel.js";
|
|
7
8
|
export { FileChannel } from "./channels/FileChannel.js";
|
|
8
9
|
export { defineConfig } from "./config.js";
|
|
@@ -11,5 +12,5 @@ export { Logger } from "./Logger.js";
|
|
|
11
12
|
export { LoggerManager } from "./LoggerManager.js";
|
|
12
13
|
export { createRustLogBridge, parseRustLog } from "./RustLogBridge.js";
|
|
13
14
|
export { channelsFromTargets, Targets, targets } from "./targets.js";
|
|
14
|
-
export { logEntryExtras, } from "./types.js";
|
|
15
|
+
export { isLogLevelWithSilent, logEntryExtras, logLevel, } from "./types.js";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMvE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMvE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACN,oBAAoB,EAOpB,cAAc,EACd,QAAQ,GAER,MAAM,YAAY,CAAC"}
|
package/dist/redact.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction paths, in the syntax pino's `redact` option is written in.
|
|
3
|
+
*
|
|
4
|
+
* Upstream hands those paths to `fast-redact`, so a migrated `config/logger.ts`
|
|
5
|
+
* legitimately contains `req.headers.authorization`, `*.password`,
|
|
6
|
+
* `users[*].token` and `headers["set-cookie"]`. Understanding only the first of
|
|
7
|
+
* those — a literal dot-path — is not a smaller feature: it is a redaction that
|
|
8
|
+
* silently does nothing. The config says the password is censored, and the
|
|
9
|
+
* password is written out in full.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Split a redaction path into the keys it names.
|
|
13
|
+
*
|
|
14
|
+
* `a["b-c"]` and `a.b-c` name the same key: the brackets and the quotes are
|
|
15
|
+
* notation, not part of the name.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseRedactPath(path: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Replace everything `tokens` selects with `censor`, without touching the
|
|
20
|
+
* input.
|
|
21
|
+
*
|
|
22
|
+
* Copy-on-write, and the copy is only made once something actually matched —
|
|
23
|
+
* so an entry with no redacted field is passed through by reference, which is
|
|
24
|
+
* the common case on the hot path. The same rule is what keeps the walk
|
|
25
|
+
* honest: a path that names nothing leaves the object exactly as it was
|
|
26
|
+
* instead of inventing the key it was looking for.
|
|
27
|
+
*/
|
|
28
|
+
export declare function redactPath(node: unknown, tokens: readonly string[], censor: string, depth?: number): unknown;
|
|
29
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,MAAM,EACd,KAAK,SAAI,GACP,OAAO,CAqBT"}
|
package/dist/redact.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction paths, in the syntax pino's `redact` option is written in.
|
|
3
|
+
*
|
|
4
|
+
* Upstream hands those paths to `fast-redact`, so a migrated `config/logger.ts`
|
|
5
|
+
* legitimately contains `req.headers.authorization`, `*.password`,
|
|
6
|
+
* `users[*].token` and `headers["set-cookie"]`. Understanding only the first of
|
|
7
|
+
* those — a literal dot-path — is not a smaller feature: it is a redaction that
|
|
8
|
+
* silently does nothing. The config says the password is censored, and the
|
|
9
|
+
* password is written out in full.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* fast-redact's own tokenizer: a run of characters that is not `.`, `[` or
|
|
13
|
+
* `]`, or anything between a pair of brackets.
|
|
14
|
+
*/
|
|
15
|
+
const PATH_TOKEN = /[^.[\]]+|\[(?:.)*?\]/g;
|
|
16
|
+
/**
|
|
17
|
+
* Split a redaction path into the keys it names.
|
|
18
|
+
*
|
|
19
|
+
* `a["b-c"]` and `a.b-c` name the same key: the brackets and the quotes are
|
|
20
|
+
* notation, not part of the name.
|
|
21
|
+
*/
|
|
22
|
+
export function parseRedactPath(path) {
|
|
23
|
+
const tokens = path.match(PATH_TOKEN);
|
|
24
|
+
if (!tokens)
|
|
25
|
+
return [];
|
|
26
|
+
return tokens.map((token) => {
|
|
27
|
+
const inner = token.startsWith("[") ? token.slice(1, -1) : token;
|
|
28
|
+
return inner.replace(/['"`]/g, "");
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Replace everything `tokens` selects with `censor`, without touching the
|
|
33
|
+
* input.
|
|
34
|
+
*
|
|
35
|
+
* Copy-on-write, and the copy is only made once something actually matched —
|
|
36
|
+
* so an entry with no redacted field is passed through by reference, which is
|
|
37
|
+
* the common case on the hot path. The same rule is what keeps the walk
|
|
38
|
+
* honest: a path that names nothing leaves the object exactly as it was
|
|
39
|
+
* instead of inventing the key it was looking for.
|
|
40
|
+
*/
|
|
41
|
+
export function redactPath(node, tokens, censor, depth = 0) {
|
|
42
|
+
const segment = tokens[depth];
|
|
43
|
+
if (segment === undefined || node === null || typeof node !== "object") {
|
|
44
|
+
return node;
|
|
45
|
+
}
|
|
46
|
+
const keys = selectKeys(node, segment);
|
|
47
|
+
if (keys.length === 0)
|
|
48
|
+
return node;
|
|
49
|
+
const isLast = depth === tokens.length - 1;
|
|
50
|
+
let copy = null;
|
|
51
|
+
for (const key of keys) {
|
|
52
|
+
const current = readKey(node, key);
|
|
53
|
+
const next = isLast
|
|
54
|
+
? censor
|
|
55
|
+
: redactPath(current, tokens, censor, depth + 1);
|
|
56
|
+
if (next === current)
|
|
57
|
+
continue;
|
|
58
|
+
if (!copy)
|
|
59
|
+
copy = Array.isArray(node) ? [...node] : { ...node };
|
|
60
|
+
writeKey(copy, key, next);
|
|
61
|
+
}
|
|
62
|
+
return copy ?? node;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The own keys a path segment selects.
|
|
66
|
+
*
|
|
67
|
+
* `*` takes every one of them — on an array too, whose own keys are its
|
|
68
|
+
* indices, which is what makes `users[*].token` reach into a list. Anything
|
|
69
|
+
* else takes that single key, and only if the object really has it: `in` would
|
|
70
|
+
* answer for `toString` and turn a redaction into an invented field.
|
|
71
|
+
*/
|
|
72
|
+
function selectKeys(node, segment) {
|
|
73
|
+
if (segment === "*")
|
|
74
|
+
return Object.keys(node);
|
|
75
|
+
return Object.hasOwn(node, segment) ? [segment] : [];
|
|
76
|
+
}
|
|
77
|
+
function readKey(node, key) {
|
|
78
|
+
const own = Object.getOwnPropertyDescriptor(node, key);
|
|
79
|
+
return own === undefined ? undefined : own.value;
|
|
80
|
+
}
|
|
81
|
+
function writeKey(node, key, value) {
|
|
82
|
+
if (Array.isArray(node)) {
|
|
83
|
+
const index = Number(key);
|
|
84
|
+
if (Number.isInteger(index))
|
|
85
|
+
node[index] = value;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
node[key] = value;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG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IACD,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACnB,CAAC"}
|
package/dist/targets.d.ts
CHANGED
|
@@ -55,7 +55,12 @@ export declare const targets: (() => Targets) & {
|
|
|
55
55
|
* file when `destination` is a path, and to the console when it is a file
|
|
56
56
|
* descriptor, which is what `destination: 1` means in a containerised app that
|
|
57
57
|
* ships stdout to its log collector.
|
|
58
|
+
*
|
|
59
|
+
* A target with no level of its own inherits `inheritedLevel`, the level of the
|
|
60
|
+
* logger it belongs to — upstream's `defineConfig` fills the same gap, by
|
|
61
|
+
* writing the level into the target. Passing it instead of writing it leaves
|
|
62
|
+
* the caller's config object alone.
|
|
58
63
|
*/
|
|
59
|
-
export declare function channelsFromTargets(list: readonly TransportTargetOptions[]): LogChannel[];
|
|
64
|
+
export declare function channelsFromTargets(list: readonly TransportTargetOptions[], inheritedLevel?: LogLevelWithSilent | string): LogChannel[];
|
|
60
65
|
export {};
|
|
61
66
|
//# sourceMappingURL=targets.d.ts.map
|
package/dist/targets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAY,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAO3E,+DAA+D;AAC/D,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IACjC,WAAW,CAAC,EAAE,M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