@splitsoftware/splitio-commons 1.15.1-rc.0 → 1.15.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.
package/CHANGES.txt CHANGED
@@ -1,4 +1,5 @@
1
1
  1.15.1 (May 28, 2024)
2
+ - Updated the Redis storage to lazily import the `ioredis` dependency when the storage is created. This prevents errors when the SDK is imported or bundled in a .mjs file, as `ioredis` is a CommonJS module.
2
3
  - Bugfixing - Restored some input validation error logs that were removed in version 1.12.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
3
4
 
4
5
  1.15.0 (May 13, 2024)
@@ -165,6 +165,7 @@ function clientFactory(params) {
165
165
  getTreatmentsByFlagSet: getTreatmentsByFlagSet,
166
166
  getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
167
167
  track: track,
168
+ isClientSide: false
168
169
  };
169
170
  }
170
171
  exports.clientFactory = clientFactory;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InRedisStorage = void 0;
4
- var RedisAdapter_1 = require("./RedisAdapter");
5
4
  var KeyBuilder_1 = require("../KeyBuilder");
6
5
  var KeyBuilderSS_1 = require("../KeyBuilderSS");
7
6
  var SplitsCacheInRedis_1 = require("./SplitsCacheInRedis");
@@ -19,12 +18,15 @@ var utils_1 = require("../utils");
19
18
  */
20
19
  function InRedisStorage(options) {
21
20
  if (options === void 0) { options = {}; }
21
+ // Lazy loading to prevent error when bundling or importing the SDK in a .mjs file, since ioredis is a CommonJS module.
22
+ // Redis storage is not supported with .mjs files.
23
+ var RD = require('./RedisAdapter').RedisAdapter;
22
24
  var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
23
25
  function InRedisStorageFactory(params) {
24
26
  var onReadyCb = params.onReadyCb, settings = params.settings, _a = params.settings, log = _a.log, impressionsMode = _a.sync.impressionsMode;
25
27
  var metadata = (0, utils_1.metadataBuilder)(settings);
26
28
  var keys = new KeyBuilderSS_1.KeyBuilderSS(prefix, metadata);
27
- var redisClient = new RedisAdapter_1.RedisAdapter(log, options.options || {});
29
+ var redisClient = new RD(log, options.options || {});
28
30
  var telemetry = new TelemetryCacheInRedis_1.TelemetryCacheInRedis(log, keys, redisClient);
29
31
  var impressionCountsCache = impressionsMode !== constants_1.DEBUG ? new ImpressionCountsCacheInRedis_1.ImpressionCountsCacheInRedis(log, keys.buildImpressionsCountKey(), redisClient) : undefined;
30
32
  var uniqueKeysCache = impressionsMode === constants_1.NONE ? new UniqueKeysCacheInRedis_1.UniqueKeysCacheInRedis(log, keys.buildUniqueKeysKey(), redisClient) : undefined;
@@ -162,5 +162,6 @@ export function clientFactory(params) {
162
162
  getTreatmentsByFlagSet: getTreatmentsByFlagSet,
163
163
  getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
164
164
  track: track,
165
+ isClientSide: false
165
166
  };
166
167
  }
@@ -1,4 +1,3 @@
1
- import { RedisAdapter } from './RedisAdapter';
2
1
  import { validatePrefix } from '../KeyBuilder';
3
2
  import { KeyBuilderSS } from '../KeyBuilderSS';
4
3
  import { SplitsCacheInRedis } from './SplitsCacheInRedis';
@@ -16,12 +15,15 @@ import { metadataBuilder } from '../utils';
16
15
  */
17
16
  export function InRedisStorage(options) {
18
17
  if (options === void 0) { options = {}; }
18
+ // Lazy loading to prevent error when bundling or importing the SDK in a .mjs file, since ioredis is a CommonJS module.
19
+ // Redis storage is not supported with .mjs files.
20
+ var RD = require('./RedisAdapter').RedisAdapter;
19
21
  var prefix = validatePrefix(options.prefix);
20
22
  function InRedisStorageFactory(params) {
21
23
  var onReadyCb = params.onReadyCb, settings = params.settings, _a = params.settings, log = _a.log, impressionsMode = _a.sync.impressionsMode;
22
24
  var metadata = metadataBuilder(settings);
23
25
  var keys = new KeyBuilderSS(prefix, metadata);
24
- var redisClient = new RedisAdapter(log, options.options || {});
26
+ var redisClient = new RD(log, options.options || {});
25
27
  var telemetry = new TelemetryCacheInRedis(log, keys, redisClient);
26
28
  var impressionCountsCache = impressionsMode !== DEBUG ? new ImpressionCountsCacheInRedis(log, keys.buildImpressionsCountKey(), redisClient) : undefined;
27
29
  var uniqueKeysCache = impressionsMode === NONE ? new UniqueKeysCacheInRedis(log, keys.buildUniqueKeysKey(), redisClient) : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.15.1-rc.0",
3
+ "version": "1.15.1-rc.1",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -199,5 +199,6 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
199
199
  getTreatmentsByFlagSet,
200
200
  getTreatmentsWithConfigByFlagSet,
201
201
  track,
202
+ isClientSide: false
202
203
  } as SplitIO.IClient | SplitIO.IAsyncClient;
203
204
  }
@@ -1,4 +1,4 @@
1
- import { RedisAdapter } from './RedisAdapter';
1
+ import type { RedisAdapter } from './RedisAdapter';
2
2
  import { IStorageAsync, IStorageAsyncFactory, IStorageFactoryParams } from '../types';
3
3
  import { validatePrefix } from '../KeyBuilder';
4
4
  import { KeyBuilderSS } from '../KeyBuilderSS';
@@ -23,13 +23,17 @@ export interface InRedisStorageOptions {
23
23
  */
24
24
  export function InRedisStorage(options: InRedisStorageOptions = {}): IStorageAsyncFactory {
25
25
 
26
+ // Lazy loading to prevent error when bundling or importing the SDK in a .mjs file, since ioredis is a CommonJS module.
27
+ // Redis storage is not supported with .mjs files.
28
+ const RD = require('./RedisAdapter').RedisAdapter;
29
+
26
30
  const prefix = validatePrefix(options.prefix);
27
31
 
28
32
  function InRedisStorageFactory(params: IStorageFactoryParams): IStorageAsync {
29
33
  const { onReadyCb, settings, settings: { log, sync: { impressionsMode } } } = params;
30
34
  const metadata = metadataBuilder(settings);
31
35
  const keys = new KeyBuilderSS(prefix, metadata);
32
- const redisClient = new RedisAdapter(log, options.options || {});
36
+ const redisClient: RedisAdapter = new RD(log, options.options || {});
33
37
  const telemetry = new TelemetryCacheInRedis(log, keys, redisClient);
34
38
  const impressionCountsCache = impressionsMode !== DEBUG ? new ImpressionCountsCacheInRedis(log, keys.buildImpressionsCountKey(), redisClient) : undefined;
35
39
  const uniqueKeysCache = impressionsMode === NONE ? new UniqueKeysCacheInRedis(log, keys.buildUniqueKeysKey(), redisClient) : undefined;