@ecency/sdk 1.0.37 → 1.0.38
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 +195 -96
- package/dist/modules/posts/index.d.ts +1 -0
- package/dist/modules/posts/mutations/add-fragment.d.ts +5 -0
- package/dist/modules/posts/mutations/edit-fragment.d.ts +5 -0
- package/dist/modules/posts/mutations/index.d.ts +3 -0
- package/dist/modules/posts/mutations/remove-fragment.d.ts +1 -0
- package/dist/modules/posts/queries/get-fragments-query-options.d.ts +9 -0
- package/dist/modules/posts/queries/index.d.ts +1 -0
- package/dist/modules/posts/types/fragment.d.ts +7 -0
- package/dist/modules/posts/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
var
|
2
|
-
var b = (e, t, n) => t in e ?
|
3
|
-
var
|
4
|
-
import { QueryClient as
|
5
|
-
import { Client as k, PrivateKey as h, cryptoUtils as
|
6
|
-
import
|
7
|
-
class
|
1
|
+
var K = Object.defineProperty;
|
2
|
+
var b = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
3
|
+
var m = (e, t, n) => b(e, typeof t != "symbol" ? t + "" : t, n);
|
4
|
+
import { QueryClient as q, useMutation as p, useQuery as Q, useInfiniteQuery as _, queryOptions as c, infiniteQueryOptions as T } from "@tanstack/react-query";
|
5
|
+
import { Client as k, PrivateKey as h, cryptoUtils as j, RCAPI as A } from "@hiveio/dhive";
|
6
|
+
import w from "hivesigner";
|
7
|
+
class F {
|
8
8
|
constructor() {
|
9
|
-
|
9
|
+
m(this, "length", 0);
|
10
10
|
}
|
11
11
|
clear() {
|
12
12
|
throw new Error("Method not implemented.");
|
@@ -26,7 +26,7 @@ class A {
|
|
26
26
|
}
|
27
27
|
const o = {
|
28
28
|
privateApiHost: "https://ecency.com",
|
29
|
-
storage: typeof window > "u" ? new
|
29
|
+
storage: typeof window > "u" ? new F() : window.localStorage,
|
30
30
|
storagePrefix: "ecency",
|
31
31
|
hiveClient: new k(
|
32
32
|
[
|
@@ -49,41 +49,41 @@ const o = {
|
|
49
49
|
}
|
50
50
|
),
|
51
51
|
heliusApiKey: void 0,
|
52
|
-
queryClient: new
|
52
|
+
queryClient: new q(),
|
53
53
|
plausibleHost: "https://pl.ecency.com"
|
54
54
|
};
|
55
|
-
var
|
55
|
+
var O;
|
56
56
|
((e) => {
|
57
57
|
function t(n) {
|
58
58
|
o.queryClient = n;
|
59
59
|
}
|
60
60
|
e.setQueryClient = t;
|
61
|
-
})(
|
62
|
-
function
|
61
|
+
})(O || (O = {}));
|
62
|
+
function D(e) {
|
63
63
|
let t = atob(e);
|
64
64
|
if (t[0] === "{")
|
65
65
|
return JSON.parse(t);
|
66
66
|
}
|
67
|
-
const
|
67
|
+
const l = (e) => {
|
68
68
|
try {
|
69
69
|
const t = o.storage.getItem(
|
70
70
|
o.storagePrefix + "_user_" + e
|
71
71
|
);
|
72
|
-
return
|
72
|
+
return D(JSON.parse(t));
|
73
73
|
} catch (t) {
|
74
74
|
console.error(t);
|
75
75
|
return;
|
76
76
|
}
|
77
|
-
},
|
78
|
-
function
|
79
|
-
return
|
77
|
+
}, f = (e) => l(e) && l(e).accessToken, I = (e) => l(e) && l(e).postingKey, $ = (e) => l(e) && l(e).refreshToken;
|
78
|
+
function P(e = [], t, n) {
|
79
|
+
return p({
|
80
80
|
mutationKey: [...e, t],
|
81
81
|
mutationFn: async (r) => {
|
82
82
|
if (!t)
|
83
83
|
throw new Error(
|
84
84
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
85
85
|
);
|
86
|
-
const a =
|
86
|
+
const a = I(t);
|
87
87
|
if (a) {
|
88
88
|
const y = h.fromString(a);
|
89
89
|
return o.hiveClient.broadcast.sendOperations(
|
@@ -91,9 +91,9 @@ function F(e = [], t, n) {
|
|
91
91
|
y
|
92
92
|
);
|
93
93
|
}
|
94
|
-
let u =
|
94
|
+
let u = f(t);
|
95
95
|
if (u)
|
96
|
-
return (await new
|
96
|
+
return (await new w.Client({
|
97
97
|
accessToken: u
|
98
98
|
}).broadcast(n(r))).result;
|
99
99
|
throw new Error(
|
@@ -102,8 +102,8 @@ function F(e = [], t, n) {
|
|
102
102
|
}
|
103
103
|
});
|
104
104
|
}
|
105
|
-
function
|
106
|
-
return new
|
105
|
+
function G() {
|
106
|
+
return new q({
|
107
107
|
defaultOptions: {
|
108
108
|
queries: {
|
109
109
|
// With SSR, we usually want to set some default staleTime
|
@@ -116,7 +116,7 @@ function $() {
|
|
116
116
|
});
|
117
117
|
}
|
118
118
|
const s = () => o.queryClient;
|
119
|
-
var
|
119
|
+
var C;
|
120
120
|
((e) => {
|
121
121
|
function t(i) {
|
122
122
|
return s().getQueryData(i);
|
@@ -138,7 +138,7 @@ var m;
|
|
138
138
|
return {
|
139
139
|
prefetch: () => r(i),
|
140
140
|
getData: () => t(i.queryKey),
|
141
|
-
useClientQuery: () =>
|
141
|
+
useClientQuery: () => Q(i),
|
142
142
|
fetchAndGet: () => s().fetchQuery(i)
|
143
143
|
};
|
144
144
|
}
|
@@ -147,14 +147,14 @@ var m;
|
|
147
147
|
return {
|
148
148
|
prefetch: () => a(i),
|
149
149
|
getData: () => n(i.queryKey),
|
150
|
-
useClientQuery: () =>
|
150
|
+
useClientQuery: () => _(i),
|
151
151
|
fetchAndGet: () => s().fetchInfiniteQuery(i)
|
152
152
|
};
|
153
153
|
}
|
154
154
|
e.generateClientServerInfiniteQuery = y;
|
155
|
-
})(
|
156
|
-
function
|
157
|
-
return
|
155
|
+
})(C || (C = {}));
|
156
|
+
function V(e) {
|
157
|
+
return P(
|
158
158
|
["accounts", "update"],
|
159
159
|
e,
|
160
160
|
({
|
@@ -176,7 +176,7 @@ function G(e) {
|
|
176
176
|
]
|
177
177
|
);
|
178
178
|
}
|
179
|
-
function
|
179
|
+
function L(e) {
|
180
180
|
return c({
|
181
181
|
queryKey: ["get-account-full", e],
|
182
182
|
queryFn: async () => {
|
@@ -213,7 +213,7 @@ function V(e) {
|
|
213
213
|
staleTime: 6e4
|
214
214
|
});
|
215
215
|
}
|
216
|
-
function
|
216
|
+
function X(e, t = 5, n = []) {
|
217
217
|
return c({
|
218
218
|
queryKey: ["accounts", "search", e, n],
|
219
219
|
enabled: !!e,
|
@@ -225,7 +225,7 @@ function L(e, t = 5, n = []) {
|
|
225
225
|
)
|
226
226
|
});
|
227
227
|
}
|
228
|
-
function
|
228
|
+
function Y(e) {
|
229
229
|
return c({
|
230
230
|
queryKey: ["accounts", "check-wallet-pending", e],
|
231
231
|
queryFn: async () => await (await fetch(
|
@@ -244,8 +244,8 @@ function X(e) {
|
|
244
244
|
refetchOnMount: !0
|
245
245
|
});
|
246
246
|
}
|
247
|
-
function
|
248
|
-
return
|
247
|
+
function Z(e) {
|
248
|
+
return p({
|
249
249
|
mutationKey: ["operations", "sign", e],
|
250
250
|
mutationFn: ({
|
251
251
|
operation: t,
|
@@ -254,14 +254,14 @@ function Y(e) {
|
|
254
254
|
if (!e)
|
255
255
|
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
256
256
|
let r;
|
257
|
-
return n.split(" ").length === 12 ? r = h.fromLogin(e, n, "active") :
|
257
|
+
return n.split(" ").length === 12 ? r = h.fromLogin(e, n, "active") : j.isWif(n) ? r = h.fromString(n) : r = h.from(n), o.hiveClient.broadcast.sendOperations(
|
258
258
|
[t],
|
259
259
|
r
|
260
260
|
);
|
261
261
|
}
|
262
262
|
});
|
263
263
|
}
|
264
|
-
function
|
264
|
+
function N() {
|
265
265
|
return new Promise((e) => {
|
266
266
|
var t;
|
267
267
|
(t = window.hive_keychain) == null || t.requestHandshake(() => {
|
@@ -269,7 +269,7 @@ function P() {
|
|
269
269
|
});
|
270
270
|
});
|
271
271
|
}
|
272
|
-
const
|
272
|
+
const S = (e, t, n, r = null) => new Promise((a, u) => {
|
273
273
|
var y;
|
274
274
|
(y = window.hive_keychain) == null || y.requestBroadcast(
|
275
275
|
e,
|
@@ -280,31 +280,31 @@ const q = (e, t, n, r = null) => new Promise((a, u) => {
|
|
280
280
|
},
|
281
281
|
r
|
282
282
|
);
|
283
|
-
}),
|
283
|
+
}), ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
284
284
|
__proto__: null,
|
285
|
-
broadcast:
|
286
|
-
handshake:
|
285
|
+
broadcast: S,
|
286
|
+
handshake: N
|
287
287
|
}, Symbol.toStringTag, { value: "Module" }));
|
288
|
-
function
|
289
|
-
return
|
288
|
+
function te(e, t = "Active") {
|
289
|
+
return p({
|
290
290
|
mutationKey: ["operations", "sign-keychain", e],
|
291
291
|
mutationFn: ({ operation: n }) => {
|
292
292
|
if (!e)
|
293
293
|
throw new Error(
|
294
294
|
"[SDK][Keychain] – cannot sign operation with anon user"
|
295
295
|
);
|
296
|
-
return
|
296
|
+
return S(e, [n], t);
|
297
297
|
}
|
298
298
|
});
|
299
299
|
}
|
300
|
-
function
|
301
|
-
return
|
300
|
+
function ne(e = "/") {
|
301
|
+
return p({
|
302
302
|
mutationKey: ["operations", "sign-hivesigner", e],
|
303
|
-
mutationFn: async ({ operation: t }) =>
|
303
|
+
mutationFn: async ({ operation: t }) => w.sendOperation(t, { callback: e }, () => {
|
304
304
|
})
|
305
305
|
});
|
306
306
|
}
|
307
|
-
function
|
307
|
+
function re(e, t) {
|
308
308
|
return c({
|
309
309
|
queryKey: ["hive-engine", "tokens-list", e, t],
|
310
310
|
queryFn: async () => (await (await fetch(
|
@@ -329,8 +329,8 @@ function ne(e, t) {
|
|
329
329
|
)).json()).result
|
330
330
|
});
|
331
331
|
}
|
332
|
-
function
|
333
|
-
return
|
332
|
+
function ie(e = 20) {
|
333
|
+
return T({
|
334
334
|
queryKey: ["posts", "trending-tags"],
|
335
335
|
queryFn: async ({ pageParam: { afterTag: t } }) => o.hiveClient.database.call("get_trending_tags", [t, e]).then(
|
336
336
|
(n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
|
@@ -343,8 +343,103 @@ function re(e = 20) {
|
|
343
343
|
refetchOnMount: !0
|
344
344
|
});
|
345
345
|
}
|
346
|
-
function
|
347
|
-
return
|
346
|
+
function v(e) {
|
347
|
+
return c({
|
348
|
+
queryKey: ["posts", "fragments", e],
|
349
|
+
queryFn: async () => (await fetch(
|
350
|
+
o.privateApiHost + "/private-api/fragments",
|
351
|
+
{
|
352
|
+
method: "POST",
|
353
|
+
body: JSON.stringify({
|
354
|
+
code: f(e)
|
355
|
+
}),
|
356
|
+
headers: {
|
357
|
+
"Content-Type": "application/json"
|
358
|
+
}
|
359
|
+
}
|
360
|
+
)).json(),
|
361
|
+
enabled: !!e
|
362
|
+
});
|
363
|
+
}
|
364
|
+
function oe(e) {
|
365
|
+
return p({
|
366
|
+
mutationKey: ["posts", "add-fragment", e],
|
367
|
+
mutationFn: async ({ title: t, body: n }) => (await fetch(
|
368
|
+
o.privateApiHost + "/private-api/fragments-add",
|
369
|
+
{
|
370
|
+
method: "POST",
|
371
|
+
body: JSON.stringify({
|
372
|
+
code: f(e),
|
373
|
+
title: t,
|
374
|
+
body: n
|
375
|
+
}),
|
376
|
+
headers: {
|
377
|
+
"Content-Type": "application/json"
|
378
|
+
}
|
379
|
+
}
|
380
|
+
)).json(),
|
381
|
+
onSuccess(t) {
|
382
|
+
s().setQueryData(
|
383
|
+
v(e).queryKey,
|
384
|
+
(n) => [t, ...n ?? []]
|
385
|
+
);
|
386
|
+
}
|
387
|
+
});
|
388
|
+
}
|
389
|
+
function ae(e, t) {
|
390
|
+
return p({
|
391
|
+
mutationKey: ["posts", "edit-fragment", e, t],
|
392
|
+
mutationFn: async ({ title: n, body: r }) => (await fetch(
|
393
|
+
o.privateApiHost + "/private-api/fragments-update",
|
394
|
+
{
|
395
|
+
method: "POST",
|
396
|
+
body: JSON.stringify({
|
397
|
+
code: f(e),
|
398
|
+
id: t,
|
399
|
+
title: n,
|
400
|
+
body: r
|
401
|
+
}),
|
402
|
+
headers: {
|
403
|
+
"Content-Type": "application/json"
|
404
|
+
}
|
405
|
+
}
|
406
|
+
)).json(),
|
407
|
+
onSuccess(n) {
|
408
|
+
s().setQueryData(
|
409
|
+
v(e).queryKey,
|
410
|
+
(r) => {
|
411
|
+
if (!r)
|
412
|
+
return [];
|
413
|
+
const a = r.findIndex(({ id: u }) => u === t);
|
414
|
+
return a >= 0 && (r[a] = n), [...r];
|
415
|
+
}
|
416
|
+
);
|
417
|
+
}
|
418
|
+
});
|
419
|
+
}
|
420
|
+
function se(e, t) {
|
421
|
+
return p({
|
422
|
+
mutationKey: ["posts", "remove-fragment", e],
|
423
|
+
mutationFn: async () => fetch(o.privateApiHost + "/private-api/fragments-delete", {
|
424
|
+
method: "POST",
|
425
|
+
body: JSON.stringify({
|
426
|
+
code: f(e),
|
427
|
+
id: t
|
428
|
+
}),
|
429
|
+
headers: {
|
430
|
+
"Content-Type": "application/json"
|
431
|
+
}
|
432
|
+
}),
|
433
|
+
onSuccess() {
|
434
|
+
s().setQueryData(
|
435
|
+
v(e).queryKey,
|
436
|
+
(n) => [...n ?? []].filter(({ id: r }) => r !== t)
|
437
|
+
);
|
438
|
+
}
|
439
|
+
});
|
440
|
+
}
|
441
|
+
function H(e, t) {
|
442
|
+
return p({
|
348
443
|
mutationKey: ["analytics", t],
|
349
444
|
mutationFn: async () => {
|
350
445
|
if (!t)
|
@@ -366,29 +461,29 @@ function M(e, t) {
|
|
366
461
|
}
|
367
462
|
});
|
368
463
|
}
|
369
|
-
const
|
464
|
+
const ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
370
465
|
__proto__: null,
|
371
|
-
useRecordActivity:
|
466
|
+
useRecordActivity: H
|
372
467
|
}, Symbol.toStringTag, { value: "Module" }));
|
373
|
-
function
|
468
|
+
function J(e, t) {
|
374
469
|
return c({
|
375
470
|
queryKey: ["integrations", "hivesigner", "decode-memo", e],
|
376
471
|
queryFn: async () => {
|
377
|
-
const n =
|
472
|
+
const n = f(e);
|
378
473
|
if (n)
|
379
|
-
return new
|
474
|
+
return new w.Client({
|
380
475
|
accessToken: n
|
381
476
|
}).decode(t);
|
382
477
|
}
|
383
478
|
});
|
384
479
|
}
|
385
|
-
const
|
480
|
+
const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
386
481
|
__proto__: null,
|
387
|
-
getDecodeMemoQueryOptions:
|
388
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
389
|
-
queries:
|
482
|
+
getDecodeMemoQueryOptions: J
|
483
|
+
}, Symbol.toStringTag, { value: "Module" })), B = {
|
484
|
+
queries: M
|
390
485
|
};
|
391
|
-
function
|
486
|
+
function g(e) {
|
392
487
|
return c({
|
393
488
|
queryKey: ["integrations", "3speak", "authenticate", e],
|
394
489
|
enabled: !!e,
|
@@ -402,7 +497,7 @@ function d(e) {
|
|
402
497
|
"Content-Type": "application/json"
|
403
498
|
}
|
404
499
|
}
|
405
|
-
), n =
|
500
|
+
), n = B.queries.getDecodeMemoQueryOptions(
|
406
501
|
e,
|
407
502
|
(await t.json()).memo
|
408
503
|
);
|
@@ -414,16 +509,16 @@ function d(e) {
|
|
414
509
|
}
|
415
510
|
});
|
416
511
|
}
|
417
|
-
function
|
512
|
+
function x(e) {
|
418
513
|
return c({
|
419
514
|
queryKey: ["integrations", "3speak", "videos", e],
|
420
515
|
enabled: !!e,
|
421
516
|
queryFn: async () => {
|
422
517
|
await s().prefetchQuery(
|
423
|
-
|
518
|
+
g(e)
|
424
519
|
);
|
425
520
|
const t = s().getQueryData(
|
426
|
-
|
521
|
+
g(e).queryKey
|
427
522
|
);
|
428
523
|
return await (await fetch(
|
429
524
|
"https://studio.3speak.tv/mobile/api/my-videos",
|
@@ -437,14 +532,14 @@ function E(e) {
|
|
437
532
|
}
|
438
533
|
});
|
439
534
|
}
|
440
|
-
const
|
535
|
+
const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
441
536
|
__proto__: null,
|
442
|
-
getAccountTokenQueryOptions:
|
443
|
-
getAccountVideosQueryOptions:
|
444
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
445
|
-
queries:
|
537
|
+
getAccountTokenQueryOptions: g,
|
538
|
+
getAccountVideosQueryOptions: x
|
539
|
+
}, Symbol.toStringTag, { value: "Module" })), ue = {
|
540
|
+
queries: E
|
446
541
|
};
|
447
|
-
function
|
542
|
+
function pe() {
|
448
543
|
return c({
|
449
544
|
queryKey: ["resource-credits", "stats"],
|
450
545
|
queryFn: async () => (await o.hiveClient.call(
|
@@ -454,37 +549,41 @@ function ae() {
|
|
454
549
|
)).rc_stats
|
455
550
|
});
|
456
551
|
}
|
457
|
-
function
|
552
|
+
function ye(e) {
|
458
553
|
return c({
|
459
554
|
queryKey: ["resource-credits", "account", e],
|
460
|
-
queryFn: async () => new
|
555
|
+
queryFn: async () => new A(o.hiveClient).findRCAccounts([e]),
|
461
556
|
enabled: !!e
|
462
557
|
});
|
463
558
|
}
|
464
559
|
export {
|
465
560
|
o as CONFIG,
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
561
|
+
O as ConfigManager,
|
562
|
+
ce as EcencyAnalytics,
|
563
|
+
C as EcencyQueriesManager,
|
564
|
+
B as HiveSignerIntegration,
|
565
|
+
ee as Keychain,
|
566
|
+
ue as ThreeSpeakIntegration,
|
567
|
+
Y as checkUsernameWalletsPendingQueryOptions,
|
568
|
+
f as getAccessToken,
|
569
|
+
L as getAccountFullQueryOptions,
|
570
|
+
ye as getAccountRcQueryOptions,
|
571
|
+
v as getFragmentsQueryOptions,
|
572
|
+
re as getHiveEngineTokensListQueryOptions,
|
573
|
+
I as getPostingKey,
|
478
574
|
s as getQueryClient,
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
575
|
+
pe as getRcStatsQueryOptions,
|
576
|
+
$ as getRefreshToken,
|
577
|
+
X as getSearchAccountsByUsernameQueryOptions,
|
578
|
+
ie as getTrendingTagsQueryOptions,
|
579
|
+
l as getUser,
|
580
|
+
G as makeQueryClient,
|
581
|
+
V as useAccountUpdate,
|
582
|
+
oe as useAddFragment,
|
583
|
+
P as useBroadcastMutation,
|
584
|
+
ae as useEditFragment,
|
585
|
+
se as useRemoveFragment,
|
586
|
+
ne as useSignOperationByHivesigner,
|
587
|
+
Z as useSignOperationByKey,
|
588
|
+
te as useSignOperationByKeychain
|
490
589
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function useRemoveFragment(username: string, fragmentId: string): import('@tanstack/react-query').UseMutationResult<Response, Error, void, unknown>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Fragment } from '../types';
|
2
|
+
export declare function getFragmentsQueryOptions(username: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Fragment[], Error, Fragment[], string[]>, "queryFn"> & {
|
3
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<Fragment[], string[], never> | undefined;
|
4
|
+
} & {
|
5
|
+
queryKey: string[] & {
|
6
|
+
[dataTagSymbol]: Fragment[];
|
7
|
+
[dataTagErrorSymbol]: Error;
|
8
|
+
};
|
9
|
+
};
|