@splitsoftware/splitio 11.0.0-rc.0 → 11.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.txt CHANGED
@@ -1,15 +1,18 @@
1
1
  11.0.0 (October XX, 2024)
2
2
  - Added support for targeting rules based on large segments for browsers.
3
+ - Added `factory.getState()` method for standalone server-side SDKs, which returns the rollout plan snapshot from the storage.
4
+ - Added `preloadedData` configuration option for standalone client-side SDKs, which allows preloading the SDK storage with a snapshot of the rollout plan.
3
5
  - Added `factory.destroy()` method, which invokes the `destroy` method of all clients created by the factory.
4
6
  - Updated @splitsoftware/splitio-commons package to version 2.0.0 that includes major updates and updated some transitive dependencies for vulnerability fixes.
7
+ - Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for EcmaScript Modules build.
5
8
  - BREAKING CHANGES:
6
- - Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for EcmaScript Modules build.
7
- - Drop support for NodeJS v6. The SDK now requires NodeJS v14 or above.
8
- - Removed internal ponyfills for `Map`, `Set` and `Array.from` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or to provide a polyfill.
9
- - Removed the deprecated `GOOGLE_ANALYTICS_TO_SPLIT` and `SPLIT_TO_GOOGLE_ANALYTICS` integrations.
10
- - Removed clients with bound traffic type. the `core.trafficType` configuration option. The SDK now uses the `core.trafficType` value from the factory configuration to create clients.
11
- - Updated TypeScript definitions.
12
- - 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.
9
+ - Dropped support for NodeJS v6. The SDK now requires NodeJS v14 or above.
10
+ - 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.
11
+ - Removed the deprecated `GOOGLE_ANALYTICS_TO_SPLIT` and `SPLIT_TO_GOOGLE_ANALYTICS` integrations. The `integrations` configuration option has been removed from the SDK factory configuration, along with the associated interfaces in the TypeScript definitions.
12
+ - Removed the `core.trafficType` configuration option (`SplitIO.IBrowserSettings['core']['trafficType]`) and the `trafficType` parameter from the SDK `client()` method in Browser (`SplitIO.IBrowserSDK['client']`). As a result, traffic types can no longer be bound to SDK clients, and the traffic type must be provided in the `track` method.
13
+ - TypeScript definitions:
14
+ - Removed an overloaded `client` method in the `SplitIO.ISDK` interface that accepted `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.
15
+ - Updated the `SplitIO.IBrowserSDK` and `SplitIO.IBrowserClient` interfaces to no longer extend the `SplitIO.ISDK` and `SplitIO.IClient` interfaces respectively, as the SDK factory instance in NodeJS or server-side (`SplitIO.ISDK`) has a different API than the SDK client instance in the Browser or client-side (`SplitIO.IBrowserClient`).
13
16
 
14
17
  10.28.0 (September 6, 2024)
15
18
  - Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
@@ -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 = '11.0.0-rc.0';
4
+ exports.packageVersion = '11.0.0-rc.2';
@@ -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 = '11.0.0-rc.0';
1
+ export var packageVersion = '11.0.0-rc.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "11.0.0-rc.0",
3
+ "version": "11.0.0-rc.2",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -38,7 +38,7 @@
38
38
  "node": ">=14.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@splitsoftware/splitio-commons": "2.0.0-rc.0",
41
+ "@splitsoftware/splitio-commons": "2.0.0-rc.2",
42
42
  "@types/ioredis": "^4.28.0",
43
43
  "bloom-filters": "^3.0.0",
44
44
  "ioredis": "^4.28.0",
@@ -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 = '11.0.0-rc.0';
1
+ export const packageVersion = '11.0.0-rc.2';
@@ -8,28 +8,6 @@ import { RequestOptions } from "http";
8
8
  export as namespace SplitIO;
9
9
  export = SplitIO;
10
10
 
11
- /**
12
- * NodeJS.EventEmitter interface
13
- * @see {@link https://nodejs.org/api/events.html}
14
- */
15
- interface EventEmitter {
16
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
17
- on(event: string | symbol, listener: (...args: any[]) => void): this;
18
- once(event: string | symbol, listener: (...args: any[]) => void): this;
19
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
20
- off(event: string | symbol, listener: (...args: any[]) => void): this;
21
- removeAllListeners(event?: string | symbol): this;
22
- setMaxListeners(n: number): this;
23
- getMaxListeners(): number;
24
- listeners(event: string | symbol): Function[];
25
- rawListeners(event: string | symbol): Function[];
26
- emit(event: string | symbol, ...args: any[]): boolean;
27
- listenerCount(type: string | symbol): number;
28
- // Added in Node 6...
29
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
30
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
31
- eventNames(): Array<string | symbol>;
32
- }
33
11
  /**
34
12
  * @typedef {Object} EventConsts
35
13
  * @property {string} SDK_READY The ready event.
@@ -92,6 +70,7 @@ interface ISettings {
92
70
  options: Object,
93
71
  type: StorageType
94
72
  },
73
+ readonly preloadedData?: SplitIO.PreloadedData,
95
74
  readonly urls: {
96
75
  events: string,
97
76
  sdk: string,
@@ -429,10 +408,9 @@ interface INodeBasicSettings extends ISharedSettings {
429
408
  }
430
409
  /**
431
410
  * Common API for entities that expose status handlers.
432
- * @interface IStatusInterface
433
- * @extends EventEmitter
411
+ * @typedef IStatusInterface
434
412
  */
435
- interface IStatusInterface extends EventEmitter {
413
+ type IStatusInterface<TEventEmitter extends SplitIO.IEventEmitter = SplitIO.EventEmitter> = TEventEmitter & {
436
414
  /**
437
415
  * Constant object containing the SDK events for you to use.
438
416
  * @property {EventConsts} Event
@@ -441,7 +419,17 @@ interface IStatusInterface extends EventEmitter {
441
419
  /**
442
420
  * 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).
443
421
  * 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.
444
- * You must handle the promise rejection to avoid an unhandled promise rejection error, or you can set the `startup.readyTimeout` configuration option to 0 to avoid the timeout and thus the rejection.
422
+ *
423
+ * 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.
424
+ * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
425
+ * ```
426
+ * try {
427
+ * await client.ready().catch((e) => { throw e; });
428
+ * // SDK is ready
429
+ * } catch(e) {
430
+ * // SDK has timedout
431
+ * }
432
+ * ```
445
433
  *
446
434
  * @function ready
447
435
  * @returns {Promise<void>}
@@ -450,10 +438,9 @@ interface IStatusInterface extends EventEmitter {
450
438
  }
451
439
  /**
452
440
  * Common definitions between clients for different environments interface.
453
- * @interface IBasicClient
454
- * @extends IStatusInterface
441
+ * @typedef IBasicClient
455
442
  */
456
- interface IBasicClient extends IStatusInterface {
443
+ type IBasicClient<TEventEmitter extends SplitIO.IEventEmitter = SplitIO.EventEmitter> = IStatusInterface<TEventEmitter> & {
457
444
  /**
458
445
  * Destroys the client instance.
459
446
  * In 'standalone' mode, this method will flush any pending impressions and events, and stop the synchronization of feature flag definitions with the backend.
@@ -492,6 +479,42 @@ interface IBasicSDK {
492
479
  * For the SDK package information see {@link https://www.npmjs.com/package/@splitsoftware/splitio}
493
480
  */
494
481
  declare namespace SplitIO {
482
+ /**
483
+ * EventEmitter interface based on a subset of the NodeJS.EventEmitter methods. Used by the JavaScript Browser SDK and React Native SDK.
484
+ */
485
+ interface IEventEmitter {
486
+ addListener(event: string, listener: (...args: any[]) => void): this
487
+ on(event: string, listener: (...args: any[]) => void): this
488
+ once(event: string, listener: (...args: any[]) => void): this
489
+ removeListener(event: string, listener: (...args: any[]) => void): this
490
+ off(event: string, listener: (...args: any[]) => void): this
491
+ removeAllListeners(event?: string): this
492
+ emit(event: string, ...args: any[]): boolean
493
+ }
494
+
495
+ /**
496
+ * NodeJS.EventEmitter interface. Used by the JavaScript SDK for both flavours: server-side (NodeJS) and client-side (Browser).
497
+ *
498
+ * @see {@link https://nodejs.org/api/events.html}
499
+ */
500
+ interface EventEmitter extends IEventEmitter {
501
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
502
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
503
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
504
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
505
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
506
+ removeAllListeners(event?: string | symbol): this;
507
+ emit(event: string | symbol, ...args: any[]): boolean;
508
+ setMaxListeners(n: number): this;
509
+ getMaxListeners(): number;
510
+ listeners(event: string | symbol): Function[];
511
+ rawListeners(event: string | symbol): Function[];
512
+ listenerCount(type: string | symbol): number;
513
+ // Added in Node 6...
514
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
515
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
516
+ eventNames(): Array<string | symbol>;
517
+ }
495
518
  /**
496
519
  * Feature flag treatment value, returned by getTreatment.
497
520
  * @typedef {string} Treatment
@@ -788,6 +811,10 @@ declare namespace SplitIO {
788
811
  * @typedef {string} ConsentStatus
789
812
  */
790
813
  type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
814
+ /**
815
+ * Defines the format of rollout plan data to preload on the factory storage (cache).
816
+ */
817
+ type PreloadedData = Object;
791
818
  /**
792
819
  * Settings interface for SDK instances created on the browser
793
820
  * @interface IBrowserSettings
@@ -946,6 +973,10 @@ declare namespace SplitIO {
946
973
  */
947
974
  prefix?: string
948
975
  },
976
+ /**
977
+ * @TODO Add description. Should be inside storage?
978
+ */
979
+ preloadedData?: SplitIO.PreloadedData,
949
980
  /**
950
981
  * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
951
982
  * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
@@ -1211,33 +1242,37 @@ declare namespace SplitIO {
1211
1242
  * @function manager
1212
1243
  * @returns {IManager} The manager instance.
1213
1244
  */
1214
- manager(): IManager
1245
+ manager(): IManager,
1246
+ /**
1247
+ * @TODO add description
1248
+ */
1249
+ getState(keys?: SplitKey[]): PreloadedData,
1215
1250
  }
1216
1251
  /**
1217
- * This represents the interface for the SDK instance with synchronous storage.
1252
+ * This represents the interface for the SDK instance with synchronous storage and client-side API.
1218
1253
  * @interface IBrowserSDK
1219
1254
  * @extends IBasicSDK
1220
1255
  */
1221
- interface IBrowserSDK extends IBasicSDK {
1256
+ interface IBrowserSDK<TEventEmitter extends IEventEmitter = EventEmitter> extends IBasicSDK {
1222
1257
  /**
1223
1258
  * Returns the default client instance of the SDK.
1224
1259
  * @function client
1225
1260
  * @returns {IBrowserClient} The client instance.
1226
1261
  */
1227
- client(): IBrowserClient,
1262
+ client(): IBrowserClient<TEventEmitter>,
1228
1263
  /**
1229
1264
  * Returns a shared client of the SDK.
1230
1265
  * @function client
1231
1266
  * @param {SplitKey} key The key for the new client instance.
1232
1267
  * @returns {IBrowserClient} The client instance.
1233
1268
  */
1234
- client(key: SplitKey): IBrowserClient
1269
+ client(key: SplitKey): IBrowserClient<TEventEmitter>
1235
1270
  /**
1236
1271
  * Returns a manager instance of the SDK to explore available information.
1237
1272
  * @function manager
1238
1273
  * @returns {IManager} The manager instance.
1239
1274
  */
1240
- manager(): IManager,
1275
+ manager(): IManager<TEventEmitter>,
1241
1276
  /**
1242
1277
  * User consent API.
1243
1278
  * @property UserConsent
@@ -1369,10 +1404,9 @@ declare namespace SplitIO {
1369
1404
  * This represents the interface for the Client instance on client-side, where the user key is bound to the instance on creation and does not need to be provided on each method call.
1370
1405
  * This interface is the default when importing the SDK in the Browser, or when importing the 'client' sub-package (e.g., `import { SplitFactory } from '@splitsoftware/splitio/client'`).
1371
1406
  *
1372
- * @interface IBrowserClient
1373
- * @extends IBasicClient
1407
+ * @typedef IBrowserClient
1374
1408
  */
1375
- interface IBrowserClient extends IBasicClient {
1409
+ type IBrowserClient<TEventEmitter extends IEventEmitter = EventEmitter> = IBasicClient<TEventEmitter> & {
1376
1410
  /**
1377
1411
  * Returns a Treatment value, which is the treatment string for the given feature.
1378
1412
  *
@@ -1603,10 +1637,9 @@ declare namespace SplitIO {
1603
1637
  }
1604
1638
  /**
1605
1639
  * Representation of a manager instance with synchronous storage of the SDK.
1606
- * @interface IManager
1607
- * @extends IStatusInterface
1640
+ * @typedef IManager
1608
1641
  */
1609
- interface IManager extends IStatusInterface {
1642
+ type IManager<TEventEmitter extends IEventEmitter = EventEmitter> = IStatusInterface<TEventEmitter> & {
1610
1643
  /**
1611
1644
  * Get the array of feature flag names.
1612
1645
  * @function names