@splitsoftware/splitio 10.28.1-rc.1 → 10.28.1-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.txt CHANGED
@@ -1,7 +1,9 @@
1
1
  10.29.0 (September XX, 2024)
2
+ - Added `factory.destroy()` method, which invokes the `destroy` method on all SDK clients created by the factory.
2
3
  - Updated @splitsoftware/splitio-commons package to version 1.18.0 that includes minor updates:
3
4
  - Added support for targeting rules based on large segments for browsers.
4
5
  - Updated some transitive dependencies for vulnerability fixes.
6
+ - Bugfixing - Removed an overloaded `client` method in the `SplitIO.ISDK` interface that accepted a key and trafficType parameters. This interface corresponds to the SDK factory instance in NodeJS, which, unlike `SplitIO.IBrowserSDK` for the Browser, does not handle multiple client instances based on keys or traffic types.
5
7
 
6
8
  10.28.0 (September 6, 2024)
7
9
  - Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
@@ -8,7 +8,6 @@ import { sdkManagerFactory } from '@splitsoftware/splitio-commons/esm/sdkManager
8
8
  import { sdkClientMethodCSFactory } from '@splitsoftware/splitio-commons/esm/sdkClient/sdkClientMethodCSWithTT';
9
9
  import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/esm/trackers/impressionObserver/impressionObserverCS';
10
10
  import { integrationsManagerFactory } from '@splitsoftware/splitio-commons/esm/integrations/browser';
11
- import { __InLocalStorageMockFactory } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/storage/storageCS';
12
11
  import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory';
13
12
  import { LOCALHOST_MODE, STORAGE_LOCALSTORAGE } from '@splitsoftware/splitio-commons/esm/utils/constants';
14
13
  import { createUserConsentAPI } from '@splitsoftware/splitio-commons/esm/consent/sdkUserConsent';
@@ -17,10 +16,8 @@ import { platform, SignalListener } from '../platform';
17
16
  var syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
18
17
  function getStorage(settings) {
19
18
  return settings.storage.type === STORAGE_LOCALSTORAGE ?
20
- InLocalStorage(settings.storage)
21
- : settings.storage.__originalType === STORAGE_LOCALSTORAGE ?
22
- __InLocalStorageMockFactory
23
- : InMemoryStorageCSFactory;
19
+ InLocalStorage(settings.storage) :
20
+ InMemoryStorageCSFactory;
24
21
  }
25
22
  /**
26
23
  *
@@ -4,6 +4,7 @@ import { pushManagerFactory } from '@splitsoftware/splitio-commons/esm/sync/stre
4
4
  import { pollingManagerSSFactory } from '@splitsoftware/splitio-commons/esm/sync/polling/pollingManagerSS';
5
5
  import { InRedisStorage } from '@splitsoftware/splitio-commons/esm/storages/inRedis';
6
6
  import { InMemoryStorageFactory } from '@splitsoftware/splitio-commons/esm/storages/inMemory/InMemoryStorage';
7
+ import { getSnapshot } from '@splitsoftware/splitio-commons/esm/storages/dataLoader';
7
8
  import { sdkManagerFactory } from '@splitsoftware/splitio-commons/esm/sdkManager';
8
9
  import { sdkClientMethodFactory } from '@splitsoftware/splitio-commons/esm/sdkClient/sdkClientMethod';
9
10
  import { impressionObserverSSFactory } from '@splitsoftware/splitio-commons/esm/trackers/impressionObserver/impressionObserverSS';
@@ -33,7 +34,16 @@ function getModules(settings) {
33
34
  sdkClientMethodFactory: sdkClientMethodFactory,
34
35
  SignalListener: SignalListener,
35
36
  impressionsObserverFactory: impressionObserverSSFactory,
36
- filterAdapterFactory: bloomFilterFactory
37
+ filterAdapterFactory: bloomFilterFactory,
38
+ extraProps: function (params) {
39
+ if (params.settings.mode !== CONSUMER_MODE) {
40
+ return {
41
+ getState: function (userKeys) {
42
+ return getSnapshot(params.storage, userKeys);
43
+ }
44
+ };
45
+ }
46
+ }
37
47
  };
38
48
  switch (settings.mode) {
39
49
  case LOCALHOST_MODE:
@@ -1 +1 @@
1
- export var packageVersion = '10.28.1-rc.1';
1
+ export var packageVersion = '10.28.1-rc.3';
@@ -1,29 +1,18 @@
1
1
  import { isLocalStorageAvailable } from '@splitsoftware/splitio-commons/esm/utils/env/isLocalStorageAvailable';
2
- import { LOCALHOST_MODE, STORAGE_MEMORY } from '@splitsoftware/splitio-commons/esm/utils/constants';
2
+ import { STORAGE_MEMORY } from '@splitsoftware/splitio-commons/esm/utils/constants';
3
3
  var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
4
4
  export function validateStorage(settings) {
5
- var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
6
- var __originalType;
7
- var fallbackToMemory = function () {
8
- __originalType = type;
9
- type = STORAGE_MEMORY;
10
- };
11
- // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
12
- // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
13
- if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
14
- fallbackToMemory();
15
- }
5
+ var log = settings.log, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
16
6
  // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
17
7
  // it's not available, fallback into MEMORY
18
8
  if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
19
9
  type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
20
- fallbackToMemory();
10
+ type = STORAGE_MEMORY;
21
11
  log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
22
12
  }
23
13
  return {
24
14
  type: type,
25
15
  options: options,
26
16
  prefix: prefix,
27
- __originalType: __originalType
28
17
  };
29
18
  }
@@ -11,7 +11,6 @@ var sdkManager_1 = require("@splitsoftware/splitio-commons/cjs/sdkManager");
11
11
  var sdkClientMethodCSWithTT_1 = require("@splitsoftware/splitio-commons/cjs/sdkClient/sdkClientMethodCSWithTT");
12
12
  var impressionObserverCS_1 = require("@splitsoftware/splitio-commons/cjs/trackers/impressionObserver/impressionObserverCS");
13
13
  var browser_1 = require("@splitsoftware/splitio-commons/cjs/integrations/browser");
14
- var storageCS_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/storage/storageCS");
15
14
  var sdkFactory_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory");
16
15
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
17
16
  var sdkUserConsent_1 = require("@splitsoftware/splitio-commons/cjs/consent/sdkUserConsent");
@@ -20,10 +19,8 @@ var platform_1 = require("../platform");
20
19
  var syncManagerOnlineCSFactory = (0, syncManagerOnline_1.syncManagerOnlineFactory)(pollingManagerCS_1.pollingManagerCSFactory, pushManager_1.pushManagerFactory);
21
20
  function getStorage(settings) {
22
21
  return settings.storage.type === constants_1.STORAGE_LOCALSTORAGE ?
23
- (0, inLocalStorage_1.InLocalStorage)(settings.storage)
24
- : settings.storage.__originalType === constants_1.STORAGE_LOCALSTORAGE ?
25
- storageCS_1.__InLocalStorageMockFactory
26
- : InMemoryStorageCS_1.InMemoryStorageCSFactory;
22
+ (0, inLocalStorage_1.InLocalStorage)(settings.storage) :
23
+ InMemoryStorageCS_1.InMemoryStorageCSFactory;
27
24
  }
28
25
  /**
29
26
  *
@@ -7,6 +7,7 @@ var pushManager_1 = require("@splitsoftware/splitio-commons/cjs/sync/streaming/p
7
7
  var pollingManagerSS_1 = require("@splitsoftware/splitio-commons/cjs/sync/polling/pollingManagerSS");
8
8
  var inRedis_1 = require("@splitsoftware/splitio-commons/cjs/storages/inRedis");
9
9
  var InMemoryStorage_1 = require("@splitsoftware/splitio-commons/cjs/storages/inMemory/InMemoryStorage");
10
+ var dataLoader_1 = require("@splitsoftware/splitio-commons/cjs/storages/dataLoader");
10
11
  var sdkManager_1 = require("@splitsoftware/splitio-commons/cjs/sdkManager");
11
12
  var sdkClientMethod_1 = require("@splitsoftware/splitio-commons/cjs/sdkClient/sdkClientMethod");
12
13
  var impressionObserverSS_1 = require("@splitsoftware/splitio-commons/cjs/trackers/impressionObserver/impressionObserverSS");
@@ -36,7 +37,16 @@ function getModules(settings) {
36
37
  sdkClientMethodFactory: sdkClientMethod_1.sdkClientMethodFactory,
37
38
  SignalListener: platform_1.SignalListener,
38
39
  impressionsObserverFactory: impressionObserverSS_1.impressionObserverSSFactory,
39
- filterAdapterFactory: bloomFilter_1.bloomFilterFactory
40
+ filterAdapterFactory: bloomFilter_1.bloomFilterFactory,
41
+ extraProps: function (params) {
42
+ if (params.settings.mode !== constants_1.CONSUMER_MODE) {
43
+ return {
44
+ getState: function (userKeys) {
45
+ return (0, dataLoader_1.getSnapshot)(params.storage, userKeys);
46
+ }
47
+ };
48
+ }
49
+ }
40
50
  };
41
51
  switch (settings.mode) {
42
52
  case constants_1.LOCALHOST_MODE:
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageVersion = void 0;
4
- exports.packageVersion = '10.28.1-rc.1';
4
+ exports.packageVersion = '10.28.1-rc.3';
@@ -5,29 +5,18 @@ var isLocalStorageAvailable_1 = require("@splitsoftware/splitio-commons/cjs/util
5
5
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
6
6
  var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
7
7
  function validateStorage(settings) {
8
- var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: constants_1.STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
9
- var __originalType;
10
- var fallbackToMemory = function () {
11
- __originalType = type;
12
- type = constants_1.STORAGE_MEMORY;
13
- };
14
- // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
15
- // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
16
- if (mode === constants_1.LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
17
- fallbackToMemory();
18
- }
8
+ var log = settings.log, _a = settings.storage, _b = _a === void 0 ? { type: constants_1.STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
19
9
  // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
20
10
  // it's not available, fallback into MEMORY
21
11
  if (type !== constants_1.STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
22
12
  type === STORAGE_LOCALSTORAGE && !(0, isLocalStorageAvailable_1.isLocalStorageAvailable)()) {
23
- fallbackToMemory();
13
+ type = constants_1.STORAGE_MEMORY;
24
14
  log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
25
15
  }
26
16
  return {
27
17
  type: type,
28
18
  options: options,
29
19
  prefix: prefix,
30
- __originalType: __originalType
31
20
  };
32
21
  }
33
22
  exports.validateStorage = validateStorage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.28.1-rc.1",
3
+ "version": "10.28.1-rc.3",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -40,7 +40,7 @@
40
40
  "node": ">=6"
41
41
  },
42
42
  "dependencies": {
43
- "@splitsoftware/splitio-commons": "1.17.1-rc.0",
43
+ "@splitsoftware/splitio-commons": "1.17.1-rc.2",
44
44
  "@types/google.analytics": "0.0.40",
45
45
  "@types/ioredis": "^4.28.0",
46
46
  "bloom-filters": "^3.0.0",
@@ -8,7 +8,6 @@ import { sdkManagerFactory } from '@splitsoftware/splitio-commons/src/sdkManager
8
8
  import { sdkClientMethodCSFactory } from '@splitsoftware/splitio-commons/src/sdkClient/sdkClientMethodCSWithTT';
9
9
  import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/impressionObserverCS';
10
10
  import { integrationsManagerFactory } from '@splitsoftware/splitio-commons/src/integrations/browser';
11
- import { __InLocalStorageMockFactory } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS';
12
11
  import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory';
13
12
  import { LOCALHOST_MODE, STORAGE_LOCALSTORAGE } from '@splitsoftware/splitio-commons/src/utils/constants';
14
13
  import { createUserConsentAPI } from '@splitsoftware/splitio-commons/src/consent/sdkUserConsent';
@@ -20,10 +19,8 @@ const syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFact
20
19
 
21
20
  function getStorage(settings) {
22
21
  return settings.storage.type === STORAGE_LOCALSTORAGE ?
23
- InLocalStorage(settings.storage)
24
- : settings.storage.__originalType === STORAGE_LOCALSTORAGE ?
25
- __InLocalStorageMockFactory
26
- : InMemoryStorageCSFactory;
22
+ InLocalStorage(settings.storage) :
23
+ InMemoryStorageCSFactory;
27
24
  }
28
25
 
29
26
  /**
@@ -4,6 +4,7 @@ import { pushManagerFactory } from '@splitsoftware/splitio-commons/src/sync/stre
4
4
  import { pollingManagerSSFactory } from '@splitsoftware/splitio-commons/src/sync/polling/pollingManagerSS';
5
5
  import { InRedisStorage } from '@splitsoftware/splitio-commons/src/storages/inRedis';
6
6
  import { InMemoryStorageFactory } from '@splitsoftware/splitio-commons/src/storages/inMemory/InMemoryStorage';
7
+ import { getSnapshot } from '@splitsoftware/splitio-commons/src/storages/dataLoader';
7
8
  import { sdkManagerFactory } from '@splitsoftware/splitio-commons/src/sdkManager';
8
9
  import { sdkClientMethodFactory } from '@splitsoftware/splitio-commons/src/sdkClient/sdkClientMethod';
9
10
  import { impressionObserverSSFactory } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/impressionObserverSS';
@@ -47,7 +48,17 @@ function getModules(settings) {
47
48
 
48
49
  impressionsObserverFactory: impressionObserverSSFactory,
49
50
 
50
- filterAdapterFactory: bloomFilterFactory
51
+ filterAdapterFactory: bloomFilterFactory,
52
+
53
+ extraProps: (params) => {
54
+ if (params.settings.mode !== CONSUMER_MODE) {
55
+ return {
56
+ getState(userKeys) {
57
+ return getSnapshot(params.storage, userKeys);
58
+ }
59
+ };
60
+ }
61
+ }
51
62
  };
52
63
 
53
64
  switch (settings.mode) {
@@ -1 +1 @@
1
- export const packageVersion = '10.28.1-rc.1';
1
+ export const packageVersion = '10.28.1-rc.3';
@@ -1,36 +1,23 @@
1
1
  import { isLocalStorageAvailable } from '@splitsoftware/splitio-commons/src/utils/env/isLocalStorageAvailable';
2
- import { LOCALHOST_MODE, STORAGE_MEMORY } from '@splitsoftware/splitio-commons/src/utils/constants';
2
+ import { STORAGE_MEMORY } from '@splitsoftware/splitio-commons/src/utils/constants';
3
3
 
4
4
  const STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
5
5
 
6
6
  export function validateStorage(settings) {
7
7
  let {
8
8
  log,
9
- mode,
10
9
  storage: {
11
10
  type,
12
11
  options = {},
13
12
  prefix
14
13
  } = { type: STORAGE_MEMORY },
15
14
  } = settings;
16
- let __originalType;
17
-
18
- const fallbackToMemory = () => {
19
- __originalType = type;
20
- type = STORAGE_MEMORY;
21
- };
22
-
23
- // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
24
- // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
25
- if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
26
- fallbackToMemory();
27
- }
28
15
 
29
16
  // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
30
17
  // it's not available, fallback into MEMORY
31
18
  if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
32
19
  type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
33
- fallbackToMemory();
20
+ type = STORAGE_MEMORY;
34
21
  log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
35
22
  }
36
23
 
@@ -38,6 +25,5 @@ export function validateStorage(settings) {
38
25
  type,
39
26
  options,
40
27
  prefix,
41
- __originalType
42
28
  };
43
29
  }
@@ -94,6 +94,7 @@ interface ISettings {
94
94
  options: Object,
95
95
  type: StorageType
96
96
  },
97
+ readonly preloadedData?: SplitIO.PreloadedData,
97
98
  readonly urls: {
98
99
  events: string,
99
100
  sdk: string,
@@ -491,6 +492,12 @@ interface IBasicSDK {
491
492
  * @property Logger
492
493
  */
493
494
  Logger: ILoggerAPI
495
+ /**
496
+ * Destroys all the clients created by this factory.
497
+ * @function destroy
498
+ * @returns {Promise<void>}
499
+ */
500
+ destroy(): Promise<void>
494
501
  }
495
502
  /****** Exposed namespace ******/
496
503
  /**
@@ -947,6 +954,10 @@ declare namespace SplitIO {
947
954
  * @typedef {string} ConsentStatus
948
955
  */
949
956
  type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
957
+ /**
958
+ * Defines the format of rollout plan data to preload on the factory storage (cache).
959
+ */
960
+ type PreloadedData = Object;
950
961
  /**
951
962
  * Settings interface for SDK instances created on the browser
952
963
  * @interface IBrowserSettings
@@ -1374,27 +1385,23 @@ declare namespace SplitIO {
1374
1385
  * @returns {IClient} The client instance.
1375
1386
  */
1376
1387
  client(): IClient,
1377
- /**
1378
- * Returns a shared client of the SDK. For usage on the browser.
1379
- * @function client
1380
- * @param {SplitKey} key The key for the new client instance.
1381
- * @param {string=} trafficType The traffic type of the provided key.
1382
- * @returns {IClient} The client instance.
1383
- */
1384
- client(key: SplitKey, trafficType?: string): IClient,
1385
1388
  /**
1386
1389
  * Returns a manager instance of the SDK to explore available information.
1387
1390
  * @function manager
1388
1391
  * @returns {IManager} The manager instance.
1389
1392
  */
1390
- manager(): IManager
1393
+ manager(): IManager,
1394
+ /**
1395
+ * @TODO add description
1396
+ */
1397
+ getState(): PreloadedData,
1391
1398
  }
1392
1399
  /**
1393
1400
  * This represents the interface for the SDK instance with synchronous storage.
1394
1401
  * @interface IBrowserSDK
1395
- * @extends ISDK
1402
+ * @extends IBasicSDK
1396
1403
  */
1397
- interface IBrowserSDK extends ISDK {
1404
+ interface IBrowserSDK extends IBasicSDK {
1398
1405
  /**
1399
1406
  * Returns the default client instance of the SDK.
1400
1407
  * @function client
@@ -1402,7 +1409,7 @@ declare namespace SplitIO {
1402
1409
  */
1403
1410
  client(): IBrowserClient,
1404
1411
  /**
1405
- * Returns a shared client of the SDK. For usage on the browser.
1412
+ * Returns a shared client of the SDK.
1406
1413
  * @function client
1407
1414
  * @param {SplitKey} key The key for the new client instance.
1408
1415
  * @param {string=} trafficType The traffic type of the provided key.