trickle-observe 0.2.104 → 0.2.105

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.
@@ -153,6 +153,23 @@ function inferObject(obj, depth, seen) {
153
153
  },
154
154
  };
155
155
  }
156
+ // Known complex framework objects — use class name instead of deep introspection.
157
+ // These types have dozens of internal properties that generate unusably verbose stubs.
158
+ const className = obj.constructor?.name;
159
+ const OPAQUE_CLASSES = new Set([
160
+ // Node.js HTTP internals
161
+ 'IncomingMessage', 'ServerResponse', 'Socket', 'Server',
162
+ 'ReadableState', 'WritableState',
163
+ // Express
164
+ 'IncomingMessage', // Express req extends this
165
+ // Streams
166
+ 'Readable', 'Writable', 'Duplex', 'Transform', 'PassThrough',
167
+ // EventEmitter
168
+ 'EventEmitter',
169
+ ]);
170
+ if (className && OPAQUE_CLASSES.has(className)) {
171
+ return { kind: 'object', properties: {}, class_name: className };
172
+ }
156
173
  // Plain objects
157
174
  return inferPlainObject(obj, depth, seen);
158
175
  }
@@ -167,7 +184,7 @@ function inferArray(arr, depth, seen) {
167
184
  }
168
185
  return { kind: 'array', element: unifyTypes(elementTypes) };
169
186
  }
170
- const MAX_PROPERTIES = 20;
187
+ const MAX_PROPERTIES = 12;
171
188
  function inferPlainObject(obj, depth, seen) {
172
189
  const properties = {};
173
190
  const keys = Object.keys(obj);
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export type TypeNode = {
7
7
  } | {
8
8
  kind: "object";
9
9
  properties: Record<string, TypeNode>;
10
+ class_name?: string;
10
11
  } | {
11
12
  kind: "union";
12
13
  members: TypeNode[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trickle-observe",
3
- "version": "0.2.104",
3
+ "version": "0.2.105",
4
4
  "description": "Runtime type observability for JavaScript applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -168,6 +168,24 @@ function inferObject(obj: object, depth: number, seen: WeakSet<object>): TypeNod
168
168
  };
169
169
  }
170
170
 
171
+ // Known complex framework objects — use class name instead of deep introspection.
172
+ // These types have dozens of internal properties that generate unusably verbose stubs.
173
+ const className = obj.constructor?.name;
174
+ const OPAQUE_CLASSES = new Set([
175
+ // Node.js HTTP internals
176
+ 'IncomingMessage', 'ServerResponse', 'Socket', 'Server',
177
+ 'ReadableState', 'WritableState',
178
+ // Express
179
+ 'IncomingMessage', // Express req extends this
180
+ // Streams
181
+ 'Readable', 'Writable', 'Duplex', 'Transform', 'PassThrough',
182
+ // EventEmitter
183
+ 'EventEmitter',
184
+ ]);
185
+ if (className && OPAQUE_CLASSES.has(className)) {
186
+ return { kind: 'object', properties: {}, class_name: className };
187
+ }
188
+
171
189
  // Plain objects
172
190
  return inferPlainObject(obj, depth, seen);
173
191
  }
@@ -187,7 +205,7 @@ function inferArray(arr: unknown[], depth: number, seen: WeakSet<object>): TypeN
187
205
  return { kind: 'array', element: unifyTypes(elementTypes) };
188
206
  }
189
207
 
190
- const MAX_PROPERTIES = 20;
208
+ const MAX_PROPERTIES = 12;
191
209
 
192
210
  function inferPlainObject(obj: object, depth: number, seen: WeakSet<object>): TypeNode {
193
211
  const properties: Record<string, TypeNode> = {};
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export type TypeNode =
2
2
  | { kind: "primitive"; name: "string" | "number" | "boolean" | "null" | "undefined" | "bigint" | "symbol" }
3
3
  | { kind: "array"; element: TypeNode }
4
- | { kind: "object"; properties: Record<string, TypeNode> }
4
+ | { kind: "object"; properties: Record<string, TypeNode>; class_name?: string }
5
5
  | { kind: "union"; members: TypeNode[] }
6
6
  | { kind: "function"; params: TypeNode[]; returnType: TypeNode }
7
7
  | { kind: "promise"; resolved: TypeNode }