toilscript 0.1.51 → 0.1.52

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "imports": {
3
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.51/dist/toilscript.js",
4
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.51/dist/cli.js",
3
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.52/dist/toilscript.js",
4
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.52/dist/cli.js",
5
5
  "binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0-nightly.20260609/index.js",
6
6
  "long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
7
7
  }
package/dist/web.js CHANGED
@@ -1,8 +1,8 @@
1
- var ASSEMBLYSCRIPT_VERSION = "0.1.51";
1
+ var ASSEMBLYSCRIPT_VERSION = "0.1.52";
2
2
  var ASSEMBLYSCRIPT_IMPORTMAP = {
3
3
  "imports": {
4
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.51/dist/toilscript.js",
5
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.51/dist/cli.js",
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",
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.51",
11
+ "version": "0.1.52",
12
12
  "author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",
13
13
  "license": "Apache-2.0",
14
14
  "homepage": "https://github.com/dacely-cloud/toilscript",
@@ -440,7 +440,7 @@ export class Counter<K> {
440
440
 
441
441
  /// Every per-domain metric, by stable numeric id. This is the WIRE CONTRACT shared with the edge
442
442
  /// (`src/analytics/metric_id.rs`) and the dev server; it orders the snapshot frame and addresses a
443
- /// time-series. Ids `0..=40` are cumulative COUNTERS (a rate is `value / seconds`); `41..=44` are the
443
+ /// time-series. Ids `0..=42` are cumulative COUNTERS (a rate is `value / seconds`); `43..=46` are the
444
444
  /// avg/peak series of the two GAUGES. Append-only: never renumber.
445
445
  export enum MetricId {
446
446
  Requests = 0,
@@ -484,15 +484,17 @@ export enum MetricId {
484
484
  DaemonHttpCallFailures = 38,
485
485
  MemGrownBytes = 39,
486
486
  Emails = 40,
487
- ConnectedStreamsAvg = 41,
488
- ConnectedStreamsPeak = 42,
489
- CommittedMemoryAvg = 43,
490
- CommittedMemoryPeak = 44,
487
+ CacheHits = 41,
488
+ CacheMisses = 42,
489
+ ConnectedStreamsAvg = 43,
490
+ ConnectedStreamsPeak = 44,
491
+ CommittedMemoryAvg = 45,
492
+ CommittedMemoryPeak = 46,
491
493
  }
492
494
 
493
- /// The number of cumulative counter metrics (`MetricId 0..=40`) = the length of the snapshot's lifetime
495
+ /// The number of cumulative counter metrics (`MetricId 0..=42`) = the length of the snapshot's lifetime
494
496
  /// section.
495
- export const METRIC_COUNTERS: i32 = 41;
497
+ export const METRIC_COUNTERS: i32 = 43;
496
498
 
497
499
  /// A dashboard time range for `Analytics.series`. Short ranges (1h/6h) read the per-MINUTE ring; the rest
498
500
  /// read the per-HOUR ring (30-day retention).
@@ -512,56 +514,81 @@ export enum AnalyticsRange {
512
514
  /// value either by the typed getter (`stats.requests`) or by id (`stats.metric(MetricId.Requests)`).
513
515
  export class TenantStats {
514
516
  /// Lifetime totals indexed by `MetricId` (length `METRIC_COUNTERS`). Prefer the named getters below.
515
- life: StaticArray<i64> = new StaticArray<i64>(METRIC_COUNTERS);
517
+ life: StaticArray<u64> = new StaticArray<u64>(METRIC_COUNTERS);
516
518
  /// Live gauges (current level, not a total).
517
- connectedStreams: i64 = 0;
518
- committedMemory: i64 = 0;
519
+ connectedStreams: u64 = 0;
520
+ committedMemory: u64 = 0;
519
521
  /// Request windows: current bucket usage + plan cap (0 = unlimited).
520
- reqMinuteUsed: i64 = 0;
522
+ reqMinuteUsed: u64 = 0;
521
523
  reqMinuteCap: u64 = 0;
522
- reqDayUsed: i64 = 0;
524
+ reqDayUsed: u64 = 0;
523
525
  reqDayCap: u64 = 0;
524
526
  /// Edge wall-clock (ms) when the snapshot was read.
525
527
  nowMs: u64 = 0;
526
528
 
527
529
  /// Any counter metric by id (0 for an out-of-range id).
528
- metric(id: MetricId): i64 {
530
+ metric(id: MetricId): u64 {
529
531
  return <i32>id < METRIC_COUNTERS ? this.life[<i32>id] : 0;
530
532
  }
531
533
 
532
534
  // Typed getters for every counter (the catalog: no magic strings, self-documenting).
533
- get requests(): i64 { return this.life[MetricId.Requests]; }
534
- get bytesOutL1(): i64 { return this.life[MetricId.BytesOutL1]; }
535
- get bytesInL1(): i64 { return this.life[MetricId.BytesInL1]; }
536
- get status2xx(): i64 { return this.life[MetricId.Status2xx]; }
537
- get status3xx(): i64 { return this.life[MetricId.Status3xx]; }
538
- get status4xx(): i64 { return this.life[MetricId.Status4xx]; }
539
- get status5xx(): i64 { return this.life[MetricId.Status5xx]; }
540
- get staticHits(): i64 { return this.life[MetricId.StaticHits]; }
541
- get wasmDispatches(): i64 { return this.life[MetricId.WasmDispatches]; }
542
- get executorFullRejects(): i64 { return this.life[MetricId.ExecutorFullRejects]; }
543
- get unknownHostRejects(): i64 { return this.life[MetricId.UnknownHostRejects]; }
544
- get rateLimitedRejects(): i64 { return this.life[MetricId.RateLimitedRejects]; }
545
- get gasUsed(): i64 { return this.life[MetricId.GasUsed]; }
546
- get dbOps(): i64 { return this.life[MetricId.DbOps]; }
547
- get dbReads(): i64 { return this.life[MetricId.DbReads]; }
548
- get dbWrites(): i64 { return this.life[MetricId.DbWrites]; }
549
- get dbErrors(): i64 { return this.life[MetricId.DbErrors]; }
550
- get dbLatencyNsSum(): i64 { return this.life[MetricId.DbLatencyNsSum]; }
551
- get streamAccepts(): i64 { return this.life[MetricId.StreamAccepts]; }
552
- get streamBytesIn(): i64 { return this.life[MetricId.StreamBytesIn]; }
553
- get streamBytesOut(): i64 { return this.life[MetricId.StreamBytesOut]; }
554
- get streamCloses(): i64 { return this.life[MetricId.StreamCloses]; }
555
- get streamDisconnects(): i64 { return this.life[MetricId.StreamDisconnects]; }
556
- get daemonTicks(): i64 { return this.life[MetricId.DaemonTicksFired]; }
557
- get memGrownBytes(): i64 { return this.life[MetricId.MemGrownBytes]; }
558
- get emails(): i64 { return this.life[MetricId.Emails]; }
535
+ get requests(): u64 { return this.life[MetricId.Requests]; }
536
+ get bytesOutL1(): u64 { return this.life[MetricId.BytesOutL1]; }
537
+ get bytesInL1(): u64 { return this.life[MetricId.BytesInL1]; }
538
+ get status2xx(): u64 { return this.life[MetricId.Status2xx]; }
539
+ get status3xx(): u64 { return this.life[MetricId.Status3xx]; }
540
+ get status4xx(): u64 { return this.life[MetricId.Status4xx]; }
541
+ get status5xx(): u64 { return this.life[MetricId.Status5xx]; }
542
+ get staticHits(): u64 { return this.life[MetricId.StaticHits]; }
543
+ get wasmDispatches(): u64 { return this.life[MetricId.WasmDispatches]; }
544
+ get executorFullRejects(): u64 { return this.life[MetricId.ExecutorFullRejects]; }
545
+ get unknownHostRejects(): u64 { return this.life[MetricId.UnknownHostRejects]; }
546
+ get rateLimitedRejects(): u64 { return this.life[MetricId.RateLimitedRejects]; }
547
+ get gasUsed(): u64 { return this.life[MetricId.GasUsed]; }
548
+ get dbOps(): u64 { return this.life[MetricId.DbOps]; }
549
+ get dbReads(): u64 { return this.life[MetricId.DbReads]; }
550
+ get dbWrites(): u64 { return this.life[MetricId.DbWrites]; }
551
+ get dbErrors(): u64 { return this.life[MetricId.DbErrors]; }
552
+ get dbLatencyNsSum(): u64 { return this.life[MetricId.DbLatencyNsSum]; }
553
+ get streamAccepts(): u64 { return this.life[MetricId.StreamAccepts]; }
554
+ get streamRejectWrongNode(): u64 { return this.life[MetricId.StreamRejectWrongNode]; }
555
+ get streamRejectCapacity(): u64 { return this.life[MetricId.StreamRejectCapacity]; }
556
+ get streamRejectArtifact(): u64 { return this.life[MetricId.StreamRejectArtifact]; }
557
+ get streamRejectGuest(): u64 { return this.life[MetricId.StreamRejectGuest]; }
558
+ get streamTraps(): u64 { return this.life[MetricId.StreamTraps]; }
559
+ get streamIdleTimeouts(): u64 { return this.life[MetricId.StreamIdleTimeouts]; }
560
+ get streamBytesIn(): u64 { return this.life[MetricId.StreamBytesIn]; }
561
+ get streamBytesOut(): u64 { return this.life[MetricId.StreamBytesOut]; }
562
+ get streamBackpressureEvents(): u64 { return this.life[MetricId.StreamBackpressureEvents]; }
563
+ get streamCloses(): u64 { return this.life[MetricId.StreamCloses]; }
564
+ get streamDisconnects(): u64 { return this.life[MetricId.StreamDisconnects]; }
565
+ get daemonStarts(): u64 { return this.life[MetricId.DaemonStarts]; }
566
+ get daemonStartFailures(): u64 { return this.life[MetricId.DaemonStartFailures]; }
567
+ get daemonTicksFired(): u64 { return this.life[MetricId.DaemonTicksFired]; }
568
+ get daemonTicksSkippedNotLeader(): u64 { return this.life[MetricId.DaemonTicksSkippedNotLeader]; }
569
+ get daemonTicksFailed(): u64 { return this.life[MetricId.DaemonTicksFailed]; }
570
+ get daemonLeaderAcquires(): u64 { return this.life[MetricId.DaemonLeaderAcquires]; }
571
+ get daemonLeaderFenced(): u64 { return this.life[MetricId.DaemonLeaderFenced]; }
572
+ get daemonHttpCallAttempts(): u64 { return this.life[MetricId.DaemonHttpCallAttempts]; }
573
+ get daemonHttpCallFailures(): u64 { return this.life[MetricId.DaemonHttpCallFailures]; }
574
+ get memGrownBytes(): u64 { return this.life[MetricId.MemGrownBytes]; }
575
+ get emails(): u64 { return this.life[MetricId.Emails]; }
576
+ get cacheHits(): u64 { return this.life[MetricId.CacheHits]; }
577
+ get cacheMisses(): u64 { return this.life[MetricId.CacheMisses]; }
559
578
 
560
579
  /// Mean host-observed DB op latency (ns), or 0 with no ops.
561
- get meanDbLatencyNs(): i64 {
580
+ get meanDbLatencyNs(): u64 {
562
581
  const ops = this.dbOps;
563
582
  return ops > 0 ? this.dbLatencyNsSum / ops : 0;
564
583
  }
584
+
585
+ /// Fraction of cacheable responses served from cache (`hits / (hits + misses)`),
586
+ /// 0.0 when there were no cacheable responses.
587
+ get cacheRatio(): f64 {
588
+ const hits = this.cacheHits;
589
+ const total = hits + this.cacheMisses;
590
+ return total > 0 ? <f64>hits / <f64>total : 0.0;
591
+ }
565
592
  }
566
593
 
567
594
  /// One metric's time series for a range: `points` oldest→newest, `bucketSecs` the per-bucket width, and
@@ -599,14 +626,15 @@ export class Analytics {
599
626
  stats.nowMs = r.readU64();
600
627
  const count = <i32>r.readU32();
601
628
  for (let i: i32 = 0; i < count && r.ok; i++) {
602
- const v = r.readI64();
629
+ // Wire fields are non-negative i64; read the same bytes as u64.
630
+ const v = r.readU64();
603
631
  if (i < METRIC_COUNTERS) stats.life[i] = v; // ignore any extra (forward-compat)
604
632
  }
605
- stats.connectedStreams = r.readI64();
606
- stats.committedMemory = r.readI64();
607
- stats.reqMinuteUsed = r.readI64();
633
+ stats.connectedStreams = r.readU64();
634
+ stats.committedMemory = r.readU64();
635
+ stats.reqMinuteUsed = r.readU64();
608
636
  stats.reqMinuteCap = r.readU64();
609
- stats.reqDayUsed = r.readI64();
637
+ stats.reqDayUsed = r.readU64();
610
638
  stats.reqDayCap = r.readU64();
611
639
  return stats;
612
640
  }
@@ -282,8 +282,8 @@ declare class Events<K, V> {
282
282
  latest(key: K, limit: i32): V[];
283
283
  }
284
284
 
285
- /** Every per-domain metric, by stable numeric id (the wire contract). `0..=40` are cumulative
286
- * COUNTERS (rate = value/seconds); `41..=44` are the avg/peak series of the two GAUGES. */
285
+ /** 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
287
  declare const enum MetricId {
288
288
  Requests = 0, BytesOutL1 = 1, BytesInL1 = 2,
289
289
  Status2xx = 3, Status3xx = 4, Status4xx = 5, Status5xx = 6,
@@ -296,7 +296,8 @@ declare const enum MetricId {
296
296
  DaemonStarts = 30, DaemonStartFailures = 31, DaemonTicksFired = 32, DaemonTicksSkippedNotLeader = 33,
297
297
  DaemonTicksFailed = 34, DaemonLeaderAcquires = 35, DaemonLeaderFenced = 36,
298
298
  DaemonHttpCallAttempts = 37, DaemonHttpCallFailures = 38, MemGrownBytes = 39, Emails = 40,
299
- ConnectedStreamsAvg = 41, ConnectedStreamsPeak = 42, CommittedMemoryAvg = 43, CommittedMemoryPeak = 44,
299
+ CacheHits = 41, CacheMisses = 42,
300
+ ConnectedStreamsAvg = 43, ConnectedStreamsPeak = 44, CommittedMemoryAvg = 45, CommittedMemoryPeak = 46,
300
301
  }
301
302
 
302
303
  /** A dashboard time range for `Analytics.series`. 1h/6h are per-minute; the rest per-hour (30-day). */
@@ -308,39 +309,58 @@ declare const enum AnalyticsRange {
308
309
  * live gauge levels, and the request windows (current usage + plan cap; cap 0 = unlimited). Read a
309
310
  * value by typed getter (`stats.requests`) or by id (`stats.metric(MetricId.Requests)`). */
310
311
  declare class TenantStats {
311
- metric(id: MetricId): i64;
312
- readonly requests: i64;
313
- readonly bytesOutL1: i64;
314
- readonly bytesInL1: i64;
315
- readonly status2xx: i64;
316
- readonly status3xx: i64;
317
- readonly status4xx: i64;
318
- readonly status5xx: i64;
319
- readonly staticHits: i64;
320
- readonly wasmDispatches: i64;
321
- readonly executorFullRejects: i64;
322
- readonly unknownHostRejects: i64;
323
- readonly rateLimitedRejects: i64;
324
- readonly gasUsed: i64;
325
- readonly dbOps: i64;
326
- readonly dbReads: i64;
327
- readonly dbWrites: i64;
328
- readonly dbErrors: i64;
329
- readonly dbLatencyNsSum: i64;
330
- readonly meanDbLatencyNs: i64;
331
- readonly streamAccepts: i64;
332
- readonly streamBytesIn: i64;
333
- readonly streamBytesOut: i64;
334
- readonly streamCloses: i64;
335
- readonly streamDisconnects: i64;
336
- readonly daemonTicks: i64;
337
- readonly memGrownBytes: i64;
338
- readonly emails: i64;
339
- connectedStreams: i64;
340
- committedMemory: i64;
341
- reqMinuteUsed: i64;
312
+ metric(id: MetricId): u64;
313
+ readonly requests: u64;
314
+ readonly bytesOutL1: u64;
315
+ readonly bytesInL1: u64;
316
+ readonly status2xx: u64;
317
+ readonly status3xx: u64;
318
+ readonly status4xx: u64;
319
+ readonly status5xx: u64;
320
+ readonly staticHits: u64;
321
+ readonly wasmDispatches: u64;
322
+ readonly executorFullRejects: u64;
323
+ readonly unknownHostRejects: u64;
324
+ readonly rateLimitedRejects: u64;
325
+ readonly gasUsed: u64;
326
+ readonly dbOps: u64;
327
+ readonly dbReads: u64;
328
+ readonly dbWrites: u64;
329
+ readonly dbErrors: u64;
330
+ readonly dbLatencyNsSum: u64;
331
+ readonly meanDbLatencyNs: u64;
332
+ readonly streamAccepts: u64;
333
+ readonly streamRejectWrongNode: u64;
334
+ readonly streamRejectCapacity: u64;
335
+ readonly streamRejectArtifact: u64;
336
+ readonly streamRejectGuest: u64;
337
+ readonly streamTraps: u64;
338
+ readonly streamIdleTimeouts: u64;
339
+ readonly streamBytesIn: u64;
340
+ readonly streamBytesOut: u64;
341
+ readonly streamBackpressureEvents: u64;
342
+ readonly streamCloses: u64;
343
+ readonly streamDisconnects: u64;
344
+ readonly daemonStarts: u64;
345
+ readonly daemonStartFailures: u64;
346
+ readonly daemonTicksFired: u64;
347
+ readonly daemonTicksSkippedNotLeader: u64;
348
+ readonly daemonTicksFailed: u64;
349
+ readonly daemonLeaderAcquires: u64;
350
+ readonly daemonLeaderFenced: u64;
351
+ readonly daemonHttpCallAttempts: u64;
352
+ readonly daemonHttpCallFailures: u64;
353
+ readonly memGrownBytes: u64;
354
+ readonly emails: u64;
355
+ readonly cacheHits: u64;
356
+ readonly cacheMisses: u64;
357
+ /** Fraction of cacheable responses served from cache (`hits / (hits + misses)`), 0.0 when none. */
358
+ readonly cacheRatio: f64;
359
+ connectedStreams: u64;
360
+ committedMemory: u64;
361
+ reqMinuteUsed: u64;
342
362
  reqMinuteCap: u64;
343
- reqDayUsed: i64;
363
+ reqDayUsed: u64;
344
364
  reqDayCap: u64;
345
365
  nowMs: u64;
346
366
  }