@opexa/portal-sdk 0.0.91 → 0.0.93

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,23 @@ class Ot {
1912
1918
  );
1913
1919
  return t.ok ? { ok: t.ok, data: t.data.messages } : t;
1914
1920
  }
1921
+ async unreadMessagesCount(e) {
1922
+ const t = await this.client.request(
1923
+ Rt,
1924
+ {
1925
+ ...e,
1926
+ filter: {
1927
+ ...e == null ? void 0 : e.filter,
1928
+ markedAsRead: {
1929
+ equal: !1
1930
+ }
1931
+ }
1932
+ }
1933
+ );
1934
+ return t.ok ? { ok: t.ok, data: t.data.messages.totalCount } : t;
1935
+ }
1915
1936
  async markMessageAsRead(e) {
1916
- const t = await this.client.request(Rt, e);
1937
+ const t = await this.client.request(Nt, e);
1917
1938
  return t.ok ? t.data.markMessageAsRead ? {
1918
1939
  ok: !0
1919
1940
  } : {
@@ -1926,7 +1947,7 @@ class Ot {
1926
1947
  }
1927
1948
  async markAllMessageAsRead() {
1928
1949
  const e = await this.client.request(
1929
- Nt
1950
+ Dt
1930
1951
  );
1931
1952
  return e.ok ? e.data.markAllMessageAsRead ? {
1932
1953
  ok: !0
@@ -1939,7 +1960,7 @@ class Ot {
1939
1960
  } : e;
1940
1961
  }
1941
1962
  }
1942
- class Bt {
1963
+ class qt {
1943
1964
  constructor(e) {
1944
1965
  c(this, "client");
1945
1966
  this.client = e;
@@ -2135,7 +2156,7 @@ function B(n, e) {
2135
2156
  function le(n, e) {
2136
2157
  return n.getTime() > e.getTime();
2137
2158
  }
2138
- class qt {
2159
+ class Ft {
2139
2160
  constructor(e) {
2140
2161
  c(this, "config");
2141
2162
  c(this, "cache");
@@ -2156,18 +2177,18 @@ class qt {
2156
2177
  return !t || le(/* @__PURE__ */ new Date(), t.validUntil) ? null : t.value;
2157
2178
  }
2158
2179
  }
2159
- function Ft(n, e, t) {
2180
+ function Lt(n, e, t) {
2160
2181
  return n < e ? e : n > t ? t : n;
2161
2182
  }
2162
2183
  function pe(n) {
2163
2184
  return Object.prototype.toString.call(n) === "[object Object]" && Object(n) === n;
2164
2185
  }
2165
- function Lt(n) {
2186
+ function Vt(n) {
2166
2187
  const e = [];
2167
2188
  function t(r, a = []) {
2168
2189
  for (const s in r) {
2169
2190
  const m = r[s];
2170
- pe(m) ? t(m, [...a, s]) : Array.isArray(m) ? t(Vt(m), [...a, s]) : e.push({
2191
+ pe(m) ? t(m, [...a, s]) : Array.isArray(m) ? t(Ht(m), [...a, s]) : e.push({
2171
2192
  key: [...a, s],
2172
2193
  value: m
2173
2194
  });
@@ -2175,7 +2196,7 @@ function Lt(n) {
2175
2196
  }
2176
2197
  return t(n), e;
2177
2198
  }
2178
- function Vt(n) {
2199
+ function Ht(n) {
2179
2200
  return n.reduce((e, t, r) => (e[r] = t, e), {});
2180
2201
  }
2181
2202
  class O {
@@ -2242,7 +2263,7 @@ class O {
2242
2263
  return t;
2243
2264
  }
2244
2265
  createUploadBody(e, t) {
2245
- const r = Lt(t).filter(
2266
+ const r = Vt(t).filter(
2246
2267
  (m) => m.value instanceof File || m.value instanceof Blob
2247
2268
  ), a = new FormData();
2248
2269
  a.append(
@@ -2260,14 +2281,14 @@ class O {
2260
2281
  }), a;
2261
2282
  }
2262
2283
  }
2263
- function Ht(n) {
2284
+ function Yt(n) {
2264
2285
  return n === "INR" ? "en-IN" : n === "MYR" ? "en-MY" : n === "IDR" ? "en-ID" : n === "USD" ? "en-US" : "en-PH";
2265
2286
  }
2266
- function Yt(n) {
2287
+ function jt(n) {
2267
2288
  return n === "en-IN" ? "+91" : n === "en-MY" ? "+60" : n === "en-ID" ? "+62" : n === "en-US" ? "+1" : "+63";
2268
2289
  }
2269
2290
  function x(n, e) {
2270
- const t = Yt(e);
2291
+ const t = jt(e);
2271
2292
  return n.startsWith(t) ? n : n.startsWith(t.substring(1)) ? `+${n}` : n.startsWith("0") ? `${t}${n.substring(1)}` : `${t}${n}`;
2272
2293
  }
2273
2294
  async function g(n) {
@@ -2318,7 +2339,7 @@ function F(n, e) {
2318
2339
  const t = we(n);
2319
2340
  return t.setMinutes(t.getMinutes() - e), t;
2320
2341
  }
2321
- class jt {
2342
+ class Qt {
2322
2343
  constructor(e) {
2323
2344
  c(this, "logger");
2324
2345
  c(this, "storageKey", "session");
@@ -2563,11 +2584,11 @@ function i(n, e) {
2563
2584
  }
2564
2585
  return e;
2565
2586
  }
2566
- class Qt {
2587
+ class Kt {
2567
2588
  constructor(e) {
2568
2589
  c(this, "staticService");
2569
2590
  const t = (e == null ? void 0 : e.environment) === "development";
2570
- this.staticService = new Ut({
2591
+ this.staticService = new Ot({
2571
2592
  url: t ? "https://static.development.opexa.io" : "https://static.opexa.io"
2572
2593
  });
2573
2594
  }
@@ -2706,7 +2727,7 @@ class Qt {
2706
2727
  return {
2707
2728
  currency: e.currency,
2708
2729
  timezone: e.timezone,
2709
- locale: Ht(e.currency)
2730
+ locale: Yt(e.currency)
2710
2731
  };
2711
2732
  }
2712
2733
  pointsClubSettings(e) {
@@ -3135,7 +3156,7 @@ class Qt {
3135
3156
  };
3136
3157
  }
3137
3158
  }
3138
- class Jt {
3159
+ class Xt {
3139
3160
  constructor(e) {
3140
3161
  c(this, "cmsPortalService");
3141
3162
  c(this, "authService");
@@ -3158,12 +3179,12 @@ class Jt {
3158
3179
  environment: s,
3159
3180
  logs: m
3160
3181
  } = e, d = s === "production";
3161
- this.transformer = new Qt({
3182
+ this.transformer = new Kt({
3162
3183
  environment: s
3163
3184
  }), this.logger = new ke({
3164
3185
  enabled: m ?? !1
3165
3186
  });
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({
3187
+ 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
3188
  url: M,
3168
3189
  site: t,
3169
3190
  platform: r
@@ -3175,15 +3196,15 @@ class Jt {
3175
3196
  "Platform-Code": a
3176
3197
  }
3177
3198
  }
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({
3199
+ }, 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
3200
  url: p,
3180
3201
  platform: a
3181
- }), W = new jt({
3202
+ }), W = new Qt({
3182
3203
  logs: m,
3183
3204
  authService: A,
3184
3205
  walletService: S
3185
3206
  });
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();
3207
+ 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
3208
  }
3188
3209
  get authMiddleware() {
3189
3210
  return async (e) => {
@@ -3264,7 +3285,7 @@ class Jt {
3264
3285
  await this.sessionManager.destroy();
3265
3286
  }
3266
3287
  watchSession(e) {
3267
- const t = Ft(e.interval ?? 3e4, 3e4, 6e4);
3288
+ const t = Lt(e.interval ?? 3e4, 3e4, 6e4);
3268
3289
  let r = null;
3269
3290
  const a = () => setTimeout(async () => {
3270
3291
  await this.sessionManager.verify() || await e.onInvalid(), r = a();
@@ -4001,6 +4022,9 @@ class Jt {
4001
4022
  }
4002
4023
  } : t;
4003
4024
  }
4025
+ async unreadMessagesCount(e) {
4026
+ return await this.triggerService.unreadMessagesCount(e);
4027
+ }
4004
4028
  async markMessageAsRead(e) {
4005
4029
  return await this.triggerService.markMessageAsRead({ id: e });
4006
4030
  }
@@ -4009,8 +4033,8 @@ class Jt {
4009
4033
  }
4010
4034
  }
4011
4035
  export {
4012
- er as ObjectId,
4036
+ tr as ObjectId,
4013
4037
  U as ObjectType,
4014
- Jt as Sdk
4038
+ Xt as Sdk
4015
4039
  };
4016
4040
  //# sourceMappingURL=index.mjs.map