@janssenproject/cedarling_wasm 0.0.473 → 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.
@@ -732,6 +732,38 @@ var Cedarling = class _Cedarling {
732
732
  wasm.__wbindgen_add_to_stack_pointer(16);
733
733
  }
734
734
  }
735
+ /**
736
+ * Destructive read: returns the telemetry metrics snapshot and resets
737
+ * the counters for the next interval.
738
+ *
739
+ * Fails when `CEDARLING_METRICS_COLLECTION` is disabled or whenever
740
+ * `CEDARLING_LOCK_TELEMETRY_INTERVAL` is set (even if the Lock server
741
+ * has no telemetry endpoint). `interval_secs` is fractional seconds,
742
+ * so sub-second intervals are reported exactly.
743
+ *
744
+ * # Example
745
+ *
746
+ * ```javascript
747
+ * const snapshot = cedarling.drainMetrics();
748
+ * console.log(`Requests: ${snapshot.operational_stats.get("authz.requests_total")}`);
749
+ * ```
750
+ * @returns {MetricsSnapshot}
751
+ */
752
+ drainMetrics() {
753
+ try {
754
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
755
+ wasm.cedarling_drainMetrics(retptr, this.__wbg_ptr);
756
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
757
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
758
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
759
+ if (r2) {
760
+ throw takeObject(r1);
761
+ }
762
+ return MetricsSnapshot.__wrap(r0);
763
+ } finally {
764
+ wasm.__wbindgen_add_to_stack_pointer(16);
765
+ }
766
+ }
735
767
  /**
736
768
  * Get trusted issuer identifiers that failed to load.
737
769
  *
@@ -1848,6 +1880,119 @@ var IntoUnderlyingSource = class {
1848
1880
  }
1849
1881
  };
1850
1882
  if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
1883
+ var MetricsSnapshot = class _MetricsSnapshot {
1884
+ static __wrap(ptr) {
1885
+ const obj = Object.create(_MetricsSnapshot.prototype);
1886
+ obj.__wbg_ptr = ptr;
1887
+ MetricsSnapshotFinalization.register(obj, obj.__wbg_ptr, obj);
1888
+ return obj;
1889
+ }
1890
+ __destroy_into_raw() {
1891
+ const ptr = this.__wbg_ptr;
1892
+ this.__wbg_ptr = 0;
1893
+ MetricsSnapshotFinalization.unregister(this);
1894
+ return ptr;
1895
+ }
1896
+ free() {
1897
+ const ptr = this.__destroy_into_raw();
1898
+ wasm.__wbg_metricssnapshot_free(ptr, 0);
1899
+ }
1900
+ /**
1901
+ * Classified error counters keyed by error metric key.
1902
+ * @returns {Map<any, any>}
1903
+ */
1904
+ get error_counters() {
1905
+ const ret = wasm.__wbg_get_metricssnapshot_error_counters(this.__wbg_ptr);
1906
+ return takeObject(ret);
1907
+ }
1908
+ /**
1909
+ * Duration of the snapshot interval in fractional seconds.
1910
+ * Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
1911
+ * @returns {number}
1912
+ */
1913
+ get interval_secs() {
1914
+ const ret = wasm.__wbg_get_metricssnapshot_interval_secs(this.__wbg_ptr);
1915
+ return ret;
1916
+ }
1917
+ /**
1918
+ * Operational counters and gauges (authorization, cache, JWT, data, lock).
1919
+ * @returns {Map<any, any>}
1920
+ */
1921
+ get operational_stats() {
1922
+ const ret = wasm.__wbg_get_metricssnapshot_operational_stats(this.__wbg_ptr);
1923
+ return takeObject(ret);
1924
+ }
1925
+ /**
1926
+ * Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
1927
+ * @returns {Map<any, any>}
1928
+ */
1929
+ get policy_stats() {
1930
+ const ret = wasm.__wbg_get_metricssnapshot_policy_stats(this.__wbg_ptr);
1931
+ return takeObject(ret);
1932
+ }
1933
+ /**
1934
+ * Convert `MetricsSnapshot` to json string value.
1935
+ *
1936
+ * `policy_stats`, `error_counters` and `operational_stats` are converted
1937
+ * from `Map` to plain objects so `JSON.stringify` emits their entries.
1938
+ * @returns {string}
1939
+ */
1940
+ jsonString() {
1941
+ let deferred2_0;
1942
+ let deferred2_1;
1943
+ try {
1944
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1945
+ wasm.metricssnapshot_jsonString(retptr, this.__wbg_ptr);
1946
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1947
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1948
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1949
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1950
+ var ptr1 = r0;
1951
+ var len1 = r1;
1952
+ if (r3) {
1953
+ ptr1 = 0;
1954
+ len1 = 0;
1955
+ throw takeObject(r2);
1956
+ }
1957
+ deferred2_0 = ptr1;
1958
+ deferred2_1 = len1;
1959
+ return getStringFromWasm0(ptr1, len1);
1960
+ } finally {
1961
+ wasm.__wbindgen_add_to_stack_pointer(16);
1962
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1963
+ }
1964
+ }
1965
+ /**
1966
+ * Classified error counters keyed by error metric key.
1967
+ * @param {Map<any, any>} arg0
1968
+ */
1969
+ set error_counters(arg0) {
1970
+ wasm.__wbg_set_metricssnapshot_error_counters(this.__wbg_ptr, addHeapObject(arg0));
1971
+ }
1972
+ /**
1973
+ * Duration of the snapshot interval in fractional seconds.
1974
+ * Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
1975
+ * @param {number} arg0
1976
+ */
1977
+ set interval_secs(arg0) {
1978
+ wasm.__wbg_set_metricssnapshot_interval_secs(this.__wbg_ptr, arg0);
1979
+ }
1980
+ /**
1981
+ * Operational counters and gauges (authorization, cache, JWT, data, lock).
1982
+ * @param {Map<any, any>} arg0
1983
+ */
1984
+ set operational_stats(arg0) {
1985
+ wasm.__wbg_set_metricssnapshot_operational_stats(this.__wbg_ptr, addHeapObject(arg0));
1986
+ }
1987
+ /**
1988
+ * Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
1989
+ * @param {Map<any, any>} arg0
1990
+ */
1991
+ set policy_stats(arg0) {
1992
+ wasm.__wbg_set_metricssnapshot_policy_stats(this.__wbg_ptr, addHeapObject(arg0));
1993
+ }
1994
+ };
1995
+ if (Symbol.dispose) MetricsSnapshot.prototype[Symbol.dispose] = MetricsSnapshot.prototype.free;
1851
1996
  var MultiIssuerAuthorizeResult = class _MultiIssuerAuthorizeResult {
1852
1997
  static __wrap(ptr) {
1853
1998
  const obj = Object.create(_MultiIssuerAuthorizeResult.prototype);
@@ -2466,7 +2611,7 @@ function __wbg_get_imports() {
2466
2611
  const a = state0.a;
2467
2612
  state0.a = 0;
2468
2613
  try {
2469
- return __wasm_bindgen_func_elem_8962(a, state0.b, arg02, arg12);
2614
+ return __wasm_bindgen_func_elem_8982(a, state0.b, arg02, arg12);
2470
2615
  } finally {
2471
2616
  state0.a = a;
2472
2617
  }
@@ -2649,6 +2794,12 @@ function __wbg_get_imports() {
2649
2794
  const ret = getObject(arg0).status;
2650
2795
  return ret;
2651
2796
  },
2797
+ __wbg_stringify_54b3d9b61602aee6: function() {
2798
+ return handleError(function(arg0) {
2799
+ const ret = JSON.stringify(getObject(arg0));
2800
+ return addHeapObject(ret);
2801
+ }, arguments);
2802
+ },
2652
2803
  __wbg_subarray_1daff70dde20c145: function(arg0, arg1, arg2) {
2653
2804
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
2654
2805
  return addHeapObject(ret);
@@ -2691,15 +2842,15 @@ function __wbg_get_imports() {
2691
2842
  console.warn(...getObject(arg0));
2692
2843
  },
2693
2844
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
2694
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8907);
2845
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8927);
2695
2846
  return addHeapObject(ret);
2696
2847
  },
2697
2848
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
2698
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12467);
2849
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12488);
2699
2850
  return addHeapObject(ret);
2700
2851
  },
2701
2852
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
2702
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8741);
2853
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8761);
2703
2854
  return addHeapObject(ret);
2704
2855
  },
2705
2856
  __wbindgen_generic_0000000000000004: function(arg0) {
@@ -2735,19 +2886,19 @@ function __wbg_get_imports() {
2735
2886
  "./cedarling_wasm_bg.js": import0
2736
2887
  };
2737
2888
  }
2738
- function __wasm_bindgen_func_elem_8741(arg0, arg1) {
2739
- wasm.__wasm_bindgen_func_elem_8741(arg0, arg1);
2889
+ function __wasm_bindgen_func_elem_8761(arg0, arg1) {
2890
+ wasm.__wasm_bindgen_func_elem_8761(arg0, arg1);
2740
2891
  }
2741
- function __wasm_bindgen_func_elem_12467(arg0, arg1, arg2) {
2742
- wasm.__wasm_bindgen_func_elem_12467(arg0, arg1, addHeapObject(arg2));
2892
+ function __wasm_bindgen_func_elem_12488(arg0, arg1, arg2) {
2893
+ wasm.__wasm_bindgen_func_elem_12488(arg0, arg1, addHeapObject(arg2));
2743
2894
  }
2744
- function __wasm_bindgen_func_elem_8962(arg0, arg1, arg2, arg3) {
2745
- wasm.__wasm_bindgen_func_elem_8962(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2895
+ function __wasm_bindgen_func_elem_8982(arg0, arg1, arg2, arg3) {
2896
+ wasm.__wasm_bindgen_func_elem_8982(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2746
2897
  }
2747
- function __wasm_bindgen_func_elem_8907(arg0, arg1, arg2) {
2898
+ function __wasm_bindgen_func_elem_8927(arg0, arg1, arg2) {
2748
2899
  try {
2749
2900
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2750
- wasm.__wasm_bindgen_func_elem_8907(retptr, arg0, arg1, addHeapObject(arg2));
2901
+ wasm.__wasm_bindgen_func_elem_8927(retptr, arg0, arg1, addHeapObject(arg2));
2751
2902
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2752
2903
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2753
2904
  if (r1) {
@@ -2805,6 +2956,9 @@ var IntoUnderlyingSinkFinalization = typeof FinalizationRegistry === "undefined"
2805
2956
  var IntoUnderlyingSourceFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2806
2957
  }, unregister: () => {
2807
2958
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_intounderlyingsource_free(ptr, 1));
2959
+ var MetricsSnapshotFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2960
+ }, unregister: () => {
2961
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_metricssnapshot_free(ptr, 1));
2808
2962
  var MultiIssuerAuthorizeResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2809
2963
  }, unregister: () => {
2810
2964
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_multiissuerauthorizeresult_free(ptr, 1));