@splitsoftware/splitio-browserjs 0.1.1-canary.2 → 0.2.1-rc.1

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.
@@ -1,4 +1,4 @@
1
- // Type definitions for Javascript Browser Split Software SDK v1.0.0
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,11 @@ 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';
35
40
  /**
36
41
  * Storage types.
37
42
  * @typedef {string} StorageType
@@ -49,6 +54,7 @@ interface ISettings {
49
54
  labelsEnabled: boolean,
50
55
  IPAddressesEnabled: boolean
51
56
  },
57
+ readonly mode: SDKMode,
52
58
  readonly scheduler: {
53
59
  featuresRefreshRate: number,
54
60
  impressionsRefreshRate: number,
@@ -64,7 +70,7 @@ interface ISettings {
64
70
  retriesOnFailureBeforeReady: number,
65
71
  eventsFirstPushWindow: number
66
72
  },
67
- readonly storage?: SplitIO.StorageSyncFactory,
73
+ readonly storage?: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory,
68
74
  readonly urls: {
69
75
  events: string,
70
76
  sdk: string,
@@ -82,6 +88,7 @@ interface ISettings {
82
88
  readonly sync: {
83
89
  splitFilters: SplitIO.SplitFilter[],
84
90
  impressionsMode: SplitIO.ImpressionsMode,
91
+ localhostMode?: SplitIO.LocalhostFactory
85
92
  }
86
93
  }
87
94
  /**
@@ -182,17 +189,20 @@ interface ISharedSettings {
182
189
  */
183
190
  impressionsMode?: SplitIO.ImpressionsMode,
184
191
  /**
185
- * Defines the factory function to instanciate the SDK in localhost mode.
192
+ * Defines the factory function to instantiate the SDK in localhost mode.
193
+ *
186
194
  * NOTE: this is only required if using the slim entry point of the library to init the SDK in localhost mode.
195
+ *
187
196
  * For more information @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
188
197
  *
189
198
  * Example:
190
199
  * ```typescript
191
- * config: {
200
+ * SplitFactory({
201
+ * ...
192
202
  * sync: {
193
203
  * localhostMode: LocalhostFromObject()
194
204
  * }
195
- * }
205
+ * })
196
206
  * ```
197
207
  * @property {Object} localhostMode
198
208
  */
@@ -367,7 +377,7 @@ declare namespace SplitIO {
367
377
  * Localhost types.
368
378
  * @typedef {string} LocalhostType
369
379
  */
370
- type LocalhostType = 'FROM_OBJECT' | 'FROM_FILE'
380
+ type LocalhostType = 'LocalhostFromObject'
371
381
  /**
372
382
  * Object with information about an impression. It contains the generated impression DTO as well as
373
383
  * complementary information around where and how it was generated in that way.
@@ -463,11 +473,11 @@ declare namespace SplitIO {
463
473
  * Input parameter details are not part of the public API.
464
474
  */
465
475
  type StorageSyncFactory = {
466
- type: StorageType
476
+ readonly type: StorageType
467
477
  (params: {}): (StorageSync | undefined)
468
478
  }
469
479
  /**
470
- * Configuration params for InLocalStorage plugable storage
480
+ * Configuration params for `InLocalStorage`
471
481
  */
472
482
  type InLocalStorageOptions = {
473
483
  /**
@@ -477,12 +487,41 @@ declare namespace SplitIO {
477
487
  */
478
488
  prefix?: string
479
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
+ }
480
519
  /**
481
520
  * Localhost mode factory.
482
521
  * Its interface details are not part of the public API.
483
522
  */
484
523
  type LocalhostFactory = {
485
- type: LocalhostType
524
+ readonly type: LocalhostType
486
525
  (params: {}): {}
487
526
  }
488
527
  /**
@@ -703,13 +742,87 @@ declare namespace SplitIO {
703
742
  interface ILogger {
704
743
  setLogLevel(logLevel: LogLevel): void
705
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
+ }
706
793
  /**
707
794
  * Settings interface for SDK instances created on the browser.
708
795
  * @interface IBrowserSettings
709
796
  * @extends ISharedSettings
710
797
  * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
711
798
  */
712
- interface IBrowserSettings extends ISharedSettings {
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,
713
826
  /**
714
827
  * SDK Startup settings for the Browser.
715
828
  * @property {Object} startup
@@ -792,64 +905,89 @@ declare namespace SplitIO {
792
905
  * @default 1
793
906
  */
794
907
  pushRetryBackoffBase?: number,
795
- },
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 {
796
918
  /**
797
- * SDK Core settings for the browser.
798
- * @property {Object} core
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
799
924
  */
800
- core: {
801
- /**
802
- * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
803
- * @property {string} authorizationKey
804
- */
805
- authorizationKey: string,
806
- /**
807
- * Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
808
- * @property {SplitKey} key
809
- */
810
- key: SplitKey,
811
- /**
812
- * Disable labels from being sent to Split backend. Labels may contain sensitive information.
813
- * @property {boolean} labelsEnabled
814
- * @default true
815
- */
816
- labelsEnabled?: boolean
817
- },
925
+ mode: 'consumer' | 'consumer_partial',
818
926
  /**
819
- * Mocked features map. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
820
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
821
- */
822
- features?: MockedFeaturesMap,
823
- /**
824
- * Defines the factory function to instanciate the storage. If not provided, the default IN MEMORY storage is used.
927
+ * Defines the factory function to instantiate the storage.
825
928
  *
826
929
  * Example:
827
930
  * ```typescript
828
- * config: {
829
- * storage: InLocalStorage()
830
- * }
931
+ * SplitFactory({
932
+ * ...
933
+ * storage: PluggableStorage({ wrapper: SomeWrapper })
934
+ * })
831
935
  * ```
832
936
  * @property {Object} storage
833
937
  */
834
- storage?: StorageSyncFactory,
938
+ storage: StorageAsyncFactory,
835
939
  /**
836
- * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
837
- * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
838
- * @property {Object} urls
940
+ * SDK Startup settings for the Browser.
941
+ * @property {Object} startup
839
942
  */
840
- urls?: UrlSettings,
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
+ },
841
960
  /**
842
- * Defines an optional list of factory functions used to instantiate SDK integrations.
843
- *
844
- * Example:
845
- * ```typescript
846
- * config: {
847
- * integrations: [SplitToGoogleAnalytics(), GoogleAnalyticsToSplit()]
848
- * }
849
- * ```
850
- * @property {Object} integrations
961
+ * SDK scheduler settings.
962
+ * @property {Object} scheduler
851
963
  */
852
- integrations?: IntegrationFactory[],
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
+ }
853
991
  }
854
992
  /**
855
993
  * This represents the interface for the SDK instance with synchronous storage and client-side API,
@@ -857,7 +995,7 @@ declare namespace SplitIO {
857
995
  * @interface ISDK
858
996
  * @extends IBasicSDK
859
997
  */
860
- export interface ISDK extends IBasicSDK {
998
+ interface ISDK extends IBasicSDK {
861
999
  /**
862
1000
  * Returns the default client instance of the SDK, associated with the key and optional traffic type from settings.
863
1001
  * @function client
@@ -878,7 +1016,26 @@ declare namespace SplitIO {
878
1016
  */
879
1017
  manager(): IManager
880
1018
  }
881
-
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
+ }
882
1039
  /**
883
1040
  * This represents the interface for the Client instance with synchronous storage for server-side SDK, where we don't have only one key.
884
1041
  * @interface IClient
@@ -886,35 +1043,35 @@ declare namespace SplitIO {
886
1043
  */
887
1044
  interface IClientSS extends IBasicClient {
888
1045
  /**
889
- * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1046
+ * Returns a Treatment value, which is the treatment string for the given feature.
890
1047
  * @function getTreatment
891
1048
  * @param {string} key - The string key representing the consumer.
892
1049
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
893
1050
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
894
- * @returns {Treatment} The treatment or treatment promise which will resolve to the treatment string.
1051
+ * @returns {Treatment} The treatment string.
895
1052
  */
896
1053
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
897
1054
  /**
898
- * Returns a TreatmentWithConfig value (a map of treatment and config), which will be (or eventually be) the map with treatment and config for the given feature.
1055
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
899
1056
  * @function getTreatmentWithConfig
900
1057
  * @param {string} key - The string key representing the consumer.
901
1058
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
902
1059
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
903
- * @returns {TreatmentWithConfig} The TreatmentWithConfig or TreatmentWithConfig promise which will resolve to the map containing
904
- * the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
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).
905
1062
  */
906
1063
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
907
1064
  /**
908
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1065
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
909
1066
  * @function getTreatments
910
1067
  * @param {string} key - The string key representing the consumer.
911
1068
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
912
1069
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
913
- * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1070
+ * @returns {Treatments} The treatments object map.
914
1071
  */
915
1072
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
916
1073
  /**
917
- * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
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.
918
1075
  * @function getTreatmentsWithConfig
919
1076
  * @param {string} key - The string key representing the consumer.
920
1077
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
@@ -930,7 +1087,7 @@ declare namespace SplitIO {
930
1087
  * @param {string} eventType - The event type corresponding to this event.
931
1088
  * @param {number=} value - The value of this event.
932
1089
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
933
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1090
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
934
1091
  */
935
1092
  track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
936
1093
  }
@@ -952,7 +1109,7 @@ declare namespace SplitIO {
952
1109
  */
953
1110
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
954
1111
  /**
955
- * Returns a TreatmentWithConfig value, which will be (or eventually be) a map with both treatment and config string for the given feature.
1112
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
956
1113
  * For usage on NodeJS as we don't have only one key.
957
1114
  * NOTE: Treatment will be a promise only in async storages, like REDIS.
958
1115
  * @function getTreatmentWithConfig
@@ -963,17 +1120,17 @@ declare namespace SplitIO {
963
1120
  */
964
1121
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
965
1122
  /**
966
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1123
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
967
1124
  * For usage on NodeJS as we don't have only one key.
968
1125
  * @function getTreatments
969
1126
  * @param {string} key - The string key representing the consumer.
970
1127
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
971
1128
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
972
- * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object.
1129
+ * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
973
1130
  */
974
1131
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
975
1132
  /**
976
- * Returns a Treatments value, whick will be (or eventually be) an object with all the maps of treatment and config string for the given features.
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.
977
1134
  * For usage on NodeJS as we don't have only one key.
978
1135
  * @function getTreatmentsWithConfig
979
1136
  * @param {string} key - The string key representing the consumer.
@@ -990,7 +1147,7 @@ declare namespace SplitIO {
990
1147
  * @param {string} eventType - The event type corresponding to this event.
991
1148
  * @param {number=} value - The value of this event.
992
1149
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
993
- * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue succesfully or not.
1150
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
994
1151
  */
995
1152
  track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
996
1153
  }
@@ -1001,31 +1158,31 @@ declare namespace SplitIO {
1001
1158
  */
1002
1159
  interface IClient extends IBasicClient {
1003
1160
  /**
1004
- * Returns a Treatment value, which will be the treatment string for the given feature.
1161
+ * Returns a Treatment value, which is the treatment string for the given feature.
1005
1162
  * @function getTreatment
1006
1163
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1007
1164
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1008
- * @returns {Treatment} The treatment result.
1165
+ * @returns {Treatment} The treatment string.
1009
1166
  */
1010
1167
  getTreatment(splitName: string, attributes?: Attributes): Treatment,
1011
1168
  /**
1012
- * Returns a TreatmentWithConfig value, which will be a map of treatment and the config for that treatment.
1013
- * @function getTreatment
1169
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
1170
+ * @function getTreatmentWithConfig
1014
1171
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1015
1172
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1016
- * @returns {TreatmentWithConfig} The treatment or treatment promise which will resolve to the treatment string.
1173
+ * @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
1017
1174
  */
1018
1175
  getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
1019
1176
  /**
1020
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1177
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
1021
1178
  * @function getTreatments
1022
1179
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1023
1180
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1024
- * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1181
+ * @returns {Treatments} The treatments object map.
1025
1182
  */
1026
1183
  getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
1027
1184
  /**
1028
- * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
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.
1029
1186
  * @function getTreatmentsWithConfig
1030
1187
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1031
1188
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
@@ -1039,10 +1196,59 @@ declare namespace SplitIO {
1039
1196
  * @param {string} eventType - The event type corresponding to this event.
1040
1197
  * @param {number=} value - The value of this event.
1041
1198
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1042
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1199
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1043
1200
  */
1044
1201
  track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1045
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
+ }
1046
1252
  /**
1047
1253
  * Representation of a manager instance with synchronous storage of the SDK.
1048
1254
  * @interface IManager
@@ -1054,20 +1260,20 @@ declare namespace SplitIO {
1054
1260
  * @function names
1055
1261
  * @returns {SplitNames} The lists of Split names.
1056
1262
  */
1057
- names(): SplitNames;
1263
+ names(): SplitNames,
1058
1264
  /**
1059
1265
  * Get the array of splits data in SplitView format.
1060
1266
  * @function splits
1061
1267
  * @returns {SplitViews} The list of SplitIO.SplitView.
1062
1268
  */
1063
- splits(): SplitViews;
1269
+ splits(): SplitViews,
1064
1270
  /**
1065
1271
  * Get the data of a split in SplitView format.
1066
1272
  * @function split
1067
1273
  * @param {string} splitName The name of the split we wan't to get info of.
1068
1274
  * @returns {SplitView} The SplitIO.SplitView of the given split.
1069
1275
  */
1070
- split(splitName: string): SplitView;
1276
+ split(splitName: string): SplitView,
1071
1277
  }
1072
1278
  /**
1073
1279
  * Representation of a manager instance with asynchronous storage of the SDK.
@@ -1080,19 +1286,19 @@ declare namespace SplitIO {
1080
1286
  * @function names
1081
1287
  * @returns {SplitNamesAsync} A promise that will resolve to the array of Splitio.SplitNames.
1082
1288
  */
1083
- names(): SplitNamesAsync;
1289
+ names(): SplitNamesAsync,
1084
1290
  /**
1085
1291
  * Get the array of splits data in SplitView format.
1086
1292
  * @function splits
1087
1293
  * @returns {SplitViewsAsync} A promise that will resolve to the SplitIO.SplitView list.
1088
1294
  */
1089
- splits(): SplitViewsAsync;
1295
+ splits(): SplitViewsAsync,
1090
1296
  /**
1091
1297
  * Get the data of a split in SplitView format.
1092
1298
  * @function split
1093
1299
  * @param {string} splitName The name of the split we wan't to get info of.
1094
1300
  * @returns {SplitViewAsync} A promise that will resolve to the SplitIO.SplitView value.
1095
1301
  */
1096
- split(splitName: string): SplitViewAsync;
1302
+ split(splitName: string): SplitViewAsync,
1097
1303
  }
1098
1304
  }