@walkeros/core 4.8.1-next-1792019907609 → 4.8.2
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/CHANGELOG.md +49 -1
- package/dist/dev.d.mts +808 -47
- package/dist/dev.d.ts +808 -47
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.d.mts +466 -136
- package/dist/index.d.ts +466 -136
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +129 -14
- package/dist/node.d.ts +129 -14
- package/dist/node.js +1 -1
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +1 -1
- package/dist/node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node.d.mts
CHANGED
|
@@ -73,6 +73,39 @@ declare function scrubJson(value: unknown, options?: ScrubOptions & {
|
|
|
73
73
|
*/
|
|
74
74
|
declare function toPrintable(value: unknown): unknown;
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Build-time feature flags.
|
|
78
|
+
*
|
|
79
|
+
* A bundler may `define` any of these as `false` to fold the matching feature
|
|
80
|
+
* out of a bundle; the walkerOS CLI does so for browser bundles whose flow does
|
|
81
|
+
* not use the feature. Left undefined (npm installs, plain bundlers) every
|
|
82
|
+
* feature is on and behaviour is unchanged.
|
|
83
|
+
*
|
|
84
|
+
* A guard reads the flag inline, in block or `&&` form:
|
|
85
|
+
* `if (typeof __WALKEROS_STATE__ === 'undefined' || __WALKEROS_STATE__) {...}`.
|
|
86
|
+
* esbuild folds that shape away when the flag is defined false. It does not
|
|
87
|
+
* fold an early `if (!flag) return;` or a module-level const holding the flag.
|
|
88
|
+
*
|
|
89
|
+
* When a flag is not defined at build time, each guard is a global lookup at
|
|
90
|
+
* runtime, so a page could set `window.__WALKEROS_STORES__ = false` before the
|
|
91
|
+
* collector starts. That only switches a feature off for that page (accepted,
|
|
92
|
+
* low risk).
|
|
93
|
+
*
|
|
94
|
+
* The global type is frozen: an install with two copies of @walkeros/core
|
|
95
|
+
* declares these `var`s twice, and TypeScript rejects differing types
|
|
96
|
+
* (TS2403). Consumers must not redeclare the names as `const` (TS2451).
|
|
97
|
+
*/
|
|
98
|
+
declare global {
|
|
99
|
+
/** Observe: telemetry posting and trace-level vendor-call capture. */
|
|
100
|
+
var __WALKEROS_OBSERVE__: boolean | undefined;
|
|
101
|
+
/** Declared flow stores. The default `__cache` store always exists. */
|
|
102
|
+
var __WALKEROS_STORES__: boolean | undefined;
|
|
103
|
+
/** Declarative step `state`. */
|
|
104
|
+
var __WALKEROS_STATE__: boolean | undefined;
|
|
105
|
+
/** Runtime validation of transformer step entries. */
|
|
106
|
+
var __WALKEROS_VALIDATE__: boolean | undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
76
109
|
/**
|
|
77
110
|
* Log levels from most to least severe
|
|
78
111
|
*/
|
|
@@ -105,8 +138,8 @@ interface LogContext {
|
|
|
105
138
|
*/
|
|
106
139
|
type LogFn = (message: string | Error, context?: unknown | Error) => void;
|
|
107
140
|
/**
|
|
108
|
-
* Throw function signature
|
|
109
|
-
*
|
|
141
|
+
* Throw function signature: throws an Error with the message, never logs
|
|
142
|
+
* (the catching collector logs the failure once). Returns never.
|
|
110
143
|
*/
|
|
111
144
|
type ThrowFn = (message: string | Error, context?: unknown) => never;
|
|
112
145
|
/**
|
|
@@ -140,8 +173,8 @@ interface Instance {
|
|
|
140
173
|
*/
|
|
141
174
|
debug: LogFn;
|
|
142
175
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
176
|
+
* Throw an Error with the message. Does not log: the collector's catch
|
|
177
|
+
* writes the one line for the failure.
|
|
145
178
|
*/
|
|
146
179
|
throw: ThrowFn;
|
|
147
180
|
/**
|
|
@@ -155,6 +188,12 @@ interface Instance {
|
|
|
155
188
|
*/
|
|
156
189
|
scope: (name: string) => Instance;
|
|
157
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Output format of a server terminal logger: one text line per call, or one
|
|
193
|
+
* JSON object per line (`severity`, `message`, `scope`, `context`, `time`),
|
|
194
|
+
* which Cloud Run, Loki and Datadog read as structured entries.
|
|
195
|
+
*/
|
|
196
|
+
type Format = 'text' | 'json';
|
|
158
197
|
/**
|
|
159
198
|
* Logger configuration options
|
|
160
199
|
*/
|
|
@@ -164,6 +203,13 @@ interface Config {
|
|
|
164
203
|
* @default Level.ERROR
|
|
165
204
|
*/
|
|
166
205
|
level?: Level | keyof typeof Level;
|
|
206
|
+
/**
|
|
207
|
+
* Output format of a server flow's log lines (`@walkeros/core/node`'s
|
|
208
|
+
* terminal logger, used by `runneros`). Web flows log to the browser
|
|
209
|
+
* console and reject it.
|
|
210
|
+
* @default 'text'
|
|
211
|
+
*/
|
|
212
|
+
format?: Format;
|
|
167
213
|
/**
|
|
168
214
|
* Custom log handler function
|
|
169
215
|
* Receives originalHandler to preserve default behavior
|
|
@@ -173,16 +219,47 @@ interface Config {
|
|
|
173
219
|
jsonHandler?: (data: unknown) => void;
|
|
174
220
|
}
|
|
175
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Canonical structured value persisted by a store. Includes `null`, but
|
|
224
|
+
* EXCLUDES `undefined`: `undefined` is the reserved "miss" sentinel returned
|
|
225
|
+
* by `GetFn` for an absent key, so it must never be a stored value.
|
|
226
|
+
* `Uint8Array` is the platform-neutral binary leaf (never Node `Buffer`).
|
|
227
|
+
*/
|
|
228
|
+
type StoreValue = string | number | boolean | null | Uint8Array | StoreValue[] | {
|
|
229
|
+
[key: string]: StoreValue;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Thrown when a value cannot be serialized (e.g. a cyclic structure that
|
|
234
|
+
* `JSON.stringify` rejects). Catchable and distinguishable from a raw
|
|
235
|
+
* `TypeError` leaking out of the platform JSON implementation.
|
|
236
|
+
*/
|
|
237
|
+
declare class StoreCodecError extends Error {
|
|
238
|
+
cause?: unknown;
|
|
239
|
+
constructor(message: string, options?: {
|
|
240
|
+
cause?: unknown;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Serialize a `StoreValue` to its UTF-8 JSON byte payload. Throws
|
|
245
|
+
* `StoreCodecError` if the value cannot be encoded (e.g. a cyclic structure).
|
|
246
|
+
*/
|
|
247
|
+
declare function serializeStoreValue(value: StoreValue): Uint8Array;
|
|
248
|
+
/**
|
|
249
|
+
* Restore a `StoreValue` from its UTF-8 JSON byte payload (or a JSON string).
|
|
250
|
+
*/
|
|
251
|
+
declare function deserializeStoreValue(raw: Uint8Array | string): StoreValue;
|
|
252
|
+
|
|
176
253
|
/**
|
|
177
254
|
* Node entry point (`@walkeros/core/node`).
|
|
178
255
|
*
|
|
179
|
-
* Helpers shared by `@walkeros/cli
|
|
180
|
-
* in the browser `.` entry: the temp-path helpers import
|
|
181
|
-
* terminal logger config writes to the console, and the
|
|
182
|
-
* the simulate output formatter (`toPrintable
|
|
183
|
-
*
|
|
184
|
-
* for them: the colouriser is injected by the caller, so chalk
|
|
185
|
-
* packages that already depend on it.
|
|
256
|
+
* Helpers shared by `@walkeros/cli`, `@walkeros/runner` and the server stores
|
|
257
|
+
* that do not belong in the browser `.` entry: the temp-path helpers import
|
|
258
|
+
* node builtins, the terminal logger config writes to the console, and the
|
|
259
|
+
* secret redactor, the simulate output formatter (`toPrintable`) and the store
|
|
260
|
+
* byte codec (both read `Buffer`) have no browser consumer. Core gains no
|
|
261
|
+
* dependency for them: the colouriser is injected by the caller, so chalk
|
|
262
|
+
* stays in the packages that already depend on it.
|
|
186
263
|
*/
|
|
187
264
|
|
|
188
265
|
/**
|
|
@@ -220,18 +297,56 @@ declare function createTmpResolver(tmpDir?: string): TmpResolver;
|
|
|
220
297
|
* Get the default temp root directory.
|
|
221
298
|
*/
|
|
222
299
|
declare function getDefaultTmpRoot(): string;
|
|
300
|
+
/**
|
|
301
|
+
* One log line as a structured entry: the shape a JSON line prints and the
|
|
302
|
+
* `onLine` tap receives, masked like the text line. `message` is
|
|
303
|
+
* `[scope] message` without the context; `scope` and `context` are omitted
|
|
304
|
+
* when empty. When the line would pass {@link MAX_JSON_LINE_BYTES}, a
|
|
305
|
+
* message above half the cap keeps a prefix (`messageTruncated`), then
|
|
306
|
+
* `context` becomes a string prefix of its JSON (`contextTruncated`).
|
|
307
|
+
*/
|
|
308
|
+
interface LogEntry {
|
|
309
|
+
severity: 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
|
|
310
|
+
message: string;
|
|
311
|
+
messageTruncated?: true;
|
|
312
|
+
scope?: string;
|
|
313
|
+
context?: Record<string, unknown> | string;
|
|
314
|
+
contextTruncated?: true;
|
|
315
|
+
time: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Size cap of one JSON line, far below the 256 KiB a log platform accepts
|
|
319
|
+
* per entry: a longer entry may be dropped whole rather than cut.
|
|
320
|
+
*/
|
|
321
|
+
declare const MAX_JSON_LINE_BYTES: number;
|
|
223
322
|
interface CLILoggerOptions {
|
|
224
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Opens the DEBUG gate. A function is read per line, so a host can open
|
|
325
|
+
* it for the level a flow sets once it knows it.
|
|
326
|
+
*/
|
|
327
|
+
verbose?: boolean | (() => boolean);
|
|
225
328
|
silent?: boolean;
|
|
226
329
|
json?: boolean;
|
|
227
330
|
stderr?: boolean;
|
|
228
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Taps every line before any visibility gate: the masked text line, and
|
|
333
|
+
* the same line as a structured entry (scope, and the context with fields
|
|
334
|
+
* such as code, status, retryable and suppressed) for forwarding.
|
|
335
|
+
*/
|
|
336
|
+
onLine?: (level: Level, message: string, entry: LogEntry) => void;
|
|
229
337
|
/**
|
|
230
338
|
* Exact secret values masked in every line (see `scrubSecrets`). An array is
|
|
231
339
|
* copied at creation; a function is read per line, so values learned after
|
|
232
340
|
* the logger exists (secrets fetched at startup) are masked too.
|
|
233
341
|
*/
|
|
234
342
|
knownSecrets?: readonly string[] | (() => readonly string[]);
|
|
343
|
+
/**
|
|
344
|
+
* Output format (`text` by default): `json` prints one JSON object per
|
|
345
|
+
* line, ERROR and WARN to stderr, INFO and DEBUG to stdout, without
|
|
346
|
+
* colour. A function is read per line, so a host can switch to the
|
|
347
|
+
* format a flow sets once it knows it. `json` (machine output) wins.
|
|
348
|
+
*/
|
|
349
|
+
format?: Format | (() => Format | undefined);
|
|
235
350
|
}
|
|
236
351
|
/** Formats one already-scrubbed line for the terminal. */
|
|
237
352
|
type LineFormatter = (line: string) => string;
|
|
@@ -276,4 +391,4 @@ declare function createCLILoggerConfig(options?: CLILoggerOptions, colors?: CLIL
|
|
|
276
391
|
*/
|
|
277
392
|
declare function createCLILogger(options?: CLILoggerOptions, colors?: CLILoggerColors): Instance;
|
|
278
393
|
|
|
279
|
-
export { type CLILoggerColors, type CLILoggerOptions, type LineFormatter, type ScrubOptions, type TmpResolver, createCLILogger, createCLILoggerConfig, createTmpResolver, getDefaultTmpRoot, getTmpPath, redactLine, scrubJson, scrubSecrets, toPrintable };
|
|
394
|
+
export { type CLILoggerColors, type CLILoggerOptions, type LineFormatter, type LogEntry, MAX_JSON_LINE_BYTES, type ScrubOptions, StoreCodecError, type TmpResolver, createCLILogger, createCLILoggerConfig, createTmpResolver, deserializeStoreValue, getDefaultTmpRoot, getTmpPath, redactLine, scrubJson, scrubSecrets, serializeStoreValue, toPrintable };
|
package/dist/node.d.ts
CHANGED
|
@@ -73,6 +73,39 @@ declare function scrubJson(value: unknown, options?: ScrubOptions & {
|
|
|
73
73
|
*/
|
|
74
74
|
declare function toPrintable(value: unknown): unknown;
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Build-time feature flags.
|
|
78
|
+
*
|
|
79
|
+
* A bundler may `define` any of these as `false` to fold the matching feature
|
|
80
|
+
* out of a bundle; the walkerOS CLI does so for browser bundles whose flow does
|
|
81
|
+
* not use the feature. Left undefined (npm installs, plain bundlers) every
|
|
82
|
+
* feature is on and behaviour is unchanged.
|
|
83
|
+
*
|
|
84
|
+
* A guard reads the flag inline, in block or `&&` form:
|
|
85
|
+
* `if (typeof __WALKEROS_STATE__ === 'undefined' || __WALKEROS_STATE__) {...}`.
|
|
86
|
+
* esbuild folds that shape away when the flag is defined false. It does not
|
|
87
|
+
* fold an early `if (!flag) return;` or a module-level const holding the flag.
|
|
88
|
+
*
|
|
89
|
+
* When a flag is not defined at build time, each guard is a global lookup at
|
|
90
|
+
* runtime, so a page could set `window.__WALKEROS_STORES__ = false` before the
|
|
91
|
+
* collector starts. That only switches a feature off for that page (accepted,
|
|
92
|
+
* low risk).
|
|
93
|
+
*
|
|
94
|
+
* The global type is frozen: an install with two copies of @walkeros/core
|
|
95
|
+
* declares these `var`s twice, and TypeScript rejects differing types
|
|
96
|
+
* (TS2403). Consumers must not redeclare the names as `const` (TS2451).
|
|
97
|
+
*/
|
|
98
|
+
declare global {
|
|
99
|
+
/** Observe: telemetry posting and trace-level vendor-call capture. */
|
|
100
|
+
var __WALKEROS_OBSERVE__: boolean | undefined;
|
|
101
|
+
/** Declared flow stores. The default `__cache` store always exists. */
|
|
102
|
+
var __WALKEROS_STORES__: boolean | undefined;
|
|
103
|
+
/** Declarative step `state`. */
|
|
104
|
+
var __WALKEROS_STATE__: boolean | undefined;
|
|
105
|
+
/** Runtime validation of transformer step entries. */
|
|
106
|
+
var __WALKEROS_VALIDATE__: boolean | undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
76
109
|
/**
|
|
77
110
|
* Log levels from most to least severe
|
|
78
111
|
*/
|
|
@@ -105,8 +138,8 @@ interface LogContext {
|
|
|
105
138
|
*/
|
|
106
139
|
type LogFn = (message: string | Error, context?: unknown | Error) => void;
|
|
107
140
|
/**
|
|
108
|
-
* Throw function signature
|
|
109
|
-
*
|
|
141
|
+
* Throw function signature: throws an Error with the message, never logs
|
|
142
|
+
* (the catching collector logs the failure once). Returns never.
|
|
110
143
|
*/
|
|
111
144
|
type ThrowFn = (message: string | Error, context?: unknown) => never;
|
|
112
145
|
/**
|
|
@@ -140,8 +173,8 @@ interface Instance {
|
|
|
140
173
|
*/
|
|
141
174
|
debug: LogFn;
|
|
142
175
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
176
|
+
* Throw an Error with the message. Does not log: the collector's catch
|
|
177
|
+
* writes the one line for the failure.
|
|
145
178
|
*/
|
|
146
179
|
throw: ThrowFn;
|
|
147
180
|
/**
|
|
@@ -155,6 +188,12 @@ interface Instance {
|
|
|
155
188
|
*/
|
|
156
189
|
scope: (name: string) => Instance;
|
|
157
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Output format of a server terminal logger: one text line per call, or one
|
|
193
|
+
* JSON object per line (`severity`, `message`, `scope`, `context`, `time`),
|
|
194
|
+
* which Cloud Run, Loki and Datadog read as structured entries.
|
|
195
|
+
*/
|
|
196
|
+
type Format = 'text' | 'json';
|
|
158
197
|
/**
|
|
159
198
|
* Logger configuration options
|
|
160
199
|
*/
|
|
@@ -164,6 +203,13 @@ interface Config {
|
|
|
164
203
|
* @default Level.ERROR
|
|
165
204
|
*/
|
|
166
205
|
level?: Level | keyof typeof Level;
|
|
206
|
+
/**
|
|
207
|
+
* Output format of a server flow's log lines (`@walkeros/core/node`'s
|
|
208
|
+
* terminal logger, used by `runneros`). Web flows log to the browser
|
|
209
|
+
* console and reject it.
|
|
210
|
+
* @default 'text'
|
|
211
|
+
*/
|
|
212
|
+
format?: Format;
|
|
167
213
|
/**
|
|
168
214
|
* Custom log handler function
|
|
169
215
|
* Receives originalHandler to preserve default behavior
|
|
@@ -173,16 +219,47 @@ interface Config {
|
|
|
173
219
|
jsonHandler?: (data: unknown) => void;
|
|
174
220
|
}
|
|
175
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Canonical structured value persisted by a store. Includes `null`, but
|
|
224
|
+
* EXCLUDES `undefined`: `undefined` is the reserved "miss" sentinel returned
|
|
225
|
+
* by `GetFn` for an absent key, so it must never be a stored value.
|
|
226
|
+
* `Uint8Array` is the platform-neutral binary leaf (never Node `Buffer`).
|
|
227
|
+
*/
|
|
228
|
+
type StoreValue = string | number | boolean | null | Uint8Array | StoreValue[] | {
|
|
229
|
+
[key: string]: StoreValue;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Thrown when a value cannot be serialized (e.g. a cyclic structure that
|
|
234
|
+
* `JSON.stringify` rejects). Catchable and distinguishable from a raw
|
|
235
|
+
* `TypeError` leaking out of the platform JSON implementation.
|
|
236
|
+
*/
|
|
237
|
+
declare class StoreCodecError extends Error {
|
|
238
|
+
cause?: unknown;
|
|
239
|
+
constructor(message: string, options?: {
|
|
240
|
+
cause?: unknown;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Serialize a `StoreValue` to its UTF-8 JSON byte payload. Throws
|
|
245
|
+
* `StoreCodecError` if the value cannot be encoded (e.g. a cyclic structure).
|
|
246
|
+
*/
|
|
247
|
+
declare function serializeStoreValue(value: StoreValue): Uint8Array;
|
|
248
|
+
/**
|
|
249
|
+
* Restore a `StoreValue` from its UTF-8 JSON byte payload (or a JSON string).
|
|
250
|
+
*/
|
|
251
|
+
declare function deserializeStoreValue(raw: Uint8Array | string): StoreValue;
|
|
252
|
+
|
|
176
253
|
/**
|
|
177
254
|
* Node entry point (`@walkeros/core/node`).
|
|
178
255
|
*
|
|
179
|
-
* Helpers shared by `@walkeros/cli
|
|
180
|
-
* in the browser `.` entry: the temp-path helpers import
|
|
181
|
-
* terminal logger config writes to the console, and the
|
|
182
|
-
* the simulate output formatter (`toPrintable
|
|
183
|
-
*
|
|
184
|
-
* for them: the colouriser is injected by the caller, so chalk
|
|
185
|
-
* packages that already depend on it.
|
|
256
|
+
* Helpers shared by `@walkeros/cli`, `@walkeros/runner` and the server stores
|
|
257
|
+
* that do not belong in the browser `.` entry: the temp-path helpers import
|
|
258
|
+
* node builtins, the terminal logger config writes to the console, and the
|
|
259
|
+
* secret redactor, the simulate output formatter (`toPrintable`) and the store
|
|
260
|
+
* byte codec (both read `Buffer`) have no browser consumer. Core gains no
|
|
261
|
+
* dependency for them: the colouriser is injected by the caller, so chalk
|
|
262
|
+
* stays in the packages that already depend on it.
|
|
186
263
|
*/
|
|
187
264
|
|
|
188
265
|
/**
|
|
@@ -220,18 +297,56 @@ declare function createTmpResolver(tmpDir?: string): TmpResolver;
|
|
|
220
297
|
* Get the default temp root directory.
|
|
221
298
|
*/
|
|
222
299
|
declare function getDefaultTmpRoot(): string;
|
|
300
|
+
/**
|
|
301
|
+
* One log line as a structured entry: the shape a JSON line prints and the
|
|
302
|
+
* `onLine` tap receives, masked like the text line. `message` is
|
|
303
|
+
* `[scope] message` without the context; `scope` and `context` are omitted
|
|
304
|
+
* when empty. When the line would pass {@link MAX_JSON_LINE_BYTES}, a
|
|
305
|
+
* message above half the cap keeps a prefix (`messageTruncated`), then
|
|
306
|
+
* `context` becomes a string prefix of its JSON (`contextTruncated`).
|
|
307
|
+
*/
|
|
308
|
+
interface LogEntry {
|
|
309
|
+
severity: 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
|
|
310
|
+
message: string;
|
|
311
|
+
messageTruncated?: true;
|
|
312
|
+
scope?: string;
|
|
313
|
+
context?: Record<string, unknown> | string;
|
|
314
|
+
contextTruncated?: true;
|
|
315
|
+
time: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Size cap of one JSON line, far below the 256 KiB a log platform accepts
|
|
319
|
+
* per entry: a longer entry may be dropped whole rather than cut.
|
|
320
|
+
*/
|
|
321
|
+
declare const MAX_JSON_LINE_BYTES: number;
|
|
223
322
|
interface CLILoggerOptions {
|
|
224
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Opens the DEBUG gate. A function is read per line, so a host can open
|
|
325
|
+
* it for the level a flow sets once it knows it.
|
|
326
|
+
*/
|
|
327
|
+
verbose?: boolean | (() => boolean);
|
|
225
328
|
silent?: boolean;
|
|
226
329
|
json?: boolean;
|
|
227
330
|
stderr?: boolean;
|
|
228
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Taps every line before any visibility gate: the masked text line, and
|
|
333
|
+
* the same line as a structured entry (scope, and the context with fields
|
|
334
|
+
* such as code, status, retryable and suppressed) for forwarding.
|
|
335
|
+
*/
|
|
336
|
+
onLine?: (level: Level, message: string, entry: LogEntry) => void;
|
|
229
337
|
/**
|
|
230
338
|
* Exact secret values masked in every line (see `scrubSecrets`). An array is
|
|
231
339
|
* copied at creation; a function is read per line, so values learned after
|
|
232
340
|
* the logger exists (secrets fetched at startup) are masked too.
|
|
233
341
|
*/
|
|
234
342
|
knownSecrets?: readonly string[] | (() => readonly string[]);
|
|
343
|
+
/**
|
|
344
|
+
* Output format (`text` by default): `json` prints one JSON object per
|
|
345
|
+
* line, ERROR and WARN to stderr, INFO and DEBUG to stdout, without
|
|
346
|
+
* colour. A function is read per line, so a host can switch to the
|
|
347
|
+
* format a flow sets once it knows it. `json` (machine output) wins.
|
|
348
|
+
*/
|
|
349
|
+
format?: Format | (() => Format | undefined);
|
|
235
350
|
}
|
|
236
351
|
/** Formats one already-scrubbed line for the terminal. */
|
|
237
352
|
type LineFormatter = (line: string) => string;
|
|
@@ -276,4 +391,4 @@ declare function createCLILoggerConfig(options?: CLILoggerOptions, colors?: CLIL
|
|
|
276
391
|
*/
|
|
277
392
|
declare function createCLILogger(options?: CLILoggerOptions, colors?: CLILoggerColors): Instance;
|
|
278
393
|
|
|
279
|
-
export { type CLILoggerColors, type CLILoggerOptions, type LineFormatter, type ScrubOptions, type TmpResolver, createCLILogger, createCLILoggerConfig, createTmpResolver, getDefaultTmpRoot, getTmpPath, redactLine, scrubJson, scrubSecrets, toPrintable };
|
|
394
|
+
export { type CLILoggerColors, type CLILoggerOptions, type LineFormatter, type LogEntry, MAX_JSON_LINE_BYTES, type ScrubOptions, StoreCodecError, type TmpResolver, createCLILogger, createCLILoggerConfig, createTmpResolver, deserializeStoreValue, getDefaultTmpRoot, getTmpPath, redactLine, scrubJson, scrubSecrets, serializeStoreValue, toPrintable };
|
package/dist/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,i=(e,t,s,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let u of o(t))c.call(e,u)||u===s||n(e,u,{get:()=>t[u],enumerable:!(i=r(t,u))||i.enumerable});return e},u=(e,r,o)=>(o=null!=e?t(s(e)):{},i(!r&&e&&e.__esModule?o:n(o,"default",{value:e,enumerable:!0}),e)),f={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(f,{createCLILogger:()=>ge,createCLILoggerConfig:()=>ae,createTmpResolver:()=>ie,getDefaultTmpRoot:()=>ue,getTmpPath:()=>ce,redactLine:()=>Q,scrubJson:()=>oe,scrubSecrets:()=>Y,toPrintable:()=>X}),module.exports=(e=f,i(n({},"__esModule",{value:!0}),e));var l=u(require("os")),a=u(require("path")),g=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(g||{});function p(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function d(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=p(e)):n=e,void 0!==t&&(t instanceof Error?r.error=p(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=p(r.error))):r.value=t),{message:n,context:r}}var y=(e,t,n,r)=>{const o=`${g[e]}${r.length>0?` [${r.join(":")}]`:""}`,s=Object.keys(n).length>0,c=0===e?console.error:1===e?console.warn:console.log;s?c(o,t,n):c(o,t)};function b(e={}){return h({level:void 0!==e.level?function(e){return"string"==typeof e?g[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function h(e){const{level:t,handler:n,jsonHandler:r,scope:o}=e,s=(e,r,s)=>{if(e<=t){const t=d(r,s);n?n(e,t.message,t.context,o,y):y(e,t.message,t.context,o)}};return{error:(e,t)=>s(0,e,t),warn:(e,t)=>s(1,e,t),info:(e,t)=>s(2,e,t),debug:(e,t)=>s(3,e,t),throw:(e,t)=>{const r=d(e,t);throw n?n(0,r.message,r.context,o,y):y(0,r.message,r.context,o),new Error(r.message)},json:e=>{r?r(e):console.log(JSON.stringify(e,null,2))},scope:e=>h({level:t,handler:n,jsonHandler:r,scope:[...o,e]})}}var m=256,$=20,v=4,j=/(:\/\/[^/:@\s"\\]*:)[^@\s/"\\]+(@)/g,O=/(\\?"(?:private_key|client_email|private_key_id|client_id|client_x509_cert_url)\\?"\s*:\s*)(\\?)"[^"]*"/g,A="(?:x-)?(?:password|passwd|secret|client[-_]?secret|secret[-_]?access[-_]?key|api[-_]?key|api[-_]?secret|access[-_]?token|refresh[-_]?token|auth[-_]?token|id[-_]?token|session[-_]?token|private[-_]?key|token|authorization)",w=new RegExp(`("(?:${A})"\\s*:\\s*)(?:"(?:[^"\\\\]|\\\\.)*"|-?\\d[\\d.eE+-]*)`,"gi"),_=new RegExp(`(\\\\"(?:${A})\\\\"\\s*:\\s*)(?:(\\\\")(?:[^"\\\\]|\\\\[^"\\\\]|\\\\\\\\(?:\\\\\\\\|\\\\"|[^"\\\\]))*|-?\\d[\\d.eE+-]*)`,"gi"),x=new RegExp(`([?&]${A}=)[^&#\\s"\\\\]+`,"gi"),E=/-----BEGIN [A-Z ]*PRIVATE KEY-----[^-]*/gi,R=/^\s*-----BEGIN [A-Z ]*PRIVATE KEY-----/i,k=/-----END[A-Z -]*-----/i,S="[A-Za-z0-9+/._-]",N=new RegExp(`(^|\\s)([A-Za-z_][A-Za-z0-9_.]{0,63}\\s*[=:]\\s*)(${S}{12,}={0,2})`,"g"),I=new RegExp(`${S}{${$},}`,"g");var P=["sk-","sk_","pk_","ghp_","gho_","xoxb-","xoxp-","AKIA"].sort((e,t)=>t.length-e.length).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("|"),Z=new RegExp(`(?:${P})${S}*`,"g"),z=/^(?:u[0-9a-fA-F]{4}|[bfnrt])/;var J=/^[0-9a-fA-F]+$/,L=/^[0-9]+$/,U=/[+=]/,B=/[0-9]/,D=/[A-Za-z]/,T=8;function M(e){return!!J.test(e)||(!!L.test(e)||(!!U.test(e)||(!(!B.test(e)||!D.test(e))||function(e){if(0===e.length)return 0;const t=new Map;for(const n of e)t.set(n,(t.get(n)??0)+1);let n=0;for(const r of t.values()){const t=r/e.length;n-=t*Math.log2(t)}return n}(e)>=v)))}var C=/^v?\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function F(e,t=!1){return!C.test(e)&&(e.includes("/")?e.split("/").filter(e=>e.length>=$).some(H):t?M(e):H(e))}function H(e){return e.includes(".")?e.split(".").filter(e=>e.length>=T).some(M):M(e)}function G(e){let t=e;return t=t.replace(j,"$1***$2"),t=t.replace(x,"$1***"),t=t.replace(E,"***"),t=t.replace(N,(e,t,n,r)=>F(r,!0)?`${t}${n}***`:e),t=t.replace(Z,"***"),t=t.replace(I,(e,t,n)=>{if(!F(e))return e;const r=t>0&&"\\"===n[t-1]?z.exec(e)?.[0]:void 0;return r?`${r}***`:"***"}),t}var q=6;function K(e,t){if(!t||0===t.length)return e;const n=new Set;for(const e of t){if(e.length<q)continue;const t=JSON.stringify(e).slice(1,-1);n.add(e),n.add(t),n.add(JSON.stringify(t).slice(1,-1));const r=V(encodeURIComponent,e);r&&(n.add(r),n.add(r.replace(/%20/g,"+")));const o=V(encodeURI,e);o&&n.add(o),n.add(new URLSearchParams({v:e}).toString().slice(2))}let r=e;for(const e of[...n].sort((e,t)=>t.length-e.length))r.includes(e)&&(r=W(r,e));return r}function V(e,t){try{return e(t)}catch{return}}function W(e,t){let n="",r=0,o=e.indexOf(t);for(;-1!==o;){let s=0;for(;o-s>r&&"\\"===e[o-s-1];)s++;const c=s%2==1?z.exec(t)?.[0]??t[0]:"";n+=`${e.slice(r,o)}${c}***`,r=o+t.length,o=e.indexOf(t,r)}return n+e.slice(r)}function Y(e,t={}){const n=function(e){const t=[];let n=!1;for(const r of e)if(n)k.test(r)&&(n=!1);else{if(R.test(r)){n=!0;continue}t.push(r)}return t}(K(e,t.known).replace(O,'$1$2"***$2"').replace(_,(e,t,n)=>n?`${t}${n}***`:`${t}\\"***\\"`).replace(w,'$1"***"').split("\n"));return n.map(G).join("\n")}function Q(e){const t=Y(e);return t.length>m?t.slice(0,m-1)+"…":t}function X(e){return re(e,new Set)}var ee=new(require("util").TextDecoder)("utf-8",{fatal:!0});function te(e){return Object.prototype.toString.call(e)}function ne(e){return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):function(e){return"[object ArrayBuffer]"===te(e)}(e)?new Uint8Array(e):void 0}function re(e,t){if("bigint"==typeof e)return e.toString();if("function"==typeof e)return`[Function ${e.name||"anonymous"}]`;if("symbol"==typeof e)return e.toString();if(null===e||"object"!=typeof e)return e;try{return function(e,t){if(function(e){return"[object Error]"===te(e)}(e))return{name:e.name,message:e.message};const n=ne(e);if(n)return function(e){try{return ee.decode(e)}catch{return`base64:${Buffer.from(e).toString("base64")}`}}(n);if(t.has(e))return"[Circular]";t.add(e);try{if(function(e){return"[object Map]"===te(e)}(e))return Array.from(e.entries(),([e,n])=>[re(e,t),re(n,t)]);if(function(e){return"[object Set]"===te(e)}(e))return Array.from(e.values(),e=>re(e,t));if(Array.isArray(e))return e.map(e=>re(e,t));if(function(e){return"toJSON"in e&&"function"==typeof e.toJSON}(e))return re(e.toJSON(),t);const n={};for(const[r,o]of Object.entries(e))n[r]=re(o,t);const r=function(e){const t=te(e).slice(8,-1);if("Object"!==t)return t;const n=Object.getPrototypeOf(e);if(null===n||n===Object.prototype)return;if("object"!=typeof n)return;const r=Reflect.get(n,"constructor");return"function"==typeof r&&"Object"!==r.name&&r.name||void 0}(e);return r?{[r]:n}:n}finally{t.delete(e)}}(e,t)}catch{return"[Unprintable]"}}function oe(e,t={}){const n=t.known??[],r=JSON.stringify(function(e,t){const n=t.filter(e=>e.length>=q),r=e=>{if("number"==typeof e){const t=String(e);return n.some(e=>t.includes(e))?"***":e}if(Array.isArray(e))return e.map(r);if(e&&"object"==typeof e){const t={};for(const[n,o]of Object.entries(e))t[n]=r(o);return t}return e};return r(e)}(X(e),n),null,t.space)??"undefined";return Y(r,{known:n})}var se=l.default.tmpdir();function ce(e,...t){const n=e||se,r=a.default.isAbsolute(n)?n:a.default.resolve(n);return a.default.join(r,...t)}function ie(e){const t=e||se,n=a.default.isAbsolute(t)?t:a.default.resolve(t);return(...e)=>a.default.join(n,...e)}function ue(){return se}var fe=e=>e,le="$TMPDIR";function ae(e={},t={}){const{verbose:n=!1,silent:r=!1,json:o=!1,stderr:s=!1,knownSecrets:c}=e,i="function"==typeof c?void 0:c?[...c]:void 0,u=l.default.tmpdir(),f=s?console.error:console.log,g=t.error??fe,p=t.warn??fe,d=t.info??fe,y=t.debug??fe;return{level:3,handler:(t,s,l,b)=>{const h=b.length>0?`[${b.join(":")}] `:"";let m="";if(Object.keys(l).length>0)try{m=` ${JSON.stringify(l)}`}catch{m=" [unserializable context]"}const $=Y(function(e,t){if(!t||t===a.default.sep)return e;const n=t.endsWith(a.default.sep)?t:t+a.default.sep,r=e.split(n);if(1===r.length)return e;let o=r[0];for(let e=1;e<r.length;e++){const t=o.length>0?o[o.length-1]:"";o+=(""!==t&&/[\w./\\~-]/.test(t)?n:le+a.default.sep)+r[e]}return o}(K(`${h}${s}${m}`,"function"==typeof c?c():i),u));try{e.onLine?.(t,$)}catch{}if(0!==t){if(!r&&!o)if(3!==t)f(1===t?p($):d($));else{if(!n)return;f(` ${y($)}`)}}else o||console.error(g($))},jsonHandler:e=>{r||f(JSON.stringify(e,null,2))}}}function ge(e={},t={}){return b(ae(e,t))}//# sourceMappingURL=node.js.map
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,i,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let f of o(t))s.call(e,f)||f===i||r(e,f,{get:()=>t[f],enumerable:!(c=n(t,f))||c.enumerable});return e},f=(e,n,o)=>(o=null!=e?t(i(e)):{},c(!n&&e&&e.__esModule?o:r(o,"default",{value:e,enumerable:!0}),e)),u={};((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(u,{MAX_JSON_LINE_BYTES:()=>ve,StoreCodecError:()=>ue,createCLILogger:()=>Se,createCLILoggerConfig:()=>we,createTmpResolver:()=>he,deserializeStoreValue:()=>de,getDefaultTmpRoot:()=>me,getTmpPath:()=>be,redactLine:()=>X,scrubJson:()=>ie,scrubSecrets:()=>Y,serializeStoreValue:()=>ye,toPrintable:()=>Q}),module.exports=(e=u,c(r({},"__esModule",{value:!0}),e));var a=f(require("os")),l=f(require("path")),g=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(g||{});function y(e){const t={message:e.message,name:e.name,stack:e.stack},r="cause"in e?function(e){if("object"!=typeof e||null===e)return;const t={};return"name"in e&&"string"==typeof e.name&&(t.name=e.name),!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}(e.cause):void 0;return r&&(t.cause=r),t}function d(e,t){let r,n={};return e instanceof Error?(r=e.message,n.error=y(e)):r=e,void 0!==t&&(t instanceof Error?n.error=y(t):"object"==typeof t&&null!==t?(n={...n,...t},"error"in n&&n.error instanceof Error&&(n.error=y(n.error))):n.value=t),{message:r,context:n}}var p=(e,t,r,n)=>{const o=`${g[e]}${n.length>0?` [${n.join(":")}]`:""}`,i=Object.keys(r).length>0,s=0===e?console.error:1===e?console.warn:console.log;i?s(o,t,r):s(o,t)};function b(e={}){return h({level:void 0!==e.level?function(e){return"string"==typeof e?g[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function h(e){const{level:t,handler:r,jsonHandler:n,scope:o}=e,i=(e,n,i)=>{if(e<=t){const t=d(n,i);r?r(e,t.message,t.context,o,p):p(e,t.message,t.context,o)}};return{error:(e,t)=>i(0,e,t),warn:(e,t)=>i(1,e,t),info:(e,t)=>i(2,e,t),debug:(e,t)=>i(3,e,t),throw:(e,t)=>{throw new Error(d(e,t).message)},json:e=>{n?n(e):console.log(JSON.stringify(e,null,2))},scope:e=>h({level:t,handler:r,jsonHandler:n,scope:[...o,e]})}}var m=256,v=20,O=4,j=/(:\/\/[^/:@\s"\\]*:)[^@\s/"\\]+(@)/g,A=/(\\?"(?:private_key|client_email|private_key_id|client_id|client_x509_cert_url)\\?"\s*:\s*)(\\?)"[^"]*"/g,$="(?:x-)?(?:password|passwd|secret|client[-_]?secret|secret[-_]?access[-_]?key|api[-_]?key|api[-_]?secret|access[-_]?token|refresh[-_]?token|auth[-_]?token|id[-_]?token|session[-_]?token|private[-_]?key|token|authorization)",w=new RegExp(`("(?:${$})"\\s*:\\s*)(?:"(?:[^"\\\\]|\\\\.)*"|-?\\d[\\d.eE+-]*)`,"gi"),S=new RegExp(`(\\\\"(?:${$})\\\\"\\s*:\\s*)(?:(\\\\")(?:[^"\\\\]|\\\\[^"\\\\]|\\\\\\\\(?:\\\\\\\\|\\\\"|[^"\\\\]))*|-?\\d[\\d.eE+-]*)`,"gi"),_=new RegExp(`([?&]${$}=)[^&#\\s"\\\\]+`,"gi"),x=/-----BEGIN [A-Z ]*PRIVATE KEY-----[^-]*/gi,E=/^\s*-----BEGIN [A-Z ]*PRIVATE KEY-----/i,N=/-----END[A-Z -]*-----/i,R="[A-Za-z0-9+/._-]",k=new RegExp(`(^|\\s)([A-Za-z_][A-Za-z0-9_.]{0,63}\\s*[=:]\\s*)(${R}{12,}={0,2})`,"g"),B=new RegExp(`${R}{${v},}`,"g");var J=["sk-","sk_","pk_","ghp_","gho_","xoxb-","xoxp-","AKIA"].sort((e,t)=>t.length-e.length).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("|"),L=new RegExp(`(?:${J})${R}*`,"g"),I=/^(?:u[0-9a-fA-F]{4}|[bfnrt])/;var z=/^[0-9a-fA-F]+$/,P=/^[0-9]+$/,U=/[+=]/,Z=/[0-9]/,M=/[A-Za-z]/,T=8;function D(e){return!!z.test(e)||(!!P.test(e)||(!!U.test(e)||(!(!Z.test(e)||!M.test(e))||function(e){if(0===e.length)return 0;const t=new Map;for(const r of e)t.set(r,(t.get(r)??0)+1);let r=0;for(const n of t.values()){const t=n/e.length;r-=t*Math.log2(t)}return r}(e)>=O)))}var C=/^v?\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function F(e,t=!1){return!C.test(e)&&(e.includes("/")?e.split("/").filter(e=>e.length>=v).some(G):t?D(e):G(e))}function G(e){return e.includes(".")?e.split(".").filter(e=>e.length>=T).some(D):D(e)}function V(e){let t=e;return t=t.replace(j,"$1***$2"),t=t.replace(_,"$1***"),t=t.replace(x,"***"),t=t.replace(k,(e,t,r,n)=>F(n,!0)?`${t}${r}***`:e),t=t.replace(L,"***"),t=t.replace(B,(e,t,r)=>{if(!F(e))return e;const n=t>0&&"\\"===r[t-1]?I.exec(e)?.[0]:void 0;return n?`${n}***`:"***"}),t}var H=6;function W(e,t){if(!t||0===t.length)return e;const r=new Set;for(const e of t){if(e.length<H)continue;const t=JSON.stringify(e).slice(1,-1);r.add(e),r.add(t),r.add(JSON.stringify(t).slice(1,-1));const n=q(encodeURIComponent,e);n&&(r.add(n),r.add(n.replace(/%20/g,"+")));const o=q(encodeURI,e);o&&r.add(o),r.add(new URLSearchParams({v:e}).toString().slice(2))}let n=e;for(const e of[...r].sort((e,t)=>t.length-e.length))n.includes(e)&&(n=K(n,e));return n}function q(e,t){try{return e(t)}catch{return}}function K(e,t){let r="",n=0,o=e.indexOf(t);for(;-1!==o;){let i=0;for(;o-i>n&&"\\"===e[o-i-1];)i++;const s=i%2==1?I.exec(t)?.[0]??t[0]:"";r+=`${e.slice(n,o)}${s}***`,n=o+t.length,o=e.indexOf(t,n)}return r+e.slice(n)}function Y(e,t={}){const r=function(e){const t=[];let r=!1;for(const n of e)if(r)N.test(n)&&(r=!1);else{if(E.test(n)){r=!0;continue}t.push(n)}return t}(W(e,t.known).replace(A,'$1$2"***$2"').replace(S,(e,t,r)=>r?`${t}${r}***`:`${t}\\"***\\"`).replace(w,'$1"***"').split("\n"));return r.map(V).join("\n")}function X(e){const t=Y(e);return t.length>m?t.slice(0,m-1)+"…":t}function Q(e){return ne(e,new Set)}var ee=new(require("util").TextDecoder)("utf-8",{fatal:!0});function te(e){return Object.prototype.toString.call(e)}function re(e){return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):function(e){return"[object ArrayBuffer]"===te(e)}(e)?new Uint8Array(e):void 0}function ne(e,t){if("bigint"==typeof e)return e.toString();if("function"==typeof e)return`[Function ${e.name||"anonymous"}]`;if("symbol"==typeof e)return e.toString();if(null===e||"object"!=typeof e)return e;try{return function(e,t){if(function(e){return"[object Error]"===te(e)}(e))return{name:e.name,message:e.message};const r=re(e);if(r)return function(e){try{return ee.decode(e)}catch{return`base64:${Buffer.from(e).toString("base64")}`}}(r);if(t.has(e))return"[Circular]";t.add(e);try{if(function(e){return"[object Map]"===te(e)}(e))return Array.from(e.entries(),([e,r])=>[ne(e,t),ne(r,t)]);if(function(e){return"[object Set]"===te(e)}(e))return Array.from(e.values(),e=>ne(e,t));if(Array.isArray(e))return e.map(e=>ne(e,t));if(function(e){return"toJSON"in e&&"function"==typeof e.toJSON}(e))return ne(e.toJSON(),t);const r={};for(const[n,o]of Object.entries(e))r[n]=ne(o,t);const n=function(e){const t=te(e).slice(8,-1);if("Object"!==t)return t;const r=Object.getPrototypeOf(e);if(null===r||r===Object.prototype)return;if("object"!=typeof r)return;const n=Reflect.get(r,"constructor");return"function"==typeof n&&"Object"!==n.name&&n.name||void 0}(e);return n?{[n]:r}:r}finally{t.delete(e)}}(e,t)}catch{return"[Unprintable]"}}function oe(e,t){const r=t.filter(e=>e.length>=H),n=e=>{if("number"==typeof e){const t=String(e);return r.some(e=>t.includes(e))?"***":e}if(Array.isArray(e))return e.map(n);if(e&&"object"==typeof e){const t={};for(const[r,o]of Object.entries(e))t[r]=n(o);return t}return e};return n(e)}function ie(e,t={}){const r=t.known??[];return Y(JSON.stringify(oe(Q(e),r),null,t.space)??"undefined",{known:r})}function se(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function ce(e){return null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||e instanceof Uint8Array||(Array.isArray(e)?e.every(e=>void 0===e||ce(e)):!!se(e)&&Object.values(e).every(e=>void 0===e||ce(e)))}var fe="__walkeros_cache__",ue=class extends Error{constructor(e,t){var r,n;super(e),this.name="StoreCodecError",t&&"cause"in t&&(r=this,n=t.cause,Object.defineProperty(r,"cause",{value:n,writable:!0,configurable:!0}))}};function ae(e){if(Buffer.isBuffer(e))return{[fe]:"buffer",d:e.toString("base64")};if(e instanceof Uint8Array)return{[fe]:"buffer",d:Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64")};if(e instanceof ArrayBuffer)return{[fe]:"buffer",d:Buffer.from(e).toString("base64")};if(Array.isArray(e))return e.map(ae);if(se(e)){if(fe in e){const t={};for(const[r,n]of Object.entries(e))t[r]=ae(n);return{[fe]:"escape",d:t}}const t={};for(const[r,n]of Object.entries(e))t[r]=ae(n);return t}return e}function le(e,t){if(se(e)){if(fe in e){const r=e[fe],n=e.d;if("buffer"===r&&"string"==typeof n)return t(Buffer.from(n,"base64"));if("escape"===r&&se(n)){const e={};for(const[r,o]of Object.entries(n))e[r]=le(o,t);return e}}const r={};for(const[n,o]of Object.entries(e))r[n]=le(o,t);return r}return Array.isArray(e)?e.map(e=>le(e,t)):e}function ge(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ye(e){let t;try{t=JSON.stringify(ae(e))}catch(e){throw new ue("Failed to serialize store value (likely a cyclic structure).",{cause:e})}return new Uint8Array(Buffer.from(t,"utf8"))}function de(e){const t="string"==typeof e?e:Buffer.from(e).toString("utf8"),r=le(JSON.parse(t),ge);if(!ce(r))throw new ue("Restored value is not a valid StoreValue.");return r}var pe=a.default.tmpdir();function be(e,...t){const r=e||pe,n=l.default.isAbsolute(r)?r:l.default.resolve(r);return l.default.join(n,...t)}function he(e){const t=e||pe,r=l.default.isAbsolute(t)?t:l.default.resolve(t);return(...e)=>l.default.join(r,...e)}function me(){return pe}var ve=32768,Oe=e=>e,je="$TMPDIR";var Ae={0:"ERROR",1:"WARNING",2:"INFO",3:"DEBUG"};function $e(e,t,r,n,o,i){const s=n.join(":"),c={severity:Ae[e],message:o(`${s?`[${s}] `:""}${t}`),time:(new Date).toISOString()};let f;if(s&&(c.scope=s),Object.keys(r).length>0)try{f=o(JSON.stringify(oe(r,i??[])));const e=JSON.parse(f);c.context="object"!=typeof(u=e)||null===u||Array.isArray(u)?"[unserializable context]":e}catch{f=void 0,c.context="[unserializable context]"}var u;let a=JSON.stringify(c);if(Buffer.byteLength(a)<=ve)return{entry:c,line:a};const l=ve/2;if(Buffer.byteLength(c.message)>l){const e=c.message;let t=l;do{c.message=e.slice(0,t),t=Math.floor(t/2)}while(Buffer.byteLength(c.message)>l&&t>0);c.messageTruncated=!0,a=JSON.stringify(c)}if(f&&Buffer.byteLength(a)>ve){c.contextTruncated=!0;let e=ve-Buffer.byteLength(c.message)-256;do{c.context=f.slice(0,Math.max(e,0)),a=JSON.stringify(c),e=Math.floor(e/2)}while(Buffer.byteLength(a)>ve&&e>0)}return{entry:c,line:a}}function we(e={},t={}){const{verbose:r=!1,silent:n=!1,json:o=!1,stderr:i=!1,knownSecrets:s,format:c}=e,f="function"==typeof s?void 0:s?[...s]:void 0,u=()=>"function"==typeof s?s():f,g=a.default.tmpdir(),y=i?console.error:console.log,d=t.error??Oe,p=t.warn??Oe,b=t.info??Oe,h=t.debug??Oe,m=e=>Y(function(e,t){if(!t||t===l.default.sep)return e;const r=t.endsWith(l.default.sep)?t:t+l.default.sep,n=e.split(r);if(1===n.length)return e;let o=n[0];for(let e=1;e<n.length;e++){const t=o.length>0?o[o.length-1]:"";o+=(""!==t&&/[\w./\\~-]/.test(t)?r:je+l.default.sep)+n[e]}return o}(W(e,u()),g));return{level:3,handler:(t,i,s,f)=>{const a=!o&&(0===t||!n)&&(3!==t||("function"==typeof r?r():r)),l=e.onLine;if(!a&&!l)return;const g=a&&"json"===(("function"==typeof c?c():c)??"text"),v=f.length>0?`[${f.join(":")}] `:"",O=g||l?$e(t,i,s,f,m,u()):void 0,j=l||!g?(()=>{let e="";if(Object.keys(s).length>0)try{e=` ${JSON.stringify(s)}`}catch{e=" [unserializable context]"}return m(`${v}${i}${e}`)})():"";if(l&&O)try{l(t,j,O.entry)}catch{}a&&(g&&O?0===t||1===t?console.error(O.line):y(O.line):0===t?console.error(d(j)):y(3===t?` ${h(j)}`:1===t?p(j):b(j)))},jsonHandler:e=>{n||y(JSON.stringify(e,null,2))}}}function Se(e={},t={}){return b(we(e,t))}//# sourceMappingURL=node.js.map
|