@ecency/sdk 1.0.32 → 1.0.33
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 +128 -79
- package/dist/index.d.ts +1 -0
- package/dist/modules/accounts/queries/check-username-wallets-pending-query-options.d.ts +8 -0
- package/dist/modules/accounts/queries/index.d.ts +1 -0
- package/dist/modules/analytics/index.d.ts +2 -0
- package/dist/modules/analytics/mutations/index.d.ts +1 -0
- package/dist/modules/analytics/mutations/use-record-activity.d.ts +3 -0
- package/dist/modules/core/config.d.ts +1 -0
- package/package.json +1 -1
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
var
|
2
|
-
var K = (e, t, n) => t in e ?
|
3
|
-
var
|
4
|
-
import { QueryClient as v, useMutation as
|
5
|
-
import { Client as
|
1
|
+
var O = Object.defineProperty;
|
2
|
+
var K = (e, t, n) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
3
|
+
var d = (e, t, n) => K(e, typeof t != "symbol" ? t + "" : t, n);
|
4
|
+
import { QueryClient as v, useMutation as y, useQuery as Q, useInfiniteQuery as b, queryOptions as f, infiniteQueryOptions as q } from "@tanstack/react-query";
|
5
|
+
import { Client as S, PrivateKey as l, cryptoUtils as _ } from "@hiveio/dhive";
|
6
6
|
import m from "hivesigner";
|
7
|
-
class
|
7
|
+
class k {
|
8
8
|
constructor() {
|
9
|
-
|
9
|
+
d(this, "length", 0);
|
10
10
|
}
|
11
11
|
clear() {
|
12
12
|
throw new Error("Method not implemented.");
|
@@ -24,11 +24,11 @@ class b {
|
|
24
24
|
this[t] = n;
|
25
25
|
}
|
26
26
|
}
|
27
|
-
const
|
27
|
+
const o = {
|
28
28
|
privateApiHost: "https://ecency.com",
|
29
|
-
storage: typeof window > "u" ? new
|
29
|
+
storage: typeof window > "u" ? new k() : window.localStorage,
|
30
30
|
storagePrefix: "ecency",
|
31
|
-
hiveClient: new
|
31
|
+
hiveClient: new S(
|
32
32
|
[
|
33
33
|
"https://api.hive.blog",
|
34
34
|
"https://api.deathwing.me",
|
@@ -49,48 +49,49 @@ const a = {
|
|
49
49
|
}
|
50
50
|
),
|
51
51
|
heliusApiKey: void 0,
|
52
|
-
queryClient: new v()
|
52
|
+
queryClient: new v(),
|
53
|
+
plausibleHost: "https://pl.ecency.com"
|
53
54
|
};
|
54
|
-
var
|
55
|
+
var g;
|
55
56
|
((e) => {
|
56
57
|
function t(n) {
|
57
|
-
|
58
|
+
o.queryClient = n;
|
58
59
|
}
|
59
60
|
e.setQueryClient = t;
|
60
|
-
})(
|
61
|
-
function
|
61
|
+
})(g || (g = {}));
|
62
|
+
function T(e) {
|
62
63
|
let t = atob(e);
|
63
64
|
if (t[0] === "{")
|
64
65
|
return JSON.parse(t);
|
65
66
|
}
|
66
|
-
const
|
67
|
+
const p = (e) => {
|
67
68
|
try {
|
68
|
-
const t =
|
69
|
-
|
69
|
+
const t = o.storage.getItem(
|
70
|
+
o.storagePrefix + "_user_" + e
|
70
71
|
);
|
71
|
-
return
|
72
|
+
return T(JSON.parse(t));
|
72
73
|
} catch (t) {
|
73
74
|
console.error(t);
|
74
75
|
return;
|
75
76
|
}
|
76
|
-
},
|
77
|
-
function
|
78
|
-
return
|
77
|
+
}, A = (e) => p(e) && p(e).accessToken, I = (e) => p(e) && p(e).postingKey, J = (e) => p(e) && p(e).refreshToken;
|
78
|
+
function j(e = [], t, n) {
|
79
|
+
return y({
|
79
80
|
mutationKey: [...e, t],
|
80
81
|
mutationFn: async (r) => {
|
81
82
|
if (!t)
|
82
83
|
throw new Error(
|
83
84
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
84
85
|
);
|
85
|
-
const
|
86
|
-
if (
|
87
|
-
const c =
|
88
|
-
return
|
86
|
+
const a = I(t);
|
87
|
+
if (a) {
|
88
|
+
const c = l.fromString(a);
|
89
|
+
return o.hiveClient.broadcast.sendOperations(
|
89
90
|
n(r),
|
90
91
|
c
|
91
92
|
);
|
92
93
|
}
|
93
|
-
let s =
|
94
|
+
let s = A(t);
|
94
95
|
if (s)
|
95
96
|
return (await new m.Client({
|
96
97
|
accessToken: s
|
@@ -101,7 +102,7 @@ function D(e = [], t, n) {
|
|
101
102
|
}
|
102
103
|
});
|
103
104
|
}
|
104
|
-
function
|
105
|
+
function x() {
|
105
106
|
return new v({
|
106
107
|
defaultOptions: {
|
107
108
|
queries: {
|
@@ -114,7 +115,7 @@ function H() {
|
|
114
115
|
}
|
115
116
|
});
|
116
117
|
}
|
117
|
-
const u = () =>
|
118
|
+
const u = () => o.queryClient;
|
118
119
|
var w;
|
119
120
|
((e) => {
|
120
121
|
function t(i) {
|
@@ -129,31 +130,31 @@ var w;
|
|
129
130
|
return await u().prefetchQuery(i), t(i.queryKey);
|
130
131
|
}
|
131
132
|
e.prefetchQuery = r;
|
132
|
-
async function
|
133
|
+
async function a(i) {
|
133
134
|
return await u().prefetchInfiniteQuery(i), n(i.queryKey);
|
134
135
|
}
|
135
|
-
e.prefetchInfiniteQuery =
|
136
|
+
e.prefetchInfiniteQuery = a;
|
136
137
|
function s(i) {
|
137
138
|
return {
|
138
139
|
prefetch: () => r(i),
|
139
140
|
getData: () => t(i.queryKey),
|
140
|
-
useClientQuery: () =>
|
141
|
+
useClientQuery: () => Q(i),
|
141
142
|
fetchAndGet: () => u().fetchQuery(i)
|
142
143
|
};
|
143
144
|
}
|
144
145
|
e.generateClientServerQuery = s;
|
145
146
|
function c(i) {
|
146
147
|
return {
|
147
|
-
prefetch: () =>
|
148
|
+
prefetch: () => a(i),
|
148
149
|
getData: () => n(i.queryKey),
|
149
|
-
useClientQuery: () =>
|
150
|
+
useClientQuery: () => b(i),
|
150
151
|
fetchAndGet: () => u().fetchInfiniteQuery(i)
|
151
152
|
};
|
152
153
|
}
|
153
154
|
e.generateClientServerInfiniteQuery = c;
|
154
155
|
})(w || (w = {}));
|
155
|
-
function
|
156
|
-
return
|
156
|
+
function E(e) {
|
157
|
+
return j(
|
157
158
|
["accounts", "update"],
|
158
159
|
e,
|
159
160
|
({
|
@@ -175,25 +176,25 @@ function J(e) {
|
|
175
176
|
]
|
176
177
|
);
|
177
178
|
}
|
178
|
-
function
|
179
|
-
return
|
179
|
+
function M(e) {
|
180
|
+
return f({
|
180
181
|
queryKey: ["get-account-full", e],
|
181
182
|
queryFn: async () => {
|
182
183
|
if (!e)
|
183
184
|
throw new Error("[SDK] Username is empty");
|
184
|
-
const t = await
|
185
|
+
const t = await o.hiveClient.database.getAccounts([e]);
|
185
186
|
if (!t[0])
|
186
187
|
throw new Error("[SDK] No account with given username");
|
187
188
|
const n = JSON.parse(t[0].posting_json_metadata).profile;
|
188
189
|
let r;
|
189
190
|
try {
|
190
|
-
r = await
|
191
|
+
r = await o.hiveClient.database.call(
|
191
192
|
"get_follow_count",
|
192
193
|
[e]
|
193
194
|
);
|
194
195
|
} catch {
|
195
196
|
}
|
196
|
-
const
|
197
|
+
const a = await o.hiveClient.call(
|
197
198
|
"condenser_api",
|
198
199
|
"get_account_reputations",
|
199
200
|
[e, 1]
|
@@ -201,10 +202,10 @@ function E(e) {
|
|
201
202
|
return {
|
202
203
|
...t,
|
203
204
|
follow_stats: r,
|
204
|
-
reputation:
|
205
|
+
reputation: a[0].reputation,
|
205
206
|
profile: {
|
206
207
|
...n,
|
207
|
-
reputation:
|
208
|
+
reputation: a[0].reputation
|
208
209
|
}
|
209
210
|
};
|
210
211
|
},
|
@@ -212,20 +213,39 @@ function E(e) {
|
|
212
213
|
staleTime: 6e4
|
213
214
|
});
|
214
215
|
}
|
215
|
-
function
|
216
|
-
return
|
216
|
+
function U(e, t = 5, n = []) {
|
217
|
+
return f({
|
217
218
|
queryKey: ["accounts", "search", e, n],
|
218
219
|
enabled: !!e,
|
219
|
-
queryFn: async () => (await
|
220
|
+
queryFn: async () => (await o.hiveClient.database.call(
|
220
221
|
"lookup_accounts",
|
221
222
|
[e, t]
|
222
223
|
)).filter(
|
223
|
-
(
|
224
|
+
(a) => n.length > 0 ? !n.includes(a) : !0
|
224
225
|
)
|
225
226
|
});
|
226
227
|
}
|
227
|
-
function
|
228
|
+
function W(e) {
|
228
229
|
return f({
|
230
|
+
queryKey: ["accounts", "check-wallet-pending", e],
|
231
|
+
queryFn: async () => (await (await fetch(
|
232
|
+
o.privateApiHost + "/private-api/wallets-chkuser",
|
233
|
+
{
|
234
|
+
method: "POST",
|
235
|
+
headers: {
|
236
|
+
"Content-Type": "application/json"
|
237
|
+
},
|
238
|
+
body: JSON.stringify({
|
239
|
+
username: e
|
240
|
+
})
|
241
|
+
}
|
242
|
+
)).json()).length === 0,
|
243
|
+
enabled: !!e,
|
244
|
+
refetchOnMount: !0
|
245
|
+
});
|
246
|
+
}
|
247
|
+
function G(e) {
|
248
|
+
return y({
|
229
249
|
mutationKey: ["operations", "sign", e],
|
230
250
|
mutationFn: ({
|
231
251
|
operation: t,
|
@@ -234,7 +254,7 @@ function U(e) {
|
|
234
254
|
if (!e)
|
235
255
|
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
236
256
|
let r;
|
237
|
-
return n.split(" ").length === 12 ? r =
|
257
|
+
return n.split(" ").length === 12 ? r = l.fromLogin(e, n, "active") : _.isWif(n) ? r = l.fromString(n) : r = l.from(n), o.hiveClient.broadcast.sendOperations(
|
238
258
|
[t],
|
239
259
|
r
|
240
260
|
);
|
@@ -249,24 +269,24 @@ function F() {
|
|
249
269
|
});
|
250
270
|
});
|
251
271
|
}
|
252
|
-
const C = (e, t, n, r = null) => new Promise((
|
272
|
+
const C = (e, t, n, r = null) => new Promise((a, s) => {
|
253
273
|
var c;
|
254
274
|
(c = window.hive_keychain) == null || c.requestBroadcast(
|
255
275
|
e,
|
256
276
|
t,
|
257
277
|
n,
|
258
278
|
(i) => {
|
259
|
-
i.success || s({ message: "Operation cancelled" }),
|
279
|
+
i.success || s({ message: "Operation cancelled" }), a(i);
|
260
280
|
},
|
261
281
|
r
|
262
282
|
);
|
263
|
-
}),
|
283
|
+
}), z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
264
284
|
__proto__: null,
|
265
285
|
broadcast: C,
|
266
286
|
handshake: F
|
267
287
|
}, Symbol.toStringTag, { value: "Module" }));
|
268
|
-
function
|
269
|
-
return
|
288
|
+
function R(e, t = "Active") {
|
289
|
+
return y({
|
270
290
|
mutationKey: ["operations", "sign-keychain", e],
|
271
291
|
mutationFn: ({ operation: n }) => {
|
272
292
|
if (!e)
|
@@ -277,18 +297,18 @@ function W(e, t = "Active") {
|
|
277
297
|
}
|
278
298
|
});
|
279
299
|
}
|
280
|
-
function
|
281
|
-
return
|
300
|
+
function $(e = "/") {
|
301
|
+
return y({
|
282
302
|
mutationKey: ["operations", "sign-hivesigner", e],
|
283
303
|
mutationFn: async ({ operation: t }) => m.sendOperation(t, { callback: e }, () => {
|
284
304
|
})
|
285
305
|
});
|
286
306
|
}
|
287
|
-
function
|
288
|
-
return
|
307
|
+
function L(e, t) {
|
308
|
+
return f({
|
289
309
|
queryKey: ["hive-engine", "tokens-list", e, t],
|
290
310
|
queryFn: async () => (await (await fetch(
|
291
|
-
`${
|
311
|
+
`${o.privateApiHost}/private-api/engine-api`,
|
292
312
|
{
|
293
313
|
method: "POST",
|
294
314
|
body: JSON.stringify({
|
@@ -309,10 +329,10 @@ function R(e, t) {
|
|
309
329
|
)).json()).result
|
310
330
|
});
|
311
331
|
}
|
312
|
-
function
|
313
|
-
return
|
332
|
+
function V(e = 20) {
|
333
|
+
return q({
|
314
334
|
queryKey: ["posts", "trending-tags"],
|
315
|
-
queryFn: async ({ pageParam: { afterTag: t } }) =>
|
335
|
+
queryFn: async ({ pageParam: { afterTag: t } }) => o.hiveClient.database.call("get_trending_tags", [t, e]).then(
|
316
336
|
(n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
|
317
337
|
),
|
318
338
|
initialPageParam: { afterTag: "" },
|
@@ -323,24 +343,53 @@ function $(e = 20) {
|
|
323
343
|
refetchOnMount: !0
|
324
344
|
});
|
325
345
|
}
|
346
|
+
function D(e, t) {
|
347
|
+
return y({
|
348
|
+
mutationKey: ["analytics", t],
|
349
|
+
mutationFn: async () => {
|
350
|
+
if (!t)
|
351
|
+
throw new Error("[SDK][Analytics] – no activity type provided");
|
352
|
+
await fetch(o.plausibleHost + "/api/event", {
|
353
|
+
method: "POST",
|
354
|
+
headers: {
|
355
|
+
"Content-Type": "application/json"
|
356
|
+
},
|
357
|
+
body: JSON.stringify({
|
358
|
+
name: t,
|
359
|
+
url: window.location.href,
|
360
|
+
domain: window.location.host,
|
361
|
+
props: {
|
362
|
+
username: e
|
363
|
+
}
|
364
|
+
})
|
365
|
+
});
|
366
|
+
}
|
367
|
+
});
|
368
|
+
}
|
369
|
+
const X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
370
|
+
__proto__: null,
|
371
|
+
useRecordActivity: D
|
372
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
326
373
|
export {
|
327
|
-
|
328
|
-
|
374
|
+
o as CONFIG,
|
375
|
+
g as ConfigManager,
|
376
|
+
X as EcencyAnalytics,
|
329
377
|
w as EcencyQueriesManager,
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
378
|
+
z as Keychain,
|
379
|
+
W as checkUsernameWalletsPendingQueryOptions,
|
380
|
+
A as getAccessToken,
|
381
|
+
M as getAccountFullQueryOptions,
|
382
|
+
L as getHiveEngineTokensListQueryOptions,
|
383
|
+
I as getPostingKey,
|
335
384
|
u as getQueryClient,
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
385
|
+
J as getRefreshToken,
|
386
|
+
U as getSearchAccountsByUsernameQueryOptions,
|
387
|
+
V as getTrendingTagsQueryOptions,
|
388
|
+
p as getUser,
|
389
|
+
x as makeQueryClient,
|
390
|
+
E as useAccountUpdate,
|
391
|
+
j as useBroadcastMutation,
|
392
|
+
$ as useSignOperationByHivesigner,
|
393
|
+
G as useSignOperationByKey,
|
394
|
+
R as useSignOperationByKeychain
|
346
395
|
};
|
package/dist/index.d.ts
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare function checkUsernameWalletsPendingQueryOptions(username: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<boolean, Error, boolean, string[]>, "queryFn"> & {
|
2
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<boolean, string[], never> | undefined;
|
3
|
+
} & {
|
4
|
+
queryKey: string[] & {
|
5
|
+
[dataTagSymbol]: boolean;
|
6
|
+
[dataTagErrorSymbol]: Error;
|
7
|
+
};
|
8
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './use-record-activity';
|
@@ -0,0 +1,3 @@
|
|
1
|
+
type ActivityType = "post-created" | "post-updated" | "post-scheduled" | "draft-created";
|
2
|
+
export declare function useRecordActivity(username: string | undefined, activityType: ActivityType): import('@tanstack/react-query').UseMutationResult<void, Error, void, unknown>;
|
3
|
+
export {};
|