@splitsoftware/splitio-browserjs 0.1.1-canary.1 → 0.2.1-rc.0
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 +10 -3
- package/README.md +2 -1
- package/cjs/{slim → full}/index.js +7 -8
- package/cjs/{slim → full}/splitFactory.js +10 -5
- package/cjs/index.js +17 -8
- package/cjs/platform/{getFetch.js → getFetchFull.js} +0 -0
- package/cjs/platform/{getFetchMin.js → getFetchSlim.js} +0 -0
- package/cjs/platform/getModules.js +26 -18
- package/cjs/settings/defaults.js +1 -1
- package/cjs/settings/{slim.js → full.js} +4 -1
- package/cjs/settings/index.js +5 -2
- package/cjs/splitFactory.js +9 -3
- package/esm/{slim → full}/index.js +3 -2
- package/esm/{slim → full}/splitFactory.js +8 -4
- package/esm/index.js +8 -2
- package/esm/platform/{getFetch.js → getFetchFull.js} +0 -0
- package/esm/platform/{getFetchMin.js → getFetchSlim.js} +0 -0
- package/esm/platform/getModules.js +26 -18
- package/esm/settings/defaults.js +1 -1
- package/esm/settings/{slim.js → full.js} +4 -1
- package/esm/settings/index.js +5 -2
- package/esm/splitFactory.js +8 -3
- package/full/package.json +6 -0
- package/package.json +12 -10
- package/src/{slim → full}/index.ts +3 -2
- package/src/{slim → full}/splitFactory.ts +9 -4
- package/src/full/umd.ts +14 -0
- package/src/index.ts +8 -2
- package/src/platform/{getFetch.ts → getFetchFull.ts} +0 -0
- package/src/platform/{getFetchMin.ts → getFetchSlim.ts} +0 -0
- package/src/platform/getModules.ts +28 -21
- package/src/settings/defaults.ts +1 -1
- package/src/settings/{slim.ts → full.ts} +4 -1
- package/src/settings/index.ts +5 -2
- package/src/splitFactory.ts +9 -3
- package/src/umd.ts +0 -15
- package/types/{slim → full}/index.d.ts +13 -5
- package/types/index.d.ts +51 -2
- package/types/splitio.d.ts +339 -75
- package/cjs/platform/getModulesSlim.js +0 -39
- package/esm/platform/getModulesSlim.js +0 -34
- package/slim/package.json +0 -6
- package/src/platform/getModulesSlim.ts +0 -52
- package/src/slim/umd.ts +0 -6
package/types/splitio.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for Javascript Browser Split Software SDK
|
|
1
|
+
// Type definitions for Javascript Browser Split Software SDK
|
|
2
2
|
// Project: http://www.split.io/
|
|
3
3
|
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
|
|
4
4
|
|
|
@@ -11,11 +11,11 @@ export = SplitIO;
|
|
|
11
11
|
* EventEmitter interface based on a subset of the NodeJS.EventEmitter methods.
|
|
12
12
|
*/
|
|
13
13
|
interface IEventEmitter {
|
|
14
|
-
addListener(event: string, listener: (...args: any[]) => void): this
|
|
14
|
+
addListener(event: string, listener: (...args: any[]) => void): this
|
|
15
15
|
on(event: string, listener: (...args: any[]) => void): this
|
|
16
16
|
once(event: string, listener: (...args: any[]) => void): this
|
|
17
|
-
removeListener(event: string, listener: (...args: any[]) => void): this
|
|
18
|
-
off(event: string, listener: (...args: any[]) => void): this
|
|
17
|
+
removeListener(event: string, listener: (...args: any[]) => void): this
|
|
18
|
+
off(event: string, listener: (...args: any[]) => void): this
|
|
19
19
|
removeAllListeners(event?: string): this
|
|
20
20
|
emit(event: string, ...args: any[]): boolean
|
|
21
21
|
}
|
|
@@ -32,6 +32,16 @@ type EventConsts = {
|
|
|
32
32
|
SDK_READY_TIMED_OUT: 'init::timeout',
|
|
33
33
|
SDK_UPDATE: 'state::update'
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* SDK Modes.
|
|
37
|
+
* @typedef {string} SDKMode
|
|
38
|
+
*/
|
|
39
|
+
type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial';
|
|
40
|
+
/**
|
|
41
|
+
* Storage types.
|
|
42
|
+
* @typedef {string} StorageType
|
|
43
|
+
*/
|
|
44
|
+
type StorageType = 'MEMORY' | 'LOCALSTORAGE';
|
|
35
45
|
/**
|
|
36
46
|
* Settings interface. This is a representation of the settings the SDK expose, that's why
|
|
37
47
|
* most of it's props are readonly. Only features should be rewritten when localhost mode is active.
|
|
@@ -44,6 +54,7 @@ interface ISettings {
|
|
|
44
54
|
labelsEnabled: boolean,
|
|
45
55
|
IPAddressesEnabled: boolean
|
|
46
56
|
},
|
|
57
|
+
readonly mode: SDKMode,
|
|
47
58
|
readonly scheduler: {
|
|
48
59
|
featuresRefreshRate: number,
|
|
49
60
|
impressionsRefreshRate: number,
|
|
@@ -59,7 +70,7 @@ interface ISettings {
|
|
|
59
70
|
retriesOnFailureBeforeReady: number,
|
|
60
71
|
eventsFirstPushWindow: number
|
|
61
72
|
},
|
|
62
|
-
readonly storage?: SplitIO.StorageSyncFactory,
|
|
73
|
+
readonly storage?: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory,
|
|
63
74
|
readonly urls: {
|
|
64
75
|
events: string,
|
|
65
76
|
sdk: string,
|
|
@@ -77,6 +88,7 @@ interface ISettings {
|
|
|
77
88
|
readonly sync: {
|
|
78
89
|
splitFilters: SplitIO.SplitFilter[],
|
|
79
90
|
impressionsMode: SplitIO.ImpressionsMode,
|
|
91
|
+
localhostMode?: SplitIO.LocalhostFactory
|
|
80
92
|
}
|
|
81
93
|
}
|
|
82
94
|
/**
|
|
@@ -121,9 +133,15 @@ interface ILoggerAPI {
|
|
|
121
133
|
interface ISharedSettings {
|
|
122
134
|
/**
|
|
123
135
|
* Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object.
|
|
124
|
-
* Passing a logger object is required
|
|
136
|
+
* Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes.
|
|
125
137
|
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}
|
|
126
138
|
*
|
|
139
|
+
* Examples:
|
|
140
|
+
* ```typescript
|
|
141
|
+
* config.debug = true
|
|
142
|
+
* config.debug = 'WARN'
|
|
143
|
+
* config.debug = ErrorLogger()
|
|
144
|
+
* ```
|
|
127
145
|
* @property {boolean | LogLevel | ILogger} debug
|
|
128
146
|
* @default false
|
|
129
147
|
*/
|
|
@@ -152,6 +170,7 @@ interface ISharedSettings {
|
|
|
152
170
|
* This configuration is only meaningful when the SDK is working in "standalone" mode.
|
|
153
171
|
*
|
|
154
172
|
* At the moment, two types of split filters are supported: by name and by prefix.
|
|
173
|
+
*
|
|
155
174
|
* Example:
|
|
156
175
|
* `splitFilter: [
|
|
157
176
|
* { type: 'byName', values: ['my_split_1', 'my_split_2'] }, // will fetch splits named 'my_split_1' and 'my_split_2'
|
|
@@ -169,6 +188,25 @@ interface ISharedSettings {
|
|
|
169
188
|
* @default 'OPTIMIZED'
|
|
170
189
|
*/
|
|
171
190
|
impressionsMode?: SplitIO.ImpressionsMode,
|
|
191
|
+
/**
|
|
192
|
+
* Defines the factory function to instantiate the SDK in localhost mode.
|
|
193
|
+
*
|
|
194
|
+
* NOTE: this is only required if using the slim entry point of the library to init the SDK in localhost mode.
|
|
195
|
+
*
|
|
196
|
+
* For more information @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
|
|
197
|
+
*
|
|
198
|
+
* Example:
|
|
199
|
+
* ```typescript
|
|
200
|
+
* SplitFactory({
|
|
201
|
+
* ...
|
|
202
|
+
* sync: {
|
|
203
|
+
* localhostMode: LocalhostFromObject()
|
|
204
|
+
* }
|
|
205
|
+
* })
|
|
206
|
+
* ```
|
|
207
|
+
* @property {Object} localhostMode
|
|
208
|
+
*/
|
|
209
|
+
localhostMode?: SplitIO.LocalhostFactory
|
|
172
210
|
}
|
|
173
211
|
}
|
|
174
212
|
/**
|
|
@@ -335,6 +373,11 @@ declare namespace SplitIO {
|
|
|
335
373
|
type MockedFeaturesMap = {
|
|
336
374
|
[featureName: string]: string | TreatmentWithConfig
|
|
337
375
|
};
|
|
376
|
+
/**
|
|
377
|
+
* Localhost types.
|
|
378
|
+
* @typedef {string} LocalhostType
|
|
379
|
+
*/
|
|
380
|
+
type LocalhostType = 'LocalhostFromObject'
|
|
338
381
|
/**
|
|
339
382
|
* Object with information about an impression. It contains the generated impression DTO as well as
|
|
340
383
|
* complementary information around where and how it was generated in that way.
|
|
@@ -429,9 +472,12 @@ declare namespace SplitIO {
|
|
|
429
472
|
* By returning undefined, the SDK will use the default IN MEMORY storage.
|
|
430
473
|
* Input parameter details are not part of the public API.
|
|
431
474
|
*/
|
|
432
|
-
type StorageSyncFactory =
|
|
475
|
+
type StorageSyncFactory = {
|
|
476
|
+
readonly type: StorageType
|
|
477
|
+
(params: {}): (StorageSync | undefined)
|
|
478
|
+
}
|
|
433
479
|
/**
|
|
434
|
-
* Configuration params for InLocalStorage
|
|
480
|
+
* Configuration params for `InLocalStorage`
|
|
435
481
|
*/
|
|
436
482
|
type InLocalStorageOptions = {
|
|
437
483
|
/**
|
|
@@ -441,6 +487,43 @@ declare namespace SplitIO {
|
|
|
441
487
|
*/
|
|
442
488
|
prefix?: string
|
|
443
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Storage for asynchronous (consumer) SDK.
|
|
492
|
+
* Its interface details are not part of the public API.
|
|
493
|
+
*/
|
|
494
|
+
type StorageAsync = {}
|
|
495
|
+
/**
|
|
496
|
+
* Storage builder for asynchronous (consumer) SDK.
|
|
497
|
+
* Input parameter details are not part of the public API.
|
|
498
|
+
*/
|
|
499
|
+
type StorageAsyncFactory = {
|
|
500
|
+
readonly type: 'PLUGGABLE'
|
|
501
|
+
(params: {}): StorageAsync
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Configuration params for `PluggableStorage`
|
|
505
|
+
*/
|
|
506
|
+
type PluggableStorageOptions = {
|
|
507
|
+
/**
|
|
508
|
+
* Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper.
|
|
509
|
+
* @property {string} prefix
|
|
510
|
+
* @default SPLITIO
|
|
511
|
+
*/
|
|
512
|
+
prefix?: string,
|
|
513
|
+
/**
|
|
514
|
+
* Storage wrapper.
|
|
515
|
+
* @property {Object} wrapper
|
|
516
|
+
*/
|
|
517
|
+
wrapper: Object
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Localhost mode factory.
|
|
521
|
+
* Its interface details are not part of the public API.
|
|
522
|
+
*/
|
|
523
|
+
type LocalhostFactory = {
|
|
524
|
+
readonly type: LocalhostType
|
|
525
|
+
(params: {}): {}
|
|
526
|
+
}
|
|
444
527
|
/**
|
|
445
528
|
* Impression listener interface. This is the interface that needs to be implemented
|
|
446
529
|
* by the element you provide to the SDK as impression listener.
|
|
@@ -659,13 +742,87 @@ declare namespace SplitIO {
|
|
|
659
742
|
interface ILogger {
|
|
660
743
|
setLogLevel(logLevel: LogLevel): void
|
|
661
744
|
}
|
|
745
|
+
/**
|
|
746
|
+
* Common settings interface for SDK instances created on the browser.
|
|
747
|
+
* @interface IBrowserBasicSettings
|
|
748
|
+
* @extends ISharedSettings
|
|
749
|
+
*/
|
|
750
|
+
interface IBrowserBasicSettings extends ISharedSettings {
|
|
751
|
+
/**
|
|
752
|
+
* SDK Core settings for the browser.
|
|
753
|
+
* @property {Object} core
|
|
754
|
+
*/
|
|
755
|
+
core: {
|
|
756
|
+
/**
|
|
757
|
+
* Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
758
|
+
* @property {string} authorizationKey
|
|
759
|
+
*/
|
|
760
|
+
authorizationKey: string,
|
|
761
|
+
/**
|
|
762
|
+
* Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
763
|
+
* @property {SplitKey} key
|
|
764
|
+
*/
|
|
765
|
+
key: SplitKey,
|
|
766
|
+
/**
|
|
767
|
+
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
768
|
+
* @property {boolean} labelsEnabled
|
|
769
|
+
* @default true
|
|
770
|
+
*/
|
|
771
|
+
labelsEnabled?: boolean
|
|
772
|
+
},
|
|
773
|
+
/**
|
|
774
|
+
* List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
|
|
775
|
+
* Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
|
|
776
|
+
* @property {Object} urls
|
|
777
|
+
*/
|
|
778
|
+
urls?: UrlSettings,
|
|
779
|
+
/**
|
|
780
|
+
* Defines an optional list of factory functions used to instantiate SDK integrations.
|
|
781
|
+
*
|
|
782
|
+
* Example:
|
|
783
|
+
* ```typescript
|
|
784
|
+
* SplitFactory({
|
|
785
|
+
* ...
|
|
786
|
+
* integrations: [SplitToGoogleAnalytics(), GoogleAnalyticsToSplit()]
|
|
787
|
+
* })
|
|
788
|
+
* ```
|
|
789
|
+
* @property {Object} integrations
|
|
790
|
+
*/
|
|
791
|
+
integrations?: IntegrationFactory[],
|
|
792
|
+
}
|
|
662
793
|
/**
|
|
663
794
|
* Settings interface for SDK instances created on the browser.
|
|
664
795
|
* @interface IBrowserSettings
|
|
665
796
|
* @extends ISharedSettings
|
|
666
797
|
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
|
|
667
798
|
*/
|
|
668
|
-
interface IBrowserSettings extends
|
|
799
|
+
interface IBrowserSettings extends IBrowserBasicSettings {
|
|
800
|
+
/**
|
|
801
|
+
* The SDK mode. When using the default in memory storage or `InLocalStorage` as storage, the only possible value is "standalone", which is the default.
|
|
802
|
+
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
803
|
+
*
|
|
804
|
+
* @property {'standalone'} mode
|
|
805
|
+
* @default standalone
|
|
806
|
+
*/
|
|
807
|
+
mode?: 'standalone',
|
|
808
|
+
/**
|
|
809
|
+
* Mocked features map. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
810
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
|
|
811
|
+
*/
|
|
812
|
+
features?: MockedFeaturesMap,
|
|
813
|
+
/**
|
|
814
|
+
* Defines the factory function to instantiate the storage. If not provided, the default IN MEMORY storage is used.
|
|
815
|
+
*
|
|
816
|
+
* Example:
|
|
817
|
+
* ```typescript
|
|
818
|
+
* SplitFactory({
|
|
819
|
+
* ...
|
|
820
|
+
* storage: InLocalStorage()
|
|
821
|
+
* })
|
|
822
|
+
* ```
|
|
823
|
+
* @property {Object} storage
|
|
824
|
+
*/
|
|
825
|
+
storage?: StorageSyncFactory,
|
|
669
826
|
/**
|
|
670
827
|
* SDK Startup settings for the Browser.
|
|
671
828
|
* @property {Object} startup
|
|
@@ -748,50 +905,89 @@ declare namespace SplitIO {
|
|
|
748
905
|
* @default 1
|
|
749
906
|
*/
|
|
750
907
|
pushRetryBackoffBase?: number,
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
authorizationKey: string,
|
|
762
|
-
/**
|
|
763
|
-
* Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
764
|
-
* @property {SplitKey} key
|
|
765
|
-
*/
|
|
766
|
-
key: SplitKey,
|
|
767
|
-
/**
|
|
768
|
-
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
769
|
-
* @property {boolean} labelsEnabled
|
|
770
|
-
* @default true
|
|
771
|
-
*/
|
|
772
|
-
labelsEnabled?: boolean
|
|
773
|
-
},
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Settings interface with async storage for SDK instances created on the browser.
|
|
912
|
+
* If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.IBrowserSettings instead.
|
|
913
|
+
* @interface IBrowserAsyncSettings
|
|
914
|
+
* @extends IBrowserBasicSettings
|
|
915
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
|
|
916
|
+
*/
|
|
917
|
+
interface IBrowserAsyncSettings extends IBrowserBasicSettings {
|
|
774
918
|
/**
|
|
775
|
-
*
|
|
776
|
-
*
|
|
919
|
+
* The SDK mode. When using `PluggableStorage` as storage, the possible values are "consumer" and "consumer_partial".
|
|
920
|
+
*
|
|
921
|
+
* @see {@link @TODO}
|
|
922
|
+
*
|
|
923
|
+
* @property {'consumer' | 'consumer_partial'} mode
|
|
777
924
|
*/
|
|
778
|
-
|
|
925
|
+
mode: 'consumer' | 'consumer_partial',
|
|
779
926
|
/**
|
|
780
|
-
* Defines the factory function to
|
|
927
|
+
* Defines the factory function to instantiate the storage.
|
|
928
|
+
*
|
|
929
|
+
* Example:
|
|
930
|
+
* ```typescript
|
|
931
|
+
* SplitFactory({
|
|
932
|
+
* ...
|
|
933
|
+
* storage: PluggableStorage({ wrapper: SomeWrapper })
|
|
934
|
+
* })
|
|
935
|
+
* ```
|
|
781
936
|
* @property {Object} storage
|
|
782
937
|
*/
|
|
783
|
-
storage
|
|
938
|
+
storage: StorageAsyncFactory,
|
|
784
939
|
/**
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
* @property {Object} urls
|
|
940
|
+
* SDK Startup settings for the Browser.
|
|
941
|
+
* @property {Object} startup
|
|
788
942
|
*/
|
|
789
|
-
|
|
943
|
+
startup?: {
|
|
944
|
+
/**
|
|
945
|
+
* Maximum amount of time used before notify a timeout.
|
|
946
|
+
* @property {number} readyTimeout
|
|
947
|
+
* @default 1.5
|
|
948
|
+
*/
|
|
949
|
+
readyTimeout?: number,
|
|
950
|
+
/**
|
|
951
|
+
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
952
|
+
* to better control on browsers. This number defines that window before the first events push.
|
|
953
|
+
*
|
|
954
|
+
* NOTE: this param is ignored in 'consumer' mode.
|
|
955
|
+
* @property {number} eventsFirstPushWindow
|
|
956
|
+
* @default 10
|
|
957
|
+
*/
|
|
958
|
+
eventsFirstPushWindow?: number,
|
|
959
|
+
},
|
|
790
960
|
/**
|
|
791
|
-
*
|
|
792
|
-
* @property {Object}
|
|
961
|
+
* SDK scheduler settings.
|
|
962
|
+
* @property {Object} scheduler
|
|
793
963
|
*/
|
|
794
|
-
|
|
964
|
+
scheduler?: {
|
|
965
|
+
/**
|
|
966
|
+
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
967
|
+
*
|
|
968
|
+
* NOTE: this param is ignored in 'consumer' mode.
|
|
969
|
+
* @property {number} impressionsRefreshRate
|
|
970
|
+
* @default 60
|
|
971
|
+
*/
|
|
972
|
+
impressionsRefreshRate?: number,
|
|
973
|
+
/**
|
|
974
|
+
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
975
|
+
*
|
|
976
|
+
* NOTE: this param is ignored in 'consumer' mode.
|
|
977
|
+
* @property {number} eventsPushRate
|
|
978
|
+
* @default 60
|
|
979
|
+
*/
|
|
980
|
+
eventsPushRate?: number,
|
|
981
|
+
/**
|
|
982
|
+
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
983
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
984
|
+
*
|
|
985
|
+
* NOTE: this param is ignored in 'consumer' mode.
|
|
986
|
+
* @property {number} eventsQueueSize
|
|
987
|
+
* @default 500
|
|
988
|
+
*/
|
|
989
|
+
eventsQueueSize?: number,
|
|
990
|
+
}
|
|
795
991
|
}
|
|
796
992
|
/**
|
|
797
993
|
* This represents the interface for the SDK instance with synchronous storage and client-side API,
|
|
@@ -799,7 +995,7 @@ declare namespace SplitIO {
|
|
|
799
995
|
* @interface ISDK
|
|
800
996
|
* @extends IBasicSDK
|
|
801
997
|
*/
|
|
802
|
-
|
|
998
|
+
interface ISDK extends IBasicSDK {
|
|
803
999
|
/**
|
|
804
1000
|
* Returns the default client instance of the SDK, associated with the key and optional traffic type from settings.
|
|
805
1001
|
* @function client
|
|
@@ -820,7 +1016,26 @@ declare namespace SplitIO {
|
|
|
820
1016
|
*/
|
|
821
1017
|
manager(): IManager
|
|
822
1018
|
}
|
|
823
|
-
|
|
1019
|
+
/**
|
|
1020
|
+
* This represents the interface for the SDK instance with asynchronous storage and client-side API,
|
|
1021
|
+
* i.e., where client instances have a bound user key.
|
|
1022
|
+
* @interface IAsyncSDK
|
|
1023
|
+
* @extends IBasicSDK
|
|
1024
|
+
*/
|
|
1025
|
+
interface IAsyncSDK extends IBasicSDK {
|
|
1026
|
+
/**
|
|
1027
|
+
* Returns the default client instance of the SDK.
|
|
1028
|
+
* @function client
|
|
1029
|
+
* @returns {IAsyncClient} The asynchronous client instance.
|
|
1030
|
+
*/
|
|
1031
|
+
client(): IAsyncClient,
|
|
1032
|
+
/**
|
|
1033
|
+
* Returns a manager instance of the SDK to explore available information.
|
|
1034
|
+
* @function manager
|
|
1035
|
+
* @returns {IManager} The manager instance.
|
|
1036
|
+
*/
|
|
1037
|
+
manager(): IAsyncManager
|
|
1038
|
+
}
|
|
824
1039
|
/**
|
|
825
1040
|
* This represents the interface for the Client instance with synchronous storage for server-side SDK, where we don't have only one key.
|
|
826
1041
|
* @interface IClient
|
|
@@ -828,35 +1043,35 @@ declare namespace SplitIO {
|
|
|
828
1043
|
*/
|
|
829
1044
|
interface IClientSS extends IBasicClient {
|
|
830
1045
|
/**
|
|
831
|
-
* Returns a Treatment value, which
|
|
1046
|
+
* Returns a Treatment value, which is the treatment string for the given feature.
|
|
832
1047
|
* @function getTreatment
|
|
833
1048
|
* @param {string} key - The string key representing the consumer.
|
|
834
1049
|
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
835
1050
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
836
|
-
* @returns {Treatment} The treatment
|
|
1051
|
+
* @returns {Treatment} The treatment string.
|
|
837
1052
|
*/
|
|
838
1053
|
getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
|
|
839
1054
|
/**
|
|
840
|
-
* Returns a TreatmentWithConfig value
|
|
1055
|
+
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
841
1056
|
* @function getTreatmentWithConfig
|
|
842
1057
|
* @param {string} key - The string key representing the consumer.
|
|
843
1058
|
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
844
1059
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
845
|
-
* @returns {TreatmentWithConfig} The TreatmentWithConfig
|
|
846
|
-
*
|
|
1060
|
+
* @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
|
|
1061
|
+
* configuration stringified JSON (or null if there was no config for that treatment).
|
|
847
1062
|
*/
|
|
848
1063
|
getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
|
|
849
1064
|
/**
|
|
850
|
-
* Returns a Treatments value,
|
|
1065
|
+
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
851
1066
|
* @function getTreatments
|
|
852
1067
|
* @param {string} key - The string key representing the consumer.
|
|
853
1068
|
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
854
1069
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
855
|
-
* @returns {Treatments} The treatments
|
|
1070
|
+
* @returns {Treatments} The treatments object map.
|
|
856
1071
|
*/
|
|
857
1072
|
getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
|
|
858
1073
|
/**
|
|
859
|
-
* Returns a TreatmentsWithConfig value,
|
|
1074
|
+
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
860
1075
|
* @function getTreatmentsWithConfig
|
|
861
1076
|
* @param {string} key - The string key representing the consumer.
|
|
862
1077
|
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
@@ -872,7 +1087,7 @@ declare namespace SplitIO {
|
|
|
872
1087
|
* @param {string} eventType - The event type corresponding to this event.
|
|
873
1088
|
* @param {number=} value - The value of this event.
|
|
874
1089
|
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
875
|
-
* @returns {boolean} Whether the event was added to the queue
|
|
1090
|
+
* @returns {boolean} Whether the event was added to the queue successfully or not.
|
|
876
1091
|
*/
|
|
877
1092
|
track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
|
|
878
1093
|
}
|
|
@@ -894,7 +1109,7 @@ declare namespace SplitIO {
|
|
|
894
1109
|
*/
|
|
895
1110
|
getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
|
|
896
1111
|
/**
|
|
897
|
-
* Returns a TreatmentWithConfig value, which will be (or eventually be)
|
|
1112
|
+
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
898
1113
|
* For usage on NodeJS as we don't have only one key.
|
|
899
1114
|
* NOTE: Treatment will be a promise only in async storages, like REDIS.
|
|
900
1115
|
* @function getTreatmentWithConfig
|
|
@@ -905,17 +1120,17 @@ declare namespace SplitIO {
|
|
|
905
1120
|
*/
|
|
906
1121
|
getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
|
|
907
1122
|
/**
|
|
908
|
-
* Returns a Treatments value,
|
|
1123
|
+
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
909
1124
|
* For usage on NodeJS as we don't have only one key.
|
|
910
1125
|
* @function getTreatments
|
|
911
1126
|
* @param {string} key - The string key representing the consumer.
|
|
912
1127
|
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
913
1128
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
914
|
-
* @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object.
|
|
1129
|
+
* @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
|
|
915
1130
|
*/
|
|
916
1131
|
getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
|
|
917
1132
|
/**
|
|
918
|
-
* Returns a
|
|
1133
|
+
* Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
919
1134
|
* For usage on NodeJS as we don't have only one key.
|
|
920
1135
|
* @function getTreatmentsWithConfig
|
|
921
1136
|
* @param {string} key - The string key representing the consumer.
|
|
@@ -932,7 +1147,7 @@ declare namespace SplitIO {
|
|
|
932
1147
|
* @param {string} eventType - The event type corresponding to this event.
|
|
933
1148
|
* @param {number=} value - The value of this event.
|
|
934
1149
|
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
935
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue
|
|
1150
|
+
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
|
|
936
1151
|
*/
|
|
937
1152
|
track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
|
|
938
1153
|
}
|
|
@@ -943,31 +1158,31 @@ declare namespace SplitIO {
|
|
|
943
1158
|
*/
|
|
944
1159
|
interface IClient extends IBasicClient {
|
|
945
1160
|
/**
|
|
946
|
-
* Returns a Treatment value, which
|
|
1161
|
+
* Returns a Treatment value, which is the treatment string for the given feature.
|
|
947
1162
|
* @function getTreatment
|
|
948
1163
|
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
949
1164
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
950
|
-
* @returns {Treatment} The treatment
|
|
1165
|
+
* @returns {Treatment} The treatment string.
|
|
951
1166
|
*/
|
|
952
1167
|
getTreatment(splitName: string, attributes?: Attributes): Treatment,
|
|
953
1168
|
/**
|
|
954
|
-
* Returns a TreatmentWithConfig value, which
|
|
955
|
-
* @function
|
|
1169
|
+
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1170
|
+
* @function getTreatmentWithConfig
|
|
956
1171
|
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
957
1172
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
958
|
-
* @returns {TreatmentWithConfig} The treatment or
|
|
1173
|
+
* @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
|
|
959
1174
|
*/
|
|
960
1175
|
getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
|
|
961
1176
|
/**
|
|
962
|
-
* Returns a Treatments value,
|
|
1177
|
+
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
963
1178
|
* @function getTreatments
|
|
964
1179
|
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
965
1180
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
966
|
-
* @returns {Treatments} The treatments
|
|
1181
|
+
* @returns {Treatments} The treatments object map.
|
|
967
1182
|
*/
|
|
968
1183
|
getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
|
|
969
1184
|
/**
|
|
970
|
-
* Returns a TreatmentsWithConfig value,
|
|
1185
|
+
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
971
1186
|
* @function getTreatmentsWithConfig
|
|
972
1187
|
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
973
1188
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
@@ -981,10 +1196,59 @@ declare namespace SplitIO {
|
|
|
981
1196
|
* @param {string} eventType - The event type corresponding to this event.
|
|
982
1197
|
* @param {number=} value - The value of this event.
|
|
983
1198
|
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
984
|
-
* @returns {boolean} Whether the event was added to the queue
|
|
1199
|
+
* @returns {boolean} Whether the event was added to the queue successfully or not.
|
|
985
1200
|
*/
|
|
986
1201
|
track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
|
|
987
1202
|
}
|
|
1203
|
+
/**
|
|
1204
|
+
* This represents the interface for the Client instance with asynchronous storage for client-side SDK, where each client has associated a key.
|
|
1205
|
+
* @interface IAsyncClient
|
|
1206
|
+
* @extends IBasicClient
|
|
1207
|
+
*/
|
|
1208
|
+
interface IAsyncClient extends IBasicClient {
|
|
1209
|
+
/**
|
|
1210
|
+
* Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
|
|
1211
|
+
* @function getTreatment
|
|
1212
|
+
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1213
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1214
|
+
* @returns {AsyncTreatment} Treatment promise which will resolve to the treatment string.
|
|
1215
|
+
*/
|
|
1216
|
+
getTreatment(splitName: string, attributes?: Attributes): AsyncTreatment,
|
|
1217
|
+
/**
|
|
1218
|
+
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1219
|
+
* @function getTreatmentWithConfig
|
|
1220
|
+
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1221
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1222
|
+
* @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise which will resolve to the TreatmentWithConfig object.
|
|
1223
|
+
*/
|
|
1224
|
+
getTreatmentWithConfig(splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
|
|
1225
|
+
/**
|
|
1226
|
+
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1227
|
+
* @function getTreatments
|
|
1228
|
+
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1229
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1230
|
+
* @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
|
|
1231
|
+
*/
|
|
1232
|
+
getTreatments(splitNames: string[], attributes?: Attributes): AsyncTreatments,
|
|
1233
|
+
/**
|
|
1234
|
+
* Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1235
|
+
* @function getTreatmentsWithConfig
|
|
1236
|
+
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1237
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1238
|
+
* @returns {TreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
|
|
1239
|
+
*/
|
|
1240
|
+
getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
|
|
1241
|
+
/**
|
|
1242
|
+
* Tracks an event to be fed to the results product on Split Webconsole and returns a promise to signal when the event was successfully queued (or not).
|
|
1243
|
+
* @function track
|
|
1244
|
+
* @param {string} trafficType - The traffic type of the entity related to this event.
|
|
1245
|
+
* @param {string} eventType - The event type corresponding to this event.
|
|
1246
|
+
* @param {number=} value - The value of this event.
|
|
1247
|
+
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1248
|
+
* @returns {boolean} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
|
|
1249
|
+
*/
|
|
1250
|
+
track(trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>,
|
|
1251
|
+
}
|
|
988
1252
|
/**
|
|
989
1253
|
* Representation of a manager instance with synchronous storage of the SDK.
|
|
990
1254
|
* @interface IManager
|
|
@@ -996,20 +1260,20 @@ declare namespace SplitIO {
|
|
|
996
1260
|
* @function names
|
|
997
1261
|
* @returns {SplitNames} The lists of Split names.
|
|
998
1262
|
*/
|
|
999
|
-
names(): SplitNames
|
|
1263
|
+
names(): SplitNames,
|
|
1000
1264
|
/**
|
|
1001
1265
|
* Get the array of splits data in SplitView format.
|
|
1002
1266
|
* @function splits
|
|
1003
1267
|
* @returns {SplitViews} The list of SplitIO.SplitView.
|
|
1004
1268
|
*/
|
|
1005
|
-
splits(): SplitViews
|
|
1269
|
+
splits(): SplitViews,
|
|
1006
1270
|
/**
|
|
1007
1271
|
* Get the data of a split in SplitView format.
|
|
1008
1272
|
* @function split
|
|
1009
1273
|
* @param {string} splitName The name of the split we wan't to get info of.
|
|
1010
1274
|
* @returns {SplitView} The SplitIO.SplitView of the given split.
|
|
1011
1275
|
*/
|
|
1012
|
-
split(splitName: string): SplitView
|
|
1276
|
+
split(splitName: string): SplitView,
|
|
1013
1277
|
}
|
|
1014
1278
|
/**
|
|
1015
1279
|
* Representation of a manager instance with asynchronous storage of the SDK.
|
|
@@ -1022,19 +1286,19 @@ declare namespace SplitIO {
|
|
|
1022
1286
|
* @function names
|
|
1023
1287
|
* @returns {SplitNamesAsync} A promise that will resolve to the array of Splitio.SplitNames.
|
|
1024
1288
|
*/
|
|
1025
|
-
names(): SplitNamesAsync
|
|
1289
|
+
names(): SplitNamesAsync,
|
|
1026
1290
|
/**
|
|
1027
1291
|
* Get the array of splits data in SplitView format.
|
|
1028
1292
|
* @function splits
|
|
1029
1293
|
* @returns {SplitViewsAsync} A promise that will resolve to the SplitIO.SplitView list.
|
|
1030
1294
|
*/
|
|
1031
|
-
splits(): SplitViewsAsync
|
|
1295
|
+
splits(): SplitViewsAsync,
|
|
1032
1296
|
/**
|
|
1033
1297
|
* Get the data of a split in SplitView format.
|
|
1034
1298
|
* @function split
|
|
1035
1299
|
* @param {string} splitName The name of the split we wan't to get info of.
|
|
1036
1300
|
* @returns {SplitViewAsync} A promise that will resolve to the SplitIO.SplitView value.
|
|
1037
1301
|
*/
|
|
1038
|
-
split(splitName: string): SplitViewAsync
|
|
1302
|
+
split(splitName: string): SplitViewAsync,
|
|
1039
1303
|
}
|
|
1040
1304
|
}
|