@ecency/sdk 1.0.37 → 1.0.39

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,12 +1,12 @@
1
- var Q = Object.defineProperty;
2
- var b = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var w = (e, t, n) => b(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as C, useMutation as l, useQuery as _, useInfiniteQuery as K, queryOptions as c, infiniteQueryOptions as S } from "@tanstack/react-query";
5
- import { Client as k, PrivateKey as h, cryptoUtils as T, RCAPI as j } from "@hiveio/dhive";
6
- import g from "hivesigner";
7
- class A {
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
- w(this, "length", 0);
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 A() : window.localStorage,
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 C(),
52
+ queryClient: new q(),
53
53
  plausibleHost: "https://pl.ecency.com"
54
54
  };
55
- var v;
55
+ var O;
56
56
  ((e) => {
57
57
  function t(n) {
58
58
  o.queryClient = n;
59
59
  }
60
60
  e.setQueryClient = t;
61
- })(v || (v = {}));
62
- function I(e) {
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 p = (e) => {
67
+ const l = (e) => {
68
68
  try {
69
69
  const t = o.storage.getItem(
70
70
  o.storagePrefix + "_user_" + e
71
71
  );
72
- return I(JSON.parse(t));
72
+ return D(JSON.parse(t));
73
73
  } catch (t) {
74
74
  console.error(t);
75
75
  return;
76
76
  }
77
- }, O = (e) => p(e) && p(e).accessToken, D = (e) => p(e) && p(e).postingKey, W = (e) => p(e) && p(e).refreshToken;
78
- function F(e = [], t, n) {
79
- return l({
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 = D(t);
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 = O(t);
94
+ let u = f(t);
95
95
  if (u)
96
- return (await new g.Client({
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 C({
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 m;
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: () => _(i),
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: () => K(i),
150
+ useClientQuery: () => _(i),
151
151
  fetchAndGet: () => s().fetchInfiniteQuery(i)
152
152
  };
153
153
  }
154
154
  e.generateClientServerInfiniteQuery = y;
155
- })(m || (m = {}));
156
- function G(e) {
157
- return F(
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 V(e) {
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 L(e, t = 5, n = []) {
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 X(e) {
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 Y(e) {
248
- return l({
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") : T.isWif(n) ? r = h.fromString(n) : r = h.from(n), o.hiveClient.broadcast.sendOperations(
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 P() {
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 q = (e, t, n, r = null) => new Promise((a, u) => {
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
- }), Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
283
+ }), ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
284
284
  __proto__: null,
285
- broadcast: q,
286
- handshake: P
285
+ broadcast: S,
286
+ handshake: N
287
287
  }, Symbol.toStringTag, { value: "Module" }));
288
- function ee(e, t = "Active") {
289
- return l({
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 q(e, [n], t);
296
+ return S(e, [n], t);
297
297
  }
298
298
  });
299
299
  }
300
- function te(e = "/") {
301
- return l({
300
+ function ne(e = "/") {
301
+ return p({
302
302
  mutationKey: ["operations", "sign-hivesigner", e],
303
- mutationFn: async ({ operation: t }) => g.sendOperation(t, { callback: e }, () => {
303
+ mutationFn: async ({ operation: t }) => w.sendOperation(t, { callback: e }, () => {
304
304
  })
305
305
  });
306
306
  }
307
- function ne(e, t) {
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 re(e = 20) {
333
- return S({
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 M(e, t) {
347
- return l({
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 ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
464
+ const ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
370
465
  __proto__: null,
371
- useRecordActivity: M
466
+ useRecordActivity: H
372
467
  }, Symbol.toStringTag, { value: "Module" }));
373
- function N(e, t) {
468
+ function J(e, t) {
374
469
  return c({
375
470
  queryKey: ["integrations", "hivesigner", "decode-memo", e],
376
471
  queryFn: async () => {
377
- const n = O(e);
472
+ const n = f(e);
378
473
  if (n)
379
- return new g.Client({
474
+ return new w.Client({
380
475
  accessToken: n
381
476
  }).decode(t);
382
477
  }
383
478
  });
384
479
  }
385
- const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
480
+ const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
386
481
  __proto__: null,
387
- getDecodeMemoQueryOptions: N
388
- }, Symbol.toStringTag, { value: "Module" })), H = {
389
- queries: B
482
+ getDecodeMemoQueryOptions: J
483
+ }, Symbol.toStringTag, { value: "Module" })), B = {
484
+ queries: M
390
485
  };
391
- function d(e) {
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 = H.queries.getDecodeMemoQueryOptions(
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 E(e) {
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
- d(e)
518
+ g(e)
424
519
  );
425
520
  const t = s().getQueryData(
426
- d(e).queryKey
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 J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
535
+ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
441
536
  __proto__: null,
442
- getAccountTokenQueryOptions: d,
443
- getAccountVideosQueryOptions: E
444
- }, Symbol.toStringTag, { value: "Module" })), oe = {
445
- queries: J
537
+ getAccountTokenQueryOptions: g,
538
+ getAccountVideosQueryOptions: x
539
+ }, Symbol.toStringTag, { value: "Module" })), ue = {
540
+ queries: E
446
541
  };
447
- function ae() {
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 se(e) {
552
+ function ye(e) {
458
553
  return c({
459
554
  queryKey: ["resource-credits", "account", e],
460
- queryFn: async () => new j(o.hiveClient).findRCAccounts([e]),
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
- v as ConfigManager,
467
- ie as EcencyAnalytics,
468
- m as EcencyQueriesManager,
469
- H as HiveSignerIntegration,
470
- Z as Keychain,
471
- oe as ThreeSpeakIntegration,
472
- X as checkUsernameWalletsPendingQueryOptions,
473
- O as getAccessToken,
474
- V as getAccountFullQueryOptions,
475
- se as getAccountRcQueryOptions,
476
- ne as getHiveEngineTokensListQueryOptions,
477
- D as getPostingKey,
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
- ae as getRcStatsQueryOptions,
480
- W as getRefreshToken,
481
- L as getSearchAccountsByUsernameQueryOptions,
482
- re as getTrendingTagsQueryOptions,
483
- p as getUser,
484
- $ as makeQueryClient,
485
- G as useAccountUpdate,
486
- F as useBroadcastMutation,
487
- te as useSignOperationByHivesigner,
488
- Y as useSignOperationByKey,
489
- ee as useSignOperationByKeychain
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
  };
@@ -1,3 +1,3 @@
1
- type ActivityType = "post-created" | "post-updated" | "post-scheduled" | "draft-created" | "video-published" | "signed-up-with-wallets" | "signed-up-with-email";
1
+ type ActivityType = "post-created" | "post-updated" | "post-scheduled" | "draft-created" | "video-published" | "legacy-post-created" | "legacy-post-updated" | "legacy-post-scheduled" | "legacy-draft-created" | "legacy-video-published" | "perks-points-by-qr" | "perks-account-boost" | "perks-promote" | "perks-boost-plus" | "signed-up-with-wallets" | "signed-up-with-email";
2
2
  export declare function useRecordActivity(username: string | undefined, activityType: ActivityType): import('@tanstack/react-query').UseMutationResult<void, Error, void, unknown>;
3
3
  export {};
@@ -1,2 +1,3 @@
1
1
  export * from './queries';
2
2
  export * from './types';
3
+ export * from './mutations';
@@ -0,0 +1,5 @@
1
+ import { Fragment } from '../types';
2
+ export declare function useAddFragment(username: string): import('@tanstack/react-query').UseMutationResult<Fragment, Error, {
3
+ title: string;
4
+ body: string;
5
+ }, unknown>;
@@ -0,0 +1,5 @@
1
+ import { Fragment } from '../types';
2
+ export declare function useEditFragment(username: string, fragmentId: string): import('@tanstack/react-query').UseMutationResult<Fragment, Error, {
3
+ title: string;
4
+ body: string;
5
+ }, unknown>;
@@ -0,0 +1,3 @@
1
+ export * from './add-fragment';
2
+ export * from './edit-fragment';
3
+ export * from './remove-fragment';
@@ -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
+ };
@@ -1 +1,2 @@
1
1
  export * from './get-trending-tags-query-options';
2
+ export * from './get-fragments-query-options';
@@ -0,0 +1,7 @@
1
+ export interface Fragment {
2
+ id: string;
3
+ title: string;
4
+ body: string;
5
+ created: string;
6
+ modified: string;
7
+ }
@@ -1 +1,2 @@
1
1
  export * from './trending-tag';
2
+ export * from './fragment';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.37",
4
+ "version": "1.0.39",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",