@opexa/portal-sdk 0.0.91 → 0.0.92

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/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ var _e = Object.defineProperty;
2
2
  var Te = (n, e, t) => e in n ? _e(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var c = (n, e, t) => Te(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ObjectId as $ } from "@opexa/object-id";
5
- import { ObjectId as er } from "@opexa/object-id";
5
+ import { ObjectId as tr } from "@opexa/object-id";
6
6
  const U = {
7
7
  Account: 8,
8
8
  Deposit: 9,
@@ -1244,10 +1244,16 @@ const tt = o`
1244
1244
  }
1245
1245
  }
1246
1246
  `, Rt = o`
1247
+ query UnreadMessagesCount($filter: MessageFilterInput) {
1248
+ messages(filter: $filter) {
1249
+ totalCount
1250
+ }
1251
+ }
1252
+ `, Nt = o`
1247
1253
  mutation MarkMessageAsRead($id: ObjectId!) {
1248
1254
  markMessageAsRead(id: $id)
1249
1255
  }
1250
- `, Nt = o`
1256
+ `, Dt = o`
1251
1257
  mutation MarkAllMessageAsRead {
1252
1258
  markAllMessageAsRead
1253
1259
  }
@@ -1307,7 +1313,7 @@ function u(n) {
1307
1313
  }[n]
1308
1314
  };
1309
1315
  }
1310
- class Dt {
1316
+ class It {
1311
1317
  constructor(e) {
1312
1318
  c(this, "client");
1313
1319
  this.client = e;
@@ -1491,7 +1497,7 @@ const ue = {
1491
1497
  429: { name: "HttpTooManyRequests", message: "Too Many Requests" },
1492
1498
  500: { name: "HttpInternalServerError", message: "Internal Server Error" }
1493
1499
  };
1494
- class It {
1500
+ class Gt {
1495
1501
  constructor(e) {
1496
1502
  c(this, "url");
1497
1503
  c(this, "platform");
@@ -1660,7 +1666,7 @@ class It {
1660
1666
  }
1661
1667
  }
1662
1668
  }
1663
- class Gt {
1669
+ class Pt {
1664
1670
  constructor(e) {
1665
1671
  c(this, "url");
1666
1672
  c(this, "siteId");
@@ -1738,7 +1744,7 @@ class Gt {
1738
1744
  }
1739
1745
  }
1740
1746
  }
1741
- class Pt {
1747
+ class Wt {
1742
1748
  constructor(e) {
1743
1749
  c(this, "client");
1744
1750
  this.client = e;
@@ -1760,7 +1766,7 @@ class Pt {
1760
1766
  } : t;
1761
1767
  }
1762
1768
  }
1763
- class Wt {
1769
+ class xt {
1764
1770
  constructor(e) {
1765
1771
  c(this, "client");
1766
1772
  this.client = e;
@@ -1797,7 +1803,7 @@ class Wt {
1797
1803
  } : t;
1798
1804
  }
1799
1805
  }
1800
- class xt {
1806
+ class $t {
1801
1807
  constructor(e) {
1802
1808
  c(this, "client");
1803
1809
  this.client = e;
@@ -1817,7 +1823,7 @@ class xt {
1817
1823
  } : e;
1818
1824
  }
1819
1825
  }
1820
- class $t {
1826
+ class Ut {
1821
1827
  constructor(e) {
1822
1828
  c(this, "client");
1823
1829
  this.client = e;
@@ -1888,7 +1894,7 @@ class $t {
1888
1894
  return t.ok ? { ok: t.ok, data: t.data.downlinesByName } : t;
1889
1895
  }
1890
1896
  }
1891
- class Ut {
1897
+ class Ot {
1892
1898
  constructor(e) {
1893
1899
  c(this, "url");
1894
1900
  this.url = e.url;
@@ -1900,7 +1906,7 @@ class Ut {
1900
1906
  ];
1901
1907
  }
1902
1908
  }
1903
- class Ot {
1909
+ class Bt {
1904
1910
  constructor(e) {
1905
1911
  c(this, "client");
1906
1912
  this.client = e;
@@ -1912,8 +1918,12 @@ class Ot {
1912
1918
  );
1913
1919
  return t.ok ? { ok: t.ok, data: t.data.messages } : t;
1914
1920
  }
1915
- async markMessageAsRead(e) {
1921
+ async unreadMessagesCount(e) {
1916
1922
  const t = await this.client.request(Rt, e);
1923
+ return t.ok ? { ok: t.ok, data: t.data.messages.totalCount } : t;
1924
+ }
1925
+ async markMessageAsRead(e) {
1926
+ const t = await this.client.request(Nt, e);
1917
1927
  return t.ok ? t.data.markMessageAsRead ? {
1918
1928
  ok: !0
1919
1929
  } : {
@@ -1926,7 +1936,7 @@ class Ot {
1926
1936
  }
1927
1937
  async markAllMessageAsRead() {
1928
1938
  const e = await this.client.request(
1929
- Nt
1939
+ Dt
1930
1940
  );
1931
1941
  return e.ok ? e.data.markAllMessageAsRead ? {
1932
1942
  ok: !0
@@ -1939,7 +1949,7 @@ class Ot {
1939
1949
  } : e;
1940
1950
  }
1941
1951
  }
1942
- class Bt {
1952
+ class qt {
1943
1953
  constructor(e) {
1944
1954
  c(this, "client");
1945
1955
  this.client = e;
@@ -2135,7 +2145,7 @@ function B(n, e) {
2135
2145
  function le(n, e) {
2136
2146
  return n.getTime() > e.getTime();
2137
2147
  }
2138
- class qt {
2148
+ class Ft {
2139
2149
  constructor(e) {
2140
2150
  c(this, "config");
2141
2151
  c(this, "cache");
@@ -2156,18 +2166,18 @@ class qt {
2156
2166
  return !t || le(/* @__PURE__ */ new Date(), t.validUntil) ? null : t.value;
2157
2167
  }
2158
2168
  }
2159
- function Ft(n, e, t) {
2169
+ function Lt(n, e, t) {
2160
2170
  return n < e ? e : n > t ? t : n;
2161
2171
  }
2162
2172
  function pe(n) {
2163
2173
  return Object.prototype.toString.call(n) === "[object Object]" && Object(n) === n;
2164
2174
  }
2165
- function Lt(n) {
2175
+ function Vt(n) {
2166
2176
  const e = [];
2167
2177
  function t(r, a = []) {
2168
2178
  for (const s in r) {
2169
2179
  const m = r[s];
2170
- pe(m) ? t(m, [...a, s]) : Array.isArray(m) ? t(Vt(m), [...a, s]) : e.push({
2180
+ pe(m) ? t(m, [...a, s]) : Array.isArray(m) ? t(Ht(m), [...a, s]) : e.push({
2171
2181
  key: [...a, s],
2172
2182
  value: m
2173
2183
  });
@@ -2175,7 +2185,7 @@ function Lt(n) {
2175
2185
  }
2176
2186
  return t(n), e;
2177
2187
  }
2178
- function Vt(n) {
2188
+ function Ht(n) {
2179
2189
  return n.reduce((e, t, r) => (e[r] = t, e), {});
2180
2190
  }
2181
2191
  class O {
@@ -2242,7 +2252,7 @@ class O {
2242
2252
  return t;
2243
2253
  }
2244
2254
  createUploadBody(e, t) {
2245
- const r = Lt(t).filter(
2255
+ const r = Vt(t).filter(
2246
2256
  (m) => m.value instanceof File || m.value instanceof Blob
2247
2257
  ), a = new FormData();
2248
2258
  a.append(
@@ -2260,14 +2270,14 @@ class O {
2260
2270
  }), a;
2261
2271
  }
2262
2272
  }
2263
- function Ht(n) {
2273
+ function Yt(n) {
2264
2274
  return n === "INR" ? "en-IN" : n === "MYR" ? "en-MY" : n === "IDR" ? "en-ID" : n === "USD" ? "en-US" : "en-PH";
2265
2275
  }
2266
- function Yt(n) {
2276
+ function jt(n) {
2267
2277
  return n === "en-IN" ? "+91" : n === "en-MY" ? "+60" : n === "en-ID" ? "+62" : n === "en-US" ? "+1" : "+63";
2268
2278
  }
2269
2279
  function x(n, e) {
2270
- const t = Yt(e);
2280
+ const t = jt(e);
2271
2281
  return n.startsWith(t) ? n : n.startsWith(t.substring(1)) ? `+${n}` : n.startsWith("0") ? `${t}${n.substring(1)}` : `${t}${n}`;
2272
2282
  }
2273
2283
  async function g(n) {
@@ -2318,7 +2328,7 @@ function F(n, e) {
2318
2328
  const t = we(n);
2319
2329
  return t.setMinutes(t.getMinutes() - e), t;
2320
2330
  }
2321
- class jt {
2331
+ class Qt {
2322
2332
  constructor(e) {
2323
2333
  c(this, "logger");
2324
2334
  c(this, "storageKey", "session");
@@ -2563,11 +2573,11 @@ function i(n, e) {
2563
2573
  }
2564
2574
  return e;
2565
2575
  }
2566
- class Qt {
2576
+ class Kt {
2567
2577
  constructor(e) {
2568
2578
  c(this, "staticService");
2569
2579
  const t = (e == null ? void 0 : e.environment) === "development";
2570
- this.staticService = new Ut({
2580
+ this.staticService = new Ot({
2571
2581
  url: t ? "https://static.development.opexa.io" : "https://static.opexa.io"
2572
2582
  });
2573
2583
  }
@@ -2706,7 +2716,7 @@ class Qt {
2706
2716
  return {
2707
2717
  currency: e.currency,
2708
2718
  timezone: e.timezone,
2709
- locale: Ht(e.currency)
2719
+ locale: Yt(e.currency)
2710
2720
  };
2711
2721
  }
2712
2722
  pointsClubSettings(e) {
@@ -3135,7 +3145,7 @@ class Qt {
3135
3145
  };
3136
3146
  }
3137
3147
  }
3138
- class Jt {
3148
+ class Xt {
3139
3149
  constructor(e) {
3140
3150
  c(this, "cmsPortalService");
3141
3151
  c(this, "authService");
@@ -3158,12 +3168,12 @@ class Jt {
3158
3168
  environment: s,
3159
3169
  logs: m
3160
3170
  } = e, d = s === "production";
3161
- this.transformer = new Qt({
3171
+ this.transformer = new Kt({
3162
3172
  environment: s
3163
3173
  }), this.logger = new ke({
3164
3174
  enabled: m ?? !1
3165
3175
  });
3166
- const p = d ? "https://auth.opexa.io" : "https://auth.development.opexa.io", f = d ? "https://wallet.opexa.io/graphql" : "https://wallet.development.opexa.io/graphql", h = d ? "https://report.opexa.io/graphql" : "https://report.development.opexa.io/graphql", l = d ? "https://account.opexa.io/graphql" : "https://account.development.opexa.io/graphql", k = d ? "https://portal.opexa.io/graphql" : "https://portal.development.opexa.io/graphql", C = d ? "https://file.opexa.io/graphql" : "https://file.development.opexa.io/graphql", _ = d ? "https://game.opexa.io/graphql" : "https://game.development.opexa.io/graphql", T = d ? "https://trigger.opexa.io/graphql" : "https://trigger.development.opexa.io/graphql", M = "https://portal-api.opexacms.io/v1", v = new Gt({
3176
+ const p = d ? "https://auth.opexa.io" : "https://auth.development.opexa.io", f = d ? "https://wallet.opexa.io/graphql" : "https://wallet.development.opexa.io/graphql", h = d ? "https://report.opexa.io/graphql" : "https://report.development.opexa.io/graphql", l = d ? "https://account.opexa.io/graphql" : "https://account.development.opexa.io/graphql", k = d ? "https://portal.opexa.io/graphql" : "https://portal.development.opexa.io/graphql", C = d ? "https://file.opexa.io/graphql" : "https://file.development.opexa.io/graphql", _ = d ? "https://game.opexa.io/graphql" : "https://game.development.opexa.io/graphql", T = d ? "https://trigger.opexa.io/graphql" : "https://trigger.development.opexa.io/graphql", M = "https://portal-api.opexacms.io/v1", v = new Pt({
3167
3177
  url: M,
3168
3178
  site: t,
3169
3179
  platform: r
@@ -3175,15 +3185,15 @@ class Jt {
3175
3185
  "Platform-Code": a
3176
3186
  }
3177
3187
  }
3178
- }, R = new Wt(new O(_, y)), N = new Pt(new O(C, y)), S = new Bt(new O(f, y)), D = new Dt(new O(l, y)), I = new $t(new O(h, y)), G = new xt(new O(k, y)), P = new Ot(new O(T, y)), A = new It({
3188
+ }, R = new xt(new O(_, y)), N = new Wt(new O(C, y)), S = new qt(new O(f, y)), D = new It(new O(l, y)), I = new Ut(new O(h, y)), G = new $t(new O(k, y)), P = new Bt(new O(T, y)), A = new Gt({
3179
3189
  url: p,
3180
3190
  platform: a
3181
- }), W = new jt({
3191
+ }), W = new Qt({
3182
3192
  logs: m,
3183
3193
  authService: A,
3184
3194
  walletService: S
3185
3195
  });
3186
- this.authService = A, this.gameService = R, this.fileService = N, this.walletService = S, this.accountService = D, this.reportService = I, this.portalService = G, this.triggerService = P, this.sessionManager = W, this.cmsPortalService = v, this.cache = new qt();
3196
+ this.authService = A, this.gameService = R, this.fileService = N, this.walletService = S, this.accountService = D, this.reportService = I, this.portalService = G, this.triggerService = P, this.sessionManager = W, this.cmsPortalService = v, this.cache = new Ft();
3187
3197
  }
3188
3198
  get authMiddleware() {
3189
3199
  return async (e) => {
@@ -3264,7 +3274,7 @@ class Jt {
3264
3274
  await this.sessionManager.destroy();
3265
3275
  }
3266
3276
  watchSession(e) {
3267
- const t = Ft(e.interval ?? 3e4, 3e4, 6e4);
3277
+ const t = Lt(e.interval ?? 3e4, 3e4, 6e4);
3268
3278
  let r = null;
3269
3279
  const a = () => setTimeout(async () => {
3270
3280
  await this.sessionManager.verify() || await e.onInvalid(), r = a();
@@ -4001,6 +4011,9 @@ class Jt {
4001
4011
  }
4002
4012
  } : t;
4003
4013
  }
4014
+ async unreadMessagesCount(e) {
4015
+ return await this.triggerService.unreadMessagesCount(e);
4016
+ }
4004
4017
  async markMessageAsRead(e) {
4005
4018
  return await this.triggerService.markMessageAsRead({ id: e });
4006
4019
  }
@@ -4009,8 +4022,8 @@ class Jt {
4009
4022
  }
4010
4023
  }
4011
4024
  export {
4012
- er as ObjectId,
4025
+ tr as ObjectId,
4013
4026
  U as ObjectType,
4014
- Jt as Sdk
4027
+ Xt as Sdk
4015
4028
  };
4016
4029
  //# sourceMappingURL=index.mjs.map