@statsig/client-core 1.2.0 → 1.3.1

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,8 +1,8 @@
1
1
  {
2
2
  "name": "@statsig/client-core",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "dependencies": {},
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
7
7
  "typings": "./src/index.d.ts"
8
- }
8
+ }
@@ -1,15 +1,15 @@
1
1
  import { DownloadConfigSpecsResponse } from './DownloadConfigSpecsResponse';
2
2
  import { ErrorBoundary } from './ErrorBoundary';
3
- import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions } from './EvaluationOptions';
3
+ import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions, ParameterStoreEvaluationOptions } from './EvaluationOptions';
4
4
  import { InitializeResponseWithUpdates } from './InitializeResponse';
5
5
  import { StatsigSession } from './SessionID';
6
6
  import { StatsigClientEventEmitterInterface } from './StatsigClientEventEmitter';
7
7
  import { EvaluationsDataAdapter, SpecsDataAdapter } from './StatsigDataAdapter';
8
8
  import { StatsigEvent } from './StatsigEvent';
9
9
  import { AnyStatsigOptions, StatsigRuntimeMutableOptions } from './StatsigOptionsCommon';
10
- import { DynamicConfig, Experiment, FeatureGate, Layer } from './StatsigTypes';
10
+ import { DynamicConfig, Experiment, FeatureGate, Layer, ParameterStore } from './StatsigTypes';
11
11
  import { StatsigUser } from './StatsigUser';
12
- import { Flatten } from './UtitlityTypes';
12
+ import { Flatten } from './TypingUtils';
13
13
  export interface StatsigClientCommonInterface extends StatsigClientEventEmitterInterface {
14
14
  initializeSync(): void;
15
15
  initializeAsync(): Promise<void>;
@@ -58,6 +58,7 @@ export interface PrecomputedEvaluationsInterface extends StatsigClientCommonInte
58
58
  getDynamicConfig(name: string, options?: DynamicConfigEvaluationOptions): DynamicConfig;
59
59
  getExperiment(name: string, options?: ExperimentEvaluationOptions): Experiment;
60
60
  getLayer(name: string, options?: LayerEvaluationOptions): Layer;
61
+ getParameterStore(name: string, options?: ParameterStoreEvaluationOptions): ParameterStore;
61
62
  logEvent(event: StatsigEvent): void;
62
63
  logEvent(eventName: string, value?: string | number, metadata?: Record<string, string>): void;
63
64
  }
@@ -18,3 +18,4 @@ export type ExperimentEvaluationOptions = EvaluationOptionsCommon & {
18
18
  userPersistedValues?: unknown;
19
19
  };
20
20
  export type LayerEvaluationOptions = EvaluationOptionsCommon & {};
21
+ export type ParameterStoreEvaluationOptions = EvaluationOptionsCommon & {};
@@ -1,4 +1,5 @@
1
- import { Flatten } from './UtitlityTypes';
1
+ import { ParamStoreConfig } from './ParamStoreTypes';
2
+ import { Flatten } from './TypingUtils';
2
3
  type EvaluationBase<T> = {
3
4
  id_type: string;
4
5
  name: string;
@@ -32,8 +33,8 @@ export type EvaluationDetails = {
32
33
  lcut?: number;
33
34
  receivedAt?: number;
34
35
  };
35
- export type DetailedEvaluation<T extends AnyEvaluation> = {
36
- evaluation: T | null;
36
+ export type DetailedStoreResult<T extends AnyEvaluation | ParamStoreConfig> = {
37
+ result: T | null;
37
38
  details: EvaluationDetails;
38
39
  };
39
40
  export {};
@@ -256,7 +256,7 @@ class EventLogger {
256
256
  }
257
257
  _startBackgroundFlushInterval() {
258
258
  var _a, _b;
259
- if (!(0, SafeJs_1._isBrowserEnv)()) {
259
+ if ((0, SafeJs_1._isServerEnv)()) {
260
260
  return; // do not run in server environments
261
261
  }
262
262
  const flushInterval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.loggingIntervalMs) !== null && _b !== void 0 ? _b : DEFAULT_FLUSH_INTERVAL_MS;
package/src/Hashing.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const _DJB2: (value: string) => string;
2
- export declare const _DJB2Object: (value: Record<string, unknown> | null) => string;
2
+ export declare const _DJB2Object: (value: Record<string, unknown> | null, maxLevels?: number) => string;
3
+ export declare const _getSortedObject: (object: Record<string, unknown> | null, maxDepth: number | undefined) => Record<string, unknown> | null;
package/src/Hashing.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._DJB2Object = exports._DJB2 = void 0;
3
+ exports._getSortedObject = exports._DJB2Object = exports._DJB2 = void 0;
4
+ const TypingUtils_1 = require("./TypingUtils");
4
5
  const _DJB2 = (value) => {
5
6
  let hash = 0;
6
7
  for (let i = 0; i < value.length; i++) {
@@ -11,22 +12,24 @@ const _DJB2 = (value) => {
11
12
  return String(hash >>> 0);
12
13
  };
13
14
  exports._DJB2 = _DJB2;
14
- const _DJB2Object = (value) => {
15
- return (0, exports._DJB2)(JSON.stringify(_getSortedObject(value)));
15
+ const _DJB2Object = (value, maxLevels) => {
16
+ return (0, exports._DJB2)(JSON.stringify((0, exports._getSortedObject)(value, maxLevels)));
16
17
  };
17
18
  exports._DJB2Object = _DJB2Object;
18
- const _getSortedObject = (object) => {
19
+ const _getSortedObject = (object, maxDepth) => {
19
20
  if (object == null) {
20
21
  return null;
21
22
  }
22
23
  const keys = Object.keys(object).sort();
23
24
  const sortedObject = {};
24
25
  keys.forEach((key) => {
25
- let value = object[key];
26
- if (!Array.isArray(value) && value instanceof Object) {
27
- value = _getSortedObject(value);
26
+ const value = object[key];
27
+ if (maxDepth === 0 || (0, TypingUtils_1._typeOf)(value) !== 'object') {
28
+ sortedObject[key] = value;
29
+ return;
28
30
  }
29
- sortedObject[key] = value;
31
+ sortedObject[key] = (0, exports._getSortedObject)(value, maxDepth != null ? maxDepth - 1 : maxDepth);
30
32
  });
31
33
  return sortedObject;
32
34
  };
35
+ exports._getSortedObject = _getSortedObject;
@@ -1,4 +1,5 @@
1
1
  import { DynamicConfigEvaluation, GateEvaluation, LayerEvaluation } from './EvaluationTypes';
2
+ import { ParamStoreConfig } from './ParamStoreTypes';
2
3
  import { StatsigUser } from './StatsigUser';
3
4
  type SessionReplayFields = {
4
5
  can_record_session?: boolean;
@@ -8,6 +9,7 @@ export type InitializeResponseWithUpdates = SessionReplayFields & {
8
9
  feature_gates: Record<string, GateEvaluation>;
9
10
  dynamic_configs: Record<string, DynamicConfigEvaluation>;
10
11
  layer_configs: Record<string, LayerEvaluation>;
12
+ param_stores?: Record<string, ParamStoreConfig>;
11
13
  time: number;
12
14
  has_updates: true;
13
15
  hash_used: 'none' | 'sha256' | 'djb2';
@@ -2,7 +2,7 @@ import './$_StatsigGlobal';
2
2
  import { NetworkPriority } from './NetworkConfig';
3
3
  import { StatsigClientEmitEventFunc } from './StatsigClientBase';
4
4
  import { AnyStatsigOptions } from './StatsigOptionsCommon';
5
- import { Flatten } from './UtitlityTypes';
5
+ import { Flatten } from './TypingUtils';
6
6
  type RequestArgs = {
7
7
  sdkKey: string;
8
8
  url: string;
@@ -0,0 +1,65 @@
1
+ type ParamType = 'string' | 'boolean' | 'number' | 'array' | 'object';
2
+ type RefType = 'gate' | 'gated_value' | 'static' | 'layer' | 'dynamic_config' | 'experiment';
3
+ export type StaticParam = {
4
+ ref_type: 'static';
5
+ } & ({
6
+ param_type: 'boolean';
7
+ value: boolean;
8
+ } | {
9
+ param_type: 'number';
10
+ value: number;
11
+ } | {
12
+ param_type: 'string';
13
+ value: string;
14
+ } | {
15
+ param_type: 'object';
16
+ value: object;
17
+ } | {
18
+ param_type: 'array';
19
+ value: unknown[];
20
+ });
21
+ export type GateParam = {
22
+ ref_type: 'gate';
23
+ gate_name: string;
24
+ } & ({
25
+ param_type: 'boolean';
26
+ pass_value: boolean;
27
+ fail_value: boolean;
28
+ } | {
29
+ param_type: 'number';
30
+ pass_value: number;
31
+ fail_value: number;
32
+ } | {
33
+ param_type: 'string';
34
+ pass_value: string;
35
+ fail_value: string;
36
+ } | {
37
+ param_type: 'object';
38
+ pass_value: object;
39
+ fail_value: object;
40
+ } | {
41
+ param_type: 'array';
42
+ pass_value: unknown[];
43
+ fail_value: unknown[];
44
+ });
45
+ type Param<R extends RefType, T extends ParamType> = {
46
+ ref_type: R;
47
+ param_type: T;
48
+ };
49
+ export type LayerParam = Param<'layer', ParamType> & {
50
+ layer_name: string;
51
+ param_name: string;
52
+ };
53
+ export type DynamicConfigParam = Param<'dynamic_config', ParamType> & {
54
+ config_name: string;
55
+ param_name: string;
56
+ };
57
+ export type ExperimentParam = Param<'experiment', ParamType> & {
58
+ experiment_name: string;
59
+ param_name: string;
60
+ };
61
+ type AnyParam = GateParam | StaticParam | LayerParam | DynamicConfigParam | ExperimentParam;
62
+ export type ParamStoreConfig = {
63
+ [param_name: string]: AnyParam | undefined;
64
+ };
65
+ export {};
package/src/SafeJs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare const _getWindowSafe: () => Window | null;
2
2
  export declare const _getDocumentSafe: () => Document | null;
3
- export declare const _isBrowserEnv: () => boolean;
3
+ export declare const _isServerEnv: () => boolean;
4
4
  export declare const _addWindowEventListenerSafe: (key: string, listener: () => void) => void;
5
5
  export declare const _addDocumentEventListenerSafe: (key: string, listener: () => void) => void;
6
6
  export declare const _getCurrentPageUrlSafe: () => string | undefined;
package/src/SafeJs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._getCurrentPageUrlSafe = exports._addDocumentEventListenerSafe = exports._addWindowEventListenerSafe = exports._isBrowserEnv = exports._getDocumentSafe = exports._getWindowSafe = void 0;
3
+ exports._getCurrentPageUrlSafe = exports._addDocumentEventListenerSafe = exports._addWindowEventListenerSafe = exports._isServerEnv = exports._getDocumentSafe = exports._getWindowSafe = void 0;
4
4
  const _getWindowSafe = () => {
5
5
  return typeof window !== 'undefined' ? window : null;
6
6
  };
@@ -11,10 +11,17 @@ const _getDocumentSafe = () => {
11
11
  return (_a = win === null || win === void 0 ? void 0 : win.document) !== null && _a !== void 0 ? _a : null;
12
12
  };
13
13
  exports._getDocumentSafe = _getDocumentSafe;
14
- const _isBrowserEnv = () => {
15
- return (0, exports._getDocumentSafe)() != null;
14
+ const _isServerEnv = () => {
15
+ if ((0, exports._getDocumentSafe)() !== null) {
16
+ return false;
17
+ }
18
+ const isNode = typeof process !== 'undefined' &&
19
+ process.versions != null &&
20
+ process.versions.node != null;
21
+ const isVercel = typeof EdgeRuntime === 'string';
22
+ return isVercel || isNode;
16
23
  };
17
- exports._isBrowserEnv = _isBrowserEnv;
24
+ exports._isServerEnv = _isServerEnv;
18
25
  const _addWindowEventListenerSafe = (key, listener) => {
19
26
  const win = (0, exports._getWindowSafe)();
20
27
  if (typeof (win === null || win === void 0 ? void 0 : win.addEventListener) === 'function') {
@@ -15,5 +15,6 @@ export declare const SessionID: {
15
15
  };
16
16
  export declare const StatsigSession: {
17
17
  get: (sdkKey: string) => Promise<StatsigSession>;
18
+ overrideInitialSessionID: (override: string, sdkKey: string) => void;
18
19
  };
19
20
  export {};
package/src/SessionID.js CHANGED
@@ -30,6 +30,9 @@ exports.StatsigSession = {
30
30
  const session = yield PROMISE_MAP[sdkKey];
31
31
  return _bumpSession(session);
32
32
  }),
33
+ overrideInitialSessionID: (override, sdkKey) => {
34
+ PROMISE_MAP[sdkKey] = _overrideSessionId(override, sdkKey);
35
+ },
33
36
  };
34
37
  function _loadSession(sdkKey) {
35
38
  return __awaiter(this, void 0, void 0, function* () {
@@ -48,6 +51,17 @@ function _loadSession(sdkKey) {
48
51
  };
49
52
  });
50
53
  }
54
+ function _overrideSessionId(override, sdkKey) {
55
+ const now = Date.now();
56
+ return Promise.resolve({
57
+ data: {
58
+ sessionID: override,
59
+ startTime: now,
60
+ lastUpdate: now,
61
+ },
62
+ sdkKey,
63
+ });
64
+ }
51
65
  function _bumpSession(session) {
52
66
  const now = Date.now();
53
67
  const data = session.data;
@@ -16,6 +16,7 @@ const ErrorBoundary_1 = require("./ErrorBoundary");
16
16
  const EventLogger_1 = require("./EventLogger");
17
17
  const Log_1 = require("./Log");
18
18
  const SafeJs_1 = require("./SafeJs");
19
+ const SessionID_1 = require("./SessionID");
19
20
  const StorageProvider_1 = require("./StorageProvider");
20
21
  class StatsigClientBase {
21
22
  constructor(sdkKey, adapter, network, options) {
@@ -25,6 +26,8 @@ class StatsigClientBase {
25
26
  const emitter = this.$emt.bind(this);
26
27
  (options === null || options === void 0 ? void 0 : options.logLevel) != null && (Log_1.Log.level = options.logLevel);
27
28
  (options === null || options === void 0 ? void 0 : options.disableStorage) && StorageProvider_1.Storage._setDisabled(true);
29
+ (options === null || options === void 0 ? void 0 : options.initialSessionID) &&
30
+ SessionID_1.StatsigSession.overrideInitialSessionID(options.initialSessionID, sdkKey);
28
31
  this._sdkKey = sdkKey;
29
32
  this._options = options !== null && options !== void 0 ? options : {};
30
33
  this._overrideAdapter = (_a = options === null || options === void 0 ? void 0 : options.overrideAdapter) !== null && _a !== void 0 ? _a : null;
@@ -34,7 +37,7 @@ class StatsigClientBase {
34
37
  this._errorBoundary.wrap(network);
35
38
  this._errorBoundary.wrap(adapter);
36
39
  this._errorBoundary.wrap(this._logger);
37
- if ((0, SafeJs_1._isBrowserEnv)()) {
40
+ if (!(0, SafeJs_1._isServerEnv)()) {
38
41
  const statsigGlobal = (0, __StatsigGlobal_1._getStatsigGlobal)();
39
42
  const instances = (_b = statsigGlobal.instances) !== null && _b !== void 0 ? _b : {};
40
43
  const inst = this;
@@ -1,6 +1,6 @@
1
1
  import { DataAdapterResult } from './StatsigDataAdapter';
2
2
  import { DynamicConfig, Experiment, FeatureGate, Layer } from './StatsigTypes';
3
- import { Flatten } from './UtitlityTypes';
3
+ import { Flatten } from './TypingUtils';
4
4
  export type StatsigLoadingStatus = 'Uninitialized' | 'Loading' | 'Ready';
5
5
  type EventNameToEventDataMap = {
6
6
  values_updated: {
@@ -5,7 +5,7 @@ export type StatsigEvent = {
5
5
  eventName: string;
6
6
  value?: string | number | null;
7
7
  metadata?: {
8
- [key: string]: string;
8
+ [key: string]: string | undefined;
9
9
  } | null;
10
10
  };
11
11
  export type StatsigEventInternal = Omit<StatsigEvent, 'metadata'> & {
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "1.2.0";
1
+ export declare const SDK_VERSION = "1.3.1";
2
2
  export type StatsigMetadata = {
3
3
  readonly [key: string]: string | undefined;
4
4
  readonly appVersion?: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '1.2.0';
4
+ exports.SDK_VERSION = '1.3.1';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
@@ -104,6 +104,12 @@ export type StatsigOptionsCommon<NetworkConfig extends NetworkConfigCommon> = St
104
104
  * returned to the caller of a check api (checkGate/getExperiment etc).
105
105
  */
106
106
  overrideAdapter?: OverrideAdapter;
107
+ /**
108
+ * Overrides the auto-generated SessionID with the provided string.
109
+ *
110
+ * Note: Sessions still expire and will be replaced with an auto-generated SessionID.
111
+ */
112
+ initialSessionID?: string;
107
113
  };
108
114
  export type AnyStatsigOptions = StatsigOptionsCommon<NetworkConfigCommon>;
109
115
  export type StatsigEnvironment = {
@@ -1,6 +1,8 @@
1
1
  import { DynamicConfigEvaluation, EvaluationDetails, GateEvaluation, LayerEvaluation } from './EvaluationTypes';
2
- import { AnyConfigBasedStatsigType, DynamicConfig, FeatureGate, Layer } from './StatsigTypes';
2
+ import { AnyConfigBasedStatsigType, DynamicConfig, Experiment, FeatureGate, Layer, TypedGet } from './StatsigTypes';
3
3
  export declare function _makeFeatureGate(name: string, details: EvaluationDetails, evaluation: GateEvaluation | null): FeatureGate;
4
4
  export declare function _makeDynamicConfig(name: string, details: EvaluationDetails, evaluation: DynamicConfigEvaluation | null): DynamicConfig;
5
+ export declare function _makeExperiment(name: string, details: EvaluationDetails, evaluation: DynamicConfigEvaluation | null): Experiment;
5
6
  export declare function _makeLayer(name: string, details: EvaluationDetails, evaluation: LayerEvaluation | null, exposeFunc?: (param: string) => void): Layer;
6
7
  export declare function _mergeOverride<T extends AnyConfigBasedStatsigType>(original: T, overridden: T | null | undefined, value: Record<string, unknown>, exposeFunc?: (param: string) => void): T;
8
+ export declare function _makeTypedGet(value: Record<string, unknown> | undefined, exposeFunc?: (param: string) => void): TypedGet;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._mergeOverride = exports._makeLayer = exports._makeDynamicConfig = exports._makeFeatureGate = void 0;
3
+ exports._makeTypedGet = exports._mergeOverride = exports._makeLayer = exports._makeExperiment = exports._makeDynamicConfig = exports._makeFeatureGate = void 0;
4
+ const TypingUtils_1 = require("./TypingUtils");
4
5
  const DEFAULT_RULE = 'default';
5
6
  function _makeEvaluation(name, details, evaluation, value) {
6
7
  var _a;
@@ -18,9 +19,16 @@ function _makeFeatureGate(name, details, evaluation) {
18
19
  exports._makeFeatureGate = _makeFeatureGate;
19
20
  function _makeDynamicConfig(name, details, evaluation) {
20
21
  var _a;
21
- return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) !== null && _a !== void 0 ? _a : {})), { groupName: null, get: _makeTypedGet(evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) });
22
+ const value = (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) !== null && _a !== void 0 ? _a : {};
23
+ return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, value)), { get: _makeTypedGet(evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) });
22
24
  }
23
25
  exports._makeDynamicConfig = _makeDynamicConfig;
26
+ function _makeExperiment(name, details, evaluation) {
27
+ var _a;
28
+ const result = _makeDynamicConfig(name, details, evaluation);
29
+ return Object.assign(Object.assign({}, result), { groupName: (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.group_name) !== null && _a !== void 0 ? _a : null });
30
+ }
31
+ exports._makeExperiment = _makeExperiment;
24
32
  function _makeLayer(name, details, evaluation, exposeFunc) {
25
33
  var _a, _b;
26
34
  return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, undefined)), { get: _makeTypedGet(evaluation === null || evaluation === void 0 ? void 0 : evaluation.value, exposeFunc), groupName: (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.group_name) !== null && _a !== void 0 ? _a : null, __value: (_b = evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) !== null && _b !== void 0 ? _b : {} });
@@ -30,10 +38,6 @@ function _mergeOverride(original, overridden, value, exposeFunc) {
30
38
  return Object.assign(Object.assign(Object.assign({}, original), overridden), { get: _makeTypedGet(value, exposeFunc) });
31
39
  }
32
40
  exports._mergeOverride = _mergeOverride;
33
- function _isTypeMatch(a, b) {
34
- const typeOf = (x) => (Array.isArray(x) ? 'array' : typeof x);
35
- return typeOf(a) === typeOf(b);
36
- }
37
41
  function _makeTypedGet(value, exposeFunc) {
38
42
  return (param, fallback) => {
39
43
  var _a;
@@ -41,10 +45,11 @@ function _makeTypedGet(value, exposeFunc) {
41
45
  if (found == null) {
42
46
  return (fallback !== null && fallback !== void 0 ? fallback : null);
43
47
  }
44
- if (fallback != null && !_isTypeMatch(found, fallback)) {
48
+ if (fallback != null && !(0, TypingUtils_1._isTypeMatch)(found, fallback)) {
45
49
  return (fallback !== null && fallback !== void 0 ? fallback : null);
46
50
  }
47
51
  exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(param);
48
52
  return found;
49
53
  };
50
54
  }
55
+ exports._makeTypedGet = _makeTypedGet;
@@ -1,6 +1,8 @@
1
1
  import { EvaluationDetails, ExperimentEvaluation, GateEvaluation, LayerEvaluation } from './EvaluationTypes';
2
- import { Flatten } from './UtitlityTypes';
2
+ import { ParamStoreConfig } from './ParamStoreTypes';
3
+ import { Flatten } from './TypingUtils';
3
4
  export type TypedGet = <T = unknown>(key: string, fallback?: T) => TypedReturn<T>;
5
+ export type ParamStoreTypedGet = <T = unknown>(key: string, fallback: T) => T;
4
6
  export type TypedReturn<T = unknown> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends Array<unknown> ? Array<unknown> : T extends object ? object : unknown;
5
7
  export type SpecType = 'gate' | 'dynamic_config' | 'experiment' | 'layer';
6
8
  export type FeatureGate = Flatten<{
@@ -19,7 +21,7 @@ export type Experiment = Flatten<{
19
21
  readonly __evaluation: ExperimentEvaluation | null;
20
22
  readonly get: TypedGet;
21
23
  }>;
22
- export type DynamicConfig = Flatten<Experiment>;
24
+ export type DynamicConfig = Flatten<Omit<Experiment, 'groupName'>>;
23
25
  export type Layer = Flatten<{
24
26
  readonly name: string;
25
27
  readonly ruleID: string;
@@ -29,5 +31,11 @@ export type Layer = Flatten<{
29
31
  readonly __evaluation: LayerEvaluation | null;
30
32
  readonly get: TypedGet;
31
33
  }>;
34
+ export type ParameterStore = Flatten<{
35
+ readonly name: string;
36
+ readonly details: EvaluationDetails;
37
+ readonly get: TypedGet;
38
+ readonly __configuration: ParamStoreConfig | null;
39
+ }>;
32
40
  export type AnyConfigBasedStatsigType = DynamicConfig | Experiment | Layer;
33
41
  export type AnyStatsigType = FeatureGate | AnyConfigBasedStatsigType;
@@ -0,0 +1,7 @@
1
+ type Primitive = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
2
+ export type Flatten<T> = {
3
+ [K in keyof T]: T[K];
4
+ } & {};
5
+ export declare function _typeOf(input: unknown): Primitive | 'array';
6
+ export declare function _isTypeMatch<T>(a: unknown, b: unknown): a is T;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._isTypeMatch = exports._typeOf = void 0;
4
+ function _typeOf(input) {
5
+ return Array.isArray(input) ? 'array' : typeof input;
6
+ }
7
+ exports._typeOf = _typeOf;
8
+ function _isTypeMatch(a, b) {
9
+ const typeOf = (x) => (Array.isArray(x) ? 'array' : typeof x);
10
+ return typeOf(a) === typeOf(b);
11
+ }
12
+ exports._isTypeMatch = _isTypeMatch;
package/src/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './Log';
17
17
  export * from './NetworkCore';
18
18
  export * from './NetworkConfig';
19
19
  export * from './OverrideAdapter';
20
+ export * from './ParamStoreTypes';
20
21
  export * from './SafeJs';
21
22
  export * from './SDKType';
22
23
  export * from './SessionID';
@@ -32,8 +33,8 @@ export * from './StatsigTypes';
32
33
  export * from './StatsigUser';
33
34
  export * from './StorageProvider';
34
35
  export * from './TypedJsonParse';
36
+ export * from './TypingUtils';
35
37
  export * from './UrlOverrides';
36
- export * from './UtitlityTypes';
37
38
  export * from './UUID';
38
39
  export * from './VisibilityObserving';
39
40
  export { EventLogger, Storage, Log };
package/src/index.js CHANGED
@@ -38,6 +38,7 @@ __exportStar(require("./Log"), exports);
38
38
  __exportStar(require("./NetworkCore"), exports);
39
39
  __exportStar(require("./NetworkConfig"), exports);
40
40
  __exportStar(require("./OverrideAdapter"), exports);
41
+ __exportStar(require("./ParamStoreTypes"), exports);
41
42
  __exportStar(require("./SafeJs"), exports);
42
43
  __exportStar(require("./SDKType"), exports);
43
44
  __exportStar(require("./SessionID"), exports);
@@ -53,8 +54,8 @@ __exportStar(require("./StatsigTypes"), exports);
53
54
  __exportStar(require("./StatsigUser"), exports);
54
55
  __exportStar(require("./StorageProvider"), exports);
55
56
  __exportStar(require("./TypedJsonParse"), exports);
57
+ __exportStar(require("./TypingUtils"), exports);
56
58
  __exportStar(require("./UrlOverrides"), exports);
57
- __exportStar(require("./UtitlityTypes"), exports);
58
59
  __exportStar(require("./UUID"), exports);
59
60
  __exportStar(require("./VisibilityObserving"), exports);
60
61
  __STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { Log: Log_1.Log,
@@ -1,3 +0,0 @@
1
- export type Flatten<T> = {
2
- [K in keyof T]: T[K];
3
- } & {};
File without changes