@visulima/pail 4.0.2 → 4.1.0
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 +14 -0
- package/LICENSE.md +346 -0
- package/README.md +17 -0
- package/dist/error.d.ts +69 -69
- package/dist/index.browser.d.ts +446 -445
- package/dist/index.browser.js +17 -17
- package/dist/index.server.d.ts +582 -582
- package/dist/index.server.js +27 -27
- package/dist/middleware/elysia.d.ts +44 -42
- package/dist/middleware/elysia.js +1 -1
- package/dist/middleware/express.d.ts +58 -59
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +55 -56
- package/dist/middleware/fastify.js +1 -1
- package/dist/middleware/hono.d.ts +56 -57
- package/dist/middleware/hono.js +1 -1
- package/dist/middleware/next/handler.d.ts +67 -68
- package/dist/middleware/next/handler.js +1 -1
- package/dist/middleware/sveltekit.d.ts +72 -73
- package/dist/middleware/sveltekit.js +1 -1
- package/dist/object-tree.d.ts +44 -44
- package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +1 -0
- package/dist/packem_shared/JsonReporter-9IcELa1m.js +2 -0
- package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +1 -0
- package/dist/packem_shared/{PrettyReporter-DsHfKOU7.js → PrettyReporter-BUWNEg3_.js} +1 -1
- package/dist/packem_shared/{PrettyReporter-CcDdPQSt.js → PrettyReporter-DbgD89ck.js} +56 -30
- package/dist/packem_shared/abstract-json-reporter.d-B6NoO-hG.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-DrLBJ6ds.js → abstract-pretty-reporter-CyfTvmKf.js} +41 -39
- package/dist/packem_shared/create-middleware-logger.d-BRkkBMlk.d.ts +47 -0
- package/dist/packem_shared/headers-DI58djdG.js +1 -0
- package/dist/packem_shared/index-CbkPnylC.js +1 -0
- package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +1 -0
- package/dist/packem_shared/storage-DVcJumyk.js +1 -0
- package/dist/packem_shared/types.d-4ge_rME4.d.ts +246 -0
- package/dist/packem_shared/{types.d-Cz9S7jZh.d.ts → types.d-BW8kAXUv.d.ts} +95 -95
- package/dist/packem_shared/types.d-DGHeA2iJ.d.ts +194 -0
- package/dist/packem_shared/useLogger-7p55yvvc.js +1 -0
- package/dist/packem_shared/wide-event.d-BMLastMR.d.ts +716 -0
- package/dist/packem_shared/write-stream-ytl_vhg_.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +32 -33
- package/dist/processor/environment-processor.d.ts +83 -84
- package/dist/processor/message-formatter-processor.d.ts +40 -45
- package/dist/processor/message-formatter-processor.js +1 -1
- package/dist/processor/opentelemetry-processor.d.ts +51 -52
- package/dist/processor/redact-processor.d.ts +57 -65
- package/dist/processor/sampling-processor.d.ts +90 -91
- package/dist/reporter/file/json-file-reporter.d.ts +77 -78
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +125 -121
- package/dist/reporter/http/abstract-http-reporter.js +2 -2
- package/dist/reporter/http/http-reporter.d.ts +33 -34
- package/dist/reporter/http/http-reporter.edge-light.d.ts +235 -230
- package/dist/reporter/http/http-reporter.edge-light.js +2 -2
- package/dist/reporter/json/index.browser.d.ts +62 -61
- package/dist/reporter/json/index.browser.js +1 -1
- package/dist/reporter/json/index.d.ts +36 -37
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/pretty/index.browser.d.ts +57 -56
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +133 -133
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +91 -90
- package/dist/reporter/simple/simple-reporter.server.js +7 -7
- package/dist/wide-event.d.ts +2 -3
- package/dist/wide-event.js +1 -1
- package/package.json +58 -37
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +0 -1
- package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +0 -1
- package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +0 -2
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +0 -1
- package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +0 -62
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +0 -25
- package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +0 -47
- package/dist/packem_shared/headers-DH0H2s8W.js +0 -1
- package/dist/packem_shared/index-Q1764hvO.js +0 -1
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +0 -1
- package/dist/packem_shared/storage-DaXAlpiO.js +0 -1
- package/dist/packem_shared/types.d-bWnqHJKL.d.ts +0 -211
- package/dist/packem_shared/types.d-xxE3FOD3.d.ts +0 -229
- package/dist/packem_shared/useLogger-DB34CuU5.js +0 -1
- package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +0 -717
- package/dist/packem_shared/write-stream-C7jxLxIT.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as g,c as i}from"../packem_shared/headers-
|
|
1
|
+
import{e as g,c as i}from"../packem_shared/headers-DI58djdG.js";import{c as u}from"../packem_shared/storage-DVcJumyk.js";const n=u("SvelteKit handle hook context. Make sure pailHandle is added to your hooks.server.ts."),k=()=>n.useLogger(),h=r=>async({event:e,resolve:a})=>{const d=e.request.headers.get("x-request-id")??crypto.randomUUID(),l=g(e.request.headers),{finish:t,logger:s,skipped:c}=i(r,{headers:l,method:e.request.method,path:e.url.pathname,requestId:d});return c?a(e):(e.locals.log=s,n.storage.run(s,async()=>{try{const o=await a(e);return t({status:o.status}),o}catch(o){throw t({error:o instanceof Error?o:new Error(String(o))}),o}}))},p=()=>({error:r,event:e})=>{const a=e.locals.log;a&&r instanceof Error&&a.error(r.message,r)},q=r=>({handle:h(r),handleError:p()});export{q as createPailHooks,h as pailHandle,p as pailHandleError,k as useLogger};
|
package/dist/object-tree.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to render a node value for display
|
|
3
|
-
* @param node The node to render
|
|
4
|
-
* @returns A string representation or undefined if should not render
|
|
5
|
-
*/
|
|
2
|
+
* Function to render a node value for display
|
|
3
|
+
* @param node The node to render
|
|
4
|
+
* @returns A string representation or undefined if should not render
|
|
5
|
+
*/
|
|
6
6
|
type TreeRenderFunction = (node: unknown) => string | undefined;
|
|
7
7
|
/**
|
|
8
|
-
* Function to sort keys during tree traversal
|
|
9
|
-
* @param a First key for comparison
|
|
10
|
-
* @param b Second key for comparison
|
|
11
|
-
* @returns Negative if a < b, positive if a > b, 0 if equal
|
|
12
|
-
*/
|
|
8
|
+
* Function to sort keys during tree traversal
|
|
9
|
+
* @param a First key for comparison
|
|
10
|
+
* @param b Second key for comparison
|
|
11
|
+
* @returns Negative if a < b, positive if a > b, 0 if equal
|
|
12
|
+
*/
|
|
13
13
|
type TreeSortFunction = (a: string, b: string) => number;
|
|
14
14
|
/**
|
|
15
|
-
* Configuration options for object tree rendering
|
|
16
|
-
*/
|
|
15
|
+
* Configuration options for object tree rendering
|
|
16
|
+
*/
|
|
17
17
|
interface ObjectTreeOptions {
|
|
18
18
|
/** Text to display for circular references (default: " (circular ref.)") */
|
|
19
19
|
breakCircularWith?: string | null;
|
|
@@ -35,38 +35,38 @@ interface ObjectTreeOptions {
|
|
|
35
35
|
spacerNoNeighbour?: string;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Renders an object as an ASCII tree structure.
|
|
39
|
-
* @param tree The object to render as a tree
|
|
40
|
-
* @param options Configuration options for tree rendering
|
|
41
|
-
* @returns Formatted tree as string or array of lines
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* const obj = {
|
|
45
|
-
* name: "John",
|
|
46
|
-
* age: 30,
|
|
47
|
-
* address: {
|
|
48
|
-
* street: "Main St",
|
|
49
|
-
* city: "New York"
|
|
50
|
-
* }
|
|
51
|
-
* };
|
|
52
|
-
*
|
|
53
|
-
* // Default output as string
|
|
54
|
-
* console.log(renderObjectTree(obj));
|
|
55
|
-
*
|
|
56
|
-
* // Custom rendering
|
|
57
|
-
* console.log(renderObjectTree(obj, {
|
|
58
|
-
* sortFn: (a, b) => a.localeCompare(b),
|
|
59
|
-
* renderFn: (node) => {
|
|
60
|
-
* if (typeof node === 'string') return node.toUpperCase();
|
|
61
|
-
* return ['boolean', 'string', 'number'].includes(typeof node)
|
|
62
|
-
* ? String(node)
|
|
63
|
-
* : undefined;
|
|
64
|
-
* }
|
|
65
|
-
* }));
|
|
66
|
-
*
|
|
67
|
-
* // Get as array of lines
|
|
68
|
-
* const lines = renderObjectTree(obj, { joined: false });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
38
|
+
* Renders an object as an ASCII tree structure.
|
|
39
|
+
* @param tree The object to render as a tree
|
|
40
|
+
* @param options Configuration options for tree rendering
|
|
41
|
+
* @returns Formatted tree as string or array of lines
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const obj = {
|
|
45
|
+
* name: "John",
|
|
46
|
+
* age: 30,
|
|
47
|
+
* address: {
|
|
48
|
+
* street: "Main St",
|
|
49
|
+
* city: "New York"
|
|
50
|
+
* }
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* // Default output as string
|
|
54
|
+
* console.log(renderObjectTree(obj));
|
|
55
|
+
*
|
|
56
|
+
* // Custom rendering
|
|
57
|
+
* console.log(renderObjectTree(obj, {
|
|
58
|
+
* sortFn: (a, b) => a.localeCompare(b),
|
|
59
|
+
* renderFn: (node) => {
|
|
60
|
+
* if (typeof node === 'string') return node.toUpperCase();
|
|
61
|
+
* return ['boolean', 'string', 'number'].includes(typeof node)
|
|
62
|
+
* ? String(node)
|
|
63
|
+
* : undefined;
|
|
64
|
+
* }
|
|
65
|
+
* }));
|
|
66
|
+
*
|
|
67
|
+
* // Get as array of lines
|
|
68
|
+
* const lines = renderObjectTree(obj, { joined: false });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
71
|
declare const renderObjectTree: (tree: Record<string, unknown> | unknown[], options?: ObjectTreeOptions) => string | string[];
|
|
72
72
|
export { ObjectTreeOptions, TreeRenderFunction, TreeSortFunction, renderObjectTree as default, renderObjectTree };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as m}from"./constants-DKfCaSUR.js";const g=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}}),d=e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},p=new WeakSet,v=e=>{if(Object.hasOwn(e,"name")&&typeof e.name=="string"&&e.name!=="")return e.name;const r=e.constructor?.name;return typeof r=="string"&&r!==""?r:e.name},O=e=>{const r=Object.getOwnPropertyNames(e);for(const a of r){const t=Object.getOwnPropertyDescriptor(e,a);t&&(t.enumerable||Object.defineProperty(e,a,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&O(t.value))}},h=e=>{p.add(e);const r=e.toJSON();return p.delete(e),Object.isExtensible(r)&&O(r),r},s=(e,r,a,t,n=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(a+=1,f(e,t,r,a));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const u=[];for(const[o,i]of e.entries())u.push([s(o,r,a,t,n),s(i,r,a,t,n)]);return{__dataType:"Map",value:u}}if(e instanceof Set){const u=[];for(const o of e.values())u.push(s(o,r,a,t,n));return{__dataType:"Set",value:u}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(d(e)){if(n.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&a+1>=t.maxDepth)return{};a+=1,n.add(e);const u={};for(const o in e)u[o]=s(e[o],r,a,t,n);return n.delete(e),u}try{return e}catch{return"[Not Available]"}},f=(e,r,a,t)=>{if(a.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return h(e);const n=Object.create(g);if(Object.defineProperty(n,"name",{configurable:!0,enumerable:!0,value:v(e),writable:!0}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const o=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(a.has(i))return Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),n;o.push(f(i,r,a,t))}Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:o,writable:!0})}const u=e.cause;if(u!=null)if(u instanceof Error)a.has(u)?Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:f(u,r,a,t),writable:!0});else{const o=s(u,a,t,r);Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:o,writable:!0})}for(const o in e){if(o==="name"||o==="message"||o==="stack"||o==="cause"||o==="errors")continue;const i=e[o],l=s(i,a,t,r);Object.defineProperty(n,o,{configurable:!0,enumerable:!0,value:l,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const o of r.exclude)try{delete n[o]}catch{}return n},y=(e,r={})=>f(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0);class S{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:a,error:t,file:n,message:u,type:o,...i}=r;if(i.label&&(i.label=i.label.trim()),n&&(i.file=`${n.name??""}:${String(n.line)}${n.column?`:${String(n.column)}`:""}`),i.message=u===m?void 0:u,t&&(i.error=y(t,this.errorOptions)),a){const l=[];for(let b=0;b<a.length;b+=1){const c=a[b];c!==m&&(c instanceof Error?l.push(y(c,this.errorOptions)):l.push(c))}i.context=l}this._log(this.stringify(i),o.level)}}export{S as AbstractJsonReporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as g}from"./serializeError-52C4oiKx-CrnRcq9R.js";import{E as a}from"./constants-ep2nsfdy.js";class u{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:s,error:l,file:o,message:c,type:f,...r}=t;if(r.label&&(r.label=r.label.trim()),o&&(r.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),r.message=c===a?void 0:c,l&&(r.error=g(l,this.errorOptions)),s){const i=[];for(let n=0;n<s.length;n+=1){const e=s[n];e!==a&&(e instanceof Error?i.push(g(e,this.errorOptions)):i.push(e))}r.context=i}this._log(this.stringify(r),f.level)}}export{u as AbstractJsonReporter};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as n}from"node:module";import{r as i,a}from"./write-stream-ytl_vhg_.js";import{AbstractJsonReporter as u}from"./AbstractJsonReporter-DxZwImm5.js";const r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:o,stderr:c}=r;class h extends u{#e;#s;constructor(e={}){super(e),this.#e=o,this.#s=c}setStdout(e){this.#e=e}setStderr(e){this.#s=e}_log(e,s){const t=i(s)?this.#s:this.#e;a(`${e}
|
|
2
|
+
`,t)}}export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AbstractJsonReporter as o}from"./AbstractJsonReporter-BpWRnN0L.js";import{t as s}from"./write-console-log-based-on-level-BqjxV016.js";class c extends o{constructor(r={}){super(r)}_log(r,t){s(t)(r)}}export{c as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import O,{grey as n,white as P,underline as T,bold as Y}from"@visulima/colorize/browser";import{y as r,g as k}from"./index-
|
|
1
|
+
import O,{grey as n,white as P,underline as T,bold as Y}from"@visulima/colorize/browser";import{y as r,g as k}from"./index-CbkPnylC.js";import{L as B,E as C}from"./constants-DKfCaSUR.js";import{t as F}from"./write-console-log-based-on-level-BqjxV016.js";const _=p=>{const l=Object.keys(p).map(t=>p[t].badge??"");return l.length===0?"":l.reduce((t,a)=>t.length>a.length?t:a,"")},v=p=>[p.getHours(),p.getMinutes(),p.getSeconds()].map(l=>String(l).padStart(2,"0")).join(":");class D{styles;loggerTypes;constructor(l){this.styles={bold:{label:!1},dateFormatter:v,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...l},this.loggerTypes=B}setLoggerTypes(l){this.loggerTypes=l}}class q extends D{constructor(l={}){super({uppercase:{label:!0,...l.uppercase},...l})}log(l){const t=typeof globalThis.window<"u"&&typeof globalThis.document<"u",a=F(l.type.level),{badge:x,context:S,date:u,error:A,groups:f,label:y,message:w,prefix:d,repeated:g,scope:h,suffix:m,type:E}=l,{color:L}=this.loggerTypes[E.name],j=L?O[L]:P,s=[];if(t&&f.length>0){const e=f.map(()=>" ").join(""),i=n(`[${f.at(-1)}]`);s.push(r(e+i[0],i.slice(1)))}if(u){const e=n(this.styles.dateFormatter(typeof u=="string"?new Date(u):u));t?s.push(r(e[0],e.slice(1))):s.push([`${e[0]} `,...e.slice(1)])}if(x){const e=j(x);t?s.push(r(e[0],e.slice(1))):s.push([`${e[0]} `,...e.slice(1)])}else{const e=_(this.loggerTypes);if(e.length>0){const i=n(".".repeat(e.length));t?s.push(r(`${i[0]} `,i.slice(1))):s.push([`${i[0]} `,...i.slice(1)])}}const M=k(this.loggerTypes);let b;if(g){const e=P(`[${g}x]`);b=t?r(e[0],e.slice(1)):[e[0],...e.slice(1)]}if(y){const e=j(this.#e(y));t?s.push(r(e[0],e.slice(1))):s.push([e[0],...e.slice(1)]),b&&s.push(b);let i=M.length-y.length;if(g?i-=String(g).length+3:i+=1,i>0){const o=n(".".repeat(i));t?s.push(r(o[0],o.slice(1))):s.push([` ${o[0]}`,...o.slice(1)])}}else{const e=n(".".repeat(M.length+1));t?s.push(r(e[0],e.slice(1))):s.push([e[0],...e.slice(1)])}if(Array.isArray(h)&&h.length>0){const e=n(`[${h.join(" > ")}]`);t?s.push(r(e[0],e.slice(1))):s.push([e[0],...e.slice(1)])}if(d){const e=n(`${Array.isArray(h)&&h.length>0?". ":" "}[${this.styles.underline.prefix?T(d):d}] `);t?s.push(r(e[0],e.slice(1))):s.push([e[0],...e.slice(1)])}if(w!==C&&s.push(w),S&&s.push(...S),A&&s.push(A,`
|
|
2
2
|
|
|
3
3
|
`),m){const e=n(this.styles.underline.suffix?T(m):m);t?s.push(r(`
|
|
4
4
|
${e[0]}`,e.slice(1))):s.push([`
|