@statsig/statsig-node-core 0.14.1-beta.2512170241 → 0.14.1-rc.2512160223

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/statsig-node-core",
3
- "version": "0.14.1-beta.2512170241",
3
+ "version": "0.14.1-rc.2512160223",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest --colors"
@@ -55,13 +55,13 @@
55
55
  ]
56
56
  },
57
57
  "optionalDependencies": {
58
- "@statsig/statsig-node-core-linux-x64-musl": "0.14.1-beta.2512170241",
59
- "@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-beta.2512170241",
60
- "@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-beta.2512170241",
61
- "@statsig/statsig-node-core-darwin-x64": "0.14.1-beta.2512170241",
62
- "@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-beta.2512170241",
63
- "@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-beta.2512170241",
64
- "@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-beta.2512170241",
65
- "@statsig/statsig-node-core-darwin-arm64": "0.14.1-beta.2512170241"
58
+ "@statsig/statsig-node-core-linux-x64-musl": "0.14.1-rc.2512160223",
59
+ "@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-rc.2512160223",
60
+ "@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-rc.2512160223",
61
+ "@statsig/statsig-node-core-darwin-x64": "0.14.1-rc.2512160223",
62
+ "@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-rc.2512160223",
63
+ "@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-rc.2512160223",
64
+ "@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-rc.2512160223",
65
+ "@statsig/statsig-node-core-darwin-arm64": "0.14.1-rc.2512160223"
66
66
  }
67
67
  }
@@ -1,6 +1,7 @@
1
1
  import { EvaluationDetails, SecondaryExposure } from './statsig-generated';
2
- export type TypedGet = <T = unknown>(key: string, defaultValue: T, typeGuard?: ((value: unknown) => value is T | null) | null) => T;
2
+ export type TypedGet = <T = unknown>(key: string, fallback?: T) => TypedReturn<T>;
3
3
  export type UnknownGet = (key: string, fallback?: boolean | number | string | object | Array<any> | null) => unknown | null;
4
+ export type TypedReturn<T = unknown> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends readonly unknown[] ? T : T extends object ? T : unknown;
4
5
  declare class BaseEvaluation {
5
6
  readonly name: string;
6
7
  readonly ruleID: string;
package/statsig_types.js CHANGED
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Layer = exports.Experiment = exports.DynamicConfig = exports.FeatureGate = void 0;
4
- function _getTypeOf(x) {
5
- return Array.isArray(x) ? 'array' : x === null ? 'null' : typeof x;
6
- }
7
4
  class BaseEvaluation {
8
5
  constructor(name, data) {
9
6
  var _a, _b, _c;
@@ -97,32 +94,23 @@ function _parseRawEvaluation(raw) {
97
94
  return {};
98
95
  }
99
96
  }
97
+ function _isTypeMatch(a, b) {
98
+ const typeOf = (x) => Array.isArray(x) ? 'array' : x === null ? 'null' : typeof x;
99
+ return typeOf(a) === typeOf(b);
100
+ }
100
101
  function _makeTypedGet(name, value, exposeFunc) {
101
- return (key, defaultValue, typeGuard = null) => {
102
+ return (param, fallback) => {
102
103
  var _a;
103
- // @ts-ignore - intentionally matches legacy behavior exactly
104
- defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : null;
105
- // Equivalent to legacy `this.getValue(key, defaultValue)`
106
- const val = ((_a = value[key]) !== null && _a !== void 0 ? _a : defaultValue);
107
- if (val == null) {
108
- return defaultValue;
109
- }
110
- const expectedType = _getTypeOf(defaultValue);
111
- const actualType = _getTypeOf(val);
112
- if (typeGuard != null) {
113
- if (typeGuard(val)) {
114
- exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(key);
115
- return val;
116
- }
117
- console.warn(`[Statsig] Parameter type mismatch. '${name}.${key}' failed typeGuard. Expected '${expectedType}', got '${actualType}'`);
118
- return defaultValue;
104
+ const found = (_a = value[param]) !== null && _a !== void 0 ? _a : null;
105
+ if (found == null) {
106
+ return (fallback !== null && fallback !== void 0 ? fallback : null);
119
107
  }
120
- if (defaultValue == null || expectedType === actualType) {
121
- exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(key);
122
- return val;
108
+ if (fallback != null && !_isTypeMatch(found, fallback)) {
109
+ console.warn(`[Statsig] Parameter type mismatch. '${name}.${param}' was found to be type '${typeof found}' but fallback/return type is '${typeof fallback}'`);
110
+ return (fallback !== null && fallback !== void 0 ? fallback : null);
123
111
  }
124
- console.warn(`[Statsig] Parameter type mismatch. '${name}.${key}' was found to be type '${actualType}' but fallback/return type is '${expectedType}'`);
125
- return defaultValue;
112
+ exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(param);
113
+ return found;
126
114
  };
127
115
  }
128
116
  function _makeUnknownGet(value, exposeFunc) {