@isoloop/bus 0.1.0-next.10 → 0.1.0-next.12

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 ADDED
@@ -0,0 +1,39 @@
1
+ # @isoloop/bus
2
+
3
+ The [Isoloop](https://isoloop.dev) bus: a log of typed topics in its own worker, through which the parts of your app share data and catch up after a restart.
4
+
5
+ ## What you get
6
+
7
+ - **Contracts:** topics with schemas from any [Standard Schema](https://standardschema.dev) library, typed where you use them and checked on every publish.
8
+ - **Retention:** keep the newest records, a span of time, or the latest record for each key.
9
+ - **Replay:** a subscriber that starts late, or restarts, reads what it needs from the log.
10
+ - **Backpressure:** records wait in the log for a busy subscriber, within the topic's retention.
11
+ - **History that lasts:** a persistent topic's records and committed positions survive a reload and a restart of the bus.
12
+ - **Request and reply** (experimental): ask on a topic and get a typed answer.
13
+ - **Contract tests:** `testContracts` from `@isoloop/bus/testing` checks your schemas against samples.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ npm install @isoloop/bus@next zod
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ts
24
+ import { contracts, topic } from '@isoloop/bus';
25
+ import { z } from 'zod';
26
+
27
+ export const cartItems = topic('cart.items.v1', {
28
+ schema: z.object({ sku: z.string(), qty: z.number().int().positive() }),
29
+ retention: { kind: 'compacted' },
30
+ });
31
+
32
+ export default contracts(cartItems);
33
+ ```
34
+
35
+ ## Learn more
36
+
37
+ - [The bus](https://isoloop.dev/docs/bus/)
38
+ - [Contracts and grants](https://isoloop.dev/docs/contracts/)
39
+ - [API reference](https://isoloop.dev/docs/api/bus/)
@@ -701,7 +701,7 @@ function bigint(v) {
701
701
  }
702
702
  bytes(v < 0n ? NBIGINT : BIGINT, -1, Uint8Array.from(out));
703
703
  }
704
- // src/size.ts
704
+ // src/broker/size.ts
705
705
  /**
706
706
  * A rough structured size of a value in bytes, for `maxRecordBytes` (design
707
707
  * §6.1). Strings count two bytes per UTF-16 unit, numbers eight, object keys
@@ -888,7 +888,7 @@ async function copySeed(c) {
888
888
  rejected
889
889
  };
890
890
  }
891
- // src/standard-schema.ts
891
+ // src/contracts/standard-schema.ts
892
892
  const segmentKey = (s) => typeof s === "object" ? s.key : s;
893
893
  /**
894
894
  * Maps schema issues to the cloneable `{ message, path }[]` sent with `invalid`
@@ -922,7 +922,7 @@ function isContracts(x) {
922
922
  function topicConfig(t) {
923
923
  return topicConfigOf(t);
924
924
  }
925
- // src/broker.ts
925
+ // src/broker/broker.ts
926
926
  const fail = (code, message, extra) => ({
927
927
  ok: false,
928
928
  error: {
@@ -3497,7 +3497,7 @@ var OpfsStorage = class {
3497
3497
  this.#topics.clear();
3498
3498
  }
3499
3499
  };
3500
- // src/preview.ts
3500
+ // src/server/preview.ts
3501
3501
  /** Typed arrays and `ArrayBuffer`s show their length, not their contents. */
3502
3502
  const binary = (v) => {
3503
3503
  if (v instanceof ArrayBuffer) return `ArrayBuffer(${v.byteLength})`;
@@ -3614,7 +3614,7 @@ function recordPreview(topic, r, bytes) {
3614
3614
  truncated
3615
3615
  };
3616
3616
  }
3617
- // src/tap.ts
3617
+ // src/server/tap.ts
3618
3618
  /** `maxPerSec` as given when it's a positive number, else the default. */
3619
3619
  const tapRate = (n) => typeof n === "number" && Number.isFinite(n) && n > 0 ? n : 50;
3620
3620
  /** Starts a tap on `broker`. Returns the function that ends it; `close` on the port ends it too. */
@@ -3668,7 +3668,7 @@ function openTap(broker, o) {
3668
3668
  o.port.start();
3669
3669
  return end;
3670
3670
  }
3671
- // src/server.ts
3671
+ // src/server/server.ts
3672
3672
  /** Storage use at or past this share of the quota counts as full (M2b task 14). */
3673
3673
  const FULL = 1;
3674
3674
  /** How long a restarting bus waits for the worker it replaces to release the files' lock. */
package/dist/index.d.ts CHANGED
@@ -1,453 +1,9 @@
1
- import { _ as unchecked, a as InputOf, c as ReplyOutputOf, d as TopicDef, f as contracts, g as topicConfig, h as topic, i as DEFAULT_MAX_RECORD_BYTES, l as Retention, m as isUnchecked, n as Contracts, o as OutputOf, p as isContracts, r as ContractsError, s as ReplyInputOf, t as AnyTopicDef, u as ToolSpec, v as StandardSchemaV1, y as toIssues } from "./topic-BpgHePIE.js";
2
- import { BusRecord, BusToIsolate, CallError, CallResult, ErrorCode, Grants, JSON_SCHEMA_TARGET, JsonSchema, JsonSchemaPair, JsonSchemaResult, NotExportableReason, RequestVia, SeedEvent, StandardJSONSchemaV1, TopicConfig, TopicJsonSchemas, TopicJsonSchemasResult, hasJsonSchema, jsonSchemaOf, topicJsonSchemas } from "@isoloop/protocol";
3
- /**
4
- * A record before the engine gives it an offset.
5
- *
6
- * @internal
7
- */
8
- type NewRecord = Omit<BusRecord, "offset">;
9
- /** A publish's instance and counter, for deduplicating re-sends (ADR 0007, step 5). */
10
- type AppendId = {
11
- epoch: number;
12
- seq: number;
13
- };
14
- /**
15
- * Where the bus keeps its logs (design §6.2). The TS engine implements it now,
16
- * the Rust/WASM engine in M5; both must pass `runEngineConformance`.
17
- *
18
- * Offsets are per topic, start at 0, are monotonic and never reused (I5).
19
- * Retention: `last-n` is applied on append; `time` and `compacted` on
20
- * `compact()`, which the broker calls on a timer. An engine may also compact
21
- * a `compacted` topic on its own once enough records are superseded.
22
- *
23
- * @internal
24
- */
25
- interface LogEngine {
26
- /** Throws if the topic exists. */
27
- createTopic(cfg: TopicConfig): void;
28
- /**
29
- * Appends and returns the record's offset. Throws on an unknown topic. On a
30
- * durable topic, `id` is stored with the record (never delivered) and
31
- * remembered for `appended`; other topics ignore it.
32
- */
33
- append(topic: string, rec: NewRecord, id?: AppendId): number;
34
- /**
35
- * The offset of the record `producer` appended to a durable topic as `id`,
36
- * including records restored from disk; undefined when the engine doesn't
37
- * know it. At least the producer's last 1,000 appends per topic are kept
38
- * (the `BusClient`'s inbox limit), for its current epoch only.
39
- */
40
- appended(topic: string, producer: string, id: AppendId): number | undefined;
41
- /** Up to `max` retained records with `offset >= fromOffset`, ascending. Skips dropped offsets. */
42
- read(topic: string, fromOffset: number, max: number): BusRecord[];
43
- /** Next offset to be written. */
44
- head(topic: string): number;
45
- /** Oldest retained offset; equals `head` when nothing is retained. */
46
- tail(topic: string): number;
47
- /**
48
- * How many records are retained in `[tail, head)`: what `read` from the
49
- * tail would return, counting records evicted to disk (ADR 0020, decision 2).
50
- */
51
- retained(topic: string): number;
52
- /** Stores a consumer's committed offset. Kept even when the records it names are dropped. */
53
- commit(topic: string, consumer: string, offset: number): void;
54
- committed(topic: string, consumer: string): number | undefined;
55
- /**
56
- * Retention pass: drops superseded (`compacted`) and expired (`time`)
57
- * records. Expiry runs in offset order and stops at the first record young
58
- * enough, so a record with an older `ts` behind it is kept until it reaches the tail.
59
- */
60
- compact(topic: string): void;
61
- /**
62
- * Whether appends to `topic` go to durable storage: a `persistent` topic on
63
- * storage that keeps it (ADR 0007). The broker acks those after `flush`.
64
- */
65
- durable(topic: string): boolean;
66
- /**
67
- * Resolves once every append so far to a durable topic is on disk. `now`
68
- * writes the pending batch at once instead of at the next group commit (the
69
- * page is freezing or going away).
70
- */
71
- flush(o?: {
72
- now?: boolean;
73
- }): Promise<void>;
74
- /**
75
- * Whether `read(topic, fromOffset, …)` can answer now. False when the
76
- * records from there were evicted to disk and aren't paged in: call `page`
77
- * first (M2b task 11). Memory topics are always readable.
78
- */
79
- readable(topic: string, fromOffset: number): boolean;
80
- /** Pages evicted records from `fromOffset` back in from disk, so `read` sees them. */
81
- page(topic: string, fromOffset: number): Promise<void>;
82
- }
83
- /**
84
- * Options every engine takes.
85
- *
86
- * @internal
87
- */
88
- type EngineOptions = {
89
- /** Clock for `time` retention. Default `Date.now`. */
90
- now?: () => number;
91
- /** Default `MemoryStorage`. */
92
- storage?: LogStorage;
93
- };
94
- /**
95
- * What a storage found on open: per topic, the offsets it holds; per topic and consumer, commits.
96
- *
97
- * @internal
98
- */
99
- type StoredState = {
100
- topics: {
101
- topic: string;
102
- tail: number;
103
- head: number;
104
- }[];
105
- offsets: Record<string, Record<string, number>>;
106
- };
107
- /**
108
- * Durable storage under the engine, for `durability: 'persistent'` topics
109
- * (design §6.2, ADR 0007). M2 ships `MemoryStorage`, which keeps nothing;
110
- * M2b adds `OpfsStorage`.
111
- *
112
- * @internal
113
- */
114
- interface LogStorage {
115
- /** `memory` keeps nothing; reported in the bus `ready` message. */
116
- readonly kind: "memory" | "opfs";
117
- open(): Promise<StoredState>;
118
- /** Buffered; group commit every 5 ms / 256 records. */
119
- appendBatch(topic: string, encoded: Uint8Array[]): void;
120
- /**
121
- * Resolves when the batch is durable; a persistent publish is acked after
122
- * it. `now` commits the pending batch without waiting for the group commit.
123
- */
124
- flush(o?: {
125
- now?: boolean;
126
- }): Promise<void>;
127
- saveOffsets(offsets: Record<string, Record<string, number>>): void;
128
- /**
129
- * Retention on disk (last-n, time): deletes the segments whose records are
130
- * all below `tail`. Never the newest segment.
131
- */
132
- dropBelow(topic: string, tail: number): void;
133
- /**
134
- * Compaction on disk: rewrites the segments before the newest one, keeping
135
- * the records `keep` accepts. In the background; appends don't wait for it.
136
- */
137
- rewrite(topic: string, keep: (offset: number, key: string | undefined) => boolean): Promise<void>;
138
- /** Replay of evicted segments. */
139
- readSegment(topic: string, fromOffset: number): Promise<Uint8Array[]>;
140
- /** Bytes a topic takes on disk; 0 for one the storage doesn't hold. */
141
- bytes(topic: string): Promise<number>;
142
- /** Deletes a topic's files. False when the storage doesn't hold it. */
143
- deleteTopic(topic: string): Promise<boolean>;
144
- /** Safe mode: moves the newest segments aside and returns their names. */
145
- quarantineNewest(): Promise<string[]>;
146
- }
147
- /**
148
- * Storage that keeps nothing. Every topic behaves as `memory`.
149
- *
150
- * @internal
151
- */
152
- export declare class MemoryStorage implements LogStorage {
153
- readonly kind: "memory";
154
- open(): Promise<StoredState>;
155
- appendBatch(_topic: string, _encoded: Uint8Array[]): void;
156
- flush(): Promise<void>;
157
- saveOffsets(_offsets: Record<string, Record<string, number>>): void;
158
- dropBelow(_topic: string, _tail: number): void;
159
- rewrite(_topic: string, _keep: (offset: number, key: string | undefined) => boolean): Promise<void>;
160
- readSegment(_topic: string, _fromOffset: number): Promise<Uint8Array[]>;
161
- bytes(_topic: string): Promise<number>;
162
- deleteTopic(_topic: string): Promise<boolean>;
163
- quarantineNewest(): Promise<string[]>;
164
- }
165
- /**
166
- * Engines call this from `createTopic`: the durability a topic actually gets.
167
- * A `persistent` topic on storage that keeps nothing (no OPFS, or another tab
168
- * holds it) behaves as `memory`; the kernel reports that as
169
- * `bus:durability_degraded` (ADR 0007, decision 6).
170
- *
171
- * @internal
172
- */
173
- export declare function effectiveDurability(cfg: TopicConfig, storage: LogStorage): "memory" | "persistent";
174
- /** @internal */
175
- type TsEngineOptions = EngineOptions & {
176
- /** Records per chunk. Default 4,096; tests use small chunks to cross boundaries often. */
177
- chunkSize?: number;
178
- /** Superseded records before a compacted topic compacts itself. Default 1,024. */
179
- dirtyMin?: number;
180
- /**
181
- * Durable topics: about how many encoded bytes of records each keeps in
182
- * memory. Older chunks are evicted; `page` reads them back from disk.
183
- * Default 8 MiB, two segments. The newest chunk always stays.
184
- */
185
- residentBytes?: number;
186
- };
187
- /**
188
- * The TypeScript `LogEngine` (design §6.2). Each topic is an array of
189
- * fixed-size chunks, so dropping old records frees a whole chunk at a time:
190
- * O(1) per chunk. Compacted topics keep a key → latest-offset index.
191
- *
192
- * @internal
193
- */
194
- export declare class TsEngine implements LogEngine {
195
- #private;
196
- readonly name = "ts";
197
- constructor(opts?: TsEngineOptions);
198
- createTopic(cfg: TopicConfig): void;
199
- append(topic: string, rec: NewRecord, id?: AppendId): number;
200
- appended(topic: string, producer: string, id: AppendId): number | undefined;
201
- /**
202
- * Rebuilds durable topics from what the storage found on open (M2b task 7):
203
- * every stored record, in order and at its own offset, with retention
204
- * applied as if it had just been appended, and the committed offsets.
205
- * Call after `createTopic`, before any append. Returns each restored
206
- * topic's head.
207
- */
208
- restore(state: StoredState): Promise<{
209
- topic: string;
210
- head: number;
211
- }[]>;
212
- read(topic: string, fromOffset: number, max: number): BusRecord[];
213
- head(topic: string): number;
214
- readable(topic: string, fromOffset: number): boolean;
215
- page(topic: string, fromOffset: number): Promise<void>;
216
- /** Lowest offset held in memory; below it, records are on disk only. For tests and metrics. */
217
- resident(topic: string): number;
218
- tail(topic: string): number;
219
- retained(topic: string): number;
220
- commit(topic: string, consumer: string, offset: number): void;
221
- committed(topic: string, consumer: string): number | undefined;
222
- durable(topic: string): boolean;
223
- flush(o?: {
224
- now?: boolean;
225
- }): Promise<void>;
226
- compact(topic: string): void;
227
- /** Chunks held for a topic, for tests and metrics. */
228
- chunkCount(topic: string): number;
229
- /** Records held in memory for a topic, for tests and metrics. */
230
- heldCount(topic: string): number;
231
- }
232
- /**
233
- * One isolate's bus connection, as the broker sees it. The bus worker wraps a
234
- * `MessagePort`; tests use in-memory ports.
235
- *
236
- * @internal
237
- */
238
- export interface BusPort {
239
- post(msg: BusToIsolate): void;
240
- /** Sets the handler for messages from the isolate. */
241
- onMessage(handler: (msg: unknown) => void): void;
242
- close(): void;
243
- }
244
- /**
245
- * Timer functions, injectable for tests.
246
- *
247
- * @internal
248
- */
249
- export type Timers = {
250
- set(fn: () => void, ms: number): void;
251
- };
252
- /** @internal */
253
- export type BrokerOptions = {
254
- contracts: Contracts;
255
- engine: LogEngine;
256
- /** Default `Date.now`. Stamps `ts` on every record. */
257
- now?: () => number;
258
- /**
259
- * Dev builds check that every validated output survives `structuredClone`
260
- * (ADR 0003, decision 11). Off in production.
261
- */
262
- dev?: boolean;
263
- /** Records delivered per `deliver` message. Default 64. */
264
- batchSize?: number;
265
- /**
266
- * Credit per subscription: records delivered and not yet committed before
267
- * delivery pauses (design §6.3). Default 1,000.
268
- */
269
- inboxLimit?: number;
270
- /** Built-in `isoloop.*` topics. Default `SYSTEM_TOPICS` from `@isoloop/protocol`. */
271
- systemTopics?: readonly AnyTopicDef[];
272
- /** Default `setTimeout`. Used to forget requests after their timeout. */
273
- timers?: Timers;
274
- /**
275
- * True for topics whose log survived a bus restart. Default: the engine's
276
- * `durable`, persistent topics on storage that keeps them. A reattached
277
- * isolate subscribing to any other topic gets `reset` first (ADR 0007).
278
- */
279
- durable?: (topic: string) => boolean;
280
- /**
281
- * A record arrived on a topic a suspended isolate subscribed to (ADR 0001).
282
- * The bus worker sends `wake` on the control port. Called once per sleep.
283
- */
284
- onWake?: (isolateId: string, topic: string) => void;
285
- /** Seeding news for the host: rejected source records and ended seeds (ADR 0003, decision 18). */
286
- onSeed?: (e: SeedEvent) => void;
287
- };
288
- /**
289
- * Gets each record appended to a tapped topic (ADR 0020, decision 3), with
290
- * its estimated size. A tap is not a consumer: it has no cursor or credit.
291
- *
292
- * @internal
293
- */
294
- export type TapSink = (topic: string, rec: BusRecord, bytes: number) => void;
295
- /**
296
- * Who is publishing: an isolate (grants apply), the host (`kernel.publish`), or the kernel itself (system topics).
297
- *
298
- * @internal
299
- */
300
- export type Publisher = {
301
- kind: "isolate";
302
- isolateId: string;
303
- } | {
304
- kind: "host";
305
- } | {
306
- kind: "kernel";
307
- };
308
- /**
309
- * Cumulative counters for metrics (design §6.3); the bus worker turns them into rates.
310
- *
311
- * @internal
312
- */
313
- export type BrokerStats = {
314
- /** `head` and `retained` are the engine's, at the time of the sample (ADR 0020, decision 2). */
315
- topics: {
316
- topic: string;
317
- records: number;
318
- bytes: number;
319
- head: number;
320
- retained: number;
321
- }[];
322
- /** `lag` is `head − cursor`: records not yet delivered. */
323
- subscriptions: {
324
- consumer: string;
325
- topic: string;
326
- lag: number;
327
- credit: number;
328
- }[];
329
- /** Rejected publishes and requests, by error code. */
330
- rejected: Partial<Record<ErrorCode, number>>;
331
- };
332
- /**
333
- * A message's `(epoch, seq)`, when it carries both as numbers.
334
- *
335
- * @internal
336
- */
337
- export declare function publishId(p: {
338
- epoch?: unknown;
339
- seq?: unknown;
340
- }): AppendId | undefined;
1
+ import { a as InputOf, c as ReplyOutputOf, d as TopicDef, f as contracts, g as StandardSchemaV1, h as unchecked, i as DEFAULT_MAX_RECORD_BYTES, l as Retention, m as topic, n as Contracts, o as OutputOf, p as isContracts, r as ContractsError, s as ReplyInputOf, t as AnyTopicDef, u as ToolSpec } from "./topic-BkBLtTpT.js";
2
+ import { JSON_SCHEMA_TARGET, JsonSchema, JsonSchemaPair, JsonSchemaResult, NotExportableReason, StandardJSONSchemaV1, TopicJsonSchemas, TopicJsonSchemasResult, hasJsonSchema, jsonSchemaOf, topicJsonSchemas } from "@isoloop/protocol";
341
3
  /** Producer id for records the host publishes through `kernel.publish`. */
342
4
  export declare const HOST_PRODUCER = "host";
343
5
  /** Producer id for records the kernel publishes to system topics. */
344
6
  export declare const KERNEL_PRODUCER = "kernel";
345
7
  /** Requests are forgotten after this long when the caller gives no timeout. */
346
8
  export declare const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
347
- /**
348
- * The bus core (design §6.3): runs the publish pipeline, keeps subscriptions
349
- * and consumer groups, delivers from the log under credit, and routes
350
- * request replies. Knows nothing about workers; the bus worker entry wires
351
- * ports to it.
352
- *
353
- * @internal
354
- */
355
- export declare class Broker {
356
- #private;
357
- constructor(opts: BrokerOptions);
358
- /** Messages dropped as malformed or unknown (design §3: dropped and counted). */
359
- get dropped(): number;
360
- /** Counters for the 1 s metrics sample. */
361
- stats(): BrokerStats;
362
- /**
363
- * The origin's storage is full (M2b task 14): publishes to persistent
364
- * topics reject with `quota_exceeded`, memory topics carry on.
365
- */
366
- setStorageFull(full: boolean): void;
367
- /**
368
- * Writes what persistent topics have pending at once: the page is freezing
369
- * or going away (ADR 0001, what the browser still controls).
370
- */
371
- flush(): Promise<void>;
372
- /**
373
- * Starts every declared seed whose topic is empty and whose source has
374
- * records, or is seeding itself (ADR 0003, decision 18). The topics are
375
- * marked seeding before this returns, so call it before any connection is
376
- * attached. Resolves when every seed has ended. The bus worker calls it
377
- * only when it holds the files: elsewhere persistent topics start empty.
378
- */
379
- seed(): Promise<void>;
380
- /**
381
- * Why `kernel.dropTopic(name)` may not delete `name`, if it may not (ADR
382
- * 0003, decision 19): the contracts list it, a declared seed that reads it
383
- * hasn't ended, or seed records rejected from it are recorded and `force`
384
- * isn't set.
385
- */
386
- dropRefusal(name: string, force: boolean): CallResult | undefined;
387
- /** Persistent topics a declared seed reads that the contracts don't list. */
388
- get seedSources(): readonly string[];
389
- /** Retention pass over every topic (`time` and `compacted`); the bus worker runs it every second. */
390
- compact(): void;
391
- /**
392
- * Connects an isolate. A second attach for the same id replaces the first.
393
- * With `reattach`, the isolate was connected to a bus that restarted: its
394
- * first subscribe to each memory topic is answered with `reset` (ADR 0007).
395
- */
396
- attach(isolateId: string, grants: Grants, port: BusPort, opts?: {
397
- reattach?: boolean;
398
- }): void;
399
- /**
400
- * Disconnects an isolate, drops its subscriptions and leaves its groups,
401
- * which rebalance. With `keepOffsets` its commits stay, so a restart with
402
- * `from: 'committed'` resumes (I6). Replies to its pending requests are dropped.
403
- */
404
- detach(isolateId: string, keepOffsets: boolean, opts?: {
405
- wake?: boolean;
406
- }): void;
407
- /**
408
- * Publishes for the host (`kernel.publish`) or the kernel (system topics).
409
- * The host can't publish system topics; the kernel can only publish them.
410
- */
411
- publish(from: Publisher, topic: string, key: string | undefined, value: unknown, id?: AppendId): Promise<CallResult>;
412
- /**
413
- * A request from the host (`kernel.request`, ADR 0018, decision 4): like
414
- * an isolate's `bus.request`, with `req: { from: 'host', id, via }` on the
415
- * record. `answer` gets one result: a failure to append, or the first
416
- * valid reply (or `reply_invalid`). Nothing, if no reply comes before the
417
- * caller's timeout; the request is forgotten after `timeoutMs`.
418
- */
419
- request(topic: string, key: string | undefined, value: unknown, opts: {
420
- id: string;
421
- timeoutMs: number;
422
- via?: RequestVia;
423
- }, answer: (r: CallResult) => void, appendId?: AppendId): void;
424
- /**
425
- * The inspection feed's tap (ADR 0020, decision 3): `sink` gets every
426
- * record appended to a topic matching one of `patterns` from now on,
427
- * through the publish pipeline. Seeds copying into a topic before it opens
428
- * aren't tapped. Returns the function that ends it.
429
- */
430
- tap(patterns: readonly string[], sink: TapSink): () => void;
431
- /**
432
- * The last `last` retained records of `topic`, oldest first (ADR 0020,
433
- * decision 3), paging evicted records in from disk when needed. Seed
434
- * sources the contracts don't list are unknown here, as to isolates.
435
- */
436
- read(name: string, last: number): Promise<{
437
- ok: true;
438
- records: BusRecord[];
439
- } | {
440
- ok: false;
441
- error: CallError;
442
- }>;
443
- }
444
- /**
445
- * A rough structured size of a value in bytes, for `maxRecordBytes` (design
446
- * §6.1). Strings count two bytes per UTF-16 unit, numbers eight, object keys
447
- * like strings, plus a little per entry. Cycles count once. Cheap rather than
448
- * exact: it only has to tell a 1 KiB record from a 1 MiB one.
449
- *
450
- * @internal
451
- */
452
- export declare function estimateSize(value: unknown, limit?: number): number;
453
- export { AnyTopicDef, Contracts, ContractsError, DEFAULT_MAX_RECORD_BYTES, type EngineOptions, InputOf, JSON_SCHEMA_TARGET, type JsonSchema, type JsonSchemaPair, type JsonSchemaResult, type LogEngine, type LogStorage, type NewRecord, type NotExportableReason, OutputOf, ReplyInputOf, ReplyOutputOf, type Retention, type StandardJSONSchemaV1, StandardSchemaV1, type StoredState, type ToolSpec, TopicDef, type TopicJsonSchemas, type TopicJsonSchemasResult, type TsEngineOptions, contracts, hasJsonSchema, isContracts, isUnchecked, jsonSchemaOf, toIssues, topic, topicConfig, topicJsonSchemas, unchecked };
9
+ export { type AnyTopicDef, type Contracts, ContractsError, DEFAULT_MAX_RECORD_BYTES, type InputOf, JSON_SCHEMA_TARGET, type JsonSchema, type JsonSchemaPair, type JsonSchemaResult, type NotExportableReason, type OutputOf, type ReplyInputOf, type ReplyOutputOf, type Retention, type StandardJSONSchemaV1, type StandardSchemaV1, type ToolSpec, type TopicDef, type TopicJsonSchemas, type TopicJsonSchemasResult, contracts, hasJsonSchema, isContracts, jsonSchemaOf, topic, topicJsonSchemas, unchecked };