@v3finance/core-sdk 0.3.2 → 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.
- package/CHANGELOG.md +175 -0
- package/README.md +18 -14
- package/dist/cjs/client.d.ts +27 -34
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +69 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/core/gated.d.ts +12 -10
- package/dist/cjs/core/gated.d.ts.map +1 -1
- package/dist/cjs/core/gated.js +12 -10
- package/dist/cjs/core/gated.js.map +1 -1
- package/dist/cjs/core/http.d.ts +18 -0
- package/dist/cjs/core/http.d.ts.map +1 -1
- package/dist/cjs/core/http.js +11 -1
- package/dist/cjs/core/http.js.map +1 -1
- package/dist/cjs/core/pagination.d.ts +11 -9
- package/dist/cjs/core/pagination.d.ts.map +1 -1
- package/dist/cjs/core/pagination.js +11 -9
- package/dist/cjs/core/pagination.js.map +1 -1
- package/dist/cjs/generated/operations.d.ts +218 -2
- package/dist/cjs/generated/operations.d.ts.map +1 -1
- package/dist/cjs/generated/operations.js +220 -4
- package/dist/cjs/generated/operations.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +945 -93
- package/dist/cjs/generated/types.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +6 -6
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resources/addresses.d.ts +91 -4
- package/dist/cjs/resources/addresses.d.ts.map +1 -1
- package/dist/cjs/resources/addresses.js +55 -3
- package/dist/cjs/resources/addresses.js.map +1 -1
- package/dist/cjs/resources/admin.d.ts +32 -1
- package/dist/cjs/resources/admin.d.ts.map +1 -1
- package/dist/cjs/resources/admin.js +45 -0
- package/dist/cjs/resources/admin.js.map +1 -1
- package/dist/cjs/resources/approvals.d.ts +30 -2
- package/dist/cjs/resources/approvals.d.ts.map +1 -1
- package/dist/cjs/resources/approvals.js.map +1 -1
- package/dist/cjs/resources/auth.d.ts +17 -1
- package/dist/cjs/resources/auth.d.ts.map +1 -1
- package/dist/cjs/resources/auth.js +20 -0
- package/dist/cjs/resources/auth.js.map +1 -1
- package/dist/cjs/resources/balances.d.ts +14 -7
- package/dist/cjs/resources/balances.d.ts.map +1 -1
- package/dist/cjs/resources/balances.js +10 -4
- package/dist/cjs/resources/balances.js.map +1 -1
- package/dist/cjs/resources/categories.d.ts +20 -6
- package/dist/cjs/resources/categories.d.ts.map +1 -1
- package/dist/cjs/resources/categories.js +19 -7
- package/dist/cjs/resources/categories.js.map +1 -1
- package/dist/cjs/resources/counterparties.d.ts +52 -6
- package/dist/cjs/resources/counterparties.d.ts.map +1 -1
- package/dist/cjs/resources/counterparties.js +24 -0
- package/dist/cjs/resources/counterparties.js.map +1 -1
- package/dist/cjs/resources/history.d.ts +227 -26
- package/dist/cjs/resources/history.d.ts.map +1 -1
- package/dist/cjs/resources/history.js +46 -0
- package/dist/cjs/resources/history.js.map +1 -1
- package/dist/cjs/resources/me.d.ts +17 -1
- package/dist/cjs/resources/me.d.ts.map +1 -1
- package/dist/cjs/resources/me.js +19 -0
- package/dist/cjs/resources/me.js.map +1 -1
- package/dist/cjs/resources/members.d.ts +21 -1
- package/dist/cjs/resources/members.d.ts.map +1 -1
- package/dist/cjs/resources/members.js +15 -0
- package/dist/cjs/resources/members.js.map +1 -1
- package/dist/cjs/resources/operations.d.ts +179 -4
- package/dist/cjs/resources/operations.d.ts.map +1 -1
- package/dist/cjs/resources/operations.js +192 -2
- package/dist/cjs/resources/operations.js.map +1 -1
- package/dist/cjs/resources/registries.d.ts +19 -2
- package/dist/cjs/resources/registries.d.ts.map +1 -1
- package/dist/cjs/resources/registries.js +16 -0
- package/dist/cjs/resources/registries.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client.d.ts +27 -34
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +69 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/core/gated.d.ts +12 -10
- package/dist/esm/core/gated.d.ts.map +1 -1
- package/dist/esm/core/gated.js +12 -10
- package/dist/esm/core/gated.js.map +1 -1
- package/dist/esm/core/http.d.ts +18 -0
- package/dist/esm/core/http.d.ts.map +1 -1
- package/dist/esm/core/http.js +11 -1
- package/dist/esm/core/http.js.map +1 -1
- package/dist/esm/core/pagination.d.ts +11 -9
- package/dist/esm/core/pagination.d.ts.map +1 -1
- package/dist/esm/core/pagination.js +11 -9
- package/dist/esm/core/pagination.js.map +1 -1
- package/dist/esm/generated/operations.d.ts +218 -2
- package/dist/esm/generated/operations.d.ts.map +1 -1
- package/dist/esm/generated/operations.js +220 -4
- package/dist/esm/generated/operations.js.map +1 -1
- package/dist/esm/generated/types.d.ts +945 -93
- package/dist/esm/generated/types.d.ts.map +1 -1
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/addresses.d.ts +91 -4
- package/dist/esm/resources/addresses.d.ts.map +1 -1
- package/dist/esm/resources/addresses.js +55 -3
- package/dist/esm/resources/addresses.js.map +1 -1
- package/dist/esm/resources/admin.d.ts +32 -1
- package/dist/esm/resources/admin.d.ts.map +1 -1
- package/dist/esm/resources/admin.js +45 -0
- package/dist/esm/resources/admin.js.map +1 -1
- package/dist/esm/resources/approvals.d.ts +30 -2
- package/dist/esm/resources/approvals.d.ts.map +1 -1
- package/dist/esm/resources/approvals.js.map +1 -1
- package/dist/esm/resources/auth.d.ts +17 -1
- package/dist/esm/resources/auth.d.ts.map +1 -1
- package/dist/esm/resources/auth.js +20 -0
- package/dist/esm/resources/auth.js.map +1 -1
- package/dist/esm/resources/balances.d.ts +14 -7
- package/dist/esm/resources/balances.d.ts.map +1 -1
- package/dist/esm/resources/balances.js +10 -4
- package/dist/esm/resources/balances.js.map +1 -1
- package/dist/esm/resources/categories.d.ts +20 -6
- package/dist/esm/resources/categories.d.ts.map +1 -1
- package/dist/esm/resources/categories.js +19 -7
- package/dist/esm/resources/categories.js.map +1 -1
- package/dist/esm/resources/counterparties.d.ts +52 -6
- package/dist/esm/resources/counterparties.d.ts.map +1 -1
- package/dist/esm/resources/counterparties.js +24 -0
- package/dist/esm/resources/counterparties.js.map +1 -1
- package/dist/esm/resources/history.d.ts +227 -26
- package/dist/esm/resources/history.d.ts.map +1 -1
- package/dist/esm/resources/history.js +46 -0
- package/dist/esm/resources/history.js.map +1 -1
- package/dist/esm/resources/me.d.ts +17 -1
- package/dist/esm/resources/me.d.ts.map +1 -1
- package/dist/esm/resources/me.js +19 -0
- package/dist/esm/resources/me.js.map +1 -1
- package/dist/esm/resources/members.d.ts +21 -1
- package/dist/esm/resources/members.d.ts.map +1 -1
- package/dist/esm/resources/members.js +15 -0
- package/dist/esm/resources/members.js.map +1 -1
- package/dist/esm/resources/operations.d.ts +179 -4
- package/dist/esm/resources/operations.d.ts.map +1 -1
- package/dist/esm/resources/operations.js +192 -2
- package/dist/esm/resources/operations.js.map +1 -1
- package/dist/esm/resources/registries.d.ts +19 -2
- package/dist/esm/resources/registries.d.ts.map +1 -1
- package/dist/esm/resources/registries.js +16 -0
- package/dist/esm/resources/registries.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/concepts.md +13 -11
- package/docs/errors.md +73 -5
- package/package.json +1 -1
- package/src/client.ts +40 -0
- package/src/core/gated.ts +12 -10
- package/src/core/http.ts +30 -1
- package/src/core/pagination.ts +11 -9
- package/src/generated/operations.ts +220 -4
- package/src/generated/types.ts +990 -95
- package/src/index.ts +15 -1
- package/src/resources/addresses.ts +102 -4
- package/src/resources/admin.ts +59 -0
- package/src/resources/approvals.ts +30 -2
- package/src/resources/auth.ts +22 -1
- package/src/resources/balances.ts +14 -7
- package/src/resources/categories.ts +19 -5
- package/src/resources/counterparties.ts +59 -5
- package/src/resources/history.ts +238 -27
- package/src/resources/me.ts +22 -0
- package/src/resources/members.ts +30 -0
- package/src/resources/operations.ts +264 -5
- package/src/resources/registries.ts +26 -3
- package/src/version.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export {
|
|
|
34
34
|
type Query,
|
|
35
35
|
type QueryValue,
|
|
36
36
|
type RequestOptions,
|
|
37
|
+
type RawBody,
|
|
37
38
|
type RawResponse,
|
|
38
39
|
} from './core/http.js'
|
|
39
40
|
|
|
@@ -84,6 +85,9 @@ export type * from './generated/types.js'
|
|
|
84
85
|
|
|
85
86
|
export {
|
|
86
87
|
AddressesResource,
|
|
88
|
+
type AddressFilters,
|
|
89
|
+
type AddressFacet,
|
|
90
|
+
type AddressesSummaryParams,
|
|
87
91
|
type ListAddressesParams,
|
|
88
92
|
type PendingApproval,
|
|
89
93
|
} from './resources/addresses.js'
|
|
@@ -96,13 +100,18 @@ export {
|
|
|
96
100
|
} from './resources/transferDrafts.js'
|
|
97
101
|
export {
|
|
98
102
|
HistoryResource,
|
|
103
|
+
type HistoryFilters,
|
|
99
104
|
type HistoryParams,
|
|
105
|
+
type HistorySummaryParams,
|
|
106
|
+
type HistoryFacet,
|
|
100
107
|
type HistoryStatusFilter,
|
|
108
|
+
type HistoryAmlLevelFilter,
|
|
109
|
+
type OperationRelationType,
|
|
101
110
|
} from './resources/history.js'
|
|
102
111
|
export { MeResource } from './resources/me.js'
|
|
103
112
|
export { SharingResource } from './resources/sharing.js'
|
|
104
113
|
export { FoldersResource } from './resources/folders.js'
|
|
105
|
-
export { MembersResource } from './resources/members.js'
|
|
114
|
+
export { MembersResource, type PolicyDirectoryParams } from './resources/members.js'
|
|
106
115
|
export { RegistriesResource, type AmlScore } from './resources/registries.js'
|
|
107
116
|
export { CategoriesResource, type OperationType } from './resources/categories.js'
|
|
108
117
|
/**
|
|
@@ -141,6 +150,8 @@ export {
|
|
|
141
150
|
OperationsResource,
|
|
142
151
|
type OperationKind,
|
|
143
152
|
type ListRelationsParams,
|
|
153
|
+
type AttachmentFile,
|
|
154
|
+
type UploadAttachmentOptions,
|
|
144
155
|
} from './resources/operations.js'
|
|
145
156
|
export {
|
|
146
157
|
ApprovalsResource,
|
|
@@ -161,6 +172,9 @@ export {
|
|
|
161
172
|
export {
|
|
162
173
|
CounterpartiesResource,
|
|
163
174
|
CounterpartyGroupsResource,
|
|
175
|
+
type CounterpartyFilters,
|
|
176
|
+
type CounterpartyFacet,
|
|
177
|
+
type CounterpartiesSummaryParams,
|
|
164
178
|
type ListCounterpartiesParams,
|
|
165
179
|
} from './resources/counterparties.js'
|
|
166
180
|
|
|
@@ -3,6 +3,7 @@ import type { Page, PageParams } from '../core/pagination.js'
|
|
|
3
3
|
import { toGated, type Gated } from '../core/gated.js'
|
|
4
4
|
import type { Address, AddressDetail } from './types.js'
|
|
5
5
|
import type {
|
|
6
|
+
AddressesSummary,
|
|
6
7
|
CreateAddressBody,
|
|
7
8
|
CreateAddressResult,
|
|
8
9
|
PatchAddressBody,
|
|
@@ -24,18 +25,62 @@ import type {
|
|
|
24
25
|
*/
|
|
25
26
|
export type PendingApproval = GeneratedPendingApproval
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The filters `list()` and `summary()` share — the same scope and the same
|
|
30
|
+
* narrowing, so a count from `summary()` is the length of the list walked to
|
|
31
|
+
* its end.
|
|
32
|
+
*
|
|
33
|
+
* A multi-value filter takes a string or an array; an array goes out as one
|
|
34
|
+
* comma-separated value (OR within the filter, AND between filters), at most
|
|
35
|
+
* 50 values — more is 400 `TOO_MANY_VALUES`. No filter widens the scope:
|
|
36
|
+
* a folder you cannot see, or an owner outside it, yields nothing rather
|
|
37
|
+
* than someone else's addresses.
|
|
38
|
+
*/
|
|
39
|
+
export interface AddressFilters {
|
|
28
40
|
/** Token code: `usdt`, `a7a5`. */
|
|
29
41
|
token?: string | undefined
|
|
30
42
|
/** Search over label and address. */
|
|
31
43
|
search?: string | undefined
|
|
44
|
+
/**
|
|
45
|
+
* Any folder you can see — your own or one shared with you or your group
|
|
46
|
+
* (an administrator: any folder of the vault). A folder you cannot see is
|
|
47
|
+
* an empty page, as if it did not exist, and it does not widen `access`.
|
|
48
|
+
*/
|
|
32
49
|
folderId?: string | undefined
|
|
33
50
|
/**
|
|
34
51
|
* Whose addresses to return. The default is your own: reading shared
|
|
35
52
|
* addresses is opt-in so that existing screens do not change meaning.
|
|
53
|
+
* Ignored for an administrator, who sees the whole vault.
|
|
36
54
|
*/
|
|
37
55
|
access?: 'own' | 'shared' | 'all' | undefined
|
|
56
|
+
/** Administrators only: one owner's addresses. Anyone else may name only themselves (403). */
|
|
38
57
|
userId?: string | undefined
|
|
58
|
+
/** `Network.slug`. */
|
|
59
|
+
network?: string | readonly string[] | undefined
|
|
60
|
+
/**
|
|
61
|
+
* Address tags, matched after normalisation: case (Cyrillic included),
|
|
62
|
+
* `ё` = `е` and extra spaces do not matter.
|
|
63
|
+
*/
|
|
64
|
+
tag?: string | readonly string[] | undefined
|
|
65
|
+
/** Owners (member ids), within the `access` scope — it opens nobody else's addresses. */
|
|
66
|
+
ownerId?: string | readonly string[] | undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ListAddressesParams extends AddressFilters, PageParams {
|
|
70
|
+
/**
|
|
71
|
+
* `createdAt` (default) — newest first. `lastActivity` — by the latest
|
|
72
|
+
* operation, most recent first; addresses with none go last. A cursor
|
|
73
|
+
* belongs to its order: one from another `sort` is a 400.
|
|
74
|
+
*/
|
|
75
|
+
sort?: 'createdAt' | 'lastActivity' | undefined
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What `summary()` can count by. */
|
|
79
|
+
export type AddressFacet = keyof AddressesSummary['facets']
|
|
80
|
+
|
|
81
|
+
export interface AddressesSummaryParams extends AddressFilters {
|
|
82
|
+
/** Which counters to compute. Only those asked for come back. */
|
|
83
|
+
facets?: AddressFacet | readonly AddressFacet[] | undefined
|
|
39
84
|
}
|
|
40
85
|
|
|
41
86
|
/**
|
|
@@ -55,19 +100,72 @@ export class AddressesResource {
|
|
|
55
100
|
this.#base = `/api/v1/vaults/${seg(vaultCode)}/addresses`
|
|
56
101
|
}
|
|
57
102
|
|
|
58
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* One page of addresses. Use `paginate` to walk them all.
|
|
105
|
+
*
|
|
106
|
+
* Each row carries `folderIds` (only the folders you can see — someone
|
|
107
|
+
* else's folder your address was put into is not listed),
|
|
108
|
+
* `lastActivityAt` (the latest transfer from it or deposit to it, any
|
|
109
|
+
* status, computed on read) and `logoPath` (see `CoreClient.logo`).
|
|
110
|
+
*/
|
|
59
111
|
list(params: ListAddressesParams = {}): Promise<Page<Address>> {
|
|
60
112
|
return this.#http.request<Page<Address>>('GET', this.#base, { query: { ...params } })
|
|
61
113
|
}
|
|
62
114
|
|
|
115
|
+
/**
|
|
116
|
+
* How many addresses match, and counters per value of the requested
|
|
117
|
+
* `facets` — for a list of tags with counts, say — under the same filters
|
|
118
|
+
* and scope as `list()`.
|
|
119
|
+
*
|
|
120
|
+
* A facet is counted with every filter EXCEPT its own dimension: with
|
|
121
|
+
* `network: 'tron'` the `network` facet still shows the other networks;
|
|
122
|
+
* `count` applies all of them. Only values met in your scope appear (no
|
|
123
|
+
* zeros), so the facet enumerates no one else's folders or people; the top
|
|
124
|
+
* 50 per dimension come back and the rest is summed in `otherCount`.
|
|
125
|
+
* `value: null` means "no value" (outside every folder, no tags). Tags are
|
|
126
|
+
* grouped by their normalised spelling and shown in the most frequent one;
|
|
127
|
+
* `folderId` carries the folder's name as `label`; `ownerId` has no label —
|
|
128
|
+
* take names from `members`, where visibility applies.
|
|
129
|
+
*
|
|
130
|
+
* An unknown facet is 400 `INVALID_FILTER_VALUE`.
|
|
131
|
+
*/
|
|
132
|
+
summary(params: AddressesSummaryParams = {}): Promise<AddressesSummary> {
|
|
133
|
+
return this.#http.request<AddressesSummary>('GET', `${this.#base}/summary`, {
|
|
134
|
+
query: { ...params },
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
63
138
|
get(addressId: string): Promise<AddressDetail> {
|
|
64
139
|
return this.#http.request<AddressDetail>('GET', `${this.#base}/${seg(addressId)}`)
|
|
65
140
|
}
|
|
66
141
|
|
|
67
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* 201 — the address is ready (`applied`); 202 — it went for approval and a
|
|
144
|
+
* request came back (`pending`); 200 — a replay of `idempotencyKey`
|
|
145
|
+
* (`replayed`).
|
|
146
|
+
*
|
|
147
|
+
* Pass `idempotencyKey` (a uuid) and keep it until you have an answer: a
|
|
148
|
+
* retry with the same key and the same body creates no second address and
|
|
149
|
+
* evaluates nothing again. The address of that attempt comes back as
|
|
150
|
+
* `replayed` (the body of a 201, without `warnings`), or the same pending
|
|
151
|
+
* request as `pending` — signers are not notified twice. The same key with
|
|
152
|
+
* another body is 409 `IDEMPOTENCY_KEY_REUSED`; a request approved whose
|
|
153
|
+
* address is still being created, 409 `IDEMPOTENCY_KEY_IN_PROGRESS` (retry
|
|
154
|
+
* later); a request closed without an address, 409
|
|
155
|
+
* `IDEMPOTENCY_KEY_CLOSED` — the outcome is settled, a new attempt needs a
|
|
156
|
+
* new key. A failure of the signing service or of monitoring (the address
|
|
157
|
+
* rolled back) does not consume the key. The key is per member of the
|
|
158
|
+
* vault.
|
|
159
|
+
*
|
|
160
|
+
* Only TRON has deposit monitoring, so an address on any other network of
|
|
161
|
+
* the vault is refused with 400 `NETWORK_NOT_MONITORED` before anything is
|
|
162
|
+
* asked of the signing service.
|
|
163
|
+
*/
|
|
68
164
|
async create(input: CreateAddressBody): Promise<Gated<CreateAddressResult, PendingApproval>> {
|
|
69
165
|
const res = await this.#http.requestRaw<unknown>('POST', this.#base, { body: input })
|
|
70
|
-
return toGated<CreateAddressResult, PendingApproval>(res.status, res.data
|
|
166
|
+
return toGated<CreateAddressResult, PendingApproval>(res.status, res.data, {
|
|
167
|
+
replayOn200: true,
|
|
168
|
+
})
|
|
71
169
|
}
|
|
72
170
|
|
|
73
171
|
/**
|
package/src/resources/admin.ts
CHANGED
|
@@ -26,6 +26,10 @@ import type {
|
|
|
26
26
|
PolicyDetail,
|
|
27
27
|
PolicyGroupDetail,
|
|
28
28
|
PolicyVersionList,
|
|
29
|
+
ReconcileLegacyMetadataBody,
|
|
30
|
+
ReconcileLegacyMetadataResult,
|
|
31
|
+
SearchIndexRebuildResult,
|
|
32
|
+
SharedAddressList,
|
|
29
33
|
UserGroupItem,
|
|
30
34
|
VaultPoliciesPage,
|
|
31
35
|
VisibilityGrant,
|
|
@@ -259,6 +263,45 @@ export class AdminResource {
|
|
|
259
263
|
),
|
|
260
264
|
}
|
|
261
265
|
|
|
266
|
+
// --- maintenance --------------------------------------------------------
|
|
267
|
+
|
|
268
|
+
readonly addresses = {
|
|
269
|
+
/**
|
|
270
|
+
* On-chain addresses that exist as a row in SEVERAL vaults. A derivation
|
|
271
|
+
* path is not unique across vaults while the signing service is shared,
|
|
272
|
+
* so the same path in two vaults is the same address. A deposit to one is
|
|
273
|
+
* credited to the EARLIEST row (first in `rows`) — deterministically, with
|
|
274
|
+
* a warning in the log — and whose money it really is, the owner decides:
|
|
275
|
+
* reassign or archive the extra rows. Read-only; new addresses no longer
|
|
276
|
+
* collide (the next derivation index is taken instead).
|
|
277
|
+
*/
|
|
278
|
+
shared: () => this.#http.request<SharedAddressList>('GET', '/api/v1/admin/addresses/shared'),
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
readonly legacyMetadata = {
|
|
282
|
+
/**
|
|
283
|
+
* Carries rows of the older `operation_metadata` table into assignments
|
|
284
|
+
* of the system category `general` — rows missing there, or NEWER than
|
|
285
|
+
* the assignment. Written through the ordinary labelling path (a version
|
|
286
|
+
* per change, authored by the row's `updatedById`) without the category's
|
|
287
|
+
* approval, since these are edits already made; `general` is created
|
|
288
|
+
* where missing.
|
|
289
|
+
*
|
|
290
|
+
* `dryRun` is required: `true` only plans (values are still validated),
|
|
291
|
+
* `false` writes. Idempotent — a repeat is all `skip`. One row's failure
|
|
292
|
+
* does not stop the others: it lands in `items[].error` and in `failed`
|
|
293
|
+
* (`LEGACY_TAGS_INVALID` for tags that are not an array of strings,
|
|
294
|
+
* `GENERAL_CATEGORY_CONFLICT` for a vault whose `general` is not the
|
|
295
|
+
* system category).
|
|
296
|
+
*/
|
|
297
|
+
reconcile: (body: ReconcileLegacyMetadataBody) =>
|
|
298
|
+
this.#http.request<ReconcileLegacyMetadataResult>(
|
|
299
|
+
'POST',
|
|
300
|
+
'/api/v1/admin/legacy-metadata/reconcile',
|
|
301
|
+
{ body },
|
|
302
|
+
),
|
|
303
|
+
}
|
|
304
|
+
|
|
262
305
|
/** Vault-scoped administrative listings and creation. */
|
|
263
306
|
vault(vaultCode: string): {
|
|
264
307
|
invitations: (params?: {
|
|
@@ -267,6 +310,7 @@ export class AdminResource {
|
|
|
267
310
|
policies: (params?: VaultPoliciesParams) => Promise<VaultPoliciesPage>
|
|
268
311
|
policyGroups: () => Promise<PolicyGroupWithCounts[]>
|
|
269
312
|
createSeat: (input: CreateSeatBody) => Promise<SeatCreated>
|
|
313
|
+
rebuildSearchIndex: () => Promise<SearchIndexRebuildResult>
|
|
270
314
|
} {
|
|
271
315
|
const base = `/api/v1/vaults/${seg(vaultCode)}`
|
|
272
316
|
return {
|
|
@@ -292,6 +336,21 @@ export class AdminResource {
|
|
|
292
336
|
*/
|
|
293
337
|
createSeat: (input) =>
|
|
294
338
|
this.#http.request<SeatCreated>('POST', `${base}/seats`, { body: input }),
|
|
339
|
+
/**
|
|
340
|
+
* Computes the amount sort keys of the feed that are still missing —
|
|
341
|
+
* old operations with a rate but no stored `usdValue`, rows written by
|
|
342
|
+
* older code during a deploy. Optional: `history.list({ sort: 'amount'
|
|
343
|
+
* | 'usd' })` computes them itself, a portion per request; this does
|
|
344
|
+
* the same by hand and reports what is left.
|
|
345
|
+
*
|
|
346
|
+
* Up to 200 rows per table per call; call it until both `remaining`
|
|
347
|
+
* counters are zero, which they always reach — a key that cannot be
|
|
348
|
+
* computed (a token outside the registry, a broken rate) is marked
|
|
349
|
+
* "not in the order" for good. Writes only the keys, never `usdValue`,
|
|
350
|
+
* by conditional update, without moving `updatedAt`. Idempotent.
|
|
351
|
+
*/
|
|
352
|
+
rebuildSearchIndex: () =>
|
|
353
|
+
this.#http.request<SearchIndexRebuildResult>('POST', `${base}/search-index/rebuild`),
|
|
295
354
|
}
|
|
296
355
|
}
|
|
297
356
|
|
|
@@ -27,20 +27,48 @@ import type {
|
|
|
27
27
|
export type ApprovalRequestStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED'
|
|
28
28
|
|
|
29
29
|
export interface ListApprovalsParams extends PageParams {
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* One status or several — an array goes out as one comma-separated value:
|
|
32
|
+
* `['APPROVED', 'REJECTED', 'CANCELLED']` is "everything decided".
|
|
33
|
+
*/
|
|
34
|
+
status?: ApprovalRequestStatus | readonly ApprovalRequestStatus[] | undefined
|
|
31
35
|
action?: string | undefined
|
|
32
36
|
/** Requests I STARTED. Not the same as the ones waiting for me. */
|
|
33
37
|
mine?: boolean | undefined
|
|
34
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Requests waiting for MY vote. This is the approvals screen. It sets
|
|
40
|
+
* `PENDING` itself, and `status` has no effect alongside it.
|
|
41
|
+
*/
|
|
35
42
|
pendingMine?: boolean | undefined
|
|
36
43
|
from?: string | undefined
|
|
37
44
|
to?: string | undefined
|
|
38
45
|
resolvedFrom?: string | undefined
|
|
39
46
|
resolvedTo?: string | undefined
|
|
40
47
|
initiatorId?: string | undefined
|
|
48
|
+
/** A person among the request's signers (by its snapshot), however they voted. */
|
|
41
49
|
approverId?: string | undefined
|
|
50
|
+
/**
|
|
51
|
+
* How `approverId` voted: `approve`, `reject` (any reject is a veto here —
|
|
52
|
+
* the whole request is rejected), `any` (voted at all) or `none` (a signer
|
|
53
|
+
* who has not voted yet). Only with `approverId` — alone it is 400
|
|
54
|
+
* `VOTE_REQUIRES_APPROVER`. "What I signed" is `{ approverId: me, vote:
|
|
55
|
+
* 'approve' }`.
|
|
56
|
+
*/
|
|
57
|
+
vote?: 'approve' | 'reject' | 'any' | 'none' | undefined
|
|
42
58
|
decisionPolicyId?: string | undefined
|
|
43
59
|
targetType?: string | undefined
|
|
60
|
+
/**
|
|
61
|
+
* `newest` (default) or `oldest` — with `status: 'PENDING'`, the ones
|
|
62
|
+
* waiting longest. A cursor belongs to its order: one from the other is a
|
|
63
|
+
* 400.
|
|
64
|
+
*/
|
|
65
|
+
order?: 'newest' | 'oldest' | undefined
|
|
66
|
+
/**
|
|
67
|
+
* Adds `total` — how many requests match the filters, visibility applied,
|
|
68
|
+
* on every page. A separate count taken at request time, not atomic with
|
|
69
|
+
* the page, which is why it is asked for rather than always there.
|
|
70
|
+
*/
|
|
71
|
+
includeTotal?: boolean | undefined
|
|
44
72
|
}
|
|
45
73
|
|
|
46
74
|
/**
|
package/src/resources/auth.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '../core/http.js'
|
|
2
|
-
import type { MagicLinkBody } from '../generated/types.js'
|
|
2
|
+
import type { DeviceLoginInfo, MagicLinkBody } from '../generated/types.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Signing in.
|
|
@@ -33,4 +33,25 @@ export class AuthResource {
|
|
|
33
33
|
body: input,
|
|
34
34
|
})
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Which client a pending login code was started for — asked by the phone
|
|
39
|
+
* BEFORE it approves the code, to name the client honestly («веб-версия» or
|
|
40
|
+
* «приложение V3 для Mac»).
|
|
41
|
+
*
|
|
42
|
+
* Only a session that may approve logins itself gets an answer: the mobile
|
|
43
|
+
* app. A web or desktop session, and a platform administrator, get 403
|
|
44
|
+
* (`WEB_SESSION_CANNOT_APPROVE`, `ADMIN_CANNOT_APPROVE_WEB_LOGIN`). Any code
|
|
45
|
+
* that cannot be approved — unknown, expired, already used — is the same
|
|
46
|
+
* 404, so the answer reveals nothing about codes.
|
|
47
|
+
*
|
|
48
|
+
* `client` is what the person who started the login declared, not a
|
|
49
|
+
* verified identity: keep the anti-phishing warning for any value.
|
|
50
|
+
* Hyphens in the code are ignored; letter case is not (pass it as shown).
|
|
51
|
+
*/
|
|
52
|
+
deviceLogin(userCode: string): Promise<DeviceLoginInfo> {
|
|
53
|
+
return this.#http.request<DeviceLoginInfo>('GET', '/api/v1/auth/device-login', {
|
|
54
|
+
query: { user_code: userCode },
|
|
55
|
+
})
|
|
56
|
+
}
|
|
36
57
|
}
|
|
@@ -207,17 +207,24 @@ export class BalancesResource {
|
|
|
207
207
|
/**
|
|
208
208
|
* The raw ledger. Append-only: corrections arrive as reversing entries.
|
|
209
209
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
210
|
+
* A member sees the entries with a posting on an address they can reach —
|
|
211
|
+
* their own, or one opened to them for viewing (a grant on the address or
|
|
212
|
+
* on its folder) — and within such an entry only the postings on those
|
|
213
|
+
* addresses plus the vault-level ones. The postings of a page therefore
|
|
214
|
+
* need not sum to zero, even though every complete entry does. An
|
|
215
|
+
* administrator, of the platform or of this vault, sees the whole vault.
|
|
216
|
+
*
|
|
217
|
+
* Ordered by when the entry was WRITTEN (`postedAt`; `effectiveAt` does not
|
|
218
|
+
* affect the order), newest first; `from` is inclusive and `to` exclusive
|
|
219
|
+
* on the same moment.
|
|
214
220
|
*/
|
|
215
221
|
entries(
|
|
216
222
|
params: PageParams & {
|
|
217
223
|
/**
|
|
218
|
-
* Entries with a posting on this address.
|
|
219
|
-
*
|
|
220
|
-
* not
|
|
224
|
+
* Entries with a posting on this address. An address that is not in the
|
|
225
|
+
* vault, or that you cannot reach, is 404 `ADDRESS_NOT_FOUND` — as the
|
|
226
|
+
* address card answers — so an empty page means "no entries", not "no
|
|
227
|
+
* access". (It used to answer an empty page for somebody else's id.)
|
|
221
228
|
*/
|
|
222
229
|
addressId?: string
|
|
223
230
|
/** Either spelling of the stage — see `LedgerEntryType`. */
|
|
@@ -144,10 +144,14 @@ export class CategoriesResource {
|
|
|
144
144
|
* Changes applied values. Append-only underneath: every change writes a new
|
|
145
145
|
* version rather than overwriting, so history survives.
|
|
146
146
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
147
|
+
* Send `baseVersion` — the assignment's `version` the editor started from.
|
|
148
|
+
* If it has changed since, the answer is 409 `ASSIGNMENT_STALE` (the
|
|
149
|
+
* current one in `details.currentVersion`) and nothing is written, neither
|
|
150
|
+
* the values nor a request: re-read, merge and resubmit. Two writes from
|
|
151
|
+
* the same version are told apart by the database itself, and the second
|
|
152
|
+
* gets the same 409. WITHOUT `baseVersion` a direct write silently
|
|
153
|
+
* overwrites a colleague's edit, last write winning — the field is optional
|
|
154
|
+
* only for compatibility.
|
|
151
155
|
*
|
|
152
156
|
* Returns `Gated` for the same reason as `assign`.
|
|
153
157
|
*/
|
|
@@ -165,15 +169,25 @@ export class CategoriesResource {
|
|
|
165
169
|
return toGated<OperationCategoryAssignment, ApprovalRequestCreated>(res.status, res.data)
|
|
166
170
|
}
|
|
167
171
|
|
|
168
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Soft: the assignment goes to `removed` and its history survives.
|
|
174
|
+
*
|
|
175
|
+
* `baseVersion` locks like `updateAssignment`'s: changed since that version
|
|
176
|
+
* — 409 `ASSIGNMENT_STALE`, nothing removed. Without it the removal is
|
|
177
|
+
* still conditional on the version this request read, so an edit or a
|
|
178
|
+
* removal that got in first produces the same 409 instead of being
|
|
179
|
+
* overwritten.
|
|
180
|
+
*/
|
|
169
181
|
removeAssignment(
|
|
170
182
|
type: OperationType,
|
|
171
183
|
operationId: string,
|
|
172
184
|
assignmentId: string,
|
|
185
|
+
options: { baseVersion?: number | undefined } = {},
|
|
173
186
|
): Promise<{ removed: boolean }> {
|
|
174
187
|
return this.#http.request(
|
|
175
188
|
'DELETE',
|
|
176
189
|
`${this.#assignments(type, operationId)}/${seg(assignmentId)}`,
|
|
190
|
+
{ query: { ...options } },
|
|
177
191
|
)
|
|
178
192
|
}
|
|
179
193
|
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
CounterpartyGroup,
|
|
8
8
|
AddCounterpartyAddressBody,
|
|
9
9
|
CounterpartiesPage,
|
|
10
|
+
CounterpartiesSummary,
|
|
10
11
|
CounterpartyAddressCreated,
|
|
11
12
|
CounterpartyCreated,
|
|
12
13
|
CounterpartyDetail,
|
|
@@ -18,20 +19,48 @@ import type {
|
|
|
18
19
|
PatchCounterpartyGroupBody,
|
|
19
20
|
} from '../generated/types.js'
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The filters `list()` and `summary()` share. A multi-value filter takes a
|
|
24
|
+
* string or an array, sent as one comma-separated value (OR), at most 50
|
|
25
|
+
* values — more is 400 `TOO_MANY_VALUES`.
|
|
26
|
+
*/
|
|
27
|
+
export interface CounterpartyFilters {
|
|
28
|
+
/** A substring of the name. */
|
|
22
29
|
search?: string | undefined
|
|
23
30
|
kind?: string | undefined
|
|
24
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* An on-chain address — the only way to find a counterparty by it. An EVM
|
|
33
|
+
* address compares case-insensitively (its case is only the EIP-55
|
|
34
|
+
* checksum), any other network exactly.
|
|
35
|
+
*/
|
|
25
36
|
address?: string | undefined
|
|
37
|
+
/** With `address`: look for it on this network only (`Network.slug`). */
|
|
38
|
+
network?: string | undefined
|
|
26
39
|
groupId?: string | undefined
|
|
27
40
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
41
|
+
* Counterparty tags, matched after normalisation: case (Cyrillic included),
|
|
42
|
+
* `ё` = `е` and extra spaces do not matter.
|
|
43
|
+
*/
|
|
44
|
+
tag?: string | readonly string[] | undefined
|
|
45
|
+
/**
|
|
46
|
+
* `true` returns ONLY archived entries. Anything else — `false`, or leaving
|
|
47
|
+
* it out — returns only active ones: there is no way to ask for both at
|
|
48
|
+
* once. (Earlier versions of this note said the default returned both; the
|
|
49
|
+
* handler filters to active ones.)
|
|
31
50
|
*/
|
|
32
51
|
archived?: boolean | undefined
|
|
33
52
|
}
|
|
34
53
|
|
|
54
|
+
export interface ListCounterpartiesParams extends CounterpartyFilters, PageParams {}
|
|
55
|
+
|
|
56
|
+
/** What `summary()` can count by. */
|
|
57
|
+
export type CounterpartyFacet = keyof CounterpartiesSummary['facets']
|
|
58
|
+
|
|
59
|
+
export interface CounterpartiesSummaryParams extends CounterpartyFilters {
|
|
60
|
+
/** Which counters to compute. Only those asked for come back. */
|
|
61
|
+
facets?: CounterpartyFacet | readonly CounterpartyFacet[] | undefined
|
|
62
|
+
}
|
|
63
|
+
|
|
35
64
|
/**
|
|
36
65
|
* The counterparty directory.
|
|
37
66
|
*
|
|
@@ -58,10 +87,35 @@ export class CounterpartiesResource {
|
|
|
58
87
|
this.#base = `/api/v1/vaults/${seg(vaultCode)}/counterparties`
|
|
59
88
|
}
|
|
60
89
|
|
|
90
|
+
/**
|
|
91
|
+
* One page of the directory. `operationsCount` is how many operations with
|
|
92
|
+
* the counterparty YOU see — the set `history.list({ includeShared: true,
|
|
93
|
+
* counterpartyId })` walks; `_count` is in your scope too, and an
|
|
94
|
+
* administrator's covers the whole vault. `groupIds` are its non-archived
|
|
95
|
+
* groups.
|
|
96
|
+
*/
|
|
61
97
|
list(params: ListCounterpartiesParams = {}): Promise<CounterpartiesPage> {
|
|
62
98
|
return this.#http.request<CounterpartiesPage>('GET', this.#base, { query: { ...params } })
|
|
63
99
|
}
|
|
64
100
|
|
|
101
|
+
/**
|
|
102
|
+
* How many counterparties match, and counters per value of the requested
|
|
103
|
+
* `facets` (`tag`, `kind`, `groupId`) under the same filters as `list()`.
|
|
104
|
+
*
|
|
105
|
+
* A facet is counted with every filter except its own dimension; `count`
|
|
106
|
+
* applies all of them. Only values met appear (no zeros), the top 50 per
|
|
107
|
+
* dimension, the rest in `otherCount`; `value: null` is "no value" (no
|
|
108
|
+
* kind, in no group, no tags). Tags are grouped by normalised spelling and
|
|
109
|
+
* shown in the most frequent one; `groupId` counts non-archived groups and
|
|
110
|
+
* carries the group's name as `label`. An unknown facet is 400
|
|
111
|
+
* `INVALID_FILTER_VALUE`.
|
|
112
|
+
*/
|
|
113
|
+
summary(params: CounterpartiesSummaryParams = {}): Promise<CounterpartiesSummary> {
|
|
114
|
+
return this.#http.request<CounterpartiesSummary>('GET', `${this.#base}/summary`, {
|
|
115
|
+
query: { ...params },
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
65
119
|
get(counterpartyId: string): Promise<CounterpartyDetail> {
|
|
66
120
|
return this.#http.request<CounterpartyDetail>('GET', `${this.#base}/${seg(counterpartyId)}`)
|
|
67
121
|
}
|