flugrekorder 1.1.0 → 1.2.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/README.md +354 -72
- package/dist/flugrekorder.d.mts +49 -24
- package/dist/flugrekorder.d.ts +49 -24
- package/dist/flugrekorder.global.js +422 -175
- package/dist/flugrekorder.global.js.map +1 -1
- package/dist/flugrekorder.js +425 -176
- package/dist/flugrekorder.js.map +1 -1
- package/dist/flugrekorder.mjs +421 -176
- package/dist/flugrekorder.mjs.map +1 -1
- package/package.json +13 -25
package/dist/flugrekorder.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Writable } from 'node:stream';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
type Proxiable = object | Function;
|
|
3
|
+
type Proxiable = object;
|
|
5
4
|
/** Reflect traps that operate on a property — carry a parent ID and key in their origin. */
|
|
6
5
|
type PropertyTrap = 'get' | 'set' | 'defineProperty' | 'getOwnPropertyDescriptor';
|
|
7
|
-
/** Reflect traps that invoke a callable — carry a source ID in their origin. */
|
|
8
|
-
type CallTrap = 'apply' | 'construct';
|
|
6
|
+
/** Reflect traps that invoke a callable — carry a source ID in their origin. Includes synthetic variants for native boundary crossings. */
|
|
7
|
+
type CallTrap = 'apply' | 'construct' | 'apply:native' | 'construct:native' | 'apply:structure' | 'apply:private';
|
|
9
8
|
/** Describes how a proxy was created — which trap fired, on which parent, and under which key or source. Null for root proxies. */
|
|
10
9
|
type Origin = {
|
|
11
10
|
trap: PropertyTrap;
|
|
@@ -24,12 +23,24 @@ type SerializedOrigin = {
|
|
|
24
23
|
trap: CallTrap;
|
|
25
24
|
source: string;
|
|
26
25
|
} | null;
|
|
27
|
-
/** A JSON-safe representation of any value. Proxiable values are replaced with `{ $proxy: id }` tags. */
|
|
26
|
+
/** A JSON-safe representation of any value. Proxiable values are replaced with `{ $proxy: id }` tags. Raw targets (proxiable values known to the graph but passed unwrapped) are tagged `{ $unwrap: { $proxy: id } }`. */
|
|
28
27
|
type Serialized = string | number | boolean | bigint | null | undefined | {
|
|
29
28
|
readonly $proxy: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly $unwrap: {
|
|
31
|
+
readonly $proxy: string;
|
|
32
|
+
};
|
|
30
33
|
} | Array<Serialized> | {
|
|
31
34
|
[key: string]: Serialized;
|
|
32
35
|
};
|
|
36
|
+
/** Returns true for any value that can meaningfully be wrapped in a Proxy. */
|
|
37
|
+
declare function isProxiable(value: unknown): value is Proxiable;
|
|
38
|
+
/**
|
|
39
|
+
* Determines whether and how a key/value pair should be redacted during serialization.
|
|
40
|
+
* Return `false` to keep as-is, `true` to replace with `"[redacted]"`,
|
|
41
|
+
* a string to use as a custom replacement, or `null` to drop the key entirely.
|
|
42
|
+
*/
|
|
43
|
+
type Redactor = (key: string | symbol, value: unknown, target: object) => string | boolean | null;
|
|
33
44
|
/** A single recorded interaction — one Reflect trap firing on one proxy. */
|
|
34
45
|
type Rekording = {
|
|
35
46
|
id: string;
|
|
@@ -37,25 +48,14 @@ type Rekording = {
|
|
|
37
48
|
origin: SerializedOrigin;
|
|
38
49
|
args: Array<Serialized>;
|
|
39
50
|
result: Serialized;
|
|
51
|
+
timestamp: number;
|
|
40
52
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
callback?: never;
|
|
48
|
-
} | {
|
|
49
|
-
callback: (record: Rekording) => void;
|
|
50
|
-
stream?: never;
|
|
51
|
-
});
|
|
52
|
-
/**
|
|
53
|
-
* Wraps `target` in a transparent recording proxy.
|
|
54
|
-
* Every Reflect trap that fires emits a `Rekording` to `callback` or `stream`.
|
|
55
|
-
*/
|
|
56
|
-
declare function create<T extends Proxiable>(target: T, options: CreateOptions): T;
|
|
57
|
-
/** Returns `true` if `value` is a proxy created by this module. */
|
|
58
|
-
declare function isFlugrekorder(value: unknown): value is Proxiable;
|
|
53
|
+
|
|
54
|
+
/** Converts a `Rekording` to a human-readable string.
|
|
55
|
+
* When `proxy` is supplied, `{ $proxy: id }` tags in args and results resolve to dotted paths.
|
|
56
|
+
* When omitted, raw IDs are shown instead. */
|
|
57
|
+
declare function format(rekording: Rekording, proxy?: Proxiable): string;
|
|
58
|
+
|
|
59
59
|
/** Returns the original unwrapped target of a proxy, or `null` for non-proxies. */
|
|
60
60
|
declare function getTarget(pxy: Proxiable): Proxiable | null;
|
|
61
61
|
/**
|
|
@@ -81,4 +81,29 @@ declare function getAncestors(pxy: Proxiable): Array<{
|
|
|
81
81
|
*/
|
|
82
82
|
declare function getPath(pxy: Proxiable): string;
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
type CommonCreateOptions = {
|
|
85
|
+
id?: number | (() => string);
|
|
86
|
+
recursive?: boolean;
|
|
87
|
+
only?: Array<string>;
|
|
88
|
+
filter?: (rekording: Rekording) => boolean;
|
|
89
|
+
depth?: number;
|
|
90
|
+
redact?: Redactor | Array<Redactor>;
|
|
91
|
+
truncate?: number;
|
|
92
|
+
bind?: boolean;
|
|
93
|
+
};
|
|
94
|
+
type StreamCreateOptions = CommonCreateOptions & {
|
|
95
|
+
stream: Writable;
|
|
96
|
+
};
|
|
97
|
+
type CallbackCreateOptions = CommonCreateOptions & {
|
|
98
|
+
callback: (record: Rekording) => void;
|
|
99
|
+
};
|
|
100
|
+
type CreateOptions = StreamCreateOptions | CallbackCreateOptions;
|
|
101
|
+
/**
|
|
102
|
+
* Wraps `target` in a transparent recording proxy.
|
|
103
|
+
* Every Reflect trap that fires emits a `Rekording` to `callback` or `stream`.
|
|
104
|
+
*/
|
|
105
|
+
declare function create<T extends Proxiable>(target: T, options: CreateOptions): T;
|
|
106
|
+
/** Returns `true` if `value` is a proxy created by this module. */
|
|
107
|
+
declare function isFlugrekorder(value: unknown): value is Proxiable;
|
|
108
|
+
|
|
109
|
+
export { type CallTrap, type Origin, type PropertyTrap, type Proxiable, type Redactor, type Rekording, type Serialized, create, format, getAncestors, getOrigin, getPath, getProxyById, getTarget, isFlugrekorder, isProxiable };
|