@splitsoftware/splitio 10.16.1 → 10.17.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.
@@ -188,7 +188,7 @@ interface ISharedSettings {
188
188
  * Possible values are 'DEBUG' and 'OPTIMIZED'.
189
189
  * - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
190
190
  * - OPTIMIZED: will send unique impressions to Split Servers avoiding a considerable amount of traffic that duplicated impressions could generate.
191
- * @property {String} impressionsMode
191
+ * @property {string} impressionsMode
192
192
  * @default 'OPTIMIZED'
193
193
  */
194
194
  impressionsMode?: SplitIO.ImpressionsMode,
@@ -481,16 +481,21 @@ declare namespace SplitIO {
481
481
  */
482
482
  type Event = 'init::timeout' | 'init::ready' | 'init::cache-ready' | 'state::update';
483
483
  /**
484
- * Split attributes should be on object with values of type string or number (dates should be sent as millis since epoch).
485
- * @typedef {Object.<number, string, boolean, string[], number[]>} Attributes
484
+ * Split attributes should be on object with values of type string, boolean, number (dates should be sent as millis since epoch) or array of strings or numbers.
485
+ * @typedef {Object.<AttributeType>} Attributes
486
486
  * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax}
487
487
  */
488
488
  type Attributes = {
489
- [attributeName: string]: string | number | boolean | Array<string | number>
489
+ [attributeName: string]: AttributeType
490
490
  };
491
+ /**
492
+ * Type of an attribute value
493
+ * @typedef {string | number | boolean | Array<string | number>} AttributeType
494
+ */
495
+ type AttributeType = string | number | boolean | Array<string | number>;
491
496
  /**
492
497
  * Split properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb.
493
- * @typedef {Object.<number, string, boolean, null>} Attributes
498
+ * @typedef {Object.<number, string, boolean, null>} Properties
494
499
  * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track
495
500
  */
496
501
  type Properties = {
@@ -1019,7 +1024,7 @@ declare namespace SplitIO {
1019
1024
  }
1020
1025
  /**
1021
1026
  * Settings interface with async storage for SDK instances created on NodeJS.
1022
- * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.INodeSyncSettings instead.
1027
+ * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.INodeSettings instead.
1023
1028
  * @interface INodeAsyncSettings
1024
1029
  * @extends INodeBasicSettings
1025
1030
  * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
@@ -1071,6 +1076,27 @@ declare namespace SplitIO {
1071
1076
  */
1072
1077
  manager(): IManager
1073
1078
  }
1079
+ /**
1080
+ * This represents the interface for the SDK instance with synchronous storage.
1081
+ * @interface ISDK
1082
+ * @extends IBasicSDK
1083
+ */
1084
+ interface IBrowserSDK extends ISDK {
1085
+ /**
1086
+ * Returns the default client instance of the SDK.
1087
+ * @function client
1088
+ * @returns {IBrowserClient} The client instance.
1089
+ */
1090
+ client(): IBrowserClient,
1091
+ /**
1092
+ * Returns a shared client of the SDK. For usage on the browser.
1093
+ * @function client
1094
+ * @param {SplitKey} key The key for the new client instance.
1095
+ * @param {string=} trafficType The traffic type of the provided key.
1096
+ * @returns {IBrowserClient} The client instance.
1097
+ */
1098
+ client(key: SplitKey, trafficType?: string): IBrowserClient
1099
+ }
1074
1100
  /**
1075
1101
  * This represents the interface for the SDK instance with asynchronous storage.
1076
1102
  * @interface IAsyncSDK
@@ -1097,67 +1123,68 @@ declare namespace SplitIO {
1097
1123
  */
1098
1124
  interface IClient extends IBasicClient {
1099
1125
  /**
1100
- * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1126
+ * Returns a Treatment value, which is the treatment string for the given feature.
1101
1127
  * For usage on NodeJS as we don't have only one key.
1102
1128
  * @function getTreatment
1103
1129
  * @param {string} key - The string key representing the consumer.
1104
1130
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1105
1131
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1106
- * @returns {Treatment} The treatment or treatment promise which will resolve to the treatment string.
1132
+ * @returns {Treatment} The treatment string.
1107
1133
  */
1108
1134
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
1109
1135
  /**
1110
- * Returns a Treatment value, which will be the treatment string for the given feature.
1136
+ * Returns a Treatment value, which is the treatment string for the given feature.
1111
1137
  * For usage on the Browser as we defined the key on the settings.
1112
1138
  * @function getTreatment
1113
1139
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1114
1140
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1115
- * @returns {Treatment} The treatment result.
1141
+ * @returns {Treatment} The treatment string.
1116
1142
  */
1117
1143
  getTreatment(splitName: string, attributes?: Attributes): Treatment,
1118
1144
  /**
1119
- * 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.
1145
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
1120
1146
  * For usage on NodeJS as we don't have only one key.
1121
1147
  * @function getTreatmentWithConfig
1122
1148
  * @param {string} key - The string key representing the consumer.
1123
1149
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1124
1150
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1125
- * @returns {TreatmentWithConfig} The TreatmentWithConfig or TreatmentWithConfig promise which will resolve to the map containing
1126
- * the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
1151
+ * @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
1152
+ * configuration stringified JSON (or null if there was no config for that treatment).
1127
1153
  */
1128
1154
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
1129
1155
  /**
1130
- * Returns a TreatmentWithConfig value, which will be a map of treatment and the config for that treatment.
1156
+ * Returns a TreatmentWithConfig value, which an object with both treatment and config string for the given feature.
1131
1157
  * For usage on the Browser as we defined the key on the settings.
1132
1158
  * @function getTreatment
1133
1159
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1134
1160
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1135
- * @returns {TreatmentWithConfig} The treatment or treatment promise which will resolve to the treatment string.
1161
+ * @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
1162
+ * configuration stringified JSON (or null if there was no config for that treatment).
1136
1163
  */
1137
1164
  getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
1138
1165
  /**
1139
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1166
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
1140
1167
  * For usage on NodeJS as we don't have only one key.
1141
1168
  * NOTE: Treatment will be a promise only in async storages, like REDIS.
1142
1169
  * @function getTreatments
1143
1170
  * @param {string} key - The string key representing the consumer.
1144
1171
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1145
1172
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1146
- * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1173
+ * @returns {Treatments} The treatments object map.
1147
1174
  */
1148
1175
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
1149
1176
  /**
1150
- * 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.
1151
1178
  * For usage on the Browser as we defined the key on the settings.
1152
1179
  * NOTE: Treatment will be a promise only in async storages, like REDIS.
1153
1180
  * @function getTreatments
1154
1181
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1155
1182
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1156
- * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1183
+ * @returns {Treatments} The treatments object map.
1157
1184
  */
1158
1185
  getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
1159
1186
  /**
1160
- * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
1187
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1161
1188
  * For usage on NodeJS as we don't have only one key.
1162
1189
  * @function getTreatmentsWithConfig
1163
1190
  * @param {string} key - The string key representing the consumer.
@@ -1167,7 +1194,7 @@ declare namespace SplitIO {
1167
1194
  */
1168
1195
  getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
1169
1196
  /**
1170
- * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
1197
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1171
1198
  * For usage on the Browser as we defined the key on the settings.
1172
1199
  * @function getTreatmentsWithConfig
1173
1200
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
@@ -1184,7 +1211,7 @@ declare namespace SplitIO {
1184
1211
  * @param {string} eventType - The event type corresponding to this event.
1185
1212
  * @param {number=} value - The value of this event.
1186
1213
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1187
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1214
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1188
1215
  */
1189
1216
  track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1190
1217
  /**
@@ -1195,7 +1222,7 @@ declare namespace SplitIO {
1195
1222
  * @param {string} eventType - The event type corresponding to this event.
1196
1223
  * @param {number=} value - The value of this event.
1197
1224
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1198
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1225
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1199
1226
  */
1200
1227
  track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1201
1228
  /**
@@ -1205,10 +1232,58 @@ declare namespace SplitIO {
1205
1232
  * @param {string} eventType - The event type corresponding to this event.
1206
1233
  * @param {number=} value - The value of this event.
1207
1234
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1208
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1235
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1209
1236
  */
1210
1237
  track(eventType: string, value?: number, properties?: Properties): boolean
1211
1238
  }
1239
+ /**
1240
+ * This represents the interface for the Client instance with attributes binding.
1241
+ * @interface IBrowserClient
1242
+ * @Extends IClient
1243
+ */
1244
+ interface IBrowserClient extends IClient {
1245
+ /**
1246
+ * Add an attribute to client's in memory attributes storage.
1247
+ *
1248
+ * @param {string} attributeName Attrinute name
1249
+ * @param {AttributeType} attributeValue Attribute value
1250
+ * @returns {boolean} true if the attribute was stored and false otherwise
1251
+ */
1252
+ setAttribute(attributeName: string, attributeValue: AttributeType): boolean,
1253
+ /**
1254
+ * Returns the attribute with the given key.
1255
+ *
1256
+ * @param {string} attributeName Attribute name
1257
+ * @returns {AttributeType} Attribute with the given key
1258
+ */
1259
+ getAttribute(attributeName: string): AttributeType,
1260
+ /**
1261
+ * Removes from client's in memory attributes storage the attribute with the given key.
1262
+ *
1263
+ * @param {string} attributeName
1264
+ * @returns {boolean} true if attribute was removed and false otherwise
1265
+ */
1266
+ removeAttribute(attributeName: string): boolean,
1267
+ /**
1268
+ * Add to client's in memory attributes storage the attributes in 'attributes'.
1269
+ *
1270
+ * @param {Attributes} attributes Object with attributes to store
1271
+ * @returns true if attributes were stored an false otherwise
1272
+ */
1273
+ setAttributes(attributes: Attributes): boolean,
1274
+ /**
1275
+ * Return all the attributes stored in client's in memory attributes storage.
1276
+ *
1277
+ * @returns {Attributes} returns all the stored attributes
1278
+ */
1279
+ getAttributes(): Attributes,
1280
+ /**
1281
+ * Remove all the stored attributes in the client's in memory attribute storage.
1282
+ *
1283
+ * @returns {boolean} true if all attribute were removed and false otherwise
1284
+ */
1285
+ clearAttributes(): boolean
1286
+ }
1212
1287
  /**
1213
1288
  * This represents the interface for the Client instance with asynchronous storage.
1214
1289
  * @interface IAsyncClient
@@ -1227,7 +1302,7 @@ declare namespace SplitIO {
1227
1302
  */
1228
1303
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
1229
1304
  /**
1230
- * Returns a TreatmentWithConfig value, which will be (or eventually be) a map with both treatment and config string for the given feature.
1305
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
1231
1306
  * For usage on NodeJS as we don't have only one key.
1232
1307
  * NOTE: Treatment will be a promise only in async storages, like REDIS.
1233
1308
  * @function getTreatmentWithConfig
@@ -1238,17 +1313,17 @@ declare namespace SplitIO {
1238
1313
  */
1239
1314
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
1240
1315
  /**
1241
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1316
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
1242
1317
  * For usage on NodeJS as we don't have only one key.
1243
1318
  * @function getTreatments
1244
1319
  * @param {string} key - The string key representing the consumer.
1245
1320
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1246
1321
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1247
- * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object.
1322
+ * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
1248
1323
  */
1249
1324
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
1250
1325
  /**
1251
- * 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.
1326
+ * 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.
1252
1327
  * For usage on NodeJS as we don't have only one key.
1253
1328
  * @function getTreatmentsWithConfig
1254
1329
  * @param {string} key - The string key representing the consumer.
@@ -1265,7 +1340,7 @@ declare namespace SplitIO {
1265
1340
  * @param {string} eventType - The event type corresponding to this event.
1266
1341
  * @param {number=} value - The value of this event.
1267
1342
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1268
- * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue succesfully or not.
1343
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
1269
1344
  */
1270
1345
  track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
1271
1346
  }