toilscript 0.1.52 → 0.1.53

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/dist/web.js CHANGED
@@ -1,8 +1,8 @@
1
- var ASSEMBLYSCRIPT_VERSION = "0.1.52";
1
+ var ASSEMBLYSCRIPT_VERSION = "0.1.53";
2
2
  var ASSEMBLYSCRIPT_IMPORTMAP = {
3
3
  "imports": {
4
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.52/dist/toilscript.js",
5
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.52/dist/cli.js",
4
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.53/dist/toilscript.js",
5
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.53/dist/cli.js",
6
6
  "binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0-nightly.20260609/index.js",
7
7
  "long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
8
8
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "toilscript",
9
9
  "wasm"
10
10
  ],
11
- "version": "0.1.52",
11
+ "version": "0.1.53",
12
12
  "author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",
13
13
  "license": "Apache-2.0",
14
14
  "homepage": "https://github.com/dacely-cloud/toilscript",
@@ -223,6 +223,10 @@ export namespace toildbHost {
223
223
  @external("env", "data.latest")
224
224
  export declare function latest(handle: u32, keyPtr: usize, keyLen: i32, limit: i32): i32;
225
225
 
226
+ // @ts-ignore: decorator
227
+ @external("env", "data.events_since")
228
+ export declare function eventsSince(handle: u32, keyPtr: usize, keyLen: i32, limit: i32): i32;
229
+
226
230
  // events.append_once -> 1 appended | 0 duplicate (deduped on eventId) | <0 error.
227
231
  // Idempotent append: a retried call with the same eventId never doubles the event.
228
232
  // @ts-ignore: decorator
@@ -451,50 +451,49 @@ export enum MetricId {
451
451
  Status4xx = 5,
452
452
  Status5xx = 6,
453
453
  StaticHits = 7,
454
- WasmDispatches = 8,
455
- ExecutorFullRejects = 9,
456
- UnknownHostRejects = 10,
457
- RateLimitedRejects = 11,
458
- GasUsed = 12,
459
- DbOps = 13,
460
- DbReads = 14,
461
- DbWrites = 15,
462
- DbErrors = 16,
463
- DbLatencyNsSum = 17,
464
- StreamAccepts = 18,
465
- StreamRejectWrongNode = 19,
466
- StreamRejectCapacity = 20,
467
- StreamRejectArtifact = 21,
468
- StreamRejectGuest = 22,
469
- StreamTraps = 23,
470
- StreamIdleTimeouts = 24,
471
- StreamBytesIn = 25,
472
- StreamBytesOut = 26,
473
- StreamBackpressureEvents = 27,
474
- StreamCloses = 28,
475
- StreamDisconnects = 29,
476
- DaemonStarts = 30,
477
- DaemonStartFailures = 31,
478
- DaemonTicksFired = 32,
479
- DaemonTicksSkippedNotLeader = 33,
480
- DaemonTicksFailed = 34,
481
- DaemonLeaderAcquires = 35,
482
- DaemonLeaderFenced = 36,
483
- DaemonHttpCallAttempts = 37,
484
- DaemonHttpCallFailures = 38,
485
- MemGrownBytes = 39,
486
- Emails = 40,
487
- CacheHits = 41,
488
- CacheMisses = 42,
489
- ConnectedStreamsAvg = 43,
490
- ConnectedStreamsPeak = 44,
491
- CommittedMemoryAvg = 45,
492
- CommittedMemoryPeak = 46,
454
+ ExecutorFullRejects = 8,
455
+ UnknownHostRejects = 9,
456
+ RateLimitedRejects = 10,
457
+ GasUsed = 11,
458
+ DbOps = 12,
459
+ DbReads = 13,
460
+ DbWrites = 14,
461
+ DbErrors = 15,
462
+ DbLatencyNsSum = 16,
463
+ StreamAccepts = 17,
464
+ StreamRejectWrongNode = 18,
465
+ StreamRejectCapacity = 19,
466
+ StreamRejectArtifact = 20,
467
+ StreamRejectGuest = 21,
468
+ StreamTraps = 22,
469
+ StreamIdleTimeouts = 23,
470
+ StreamBytesIn = 24,
471
+ StreamBytesOut = 25,
472
+ StreamBackpressureEvents = 26,
473
+ StreamCloses = 27,
474
+ StreamDisconnects = 28,
475
+ DaemonStarts = 29,
476
+ DaemonStartFailures = 30,
477
+ DaemonTicksFired = 31,
478
+ DaemonTicksSkippedNotLeader = 32,
479
+ DaemonTicksFailed = 33,
480
+ DaemonLeaderAcquires = 34,
481
+ DaemonLeaderFenced = 35,
482
+ DaemonHttpCallAttempts = 36,
483
+ DaemonHttpCallFailures = 37,
484
+ MemGrownBytes = 38,
485
+ Emails = 39,
486
+ CacheHits = 40,
487
+ CacheMisses = 41,
488
+ ConnectedStreamsAvg = 42,
489
+ ConnectedStreamsPeak = 43,
490
+ CommittedMemoryAvg = 44,
491
+ CommittedMemoryPeak = 45,
493
492
  }
494
493
 
495
- /// The number of cumulative counter metrics (`MetricId 0..=42`) = the length of the snapshot's lifetime
494
+ /// The number of cumulative counter metrics (`MetricId 0..=41`) = the length of the snapshot's lifetime
496
495
  /// section.
497
- export const METRIC_COUNTERS: i32 = 43;
496
+ export const METRIC_COUNTERS: i32 = 42;
498
497
 
499
498
  /// A dashboard time range for `Analytics.series`. Short ranges (1h/6h) read the per-MINUTE ring; the rest
500
499
  /// read the per-HOUR ring (30-day retention).
@@ -540,7 +539,6 @@ export class TenantStats {
540
539
  get status4xx(): u64 { return this.life[MetricId.Status4xx]; }
541
540
  get status5xx(): u64 { return this.life[MetricId.Status5xx]; }
542
541
  get staticHits(): u64 { return this.life[MetricId.StaticHits]; }
543
- get wasmDispatches(): u64 { return this.life[MetricId.WasmDispatches]; }
544
542
  get executorFullRejects(): u64 { return this.life[MetricId.ExecutorFullRejects]; }
545
543
  get unknownHostRejects(): u64 { return this.life[MetricId.UnknownHostRejects]; }
546
544
  get rateLimitedRejects(): u64 { return this.life[MetricId.RateLimitedRejects]; }
@@ -735,6 +733,34 @@ export class Events<K, V> {
735
733
  return status == 1;
736
734
  }
737
735
 
736
+ /// The NEXT batch of events for `key` past this derive's checkpoint, OLDEST first, up to `limit`. The
737
+ /// host owns the resumable cursor (seeded from the durable checkpoint and advanced/committed around the
738
+ /// fold), so repeated calls drain an unbounded log in bounded batches and return an empty array once
739
+ /// caught up. Use it in a `@derive` (or `@job`) to fold a growing log incrementally instead of rescanning:
740
+ /// `for (const e of this.events.since(key, 500)) { ...update the view... }`, looping until it is empty.
741
+ /// The fold must be idempotent per event (a heal can trigger a full re-read). Same frame as `latest`.
742
+ since(key: K, limit: i32): V[] {
743
+ const kb = key.encode();
744
+ const status = toildbHost.eventsSince(this.__handle, kb.dataStart, kb.byteLength, limit);
745
+ if (status < 0) unreachable();
746
+ const blob = __toildbTake(status);
747
+ const out = new Array<V>();
748
+ let off: i32 = 0;
749
+ const count = load<u32>(blob.dataStart + off);
750
+ off += 4;
751
+ for (let i: u32 = 0; i < count; i++) {
752
+ const ver = <i64>load<u32>(blob.dataStart + off);
753
+ off += 4;
754
+ const len = <i32>load<u32>(blob.dataStart + off);
755
+ off += 4;
756
+ const ev = instantiate<V>();
757
+ ev.decodeIntoVersioned(blob.subarray(off, off + len), ver);
758
+ out.push(ev);
759
+ off += len;
760
+ }
761
+ return out;
762
+ }
763
+
738
764
  /// The newest `limit` events, newest first. Decodes each framed event into a
739
765
  /// `V`. The host frames them as `u32 count` then per event
740
766
  /// `u32 schema_version + u32 len + bytes`.
@@ -280,24 +280,25 @@ declare class Counter<K> {
280
280
  declare class Events<K, V> {
281
281
  append(key: K, event: V): void;
282
282
  latest(key: K, limit: i32): V[];
283
+ since(key: K, limit: i32): V[];
283
284
  }
284
285
 
285
286
  /** Every per-domain metric, by stable numeric id (the wire contract). `0..=42` are cumulative
286
- * COUNTERS (rate = value/seconds); `43..=46` are the avg/peak series of the two GAUGES. */
287
+ * COUNTERS (rate = value/seconds); `42..=45` are the avg/peak series of the two GAUGES. */
287
288
  declare const enum MetricId {
288
289
  Requests = 0, BytesOutL1 = 1, BytesInL1 = 2,
289
290
  Status2xx = 3, Status3xx = 4, Status4xx = 5, Status5xx = 6,
290
- StaticHits = 7, WasmDispatches = 8,
291
- ExecutorFullRejects = 9, UnknownHostRejects = 10, RateLimitedRejects = 11, GasUsed = 12,
292
- DbOps = 13, DbReads = 14, DbWrites = 15, DbErrors = 16, DbLatencyNsSum = 17,
293
- StreamAccepts = 18, StreamRejectWrongNode = 19, StreamRejectCapacity = 20, StreamRejectArtifact = 21,
294
- StreamRejectGuest = 22, StreamTraps = 23, StreamIdleTimeouts = 24, StreamBytesIn = 25,
295
- StreamBytesOut = 26, StreamBackpressureEvents = 27, StreamCloses = 28, StreamDisconnects = 29,
296
- DaemonStarts = 30, DaemonStartFailures = 31, DaemonTicksFired = 32, DaemonTicksSkippedNotLeader = 33,
297
- DaemonTicksFailed = 34, DaemonLeaderAcquires = 35, DaemonLeaderFenced = 36,
298
- DaemonHttpCallAttempts = 37, DaemonHttpCallFailures = 38, MemGrownBytes = 39, Emails = 40,
299
- CacheHits = 41, CacheMisses = 42,
300
- ConnectedStreamsAvg = 43, ConnectedStreamsPeak = 44, CommittedMemoryAvg = 45, CommittedMemoryPeak = 46,
291
+ StaticHits = 7,
292
+ ExecutorFullRejects = 8, UnknownHostRejects = 9, RateLimitedRejects = 10, GasUsed = 11,
293
+ DbOps = 12, DbReads = 13, DbWrites = 14, DbErrors = 15, DbLatencyNsSum = 16,
294
+ StreamAccepts = 17, StreamRejectWrongNode = 18, StreamRejectCapacity = 19, StreamRejectArtifact = 20,
295
+ StreamRejectGuest = 21, StreamTraps = 22, StreamIdleTimeouts = 23, StreamBytesIn = 24,
296
+ StreamBytesOut = 25, StreamBackpressureEvents = 26, StreamCloses = 27, StreamDisconnects = 28,
297
+ DaemonStarts = 29, DaemonStartFailures = 30, DaemonTicksFired = 31, DaemonTicksSkippedNotLeader = 32,
298
+ DaemonTicksFailed = 33, DaemonLeaderAcquires = 34, DaemonLeaderFenced = 35,
299
+ DaemonHttpCallAttempts = 36, DaemonHttpCallFailures = 37, MemGrownBytes = 38, Emails = 39,
300
+ CacheHits = 40, CacheMisses = 41,
301
+ ConnectedStreamsAvg = 42, ConnectedStreamsPeak = 43, CommittedMemoryAvg = 44, CommittedMemoryPeak = 45,
301
302
  }
302
303
 
303
304
  /** A dashboard time range for `Analytics.series`. 1h/6h are per-minute; the rest per-hour (30-day). */
@@ -318,7 +319,6 @@ declare class TenantStats {
318
319
  readonly status4xx: u64;
319
320
  readonly status5xx: u64;
320
321
  readonly staticHits: u64;
321
- readonly wasmDispatches: u64;
322
322
  readonly executorFullRejects: u64;
323
323
  readonly unknownHostRejects: u64;
324
324
  readonly rateLimitedRejects: u64;