@statsig/statsig-node-core 0.14.1-rc.2512160223 → 0.14.1-rc.2512162207
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 +9 -9
- package/statsig_types.d.ts +1 -2
- package/statsig_types.js +25 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/statsig-node-core",
|
|
3
|
-
"version": "0.14.1-rc.
|
|
3
|
+
"version": "0.14.1-rc.2512162207",
|
|
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-rc.
|
|
59
|
-
"@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-rc.
|
|
60
|
-
"@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-rc.
|
|
61
|
-
"@statsig/statsig-node-core-darwin-x64": "0.14.1-rc.
|
|
62
|
-
"@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-rc.
|
|
63
|
-
"@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-rc.
|
|
64
|
-
"@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-rc.
|
|
65
|
-
"@statsig/statsig-node-core-darwin-arm64": "0.14.1-rc.
|
|
58
|
+
"@statsig/statsig-node-core-linux-x64-musl": "0.14.1-rc.2512162207",
|
|
59
|
+
"@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-rc.2512162207",
|
|
60
|
+
"@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-rc.2512162207",
|
|
61
|
+
"@statsig/statsig-node-core-darwin-x64": "0.14.1-rc.2512162207",
|
|
62
|
+
"@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-rc.2512162207",
|
|
63
|
+
"@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-rc.2512162207",
|
|
64
|
+
"@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-rc.2512162207",
|
|
65
|
+
"@statsig/statsig-node-core-darwin-arm64": "0.14.1-rc.2512162207"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/statsig_types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EvaluationDetails, SecondaryExposure } from './statsig-generated';
|
|
2
|
-
export type TypedGet = <T = unknown>(key: string,
|
|
2
|
+
export type TypedGet = <T = unknown>(key: string, defaultValue: T, typeGuard?: ((value: unknown) => value is T | null) | null) => 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;
|
|
5
4
|
declare class BaseEvaluation {
|
|
6
5
|
readonly name: string;
|
|
7
6
|
readonly ruleID: string;
|
package/statsig_types.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
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
|
+
}
|
|
4
7
|
class BaseEvaluation {
|
|
5
8
|
constructor(name, data) {
|
|
6
9
|
var _a, _b, _c;
|
|
@@ -94,23 +97,32 @@ function _parseRawEvaluation(raw) {
|
|
|
94
97
|
return {};
|
|
95
98
|
}
|
|
96
99
|
}
|
|
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
|
-
}
|
|
101
100
|
function _makeTypedGet(name, value, exposeFunc) {
|
|
102
|
-
return (
|
|
101
|
+
return (key, defaultValue, typeGuard = null) => {
|
|
103
102
|
var _a;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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;
|
|
107
119
|
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
return
|
|
120
|
+
if (defaultValue == null || expectedType === actualType) {
|
|
121
|
+
exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(key);
|
|
122
|
+
return val;
|
|
111
123
|
}
|
|
112
|
-
|
|
113
|
-
return
|
|
124
|
+
console.warn(`[Statsig] Parameter type mismatch. '${name}.${key}' was found to be type '${actualType}' but fallback/return type is '${expectedType}'`);
|
|
125
|
+
return defaultValue;
|
|
114
126
|
};
|
|
115
127
|
}
|
|
116
128
|
function _makeUnknownGet(value, exposeFunc) {
|