@owneraio/finp2p-sdk-js 0.28.41 → 0.29.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 (61) hide show
  1. package/README.md +22 -1
  2. package/lib/OwneraAPI/__tests__/utils.test.d.ts +1 -0
  3. package/lib/OwneraAPI/__tests__/utils.test.js +82 -0
  4. package/lib/OwneraAPI/__tests__/utils.test.js.map +1 -0
  5. package/lib/OwneraAPI/finp2p-node-api/__tests__/agreements.test.d.ts +1 -0
  6. package/lib/OwneraAPI/finp2p-node-api/__tests__/agreements.test.js +149 -0
  7. package/lib/OwneraAPI/finp2p-node-api/__tests__/agreements.test.js.map +1 -0
  8. package/lib/OwneraAPI/finp2p-node-api/__tests__/collateral.test.d.ts +1 -0
  9. package/lib/OwneraAPI/finp2p-node-api/__tests__/collateral.test.js +502 -0
  10. package/lib/OwneraAPI/finp2p-node-api/__tests__/collateral.test.js.map +1 -0
  11. package/lib/OwneraAPI/finp2p-node-api/agreements.d.ts +8 -0
  12. package/lib/OwneraAPI/finp2p-node-api/agreements.js +31 -0
  13. package/lib/OwneraAPI/finp2p-node-api/agreements.js.map +1 -0
  14. package/lib/OwneraAPI/finp2p-node-api/collateral.d.ts +16 -0
  15. package/lib/OwneraAPI/finp2p-node-api/collateral.js +131 -0
  16. package/lib/OwneraAPI/finp2p-node-api/collateral.js.map +1 -0
  17. package/lib/OwneraAPI/index.js +4 -0
  18. package/lib/OwneraAPI/index.js.map +1 -1
  19. package/lib/OwneraAPI/oss-api/__tests__/filterUtils.test.d.ts +1 -0
  20. package/lib/OwneraAPI/oss-api/__tests__/filterUtils.test.js +15 -0
  21. package/lib/OwneraAPI/oss-api/__tests__/filterUtils.test.js.map +1 -0
  22. package/lib/OwneraAPI/oss-api/__tests__/getAgreements.test.d.ts +1 -0
  23. package/lib/OwneraAPI/oss-api/__tests__/getAgreements.test.js +175 -0
  24. package/lib/OwneraAPI/oss-api/__tests__/getAgreements.test.js.map +1 -0
  25. package/lib/OwneraAPI/oss-api/__tests__/getCollateralAgreements.test.d.ts +1 -0
  26. package/lib/OwneraAPI/oss-api/__tests__/getCollateralAgreements.test.js +321 -0
  27. package/lib/OwneraAPI/oss-api/__tests__/getCollateralAgreements.test.js.map +1 -0
  28. package/lib/OwneraAPI/oss-api/__tests__/getCollateralReports.test.d.ts +1 -0
  29. package/lib/OwneraAPI/oss-api/__tests__/getCollateralReports.test.js +152 -0
  30. package/lib/OwneraAPI/oss-api/__tests__/getCollateralReports.test.js.map +1 -0
  31. package/lib/OwneraAPI/oss-api/oss.js +576 -0
  32. package/lib/OwneraAPI/oss-api/oss.js.map +1 -1
  33. package/lib/OwneraAPI/utils.js +51 -9
  34. package/lib/OwneraAPI/utils.js.map +1 -1
  35. package/lib/types/Agreements/Agreements.d.ts +355 -0
  36. package/lib/types/Agreements/Agreements.js +3 -0
  37. package/lib/types/Agreements/Agreements.js.map +1 -0
  38. package/lib/types/Agreements/index.d.ts +1 -0
  39. package/lib/types/Agreements/index.js +18 -0
  40. package/lib/types/Agreements/index.js.map +1 -0
  41. package/lib/types/Collateral/Collateral.d.ts +564 -0
  42. package/lib/types/Collateral/Collateral.js +3 -0
  43. package/lib/types/Collateral/Collateral.js.map +1 -0
  44. package/lib/types/Collateral/index.d.ts +1 -0
  45. package/lib/types/Collateral/index.js +18 -0
  46. package/lib/types/Collateral/index.js.map +1 -0
  47. package/lib/types/Core/OwneraAPI.d.ts +4 -0
  48. package/lib/types/Oss/Agreements.d.ts +671 -0
  49. package/lib/types/Oss/Agreements.js +3 -0
  50. package/lib/types/Oss/Agreements.js.map +1 -0
  51. package/lib/types/Oss/Oss.d.ts +63 -0
  52. package/lib/types/Oss/index.d.ts +1 -0
  53. package/lib/types/Oss/index.js +1 -0
  54. package/lib/types/Oss/index.js.map +1 -1
  55. package/lib/types/Oss/utils.d.ts +7 -0
  56. package/lib/types/index.d.ts +2 -0
  57. package/lib/types/index.js +2 -0
  58. package/lib/types/index.js.map +1 -1
  59. package/lib/types/utils.d.ts +5 -0
  60. package/lib/types/utils.js.map +1 -1
  61. package/package.json +1 -1
@@ -0,0 +1,564 @@
1
+ import { RequestOptions } from '../Commons';
2
+ /**
3
+ * Collateral facade REST surface — shapes authored from finp2p-core
4
+ * `api/collateral-api.gen.yaml` (`/collateral/*` paths). The facade is mounted on
5
+ * the shared `/finapi` server; it authors roles, participants, policy templates
6
+ * and canonical container keys itself, so callers supply business inputs only.
7
+ */
8
+ /**
9
+ * Collateral agreement role vocabulary accepted by the facade on writes (`agreementRole`).
10
+ *
11
+ * `vault-controller` controls and provisions the agreement's vaults. Read the role an agreement
12
+ * actually binds off `setup.provisionerRole`.
13
+ */
14
+ export type CollateralAgreementRole = 'pledger' | 'receiver' | 'vault-controller' | 'valuation-engine';
15
+ /**
16
+ * Roles that a collateral agreement may expose on reads.
17
+ *
18
+ * collateral-terms/v3 binds ONE `approver` role to both party orgs: each side approves what the
19
+ * other posts, and the side a report calls may not decide its own list. The node binds it itself:
20
+ * a propose carries no approver field, and approve, reject and `consentRoles` never accept it.
21
+ *
22
+ * Read-side role fields stay `string`: agreements proposed before the facade dropped `calculator`
23
+ * may still carry that binding, and generic agreements may bind other roles. Use this type to
24
+ * compare against the known collateral roles.
25
+ */
26
+ export type CollateralAgreementBoundRole = CollateralAgreementRole | 'approver';
27
+ /** The schema bundle an agreement is governed by; it becomes the agreement's termsType */
28
+ export type CollateralDefinitionTemplate = 'collateral-terms/v3';
29
+ export interface CollateralEligibleAssetTerm {
30
+ assetId: string;
31
+ /** Decimal fraction (0.10 = 10%) */
32
+ haircut?: number;
33
+ caip19?: string;
34
+ }
35
+ /** Typed collateral terms — encoded onto the rails by the facade */
36
+ export interface CollateralTerms {
37
+ baseCurrency: string;
38
+ eligibleAssets: CollateralEligibleAssetTerm[];
39
+ /**
40
+ * Optional agreement policy for attribution pricing. The facade records it without applying
41
+ * it or validating valuations against it. Readers must allow future method strings.
42
+ */
43
+ haircutApplyMethod?: CollateralHaircutApplyMethod;
44
+ }
45
+ /** Which side(s) of the agreement a container serves. */
46
+ export type CollateralContainerRole = 'pledger' | 'receiver';
47
+ /**
48
+ * One container (vault) the agreement declares.
49
+ *
50
+ * Declared ONCE, at `parties.containers` — not per party. The entry itself says which side(s) it
51
+ * serves, so topology is read off `servesRoles` rather than carried in a separate mode field.
52
+ *
53
+ * It names WHICH CUSTODIAN provisions the container and WHAT may go in it — never an account:
54
+ * the holder is the served side's own `investorFinId`, and a side has exactly one investor.
55
+ */
56
+ export interface CollateralPartyContainer {
57
+ /**
58
+ * The side(s) this container serves: `['pledger']`, `['receiver']`, or both.
59
+ *
60
+ * A single-role container REQUIRES that side's `investorFinId`. A both-roles container binds
61
+ * neither side, and is then the ONLY container the agreement may declare.
62
+ */
63
+ servesRoles: CollateralContainerRole[];
64
+ /** The vault's controller: the org that provisions it and is bound to the vault-controller role. Defaults to `parties.controllerOrgId`. */
65
+ custodianOrgId?: string;
66
+ /**
67
+ * The subset of `terms.eligibleAssets` this container holds, by assetId. Omitted = every
68
+ * eligible asset. Each id must appear in the terms AND that terms entry must carry a `caip19`,
69
+ * or the facade refuses the proposal.
70
+ */
71
+ assetIds?: string[];
72
+ }
73
+ export interface CollateralPartyBinding {
74
+ orgId: string;
75
+ /** finId (compressed secp256k1 public key, hex) of the bound investor */
76
+ investorFinId?: string;
77
+ }
78
+ export interface CollateralParties {
79
+ pledger: CollateralPartyBinding;
80
+ receiver: CollateralPartyBinding;
81
+ /**
82
+ * Every vault the agreement declares, flat — each entry naming the side(s) it serves.
83
+ *
84
+ * At most one container per (role set, custodian). Omitted, the facade defaults it from the
85
+ * bindings: both `investorFinId`s bound gives one container per side at `controllerOrgId`; neither
86
+ * bound gives one container the sides share; exactly one bound is REFUSED, with a message
87
+ * pointing here.
88
+ */
89
+ containers?: CollateralPartyContainer[];
90
+ /**
91
+ * REQUIRED by the facade schema, but only ever a DEFAULT: the custodian of a container that names none
92
+ * (and of the bindings-derived default layout), ordered first among the vault-controller parties when it
93
+ * provisions anything. It binds no role by itself — only orgs that provision a container hold the
94
+ * vault-controller role. Callers that name `custodianOrgId` on every container may send any of those orgs.
95
+ */
96
+ controllerOrgId: string;
97
+ /** Defaults to the proposing org */
98
+ valuationEngineOrgId?: string;
99
+ }
100
+ /**
101
+ * Per-organization operational settings, stored by the facade per (agreement, organization) — NOT
102
+ * per role, never written into the agreement and not exposed by OSS. Declared on propose, on
103
+ * approve, or through `updateAgreementSettings`. An omitted field keeps its stored value; a field
104
+ * never declared is false.
105
+ */
106
+ export interface CollateralOrgSettings {
107
+ /**
108
+ * true — the node's collateral monitor resolves this org's side of a report once its overlay
109
+ * status is `completed`. Acts only when this org is a party of the report (pledger / receiver).
110
+ */
111
+ autoResolve?: boolean;
112
+ /**
113
+ * true — on direct-fulfillment reports where this org is the called party (the report sender),
114
+ * the monitor executes the report's transfer lines while it is `new` / `in_progress`, through the
115
+ * same execution-leg claim as a manual transfer.
116
+ */
117
+ autoTransfer?: boolean;
118
+ }
119
+ /**
120
+ * The calling organization's effective settings — false for anything never declared. The facade
121
+ * does not distinguish "never declared" from "declared false", and answers defaults for any id.
122
+ */
123
+ export interface CollateralOrgSettingsState {
124
+ autoResolve: boolean;
125
+ autoTransfer: boolean;
126
+ }
127
+ /** `POST /collateral/agreements` body */
128
+ export interface ProposeCollateralAgreementRequest {
129
+ terms: CollateralTerms;
130
+ parties: CollateralParties;
131
+ /** Defaults to [pledger, receiver] */
132
+ consentRoles?: CollateralAgreementRole[];
133
+ /** Epoch seconds, defaults to now */
134
+ validFrom?: number;
135
+ /** Epoch seconds, defaults to now + 1 year */
136
+ validUntil?: number;
137
+ settings?: CollateralOrgSettings;
138
+ /**
139
+ * Defaults to collateral-terms/v3 in the SDK. Reports carry only the nominal amount;
140
+ * the called side proposes the priced asset list for attribution approval.
141
+ */
142
+ definitionTemplate?: CollateralDefinitionTemplate;
143
+ }
144
+ export interface ProposeCollateralAgreementResponse {
145
+ /** Resource id of the proposed agreement */
146
+ agreementId: string;
147
+ }
148
+ export interface ApproveCollateralAgreementRequest {
149
+ role: CollateralAgreementRole;
150
+ agreementVersion: number;
151
+ /** Skip the terms-template validation (otherwise 422 TermsTemplateMismatch) */
152
+ force?: boolean;
153
+ settings?: CollateralOrgSettings;
154
+ }
155
+ export type CollateralAgreementApprovalStatus = 'PROPOSED' | 'ACTIVE';
156
+ export interface ApproveCollateralAgreementResponse {
157
+ status: CollateralAgreementApprovalStatus;
158
+ }
159
+ export interface RejectCollateralAgreementRequest {
160
+ role: CollateralAgreementRole;
161
+ reason?: string;
162
+ }
163
+ /** Both close-out documents carry an audit note and nothing else */
164
+ export interface CollateralCloseoutRequest {
165
+ /** Why the agreement is ending */
166
+ reason?: string;
167
+ }
168
+ export interface CollateralCloseoutResponse {
169
+ /** Log sequence of the appended close-out event (the ORIGINAL event's sequence on a repeat call) */
170
+ sequence: number;
171
+ }
172
+ export type CollateralReportType = 'initial' | 'variation' | 'substitution' | 'closeout_default';
173
+ export type CollateralFulfillmentMode = 'direct' | 'negotiated';
174
+ export interface CollateralReportAction {
175
+ assetId: string;
176
+ /** Decimal string */
177
+ quantity: string;
178
+ }
179
+ /**
180
+ * Agreement policy for applying haircuts when pricing attribution lines. The facade records the
181
+ * policy without applying it. Further methods are expected, so readers must not treat the list as closed.
182
+ */
183
+ export type CollateralHaircutApplyMethod = 'reduce-from-price' | 'add-to-total';
184
+ /**
185
+ * Nominal-only `POST /collateral/agreements/{agreementId}/reports` body for collateral-terms/v3.
186
+ * The single empty action authors the nominal call; the called side later proposes the priced
187
+ * asset list for approval. The haircut method comes from the agreement's terms.
188
+ */
189
+ export interface CreateCollateralReportRequest {
190
+ type: CollateralReportType;
191
+ /** Absent → derived by the node; refused on closeout_default */
192
+ fulfillmentMode?: CollateralFulfillmentMode;
193
+ /** Decimal string in the agreement's base currency */
194
+ nominalMarginAmount: string;
195
+ /** finId of the investor called to post; optional when the topology makes the direction unambiguous */
196
+ calledParty?: string;
197
+ /** Explicit container binding; optional, resolution can derive it */
198
+ containerKey?: string;
199
+ /** The nominal report marker; asset and valuation fields are deliberately absent. */
200
+ actions: [Record<string, never>];
201
+ /** Refused on closeout_default reports */
202
+ settlementAssetId?: string;
203
+ /** Substitution reports only (required for them): the exact posted position to be returned */
204
+ recoveredAsset?: CollateralReportAction;
205
+ /**
206
+ * Absolute Unix timestamp in SECONDS by which the report must be covered. A positive value later
207
+ * than the agreement terms' `reportDeadline` is refused (`InvalidFieldValue`); absent or
208
+ * non-positive means the node's default window, counted from the report's creation. The facade
209
+ * does not check that it lies in the future.
210
+ */
211
+ deadline?: number;
212
+ }
213
+ /** @deprecated Use CreateCollateralReportRequest; report creation is always nominal-only. */
214
+ export type CreateNominalCollateralReportRequest = CreateCollateralReportRequest;
215
+ export interface CreateCollateralReportResponse {
216
+ reportId: string;
217
+ sequence: number;
218
+ }
219
+ /** All seven decimal-string valuation fields carried by one proposed attribution line. */
220
+ export interface CollateralAttributionLineValuation {
221
+ /** The haircut actually applied to this line (decimal fraction) */
222
+ appliedHaircut: string;
223
+ /** Unit price before the haircut */
224
+ baseUnitPrice: string;
225
+ /** Line value before the haircut */
226
+ baseValue: string;
227
+ /** Units before the haircut */
228
+ baseUnits: string;
229
+ /** Unit price after the haircut */
230
+ finalUnitPrice: string;
231
+ /** Line value after the haircut */
232
+ finalValue: string;
233
+ /** Units after the haircut; the amount the facade transfers */
234
+ finalUnits: string;
235
+ }
236
+ /** One asset and quantity offered by the called side against a v3 nominal report. */
237
+ export interface CollateralAttributionLine {
238
+ assetId: string;
239
+ /** Units offered, as a decimal string */
240
+ quantity: string;
241
+ metadata: CollateralAttributionLineValuation;
242
+ }
243
+ /** `POST /collateral/reports/{reportId}/attribution-proposals` body (v3 only). */
244
+ export interface ProposeCollateralAttributionRequest {
245
+ /** At least one fully valued line */
246
+ lines: [CollateralAttributionLine, ...CollateralAttributionLine[]];
247
+ }
248
+ export interface ProposeCollateralAttributionResponse {
249
+ proposalId: string;
250
+ }
251
+ /** One structured reason why an approver refuses a proposed attribution line. */
252
+ export interface CollateralAttributionObjection {
253
+ assetId: string;
254
+ code: 'assetRejected' | 'amountRejected';
255
+ message?: string;
256
+ }
257
+ /**
258
+ * `POST /collateral/reports/{reportId}/attribution-proposals/{proposalId}/respond` body.
259
+ * An approval may carry an audit note; a rejection must identify at least one objection.
260
+ */
261
+ export type RespondCollateralAttributionProposalRequest = {
262
+ status: 'approved';
263
+ note?: string;
264
+ } | {
265
+ status: 'rejected';
266
+ details: CollateralAttributionObjection[];
267
+ };
268
+ export interface RespondCollateralAttributionProposalResponse {
269
+ status: 'approved' | 'rejected';
270
+ }
271
+ /**
272
+ * `POST /collateral/reports/{reportId}/resolve` body — optional in full.
273
+ *
274
+ * A resolution is the calling ORGANIZATION's answer, recorded per org rather than as a report
275
+ * status. Repeating an answer this org has already given is accepted and changes nothing, so a
276
+ * retry is safe without an idempotency key.
277
+ */
278
+ export interface ResolveCollateralReportRequest {
279
+ /** Free-text audit note */
280
+ note?: string;
281
+ }
282
+ /** `POST /collateral/reports/{reportId}/resolve` answer: the calling org's disposition, not the report's status */
283
+ export interface ResolveCollateralReportResponse {
284
+ status: 'resolved';
285
+ }
286
+ /** `POST /collateral/reports/{reportId}/reject` body. Unlike a resolution, the reason is required. */
287
+ export interface RejectCollateralReportRequest {
288
+ /** Why this organization refuses the report */
289
+ reason: string;
290
+ }
291
+ /** `POST /collateral/reports/{reportId}/reject` answer: the calling org's disposition, not the report's status */
292
+ export interface RejectCollateralReportResponse {
293
+ status: 'rejected';
294
+ }
295
+ /**
296
+ * `POST /collateral/reports/{reportId}/transfers` body — post one line against a report.
297
+ *
298
+ * The manual execution path, for direct-mode reports. A negotiated report executes its agreed
299
+ * lines automatically: the called (sender) org's facade runs them when it agrees the thread itself,
300
+ * and through its push tail / monitor sweep when the receiver agrees. A close-out report carries no
301
+ * transfer obligation and is refused with `NotExecutableReport`.
302
+ */
303
+ export interface ExecuteReportTransferRequest {
304
+ assetId: string;
305
+ /** Decimal string */
306
+ quantity: string;
307
+ /** Explicit source account; absent means the report's called party */
308
+ sourceFinId?: string;
309
+ }
310
+ export interface ExecuteReportTransferResponse {
311
+ /** The execution plan the transfer opened; the transfer settles asynchronously under it */
312
+ executionPlanId: string;
313
+ }
314
+ export type CollateralNegotiationKind = 'fulfillment' | 'substitution';
315
+ export type CollateralNegotiationThreadStatus = 'open' | 'agreed' | 'rejected' | 'withdrawn';
316
+ export type CollateralNegotiationResponseAction = 'counter' | 'agree' | 'reject' | 'withdraw';
317
+ /** One proposal line; `quantity` is a decimal string, the units the executor transfers verbatim */
318
+ export interface CollateralNegotiationLine {
319
+ assetId: string;
320
+ quantity: string;
321
+ }
322
+ /** `POST /collateral/reports/{reportId}/negotiations` body — open a thread with its round-1 offer */
323
+ export interface OpenCollateralNegotiationRequest {
324
+ kind: CollateralNegotiationKind;
325
+ /** At least one line, each asset once */
326
+ lines: CollateralNegotiationLine[];
327
+ /** minLength 1 — omit rather than send an empty string */
328
+ reason?: string;
329
+ }
330
+ export interface OpenCollateralNegotiationResponse {
331
+ negotiationId: string;
332
+ round: number;
333
+ /** Log sequence of the appended event */
334
+ sequence: number;
335
+ }
336
+ /**
337
+ * `POST /collateral/reports/{reportId}/negotiations/{negotiationId}/respond` body.
338
+ *
339
+ * `round` must be the thread's standing round (409 `NegotiationRoundStale` otherwise). `lines` are
340
+ * required on `counter` and refused on every other action.
341
+ */
342
+ export type RespondCollateralNegotiationRequest = {
343
+ action: 'counter';
344
+ round: number;
345
+ lines: CollateralNegotiationLine[];
346
+ reason?: string;
347
+ } | {
348
+ action: 'agree' | 'reject' | 'withdraw';
349
+ round: number;
350
+ lines?: never;
351
+ reason?: string;
352
+ };
353
+ export interface RespondCollateralNegotiationResponse {
354
+ round: number;
355
+ threadStatus: CollateralNegotiationThreadStatus;
356
+ sequence: number;
357
+ }
358
+ /**
359
+ * The side a report exception's problem is on — not an allocation of fault. Same vocabulary as
360
+ * {@link CollateralAgreementRole}.
361
+ */
362
+ export type CollateralExceptionBlame = 'pledger' | 'receiver' | 'vault-controller' | 'valuation-engine';
363
+ /** One diagnostic execution leg that a report exception is about */
364
+ export interface CollateralExceptionLeg {
365
+ /** The execution plan that failed, when there was one */
366
+ executionPlanId?: string;
367
+ assetId?: string;
368
+ /** Decimal string — the amount at issue */
369
+ quantity?: string;
370
+ }
371
+ /**
372
+ * `POST /collateral/reports/{reportId}/exceptions` body — park a report that cannot be covered.
373
+ *
374
+ * While any exception is open the report's deadline is held, so it is never settled incomplete
375
+ * mid-answer.
376
+ */
377
+ export interface RaiseCollateralExceptionRequest {
378
+ blame: CollateralExceptionBlame;
379
+ /** minLength 1 */
380
+ reason: string;
381
+ /** Omit for a report-level exception; otherwise send one or more legs, never `[]`. */
382
+ details?: CollateralExceptionLeg[];
383
+ }
384
+ export interface RaiseCollateralExceptionResponse {
385
+ /** `exc-YYYY-MM-DD-<uuid>` */
386
+ exceptionId: string;
387
+ }
388
+ /**
389
+ * `POST /collateral/reports/{reportId}/manual-resolves` body — ask to close the cited open
390
+ * exceptions without posting collateral (settled off-platform, or the call no longer stands). The
391
+ * request is the requester's own consent; the counterparty answers it.
392
+ */
393
+ export interface RequestCollateralManualResolveRequest {
394
+ /** At least one id of an open exception on this report */
395
+ exceptionIds: string[];
396
+ /** minLength 1 — why closing without collateral is appropriate */
397
+ reason: string;
398
+ }
399
+ export interface RequestCollateralManualResolveResponse {
400
+ /** `mrs-YYYY-MM-DD-<uuid>` */
401
+ manualResolveId: string;
402
+ }
403
+ export type CollateralManualResolveDecisionStatus = 'accepted' | 'rejected';
404
+ /**
405
+ * `POST /collateral/reports/{reportId}/manual-resolves/{manualResolveId}/respond` body. A refusal
406
+ * must say why (`InvalidFieldValue(reason)` otherwise); an acceptance may.
407
+ */
408
+ export type RespondCollateralManualResolveRequest = {
409
+ status: 'accepted';
410
+ reason?: string;
411
+ } | {
412
+ status: 'rejected';
413
+ reason: string;
414
+ };
415
+ export interface RespondCollateralManualResolveResponse {
416
+ status: CollateralManualResolveDecisionStatus;
417
+ }
418
+ /**
419
+ * `POST /collateral/reports/{reportId}/coverage-rechecks` body — ask the valuation engine to look at
420
+ * the report again because collateral landed late. A signed request, not a status change.
421
+ */
422
+ export interface RequestCollateralCoverageRecheckRequest {
423
+ /** minLength 1 */
424
+ reason: string;
425
+ }
426
+ export interface RequestCollateralCoverageRecheckResponse {
427
+ reportId: string;
428
+ }
429
+ /**
430
+ * The facade's domain-rejection vocabulary: a flat `{ code, message }` body with HTTP 409 for state
431
+ * conflicts (`NegotiationClosed`, `NegotiationRoundStale`, `SubstitutionAlreadyAgreed`,
432
+ * `NoLiveContainer`, `ReportDispositionInProgress`, `AgreementNotActive`) and HTTP 422 for the rest.
433
+ * `NotPledgingParty`, `NoApprovingParty`, `NotApprover`, `ProposalAlreadyDecided`,
434
+ * `ProposalNotApproved` and `SingleLegException` are all HTTP 422.
435
+ *
436
+ * Non-domain errors use the APIErrors envelope (`{ errors: [{ code, message }] }`): HTTP 400/code
437
+ * 1002 for decoding or OAS validation (including an empty array), code 1300 for owner or guard
438
+ * refusal (including attribution outside `reportProcessing`), and code 4003 for field
439
+ * validation (including a rejected attribution without `details`). An unknown report or thread is
440
+ * HTTP 404/code 1101, as is an unknown proposal on respond; complete reports an unknown or
441
+ * unapproved proposal as HTTP 422 `ProposalNotApproved`.
442
+ *
443
+ * The report-exception commands add `NotAgreementParticipant`, `SelfApproval` and
444
+ * `ExceptionAlreadyResolved`. Their field errors are NOT flat codes: empty strings or arrays fail
445
+ * OAS validation with code 1002; an exception id unknown on the report, a refusal without a reason
446
+ * and a report `deadline` later than the terms' `reportDeadline` use code 4003; an unknown
447
+ * `manualResolveId` uses HTTP 404/code 1101.
448
+ *
449
+ * On the rejected SDK error, `error.code` is the HTTP status (or `TRANSPORT_ERROR_CODE` when no
450
+ * response arrived) and `error.data.error` is the response body: a flat domain code is
451
+ * `error.data.error.code`, an envelope code is `error.data.error.errors[0].code`.
452
+ */
453
+ export type CollateralDomainErrorCode = 'TermsTemplateMismatch' | 'NoSuchContainer' | 'AmbiguousContainer' | 'NoContainerForParty' | 'CalledPartyNotBound' | 'AgreementNotActive' | 'NoLiveContainer' | 'NotValuationEngine' | 'AgreementNotIdle' | 'ReportEvaluationPending' | 'LastReportIncomplete' | 'ReportNotOpen' | 'NotReportParty' | 'ReportAlreadyAnswered' | 'ReportDispositionInProgress' | 'NegotiationRoundStale' | 'NegotiationClosed' | 'NotExecutableReport' | 'NotNegotiableReport' | 'NotNegotiatedReport' | 'NegotiationKindMismatch' | 'NotThreadOpener' | 'NotOfferingParty' | 'SubstitutionAlreadyAgreed' | 'UnknownSourceAccount' | 'NoDispositionOwed' | 'ReportIdentitiesUnpinned' | 'NotAgreementParticipant' | 'SelfApproval' | 'ExceptionAlreadyResolved' | 'NotPledgingParty' | 'NoApprovingParty' | 'NotApprover' | 'ProposalAlreadyDecided' | 'ProposalNotApproved' | 'SingleLegException';
454
+ export interface CollateralDomainError {
455
+ code: CollateralDomainErrorCode;
456
+ message: string;
457
+ }
458
+ /**
459
+ * Collateral facade commands: agreement-level (`/collateral/agreements*`) and the report-level
460
+ * dispositions, manual transfer, negotiation, exception and v3 attribution flows
461
+ * (`/collateral/reports*`).
462
+ *
463
+ * Negotiation is round-based: the caller must cite the thread's standing round, and only the org
464
+ * that did NOT author the standing proposal may counter, agree or reject it (the opener withdraws).
465
+ * Requires finp2p-core feat/2685 at or after 885d0b99c.
466
+ *
467
+ * `CreateCollateralReportRequest.deadline`, v3 attribution approval and the report-exception commands (`raiseReportException`,
468
+ * `requestReportManualResolve`, `respondReportManualResolve`, `requestReportCoverageRecheck`) require
469
+ * finp2p-core `feat/attribution-approval` at or after 96b1f18c. An agreement keeps the definition it
470
+ * was proposed with. Exception commands work only while the agreement is in `reportProcessing`
471
+ * (an open report exists).
472
+ */
473
+ export interface Collateral {
474
+ /** Author and propose a collateral agreement from business inputs. */
475
+ proposeAgreement(request: ProposeCollateralAgreementRequest, options?: RequestOptions): Promise<ProposeCollateralAgreementResponse>;
476
+ /** Record the calling org's consent for one of its bound roles; the last consent activates the agreement. */
477
+ approveAgreement(agreementId: string, request: ApproveCollateralAgreementRequest, options?: RequestOptions): Promise<ApproveCollateralAgreementResponse>;
478
+ /** Reject a proposed collateral agreement for a role. */
479
+ rejectAgreement(agreementId: string, request: RejectCollateralAgreementRequest, options?: RequestOptions): Promise<void>;
480
+ /** Read the calling org's per-agreement settings (org-private, served by the facade). */
481
+ getAgreementSettings(agreementId: string, options?: RequestOptions): Promise<CollateralOrgSettingsState>;
482
+ /** Update the calling org's per-agreement settings (an omitted field keeps its stored value). */
483
+ updateAgreementSettings(agreementId: string, request: CollateralOrgSettings, options?: RequestOptions): Promise<CollateralOrgSettingsState>;
484
+ /** Author a nominal margin report (valuation-engine authority) under collateral-terms/v3. */
485
+ createReport(agreementId: string, request: CreateCollateralReportRequest, options?: RequestOptions): Promise<CreateCollateralReportResponse>;
486
+ /** Declare the normal close-out of an agreement. */
487
+ closeout(agreementId: string, request?: CollateralCloseoutRequest, options?: RequestOptions): Promise<CollateralCloseoutResponse>;
488
+ /** Declare a default close-out of an agreement. */
489
+ closeoutDefault(agreementId: string, request?: CollateralCloseoutRequest, options?: RequestOptions): Promise<CollateralCloseoutResponse>;
490
+ /**
491
+ * Record the calling org's resolution of a report.
492
+ *
493
+ * Refused with `NotReportParty` unless the caller is the report's sender or receiver org, and
494
+ * the caller's role must be bound on the agreement. Idempotent per org: answering twice is
495
+ * accepted and changes nothing.
496
+ */
497
+ resolveReport(reportId: string, request?: ResolveCollateralReportRequest, options?: RequestOptions): Promise<ResolveCollateralReportResponse>;
498
+ /** Record the calling org's rejection of a report. Same authority as `resolveReport`; `reason` is required. */
499
+ rejectReport(reportId: string, request: RejectCollateralReportRequest, options?: RequestOptions): Promise<RejectCollateralReportResponse>;
500
+ /**
501
+ * Post one collateral line against a report, returning the execution plan it opened.
502
+ *
503
+ * On v3 the node does not check attribution consent before submitting the transfer. A later
504
+ * attribution declaration can therefore be refused after a plan may already have been created and
505
+ * may settle; policy can also reject the transfer before plan creation, and a created plan can fail.
506
+ */
507
+ executeReportTransfer(reportId: string, request: ExecuteReportTransferRequest, options?: RequestOptions): Promise<ExecuteReportTransferResponse>;
508
+ /**
509
+ * Open a negotiation thread with its round-1 offer. Either party org may open a fulfilment
510
+ * thread; a substitution thread is the pledging (sender) org's only (`NotOfferingParty`).
511
+ */
512
+ openReportNegotiation(reportId: string, request: OpenCollateralNegotiationRequest, options?: RequestOptions): Promise<OpenCollateralNegotiationResponse>;
513
+ /**
514
+ * Counter, agree or reject the standing proposal (the counterparty of its author), or withdraw
515
+ * (the opener). The Idempotency-Key cache keeps every answer except 502/503/504, and a replay with
516
+ * a different body is refused (`IdempotentRequestMismatch`), so use one key per distinct request.
517
+ */
518
+ respondReportNegotiation(reportId: string, negotiationId: string, request: RespondCollateralNegotiationRequest, options?: RequestOptions): Promise<RespondCollateralNegotiationResponse>;
519
+ /**
520
+ * Raise an exception against a report that cannot be covered, parking it: its deadline is held
521
+ * while any exception is open. Any agreement participant may raise one (`NotAgreementParticipant`
522
+ * otherwise); `blame` names the side the problem is on, not who is at fault. A legacy report with
523
+ * no authoring event cannot be cited, so the lineage guard refuses it.
524
+ */
525
+ raiseReportException(reportId: string, request: RaiseCollateralExceptionRequest, options?: RequestOptions): Promise<RaiseCollateralExceptionResponse>;
526
+ /**
527
+ * Ask to close the cited open exceptions without posting collateral. Pledger or receiver org only
528
+ * (`NotReportParty`); an already resolved exception is refused (`ExceptionAlreadyResolved`).
529
+ */
530
+ requestReportManualResolve(reportId: string, request: RequestCollateralManualResolveRequest, options?: RequestOptions): Promise<RequestCollateralManualResolveResponse>;
531
+ /**
532
+ * Accept or refuse a manual-resolve request. Only the counterparty of the requesting org may
533
+ * answer (`SelfApproval` for the requester, `NotReportParty` for anyone else). An acceptance
534
+ * resolves every exception the request cited; once that leaves no exception on the report open, the
535
+ * valuation engine completes it through the ordinary `completed` status. A refusal leaves the
536
+ * exceptions open and must carry a reason.
537
+ */
538
+ respondReportManualResolve(reportId: string, manualResolveId: string, request: RespondCollateralManualResolveRequest, options?: RequestOptions): Promise<RespondCollateralManualResolveResponse>;
539
+ /**
540
+ * Ask the valuation engine to evaluate the report again because collateral landed late. Pledger
541
+ * or receiver org only. The request is recorded, not acted on: in this core build it does not
542
+ * reopen a report already settled incomplete.
543
+ */
544
+ requestReportCoverageRecheck(reportId: string, request: RequestCollateralCoverageRecheckRequest, options?: RequestOptions): Promise<RequestCollateralCoverageRecheckResponse>;
545
+ /**
546
+ * Offer the fully valued asset list for a v3 report. The caller must be the called side
547
+ * (`report.senderOrgId`, pledger or receiver). Forward an Idempotency-Key: an uncached retry
548
+ * creates another proposal.
549
+ */
550
+ proposeReportAttribution(reportId: string, request: ProposeCollateralAttributionRequest, options?: RequestOptions): Promise<ProposeCollateralAttributionResponse>;
551
+ /**
552
+ * Approve or reject a v3 attribution proposal. The caller must be an org bound to the `approver`
553
+ * role and must not be the called side (`report.senderOrgId`), which is refused with `SelfApproval`.
554
+ * The request options are forwarded, including Idempotency-Key.
555
+ */
556
+ respondReportAttributionProposal(reportId: string, proposalId: string, request: RespondCollateralAttributionProposalRequest, options?: RequestOptions): Promise<RespondCollateralAttributionProposalResponse>;
557
+ /**
558
+ * Close an approved v3 attribution round. The caller must be the called side
559
+ * (`report.senderOrgId`, pledger or receiver). An unapproved proposal returns `ProposalNotApproved`.
560
+ * The request options are forwarded, including Idempotency-Key. The node's `{}` response is
561
+ * discarded and the promise resolves void.
562
+ */
563
+ completeReportAttribution(reportId: string, proposalId: string, options?: RequestOptions): Promise<void>;
564
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Collateral.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collateral.js","sourceRoot":"","sources":["../../../src/types/Collateral/Collateral.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './Collateral';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Collateral"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/Collateral/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
@@ -15,6 +15,8 @@ import { Messages } from '../Messages';
15
15
  import { Ledgers, Custodies } from '../Ledgers';
16
16
  import { InvestorAccounts } from '../InvestorAccounts';
17
17
  import { Policies } from '../Policies';
18
+ import { Agreements } from '../Agreements';
19
+ import { Collateral } from '../Collateral';
18
20
  import { PinningConfigData, CreatePinningConfigRequest, UpdatePinningConfigRequest, DeletePinningConfigRequest } from '../PinningConfig';
19
21
  import { RequestOptions } from '../Commons';
20
22
  export interface OwneraAPIInterface {
@@ -32,6 +34,8 @@ export interface OwneraAPIInterface {
32
34
  custodies: Custodies;
33
35
  investorAccounts: InvestorAccounts;
34
36
  policies: Policies;
37
+ agreements: Agreements;
38
+ collateral: Collateral;
35
39
  approvalsConfig: ApprovalsConfig;
36
40
  data: DataApi;
37
41
  getPinningConfig: () => Promise<PinningConfigData[]>;