From 23668a9bbd69bfdf569e3e5ae0e551bdf283e522 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 25 Oct 2024 03:03:11 -0300 Subject: [PATCH 01/12] Remove 'full' subpackage, since there is not significant difference with the default 'slim' subpackage --- CHANGES.txt | 1 + full/package.json | 6 -- package-lock.json | 13 +--- package.json | 6 +- rollup.ci.config.js | 2 +- src/__tests__/offline/browser.spec.js | 12 ++-- src/full/index.ts | 7 --- src/full/splitFactory.ts | 27 -------- src/platform/{getFetchSlim.ts => getFetch.ts} | 0 src/platform/getFetchFull.ts | 6 -- src/settings/__tests__/index.spec.ts | 21 +++---- src/settings/full.ts | 23 ------- src/splitFactory.ts | 5 +- src/{full/umd.ts => umd-full.ts} | 0 ts-tests/index.ts | 9 --- types/full/index.d.ts | 61 ------------------- types/index.d.ts | 4 +- 17 files changed, 21 insertions(+), 182 deletions(-) delete mode 100644 full/package.json delete mode 100644 src/full/index.ts delete mode 100644 src/full/splitFactory.ts rename src/platform/{getFetchSlim.ts => getFetch.ts} (100%) delete mode 100644 src/platform/getFetchFull.ts delete mode 100644 src/settings/full.ts rename src/{full/umd.ts => umd-full.ts} (100%) delete mode 100644 types/full/index.d.ts diff --git a/CHANGES.txt b/CHANGES.txt index 7c7a536..bdeaae2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,7 @@ - Removed internal ponyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or provide a polyfill. - Removed the deprecated `GoogleAnalyticsToSplit` and `SplitToGoogleAnalytics` pluggable integration modules, along with the related interfaces in the TypeScript definitions. - Removed the `LocalhostFromObject` export from the "slim" entrypoint (`import { LocalhostFromObject } from '@splitsoftware/splitio-browserjs'`). It is no longer necessary to manually import and configure it in the `sync.localhostMode` option to enable localhost mode. + - Removed the "full" entrypoint (`import { SplitFactory } from '@splitsoftware/splitio-browserjs/full'`), since with the removal of `LocalhostFromObject` from the "slim" entrypoint, the difference between "slim" and "full" entrypoints is minimal. The "full" entrypoint differs only by including the `unfetch` ponyfill to support older browsers. 0.15.0 (September 13, 2024) - Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates: diff --git a/full/package.json b/full/package.json deleted file mode 100644 index a59cb3f..0000000 --- a/full/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "main": "../cjs/full/index.js", - "module": "../esm/full/index.js", - "types": "../types/full/index.d.ts", - "sideEffects": false -} diff --git a/package-lock.json b/package-lock.json index 3df898f..82d21f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@splitsoftware/splitio-commons": "2.0.0-rc.2", - "tslib": "^2.3.1", - "unfetch": "^4.2.0" + "tslib": "^2.3.1" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", @@ -9093,11 +9092,6 @@ "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", "dev": true }, - "node_modules/unfetch": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz", - "integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==" - }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -16231,11 +16225,6 @@ "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", "dev": true }, - "unfetch": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz", - "integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==" - }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", diff --git a/package.json b/package.json index c1445f2..f6f279e 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,7 @@ "cjs", "esm", "src", - "types", - "full" + "types" ], "scripts": { "check": "npm run check:lint && npm run check:types && npm run check:version", @@ -62,8 +61,7 @@ "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { "@splitsoftware/splitio-commons": "2.0.0-rc.2", - "tslib": "^2.3.1", - "unfetch": "^4.2.0" + "tslib": "^2.3.1" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", diff --git a/rollup.ci.config.js b/rollup.ci.config.js index af1d738..80dcb43 100644 --- a/rollup.ci.config.js +++ b/rollup.ci.config.js @@ -35,7 +35,7 @@ export default env => { * * Only https://www.npmjs.com/package/rollup-plugin-ts compiles from node_modules, and is used for tests. */ - createRollupConfig('esm/full/umd.js', 'full'), // umd/split-browser-VERSION.full[.min].js + createRollupConfig('esm/umd-full.js', 'full'), // umd/split-browser-VERSION.full[.min].js createRollupConfig('esm/umd.js') // umd/split-browser-VERSION[.min].js ]; }; diff --git a/src/__tests__/offline/browser.spec.js b/src/__tests__/offline/browser.spec.js index 6b2d981..2c5ee06 100644 --- a/src/__tests__/offline/browser.spec.js +++ b/src/__tests__/offline/browser.spec.js @@ -2,8 +2,7 @@ import tape from 'tape-catch'; import sinon from 'sinon'; import fetchMock from '../testUtils/fetchMock'; import { url } from '../testUtils'; -import { SplitFactory, InLocalStorage } from '../../full'; -import { SplitFactory as SplitFactorySlim } from '../../'; +import { SplitFactory, InLocalStorage } from '../../index'; import { settingsFactory } from '../../settings'; const settings = settingsFactory({ core: { key: 'facundo@split.io' } }); @@ -88,10 +87,7 @@ tape('Browser offline mode', function (assert) { sharedUpdateCount++; }); - const factoriesReadyFromCache = [ - SplitFactory({ ...config, storage: InLocalStorage() }), - SplitFactorySlim({ ...config, storage: InLocalStorage() }) - ]; + const factoryReadyFromCache = SplitFactory({ ...config, storage: InLocalStorage() }); const configs = [ { ...config, features: { ...config.features }, storage: InLocalStorage /* invalid */ }, { ...config }, @@ -99,7 +95,7 @@ tape('Browser offline mode', function (assert) { ]; const factories = [ ...configs.map(config => SplitFactory(config)), - ...factoriesReadyFromCache + factoryReadyFromCache ]; let readyCount = 0, updateCount = 0, readyFromCacheCount = 0; @@ -361,7 +357,7 @@ tape('Browser offline mode', function (assert) { // SDK events on other factory clients assert.equal(readyCount, factories.length, 'Each factory client should have emitted SDK_READY event once'); assert.equal(updateCount, factories.length - 1, 'Each factory client except one should have emitted SDK_UPDATE event once'); - assert.equal(readyFromCacheCount, factoriesReadyFromCache.length * 2, 'The main and shared client of the factories with LOCALSTORAGE should have emitted SDK_READY_FROM_CACHE event'); + assert.equal(readyFromCacheCount, 2, 'The main and shared client of the factory with LOCALSTORAGE should have emitted SDK_READY_FROM_CACHE event'); assert.end(); }); diff --git a/src/full/index.ts b/src/full/index.ts deleted file mode 100644 index be0ed7a..0000000 --- a/src/full/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { SplitFactory } from './splitFactory'; -export { InLocalStorage } from '@splitsoftware/splitio-commons/src/storages/inLocalStorage/index'; -export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/ErrorLogger'; -export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger'; -export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger'; -export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger'; -export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable'; diff --git a/src/full/splitFactory.ts b/src/full/splitFactory.ts deleted file mode 100644 index f134f29..0000000 --- a/src/full/splitFactory.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { settingsFactory } from '../settings/full'; -import { getModules } from '../platform/getModules'; -import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; -import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; -import { getFetch } from '../platform/getFetchFull'; -import { getEventSource } from '../platform/getEventSource'; -import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; -import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; -import { IBrowserSettings } from '../../types/splitio'; - -const platform = { getFetch, getEventSource, EventEmitter, now }; - -/** - * SplitFactory with pluggable modules for Browser. - * Includes fetch polyfill out-of-the-box. - * - * @param config configuration object used to instantiate the SDK - * @param __updateModules optional function that lets redefine internal SDK modules. Use with - * caution since, unlike `config`, this param is not validated neither considered part of the public API. - * @throws Will throw an error if the provided config is invalid. - */ -export function SplitFactory(config: IBrowserSettings, __updateModules?: (modules: ISdkFactoryParams) => void) { - const settings = settingsFactory(config); - const modules = getModules(settings, platform); - if (__updateModules) __updateModules(modules); - return sdkFactory(modules); -} diff --git a/src/platform/getFetchSlim.ts b/src/platform/getFetch.ts similarity index 100% rename from src/platform/getFetchSlim.ts rename to src/platform/getFetch.ts diff --git a/src/platform/getFetchFull.ts b/src/platform/getFetchFull.ts deleted file mode 100644 index 496c07a..0000000 --- a/src/platform/getFetchFull.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IFetch } from '@splitsoftware/splitio-commons/src/services/types'; -import unfetch from 'unfetch'; - -export function getFetch() { - return typeof fetch === 'function' ? fetch : unfetch as unknown as IFetch; -} diff --git a/src/settings/__tests__/index.spec.ts b/src/settings/__tests__/index.spec.ts index 4b1ad49..ab157b6 100644 --- a/src/settings/__tests__/index.spec.ts +++ b/src/settings/__tests__/index.spec.ts @@ -1,18 +1,15 @@ -import { settingsFactory as slimSettingsFactory } from '../index'; -import { settingsFactory as fullSettingsFactory } from '../full'; +import { settingsFactory } from '../index'; test('SETTINGS / Consent is overwritable and "GRANTED" by default', () => { - [slimSettingsFactory, fullSettingsFactory].forEach((settingsFactory) => { - let settings = settingsFactory({}); - expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if not provided + let settings = settingsFactory({}); + expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if not provided - settings = settingsFactory({ userConsent: 'INVALID-VALUE' }); - expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if a wrong value is provided + settings = settingsFactory({ userConsent: 'INVALID-VALUE' }); + expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if a wrong value is provided - settings = settingsFactory({ userConsent: 'UNKNOWN' }); - expect(settings.userConsent).toEqual('UNKNOWN'); // userConsent can be overwritten + settings = settingsFactory({ userConsent: 'UNKNOWN' }); + expect(settings.userConsent).toEqual('UNKNOWN'); // userConsent can be overwritten - settings = settingsFactory({ userConsent: 'declined' }); - expect(settings.userConsent).toEqual('DECLINED'); // userConsent can be overwritten - }); + settings = settingsFactory({ userConsent: 'declined' }); + expect(settings.userConsent).toEqual('DECLINED'); // userConsent can be overwritten }); diff --git a/src/settings/full.ts b/src/settings/full.ts deleted file mode 100644 index 8c6f6fb..0000000 --- a/src/settings/full.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/index'; -import { defaults } from './defaults'; -import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime'; -import { validateStorageCS } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS'; -import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/integrations/pluggable'; -import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/pluggableLogger'; -import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent'; - -const params = { - defaults, - acceptKey: true, // Client with bound key - runtime: validateRuntime, - storage: validateStorageCS, - integrations: validatePluggableIntegrations, - logger: validateLogger, - consent: validateConsent, -}; - -export function settingsFactory(config: any) { - const settings = settingsValidation(config, params); - - return settings; -} diff --git a/src/splitFactory.ts b/src/splitFactory.ts index e7456ec..f38f382 100644 --- a/src/splitFactory.ts +++ b/src/splitFactory.ts @@ -2,7 +2,7 @@ import { settingsFactory } from './settings'; import { getModules } from './platform/getModules'; import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; -import { getFetch } from './platform/getFetchSlim'; +import { getFetch } from './platform/getFetch'; import { getEventSource } from './platform/getEventSource'; import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; @@ -11,8 +11,7 @@ import { IBrowserSettings } from '../types/splitio'; const platform = { getFetch, getEventSource, EventEmitter, now }; /** - * Slim SplitFactory with pluggable modules for Browser. - * Doesn't include fetch ponyfill out-of-the-box. + * SplitFactory with pluggable modules for Browser. * * @param config configuration object used to instantiate the SDK * @param __updateModules optional function that lets redefine internal SDK modules. Use with diff --git a/src/full/umd.ts b/src/umd-full.ts similarity index 100% rename from src/full/umd.ts rename to src/umd-full.ts diff --git a/ts-tests/index.ts b/ts-tests/index.ts index ad8e512..462daac 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -11,13 +11,8 @@ * @author Nico Zelaya */ -import { SplitFactory as SplitFactoryFull, InLocalStorage as InLocalStorageFull, DebugLogger as DebugLoggerFull, InfoLogger as InfoLoggerFull, WarnLogger as WarnLoggerFull, ErrorLogger as ErrorLoggerFull, PluggableStorage as PluggableStorageFull } from '@splitsoftware/splitio-browserjs/full'; import { SplitFactory, InLocalStorage, DebugLogger, InfoLogger, WarnLogger, ErrorLogger, PluggableStorage } from '@splitsoftware/splitio-browserjs'; -// Entry points must export the same objects -let splitFactory = SplitFactory; splitFactory = SplitFactoryFull; -let inLocalStorage = InLocalStorage; inLocalStorage = InLocalStorageFull; -let pluggableStorage = PluggableStorage; pluggableStorage = PluggableStorageFull; let stringPromise: Promise; let splitNamesPromise: Promise; @@ -626,10 +621,6 @@ fullBrowserSettings.debug = DebugLogger(); fullBrowserSettings.debug = InfoLogger(); fullBrowserSettings.debug = WarnLogger(); fullBrowserSettings.debug = ErrorLogger(); -fullBrowserSettings.debug = DebugLoggerFull(); -fullBrowserSettings.debug = InfoLoggerFull(); -fullBrowserSettings.debug = WarnLoggerFull(); -fullBrowserSettings.debug = ErrorLoggerFull(); // let fullNodeSettings: SplitIO.INodeSettings = { // core: { diff --git a/types/full/index.d.ts b/types/full/index.d.ts deleted file mode 100644 index fa667ad..0000000 --- a/types/full/index.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Declaration file for JavaScript Browser Split Software SDK -// Project: http://www.split.io/ -// Definitions by: Nico Zelaya - -/// -export = JsSdk; - -declare module JsSdk { - /** - * Full version of the Split.io SDK factory function. - * - * Unlike the slim version, it doesn't require a 'fetch' polyfill to support old browsers @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#language-support}. - * - * The settings parameter should be an object that complies with the SplitIO.IBrowserSettings. - * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} - */ - export function SplitFactory(settings: SplitIO.IBrowserSettings): SplitIO.ISDK; - export function SplitFactory(settings: SplitIO.IBrowserAsyncSettings): SplitIO.IAsyncSDK; - - /** - * Persistent storage based on the LocalStorage Web API for browsers. - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#storage} - */ - export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory; - - /** - * Pluggable storage to use the SDK in consumer mode. - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage} - */ - export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory; - - /** - * Creates a logger instance that enables descriptive log messages with DEBUG log level when passed in the factory settings. - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} - */ - export function DebugLogger(): SplitIO.ILogger; - - /** - * Creates a logger instance that enables descriptive log messages with INFO log level when passed in the factory settings. - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} - */ - export function InfoLogger(): SplitIO.ILogger; - - /** - * Creates a logger instance that enables descriptive log messages with WARN log level when passed in the factory settings. - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} - */ - export function WarnLogger(): SplitIO.ILogger; - - /** - * Creates a logger instance that enables descriptive log messages with ERROR log level when passed in the factory settings. - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} - */ - export function ErrorLogger(): SplitIO.ILogger; -} diff --git a/types/index.d.ts b/types/index.d.ts index 1f1b113..ba0059f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -7,9 +7,7 @@ export = JsSdk; declare module JsSdk { /** - * Slim version of the Split.io SDK factory function. - * - * Recommended to use for bundle size reduction in production, since it doesn't include a 'fetch' polyfill out-of-the-box + * Split.io SDK factory function. * * The settings parameter should be an object that complies with the SplitIO.IBrowserSettings. * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} From b935a911d7b739ad41a2924bc5222088eb1ef0b3 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 25 Oct 2024 12:48:23 -0300 Subject: [PATCH 02/12] 1st step: move SplitIO namespace definition from Browser SDK to JS-Commons --- package.json | 4 +- scripts/ts-tests.sh | 20 - ts-tests/.gitignore | 3 - ts-tests/index.ts | 2 +- ts-tests/package.json | 11 - ts-tests/tsconfig.json | 3 +- types/index.d.ts | 3 +- types/splitio.d.ts | 1553 ---------------------------------------- 8 files changed, 6 insertions(+), 1593 deletions(-) delete mode 100755 scripts/ts-tests.sh delete mode 100644 ts-tests/.gitignore delete mode 100644 ts-tests/package.json delete mode 100644 types/splitio.d.ts diff --git a/package.json b/package.json index f6f279e..299b847 100644 --- a/package.json +++ b/package.json @@ -35,9 +35,7 @@ "test:e2e-errorCatching": "karma start karma/e2e.errorCatching.karma.conf.js", "test:e2e-push": "karma start karma/e2e.push.karma.conf.js", "test:e2e-consumer": "karma start karma/e2e.consumer.karma.conf.js", - "pretest-ts-decls": "npm run build:esm && npm run build:cjs && npm link", - "test-ts-decls": "./scripts/ts-tests.sh", - "posttest-ts-decls": "npm rm --location=global @splitsoftware/splitio-browserjs && npm install", + "test-ts-decls": "tsc --build ts-tests", "all": "npm run check && npm run build && npm run test-ts-decls && npm run test", "publish:rc": "npm run check && npm run build && npm publish --tag rc", "publish:stable": "npm run check && npm run build && npm publish" diff --git a/scripts/ts-tests.sh b/scripts/ts-tests.sh deleted file mode 100755 index f3a9491..0000000 --- a/scripts/ts-tests.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -cd ts-tests ## Go to typescript tests folder -echo "Installing dependencies for TypeScript declarations testing..." -npm install ## Install dependencies -echo "Dependencies installed, linking the package." -npm link @splitsoftware/splitio-browserjs ## Link to the cloned code -echo "Running tsc compiler." -../node_modules/.bin/tsc ## Run typescript compiler. No need for flags as we have a tsconfig.json file - -if [ $? -eq 0 ] -then - echo "✅ Successfully compiled TS tests." - npm unlink @splitsoftware/splitio-browserjs - exit 0 -else - echo "☠️ Error compiling TS tests." - npm unlink @splitsoftware/splitio-browserjs - exit 1 -fi diff --git a/ts-tests/.gitignore b/ts-tests/.gitignore deleted file mode 100644 index e00a366..0000000 --- a/ts-tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -index.js -package-lock.json -node_modules/ \ No newline at end of file diff --git a/ts-tests/index.ts b/ts-tests/index.ts index 462daac..fead10c 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -11,7 +11,7 @@ * @author Nico Zelaya */ -import { SplitFactory, InLocalStorage, DebugLogger, InfoLogger, WarnLogger, ErrorLogger, PluggableStorage } from '@splitsoftware/splitio-browserjs'; +import { SplitFactory, InLocalStorage, DebugLogger, InfoLogger, WarnLogger, ErrorLogger, PluggableStorage } from '../types/index'; let stringPromise: Promise; diff --git a/ts-tests/package.json b/ts-tests/package.json deleted file mode 100644 index 32358c4..0000000 --- a/ts-tests/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts-tests", - "version": "1.0.0", - "description": "SDK tests for TypeScript declaration files", - "author": "Nico Zelaya", - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "git+https://github.com/splitio/javascript-browser-client.git" - } -} diff --git a/ts-tests/tsconfig.json b/ts-tests/tsconfig.json index 4adc239..a0ceeb0 100644 --- a/ts-tests/tsconfig.json +++ b/ts-tests/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "noImplicitAny": true, "target": "es5", - "module": "commonjs" + "module": "commonjs", + "noEmit": true }, "files": [ "index" diff --git a/types/index.d.ts b/types/index.d.ts index ba0059f..280dfc6 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,7 +2,8 @@ // Project: http://www.split.io/ // Definitions by: Nico Zelaya -/// +import '@splitsoftware/splitio-commons'; + export = JsSdk; declare module JsSdk { diff --git a/types/splitio.d.ts b/types/splitio.d.ts deleted file mode 100644 index d8840bd..0000000 --- a/types/splitio.d.ts +++ /dev/null @@ -1,1553 +0,0 @@ -// Type definitions for JavaScript Browser Split Software SDK -// Project: http://www.split.io/ -// Definitions by: Nico Zelaya - -export as namespace SplitIO; -export = SplitIO; - -/** - * EventEmitter interface based on a subset of the NodeJS.EventEmitter methods. - */ -interface IEventEmitter { - addListener(event: string, listener: (...args: any[]) => void): this - on(event: string, listener: (...args: any[]) => void): this - once(event: string, listener: (...args: any[]) => void): this - removeListener(event: string, listener: (...args: any[]) => void): this - off(event: string, listener: (...args: any[]) => void): this - removeAllListeners(event?: string): this - emit(event: string, ...args: any[]): boolean -} -/** - * @typedef {Object} EventConsts - * @property {string} SDK_READY The ready event. - * @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data. - * @property {string} SDK_READY_TIMED_OUT The timeout event. - * @property {string} SDK_UPDATE The update event. - */ -type EventConsts = { - SDK_READY: 'init::ready', - SDK_READY_FROM_CACHE: 'init::cache-ready', - SDK_READY_TIMED_OUT: 'init::timeout', - SDK_UPDATE: 'state::update' -}; -/** - * SDK Modes. - * @typedef {string} SDKMode - */ -type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial'; -/** - * Storage types. - * @typedef {string} StorageType - */ -type StorageType = 'MEMORY' | 'LOCALSTORAGE'; -/** - * Settings interface. This is a representation of the settings the SDK expose, that's why - * most of it's props are readonly. Only features should be rewritten when localhost mode is active. - * @interface ISettings - */ -interface ISettings { - readonly core: { - authorizationKey: string, - key: SplitIO.SplitKey, - labelsEnabled: boolean, - IPAddressesEnabled: boolean - }, - readonly mode: SDKMode, - readonly scheduler: { - featuresRefreshRate: number, - impressionsRefreshRate: number, - impressionsQueueSize: number, - telemetryRefreshRate: number, - segmentsRefreshRate: number, - offlineRefreshRate: number, - eventsPushRate: number, - eventsQueueSize: number, - pushRetryBackoffBase: number - }, - readonly startup: { - readyTimeout: number, - requestTimeoutBeforeReady: number, - retriesOnFailureBeforeReady: number, - eventsFirstPushWindow: number - }, - readonly storage?: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory, - readonly urls: { - events: string, - sdk: string, - auth: string, - streaming: string, - telemetry: string - }, - readonly integrations?: SplitIO.IntegrationFactory[], - readonly debug: boolean | LogLevel | SplitIO.ILogger, - readonly version: string, - /** - * Mocked features map. - */ - features?: SplitIO.MockedFeaturesMap, - readonly streamingEnabled: boolean, - readonly sync: { - splitFilters: SplitIO.SplitFilter[], - impressionsMode: SplitIO.ImpressionsMode, - enabled: boolean, - flagSpecVersion: string, - requestOptions?: { - getHeaderOverrides?: (context: { headers: Record }) => Record - }, - }, - readonly userConsent: SplitIO.ConsentStatus -} -/** - * Log levels. - * @typedef {string} LogLevel - */ -type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE'; -/** - * Logger API - * @interface ILoggerAPI - */ -interface ILoggerAPI { - /** - * Enables SDK logging to the console. - * @function enable - * @returns {void} - */ - enable(): void, - /** - * Disables SDK logging. - * @function disable - * @returns {void} - */ - disable(): void, - /** - * Sets a log level for the SDK logs. - * @function setLogLevel - * @returns {void} - */ - setLogLevel(logLevel: LogLevel): void, - /** - * Log level constants. Use this to pass them to setLogLevel function. - */ - LogLevel: { - [level in LogLevel]: LogLevel - } -} -/** - * User consent API - * @interface IUserConsentAPI - */ -interface IUserConsentAPI { - /** - * Sets or updates the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively. - * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud. - * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud. - * - * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory. - * - * @function setStatus - * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'. - * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not. - */ - setStatus(userConsent: boolean): boolean; - /** - * Gets the user consent status. - * - * @function getStatus - * @returns {ConsentStatus} The user consent status. - */ - getStatus(): SplitIO.ConsentStatus; - /** - * Consent status constants. Use this to compare with the getStatus function result. - */ - Status: { - [status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus - } -} -/** - * Common settings between Browser and NodeJS settings interface. - * @interface ISharedSettings - */ -interface ISharedSettings { - /** - * Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object. - * Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes. - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} - * - * Examples: - * ```typescript - * config.debug = true - * config.debug = 'WARN' - * config.debug = ErrorLogger() - * ``` - * @property {boolean | LogLevel | ILogger} debug - * @default false - */ - debug?: boolean | LogLevel | SplitIO.ILogger, - /** - * The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface, - * which will check for the logImpression method. - * @property {IImpressionListener} impressionListener - * @default undefined - */ - impressionListener?: SplitIO.IImpressionListener, - /** - * Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming, - * the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming. - * @property {boolean} streamingEnabled - * @default true - */ - streamingEnabled?: boolean, - /** - * SDK synchronization settings. - * @property {Object} sync - */ - sync?: { - /** - * List of feature flag filters. These filters are used to fetch a subset of the feature flag definitions in your environment, in order to reduce the delay of the SDK to be ready. - * This configuration is only meaningful when the SDK is working in "standalone" mode. - * - * Example: - * `splitFilter: [ - * { type: 'byName', values: ['my_feature_flag_1', 'my_feature_flag_2'] }, // will fetch feature flags named 'my_feature_flag_1' and 'my_feature_flag_2' - * ]` - * @property {SplitIO.SplitFilter[]} splitFilters - */ - splitFilters?: SplitIO.SplitFilter[] - /** - * Impressions Collection Mode. Option to determine how impressions are going to be sent to Split servers. - * Possible values are 'DEBUG', 'OPTIMIZED', and 'NONE'. - * - DEBUG: will send all the impressions generated (recommended only for debugging purposes). - * - OPTIMIZED: will send unique impressions to Split servers, avoiding a considerable amount of traffic that duplicated impressions could generate. - * - NONE: will send unique keys evaluated per feature to Split servers instead of full blown impressions, avoiding a considerable amount of traffic that impressions could generate. - * - * @property {String} impressionsMode - * @default 'OPTIMIZED' - */ - impressionsMode?: SplitIO.ImpressionsMode, - /** - * Controls the SDK continuous synchronization flags. - * - * When `true` a running SDK will process rollout plan updates performed on the UI (default). - * When false it'll just fetch all data upon init. - * - * @property {boolean} enabled - * @default true - */ - enabled?: boolean - /** - * Custom options object for HTTP(S) requests in the Browser. - * If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls. - * This configuration has no effect in "consumer" mode, as no HTTP(S) requests are made by the SDK. - */ - requestOptions?: { - /** - * Custom function called before each request, allowing you to add or update headers in SDK HTTP requests. - * Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden. - * To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }` - * Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }` - * - * NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers, - * like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and will be ignored. - * - * @property getHeaderOverrides - * @default undefined - * - * @param context - The context for the request. - * @param context.headers - The current headers in the request. - * @returns A set of headers to be merged with the current headers. - * - * @example - * const getHeaderOverrides = (context) => { - * return { - * 'Authorization': context.headers['Authorization'] + ', other-value', - * 'custom-header': 'custom-value' - * }; - * }; - */ - getHeaderOverrides?: (context: { headers: Record }) => Record - }, - } -} -/** - * Common API for entities that expose status handlers. - * @interface IStatusInterface - * @extends IEventEmitter - */ -interface IStatusInterface extends IEventEmitter { - /** - * Constant object containing the SDK events for you to use. - * @property {EventConsts} Event - */ - Event: EventConsts, - /** - * Returns a promise that resolves once the SDK has finished loading (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted). - * As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `ready` method will return a resolved promise once the SDK is ready. - * - * Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises. - * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example: - * ``` - * try { - * await client.ready().catch((e) => { throw e; }); - * // SDK is ready - * } catch(e) { - * // SDK has timedout - * } - * ``` - * - * @function ready - * @returns {Promise} - */ - ready(): Promise -} -/** - * Common definitions between clients for different environments interface. - * @interface IBasicClient - * @extends IStatusInterface - */ -interface IBasicClient extends IStatusInterface { - /** - * Destroys the client instance. - * - * In 'standalone' and 'partial consumer' modes, this method will flush any pending impressions and events. - * In 'standalone' mode, it also stops the synchronization of feature flag definitions with the backend. - * In 'consumer' and 'partial consumer' modes, this method also disconnects the SDK from the Pluggable storage. - * - * @function destroy - * @returns {Promise} A promise that resolves once the client is destroyed. - */ - destroy(): Promise -} -/** - * Common definitions between SDK instances for different environments interface. - * @interface IBasicSDK - */ -interface IBasicSDK { - /** - * Current settings of the SDK instance. - * @property settings - */ - settings: ISettings, - /** - * Logger API. - * @property Logger - */ - Logger: ILoggerAPI, - /** - * User consent API. - * @property UserConsent - */ - UserConsent: IUserConsentAPI, - /** - * Destroys all the clients created by this factory. - * @function destroy - * @returns {Promise} - */ - destroy(): Promise -} -/****** Exposed namespace ******/ -/** - * Types and interfaces for @splitsoftware/splitio-browserjs package for usage when integrating javascript browser sdk on typescript apps. - * For the SDK package information see {@link https://www.npmjs.com/package/@splitsoftware/splitio-browserjs} - */ -declare namespace SplitIO { - /** - * Feature flag treatment value, returned by getTreatment. - * @typedef {string} Treatment - */ - type Treatment = string; - /** - * Feature flag treatment promise that resolves to actual treatment value. - * @typedef {Promise} AsyncTreatment - */ - type AsyncTreatment = Promise; - /** - * An object with the treatments for a bulk of feature flags, returned by getTreatments. For example: - * { - * feature1: 'on', - * feature2: 'off - * } - * @typedef {Object.} Treatments - */ - type Treatments = { - [featureName: string]: Treatment - }; - /** - * Feature flags treatments promise that resolves to the actual SplitIO.Treatments object. - * @typedef {Promise} AsyncTreatments - */ - type AsyncTreatments = Promise; - /** - * Feature flag evaluation result with treatment and configuration, returned by getTreatmentWithConfig. - * @typedef {Object} TreatmentWithConfig - * @property {string} treatment The treatment string - * @property {string | null} config The stringified version of the JSON config defined for that treatment, null if there is no config for the resulting treatment. - */ - type TreatmentWithConfig = { - treatment: string, - config: string | null - }; - /** - * Feature flag treatment promise that resolves to actual treatment with config value. - * @typedef {Promise} AsyncTreatmentWithConfig - */ - type AsyncTreatmentWithConfig = Promise; - /** - * An object with the treatments with configs for a bulk of feature flags, returned by getTreatmentsWithConfig. - * Each existing configuration is a stringified version of the JSON you defined on the Split user interface. For example: - * { - * feature1: { treatment: 'on', config: null } - * feature2: { treatment: 'off', config: '{"bannerText":"Click here."}' } - * } - * @typedef {Object.} Treatments - */ - type TreatmentsWithConfig = { - [featureName: string]: TreatmentWithConfig - }; - /** - * Feature flags treatments promise that resolves to the actual SplitIO.TreatmentsWithConfig object. - * @typedef {Promise} AsyncTreatmentsWithConfig - */ - type AsyncTreatmentsWithConfig = Promise; - /** - * Possible Split SDK events. - * @typedef {string} Event - */ - type Event = 'init::timeout' | 'init::ready' | 'init::cache-ready' | 'state::update'; - /** - * Attributes should be on object with values of type string or number (dates should be sent as millis since epoch). - * @typedef {Object.} Attributes - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#attribute-syntax} - */ - type Attributes = { - [attributeName: string]: AttributeType - }; - /** - * Type of an attribute value - * @typedef {string | number | boolean | Array} AttributeType - */ - type AttributeType = string | number | boolean | Array; - /** - * Properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb. - * @typedef {Object.} Attributes - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#track - */ - type Properties = { - [propertyName: string]: string | number | boolean | null - }; - /** - * The customer identifier represented by a string. - * @typedef {string} SplitKey - */ - type SplitKey = string; - /** - * Path to file with mocked features (for node). - * @typedef {string} MockedFeaturesFilePath - */ - type MockedFeaturesFilePath = string; - /** - * Object with mocked features mapping (for browser). We need to specify the featureName as key, and the mocked treatment as value. - * @typedef {Object} MockedFeaturesMap - */ - type MockedFeaturesMap = { - [featureName: string]: string | TreatmentWithConfig - }; - /** - * Object with information about an impression. It contains the generated impression DTO as well as - * complementary information around where and how it was generated in that way. - * @typedef {Object} ImpressionData - */ - type ImpressionData = { - impression: { - feature: string, - keyName: string, - treatment: string, - time: number, - bucketingKey?: string, - label: string, - changeNumber: number, - pt?: number, - }, - attributes?: SplitIO.Attributes, - ip: string, - hostname: string, - sdkLanguageVersion: string - }; - /** - * Data corresponding to one feature flag view. - * @typedef {Object} SplitView - */ - type SplitView = { - /** - * The name of the feature flag. - * @property {string} name - */ - name: string, - /** - * The traffic type of the feature flag. - * @property {string} trafficType - */ - trafficType: string, - /** - * Whether the feature flag is killed or not. - * @property {boolean} killed - */ - killed: boolean, - /** - * The list of treatments available for the feature flag. - * @property {Array} treatments - */ - treatments: Array, - /** - * Current change number of the feature flag. - * @property {number} changeNumber - */ - changeNumber: number, - /** - * Map of configurations per treatment. - * Each existing configuration is a stringified version of the JSON you defined on the Split user interface. - * @property {Object.} configs - */ - configs: { - [treatmentName: string]: string - }, - /** - * List of sets of the feature flag. - * @property {string[]} sets - */ - sets: string[], - /** - * The default treatment of the feature flag. - * @property {string} defaultTreatment - */ - defaultTreatment: string, - }; - /** - * A promise that resolves to a feature flag view. - * @typedef {Promise} SplitView - */ - type SplitViewAsync = Promise; - /** - * An array containing the SplitIO.SplitView elements. - */ - type SplitViews = Array; - /** - * A promise that resolves to an SplitIO.SplitViews array. - * @typedef {Promise} SplitViewsAsync - */ - type SplitViewsAsync = Promise; - /** - * An array of feature flag names. - * @typedef {Array} SplitNames - */ - type SplitNames = Array; - /** - * A promise that resolves to an array of feature flag names. - * @typedef {Promise} SplitNamesAsync - */ - type SplitNamesAsync = Promise; - /** - * Storage for synchronous (standalone) SDK. - * Its interface details are not part of the public API. - */ - type StorageSync = {}; - /** - * Storage builder for synchronous (standalone) SDK. - * By returning undefined, the SDK will use the default IN MEMORY storage. - * Input parameter details are not part of the public API. - */ - type StorageSyncFactory = { - readonly type: StorageType - (params: {}): (StorageSync | undefined) - } - /** - * Configuration params for `InLocalStorage` - */ - type InLocalStorageOptions = { - /** - * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage type. - * @property {string} prefix - * @default 'SPLITIO' - */ - prefix?: string - } - /** - * Storage for asynchronous (consumer) SDK. - * Its interface details are not part of the public API. - */ - type StorageAsync = {} - /** - * Storage builder for asynchronous (consumer) SDK. - * Input parameter details are not part of the public API. - */ - type StorageAsyncFactory = { - readonly type: 'PLUGGABLE' - (params: {}): StorageAsync - } - /** - * Configuration params for `PluggableStorage` - */ - type PluggableStorageOptions = { - /** - * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper. - * @property {string} prefix - * @default 'SPLITIO' - */ - prefix?: string, - /** - * Storage wrapper. - * @property {Object} wrapper - */ - wrapper: Object - } - /** - * Impression listener interface. This is the interface that needs to be implemented - * by the element you provide to the SDK as impression listener. - * @interface IImpressionListener - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#listener} - */ - interface IImpressionListener { - logImpression(data: SplitIO.ImpressionData): void - } - /** - * SDK integration instance. - * Its interface details are not part of the public API. - */ - type Integration = {}; - /** - * SDK integration factory. - * By returning an integration, the SDK will queue events and impressions into it. - * Input parameter details are not part of the public API. - */ - type IntegrationFactory = { - readonly type: string - (params: {}): (Integration | void) - } - /** - * A pair of user key and it's trafficType, required for tracking valid Split events. - * @typedef {Object} Identity - * @property {string} key The user key. - * @property {string} trafficType The key traffic type. - */ - type Identity = { - key: string; - trafficType: string; - }; - /** - * Object with information about a Split event. - * @typedef {Object} EventData - */ - type EventData = { - eventTypeId: string; - value?: number; - properties?: Properties; - trafficTypeName?: string; - key?: string; - timestamp?: number; - }; - /** - * Object representing the data sent by Split (events and impressions). - * @typedef {Object} IntegrationData - * @property {string} type The type of Split data, either 'IMPRESSION' or 'EVENT'. - * @property {ImpressionData | EventData} payload The data instance itself. - */ - type IntegrationData = { type: 'IMPRESSION', payload: SplitIO.ImpressionData } | { type: 'EVENT', payload: SplitIO.EventData }; - /** - * Available URL settings for the SDKs. - */ - type UrlSettings = { - /** - * String property to override the base URL where the SDK will get rollout plan related data, like feature flags and segments definitions. - * @property {string} sdk - * @default 'https://sdk.split.io/api' - */ - sdk?: string, - /** - * String property to override the base URL where the SDK will post event-related information like impressions. - * @property {string} events - * @default 'https://events.split.io/api' - */ - events?: string, - /** - * String property to override the base URL where the SDK will get authorization tokens to be used with functionality that requires it, like streaming. - * @property {string} auth - * @default 'https://auth.split.io/api' - */ - auth?: string, - /** - * String property to override the base URL where the SDK will connect to receive streaming updates. - * @property {string} streaming - * @default 'https://streaming.split.io' - */ - streaming?: string, - /** - * String property to override the base URL where the SDK will post telemetry data. - * @property {string} telemetry - * @default 'https://telemetry.split.io/api' - */ - telemetry?: string - }; - - /** - * SplitFilter type. - * - * @typedef {string} SplitFilterType - */ - type SplitFilterType = 'bySet' | 'byName' | 'byPrefix'; - /** - * Defines a feature flag filter, described by a type and list of values. - */ - interface SplitFilter { - /** - * Type of the filter. - * - * @property {SplitFilterType} type - */ - type: SplitFilterType, - /** - * List of values: feature flag names for 'byName' filter type, and feature flag name prefixes for 'byPrefix' type. - * - * @property {string[]} values - */ - values: string[], - } - /** - * ImpressionsMode type - * @typedef {string} ImpressionsMode - */ - type ImpressionsMode = 'OPTIMIZED' | 'DEBUG' | 'NONE'; - /** - * User consent status. - * @typedef {string} ConsentStatus - */ - type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN'; - /** - * Logger - * Its interface details are not part of the public API. It shouldn't be used directly. - * @interface ILogger - */ - interface ILogger { - setLogLevel(logLevel: LogLevel): void - } - /** - * Common settings interface for SDK instances created on the browser. - * @interface IBrowserBasicSettings - * @extends ISharedSettings - */ - interface IBrowserBasicSettings extends ISharedSettings { - /** - * SDK Core settings for the browser. - * @property {Object} core - */ - core: { - /** - * Your SDK key. - * @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys} - * @property {string} authorizationKey - */ - authorizationKey: string, - /** - * Customer identifier. Whatever this means to you. - * @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type} - * @property {SplitKey} key - */ - key: SplitKey, - /** - * Disable labels from being sent to Split backend. Labels may contain sensitive information. - * @property {boolean} labelsEnabled - * @default true - */ - labelsEnabled?: boolean - }, - /** - * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone. - * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy. - * @property {Object} urls - */ - urls?: UrlSettings, - /** - * Defines an optional list of factory functions used to instantiate SDK integrations. - * - * NOTE: at the moment there are not integrations to plug in Browser SDK. - * - * @property {Object} integrations - */ - integrations?: IntegrationFactory[], - /** - * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`. - * - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud. - * - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud. - * - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends - * them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method. - * - * @typedef {string} userConsent - * @default 'GRANTED' - */ - userConsent?: ConsentStatus - } - /** - * Settings interface for SDK instances created on the browser. - * @interface IBrowserSettings - * @extends ISharedSettings - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} - */ - interface IBrowserSettings extends IBrowserBasicSettings { - /** - * The SDK mode. When using the default in memory storage or `InLocalStorage` as storage, the only possible value is "standalone", which is the default. - * For "localhost" mode, use "localhost" as authorizationKey. - * - * @property {'standalone'} mode - * @default 'standalone' - */ - mode?: 'standalone', - /** - * Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings. - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode} - */ - features?: MockedFeaturesMap, - /** - * Defines the factory function to instantiate the storage. If not provided, the default IN MEMORY storage is used. - * - * Example: - * ```typescript - * SplitFactory({ - * ... - * storage: InLocalStorage() - * }) - * ``` - * @property {Object} storage - */ - storage?: StorageSyncFactory, - /** - * SDK Startup settings for the Browser. - * @property {Object} startup - */ - startup?: { - /** - * Maximum amount of time used before notify a timeout. - * @property {number} readyTimeout - * @default 1.5 - */ - readyTimeout?: number, - /** - * Time to wait for a request before the SDK is ready. If this time expires, JS Sdk will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'. - * @property {number} requestTimeoutBeforeReady - * @default 1.5 - */ - requestTimeoutBeforeReady?: number, - /** - * How many quick retries we will do while starting up the SDK. - * @property {number} retriesOnFailureBeforeReady - * @default 1 - */ - retriesOnFailureBeforeReady?: number, - /** - * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately, - * to better control on browsers. This number defines that window before the first events push. - * - * @property {number} eventsFirstPushWindow - * @default 10 - */ - eventsFirstPushWindow?: number, - }, - /** - * SDK scheduler settings. - * @property {Object} scheduler - */ - scheduler?: { - /** - * The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds. - * @property {number} featuresRefreshRate - * @default 60 - */ - featuresRefreshRate?: number, - /** - * The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds. - * @property {number} impressionsRefreshRate - * @default 60 - */ - impressionsRefreshRate?: number, - /** - * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer. - * If you use a 0 here, the queue will have no maximum size. - * @property {number} impressionsQueueSize - * @default 30000 - */ - impressionsQueueSize?: number, - /** - * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds. - * @property {number} telemetryRefreshRate - * @default 3600 - */ - telemetryRefreshRate?: number, - /** - * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds. - * @property {number} segmentsRefreshRate - * @default 60 - */ - segmentsRefreshRate?: number, - /** - * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds. - * @property {number} eventsPushRate - * @default 60 - */ - eventsPushRate?: number, - /** - * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer. - * If you use a 0 here, the queue will have no maximum size. - * @property {number} eventsQueueSize - * @default 500 - */ - eventsQueueSize?: number, - /** - * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key. - * For more information see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode} - * @property {number} offlineRefreshRate - * @default 15 - */ - offlineRefreshRate?: number, - /** - * When using streaming mode, seconds to wait before re attempting to connect for push notifications. - * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ... - * @property {number} pushRetryBackoffBase - * @default 1 - */ - pushRetryBackoffBase?: number, - } - } - /** - * Settings interface with async storage for SDK instances created on the browser. - * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.IBrowserSettings instead. - * @interface IBrowserAsyncSettings - * @extends IBrowserBasicSettings - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} - */ - interface IBrowserAsyncSettings extends IBrowserBasicSettings { - /** - * The SDK mode. When using `PluggableStorage` as storage, the possible values are "consumer" and "consumer_partial". - * - * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage} - * - * @property {'consumer' | 'consumer_partial'} mode - */ - mode: 'consumer' | 'consumer_partial', - /** - * Defines the factory function to instantiate the storage. - * - * Example: - * ```typescript - * SplitFactory({ - * ... - * storage: PluggableStorage({ wrapper: SomeWrapper }) - * }) - * ``` - * @property {Object} storage - */ - storage: StorageAsyncFactory, - /** - * SDK Startup settings for the Browser. - * @property {Object} startup - */ - startup?: { - /** - * Maximum amount of time used before notify a timeout. - * @property {number} readyTimeout - * @default 1.5 - */ - readyTimeout?: number, - /** - * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately, - * to better control on browsers. This number defines that window before the first events push. - * - * NOTE: this param is ignored in 'consumer' mode. - * @property {number} eventsFirstPushWindow - * @default 10 - */ - eventsFirstPushWindow?: number, - }, - /** - * SDK scheduler settings. - * @property {Object} scheduler - */ - scheduler?: { - /** - * The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds. - * - * NOTE: this param is ignored in 'consumer' mode. - * @property {number} impressionsRefreshRate - * @default 60 - */ - impressionsRefreshRate?: number, - /** - * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer. - * If you use a 0 here, the queue will have no maximum size. - * @property {number} impressionsQueueSize - * @default 30000 - */ - impressionsQueueSize?: number, - /** - * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds. - * @property {number} telemetryRefreshRate - * @default 3600 - */ - telemetryRefreshRate?: number, - /** - * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds. - * - * NOTE: this param is ignored in 'consumer' mode. - * @property {number} eventsPushRate - * @default 60 - */ - eventsPushRate?: number, - /** - * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer. - * If you use a 0 here, the queue will have no maximum size. - * - * NOTE: this param is ignored in 'consumer' mode. - * @property {number} eventsQueueSize - * @default 500 - */ - eventsQueueSize?: number, - } - } - /** - * This represents the interface for the SDK instance with synchronous storage and client-side API, - * i.e., where client instances have a bound user key. - * @interface ISDK - * @extends IBasicSDK - */ - interface ISDK extends IBasicSDK { - /** - * Returns the default client instance of the SDK, associated with the key provided on settings. - * @function client - * @returns {IClient} The client instance. - */ - client(): IClient, - /** - * Returns a shared client of the SDK, associated with the given key. - * @function client - * @param {SplitKey} key The key for the new client instance. - * @returns {IClient} The client instance. - */ - client(key: SplitKey): IClient, - /** - * Returns a manager instance of the SDK to explore available information. - * @function manager - * @returns {IManager} The manager instance. - */ - manager(): IManager - } - /** - * This represents the interface for the SDK instance with asynchronous storage and client-side API, - * i.e., where client instances have a bound user key. - * @interface IAsyncSDK - * @extends IBasicSDK - */ - interface IAsyncSDK extends IBasicSDK { - /** - * Returns the default client instance of the SDK, associated with the key provided on settings. - * @function client - * @returns {IAsyncClient} The asynchronous client instance. - */ - client(): IAsyncClient, - /** - * Returns a shared client of the SDK, associated with the given key. - * @function client - * @param {SplitKey} key The key for the new client instance. - * @returns {IAsyncClient} The asynchronous client instance. - */ - client(key: SplitKey): IAsyncClient, - /** - * Returns a manager instance of the SDK to explore available information. - * @function manager - * @returns {IManager} The manager instance. - */ - manager(): IAsyncManager - } - /** - * This represents the interface for the Client instance with synchronous storage for server-side SDK, where we don't have only one key. - * @interface IClient - * @extends IBasicClient - */ - interface IClientSS extends IBasicClient { - /** - * Returns a Treatment value, which is the treatment string for the given feature. - * @function getTreatment - * @param {string} key - The string key representing the consumer. - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatment} The treatment string. - */ - getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): Treatment, - /** - * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature. - * @function getTreatmentWithConfig - * @param {string} key - The string key representing the consumer. - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the - * configuration stringified JSON (or null if there was no config for that treatment). - */ - getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): TreatmentWithConfig, - /** - * Returns a Treatments value, which is an object map with the treatments for the given features. - * @function getTreatments - * @param {string} key - The string key representing the consumer. - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatments} The treatments object map. - */ - getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): Treatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features. - * @function getTreatmentsWithConfig - * @param {string} key - The string key representing the consumer. - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects - */ - getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig, - /** - * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set. - * @function getTreatmentsByFlagSet - * @param {string} key - The string key representing the consumer. - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatments} The map with all the Treatment objects - */ - getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set. - * @function getTreatmentsWithConfigByFlagSet - * @param {string} key - The string key representing the consumer. - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects - */ - getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig, - /** - * Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets. - * @function getTreatmentsByFlagSets - * @param {string} key - The string key representing the consumer. - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatments} The map with all the Treatment objects - */ - getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets. - * @function getTreatmentsWithConfigByFlagSets - * @param {string} key - The string key representing the consumer. - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects - */ - getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig, - /** - * Tracks an event to be fed to the results product on Split user interface. - * @function track - * @param {SplitKey} key - The key that identifies the entity related to this event. - * @param {string} trafficType - The traffic type of the entity related to this event. - * @param {string} eventType - The event type corresponding to this event. - * @param {number=} value - The value of this event. - * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null. - * @returns {boolean} Whether the event was added to the queue successfully or not. - */ - track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean, - } - /** - * This represents the interface for the Client instance with asynchronous storage for server-side SDK, where we don't have only one key. - * @interface IAsyncClient - * @extends IBasicClient - */ - interface IAsyncClientSS extends IBasicClient { - /** - * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature. - * For usage on NodeJS as we don't have only one key. - * NOTE: Treatment will be a promise only in async storages, like REDIS. - * @function getTreatment - * @param {string} key - The string key representing the consumer. - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatment} Treatment promise that resolves to the treatment string. - */ - getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatment, - /** - * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature. - * For usage on NodeJS as we don't have only one key. - * NOTE: Treatment will be a promise only in async storages, like REDIS. - * @function getTreatmentWithConfig - * @param {string} key - The string key representing the consumer. - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise that resolves to the TreatmentWithConfig object. - */ - getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig, - /** - * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features. - * For usage on NodeJS as we don't have only one key. - * @function getTreatments - * @param {string} key - The string key representing the consumer. - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map. - */ - getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatments, - /** - * Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features. - * For usage on NodeJS as we don't have only one key. - * @function getTreatmentsWithConfig - * @param {string} key - The string key representing the consumer. - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects. - */ - getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig, - /** - * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set. - * For usage on NodeJS as we don't have only one key. - * @function getTreatmentsByFlagSet - * @param {string} key - The string key representing the consumer. - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map. - */ - getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set. - * For usage on NodeJS as we don't have only one key. - * @function getTreatmentsWithConfigByFlagSet - * @param {string} key - The string key representing the consumer. - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects. - */ - getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatmentWithConfig, - /** - * Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets. - * For usage on NodeJS as we don't have only one key. - * @function getTreatmentsByFlagSets - * @param {string} key - The string key representing the consumer. - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map. - */ - getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets. - * For usage on NodeJS as we don't have only one key. - * @function getTreatmentsWithConfigByFlagSets - * @param {string} key - The string key representing the consumer. - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects. - */ - getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatmentWithConfig, - /** - * Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not). - * @function track - * @param {SplitKey} key - The key that identifies the entity related to this event. - * @param {string} trafficType - The traffic type of the entity related to this event. - * @param {string} eventType - The event type corresponding to this event. - * @param {number=} value - The value of this event. - * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null. - * @returns {Promise} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not. - */ - track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise - } - /** - * This represents the interface for the Client instance with synchronous storage for client-side SDK, where each client has associated a key. - * @interface IClient - * @extends IBasicClient - */ - interface IClient extends IBasicClient { - /** - * Returns a Treatment value, which is the treatment string for the given feature. - * @function getTreatment - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatment} The treatment string. - */ - getTreatment(featureFlagName: string, attributes?: Attributes): Treatment, - /** - * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature. - * @function getTreatmentWithConfig - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment). - */ - getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): TreatmentWithConfig, - /** - * Returns a Treatments value, which is an object map with the treatments for the given features. - * @function getTreatments - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatments} The treatments object map. - */ - getTreatments(featureFlagNames: string[], attributes?: Attributes): Treatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features. - * @function getTreatmentsWithConfig - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects - */ - getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig, - /** - * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set. - * @function getTreatmentsByFlagSet - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatments} The map with all the Treatments objects - */ - getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set. - * @function getTreatmentsWithConfigByFlagSet - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects - */ - getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig, - /** - * Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets. - * @function getTreatmentsByFlagSets - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {Treatments} The map with all the Treatments objects - */ - getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets. - * @function getTreatmentsWithConfigByFlagSets - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects - */ - getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig, - /** - * Tracks an event to be fed to the results product on Split user interface. - * @function track - * @param {string} trafficType - The traffic type of the entity related to this event. - * @param {string} eventType - The event type corresponding to this event. - * @param {number=} value - The value of this event. - * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null. - * @returns {boolean} Whether the event was added to the queue successfully or not. - */ - track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean, - /** - * Add an attribute to client's in memory attributes storage. - * - * @param {string} attributeName Attribute name - * @param {AttributeType} attributeValue Attribute value - * @returns {boolean} true if the attribute was stored and false otherwise - */ - setAttribute(attributeName: string, attributeValue: AttributeType): boolean, - /** - * Returns the attribute with the given name. - * - * @param {string} attributeName Attribute name - * @returns {AttributeType} Attribute with the given name - */ - getAttribute(attributeName: string): AttributeType, - /** - * Removes from client's in memory attributes storage the attribute with the given name. - * - * @param {string} attributeName - * @returns {boolean} true if attribute was removed and false otherwise - */ - removeAttribute(attributeName: string): boolean, - /** - * Add to client's in memory attributes storage the attributes in 'attributes'. - * - * @param {Attributes} attributes Object with attributes to store - * @returns true if attributes were stored an false otherwise - */ - setAttributes(attributes: Attributes): boolean, - /** - * Return all the attributes stored in client's in memory attributes storage. - * - * @returns {Attributes} returns all the stored attributes - */ - getAttributes(): Attributes, - /** - * Remove all the stored attributes in the client's in memory attribute storage. - * - * @returns {boolean} true if all attribute were removed and false otherwise - */ - clearAttributes(): boolean - } - /** - * This represents the interface for the Client instance with asynchronous storage for client-side SDK, where each client has associated a key. - * @interface IAsyncClient - * @extends IBasicClient - */ - interface IAsyncClient extends IBasicClient { - /** - * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature. - * @function getTreatment - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatment} Treatment promise that resolves to the treatment string. - */ - getTreatment(featureFlagName: string, attributes?: Attributes): AsyncTreatment, - /** - * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature. - * @function getTreatmentWithConfig - * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise that resolves to the TreatmentWithConfig object. - */ - getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig, - /** - * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features. - * @function getTreatments - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map. - */ - getTreatments(featureFlagNames: string[], attributes?: Attributes): AsyncTreatments, - /** - * Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features. - * @function getTreatmentsWithConfig - * @param {Array} featureFlagNames - An array of the feature flag names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object. - */ - getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig, - /** - * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set. - * @function getTreatmentsByFlagSet - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map. - */ - getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set. - * @function getTreatmentsWithConfigByFlagSet - * @param {string} flagSet - The flag set name we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object. - */ - getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig, - /** - * Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets. - * @function getTreatmentsByFlagSets - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map. - */ - getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatments, - /** - * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets. - * @function getTreatmentsWithConfigByFlagSets - * @param {Array} flagSets - An array of the flag set names we want to get the treatments. - * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key. - * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object. - */ - getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig, - /** - * Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not). - * @function track - * @param {string} trafficType - The traffic type of the entity related to this event. - * @param {string} eventType - The event type corresponding to this event. - * @param {number=} value - The value of this event. - * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null. - * @returns {boolean} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not. - */ - track(trafficType: string, eventType: string, value?: number, properties?: Properties): Promise, - /** - * Add an attribute to client's in memory attributes storage. - * - * @param {string} attributeName Attribute name - * @param {AttributeType} attributeValue Attribute value - * @returns {boolean} true if the attribute was stored and false otherwise - */ - setAttribute(attributeName: string, attributeValue: AttributeType): boolean, - /** - * Returns the attribute with the given name. - * - * @param {string} attributeName Attribute name - * @returns {AttributeType} Attribute with the given name - */ - getAttribute(attributeName: string): AttributeType, - /** - * Removes from client's in memory attributes storage the attribute with the given name. - * - * @param {string} attributeName - * @returns {boolean} true if attribute was removed and false otherwise - */ - removeAttribute(attributeName: string): boolean, - /** - * Add to client's in memory attributes storage the attributes in 'attributes'. - * - * @param {Attributes} attributes Object with attributes to store - * @returns true if attributes were stored an false otherwise - */ - setAttributes(attributes: Attributes): boolean, - /** - * Return all the attributes stored in client's in memory attributes storage. - * - * @returns {Attributes} returns all the stored attributes - */ - getAttributes(): Attributes, - /** - * Remove all the stored attributes in the client's in memory attribute storage. - * - * @returns {boolean} true if all attribute were removed and false otherwise - */ - clearAttributes(): boolean - } - /** - * Representation of a manager instance with synchronous storage of the SDK. - * @interface IManager - * @extends IStatusInterface - */ - interface IManager extends IStatusInterface { - /** - * Get the array of feature flag names. - * @function names - * @returns {SplitNames} The list of feature flag names. - */ - names(): SplitNames, - /** - * Get the array of feature flags data in SplitView format. - * @function splits - * @returns {SplitViews} The list of SplitIO.SplitView. - */ - splits(): SplitViews, - /** - * Get the data of a split in SplitView format. - * @function split - * @param {string} featureFlagName The name of the feature flag we want to get info of. - * @returns {SplitView} The SplitIO.SplitView of the given split. - */ - split(featureFlagName: string): SplitView, - } - /** - * Representation of a manager instance with asynchronous storage of the SDK. - * @interface IAsyncManager - * @extends IStatusInterface - */ - interface IAsyncManager extends IStatusInterface { - /** - * Get the array of feature flag names. - * @function names - * @returns {SplitNamesAsync} A promise that resolves to the list of feature flag names. - */ - names(): SplitNamesAsync, - /** - * Get the array of feature flags data in SplitView format. - * @function splits - * @returns {SplitViewsAsync} A promise that resolves to the SplitIO.SplitView list. - */ - splits(): SplitViewsAsync, - /** - * Get the data of a split in SplitView format. - * @function split - * @param {string} featureFlagName The name of the feature flag we want to get info of. - * @returns {SplitViewAsync} A promise that resolves to the SplitIO.SplitView value. - */ - split(featureFlagName: string): SplitViewAsync, - } -} From dabfdabc7543d07462214bfc25aeb1ea42be701f Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 25 Oct 2024 13:26:54 -0300 Subject: [PATCH 03/12] 2nd step: move SplitIO namespace definition from React Native SDK to JS-Commons and merge --- src/splitFactory.ts | 4 ++-- ts-tests/index.ts | 8 ++++---- types/index.d.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/splitFactory.ts b/src/splitFactory.ts index f38f382..344f60b 100644 --- a/src/splitFactory.ts +++ b/src/splitFactory.ts @@ -6,7 +6,7 @@ import { getFetch } from './platform/getFetch'; import { getEventSource } from './platform/getEventSource'; import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; -import { IBrowserSettings } from '../types/splitio'; +import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; const platform = { getFetch, getEventSource, EventEmitter, now }; @@ -18,7 +18,7 @@ const platform = { getFetch, getEventSource, EventEmitter, now }; * caution since, unlike `config`, this param is not validated neither considered part of the public API. * @throws Will throw an error if the provided config is invalid. */ -export function SplitFactory(config: IBrowserSettings, __updateModules?: (modules: ISdkFactoryParams) => void) { +export function SplitFactory(config: SplitIO.IClientSideSettings, __updateModules?: (modules: ISdkFactoryParams) => void) { const settings = settingsFactory(config); const modules = getModules(settings, platform); if (__updateModules) __updateModules(modules); diff --git a/ts-tests/index.ts b/ts-tests/index.ts index fead10c..a7516ca 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -32,8 +32,8 @@ let SDK: SplitIO.ISDK; // Settings interfaces // let nodeSettings: SplitIO.INodeSettings; // let asyncSettings: SplitIO.INodeAsyncSettings; -let browserSettings: SplitIO.IBrowserSettings; -let browserAsyncSettings: SplitIO.IBrowserAsyncSettings; +let browserSettings: SplitIO.IClientSideSettings; +let browserAsyncSettings: SplitIO.IClientSideAsyncSettings; // Client & Manager APIs // let client: SplitIO.IClient; let client: SplitIO.IClient; @@ -518,7 +518,7 @@ userConsent = AsyncSDK.UserConsent.Status.UNKNOWN; // Split filters let splitFilters: SplitIO.SplitFilter[] = [{ type: 'bySet', values: ['set_a', 'set_b'] }, { type: 'byName', values: ['my_split_1', 'my_split_1'] }, { type: 'byPrefix', values: ['my_split', 'test_split_'] }] -let fullBrowserSettings: SplitIO.IBrowserSettings = { +let fullBrowserSettings: SplitIO.IClientSideSettings = { core: { authorizationKey: 'asd', key: 'asd', @@ -568,7 +568,7 @@ let fullBrowserSettings: SplitIO.IBrowserSettings = { fullBrowserSettings.userConsent = 'DECLINED'; fullBrowserSettings.userConsent = 'UNKNOWN'; -let fullBrowserAsyncSettings: SplitIO.IBrowserAsyncSettings = { +let fullBrowserAsyncSettings: SplitIO.IClientSideAsyncSettings = { mode: 'consumer', core: { authorizationKey: 'asd', diff --git a/types/index.d.ts b/types/index.d.ts index 280dfc6..7763d9e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -10,11 +10,11 @@ declare module JsSdk { /** * Split.io SDK factory function. * - * The settings parameter should be an object that complies with the SplitIO.IBrowserSettings. + * The settings parameter should be an object that complies with the SplitIO.IClientSideSettings or SplitIO.IClientSideAsyncSettings interfaces. * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} */ - export function SplitFactory(settings: SplitIO.IBrowserSettings): SplitIO.ISDK; - export function SplitFactory(settings: SplitIO.IBrowserAsyncSettings): SplitIO.IAsyncSDK; + export function SplitFactory(config: SplitIO.IClientSideSettings): SplitIO.ISDK; + export function SplitFactory(config: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; /** * Persistent storage based on the LocalStorage Web API for browsers. From 3e5d64092d25f0a59328aa17003d1a04a7e0cc1e Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Sat, 26 Oct 2024 12:20:53 -0300 Subject: [PATCH 04/12] 3rd step: move SplitIO namespace definition from JS SDK to JS-Commons and merge --- CHANGES.txt | 1 + ts-tests/index.ts | 4 ++-- types/index.d.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b6a9b44..deb4281 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,7 @@ - Added `factory.destroy()` method, which invokes the `destroy` method of all clients created by the factory. - Updated @splitsoftware/splitio-commons package to version 2.0.0 that includes major updates and updated some transitive dependencies for vulnerability fixes. - BREAKING CHANGES: + - Renamed some TypeScript definitions in the SplitIO namespace to avoid conflicts with other libraries: `SplitIO.IBrowserSettings` to `SplitIO.IClientSideSettings`, `SplitIO.IBrowserAsyncSettings` to `SplitIO.IClientSideAsyncSettings`. - Removed internal ponyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or provide a polyfill. - Removed the deprecated `GoogleAnalyticsToSplit` and `SplitToGoogleAnalytics` pluggable integration modules, along with the related interfaces in the TypeScript definitions. - Removed the `LocalhostFromObject` export from the default import (`import { LocalhostFromObject } from '@splitsoftware/splitio-browserjs'`). It is no longer necessary to manually import and configure it in the `sync.localhostMode` option to enable localhost mode. diff --git a/ts-tests/index.ts b/ts-tests/index.ts index a7516ca..abf34f6 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -197,8 +197,8 @@ const instantiatedSettingsStartup: { [key: string]: number } = SDK.settings.star const instantiatedStorage: SplitIO.StorageSync = SDK.settings.storage; const instantiatedSettingsUrls: { [key: string]: string } = SDK.settings.urls; const instantiatedSettingsVersion: string = SDK.settings.version; -let instantiatedSettingsFeatures = SDK.settings.features; -// // We should be able to write on features prop. The rest are readonly props. +let instantiatedSettingsFeatures = SDK.settings.features as SplitIO.MockedFeaturesMap; +// We should be able to write on features prop. The rest are readonly props. instantiatedSettingsFeatures.something = 'something'; SDK.settings.features = { 'split_x': 'on' }; diff --git a/types/index.d.ts b/types/index.d.ts index 7763d9e..1b93b6b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -13,8 +13,8 @@ declare module JsSdk { * The settings parameter should be an object that complies with the SplitIO.IClientSideSettings or SplitIO.IClientSideAsyncSettings interfaces. * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} */ - export function SplitFactory(config: SplitIO.IClientSideSettings): SplitIO.ISDK; - export function SplitFactory(config: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; + export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.ISDK; + export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; /** * Persistent storage based on the LocalStorage Web API for browsers. From 41519cd2b2fa4fb6b25cd36fc31fccd7eba7da9a Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Sat, 26 Oct 2024 12:22:00 -0300 Subject: [PATCH 05/12] rc --- package-lock.json | 44 ++++++++++++++++++++++++++-------------- package.json | 4 ++-- src/settings/defaults.ts | 2 +- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 505a79b..5144926 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.0", + "version": "1.0.0-rc.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.0", + "version": "1.0.0-rc.1", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "2.0.0-rc.3", + "@splitsoftware/splitio-commons": "2.0.0-rc.4", "tslib": "^2.3.1" }, "devDependencies": { @@ -1500,10 +1500,11 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.3.tgz", - "integrity": "sha512-XkDbULWBg6nw061b4Vc425JyrpDe5nSypoScO4eVsFbgcCqUPlGbr+s9bfriwNFyZe2Q29ijIlyGM06TCt27kQ==", + "version": "2.0.0-rc.4", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.4.tgz", + "integrity": "sha512-z0rm4X9oh7LdIcHeEkh6Ca3JzfdhJ0IH3r7nZ6ghL0AXmPzbezoDswxjKOe/WYBbTW3utsgLqTTjr9Ww/b/hUw==", "dependencies": { + "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" }, "peerDependencies": { @@ -1601,6 +1602,14 @@ "@types/node": "*" } }, + "node_modules/@types/ioredis": { + "version": "4.28.10", + "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz", + "integrity": "sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", @@ -1651,7 +1660,6 @@ "version": "20.8.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", - "dev": true, "dependencies": { "undici-types": "~5.25.1" } @@ -9089,8 +9097,7 @@ "node_modules/undici-types": { "version": "5.25.3", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", - "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", - "dev": true + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" }, "node_modules/universalify": { "version": "0.1.2", @@ -10571,10 +10578,11 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.3.tgz", - "integrity": "sha512-XkDbULWBg6nw061b4Vc425JyrpDe5nSypoScO4eVsFbgcCqUPlGbr+s9bfriwNFyZe2Q29ijIlyGM06TCt27kQ==", + "version": "2.0.0-rc.4", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.4.tgz", + "integrity": "sha512-z0rm4X9oh7LdIcHeEkh6Ca3JzfdhJ0IH3r7nZ6ghL0AXmPzbezoDswxjKOe/WYBbTW3utsgLqTTjr9Ww/b/hUw==", "requires": { + "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" } }, @@ -10661,6 +10669,14 @@ "@types/node": "*" } }, + "@types/ioredis": { + "version": "4.28.10", + "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz", + "integrity": "sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==", + "requires": { + "@types/node": "*" + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", @@ -10711,7 +10727,6 @@ "version": "20.8.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", - "dev": true, "requires": { "undici-types": "~5.25.1" } @@ -16222,8 +16237,7 @@ "undici-types": { "version": "5.25.3", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", - "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", - "dev": true + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" }, "universalify": { "version": "0.1.2", diff --git a/package.json b/package.json index b88f0b2..2f176d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.0", + "version": "1.0.0-rc.1", "description": "Split SDK for JavaScript on Browser", "main": "cjs/index.js", "module": "esm/index.js", @@ -58,7 +58,7 @@ "bugs": "https://github.com/splitio/javascript-browser-client/issues", "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { - "@splitsoftware/splitio-commons": "2.0.0-rc.3", + "@splitsoftware/splitio-commons": "2.0.0-rc.4", "tslib": "^2.3.1" }, "devDependencies": { diff --git a/src/settings/defaults.ts b/src/settings/defaults.ts index 2e820ab..6661e18 100644 --- a/src/settings/defaults.ts +++ b/src/settings/defaults.ts @@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/ import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types'; import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants'; -const packageVersion = '1.0.0-rc.0'; +const packageVersion = '1.0.0-rc.1'; /** * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item. From cca40d9769a8162da5796195c00e2a3ee2d1aaba Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Tue, 29 Oct 2024 13:40:48 -0300 Subject: [PATCH 06/12] Add TSDoc linter rules --- .eslintrc | 10 +++- package-lock.json | 140 +++++++++++++++++++++++++++++++++++++++++--- package.json | 3 +- src/splitFactory.ts | 4 +- ts-tests/index.ts | 2 - 5 files changed, 146 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index 383d3b6..b09d09a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -5,6 +5,7 @@ "parser": "@typescript-eslint/parser", "plugins": [ "@typescript-eslint", + "eslint-plugin-tsdoc", "import" ], @@ -60,7 +61,14 @@ "files": ["types/**"], "rules": { "no-use-before-define": "off", - "no-undef": "off" // turned off to avoid issue with triple-slash path directive + "no-undef": "off" // turned off to avoid issue with SplitIO namespace not defined + } + }, + { + // Enable TSDoc rules for TypeScript files, allowing the use of JSDoc in JS files. + "files": ["**/*.ts"], + "rules": { + "tsdoc/syntax": "warn" } } ], diff --git a/package-lock.json b/package-lock.json index 5144926..e528136 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0-rc.1", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "2.0.0-rc.4", + "@splitsoftware/splitio-commons": "2.0.0-rc.5", "tslib": "^2.3.1" }, "devDependencies": { @@ -24,6 +24,7 @@ "eslint": "^8.48.0", "eslint-plugin-compat": "^4.2.0", "eslint-plugin-import": "^2.25.4", + "eslint-plugin-tsdoc": "^0.3.0", "fetch-mock": "^11.1.3", "jest": "^27.2.3", "karma": "^6.4.1", @@ -1251,6 +1252,46 @@ "integrity": "sha512-fjXsjZJvdnC+j4AipnxHbwPCohV0cC1qLh3XHy2+zeXLDb1TVepLK7qDS9UcvNxuEkl/qYPsBf0lad2paHSuIQ==", "dev": true }, + "node_modules/@microsoft/tsdoc": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.0.tgz", + "integrity": "sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==", + "dev": true + }, + "node_modules/@microsoft/tsdoc-config": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.17.0.tgz", + "integrity": "sha512-v/EYRXnCAIHxOHW+Plb6OWuUoMotxTN0GLatnpOb1xq0KuTNw/WI3pamJx/UbsoJP5k9MCw1QxvvhPcF9pH3Zg==", + "dev": true, + "dependencies": { + "@microsoft/tsdoc": "0.15.0", + "ajv": "~8.12.0", + "jju": "~1.4.0", + "resolve": "~1.22.2" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1500,9 +1541,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "2.0.0-rc.4", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.4.tgz", - "integrity": "sha512-z0rm4X9oh7LdIcHeEkh6Ca3JzfdhJ0IH3r7nZ6ghL0AXmPzbezoDswxjKOe/WYBbTW3utsgLqTTjr9Ww/b/hUw==", + "version": "2.0.0-rc.5", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.5.tgz", + "integrity": "sha512-hNLA3cfVj5yGSHpOyTQVzcU2kIceJtJOdatcuue2ENOesjwDHfpvEy/YkIgLcLwXpvUxTFKpZd1BRej8gSbWoA==", "dependencies": { "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" @@ -3839,6 +3880,16 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-tsdoc": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.3.0.tgz", + "integrity": "sha512-0MuFdBrrJVBjT/gyhkP2BqpD0np1NxNLfQ38xXDlSs/KVVpKI2A6vN7jx2Rve/CyUsvOsMGwp9KKrinv7q9g3A==", + "dev": true, + "dependencies": { + "@microsoft/tsdoc": "0.15.0", + "@microsoft/tsdoc-config": "0.17.0" + } + }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -6012,6 +6063,12 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", + "dev": true + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -7623,6 +7680,15 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -10404,6 +10470,44 @@ "integrity": "sha512-fjXsjZJvdnC+j4AipnxHbwPCohV0cC1qLh3XHy2+zeXLDb1TVepLK7qDS9UcvNxuEkl/qYPsBf0lad2paHSuIQ==", "dev": true }, + "@microsoft/tsdoc": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.0.tgz", + "integrity": "sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==", + "dev": true + }, + "@microsoft/tsdoc-config": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.17.0.tgz", + "integrity": "sha512-v/EYRXnCAIHxOHW+Plb6OWuUoMotxTN0GLatnpOb1xq0KuTNw/WI3pamJx/UbsoJP5k9MCw1QxvvhPcF9pH3Zg==", + "dev": true, + "requires": { + "@microsoft/tsdoc": "0.15.0", + "ajv": "~8.12.0", + "jju": "~1.4.0", + "resolve": "~1.22.2" + }, + "dependencies": { + "ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + } + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -10578,9 +10682,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "2.0.0-rc.4", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.4.tgz", - "integrity": "sha512-z0rm4X9oh7LdIcHeEkh6Ca3JzfdhJ0IH3r7nZ6ghL0AXmPzbezoDswxjKOe/WYBbTW3utsgLqTTjr9Ww/b/hUw==", + "version": "2.0.0-rc.5", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.5.tgz", + "integrity": "sha512-hNLA3cfVj5yGSHpOyTQVzcU2kIceJtJOdatcuue2ENOesjwDHfpvEy/YkIgLcLwXpvUxTFKpZd1BRej8gSbWoA==", "requires": { "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" @@ -12340,6 +12444,16 @@ } } }, + "eslint-plugin-tsdoc": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.3.0.tgz", + "integrity": "sha512-0MuFdBrrJVBjT/gyhkP2BqpD0np1NxNLfQ38xXDlSs/KVVpKI2A6vN7jx2Rve/CyUsvOsMGwp9KKrinv7q9g3A==", + "dev": true, + "requires": { + "@microsoft/tsdoc": "0.15.0", + "@microsoft/tsdoc-config": "0.17.0" + } + }, "eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -13941,6 +14055,12 @@ } } }, + "jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", + "dev": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -15182,6 +15302,12 @@ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", diff --git a/package.json b/package.json index 2f176d2..3725db4 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "bugs": "https://github.com/splitio/javascript-browser-client/issues", "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { - "@splitsoftware/splitio-commons": "2.0.0-rc.4", + "@splitsoftware/splitio-commons": "2.0.0-rc.5", "tslib": "^2.3.1" }, "devDependencies": { @@ -73,6 +73,7 @@ "eslint": "^8.48.0", "eslint-plugin-compat": "^4.2.0", "eslint-plugin-import": "^2.25.4", + "eslint-plugin-tsdoc": "^0.3.0", "fetch-mock": "^11.1.3", "jest": "^27.2.3", "karma": "^6.4.1", diff --git a/src/splitFactory.ts b/src/splitFactory.ts index 344f60b..f959290 100644 --- a/src/splitFactory.ts +++ b/src/splitFactory.ts @@ -13,8 +13,8 @@ const platform = { getFetch, getEventSource, EventEmitter, now }; /** * SplitFactory with pluggable modules for Browser. * - * @param config configuration object used to instantiate the SDK - * @param __updateModules optional function that lets redefine internal SDK modules. Use with + * @param config - configuration object used to instantiate the SDK + * @param __updateModules - optional function that lets redefine internal SDK modules. Use with * caution since, unlike `config`, this param is not validated neither considered part of the public API. * @throws Will throw an error if the provided config is invalid. */ diff --git a/ts-tests/index.ts b/ts-tests/index.ts index abf34f6..5b40ecf 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -601,10 +601,8 @@ let fullBrowserAsyncSettings: SplitIO.IClientSideAsyncSettings = { impressionListener: impressionListener, debug: true, integrations: [], - streamingEnabled: true, sync: { impressionsMode: 'DEBUG', - enabled: true, requestOptions: { getHeaderOverrides(context) { return { ...context.headers, 'header': 'value' }; }, } From cf7c9c764eca52cb9c38b42760dbe5f1d0d25a5a Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Tue, 29 Oct 2024 13:41:31 -0300 Subject: [PATCH 07/12] rc --- package-lock.json | 4 ++-- package.json | 2 +- src/settings/defaults.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e528136..23b7e48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "license": "Apache-2.0", "dependencies": { "@splitsoftware/splitio-commons": "2.0.0-rc.5", diff --git a/package.json b/package.json index 3725db4..56a42fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "description": "Split SDK for JavaScript on Browser", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/settings/defaults.ts b/src/settings/defaults.ts index 6661e18..a20567d 100644 --- a/src/settings/defaults.ts +++ b/src/settings/defaults.ts @@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/ import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types'; import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants'; -const packageVersion = '1.0.0-rc.1'; +const packageVersion = '1.0.0-rc.2'; /** * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item. From 558dd0a87618db92a35b5303abb5790086f57dc2 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Tue, 29 Oct 2024 14:02:06 -0300 Subject: [PATCH 08/12] Fixes --- src/platform/getModules.ts | 2 +- src/settings/defaults.ts | 6 +++--- src/splitFactory.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/platform/getModules.ts b/src/platform/getModules.ts index 62e2d86..a6e168f 100644 --- a/src/platform/getModules.ts +++ b/src/platform/getModules.ts @@ -25,7 +25,7 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor platform, - storageFactory: settings.storage, + storageFactory: settings.storage as ISdkFactoryParams['storageFactory'], splitApiFactory, diff --git a/src/settings/defaults.ts b/src/settings/defaults.ts index a20567d..7d28ad2 100644 --- a/src/settings/defaults.ts +++ b/src/settings/defaults.ts @@ -1,5 +1,5 @@ +import type SplitIO from '@splitsoftware/splitio-commons/types/splitio'; import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/logger/index'; -import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types'; import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants'; const packageVersion = '1.0.0-rc.2'; @@ -10,7 +10,7 @@ const packageVersion = '1.0.0-rc.2'; * Other acceptable values are 'on', 'enable' and 'enabled', which are equivalent to 'DEBUG'. * Any other string value is equivalent to disable ('NONE'). */ -let initialLogLevel: LogLevel | undefined; +let initialLogLevel: SplitIO.LogLevel | undefined; const LS_KEY = 'splitio_debug'; @@ -34,7 +34,7 @@ export const defaults = { }, // Consent is considered granted by default - userConsent: CONSENT_GRANTED as ConsentStatus, + userConsent: CONSENT_GRANTED as SplitIO.ConsentStatus, // Instance version. version: `browserjs-${packageVersion}`, diff --git a/src/splitFactory.ts b/src/splitFactory.ts index f959290..7a7f81f 100644 --- a/src/splitFactory.ts +++ b/src/splitFactory.ts @@ -1,3 +1,4 @@ +import type SplitIO from '@splitsoftware/splitio-commons/types/splitio'; import { settingsFactory } from './settings'; import { getModules } from './platform/getModules'; import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; @@ -6,7 +7,6 @@ import { getFetch } from './platform/getFetch'; import { getEventSource } from './platform/getEventSource'; import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; -import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; const platform = { getFetch, getEventSource, EventEmitter, now }; From 0ee933186729cd63ce35609d3c75fbfca2cdc5bc Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Wed, 30 Oct 2024 23:08:38 -0300 Subject: [PATCH 09/12] Revert "Remove 'full' subpackage, since there is not significant difference with the default 'slim' subpackage" This reverts commit 23668a9bbd69bfdf569e3e5ae0e551bdf283e522. --- CHANGES.txt | 1 - full/package.json | 6 ++ package-lock.json | 13 +++- package.json | 6 +- rollup.ci.config.js | 2 +- src/__tests__/offline/browser.spec.js | 12 ++-- src/full/index.ts | 7 +++ src/full/splitFactory.ts | 27 ++++++++ src/{umd-full.ts => full/umd.ts} | 0 src/platform/getFetchFull.ts | 6 ++ src/platform/{getFetch.ts => getFetchSlim.ts} | 0 src/settings/__tests__/index.spec.ts | 21 ++++--- src/settings/full.ts | 23 +++++++ src/splitFactory.ts | 5 +- ts-tests/index.ts | 9 +++ types/full/index.d.ts | 62 +++++++++++++++++++ 16 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 full/package.json create mode 100644 src/full/index.ts create mode 100644 src/full/splitFactory.ts rename src/{umd-full.ts => full/umd.ts} (100%) create mode 100644 src/platform/getFetchFull.ts rename src/platform/{getFetch.ts => getFetchSlim.ts} (100%) create mode 100644 src/settings/full.ts create mode 100644 types/full/index.d.ts diff --git a/CHANGES.txt b/CHANGES.txt index deb4281..08b6a6a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,7 +7,6 @@ - Removed internal ponyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or provide a polyfill. - Removed the deprecated `GoogleAnalyticsToSplit` and `SplitToGoogleAnalytics` pluggable integration modules, along with the related interfaces in the TypeScript definitions. - Removed the `LocalhostFromObject` export from the default import (`import { LocalhostFromObject } from '@splitsoftware/splitio-browserjs'`). It is no longer necessary to manually import and configure it in the `sync.localhostMode` option to enable localhost mode. - - Removed the "full" import (`import { SplitFactory } from '@splitsoftware/splitio-browserjs/full'`), since with the removal of `LocalhostFromObject` from the default import, the difference between them is minimal. The "full" import differs only by including the `unfetch` ponyfill to support older browsers. 0.15.0 (September 13, 2024) - Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates: diff --git a/full/package.json b/full/package.json new file mode 100644 index 0000000..a59cb3f --- /dev/null +++ b/full/package.json @@ -0,0 +1,6 @@ +{ + "main": "../cjs/full/index.js", + "module": "../esm/full/index.js", + "types": "../types/full/index.d.ts", + "sideEffects": false +} diff --git a/package-lock.json b/package-lock.json index 23b7e48..297c4df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "Apache-2.0", "dependencies": { "@splitsoftware/splitio-commons": "2.0.0-rc.5", - "tslib": "^2.3.1" + "tslib": "^2.3.1", + "unfetch": "^4.2.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", @@ -9165,6 +9166,11 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" }, + "node_modules/unfetch": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz", + "integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==" + }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -16365,6 +16371,11 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" }, + "unfetch": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz", + "integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==" + }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", diff --git a/package.json b/package.json index 56a42fc..e5b2ba5 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "cjs", "esm", "src", - "types" + "types", + "full" ], "scripts": { "check": "npm run check:lint && npm run check:types && npm run check:version", @@ -59,7 +60,8 @@ "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { "@splitsoftware/splitio-commons": "2.0.0-rc.5", - "tslib": "^2.3.1" + "tslib": "^2.3.1", + "unfetch": "^4.2.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", diff --git a/rollup.ci.config.js b/rollup.ci.config.js index 80dcb43..af1d738 100644 --- a/rollup.ci.config.js +++ b/rollup.ci.config.js @@ -35,7 +35,7 @@ export default env => { * * Only https://www.npmjs.com/package/rollup-plugin-ts compiles from node_modules, and is used for tests. */ - createRollupConfig('esm/umd-full.js', 'full'), // umd/split-browser-VERSION.full[.min].js + createRollupConfig('esm/full/umd.js', 'full'), // umd/split-browser-VERSION.full[.min].js createRollupConfig('esm/umd.js') // umd/split-browser-VERSION[.min].js ]; }; diff --git a/src/__tests__/offline/browser.spec.js b/src/__tests__/offline/browser.spec.js index 2c5ee06..6b2d981 100644 --- a/src/__tests__/offline/browser.spec.js +++ b/src/__tests__/offline/browser.spec.js @@ -2,7 +2,8 @@ import tape from 'tape-catch'; import sinon from 'sinon'; import fetchMock from '../testUtils/fetchMock'; import { url } from '../testUtils'; -import { SplitFactory, InLocalStorage } from '../../index'; +import { SplitFactory, InLocalStorage } from '../../full'; +import { SplitFactory as SplitFactorySlim } from '../../'; import { settingsFactory } from '../../settings'; const settings = settingsFactory({ core: { key: 'facundo@split.io' } }); @@ -87,7 +88,10 @@ tape('Browser offline mode', function (assert) { sharedUpdateCount++; }); - const factoryReadyFromCache = SplitFactory({ ...config, storage: InLocalStorage() }); + const factoriesReadyFromCache = [ + SplitFactory({ ...config, storage: InLocalStorage() }), + SplitFactorySlim({ ...config, storage: InLocalStorage() }) + ]; const configs = [ { ...config, features: { ...config.features }, storage: InLocalStorage /* invalid */ }, { ...config }, @@ -95,7 +99,7 @@ tape('Browser offline mode', function (assert) { ]; const factories = [ ...configs.map(config => SplitFactory(config)), - factoryReadyFromCache + ...factoriesReadyFromCache ]; let readyCount = 0, updateCount = 0, readyFromCacheCount = 0; @@ -357,7 +361,7 @@ tape('Browser offline mode', function (assert) { // SDK events on other factory clients assert.equal(readyCount, factories.length, 'Each factory client should have emitted SDK_READY event once'); assert.equal(updateCount, factories.length - 1, 'Each factory client except one should have emitted SDK_UPDATE event once'); - assert.equal(readyFromCacheCount, 2, 'The main and shared client of the factory with LOCALSTORAGE should have emitted SDK_READY_FROM_CACHE event'); + assert.equal(readyFromCacheCount, factoriesReadyFromCache.length * 2, 'The main and shared client of the factories with LOCALSTORAGE should have emitted SDK_READY_FROM_CACHE event'); assert.end(); }); diff --git a/src/full/index.ts b/src/full/index.ts new file mode 100644 index 0000000..be0ed7a --- /dev/null +++ b/src/full/index.ts @@ -0,0 +1,7 @@ +export { SplitFactory } from './splitFactory'; +export { InLocalStorage } from '@splitsoftware/splitio-commons/src/storages/inLocalStorage/index'; +export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/ErrorLogger'; +export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger'; +export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger'; +export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger'; +export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable'; diff --git a/src/full/splitFactory.ts b/src/full/splitFactory.ts new file mode 100644 index 0000000..ba1f6fe --- /dev/null +++ b/src/full/splitFactory.ts @@ -0,0 +1,27 @@ +import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; +import { settingsFactory } from '../settings/full'; +import { getModules } from '../platform/getModules'; +import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; +import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; +import { getFetch } from '../platform/getFetchFull'; +import { getEventSource } from '../platform/getEventSource'; +import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; +import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; + +const platform = { getFetch, getEventSource, EventEmitter, now }; + +/** + * SplitFactory with pluggable modules for Browser. + * Includes fetch polyfill out-of-the-box. + * + * @param config - configuration object used to instantiate the SDK + * @param __updateModules - optional function that lets redefine internal SDK modules. Use with + * caution since, unlike `config`, this param is not validated neither considered part of the public API. + * @throws Will throw an error if the provided config is invalid. + */ +export function SplitFactory(config: SplitIO.IClientSideSettings, __updateModules?: (modules: ISdkFactoryParams) => void) { + const settings = settingsFactory(config); + const modules = getModules(settings, platform); + if (__updateModules) __updateModules(modules); + return sdkFactory(modules); +} diff --git a/src/umd-full.ts b/src/full/umd.ts similarity index 100% rename from src/umd-full.ts rename to src/full/umd.ts diff --git a/src/platform/getFetchFull.ts b/src/platform/getFetchFull.ts new file mode 100644 index 0000000..496c07a --- /dev/null +++ b/src/platform/getFetchFull.ts @@ -0,0 +1,6 @@ +import { IFetch } from '@splitsoftware/splitio-commons/src/services/types'; +import unfetch from 'unfetch'; + +export function getFetch() { + return typeof fetch === 'function' ? fetch : unfetch as unknown as IFetch; +} diff --git a/src/platform/getFetch.ts b/src/platform/getFetchSlim.ts similarity index 100% rename from src/platform/getFetch.ts rename to src/platform/getFetchSlim.ts diff --git a/src/settings/__tests__/index.spec.ts b/src/settings/__tests__/index.spec.ts index ab157b6..4b1ad49 100644 --- a/src/settings/__tests__/index.spec.ts +++ b/src/settings/__tests__/index.spec.ts @@ -1,15 +1,18 @@ -import { settingsFactory } from '../index'; +import { settingsFactory as slimSettingsFactory } from '../index'; +import { settingsFactory as fullSettingsFactory } from '../full'; test('SETTINGS / Consent is overwritable and "GRANTED" by default', () => { - let settings = settingsFactory({}); - expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if not provided + [slimSettingsFactory, fullSettingsFactory].forEach((settingsFactory) => { + let settings = settingsFactory({}); + expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if not provided - settings = settingsFactory({ userConsent: 'INVALID-VALUE' }); - expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if a wrong value is provided + settings = settingsFactory({ userConsent: 'INVALID-VALUE' }); + expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if a wrong value is provided - settings = settingsFactory({ userConsent: 'UNKNOWN' }); - expect(settings.userConsent).toEqual('UNKNOWN'); // userConsent can be overwritten + settings = settingsFactory({ userConsent: 'UNKNOWN' }); + expect(settings.userConsent).toEqual('UNKNOWN'); // userConsent can be overwritten - settings = settingsFactory({ userConsent: 'declined' }); - expect(settings.userConsent).toEqual('DECLINED'); // userConsent can be overwritten + settings = settingsFactory({ userConsent: 'declined' }); + expect(settings.userConsent).toEqual('DECLINED'); // userConsent can be overwritten + }); }); diff --git a/src/settings/full.ts b/src/settings/full.ts new file mode 100644 index 0000000..8c6f6fb --- /dev/null +++ b/src/settings/full.ts @@ -0,0 +1,23 @@ +import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/index'; +import { defaults } from './defaults'; +import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime'; +import { validateStorageCS } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS'; +import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/integrations/pluggable'; +import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/pluggableLogger'; +import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent'; + +const params = { + defaults, + acceptKey: true, // Client with bound key + runtime: validateRuntime, + storage: validateStorageCS, + integrations: validatePluggableIntegrations, + logger: validateLogger, + consent: validateConsent, +}; + +export function settingsFactory(config: any) { + const settings = settingsValidation(config, params); + + return settings; +} diff --git a/src/splitFactory.ts b/src/splitFactory.ts index 7a7f81f..b376756 100644 --- a/src/splitFactory.ts +++ b/src/splitFactory.ts @@ -1,9 +1,9 @@ -import type SplitIO from '@splitsoftware/splitio-commons/types/splitio'; +import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; import { settingsFactory } from './settings'; import { getModules } from './platform/getModules'; import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; -import { getFetch } from './platform/getFetch'; +import { getFetch } from './platform/getFetchSlim'; import { getEventSource } from './platform/getEventSource'; import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; @@ -12,6 +12,7 @@ const platform = { getFetch, getEventSource, EventEmitter, now }; /** * SplitFactory with pluggable modules for Browser. + * Doesn't include fetch ponyfill out-of-the-box. * * @param config - configuration object used to instantiate the SDK * @param __updateModules - optional function that lets redefine internal SDK modules. Use with diff --git a/ts-tests/index.ts b/ts-tests/index.ts index 5b40ecf..0a90b87 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -11,8 +11,13 @@ * @author Nico Zelaya */ +import { SplitFactory as SplitFactoryFull, InLocalStorage as InLocalStorageFull, DebugLogger as DebugLoggerFull, InfoLogger as InfoLoggerFull, WarnLogger as WarnLoggerFull, ErrorLogger as ErrorLoggerFull, PluggableStorage as PluggableStorageFull } from '../types/full'; import { SplitFactory, InLocalStorage, DebugLogger, InfoLogger, WarnLogger, ErrorLogger, PluggableStorage } from '../types/index'; +// Entry points must export the same objects +let splitFactory = SplitFactory; splitFactory = SplitFactoryFull; +let inLocalStorage = InLocalStorage; inLocalStorage = InLocalStorageFull; +let pluggableStorage = PluggableStorage; pluggableStorage = PluggableStorageFull; let stringPromise: Promise; let splitNamesPromise: Promise; @@ -619,6 +624,10 @@ fullBrowserSettings.debug = DebugLogger(); fullBrowserSettings.debug = InfoLogger(); fullBrowserSettings.debug = WarnLogger(); fullBrowserSettings.debug = ErrorLogger(); +fullBrowserSettings.debug = DebugLoggerFull(); +fullBrowserSettings.debug = InfoLoggerFull(); +fullBrowserSettings.debug = WarnLoggerFull(); +fullBrowserSettings.debug = ErrorLoggerFull(); // let fullNodeSettings: SplitIO.INodeSettings = { // core: { diff --git a/types/full/index.d.ts b/types/full/index.d.ts new file mode 100644 index 0000000..648e49a --- /dev/null +++ b/types/full/index.d.ts @@ -0,0 +1,62 @@ +// Declaration file for JavaScript Browser Split Software SDK +// Project: http://www.split.io/ +// Definitions by: Nico Zelaya + +import '@splitsoftware/splitio-commons'; + +export = JsSdk; + +declare module JsSdk { + /** + * Full version of the Split.io SDK factory function. + * + * Unlike the default version, it includes a `fetch` polyfill to support old browsers @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#language-support}. + * + * The settings parameter should be an object that complies with the SplitIO.IClientSideSettings or SplitIO.IClientSideAsyncSettings interfaces. + * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} + */ + export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.ISDK; + export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; + + /** + * Persistent storage based on the LocalStorage Web API for browsers. + * + * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#storage} + */ + export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory; + + /** + * Pluggable storage to use the SDK in consumer mode. + * + * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage} + */ + export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory; + + /** + * Creates a logger instance that enables descriptive log messages with DEBUG log level when passed in the factory settings. + * + * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} + */ + export function DebugLogger(): SplitIO.ILogger; + + /** + * Creates a logger instance that enables descriptive log messages with INFO log level when passed in the factory settings. + * + * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} + */ + export function InfoLogger(): SplitIO.ILogger; + + /** + * Creates a logger instance that enables descriptive log messages with WARN log level when passed in the factory settings. + * + * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} + */ + export function WarnLogger(): SplitIO.ILogger; + + /** + * Creates a logger instance that enables descriptive log messages with ERROR log level when passed in the factory settings. + * + * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} + */ + export function ErrorLogger(): SplitIO.ILogger; +} From 752f1c4111432482deac469cf4932925029b9b8e Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Thu, 31 Oct 2024 00:43:50 -0300 Subject: [PATCH 10/12] Update ts test --- ts-tests/index.ts | 10 +++++----- types/full/index.d.ts | 4 ++-- types/index.d.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ts-tests/index.ts b/ts-tests/index.ts index 0a90b87..6195c90 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -32,8 +32,8 @@ let trackPromise: Promise; // Facade return interface // let SDK: SplitIO.ISDK; -let AsyncSDK: SplitIO.IAsyncSDK; -let SDK: SplitIO.ISDK; +let AsyncSDK: SplitIO.IBrowserAsyncSDK; +let SDK: SplitIO.IBrowserSDK; // Settings interfaces // let nodeSettings: SplitIO.INodeSettings; // let asyncSettings: SplitIO.INodeAsyncSettings; @@ -41,9 +41,9 @@ let browserSettings: SplitIO.IClientSideSettings; let browserAsyncSettings: SplitIO.IClientSideAsyncSettings; // Client & Manager APIs // let client: SplitIO.IClient; -let client: SplitIO.IClient; +let client: SplitIO.IBrowserClient; let manager: SplitIO.IManager; -let asyncClient: SplitIO.IAsyncClient; +let asyncClient: SplitIO.IBrowserAsyncClient; let asyncManager: SplitIO.IAsyncManager; // Utility interfaces let impressionListener: SplitIO.IImpressionListener; @@ -182,7 +182,7 @@ browserAsyncSettings = { wrapper: {} }) }; -// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK +// With sync settings should return IBrowserSDK, if settings have async storage it should return IBrowserAsyncSDK SDK = SplitFactory(browserSettings); AsyncSDK = SplitFactory(browserAsyncSettings); // SDK = SplitFactory(nodeSettings); diff --git a/types/full/index.d.ts b/types/full/index.d.ts index 648e49a..521c48a 100644 --- a/types/full/index.d.ts +++ b/types/full/index.d.ts @@ -15,8 +15,8 @@ declare module JsSdk { * The settings parameter should be an object that complies with the SplitIO.IClientSideSettings or SplitIO.IClientSideAsyncSettings interfaces. * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} */ - export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.ISDK; - export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; + export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.IBrowserSDK; + export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IBrowserAsyncSDK; /** * Persistent storage based on the LocalStorage Web API for browsers. diff --git a/types/index.d.ts b/types/index.d.ts index 1b93b6b..796120d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -13,8 +13,8 @@ declare module JsSdk { * The settings parameter should be an object that complies with the SplitIO.IClientSideSettings or SplitIO.IClientSideAsyncSettings interfaces. * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} */ - export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.ISDK; - export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; + export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.IBrowserSDK; + export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IBrowserAsyncSDK; /** * Persistent storage based on the LocalStorage Web API for browsers. From c7be832fd06cab6a96590a1e8add4817bf9ab5df Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Thu, 31 Oct 2024 01:05:30 -0300 Subject: [PATCH 11/12] Upgrade JS-commons --- CHANGES.txt | 2 +- package-lock.json | 14 +++++++------- package.json | 2 +- src/full/splitFactory.ts | 2 +- src/splitFactory.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 08b6a6a..fa1b3ce 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,7 +3,7 @@ - Added `factory.destroy()` method, which invokes the `destroy` method of all clients created by the factory. - Updated @splitsoftware/splitio-commons package to version 2.0.0 that includes major updates and updated some transitive dependencies for vulnerability fixes. - BREAKING CHANGES: - - Renamed some TypeScript definitions in the SplitIO namespace to avoid conflicts with other libraries: `SplitIO.IBrowserSettings` to `SplitIO.IClientSideSettings`, `SplitIO.IBrowserAsyncSettings` to `SplitIO.IClientSideAsyncSettings`. + - Renamed some TypeScript definitions in the SplitIO namespace to avoid conflicts with other Split packages: `SplitIO.IBrowserSettings` to `SplitIO.IClientSideSettings`, `SplitIO.IBrowserAsyncSettings` to `SplitIO.IClientSideAsyncSettings`, `SplitIO.ISDK` to `SplitIO.IBrowserSDK`, and `SplitIO.IAsyncSDK` to `SplitIO.IBrowserAsyncSDK`. - Removed internal ponyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or provide a polyfill. - Removed the deprecated `GoogleAnalyticsToSplit` and `SplitToGoogleAnalytics` pluggable integration modules, along with the related interfaces in the TypeScript definitions. - Removed the `LocalhostFromObject` export from the default import (`import { LocalhostFromObject } from '@splitsoftware/splitio-browserjs'`). It is no longer necessary to manually import and configure it in the `sync.localhostMode` option to enable localhost mode. diff --git a/package-lock.json b/package-lock.json index 297c4df..7b18a22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0-rc.2", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "2.0.0-rc.5", + "@splitsoftware/splitio-commons": "2.0.0-rc.6", "tslib": "^2.3.1", "unfetch": "^4.2.0" }, @@ -1542,9 +1542,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "2.0.0-rc.5", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.5.tgz", - "integrity": "sha512-hNLA3cfVj5yGSHpOyTQVzcU2kIceJtJOdatcuue2ENOesjwDHfpvEy/YkIgLcLwXpvUxTFKpZd1BRej8gSbWoA==", + "version": "2.0.0-rc.6", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.6.tgz", + "integrity": "sha512-A4Dk02ShJBjXqtPro6ylBAPc344Unnyk7YmEmvQqv1x4VUKloLw76PI7FgUgG7bM2UH079jSIeUg8HePW2PL1g==", "dependencies": { "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" @@ -10688,9 +10688,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "2.0.0-rc.5", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.5.tgz", - "integrity": "sha512-hNLA3cfVj5yGSHpOyTQVzcU2kIceJtJOdatcuue2ENOesjwDHfpvEy/YkIgLcLwXpvUxTFKpZd1BRej8gSbWoA==", + "version": "2.0.0-rc.6", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.0.0-rc.6.tgz", + "integrity": "sha512-A4Dk02ShJBjXqtPro6ylBAPc344Unnyk7YmEmvQqv1x4VUKloLw76PI7FgUgG7bM2UH079jSIeUg8HePW2PL1g==", "requires": { "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" diff --git a/package.json b/package.json index e5b2ba5..01fe19f 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "bugs": "https://github.com/splitio/javascript-browser-client/issues", "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { - "@splitsoftware/splitio-commons": "2.0.0-rc.5", + "@splitsoftware/splitio-commons": "2.0.0-rc.6", "tslib": "^2.3.1", "unfetch": "^4.2.0" }, diff --git a/src/full/splitFactory.ts b/src/full/splitFactory.ts index d260c98..6b36516 100644 --- a/src/full/splitFactory.ts +++ b/src/full/splitFactory.ts @@ -1,4 +1,4 @@ -import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; +import type SplitIO from '@splitsoftware/splitio-commons/types/splitio'; import { settingsFactory } from '../settings/full'; import { getModules } from '../platform/getModules'; import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; diff --git a/src/splitFactory.ts b/src/splitFactory.ts index fff89cc..cdf93fb 100644 --- a/src/splitFactory.ts +++ b/src/splitFactory.ts @@ -1,4 +1,4 @@ -import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; +import type SplitIO from '@splitsoftware/splitio-commons/types/splitio'; import { settingsFactory } from './settings'; import { getModules } from './platform/getModules'; import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; From 964235ad1b1c2b5c7b91be5f4a4fd661ea63e6b7 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Thu, 31 Oct 2024 13:42:28 -0300 Subject: [PATCH 12/12] rc --- .github/workflows/ci-cd.yml | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- src/settings/defaults.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index f55585a..70af004 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -47,7 +47,7 @@ jobs: run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build - name: Store assets - if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main') }} + if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/refactor_type_definitions' || github.ref == 'refs/heads/main') }} uses: actions/upload-artifact@v3 with: name: assets @@ -58,7 +58,7 @@ jobs: name: Upload assets runs-on: ubuntu-20.04 needs: build - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/refactor_type_definitions' }} strategy: matrix: environment: diff --git a/package-lock.json b/package-lock.json index 7b18a22..c6c4afb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "license": "Apache-2.0", "dependencies": { "@splitsoftware/splitio-commons": "2.0.0-rc.6", diff --git a/package.json b/package.json index 01fe19f..f93ef34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "description": "Split SDK for JavaScript on Browser", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/settings/defaults.ts b/src/settings/defaults.ts index 7d28ad2..ad4a367 100644 --- a/src/settings/defaults.ts +++ b/src/settings/defaults.ts @@ -2,7 +2,7 @@ import type SplitIO from '@splitsoftware/splitio-commons/types/splitio'; import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/logger/index'; import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants'; -const packageVersion = '1.0.0-rc.2'; +const packageVersion = '1.0.0-rc.3'; /** * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.