hive-react-kit 0.9.0 → 0.9.2

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.
@@ -2,6 +2,19 @@ import { Follower, Following, UserProfileResponse, Account } from "@/types/user"
2
2
  import { Post } from "@/types/post";
3
3
  import type { Poll } from "@/types/poll";
4
4
  import type { PendingAuthorRow, PendingCurationRow } from "@/types/reward";
5
+ /** Default "parent" container for getUserSnaps (kept for backwards compatibility). */
6
+ export declare const DEFAULT_SNAP_PARENT = "peak.snaps";
7
+ /**
8
+ * Known snap-container parents supported by UserDetailProfile's segmented
9
+ * control. Values are the account names queried via `?parent=<account>`.
10
+ */
11
+ export declare const SNAP_SUBTYPE_PARENTS: {
12
+ readonly snaps: "peak.snaps";
13
+ readonly ecency: "ecency.waves";
14
+ readonly threads: "leothreads";
15
+ readonly liketu: "liketu.moments";
16
+ };
17
+ export type SnapSubType = keyof typeof SNAP_SUBTYPE_PARENTS;
5
18
  declare class UserService {
6
19
  private readonly HIVE_API_URL;
7
20
  /** Central fetch wrapper — threads AbortSignal to every network request */
@@ -19,10 +32,15 @@ declare class UserService {
19
32
  getUserComments(username: string, limit?: number, startAuthor?: string, startPermlink?: string, signal?: AbortSignal): Promise<Post[]>;
20
33
  getUserReplies(username: string, limit?: number, startAuthor?: string, startPermlink?: string, signal?: AbortSignal): Promise<Post[]>;
21
34
  /**
22
- * Fetch snap references for a user from PeakD API.
23
- * Returns { id, author, permlink }[] with cursor for pagination.
35
+ * Fetch snap references for a user from the hreplier API.
36
+ * Returns `{ id, author, permlink }[]`. The endpoint does not support
37
+ * cursor-based pagination — it returns a single batch, so `startId`
38
+ * is accepted for call-site compatibility but ignored.
39
+ *
40
+ * `parent` selects the container account: `peak.snaps` (Snaps), `ecency.waves`
41
+ * (Ecency waves), `leothreads` (Threads), `liketu.moments` (Liketu moments).
24
42
  */
25
- getSnapReferences(username: string, startId?: number, signal?: AbortSignal): Promise<{
43
+ getSnapReferences(username: string, _startId?: number, signal?: AbortSignal, parent?: string): Promise<{
26
44
  id: number;
27
45
  author: string;
28
46
  permlink: string;
@@ -33,11 +51,24 @@ declare class UserService {
33
51
  */
34
52
  private batchGetPosts;
35
53
  /**
36
- * Fetch snaps for a user using PeakD API + Hive bridge.get_post.
37
- * Step 1: Get snap references from PeakD (with pagination via startId)
38
- * Step 2: Batch fetch full post data via bridge.get_post
54
+ * Fetch a page of snaps for a user via the hreplier API + Hive bridge.get_post.
55
+ *
56
+ * The hreplier endpoint returns the full snap-reference list in one shot and
57
+ * has no server-side pagination, so we cache it per (username, parent) and
58
+ * slice client-side. `startId` is repurposed as the slice offset (20-item
59
+ * pages):
60
+ * - undefined / 0 → first 20 refs
61
+ * - 20, 40, … → subsequent pages
62
+ * `nextStartId` is the next offset to request, or null when exhausted.
63
+ *
64
+ * `parent` selects the container account — see SNAP_SUBTYPE_PARENTS
65
+ * (defaults to `peak.snaps`). Cache is keyed per parent so switching
66
+ * segments never collides.
67
+ *
68
+ * Only the current slice is materialised via bridge.get_post, so switching
69
+ * pages stays snappy.
39
70
  */
40
- getUserSnaps(username: string, startId?: number, observer?: string, signal?: AbortSignal): Promise<{
71
+ getUserSnaps(username: string, startId?: number, observer?: string, signal?: AbortSignal, parent?: string): Promise<{
41
72
  snaps: Post[];
42
73
  nextStartId: number | null;
43
74
  }>;
@@ -73,7 +104,90 @@ declare class UserService {
73
104
  }>;
74
105
  /** Generic RPC call helper */
75
106
  private rpcCall;
107
+ /**
108
+ * Fetch daily growth analytics for an account over a `days` window
109
+ * (typically 7 or 30). Walks `get_account_history` backwards in pages of
110
+ * 1000 ops until the window cutoff is passed, buckets reward / power-up /
111
+ * power-down operations by UTC day, and reconstructs the cumulative HP
112
+ * trend by working back from the account's current effective HP.
113
+ *
114
+ * Reference: hivelytics (mrtats/hivelytics) — buildChartDays / addChartBucket / renderCharts.
115
+ */
116
+ getGrowthAnalytics(username: string, days?: number, onProgress?: (partial: GrowthAnalyticsResult) => void, signal?: AbortSignal): Promise<GrowthAnalyticsResult>;
117
+ private buildGrowthDays;
118
+ private initGrowthMap;
119
+ private dateKeyFromMs;
120
+ private vestsToHp;
121
+ private effectiveHp;
122
+ private buildGrowthResult;
76
123
  userAvatar(username: string): string;
77
124
  }
125
+ export interface GrowthDay {
126
+ key: string;
127
+ label: string;
128
+ }
129
+ export interface GrowthBucket {
130
+ author: {
131
+ hp: number;
132
+ hive: number;
133
+ hbd: number;
134
+ };
135
+ curation: {
136
+ hp: number;
137
+ hive: number;
138
+ hbd: number;
139
+ };
140
+ witness: {
141
+ hp: number;
142
+ hive: number;
143
+ hbd: number;
144
+ };
145
+ benefactor: {
146
+ hp: number;
147
+ hive: number;
148
+ hbd: number;
149
+ };
150
+ hpDelta: number;
151
+ powerUp: number;
152
+ powerDown: number;
153
+ powerDownTo: number;
154
+ }
155
+ export interface GrowthDailyPoint {
156
+ key: string;
157
+ label: string;
158
+ cumulativeHp: number;
159
+ hpDelta: number;
160
+ powerUp: number;
161
+ powerDown: number;
162
+ powerDownTo: number;
163
+ authorHp: number;
164
+ curationHp: number;
165
+ witnessHp: number;
166
+ benefactorHp: number;
167
+ authorUsd: number;
168
+ curationUsd: number;
169
+ witnessUsd: number;
170
+ benefactorUsd: number;
171
+ }
172
+ export interface GrowthAnalyticsResult {
173
+ days: GrowthDay[];
174
+ series: GrowthDailyPoint[];
175
+ currentHp: number;
176
+ startHp: number;
177
+ hpDelta: number;
178
+ hivePrice: number;
179
+ totals: {
180
+ authorHp: number;
181
+ curationHp: number;
182
+ witnessHp: number;
183
+ benefactorHp: number;
184
+ powerUp: number;
185
+ powerDown: number;
186
+ authorUsd: number;
187
+ curationUsd: number;
188
+ witnessUsd: number;
189
+ benefactorUsd: number;
190
+ };
191
+ }
78
192
  export declare const userService: UserService;
79
193
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hive-react-kit",
3
3
  "private": false,
4
- "version": "0.9.0",
4
+ "version": "0.9.2",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.esm.js",