@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.
Files changed (96) hide show
  1. package/.nvmrc +1 -1
  2. package/dist/Base/ClassId.d.ts +21 -0
  3. package/dist/Base/ProtocolMessage.d.ts +5 -0
  4. package/dist/Base/ProtocolRequest.d.ts +6 -0
  5. package/dist/Base/ProtocolResponse.d.ts +5 -0
  6. package/dist/ErrorCodes.d.ts +12 -0
  7. package/dist/GResponse.d.ts +9 -0
  8. package/dist/ILogger.d.ts +7 -0
  9. package/dist/IntUtils.d.ts +8 -0
  10. package/dist/MiniGames/SAWAcknowledgeType.d.ts +5 -0
  11. package/dist/MiniGames/SAWBuyInType.d.ts +10 -0
  12. package/dist/MiniGames/SAWDoSpinRequest.d.ts +5 -0
  13. package/dist/MiniGames/SAWDoSpinResponse.d.ts +15 -0
  14. package/dist/MiniGames/SAWGameType.d.ts +10 -0
  15. package/dist/MiniGames/SAWGetTemplatesRequest.d.ts +3 -0
  16. package/dist/MiniGames/SAWGetTemplatesResponse.d.ts +5 -0
  17. package/dist/MiniGames/SAWPrize.d.ts +11 -0
  18. package/dist/MiniGames/SAWPrizeType.d.ts +8 -0
  19. package/dist/MiniGames/SAWPrizeUI.d.ts +13 -0
  20. package/dist/MiniGames/SAWTemplate.d.ts +26 -0
  21. package/dist/MiniGames/SAWTemplateUI.d.ts +31 -0
  22. package/dist/MiniGames/SAWWinSoundType.d.ts +12 -0
  23. package/dist/MiniGames/index.d.ts +14 -0
  24. package/dist/SmarticoAPI.d.ts +23 -0
  25. package/dist/SmarticoPublicAPI.d.ts +23 -0
  26. package/dist/index.d.ts +5 -2
  27. package/dist/index.js +322 -241
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.modern.mjs +232 -231
  30. package/dist/index.modern.mjs.map +1 -1
  31. package/dist/service/index.d.ts +3 -2
  32. package/dist/service/types/ErrorCodes.d.ts +13 -0
  33. package/dist/service/types/GRequest.d.ts +16 -0
  34. package/dist/service/types/GResponse.d.ts +10 -0
  35. package/dist/service/types/Game/GameAttemptType.d.ts +6 -0
  36. package/{src/service/types/Game/GameCanPlayType.ts → dist/service/types/Game/GameCanPlayType.d.ts} +10 -11
  37. package/dist/service/types/Game/GameExternalStatus.d.ts +6 -0
  38. package/{src/service/types/Game/GameInfo.ts → dist/service/types/Game/GameInfo.d.ts} +9 -11
  39. package/{src/service/types/Game/GamePick.ts → dist/service/types/Game/GamePick.d.ts} +90 -104
  40. package/dist/service/types/Game/GameUtil.d.ts +7 -0
  41. package/{src/service/types/SmarticoProto/GetTranslationsRequest.ts → dist/service/types/SmarticoProto/GetTranslationsRequest.d.ts} +7 -9
  42. package/{src/service/types/SmarticoProto/GetTranslationsResponse.ts → dist/service/types/SmarticoProto/GetTranslationsResponse.d.ts} +7 -8
  43. package/dist/service/types/SmarticoProto/ProtocolMessage.d.ts +5 -0
  44. package/dist/service/types/SmarticoProto/ProtocolRequest.d.ts +6 -0
  45. package/dist/service/types/SmarticoProto/ProtocolResponse.d.ts +5 -0
  46. package/{src/service/types/SmarticoProto/PublicLabelInfo.ts → dist/service/types/SmarticoProto/PublicLabelInfo.d.ts} +34 -39
  47. package/{src/service/types/SmarticoProto/PublicProperties.ts → dist/service/types/SmarticoProto/PublicProperties.d.ts} +11 -11
  48. package/{src/service/types/SmarticoProto/ResponseIdentify.ts → dist/service/types/SmarticoProto/ResponseIdentify.d.ts} +12 -16
  49. package/dist/service/types/SmarticoProto/SAW/SAWAcknowledgeType.d.ts +5 -0
  50. package/{src/service/types/SmarticoProto/SAW/SAWBuyInType.ts → dist/service/types/SmarticoProto/SAW/SAWBuyInType.d.ts} +5 -5
  51. package/{src/service/types/SmarticoProto/SAW/SAWDoSpinRequest.ts → dist/service/types/SmarticoProto/SAW/SAWDoSpinRequest.d.ts} +5 -8
  52. package/dist/service/types/SmarticoProto/SAW/SAWDoSpinResponse.d.ts +15 -0
  53. package/dist/service/types/SmarticoProto/SAW/SAWGameType.d.ts +10 -0
  54. package/{src/service/types/SmarticoProto/SAW/SAWGetTemplatesRequest.ts → dist/service/types/SmarticoProto/SAW/SAWGetTemplatesRequest.d.ts} +3 -5
  55. package/{src/service/types/SmarticoProto/SAW/SAWGetTemplatesResponse.ts → dist/service/types/SmarticoProto/SAW/SAWGetTemplatesResponse.d.ts} +5 -8
  56. package/dist/service/types/SmarticoProto/SAW/SAWPrize.d.ts +11 -0
  57. package/dist/service/types/SmarticoProto/SAW/SAWPrizeType.d.ts +8 -0
  58. package/dist/service/types/SmarticoProto/SAW/SAWPrizeUI.d.ts +13 -0
  59. package/dist/service/types/SmarticoProto/SAW/SAWTemplate.d.ts +21 -0
  60. package/dist/service/types/SmarticoProto/SAW/SAWTemplateUI.d.ts +31 -0
  61. package/dist/service/types/SmarticoProto/SAW/SAWWinSoundType.d.ts +12 -0
  62. package/{src/service/types/SmarticoProto/TranslationArea.ts → dist/service/types/SmarticoProto/TranslationArea.d.ts} +9 -11
  63. package/{src/service/types/User/UserInfo.ts → dist/service/types/User/UserInfo.d.ts} +10 -12
  64. package/package.json +2 -1
  65. package/src/Base/ClassId.ts +26 -0
  66. package/src/{service/types/SmarticoProto → Base}/ProtocolMessage.ts +0 -0
  67. package/src/{service/types/SmarticoProto → Base}/ProtocolRequest.ts +0 -0
  68. package/src/{service/types/SmarticoProto → Base}/ProtocolResponse.ts +0 -0
  69. package/src/{service/types/ErrorCodes.ts → ErrorCodes.ts} +1 -3
  70. package/src/{service/types/GResponse.ts → GResponse.ts} +0 -0
  71. package/src/ILogger.ts +11 -0
  72. package/src/IntUtils.ts +39 -0
  73. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWAcknowledgeType.ts +0 -0
  74. package/src/MiniGames/SAWBuyInType.ts +11 -0
  75. package/src/MiniGames/SAWDoSpinRequest.ts +8 -0
  76. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWDoSpinResponse.ts +1 -1
  77. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWGameType.ts +2 -2
  78. package/src/MiniGames/SAWGetTemplatesRequest.ts +5 -0
  79. package/src/MiniGames/SAWGetTemplatesResponse.ts +8 -0
  80. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWPrize.ts +0 -0
  81. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWPrizeType.ts +0 -0
  82. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWPrizeUI.ts +0 -0
  83. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWTemplate.ts +5 -0
  84. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWTemplateUI.ts +0 -0
  85. package/src/{service/types/SmarticoProto/SAW → MiniGames}/SAWWinSoundType.ts +0 -0
  86. package/src/MiniGames/index.ts +30 -0
  87. package/src/SmarticoAPI.ts +177 -0
  88. package/src/index.ts +11 -2
  89. package/tsconfig.json +17 -0
  90. package/src/service/index.ts +0 -12
  91. package/src/service/types/GRequest.ts +0 -18
  92. package/src/service/types/Game/GameAttemptType.ts +0 -8
  93. package/src/service/types/Game/GameExternalStatus.ts +0 -7
  94. package/src/service/types/Game/GameUtil.ts +0 -30
  95. package/src/util/Util.ts +0 -306
  96. package/test/package.json +0 -11
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "esModuleInterop": true,
5
+ "target": "ESNext",
6
+ "noImplicitAny": false,
7
+ "moduleResolution": "node",
8
+ "sourceMap": true,
9
+ "outDir": "dist",
10
+ "baseUrl": ".",
11
+ "allowJs": true
12
+ },
13
+ "include": [
14
+ "src/**/*"
15
+ ]
16
+ }
17
+
@@ -1,12 +0,0 @@
1
- import { ErrorCodes } from './types/ErrorCodes';
2
- import { GBaseRequest } from './types/GRequest';
3
- import { GResponseBase, GResponse } from './types/GResponse';
4
-
5
- export {
6
-
7
- ErrorCodes,
8
- GBaseRequest,
9
- GResponseBase,
10
- GResponse,
11
-
12
- }
@@ -1,18 +0,0 @@
1
-
2
- interface GBaseRequest {
3
- customer_id: string;
4
- ext_user_id: string; // int in the smartico system
5
- int_user_id: number; // int in the retention games
6
- smartico_ext_user_id: string; // string in the smartico system, that is referencing to user identification in the partner system
7
- ext_game_id: number;
8
- lang: string;
9
- hash: string;
10
- zoom?: number;
11
- label_api_key?: string;
12
- brand_key?: string;
13
- bridgeId?: string;
14
- height?: 'auto' | string;
15
- theme?: string;
16
- }
17
-
18
- export { GBaseRequest }
@@ -1,8 +0,0 @@
1
- enum GameAttemptType {
2
- Free = 1,
3
- Points = 2,
4
- Attempts = 3,
5
- }
6
-
7
-
8
- export { GameAttemptType }
@@ -1,7 +0,0 @@
1
- enum GameExternalStatus {
2
- Draft = 1,
3
- Active = 2,
4
- Archived = 3
5
- }
6
-
7
- export { GameExternalStatus }
@@ -1,30 +0,0 @@
1
- import { GameInfo } from "./GameInfo";
2
- import { GamePickRound, GamePickRoundBase } from "./GamePick";
3
- import { Util } from "../../../util/Util";
4
-
5
-
6
- class GameUtil {
7
-
8
- public static getRoundName(round: GamePickRoundBase, gameInfo: GameInfo): string {
9
- if (gameInfo.sawTemplate.jackpot_current) {
10
- const t = gameInfo.sawTemplate;
11
- const jackpotValue = t.jackpot_current + (t.saw_template_ui_definition?.jackpot_symbol ? ' ' + t.saw_template_ui_definition?.jackpot_symbol : '');
12
- return Util.replaceAll(round.round_name, "{{jackpot}}", jackpotValue);
13
- } else {
14
- return round.round_name;
15
- }
16
- }
17
-
18
- public static getRoundDescription(round: GamePickRound, gameInfo: GameInfo): string {
19
- if (gameInfo.sawTemplate.jackpot_current) {
20
- const t = gameInfo.sawTemplate;
21
- const jackpotValue = t.jackpot_current + (t.saw_template_ui_definition?.jackpot_symbol ? ' ' + t.saw_template_ui_definition?.jackpot_symbol : '');
22
- return Util.replaceAll(round.round_description, "{{jackpot}}", jackpotValue);
23
- } else {
24
- return round.round_description;
25
- }
26
- }
27
- }
28
-
29
-
30
- export { GameUtil }
package/src/util/Util.ts DELETED
@@ -1,306 +0,0 @@
1
- import { Md5 } from "md5-typescript";
2
- import {TSMap} from "typescript-map";
3
-
4
- class Util {
5
-
6
- private constructor() {
7
- }
8
-
9
- public static isNumber(value: string): boolean {
10
- return /^\d+$/.test(value);
11
- }
12
-
13
- public static parseNumber(v: string): number | null {
14
- if (Util.isNotEmpty(v)) {
15
- const result: number = parseFloat(v);
16
- if (isNaN(result)) {
17
- return null;
18
- }
19
- return result;
20
- }
21
- return null;
22
- }
23
-
24
- public static parseBoolean(v: string | boolean): boolean | null {
25
- return v === "true" || v === true ? true : v === "false" || v === false ? false : null;
26
- }
27
-
28
- public static escapeRegExp(v: string): string {
29
- if (Util.isNotEmpty(v)) {
30
- return v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31
- }
32
- return v;
33
- }
34
-
35
- public static nullToEmpty(val: string): string {
36
- return this.isNotEmpty(val) ? val : "";
37
- }
38
-
39
- public static nullTo0(val: number): number {
40
- return this.isNotNull(val) ? val : 0;
41
- }
42
-
43
- public static isNotEmpty(val: string): boolean {
44
- return typeof val !== "undefined" && val !== null && val.length > 0;
45
- }
46
-
47
- public static isNotNull(val: any): boolean {
48
- return typeof val !== "undefined" && val !== null;
49
- }
50
-
51
- public static isNull(val: any): boolean {
52
- return typeof val === "undefined" || val === null;
53
- }
54
-
55
- public static isArrayNotEmpty(val: any[]): boolean {
56
- return typeof val !== "undefined" && val !== null && val.length > 0;
57
- }
58
-
59
- public static isArrayEmpty(val: any[]): boolean {
60
- return typeof val === "undefined" || val === null || val.length === 0;
61
- }
62
-
63
- public static isObjectEmpty(val: any): boolean {
64
- return Util.isNull(val) || (Object.keys(val).length === 0 && val.constructor === Object);
65
- }
66
-
67
- public static isMapNotEmpty(val: TSMap<any, any>): boolean {
68
- return typeof val !== "undefined" && val !== null && (val.size() > 0 || val.keys().length > 0);
69
- }
70
-
71
- public static isMapEmpty(val: TSMap<any, any>): boolean {
72
- return typeof val === "undefined" || val === null || val.size() === 0 || val.keys().length === 0;
73
- }
74
-
75
- public static objectToMap<K, V>(obj: any): TSMap<K, V> | null {
76
- if (Util.isNotNull(obj)) {
77
- const map: TSMap<K, V> = new TSMap();
78
- Object.keys(obj).forEach((key: any) => {
79
- map.set(key, obj[key]);
80
- });
81
- return map;
82
- }
83
- return null;
84
- }
85
-
86
- public static keyByValue(obj: any, value: any): string | null {
87
- for (const prop in obj) {
88
- if (obj.hasOwnProperty(prop)) {
89
- if (obj[prop] === value) {
90
- return prop;
91
- }
92
- }
93
- }
94
- return null;
95
- }
96
-
97
- public static greaterThen0(val: number): boolean {
98
- return this.isNotNull(val) && val > 0;
99
- }
100
-
101
- public static not0(val: number): boolean {
102
- return this.isNotNull(val) && val !== 0;
103
- }
104
-
105
- public static lessThen0(val: number): boolean {
106
- return this.isNotNull(val) && val < 0;
107
- }
108
-
109
- public static compareUndefined(o1: any, o2: any): number {
110
- if (this.isNotNull(o1) && this.isNull(o2)) {
111
- return -1;
112
- }
113
- if (this.isNull(o1) && this.isNotNull(o2)) {
114
- return 1;
115
- }
116
- return 0;
117
- }
118
-
119
- public static compareArrayLength<T>(o1: T[], o2: T[]): number {
120
- const result: number = Util.compareUndefined(o1, o2);
121
- if (result === 0 && Util.isNotNull(o1) && Util.isNotNull(o2)) {
122
- return o1.length < o2.length ? -1 : (o1.length > o2.length ? 1 : 0);
123
- }
124
- return result;
125
- }
126
-
127
- public static compareObject(a: { [key: string]: any }, b: { [key: string]: any }) {
128
- for (const key in a) {
129
- if (!(key in b) || a[key] !== b[key]) {
130
- return false;
131
- }
132
- }
133
- for (const key in b) {
134
- if (!(key in a) || a[key] !== b[key]) {
135
- return false;
136
- }
137
- }
138
- return true;
139
- }
140
-
141
- public static compareArrays<T>(arr1: T[], arr2: T[], comparator: (t1: T, t2: T) => number): number {
142
- Util.checkNotNull(comparator);
143
- let result: number = this.compareArrayLength(arr1, arr2);
144
- if (result === 0 && Util.isNotNull(arr1) && Util.isNotNull(arr2)) {
145
- for (let i = 0; i < arr1.length; i++) {
146
- result = comparator(arr1[i], arr2[i]);
147
- if (result !== 0) {
148
- break;
149
- }
150
- }
151
- }
152
- return result;
153
- }
154
-
155
- public static compareBool(o1: boolean, o2: boolean): number {
156
- const result: number = this.compareUndefined(o1, o2);
157
- if (result === 0 && this.isNotNull(o1) && this.isNotNull(o2)) {
158
- return (Boolean(o2) as any) - (Boolean(o1) as any)
159
- }
160
- return result;
161
- }
162
-
163
- public static compareNumber(o1: number, o2: number): number {
164
- const result: number = this.compareUndefined(o1, o2);
165
- if (result === 0 && this.isNotNull(o1) && this.isNotNull(o2)) {
166
- return o1 === o2 ? 0 : o1 < o2 ? -1 : 1;
167
- }
168
- return result;
169
- }
170
-
171
- public static compareString(o1: string, o2: string): number {
172
- const result: number = Util.compareUndefined(o1, o2);
173
- if (result === 0 && Util.isNotNull(o1) && Util.isNotNull(o2)) {
174
- return o1 < o2 ? -1 : (o1 > o2 ? 1 : 0);
175
- }
176
- return result;
177
- }
178
-
179
- public static range(from: number, to: number): number[] {
180
- return Array(to - from + 1).fill(null).map((_, idx) => from + idx);
181
- }
182
-
183
- public static has(array: any[], val: any): boolean {
184
- if (Util.isArrayNotEmpty(array) && Util.isNotNull(val)) {
185
- for (let i = 0; i < array.length; i++) {
186
- if (array[i] === val) {
187
- return true;
188
- }
189
- }
190
- }
191
- return false;
192
- }
193
-
194
- public static isEmpty(val: string): boolean {
195
- return typeof val === "undefined" || val === null || val.length === 0;
196
- }
197
-
198
- public static checkNotNull<T>(reference: T, msg?: string): T {
199
- if (Util.isNull(reference)) {
200
- throw new ReferenceError(msg);
201
- }
202
- return reference;
203
- }
204
-
205
- public static randomInt(min: number, max: number): number {
206
- return Math.floor(Math.random() * (max - min + 1)) + min;
207
- }
208
-
209
- public static randomArr<T>(arr: T[]): T | undefined {
210
- if (Util.isArrayEmpty(arr)) {
211
- return undefined;
212
- }
213
- return arr[Util.randomInt(0, arr.length - 1)];
214
- }
215
-
216
- public static remove<T>(arr: T[], item: T): boolean {
217
- if (Util.isArrayNotEmpty(arr) && item) {
218
- for (let i: number = 0; i < arr.length; i++) {
219
- if (arr[i] === item) {
220
- arr.splice(i, 1);
221
- return true;
222
- }
223
- }
224
- }
225
- return false;
226
- }
227
-
228
- public static replaceAll(value: string, regex: string, replacement: string | number): string {
229
- if (Util.isNotNull(value)) {
230
- return value.replace(new RegExp(Util.escapeRegExp(regex), "g"), replacement as string);
231
- }
232
- return value;
233
- }
234
-
235
- public static to<T, U = any>(
236
- promise: Promise<T>,
237
- errorExt?: object
238
- ): Promise<[U | null, T | undefined]> {
239
- return promise
240
- .then<[null, T]>((data: T) => [null, data])
241
- .catch<[U, undefined]>((err) => {
242
- if (errorExt) {
243
- Object.assign(err, errorExt);
244
- }
245
- return [err, undefined];
246
- });
247
- }
248
-
249
- public static isObject(item: any): boolean {
250
- return (item && typeof item === "object" && !Array.isArray(item));
251
- }
252
-
253
- public static merge(target: any, ...sources: any[]): any {
254
- if (!sources.length) {
255
- return target;
256
- }
257
- const source = sources.shift();
258
- if (this.isObject(target) && this.isObject(source)) {
259
- for (const key in source) {
260
- if (this.isObject(source[key])) {
261
- if (!target[key]) {
262
- Object.assign(target, { [key]: {} });
263
- }
264
- this.merge(target[key], source[key]);
265
- } else if (Array.isArray(source[key])) {
266
- Object.assign(target, { [key]: [...source[key]] });
267
- } else if (typeof source[key] !== "undefined") {
268
- Object.assign(target, { [key]: source[key] });
269
- }
270
- }
271
- }
272
- return this.merge(target, ...sources);
273
- }
274
-
275
- public static deepCopy(source: object): object {
276
- return JSON.parse(JSON.stringify(source));
277
- }
278
-
279
- public static uuid = () => {
280
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
281
- // eslint-disable-next-line no-mixed-operators
282
- const r = Math.random() * 16 | 0, v = c === "x" ? r : (r & 0x3 | 0x8);
283
- return v.toString(16);
284
- });
285
- }
286
-
287
- public static getStackTrace(): string | undefined {
288
- return (new Error()).stack;
289
- }
290
-
291
- public static shuffleArray(array: any[]) {
292
- for (let i = array.length - 1; i > 0; i--) {
293
- const j = Math.floor(Math.random() * (i + 1));
294
- [array[i], array[j]] = [array[j], array[i]];
295
- };
296
- return array;
297
- }
298
-
299
- public static buildValidationHash(ext_user_id: string, ext_game_id: number, customer_id: string, secretKey: string): string {
300
- const toHash = `${ext_user_id}|${ext_game_id}|${customer_id}:${secretKey}`;
301
- return Md5.init(toHash);
302
- }
303
- }
304
-
305
-
306
- export { Util };
package/test/package.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "name": "@my-org/test",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "",
10
- "license": "ISC"
11
- }