@v3finance/core-sdk 0.4.0 → 0.5.0

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/README.md +18 -14
  3. package/dist/cjs/client.d.ts +27 -34
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +69 -0
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/core/gated.d.ts +12 -10
  8. package/dist/cjs/core/gated.d.ts.map +1 -1
  9. package/dist/cjs/core/gated.js +12 -10
  10. package/dist/cjs/core/gated.js.map +1 -1
  11. package/dist/cjs/core/http.d.ts +18 -0
  12. package/dist/cjs/core/http.d.ts.map +1 -1
  13. package/dist/cjs/core/http.js +11 -1
  14. package/dist/cjs/core/http.js.map +1 -1
  15. package/dist/cjs/core/pagination.d.ts +11 -9
  16. package/dist/cjs/core/pagination.d.ts.map +1 -1
  17. package/dist/cjs/core/pagination.js +11 -9
  18. package/dist/cjs/core/pagination.js.map +1 -1
  19. package/dist/cjs/generated/operations.d.ts +210 -2
  20. package/dist/cjs/generated/operations.d.ts.map +1 -1
  21. package/dist/cjs/generated/operations.js +212 -4
  22. package/dist/cjs/generated/operations.js.map +1 -1
  23. package/dist/cjs/generated/types.d.ts +935 -93
  24. package/dist/cjs/generated/types.d.ts.map +1 -1
  25. package/dist/cjs/index.d.ts +6 -6
  26. package/dist/cjs/index.d.ts.map +1 -1
  27. package/dist/cjs/index.js.map +1 -1
  28. package/dist/cjs/resources/addresses.d.ts +91 -4
  29. package/dist/cjs/resources/addresses.d.ts.map +1 -1
  30. package/dist/cjs/resources/addresses.js +55 -3
  31. package/dist/cjs/resources/addresses.js.map +1 -1
  32. package/dist/cjs/resources/admin.d.ts +32 -1
  33. package/dist/cjs/resources/admin.d.ts.map +1 -1
  34. package/dist/cjs/resources/admin.js +45 -0
  35. package/dist/cjs/resources/admin.js.map +1 -1
  36. package/dist/cjs/resources/approvals.d.ts +30 -2
  37. package/dist/cjs/resources/approvals.d.ts.map +1 -1
  38. package/dist/cjs/resources/approvals.js.map +1 -1
  39. package/dist/cjs/resources/balances.d.ts +14 -7
  40. package/dist/cjs/resources/balances.d.ts.map +1 -1
  41. package/dist/cjs/resources/balances.js +10 -4
  42. package/dist/cjs/resources/balances.js.map +1 -1
  43. package/dist/cjs/resources/categories.d.ts +20 -6
  44. package/dist/cjs/resources/categories.d.ts.map +1 -1
  45. package/dist/cjs/resources/categories.js +19 -7
  46. package/dist/cjs/resources/categories.js.map +1 -1
  47. package/dist/cjs/resources/counterparties.d.ts +52 -6
  48. package/dist/cjs/resources/counterparties.d.ts.map +1 -1
  49. package/dist/cjs/resources/counterparties.js +24 -0
  50. package/dist/cjs/resources/counterparties.js.map +1 -1
  51. package/dist/cjs/resources/history.d.ts +227 -26
  52. package/dist/cjs/resources/history.d.ts.map +1 -1
  53. package/dist/cjs/resources/history.js +46 -0
  54. package/dist/cjs/resources/history.js.map +1 -1
  55. package/dist/cjs/resources/me.d.ts +17 -1
  56. package/dist/cjs/resources/me.d.ts.map +1 -1
  57. package/dist/cjs/resources/me.js +19 -0
  58. package/dist/cjs/resources/me.js.map +1 -1
  59. package/dist/cjs/resources/members.d.ts +21 -1
  60. package/dist/cjs/resources/members.d.ts.map +1 -1
  61. package/dist/cjs/resources/members.js +15 -0
  62. package/dist/cjs/resources/members.js.map +1 -1
  63. package/dist/cjs/resources/operations.d.ts +179 -4
  64. package/dist/cjs/resources/operations.d.ts.map +1 -1
  65. package/dist/cjs/resources/operations.js +192 -2
  66. package/dist/cjs/resources/operations.js.map +1 -1
  67. package/dist/cjs/resources/registries.d.ts +19 -2
  68. package/dist/cjs/resources/registries.d.ts.map +1 -1
  69. package/dist/cjs/resources/registries.js +16 -0
  70. package/dist/cjs/resources/registries.js.map +1 -1
  71. package/dist/cjs/version.d.ts +1 -1
  72. package/dist/cjs/version.js +1 -1
  73. package/dist/esm/client.d.ts +27 -34
  74. package/dist/esm/client.d.ts.map +1 -1
  75. package/dist/esm/client.js +69 -0
  76. package/dist/esm/client.js.map +1 -1
  77. package/dist/esm/core/gated.d.ts +12 -10
  78. package/dist/esm/core/gated.d.ts.map +1 -1
  79. package/dist/esm/core/gated.js +12 -10
  80. package/dist/esm/core/gated.js.map +1 -1
  81. package/dist/esm/core/http.d.ts +18 -0
  82. package/dist/esm/core/http.d.ts.map +1 -1
  83. package/dist/esm/core/http.js +11 -1
  84. package/dist/esm/core/http.js.map +1 -1
  85. package/dist/esm/core/pagination.d.ts +11 -9
  86. package/dist/esm/core/pagination.d.ts.map +1 -1
  87. package/dist/esm/core/pagination.js +11 -9
  88. package/dist/esm/core/pagination.js.map +1 -1
  89. package/dist/esm/generated/operations.d.ts +210 -2
  90. package/dist/esm/generated/operations.d.ts.map +1 -1
  91. package/dist/esm/generated/operations.js +212 -4
  92. package/dist/esm/generated/operations.js.map +1 -1
  93. package/dist/esm/generated/types.d.ts +935 -93
  94. package/dist/esm/generated/types.d.ts.map +1 -1
  95. package/dist/esm/index.d.ts +6 -6
  96. package/dist/esm/index.d.ts.map +1 -1
  97. package/dist/esm/index.js.map +1 -1
  98. package/dist/esm/resources/addresses.d.ts +91 -4
  99. package/dist/esm/resources/addresses.d.ts.map +1 -1
  100. package/dist/esm/resources/addresses.js +55 -3
  101. package/dist/esm/resources/addresses.js.map +1 -1
  102. package/dist/esm/resources/admin.d.ts +32 -1
  103. package/dist/esm/resources/admin.d.ts.map +1 -1
  104. package/dist/esm/resources/admin.js +45 -0
  105. package/dist/esm/resources/admin.js.map +1 -1
  106. package/dist/esm/resources/approvals.d.ts +30 -2
  107. package/dist/esm/resources/approvals.d.ts.map +1 -1
  108. package/dist/esm/resources/approvals.js.map +1 -1
  109. package/dist/esm/resources/balances.d.ts +14 -7
  110. package/dist/esm/resources/balances.d.ts.map +1 -1
  111. package/dist/esm/resources/balances.js +10 -4
  112. package/dist/esm/resources/balances.js.map +1 -1
  113. package/dist/esm/resources/categories.d.ts +20 -6
  114. package/dist/esm/resources/categories.d.ts.map +1 -1
  115. package/dist/esm/resources/categories.js +19 -7
  116. package/dist/esm/resources/categories.js.map +1 -1
  117. package/dist/esm/resources/counterparties.d.ts +52 -6
  118. package/dist/esm/resources/counterparties.d.ts.map +1 -1
  119. package/dist/esm/resources/counterparties.js +24 -0
  120. package/dist/esm/resources/counterparties.js.map +1 -1
  121. package/dist/esm/resources/history.d.ts +227 -26
  122. package/dist/esm/resources/history.d.ts.map +1 -1
  123. package/dist/esm/resources/history.js +46 -0
  124. package/dist/esm/resources/history.js.map +1 -1
  125. package/dist/esm/resources/me.d.ts +17 -1
  126. package/dist/esm/resources/me.d.ts.map +1 -1
  127. package/dist/esm/resources/me.js +19 -0
  128. package/dist/esm/resources/me.js.map +1 -1
  129. package/dist/esm/resources/members.d.ts +21 -1
  130. package/dist/esm/resources/members.d.ts.map +1 -1
  131. package/dist/esm/resources/members.js +15 -0
  132. package/dist/esm/resources/members.js.map +1 -1
  133. package/dist/esm/resources/operations.d.ts +179 -4
  134. package/dist/esm/resources/operations.d.ts.map +1 -1
  135. package/dist/esm/resources/operations.js +192 -2
  136. package/dist/esm/resources/operations.js.map +1 -1
  137. package/dist/esm/resources/registries.d.ts +19 -2
  138. package/dist/esm/resources/registries.d.ts.map +1 -1
  139. package/dist/esm/resources/registries.js +16 -0
  140. package/dist/esm/resources/registries.js.map +1 -1
  141. package/dist/esm/version.d.ts +1 -1
  142. package/dist/esm/version.js +1 -1
  143. package/docs/concepts.md +13 -11
  144. package/docs/errors.md +73 -5
  145. package/package.json +1 -1
  146. package/src/client.ts +40 -0
  147. package/src/core/gated.ts +12 -10
  148. package/src/core/http.ts +30 -1
  149. package/src/core/pagination.ts +11 -9
  150. package/src/generated/operations.ts +212 -4
  151. package/src/generated/types.ts +979 -95
  152. package/src/index.ts +15 -1
  153. package/src/resources/addresses.ts +102 -4
  154. package/src/resources/admin.ts +59 -0
  155. package/src/resources/approvals.ts +30 -2
  156. package/src/resources/balances.ts +14 -7
  157. package/src/resources/categories.ts +19 -5
  158. package/src/resources/counterparties.ts +59 -5
  159. package/src/resources/history.ts +238 -27
  160. package/src/resources/me.ts +22 -0
  161. package/src/resources/members.ts +30 -0
  162. package/src/resources/operations.ts +264 -5
  163. package/src/resources/registries.ts +26 -3
  164. package/src/version.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import { seg, type HttpClient } from '../core/http.js'
2
- import type { Page, PageParams } from '../core/pagination.js'
3
- import type { HistoryItem } from '../generated/types.js'
2
+ import type { PageParams } from '../core/pagination.js'
3
+ import type { HistoryResponse, HistorySummary } from '../generated/types.js'
4
4
 
5
5
  /**
6
6
  * One feed of operations: incoming and outgoing together.
@@ -15,10 +15,11 @@ import type { HistoryItem } from '../generated/types.js'
15
15
  *
16
16
  * One value short of `TransactionStatus`, which is the right set for reading
17
17
  * a transfer: `submitted` is missing here. It is a legacy status — still the
18
- * column default in the schema, so old rows carry it — and the endpoint's
19
- * enum does not accept it, so filtering by it is a 400 rather than an empty
20
- * page. Hence a separate type: taking the reader's union would have the
21
- * package suggest a value its own filter rejects.
18
+ * column default in the schema, so old rows carry it, and `HistoryOutItem`
19
+ * can report it — but the filter does not accept it, so filtering by it is a
20
+ * 400 `INVALID_FILTER_VALUE` rather than an empty page. Hence a separate
21
+ * type: taking the reader's union would have the package suggest a value its
22
+ * own filter rejects.
22
23
  */
23
24
  export type HistoryStatusFilter =
24
25
  | 'awaiting_approval'
@@ -28,39 +29,202 @@ export type HistoryStatusFilter =
28
29
  | 'rejected'
29
30
  | 'cancelled'
30
31
 
31
- export interface HistoryParams extends PageParams {
32
- direction?: 'in' | 'out' | undefined
32
+ /**
33
+ * AML levels the feed can be filtered by. `unchecked` selects the operations
34
+ * nobody checked (`amlLevel: null`) — which is NOT "clean", so it has to be
35
+ * asked for by name.
36
+ */
37
+ export type HistoryAmlLevelFilter = 'critical' | 'high' | 'medium' | 'low' | 'minimal' | 'unchecked'
38
+
39
+ export type OperationRelationType = 'refund' | 'reversal' | 'correction' | 'replacement'
40
+
41
+ /** One value, or several — sent as one comma-separated value. */
42
+ type OneOrMany<T> = T | readonly T[]
43
+
44
+ /**
45
+ * The filters `list()` and `summary()` share.
46
+ *
47
+ * A multi-value filter takes a string or an array; an array goes out as one
48
+ * comma-separated value — OR within the filter, AND between filters, at most
49
+ * 50 values (more is 400 `TOO_MANY_VALUES`). An unknown value of an
50
+ * enumeration (`direction`, `status`, `flowType`, `amlLevel`,
51
+ * `relationType`…) is 400 `INVALID_FILTER_VALUE`, with `details.param`,
52
+ * `details.invalid` and `details.allowed`.
53
+ *
54
+ * `<name>Not` means "none of": an operation that has NO value there is kept,
55
+ * because "not X" includes "none". No filter widens the scope — a folder you
56
+ * cannot see, an address you cannot reach or an initiator outside your scope
57
+ * yields nothing rather than someone else's operations.
58
+ */
59
+ export interface HistoryFilters {
60
+ /** `in` — deposits, `out` — transfers. Both is the same as neither. */
61
+ direction?: OneOrMany<'in' | 'out'> | undefined
33
62
  /**
34
63
  * Outgoing only, whichever value you pass: a status belongs to a transfer,
35
64
  * so setting this EXCLUDES the incoming side of the feed even without
36
- * `direction: 'out'`. The same goes for `awaitingMyApproval` and
37
- * `decisionPolicyId`.
65
+ * `direction: 'out'`. The same goes for `awaitingMyApproval`,
66
+ * `decisionPolicyId` and `initiatorId`.
67
+ */
68
+ status?: OneOrMany<HistoryStatusFilter> | undefined
69
+ /**
70
+ * None of these statuses. A deposit counts as `confirmed` here, as its row
71
+ * shows it: `statusNot: 'failed'` keeps deposits, `statusNot: 'confirmed'`
72
+ * drops them.
73
+ */
74
+ statusNot?: OneOrMany<HistoryStatusFilter> | undefined
75
+ /**
76
+ * Only what awaits MY signature. For the approvals screen. Implies
77
+ * `direction: 'out'` and `status: 'awaiting_approval'` — a `status` passed
78
+ * alongside is ignored; the other filters, `statusNot` included, still
79
+ * apply.
38
80
  */
39
- status?: HistoryStatusFilter | undefined
40
- /** Only what awaits MY signature. For the approvals screen. */
41
81
  awaitingMyApproval?: boolean | undefined
42
- asset?: string | undefined
43
- tokenId?: string | undefined
44
- network?: string | undefined
45
- addressId?: string | undefined
46
- folderId?: string | undefined
47
- counterpartyId?: string | undefined
48
- counterpartyGroupId?: string | undefined
49
- counterpartyAddressId?: string | undefined
82
+ /** Token code. */
83
+ asset?: OneOrMany<string> | undefined
84
+ assetNot?: OneOrMany<string> | undefined
85
+ /** Token id from the registry. With `asset` — the intersection. */
86
+ tokenId?: OneOrMany<string> | undefined
87
+ tokenIdNot?: OneOrMany<string> | undefined
88
+ /** `Network.slug`. */
89
+ network?: OneOrMany<string> | undefined
90
+ networkNot?: OneOrMany<string> | undefined
91
+ /** Our address: the sender of a transfer, the recipient of a deposit. */
92
+ addressId?: OneOrMany<string> | undefined
93
+ addressIdNot?: OneOrMany<string> | undefined
94
+ /**
95
+ * Operations on the addresses of a folder, as it is now. Any folder you can
96
+ * see; it narrows, never widens — without `includeShared` a shared folder
97
+ * narrows only your own operations.
98
+ */
99
+ folderId?: OneOrMany<string> | undefined
100
+ folderIdNot?: OneOrMany<string> | undefined
101
+ counterpartyId?: OneOrMany<string> | undefined
102
+ counterpartyIdNot?: OneOrMany<string> | undefined
103
+ /** By the group's current members. */
104
+ counterpartyGroupId?: OneOrMany<string> | undefined
105
+ counterpartyGroupIdNot?: OneOrMany<string> | undefined
106
+ /** The on-chain address of the other side. EVM addresses compare case-insensitively. */
107
+ counterpartyAddressId?: OneOrMany<string> | undefined
50
108
  /** `internal` — the other side is an address of this vault; `external` — it is not. */
51
- flowType?: 'internal' | 'external' | undefined
52
- category?: string | undefined
109
+ flowType?: OneOrMany<'internal' | 'external'> | undefined
110
+ /** The `category` of the older metadata (the system category `general`). */
111
+ category?: OneOrMany<string> | undefined
112
+ categoryNot?: OneOrMany<string> | undefined
113
+ /** Exact match, ONE value: a comma is part of the text here, not a separator. */
53
114
  paymentPurpose?: string | undefined
54
- decisionPolicyId?: string | undefined
55
- txHash?: string | undefined
115
+ decisionPolicyId?: OneOrMany<string> | undefined
116
+ decisionPolicyIdNot?: OneOrMany<string> | undefined
117
+ /** Who started the transfer (member ids). Deposits drop out — they have no initiator. */
118
+ initiatorId?: OneOrMany<string> | undefined
119
+ initiatorIdNot?: OneOrMany<string> | undefined
120
+ /** The recipient's risk on a transfer, the sender's on a deposit. */
121
+ amlLevel?: OneOrMany<HistoryAmlLevelFilter> | undefined
122
+ /** `unchecked` here drops the unchecked ones; without it they stay. */
123
+ amlLevelNot?: OneOrMany<HistoryAmlLevelFilter> | undefined
124
+ /** A deposit always has a hash. */
125
+ hasTxHash?: boolean | undefined
126
+ /** Whether the transfer has a fee recorded. A deposit has none: `true` drops it, `false` keeps it. */
127
+ hasFee?: boolean | undefined
128
+ hasCounterparty?: boolean | undefined
129
+ /**
130
+ * What `from`/`to` apply to. With `confirmedAt` and a period, a transfer that
131
+ * was never confirmed does not match; a deposit's `confirmedAt` is its
132
+ * `createdAt`. The ORDER of the feed is not affected — that is `sort`.
133
+ */
134
+ dateBasis?: 'createdAt' | 'confirmedAt' | undefined
135
+ /** Tags of the older metadata, matched after normalisation (case, `ё` = `е`, spaces). */
136
+ tag?: OneOrMany<string> | undefined
137
+ tagNot?: OneOrMany<string> | undefined
138
+ /**
139
+ * Has an active assignment of a vault category, by key. Only assignments
140
+ * VISIBLE to you count — as on the operation's card; the same holds for the
141
+ * other category filters, and a hidden sensitive value never matches.
142
+ */
143
+ categoryKey?: OneOrMany<string> | undefined
144
+ categoryKeyNot?: OneOrMany<string> | undefined
145
+ /** `false` — no visible assignment at all ("unlabelled"). */
146
+ hasCategory?: boolean | undefined
147
+ /**
148
+ * A field's value — the grammar of the reports' `categoryField`:
149
+ * `key:v1|v2,key2:v3` (`,` is AND, `|` is OR), every condition on ONE
150
+ * assignment; with `categoryKey`, within those categories only. Values in
151
+ * canonical form (`84.10` for 84.1 at scale 2).
152
+ */
153
+ categoryField?: string | undefined
154
+ /**
155
+ * A range over a field: `key:from..to[,…]`, both ends inclusive, either may
156
+ * be omitted (`amount:100..`). Numbers compare as decimals; dates are ISO in
157
+ * UTC, and an END date without a time covers that WHOLE day — unlike the
158
+ * feed's own `to`. Same one assignment as `categoryField`.
159
+ */
160
+ categoryFieldRange?: string | undefined
161
+ /**
162
+ * The assignment has no value in these fields (keys). A hidden sensitive
163
+ * field counts as FILLED, whatever it holds — otherwise the filter would
164
+ * reveal whether it is empty.
165
+ */
166
+ categoryFieldEmpty?: OneOrMany<string> | undefined
167
+ /** Has a relation (refund, reversal, correction, replacement) in either role. */
168
+ hasRelations?: boolean | undefined
169
+ /** A relation of this type, in either role. */
170
+ relationType?: OneOrMany<OperationRelationType> | undefined
171
+ /**
172
+ * Amount at least (inclusive) — a decimal string IN THE OPERATION'S OWN
173
+ * TOKEN: `'100'` is 100 USDT on a USDT operation and 100 TRX on a TRX one.
174
+ * Compared exactly. An operation whose token is outside the registry never
175
+ * matches. Add `asset` or `tokenId` to compare one asset.
176
+ */
177
+ minimumAmount?: string | undefined
178
+ maximumAmount?: string | undefined
179
+ /**
180
+ * USD valuation at least (inclusive), a decimal string — the row's
181
+ * `usdValue`. An operation without a valuation NEVER matches; how many there
182
+ * are is `usd.unpricedCount` of `summary()`.
183
+ */
184
+ minimumUsd?: string | undefined
185
+ maximumUsd?: string | undefined
186
+ /** `false` — no USD valuation: no rate at the time, or a token outside the registry. */
187
+ hasUsd?: boolean | undefined
56
188
  /** Include operations on addresses shared with you. Off by default. */
57
189
  includeShared?: boolean | undefined
58
- /** ISO date, inclusive. */
190
+ /** Exact on-chain hash, one value. */
191
+ txHash?: string | undefined
192
+ /**
193
+ * BOTH INCLUSIVE, by `dateBasis`: ISO moment or `YYYY-MM-DD` (midnight UTC).
194
+ * Reports treat `to` as exclusive, so the same pair selects different sets
195
+ * there and here — exactly on the operations at `to`. To take a whole day
196
+ * here, pass its last moment or the next midnight.
197
+ */
59
198
  from?: string | undefined
60
199
  to?: string | undefined
200
+ /**
201
+ * Administrators — of the platform or of THIS vault — see the whole vault;
202
+ * this narrows it to one person. Anyone else may name only themselves (403).
203
+ */
61
204
  userId?: string | undefined
62
205
  }
63
206
 
207
+ export interface HistoryParams extends HistoryFilters, PageParams {
208
+ /**
209
+ * Order of the feed; `createdAt` by default. `confirmedAt` — only confirmed
210
+ * operations. `amount` — by the raw amount, and ONLY with exactly one asset
211
+ * in `asset`/`tokenId` (amounts of different tokens do not compare), else
212
+ * 400 `SORT_REQUIRES_SINGLE_ASSET`; "largest in any asset" is `usd`. `usd` —
213
+ * by the USD valuation, valued operations only. Equal keys go by id.
214
+ */
215
+ sort?: 'createdAt' | 'confirmedAt' | 'amount' | 'usd' | undefined
216
+ /** `desc` by default. */
217
+ order?: 'desc' | 'asc' | undefined
218
+ }
219
+
220
+ /** What `summary()` can count by. */
221
+ export type HistoryFacet = keyof HistorySummary['facets']
222
+
223
+ export interface HistorySummaryParams extends HistoryFilters {
224
+ /** Which counters to compute. Only those asked for come back. */
225
+ facets?: OneOrMany<HistoryFacet> | undefined
226
+ }
227
+
64
228
  export class HistoryResource {
65
229
  readonly #http: HttpClient
66
230
  readonly #base: string
@@ -70,7 +234,54 @@ export class HistoryResource {
70
234
  this.#base = `/api/v1/vaults/${seg(vaultCode)}/history`
71
235
  }
72
236
 
73
- list(params: HistoryParams = {}): Promise<Page<HistoryItem>> {
74
- return this.#http.request<Page<HistoryItem>>('GET', this.#base, { query: { ...params } })
237
+ /**
238
+ * One page of the feed. A member sees their own transfers and the deposits
239
+ * to their addresses; `includeShared` adds the operations of addresses
240
+ * opened to them, `awaitingMyApproval` the transfers waiting for their vote.
241
+ * An administrator of the platform or of THIS vault sees the whole vault —
242
+ * seeing is not acting: what a vault administrator may send, sign or label
243
+ * is still decided by their own rights as a member.
244
+ *
245
+ * A cursor remembers `sort` and `order`: one issued for another order is
246
+ * 400 `INVALID_CURSOR` (older cursors are `createdAt desc`).
247
+ *
248
+ * Two flags can come back, and neither means the end of the feed:
249
+ *
250
+ * • `scanTruncated` — some filters are decided over rows already read,
251
+ * and the page did not fill within 50 000 of them. What was found is
252
+ * returned and `nextCursor` continues from where the scan stopped:
253
+ * keep paging;
254
+ * • `sortIncomplete` — with `sort: 'amount' | 'usd'`, some operations
255
+ * have no sort key yet and this request could not compute them all
256
+ * (200 rows per table per request); those operations are not in the
257
+ * order yet. Repeat the request.
258
+ */
259
+ list(params: HistoryParams = {}): Promise<HistoryResponse> {
260
+ return this.#http.request<HistoryResponse>('GET', this.#base, { query: { ...params } })
261
+ }
262
+
263
+ /**
264
+ * Totals for the same scope and filters as `list()`: how many operations,
265
+ * amounts per asset, the USD total and counters per value of the requested
266
+ * `facets`. `count` is the length of the feed paged to its end, the amounts
267
+ * the sum of its rows.
268
+ *
269
+ * `byAsset` is per asset AND per direction, in raw units (a BigInt string)
270
+ * and as a decimal — there is no cross-asset "turnover", and the sums
271
+ * include unsuccessful transfers unless a filter drops them
272
+ * (`statusNot: ['failed', 'rejected', 'cancelled']`). Different assets add
273
+ * up only in `usd`, valued as the rows' `usdValue`; operations without a
274
+ * valuation are counted in `usd.unpricedCount` and are in no USD total.
275
+ *
276
+ * A facet is counted with every filter EXCEPT its own dimension.
277
+ *
278
+ * More than 25 000 operations after filtering is 422
279
+ * `HISTORY_SUMMARY_TOO_BROAD` with `details.limit` — narrow the period or
280
+ * the filters; a cut-off total would look like a complete one.
281
+ */
282
+ summary(params: HistorySummaryParams = {}): Promise<HistorySummary> {
283
+ return this.#http.request<HistorySummary>('GET', `${this.#base}/summary`, {
284
+ query: { ...params },
285
+ })
75
286
  }
76
287
  }
@@ -1,7 +1,9 @@
1
1
  import type { HttpClient } from '../core/http.js'
2
+ import type { PageParams } from '../core/pagination.js'
2
3
  import type {
3
4
  AllowedSegmentsResponse,
4
5
  MeVaultResponse,
6
+ MySessionList,
5
7
  PatchProfileBody,
6
8
  PushToken,
7
9
  RegisterPushTokenBody,
@@ -77,6 +79,26 @@ export class MeResource {
77
79
  })
78
80
  }
79
81
 
82
+ /**
83
+ * Where I am signed in: my live sessions — the phone, the web version, the
84
+ * Mac app, a browser — newest first, with `current` on the one making this
85
+ * request.
86
+ *
87
+ * Open to ANY session, a web or Mac one included, because it carries
88
+ * nothing worth stealing: no tokens, no IP addresses, no raw user agent.
89
+ * Read-only — ending another session is better-auth's own
90
+ * `/api/auth/revoke-session` and its neighbours, which a web or Mac
91
+ * session is refused; signing out of this session is always possible.
92
+ * Expired sessions are not listed, and neither are web or Mac ones older
93
+ * than 30 days from sign-in — their real ceiling, which is what
94
+ * `expiresAt` says for them.
95
+ */
96
+ sessions(params: PageParams = {}): Promise<MySessionList> {
97
+ return this.#http.request<MySessionList>('GET', '/api/v1/me/sessions', {
98
+ query: { ...params },
99
+ })
100
+ }
101
+
80
102
  registerPushToken(input: RegisterPushTokenBody): Promise<PushToken> {
81
103
  return this.#http.request<PushToken>('POST', '/api/v1/me/push-tokens', { body: input })
82
104
  }
@@ -1,14 +1,24 @@
1
1
  import { seg, type HttpClient } from '../core/http.js'
2
2
  import type { PageParams } from '../core/pagination.js'
3
3
  import type {
4
+ ActionType,
4
5
  MemberCard,
5
6
  MemberDetail,
6
7
  MembersPage,
8
+ PolicyDirectoryPage,
7
9
  UserGroup,
8
10
  UserGroupDetail,
9
11
  UserGroupMembers,
10
12
  } from '../generated/types.js'
11
13
 
14
+ export interface PolicyDirectoryParams extends PageParams {
15
+ actionType?: ActionType | undefined
16
+ effect?: 'allow' | 'block' | undefined
17
+ enabled?: boolean | undefined
18
+ /** Only the policies of groups I belong to. Without it — every group's. */
19
+ mine?: boolean | undefined
20
+ }
21
+
12
22
  /**
13
23
  * People in the vault, and the groups they belong to.
14
24
  *
@@ -87,6 +97,26 @@ export class MembersResource {
87
97
  )
88
98
  }
89
99
 
100
+ /**
101
+ * Every policy of the vault by name — code, name, look, `actionType`,
102
+ * `effect`, `enabled` and the group it hangs on — for a "decided by" label
103
+ * and the feed's `decisionPolicyId` filter. Open to any member, and it
104
+ * lists the policies of ALL groups, not only yours: rule names are not
105
+ * personal data and each group's detail already shows them.
106
+ *
107
+ * No rules, conditions, limits, thresholds or signers here — those stay
108
+ * with the administrator endpoints (`admin.policies`). The fields are the
109
+ * ones `group()` shows in `policies[]`, gathered into one list. Keyset
110
+ * paging, newest first.
111
+ */
112
+ policyDirectory(params: PolicyDirectoryParams = {}): Promise<PolicyDirectoryPage> {
113
+ return this.#http.request<PolicyDirectoryPage>(
114
+ 'GET',
115
+ `/api/v1/vaults/${this.#vault}/policy-directory`,
116
+ { query: { ...params } },
117
+ )
118
+ }
119
+
90
120
  groupMembers(groupId: string): Promise<UserGroupMembers> {
91
121
  return this.#http.request<UserGroupMembers>(
92
122
  'GET',