toilscript 0.1.53 → 0.1.55

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.53";
1
+ var ASSEMBLYSCRIPT_VERSION = "0.1.55";
2
2
  var ASSEMBLYSCRIPT_IMPORTMAP = {
3
3
  "imports": {
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",
4
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.55/dist/toilscript.js",
5
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.55/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.53",
11
+ "version": "0.1.55",
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,8 +440,8 @@ 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..=42` are cumulative COUNTERS (a rate is `value / seconds`); `43..=46` are the
444
- /// avg/peak series of the two GAUGES. Append-only: never renumber.
443
+ /// time-series. Ids `0..=41` are cumulative COUNTERS (a rate is `value / seconds`); `42..=45` are the
444
+ /// avg/peak series of the two GAUGES (ConnectedStreams, CommittedMemory). Append-only: never renumber.
445
445
  export enum MetricId {
446
446
  Requests = 0,
447
447
  BytesOutL1 = 1,
@@ -495,8 +495,9 @@ export enum MetricId {
495
495
  /// section.
496
496
  export const METRIC_COUNTERS: i32 = 42;
497
497
 
498
- /// A dashboard time range for `Analytics.series`. Short ranges (1h/6h) read the per-MINUTE ring; the rest
499
- /// read the per-HOUR ring (30-day retention).
498
+ /// A dashboard time range for `Analytics.series`. Short ranges (1h/6h) read the per-MINUTE ring; the long
499
+ /// ranges (60d/90d) read the per-DAY ring (90-day retention); the rest read the per-HOUR ring (30-day).
500
+ /// Append-only: never renumber (D60/D90 were added after D30, keeping the wire ids stable).
500
501
  export enum AnalyticsRange {
501
502
  H1 = 0,
502
503
  H6 = 1,
@@ -506,6 +507,8 @@ export enum AnalyticsRange {
506
507
  D7 = 5,
507
508
  D14 = 6,
508
509
  D30 = 7,
510
+ D60 = 8,
511
+ D90 = 9,
509
512
  }
510
513
 
511
514
  /// One tenant's analytics snapshot: the lifetime totals (indexed by `MetricId`, NO string keys), the two
@@ -522,6 +525,16 @@ export class TenantStats {
522
525
  reqMinuteCap: u64 = 0;
523
526
  reqDayUsed: u64 = 0;
524
527
  reqDayCap: u64 = 0;
528
+ /// LIVE per-second gauges (rates), computed edge-side from the last completed minute bucket so the
529
+ /// guest is STATELESS (no client diffing of two snapshots). Idle -> 0.0. `f64` (a rate is fractional
530
+ /// and bounded; f64 cannot overflow for any real value).
531
+ rps: f64 = 0;
532
+ bytesInPerSec: f64 = 0;
533
+ bytesOutPerSec: f64 = 0;
534
+ streamBytesInPerSec: f64 = 0;
535
+ streamBytesOutPerSec: f64 = 0;
536
+ dbOpsPerSec: f64 = 0;
537
+ gasPerSec: f64 = 0;
525
538
  /// Edge wall-clock (ms) when the snapshot was read.
526
539
  nowMs: u64 = 0;
527
540
 
@@ -589,19 +602,28 @@ export class TenantStats {
589
602
  }
590
603
  }
591
604
 
592
- /// One metric's time series for a range: `points` oldest→newest, `bucketSecs` the per-bucket width, and
593
- /// `headMs` the newest bucket's end. Rates are derived, never stored.
605
+ /// One metric's time series for a range: `points` oldest→newest (per-bucket totals, `u64` — non-negative),
606
+ /// `bucketSecs` the per-bucket width, and `headMs` the newest bucket's end. Rates are derived, never stored.
594
607
  export class Series {
595
608
  metric: MetricId = MetricId.Requests;
596
609
  bucketSecs: u32 = 0;
597
610
  headMs: u64 = 0;
598
- points: i64[] = [];
611
+ points: u64[] = [];
599
612
 
600
613
  /// Per-second rate of bucket `i` (its total divided by the bucket width). 0 for an out-of-range index.
601
614
  ratePerSec(i: i32): f64 {
602
615
  if (i < 0 || i >= this.points.length || this.bucketSecs == 0) return 0;
603
616
  return <f64>this.points[i] / <f64>this.bucketSecs;
604
617
  }
618
+
619
+ /// The CUMULATIVE total over the whole window (e.g. total bytes across a 30d/90d range). Folded into an
620
+ /// `f64` accumulator — NEVER a `u64`/`i64` sum, which could overflow a long byte-count window (AS has no
621
+ /// u128; `f64` max is 1.8e308, so it cannot overflow for any real value).
622
+ sum(): f64 {
623
+ let acc: f64 = 0;
624
+ for (let i = 0; i < this.points.length; i++) acc += <f64>this.points[i];
625
+ return acc;
626
+ }
605
627
  }
606
628
 
607
629
  /// A page of site names from `Analytics.listSites` (dacely.com only). When `hasMore` is
@@ -634,6 +656,16 @@ export class Analytics {
634
656
  stats.reqMinuteCap = r.readU64();
635
657
  stats.reqDayUsed = r.readU64();
636
658
  stats.reqDayCap = r.readU64();
659
+ // LIVE per-second rates (f64), appended after the windows. VERSION-GATE by LENGTH: a pre-rates
660
+ // (shorter) frame from an older edge exhausts the buffer here, so `readF64` returns 0.0 for each
661
+ // missing rate (DataReader is bounds-checked). No frame-version bump needed.
662
+ stats.rps = r.readF64();
663
+ stats.bytesInPerSec = r.readF64();
664
+ stats.bytesOutPerSec = r.readF64();
665
+ stats.streamBytesInPerSec = r.readF64();
666
+ stats.streamBytesOutPerSec = r.readF64();
667
+ stats.dbOpsPerSec = r.readF64();
668
+ stats.gasPerSec = r.readF64();
637
669
  return stats;
638
670
  }
639
671
 
@@ -646,8 +678,9 @@ export class Analytics {
646
678
  out.bucketSecs = r.readU32();
647
679
  out.headMs = r.readU64();
648
680
  const count = <i32>r.readU32();
649
- const pts = new Array<i64>(count);
650
- for (let i: i32 = 0; i < count && r.ok; i++) pts[i] = r.readI64();
681
+ // Points are non-negative per-bucket totals: read as u64 (matches the edge `u64 LE` series frame).
682
+ const pts = new Array<u64>(count);
683
+ for (let i: i32 = 0; i < count && r.ok; i++) pts[i] = r.readU64();
651
684
  out.points = pts;
652
685
  return out;
653
686
  }
@@ -283,7 +283,7 @@ declare class Events<K, V> {
283
283
  since(key: K, limit: i32): V[];
284
284
  }
285
285
 
286
- /** Every per-domain metric, by stable numeric id (the wire contract). `0..=42` are cumulative
286
+ /** Every per-domain metric, by stable numeric id (the wire contract). `0..=41` are cumulative
287
287
  * COUNTERS (rate = value/seconds); `42..=45` are the avg/peak series of the two GAUGES. */
288
288
  declare const enum MetricId {
289
289
  Requests = 0, BytesOutL1 = 1, BytesInL1 = 2,
@@ -301,9 +301,10 @@ declare const enum MetricId {
301
301
  ConnectedStreamsAvg = 42, ConnectedStreamsPeak = 43, CommittedMemoryAvg = 44, CommittedMemoryPeak = 45,
302
302
  }
303
303
 
304
- /** A dashboard time range for `Analytics.series`. 1h/6h are per-minute; the rest per-hour (30-day). */
304
+ /** A dashboard time range for `Analytics.series`. 1h/6h are per-minute; 60d/90d are per-day (90-day
305
+ * retention); the rest are per-hour (30-day). Append-only ids. */
305
306
  declare const enum AnalyticsRange {
306
- H1 = 0, H6 = 1, H12 = 2, H24 = 3, D3 = 4, D7 = 5, D14 = 6, D30 = 7,
307
+ H1 = 0, H6 = 1, H12 = 2, H24 = 3, D3 = 4, D7 = 5, D14 = 6, D30 = 7, D60 = 8, D90 = 9,
307
308
  }
308
309
 
309
310
  /** One tenant's analytics snapshot: lifetime totals (indexed by `MetricId`, no string keys), the two
@@ -362,17 +363,28 @@ declare class TenantStats {
362
363
  reqMinuteCap: u64;
363
364
  reqDayUsed: u64;
364
365
  reqDayCap: u64;
366
+ /** LIVE per-second gauges (rates), computed edge-side from the last completed minute bucket (idle 0.0),
367
+ * so no client diffing is needed. `f64` cannot overflow for any real value. */
368
+ readonly rps: f64;
369
+ readonly bytesInPerSec: f64;
370
+ readonly bytesOutPerSec: f64;
371
+ readonly streamBytesInPerSec: f64;
372
+ readonly streamBytesOutPerSec: f64;
373
+ readonly dbOpsPerSec: f64;
374
+ readonly gasPerSec: f64;
365
375
  nowMs: u64;
366
376
  }
367
377
 
368
- /** One metric's time series for a range: `points` oldest→newest, `bucketSecs` bucket width,
369
- * `headMs` newest bucket end. `ratePerSec(i)` derives the per-second rate of point `i`. */
378
+ /** One metric's time series for a range: `points` oldest→newest (per-bucket totals, `u64`), `bucketSecs`
379
+ * bucket width, `headMs` newest bucket end. `ratePerSec(i)` derives the per-second rate of point `i`;
380
+ * `sum()` folds the window into an `f64` cumulative (never a `u64` sum -> overflow-safe). */
370
381
  declare class Series {
371
382
  metric: MetricId;
372
383
  bucketSecs: u32;
373
384
  headMs: u64;
374
- points: i64[];
385
+ points: u64[];
375
386
  ratePerSec(i: i32): f64;
387
+ sum(): f64;
376
388
  }
377
389
 
378
390
  /** A page of site names from `Analytics.listSites` (dacely.com only). When `hasMore` is