@ecency/sdk 1.0.49 → 1.0.50

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.
@@ -1,12 +1,12 @@
1
- var _ = Object.defineProperty;
2
- var T = (e, t, n) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var C = (e, t, n) => T(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as O, useMutation as y, useQuery as j, useInfiniteQuery as k, queryOptions as p, infiniteQueryOptions as A } from "@tanstack/react-query";
5
- import { Client as F, PrivateKey as h, cryptoUtils as D, RCAPI as P } from "@hiveio/dhive";
6
- import d from "hivesigner";
1
+ var T = Object.defineProperty;
2
+ var j = (e, t, n) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var b = (e, t, n) => j(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { QueryClient as K, useMutation as l, useQuery as A, useInfiniteQuery as k, queryOptions as u, infiniteQueryOptions as D } from "@tanstack/react-query";
5
+ import { Client as F, PrivateKey as d, cryptoUtils as P, RCAPI as M } from "@hiveio/dhive";
6
+ import g from "hivesigner";
7
7
  class I {
8
8
  constructor() {
9
- C(this, "length", 0);
9
+ b(this, "length", 0);
10
10
  }
11
11
  clear() {
12
12
  throw new Error("Method not implemented.");
@@ -49,22 +49,22 @@ const a = {
49
49
  }
50
50
  ),
51
51
  heliusApiKey: void 0,
52
- queryClient: new O(),
52
+ queryClient: new K(),
53
53
  plausibleHost: "https://pl.ecency.com"
54
54
  };
55
- var b;
55
+ var O;
56
56
  ((e) => {
57
57
  function t(n) {
58
58
  a.queryClient = n;
59
59
  }
60
60
  e.setQueryClient = t;
61
- })(b || (b = {}));
61
+ })(O || (O = {}));
62
62
  function N(e) {
63
63
  let t = atob(e);
64
64
  if (t[0] === "{")
65
65
  return JSON.parse(t);
66
66
  }
67
- const f = (e) => {
67
+ const h = (e) => {
68
68
  try {
69
69
  const t = a.storage.getItem(
70
70
  a.storagePrefix + "_user_" + e
@@ -74,8 +74,8 @@ const f = (e) => {
74
74
  console.error(t);
75
75
  return;
76
76
  }
77
- }, l = (e) => f(e) && f(e).accessToken, K = (e) => f(e) && f(e).postingKey, S = (e) => f(e) && f(e).loginType, Z = (e) => f(e) && f(e).refreshToken;
78
- function M() {
77
+ }, f = (e) => h(e) && h(e).accessToken, S = (e) => h(e) && h(e).postingKey, Q = (e) => h(e) && h(e).loginType, Z = (e) => h(e) && h(e).refreshToken;
78
+ function E() {
79
79
  return new Promise((e) => {
80
80
  var t;
81
81
  (t = window.hive_keychain) == null || t.requestHandshake(() => {
@@ -83,46 +83,46 @@ function M() {
83
83
  });
84
84
  });
85
85
  }
86
- const g = (e, t, n, o = null) => new Promise((i, c) => {
86
+ const w = (e, t, n, r = null) => new Promise((o, c) => {
87
87
  var s;
88
88
  (s = window.hive_keychain) == null || s.requestBroadcast(
89
89
  e,
90
90
  t,
91
91
  n,
92
- (r) => {
93
- r.success || c({ message: "Operation cancelled" }), i(r);
92
+ (i) => {
93
+ i.success || c({ message: "Operation cancelled" }), o(i);
94
94
  },
95
- o
95
+ r
96
96
  );
97
97
  }), L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
98
98
  __proto__: null,
99
- broadcast: g,
100
- handshake: M
99
+ broadcast: w,
100
+ handshake: E
101
101
  }, Symbol.toStringTag, { value: "Module" }));
102
102
  function J(e = [], t, n) {
103
- return y({
103
+ return l({
104
104
  mutationKey: [...e, t],
105
- mutationFn: async (o) => {
105
+ mutationFn: async (r) => {
106
106
  if (!t)
107
107
  throw new Error(
108
108
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
109
109
  );
110
- const i = K(t);
111
- if (i) {
112
- const r = h.fromString(i);
110
+ const o = S(t);
111
+ if (o) {
112
+ const i = d.fromString(o);
113
113
  return a.hiveClient.broadcast.sendOperations(
114
- n(o),
115
- r
114
+ n(r),
115
+ i
116
116
  );
117
117
  }
118
- const c = S(t);
118
+ const c = Q(t);
119
119
  if (c && c == "keychain")
120
- return g(t, n(o), "Posting").then((r) => r.result);
121
- let s = l(t);
120
+ return w(t, n(r), "Posting").then((i) => i.result);
121
+ let s = f(t);
122
122
  if (s)
123
- return (await new d.Client({
123
+ return (await new g.Client({
124
124
  accessToken: s
125
- }).broadcast(n(o))).result;
125
+ }).broadcast(n(r))).result;
126
126
  throw new Error(
127
127
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
128
128
  );
@@ -134,25 +134,25 @@ async function H(e, t, n) {
134
134
  throw new Error(
135
135
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
136
136
  );
137
- const o = {
137
+ const r = {
138
138
  id: t,
139
139
  required_auths: [],
140
140
  required_posting_auths: [e],
141
141
  json: JSON.stringify(n)
142
- }, i = K(e);
143
- if (i) {
144
- const r = h.fromString(i);
142
+ }, o = S(e);
143
+ if (o) {
144
+ const i = d.fromString(o);
145
145
  return a.hiveClient.broadcast.json(
146
- o,
147
- r
146
+ r,
147
+ i
148
148
  );
149
149
  }
150
- const c = S(e);
150
+ const c = Q(e);
151
151
  if (c && c == "keychain")
152
- return g(e, [["custom_json", o]], "Posting").then((r) => r.result);
153
- let s = l(e);
152
+ return w(e, [["custom_json", r]], "Posting").then((i) => i.result);
153
+ let s = f(e);
154
154
  if (s)
155
- return (await new d.Client({
155
+ return (await new g.Client({
156
156
  accessToken: s
157
157
  }).customJson([], [e], t, JSON.stringify(n))).result;
158
158
  throw new Error(
@@ -160,7 +160,7 @@ async function H(e, t, n) {
160
160
  );
161
161
  }
162
162
  function R() {
163
- return new O({
163
+ return new K({
164
164
  defaultOptions: {
165
165
  queries: {
166
166
  // With SSR, we usually want to set some default staleTime
@@ -172,40 +172,40 @@ function R() {
172
172
  }
173
173
  });
174
174
  }
175
- const u = () => a.queryClient;
175
+ const p = () => a.queryClient;
176
176
  var q;
177
177
  ((e) => {
178
- function t(r) {
179
- return u().getQueryData(r);
178
+ function t(i) {
179
+ return p().getQueryData(i);
180
180
  }
181
181
  e.getQueryData = t;
182
- function n(r) {
183
- return u().getQueryData(r);
182
+ function n(i) {
183
+ return p().getQueryData(i);
184
184
  }
185
185
  e.getInfiniteQueryData = n;
186
- async function o(r) {
187
- return await u().prefetchQuery(r), t(r.queryKey);
186
+ async function r(i) {
187
+ return await p().prefetchQuery(i), t(i.queryKey);
188
188
  }
189
- e.prefetchQuery = o;
190
- async function i(r) {
191
- return await u().prefetchInfiniteQuery(r), n(r.queryKey);
189
+ e.prefetchQuery = r;
190
+ async function o(i) {
191
+ return await p().prefetchInfiniteQuery(i), n(i.queryKey);
192
192
  }
193
- e.prefetchInfiniteQuery = i;
194
- function c(r) {
193
+ e.prefetchInfiniteQuery = o;
194
+ function c(i) {
195
195
  return {
196
- prefetch: () => o(r),
197
- getData: () => t(r.queryKey),
198
- useClientQuery: () => j(r),
199
- fetchAndGet: () => u().fetchQuery(r)
196
+ prefetch: () => r(i),
197
+ getData: () => t(i.queryKey),
198
+ useClientQuery: () => A(i),
199
+ fetchAndGet: () => p().fetchQuery(i)
200
200
  };
201
201
  }
202
202
  e.generateClientServerQuery = c;
203
- function s(r) {
203
+ function s(i) {
204
204
  return {
205
- prefetch: () => i(r),
206
- getData: () => n(r.queryKey),
207
- useClientQuery: () => k(r),
208
- fetchAndGet: () => u().fetchInfiniteQuery(r)
205
+ prefetch: () => o(i),
206
+ getData: () => n(i.queryKey),
207
+ useClientQuery: () => k(i),
208
+ fetchAndGet: () => p().fetchInfiniteQuery(i)
209
209
  };
210
210
  }
211
211
  e.generateClientServerInfiniteQuery = s;
@@ -234,7 +234,7 @@ function ee(e) {
234
234
  );
235
235
  }
236
236
  function te(e) {
237
- return p({
237
+ return u({
238
238
  queryKey: ["get-account-full", e],
239
239
  queryFn: async () => {
240
240
  if (!e)
@@ -243,26 +243,26 @@ function te(e) {
243
243
  if (!t[0])
244
244
  throw new Error("[SDK] No account with given username");
245
245
  const n = JSON.parse(t[0].posting_json_metadata).profile;
246
- let o;
246
+ let r;
247
247
  try {
248
- o = await a.hiveClient.database.call(
248
+ r = await a.hiveClient.database.call(
249
249
  "get_follow_count",
250
250
  [e]
251
251
  );
252
252
  } catch {
253
253
  }
254
- const i = await a.hiveClient.call(
254
+ const o = await a.hiveClient.call(
255
255
  "condenser_api",
256
256
  "get_account_reputations",
257
257
  [e, 1]
258
258
  );
259
259
  return {
260
260
  ...t,
261
- follow_stats: o,
262
- reputation: i[0].reputation,
261
+ follow_stats: r,
262
+ reputation: o[0].reputation,
263
263
  profile: {
264
264
  ...n,
265
- reputation: i[0].reputation
265
+ reputation: o[0].reputation
266
266
  }
267
267
  };
268
268
  },
@@ -271,19 +271,19 @@ function te(e) {
271
271
  });
272
272
  }
273
273
  function ne(e, t = 5, n = []) {
274
- return p({
274
+ return u({
275
275
  queryKey: ["accounts", "search", e, n],
276
276
  enabled: !!e,
277
277
  queryFn: async () => (await a.hiveClient.database.call(
278
278
  "lookup_accounts",
279
279
  [e, t]
280
280
  )).filter(
281
- (i) => n.length > 0 ? !n.includes(i) : !0
281
+ (o) => n.length > 0 ? !n.includes(o) : !0
282
282
  )
283
283
  });
284
284
  }
285
- function oe(e) {
286
- return p({
285
+ function re(e) {
286
+ return u({
287
287
  queryKey: ["accounts", "check-wallet-pending", e],
288
288
  queryFn: async () => await (await fetch(
289
289
  a.privateApiHost + "/private-api/wallets-chkuser",
@@ -302,7 +302,7 @@ function oe(e) {
302
302
  });
303
303
  }
304
304
  function B(e, t) {
305
- return p({
305
+ return u({
306
306
  queryKey: ["accounts", "relations", e, t],
307
307
  enabled: !!e && !!t,
308
308
  refetchOnMount: !1,
@@ -314,8 +314,8 @@ function B(e, t) {
314
314
  )
315
315
  });
316
316
  }
317
- function re(e) {
318
- return p({
317
+ function oe(e) {
318
+ return u({
319
319
  queryKey: ["accounts", "subscriptions", e],
320
320
  enabled: !!e,
321
321
  queryFn: async () => await a.hiveClient.call(
@@ -327,16 +327,16 @@ function re(e) {
327
327
  ) ?? []
328
328
  });
329
329
  }
330
- function ie(e, t, n, o) {
331
- return y({
330
+ function ie(e, t, n, r) {
331
+ return l({
332
332
  mutationKey: [],
333
- mutationFn: async (i) => {
333
+ mutationFn: async (o) => {
334
334
  const c = B(
335
335
  e,
336
336
  t
337
337
  );
338
- await u().prefetchQuery(c);
339
- const s = u().getQueryData(
338
+ await p().prefetchQuery(c);
339
+ const s = p().getQueryData(
340
340
  c.queryKey
341
341
  );
342
342
  return await H(e, "follow", [
@@ -345,27 +345,27 @@ function ie(e, t, n, o) {
345
345
  follower: e,
346
346
  following: t,
347
347
  what: [
348
- ...i === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
349
- ...i === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
348
+ ...o === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
349
+ ...o === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
350
350
  ]
351
351
  }
352
352
  ]), {
353
353
  ...s,
354
- ignores: i === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
355
- follows: i === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
354
+ ignores: o === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
355
+ follows: o === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
356
356
  };
357
357
  },
358
- onError: o,
359
- onSuccess(i) {
360
- n(i), u().setQueryData(
358
+ onError: r,
359
+ onSuccess(o) {
360
+ n(o), p().setQueryData(
361
361
  ["accounts", "relations", e, t],
362
- i
362
+ o
363
363
  );
364
364
  }
365
365
  });
366
366
  }
367
367
  function se(e) {
368
- return y({
368
+ return l({
369
369
  mutationKey: ["operations", "sign", e],
370
370
  mutationFn: ({
371
371
  operation: t,
@@ -373,41 +373,41 @@ function se(e) {
373
373
  }) => {
374
374
  if (!e)
375
375
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
376
- let o;
377
- return n.split(" ").length === 12 ? o = h.fromLogin(e, n, "active") : D.isWif(n) ? o = h.fromString(n) : o = h.from(n), a.hiveClient.broadcast.sendOperations(
376
+ let r;
377
+ return n.split(" ").length === 12 ? r = d.fromLogin(e, n, "active") : P.isWif(n) ? r = d.fromString(n) : r = d.from(n), a.hiveClient.broadcast.sendOperations(
378
378
  [t],
379
- o
379
+ r
380
380
  );
381
381
  }
382
382
  });
383
383
  }
384
384
  function ae(e, t = "Active") {
385
- return y({
385
+ return l({
386
386
  mutationKey: ["operations", "sign-keychain", e],
387
387
  mutationFn: ({ operation: n }) => {
388
388
  if (!e)
389
389
  throw new Error(
390
390
  "[SDK][Keychain] – cannot sign operation with anon user"
391
391
  );
392
- return g(e, [n], t);
392
+ return w(e, [n], t);
393
393
  }
394
394
  });
395
395
  }
396
396
  function ce(e = "/") {
397
- return y({
397
+ return l({
398
398
  mutationKey: ["operations", "sign-hivesigner", e],
399
- mutationFn: async ({ operation: t }) => d.sendOperation(t, { callback: e }, () => {
399
+ mutationFn: async ({ operation: t }) => g.sendOperation(t, { callback: e }, () => {
400
400
  })
401
401
  });
402
402
  }
403
403
  function ue() {
404
- return p({
404
+ return u({
405
405
  queryKey: ["operations", "chain-properties"],
406
406
  queryFn: async () => await a.hiveClient.database.getChainProperties()
407
407
  });
408
408
  }
409
409
  function pe(e, t) {
410
- return p({
410
+ return u({
411
411
  queryKey: ["hive-engine", "tokens-list", e, t],
412
412
  queryFn: async () => (await (await fetch(
413
413
  `${a.privateApiHost}/private-api/engine-api`,
@@ -432,10 +432,10 @@ function pe(e, t) {
432
432
  });
433
433
  }
434
434
  function ye(e = 20) {
435
- return A({
435
+ return D({
436
436
  queryKey: ["posts", "trending-tags"],
437
437
  queryFn: async ({ pageParam: { afterTag: t } }) => a.hiveClient.database.call("get_trending_tags", [t, e]).then(
438
- (n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
438
+ (n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
439
439
  ),
440
440
  initialPageParam: { afterTag: "" },
441
441
  getNextPageParam: (t) => ({
@@ -445,15 +445,15 @@ function ye(e = 20) {
445
445
  refetchOnMount: !0
446
446
  });
447
447
  }
448
- function v(e) {
449
- return p({
448
+ function C(e) {
449
+ return u({
450
450
  queryKey: ["posts", "fragments", e],
451
451
  queryFn: async () => (await fetch(
452
452
  a.privateApiHost + "/private-api/fragments",
453
453
  {
454
454
  method: "POST",
455
455
  body: JSON.stringify({
456
- code: l(e)
456
+ code: f(e)
457
457
  }),
458
458
  headers: {
459
459
  "Content-Type": "application/json"
@@ -464,7 +464,7 @@ function v(e) {
464
464
  });
465
465
  }
466
466
  function le(e = "feed") {
467
- return p({
467
+ return u({
468
468
  queryKey: ["posts", "promoted", e],
469
469
  queryFn: async () => {
470
470
  const t = new URL(
@@ -480,14 +480,14 @@ function le(e = "feed") {
480
480
  });
481
481
  }
482
482
  function fe(e) {
483
- return y({
483
+ return l({
484
484
  mutationKey: ["posts", "add-fragment", e],
485
485
  mutationFn: async ({ title: t, body: n }) => (await fetch(
486
486
  a.privateApiHost + "/private-api/fragments-add",
487
487
  {
488
488
  method: "POST",
489
489
  body: JSON.stringify({
490
- code: l(e),
490
+ code: f(e),
491
491
  title: t,
492
492
  body: n
493
493
  }),
@@ -497,25 +497,25 @@ function fe(e) {
497
497
  }
498
498
  )).json(),
499
499
  onSuccess(t) {
500
- u().setQueryData(
501
- v(e).queryKey,
500
+ p().setQueryData(
501
+ C(e).queryKey,
502
502
  (n) => [t, ...n ?? []]
503
503
  );
504
504
  }
505
505
  });
506
506
  }
507
507
  function he(e, t) {
508
- return y({
508
+ return l({
509
509
  mutationKey: ["posts", "edit-fragment", e, t],
510
- mutationFn: async ({ title: n, body: o }) => (await fetch(
510
+ mutationFn: async ({ title: n, body: r }) => (await fetch(
511
511
  a.privateApiHost + "/private-api/fragments-update",
512
512
  {
513
513
  method: "POST",
514
514
  body: JSON.stringify({
515
- code: l(e),
515
+ code: f(e),
516
516
  id: t,
517
517
  title: n,
518
- body: o
518
+ body: r
519
519
  }),
520
520
  headers: {
521
521
  "Content-Type": "application/json"
@@ -523,25 +523,25 @@ function he(e, t) {
523
523
  }
524
524
  )).json(),
525
525
  onSuccess(n) {
526
- u().setQueryData(
527
- v(e).queryKey,
528
- (o) => {
529
- if (!o)
526
+ p().setQueryData(
527
+ C(e).queryKey,
528
+ (r) => {
529
+ if (!r)
530
530
  return [];
531
- const i = o.findIndex(({ id: c }) => c === t);
532
- return i >= 0 && (o[i] = n), [...o];
531
+ const o = r.findIndex(({ id: c }) => c === t);
532
+ return o >= 0 && (r[o] = n), [...r];
533
533
  }
534
534
  );
535
535
  }
536
536
  });
537
537
  }
538
538
  function de(e, t) {
539
- return y({
539
+ return l({
540
540
  mutationKey: ["posts", "remove-fragment", e],
541
541
  mutationFn: async () => fetch(a.privateApiHost + "/private-api/fragments-delete", {
542
542
  method: "POST",
543
543
  body: JSON.stringify({
544
- code: l(e),
544
+ code: f(e),
545
545
  id: t
546
546
  }),
547
547
  headers: {
@@ -549,15 +549,15 @@ function de(e, t) {
549
549
  }
550
550
  }),
551
551
  onSuccess() {
552
- u().setQueryData(
553
- v(e).queryKey,
554
- (n) => [...n ?? []].filter(({ id: o }) => o !== t)
552
+ p().setQueryData(
553
+ C(e).queryKey,
554
+ (n) => [...n ?? []].filter(({ id: r }) => r !== t)
555
555
  );
556
556
  }
557
557
  });
558
558
  }
559
- function Q(e, t) {
560
- return y({
559
+ function _(e, t) {
560
+ return l({
561
561
  mutationKey: ["analytics", t],
562
562
  mutationFn: async () => {
563
563
  if (!t)
@@ -581,28 +581,28 @@ function Q(e, t) {
581
581
  }
582
582
  const ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
583
583
  __proto__: null,
584
- useRecordActivity: Q
584
+ useRecordActivity: _
585
585
  }, Symbol.toStringTag, { value: "Module" }));
586
- function E(e, t) {
587
- return p({
586
+ function U(e, t) {
587
+ return u({
588
588
  queryKey: ["integrations", "hivesigner", "decode-memo", e],
589
589
  queryFn: async () => {
590
- const n = l(e);
590
+ const n = f(e);
591
591
  if (n)
592
- return new d.Client({
592
+ return new g.Client({
593
593
  accessToken: n
594
594
  }).decode(t);
595
595
  }
596
596
  });
597
597
  }
598
- const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
598
+ const x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
599
599
  __proto__: null,
600
- getDecodeMemoQueryOptions: E
601
- }, Symbol.toStringTag, { value: "Module" })), U = {
602
- queries: G
600
+ getDecodeMemoQueryOptions: U
601
+ }, Symbol.toStringTag, { value: "Module" })), G = {
602
+ queries: x
603
603
  };
604
- function m(e) {
605
- return p({
604
+ function v(e) {
605
+ return u({
606
606
  queryKey: ["integrations", "3speak", "authenticate", e],
607
607
  enabled: !!e,
608
608
  queryFn: async () => {
@@ -615,28 +615,28 @@ function m(e) {
615
615
  "Content-Type": "application/json"
616
616
  }
617
617
  }
618
- ), n = U.queries.getDecodeMemoQueryOptions(
618
+ ), n = G.queries.getDecodeMemoQueryOptions(
619
619
  e,
620
620
  (await t.json()).memo
621
621
  );
622
- await u().prefetchQuery(n);
623
- const { memoDecoded: o } = u().getQueryData(
622
+ await p().prefetchQuery(n);
623
+ const { memoDecoded: r } = p().getQueryData(
624
624
  n.queryKey
625
625
  );
626
- return o.replace("#", "");
626
+ return r.replace("#", "");
627
627
  }
628
628
  });
629
629
  }
630
- function x(e) {
631
- return p({
630
+ function W(e) {
631
+ return u({
632
632
  queryKey: ["integrations", "3speak", "videos", e],
633
633
  enabled: !!e,
634
634
  queryFn: async () => {
635
- await u().prefetchQuery(
636
- m(e)
635
+ await p().prefetchQuery(
636
+ v(e)
637
637
  );
638
- const t = u().getQueryData(
639
- m(e).queryKey
638
+ const t = p().getQueryData(
639
+ v(e).queryKey
640
640
  );
641
641
  return await (await fetch(
642
642
  "https://studio.3speak.tv/mobile/api/my-videos",
@@ -652,13 +652,13 @@ function x(e) {
652
652
  }
653
653
  const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
654
654
  __proto__: null,
655
- getAccountTokenQueryOptions: m,
656
- getAccountVideosQueryOptions: x
655
+ getAccountTokenQueryOptions: v,
656
+ getAccountVideosQueryOptions: W
657
657
  }, Symbol.toStringTag, { value: "Module" })), we = {
658
658
  queries: z
659
659
  };
660
660
  function me() {
661
- return p({
661
+ return u({
662
662
  queryKey: ["resource-credits", "stats"],
663
663
  queryFn: async () => (await a.hiveClient.call(
664
664
  "rc_api",
@@ -668,14 +668,14 @@ function me() {
668
668
  });
669
669
  }
670
670
  function ve(e) {
671
- return p({
671
+ return u({
672
672
  queryKey: ["resource-credits", "account", e],
673
- queryFn: async () => new P(a.hiveClient).findRCAccounts([e]),
673
+ queryFn: async () => new M(a.hiveClient).findRCAccounts([e]),
674
674
  enabled: !!e
675
675
  });
676
676
  }
677
677
  function Ce(e, t) {
678
- return p({
678
+ return u({
679
679
  queryKey: ["games", "status-check", t, e],
680
680
  enabled: !!e,
681
681
  queryFn: async () => {
@@ -687,7 +687,7 @@ function Ce(e, t) {
687
687
  method: "POST",
688
688
  body: JSON.stringify({
689
689
  game_type: t,
690
- code: l(e)
690
+ code: f(e)
691
691
  }),
692
692
  headers: {
693
693
  "Content-Type": "application/json"
@@ -698,11 +698,11 @@ function Ce(e, t) {
698
698
  });
699
699
  }
700
700
  function be(e, t, n) {
701
- const { mutateAsync: o } = Q(
701
+ const { mutateAsync: r } = _(
702
702
  e,
703
703
  "spin-rolled"
704
704
  );
705
- return y({
705
+ return l({
706
706
  mutationKey: ["games", "post", t, e],
707
707
  mutationFn: async () => {
708
708
  if (!e)
@@ -713,7 +713,7 @@ function be(e, t, n) {
713
713
  method: "POST",
714
714
  body: JSON.stringify({
715
715
  game_type: t,
716
- code: l(e),
716
+ code: f(e),
717
717
  key: n
718
718
  }),
719
719
  headers: {
@@ -723,14 +723,14 @@ function be(e, t, n) {
723
723
  )).json();
724
724
  },
725
725
  onSuccess() {
726
- o();
726
+ r();
727
727
  }
728
728
  });
729
729
  }
730
- function qe(e, t, n = 100, o = void 0, i = !0) {
731
- return p({
730
+ function Oe(e, t, n = 100, r = void 0, o = !0) {
731
+ return u({
732
732
  queryKey: ["communities", "list", e, t, n],
733
- enabled: i,
733
+ enabled: o,
734
734
  queryFn: async () => {
735
735
  const c = await a.hiveClient.call(
736
736
  "bridge",
@@ -740,15 +740,31 @@ function qe(e, t, n = 100, o = void 0, i = !0) {
740
740
  limit: n,
741
741
  sort: e === "hot" ? "rank" : e,
742
742
  query: t || null,
743
- observer: o
743
+ observer: r
744
744
  }
745
745
  );
746
746
  return c ? e === "hot" ? c.sort(() => Math.random() - 0.5) : c : [];
747
747
  }
748
748
  });
749
749
  }
750
- var W = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(W || {});
751
- const Oe = {
750
+ function qe(e, t) {
751
+ return u({
752
+ queryKey: ["community", "context", e, t],
753
+ enabled: !!e && !!t,
754
+ queryFn: async () => {
755
+ const n = await a.hiveClient.call("bridge", "get_community_context", {
756
+ account: e,
757
+ name: t
758
+ });
759
+ return {
760
+ role: (n == null ? void 0 : n.role) ?? "guest",
761
+ subscribed: (n == null ? void 0 : n.subscribed) ?? !1
762
+ };
763
+ }
764
+ });
765
+ }
766
+ var y = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(y || {});
767
+ const Ke = {
752
768
  owner: [
753
769
  "admin",
754
770
  "mod",
@@ -771,38 +787,66 @@ const Oe = {
771
787
  /* MUTED */
772
788
  ]
773
789
  };
790
+ function Se(e, t) {
791
+ return e.startsWith("hive-3") || t === 3 ? "Council" : e.startsWith("hive-2") || t === 2 ? "Journal" : "Topic";
792
+ }
793
+ function Qe({
794
+ communityType: e,
795
+ userRole: t,
796
+ subscribed: n
797
+ }) {
798
+ const r = t === y.MUTED ? !1 : e === "Topic" ? !0 : [y.OWNER, y.ADMIN, y.MOD, y.MEMBER].includes(t), o = (() => {
799
+ if (t === y.MUTED) return !1;
800
+ switch (e) {
801
+ case "Topic":
802
+ return !0;
803
+ case "Journal":
804
+ return t !== y.GUEST || n;
805
+ case "Council":
806
+ return r;
807
+ }
808
+ })(), c = [y.OWNER, y.ADMIN, y.MOD].includes(t);
809
+ return {
810
+ canPost: r,
811
+ canComment: o,
812
+ isModerator: c
813
+ };
814
+ }
774
815
  export {
775
816
  a as CONFIG,
776
- b as ConfigManager,
817
+ O as ConfigManager,
777
818
  ge as EcencyAnalytics,
778
819
  q as EcencyQueriesManager,
779
- U as HiveSignerIntegration,
820
+ G as HiveSignerIntegration,
780
821
  L as Keychain,
781
- W as ROLES,
822
+ y as ROLES,
782
823
  we as ThreeSpeakIntegration,
783
824
  H as broadcastJson,
784
- oe as checkUsernameWalletsPendingQueryOptions,
785
- l as getAccessToken,
825
+ re as checkUsernameWalletsPendingQueryOptions,
826
+ f as getAccessToken,
786
827
  te as getAccountFullQueryOptions,
787
828
  ve as getAccountRcQueryOptions,
788
- re as getAccountSubscriptionsQueryOptions,
829
+ oe as getAccountSubscriptionsQueryOptions,
789
830
  ue as getChainPropertiesQueryOptions,
790
- qe as getCommunitiesQueryOptions,
791
- v as getFragmentsQueryOptions,
831
+ Oe as getCommunitiesQueryOptions,
832
+ qe as getCommunityContextQueryOptions,
833
+ Qe as getCommunityPermissions,
834
+ Se as getCommunityType,
835
+ C as getFragmentsQueryOptions,
792
836
  Ce as getGameStatusCheckQueryOptions,
793
837
  pe as getHiveEngineTokensListQueryOptions,
794
- S as getLoginType,
795
- K as getPostingKey,
838
+ Q as getLoginType,
839
+ S as getPostingKey,
796
840
  le as getPromotedPostsQuery,
797
- u as getQueryClient,
841
+ p as getQueryClient,
798
842
  me as getRcStatsQueryOptions,
799
843
  Z as getRefreshToken,
800
844
  B as getRelationshipBetweenAccountsQueryOptions,
801
845
  ne as getSearchAccountsByUsernameQueryOptions,
802
846
  ye as getTrendingTagsQueryOptions,
803
- f as getUser,
847
+ h as getUser,
804
848
  R as makeQueryClient,
805
- Oe as roleMap,
849
+ Ke as roleMap,
806
850
  ie as useAccountRelationsUpdate,
807
851
  ee as useAccountUpdate,
808
852
  fe as useAddFragment,
@@ -1,2 +1,3 @@
1
1
  export * from './queries';
2
2
  export * from './types';
3
+ export * from './utils';
@@ -0,0 +1,20 @@
1
+ export declare function getCommunityContextQueryOptions(username: string | undefined, communityName: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
2
+ role: any;
3
+ subscribed: any;
4
+ }, Error, {
5
+ role: any;
6
+ subscribed: any;
7
+ }, (string | undefined)[]>, "queryFn"> & {
8
+ queryFn?: import('@tanstack/query-core').QueryFunction<{
9
+ role: any;
10
+ subscribed: any;
11
+ }, (string | undefined)[], never> | undefined;
12
+ } & {
13
+ queryKey: (string | undefined)[] & {
14
+ [dataTagSymbol]: {
15
+ role: any;
16
+ subscribed: any;
17
+ };
18
+ [dataTagErrorSymbol]: Error;
19
+ };
20
+ };
@@ -1 +1,2 @@
1
1
  export * from './get-communities-query-options';
2
+ export * from './get-community-context-query-options';
@@ -0,0 +1,19 @@
1
+ import { ROLES } from '../types';
2
+ export type CommunityRole = (typeof ROLES)[keyof typeof ROLES];
3
+ export type CommunityType = "Topic" | "Journal" | "Council";
4
+ /**
5
+ * Determine community type based on its `name` or `type_id`
6
+ */
7
+ export declare function getCommunityType(name: string, type_id: number): CommunityType;
8
+ /**
9
+ * Compute permissions for a given user role in a community
10
+ */
11
+ export declare function getCommunityPermissions({ communityType, userRole, subscribed, }: {
12
+ communityType: CommunityType;
13
+ userRole: CommunityRole;
14
+ subscribed: boolean;
15
+ }): {
16
+ canPost: boolean;
17
+ canComment: boolean;
18
+ isModerator: boolean;
19
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.49",
4
+ "version": "1.0.50",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",