@smartico/public-api 0.0.201 → 0.0.203

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.
@@ -50,6 +50,12 @@ ___
50
50
 
51
51
  ___
52
52
 
53
+ ### TreasureHunt
54
+
55
+ • **TreasureHunt** = ``"treasure_hunt"``
56
+
57
+ ___
58
+
53
59
  ### Unknown
54
60
 
55
61
  • **Unknown** = ``"unknown"``
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.201",
3
+ "version": "0.0.203",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,6 +10,7 @@ export enum AchCustomSectionType {
10
10
  REDIRECT_LINK = 9,
11
11
  LOOTBOX_WEEKLY = 10,
12
12
  LOOTBOX_CALENDAR_DAYS = 11,
13
+ TREASURE_HUNT = 12,
13
14
  }
14
15
 
15
16
  export enum AchCustomLayoutTheme {
@@ -9,6 +9,7 @@ export enum SAWGameType {
9
9
  Quiz = 6,
10
10
  LootboxWeekdays = 7,
11
11
  LootboxCalendarDays = 8,
12
+ TreasureHunt = 9
12
13
  }
13
14
 
14
15
  export enum SAWGameTypeName {
@@ -20,6 +21,7 @@ export enum SAWGameTypeName {
20
21
  Quiz = 'quiz',
21
22
  LootboxWeekdays = 'lootbox_weekdays',
22
23
  LootboxCalendarDays = 'lootbox_calendar_days',
24
+ TreasureHunt = 'treasure_hunt',
23
25
  Unknown = 'unknown',
24
26
  }
25
27
 
@@ -35,6 +37,7 @@ export const SAWGameTypeNamed = (type: SAWGameType): SAWGameTypeName => {
35
37
  [SAWGameType.Quiz]: SAWGameTypeName.Quiz,
36
38
  [SAWGameType.LootboxWeekdays]: SAWGameTypeName.LootboxWeekdays,
37
39
  [SAWGameType.LootboxCalendarDays]: SAWGameTypeName.LootboxCalendarDays,
40
+ [SAWGameType.TreasureHunt]: SAWGameTypeName.TreasureHunt,
38
41
  }[type] || SAWGameTypeName.Unknown
39
42
  );
40
43
  };
package/src/NodeCache.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  class NodeCache {
2
- private static ttlChecker: NodeJS.Timeout;
2
+ private ttlChecker: NodeJS.Timeout;
3
3
 
4
- private static cache: { [key: string]: any } = {};
4
+ private cache: { [key: string]: any } = {};
5
5
 
6
- constructor() {
7
- if (NodeCache.ttlChecker === undefined) {
8
- NodeCache.ttlChecker = setInterval(() => {
6
+ constructor() {
7
+ if (this.ttlChecker === undefined) {
8
+ this.ttlChecker = setInterval(() => {
9
9
  const now = new Date().getTime();
10
- for (const key in NodeCache.cache) {
11
- if (NodeCache.cache.hasOwnProperty(key)) {
12
- const o = NodeCache.cache[key];
10
+ for (const key in this.cache) {
11
+ if (this.cache.hasOwnProperty(key)) {
12
+ const o = this.cache[key];
13
13
  if (o.ttl < now) {
14
- delete NodeCache.cache[key];
14
+ delete this.cache[key];
15
15
  }
16
16
  }
17
17
  }
@@ -20,27 +20,31 @@ class NodeCache {
20
20
  }
21
21
 
22
22
  public get(key: string): any {
23
- const o = NodeCache.cache[key];
23
+ const o = this.cache[key];
24
24
  if (o !== undefined && o.ttl > new Date().getTime()) {
25
25
  return o.value;
26
26
  }
27
27
  }
28
28
 
29
29
  public set(key: string, value: any, ttlSeconds: number = 60) {
30
- NodeCache.cache[key] = {
30
+ this.cache[key] = {
31
31
  value,
32
32
  ttl: new Date().getTime() + ttlSeconds * 1000,
33
33
  };
34
34
  }
35
35
 
36
36
  public remove(key: string) {
37
- if (NodeCache.cache.hasOwnProperty(key)) {
38
- delete NodeCache.cache[key];
37
+ if (this.cache.hasOwnProperty(key)) {
38
+ delete this.cache[key];
39
39
  }
40
40
  }
41
41
 
42
42
  public flushAll() {
43
- NodeCache.cache = {};
43
+ this.cache = {};
44
+ if (this.ttlChecker) {
45
+ clearInterval(this.ttlChecker);
46
+ this.ttlChecker = undefined
47
+ }
44
48
  }
45
49
  }
46
50
 
package/src/OCache.ts CHANGED
@@ -63,6 +63,11 @@ export class OCache {
63
63
  }
64
64
 
65
65
  public static async clearAll() {
66
+ for (const cacheContext in this.cache) {
67
+ if (this.cache.hasOwnProperty(cacheContext)) {
68
+ this.cache[cacheContext].flushAll();
69
+ }
70
+ }
66
71
  this.cache = {};
67
72
  }
68
73
  }