@janssenproject/cedarling_wasm 0.0.472 → 0.0.474

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.
@@ -705,6 +705,38 @@ var Cedarling = class _Cedarling {
705
705
  wasm.__wbindgen_add_to_stack_pointer(16);
706
706
  }
707
707
  }
708
+ /**
709
+ * Destructive read: returns the telemetry metrics snapshot and resets
710
+ * the counters for the next interval.
711
+ *
712
+ * Fails when `CEDARLING_METRICS_COLLECTION` is disabled or whenever
713
+ * `CEDARLING_LOCK_TELEMETRY_INTERVAL` is set (even if the Lock server
714
+ * has no telemetry endpoint). `interval_secs` is fractional seconds,
715
+ * so sub-second intervals are reported exactly.
716
+ *
717
+ * # Example
718
+ *
719
+ * ```javascript
720
+ * const snapshot = cedarling.drainMetrics();
721
+ * console.log(`Requests: ${snapshot.operational_stats.get("authz.requests_total")}`);
722
+ * ```
723
+ * @returns {MetricsSnapshot}
724
+ */
725
+ drainMetrics() {
726
+ try {
727
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
728
+ wasm.cedarling_drainMetrics(retptr, this.__wbg_ptr);
729
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
730
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
731
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
732
+ if (r2) {
733
+ throw takeObject(r1);
734
+ }
735
+ return MetricsSnapshot.__wrap(r0);
736
+ } finally {
737
+ wasm.__wbindgen_add_to_stack_pointer(16);
738
+ }
739
+ }
708
740
  /**
709
741
  * Get trusted issuer identifiers that failed to load.
710
742
  *
@@ -1821,6 +1853,119 @@ var IntoUnderlyingSource = class {
1821
1853
  }
1822
1854
  };
1823
1855
  if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
1856
+ var MetricsSnapshot = class _MetricsSnapshot {
1857
+ static __wrap(ptr) {
1858
+ const obj = Object.create(_MetricsSnapshot.prototype);
1859
+ obj.__wbg_ptr = ptr;
1860
+ MetricsSnapshotFinalization.register(obj, obj.__wbg_ptr, obj);
1861
+ return obj;
1862
+ }
1863
+ __destroy_into_raw() {
1864
+ const ptr = this.__wbg_ptr;
1865
+ this.__wbg_ptr = 0;
1866
+ MetricsSnapshotFinalization.unregister(this);
1867
+ return ptr;
1868
+ }
1869
+ free() {
1870
+ const ptr = this.__destroy_into_raw();
1871
+ wasm.__wbg_metricssnapshot_free(ptr, 0);
1872
+ }
1873
+ /**
1874
+ * Classified error counters keyed by error metric key.
1875
+ * @returns {Map<any, any>}
1876
+ */
1877
+ get error_counters() {
1878
+ const ret = wasm.__wbg_get_metricssnapshot_error_counters(this.__wbg_ptr);
1879
+ return takeObject(ret);
1880
+ }
1881
+ /**
1882
+ * Duration of the snapshot interval in fractional seconds.
1883
+ * Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
1884
+ * @returns {number}
1885
+ */
1886
+ get interval_secs() {
1887
+ const ret = wasm.__wbg_get_metricssnapshot_interval_secs(this.__wbg_ptr);
1888
+ return ret;
1889
+ }
1890
+ /**
1891
+ * Operational counters and gauges (authorization, cache, JWT, data, lock).
1892
+ * @returns {Map<any, any>}
1893
+ */
1894
+ get operational_stats() {
1895
+ const ret = wasm.__wbg_get_metricssnapshot_operational_stats(this.__wbg_ptr);
1896
+ return takeObject(ret);
1897
+ }
1898
+ /**
1899
+ * Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
1900
+ * @returns {Map<any, any>}
1901
+ */
1902
+ get policy_stats() {
1903
+ const ret = wasm.__wbg_get_metricssnapshot_policy_stats(this.__wbg_ptr);
1904
+ return takeObject(ret);
1905
+ }
1906
+ /**
1907
+ * Convert `MetricsSnapshot` to json string value.
1908
+ *
1909
+ * `policy_stats`, `error_counters` and `operational_stats` are converted
1910
+ * from `Map` to plain objects so `JSON.stringify` emits their entries.
1911
+ * @returns {string}
1912
+ */
1913
+ jsonString() {
1914
+ let deferred2_0;
1915
+ let deferred2_1;
1916
+ try {
1917
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1918
+ wasm.metricssnapshot_jsonString(retptr, this.__wbg_ptr);
1919
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1920
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1921
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1922
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1923
+ var ptr1 = r0;
1924
+ var len1 = r1;
1925
+ if (r3) {
1926
+ ptr1 = 0;
1927
+ len1 = 0;
1928
+ throw takeObject(r2);
1929
+ }
1930
+ deferred2_0 = ptr1;
1931
+ deferred2_1 = len1;
1932
+ return getStringFromWasm0(ptr1, len1);
1933
+ } finally {
1934
+ wasm.__wbindgen_add_to_stack_pointer(16);
1935
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1936
+ }
1937
+ }
1938
+ /**
1939
+ * Classified error counters keyed by error metric key.
1940
+ * @param {Map<any, any>} arg0
1941
+ */
1942
+ set error_counters(arg0) {
1943
+ wasm.__wbg_set_metricssnapshot_error_counters(this.__wbg_ptr, addHeapObject(arg0));
1944
+ }
1945
+ /**
1946
+ * Duration of the snapshot interval in fractional seconds.
1947
+ * Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
1948
+ * @param {number} arg0
1949
+ */
1950
+ set interval_secs(arg0) {
1951
+ wasm.__wbg_set_metricssnapshot_interval_secs(this.__wbg_ptr, arg0);
1952
+ }
1953
+ /**
1954
+ * Operational counters and gauges (authorization, cache, JWT, data, lock).
1955
+ * @param {Map<any, any>} arg0
1956
+ */
1957
+ set operational_stats(arg0) {
1958
+ wasm.__wbg_set_metricssnapshot_operational_stats(this.__wbg_ptr, addHeapObject(arg0));
1959
+ }
1960
+ /**
1961
+ * Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
1962
+ * @param {Map<any, any>} arg0
1963
+ */
1964
+ set policy_stats(arg0) {
1965
+ wasm.__wbg_set_metricssnapshot_policy_stats(this.__wbg_ptr, addHeapObject(arg0));
1966
+ }
1967
+ };
1968
+ if (Symbol.dispose) MetricsSnapshot.prototype[Symbol.dispose] = MetricsSnapshot.prototype.free;
1824
1969
  var MultiIssuerAuthorizeResult = class _MultiIssuerAuthorizeResult {
1825
1970
  static __wrap(ptr) {
1826
1971
  const obj = Object.create(_MultiIssuerAuthorizeResult.prototype);
@@ -2439,7 +2584,7 @@ function __wbg_get_imports() {
2439
2584
  const a = state0.a;
2440
2585
  state0.a = 0;
2441
2586
  try {
2442
- return __wasm_bindgen_func_elem_8962(a, state0.b, arg02, arg12);
2587
+ return __wasm_bindgen_func_elem_8982(a, state0.b, arg02, arg12);
2443
2588
  } finally {
2444
2589
  state0.a = a;
2445
2590
  }
@@ -2622,6 +2767,12 @@ function __wbg_get_imports() {
2622
2767
  const ret = getObject(arg0).status;
2623
2768
  return ret;
2624
2769
  },
2770
+ __wbg_stringify_54b3d9b61602aee6: function() {
2771
+ return handleError(function(arg0) {
2772
+ const ret = JSON.stringify(getObject(arg0));
2773
+ return addHeapObject(ret);
2774
+ }, arguments);
2775
+ },
2625
2776
  __wbg_subarray_1daff70dde20c145: function(arg0, arg1, arg2) {
2626
2777
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
2627
2778
  return addHeapObject(ret);
@@ -2664,15 +2815,15 @@ function __wbg_get_imports() {
2664
2815
  console.warn(...getObject(arg0));
2665
2816
  },
2666
2817
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
2667
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8907);
2818
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8927);
2668
2819
  return addHeapObject(ret);
2669
2820
  },
2670
2821
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
2671
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12467);
2822
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12488);
2672
2823
  return addHeapObject(ret);
2673
2824
  },
2674
2825
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
2675
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8741);
2826
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8761);
2676
2827
  return addHeapObject(ret);
2677
2828
  },
2678
2829
  __wbindgen_generic_0000000000000004: function(arg0) {
@@ -2708,19 +2859,19 @@ function __wbg_get_imports() {
2708
2859
  "./cedarling_wasm_bg.js": import0
2709
2860
  };
2710
2861
  }
2711
- function __wasm_bindgen_func_elem_8741(arg0, arg1) {
2712
- wasm.__wasm_bindgen_func_elem_8741(arg0, arg1);
2862
+ function __wasm_bindgen_func_elem_8761(arg0, arg1) {
2863
+ wasm.__wasm_bindgen_func_elem_8761(arg0, arg1);
2713
2864
  }
2714
- function __wasm_bindgen_func_elem_12467(arg0, arg1, arg2) {
2715
- wasm.__wasm_bindgen_func_elem_12467(arg0, arg1, addHeapObject(arg2));
2865
+ function __wasm_bindgen_func_elem_12488(arg0, arg1, arg2) {
2866
+ wasm.__wasm_bindgen_func_elem_12488(arg0, arg1, addHeapObject(arg2));
2716
2867
  }
2717
- function __wasm_bindgen_func_elem_8962(arg0, arg1, arg2, arg3) {
2718
- wasm.__wasm_bindgen_func_elem_8962(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2868
+ function __wasm_bindgen_func_elem_8982(arg0, arg1, arg2, arg3) {
2869
+ wasm.__wasm_bindgen_func_elem_8982(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2719
2870
  }
2720
- function __wasm_bindgen_func_elem_8907(arg0, arg1, arg2) {
2871
+ function __wasm_bindgen_func_elem_8927(arg0, arg1, arg2) {
2721
2872
  try {
2722
2873
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2723
- wasm.__wasm_bindgen_func_elem_8907(retptr, arg0, arg1, addHeapObject(arg2));
2874
+ wasm.__wasm_bindgen_func_elem_8927(retptr, arg0, arg1, addHeapObject(arg2));
2724
2875
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2725
2876
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2726
2877
  if (r1) {
@@ -2778,6 +2929,9 @@ var IntoUnderlyingSinkFinalization = typeof FinalizationRegistry === "undefined"
2778
2929
  var IntoUnderlyingSourceFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2779
2930
  }, unregister: () => {
2780
2931
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_intounderlyingsource_free(ptr, 1));
2932
+ var MetricsSnapshotFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2933
+ }, unregister: () => {
2934
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_metricssnapshot_free(ptr, 1));
2781
2935
  var MultiIssuerAuthorizeResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2782
2936
  }, unregister: () => {
2783
2937
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_multiissuerauthorizeresult_free(ptr, 1));