@splitsoftware/splitio-commons 2.5.0 → 2.5.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGES.txt +12 -0
  2. package/README.md +18 -18
  3. package/cjs/logger/messages/info.js +1 -1
  4. package/cjs/sdkFactory/index.js +1 -1
  5. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +16 -16
  6. package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +17 -17
  7. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +33 -37
  8. package/cjs/storages/inLocalStorage/index.js +31 -13
  9. package/cjs/storages/inLocalStorage/storageAdapter.js +54 -0
  10. package/cjs/storages/inLocalStorage/validateCache.js +28 -23
  11. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
  12. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -0
  13. package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -0
  14. package/cjs/sync/syncManagerOnline.js +28 -24
  15. package/cjs/utils/env/isLocalStorageAvailable.js +22 -1
  16. package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
  17. package/esm/logger/messages/info.js +1 -1
  18. package/esm/sdkFactory/index.js +1 -1
  19. package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +16 -16
  20. package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +17 -17
  21. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +33 -37
  22. package/esm/storages/inLocalStorage/index.js +32 -14
  23. package/esm/storages/inLocalStorage/storageAdapter.js +50 -0
  24. package/esm/storages/inLocalStorage/validateCache.js +28 -23
  25. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
  26. package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -0
  27. package/esm/sync/polling/updaters/splitChangesUpdater.js +2 -0
  28. package/esm/sync/syncManagerOnline.js +28 -24
  29. package/esm/utils/env/isLocalStorageAvailable.js +19 -0
  30. package/esm/utils/settingsValidation/storage/storageCS.js +1 -1
  31. package/package.json +1 -1
  32. package/src/logger/messages/info.ts +1 -1
  33. package/src/sdkFactory/index.ts +1 -1
  34. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +18 -17
  35. package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +19 -18
  36. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +34 -37
  37. package/src/storages/inLocalStorage/index.ts +37 -16
  38. package/src/storages/inLocalStorage/storageAdapter.ts +62 -0
  39. package/src/storages/inLocalStorage/validateCache.ts +29 -23
  40. package/src/storages/types.ts +19 -1
  41. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +1 -2
  42. package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -0
  43. package/src/sync/polling/updaters/splitChangesUpdater.ts +3 -1
  44. package/src/sync/syncManagerOnline.ts +27 -22
  45. package/src/utils/env/isLocalStorageAvailable.ts +20 -0
  46. package/src/utils/settingsValidation/storage/storageCS.ts +1 -1
  47. package/types/splitio.d.ts +52 -22
@@ -132,7 +132,7 @@ interface IPluggableSharedSettings {
132
132
  /**
133
133
  * Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object.
134
134
  * Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes.
135
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}.
135
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/browser-sdk/#logging}.
136
136
  *
137
137
  * Examples:
138
138
  * ```
@@ -179,7 +179,7 @@ interface IServerSideSharedSettings {
179
179
  /**
180
180
  * Your SDK key.
181
181
  *
182
- * @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
182
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/account-settings/api-keys/}
183
183
  */
184
184
  authorizationKey: string;
185
185
  /**
@@ -282,7 +282,7 @@ interface IServerSideSharedSettings {
282
282
  eventsQueueSize?: number;
283
283
  /**
284
284
  * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
285
- * For more information see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
285
+ * For more information see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/nodejs-sdk/#localhost-mode}
286
286
  *
287
287
  * @defaultValue `15`
288
288
  */
@@ -297,7 +297,7 @@ interface IServerSideSharedSettings {
297
297
  };
298
298
  /**
299
299
  * Mocked features file path. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
300
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
300
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/nodejs-sdk/#localhost-mode}
301
301
  *
302
302
  * @defaultValue `'$HOME/.split'`
303
303
  */
@@ -314,13 +314,13 @@ interface IClientSideSharedSettings {
314
314
  /**
315
315
  * Your SDK key.
316
316
  *
317
- * @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
317
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/account-settings/api-keys/}
318
318
  */
319
319
  authorizationKey: string;
320
320
  /**
321
321
  * Customer identifier. Whatever this means to you.
322
322
  *
323
- * @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
323
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/fme-settings/traffic-types/}
324
324
  */
325
325
  key: SplitIO.SplitKey;
326
326
  /**
@@ -347,7 +347,7 @@ interface IClientSideSharedSettings {
347
347
  interface IClientSideSyncSharedSettings extends IClientSideSharedSettings, ISyncSharedSettings {
348
348
  /**
349
349
  * Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
350
- * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
350
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#localhost-mode}
351
351
  */
352
352
  features?: SplitIO.MockedFeaturesMap;
353
353
  /**
@@ -442,7 +442,7 @@ interface IClientSideSyncSharedSettings extends IClientSideSharedSettings, ISync
442
442
  eventsQueueSize?: number;
443
443
  /**
444
444
  * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
445
- * For more information see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
445
+ * For more information see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#localhost-mode}
446
446
  *
447
447
  * @defaultValue `15`
448
448
  */
@@ -463,6 +463,24 @@ interface IClientSideSyncSharedSettings extends IClientSideSharedSettings, ISync
463
463
  */
464
464
  declare namespace SplitIO {
465
465
 
466
+ interface StorageWrapper {
467
+ /**
468
+ * Returns the value associated with the given key, or null if the key does not exist.
469
+ * If the operation is asynchronous, returns a Promise.
470
+ */
471
+ getItem(key: string): string | null | Promise<string | null>;
472
+ /**
473
+ * Sets the value for the given key, creating a new key/value pair if key does not exist.
474
+ * If the operation is asynchronous, returns a Promise.
475
+ */
476
+ setItem(key: string, value: string): void | Promise<void>;
477
+ /**
478
+ * Removes the key/value pair for the given key, if the key exists.
479
+ * If the operation is asynchronous, returns a Promise.
480
+ */
481
+ removeItem(key: string): void | Promise<void>;
482
+ }
483
+
466
484
  /**
467
485
  * EventEmitter interface based on a subset of the Node.js EventEmitter methods.
468
486
  */
@@ -776,7 +794,7 @@ declare namespace SplitIO {
776
794
  /**
777
795
  * Attributes should be on object with values of type string, boolean, number (dates should be sent as millis since epoch) or array of strings or numbers.
778
796
  *
779
- * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax}
797
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#attribute-syntax}
780
798
  */
781
799
  type Attributes = {
782
800
  [attributeName: string]: AttributeType;
@@ -788,7 +806,7 @@ declare namespace SplitIO {
788
806
  /**
789
807
  * Properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb.
790
808
  *
791
- * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track}
809
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#track}
792
810
  */
793
811
  type Properties = {
794
812
  [propertyName: string]: string | number | boolean | null;
@@ -978,6 +996,12 @@ declare namespace SplitIO {
978
996
  * @defaultValue `false`
979
997
  */
980
998
  clearOnInit?: boolean;
999
+ /**
1000
+ * Optional storage wrapper to persist rollout plan related data. If not provided, the SDK will use the default localStorage Web API.
1001
+ *
1002
+ * @defaultValue `window.localStorage`
1003
+ */
1004
+ wrapper?: StorageWrapper;
981
1005
  }
982
1006
  /**
983
1007
  * Storage for asynchronous (consumer) SDK.
@@ -1052,7 +1076,7 @@ declare namespace SplitIO {
1052
1076
  * Impression listener interface. This is the interface that needs to be implemented
1053
1077
  * by the element you provide to the SDK as impression listener.
1054
1078
  *
1055
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#listener}
1079
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/nodejs-sdk/#listener}
1056
1080
  */
1057
1081
  interface IImpressionListener {
1058
1082
  logImpression(data: ImpressionData): void;
@@ -1187,7 +1211,7 @@ declare namespace SplitIO {
1187
1211
  /**
1188
1212
  * Settings interface for Browser SDK instances created with client-side API and synchronous storage (e.g., in-memory or local storage).
1189
1213
  *
1190
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
1214
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/browser-sdk/#configuration}
1191
1215
  */
1192
1216
  interface IClientSideSettings extends IClientSideSyncSharedSettings, IPluggableSharedSettings {
1193
1217
  /**
@@ -1208,20 +1232,20 @@ declare namespace SplitIO {
1208
1232
  /**
1209
1233
  * Settings interface for React Native SDK instances, with client-side API and synchronous storage.
1210
1234
  *
1211
- * @see {@link https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK#configuration}
1235
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/react-native-sdk/#configuration}
1212
1236
  */
1213
1237
  interface IReactNativeSettings extends IClientSideSettings { }
1214
1238
  /**
1215
1239
  * Settings interface for Browser SDK instances created with client-side API and asynchronous storage (e.g., serverless environments with a persistent storage).
1216
1240
  * If your storage is synchronous (by default we use memory, which is sync) use SplitIO.IClientSideSettings instead.
1217
1241
  *
1218
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage}
1242
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/browser-sdk/#sharing-state-with-a-pluggable-storage}
1219
1243
  */
1220
1244
  interface IClientSideAsyncSettings extends IClientSideSharedSettings, ISharedSettings, IPluggableSharedSettings {
1221
1245
  /**
1222
1246
  * The SDK mode. When using `PluggableStorage` as storage, the possible values are "consumer" and "consumer_partial".
1223
1247
  *
1224
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage}
1248
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/browser-sdk/#sharing-state-with-a-pluggable-storage}
1225
1249
  */
1226
1250
  mode: 'consumer' | 'consumer_partial';
1227
1251
  /**
@@ -1307,7 +1331,7 @@ declare namespace SplitIO {
1307
1331
  /**
1308
1332
  * Settings interface for JavaScript SDK instances created on the browser, with client-side API and synchronous storage (e.g., in-memory or local storage).
1309
1333
  *
1310
- * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
1334
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#configuration}
1311
1335
  */
1312
1336
  interface IBrowserSettings extends IClientSideSyncSharedSettings, INonPluggableSharedSettings {
1313
1337
  /**
@@ -1339,13 +1363,19 @@ declare namespace SplitIO {
1339
1363
  * @defaultValue `false`
1340
1364
  */
1341
1365
  clearOnInit?: boolean;
1366
+ /**
1367
+ * Optional storage wrapper to persist rollout plan related data. If not provided, the SDK will use the default localStorage Web API.
1368
+ *
1369
+ * @defaultValue `window.localStorage`
1370
+ */
1371
+ wrapper?: StorageWrapper;
1342
1372
  };
1343
1373
  }
1344
1374
  /**
1345
1375
  * Settings interface for JavaScript SDK instances created on Node.js, with server-side API and synchronous in-memory storage.
1346
1376
  * If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
1347
1377
  *
1348
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1378
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/nodejs-sdk/#configuration}
1349
1379
  */
1350
1380
  interface INodeSettings extends IServerSideSharedSettings, ISyncSharedSettings, INonPluggableSharedSettings {
1351
1381
  /**
@@ -1432,13 +1462,13 @@ declare namespace SplitIO {
1432
1462
  * Settings interface for JavaScript SDK instances created on Node.js, with asynchronous storage like Redis.
1433
1463
  * If your storage is synchronous (by default we use memory, which is sync) use SplitIO.INodeSettings instead.
1434
1464
  *
1435
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1465
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/nodejs-sdk/#configuration}
1436
1466
  */
1437
1467
  interface INodeAsyncSettings extends IServerSideSharedSettings, ISharedSettings, INonPluggableSharedSettings {
1438
1468
  /**
1439
1469
  * The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
1440
1470
  *
1441
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
1471
+ * @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/nodejs-sdk/#state-sharing-redis-integration}
1442
1472
  */
1443
1473
  mode: 'consumer';
1444
1474
  /**
@@ -1712,7 +1742,7 @@ declare namespace SplitIO {
1712
1742
  * Tracks an event to be fed to the results product on Split user interface.
1713
1743
  *
1714
1744
  * @param key - The key that identifies the entity related to this event.
1715
- * @param trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1745
+ * @param trafficType - The traffic type of the entity related to this event. See {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/fme-settings/traffic-types/}
1716
1746
  * @param eventType - The event type corresponding to this event.
1717
1747
  * @param value - The value of this event.
1718
1748
  * @param properties - The properties of this event. Values can be string, number, boolean or null.
@@ -1810,7 +1840,7 @@ declare namespace SplitIO {
1810
1840
  * 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).
1811
1841
  *
1812
1842
  * @param key - The key that identifies the entity related to this event.
1813
- * @param trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1843
+ * @param trafficType - The traffic type of the entity related to this event. See {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/fme-settings/traffic-types/}
1814
1844
  * @param eventType - The event type corresponding to this event.
1815
1845
  * @param value - The value of this event.
1816
1846
  * @param properties - The properties of this event. Values can be string, number, boolean or null.
@@ -1940,7 +1970,7 @@ declare namespace SplitIO {
1940
1970
  /**
1941
1971
  * Tracks an event to be fed to the results product on Split user interface.
1942
1972
  *
1943
- * @param trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1973
+ * @param trafficType - The traffic type of the entity related to this event. See {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/fme-settings/traffic-types/}
1944
1974
  * @param eventType - The event type corresponding to this event.
1945
1975
  * @param value - The value of this event.
1946
1976
  * @param properties - The properties of this event. Values can be string, number, boolean or null.