@smartico/public-api 0.0.3 → 0.0.4
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/.nvmrc +1 -1
- package/dist/Base/ClassId.d.ts +21 -0
- package/dist/Base/ProtocolMessage.d.ts +5 -0
- package/dist/Base/ProtocolRequest.d.ts +6 -0
- package/dist/Base/ProtocolResponse.d.ts +5 -0
- package/dist/ErrorCodes.d.ts +12 -0
- package/dist/GResponse.d.ts +9 -0
- package/dist/ILogger.d.ts +7 -0
- package/dist/IntUtils.d.ts +8 -0
- package/dist/MiniGames/SAWAcknowledgeType.d.ts +5 -0
- package/dist/MiniGames/SAWBuyInType.d.ts +10 -0
- package/dist/MiniGames/SAWDoSpinRequest.d.ts +5 -0
- package/dist/MiniGames/SAWDoSpinResponse.d.ts +15 -0
- package/dist/MiniGames/SAWGameType.d.ts +10 -0
- package/dist/MiniGames/SAWGetTemplatesRequest.d.ts +3 -0
- package/dist/MiniGames/SAWGetTemplatesResponse.d.ts +5 -0
- package/dist/MiniGames/SAWPrize.d.ts +11 -0
- package/dist/MiniGames/SAWPrizeType.d.ts +8 -0
- package/dist/MiniGames/SAWPrizeUI.d.ts +13 -0
- package/dist/MiniGames/SAWTemplate.d.ts +26 -0
- package/dist/MiniGames/SAWTemplateUI.d.ts +31 -0
- package/dist/MiniGames/SAWWinSoundType.d.ts +12 -0
- package/dist/MiniGames/index.d.ts +14 -0
- package/dist/SmarticoAPI.d.ts +23 -0
- package/dist/SmarticoPublicAPI.d.ts +23 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +322 -241
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +232 -231
- package/dist/index.modern.mjs.map +1 -1
- package/dist/service/index.d.ts +3 -2
- package/dist/service/types/ErrorCodes.d.ts +13 -0
- package/dist/service/types/GRequest.d.ts +16 -0
- package/dist/service/types/GResponse.d.ts +10 -0
- package/dist/service/types/Game/GameAttemptType.d.ts +6 -0
- package/{src/service/types/Game/GameCanPlayType.ts → dist/service/types/Game/GameCanPlayType.d.ts} +10 -11
- package/dist/service/types/Game/GameExternalStatus.d.ts +6 -0
- package/{src/service/types/Game/GameInfo.ts → dist/service/types/Game/GameInfo.d.ts} +9 -11
- package/{src/service/types/Game/GamePick.ts → dist/service/types/Game/GamePick.d.ts} +90 -104
- package/dist/service/types/Game/GameUtil.d.ts +7 -0
- package/{src/service/types/SmarticoProto/GetTranslationsRequest.ts → dist/service/types/SmarticoProto/GetTranslationsRequest.d.ts} +7 -9
- package/{src/service/types/SmarticoProto/GetTranslationsResponse.ts → dist/service/types/SmarticoProto/GetTranslationsResponse.d.ts} +7 -8
- package/dist/service/types/SmarticoProto/ProtocolMessage.d.ts +5 -0
- package/dist/service/types/SmarticoProto/ProtocolRequest.d.ts +6 -0
- package/dist/service/types/SmarticoProto/ProtocolResponse.d.ts +5 -0
- package/{src/service/types/SmarticoProto/PublicLabelInfo.ts → dist/service/types/SmarticoProto/PublicLabelInfo.d.ts} +34 -39
- package/{src/service/types/SmarticoProto/PublicProperties.ts → dist/service/types/SmarticoProto/PublicProperties.d.ts} +11 -11
- package/{src/service/types/SmarticoProto/ResponseIdentify.ts → dist/service/types/SmarticoProto/ResponseIdentify.d.ts} +12 -16
- package/dist/service/types/SmarticoProto/SAW/SAWAcknowledgeType.d.ts +5 -0
- package/{src/service/types/SmarticoProto/SAW/SAWBuyInType.ts → dist/service/types/SmarticoProto/SAW/SAWBuyInType.d.ts} +5 -5
- package/{src/service/types/SmarticoProto/SAW/SAWDoSpinRequest.ts → dist/service/types/SmarticoProto/SAW/SAWDoSpinRequest.d.ts} +5 -8
- package/dist/service/types/SmarticoProto/SAW/SAWDoSpinResponse.d.ts +15 -0
- package/dist/service/types/SmarticoProto/SAW/SAWGameType.d.ts +10 -0
- package/{src/service/types/SmarticoProto/SAW/SAWGetTemplatesRequest.ts → dist/service/types/SmarticoProto/SAW/SAWGetTemplatesRequest.d.ts} +3 -5
- package/{src/service/types/SmarticoProto/SAW/SAWGetTemplatesResponse.ts → dist/service/types/SmarticoProto/SAW/SAWGetTemplatesResponse.d.ts} +5 -8
- package/dist/service/types/SmarticoProto/SAW/SAWPrize.d.ts +11 -0
- package/dist/service/types/SmarticoProto/SAW/SAWPrizeType.d.ts +8 -0
- package/dist/service/types/SmarticoProto/SAW/SAWPrizeUI.d.ts +13 -0
- package/dist/service/types/SmarticoProto/SAW/SAWTemplate.d.ts +21 -0
- package/dist/service/types/SmarticoProto/SAW/SAWTemplateUI.d.ts +31 -0
- package/dist/service/types/SmarticoProto/SAW/SAWWinSoundType.d.ts +12 -0
- package/{src/service/types/SmarticoProto/TranslationArea.ts → dist/service/types/SmarticoProto/TranslationArea.d.ts} +9 -11
- package/{src/service/types/User/UserInfo.ts → dist/service/types/User/UserInfo.d.ts} +10 -12
- package/package.json +2 -1
- package/src/Base/ClassId.ts +26 -0
- package/src/{service/types/SmarticoProto → Base}/ProtocolMessage.ts +0 -0
- package/src/{service/types/SmarticoProto → Base}/ProtocolRequest.ts +0 -0
- package/src/{service/types/SmarticoProto → Base}/ProtocolResponse.ts +0 -0
- package/src/{service/types/ErrorCodes.ts → ErrorCodes.ts} +1 -3
- package/src/{service/types/GResponse.ts → GResponse.ts} +0 -0
- package/src/ILogger.ts +11 -0
- package/src/IntUtils.ts +39 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWAcknowledgeType.ts +0 -0
- package/src/MiniGames/SAWBuyInType.ts +11 -0
- package/src/MiniGames/SAWDoSpinRequest.ts +8 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWDoSpinResponse.ts +1 -1
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWGameType.ts +2 -2
- package/src/MiniGames/SAWGetTemplatesRequest.ts +5 -0
- package/src/MiniGames/SAWGetTemplatesResponse.ts +8 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWPrize.ts +0 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWPrizeType.ts +0 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWPrizeUI.ts +0 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWTemplate.ts +5 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWTemplateUI.ts +0 -0
- package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWWinSoundType.ts +0 -0
- package/src/MiniGames/index.ts +30 -0
- package/src/SmarticoAPI.ts +177 -0
- package/src/index.ts +11 -2
- package/tsconfig.json +17 -0
- package/src/service/index.ts +0 -12
- package/src/service/types/GRequest.ts +0 -18
- package/src/service/types/Game/GameAttemptType.ts +0 -8
- package/src/service/types/Game/GameExternalStatus.ts +0 -7
- package/src/service/types/Game/GameUtil.ts +0 -30
- package/src/util/Util.ts +0 -306
- package/test/package.json +0 -11
package/dist/index.js
CHANGED
|
@@ -1,269 +1,350 @@
|
|
|
1
|
-
var
|
|
2
|
-
var typescriptMap = require('typescript-map');
|
|
1
|
+
var superagent = require('superagent');
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
function _interopNamespace(e) {
|
|
4
|
+
if (e && e.__esModule) return e;
|
|
5
|
+
var n = Object.create(null);
|
|
6
|
+
if (e) {
|
|
7
|
+
Object.keys(e).forEach(function (k) {
|
|
8
|
+
if (k !== 'default') {
|
|
9
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return e[k]; }
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
n["default"] = e;
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var superagent__namespace = /*#__PURE__*/_interopNamespace(superagent);
|
|
22
|
+
|
|
23
|
+
exports.ClassId = void 0;
|
|
24
|
+
(function (ClassId) {
|
|
25
|
+
ClassId[ClassId["GET_LABEL_INFO"] = 3] = "GET_LABEL_INFO";
|
|
26
|
+
ClassId[ClassId["GET_LABEL_INFO_RESPONSE"] = 4] = "GET_LABEL_INFO_RESPONSE";
|
|
27
|
+
ClassId[ClassId["IDENTIFY"] = 5] = "IDENTIFY";
|
|
28
|
+
ClassId[ClassId["IDENTIFY_RESPONSE"] = 6] = "IDENTIFY_RESPONSE";
|
|
29
|
+
ClassId[ClassId["EVENT"] = 9] = "EVENT";
|
|
30
|
+
ClassId[ClassId["EVENT_RESPONSE"] = 10] = "EVENT_RESPONSE";
|
|
31
|
+
ClassId[ClassId["GET_TRANSLATIONS_REQUEST"] = 13] = "GET_TRANSLATIONS_REQUEST";
|
|
32
|
+
ClassId[ClassId["GET_TRANSLATIONS_RESPONSE"] = 14] = "GET_TRANSLATIONS_RESPONSE";
|
|
33
|
+
ClassId[ClassId["CHANGE_USERNAME"] = 159] = "CHANGE_USERNAME";
|
|
34
|
+
ClassId[ClassId["CHANGE_USERNAME_RESPONSE"] = 160] = "CHANGE_USERNAME_RESPONSE";
|
|
35
|
+
ClassId[ClassId["SAW_GET_SPINS_REQUEST"] = 700] = "SAW_GET_SPINS_REQUEST";
|
|
36
|
+
ClassId[ClassId["SAW_GET_SPINS_RESPONSE"] = 701] = "SAW_GET_SPINS_RESPONSE";
|
|
37
|
+
ClassId[ClassId["SAW_DO_SPIN_REQUEST"] = 702] = "SAW_DO_SPIN_REQUEST";
|
|
38
|
+
ClassId[ClassId["SAW_DO_SPIN_RESPONSE"] = 703] = "SAW_DO_SPIN_RESPONSE";
|
|
39
|
+
ClassId[ClassId["SAW_AKNOWLEDGE_REQUEST"] = 704] = "SAW_AKNOWLEDGE_REQUEST";
|
|
40
|
+
ClassId[ClassId["SAW_AKNOWLEDGE_RESPONSE"] = 705] = "SAW_AKNOWLEDGE_RESPONSE";
|
|
41
|
+
ClassId[ClassId["SAW_SPINS_COUNT_PUSH"] = 706] = "SAW_SPINS_COUNT_PUSH";
|
|
42
|
+
ClassId[ClassId["SAW_SHOW_SPIN_PUSH"] = 707] = "SAW_SHOW_SPIN_PUSH";
|
|
43
|
+
ClassId[ClassId["UNSUPPORTED_COMMAND"] = 99999] = "UNSUPPORTED_COMMAND";
|
|
44
|
+
})(exports.ClassId || (exports.ClassId = {}));
|
|
45
|
+
|
|
46
|
+
function _extends() {
|
|
47
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
48
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
49
|
+
var source = arguments[i];
|
|
50
|
+
for (var key in source) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
52
|
+
target[key] = source[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
25
55
|
}
|
|
26
|
-
return
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
return target;
|
|
57
|
+
};
|
|
58
|
+
return _extends.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
61
|
+
if (!o) return;
|
|
62
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
63
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
64
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
65
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
66
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
67
|
+
}
|
|
68
|
+
function _arrayLikeToArray(arr, len) {
|
|
69
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
70
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
71
|
+
return arr2;
|
|
72
|
+
}
|
|
73
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
74
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
75
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
76
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
77
|
+
if (it) o = it;
|
|
78
|
+
var i = 0;
|
|
79
|
+
return function () {
|
|
80
|
+
if (i >= o.length) return {
|
|
81
|
+
done: true
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
done: false,
|
|
85
|
+
value: o[i++]
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var IntUtils = /*#__PURE__*/function () {
|
|
93
|
+
function IntUtils() {}
|
|
94
|
+
IntUtils.uuid = function uuid() {
|
|
95
|
+
var a;
|
|
96
|
+
var b;
|
|
97
|
+
for (b = a = ""; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : "-") {}
|
|
98
|
+
return b;
|
|
99
|
+
};
|
|
100
|
+
IntUtils.isNotNull = function isNotNull(val) {
|
|
38
101
|
return typeof val !== "undefined" && val !== null;
|
|
39
102
|
};
|
|
40
|
-
|
|
41
|
-
return typeof val === "undefined" || val === null;
|
|
42
|
-
};
|
|
43
|
-
Util.isArrayNotEmpty = function isArrayNotEmpty(val) {
|
|
103
|
+
IntUtils.isNotEmpty = function isNotEmpty(val) {
|
|
44
104
|
return typeof val !== "undefined" && val !== null && val.length > 0;
|
|
45
105
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Util.isObjectEmpty = function isObjectEmpty(val) {
|
|
50
|
-
return Util.isNull(val) || Object.keys(val).length === 0 && val.constructor === Object;
|
|
51
|
-
};
|
|
52
|
-
Util.isMapNotEmpty = function isMapNotEmpty(val) {
|
|
53
|
-
return typeof val !== "undefined" && val !== null && (val.size() > 0 || val.keys().length > 0);
|
|
54
|
-
};
|
|
55
|
-
Util.isMapEmpty = function isMapEmpty(val) {
|
|
56
|
-
return typeof val === "undefined" || val === null || val.size() === 0 || val.keys().length === 0;
|
|
57
|
-
};
|
|
58
|
-
Util.objectToMap = function objectToMap(obj) {
|
|
59
|
-
if (Util.isNotNull(obj)) {
|
|
60
|
-
var map = new typescriptMap.TSMap();
|
|
61
|
-
Object.keys(obj).forEach(function (key) {
|
|
62
|
-
map.set(key, obj[key]);
|
|
63
|
-
});
|
|
64
|
-
return map;
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
};
|
|
68
|
-
Util.keyByValue = function keyByValue(obj, value) {
|
|
69
|
-
for (var prop in obj) {
|
|
70
|
-
if (obj.hasOwnProperty(prop)) {
|
|
71
|
-
if (obj[prop] === value) {
|
|
72
|
-
return prop;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
106
|
+
IntUtils.replaceAll = function replaceAll(value, regex, replacement) {
|
|
107
|
+
if (IntUtils.isNotNull(value)) {
|
|
108
|
+
return value.replace(new RegExp(IntUtils.escapeRegExp(regex), "g"), replacement == null ? void 0 : replacement.toString());
|
|
75
109
|
}
|
|
76
|
-
return
|
|
77
|
-
};
|
|
78
|
-
Util.greaterThen0 = function greaterThen0(val) {
|
|
79
|
-
return this.isNotNull(val) && val > 0;
|
|
80
|
-
};
|
|
81
|
-
Util.not0 = function not0(val) {
|
|
82
|
-
return this.isNotNull(val) && val !== 0;
|
|
83
|
-
};
|
|
84
|
-
Util.lessThen0 = function lessThen0(val) {
|
|
85
|
-
return this.isNotNull(val) && val < 0;
|
|
110
|
+
return value;
|
|
86
111
|
};
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
if (this.isNull(o1) && this.isNotNull(o2)) {
|
|
92
|
-
return 1;
|
|
112
|
+
IntUtils.escapeRegExp = function escapeRegExp(v) {
|
|
113
|
+
if (IntUtils.isNotEmpty(v)) {
|
|
114
|
+
return v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
93
115
|
}
|
|
94
|
-
return
|
|
116
|
+
return v;
|
|
95
117
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
return IntUtils;
|
|
119
|
+
}();
|
|
120
|
+
|
|
121
|
+
exports.SAWAcknowledgeType = void 0;
|
|
122
|
+
(function (SAWAcknowledgeType) {
|
|
123
|
+
SAWAcknowledgeType[SAWAcknowledgeType["Silent"] = 1] = "Silent";
|
|
124
|
+
SAWAcknowledgeType[SAWAcknowledgeType["QuickMessage"] = 2] = "QuickMessage";
|
|
125
|
+
SAWAcknowledgeType[SAWAcknowledgeType["FullMessage"] = 3] = "FullMessage";
|
|
126
|
+
})(exports.SAWAcknowledgeType || (exports.SAWAcknowledgeType = {}));
|
|
127
|
+
|
|
128
|
+
var _SAWBuyInTypeName;
|
|
129
|
+
exports.SAWBuyInType = void 0;
|
|
130
|
+
(function (SAWBuyInType) {
|
|
131
|
+
SAWBuyInType[SAWBuyInType["Free"] = 1] = "Free";
|
|
132
|
+
SAWBuyInType[SAWBuyInType["Points"] = 2] = "Points";
|
|
133
|
+
SAWBuyInType[SAWBuyInType["Spins"] = 3] = "Spins";
|
|
134
|
+
})(exports.SAWBuyInType || (exports.SAWBuyInType = {}));
|
|
135
|
+
var SAWBuyInTypeName = (_SAWBuyInTypeName = {}, _SAWBuyInTypeName[exports.SAWBuyInType.Free] = "free", _SAWBuyInTypeName[exports.SAWBuyInType.Points] = "points", _SAWBuyInTypeName[exports.SAWBuyInType.Spins] = "spins", _SAWBuyInTypeName);
|
|
136
|
+
|
|
137
|
+
exports.SAWSpinErrorCode = void 0;
|
|
138
|
+
(function (SAWSpinErrorCode) {
|
|
139
|
+
SAWSpinErrorCode[SAWSpinErrorCode["SAW_OK"] = 0] = "SAW_OK";
|
|
140
|
+
SAWSpinErrorCode[SAWSpinErrorCode["SAW_NO_SPINS"] = 40001] = "SAW_NO_SPINS";
|
|
141
|
+
SAWSpinErrorCode[SAWSpinErrorCode["SAW_PRIZE_POOL_EMPTY"] = 40002] = "SAW_PRIZE_POOL_EMPTY";
|
|
142
|
+
SAWSpinErrorCode[SAWSpinErrorCode["SAW_NOT_ENOUGH_POINTS"] = 40003] = "SAW_NOT_ENOUGH_POINTS";
|
|
143
|
+
SAWSpinErrorCode[SAWSpinErrorCode["SAW_FAILED_MAX_SPINS_REACHED"] = 40004] = "SAW_FAILED_MAX_SPINS_REACHED";
|
|
144
|
+
})(exports.SAWSpinErrorCode || (exports.SAWSpinErrorCode = {}));
|
|
145
|
+
|
|
146
|
+
var _SAWGameTypeName;
|
|
147
|
+
exports.SAWGameType = void 0;
|
|
148
|
+
(function (SAWGameType) {
|
|
149
|
+
SAWGameType[SAWGameType["SpinAWheel"] = 1] = "SpinAWheel";
|
|
150
|
+
SAWGameType[SAWGameType["ScratchCard"] = 2] = "ScratchCard";
|
|
151
|
+
SAWGameType[SAWGameType["MatchX"] = 3] = "MatchX";
|
|
152
|
+
})(exports.SAWGameType || (exports.SAWGameType = {}));
|
|
153
|
+
var SAWGameTypeName = (_SAWGameTypeName = {}, _SAWGameTypeName[exports.SAWGameType.SpinAWheel] = "wheel", _SAWGameTypeName[exports.SAWGameType.ScratchCard] = "scratch", _SAWGameTypeName[exports.SAWGameType.MatchX] = "matchx", _SAWGameTypeName);
|
|
154
|
+
|
|
155
|
+
exports.SAWPrizeType = void 0;
|
|
156
|
+
(function (SAWPrizeType) {
|
|
157
|
+
SAWPrizeType[SAWPrizeType["NO_PRIZE"] = 1] = "NO_PRIZE";
|
|
158
|
+
SAWPrizeType[SAWPrizeType["POINTS"] = 2] = "POINTS";
|
|
159
|
+
SAWPrizeType[SAWPrizeType["BONUS"] = 3] = "BONUS";
|
|
160
|
+
SAWPrizeType[SAWPrizeType["MANUAL"] = 4] = "MANUAL";
|
|
161
|
+
SAWPrizeType[SAWPrizeType["SPIN"] = 5] = "SPIN";
|
|
162
|
+
SAWPrizeType[SAWPrizeType["JACKPOT"] = 6] = "JACKPOT";
|
|
163
|
+
})(exports.SAWPrizeType || (exports.SAWPrizeType = {}));
|
|
164
|
+
|
|
165
|
+
var _SAWWinSoundFiles;
|
|
166
|
+
exports.SAWWinSoundType = void 0;
|
|
167
|
+
(function (SAWWinSoundType) {
|
|
168
|
+
SAWWinSoundType[SAWWinSoundType["Disappointing"] = 1] = "Disappointing";
|
|
169
|
+
SAWWinSoundType[SAWWinSoundType["Positive"] = 2] = "Positive";
|
|
170
|
+
SAWWinSoundType[SAWWinSoundType["HighlyPositive"] = 3] = "HighlyPositive";
|
|
171
|
+
SAWWinSoundType[SAWWinSoundType["NoSound"] = 4] = "NoSound";
|
|
172
|
+
})(exports.SAWWinSoundType || (exports.SAWWinSoundType = {}));
|
|
173
|
+
var SAWWinSoundFiles = (_SAWWinSoundFiles = {}, _SAWWinSoundFiles[exports.SAWWinSoundType.NoSound] = null, _SAWWinSoundFiles[exports.SAWWinSoundType.Disappointing] = "saw-disappointed.m4a", _SAWWinSoundFiles[exports.SAWWinSoundType.Positive] = "saw-positive.m4a", _SAWWinSoundFiles[exports.SAWWinSoundType.HighlyPositive] = "saw-highly-positive.m4a", _SAWWinSoundFiles);
|
|
174
|
+
|
|
175
|
+
function _catch(body, recover) {
|
|
176
|
+
try {
|
|
177
|
+
var result = body();
|
|
178
|
+
} catch (e) {
|
|
179
|
+
return recover(e);
|
|
180
|
+
}
|
|
181
|
+
if (result && result.then) {
|
|
182
|
+
return result.then(void 0, recover);
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
var PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
|
|
187
|
+
var SmarticoAPI = /*#__PURE__*/function () {
|
|
188
|
+
function SmarticoAPI(label_api_key, brand_api_key, options) {
|
|
189
|
+
if (options === void 0) {
|
|
190
|
+
options = {};
|
|
100
191
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
192
|
+
this.label_api_key = void 0;
|
|
193
|
+
this.brand_api_key = void 0;
|
|
194
|
+
this.publicUrl = void 0;
|
|
195
|
+
this.logger = void 0;
|
|
196
|
+
this.logCIDs = void 0;
|
|
197
|
+
this.logHTTPTiming = void 0;
|
|
198
|
+
this.label_api_key = label_api_key;
|
|
199
|
+
this.brand_api_key = brand_api_key;
|
|
200
|
+
this.logger = options.logger || console;
|
|
201
|
+
if (this.logger.always === undefined) {
|
|
202
|
+
this.logger.always = this.logger.info;
|
|
108
203
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
204
|
+
this.logCIDs = options.logCIDs || [];
|
|
205
|
+
this.logHTTPTiming = options.logHTTPTiming || false;
|
|
206
|
+
var ENV_ID = this.label_api_key.length === 38 ? label_api_key.substring(37, 38) : '';
|
|
207
|
+
if (ENV_ID === '1' || ENV_ID === '2') {
|
|
208
|
+
ENV_ID = '';
|
|
113
209
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
|
|
210
|
+
label_api_key = label_api_key.substring(0, 36);
|
|
211
|
+
this.publicUrl = PUBLIC_API_URL.replace('{ENV_ID}', ENV_ID);
|
|
212
|
+
}
|
|
213
|
+
var _proto = SmarticoAPI.prototype;
|
|
214
|
+
_proto.send = function send(message, expectCID) {
|
|
215
|
+
try {
|
|
216
|
+
var _temp2 = function _temp2(_result) {
|
|
217
|
+
if (_exit) return _result;
|
|
218
|
+
if (_this.logCIDs.includes(message.cid)) {
|
|
219
|
+
_this.logger.info('RES', result);
|
|
124
220
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return
|
|
221
|
+
if (expectCID) {
|
|
222
|
+
if (Array.isArray(result)) {
|
|
223
|
+
for (var _iterator = _createForOfIteratorHelperLoose(result), _step; !(_step = _iterator()).done;) {
|
|
224
|
+
var str = _step.value;
|
|
225
|
+
var obj = JSON.parse(str);
|
|
226
|
+
if (_this.logCIDs.includes(obj.cid)) {
|
|
227
|
+
_this.logger.info('RES', result);
|
|
228
|
+
}
|
|
229
|
+
if (obj.cid === expectCID) {
|
|
230
|
+
return obj;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
_this.logger.error("Cant find proper response in array, expected CID " + expectCID, {
|
|
234
|
+
request: message,
|
|
235
|
+
response: result
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
if (Array.isArray(result)) {
|
|
242
|
+
if (result.length === 1) {
|
|
243
|
+
var _obj = JSON.parse(result[0]);
|
|
244
|
+
if (_this.logCIDs.includes(_obj.cid)) {
|
|
245
|
+
_this.logger.info('RES', result);
|
|
246
|
+
}
|
|
247
|
+
return _obj;
|
|
248
|
+
} else {
|
|
249
|
+
_this.logger.error('Expected one response, but got array', {
|
|
250
|
+
request: message,
|
|
251
|
+
response: result
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
160
256
|
}
|
|
257
|
+
};
|
|
258
|
+
var _exit;
|
|
259
|
+
var _this = this;
|
|
260
|
+
if (_this.logCIDs.includes(message.cid)) {
|
|
261
|
+
_this.logger.info('REQ', message);
|
|
161
262
|
}
|
|
263
|
+
var result;
|
|
264
|
+
var _temp = _catch(function () {
|
|
265
|
+
var timeStart = new Date().getTime();
|
|
266
|
+
return Promise.resolve(superagent__namespace.post(_this.publicUrl).send(message)).then(function (res) {
|
|
267
|
+
var timeEnd = new Date().getTime();
|
|
268
|
+
if (_this.logHTTPTiming) {
|
|
269
|
+
_this.logger.always('HTTP time, ms:' + (timeEnd - timeStart));
|
|
270
|
+
}
|
|
271
|
+
result = JSON.parse(res.text);
|
|
272
|
+
});
|
|
273
|
+
}, function (e) {
|
|
274
|
+
_this.logger.error("Failed to make request to smartico channel. " + e.message, {
|
|
275
|
+
url: _this.publicUrl,
|
|
276
|
+
request: message,
|
|
277
|
+
error: e.message
|
|
278
|
+
});
|
|
279
|
+
throw new Error("Failed to make request to smartico channel. " + e.message);
|
|
280
|
+
});
|
|
281
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
|
282
|
+
} catch (e) {
|
|
283
|
+
return Promise.reject(e);
|
|
162
284
|
}
|
|
163
|
-
return false;
|
|
164
|
-
};
|
|
165
|
-
Util.isEmpty = function isEmpty(val) {
|
|
166
|
-
return typeof val === "undefined" || val === null || val.length === 0;
|
|
167
285
|
};
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
|
|
286
|
+
_proto.buildMessage = function buildMessage(user_ext_id, cid, payload) {
|
|
287
|
+
if (payload === void 0) {
|
|
288
|
+
payload = {};
|
|
171
289
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
290
|
+
var message = _extends({
|
|
291
|
+
api_key: this.label_api_key,
|
|
292
|
+
brand_key: this.brand_api_key,
|
|
293
|
+
ext_user_id: user_ext_id,
|
|
294
|
+
cid: cid,
|
|
295
|
+
uuid: IntUtils.uuid(),
|
|
296
|
+
ts: new Date().getTime()
|
|
297
|
+
}, payload);
|
|
298
|
+
return message;
|
|
299
|
+
};
|
|
300
|
+
_proto.miniGamesGetTemplates = function miniGamesGetTemplates(user_ext_id) {
|
|
301
|
+
try {
|
|
302
|
+
var _this2 = this;
|
|
303
|
+
var message = _this2.buildMessage(user_ext_id, exports.ClassId.SAW_GET_SPINS_REQUEST);
|
|
304
|
+
return Promise.resolve(_this2.send(message)).then(function (response) {
|
|
305
|
+
if (response && response.templates) {
|
|
306
|
+
response.templates.forEach(function (t) {
|
|
307
|
+
if (t.jackpot_current) {
|
|
308
|
+
t.saw_template_ui_definition.name = IntUtils.replaceAll(t.saw_template_ui_definition.name, '{{jackpot}}', t.jackpot_current);
|
|
309
|
+
t.saw_template_ui_definition.description = IntUtils.replaceAll(t.saw_template_ui_definition.description, '{{jackpot}}', t.jackpot_current);
|
|
310
|
+
t.saw_template_ui_definition.promo_text = IntUtils.replaceAll(t.saw_template_ui_definition.promo_text, '{{jackpot}}', t.jackpot_current);
|
|
311
|
+
t.prizes.forEach(function (p) {
|
|
312
|
+
p.saw_prize_ui_definition.name = IntUtils.replaceAll(p.saw_prize_ui_definition.name, '{{jackpot}}', t.jackpot_current);
|
|
313
|
+
p.saw_prize_ui_definition.aknowledge_message = IntUtils.replaceAll(p.saw_prize_ui_definition.aknowledge_message, '{{jackpot}}', t.jackpot_current);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
});
|
|
189
317
|
}
|
|
190
|
-
|
|
318
|
+
return response;
|
|
319
|
+
});
|
|
320
|
+
} catch (e) {
|
|
321
|
+
return Promise.reject(e);
|
|
191
322
|
}
|
|
192
|
-
return false;
|
|
193
323
|
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
324
|
+
_proto.miniGamesFormatTemplatesForWidget = function miniGamesFormatTemplatesForWidget(templates, pointsBalance) {
|
|
325
|
+
return templates.filter(function (r) {
|
|
326
|
+
return r.saw_template_id >= 1;
|
|
327
|
+
}).map(function (r) {
|
|
328
|
+
var _r$saw_skin_ui_defini, _r$saw_skin_ui_defini2;
|
|
329
|
+
return {
|
|
330
|
+
id: r.saw_template_id,
|
|
331
|
+
name: r.saw_template_ui_definition.name,
|
|
332
|
+
// description: r.saw_template_ui_definition.description,
|
|
333
|
+
game_type: SAWGameTypeName[r.saw_game_type_id] || 'unknown',
|
|
334
|
+
buyin_type: SAWBuyInTypeName[r.saw_buyin_type_id] || 'unknown',
|
|
335
|
+
jackpot: r.jackpot_current,
|
|
336
|
+
spin_count: r.spin_count,
|
|
337
|
+
buyin_cost_points: r.buyin_cost_points,
|
|
338
|
+
can_play: r.saw_buyin_type_id === exports.SAWBuyInType.Free || r.saw_buyin_type_id === exports.SAWBuyInType.Points && r.buyin_cost_points <= pointsBalance || r.saw_buyin_type_id === exports.SAWBuyInType.Spins && r.spin_count > 0,
|
|
339
|
+
icon: (_r$saw_skin_ui_defini = r.saw_skin_ui_definition) != null && _r$saw_skin_ui_defini.skin_folder ? ((_r$saw_skin_ui_defini2 = r.saw_skin_ui_definition) == null ? void 0 : _r$saw_skin_ui_defini2.skin_folder) + '/ico.png' : "https://libs.smartico.ai/gf/images/saw/" + r.saw_skin_key + "/ico.png"
|
|
340
|
+
};
|
|
208
341
|
});
|
|
209
342
|
};
|
|
210
|
-
|
|
211
|
-
return item && typeof item === "object" && !Array.isArray(item);
|
|
212
|
-
};
|
|
213
|
-
Util.merge = function merge(target) {
|
|
214
|
-
var sources = [].slice.call(arguments, 1);
|
|
215
|
-
if (!sources.length) {
|
|
216
|
-
return target;
|
|
217
|
-
}
|
|
218
|
-
var source = sources.shift();
|
|
219
|
-
if (this.isObject(target) && this.isObject(source)) {
|
|
220
|
-
for (var key in source) {
|
|
221
|
-
if (this.isObject(source[key])) {
|
|
222
|
-
if (!target[key]) {
|
|
223
|
-
var _Object$assign;
|
|
224
|
-
Object.assign(target, (_Object$assign = {}, _Object$assign[key] = {}, _Object$assign));
|
|
225
|
-
}
|
|
226
|
-
this.merge(target[key], source[key]);
|
|
227
|
-
} else if (Array.isArray(source[key])) {
|
|
228
|
-
var _Object$assign2;
|
|
229
|
-
Object.assign(target, (_Object$assign2 = {}, _Object$assign2[key] = [].concat(source[key]), _Object$assign2));
|
|
230
|
-
} else if (typeof source[key] !== "undefined") {
|
|
231
|
-
var _Object$assign3;
|
|
232
|
-
Object.assign(target, (_Object$assign3 = {}, _Object$assign3[key] = source[key], _Object$assign3));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return this.merge.apply(this, [target].concat(sources));
|
|
237
|
-
};
|
|
238
|
-
Util.deepCopy = function deepCopy(source) {
|
|
239
|
-
return JSON.parse(JSON.stringify(source));
|
|
240
|
-
};
|
|
241
|
-
Util.getStackTrace = function getStackTrace() {
|
|
242
|
-
return new Error().stack;
|
|
243
|
-
};
|
|
244
|
-
Util.shuffleArray = function shuffleArray(array) {
|
|
245
|
-
for (var i = array.length - 1; i > 0; i--) {
|
|
246
|
-
var j = Math.floor(Math.random() * (i + 1));
|
|
247
|
-
var _ref = [array[j], array[i]];
|
|
248
|
-
array[i] = _ref[0];
|
|
249
|
-
array[j] = _ref[1];
|
|
250
|
-
}
|
|
251
|
-
return array;
|
|
252
|
-
};
|
|
253
|
-
Util.buildValidationHash = function buildValidationHash(ext_user_id, ext_game_id, customer_id, secretKey) {
|
|
254
|
-
var toHash = ext_user_id + "|" + ext_game_id + "|" + customer_id + ":" + secretKey;
|
|
255
|
-
return md5Typescript.Md5.init(toHash);
|
|
256
|
-
};
|
|
257
|
-
return Util;
|
|
343
|
+
return SmarticoAPI;
|
|
258
344
|
}();
|
|
259
|
-
Util.uuid = function () {
|
|
260
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
261
|
-
// eslint-disable-next-line no-mixed-operators
|
|
262
|
-
var r = Math.random() * 16 | 0,
|
|
263
|
-
v = c === "x" ? r : r & 0x3 | 0x8;
|
|
264
|
-
return v.toString(16);
|
|
265
|
-
});
|
|
266
|
-
};
|
|
267
345
|
|
|
268
|
-
exports.
|
|
346
|
+
exports.SAWBuyInTypeName = SAWBuyInTypeName;
|
|
347
|
+
exports.SAWGameTypeName = SAWGameTypeName;
|
|
348
|
+
exports.SAWWinSoundFiles = SAWWinSoundFiles;
|
|
349
|
+
exports.SmarticoAPI = SmarticoAPI;
|
|
269
350
|
//# sourceMappingURL=index.js.map
|