@splitsoftware/splitio-commons 2.0.0-rc.2 → 2.0.0-rc.3
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 +1 -3
- package/cjs/logger/constants.js +1 -2
- package/cjs/logger/messages/error.js +0 -1
- package/cjs/sdkFactory/index.js +1 -3
- package/cjs/storages/dataLoader.js +37 -99
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/cjs/sync/offline/LocalhostFromObject.js +3 -8
- package/cjs/utils/settingsValidation/index.js +1 -4
- package/esm/logger/constants.js +0 -1
- package/esm/logger/messages/error.js +0 -1
- package/esm/sdkFactory/index.js +2 -4
- package/esm/storages/dataLoader.js +35 -96
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/esm/sync/offline/LocalhostFromObject.js +2 -6
- package/esm/utils/settingsValidation/index.js +1 -4
- package/package.json +1 -1
- package/src/logger/constants.ts +0 -1
- package/src/logger/messages/error.ts +0 -1
- package/src/sdkFactory/index.ts +3 -6
- package/src/storages/dataLoader.ts +38 -97
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
- package/src/storages/types.ts +2 -4
- package/src/sync/offline/LocalhostFromObject.ts +2 -8
- package/src/types.ts +14 -26
- package/src/utils/settingsValidation/index.ts +1 -4
- package/src/utils/settingsValidation/types.ts +0 -2
- package/types/logger/constants.d.ts +0 -1
- package/types/storages/dataLoader.d.ts +6 -17
- package/types/storages/types.d.ts +1 -4
- package/types/sync/offline/LocalhostFromObject.d.ts +1 -2
- package/types/types.d.ts +13 -23
- package/types/utils/settingsValidation/index.d.ts +0 -1
- package/types/utils/settingsValidation/types.d.ts +0 -2
- package/cjs/utils/settingsValidation/localhost/builtin.js +0 -18
- package/cjs/utils/settingsValidation/localhost/pluggable.js +0 -22
- package/esm/utils/settingsValidation/localhost/builtin.js +0 -14
- package/esm/utils/settingsValidation/localhost/pluggable.js +0 -18
- package/src/utils/settingsValidation/localhost/builtin.ts +0 -16
- package/src/utils/settingsValidation/localhost/pluggable.ts +0 -22
- package/types/evaluator/matchers/sember_inlist.d.ts +0 -3
- package/types/evaluator/matchersTransform/set.d.ts +0 -5
- package/types/evaluator/matchersTransform/string.d.ts +0 -7
- package/types/integrations/browser.d.ts +0 -12
- package/types/integrations/ga/GaToSplit.d.ts +0 -40
- package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +0 -3
- package/types/integrations/ga/SplitToGa.d.ts +0 -34
- package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +0 -3
- package/types/integrations/ga/types.d.ts +0 -148
- package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +0 -8
- package/types/storages/AbstractSegmentsCacheSync.d.ts +0 -54
- package/types/storages/AbstractSplitsCache.d.ts +0 -46
- package/types/sync/streaming/mySegmentsV2utils.d.ts +0 -27
- package/types/sync/streaming/pushManagerCS_Spec1_3.d.ts +0 -9
- package/types/sync/streaming/pushManager_Spec1_3.d.ts +0 -9
- package/types/trackers/impressionObserver/utils.d.ts +0 -5
- package/types/utils/inputValidation/sdkKey.d.ts +0 -7
- package/types/utils/inputValidation/splitExistance.d.ts +0 -7
- package/types/utils/inputValidation/trafficTypeExistance.d.ts +0 -9
- package/types/utils/lang/maps.d.ts +0 -59
- package/types/utils/redis/RedisMock.d.ts +0 -4
- package/types/utils/settingsValidation/localhost/builtin.d.ts +0 -16
- package/types/utils/settingsValidation/localhost/pluggable.d.ts +0 -16
- package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +0 -8
- /package/types/utils/{semVer.d.ts → Semver.d.ts} +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ILogger } from '../../../logger/types';
|
|
2
|
-
import { SDKMode, } from '../../../types';
|
|
3
|
-
import { LocalhostFromObject } from '../../../sync/offline/LocalhostFromObject';
|
|
4
|
-
import { validateLocalhost } from './pluggable';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This function validates `settings.sync.localhostMode` object
|
|
8
|
-
*
|
|
9
|
-
* @param {any} settings config object provided by the user to initialize the sdk
|
|
10
|
-
*
|
|
11
|
-
* @returns {Object} provided localhost mode module at `settings.sync.localhostMode` if valid, or a default LocalhostFromObject instance if not provided or invalid
|
|
12
|
-
*/
|
|
13
|
-
export function validateLocalhostWithDefault(settings: { log: ILogger, sync: { localhostMode?: any }, mode: SDKMode }) {
|
|
14
|
-
if (!settings.sync.localhostMode) return LocalhostFromObject();
|
|
15
|
-
return validateLocalhost(settings) || LocalhostFromObject();
|
|
16
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ERROR_LOCALHOST_MODULE_REQUIRED } from '../../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../../logger/types';
|
|
3
|
-
import { SDKMode, } from '../../../types';
|
|
4
|
-
import { LOCALHOST_MODE } from '../../constants';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This function validates `settings.sync.localhostMode` object
|
|
8
|
-
*
|
|
9
|
-
* @param {any} settings config object provided by the user to initialize the sdk
|
|
10
|
-
*
|
|
11
|
-
* @returns {Object | undefined} provided localhost mode module at `settings.sync.localhostMode`, or undefined if it is not provided or invalid
|
|
12
|
-
*/
|
|
13
|
-
export function validateLocalhost(settings: { log: ILogger, sync: { localhostMode?: any}, mode: SDKMode }) {
|
|
14
|
-
const localhostMode = settings.sync.localhostMode;
|
|
15
|
-
|
|
16
|
-
// localhostMode.type is used for internal validation. Not considered part of the public API, and might be updated eventually.
|
|
17
|
-
if (settings.mode === LOCALHOST_MODE && (typeof localhostMode !== 'function' || localhostMode.type !== 'LocalhostFromObject')) {
|
|
18
|
-
settings.log.error(ERROR_LOCALHOST_MODULE_REQUIRED);
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return localhostMode;
|
|
22
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IIntegrationManager, IIntegrationFactoryParams } from './types';
|
|
2
|
-
import { BrowserIntegration } from './ga/types';
|
|
3
|
-
/**
|
|
4
|
-
* IntegrationsManager factory for the browser variant of the isomorphic JS SDK.
|
|
5
|
-
* The integrations manager instantiates integration modules, and bypass tracked events and impressions to them.
|
|
6
|
-
*
|
|
7
|
-
* @param integrations valid integration settings object for browser sdk
|
|
8
|
-
* @param params information of the Sdk factory instance that integrations can access to
|
|
9
|
-
*
|
|
10
|
-
* @returns integration manager or undefined if `integrations` are not present in settings.
|
|
11
|
-
*/
|
|
12
|
-
export declare function integrationsManagerFactory(integrations: BrowserIntegration[], params: IIntegrationFactoryParams): IIntegrationManager | undefined;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="google.analytics" />
|
|
2
|
-
import { SplitIO } from '../../types';
|
|
3
|
-
import { Identity, GoogleAnalyticsToSplitOptions } from './types';
|
|
4
|
-
import { ILogger } from '../../logger/types';
|
|
5
|
-
import { IIntegrationFactoryParams } from '../types';
|
|
6
|
-
export declare const defaultMapper: (model: UniversalAnalytics.Model) => SplitIO.EventData;
|
|
7
|
-
export declare const defaultPrefix = "ga";
|
|
8
|
-
/**
|
|
9
|
-
* Return a new list of identities removing invalid and duplicated ones.
|
|
10
|
-
*
|
|
11
|
-
* @param {Array} identities list of identities
|
|
12
|
-
* @returns list of valid and unique identities. The list might be empty if `identities` is not an array or all its elements are invalid.
|
|
13
|
-
*/
|
|
14
|
-
export declare function validateIdentities(identities?: Identity[]): Identity[];
|
|
15
|
-
/**
|
|
16
|
-
* Checks if EventData fields (except EventTypeId) are valid, and logs corresponding warnings.
|
|
17
|
-
* EventTypeId is validated separately.
|
|
18
|
-
*
|
|
19
|
-
* @param {EventData} data event data instance to validate. Precondition: data != undefined
|
|
20
|
-
* @returns {boolean} Whether the data instance is a valid EventData or not.
|
|
21
|
-
*/
|
|
22
|
-
export declare function validateEventData(log: ILogger, eventData: any): eventData is SplitIO.EventData;
|
|
23
|
-
/**
|
|
24
|
-
* Fixes the passed string value to comply with EventTypeId format, by removing invalid characters and truncating if necessary.
|
|
25
|
-
*
|
|
26
|
-
* @param {object} log factory logger
|
|
27
|
-
* @param {string} eventTypeId string value to fix.
|
|
28
|
-
* @returns {string} Fixed version of `eventTypeId`.
|
|
29
|
-
*/
|
|
30
|
-
export declare function fixEventTypeId(log: ILogger, eventTypeId: any): any;
|
|
31
|
-
/**
|
|
32
|
-
* GaToSplit integration.
|
|
33
|
-
* This function provides the SplitTracker plugin to ga command queue.
|
|
34
|
-
*
|
|
35
|
-
* @param {object} sdkOptions options passed at the SDK integrations settings (isomorphic SDK) or the GoogleAnalyticsToSplit plugin (pluggable browser SDK)
|
|
36
|
-
* @param {object} storage SDK storage passed to track events
|
|
37
|
-
* @param {object} coreSettings core settings used to define an identity if no one provided as SDK or plugin options
|
|
38
|
-
* @param {object} log factory logger
|
|
39
|
-
*/
|
|
40
|
-
export declare function GaToSplit(sdkOptions: GoogleAnalyticsToSplitOptions, params: IIntegrationFactoryParams): void;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="google.analytics" />
|
|
2
|
-
import { SplitIO } from '../../types';
|
|
3
|
-
import { IIntegration } from '../types';
|
|
4
|
-
import { SplitToGoogleAnalyticsOptions } from './types';
|
|
5
|
-
import { ILogger } from '../../logger/types';
|
|
6
|
-
export declare class SplitToGa implements IIntegration {
|
|
7
|
-
static defaultTrackerNames: string[];
|
|
8
|
-
private trackerNames;
|
|
9
|
-
private filter?;
|
|
10
|
-
private mapper?;
|
|
11
|
-
private impressions;
|
|
12
|
-
private events;
|
|
13
|
-
private log;
|
|
14
|
-
static defaultMapper({ type, payload }: SplitIO.IntegrationData): UniversalAnalytics.FieldsObject;
|
|
15
|
-
static getGa(): UniversalAnalytics.ga | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Validates if a given object is a UniversalAnalytics.FieldsObject instance, and logs a warning if not.
|
|
18
|
-
* It checks that the object contains a `hitType`, since it is the minimal field required to send the hit
|
|
19
|
-
* and avoid the GA error `No hit type specified. Aborting hit.`.
|
|
20
|
-
* Other validations (e.g., an `event` hitType must have a `eventCategory` and `eventAction`) are handled
|
|
21
|
-
* and logged (as warnings or errors depending the case) by GA debugger, but the hit is sent anyway.
|
|
22
|
-
*
|
|
23
|
-
* @param {object} log factory logger
|
|
24
|
-
* @param {UniversalAnalytics.FieldsObject} fieldsObject object to validate.
|
|
25
|
-
* @returns {boolean} Whether the data instance is a valid FieldsObject or not.
|
|
26
|
-
*/
|
|
27
|
-
static validateFieldsObject(log: ILogger, fieldsObject: any): fieldsObject is UniversalAnalytics.FieldsObject;
|
|
28
|
-
/**
|
|
29
|
-
* constructor description
|
|
30
|
-
* @param {object} options options passed at the SDK integrations settings (isomorphic SDK) or the SplitToGoogleAnalytics plugin (pluggable browser SDK)
|
|
31
|
-
*/
|
|
32
|
-
constructor(log: ILogger, options: SplitToGoogleAnalyticsOptions);
|
|
33
|
-
queue(data: SplitIO.IntegrationData): void;
|
|
34
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/// <reference types="google.analytics" />
|
|
2
|
-
import { SplitIO } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* A pair of user key and it's trafficType, required for tracking valid Split events.
|
|
5
|
-
* @typedef {Object} Identity
|
|
6
|
-
* @property {string} key The user key.
|
|
7
|
-
* @property {string} trafficType The key traffic type.
|
|
8
|
-
*/
|
|
9
|
-
export declare type Identity = {
|
|
10
|
-
key: string;
|
|
11
|
-
trafficType: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Options for GoogleAnalyticsToSplit integration plugin
|
|
15
|
-
*/
|
|
16
|
-
export interface GoogleAnalyticsToSplitOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Optional flag to filter GA hits from being tracked as Split events.
|
|
19
|
-
* @property {boolean} hits
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
hits?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Optional predicate used to define a custom filter for tracking GA hits as Split events.
|
|
25
|
-
* For example, the following filter allows to track only 'event' hits:
|
|
26
|
-
* `(model) => model.get('hitType') === 'event'`
|
|
27
|
-
* By default, all hits are tracked as Split events.
|
|
28
|
-
*/
|
|
29
|
-
filter?: (model: UniversalAnalytics.Model) => boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Optional function useful when you need to modify the Split event before tracking it.
|
|
32
|
-
* This function is invoked with two arguments:
|
|
33
|
-
* 1. the GA model object representing the hit.
|
|
34
|
-
* 2. the default format of the mapped Split event instance.
|
|
35
|
-
* The return value must be a Split event, that can be the second argument or a new object.
|
|
36
|
-
*
|
|
37
|
-
* For example, the following mapper adds a custom property to events:
|
|
38
|
-
* `(model, defaultMapping) => {
|
|
39
|
-
* defaultMapping.properties.someProperty = SOME_VALUE;
|
|
40
|
-
* return defaultMapping;
|
|
41
|
-
* }`
|
|
42
|
-
*/
|
|
43
|
-
mapper?: (model: UniversalAnalytics.Model, defaultMapping: SplitIO.EventData) => SplitIO.EventData;
|
|
44
|
-
/**
|
|
45
|
-
* Optional prefix for EventTypeId, to prevent any kind of data collision between events.
|
|
46
|
-
* @property {string} prefix
|
|
47
|
-
* @default 'ga'
|
|
48
|
-
*/
|
|
49
|
-
prefix?: string;
|
|
50
|
-
/**
|
|
51
|
-
* List of Split identities (key & traffic type pairs) used to track events.
|
|
52
|
-
* If not provided, events are sent using the key and traffic type provided at SDK config
|
|
53
|
-
*/
|
|
54
|
-
identities?: Identity[];
|
|
55
|
-
/**
|
|
56
|
-
* Optional flag to log an error if the `auto-require` script is not detected.
|
|
57
|
-
* The auto-require script automatically requires the `splitTracker` plugin for created trackers,
|
|
58
|
-
* and should be placed right after your Google Analytics, Google Tag Manager or gtag.js script tag.
|
|
59
|
-
*
|
|
60
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360040838752#set-up-with-gtm-and-gtag.js}
|
|
61
|
-
*
|
|
62
|
-
* @property {boolean} autoRequire
|
|
63
|
-
* @default false
|
|
64
|
-
*/
|
|
65
|
-
autoRequire?: boolean;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
|
|
69
|
-
* Used by the browser variant of the isomorphic JS SDK.
|
|
70
|
-
*
|
|
71
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
|
|
72
|
-
*/
|
|
73
|
-
export interface IGoogleAnalyticsToSplitConfig extends GoogleAnalyticsToSplitOptions {
|
|
74
|
-
type: 'GOOGLE_ANALYTICS_TO_SPLIT';
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Options for SplitToGoogleAnalytics integration plugin
|
|
78
|
-
*/
|
|
79
|
-
export interface SplitToGoogleAnalyticsOptions {
|
|
80
|
-
/**
|
|
81
|
-
* Optional flag to filter Split impressions from being tracked as GA hits.
|
|
82
|
-
* @property {boolean} impressions
|
|
83
|
-
* @default true
|
|
84
|
-
*/
|
|
85
|
-
impressions?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Optional flag to filter Split events from being tracked as GA hits.
|
|
88
|
-
* @property {boolean} events
|
|
89
|
-
* @default true
|
|
90
|
-
*/
|
|
91
|
-
events?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Optional predicate used to define a custom filter for tracking Split data (events and impressions) as GA hits.
|
|
94
|
-
* For example, the following filter allows to track only impressions, equivalent to setting events to false:
|
|
95
|
-
* `(data) => data.type === 'IMPRESSION'`
|
|
96
|
-
*/
|
|
97
|
-
filter?: (data: SplitIO.IntegrationData) => boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Optional function useful when you need to modify the GA hit before sending it.
|
|
100
|
-
* This function is invoked with two arguments:
|
|
101
|
-
* 1. the input data (Split event or impression).
|
|
102
|
-
* 2. the default format of the mapped FieldsObject instance (GA hit).
|
|
103
|
-
* The return value must be a FieldsObject, that can be the second argument or a new object.
|
|
104
|
-
*
|
|
105
|
-
* For example, the following mapper adds a custom dimension to hits:
|
|
106
|
-
* `(data, defaultMapping) => {
|
|
107
|
-
* defaultMapping.dimension1 = SOME_VALUE;
|
|
108
|
-
* return defaultMapping;
|
|
109
|
-
* }`
|
|
110
|
-
*
|
|
111
|
-
* Default FieldsObject instance for data.type === 'IMPRESSION':
|
|
112
|
-
* `{
|
|
113
|
-
* hitType: 'event',
|
|
114
|
-
* eventCategory: 'split-impression',
|
|
115
|
-
* eventAction: 'Evaluate ' + data.payload.impression.feature,
|
|
116
|
-
* eventLabel: 'Treatment: ' + data.payload.impression.treatment + '. Targeting rule: ' + data.payload.impression.label + '.',
|
|
117
|
-
* nonInteraction: true,
|
|
118
|
-
* }`
|
|
119
|
-
* Default FieldsObject instance for data.type === 'EVENT':
|
|
120
|
-
* `{
|
|
121
|
-
* hitType: 'event',
|
|
122
|
-
* eventCategory: 'split-event',
|
|
123
|
-
* eventAction: data.payload.eventTypeId,
|
|
124
|
-
* eventValue: data.payload.value,
|
|
125
|
-
* nonInteraction: true,
|
|
126
|
-
* }`
|
|
127
|
-
*/
|
|
128
|
-
mapper?: (data: SplitIO.IntegrationData, defaultMapping: UniversalAnalytics.FieldsObject) => UniversalAnalytics.FieldsObject;
|
|
129
|
-
/**
|
|
130
|
-
* List of tracker names to send the hit. An empty string represents the default tracker.
|
|
131
|
-
* If not provided, hits are only sent to default tracker.
|
|
132
|
-
*/
|
|
133
|
-
trackerNames?: string[];
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Enable 'Split to Google Analytics' integration, to track Split impressions and events as Google Analytics hits.
|
|
137
|
-
* Used by the browser variant of the isomorphic JS SDK.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
|
|
140
|
-
*/
|
|
141
|
-
export interface ISplitToGoogleAnalyticsConfig extends SplitToGoogleAnalyticsOptions {
|
|
142
|
-
type: 'SPLIT_TO_GOOGLE_ANALYTICS';
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Available integration options for the browser
|
|
146
|
-
* Used by the browser variant of the isomorphic JS SDK.
|
|
147
|
-
*/
|
|
148
|
-
export declare type BrowserIntegration = ISplitToGoogleAnalyticsConfig | IGoogleAnalyticsToSplitConfig;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SplitIO } from '../types';
|
|
2
|
-
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
|
-
/**
|
|
4
|
-
* Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
|
|
5
|
-
* where clients can have a bound TT for the track method, which is provided via the settings
|
|
6
|
-
* (default client) or the client method (shared clients).
|
|
7
|
-
*/
|
|
8
|
-
export declare function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey, trafficType?: string) => SplitIO.ICsClient;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { IMySegmentsResponse } from '../dtos/types';
|
|
2
|
-
import { MySegmentsData } from '../sync/polling/types';
|
|
3
|
-
import { ISegmentsCacheSync } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* This class provides a skeletal implementation of the ISegmentsCacheSync interface
|
|
6
|
-
* to minimize the effort required to implement this interface.
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class AbstractSegmentsCacheSync implements ISegmentsCacheSync {
|
|
9
|
-
/**
|
|
10
|
-
* For server-side synchronizer: add `segmentKeys` list of keys to `name` segment.
|
|
11
|
-
* For client-side synchronizer: add `name` segment to the cache. `segmentKeys` is undefined.
|
|
12
|
-
*/
|
|
13
|
-
abstract addToSegment(name: string, segmentKeys?: string[]): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* For server-side synchronizer: remove `segmentKeys` list of keys from `name` segment.
|
|
16
|
-
* For client-side synchronizer: remove `name` segment from the cache. `segmentKeys` is undefined.
|
|
17
|
-
*/
|
|
18
|
-
abstract removeFromSegment(name: string, segmentKeys?: string[]): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* For server-side synchronizer: check if `key` is in `name` segment.
|
|
21
|
-
* For client-side synchronizer: check if `name` segment is in the cache. `key` is undefined.
|
|
22
|
-
*/
|
|
23
|
-
abstract isInSegment(name: string, key?: string): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* clear the cache.
|
|
26
|
-
*/
|
|
27
|
-
clear(): void;
|
|
28
|
-
/**
|
|
29
|
-
* For server-side synchronizer: add the given list of segments to the cache, with an empty list of keys. The segments that already exist are not modified.
|
|
30
|
-
* For client-side synchronizer: the method is not used.
|
|
31
|
-
*/
|
|
32
|
-
registerSegments(names: string[]): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* For server-side synchronizer: get the list of segments to fetch changes.
|
|
35
|
-
* Also used for the `seC` (segment count) telemetry stat.
|
|
36
|
-
*/
|
|
37
|
-
abstract getRegisteredSegments(): string[];
|
|
38
|
-
/**
|
|
39
|
-
* Only used for the `skC`(segment keys count) telemetry stat: 1 for client-side, and total count of keys in server-side.
|
|
40
|
-
* @TODO for client-side it should be the number of clients, but it requires a refactor of MySegments caches to simplify the code.
|
|
41
|
-
*/
|
|
42
|
-
abstract getKeysCount(): number;
|
|
43
|
-
/**
|
|
44
|
-
* For server-side synchronizer: change number of `name` segment.
|
|
45
|
-
* For client-side synchronizer: change number of mySegments.
|
|
46
|
-
*/
|
|
47
|
-
abstract setChangeNumber(name?: string, changeNumber?: number): boolean | void;
|
|
48
|
-
abstract getChangeNumber(name: string): number;
|
|
49
|
-
/**
|
|
50
|
-
* For server-side synchronizer: the method is not used.
|
|
51
|
-
* For client-side synchronizer: it resets or updates the cache.
|
|
52
|
-
*/
|
|
53
|
-
resetSegments(segmentsData: MySegmentsData | IMySegmentsResponse): boolean;
|
|
54
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
2
|
-
/**
|
|
3
|
-
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
4
|
-
* to minimize the effort required to implement this interface.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class AbstractSplitsCache {
|
|
7
|
-
/**
|
|
8
|
-
* Check if the splits information is already stored in cache. This data can be preloaded.
|
|
9
|
-
* It is used as condition to emit SDK_SPLITS_CACHE_LOADED, and then SDK_READY_FROM_CACHE.
|
|
10
|
-
*/
|
|
11
|
-
checkCache(): boolean;
|
|
12
|
-
protected abstract addSplit(name: string, split: ISplit): MaybeThenable<boolean>;
|
|
13
|
-
/**
|
|
14
|
-
* Add a list of splits.
|
|
15
|
-
* The returned promise is resolved when the operation success or rejected if it fails (e.g., wrapper operation fails).
|
|
16
|
-
*/
|
|
17
|
-
protected addSplits(entries: [string, ISplit][]): Promise<boolean[]>;
|
|
18
|
-
protected abstract removeSplit(name: string): MaybeThenable<boolean>;
|
|
19
|
-
/**
|
|
20
|
-
* Remove a list of splits.
|
|
21
|
-
* The returned promise is resolved when the operation success, with a boolean array indicating if the splits existed or not.
|
|
22
|
-
* or rejected if it fails (e.g., wrapper operation fails).
|
|
23
|
-
*/
|
|
24
|
-
protected removeSplits(names: string[]): Promise<boolean[]>;
|
|
25
|
-
protected abstract setChangeNumber(changeNumber: number): MaybeThenable<boolean | void>;
|
|
26
|
-
/**
|
|
27
|
-
* Updates the cache with the provided changeNumber, feature flags to add and feature flags to remove.
|
|
28
|
-
*
|
|
29
|
-
* @returns {Promise<boolean>} a promise that resolved once the operation is performed successfully. The fulfillment value is `true` if at least one feature flag was added, modified or removed; or `false` if there was no change.
|
|
30
|
-
* The promise will reject if some storage operation rejects.
|
|
31
|
-
*/
|
|
32
|
-
update(changeNumber: number, toAdd: [string, ISplit][], toRemove?: string[]): Promise<boolean>;
|
|
33
|
-
abstract getSplit(name: string): MaybeThenable<ISplit | null>;
|
|
34
|
-
/**
|
|
35
|
-
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
36
|
-
* Used for SPLIT_KILL push notifications.
|
|
37
|
-
*
|
|
38
|
-
* @param {string} name
|
|
39
|
-
* @param {string} defaultTreatment
|
|
40
|
-
* @param {number} changeNumber
|
|
41
|
-
* @returns {Promise} a promise that is resolved once the split kill operation is performed. The fulfillment value is a boolean: `true` if the operation successed updating the split or `false` if no split is updated,
|
|
42
|
-
* for instance, if the `changeNumber` is old, or if the split is not found (e.g., `/splitchanges` hasn't been fetched yet), or if the storage fails to apply the update.
|
|
43
|
-
* The promise will never be rejected.
|
|
44
|
-
*/
|
|
45
|
-
killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise<boolean>;
|
|
46
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Compression, KeyList } from './SSEHandler/types';
|
|
2
|
-
/**
|
|
3
|
-
* Decode, decompress and parse the provided 'data' into a KeyList object
|
|
4
|
-
*
|
|
5
|
-
* @param {string} data
|
|
6
|
-
* @param {number} compression
|
|
7
|
-
* @returns {{a?: string[], r?: string[] }}
|
|
8
|
-
* @throws if data string cannot be decoded, decompressed or parsed
|
|
9
|
-
*/
|
|
10
|
-
export declare function parseKeyList(data: string, compression: Compression): KeyList;
|
|
11
|
-
/**
|
|
12
|
-
* Decode, decompress and parse the provided 'data' into a Bitmap object
|
|
13
|
-
*
|
|
14
|
-
* @param {string} data
|
|
15
|
-
* @param {number} compression
|
|
16
|
-
* @returns {Uint8Array}
|
|
17
|
-
* @throws if data string cannot be decoded or decompressed
|
|
18
|
-
*/
|
|
19
|
-
export declare function parseBitmap(data: string, compression: Compression): Uint8Array;
|
|
20
|
-
/**
|
|
21
|
-
* Check if the 'bitmap' bit at 'hash64hex' position is 1
|
|
22
|
-
*
|
|
23
|
-
* @param {Uint8Array} bitmap
|
|
24
|
-
* @param {string} hash64hex 16-chars string, representing a number in hexa
|
|
25
|
-
* @returns {boolean}
|
|
26
|
-
*/
|
|
27
|
-
export declare function isInBitmap(bitmap: Uint8Array, hash64hex: string): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IPushManager } from './types';
|
|
2
|
-
import { IPollingManager } from '../polling/types';
|
|
3
|
-
import { ISdkFactoryContextSync } from '../../sdkFactory/types';
|
|
4
|
-
/**
|
|
5
|
-
* PushManager factory:
|
|
6
|
-
* - for server-side if key is not provided in settings.
|
|
7
|
-
* - for client-side, with support for multiple clients, if key is provided in settings
|
|
8
|
-
*/
|
|
9
|
-
export declare function pushManagerFactory(params: ISdkFactoryContextSync, pollingManager: IPollingManager): IPushManager | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IPushManager } from './types';
|
|
2
|
-
import { IPollingManager } from '../polling/types';
|
|
3
|
-
import { ISdkFactoryContextSync } from '../../sdkFactory/types';
|
|
4
|
-
/**
|
|
5
|
-
* PushManager factory:
|
|
6
|
-
* - for server-side if key is not provided in settings.
|
|
7
|
-
* - for client-side, with support for multiple clients, if key is provided in settings
|
|
8
|
-
*/
|
|
9
|
-
export declare function pushManagerFactory(params: ISdkFactoryContextSync, pollingManager: IPollingManager): IPushManager | undefined;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ILogger } from '../../logger/types';
|
|
2
|
-
/** validates the given SDK key */
|
|
3
|
-
export declare function validateApiKey(log: ILogger, maybeSdkKey: any): string | false;
|
|
4
|
-
export declare const usedKeysMap: Record<string, number>;
|
|
5
|
-
/** validates the given SDK key and also warns if it is in use */
|
|
6
|
-
export declare function validateAndTrackApiKey(log: ILogger, maybeSdkKey: any): string | false;
|
|
7
|
-
export declare function releaseApiKey(sdkKey: string): void;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IReadinessManager } from '../../readiness/types';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
|
-
/**
|
|
4
|
-
* This is defined here and in this format mostly because of the logger and the fact that it's considered a validation at product level.
|
|
5
|
-
* But it's not going to run on the input validation layer. In any case, the most compeling reason to use it as we do is to avoid going to Redis and get a split twice.
|
|
6
|
-
*/
|
|
7
|
-
export declare function validateSplitExistance(log: ILogger, readinessManager: IReadinessManager, splitName: string, labelOrSplitObj: any, method: string): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ISplitsCacheBase } from '../../storages/types';
|
|
2
|
-
import { IReadinessManager } from '../../readiness/types';
|
|
3
|
-
import { SDKMode } from '../../types';
|
|
4
|
-
import { MaybeThenable } from '../../dtos/types';
|
|
5
|
-
import { ILogger } from '../../logger/types';
|
|
6
|
-
/**
|
|
7
|
-
* Separated from the previous method since on some cases it'll be async.
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateTrafficTypeExistance(log: ILogger, readinessManager: IReadinessManager, splitsCache: ISplitsCacheBase, mode: SDKMode, maybeTT: string, method: string): MaybeThenable<boolean>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Map implementation based on es6-map polyfill (https://github.com/medikoo/es6-map/blob/master/polyfill.js),
|
|
3
|
-
* with the minimal features used by the SDK.
|
|
4
|
-
|
|
5
|
-
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
**/
|
|
25
|
-
export interface IMap<K, V> {
|
|
26
|
-
clear(): void;
|
|
27
|
-
delete(key: K): boolean;
|
|
28
|
-
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
|
29
|
-
get(key: K): V | undefined;
|
|
30
|
-
has(key: K): boolean;
|
|
31
|
-
set(key: K, value: V): this;
|
|
32
|
-
readonly size: number;
|
|
33
|
-
}
|
|
34
|
-
export declare class MapPoly<K, V> implements IMap<K, V> {
|
|
35
|
-
private __mapKeysData__;
|
|
36
|
-
private __mapValuesData__;
|
|
37
|
-
constructor(entries?: readonly (readonly [K, V])[] | null);
|
|
38
|
-
clear(): void;
|
|
39
|
-
delete(key: K): boolean;
|
|
40
|
-
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
|
41
|
-
get(key: K): V | undefined;
|
|
42
|
-
has(key: K): boolean;
|
|
43
|
-
set(key: K, value: V): this;
|
|
44
|
-
get size(): number;
|
|
45
|
-
}
|
|
46
|
-
interface IMapConstructor {
|
|
47
|
-
new (): IMap<any, any>;
|
|
48
|
-
new <K, V>(entries?: readonly (readonly [K, V])[] | null): IMap<K, V>;
|
|
49
|
-
readonly prototype: IMap<any, any>;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* return the Map constructor to use. If native Map is not available or it doesn't support the required features (e.g., IE11),
|
|
53
|
-
* a ponyfill with minimal features is returned instead.
|
|
54
|
-
*
|
|
55
|
-
* Exported for testing purposes only.
|
|
56
|
-
*/
|
|
57
|
-
export declare function __getMapConstructor(): IMapConstructor;
|
|
58
|
-
export declare const _Map: IMapConstructor;
|
|
59
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ILogger } from '../../../logger/types';
|
|
2
|
-
import { SDKMode } from '../../../types';
|
|
3
|
-
/**
|
|
4
|
-
* This function validates `settings.sync.localhostMode` object
|
|
5
|
-
*
|
|
6
|
-
* @param {any} settings config object provided by the user to initialize the sdk
|
|
7
|
-
*
|
|
8
|
-
* @returns {Object} provided localhost mode module at `settings.sync.localhostMode` if valid, or a default LocalhostFromObject instance if not provided or invalid
|
|
9
|
-
*/
|
|
10
|
-
export declare function validateLocalhostWithDefault(settings: {
|
|
11
|
-
log: ILogger;
|
|
12
|
-
sync: {
|
|
13
|
-
localhostMode?: any;
|
|
14
|
-
};
|
|
15
|
-
mode: SDKMode;
|
|
16
|
-
}): any;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ILogger } from '../../../logger/types';
|
|
2
|
-
import { SDKMode } from '../../../types';
|
|
3
|
-
/**
|
|
4
|
-
* This function validates `settings.sync.localhostMode` object
|
|
5
|
-
*
|
|
6
|
-
* @param {any} settings config object provided by the user to initialize the sdk
|
|
7
|
-
*
|
|
8
|
-
* @returns {Object | undefined} provided localhost mode module at `settings.sync.localhostMode`, or undefined if it is not provided or invalid
|
|
9
|
-
*/
|
|
10
|
-
export declare function validateLocalhost(settings: {
|
|
11
|
-
log: ILogger;
|
|
12
|
-
sync: {
|
|
13
|
-
localhostMode?: any;
|
|
14
|
-
};
|
|
15
|
-
mode: SDKMode;
|
|
16
|
-
}): any;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LogLevel } from '../../../types';
|
|
2
|
-
/**
|
|
3
|
-
* The debug level can be set globally via the `localStorage.splitio_debug` item in browser, or the `SPLITIO_DEBUG` env var in NodeJS.
|
|
4
|
-
* Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
|
|
5
|
-
* Other acceptable values are 'on', 'enable' and 'enabled', which are equivalent to 'DEBUG'.
|
|
6
|
-
* Any other value, like undefined, null or an invalid string, returns `undefined` and means that the global log level is not set.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getGlobalLogLevel(): LogLevel | undefined;
|
|
File without changes
|