Skip to content

Commit

Permalink
Merge pull request #361 from splitio/remove_pluggable_localhost_mode
Browse files Browse the repository at this point in the history
Remove pluggable localhost modules and validation.
  • Loading branch information
EmilianoSanchez authored Oct 31, 2024
2 parents e79229a + b415e43 commit c1f766f
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 133 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Removed the migration logic for the old format of MySegments keys in LocalStorage introduced in JavaScript SDK v10.17.3.
- 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.
- 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.
- Removed the `sync.localhostMode` configuration option to plug the LocalhostMode module.

1.17.0 (September 6, 2024)
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "2.0.0-rc.1",
"version": "2.0.0-rc.3",
"description": "Split JavaScript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
1 change: 0 additions & 1 deletion src/logger/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const ERROR_EMPTY = 319;
export const ERROR_EMPTY_ARRAY = 320;
export const ERROR_INVALID_CONFIG_PARAM = 321;
export const ERROR_HTTP = 322;
export const ERROR_LOCALHOST_MODULE_REQUIRED = 323;
export const ERROR_STORAGE_INVALID = 324;
export const ERROR_NOT_BOOLEAN = 325;
export const ERROR_MIN_CONFIG_PARAM = 326;
Expand Down
1 change: 0 additions & 1 deletion src/logger/messages/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const codesError: [number, string][] = [
[c.ERROR_NOT_BOOLEAN, '%s: provided param must be a boolean value.'],
// initialization / settings validation
[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".'],
[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.'],
[c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS+': the provided storage is invalid.%s Falling back into default MEMORY storage'],
[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'],
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
Expand Down
10 changes: 2 additions & 8 deletions src/sync/offline/LocalhostFromObject.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { splitsParserFromSettingsFactory } from './splitsParser/splitsParserFromSettings';
import { syncManagerOfflineFactory } from './syncManagerOffline';
import { SplitIO } from '../../types';

// Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
// Singleton instance of the factory function for offline SyncManager from object
// SDK instances instantiate their SyncManagers with the same factory
const localhostFromObject = syncManagerOfflineFactory(splitsParserFromSettingsFactory) as SplitIO.LocalhostFactory;
localhostFromObject.type = 'LocalhostFromObject';

export function LocalhostFromObject(): SplitIO.LocalhostFactory {
return localhostFromObject;
}
export const localhostFromObjectFactory = syncManagerOfflineFactory(splitsParserFromSettingsFactory);
13 changes: 1 addition & 12 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/* eslint-disable no-use-before-define */
import { ISplitFiltersValidation } from './dtos/types';
import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
import { ILogger } from './logger/types';
import { ISdkFactoryContext } from './sdkFactory/types';
/* eslint-disable no-use-before-define */

import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
import { ISyncManagerCS } from './sync/types';

/**
* Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
Expand Down Expand Up @@ -116,7 +113,6 @@ export interface ISettings {
splitFilters: SplitIO.SplitFilter[],
impressionsMode: SplitIO.ImpressionsMode,
__splitFiltersValidation: ISplitFiltersValidation,
localhostMode?: SplitIO.LocalhostFactory,
enabled: boolean,
flagSpecVersion: string,
requestOptions?: {
Expand Down Expand Up @@ -666,13 +662,6 @@ export namespace SplitIO {
* @typedef {Promise<SplitNames>} SplitNamesAsync
*/
export type SplitNamesAsync = Promise<SplitNames>;
/**
* Localhost mode factory.
*/
export type LocalhostFactory = {
type: 'LocalhostFromObject' | 'LocalhostFromFile'
(params: ISdkFactoryContext): ISyncManagerCS
}
/**
* Impression listener interface. This is the interface that needs to be implemented
* by the element you provide to the SDK as impression listener.
Expand Down
2 changes: 0 additions & 2 deletions src/utils/settingsValidation/__tests__/settings.mocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { InMemoryStorageCSFactory } from '../../../storages/inMemory/InMemoryStorageCS';
import { ISettings } from '../../../types';
import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';
import { LocalhostFromObject } from '../../../sync/offline/LocalhostFromObject';

export const settingsWithKey = {
core: {
Expand Down Expand Up @@ -62,7 +61,6 @@ export const fullSettings: ISettings = {
sync: {
splitFilters: [],
impressionsMode: 'OPTIMIZED',
localhostMode: LocalhostFromObject(),
__splitFiltersValidation: {
validFilters: [],
queryString: null,
Expand Down
5 changes: 1 addition & 4 deletions src/utils/settingsValidation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const base = {
splitFilters: undefined,
// impressions collection mode
impressionsMode: OPTIMIZED,
localhostMode: undefined,
enabled: true,
flagSpecVersion: FLAG_SPEC_VERSION
},
Expand All @@ -102,7 +101,7 @@ function fromSecondsToMillis(n: number) {
*/
export function settingsValidation(config: unknown, validationParams: ISettingsValidationParams) {

const { defaults, runtime, storage, integrations, logger, localhost, consent, flagSpec } = validationParams;
const { defaults, runtime, storage, integrations, logger, consent, flagSpec } = validationParams;

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

if (localhost) sync.localhostMode = localhost(withDefaults);

// validate push options
if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
withDefaults.streamingEnabled = true;
Expand Down
62 changes: 0 additions & 62 deletions src/utils/settingsValidation/localhost/__tests__/index.spec.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/utils/settingsValidation/localhost/builtin.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/utils/settingsValidation/localhost/pluggable.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/utils/settingsValidation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export interface ISettingsValidationParams {
integrations?: (settings: ISettings) => ISettings['integrations'],
/** Logger validator (`settings.debug`) */
logger: (settings: ISettings) => ISettings['log'],
/** Localhost mode validator (`settings.sync.localhostMode`) */
localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'],
/** User consent validator (`settings.userConsent`) */
consent?: (settings: ISettings) => ISettings['userConsent'],
/** Flag spec version validation. Configurable by the JS Synchronizer but not by the SDKs */
Expand Down

0 comments on commit c1f766f

Please sign in to comment.