kv-test-lib 3.5.1-rc.6 → 3.5.2-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.
- package/es5_dist/Capabilities.js +117 -0
- package/es5_dist/Capabilities.js.map +1 -0
- package/es5_dist/Context.js +6 -0
- package/es5_dist/Context.js.map +1 -0
- package/es5_dist/EncodableTo.js +6 -0
- package/es5_dist/EncodableTo.js.map +1 -0
- package/es5_dist/Host.js +92 -0
- package/es5_dist/Host.js.map +1 -0
- package/es5_dist/Kochava.Any.js +470 -0
- package/es5_dist/Kochava.Any.js.map +1 -0
- package/es5_dist/Kochava.URL.js +110 -0
- package/es5_dist/Kochava.URL.js.map +1 -0
- package/es5_dist/Networking.General.js +113 -0
- package/es5_dist/Networking.General.js.map +1 -0
- package/es5_dist/Networking.Timing.js +110 -0
- package/es5_dist/Networking.Timing.js.map +1 -0
- package/es5_dist/Networking.Transactions.IP.js +526 -0
- package/es5_dist/Networking.Transactions.IP.js.map +1 -0
- package/es5_dist/Networking.Transactions.URLs.js +299 -0
- package/es5_dist/Networking.Transactions.URLs.js.map +1 -0
- package/es5_dist/Networking.Transactions.js +108 -0
- package/es5_dist/Networking.Transactions.js.map +1 -0
- package/es5_dist/Networking.js +143 -0
- package/es5_dist/Networking.js.map +1 -0
- package/es5_dist/Transaction.js +88 -0
- package/es5_dist/Transaction.js.map +1 -0
- package/es5_dist/generated/buildInfo.js +2 -2
- package/es5_dist/generated/buildInfo.js.map +1 -1
- package/es5_dist/ipAlternate.js +285 -0
- package/es5_dist/ipAlternate.js.map +1 -0
- package/es5_dist/kochava.js +24 -0
- package/es5_dist/kochava.js.map +1 -1
- package/es5_dist/transactionURLs.js +183 -0
- package/es5_dist/transactionURLs.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Authored by John Bushnell on 06/29/23.
|
|
3
|
+
Copyright (c) Kochava, Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
// MARK: - Capabilities
|
|
6
|
+
var Capabilities = /** @class */function () {
|
|
7
|
+
// MARK: - 🆕 Creating an Instance of Capabilities
|
|
8
|
+
function Capabilities(array) {
|
|
9
|
+
if (array === void 0) {
|
|
10
|
+
array = null;
|
|
11
|
+
}
|
|
12
|
+
// MARK: - Constants
|
|
13
|
+
// MARK: let bitwiseIntegersBitCount
|
|
14
|
+
this.bitwiseIntegersBitCount = 32;
|
|
15
|
+
this.array = array;
|
|
16
|
+
}
|
|
17
|
+
Capabilities.creating = function (capabilities, subCapabilitiesArray) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
// array
|
|
20
|
+
var array = (_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.array) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
21
|
+
subCapabilitiesArray === null || subCapabilitiesArray === void 0 ? void 0 : subCapabilitiesArray.forEach(function (subCapabilities) {
|
|
22
|
+
var subCapabilitiesElementArray = subCapabilities.array;
|
|
23
|
+
if (!subCapabilitiesElementArray) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
array = array.concat(subCapabilitiesElementArray);
|
|
27
|
+
});
|
|
28
|
+
if (array.length === 0) {
|
|
29
|
+
return new Capabilities(null);
|
|
30
|
+
}
|
|
31
|
+
// self
|
|
32
|
+
// ⓘ Initialize.
|
|
33
|
+
return new Capabilities(array);
|
|
34
|
+
};
|
|
35
|
+
// MARK: - ⏬ Decoding
|
|
36
|
+
Capabilities.from = function (object) {
|
|
37
|
+
// VALIDATE ELSE RETURN
|
|
38
|
+
// objectSelf
|
|
39
|
+
if (object instanceof Capabilities) {
|
|
40
|
+
return object;
|
|
41
|
+
}
|
|
42
|
+
// dictionary
|
|
43
|
+
if (!object || typeof object !== "object" || Array.isArray(object)) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
var dictionary = object;
|
|
47
|
+
// MAIN
|
|
48
|
+
// capabilities
|
|
49
|
+
var arrayRaw = dictionary["array"];
|
|
50
|
+
var array = Array.isArray(arrayRaw) ? arrayRaw.filter(function (e) {
|
|
51
|
+
return typeof e === "number";
|
|
52
|
+
}).map(function (e) {
|
|
53
|
+
return e;
|
|
54
|
+
}) : null;
|
|
55
|
+
var capabilities = new Capabilities(array);
|
|
56
|
+
// return
|
|
57
|
+
return capabilities;
|
|
58
|
+
};
|
|
59
|
+
// MARK: - ⏫ Encoding
|
|
60
|
+
// MARK: c EncodableTo
|
|
61
|
+
Capabilities.prototype.to = function (context) {
|
|
62
|
+
// contextIsHostBool, contextIsLogBool, contextIsPersistentStorageBool, contextIsSDKBool, contextIsServerBool
|
|
63
|
+
var contextIsHostBool = context === "host";
|
|
64
|
+
var contextIsLogBool = context === "log";
|
|
65
|
+
var contextIsPersistentStorageBool = context === "persistentStorage";
|
|
66
|
+
var contextIsSDKBool = context === "sdk";
|
|
67
|
+
var contextIsServerBool = context === "server";
|
|
68
|
+
// dictionary
|
|
69
|
+
var dictionary = {};
|
|
70
|
+
if (contextIsPersistentStorageBool || contextIsSDKBool || contextIsLogBool || contextIsServerBool || contextIsHostBool) {
|
|
71
|
+
dictionary["array"] = this.array;
|
|
72
|
+
}
|
|
73
|
+
if (contextIsLogBool || contextIsServerBool) {
|
|
74
|
+
dictionary["bitwiseIntegersString"] = this.bitwiseIntegersString();
|
|
75
|
+
}
|
|
76
|
+
// return
|
|
77
|
+
return dictionary;
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(Capabilities.prototype, "description", {
|
|
80
|
+
// MARK: - ℹ️ Describing
|
|
81
|
+
get: function () {
|
|
82
|
+
var _a;
|
|
83
|
+
return "<Capabilities: bitwiseIntegersString = ".concat((_a = this.bitwiseIntegersString()) !== null && _a !== void 0 ? _a : "", ">");
|
|
84
|
+
},
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
// MARK: - Getting an Array of Bitwise Integers
|
|
89
|
+
Capabilities.prototype.bitwiseIntegersArray = function () {
|
|
90
|
+
var _a;
|
|
91
|
+
// bitCount
|
|
92
|
+
var bitCount = this.bitwiseIntegersBitCount;
|
|
93
|
+
// bitwiseIntegersArray
|
|
94
|
+
var bitwiseIntegersArray = [];
|
|
95
|
+
(_a = this.array) === null || _a === void 0 ? void 0 : _a.forEach(function (capability) {
|
|
96
|
+
var bitwiseIntegersArrayIndex = Math.floor(capability / bitCount);
|
|
97
|
+
var bitIndex = capability % bitCount;
|
|
98
|
+
var bitMask = 1 << bitIndex;
|
|
99
|
+
while (bitwiseIntegersArrayIndex >= bitwiseIntegersArray.length) {
|
|
100
|
+
bitwiseIntegersArray.push(0);
|
|
101
|
+
}
|
|
102
|
+
bitwiseIntegersArray[bitwiseIntegersArrayIndex] = bitwiseIntegersArray[bitwiseIntegersArrayIndex] | bitMask;
|
|
103
|
+
});
|
|
104
|
+
// return
|
|
105
|
+
return bitwiseIntegersArray.length > 0 ? bitwiseIntegersArray : null;
|
|
106
|
+
};
|
|
107
|
+
// MARK: - Getting a String of Bitwise Integers
|
|
108
|
+
Capabilities.prototype.bitwiseIntegersString = function () {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return (_b = (_a = this.bitwiseIntegersArray()) === null || _a === void 0 ? void 0 : _a.map(function (n) {
|
|
111
|
+
return String(n);
|
|
112
|
+
}).join(",")) !== null && _b !== void 0 ? _b : null;
|
|
113
|
+
};
|
|
114
|
+
return Capabilities;
|
|
115
|
+
}();
|
|
116
|
+
export { Capabilities };
|
|
117
|
+
//# sourceMappingURL=Capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node/Capabilities.js"],"names":["Capabilities","array","bitwiseIntegersBitCount","creating","capabilities","subCapabilitiesArray","_a","_b","slice","forEach","subCapabilities","subCapabilitiesElementArray","concat","length","from","object","Array","isArray","dictionary","arrayRaw","filter","e","map","prototype","to","context","contextIsHostBool","contextIsLogBool","contextIsPersistentStorageBool","contextIsSDKBool","contextIsServerBool","bitwiseIntegersString","Object","defineProperty","get","enumerable","configurable","bitwiseIntegersArray","bitCount","capability","bitwiseIntegersArrayIndex","Math","floor","bitIndex","bitMask","push","n","String","join"],"mappings":"AAAA;;;;AAIA;AACA,IAAIA,eAAe,aAAe,YAAY;AAC1C;AACA,aAASA,YAAT,CAAsBC,KAAtB,EAA6B;AACzB,YAAIA,UAAU,KAAK,CAAnB,EAAsB;AAAEA,oBAAQ,IAAR;AAAe;AACvC;AACA;AACA,aAAKC,uBAAL,GAA+B,EAA/B;AACA,aAAKD,KAAL,GAAaA,KAAb;AACH;AACDD,iBAAaG,QAAb,GAAwB,UAAUC,YAAV,EAAwBC,oBAAxB,EAA8C;AAClE,YAAIC,EAAJ,EAAQC,EAAR;AACA;AACA,YAAIN,QAAQ,CAACM,KAAK,CAACD,KAAKF,iBAAiB,IAAjB,IAAyBA,iBAAiB,KAAK,CAA/C,GAAmD,KAAK,CAAxD,GAA4DA,aAAaH,KAA/E,MAA0F,IAA1F,IAAkGK,OAAO,KAAK,CAA9G,GAAkH,KAAK,CAAvH,GAA2HA,GAAGE,KAAH,EAAjI,MAAiJ,IAAjJ,IAAyJD,OAAO,KAAK,CAArK,GAAyKA,EAAzK,GAA8K,EAA1L;AACAF,iCAAyB,IAAzB,IAAiCA,yBAAyB,KAAK,CAA/D,GAAmE,KAAK,CAAxE,GAA4EA,qBAAqBI,OAArB,CAA6B,UAAUC,eAAV,EAA2B;AAChI,gBAAIC,8BAA8BD,gBAAgBT,KAAlD;AACA,gBAAI,CAACU,2BAAL,EAAkC;AAC9B;AACH;AACDV,oBAAQA,MAAMW,MAAN,CAAaD,2BAAb,CAAR;AACH,SAN2E,CAA5E;AAOA,YAAIV,MAAMY,MAAN,KAAiB,CAArB,EAAwB;AACpB,mBAAO,IAAIb,YAAJ,CAAiB,IAAjB,CAAP;AACH;AACD;AACA;AACA,eAAO,IAAIA,YAAJ,CAAiBC,KAAjB,CAAP;AACH,K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ApE,GAAwEA,GAAGgB,GAAH,CAAO,UAAUwB,CAAV,EAAa;AAAE,mBAAOC,OAAOD,CAAP,CAAP;AAAmB,SAAzC,EAA2CE,IAA3C,CAAgD,GAAhD,CAA9E,MAAwI,IAAxI,IAAgJzC,OAAO,KAAK,CAA5J,GAAgKA,EAAhK,GAAqK,IAA5K;AACH,KAHD;AAIA,WAAOP,YAAP;AACH,CAzGiC,EAAlC;AA0GA,SAASA,YAAT","file":"Capabilities.js","sourcesContent":["/*\n Authored by John Bushnell on 06/29/23.\n Copyright (c) Kochava, Inc. All rights reserved.\n*/\n// MARK: - Capabilities\nvar Capabilities = /** @class */ (function () {\n // MARK: - 🆕 Creating an Instance of Capabilities\n function Capabilities(array) {\n if (array === void 0) { array = null; }\n // MARK: - Constants\n // MARK: let bitwiseIntegersBitCount\n this.bitwiseIntegersBitCount = 32;\n this.array = array;\n }\n Capabilities.creating = function (capabilities, subCapabilitiesArray) {\n var _a, _b;\n // array\n var array = (_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.array) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];\n subCapabilitiesArray === null || subCapabilitiesArray === void 0 ? void 0 : subCapabilitiesArray.forEach(function (subCapabilities) {\n var subCapabilitiesElementArray = subCapabilities.array;\n if (!subCapabilitiesElementArray) {\n return;\n }\n array = array.concat(subCapabilitiesElementArray);\n });\n if (array.length === 0) {\n return new Capabilities(null);\n }\n // self\n // ⓘ Initialize.\n return new Capabilities(array);\n };\n // MARK: - ⏬ Decoding\n Capabilities.from = function (object) {\n // VALIDATE ELSE RETURN\n // objectSelf\n if (object instanceof Capabilities) {\n return object;\n }\n // dictionary\n if (!object || typeof object !== \"object\" || Array.isArray(object)) {\n return null;\n }\n var dictionary = object;\n // MAIN\n // capabilities\n var arrayRaw = dictionary[\"array\"];\n var array = Array.isArray(arrayRaw)\n ? arrayRaw.filter(function (e) { return typeof e === \"number\"; }).map(function (e) { return e; })\n : null;\n var capabilities = new Capabilities(array);\n // return\n return capabilities;\n };\n // MARK: - ⏫ Encoding\n // MARK: c EncodableTo\n Capabilities.prototype.to = function (context) {\n // contextIsHostBool, contextIsLogBool, contextIsPersistentStorageBool, contextIsSDKBool, contextIsServerBool\n var contextIsHostBool = context === \"host\";\n var contextIsLogBool = context === \"log\";\n var contextIsPersistentStorageBool = context === \"persistentStorage\";\n var contextIsSDKBool = context === \"sdk\";\n var contextIsServerBool = context === \"server\";\n // dictionary\n var dictionary = {};\n if (contextIsPersistentStorageBool || contextIsSDKBool || contextIsLogBool || contextIsServerBool || contextIsHostBool) {\n dictionary[\"array\"] = this.array;\n }\n if (contextIsLogBool || contextIsServerBool) {\n dictionary[\"bitwiseIntegersString\"] = this.bitwiseIntegersString();\n }\n // return\n return dictionary;\n };\n Object.defineProperty(Capabilities.prototype, \"description\", {\n // MARK: - ℹ️ Describing\n get: function () {\n var _a;\n return \"<Capabilities: bitwiseIntegersString = \".concat((_a = this.bitwiseIntegersString()) !== null && _a !== void 0 ? _a : \"\", \">\");\n },\n enumerable: false,\n configurable: true\n });\n // MARK: - Getting an Array of Bitwise Integers\n Capabilities.prototype.bitwiseIntegersArray = function () {\n var _a;\n // bitCount\n var bitCount = this.bitwiseIntegersBitCount;\n // bitwiseIntegersArray\n var bitwiseIntegersArray = [];\n (_a = this.array) === null || _a === void 0 ? void 0 : _a.forEach(function (capability) {\n var bitwiseIntegersArrayIndex = Math.floor(capability / bitCount);\n var bitIndex = capability % bitCount;\n var bitMask = 1 << bitIndex;\n while (bitwiseIntegersArrayIndex >= bitwiseIntegersArray.length) {\n bitwiseIntegersArray.push(0);\n }\n bitwiseIntegersArray[bitwiseIntegersArrayIndex] = bitwiseIntegersArray[bitwiseIntegersArrayIndex] | bitMask;\n });\n // return\n return bitwiseIntegersArray.length > 0\n ? bitwiseIntegersArray\n : null;\n };\n // MARK: - Getting a String of Bitwise Integers\n Capabilities.prototype.bitwiseIntegersString = function () {\n var _a, _b;\n return (_b = (_a = this.bitwiseIntegersArray()) === null || _a === void 0 ? void 0 : _a.map(function (n) { return String(n); }).join(\",\")) !== null && _b !== void 0 ? _b : null;\n };\n return Capabilities;\n}());\nexport { Capabilities };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node/Context.js"],"names":[],"mappings":"AAAA;;;;AAIA","file":"Context.js","sourcesContent":["/*\n Authored by John Bushnell on 06/26/26.\n Copyright (c) Kochava, Inc. All rights reserved.\n*/\nexport {};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node/EncodableTo.js"],"names":[],"mappings":"AAAA;;;;AAIA","file":"EncodableTo.js","sourcesContent":["/*\n Authored by John Bushnell on 06/26/26.\n Copyright (c) Kochava, Inc. All rights reserved.\n*/\nexport {};\n"]}
|
package/es5_dist/Host.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Authored by John Bushnell on 06/25/26.
|
|
3
|
+
Copyright (c) Kochava, Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
var Host = /** @class */function () {
|
|
6
|
+
// MARK: - 🆕 Creating a Host
|
|
7
|
+
function Host(identifier) {
|
|
8
|
+
this.identifier = identifier;
|
|
9
|
+
// MARK: - Properties
|
|
10
|
+
/** Most recent successful attempt timestamp (ms), or null if never succeeded. */
|
|
11
|
+
this.didSucceedLastMs = null;
|
|
12
|
+
/** Most recent failed attempt timestamp (ms), or null if never failed. */
|
|
13
|
+
this.didFailLastMs = null;
|
|
14
|
+
}
|
|
15
|
+
// MARK: - ➡️ Executing
|
|
16
|
+
Host.prototype.didSucceed = function () {
|
|
17
|
+
this.didSucceedLastMs = Date.now();
|
|
18
|
+
};
|
|
19
|
+
Host.prototype.didFail = function (urlRotationEnabledBool) {
|
|
20
|
+
if (urlRotationEnabledBool === void 0) {
|
|
21
|
+
urlRotationEnabledBool = true;
|
|
22
|
+
}
|
|
23
|
+
if (!urlRotationEnabledBool) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.didFailLastMs = Date.now();
|
|
27
|
+
};
|
|
28
|
+
// MARK: - ⏬ Decoding
|
|
29
|
+
/**
|
|
30
|
+
* Decode a Host from a plain dictionary.
|
|
31
|
+
*/
|
|
32
|
+
Host.from = function (object) {
|
|
33
|
+
if (object instanceof Host) {
|
|
34
|
+
return object;
|
|
35
|
+
}
|
|
36
|
+
if (!object || typeof object !== "object" || Array.isArray(object)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
var dict = object;
|
|
40
|
+
var identifier = dict["identifier"];
|
|
41
|
+
if (typeof identifier !== "string" || !identifier) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
var host = new Host(identifier);
|
|
45
|
+
var s = dict["did_succeed_last_ms"];
|
|
46
|
+
var f = dict["did_fail_last_ms"];
|
|
47
|
+
host.didSucceedLastMs = typeof s === "number" ? s : null;
|
|
48
|
+
host.didFailLastMs = typeof f === "number" ? f : null;
|
|
49
|
+
return host;
|
|
50
|
+
};
|
|
51
|
+
// MARK: - ⏫ Encoding
|
|
52
|
+
/**
|
|
53
|
+
* Encode this host to a plain dictionary.
|
|
54
|
+
* status is included only in log context for diagnostics.
|
|
55
|
+
*/
|
|
56
|
+
Host.prototype.to = function (context) {
|
|
57
|
+
var dict = {};
|
|
58
|
+
dict["identifier"] = this.identifier;
|
|
59
|
+
dict["did_succeed_last_ms"] = this.didSucceedLastMs;
|
|
60
|
+
dict["did_fail_last_ms"] = this.didFailLastMs;
|
|
61
|
+
if (context === "log") {
|
|
62
|
+
dict["status"] = this.status;
|
|
63
|
+
}
|
|
64
|
+
return dict;
|
|
65
|
+
};
|
|
66
|
+
Object.defineProperty(Host.prototype, "status", {
|
|
67
|
+
// MARK: - Computed
|
|
68
|
+
get: function () {
|
|
69
|
+
var s = this.didSucceedLastMs;
|
|
70
|
+
var f = this.didFailLastMs;
|
|
71
|
+
if (s === null && f === null) {
|
|
72
|
+
return "notKnown";
|
|
73
|
+
}
|
|
74
|
+
if (s !== null && (f === null || s >= f)) {
|
|
75
|
+
return "succeeding";
|
|
76
|
+
}
|
|
77
|
+
return "failing";
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(Host.prototype, "statusSucceedingOrNotKnownBool", {
|
|
83
|
+
get: function () {
|
|
84
|
+
return this.status !== "failing";
|
|
85
|
+
},
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true
|
|
88
|
+
});
|
|
89
|
+
return Host;
|
|
90
|
+
}();
|
|
91
|
+
export { Host };
|
|
92
|
+
//# sourceMappingURL=Host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node/Host.js"],"names":["Host","identifier","didSucceedLastMs","didFailLastMs","prototype","didSucceed","Date","now","didFail","urlRotationEnabledBool","from","object","Array","isArray","dict","host","s","f","to","context","status","Object","defineProperty","get","enumerable","configurable"],"mappings":"AAAA;;;;AAIA,IAAIA,OAAO,aAAe,YAAY;AAClC;AACA,aAASA,IAAT,CAAcC,UAAd,EAA0B;AACtB,aAAKA,UAAL,GAAkBA,UAAlB;AACA;AACA;AACA,aAAKC,gBAAL,GAAwB,IAAxB;AACA;AACA,aAAKC,aAAL,GAAqB,IAArB;AACH;AACD;AACAH,SAAKI,SAAL,CAAeC,UAAf,GAA4B,YAAY;AACpC,aAAKH,gBAAL,GAAwBI,KAAKC,GAAL,EAAxB;AACH,KAFD;AAGAP,SAAKI,SAAL,CAAeI,OAAf,GAAyB,UAAUC,sBAAV,EAAkC;AACvD,YAAIA,2BAA2B,KAAK,CAApC,EAAuC;AAAEA,qCAAyB,IAAzB;AAAgC;AACzE,YAAI,CAACA,sBAAL,EAA6B;AACzB;AACH;AACD,aAAKN,aAAL,GAAqBG,KAAKC,GAAL,EAArB;AACH,KAND;AAOA;AACA;;;AAGAP,SAAKU,IAAL,GAAY,UAAUC,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1B,uBAAO,UAAP;AACH;AACD,gBAAID,MAAM,IAAN,KAAeC,MAAM,IAAN,IAAcD,KAAKC,CAAlC,CAAJ,EAA0C;AACtC,uBAAO,YAAP;AACH;AACD,mBAAO,SAAP;AACH,SAZ2C;AAa5CO,oBAAY,KAbgC;AAc5CC,sBAAc;AAd8B,KAAhD;AAgBAJ,WAAOC,cAAP,CAAsBtB,KAAKI,SAA3B,EAAsC,gCAAtC,EAAwE;AACpEmB,aAAK,YAAY;AACb,mBAAO,KAAKH,MAAL,KAAgB,SAAvB;AACH,SAHmE;AAIpEI,oBAAY,KAJwD;AAKpEC,sBAAc;AALsD,KAAxE;AAOA,WAAOzB,IAAP;AACH,CAnFyB,EAA1B;AAoFA,SAASA,IAAT","file":"Host.js","sourcesContent":["/*\n Authored by John Bushnell on 06/25/26.\n Copyright (c) Kochava, Inc. All rights reserved.\n*/\nvar Host = /** @class */ (function () {\n // MARK: - 🆕 Creating a Host\n function Host(identifier) {\n this.identifier = identifier;\n // MARK: - Properties\n /** Most recent successful attempt timestamp (ms), or null if never succeeded. */\n this.didSucceedLastMs = null;\n /** Most recent failed attempt timestamp (ms), or null if never failed. */\n this.didFailLastMs = null;\n }\n // MARK: - ➡️ Executing\n Host.prototype.didSucceed = function () {\n this.didSucceedLastMs = Date.now();\n };\n Host.prototype.didFail = function (urlRotationEnabledBool) {\n if (urlRotationEnabledBool === void 0) { urlRotationEnabledBool = true; }\n if (!urlRotationEnabledBool) {\n return;\n }\n this.didFailLastMs = Date.now();\n };\n // MARK: - ⏬ Decoding\n /**\n * Decode a Host from a plain dictionary.\n */\n Host.from = function (object) {\n if (object instanceof Host) {\n return object;\n }\n if (!object || typeof object !== \"object\" || Array.isArray(object)) {\n return null;\n }\n var dict = object;\n var identifier = dict[\"identifier\"];\n if (typeof identifier !== \"string\" || !identifier) {\n return null;\n }\n var host = new Host(identifier);\n var s = dict[\"did_succeed_last_ms\"];\n var f = dict[\"did_fail_last_ms\"];\n host.didSucceedLastMs = typeof s === \"number\" ? s : null;\n host.didFailLastMs = typeof f === \"number\" ? f : null;\n return host;\n };\n // MARK: - ⏫ Encoding\n /**\n * Encode this host to a plain dictionary.\n * status is included only in log context for diagnostics.\n */\n Host.prototype.to = function (context) {\n var dict = {};\n dict[\"identifier\"] = this.identifier;\n dict[\"did_succeed_last_ms\"] = this.didSucceedLastMs;\n dict[\"did_fail_last_ms\"] = this.didFailLastMs;\n if (context === \"log\") {\n dict[\"status\"] = this.status;\n }\n return dict;\n };\n Object.defineProperty(Host.prototype, \"status\", {\n // MARK: - Computed\n get: function () {\n var s = this.didSucceedLastMs;\n var f = this.didFailLastMs;\n if (s === null && f === null) {\n return \"notKnown\";\n }\n if (s !== null && (f === null || s >= f)) {\n return \"succeeding\";\n }\n return \"failing\";\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Host.prototype, \"statusSucceedingOrNotKnownBool\", {\n get: function () {\n return this.status !== \"failing\";\n },\n enumerable: false,\n configurable: true\n });\n return Host;\n}());\nexport { Host };\n"]}
|