@statsig/on-device-eval-core 3.12.0 → 3.12.2
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 +3 -3
- package/src/Evaluator.d.ts +5 -1
- package/src/Evaluator.js +13 -2
- package/src/SpecStore.d.ts +7 -1
- package/src/SpecStore.js +10 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/on-device-eval-core",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@statsig/client-core": "3.12.
|
|
6
|
-
"@statsig/sha256": "3.12.
|
|
5
|
+
"@statsig/client-core": "3.12.2",
|
|
6
|
+
"@statsig/sha256": "3.12.2"
|
|
7
7
|
},
|
|
8
8
|
"type": "commonjs",
|
|
9
9
|
"main": "./src/index.js",
|
package/src/Evaluator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicConfigEvaluation, EvaluationDetails, GateEvaluation, LayerEvaluation, StatsigUserInternal } from '@statsig/client-core';
|
|
1
|
+
import { DynamicConfigEvaluation, EvaluationDetails, GateEvaluation, LayerEvaluation, ParamStoreConfig, StatsigUserInternal } from '@statsig/client-core';
|
|
2
2
|
import { SpecStore } from './SpecStore';
|
|
3
3
|
type DetailedEvaluation<T> = {
|
|
4
4
|
evaluation: T | null;
|
|
@@ -10,6 +10,10 @@ export declare class Evaluator {
|
|
|
10
10
|
evaluateGate(name: string, user: StatsigUserInternal): DetailedEvaluation<GateEvaluation>;
|
|
11
11
|
evaluateConfig(name: string, user: StatsigUserInternal): DetailedEvaluation<DynamicConfigEvaluation>;
|
|
12
12
|
evaluateLayer(name: string, user: StatsigUserInternal): DetailedEvaluation<LayerEvaluation>;
|
|
13
|
+
getParamStoreConfig(name: string): {
|
|
14
|
+
config: ParamStoreConfig | null;
|
|
15
|
+
details: EvaluationDetails;
|
|
16
|
+
};
|
|
13
17
|
private _getSpecAndDetails;
|
|
14
18
|
private _getEvaluationDetails;
|
|
15
19
|
private _evaluateSpec;
|
package/src/Evaluator.js
CHANGED
|
@@ -38,17 +38,28 @@ class Evaluator {
|
|
|
38
38
|
const evaluation = (0, EvaluationResult_1.resultToLayerEval)(spec, experimentSpec, result);
|
|
39
39
|
return { evaluation, details };
|
|
40
40
|
}
|
|
41
|
+
getParamStoreConfig(name) {
|
|
42
|
+
var _a;
|
|
43
|
+
const paramStoreAndSourceInfo = this._store.getParamStoreAndSourceInfo(name);
|
|
44
|
+
const details = this._getEvaluationDetails(paramStoreAndSourceInfo);
|
|
45
|
+
return {
|
|
46
|
+
config: (_a = paramStoreAndSourceInfo.paramStoreConfig) !== null && _a !== void 0 ? _a : null,
|
|
47
|
+
details,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
41
50
|
_getSpecAndDetails(kind, name) {
|
|
42
51
|
const specAndSourceInfo = this._store.getSpecAndSourceInfo(kind, name);
|
|
43
52
|
const details = this._getEvaluationDetails(specAndSourceInfo);
|
|
44
53
|
return { details, spec: specAndSourceInfo.spec };
|
|
45
54
|
}
|
|
46
55
|
_getEvaluationDetails(info) {
|
|
47
|
-
const { source,
|
|
56
|
+
const { source, lcut, receivedAt } = info;
|
|
48
57
|
if (source === 'Uninitialized' || source === 'NoValues') {
|
|
49
58
|
return { reason: source };
|
|
50
59
|
}
|
|
51
|
-
const subreason = spec
|
|
60
|
+
const subreason = ('spec' in info ? info.spec : info.paramStoreConfig) == null
|
|
61
|
+
? 'Unrecognized'
|
|
62
|
+
: 'Recognized';
|
|
52
63
|
const reason = `${source}:${subreason}`;
|
|
53
64
|
return { reason, lcut, receivedAt };
|
|
54
65
|
}
|
package/src/SpecStore.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { DataAdapterResult, DataSource, DownloadConfigSpecsResponse, Spec } from '@statsig/client-core';
|
|
1
|
+
import { DataAdapterResult, DataSource, DownloadConfigSpecsResponse, ParamStoreConfig, Spec } from '@statsig/client-core';
|
|
2
2
|
export type SpecAndSourceInfo = {
|
|
3
3
|
spec: Spec | null;
|
|
4
|
+
} & SourceInfo;
|
|
5
|
+
export type ParamStoreAndSourceInfo = {
|
|
6
|
+
paramStoreConfig: ParamStoreConfig | null;
|
|
7
|
+
} & SourceInfo;
|
|
8
|
+
export type SourceInfo = {
|
|
4
9
|
source: DataSource;
|
|
5
10
|
lcut: number;
|
|
6
11
|
receivedAt: number;
|
|
@@ -20,5 +25,6 @@ export declare class SpecStore {
|
|
|
20
25
|
reset(): void;
|
|
21
26
|
finalize(): void;
|
|
22
27
|
getSpecAndSourceInfo(kind: SpecKind, name: string): SpecAndSourceInfo;
|
|
28
|
+
getParamStoreAndSourceInfo(name: string): ParamStoreAndSourceInfo;
|
|
23
29
|
private _getSpecs;
|
|
24
30
|
}
|
package/src/SpecStore.js
CHANGED
|
@@ -61,6 +61,16 @@ class SpecStore {
|
|
|
61
61
|
receivedAt: this._receivedAt,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
getParamStoreAndSourceInfo(name) {
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
const paramStores = (_a = this._values) === null || _a === void 0 ? void 0 : _a.param_stores;
|
|
67
|
+
return {
|
|
68
|
+
paramStoreConfig: (_c = (_b = paramStores === null || paramStores === void 0 ? void 0 : paramStores[name]) === null || _b === void 0 ? void 0 : _b.parameters) !== null && _c !== void 0 ? _c : null,
|
|
69
|
+
source: this._source,
|
|
70
|
+
lcut: this._lcut,
|
|
71
|
+
receivedAt: this._receivedAt,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
64
74
|
_getSpecs(kind) {
|
|
65
75
|
var _a, _b, _c;
|
|
66
76
|
switch (kind) {
|