Skip to content

Commit c1f766f

Browse files
Merge pull request #361 from splitio/remove_pluggable_localhost_mode
Remove pluggable localhost modules and validation.
2 parents e79229a + b415e43 commit c1f766f

File tree

13 files changed

+8
-133
lines changed

13 files changed

+8
-133
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Removed the migration logic for the old format of MySegments keys in LocalStorage introduced in JavaScript SDK v10.17.3.
1212
- Removed the `sdkClientMethodCSWithTT` function, which handled the logic to bound an optional traffic type to SDK clients. Client-side SDK implementations must use `sdkClientMethodCS` module, which, unlike the previous function, does not allow passing a traffic type but simplifies the SDK API.
1313
- Removed internal ponyfills for `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 to provide a polyfill.
14+
- Removed the `sync.localhostMode` configuration option to plug the LocalhostMode module.
1415

1516
1.17.0 (September 6, 2024)
1617
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "2.0.0-rc.1",
3+
"version": "2.0.0-rc.3",
44
"description": "Split JavaScript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

src/logger/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export const ERROR_EMPTY = 319;
109109
export const ERROR_EMPTY_ARRAY = 320;
110110
export const ERROR_INVALID_CONFIG_PARAM = 321;
111111
export const ERROR_HTTP = 322;
112-
export const ERROR_LOCALHOST_MODULE_REQUIRED = 323;
113112
export const ERROR_STORAGE_INVALID = 324;
114113
export const ERROR_NOT_BOOLEAN = 325;
115114
export const ERROR_MIN_CONFIG_PARAM = 326;

src/logger/messages/error.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const codesError: [number, string][] = [
3232
[c.ERROR_NOT_BOOLEAN, '%s: provided param must be a boolean value.'],
3333
// initialization / settings validation
3434
[c.ERROR_INVALID_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "%s" config param. It should be one of the following values: %s. Defaulting to "%s".'],
35-
[c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
3635
[c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS+': the provided storage is invalid.%s Falling back into default MEMORY storage'],
3736
[c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
3837
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { splitsParserFromSettingsFactory } from './splitsParser/splitsParserFromSettings';
22
import { syncManagerOfflineFactory } from './syncManagerOffline';
3-
import { SplitIO } from '../../types';
43

5-
// Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
4+
// Singleton instance of the factory function for offline SyncManager from object
65
// SDK instances instantiate their SyncManagers with the same factory
7-
const localhostFromObject = syncManagerOfflineFactory(splitsParserFromSettingsFactory) as SplitIO.LocalhostFactory;
8-
localhostFromObject.type = 'LocalhostFromObject';
9-
10-
export function LocalhostFromObject(): SplitIO.LocalhostFactory {
11-
return localhostFromObject;
12-
}
6+
export const localhostFromObjectFactory = syncManagerOfflineFactory(splitsParserFromSettingsFactory);

src/types.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
/* eslint-disable no-use-before-define */
12
import { ISplitFiltersValidation } from './dtos/types';
23
import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
34
import { ILogger } from './logger/types';
4-
import { ISdkFactoryContext } from './sdkFactory/types';
5-
/* eslint-disable no-use-before-define */
6-
75
import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
8-
import { ISyncManagerCS } from './sync/types';
96

107
/**
118
* Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
@@ -116,7 +113,6 @@ export interface ISettings {
116113
splitFilters: SplitIO.SplitFilter[],
117114
impressionsMode: SplitIO.ImpressionsMode,
118115
__splitFiltersValidation: ISplitFiltersValidation,
119-
localhostMode?: SplitIO.LocalhostFactory,
120116
enabled: boolean,
121117
flagSpecVersion: string,
122118
requestOptions?: {
@@ -666,13 +662,6 @@ export namespace SplitIO {
666662
* @typedef {Promise<SplitNames>} SplitNamesAsync
667663
*/
668664
export type SplitNamesAsync = Promise<SplitNames>;
669-
/**
670-
* Localhost mode factory.
671-
*/
672-
export type LocalhostFactory = {
673-
type: 'LocalhostFromObject' | 'LocalhostFromFile'
674-
(params: ISdkFactoryContext): ISyncManagerCS
675-
}
676665
/**
677666
* Impression listener interface. This is the interface that needs to be implemented
678667
* by the element you provide to the SDK as impression listener.

src/utils/settingsValidation/__tests__/settings.mocks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { InMemoryStorageCSFactory } from '../../../storages/inMemory/InMemoryStorageCS';
22
import { ISettings } from '../../../types';
33
import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';
4-
import { LocalhostFromObject } from '../../../sync/offline/LocalhostFromObject';
54

65
export const settingsWithKey = {
76
core: {
@@ -62,7 +61,6 @@ export const fullSettings: ISettings = {
6261
sync: {
6362
splitFilters: [],
6463
impressionsMode: 'OPTIMIZED',
65-
localhostMode: LocalhostFromObject(),
6664
__splitFiltersValidation: {
6765
validFilters: [],
6866
queryString: null,

src/utils/settingsValidation/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export const base = {
8080
splitFilters: undefined,
8181
// impressions collection mode
8282
impressionsMode: OPTIMIZED,
83-
localhostMode: undefined,
8483
enabled: true,
8584
flagSpecVersion: FLAG_SPEC_VERSION
8685
},
@@ -102,7 +101,7 @@ function fromSecondsToMillis(n: number) {
102101
*/
103102
export function settingsValidation(config: unknown, validationParams: ISettingsValidationParams) {
104103

105-
const { defaults, runtime, storage, integrations, logger, localhost, consent, flagSpec } = validationParams;
104+
const { defaults, runtime, storage, integrations, logger, consent, flagSpec } = validationParams;
106105

107106
// creates a settings object merging base, defaults and config objects.
108107
const withDefaults = merge({}, base, defaults, config) as ISettings;
@@ -180,8 +179,6 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
180179
// @ts-ignore, modify readonly prop
181180
if (integrations) withDefaults.integrations = integrations(withDefaults);
182181

183-
if (localhost) sync.localhostMode = localhost(withDefaults);
184-
185182
// validate push options
186183
if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
187184
withDefaults.streamingEnabled = true;

src/utils/settingsValidation/localhost/__tests__/index.spec.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)