@ecency/sdk 1.0.30 → 1.0.31

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,10 +1,10 @@
1
- var K = Object.defineProperty;
2
- var Q = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var g = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as v, useMutation as l, useQuery as q, useInfiniteQuery as O, queryOptions as h } from "@tanstack/react-query";
1
+ var Q = Object.defineProperty;
2
+ var K = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var g = (e, t, n) => K(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { QueryClient as v, useMutation as f, useQuery as q, useInfiniteQuery as O, queryOptions as l, infiniteQueryOptions as _ } from "@tanstack/react-query";
5
5
  import { Client as k, PrivateKey as p, cryptoUtils as S } from "@hiveio/dhive";
6
- import C from "hivesigner";
7
- class _ {
6
+ import m from "hivesigner";
7
+ class b {
8
8
  constructor() {
9
9
  g(this, "length", 0);
10
10
  }
@@ -26,7 +26,7 @@ class _ {
26
26
  }
27
27
  const a = {
28
28
  privateApiHost: "https://ecency.com",
29
- storage: typeof window > "u" ? new _() : window.localStorage,
29
+ storage: typeof window > "u" ? new b() : window.localStorage,
30
30
  storagePrefix: "ecency",
31
31
  hiveClient: new k(
32
32
  [
@@ -58,7 +58,7 @@ var d;
58
58
  }
59
59
  e.setQueryClient = t;
60
60
  })(d || (d = {}));
61
- function b(e) {
61
+ function I(e) {
62
62
  let t = atob(e);
63
63
  if (t[0] === "{")
64
64
  return JSON.parse(t);
@@ -68,16 +68,16 @@ const y = (e) => {
68
68
  const t = a.storage.getItem(
69
69
  a.storagePrefix + "_user_" + e
70
70
  );
71
- return b(JSON.parse(t));
71
+ return I(JSON.parse(t));
72
72
  } catch (t) {
73
73
  console.error(t);
74
74
  return;
75
75
  }
76
- }, I = (e) => y(e) && y(e).accessToken, A = (e) => y(e) && y(e).postingKey, N = (e) => y(e) && y(e).refreshToken;
76
+ }, T = (e) => y(e) && y(e).accessToken, A = (e) => y(e) && y(e).postingKey, x = (e) => y(e) && y(e).refreshToken;
77
77
  function D(e = [], t, n) {
78
- return l({
78
+ return f({
79
79
  mutationKey: [...e, t],
80
- mutationFn: async (i) => {
80
+ mutationFn: async (r) => {
81
81
  if (!t)
82
82
  throw new Error(
83
83
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
@@ -86,15 +86,15 @@ function D(e = [], t, n) {
86
86
  if (o) {
87
87
  const c = p.fromString(o);
88
88
  return a.hiveClient.broadcast.sendOperations(
89
- n(i),
89
+ n(r),
90
90
  c
91
91
  );
92
92
  }
93
- let s = I(t);
93
+ let s = T(t);
94
94
  if (s)
95
- return (await new C.Client({
95
+ return (await new m.Client({
96
96
  accessToken: s
97
- }).broadcast(n(i))).result;
97
+ }).broadcast(n(r))).result;
98
98
  throw new Error(
99
99
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
100
100
  );
@@ -117,37 +117,37 @@ function H() {
117
117
  const u = () => a.queryClient;
118
118
  var w;
119
119
  ((e) => {
120
- function t(r) {
121
- return u().getQueryData(r);
120
+ function t(i) {
121
+ return u().getQueryData(i);
122
122
  }
123
123
  e.getQueryData = t;
124
- function n(r) {
125
- return u().getQueryData(r);
124
+ function n(i) {
125
+ return u().getQueryData(i);
126
126
  }
127
127
  e.getInfiniteQueryData = n;
128
- async function i(r) {
129
- return await u().prefetchQuery(r), t(r.queryKey);
128
+ async function r(i) {
129
+ return await u().prefetchQuery(i), t(i.queryKey);
130
130
  }
131
- e.prefetchQuery = i;
132
- async function o(r) {
133
- return await u().prefetchInfiniteQuery(r), n(r.queryKey);
131
+ e.prefetchQuery = r;
132
+ async function o(i) {
133
+ return await u().prefetchInfiniteQuery(i), n(i.queryKey);
134
134
  }
135
135
  e.prefetchInfiniteQuery = o;
136
- function s(r) {
136
+ function s(i) {
137
137
  return {
138
- prefetch: () => i(r),
139
- getData: () => t(r.queryKey),
140
- useClientQuery: () => q(r),
141
- fetchAndGet: () => u().fetchQuery(r)
138
+ prefetch: () => r(i),
139
+ getData: () => t(i.queryKey),
140
+ useClientQuery: () => q(i),
141
+ fetchAndGet: () => u().fetchQuery(i)
142
142
  };
143
143
  }
144
144
  e.generateClientServerQuery = s;
145
- function c(r) {
145
+ function c(i) {
146
146
  return {
147
- prefetch: () => o(r),
148
- getData: () => n(r.queryKey),
149
- useClientQuery: () => O(r),
150
- fetchAndGet: () => u().fetchInfiniteQuery(r)
147
+ prefetch: () => o(i),
148
+ getData: () => n(i.queryKey),
149
+ useClientQuery: () => O(i),
150
+ fetchAndGet: () => u().fetchInfiniteQuery(i)
151
151
  };
152
152
  }
153
153
  e.generateClientServerInfiniteQuery = c;
@@ -175,8 +175,8 @@ function J(e) {
175
175
  ]
176
176
  );
177
177
  }
178
- function x(e) {
179
- return h({
178
+ function E(e) {
179
+ return l({
180
180
  queryKey: ["get-account-full", e],
181
181
  queryFn: async () => {
182
182
  if (!e)
@@ -185,9 +185,9 @@ function x(e) {
185
185
  if (!t[0])
186
186
  throw new Error("[SDK] No account with given username");
187
187
  const n = JSON.parse(t[0].posting_json_metadata).profile;
188
- let i;
188
+ let r;
189
189
  try {
190
- i = await a.hiveClient.database.call(
190
+ r = await a.hiveClient.database.call(
191
191
  "get_follow_count",
192
192
  [e]
193
193
  );
@@ -200,7 +200,7 @@ function x(e) {
200
200
  );
201
201
  return {
202
202
  ...t,
203
- follow_stats: i,
203
+ follow_stats: r,
204
204
  reputation: o[0].reputation,
205
205
  profile: {
206
206
  ...n,
@@ -212,8 +212,8 @@ function x(e) {
212
212
  staleTime: 6e4
213
213
  });
214
214
  }
215
- function E(e, t = 5, n = []) {
216
- return h({
215
+ function M(e, t = 5, n = []) {
216
+ return l({
217
217
  queryKey: ["accounts", "search", e, n],
218
218
  enabled: !!e,
219
219
  queryFn: async () => (await a.hiveClient.database.call(
@@ -225,7 +225,7 @@ function E(e, t = 5, n = []) {
225
225
  });
226
226
  }
227
227
  function U(e) {
228
- return l({
228
+ return f({
229
229
  mutationKey: ["operations", "sign", e],
230
230
  mutationFn: ({
231
231
  operation: t,
@@ -233,10 +233,10 @@ function U(e) {
233
233
  }) => {
234
234
  if (!e)
235
235
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
236
- let i;
237
- return n.split(" ").length === 12 ? i = p.fromLogin(e, n, "active") : S.isWif(n) ? i = p.fromString(n) : i = p.from(n), a.hiveClient.broadcast.sendOperations(
236
+ let r;
237
+ return n.split(" ").length === 12 ? r = p.fromLogin(e, n, "active") : S.isWif(n) ? r = p.fromString(n) : r = p.from(n), a.hiveClient.broadcast.sendOperations(
238
238
  [t],
239
- i
239
+ r
240
240
  );
241
241
  }
242
242
  });
@@ -249,43 +249,43 @@ function F() {
249
249
  });
250
250
  });
251
251
  }
252
- const m = (e, t, n, i = null) => new Promise((o, s) => {
252
+ const C = (e, t, n, r = null) => new Promise((o, s) => {
253
253
  var c;
254
254
  (c = window.hive_keychain) == null || c.requestBroadcast(
255
255
  e,
256
256
  t,
257
257
  n,
258
- (r) => {
259
- r.success || s({ message: "Operation cancelled" }), o(r);
258
+ (i) => {
259
+ i.success || s({ message: "Operation cancelled" }), o(i);
260
260
  },
261
- i
261
+ r
262
262
  );
263
263
  }), G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
264
264
  __proto__: null,
265
- broadcast: m,
265
+ broadcast: C,
266
266
  handshake: F
267
267
  }, Symbol.toStringTag, { value: "Module" }));
268
- function M(e, t = "Active") {
269
- return l({
268
+ function W(e, t = "Active") {
269
+ return f({
270
270
  mutationKey: ["operations", "sign-keychain", e],
271
271
  mutationFn: ({ operation: n }) => {
272
272
  if (!e)
273
273
  throw new Error(
274
274
  "[SDK][Keychain] – cannot sign operation with anon user"
275
275
  );
276
- return m(e, [n], t);
276
+ return C(e, [n], t);
277
277
  }
278
278
  });
279
279
  }
280
- function W(e = "/") {
281
- return l({
280
+ function z(e = "/") {
281
+ return f({
282
282
  mutationKey: ["operations", "sign-hivesigner", e],
283
- mutationFn: async ({ operation: t }) => C.sendOperation(t, { callback: e }, () => {
283
+ mutationFn: async ({ operation: t }) => m.sendOperation(t, { callback: e }, () => {
284
284
  })
285
285
  });
286
286
  }
287
- function z(e, t) {
288
- return h({
287
+ function R(e, t) {
288
+ return l({
289
289
  queryKey: ["hive-engine", "tokens-list", e, t],
290
290
  queryFn: async () => (await (await fetch(
291
291
  `${a.privateApiHost}/private-api/engine-api`,
@@ -309,23 +309,38 @@ function z(e, t) {
309
309
  )).json()).result
310
310
  });
311
311
  }
312
+ function $(e = 20) {
313
+ return _({
314
+ queryKey: ["posts", "trending-tags"],
315
+ queryFn: async ({ pageParam: { afterTag: t } }) => a.hiveClient.database.call("get_trending_tags", [t, e]).then(
316
+ (n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
317
+ ),
318
+ initialPageParam: { afterTag: "" },
319
+ getNextPageParam: (t) => ({
320
+ afterTag: t == null ? void 0 : t[(t == null ? void 0 : t.length) - 1]
321
+ }),
322
+ staleTime: 1 / 0,
323
+ refetchOnMount: !0
324
+ });
325
+ }
312
326
  export {
313
327
  a as CONFIG,
314
328
  d as ConfigManager,
315
329
  w as EcencyQueriesManager,
316
330
  G as Keychain,
317
- I as getAccessToken,
318
- x as getAccountFullQueryOptions,
319
- z as getHiveEngineTokensListQueryOptions,
331
+ T as getAccessToken,
332
+ E as getAccountFullQueryOptions,
333
+ R as getHiveEngineTokensListQueryOptions,
320
334
  A as getPostingKey,
321
335
  u as getQueryClient,
322
- N as getRefreshToken,
323
- E as getSearchAccountsByUsernameQueryOptions,
336
+ x as getRefreshToken,
337
+ M as getSearchAccountsByUsernameQueryOptions,
338
+ $ as getTrendingTagsQueryOptions,
324
339
  y as getUser,
325
340
  H as makeQueryClient,
326
341
  J as useAccountUpdate,
327
342
  D as useBroadcastMutation,
328
- W as useSignOperationByHivesigner,
343
+ z as useSignOperationByHivesigner,
329
344
  U as useSignOperationByKey,
330
- M as useSignOperationByKeychain
345
+ W as useSignOperationByKeychain
331
346
  };
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './modules/operations';
3
3
  export * from './modules/core';
4
4
  export * from './modules/hive-engine';
5
5
  export * from './modules/keychain';
6
+ export * from './modules/posts';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.30",
4
+ "version": "1.0.31",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",