@ecency/sdk 1.0.48 → 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.
- package/dist/ecency-sdk.es.js +224 -180
- package/dist/modules/communities/index.d.ts +1 -0
- package/dist/modules/communities/queries/get-community-context-query-options.d.ts +20 -0
- package/dist/modules/communities/queries/index.d.ts +1 -0
- package/dist/modules/communities/utils/index.d.ts +19 -0
- package/package.json +1 -1
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import { QueryClient as
|
5
|
-
import { Client as F, PrivateKey as
|
6
|
-
import
|
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
|
-
|
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
|
52
|
+
queryClient: new K(),
|
53
53
|
plausibleHost: "https://pl.ecency.com"
|
54
54
|
};
|
55
|
-
var
|
55
|
+
var O;
|
56
56
|
((e) => {
|
57
57
|
function t(n) {
|
58
58
|
a.queryClient = n;
|
59
59
|
}
|
60
60
|
e.setQueryClient = t;
|
61
|
-
})(
|
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
|
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
|
-
},
|
78
|
-
function
|
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
|
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
|
-
(
|
93
|
-
|
92
|
+
(i) => {
|
93
|
+
i.success || c({ message: "Operation cancelled" }), o(i);
|
94
94
|
},
|
95
|
-
|
95
|
+
r
|
96
96
|
);
|
97
97
|
}), L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
98
98
|
__proto__: null,
|
99
|
-
broadcast:
|
100
|
-
handshake:
|
99
|
+
broadcast: w,
|
100
|
+
handshake: E
|
101
101
|
}, Symbol.toStringTag, { value: "Module" }));
|
102
102
|
function J(e = [], t, n) {
|
103
|
-
return
|
103
|
+
return l({
|
104
104
|
mutationKey: [...e, t],
|
105
|
-
mutationFn: async (
|
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
|
111
|
-
if (
|
112
|
-
const
|
110
|
+
const o = S(t);
|
111
|
+
if (o) {
|
112
|
+
const i = d.fromString(o);
|
113
113
|
return a.hiveClient.broadcast.sendOperations(
|
114
|
-
n(
|
115
|
-
|
114
|
+
n(r),
|
115
|
+
i
|
116
116
|
);
|
117
117
|
}
|
118
|
-
const c =
|
118
|
+
const c = Q(t);
|
119
119
|
if (c && c == "keychain")
|
120
|
-
return
|
121
|
-
let s =
|
120
|
+
return w(t, n(r), "Posting").then((i) => i.result);
|
121
|
+
let s = f(t);
|
122
122
|
if (s)
|
123
|
-
return (await new
|
123
|
+
return (await new g.Client({
|
124
124
|
accessToken: s
|
125
|
-
}).broadcast(n(
|
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
|
137
|
+
const r = {
|
138
138
|
id: t,
|
139
139
|
required_auths: [],
|
140
140
|
required_posting_auths: [e],
|
141
141
|
json: JSON.stringify(n)
|
142
|
-
},
|
143
|
-
if (
|
144
|
-
const
|
142
|
+
}, o = S(e);
|
143
|
+
if (o) {
|
144
|
+
const i = d.fromString(o);
|
145
145
|
return a.hiveClient.broadcast.json(
|
146
|
-
|
147
|
-
|
146
|
+
r,
|
147
|
+
i
|
148
148
|
);
|
149
149
|
}
|
150
|
-
const c =
|
150
|
+
const c = Q(e);
|
151
151
|
if (c && c == "keychain")
|
152
|
-
return
|
153
|
-
let s =
|
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
|
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
|
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
|
175
|
+
const p = () => a.queryClient;
|
176
176
|
var q;
|
177
177
|
((e) => {
|
178
|
-
function t(
|
179
|
-
return
|
178
|
+
function t(i) {
|
179
|
+
return p().getQueryData(i);
|
180
180
|
}
|
181
181
|
e.getQueryData = t;
|
182
|
-
function n(
|
183
|
-
return
|
182
|
+
function n(i) {
|
183
|
+
return p().getQueryData(i);
|
184
184
|
}
|
185
185
|
e.getInfiniteQueryData = n;
|
186
|
-
async function
|
187
|
-
return await
|
186
|
+
async function r(i) {
|
187
|
+
return await p().prefetchQuery(i), t(i.queryKey);
|
188
188
|
}
|
189
|
-
e.prefetchQuery =
|
190
|
-
async function i
|
191
|
-
return await
|
189
|
+
e.prefetchQuery = r;
|
190
|
+
async function o(i) {
|
191
|
+
return await p().prefetchInfiniteQuery(i), n(i.queryKey);
|
192
192
|
}
|
193
|
-
e.prefetchInfiniteQuery =
|
194
|
-
function c(
|
193
|
+
e.prefetchInfiniteQuery = o;
|
194
|
+
function c(i) {
|
195
195
|
return {
|
196
|
-
prefetch: () =>
|
197
|
-
getData: () => t(
|
198
|
-
useClientQuery: () =>
|
199
|
-
fetchAndGet: () =>
|
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(
|
203
|
+
function s(i) {
|
204
204
|
return {
|
205
|
-
prefetch: () => i
|
206
|
-
getData: () => n(
|
207
|
-
useClientQuery: () => k(
|
208
|
-
fetchAndGet: () =>
|
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
|
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
|
246
|
+
let r;
|
247
247
|
try {
|
248
|
-
|
248
|
+
r = await a.hiveClient.database.call(
|
249
249
|
"get_follow_count",
|
250
250
|
[e]
|
251
251
|
);
|
252
252
|
} catch {
|
253
253
|
}
|
254
|
-
const
|
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:
|
262
|
-
reputation:
|
261
|
+
follow_stats: r,
|
262
|
+
reputation: o[0].reputation,
|
263
263
|
profile: {
|
264
264
|
...n,
|
265
|
-
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
|
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
|
-
(
|
281
|
+
(o) => n.length > 0 ? !n.includes(o) : !0
|
282
282
|
)
|
283
283
|
});
|
284
284
|
}
|
285
|
-
function
|
286
|
-
return
|
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
|
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
|
318
|
-
return
|
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,
|
331
|
-
return
|
330
|
+
function ie(e, t, n, r) {
|
331
|
+
return l({
|
332
332
|
mutationKey: [],
|
333
|
-
mutationFn: async (
|
333
|
+
mutationFn: async (o) => {
|
334
334
|
const c = B(
|
335
335
|
e,
|
336
336
|
t
|
337
337
|
);
|
338
|
-
await
|
339
|
-
const s =
|
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
|
-
...
|
349
|
-
...
|
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:
|
355
|
-
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:
|
359
|
-
onSuccess(
|
360
|
-
n(
|
358
|
+
onError: r,
|
359
|
+
onSuccess(o) {
|
360
|
+
n(o), p().setQueryData(
|
361
361
|
["accounts", "relations", e, t],
|
362
|
-
|
362
|
+
o
|
363
363
|
);
|
364
364
|
}
|
365
365
|
});
|
366
366
|
}
|
367
367
|
function se(e) {
|
368
|
-
return
|
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
|
377
|
-
return n.split(" ").length === 12 ?
|
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
|
-
|
379
|
+
r
|
380
380
|
);
|
381
381
|
}
|
382
382
|
});
|
383
383
|
}
|
384
384
|
function ae(e, t = "Active") {
|
385
|
-
return
|
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
|
392
|
+
return w(e, [n], t);
|
393
393
|
}
|
394
394
|
});
|
395
395
|
}
|
396
396
|
function ce(e = "/") {
|
397
|
-
return
|
397
|
+
return l({
|
398
398
|
mutationKey: ["operations", "sign-hivesigner", e],
|
399
|
-
mutationFn: async ({ operation: t }) =>
|
399
|
+
mutationFn: async ({ operation: t }) => g.sendOperation(t, { callback: e }, () => {
|
400
400
|
})
|
401
401
|
});
|
402
402
|
}
|
403
403
|
function ue() {
|
404
|
-
return
|
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
|
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
|
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((
|
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
|
449
|
-
return
|
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:
|
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
|
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
|
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:
|
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
|
-
|
501
|
-
|
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
|
508
|
+
return l({
|
509
509
|
mutationKey: ["posts", "edit-fragment", e, t],
|
510
|
-
mutationFn: async ({ title: n, body:
|
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:
|
515
|
+
code: f(e),
|
516
516
|
id: t,
|
517
517
|
title: n,
|
518
|
-
body:
|
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
|
-
|
527
|
-
|
528
|
-
(
|
529
|
-
if (!
|
526
|
+
p().setQueryData(
|
527
|
+
C(e).queryKey,
|
528
|
+
(r) => {
|
529
|
+
if (!r)
|
530
530
|
return [];
|
531
|
-
const
|
532
|
-
return
|
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
|
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:
|
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
|
-
|
553
|
-
|
554
|
-
(n) => [...n ?? []].filter(({ id:
|
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
|
560
|
-
return
|
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:
|
584
|
+
useRecordActivity: _
|
585
585
|
}, Symbol.toStringTag, { value: "Module" }));
|
586
|
-
function
|
587
|
-
return
|
586
|
+
function U(e, t) {
|
587
|
+
return u({
|
588
588
|
queryKey: ["integrations", "hivesigner", "decode-memo", e],
|
589
589
|
queryFn: async () => {
|
590
|
-
const n =
|
590
|
+
const n = f(e);
|
591
591
|
if (n)
|
592
|
-
return new
|
592
|
+
return new g.Client({
|
593
593
|
accessToken: n
|
594
594
|
}).decode(t);
|
595
595
|
}
|
596
596
|
});
|
597
597
|
}
|
598
|
-
const
|
598
|
+
const x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
599
599
|
__proto__: null,
|
600
|
-
getDecodeMemoQueryOptions:
|
601
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
602
|
-
queries:
|
600
|
+
getDecodeMemoQueryOptions: U
|
601
|
+
}, Symbol.toStringTag, { value: "Module" })), G = {
|
602
|
+
queries: x
|
603
603
|
};
|
604
|
-
function
|
605
|
-
return
|
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 =
|
618
|
+
), n = G.queries.getDecodeMemoQueryOptions(
|
619
619
|
e,
|
620
620
|
(await t.json()).memo
|
621
621
|
);
|
622
|
-
await
|
623
|
-
const { memoDecoded:
|
622
|
+
await p().prefetchQuery(n);
|
623
|
+
const { memoDecoded: r } = p().getQueryData(
|
624
624
|
n.queryKey
|
625
625
|
);
|
626
|
-
return
|
626
|
+
return r.replace("#", "");
|
627
627
|
}
|
628
628
|
});
|
629
629
|
}
|
630
|
-
function
|
631
|
-
return
|
630
|
+
function W(e) {
|
631
|
+
return u({
|
632
632
|
queryKey: ["integrations", "3speak", "videos", e],
|
633
633
|
enabled: !!e,
|
634
634
|
queryFn: async () => {
|
635
|
-
await
|
636
|
-
|
635
|
+
await p().prefetchQuery(
|
636
|
+
v(e)
|
637
637
|
);
|
638
|
-
const t =
|
639
|
-
|
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:
|
656
|
-
getAccountVideosQueryOptions:
|
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
|
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
|
671
|
+
return u({
|
672
672
|
queryKey: ["resource-credits", "account", e],
|
673
|
-
queryFn: async () => new
|
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
|
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:
|
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:
|
701
|
+
const { mutateAsync: r } = _(
|
702
702
|
e,
|
703
703
|
"spin-rolled"
|
704
704
|
);
|
705
|
-
return
|
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:
|
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
|
-
|
726
|
+
r();
|
727
727
|
}
|
728
728
|
});
|
729
729
|
}
|
730
|
-
function
|
731
|
-
return
|
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:
|
733
|
+
enabled: o,
|
734
734
|
queryFn: async () => {
|
735
735
|
const c = await a.hiveClient.call(
|
736
736
|
"bridge",
|
@@ -738,17 +738,33 @@ function qe(e, t, n = 100, o = void 0, i = !0) {
|
|
738
738
|
{
|
739
739
|
last: "",
|
740
740
|
limit: n,
|
741
|
-
sort: e,
|
742
|
-
query: t,
|
743
|
-
observer:
|
741
|
+
sort: e === "hot" ? "rank" : e,
|
742
|
+
query: t || null,
|
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
|
-
|
751
|
-
|
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
|
-
|
817
|
+
O as ConfigManager,
|
777
818
|
ge as EcencyAnalytics,
|
778
819
|
q as EcencyQueriesManager,
|
779
|
-
|
820
|
+
G as HiveSignerIntegration,
|
780
821
|
L as Keychain,
|
781
|
-
|
822
|
+
y as ROLES,
|
782
823
|
we as ThreeSpeakIntegration,
|
783
824
|
H as broadcastJson,
|
784
|
-
|
785
|
-
|
825
|
+
re as checkUsernameWalletsPendingQueryOptions,
|
826
|
+
f as getAccessToken,
|
786
827
|
te as getAccountFullQueryOptions,
|
787
828
|
ve as getAccountRcQueryOptions,
|
788
|
-
|
829
|
+
oe as getAccountSubscriptionsQueryOptions,
|
789
830
|
ue as getChainPropertiesQueryOptions,
|
790
|
-
|
791
|
-
|
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
|
-
|
795
|
-
|
838
|
+
Q as getLoginType,
|
839
|
+
S as getPostingKey,
|
796
840
|
le as getPromotedPostsQuery,
|
797
|
-
|
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
|
-
|
847
|
+
h as getUser,
|
804
848
|
R as makeQueryClient,
|
805
|
-
|
849
|
+
Ke as roleMap,
|
806
850
|
ie as useAccountRelationsUpdate,
|
807
851
|
ee as useAccountUpdate,
|
808
852
|
fe as useAddFragment,
|
@@ -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
|
+
};
|
@@ -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
|
+
};
|