-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove 'full' subpackage, since there is not significant diff…
…erence with the default 'slim' subpackage" This reverts commit 23668a9.
- Loading branch information
1 parent
558dd0a
commit 0ee9331
Showing
16 changed files
with
180 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"main": "../cjs/full/index.js", | ||
"module": "../esm/full/index.js", | ||
"types": "../types/full/index.d.ts", | ||
"sideEffects": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { SplitFactory } from './splitFactory'; | ||
export { InLocalStorage } from '@splitsoftware/splitio-commons/src/storages/inLocalStorage/index'; | ||
export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/ErrorLogger'; | ||
export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger'; | ||
export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger'; | ||
export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger'; | ||
export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import SplitIO from '@splitsoftware/splitio-commons/types/splitio'; | ||
import { settingsFactory } from '../settings/full'; | ||
import { getModules } from '../platform/getModules'; | ||
import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; | ||
import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; | ||
import { getFetch } from '../platform/getFetchFull'; | ||
import { getEventSource } from '../platform/getEventSource'; | ||
import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents'; | ||
import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser'; | ||
|
||
const platform = { getFetch, getEventSource, EventEmitter, now }; | ||
|
||
/** | ||
* SplitFactory with pluggable modules for Browser. | ||
* Includes fetch polyfill out-of-the-box. | ||
* | ||
* @param config - configuration object used to instantiate the SDK | ||
* @param __updateModules - optional function that lets redefine internal SDK modules. Use with | ||
* caution since, unlike `config`, this param is not validated neither considered part of the public API. | ||
* @throws Will throw an error if the provided config is invalid. | ||
*/ | ||
export function SplitFactory(config: SplitIO.IClientSideSettings, __updateModules?: (modules: ISdkFactoryParams) => void) { | ||
const settings = settingsFactory(config); | ||
const modules = getModules(settings, platform); | ||
if (__updateModules) __updateModules(modules); | ||
return sdkFactory(modules); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { IFetch } from '@splitsoftware/splitio-commons/src/services/types'; | ||
import unfetch from 'unfetch'; | ||
|
||
export function getFetch() { | ||
return typeof fetch === 'function' ? fetch : unfetch as unknown as IFetch; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import { settingsFactory } from '../index'; | ||
import { settingsFactory as slimSettingsFactory } from '../index'; | ||
import { settingsFactory as fullSettingsFactory } from '../full'; | ||
|
||
test('SETTINGS / Consent is overwritable and "GRANTED" by default', () => { | ||
let settings = settingsFactory({}); | ||
expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if not provided | ||
[slimSettingsFactory, fullSettingsFactory].forEach((settingsFactory) => { | ||
let settings = settingsFactory({}); | ||
expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if not provided | ||
|
||
settings = settingsFactory({ userConsent: 'INVALID-VALUE' }); | ||
expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if a wrong value is provided | ||
settings = settingsFactory({ userConsent: 'INVALID-VALUE' }); | ||
expect(settings.userConsent).toEqual('GRANTED'); // userConsent defaults to granted if a wrong value is provided | ||
|
||
settings = settingsFactory({ userConsent: 'UNKNOWN' }); | ||
expect(settings.userConsent).toEqual('UNKNOWN'); // userConsent can be overwritten | ||
settings = settingsFactory({ userConsent: 'UNKNOWN' }); | ||
expect(settings.userConsent).toEqual('UNKNOWN'); // userConsent can be overwritten | ||
|
||
settings = settingsFactory({ userConsent: 'declined' }); | ||
expect(settings.userConsent).toEqual('DECLINED'); // userConsent can be overwritten | ||
settings = settingsFactory({ userConsent: 'declined' }); | ||
expect(settings.userConsent).toEqual('DECLINED'); // userConsent can be overwritten | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/index'; | ||
import { defaults } from './defaults'; | ||
import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime'; | ||
import { validateStorageCS } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS'; | ||
import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/integrations/pluggable'; | ||
import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/pluggableLogger'; | ||
import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent'; | ||
|
||
const params = { | ||
defaults, | ||
acceptKey: true, // Client with bound key | ||
runtime: validateRuntime, | ||
storage: validateStorageCS, | ||
integrations: validatePluggableIntegrations, | ||
logger: validateLogger, | ||
consent: validateConsent, | ||
}; | ||
|
||
export function settingsFactory(config: any) { | ||
const settings = settingsValidation(config, params); | ||
|
||
return settings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Declaration file for JavaScript Browser Split Software SDK | ||
// Project: http://www.split.io/ | ||
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/> | ||
|
||
import '@splitsoftware/splitio-commons'; | ||
|
||
export = JsSdk; | ||
|
||
declare module JsSdk { | ||
/** | ||
* Full version of the Split.io SDK factory function. | ||
* | ||
* Unlike the default version, it includes a `fetch` polyfill to support old browsers @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#language-support}. | ||
* | ||
* The settings parameter should be an object that complies with the SplitIO.IClientSideSettings or SplitIO.IClientSideAsyncSettings interfaces. | ||
* For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration} | ||
*/ | ||
export function SplitFactory(settings: SplitIO.IClientSideSettings): SplitIO.ISDK; | ||
export function SplitFactory(settings: SplitIO.IClientSideAsyncSettings): SplitIO.IAsyncSDK; | ||
|
||
/** | ||
* Persistent storage based on the LocalStorage Web API for browsers. | ||
* | ||
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#storage} | ||
*/ | ||
export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory; | ||
|
||
/** | ||
* Pluggable storage to use the SDK in consumer mode. | ||
* | ||
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage} | ||
*/ | ||
export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory; | ||
|
||
/** | ||
* Creates a logger instance that enables descriptive log messages with DEBUG log level when passed in the factory settings. | ||
* | ||
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} | ||
*/ | ||
export function DebugLogger(): SplitIO.ILogger; | ||
|
||
/** | ||
* Creates a logger instance that enables descriptive log messages with INFO log level when passed in the factory settings. | ||
* | ||
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} | ||
*/ | ||
export function InfoLogger(): SplitIO.ILogger; | ||
|
||
/** | ||
* Creates a logger instance that enables descriptive log messages with WARN log level when passed in the factory settings. | ||
* | ||
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} | ||
*/ | ||
export function WarnLogger(): SplitIO.ILogger; | ||
|
||
/** | ||
* Creates a logger instance that enables descriptive log messages with ERROR log level when passed in the factory settings. | ||
* | ||
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} | ||
*/ | ||
export function ErrorLogger(): SplitIO.ILogger; | ||
} |