@ecency/sdk 1.0.45 → 1.0.47
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 +296 -231
- package/dist/index.d.ts +1 -0
- package/dist/modules/accounts/queries/get-account-subscriptions-query-options.d.ts +10 -0
- package/dist/modules/accounts/queries/index.d.ts +1 -0
- package/dist/modules/communities/index.d.ts +2 -0
- package/dist/modules/communities/queries/get-communities-query-options.d.ts +9 -0
- package/dist/modules/communities/queries/index.d.ts +1 -0
- package/dist/modules/communities/types/community.d.ts +31 -0
- package/dist/modules/communities/types/index.d.ts +1 -0
- package/dist/modules/core/entities/user.d.ts +1 -0
- package/dist/modules/core/storage.d.ts +1 -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
|
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
6
|
import d from "hivesigner";
|
7
|
-
class
|
7
|
+
class I {
|
8
8
|
constructor() {
|
9
|
-
|
9
|
+
C(this, "length", 0);
|
10
10
|
}
|
11
11
|
clear() {
|
12
12
|
throw new Error("Method not implemented.");
|
@@ -24,11 +24,11 @@ class P {
|
|
24
24
|
this[t] = n;
|
25
25
|
}
|
26
26
|
}
|
27
|
-
const
|
27
|
+
const a = {
|
28
28
|
privateApiHost: "https://ecency.com",
|
29
|
-
storage: typeof window > "u" ? new
|
29
|
+
storage: typeof window > "u" ? new I() : window.localStorage,
|
30
30
|
storagePrefix: "ecency",
|
31
|
-
hiveClient: new
|
31
|
+
hiveClient: new F(
|
32
32
|
[
|
33
33
|
"https://api.hive.blog",
|
34
34
|
"https://api.deathwing.me",
|
@@ -49,88 +49,118 @@ const s = {
|
|
49
49
|
}
|
50
50
|
),
|
51
51
|
heliusApiKey: void 0,
|
52
|
-
queryClient: new
|
52
|
+
queryClient: new O(),
|
53
53
|
plausibleHost: "https://pl.ecency.com"
|
54
54
|
};
|
55
|
-
var
|
55
|
+
var b;
|
56
56
|
((e) => {
|
57
57
|
function t(n) {
|
58
|
-
|
58
|
+
a.queryClient = n;
|
59
59
|
}
|
60
60
|
e.setQueryClient = t;
|
61
|
-
})(
|
62
|
-
function
|
61
|
+
})(b || (b = {}));
|
62
|
+
function N(e) {
|
63
63
|
let t = atob(e);
|
64
64
|
if (t[0] === "{")
|
65
65
|
return JSON.parse(t);
|
66
66
|
}
|
67
67
|
const f = (e) => {
|
68
68
|
try {
|
69
|
-
const t =
|
70
|
-
|
69
|
+
const t = a.storage.getItem(
|
70
|
+
a.storagePrefix + "_user_" + e
|
71
71
|
);
|
72
|
-
return
|
72
|
+
return N(JSON.parse(t));
|
73
73
|
} catch (t) {
|
74
74
|
console.error(t);
|
75
75
|
return;
|
76
76
|
}
|
77
|
-
}, l = (e) => f(e) && f(e).accessToken,
|
78
|
-
function
|
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 J() {
|
79
|
+
return new Promise((e) => {
|
80
|
+
var t;
|
81
|
+
(t = window.hive_keychain) == null || t.requestHandshake(() => {
|
82
|
+
e();
|
83
|
+
});
|
84
|
+
});
|
85
|
+
}
|
86
|
+
const g = (e, t, n, o = null) => new Promise((i, c) => {
|
87
|
+
var s;
|
88
|
+
(s = window.hive_keychain) == null || s.requestBroadcast(
|
89
|
+
e,
|
90
|
+
t,
|
91
|
+
n,
|
92
|
+
(r) => {
|
93
|
+
r.success || c({ message: "Operation cancelled" }), i(r);
|
94
|
+
},
|
95
|
+
o
|
96
|
+
);
|
97
|
+
}), L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
98
|
+
__proto__: null,
|
99
|
+
broadcast: g,
|
100
|
+
handshake: J
|
101
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
102
|
+
function M(e = [], t, n) {
|
79
103
|
return y({
|
80
104
|
mutationKey: [...e, t],
|
81
|
-
mutationFn: async (
|
105
|
+
mutationFn: async (o) => {
|
82
106
|
if (!t)
|
83
107
|
throw new Error(
|
84
108
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
85
109
|
);
|
86
|
-
const
|
87
|
-
if (
|
88
|
-
const
|
89
|
-
return
|
90
|
-
n(
|
91
|
-
|
110
|
+
const i = K(t);
|
111
|
+
if (i) {
|
112
|
+
const r = h.fromString(i);
|
113
|
+
return a.hiveClient.broadcast.sendOperations(
|
114
|
+
n(o),
|
115
|
+
r
|
92
116
|
);
|
93
117
|
}
|
94
|
-
|
95
|
-
if (
|
118
|
+
const c = S(t);
|
119
|
+
if (c && c == "keychain")
|
120
|
+
return g(t, n(o), "Posting").then((r) => r.result);
|
121
|
+
let s = l(t);
|
122
|
+
if (s)
|
96
123
|
return (await new d.Client({
|
97
|
-
accessToken:
|
98
|
-
}).broadcast(n(
|
124
|
+
accessToken: s
|
125
|
+
}).broadcast(n(o))).result;
|
99
126
|
throw new Error(
|
100
127
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
101
128
|
);
|
102
129
|
}
|
103
130
|
});
|
104
131
|
}
|
105
|
-
async function
|
132
|
+
async function H(e, t, n) {
|
106
133
|
if (!e)
|
107
134
|
throw new Error(
|
108
135
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
109
136
|
);
|
110
|
-
const
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
137
|
+
const o = {
|
138
|
+
id: t,
|
139
|
+
required_auths: [],
|
140
|
+
required_posting_auths: [e],
|
141
|
+
json: JSON.stringify(n)
|
142
|
+
}, i = K(e);
|
143
|
+
if (i) {
|
144
|
+
const r = h.fromString(i);
|
145
|
+
return a.hiveClient.broadcast.json(
|
146
|
+
o,
|
147
|
+
r
|
121
148
|
);
|
122
149
|
}
|
123
|
-
|
124
|
-
if (
|
150
|
+
const c = S(e);
|
151
|
+
if (c && c == "keychain")
|
152
|
+
return g(e, [["custom_json", o]], "Posting").then((r) => r.result);
|
153
|
+
let s = l(e);
|
154
|
+
if (s)
|
125
155
|
return (await new d.Client({
|
126
|
-
accessToken:
|
156
|
+
accessToken: s
|
127
157
|
}).customJson([], [e], t, JSON.stringify(n))).result;
|
128
158
|
throw new Error(
|
129
159
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
130
160
|
);
|
131
161
|
}
|
132
|
-
function
|
133
|
-
return new
|
162
|
+
function R() {
|
163
|
+
return new O({
|
134
164
|
defaultOptions: {
|
135
165
|
queries: {
|
136
166
|
// With SSR, we usually want to set some default staleTime
|
@@ -142,46 +172,46 @@ function X() {
|
|
142
172
|
}
|
143
173
|
});
|
144
174
|
}
|
145
|
-
const
|
146
|
-
var
|
175
|
+
const u = () => a.queryClient;
|
176
|
+
var q;
|
147
177
|
((e) => {
|
148
|
-
function t(
|
149
|
-
return
|
178
|
+
function t(r) {
|
179
|
+
return u().getQueryData(r);
|
150
180
|
}
|
151
181
|
e.getQueryData = t;
|
152
|
-
function n(
|
153
|
-
return
|
182
|
+
function n(r) {
|
183
|
+
return u().getQueryData(r);
|
154
184
|
}
|
155
185
|
e.getInfiniteQueryData = n;
|
156
|
-
async function r
|
157
|
-
return await
|
186
|
+
async function o(r) {
|
187
|
+
return await u().prefetchQuery(r), t(r.queryKey);
|
158
188
|
}
|
159
|
-
e.prefetchQuery =
|
160
|
-
async function
|
161
|
-
return await
|
189
|
+
e.prefetchQuery = o;
|
190
|
+
async function i(r) {
|
191
|
+
return await u().prefetchInfiniteQuery(r), n(r.queryKey);
|
162
192
|
}
|
163
|
-
e.prefetchInfiniteQuery =
|
164
|
-
function
|
193
|
+
e.prefetchInfiniteQuery = i;
|
194
|
+
function c(r) {
|
165
195
|
return {
|
166
|
-
prefetch: () => r
|
167
|
-
getData: () => t(
|
168
|
-
useClientQuery: () =>
|
169
|
-
fetchAndGet: () =>
|
196
|
+
prefetch: () => o(r),
|
197
|
+
getData: () => t(r.queryKey),
|
198
|
+
useClientQuery: () => j(r),
|
199
|
+
fetchAndGet: () => u().fetchQuery(r)
|
170
200
|
};
|
171
201
|
}
|
172
|
-
e.generateClientServerQuery =
|
173
|
-
function
|
202
|
+
e.generateClientServerQuery = c;
|
203
|
+
function s(r) {
|
174
204
|
return {
|
175
|
-
prefetch: () =>
|
176
|
-
getData: () => n(
|
177
|
-
useClientQuery: () =>
|
178
|
-
fetchAndGet: () =>
|
205
|
+
prefetch: () => i(r),
|
206
|
+
getData: () => n(r.queryKey),
|
207
|
+
useClientQuery: () => k(r),
|
208
|
+
fetchAndGet: () => u().fetchInfiniteQuery(r)
|
179
209
|
};
|
180
210
|
}
|
181
|
-
e.generateClientServerInfiniteQuery =
|
182
|
-
})(
|
183
|
-
function
|
184
|
-
return
|
211
|
+
e.generateClientServerInfiniteQuery = s;
|
212
|
+
})(q || (q = {}));
|
213
|
+
function ee(e) {
|
214
|
+
return M(
|
185
215
|
["accounts", "update"],
|
186
216
|
e,
|
187
217
|
({
|
@@ -203,36 +233,36 @@ function Y(e) {
|
|
203
233
|
]
|
204
234
|
);
|
205
235
|
}
|
206
|
-
function
|
236
|
+
function te(e) {
|
207
237
|
return p({
|
208
238
|
queryKey: ["get-account-full", e],
|
209
239
|
queryFn: async () => {
|
210
240
|
if (!e)
|
211
241
|
throw new Error("[SDK] Username is empty");
|
212
|
-
const t = await
|
242
|
+
const t = await a.hiveClient.database.getAccounts([e]);
|
213
243
|
if (!t[0])
|
214
244
|
throw new Error("[SDK] No account with given username");
|
215
245
|
const n = JSON.parse(t[0].posting_json_metadata).profile;
|
216
|
-
let
|
246
|
+
let o;
|
217
247
|
try {
|
218
|
-
|
248
|
+
o = await a.hiveClient.database.call(
|
219
249
|
"get_follow_count",
|
220
250
|
[e]
|
221
251
|
);
|
222
252
|
} catch {
|
223
253
|
}
|
224
|
-
const
|
254
|
+
const i = await a.hiveClient.call(
|
225
255
|
"condenser_api",
|
226
256
|
"get_account_reputations",
|
227
257
|
[e, 1]
|
228
258
|
);
|
229
259
|
return {
|
230
260
|
...t,
|
231
|
-
follow_stats:
|
232
|
-
reputation:
|
261
|
+
follow_stats: o,
|
262
|
+
reputation: i[0].reputation,
|
233
263
|
profile: {
|
234
264
|
...n,
|
235
|
-
reputation:
|
265
|
+
reputation: i[0].reputation
|
236
266
|
}
|
237
267
|
};
|
238
268
|
},
|
@@ -240,23 +270,23 @@ function Z(e) {
|
|
240
270
|
staleTime: 6e4
|
241
271
|
});
|
242
272
|
}
|
243
|
-
function
|
273
|
+
function ne(e, t = 5, n = []) {
|
244
274
|
return p({
|
245
275
|
queryKey: ["accounts", "search", e, n],
|
246
276
|
enabled: !!e,
|
247
|
-
queryFn: async () => (await
|
277
|
+
queryFn: async () => (await a.hiveClient.database.call(
|
248
278
|
"lookup_accounts",
|
249
279
|
[e, t]
|
250
280
|
)).filter(
|
251
|
-
(
|
281
|
+
(i) => n.length > 0 ? !n.includes(i) : !0
|
252
282
|
)
|
253
283
|
});
|
254
284
|
}
|
255
|
-
function
|
285
|
+
function oe(e) {
|
256
286
|
return p({
|
257
287
|
queryKey: ["accounts", "check-wallet-pending", e],
|
258
288
|
queryFn: async () => await (await fetch(
|
259
|
-
|
289
|
+
a.privateApiHost + "/private-api/wallets-chkuser",
|
260
290
|
{
|
261
291
|
method: "POST",
|
262
292
|
headers: {
|
@@ -271,57 +301,70 @@ function ee(e) {
|
|
271
301
|
refetchOnMount: !0
|
272
302
|
});
|
273
303
|
}
|
274
|
-
function
|
304
|
+
function B(e, t) {
|
275
305
|
return p({
|
276
306
|
queryKey: ["accounts", "relations", e, t],
|
277
307
|
enabled: !!e && !!t,
|
278
308
|
refetchOnMount: !1,
|
279
309
|
refetchInterval: 36e5,
|
280
|
-
queryFn: async () => await
|
310
|
+
queryFn: async () => await a.hiveClient.call(
|
281
311
|
"bridge",
|
282
312
|
"get_relationship_between_accounts",
|
283
313
|
[e, t]
|
284
314
|
)
|
285
315
|
});
|
286
316
|
}
|
287
|
-
function
|
317
|
+
function re(e) {
|
318
|
+
return p({
|
319
|
+
queryKey: ["accounts", "subscriptions", e],
|
320
|
+
enabled: !!e,
|
321
|
+
queryFn: async () => await a.hiveClient.call(
|
322
|
+
"bridge",
|
323
|
+
"list_all_subscriptions",
|
324
|
+
{
|
325
|
+
account: e
|
326
|
+
}
|
327
|
+
) ?? []
|
328
|
+
});
|
329
|
+
}
|
330
|
+
function ie(e, t, n, o) {
|
288
331
|
return y({
|
289
332
|
mutationKey: [],
|
290
|
-
mutationFn: async (
|
291
|
-
const
|
333
|
+
mutationFn: async (i) => {
|
334
|
+
const c = B(
|
292
335
|
e,
|
293
336
|
t
|
294
337
|
);
|
295
|
-
await
|
296
|
-
const
|
297
|
-
|
338
|
+
await u().prefetchQuery(c);
|
339
|
+
const s = u().getQueryData(
|
340
|
+
c.queryKey
|
298
341
|
);
|
299
|
-
return await
|
342
|
+
return await H(e, "follow", [
|
300
343
|
"follow",
|
301
344
|
{
|
302
345
|
follower: e,
|
303
346
|
following: t,
|
304
347
|
what: [
|
305
|
-
...
|
306
|
-
...
|
348
|
+
...i === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
|
349
|
+
...i === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
|
307
350
|
]
|
308
351
|
}
|
309
352
|
]), {
|
310
|
-
...
|
311
|
-
ignores:
|
312
|
-
follows:
|
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
|
313
356
|
};
|
314
357
|
},
|
315
|
-
onError:
|
316
|
-
onSuccess(
|
317
|
-
n(
|
358
|
+
onError: o,
|
359
|
+
onSuccess(i) {
|
360
|
+
n(i), u().setQueryData(
|
318
361
|
["accounts", "relations", e, t],
|
319
|
-
|
362
|
+
i
|
320
363
|
);
|
321
364
|
}
|
322
365
|
});
|
323
366
|
}
|
324
|
-
function
|
367
|
+
function se(e) {
|
325
368
|
return y({
|
326
369
|
mutationKey: ["operations", "sign", e],
|
327
370
|
mutationFn: ({
|
@@ -330,39 +373,15 @@ function ne(e) {
|
|
330
373
|
}) => {
|
331
374
|
if (!e)
|
332
375
|
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
333
|
-
let
|
334
|
-
return n.split(" ").length === 12 ?
|
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(
|
335
378
|
[t],
|
336
|
-
|
379
|
+
o
|
337
380
|
);
|
338
381
|
}
|
339
382
|
});
|
340
383
|
}
|
341
|
-
function
|
342
|
-
return new Promise((e) => {
|
343
|
-
var t;
|
344
|
-
(t = window.hive_keychain) == null || t.requestHandshake(() => {
|
345
|
-
e();
|
346
|
-
});
|
347
|
-
});
|
348
|
-
}
|
349
|
-
const K = (e, t, n, r = null) => new Promise((o, u) => {
|
350
|
-
var i;
|
351
|
-
(i = window.hive_keychain) == null || i.requestBroadcast(
|
352
|
-
e,
|
353
|
-
t,
|
354
|
-
n,
|
355
|
-
(a) => {
|
356
|
-
a.success || u({ message: "Operation cancelled" }), o(a);
|
357
|
-
},
|
358
|
-
r
|
359
|
-
);
|
360
|
-
}), re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
361
|
-
__proto__: null,
|
362
|
-
broadcast: K,
|
363
|
-
handshake: E
|
364
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
365
|
-
function oe(e, t = "Active") {
|
384
|
+
function ae(e, t = "Active") {
|
366
385
|
return y({
|
367
386
|
mutationKey: ["operations", "sign-keychain", e],
|
368
387
|
mutationFn: ({ operation: n }) => {
|
@@ -370,28 +389,28 @@ function oe(e, t = "Active") {
|
|
370
389
|
throw new Error(
|
371
390
|
"[SDK][Keychain] – cannot sign operation with anon user"
|
372
391
|
);
|
373
|
-
return
|
392
|
+
return g(e, [n], t);
|
374
393
|
}
|
375
394
|
});
|
376
395
|
}
|
377
|
-
function
|
396
|
+
function ce(e = "/") {
|
378
397
|
return y({
|
379
398
|
mutationKey: ["operations", "sign-hivesigner", e],
|
380
399
|
mutationFn: async ({ operation: t }) => d.sendOperation(t, { callback: e }, () => {
|
381
400
|
})
|
382
401
|
});
|
383
402
|
}
|
384
|
-
function
|
403
|
+
function ue() {
|
385
404
|
return p({
|
386
405
|
queryKey: ["operations", "chain-properties"],
|
387
|
-
queryFn: async () => await
|
406
|
+
queryFn: async () => await a.hiveClient.database.getChainProperties()
|
388
407
|
});
|
389
408
|
}
|
390
|
-
function
|
409
|
+
function pe(e, t) {
|
391
410
|
return p({
|
392
411
|
queryKey: ["hive-engine", "tokens-list", e, t],
|
393
412
|
queryFn: async () => (await (await fetch(
|
394
|
-
`${
|
413
|
+
`${a.privateApiHost}/private-api/engine-api`,
|
395
414
|
{
|
396
415
|
method: "POST",
|
397
416
|
body: JSON.stringify({
|
@@ -412,11 +431,11 @@ function ae(e, t) {
|
|
412
431
|
)).json()).result
|
413
432
|
});
|
414
433
|
}
|
415
|
-
function
|
416
|
-
return
|
434
|
+
function ye(e = 20) {
|
435
|
+
return A({
|
417
436
|
queryKey: ["posts", "trending-tags"],
|
418
|
-
queryFn: async ({ pageParam: { afterTag: t } }) =>
|
419
|
-
(n) => n.filter((
|
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)
|
420
439
|
),
|
421
440
|
initialPageParam: { afterTag: "" },
|
422
441
|
getNextPageParam: (t) => ({
|
@@ -430,7 +449,7 @@ function v(e) {
|
|
430
449
|
return p({
|
431
450
|
queryKey: ["posts", "fragments", e],
|
432
451
|
queryFn: async () => (await fetch(
|
433
|
-
|
452
|
+
a.privateApiHost + "/private-api/fragments",
|
434
453
|
{
|
435
454
|
method: "POST",
|
436
455
|
body: JSON.stringify({
|
@@ -444,12 +463,12 @@ function v(e) {
|
|
444
463
|
enabled: !!e
|
445
464
|
});
|
446
465
|
}
|
447
|
-
function
|
466
|
+
function le(e = "feed") {
|
448
467
|
return p({
|
449
468
|
queryKey: ["posts", "promoted", e],
|
450
469
|
queryFn: async () => {
|
451
470
|
const t = new URL(
|
452
|
-
|
471
|
+
a.privateApiHost + "/private-api/promoted-entries"
|
453
472
|
);
|
454
473
|
return e === "waves" && t.searchParams.append("short_content", "1"), await (await fetch(t.toString(), {
|
455
474
|
method: "GET",
|
@@ -460,11 +479,11 @@ function ue(e = "feed") {
|
|
460
479
|
}
|
461
480
|
});
|
462
481
|
}
|
463
|
-
function
|
482
|
+
function fe(e) {
|
464
483
|
return y({
|
465
484
|
mutationKey: ["posts", "add-fragment", e],
|
466
485
|
mutationFn: async ({ title: t, body: n }) => (await fetch(
|
467
|
-
|
486
|
+
a.privateApiHost + "/private-api/fragments-add",
|
468
487
|
{
|
469
488
|
method: "POST",
|
470
489
|
body: JSON.stringify({
|
@@ -478,25 +497,25 @@ function pe(e) {
|
|
478
497
|
}
|
479
498
|
)).json(),
|
480
499
|
onSuccess(t) {
|
481
|
-
|
500
|
+
u().setQueryData(
|
482
501
|
v(e).queryKey,
|
483
502
|
(n) => [t, ...n ?? []]
|
484
503
|
);
|
485
504
|
}
|
486
505
|
});
|
487
506
|
}
|
488
|
-
function
|
507
|
+
function he(e, t) {
|
489
508
|
return y({
|
490
509
|
mutationKey: ["posts", "edit-fragment", e, t],
|
491
|
-
mutationFn: async ({ title: n, body:
|
492
|
-
|
510
|
+
mutationFn: async ({ title: n, body: o }) => (await fetch(
|
511
|
+
a.privateApiHost + "/private-api/fragments-update",
|
493
512
|
{
|
494
513
|
method: "POST",
|
495
514
|
body: JSON.stringify({
|
496
515
|
code: l(e),
|
497
516
|
id: t,
|
498
517
|
title: n,
|
499
|
-
body:
|
518
|
+
body: o
|
500
519
|
}),
|
501
520
|
headers: {
|
502
521
|
"Content-Type": "application/json"
|
@@ -504,22 +523,22 @@ function ye(e, t) {
|
|
504
523
|
}
|
505
524
|
)).json(),
|
506
525
|
onSuccess(n) {
|
507
|
-
|
526
|
+
u().setQueryData(
|
508
527
|
v(e).queryKey,
|
509
|
-
(
|
510
|
-
if (!
|
528
|
+
(o) => {
|
529
|
+
if (!o)
|
511
530
|
return [];
|
512
|
-
const
|
513
|
-
return
|
531
|
+
const i = o.findIndex(({ id: c }) => c === t);
|
532
|
+
return i >= 0 && (o[i] = n), [...o];
|
514
533
|
}
|
515
534
|
);
|
516
535
|
}
|
517
536
|
});
|
518
537
|
}
|
519
|
-
function
|
538
|
+
function de(e, t) {
|
520
539
|
return y({
|
521
540
|
mutationKey: ["posts", "remove-fragment", e],
|
522
|
-
mutationFn: async () => fetch(
|
541
|
+
mutationFn: async () => fetch(a.privateApiHost + "/private-api/fragments-delete", {
|
523
542
|
method: "POST",
|
524
543
|
body: JSON.stringify({
|
525
544
|
code: l(e),
|
@@ -530,20 +549,20 @@ function le(e, t) {
|
|
530
549
|
}
|
531
550
|
}),
|
532
551
|
onSuccess() {
|
533
|
-
|
552
|
+
u().setQueryData(
|
534
553
|
v(e).queryKey,
|
535
|
-
(n) => [...n ?? []].filter(({ id:
|
554
|
+
(n) => [...n ?? []].filter(({ id: o }) => o !== t)
|
536
555
|
);
|
537
556
|
}
|
538
557
|
});
|
539
558
|
}
|
540
|
-
function
|
559
|
+
function Q(e, t) {
|
541
560
|
return y({
|
542
561
|
mutationKey: ["analytics", t],
|
543
562
|
mutationFn: async () => {
|
544
563
|
if (!t)
|
545
564
|
throw new Error("[SDK][Analytics] – no activity type provided");
|
546
|
-
await fetch(
|
565
|
+
await fetch(a.plausibleHost + "/api/event", {
|
547
566
|
method: "POST",
|
548
567
|
headers: {
|
549
568
|
"Content-Type": "application/json"
|
@@ -560,11 +579,11 @@ function b(e, t) {
|
|
560
579
|
}
|
561
580
|
});
|
562
581
|
}
|
563
|
-
const
|
582
|
+
const ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
564
583
|
__proto__: null,
|
565
|
-
useRecordActivity:
|
584
|
+
useRecordActivity: Q
|
566
585
|
}, Symbol.toStringTag, { value: "Module" }));
|
567
|
-
function
|
586
|
+
function E(e, t) {
|
568
587
|
return p({
|
569
588
|
queryKey: ["integrations", "hivesigner", "decode-memo", e],
|
570
589
|
queryFn: async () => {
|
@@ -576,13 +595,13 @@ function B(e, t) {
|
|
576
595
|
}
|
577
596
|
});
|
578
597
|
}
|
579
|
-
const
|
598
|
+
const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
580
599
|
__proto__: null,
|
581
|
-
getDecodeMemoQueryOptions:
|
582
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
583
|
-
queries:
|
600
|
+
getDecodeMemoQueryOptions: E
|
601
|
+
}, Symbol.toStringTag, { value: "Module" })), U = {
|
602
|
+
queries: G
|
584
603
|
};
|
585
|
-
function
|
604
|
+
function m(e) {
|
586
605
|
return p({
|
587
606
|
queryKey: ["integrations", "3speak", "authenticate", e],
|
588
607
|
enabled: !!e,
|
@@ -596,28 +615,28 @@ function w(e) {
|
|
596
615
|
"Content-Type": "application/json"
|
597
616
|
}
|
598
617
|
}
|
599
|
-
), n =
|
618
|
+
), n = U.queries.getDecodeMemoQueryOptions(
|
600
619
|
e,
|
601
620
|
(await t.json()).memo
|
602
621
|
);
|
603
|
-
await
|
604
|
-
const { memoDecoded:
|
622
|
+
await u().prefetchQuery(n);
|
623
|
+
const { memoDecoded: o } = u().getQueryData(
|
605
624
|
n.queryKey
|
606
625
|
);
|
607
|
-
return
|
626
|
+
return o.replace("#", "");
|
608
627
|
}
|
609
628
|
});
|
610
629
|
}
|
611
|
-
function
|
630
|
+
function x(e) {
|
612
631
|
return p({
|
613
632
|
queryKey: ["integrations", "3speak", "videos", e],
|
614
633
|
enabled: !!e,
|
615
634
|
queryFn: async () => {
|
616
|
-
await
|
617
|
-
|
635
|
+
await u().prefetchQuery(
|
636
|
+
m(e)
|
618
637
|
);
|
619
|
-
const t =
|
620
|
-
|
638
|
+
const t = u().getQueryData(
|
639
|
+
m(e).queryKey
|
621
640
|
);
|
622
641
|
return await (await fetch(
|
623
642
|
"https://studio.3speak.tv/mobile/api/my-videos",
|
@@ -631,31 +650,31 @@ function G(e) {
|
|
631
650
|
}
|
632
651
|
});
|
633
652
|
}
|
634
|
-
const
|
653
|
+
const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
635
654
|
__proto__: null,
|
636
|
-
getAccountTokenQueryOptions:
|
637
|
-
getAccountVideosQueryOptions:
|
638
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
639
|
-
queries:
|
655
|
+
getAccountTokenQueryOptions: m,
|
656
|
+
getAccountVideosQueryOptions: x
|
657
|
+
}, Symbol.toStringTag, { value: "Module" })), we = {
|
658
|
+
queries: z
|
640
659
|
};
|
641
|
-
function
|
660
|
+
function me() {
|
642
661
|
return p({
|
643
662
|
queryKey: ["resource-credits", "stats"],
|
644
|
-
queryFn: async () => (await
|
663
|
+
queryFn: async () => (await a.hiveClient.call(
|
645
664
|
"rc_api",
|
646
665
|
"get_rc_stats",
|
647
666
|
{}
|
648
667
|
)).rc_stats
|
649
668
|
});
|
650
669
|
}
|
651
|
-
function
|
670
|
+
function ve(e) {
|
652
671
|
return p({
|
653
672
|
queryKey: ["resource-credits", "account", e],
|
654
|
-
queryFn: async () => new
|
673
|
+
queryFn: async () => new P(a.hiveClient).findRCAccounts([e]),
|
655
674
|
enabled: !!e
|
656
675
|
});
|
657
676
|
}
|
658
|
-
function
|
677
|
+
function Ce(e, t) {
|
659
678
|
return p({
|
660
679
|
queryKey: ["games", "status-check", t, e],
|
661
680
|
enabled: !!e,
|
@@ -663,7 +682,7 @@ function we(e, t) {
|
|
663
682
|
if (!e)
|
664
683
|
throw new Error("[SDK][Games] – anon user in status check");
|
665
684
|
return await (await fetch(
|
666
|
-
|
685
|
+
a.privateApiHost + "/private-api/get-game",
|
667
686
|
{
|
668
687
|
method: "POST",
|
669
688
|
body: JSON.stringify({
|
@@ -678,8 +697,8 @@ function we(e, t) {
|
|
678
697
|
}
|
679
698
|
});
|
680
699
|
}
|
681
|
-
function
|
682
|
-
const { mutateAsync:
|
700
|
+
function be(e, t, n) {
|
701
|
+
const { mutateAsync: o } = Q(
|
683
702
|
e,
|
684
703
|
"spin-rolled"
|
685
704
|
);
|
@@ -689,7 +708,7 @@ function ve(e, t, n) {
|
|
689
708
|
if (!e)
|
690
709
|
throw new Error("[SDK][Games] – anon user in game post");
|
691
710
|
return await (await fetch(
|
692
|
-
|
711
|
+
a.privateApiHost + "/private-api/post-game",
|
693
712
|
{
|
694
713
|
method: "POST",
|
695
714
|
body: JSON.stringify({
|
@@ -704,45 +723,91 @@ function ve(e, t, n) {
|
|
704
723
|
)).json();
|
705
724
|
},
|
706
725
|
onSuccess() {
|
707
|
-
|
726
|
+
o();
|
708
727
|
}
|
709
728
|
});
|
710
729
|
}
|
730
|
+
function qe(e, t, n = 100, o = void 0, i = !0) {
|
731
|
+
return p({
|
732
|
+
queryKey: ["communities", "list", e, t, n],
|
733
|
+
enabled: i,
|
734
|
+
queryFn: async () => await a.hiveClient.call(
|
735
|
+
"bridge",
|
736
|
+
"list_communities",
|
737
|
+
{
|
738
|
+
last: "",
|
739
|
+
limit: n,
|
740
|
+
sort: e,
|
741
|
+
query: t,
|
742
|
+
observer: o
|
743
|
+
}
|
744
|
+
) ?? []
|
745
|
+
});
|
746
|
+
}
|
747
|
+
var W = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(W || {});
|
748
|
+
const Oe = {
|
749
|
+
owner: [
|
750
|
+
"admin",
|
751
|
+
"mod",
|
752
|
+
"member",
|
753
|
+
"guest",
|
754
|
+
"muted"
|
755
|
+
/* MUTED */
|
756
|
+
],
|
757
|
+
admin: [
|
758
|
+
"mod",
|
759
|
+
"member",
|
760
|
+
"guest",
|
761
|
+
"muted"
|
762
|
+
/* MUTED */
|
763
|
+
],
|
764
|
+
mod: [
|
765
|
+
"member",
|
766
|
+
"guest",
|
767
|
+
"muted"
|
768
|
+
/* MUTED */
|
769
|
+
]
|
770
|
+
};
|
711
771
|
export {
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
772
|
+
a as CONFIG,
|
773
|
+
b as ConfigManager,
|
774
|
+
ge as EcencyAnalytics,
|
775
|
+
q as EcencyQueriesManager,
|
776
|
+
U as HiveSignerIntegration,
|
777
|
+
L as Keychain,
|
778
|
+
W as ROLES,
|
779
|
+
we as ThreeSpeakIntegration,
|
780
|
+
H as broadcastJson,
|
781
|
+
oe as checkUsernameWalletsPendingQueryOptions,
|
721
782
|
l as getAccessToken,
|
722
|
-
|
723
|
-
|
724
|
-
|
783
|
+
te as getAccountFullQueryOptions,
|
784
|
+
ve as getAccountRcQueryOptions,
|
785
|
+
re as getAccountSubscriptionsQueryOptions,
|
786
|
+
ue as getChainPropertiesQueryOptions,
|
787
|
+
qe as getCommunitiesQueryOptions,
|
725
788
|
v as getFragmentsQueryOptions,
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
789
|
+
Ce as getGameStatusCheckQueryOptions,
|
790
|
+
pe as getHiveEngineTokensListQueryOptions,
|
791
|
+
S as getLoginType,
|
792
|
+
K as getPostingKey,
|
793
|
+
le as getPromotedPostsQuery,
|
794
|
+
u as getQueryClient,
|
795
|
+
me as getRcStatsQueryOptions,
|
796
|
+
Z as getRefreshToken,
|
797
|
+
B as getRelationshipBetweenAccountsQueryOptions,
|
798
|
+
ne as getSearchAccountsByUsernameQueryOptions,
|
799
|
+
ye as getTrendingTagsQueryOptions,
|
736
800
|
f as getUser,
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
801
|
+
R as makeQueryClient,
|
802
|
+
Oe as roleMap,
|
803
|
+
ie as useAccountRelationsUpdate,
|
804
|
+
ee as useAccountUpdate,
|
805
|
+
fe as useAddFragment,
|
806
|
+
M as useBroadcastMutation,
|
807
|
+
he as useEditFragment,
|
808
|
+
be as useGameClaim,
|
809
|
+
de as useRemoveFragment,
|
810
|
+
ce as useSignOperationByHivesigner,
|
811
|
+
se as useSignOperationByKey,
|
812
|
+
ae as useSignOperationByKeychain
|
748
813
|
};
|
package/dist/index.d.ts
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
type Subscriptions = string[];
|
2
|
+
export declare function getAccountSubscriptionsQueryOptions(username: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Subscriptions, Error, Subscriptions, (string | undefined)[]>, "queryFn"> & {
|
3
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<Subscriptions, (string | undefined)[], never> | undefined;
|
4
|
+
} & {
|
5
|
+
queryKey: (string | undefined)[] & {
|
6
|
+
[dataTagSymbol]: Subscriptions;
|
7
|
+
[dataTagErrorSymbol]: Error;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export {};
|
@@ -2,3 +2,4 @@ export * from './get-account-full-query-options';
|
|
2
2
|
export * from './search-accounts-by-username-query-options';
|
3
3
|
export * from './check-username-wallets-pending-query-options';
|
4
4
|
export * from './get-relationship-between-accounts-query-options';
|
5
|
+
export * from './get-account-subscriptions-query-options';
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Communities } from '../types';
|
2
|
+
export declare function getCommunitiesQueryOptions(sort: string, query?: string, limit?: number, observer?: string | undefined, enabled?: boolean): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Communities, Error, Communities, (string | number | undefined)[]>, "queryFn"> & {
|
3
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<Communities, (string | number | undefined)[], never> | undefined;
|
4
|
+
} & {
|
5
|
+
queryKey: (string | number | undefined)[] & {
|
6
|
+
[dataTagSymbol]: Communities;
|
7
|
+
[dataTagErrorSymbol]: Error;
|
8
|
+
};
|
9
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './get-communities-query-options';
|
@@ -0,0 +1,31 @@
|
|
1
|
+
export declare enum ROLES {
|
2
|
+
OWNER = "owner",
|
3
|
+
ADMIN = "admin",
|
4
|
+
MOD = "mod",
|
5
|
+
MEMBER = "member",
|
6
|
+
GUEST = "guest",
|
7
|
+
MUTED = "muted"
|
8
|
+
}
|
9
|
+
export declare const roleMap: Record<string, string[]>;
|
10
|
+
export type CommunityTeam = Array<Array<string>>;
|
11
|
+
export interface Community {
|
12
|
+
about: string;
|
13
|
+
admins?: string[];
|
14
|
+
avatar_url: string;
|
15
|
+
created_at: string;
|
16
|
+
description: string;
|
17
|
+
flag_text: string;
|
18
|
+
id: number;
|
19
|
+
is_nsfw: boolean;
|
20
|
+
lang: string;
|
21
|
+
name: string;
|
22
|
+
num_authors: number;
|
23
|
+
num_pending: number;
|
24
|
+
subscribers: number;
|
25
|
+
sum_pending: number;
|
26
|
+
settings?: any;
|
27
|
+
team: CommunityTeam;
|
28
|
+
title: string;
|
29
|
+
type_id: number;
|
30
|
+
}
|
31
|
+
export type Communities = Community[];
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './community';
|
@@ -2,4 +2,5 @@ import { StoringUser } from './entities';
|
|
2
2
|
export declare const getUser: (username: string) => StoringUser | undefined;
|
3
3
|
export declare const getAccessToken: (username: string) => string | undefined;
|
4
4
|
export declare const getPostingKey: (username: string) => null | undefined | string;
|
5
|
+
export declare const getLoginType: (username: string) => null | undefined | string;
|
5
6
|
export declare const getRefreshToken: (username: string) => string | undefined;
|