@visulima/pail 4.0.0-alpha.20 → 4.0.0-alpha.22
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 +62 -0
- package/LICENSE.md +841 -6
- package/README.md +53 -24
- package/dist/error.js +2 -2
- package/dist/index.browser.d.ts +16 -5
- package/dist/index.browser.js +19 -19
- package/dist/index.server.d.ts +30 -5
- package/dist/index.server.js +28 -27
- package/dist/middleware/elysia.d.ts +5 -4
- package/dist/middleware/elysia.js +1 -1
- package/dist/middleware/express.d.ts +5 -4
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +5 -4
- package/dist/middleware/fastify.js +1 -1
- package/dist/middleware/hono.d.ts +5 -4
- package/dist/middleware/hono.js +1 -1
- package/dist/middleware/next/handler.d.ts +5 -4
- package/dist/middleware/next/handler.js +1 -1
- package/dist/middleware/sveltekit.d.ts +5 -4
- package/dist/middleware/sveltekit.js +1 -1
- package/dist/object-tree.js +2 -2
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-C6iu_u9-.js +1 -0
- package/dist/packem_shared/JsonReporter-BXktpC__.js +2 -0
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
- package/dist/packem_shared/PailError-CbU1Ogfa.js +5 -0
- package/dist/packem_shared/PrettyReporter-DNNseeLK.js +44 -0
- package/dist/packem_shared/PrettyReporter-DsHfKOU7.js +5 -0
- package/dist/packem_shared/{abstract-json-reporter.d-BAgznjyU.d.ts → abstract-json-reporter.d-wfESoEa-.d.ts} +3 -2
- package/dist/packem_shared/abstract-pretty-reporter-Bczvp2Zh.js +57 -0
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-f9no2VNI.js +25 -0
- package/dist/packem_shared/{create-middleware-logger.d-CR3o6VDh.d.ts → create-middleware-logger.d-B-JmQ1Sl.d.ts} +2 -2
- package/dist/packem_shared/headers-DH0H2s8W.js +1 -0
- package/dist/packem_shared/index-Q1764hvO.js +1 -0
- package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
- package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +1 -0
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
- package/dist/packem_shared/storage-DaXAlpiO.js +1 -0
- package/dist/packem_shared/{types.d-BeLumqgD.d.ts → types.d-bWnqHJKL.d.ts} +2 -37
- package/dist/packem_shared/useLogger-DB34CuU5.js +1 -0
- package/dist/packem_shared/{wide-event.d-gb2-ks5w.d.ts → wide-event.d-D3ATYpoK.d.ts} +17 -5
- package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
- package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +2 -1
- package/dist/processor/caller/caller-processor.js +1 -1
- package/dist/processor/environment-processor.d.ts +2 -1
- package/dist/processor/environment-processor.js +1 -1
- package/dist/processor/message-formatter-processor.d.ts +9 -1
- package/dist/processor/message-formatter-processor.js +1 -1
- package/dist/processor/opentelemetry-processor.d.ts +2 -1
- package/dist/processor/opentelemetry-processor.js +1 -1
- package/dist/processor/redact-processor.d.ts +41 -2
- package/dist/processor/redact-processor.js +1 -1
- package/dist/processor/sampling-processor.d.ts +2 -1
- package/dist/processor/sampling-processor.js +1 -1
- package/dist/reporter/file/json-file-reporter.d.ts +21 -3
- package/dist/reporter/file/json-file-reporter.js +2 -2
- package/dist/reporter/http/abstract-http-reporter.d.ts +46 -3
- package/dist/reporter/http/abstract-http-reporter.js +2 -2
- package/dist/reporter/http/http-reporter.d.ts +4 -3
- package/dist/reporter/http/http-reporter.edge-light.d.ts +57 -1
- package/dist/reporter/http/http-reporter.edge-light.js +2 -2
- package/dist/reporter/http/http-reporter.js +1 -1
- package/dist/reporter/json/index.browser.d.ts +1 -1
- package/dist/reporter/json/index.browser.js +1 -1
- package/dist/reporter/json/index.d.ts +6 -4
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +125 -5
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +87 -5
- package/dist/reporter/simple/simple-reporter.server.js +8 -8
- package/dist/wide-event.d.ts +4 -3
- package/dist/wide-event.js +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/AbstractJsonReporter-D_Pb6kpB.js +0 -1
- package/dist/packem_shared/AbstractJsonReporter-PVC4ONf2.js +0 -1
- package/dist/packem_shared/JsonReporter-BEEmb0W4.js +0 -2
- package/dist/packem_shared/JsonReporter-CE-lw7R0.js +0 -1
- package/dist/packem_shared/PrettyReporter-CDv9n1Fy.js +0 -5
- package/dist/packem_shared/PrettyReporter-CuFxJm_o.js +0 -44
- package/dist/packem_shared/abstract-pretty-reporter-BpyhtAoN.js +0 -33
- package/dist/packem_shared/createPailError-53jAfQ-T.js +0 -5
- package/dist/packem_shared/headers-S8WyX-2m.js +0 -1
- package/dist/packem_shared/index-Dwp5v97D.js +0 -1
- package/dist/packem_shared/pailMiddleware-CWOJRmJq.js +0 -1
- package/dist/packem_shared/storage-DHM1EP2P.js +0 -1
- package/dist/packem_shared/useLogger-qyZrjy4D.js +0 -1
- package/dist/packem_shared/write-console-log-based-on-level-DfD64owL.js +0 -1
- package/dist/packem_shared/write-stream-Dd4_PTcm.js +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { E as ExtendedRfc5424LogLevels, S as StringifyAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
3
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
|
|
3
4
|
import '@visulima/colorize';
|
|
4
5
|
import '@visulima/interactive-manager';
|
|
5
|
-
import
|
|
6
|
+
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
6
7
|
/**
|
|
7
8
|
* Configuration options for the HTTP reporter.
|
|
8
9
|
*/
|
|
@@ -76,6 +77,13 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
76
77
|
*/
|
|
77
78
|
maxPayloadSize?: number;
|
|
78
79
|
/**
|
|
80
|
+
* Maximum number of entries to keep queued while the endpoint is unavailable.
|
|
81
|
+
* When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
|
|
82
|
+
* so a sustained outage cannot grow memory without bound.
|
|
83
|
+
* @default 10000
|
|
84
|
+
*/
|
|
85
|
+
maxQueueSize?: number;
|
|
86
|
+
/**
|
|
79
87
|
* Number of retry attempts before giving up
|
|
80
88
|
* @default 3
|
|
81
89
|
*/
|
|
@@ -107,6 +115,11 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
107
115
|
};
|
|
108
116
|
}) => void;
|
|
109
117
|
/**
|
|
118
|
+
* Optional callback invoked when queued log entries are dropped because the queue
|
|
119
|
+
* exceeded `maxQueueSize`. Receives the number of dropped entries.
|
|
120
|
+
*/
|
|
121
|
+
onDrop?: (droppedCount: number) => void;
|
|
122
|
+
/**
|
|
110
123
|
* Optional callback for error handling
|
|
111
124
|
*/
|
|
112
125
|
onError?: (error: Error) => void;
|
|
@@ -142,12 +155,15 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
142
155
|
* @template L - The log level type
|
|
143
156
|
*/
|
|
144
157
|
declare abstract class AbstractHttpReporter<L extends string = string> extends AbstractJsonReporter<L> implements StringifyAwareReporter<L> {
|
|
158
|
+
#private;
|
|
145
159
|
protected url: string;
|
|
146
160
|
protected method: string;
|
|
147
161
|
protected headers: Record<string, string> | (() => Record<string, string>);
|
|
148
162
|
protected contentType: string;
|
|
149
163
|
protected batchContentType: string;
|
|
150
164
|
protected onError?: (error: Error) => void;
|
|
165
|
+
protected onDrop?: (droppedCount: number) => void;
|
|
166
|
+
protected maxQueueSize: number;
|
|
151
167
|
protected onDebug?: (entry: Record<string, unknown>) => void;
|
|
152
168
|
protected onDebugRequestResponse?: (requestResponse: {
|
|
153
169
|
req: {
|
|
@@ -191,6 +207,33 @@ declare abstract class AbstractHttpReporter<L extends string = string> extends A
|
|
|
191
207
|
*/
|
|
192
208
|
constructor(config: AbstractHttpReporterOptions);
|
|
193
209
|
/**
|
|
210
|
+
* Flushes all queued log entries to the HTTP endpoint immediately.
|
|
211
|
+
*
|
|
212
|
+
* Returns a promise that resolves once the queue has been drained (or rejects
|
|
213
|
+
* if a batch send fails terminally). Use this before a serverless function or
|
|
214
|
+
* short-lived process exits so the tail of the batch is not lost.
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* await reporter.flush();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
flush(): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Flushes any remaining queued entries and clears pending timers.
|
|
223
|
+
*
|
|
224
|
+
* Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
|
|
225
|
+
* the reporter can still be used, but any pending batch timeout is cleared.
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* process.on("beforeExit", () => reporter.close());
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
close(): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Alias for {@link close} to match common transport `dispose` conventions.
|
|
234
|
+
*/
|
|
235
|
+
dispose(): Promise<void>;
|
|
236
|
+
/**
|
|
194
237
|
* Processes and ships log entries to the HTTP endpoint.
|
|
195
238
|
* @param message The JSON-formatted log message
|
|
196
239
|
* @param logLevel The log level of the message
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`,this.batchMode=
|
|
1
|
+
import{createRequire as S}from"node:module";import{AbstractJsonReporter as w}from"../../packem_shared/AbstractJsonReporter-C6iu_u9-.js";const T=S(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=i=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,e]=m.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return m.getBuiltinModule(i)}return T(i)},{Buffer:g}=f("node:buffer"),{gzipSync:x}=f("node:zlib"),z=async i=>{const t=globalThis.CompressionStream;if(t){const e=new t("gzip"),s=e.writable.getWriter(),a=e.readable.getReader(),o=new TextEncoder,n=[];await s.write(o.encode(i)),await s.close();let u=!1;for(;!u;){const h=await a.read();u=h.done,h.value&&n.push(h.value)}const c=n.reduce((h,d)=>h+d.length,0),r=new Uint8Array(c);let l=0;for(let h=0;h<n.length;h+=1){const d=n[h];r.set(d,l),l+=d.length}return r}return x(i)};class D extends Error{logData;actualSize;maxSize;constructor(t,e,s,a){super(t),this.name="LogSizeError",this.logData=e,this.actualSize=s,this.maxSize=a}}const b=(i,t)=>i*2**t,B=/^\d+$/,E=i=>{const t=i.trim();if(B.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,6e4)}const e=Date.parse(t);if(Number.isNaN(e))return;const s=e-Date.now();return Math.min(Math.max(s,0),6e4)},y=i=>new Promise(t=>{setTimeout(t,i)}),R=i=>typeof i=="string"?i:new Uint8Array(i.buffer,i.byteOffset,i.byteLength),P=async(i,t,e,s,a,o,n)=>{const u={};i.headers.forEach((l,h)=>{u[h]=l});const c=await i.text(),r={req:{body:a,headers:s,method:e,url:t},res:{body:c,headers:u,status:i.status,statusText:i.statusText}};if(o&&o(r),i.ok)return!1;if(i.status<500&&i.status!==429){const l=new Error(`HTTP ${String(i.status)}: ${i.statusText}`);throw n&&n(l),l}return!0},Q=(i,t,e,s,a)=>{if(i.status===429&&t&&s<a){const o=i.headers.get("retry-after");return(o?E(o):void 0)??b(e,s)}},L=(i,t,e,s)=>{if(i.status>=500&&e<s)return b(t,e)},N=(i,t,e,s,a)=>{const o=Q(i,t,e,s,a);return o!==void 0?o:L(i,e,s,a)},v=async(i,t,e,s,a)=>{if(t<e){const o=b(s,t);return await y(o),!0}return a&&a(i),!1},_=async(i,t,e,s,a,o,n,u,c)=>{let r=0;for(;r<=a;)try{const l=R(s),h=await fetch(i,{body:l,headers:e,method:t});if(!await P(h,i,t,e,s,u,c))return;const d=N(h,n,o,r,a);if(d!==void 0){await y(d),r+=1;continue}if(!h.ok){const p=new Error(`HTTP ${String(h.status)}: ${h.statusText}`);throw c&&c(p),p}return}catch(l){if(await v(l,r,a,o,c)){r+=1;continue}throw l}};class $ extends w{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDrop=t.onDrop,this.maxQueueSize=t.maxQueueSize??1e4,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(e=>JSON.stringify(e)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
|
|
2
|
+
`,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(t=>setTimeout(t,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(t,e){try{const s=JSON.parse(t),a=e,o=s.message,n={logLevel:a,message:o??""};if(s.data)n.data=s.data;else if(s.context)n.data=s.context;else{const r={...s};delete r.message,Object.keys(r).length>0&&(n.data=r)}const u=this.payloadTemplate(n);this.onDebug&&this.onDebug({data:n.data,logLevel:a,message:o});const c=this.edgeCompat||typeof TextEncoder>"u"?g.byteLength(u,"utf8"):new TextEncoder().encode(u).length;if(c>this.maxLogSize){const r=new D(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(c)} bytes`,{data:n.data,logLevel:a,message:o},c,this.maxLogSize);this.onError&&this.onError(r);return}this.enableBatchSend?this.addToBatch(u,c):this.sendPayload(u).catch(r=>{this.onError&&this.onError(r)})}catch(s){this.onError&&this.onError(s)}}addToBatch(t,e){const s=this.currentBatchSize+e+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(s>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.currentBatchSize+=e+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const o=this.batchQueue.splice(0,this.batchQueue.length-this.maxQueueSize);this.currentBatchSize=this.#t(),this.onDrop&&this.onDrop(o.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#t(){let t=0;for(let e=0;e<this.batchQueue.length;e+=1){const s=this.batchQueue[e],a=this.edgeCompat||typeof TextEncoder>"u"?g.byteLength(s,"utf8"):new TextEncoder().encode(s).length;t+=a+(e<this.batchQueue.length-1?this.batchSendDelimiter.length:0)}return t}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.currentBatchSize=this.#t();try{await this.sendBatch(t)}catch(e){this.onError&&this.onError(e)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let e;switch(this.batchMode){case"array":{const s=t.map(a=>JSON.parse(a));e=JSON.stringify(s);break}case"field":{const s=t.map(o=>JSON.parse(o)),a=this.batchFieldName?{[this.batchFieldName]:s}:{};e=JSON.stringify(a);break}default:{e=t.join(this.batchSendDelimiter);break}}await this.sendPayload(e,this.batchContentType)}async sendPayload(t,e){const s=typeof this.headers=="function"?this.headers():{...this.headers};s["content-type"]??=e??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await z(t),s["content-encoding"]="gzip"}catch(o){this.onError&&this.onError(new Error(`Compression failed: ${String(o)}`))}await _(this.url,this.method,s,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}export{$ as AbstractHttpReporter};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AbstractHttpReporterOptions, AbstractHttpReporter } from "./abstract-http-reporter.js";
|
|
2
|
-
import
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
import "../../packem_shared/types.d-bWnqHJKL.js";
|
|
3
4
|
import '@visulima/colorize';
|
|
4
5
|
import '@visulima/interactive-manager';
|
|
5
|
-
import "../../packem_shared/abstract-json-reporter.d-
|
|
6
|
-
import
|
|
6
|
+
import "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
|
|
7
|
+
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
7
8
|
/**
|
|
8
9
|
* HTTP Reporter.
|
|
9
10
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '@visulima/colorize';
|
|
2
2
|
import '@visulima/interactive-manager';
|
|
3
|
-
import { stringify } from 'safe-stable-stringify';
|
|
4
3
|
/**
|
|
5
4
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
6
5
|
|
|
@@ -123,6 +122,21 @@ interface StringifyAwareReporter<L extends string> extends Reporter<L> {
|
|
|
123
122
|
/** Set the stringify function for object serialization */
|
|
124
123
|
setStringify: (stringify: any) => void;
|
|
125
124
|
}
|
|
125
|
+
type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object);
|
|
126
|
+
declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined;
|
|
127
|
+
declare function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string;
|
|
128
|
+
declare function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined;
|
|
129
|
+
declare namespace stringify {
|
|
130
|
+
export function configure(options: StringifyOptions): typeof stringify;
|
|
131
|
+
}
|
|
132
|
+
interface StringifyOptions {
|
|
133
|
+
bigint?: boolean;
|
|
134
|
+
circularValue?: string | null | TypeErrorConstructor | ErrorConstructor;
|
|
135
|
+
deterministic?: boolean | ((a: string, b: string) => number);
|
|
136
|
+
maximumBreadth?: number;
|
|
137
|
+
maximumDepth?: number;
|
|
138
|
+
strict?: boolean;
|
|
139
|
+
}
|
|
126
140
|
/**
|
|
127
141
|
* Options for configuring JSON reporters.
|
|
128
142
|
*/
|
|
@@ -254,6 +268,13 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
254
268
|
*/
|
|
255
269
|
maxPayloadSize?: number;
|
|
256
270
|
/**
|
|
271
|
+
* Maximum number of entries to keep queued while the endpoint is unavailable.
|
|
272
|
+
* When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
|
|
273
|
+
* so a sustained outage cannot grow memory without bound.
|
|
274
|
+
* @default 10000
|
|
275
|
+
*/
|
|
276
|
+
maxQueueSize?: number;
|
|
277
|
+
/**
|
|
257
278
|
* Number of retry attempts before giving up
|
|
258
279
|
* @default 3
|
|
259
280
|
*/
|
|
@@ -285,6 +306,11 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
285
306
|
};
|
|
286
307
|
}) => void;
|
|
287
308
|
/**
|
|
309
|
+
* Optional callback invoked when queued log entries are dropped because the queue
|
|
310
|
+
* exceeded `maxQueueSize`. Receives the number of dropped entries.
|
|
311
|
+
*/
|
|
312
|
+
onDrop?: (droppedCount: number) => void;
|
|
313
|
+
/**
|
|
288
314
|
* Optional callback for error handling
|
|
289
315
|
*/
|
|
290
316
|
onError?: (error: Error) => void;
|
|
@@ -320,12 +346,15 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
320
346
|
* @template L - The log level type
|
|
321
347
|
*/
|
|
322
348
|
declare abstract class AbstractHttpReporter<L extends string = string> extends AbstractJsonReporter<L> implements StringifyAwareReporter<L> {
|
|
349
|
+
#private;
|
|
323
350
|
protected url: string;
|
|
324
351
|
protected method: string;
|
|
325
352
|
protected headers: Record<string, string> | (() => Record<string, string>);
|
|
326
353
|
protected contentType: string;
|
|
327
354
|
protected batchContentType: string;
|
|
328
355
|
protected onError?: (error: Error) => void;
|
|
356
|
+
protected onDrop?: (droppedCount: number) => void;
|
|
357
|
+
protected maxQueueSize: number;
|
|
329
358
|
protected onDebug?: (entry: Record<string, unknown>) => void;
|
|
330
359
|
protected onDebugRequestResponse?: (requestResponse: {
|
|
331
360
|
req: {
|
|
@@ -369,6 +398,33 @@ declare abstract class AbstractHttpReporter<L extends string = string> extends A
|
|
|
369
398
|
*/
|
|
370
399
|
constructor(config: AbstractHttpReporterOptions);
|
|
371
400
|
/**
|
|
401
|
+
* Flushes all queued log entries to the HTTP endpoint immediately.
|
|
402
|
+
*
|
|
403
|
+
* Returns a promise that resolves once the queue has been drained (or rejects
|
|
404
|
+
* if a batch send fails terminally). Use this before a serverless function or
|
|
405
|
+
* short-lived process exits so the tail of the batch is not lost.
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* await reporter.flush();
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
flush(): Promise<void>;
|
|
412
|
+
/**
|
|
413
|
+
* Flushes any remaining queued entries and clears pending timers.
|
|
414
|
+
*
|
|
415
|
+
* Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
|
|
416
|
+
* the reporter can still be used, but any pending batch timeout is cleared.
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* process.on("beforeExit", () => reporter.close());
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
close(): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Alias for {@link close} to match common transport `dispose` conventions.
|
|
425
|
+
*/
|
|
426
|
+
dispose(): Promise<void>;
|
|
427
|
+
/**
|
|
372
428
|
* Processes and ships log entries to the HTTP endpoint.
|
|
373
429
|
* @param message The JSON-formatted log message
|
|
374
430
|
* @param logLevel The log level of the message
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`,this.batchMode=e.batchMode??"delimiter",this.batchFieldName=e.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=e.maxLogSize??1048576,this.maxPayloadSize=e.maxPayloadSize??5242880,this.edgeCompat=e.edgeCompat??!1}_log(e,
|
|
1
|
+
import{createRequire as N}from"node:module";const z=N(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,r]=d.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return d.getBuiltinModule(t)}return z(t)},{Buffer:E}=S("node:buffer"),{createRequire:P}=S("node:module"),{gzipSync:B}=S("node:zlib"),R=P(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=t=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,r]=p.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return p.getBuiltinModule(t)}return R(t)};_("node:util");const L=P(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,r]=m.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return m.getBuiltinModule(t)}return L(t)};T("node:fs");T("node:path");T("node:url");const M=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&M.set("AggregateError",AggregateError);const $=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),Q=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null},y=new WeakSet,j=t=>{const e=Object.getOwnPropertyNames(t);for(const r of e){const s=Object.getOwnPropertyDescriptor(t,r);s&&(s.enumerable||Object.defineProperty(t,r,{...s,enumerable:!0}),s.value&&typeof s.value=="object"&&!Array.isArray(s.value)&&(Object.getPrototypeOf(s.value)===Object.prototype||Object.getPrototypeOf(s.value)===null)&&j(s.value))}},A=t=>{y.add(t);const e=t.toJSON();return y.delete(t),Object.isExtensible(e)&&j(e),e},b=(t,e,r,s,o=new Set)=>{if(t&&t instanceof Uint8Array&&t.constructor.name==="Buffer")return"[object Buffer]";if(t!==null&&typeof t=="object"&&"pipe"in t&&typeof t.pipe=="function")return"[object Stream]";if(t instanceof Error)return e.has(t)?"[Circular]":(r+=1,g(t,s,e,r));if(s.useToJSON&&t!==null&&typeof t=="object"&&"toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return t.toString();if(typeof URL<"u"&&t instanceof URL)return t.href;if(t instanceof Map){const i=[];for(const[a,n]of t.entries())i.push([b(a,e,r,s,o),b(n,e,r,s,o)]);return{__dataType:"Map",value:i}}if(t instanceof Set){const i=[];for(const a of t.values())i.push(b(a,e,r,s,o));return{__dataType:"Set",value:i}}if(typeof t=="function")return`[Function: ${t.name||"anonymous"}]`;if(typeof t=="bigint")return`${String(t)}n`;if(Q(t)){if(o.has(t))return"[Circular]";if(s.maxDepth!==void 0&&s.maxDepth!==Number.POSITIVE_INFINITY&&r+1>=s.maxDepth)return{};r+=1,o.add(t);const i={};for(const a in t)i[a]=b(t[a],e,r,s,o);return o.delete(t),i}try{return t}catch{return"[Not Available]"}},g=(t,e,r,s)=>{if(r.add(t),e.maxDepth===0)return{};if(e.useToJSON&&typeof t.toJSON=="function"&&!y.has(t))return A(t);const o=Object.create($);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(t.constructor)==="[object Function]"?t.constructor.name:t.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:t.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:t.stack,writable:!0}),Array.isArray(t.errors)){const a=[];for(const n of t.errors){if(!(n instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.has(n))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;a.push(g(n,e,r,s))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:a,writable:!0})}const i=t.cause;if(i!=null)if(i instanceof Error)r.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:g(i,e,r,s),writable:!0});else{const a=b(i,r,s,e);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:a,writable:!0})}for(const a in t){if(a==="name"||a==="message"||a==="stack"||a==="cause"||a==="errors")continue;const n=t[a],u=b(n,r,s,e);Object.defineProperty(o,a,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(e.exclude)&&e.exclude.length>0)for(const a of e.exclude)try{delete o[a]}catch{}return o},v=(t,e={})=>g(t,{exclude:e.exclude??[],maxDepth:e.maxDepth??Number.POSITIVE_INFINITY,useToJSON:e.useToJSON??!1},new Set,0),O=Symbol("EMPTY");class C{stringify;errorOptions;constructor(e={}){this.errorOptions=e.error??{}}setStringify(e){this.stringify=e}log(e){const{context:r,error:s,file:o,message:i,type:a,...n}=e;if(n.label&&(n.label=n.label.trim()),o&&(n.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),n.message=i===O?void 0:i,s&&(n.error=v(s,this.errorOptions)),r){const u=[];for(let c=0;c<r.length;c+=1){const h=r[c];h!==O&&(h instanceof Error?u.push(v(h,this.errorOptions)):u.push(h))}n.context=u}this._log(this.stringify(n),a.level)}}const J=async t=>{const e=globalThis.CompressionStream;if(e){const r=new e("gzip"),s=r.writable.getWriter(),o=r.readable.getReader(),i=new TextEncoder,a=[];await s.write(i.encode(t)),await s.close();let n=!1;for(;!n;){const l=await o.read();n=l.done,l.value&&a.push(l.value)}const u=a.reduce((l,f)=>l+f.length,0),c=new Uint8Array(u);let h=0;for(let l=0;l<a.length;l+=1){const f=a[l];c.set(f,h),h+=f.length}return c}return B(t)};class I extends Error{logData;actualSize;maxSize;constructor(e,r,s,o){super(e),this.name="LogSizeError",this.logData=r,this.actualSize=s,this.maxSize=o}}const w=(t,e)=>t*2**e,k=/^\d+$/,F=t=>{const e=t.trim();if(k.test(e)){const o=Number.parseInt(e,10);return Math.min(Math.max(o,0)*1e3,6e4)}const r=Date.parse(e);if(Number.isNaN(r))return;const s=r-Date.now();return Math.min(Math.max(s,0),6e4)},D=t=>new Promise(e=>{setTimeout(e,t)}),q=t=>typeof t=="string"?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),U=async(t,e,r,s,o,i,a)=>{const n={};t.headers.forEach((h,l)=>{n[l]=h});const u=await t.text(),c={req:{body:o,headers:s,method:r,url:e},res:{body:u,headers:n,status:t.status,statusText:t.statusText}};if(i&&i(c),t.ok)return!1;if(t.status<500&&t.status!==429){const h=new Error(`HTTP ${String(t.status)}: ${t.statusText}`);throw a&&a(h),h}return!0},Y=(t,e,r,s,o)=>{if(t.status===429&&e&&s<o){const i=t.headers.get("retry-after");return(i?F(i):void 0)??w(r,s)}},H=(t,e,r,s)=>{if(t.status>=500&&r<s)return w(e,r)},V=(t,e,r,s,o)=>{const i=Y(t,e,r,s,o);return i!==void 0?i:H(t,r,s,o)},W=async(t,e,r,s,o)=>{if(e<r){const i=w(s,e);return await D(i),!0}return o&&o(t),!1},G=async(t,e,r,s,o,i,a,n,u)=>{let c=0;for(;c<=o;)try{const h=q(s),l=await fetch(t,{body:h,headers:r,method:e});if(!await U(l,t,e,r,s,n,u))return;const f=V(l,a,i,c,o);if(f!==void 0){await D(f),c+=1;continue}if(!l.ok){const x=new Error(`HTTP ${String(l.status)}: ${l.statusText}`);throw u&&u(x),x}return}catch(h){if(await W(h,c,o,i,u)){c+=1;continue}throw h}};class K extends C{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(e){if(super(e),this.url=e.url,this.method=e.method??"POST",this.headers=e.headers??{},this.contentType=e.contentType??"application/json",this.batchContentType=e.batchContentType??"application/json",this.onError=e.onError,this.onDrop=e.onDrop,this.maxQueueSize=e.maxQueueSize??1e4,this.onDebug=e.onDebug,this.onDebugRequestResponse=e.onDebugRequestResponse,this.payloadTemplate=e.payloadTemplate??(r=>JSON.stringify(r)),this.compression=e.compression??!1,this.maxRetries=e.maxRetries??3,this.retryDelay=e.retryDelay??1e3,this.respectRateLimit=e.respectRateLimit??!0,this.enableBatchSend=e.enableBatchSend??!0,this.batchSize=e.batchSize??100,this.batchSendTimeout=e.batchSendTimeout??5e3,this.batchSendDelimiter=e.batchSendDelimiter??`
|
|
2
|
+
`,this.batchMode=e.batchMode??"delimiter",this.batchFieldName=e.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=e.maxLogSize??1048576,this.maxPayloadSize=e.maxPayloadSize??5242880,this.edgeCompat=e.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(e=>setTimeout(e,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(e,r){try{const s=JSON.parse(e),o=r,i=s.message,a={logLevel:o,message:i??""};if(s.data)a.data=s.data;else if(s.context)a.data=s.context;else{const c={...s};delete c.message,Object.keys(c).length>0&&(a.data=c)}const n=this.payloadTemplate(a);this.onDebug&&this.onDebug({data:a.data,logLevel:o,message:i});const u=this.edgeCompat||typeof TextEncoder>"u"?E.byteLength(n,"utf8"):new TextEncoder().encode(n).length;if(u>this.maxLogSize){const c=new I(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:a.data,logLevel:o,message:i},u,this.maxLogSize);this.onError&&this.onError(c);return}this.enableBatchSend?this.addToBatch(n,u):this.sendPayload(n).catch(c=>{this.onError&&this.onError(c)})}catch(s){this.onError&&this.onError(s)}}addToBatch(e,r){const s=this.currentBatchSize+r+this.batchSendDelimiter.length,o=this.maxPayloadSize*.9;if(s>o&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(e),this.currentBatchSize+=r+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const i=this.batchQueue.splice(0,this.batchQueue.length-this.maxQueueSize);this.currentBatchSize=this.#e(),this.onDrop&&this.onDrop(i.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#e(){let e=0;for(let r=0;r<this.batchQueue.length;r+=1){const s=this.batchQueue[r],o=this.edgeCompat||typeof TextEncoder>"u"?E.byteLength(s,"utf8"):new TextEncoder().encode(s).length;e+=o+(r<this.batchQueue.length-1?this.batchSendDelimiter.length:0)}return e}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const e=this.batchQueue.splice(0,this.batchSize);this.currentBatchSize=this.#e();try{await this.sendBatch(e)}catch(r){this.onError&&this.onError(r)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(e){let r;switch(this.batchMode){case"array":{const s=e.map(o=>JSON.parse(o));r=JSON.stringify(s);break}case"field":{const s=e.map(i=>JSON.parse(i)),o=this.batchFieldName?{[this.batchFieldName]:s}:{};r=JSON.stringify(o);break}default:{r=e.join(this.batchSendDelimiter);break}}await this.sendPayload(r,this.batchContentType)}async sendPayload(e,r){const s=typeof this.headers=="function"?this.headers():{...this.headers};s["content-type"]??=r??this.contentType;let o=e;if(this.compression&&!this.edgeCompat)try{o=await J(e),s["content-encoding"]="gzip"}catch(i){this.onError&&this.onError(new Error(`Compression failed: ${String(i)}`))}await G(this.url,this.method,s,o,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class Z extends K{constructor(e){super({...e,edgeCompat:!0})}}export{Z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{AbstractHttpReporter as r}from"./abstract-http-reporter.js";class o extends r{constructor(t){super(t)}}export{o as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringify } from
|
|
1
|
+
import { s as stringify } from "../../packem_shared/index.d-T71KjNAr.js";
|
|
2
2
|
import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, L as LiteralUnion, S as StringifyAwareReporter } from "../../packem_shared/types.d-xxE3FOD3.js";
|
|
3
3
|
import '@visulima/colorize';
|
|
4
4
|
import '@visulima/interactive-manager';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-Bp_JCrMQ.js";import{default as p}from"../../packem_shared/JsonReporter-bmem9lcg.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { E as ExtendedRfc5424LogLevels, a as StreamAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
4
|
+
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
4
5
|
import '@visulima/colorize';
|
|
5
6
|
import '@visulima/interactive-manager';
|
|
6
7
|
/**
|
|
@@ -41,7 +42,8 @@ declare class JsonReporter<L extends string = string> extends AbstractJsonReport
|
|
|
41
42
|
/**
|
|
42
43
|
* Outputs the JSON message to the appropriate stream.
|
|
43
44
|
*
|
|
44
|
-
* Routes
|
|
45
|
+
* Routes high-severity RFC 5424 levels (warning/error/critical/alert/emergency/trace)
|
|
46
|
+
* to stderr, others to stdout.
|
|
45
47
|
* @param message The JSON-formatted log message
|
|
46
48
|
* @param logLevel The log level determining which stream to use
|
|
47
49
|
* @protected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-C6iu_u9-.js";import{default as p}from"../../packem_shared/JsonReporter-BXktpC__.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as t}from"../../packem_shared/PrettyReporter-
|
|
1
|
+
import{default as t}from"../../packem_shared/PrettyReporter-DsHfKOU7.js";export{t as PrettyReporter};
|
|
@@ -1,18 +1,133 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { L as LiteralUnion, D as DefaultLogTypes, c as LoggerTypesConfig, R as ReadonlyMeta, f as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-BeLumqgD.js";
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
2
|
import { InteractiveManager } from '@visulima/interactive-manager';
|
|
3
|
+
import { D as DefaultLogTypes, c as LoggerTypesConfig, R as ReadonlyMeta, e as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
4
4
|
import '@visulima/colorize';
|
|
5
|
+
type ColorizeMethod = (value: string) => string;
|
|
6
|
+
type CodeFrameOptions = {
|
|
7
|
+
color?: {
|
|
8
|
+
gutter?: ColorizeMethod;
|
|
9
|
+
marker?: ColorizeMethod;
|
|
10
|
+
message?: ColorizeMethod;
|
|
11
|
+
};
|
|
12
|
+
linesAbove?: number;
|
|
13
|
+
linesBelow?: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
showGutter?: boolean;
|
|
17
|
+
showLineNumbers?: boolean;
|
|
18
|
+
tabWidth?: number | false;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The compiled position of a stack frame handed to a {@link SourceMapResolver}.
|
|
22
|
+
*/
|
|
23
|
+
interface SourceMapLocation {
|
|
24
|
+
column?: number;
|
|
25
|
+
file: string;
|
|
26
|
+
line: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The resolved original position returned by a {@link SourceMapResolver}. Any omitted field falls
|
|
30
|
+
* back to the compiled value. `source`, when provided, is used directly as the code-frame content
|
|
31
|
+
* (e.g. from an inlined `sourcesContent`) instead of reading the resolved file from disk.
|
|
32
|
+
*/
|
|
33
|
+
interface ResolvedSourceLocation {
|
|
34
|
+
column?: number;
|
|
35
|
+
file?: string;
|
|
36
|
+
line?: number;
|
|
37
|
+
source?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pluggable hook that maps a compiled `*.js:line:col` position back to its original source position
|
|
41
|
+
* (e.g. TS/JSX). Return `undefined` (or throw) to leave the frame untouched. Synchronous so it can
|
|
42
|
+
* be used by the synchronous `renderError`; resolve/inline your maps ahead of time.
|
|
43
|
+
*/
|
|
44
|
+
type SourceMapResolver = (location: SourceMapLocation) => ResolvedSourceLocation | undefined;
|
|
45
|
+
type Options$1 = {
|
|
46
|
+
/**
|
|
47
|
+
* Read source files for code frames from anywhere on disk, including absolute paths outside
|
|
48
|
+
* `cwd`. Defaults to `false`, in which case only files resolving inside `cwd` are read — this
|
|
49
|
+
* prevents local file disclosure when rendering errors whose stack came from untrusted input
|
|
50
|
+
* (e.g. a deserialized error). Enable only for trusted, locally-thrown errors.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
allowAllFilePaths: boolean;
|
|
54
|
+
color: CodeFrameOptions["color"] & {
|
|
55
|
+
fileLine: ColorizeMethod;
|
|
56
|
+
hint: ColorizeMethod;
|
|
57
|
+
method: ColorizeMethod;
|
|
58
|
+
title: ColorizeMethod;
|
|
59
|
+
};
|
|
60
|
+
cwd: string;
|
|
61
|
+
displayShortPath: boolean;
|
|
62
|
+
filterStacktrace: ((line: string) => boolean) | undefined;
|
|
63
|
+
framesMaxLimit: number;
|
|
64
|
+
hideErrorCauseCodeView: boolean;
|
|
65
|
+
hideErrorCodeView: boolean;
|
|
66
|
+
hideErrorErrorsCodeView: boolean;
|
|
67
|
+
hideErrorTitle: boolean;
|
|
68
|
+
hideMessage: boolean;
|
|
69
|
+
indentation: number | " ";
|
|
70
|
+
prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
|
|
71
|
+
sourceMap?: SourceMapResolver;
|
|
72
|
+
} & Omit<CodeFrameOptions, "message | prefix">;
|
|
5
73
|
interface Options {
|
|
6
|
-
|
|
74
|
+
/**
|
|
75
|
+
* When `true`, honour custom inspectors: a value's
|
|
76
|
+
* `Symbol.for("nodejs.util.inspect.custom")` method (Node only),
|
|
77
|
+
* `Symbol.for("chai/inspect")` method, an `.inspect()` method, or a handler
|
|
78
|
+
* registered via `registerConstructor` / `registerStringTag`.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
7
81
|
customInspect: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum nesting depth to traverse before collapsing a nested value to
|
|
84
|
+
* `[Object]` / `[Array]`. A value `<= 0` disables the limit.
|
|
85
|
+
* @default 5
|
|
86
|
+
*/
|
|
8
87
|
depth: number;
|
|
88
|
+
/**
|
|
89
|
+
* Pretty-print with indentation. `"\t"` indents with tabs, a positive integer
|
|
90
|
+
* indents with that many spaces, and `undefined` keeps everything on one line.
|
|
91
|
+
* @default undefined
|
|
92
|
+
*/
|
|
9
93
|
indent: number | " " | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum number of array / typed-array / iterable elements to render
|
|
96
|
+
* before the remainder is replaced with an `… (N more)` marker. Use
|
|
97
|
+
* `Number.POSITIVE_INFINITY` to show every element.
|
|
98
|
+
* @default Number.POSITIVE_INFINITY
|
|
99
|
+
*/
|
|
10
100
|
maxArrayLength: number;
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, render large numbers and bigints with `_` digit-group
|
|
103
|
+
* separators (e.g. `1_000_000`).
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
11
106
|
numericSeparator: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The quote character used when rendering string values and complex object
|
|
109
|
+
* keys.
|
|
110
|
+
* @default "single"
|
|
111
|
+
*/
|
|
12
112
|
quoteStyle: "double" | "single";
|
|
113
|
+
/**
|
|
114
|
+
* When `true`, also render non-enumerable own properties of plain objects
|
|
115
|
+
* (mirrors `util.inspect`'s `showHidden`).
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
13
118
|
showHidden: boolean;
|
|
14
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Colourize / decorate a rendered fragment. Receives the raw fragment and a
|
|
121
|
+
* style hint and must return the (optionally wrapped) string. Defaults to the
|
|
122
|
+
* identity function.
|
|
123
|
+
*/
|
|
15
124
|
stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
|
|
125
|
+
/**
|
|
126
|
+
* The maximum length (in characters) of a single rendered value before it is
|
|
127
|
+
* truncated with an ellipsis. Use `Number.POSITIVE_INFINITY` to disable
|
|
128
|
+
* truncation.
|
|
129
|
+
* @default Number.POSITIVE_INFINITY
|
|
130
|
+
*/
|
|
16
131
|
truncate: number;
|
|
17
132
|
}
|
|
18
133
|
/**
|
|
@@ -89,7 +204,7 @@ type PrettyStyleOptions = {
|
|
|
89
204
|
*/
|
|
90
205
|
type PrettyReporterOptions = PrettyStyleOptions & {
|
|
91
206
|
/** Error rendering options */
|
|
92
|
-
error: Partial<Omit<
|
|
207
|
+
error: Partial<Omit<Options$1, "color" | "prefix" | "indentation">>;
|
|
93
208
|
/** Object inspection options */
|
|
94
209
|
inspect: Partial<Options>;
|
|
95
210
|
};
|
|
@@ -124,6 +239,11 @@ declare class PrettyReporter<T extends string = string, L extends string = strin
|
|
|
124
239
|
*/
|
|
125
240
|
constructor(options?: Partial<PrettyReporterOptions>);
|
|
126
241
|
/**
|
|
242
|
+
* Sets the logger types configuration and refreshes cached badge/label widths.
|
|
243
|
+
* @param types Logger type configurations with colors and labels
|
|
244
|
+
*/
|
|
245
|
+
override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
246
|
+
/**
|
|
127
247
|
* Sets the stdout stream for the reporter.
|
|
128
248
|
* @param stdout_ The writable stream to use for standard output
|
|
129
249
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-
|
|
1
|
+
import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-DNNseeLK.js";export{t as PrettyReporter};
|