@oai-statsig/statsig-node-core 0.19.5-beta.2604230102

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.
@@ -0,0 +1,15 @@
1
+ import { SecondaryExposure } from './statsig-generated';
2
+ export type StickyValues = {
3
+ value: boolean;
4
+ json_value: Record<string, unknown>;
5
+ rule_id: string;
6
+ group_name: string | null;
7
+ secondary_exposures: SecondaryExposure[];
8
+ undelegated_secondary_exposures: SecondaryExposure[];
9
+ config_delegate: string | null;
10
+ explicit_parameters: string[] | null;
11
+ time: number;
12
+ configVersion?: number | undefined;
13
+ };
14
+ export type UserPersistedValues = Record<string, StickyValues>;
15
+ export type SdkEvent = '*' | 'gate_evaluated' | 'dynamic_config_evaluated' | 'experiment_evaluated' | 'layer_evaluated' | 'specs_updated';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Utility functions for console capture payload parsing and processing
3
+ */
4
+ export declare function safeStringify(val: unknown, maxKeysCount: number, maxDepth: number, maxLength: number): string;
5
+ export declare function shouldNotStringify(val: object, maxKeysCount: number, maxDepth: number): boolean;
6
+ export declare function isPlainObject(obj: unknown): boolean;
7
+ export declare function isObjectTooDeep(obj: unknown, maxDepth: number, seen?: WeakSet<object>): boolean;
8
+ export declare function getStackTrace(): string | null;
9
+ export declare function truncateString(str: string, maxLength: number): string;
10
+ export declare function simpleStringify(val: object, maxLength: number): string;
11
+ export declare function wrapFunctionWithRestore(targetObject: Record<string, unknown>, functionName: string, wrapperFactory: (original: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown): () => void;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for console capture payload parsing and processing
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.safeStringify = safeStringify;
7
+ exports.shouldNotStringify = shouldNotStringify;
8
+ exports.isPlainObject = isPlainObject;
9
+ exports.isObjectTooDeep = isObjectTooDeep;
10
+ exports.getStackTrace = getStackTrace;
11
+ exports.truncateString = truncateString;
12
+ exports.simpleStringify = simpleStringify;
13
+ exports.wrapFunctionWithRestore = wrapFunctionWithRestore;
14
+ function safeStringify(val, maxKeysCount, maxDepth, maxLength) {
15
+ try {
16
+ if (shouldNotStringify(val, maxKeysCount, maxDepth)) {
17
+ return simpleStringify(val, maxLength);
18
+ }
19
+ if (typeof val === 'string') {
20
+ return truncateString(val, maxLength);
21
+ }
22
+ if (typeof val === 'object' && val !== null) {
23
+ return truncateString(JSON.stringify(val), maxLength);
24
+ }
25
+ return truncateString(String(val), maxLength);
26
+ }
27
+ catch (_a) {
28
+ return truncateString('[Unserializable]', maxLength);
29
+ }
30
+ }
31
+ function shouldNotStringify(val, maxKeysCount, maxDepth) {
32
+ if (isPlainObject(val)) {
33
+ if (Object.keys(val).length > maxKeysCount) {
34
+ return true;
35
+ }
36
+ if (isObjectTooDeep(val, maxDepth)) {
37
+ return true;
38
+ }
39
+ return false;
40
+ }
41
+ if (typeof val === 'function') {
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ function isPlainObject(obj) {
47
+ return Object.prototype.toString.call(obj) === '[object Object]';
48
+ }
49
+ function isObjectTooDeep(obj, maxDepth, seen = new WeakSet()) {
50
+ if (maxDepth <= 0) {
51
+ return true;
52
+ }
53
+ if (typeof obj !== 'object' || obj === null) {
54
+ return false; // primitives are never "too deep"
55
+ }
56
+ if (seen.has(obj)) {
57
+ return false; // cycle detected
58
+ }
59
+ seen.add(obj);
60
+ return Object.values(obj).some((value) => isObjectTooDeep(value, maxDepth - 1, seen));
61
+ }
62
+ function getStackTrace() {
63
+ const stack = new Error().stack;
64
+ return stack ? stack.split('\n').slice(2, 5).join('\n') : null;
65
+ }
66
+ function truncateString(str, maxLength) {
67
+ if (str.length <= maxLength) {
68
+ return str;
69
+ }
70
+ return str.slice(0, maxLength) + '...';
71
+ }
72
+ function simpleStringify(val, maxLength) {
73
+ return truncateString(val.toString(), maxLength);
74
+ }
75
+ function wrapFunctionWithRestore(targetObject, functionName, wrapperFactory) {
76
+ const originalFunction = targetObject[functionName];
77
+ if (typeof originalFunction !== 'function') {
78
+ return () => {
79
+ // noop
80
+ };
81
+ }
82
+ try {
83
+ const wrappedFunction = wrapperFactory(originalFunction);
84
+ Object.defineProperty(wrappedFunction, '__statsig_original__', {
85
+ enumerable: false,
86
+ value: originalFunction,
87
+ });
88
+ targetObject[functionName] = wrappedFunction;
89
+ // Restore function
90
+ return () => {
91
+ targetObject[functionName] = originalFunction;
92
+ };
93
+ }
94
+ catch (_a) {
95
+ return () => {
96
+ // noop
97
+ };
98
+ }
99
+ }
@@ -0,0 +1,3 @@
1
+ import { ConsoleCaptureOptions } from './statsig-generated';
2
+ export declare function startStatsigConsoleCapture(sdkKey: string, options?: ConsoleCaptureOptions): void;
3
+ export declare function stopStatsigConsoleCapture(): void;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startStatsigConsoleCapture = startStatsigConsoleCapture;
4
+ exports.stopStatsigConsoleCapture = stopStatsigConsoleCapture;
5
+ const console_captrue_utils_1 = require("./console_captrue_utils");
6
+ const _1 = require(".");
7
+ const CAPTURE_LEVELS = [
8
+ 'log',
9
+ 'warn',
10
+ 'error',
11
+ 'debug',
12
+ 'info',
13
+ 'trace',
14
+ ];
15
+ const originalConsoleFns = {};
16
+ const originalConsoleErrorFn = typeof console !== 'undefined' ? console.error : undefined;
17
+ const MAX_KEYS = 100;
18
+ const MAX_DEPTH = 10;
19
+ const MAX_LENGTH = 4096;
20
+ function captureLog(level, args, sdkKey, maxKeys, maxDepth, maxLength) {
21
+ const message = args.map((a) => (0, console_captrue_utils_1.safeStringify)(a, maxKeys, maxDepth, maxLength));
22
+ if (level.toLowerCase() === 'error' &&
23
+ typeof args[0] === 'string' &&
24
+ args[0].startsWith('Trace')) {
25
+ level = 'trace'; // node use error for console.trace
26
+ }
27
+ const stackTrace = (0, console_captrue_utils_1.getStackTrace)();
28
+ (0, _1.statsigCaptureLogLine)(level, message, sdkKey, stackTrace);
29
+ }
30
+ function startStatsigConsoleCapture(sdkKey, options) {
31
+ stopStatsigConsoleCapture();
32
+ for (const level of CAPTURE_LEVELS) {
33
+ const originalFn = console[level];
34
+ if (!originalFn || typeof originalFn !== 'function') {
35
+ continue;
36
+ }
37
+ let isCapturing = false;
38
+ const restoreFn = (0, console_captrue_utils_1.wrapFunctionWithRestore)(console, level, (originalFn) => {
39
+ return (...args) => {
40
+ var _a, _b, _c;
41
+ originalFn(...args);
42
+ if (isCapturing)
43
+ return;
44
+ isCapturing = true;
45
+ const maxKeys = Math.min((_a = options === null || options === void 0 ? void 0 : options.maxKeys) !== null && _a !== void 0 ? _a : MAX_KEYS, MAX_KEYS);
46
+ const maxDepth = Math.min((_b = options === null || options === void 0 ? void 0 : options.maxDepth) !== null && _b !== void 0 ? _b : MAX_DEPTH, MAX_DEPTH);
47
+ const maxLength = Math.min((_c = options === null || options === void 0 ? void 0 : options.maxLength) !== null && _c !== void 0 ? _c : MAX_LENGTH, MAX_LENGTH);
48
+ try {
49
+ captureLog(level, args, sdkKey, maxKeys, maxDepth, maxLength);
50
+ }
51
+ catch (err) {
52
+ if (originalConsoleErrorFn &&
53
+ typeof originalConsoleErrorFn === 'function') {
54
+ originalConsoleErrorFn('Statsig log capture failed:', err);
55
+ }
56
+ }
57
+ finally {
58
+ isCapturing = false;
59
+ }
60
+ };
61
+ });
62
+ originalConsoleFns[level] = restoreFn;
63
+ }
64
+ }
65
+ function stopStatsigConsoleCapture() {
66
+ for (const level of CAPTURE_LEVELS) {
67
+ const restoreFn = originalConsoleFns[level];
68
+ if (restoreFn && typeof restoreFn === 'function') {
69
+ restoreFn();
70
+ delete originalConsoleFns[level];
71
+ }
72
+ }
73
+ for (const key of Object.keys(originalConsoleFns)) {
74
+ delete originalConsoleFns[key];
75
+ }
76
+ }
@@ -0,0 +1,5 @@
1
+ export declare class ErrorBoundary {
2
+ static wrap(instance: unknown): void;
3
+ private static _capture;
4
+ private static _onError;
5
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorBoundary = void 0;
4
+ class ErrorBoundary {
5
+ static wrap(instance) {
6
+ try {
7
+ const obj = instance;
8
+ _getAllInstanceMethodNames(obj).forEach((name) => {
9
+ const original = obj[name];
10
+ if ('$EB' in original) {
11
+ return;
12
+ }
13
+ obj[name] = (...args) => {
14
+ return this._capture(name, () => original.apply(instance, args));
15
+ };
16
+ obj[name].$EB = true;
17
+ });
18
+ }
19
+ catch (err) {
20
+ this._onError('eb:wrap', err);
21
+ }
22
+ }
23
+ static _capture(tag, task) {
24
+ try {
25
+ const res = task();
26
+ if (res && res instanceof Promise) {
27
+ return res.catch((err) => this._onError(tag, err));
28
+ }
29
+ return res;
30
+ }
31
+ catch (error) {
32
+ this._onError(tag, error);
33
+ return null;
34
+ }
35
+ }
36
+ static _onError(tag, error) {
37
+ _tryConvertInvalidArgError(error);
38
+ const printableTag = tag.replace('__INTERNAL_', '');
39
+ console.error('Statsig::' + printableTag, error);
40
+ }
41
+ }
42
+ exports.ErrorBoundary = ErrorBoundary;
43
+ function _getAllInstanceMethodNames(instance) {
44
+ const names = new Set();
45
+ let proto = Object.getPrototypeOf(instance);
46
+ while (proto && proto !== Object.prototype) {
47
+ Object.getOwnPropertyNames(proto)
48
+ .filter((prop) => typeof (proto === null || proto === void 0 ? void 0 : proto[prop]) === 'function')
49
+ .forEach((name) => names.add(name));
50
+ proto = Object.getPrototypeOf(proto);
51
+ }
52
+ return Array.from(names);
53
+ }
54
+ function _tryConvertInvalidArgError(error) {
55
+ if (typeof error !== 'object' || error === null) {
56
+ return;
57
+ }
58
+ if (!('code' in error) || error.code !== 'InvalidArg') {
59
+ return;
60
+ }
61
+ if (!('message' in error) || typeof error.message !== 'string') {
62
+ return;
63
+ }
64
+ if (error.message.startsWith('Failed to recover `StatsigUser` type from napi value')) {
65
+ error.message =
66
+ 'Expected StatsigUser instance, plain javascript object is not supported. Please create a StatsigUser instance using `new StatsigUser(...)` instead.';
67
+ return;
68
+ }
69
+ }
package/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions, SdkEvent, StatsigNapiInternal, StatsigOptions, StatsigResult, StatsigUser } from './statsig-generated';
2
+ import { DynamicConfig, Experiment, FeatureGate, Layer } from './statsig_types';
3
+ export * from './statsig-generated';
4
+ export * from './statsig_types';
5
+ export declare class Statsig extends StatsigNapiInternal {
6
+ private static _sharedInstance;
7
+ static shared(): Statsig;
8
+ static hasShared(): boolean;
9
+ static newShared(sdkKey: string, options?: StatsigOptions): Statsig;
10
+ static removeSharedInstance(): void;
11
+ constructor(sdkKey: string, options?: StatsigOptions);
12
+ stopConsoleCapture(): void;
13
+ shutdown(timeout_ms?: number): Promise<StatsigResult>;
14
+ subscribe(eventName: SdkEvent, callback: (event: any) => void): string;
15
+ getFeatureGate(user: StatsigUser, gateName: string, options?: FeatureGateEvaluationOptions): FeatureGate;
16
+ getDynamicConfig(user: StatsigUser, configName: string, options?: DynamicConfigEvaluationOptions): DynamicConfig;
17
+ getExperiment(user: StatsigUser, experimentName: string, options?: ExperimentEvaluationOptions): Experiment;
18
+ getExperimentByGroupName(experimentName: string, groupName: string): Experiment;
19
+ getLayer(user: StatsigUser, layerName: string, options?: LayerEvaluationOptions): Layer;
20
+ }
package/index.js ADDED
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Statsig = void 0;
27
+ const https_proxy_agent_1 = require("https-proxy-agent");
28
+ const console_capture_1 = require("./console_capture");
29
+ const error_boundary_1 = require("./error_boundary");
30
+ const statsig_generated_1 = require("./statsig-generated");
31
+ const statsig_types_1 = require("./statsig_types");
32
+ __exportStar(require("./statsig-generated"), exports);
33
+ __exportStar(require("./statsig_types"), exports);
34
+ const inspectSym = Symbol.for('nodejs.util.inspect.custom');
35
+ // @ts-expect-error - prototype assignment
36
+ statsig_generated_1.StatsigUser.prototype[inspectSym] = function () {
37
+ return this.toJSON();
38
+ };
39
+ // @ts-expect-error - prototype assignment
40
+ statsig_generated_1.ParameterStore.prototype[inspectSym] = function () {
41
+ return this.toJSON();
42
+ };
43
+ function createProxyAgent(options) {
44
+ const proxy = options === null || options === void 0 ? void 0 : options.proxyConfig;
45
+ if ((proxy === null || proxy === void 0 ? void 0 : proxy.proxyHost) && (proxy === null || proxy === void 0 ? void 0 : proxy.proxyProtocol)) {
46
+ const protocol = proxy.proxyProtocol;
47
+ const host = proxy.proxyHost;
48
+ const port = proxy.proxyPort ? `:${proxy.proxyPort}` : '';
49
+ const auth = proxy.proxyAuth ? `${proxy.proxyAuth}@` : '';
50
+ const proxyUrl = `${protocol}://${auth}${host}${port}`;
51
+ if (protocol === 'http' || protocol === 'https') {
52
+ return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl);
53
+ }
54
+ }
55
+ return undefined; // node-fetch agent parameter takes in undefined type instead of null
56
+ }
57
+ class Statsig extends statsig_generated_1.StatsigNapiInternal {
58
+ static shared() {
59
+ if (!Statsig.hasShared()) {
60
+ console.warn('[Statsig] No shared instance has been created yet. Call newShared() before using it. Returning an invalid instance');
61
+ return _createErrorInstance();
62
+ }
63
+ return Statsig._sharedInstance;
64
+ }
65
+ static hasShared() {
66
+ return Statsig._sharedInstance !== null;
67
+ }
68
+ static newShared(sdkKey, options) {
69
+ if (Statsig.hasShared()) {
70
+ console.warn('[Statsig] Shared instance has been created, call removeSharedInstance() if you want to create another one. ' +
71
+ 'Returning an invalid instance');
72
+ return _createErrorInstance();
73
+ }
74
+ Statsig._sharedInstance = new Statsig(sdkKey, options);
75
+ return Statsig._sharedInstance;
76
+ }
77
+ static removeSharedInstance() {
78
+ Statsig._sharedInstance = null;
79
+ }
80
+ constructor(sdkKey, options) {
81
+ var _a;
82
+ super(sdkKey, options);
83
+ error_boundary_1.ErrorBoundary.wrap(this);
84
+ if ((_a = options === null || options === void 0 ? void 0 : options.consoleCaptureOptions) === null || _a === void 0 ? void 0 : _a.enabled) {
85
+ (0, console_capture_1.startStatsigConsoleCapture)(sdkKey, options.consoleCaptureOptions);
86
+ }
87
+ }
88
+ stopConsoleCapture() {
89
+ (0, console_capture_1.stopStatsigConsoleCapture)();
90
+ }
91
+ shutdown(timeout_ms) {
92
+ const _super = Object.create(null, {
93
+ shutdown: { get: () => super.shutdown }
94
+ });
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ (0, console_capture_1.stopStatsigConsoleCapture)();
97
+ return _super.shutdown.call(this, timeout_ms);
98
+ });
99
+ }
100
+ subscribe(eventName, callback) {
101
+ return this.__INTERNAL_subscribe(eventName, (raw) => {
102
+ try {
103
+ callback(JSON.parse(raw));
104
+ }
105
+ catch (error) {
106
+ console.error(`[Statsig] Error parsing SDK Event: ${error}`);
107
+ }
108
+ });
109
+ }
110
+ getFeatureGate(user, gateName, options) {
111
+ const raw = this.__INTERNAL_getFeatureGate(user, gateName, options);
112
+ return new statsig_types_1.FeatureGate(gateName, raw);
113
+ }
114
+ getDynamicConfig(user, configName, options) {
115
+ const raw = this.__INTERNAL_getDynamicConfig(user, configName, options);
116
+ return new statsig_types_1.DynamicConfig(configName, raw);
117
+ }
118
+ getExperiment(user, experimentName, options) {
119
+ const raw = this.__INTERNAL_getExperiment(user, experimentName, options);
120
+ return new statsig_types_1.Experiment(experimentName, raw);
121
+ }
122
+ getExperimentByGroupName(experimentName, groupName) {
123
+ const raw = this.__INTERNAL_getExperimentByGroupName(experimentName, groupName);
124
+ return new statsig_types_1.Experiment(experimentName, raw);
125
+ }
126
+ getLayer(user, layerName, options) {
127
+ const raw = this.__INTERNAL_getLayer(user, layerName, options);
128
+ const exposure = raw.__exposure;
129
+ return new statsig_types_1.Layer((param) => {
130
+ if (exposure != null) {
131
+ this.__INTERNAL_logLayerParamExposure(exposure, param);
132
+ }
133
+ }, layerName, raw);
134
+ }
135
+ }
136
+ exports.Statsig = Statsig;
137
+ Statsig._sharedInstance = null;
138
+ function _createErrorInstance() {
139
+ let dummyInstance = new Statsig('INVALID-KEY');
140
+ dummyInstance.shutdown();
141
+ return dummyInstance;
142
+ }
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@oai-statsig/statsig-node-core",
3
+ "version": "0.19.5-beta.2604230102",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "jest --colors"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "description": "",
12
+ "repository": "https://github.com/statsig-io/statsig-server-core.git",
13
+ "dependencies": {
14
+ "@octokit/core": "^6",
15
+ "https-proxy-agent": "^7.0.6",
16
+ "node-fetch": "2.7.0"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/helpers": "7.26.10",
20
+ "@napi-rs/cli": "3.0.0-alpha.65",
21
+ "@octokit/endpoint": "10.1.3",
22
+ "@octokit/plugin-paginate-rest": "11.4.1",
23
+ "@octokit/request": "9.2.1",
24
+ "@octokit/request-error": "6.1.7",
25
+ "@types/compression": "^1.7.5",
26
+ "@types/express": "^5.0.0",
27
+ "@types/jest": "^29.5.14",
28
+ "@types/node": "^22.10.10",
29
+ "@types/node-fetch": "2.6.12",
30
+ "compression": "^1.7.5",
31
+ "express": "^4.21.2",
32
+ "form-data": "4.0.4",
33
+ "jest": "^29.7.0",
34
+ "jest-extended": "^7.0.0",
35
+ "on-headers": "1.1.0",
36
+ "tar-fs": "^2.1.4",
37
+ "ts-jest": "^29.2.5",
38
+ "typescript": "^5.7.3"
39
+ },
40
+ "engines": {
41
+ "node": ">= 6.14.2 < 7 || >= 8.11.2 < 9 || >= 9.11.0 < 10 || >= 10.0.0"
42
+ },
43
+ "napi": {
44
+ "binaryName": "statsig-node-core",
45
+ "targets": [
46
+ "aarch64-apple-darwin",
47
+ "aarch64-unknown-linux-gnu",
48
+ "aarch64-unknown-linux-musl",
49
+ "aarch64-pc-windows-msvc",
50
+ "i686-pc-windows-msvc",
51
+ "x86_64-apple-darwin",
52
+ "x86_64-pc-windows-msvc",
53
+ "x86_64-unknown-linux-gnu",
54
+ "x86_64-unknown-linux-musl"
55
+ ]
56
+ },
57
+ "pnpm": {
58
+ "overrides": {
59
+ "minimatch": "10.2.1"
60
+ }
61
+ },
62
+ "optionalDependencies": {
63
+ "@oai-statsig/statsig-node-core-linux-x64-musl": "0.19.5-beta.2604230102",
64
+ "@oai-statsig/statsig-node-core-linux-x64-gnu": "0.19.5-beta.2604230102",
65
+ "@oai-statsig/statsig-node-core-win32-x64-msvc": "0.19.5-beta.2604230102",
66
+ "@oai-statsig/statsig-node-core-darwin-x64": "0.19.5-beta.2604230102",
67
+ "@oai-statsig/statsig-node-core-win32-ia32-msvc": "0.19.5-beta.2604230102",
68
+ "@oai-statsig/statsig-node-core-linux-arm64-musl": "0.19.5-beta.2604230102",
69
+ "@oai-statsig/statsig-node-core-linux-arm64-gnu": "0.19.5-beta.2604230102",
70
+ "@oai-statsig/statsig-node-core-darwin-arm64": "0.19.5-beta.2604230102"
71
+ }
72
+ }
@@ -0,0 +1,22 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const GENERATED_FILE = 'src/lib/statsig-generated.d.ts';
5
+ const FILES_TO_APPEND = ['src/lib/additional_types.ts'];
6
+ const generatedFileFullPath = path.resolve(__dirname, '..', GENERATED_FILE);
7
+
8
+ FILES_TO_APPEND.forEach((filePath) => {
9
+ const fullPath = path.resolve(__dirname, '..', filePath);
10
+ let header = `// ---- Manually defined typing section ----- \n`;
11
+ if (fs.existsSync(fullPath)) {
12
+ let content = fs.readFileSync(fullPath, 'utf8');
13
+ content = content.replace(
14
+ /^\s*import\s+.*?from\s+['"]\.\/statsig-generated['"];\s*$/gm,
15
+ '',
16
+ );
17
+ content = header + content;
18
+ fs.appendFileSync(generatedFileFullPath, content, 'utf8');
19
+ } else {
20
+ console.warn(`❌ File not found: ${filePath}`);
21
+ }
22
+ });