@cero-base/tools 1.18.2 → 1.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cero-base/tools",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "Passive devtools for cero — observe data, events, and p2p/replication stats over a local out-of-band pipe.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -72,11 +72,11 @@
72
72
  "build:types": "rm -rf types && tsc -p .",
73
73
  "prepublishOnly": "npm run build:types",
74
74
  "test": "npm run test:bare",
75
- "test:bare": "ls test/*.test.js | xargs -P1 -n1 brittle-bare test/bare.js",
76
- "test:node": "ls test/*.test.js | xargs -P1 -n1 brittle-node"
75
+ "test:bare": "find test -name '*.test.js' | sort | xargs -P1 -n1 brittle-bare test/bare.js",
76
+ "test:node": "find test -name '*.test.js' | sort | xargs -P1 -n1 brittle-node"
77
77
  },
78
78
  "dependencies": {
79
- "@cero-base/cero": "^1.18.2",
79
+ "@cero-base/cero": "^1.19.0",
80
80
  "b4a": "^1.8.1",
81
81
  "bare-crypto": "^1.15.3",
82
82
  "bare-net": "^2.3.3",
@@ -91,7 +91,7 @@
91
91
  "bare-path": "^3.1.2",
92
92
  "bare-url": "^2.5.4",
93
93
  "brittle": "^4.1.1",
94
- "typescript": "^5.9.3"
94
+ "typescript": "^7.0.2"
95
95
  },
96
96
  "license": "Apache-2.0",
97
97
  "typesVersions": {
@@ -1,3 +1,7 @@
1
+ import { Readable } from 'streamx';
2
+ import { Framed } from './protocol.js';
3
+ export type Query = object;
4
+ export type Handle = Record<string, unknown>;
1
5
  /**
2
6
  * @typedef {object} Query Opaque query filter passed to the server.
3
7
  */
@@ -13,23 +17,23 @@
13
17
  * @param {object} stream A streamx Duplex connected to a tap server.
14
18
  * @returns {Promise<{ handles(): Promise<Handle[]>, get(ref: string, query?: Query, handleId?: string): Promise<unknown>, count(ref: string, query?: Query, handleId?: string): Promise<number>, watch(ref: string, query?: Query, handleId?: string): import('streamx').Readable, events(): import('streamx').Readable, stats(): import('streamx').Readable, close(): void }>}
15
19
  */
16
- export function connect(stream: object, { token }?: {}): Promise<{
20
+ export declare function connect(stream: object, { token }?: {}): Promise<{
17
21
  handles(): Promise<Handle[]>;
18
22
  get(ref: string, query?: Query, handleId?: string): Promise<unknown>;
19
23
  count(ref: string, query?: Query, handleId?: string): Promise<number>;
20
- watch(ref: string, query?: Query, handleId?: string): import("streamx").Readable;
21
- events(): import("streamx").Readable;
22
- stats(): import("streamx").Readable;
24
+ watch(ref: string, query?: Query, handleId?: string): import('streamx').Readable;
25
+ events(): import('streamx').Readable;
26
+ stats(): import('streamx').Readable;
23
27
  close(): void;
24
28
  }>;
25
- export class Session {
26
- constructor(stream: any, { token }?: {});
29
+ export declare class Session {
27
30
  stream: any;
28
31
  token: any;
29
32
  pending: Map<any, any>;
30
33
  streams: Map<any, any>;
31
34
  seq: number;
32
35
  wire: Framed;
36
+ constructor(stream: any, { token }?: {});
33
37
  _onclose(): void;
34
38
  _onmessage(msg: any): void;
35
39
  _newId(): number;
@@ -68,19 +72,19 @@ export class Session {
68
72
  * @param {string} [handleId] Optional handle to scope the watch.
69
73
  * @returns {import('streamx').Readable} Cancels its server-side source when destroyed.
70
74
  */
71
- watch(ref: string, query?: Query, handleId?: string): import("streamx").Readable;
75
+ watch(ref: string, query?: Query, handleId?: string): import('streamx').Readable;
72
76
  /**
73
77
  * Streams server events.
74
78
  *
75
79
  * @returns {import('streamx').Readable} Cancels its server-side source when destroyed.
76
80
  */
77
- events(): import("streamx").Readable;
81
+ events(): import('streamx').Readable;
78
82
  /**
79
83
  * Streams server stats.
80
84
  *
81
85
  * @returns {import('streamx').Readable} Cancels its server-side source when destroyed.
82
86
  */
83
- stats(): import("streamx").Readable;
87
+ stats(): import('streamx').Readable;
84
88
  /**
85
89
  * Closes the session by ending the underlying stream.
86
90
  *
@@ -88,13 +92,3 @@ export class Session {
88
92
  */
89
93
  close(): void;
90
94
  }
91
- /**
92
- * Opaque query filter passed to the server.
93
- */
94
- export type Query = object;
95
- /**
96
- * A handle descriptor returned by the server.
97
- */
98
- export type Handle = Record<string, unknown>;
99
- import { Framed } from './protocol.js';
100
- import { Readable } from 'streamx';
package/types/format.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @param {Array<{ id: string, type: string | null }>} tree
5
5
  * @returns {string}
6
6
  */
7
- export function formatHandles(tree: Array<{
7
+ export declare function formatHandles(tree: Array<{
8
8
  id: string;
9
9
  type: string | null;
10
10
  }>): string;
@@ -16,7 +16,7 @@ export function formatHandles(tree: Array<{
16
16
  * @param {{ data: any, total?: number, size?: number }} result
17
17
  * @returns {string}
18
18
  */
19
- export function formatState(ref: string, result: {
19
+ export declare function formatState(ref: string, result: {
20
20
  data: any;
21
21
  total?: number;
22
22
  size?: number;
@@ -28,7 +28,7 @@ export function formatState(ref: string, result: {
28
28
  * @param {{ message?: string }} err
29
29
  * @returns {string}
30
30
  */
31
- export function formatError(ref: string, err: {
31
+ export declare function formatError(ref: string, err: {
32
32
  message?: string;
33
33
  }): string;
34
34
  /**
@@ -37,7 +37,7 @@ export function formatError(ref: string, err: {
37
37
  * @param {{ op: string, name: string, row: any, writerKey?: any, seq?: number }} e
38
38
  * @returns {string}
39
39
  */
40
- export function formatEvent(e: {
40
+ export declare function formatEvent(e: {
41
41
  op: string;
42
42
  name: string;
43
43
  row: any;
@@ -50,7 +50,7 @@ export function formatEvent(e: {
50
50
  * @param {{ network?: { connections: number, peers: number }, bee?: { local: number }, cores?: any[] }} s
51
51
  * @returns {string}
52
52
  */
53
- export function formatStats(s: {
53
+ export declare function formatStats(s: {
54
54
  network?: {
55
55
  connections: number;
56
56
  peers: number;
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { stats } from "./stats.js";
2
- export { redact } from "./redact.js";
3
- export { devtools } from "./tap.js";
4
- export { serve } from "./server.js";
5
- export { connect } from "./connect.js";
6
- export { loopback, dial } from "./transport.js";
1
+ export { stats } from './stats.js';
2
+ export { redact } from './redact.js';
3
+ export { devtools } from './tap.js';
4
+ export { serve } from './server.js';
5
+ export { connect } from './connect.js';
6
+ export { loopback, dial } from './transport.js';
@@ -2,11 +2,11 @@
2
2
  * Length-prefixed JSON framing over a Duplex `stream`. Buffers incoming chunks
3
3
  * and delivers each decoded frame to `onMessage`; `send` writes a framed frame.
4
4
  */
5
- export class Framed {
6
- constructor(stream: any, onMessage: any);
5
+ export declare class Framed {
7
6
  stream: any;
8
7
  onMessage: any;
9
8
  buf: any;
9
+ constructor(stream: any, onMessage: any);
10
10
  _ondata(chunk: any): void;
11
11
  /**
12
12
  * Encode `obj` to wire form and write it as one length-prefixed frame.
package/types/redact.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * @param {{ fields?: string[], deny?: RegExp | false, match?: (key: string, value: any, path: string) => boolean }} [config]
9
9
  * @returns {(ref: string, row: any) => any}
10
10
  */
11
- export function redact(config?: {
11
+ export declare function redact(config?: {
12
12
  fields?: string[];
13
13
  deny?: RegExp | false;
14
14
  match?: (key: string, value: any, path: string) => boolean;
package/types/server.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ import { Framed } from './protocol.js';
2
+ export type ReqFrame = {
3
+ id?: string;
4
+ method?: string;
5
+ ref?: string;
6
+ handleId?: string;
7
+ query?: object;
8
+ cancelId?: string;
9
+ };
1
10
  /**
2
11
  * A decoded request frame. Carries the correlation `id` and `method`, plus the
3
12
  * per-method fields a handler reads: `ref`, `handleId`, `query`, `cancelId`.
@@ -14,7 +23,7 @@
14
23
  * @param {{ events?: { snapshot(): unknown, subscribe(fn: (e: object) => void): () => void }, stats?: { snapshot(): unknown, subscribe(fn: (s: object) => void): () => void }, redact?: (ref: string, row: Record<string, unknown>) => Record<string, unknown> }} [opts]
15
24
  * @returns {{ close(): void }}
16
25
  */
17
- export function serve(stream: object, me: object, opts?: {
26
+ export declare function serve(stream: object, me: object, opts?: {
18
27
  events?: {
19
28
  snapshot(): unknown;
20
29
  subscribe(fn: (e: object) => void): () => void;
@@ -27,8 +36,7 @@ export function serve(stream: object, me: object, opts?: {
27
36
  }): {
28
37
  close(): void;
29
38
  };
30
- export class TapServer {
31
- constructor(stream: any, me: any, opts?: {});
39
+ export declare class TapServer {
32
40
  stream: any;
33
41
  me: any;
34
42
  redact: any;
@@ -37,6 +45,7 @@ export class TapServer {
37
45
  _authed: boolean;
38
46
  wire: Framed;
39
47
  _cleanup: () => void;
48
+ constructor(stream: any, me: any, opts?: {});
40
49
  /**
41
50
  * Dispatch an inbound request frame to its named method handler.
42
51
  * @param {ReqFrame} req A decoded request frame, expected to carry `id` and `method`.
@@ -97,16 +106,3 @@ export class TapServer {
97
106
  */
98
107
  close(): void;
99
108
  }
100
- /**
101
- * A decoded request frame. Carries the correlation `id` and `method`, plus the
102
- * per-method fields a handler reads: `ref`, `handleId`, `query`, `cancelId`.
103
- */
104
- export type ReqFrame = {
105
- id?: string;
106
- method?: string;
107
- ref?: string;
108
- handleId?: string;
109
- query?: object;
110
- cancelId?: string;
111
- };
112
- import { Framed } from './protocol.js';
package/types/stats.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * @param {number} [at] Sample timestamp, stamped by the caller.
9
9
  * @returns {{ handleId: string, network: { connections: number, peers: number, dht: any }, bee: { local: number, stats: any }, cores: Array<{ length: number, byteLength: number, peers: number }>, at: number }}
10
10
  */
11
- export function stats(handle: any, at?: number): {
11
+ export declare function stats(handle: any, at?: number): {
12
12
  handleId: string;
13
13
  network: {
14
14
  connections: number;
package/types/tap.d.ts CHANGED
@@ -1,3 +1,27 @@
1
+ export type OpEvent = {
2
+ op: string;
3
+ name: string;
4
+ row: Record<string, unknown>;
5
+ writerKey: Buffer;
6
+ seq: number;
7
+ };
8
+ export type StatsSample = {
9
+ handleId: string;
10
+ network: {
11
+ connections: number;
12
+ peers: number;
13
+ dht: object | null;
14
+ };
15
+ bee: {
16
+ local: number;
17
+ };
18
+ cores: Array<{
19
+ length: number;
20
+ byteLength: number;
21
+ peers: number;
22
+ }>;
23
+ at: number;
24
+ };
1
25
  /**
2
26
  * An applied-op event fed into the ring buffer. `op` is the dispatch verb
3
27
  * prefix, `name` the ref name, `row` the decoded value, `writerKey` the source
@@ -21,7 +45,7 @@
21
45
  * @param {{ port?: number, host?: string, token?: string | false, bufferSize?: number, sampleInterval?: number, redact?: ((ref: string, row: Record<string, unknown>) => Record<string, unknown>) | { fields?: string[], match?: (key: string, value: unknown, path: string) => boolean, deny?: RegExp | false }, transport?: { accept(handler: (stream: object) => void): void } }} [opts]
22
46
  * @returns {{ setup(me: object): () => void }}
23
47
  */
24
- export function devtools(opts?: {
48
+ export declare function devtools(opts?: {
25
49
  port?: number;
26
50
  host?: string;
27
51
  token?: string | false;
@@ -38,36 +62,3 @@ export function devtools(opts?: {
38
62
  }): {
39
63
  setup(me: object): () => void;
40
64
  };
41
- /**
42
- * An applied-op event fed into the ring buffer. `op` is the dispatch verb
43
- * prefix, `name` the ref name, `row` the decoded value, `writerKey` the source
44
- * writer's key and `seq` a monotonic apply counter. After redaction `row` is
45
- * replaced with its masked copy; the rest is spread through unchanged.
46
- */
47
- export type OpEvent = {
48
- op: string;
49
- name: string;
50
- row: Record<string, unknown>;
51
- writerKey: Buffer;
52
- seq: number;
53
- };
54
- /**
55
- * A periodic `stats(me)` sample. See `stats()` for the field meanings.
56
- */
57
- export type StatsSample = {
58
- handleId: string;
59
- network: {
60
- connections: number;
61
- peers: number;
62
- dht: object | null;
63
- };
64
- bee: {
65
- local: number;
66
- };
67
- cores: Array<{
68
- length: number;
69
- byteLength: number;
70
- peers: number;
71
- }>;
72
- at: number;
73
- };
@@ -6,7 +6,7 @@
6
6
  * @param {{ port?: number, host?: string, token?: string | null }} [opts]
7
7
  * @returns {{ accept(handler: (socket: any) => void): void, ready(): Promise<{ port: number }>, port: number | null, close(): void }}
8
8
  */
9
- export function loopback(opts?: {
9
+ export declare function loopback(opts?: {
10
10
  port?: number;
11
11
  host?: string;
12
12
  token?: string | null;
@@ -25,7 +25,7 @@ export function loopback(opts?: {
25
25
  * @param {{ port: number, host?: string }} [opts]
26
26
  * @returns {any} A streamx-compatible Duplex socket.
27
27
  */
28
- export function dial(opts?: {
28
+ export declare function dial(opts?: {
29
29
  port: number;
30
30
  host?: string;
31
31
  }): any;