@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.
Files changed (173) hide show
  1. package/CHANGELOG.md +175 -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 +218 -2
  20. package/dist/cjs/generated/operations.d.ts.map +1 -1
  21. package/dist/cjs/generated/operations.js +220 -4
  22. package/dist/cjs/generated/operations.js.map +1 -1
  23. package/dist/cjs/generated/types.d.ts +945 -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/auth.d.ts +17 -1
  40. package/dist/cjs/resources/auth.d.ts.map +1 -1
  41. package/dist/cjs/resources/auth.js +20 -0
  42. package/dist/cjs/resources/auth.js.map +1 -1
  43. package/dist/cjs/resources/balances.d.ts +14 -7
  44. package/dist/cjs/resources/balances.d.ts.map +1 -1
  45. package/dist/cjs/resources/balances.js +10 -4
  46. package/dist/cjs/resources/balances.js.map +1 -1
  47. package/dist/cjs/resources/categories.d.ts +20 -6
  48. package/dist/cjs/resources/categories.d.ts.map +1 -1
  49. package/dist/cjs/resources/categories.js +19 -7
  50. package/dist/cjs/resources/categories.js.map +1 -1
  51. package/dist/cjs/resources/counterparties.d.ts +52 -6
  52. package/dist/cjs/resources/counterparties.d.ts.map +1 -1
  53. package/dist/cjs/resources/counterparties.js +24 -0
  54. package/dist/cjs/resources/counterparties.js.map +1 -1
  55. package/dist/cjs/resources/history.d.ts +227 -26
  56. package/dist/cjs/resources/history.d.ts.map +1 -1
  57. package/dist/cjs/resources/history.js +46 -0
  58. package/dist/cjs/resources/history.js.map +1 -1
  59. package/dist/cjs/resources/me.d.ts +17 -1
  60. package/dist/cjs/resources/me.d.ts.map +1 -1
  61. package/dist/cjs/resources/me.js +19 -0
  62. package/dist/cjs/resources/me.js.map +1 -1
  63. package/dist/cjs/resources/members.d.ts +21 -1
  64. package/dist/cjs/resources/members.d.ts.map +1 -1
  65. package/dist/cjs/resources/members.js +15 -0
  66. package/dist/cjs/resources/members.js.map +1 -1
  67. package/dist/cjs/resources/operations.d.ts +179 -4
  68. package/dist/cjs/resources/operations.d.ts.map +1 -1
  69. package/dist/cjs/resources/operations.js +192 -2
  70. package/dist/cjs/resources/operations.js.map +1 -1
  71. package/dist/cjs/resources/registries.d.ts +19 -2
  72. package/dist/cjs/resources/registries.d.ts.map +1 -1
  73. package/dist/cjs/resources/registries.js +16 -0
  74. package/dist/cjs/resources/registries.js.map +1 -1
  75. package/dist/cjs/version.d.ts +1 -1
  76. package/dist/cjs/version.js +1 -1
  77. package/dist/esm/client.d.ts +27 -34
  78. package/dist/esm/client.d.ts.map +1 -1
  79. package/dist/esm/client.js +69 -0
  80. package/dist/esm/client.js.map +1 -1
  81. package/dist/esm/core/gated.d.ts +12 -10
  82. package/dist/esm/core/gated.d.ts.map +1 -1
  83. package/dist/esm/core/gated.js +12 -10
  84. package/dist/esm/core/gated.js.map +1 -1
  85. package/dist/esm/core/http.d.ts +18 -0
  86. package/dist/esm/core/http.d.ts.map +1 -1
  87. package/dist/esm/core/http.js +11 -1
  88. package/dist/esm/core/http.js.map +1 -1
  89. package/dist/esm/core/pagination.d.ts +11 -9
  90. package/dist/esm/core/pagination.d.ts.map +1 -1
  91. package/dist/esm/core/pagination.js +11 -9
  92. package/dist/esm/core/pagination.js.map +1 -1
  93. package/dist/esm/generated/operations.d.ts +218 -2
  94. package/dist/esm/generated/operations.d.ts.map +1 -1
  95. package/dist/esm/generated/operations.js +220 -4
  96. package/dist/esm/generated/operations.js.map +1 -1
  97. package/dist/esm/generated/types.d.ts +945 -93
  98. package/dist/esm/generated/types.d.ts.map +1 -1
  99. package/dist/esm/index.d.ts +6 -6
  100. package/dist/esm/index.d.ts.map +1 -1
  101. package/dist/esm/index.js.map +1 -1
  102. package/dist/esm/resources/addresses.d.ts +91 -4
  103. package/dist/esm/resources/addresses.d.ts.map +1 -1
  104. package/dist/esm/resources/addresses.js +55 -3
  105. package/dist/esm/resources/addresses.js.map +1 -1
  106. package/dist/esm/resources/admin.d.ts +32 -1
  107. package/dist/esm/resources/admin.d.ts.map +1 -1
  108. package/dist/esm/resources/admin.js +45 -0
  109. package/dist/esm/resources/admin.js.map +1 -1
  110. package/dist/esm/resources/approvals.d.ts +30 -2
  111. package/dist/esm/resources/approvals.d.ts.map +1 -1
  112. package/dist/esm/resources/approvals.js.map +1 -1
  113. package/dist/esm/resources/auth.d.ts +17 -1
  114. package/dist/esm/resources/auth.d.ts.map +1 -1
  115. package/dist/esm/resources/auth.js +20 -0
  116. package/dist/esm/resources/auth.js.map +1 -1
  117. package/dist/esm/resources/balances.d.ts +14 -7
  118. package/dist/esm/resources/balances.d.ts.map +1 -1
  119. package/dist/esm/resources/balances.js +10 -4
  120. package/dist/esm/resources/balances.js.map +1 -1
  121. package/dist/esm/resources/categories.d.ts +20 -6
  122. package/dist/esm/resources/categories.d.ts.map +1 -1
  123. package/dist/esm/resources/categories.js +19 -7
  124. package/dist/esm/resources/categories.js.map +1 -1
  125. package/dist/esm/resources/counterparties.d.ts +52 -6
  126. package/dist/esm/resources/counterparties.d.ts.map +1 -1
  127. package/dist/esm/resources/counterparties.js +24 -0
  128. package/dist/esm/resources/counterparties.js.map +1 -1
  129. package/dist/esm/resources/history.d.ts +227 -26
  130. package/dist/esm/resources/history.d.ts.map +1 -1
  131. package/dist/esm/resources/history.js +46 -0
  132. package/dist/esm/resources/history.js.map +1 -1
  133. package/dist/esm/resources/me.d.ts +17 -1
  134. package/dist/esm/resources/me.d.ts.map +1 -1
  135. package/dist/esm/resources/me.js +19 -0
  136. package/dist/esm/resources/me.js.map +1 -1
  137. package/dist/esm/resources/members.d.ts +21 -1
  138. package/dist/esm/resources/members.d.ts.map +1 -1
  139. package/dist/esm/resources/members.js +15 -0
  140. package/dist/esm/resources/members.js.map +1 -1
  141. package/dist/esm/resources/operations.d.ts +179 -4
  142. package/dist/esm/resources/operations.d.ts.map +1 -1
  143. package/dist/esm/resources/operations.js +192 -2
  144. package/dist/esm/resources/operations.js.map +1 -1
  145. package/dist/esm/resources/registries.d.ts +19 -2
  146. package/dist/esm/resources/registries.d.ts.map +1 -1
  147. package/dist/esm/resources/registries.js +16 -0
  148. package/dist/esm/resources/registries.js.map +1 -1
  149. package/dist/esm/version.d.ts +1 -1
  150. package/dist/esm/version.js +1 -1
  151. package/docs/concepts.md +13 -11
  152. package/docs/errors.md +73 -5
  153. package/package.json +1 -1
  154. package/src/client.ts +40 -0
  155. package/src/core/gated.ts +12 -10
  156. package/src/core/http.ts +30 -1
  157. package/src/core/pagination.ts +11 -9
  158. package/src/generated/operations.ts +220 -4
  159. package/src/generated/types.ts +990 -95
  160. package/src/index.ts +15 -1
  161. package/src/resources/addresses.ts +102 -4
  162. package/src/resources/admin.ts +59 -0
  163. package/src/resources/approvals.ts +30 -2
  164. package/src/resources/auth.ts +22 -1
  165. package/src/resources/balances.ts +14 -7
  166. package/src/resources/categories.ts +19 -5
  167. package/src/resources/counterparties.ts +59 -5
  168. package/src/resources/history.ts +238 -27
  169. package/src/resources/me.ts +22 -0
  170. package/src/resources/members.ts +30 -0
  171. package/src/resources/operations.ts +264 -5
  172. package/src/resources/registries.ts +26 -3
  173. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/resources/history.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AA+DtD;IACW,KAAK,CAAY;IACjB,KAAK,CAAQ;IAEtB,YAAY,IAAgB,EAAE,SAAiB;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,KAAK,GAAG,kBAAkB,IAAA,aAAG,EAAC,SAAS,CAAC,UAAU,CAAA;IACzD,CAAC;IAED,IAAI,CAAC,MAAM,GAAkB,EAAE;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAA;IAC3F,CAAC;CACF"}
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/resources/history.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AAmOtD;IACW,KAAK,CAAY;IACjB,KAAK,CAAQ;IAEtB,YAAY,IAAgB,EAAE,SAAiB;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,KAAK,GAAG,kBAAkB,IAAA,aAAG,EAAC,SAAS,CAAC,UAAU,CAAA;IACzD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,IAAI,CAAC,MAAM,GAAkB,EAAE;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAkB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAA;IACzF,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,MAAM,GAAyB,EAAE;QACvC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,UAAU,EAAE;YACxE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE;SACrB,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -1,5 +1,6 @@
1
1
  import type { HttpClient } from '../core/http.js';
2
- import type { AllowedSegmentsResponse, MeVaultResponse, PatchProfileBody, PushToken, RegisterPushTokenBody, UserProfile } from '../generated/types.js';
2
+ import type { PageParams } from '../core/pagination.js';
3
+ import type { AllowedSegmentsResponse, MeVaultResponse, MySessionList, PatchProfileBody, PushToken, RegisterPushTokenBody, UserProfile } from '../generated/types.js';
3
4
  /** The caller's own profile, devices and permissions. Not scoped to a vault. */
4
5
  export declare class MeResource {
5
6
  #private;
@@ -51,6 +52,21 @@ export declare class MeResource {
51
52
  vaultId: string;
52
53
  action: string;
53
54
  }): Promise<AllowedSegmentsResponse>;
55
+ /**
56
+ * Where I am signed in: my live sessions — the phone, the web version, the
57
+ * Mac app, a browser — newest first, with `current` on the one making this
58
+ * request.
59
+ *
60
+ * Open to ANY session, a web or Mac one included, because it carries
61
+ * nothing worth stealing: no tokens, no IP addresses, no raw user agent.
62
+ * Read-only — ending another session is better-auth's own
63
+ * `/api/auth/revoke-session` and its neighbours, which a web or Mac
64
+ * session is refused; signing out of this session is always possible.
65
+ * Expired sessions are not listed, and neither are web or Mac ones older
66
+ * than 30 days from sign-in — their real ceiling, which is what
67
+ * `expiresAt` says for them.
68
+ */
69
+ sessions(params?: PageParams): Promise<MySessionList>;
54
70
  registerPushToken(input: RegisterPushTokenBody): Promise<PushToken>;
55
71
  /** `deleted: false` simply means the token was not registered — not a failure. */
56
72
  removePushToken(token: string): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/resources/me.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAE9B,gFAAgF;AAChF,qBAAa,UAAU;;IAGrB,YAAY,IAAI,EAAE,UAAU,EAE3B;IAED,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAE9B;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAE3D;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAInD;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC,CAEhC;IAED;;;;;;;OAOG;IACH,eAAe,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAI7F;IAED,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC,CAElE;IAED,kFAAkF;IAClF,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAK5D;CACF"}
1
+ {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/resources/me.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAE9B,gFAAgF;AAChF,qBAAa,UAAU;;IAGrB,YAAY,IAAI,EAAE,UAAU,EAE3B;IAED,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAE9B;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAE3D;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAInD;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC,CAEhC;IAED;;;;;;;OAOG;IACH,eAAe,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAI7F;IAED;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAIxD;IAED,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC,CAElE;IAED,kFAAkF;IAClF,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAK5D;CACF"}
@@ -63,6 +63,25 @@ class MeResource {
63
63
  query: { ...params },
64
64
  });
65
65
  }
66
+ /**
67
+ * Where I am signed in: my live sessions — the phone, the web version, the
68
+ * Mac app, a browser — newest first, with `current` on the one making this
69
+ * request.
70
+ *
71
+ * Open to ANY session, a web or Mac one included, because it carries
72
+ * nothing worth stealing: no tokens, no IP addresses, no raw user agent.
73
+ * Read-only — ending another session is better-auth's own
74
+ * `/api/auth/revoke-session` and its neighbours, which a web or Mac
75
+ * session is refused; signing out of this session is always possible.
76
+ * Expired sessions are not listed, and neither are web or Mac ones older
77
+ * than 30 days from sign-in — their real ceiling, which is what
78
+ * `expiresAt` says for them.
79
+ */
80
+ sessions(params = {}) {
81
+ return this.#http.request('GET', '/api/v1/me/sessions', {
82
+ query: { ...params },
83
+ });
84
+ }
66
85
  registerPushToken(input) {
67
86
  return this.#http.request('POST', '/api/v1/me/push-tokens', { body: input });
68
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"me.js","sourceRoot":"","sources":["../../../src/resources/me.ts"],"names":[],"mappings":";;;AAUA,gFAAgF;AAChF;IACW,KAAK,CAAY;IAE1B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,KAAK,EAAE,oBAAoB,CAAC,CAAA;IACrE,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,KAAuB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,OAAO,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACxF,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,KAAa;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,MAAM,EAAE,0BAA0B,EAAE;YAC/E,IAAI,EAAE,EAAE,KAAK,EAAE;SAChB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK;QACH,OAA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,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAkB,KAAK,EAAE,kBAAkB,CAAC,CAAA;IACvE,CAAC;IAED;;;;;;;OAOG;IACH,eAAe,CAAC,MAA2C;QACzD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA0B,KAAK,EAAE,6BAA6B,EAAE;YACvF,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE;SACrB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAM,GAAe,EAAE;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB,KAAK,EAAE,qBAAqB,EAAE;YACrE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,iBAAiB,CAAC,KAA4B;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAY,MAAM,EAAE,wBAAwB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACzF,CAAC;IAED,kFAAkF;IAClF,eAAe,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,QAAQ,EACR,0BAA0B,kBAAkB,CAAC,KAAK,CAAC,EAAE,CACtD,CAAA;IACH,CAAC;CACF"}
@@ -1,6 +1,13 @@
1
1
  import { type HttpClient } from '../core/http.js';
2
2
  import type { PageParams } from '../core/pagination.js';
3
- import type { MemberCard, MemberDetail, MembersPage, UserGroup, UserGroupDetail, UserGroupMembers } from '../generated/types.js';
3
+ import type { ActionType, MemberCard, MemberDetail, MembersPage, PolicyDirectoryPage, UserGroup, UserGroupDetail, UserGroupMembers } from '../generated/types.js';
4
+ export interface PolicyDirectoryParams extends PageParams {
5
+ actionType?: ActionType | undefined;
6
+ effect?: 'allow' | 'block' | undefined;
7
+ enabled?: boolean | undefined;
8
+ /** Only the policies of groups I belong to. Without it — every group's. */
9
+ mine?: boolean | undefined;
10
+ }
4
11
  /**
5
12
  * People in the vault, and the groups they belong to.
6
13
  *
@@ -48,6 +55,19 @@ export declare class MembersResource {
48
55
  * policies stays administrator-only.
49
56
  */
50
57
  group(groupId: string): Promise<UserGroupDetail>;
58
+ /**
59
+ * Every policy of the vault by name — code, name, look, `actionType`,
60
+ * `effect`, `enabled` and the group it hangs on — for a "decided by" label
61
+ * and the feed's `decisionPolicyId` filter. Open to any member, and it
62
+ * lists the policies of ALL groups, not only yours: rule names are not
63
+ * personal data and each group's detail already shows them.
64
+ *
65
+ * No rules, conditions, limits, thresholds or signers here — those stay
66
+ * with the administrator endpoints (`admin.policies`). The fields are the
67
+ * ones `group()` shows in `policies[]`, gathered into one list. Keyset
68
+ * paging, newest first.
69
+ */
70
+ policyDirectory(params?: PolicyDirectoryParams): Promise<PolicyDirectoryPage>;
51
71
  groupMembers(groupId: string): Promise<UserGroupMembers>;
52
72
  }
53
73
  //# sourceMappingURL=members.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../../../src/resources/members.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;;;;;GAOG;AACH,qBAAa,eAAe;;IAI1B,YAAY,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAG9C;IAED,IAAI,CAAC,MAAM,GAAE,UAAU,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAIxE;IAED,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAK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AC,WAAW,CAAC,CAIxE;IAED,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAKzC;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAM7C;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAO,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAMpF;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAK/C;IAED;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAMhF;IAED,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAKvD;CACF"}
@@ -59,6 +59,21 @@ class MembersResource {
59
59
  group(groupId) {
60
60
  return this.#http.request('GET', `/api/v1/vaults/${this.#vault}/user-groups/${(0, http_js_1.seg)(groupId)}`);
61
61
  }
62
+ /**
63
+ * Every policy of the vault by name — code, name, look, `actionType`,
64
+ * `effect`, `enabled` and the group it hangs on — for a "decided by" label
65
+ * and the feed's `decisionPolicyId` filter. Open to any member, and it
66
+ * lists the policies of ALL groups, not only yours: rule names are not
67
+ * personal data and each group's detail already shows them.
68
+ *
69
+ * No rules, conditions, limits, thresholds or signers here — those stay
70
+ * with the administrator endpoints (`admin.policies`). The fields are the
71
+ * ones `group()` shows in `policies[]`, gathered into one list. Keyset
72
+ * paging, newest first.
73
+ */
74
+ policyDirectory(params = {}) {
75
+ return this.#http.request('GET', `/api/v1/vaults/${this.#vault}/policy-directory`, { query: { ...params } });
76
+ }
62
77
  groupMembers(groupId) {
63
78
  return this.#http.request('GET', `/api/v1/vaults/${this.#vault}/user-groups/${(0, http_js_1.seg)(groupId)}/members`);
64
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"members.js","sourceRoot":"","sources":["../../../src/resources/members.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AAWtD;;;;;;;GAOG;AACH;IACW,KAAK,CAAY;IACjB,MAAM,CAAQ;IAEvB,YAAY,IAAgB,EAAE,SAAiB;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,MAAM,GAAG,IAAA,aAAG,EAAC,SAAS,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,CAAC,MAAM,GAAqC,EAAE;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,KAAK,EAAE,kBAAkB,IAAI,CAAC,MAAM,UAAU,EAAE;YACrF,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,YAAY,IAAA,aAAG,EAAC,MAAM,CAAC,EAAE,CACvD,CAAA;IACH,CAAC;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,QAAgB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,kBAAkB,EAC/C,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,CACxB,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,GAAoC,EAAE;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,cAAc,EAC3C,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CACzB,CAAA;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAe;QACnB,OAAO,IAAI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MG;IACH,MAAM,CAAC,MAAM,GAAoC,EAAE;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,cAAc,EAC3C,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CACzB,CAAA;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAe;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,gBAAgB,IAAA,aAAG,EAAC,OAAO,CAAC,EAAE,CAC5D,CAAA;IACH,CAAC;IAED;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,MAAM,GAA0B,EAAE;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,mBAAmB,EAChD,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CACzB,CAAA;IACH,CAAC;IAED,YAAY,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,gBAAgB,IAAA,aAAG,EAAC,OAAO,CAAC,UAAU,CACpE,CAAA;IACH,CAAC;CACF"}
@@ -1,6 +1,8 @@
1
- import { type HttpClient } from '../core/http.js';
1
+ import { type HttpClient, type RawBody } from '../core/http.js';
2
+ import { type Gated } from '../core/gated.js';
2
3
  import type { PageParams } from '../core/pagination.js';
3
- import type { ApprovalRelations, CreateOperationRelationBody, IncomingTransactionDetail, OperationMetadata, OperationRelation, OperationRelationsPage, OperationType, PatchOperationMetadataBody } from '../generated/types.js';
4
+ import type { ApprovalRelations, ApprovalRequestCreated, CreateOperationRelationBody, IncomingTransactionDetail, OperationAttachment, OperationAttachmentDeleted, OperationAttachmentsList, OperationCounterparty, OperationMetadata, OperationRelation, OperationRelationsPage, OperationType, PatchOperationMetadataBody } from '../generated/types.js';
5
+ import type { OperationRelationType } from './history.js';
4
6
  /**
5
7
  * Operation kind in a path. Exactly two values exist.
6
8
  *
@@ -13,7 +15,7 @@ import type { ApprovalRelations, CreateOperationRelationBody, IncomingTransactio
13
15
  */
14
16
  export type OperationKind = OperationType;
15
17
  export interface ListRelationsParams extends PageParams {
16
- relationType?: 'refund' | 'reversal' | 'correction' | 'replacement' | undefined;
18
+ relationType?: OperationRelationType | undefined;
17
19
  sourceOperationId?: string | undefined;
18
20
  targetOperationId?: string | undefined;
19
21
  /** Links that carry a partial amount in this token. */
@@ -26,6 +28,20 @@ export interface ListRelationsParams extends PageParams {
26
28
  from?: string | undefined;
27
29
  to?: string | undefined;
28
30
  }
31
+ /** A file to attach, sent as the raw request body. */
32
+ export type AttachmentFile = Exclude<RawBody, FormData>;
33
+ export interface UploadAttachmentOptions {
34
+ /**
35
+ * The file's name, for a raw body. Taken from a `File` when omitted; an
36
+ * `ArrayBuffer` or `Uint8Array` has none, and a raw upload without a name is
37
+ * 400 `ATTACHMENT_FILENAME_REQUIRED`. Not used with a `FormData`: there the
38
+ * name is the form's `filename` field, or the file part's own name.
39
+ */
40
+ filename?: string | undefined;
41
+ signal?: AbortSignal | undefined;
42
+ /** An upload can be large; the client's default timeout applies otherwise. */
43
+ timeoutMs?: number | undefined;
44
+ }
29
45
  /**
30
46
  * Everything hanging off a single operation: free-form metadata, links to
31
47
  * other operations, and how its status changed over time.
@@ -43,7 +59,24 @@ export declare class OperationsResource {
43
59
  * DEFAULT state, not an edge case. Check before reading fields.
44
60
  */
45
61
  metadata(kind: OperationKind, operationId: string): Promise<OperationMetadata | null>;
46
- setMetadata(kind: OperationKind, operationId: string, input: PatchOperationMetadataBody): Promise<OperationMetadata>;
62
+ /**
63
+ * A sent field replaces its value, `null` clears it, an absent one stays.
64
+ *
65
+ * Returns `Gated`. The metadata is a facade over the assignment of the
66
+ * system category `general`, and is written the way `categories` writes:
67
+ * a version per change, an optimistic lock, and the category's approval.
68
+ * By default `general` has none and the answer is `applied` (200), as it
69
+ * always was. If an administrator set its `approvalScope`, nothing is
70
+ * written: a request is created (`category_assign` / `category_edit`) and
71
+ * the answer is `pending` (202) with its card. An edit of ANOTHER field
72
+ * made concurrently is not lost — the patch is laid over the fresh version
73
+ * up to three times before 409 `ASSIGNMENT_STALE`.
74
+ *
75
+ * Writing takes the labelling right of `general`: by default `transfer` on
76
+ * the operation's address. Seeing the operation is not enough — a signer or
77
+ * an initiator without that right gets 404.
78
+ */
79
+ setMetadata(kind: OperationKind, operationId: string, input: PatchOperationMetadataBody): Promise<Gated<OperationMetadata, ApprovalRequestCreated>>;
47
80
  /** Other operations linked to this one. A plain array, not a page. */
48
81
  relations(kind: OperationKind, operationId: string): Promise<OperationRelation[]>;
49
82
  /**
@@ -76,7 +109,149 @@ export declare class OperationsResource {
76
109
  * `sourceOperationId` alone will miss half of its links.
77
110
  */
78
111
  listRelations(params?: ListRelationsParams): Promise<OperationRelationsPage>;
112
+ /**
113
+ * Links two operations. DIRECTION: `source` is the DERIVED operation (the
114
+ * refund, reversal, correction or replacement itself), `target` the
115
+ * ORIGINAL it refers to — a deposit refunded by a transfer is source =
116
+ * transfer, target = deposit. Both must be in this vault, with `transfer`
117
+ * on the addresses of BOTH; otherwise 404 `OPERATION_NOT_FOUND`, as if
118
+ * missing.
119
+ *
120
+ * Idempotent, and not wrapped in `Gated`: a relation is unique by (type,
121
+ * source, target), and repeating the same body answers 200 with the
122
+ * existing relation where a new one answers 201 — both mean "this relation
123
+ * now exists, exactly as asked". The same triple with another amount, token
124
+ * or comment is 409 `OPERATION_RELATION_EXISTS`, the existing id in
125
+ * `details.relationId`. To change a relation, delete it and create it
126
+ * again.
127
+ *
128
+ * `relatedAmountRaw` only together with `tokenId`: a token of at least one
129
+ * of the two operations, an amount above zero and no larger than either
130
+ * side's amount in that token — otherwise 422 `OPERATION_RELATION_INVALID`,
131
+ * the field in `details.field`.
132
+ */
79
133
  createRelation(input: CreateOperationRelationBody): Promise<OperationRelation>;
134
+ /**
135
+ * Removes a relation — physically: a relation has no version history, so
136
+ * reports read the current state and report snapshots stay as they were.
137
+ *
138
+ * Its creator or an administrator. The creator needs what creating took —
139
+ * `transfer` on the addresses of BOTH operations, now; otherwise 403
140
+ * `OPERATION_RELATION_FORBIDDEN`. Someone else's relation is 403
141
+ * `NOT_RELATION_CREATOR`. A relation neither side of which you can see,
142
+ * like one already removed, is 404 `OPERATION_RELATION_NOT_FOUND`.
143
+ */
144
+ deleteRelation(relationId: string): Promise<{
145
+ deleted: true;
146
+ }>;
147
+ /**
148
+ * Picks the counterparty of a transfer or a deposit by hand, correcting a
149
+ * wrong or missing automatic match: `counterpartySource` becomes `manual`.
150
+ * `null` is a choice too — "this operation has no counterparty".
151
+ *
152
+ * The choice is written where the automatic match is, so the feed, the
153
+ * cards, the counterparty's counters and reports see it at once. Neither
154
+ * the automatic match nor the retro-match on adding an address overwrites
155
+ * it; `resetCounterparty()` hands the operation back to them. Repeating the
156
+ * same value writes nothing and answers the current state.
157
+ *
158
+ * Only a counterparty of this vault that is not archived: 404
159
+ * `COUNTERPARTY_NOT_FOUND` (someone else's and a missing one alike), 409
160
+ * `COUNTERPARTY_ARCHIVED`. A transfer awaiting signatures is 409
161
+ * `OPERATION_AWAITING_APPROVAL` — its signers see the counterparty matched
162
+ * by the recipient's address, and a manual choice then would let them sign
163
+ * a stranger's address under a trusted name. The policy decision never
164
+ * depends on this choice; it was taken by address at creation.
165
+ *
166
+ * Takes the right to write the operation's metadata: `transfer` on its
167
+ * address. Seeing it is not enough — anyone else gets 404
168
+ * `OPERATION_NOT_FOUND`.
169
+ */
170
+ setCounterparty(kind: OperationKind, operationId: string, counterpartyId: string | null): Promise<OperationCounterparty>;
171
+ /**
172
+ * Drops the manual choice and matches the operation again AT ONCE — by the
173
+ * other side's address (the recipient of a transfer, the sender of a
174
+ * deposit) against the directory as it is NOW, by the rule used at
175
+ * creation (an archived counterparty does not match). The result can
176
+ * differ from what was there before the manual choice if the directory has
177
+ * changed since.
178
+ *
179
+ * On an operation that is already automatic nothing is written and the
180
+ * current state comes back, so a repeat is safe. Afterwards
181
+ * `counterpartySource` is `auto` and `counterpartySetById`/`At` say who
182
+ * reset it and when. Same rights and the same 409
183
+ * `OPERATION_AWAITING_APPROVAL` as `setCounterparty()`.
184
+ */
185
+ resetCounterparty(kind: OperationKind, operationId: string): Promise<OperationCounterparty>;
186
+ /**
187
+ * Files attached to an operation (invoices, acts, screenshots) — metadata,
188
+ * in upload order; the bytes are fetched with `downloadAttachment()`. At
189
+ * most 20 per operation, so there is no cursor. Removed ones are not
190
+ * listed.
191
+ *
192
+ * Seen by whoever sees the operation: for a transfer an administrator, its
193
+ * initiator, a signer from the request's snapshot, or `view` on the sending
194
+ * address; for a deposit `view` on the receiving address. Anyone else gets
195
+ * 404 `OPERATION_NOT_FOUND`. A server without attachment storage answers
196
+ * 501 `ATTACHMENTS_DISABLED` on every attachment call — hide the feature
197
+ * then.
198
+ */
199
+ attachments(kind: OperationKind, operationId: string): Promise<OperationAttachmentsList>;
200
+ /**
201
+ * Attaches a file. Two forms, chosen by what you pass:
202
+ *
203
+ * • a `Blob`/`File`, an `ArrayBuffer` or a `Uint8Array` goes as the raw
204
+ * body (`application/octet-stream`, the name in `?filename=`), streamed
205
+ * to storage, up to 10 MB. `fetch` sets `Content-Length` itself, which
206
+ * the API requires (411 `ATTACHMENT_LENGTH_REQUIRED` without it);
207
+ * • a `FormData` goes as `multipart/form-data` exactly as built: the file
208
+ * in the field `file`, the name in the field `filename` or the part's
209
+ * own. Parsed in memory, so up to 5 MB. This is the form React Native
210
+ * sends a file from a `uri` with.
211
+ *
212
+ * The type is decided by the BYTES, never by a header: PDF, PNG, JPEG and
213
+ * WebP only — anything else (SVG and HTML included) is 415
214
+ * `ATTACHMENT_TYPE_NOT_ALLOWED`. The name is cleaned and its extension made
215
+ * to match the type; read the stored one from the answer. Over the size
216
+ * limit is 413 `ATTACHMENT_TOO_LARGE`; over 20 files on the operation, 409
217
+ * `ATTACHMENT_LIMIT_REACHED`; over the vault's quota (1 GB of live files by
218
+ * default), 409 `ATTACHMENT_QUOTA_EXCEEDED` with `details.quotaBytes` and
219
+ * `details.usedBytes`.
220
+ *
221
+ * Uploading takes `transfer` on the operation's address, as labelling does;
222
+ * a signer, an initiator whose grant was revoked and a view-only grant get
223
+ * 404. From a browser, a page of a site the API does not trust is refused
224
+ * with 403 `CROSS_SITE_REQUEST_REFUSED`, as every changing request is.
225
+ */
226
+ uploadAttachment(kind: OperationKind, operationId: string, file: AttachmentFile | FormData, options?: UploadAttachmentOptions): Promise<OperationAttachment>;
227
+ /**
228
+ * The file itself, as the untouched `Response`: read it with `.blob()` or
229
+ * `.arrayBuffer()`. `Content-Type` is the type detected at upload, and
230
+ * `Content-Disposition: attachment` carries the cleaned name. The same
231
+ * path is the attachment's `downloadPath`, relative to the API base.
232
+ *
233
+ * Who may read it is checked on every request, so a revoked access closes a
234
+ * cached copy too: the API answers with `ETag` = the file's SHA-256 and
235
+ * `Cache-Control: private, max-age=0, must-revalidate`. Do not send
236
+ * `If-None-Match` yourself — a 304 has no body and the transport reports it
237
+ * as an error; the browser's own revalidation is transparent. A file
238
+ * missing from storage is 502 `ATTACHMENT_STORAGE_UNAVAILABLE`.
239
+ */
240
+ downloadAttachment(kind: OperationKind, operationId: string, attachmentId: string, options?: {
241
+ signal?: AbortSignal | undefined;
242
+ }): Promise<Response>;
243
+ /**
244
+ * Removes an attachment: its uploader, while they still hold `transfer` on
245
+ * the operation's address, or an administrator — anyone else who sees the
246
+ * operation gets 403 `ATTACHMENT_DELETE_FORBIDDEN`. Soft: the file leaves
247
+ * the list and is no longer served, its bytes are erased, and the record
248
+ * stays as an audit trail. Repeating it answers the same.
249
+ *
250
+ * 502 `ATTACHMENT_STORAGE_UNAVAILABLE` with `details.deleted: true` means
251
+ * the attachment is already hidden but storage kept the bytes; repeat the
252
+ * call to clean them up.
253
+ */
254
+ deleteAttachment(kind: OperationKind, operationId: string, attachmentId: string): Promise<OperationAttachmentDeleted>;
80
255
  /**
81
256
  * An incoming payment in detail.
82
257
  *
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/resources/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,0BAA0B,EAC3B,MAAM,uBAAuB,CAAA;AAE9B;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAA;AAEzC,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAA;IAC/E,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACxB;AAED;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;;IAI7B,YAAY,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAG9C;IAMD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAKpF;IAED,WAAW,CACT,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,iBAAiB,CAAC,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AAG,OAAO,CAAC,qBAAqB,CAAC,CAK1F;IAED;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAKvF;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CACd,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,cAAc,GAAG,QAAQ,EAC/B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,mBAAmB,CAAC,CAY9B;IAED;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAChB,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;KAAO,GACjD,OAAO,CAAC,QAAQ,CAAC,CAMnB;IAED;;;;;;;;;;OAUG;IACH,gBAAgB,CACd,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,0BAA0B,CAAC,CAKrC;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAK7D;IAED;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAM9E;CACF"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OperationsResource = void 0;
4
4
  const http_js_1 = require("../core/http.js");
5
+ const gated_js_1 = require("../core/gated.js");
5
6
  /**
6
7
  * Everything hanging off a single operation: free-form metadata, links to
7
8
  * other operations, and how its status changed over time.
@@ -28,8 +29,26 @@ class OperationsResource {
28
29
  metadata(kind, operationId) {
29
30
  return this.#http.request('GET', `${this.#op(kind, operationId)}/metadata`);
30
31
  }
31
- setMetadata(kind, operationId, input) {
32
- return this.#http.request('PATCH', `${this.#op(kind, operationId)}/metadata`, { body: input });
32
+ /**
33
+ * A sent field replaces its value, `null` clears it, an absent one stays.
34
+ *
35
+ * Returns `Gated`. The metadata is a facade over the assignment of the
36
+ * system category `general`, and is written the way `categories` writes:
37
+ * a version per change, an optimistic lock, and the category's approval.
38
+ * By default `general` has none and the answer is `applied` (200), as it
39
+ * always was. If an administrator set its `approvalScope`, nothing is
40
+ * written: a request is created (`category_assign` / `category_edit`) and
41
+ * the answer is `pending` (202) with its card. An edit of ANOTHER field
42
+ * made concurrently is not lost — the patch is laid over the fresh version
43
+ * up to three times before 409 `ASSIGNMENT_STALE`.
44
+ *
45
+ * Writing takes the labelling right of `general`: by default `transfer` on
46
+ * the operation's address. Seeing the operation is not enough — a signer or
47
+ * an initiator without that right gets 404.
48
+ */
49
+ async setMetadata(kind, operationId, input) {
50
+ const res = await this.#http.requestRaw('PATCH', `${this.#op(kind, operationId)}/metadata`, { body: input });
51
+ return (0, gated_js_1.toGated)(res.status, res.data);
33
52
  }
34
53
  /** Other operations linked to this one. A plain array, not a page. */
35
54
  relations(kind, operationId) {
@@ -60,9 +79,171 @@ class OperationsResource {
60
79
  listRelations(params = {}) {
61
80
  return this.#http.request('GET', `/api/v1/vaults/${this.#vault}/operation-relations`, { query: { ...params } });
62
81
  }
82
+ /**
83
+ * Links two operations. DIRECTION: `source` is the DERIVED operation (the
84
+ * refund, reversal, correction or replacement itself), `target` the
85
+ * ORIGINAL it refers to — a deposit refunded by a transfer is source =
86
+ * transfer, target = deposit. Both must be in this vault, with `transfer`
87
+ * on the addresses of BOTH; otherwise 404 `OPERATION_NOT_FOUND`, as if
88
+ * missing.
89
+ *
90
+ * Idempotent, and not wrapped in `Gated`: a relation is unique by (type,
91
+ * source, target), and repeating the same body answers 200 with the
92
+ * existing relation where a new one answers 201 — both mean "this relation
93
+ * now exists, exactly as asked". The same triple with another amount, token
94
+ * or comment is 409 `OPERATION_RELATION_EXISTS`, the existing id in
95
+ * `details.relationId`. To change a relation, delete it and create it
96
+ * again.
97
+ *
98
+ * `relatedAmountRaw` only together with `tokenId`: a token of at least one
99
+ * of the two operations, an amount above zero and no larger than either
100
+ * side's amount in that token — otherwise 422 `OPERATION_RELATION_INVALID`,
101
+ * the field in `details.field`.
102
+ */
63
103
  createRelation(input) {
64
104
  return this.#http.request('POST', `/api/v1/vaults/${this.#vault}/operation-relations`, { body: input });
65
105
  }
106
+ /**
107
+ * Removes a relation — physically: a relation has no version history, so
108
+ * reports read the current state and report snapshots stay as they were.
109
+ *
110
+ * Its creator or an administrator. The creator needs what creating took —
111
+ * `transfer` on the addresses of BOTH operations, now; otherwise 403
112
+ * `OPERATION_RELATION_FORBIDDEN`. Someone else's relation is 403
113
+ * `NOT_RELATION_CREATOR`. A relation neither side of which you can see,
114
+ * like one already removed, is 404 `OPERATION_RELATION_NOT_FOUND`.
115
+ */
116
+ deleteRelation(relationId) {
117
+ return this.#http.request('DELETE', `/api/v1/vaults/${this.#vault}/operation-relations/${(0, http_js_1.seg)(relationId)}`);
118
+ }
119
+ /**
120
+ * Picks the counterparty of a transfer or a deposit by hand, correcting a
121
+ * wrong or missing automatic match: `counterpartySource` becomes `manual`.
122
+ * `null` is a choice too — "this operation has no counterparty".
123
+ *
124
+ * The choice is written where the automatic match is, so the feed, the
125
+ * cards, the counterparty's counters and reports see it at once. Neither
126
+ * the automatic match nor the retro-match on adding an address overwrites
127
+ * it; `resetCounterparty()` hands the operation back to them. Repeating the
128
+ * same value writes nothing and answers the current state.
129
+ *
130
+ * Only a counterparty of this vault that is not archived: 404
131
+ * `COUNTERPARTY_NOT_FOUND` (someone else's and a missing one alike), 409
132
+ * `COUNTERPARTY_ARCHIVED`. A transfer awaiting signatures is 409
133
+ * `OPERATION_AWAITING_APPROVAL` — its signers see the counterparty matched
134
+ * by the recipient's address, and a manual choice then would let them sign
135
+ * a stranger's address under a trusted name. The policy decision never
136
+ * depends on this choice; it was taken by address at creation.
137
+ *
138
+ * Takes the right to write the operation's metadata: `transfer` on its
139
+ * address. Seeing it is not enough — anyone else gets 404
140
+ * `OPERATION_NOT_FOUND`.
141
+ */
142
+ setCounterparty(kind, operationId, counterpartyId) {
143
+ return this.#http.request('PUT', `${this.#op(kind, operationId)}/counterparty`, { body: { counterpartyId } });
144
+ }
145
+ /**
146
+ * Drops the manual choice and matches the operation again AT ONCE — by the
147
+ * other side's address (the recipient of a transfer, the sender of a
148
+ * deposit) against the directory as it is NOW, by the rule used at
149
+ * creation (an archived counterparty does not match). The result can
150
+ * differ from what was there before the manual choice if the directory has
151
+ * changed since.
152
+ *
153
+ * On an operation that is already automatic nothing is written and the
154
+ * current state comes back, so a repeat is safe. Afterwards
155
+ * `counterpartySource` is `auto` and `counterpartySetById`/`At` say who
156
+ * reset it and when. Same rights and the same 409
157
+ * `OPERATION_AWAITING_APPROVAL` as `setCounterparty()`.
158
+ */
159
+ resetCounterparty(kind, operationId) {
160
+ return this.#http.request('DELETE', `${this.#op(kind, operationId)}/counterparty`);
161
+ }
162
+ /**
163
+ * Files attached to an operation (invoices, acts, screenshots) — metadata,
164
+ * in upload order; the bytes are fetched with `downloadAttachment()`. At
165
+ * most 20 per operation, so there is no cursor. Removed ones are not
166
+ * listed.
167
+ *
168
+ * Seen by whoever sees the operation: for a transfer an administrator, its
169
+ * initiator, a signer from the request's snapshot, or `view` on the sending
170
+ * address; for a deposit `view` on the receiving address. Anyone else gets
171
+ * 404 `OPERATION_NOT_FOUND`. A server without attachment storage answers
172
+ * 501 `ATTACHMENTS_DISABLED` on every attachment call — hide the feature
173
+ * then.
174
+ */
175
+ attachments(kind, operationId) {
176
+ return this.#http.request('GET', `${this.#op(kind, operationId)}/attachments`);
177
+ }
178
+ /**
179
+ * Attaches a file. Two forms, chosen by what you pass:
180
+ *
181
+ * • a `Blob`/`File`, an `ArrayBuffer` or a `Uint8Array` goes as the raw
182
+ * body (`application/octet-stream`, the name in `?filename=`), streamed
183
+ * to storage, up to 10 MB. `fetch` sets `Content-Length` itself, which
184
+ * the API requires (411 `ATTACHMENT_LENGTH_REQUIRED` without it);
185
+ * • a `FormData` goes as `multipart/form-data` exactly as built: the file
186
+ * in the field `file`, the name in the field `filename` or the part's
187
+ * own. Parsed in memory, so up to 5 MB. This is the form React Native
188
+ * sends a file from a `uri` with.
189
+ *
190
+ * The type is decided by the BYTES, never by a header: PDF, PNG, JPEG and
191
+ * WebP only — anything else (SVG and HTML included) is 415
192
+ * `ATTACHMENT_TYPE_NOT_ALLOWED`. The name is cleaned and its extension made
193
+ * to match the type; read the stored one from the answer. Over the size
194
+ * limit is 413 `ATTACHMENT_TOO_LARGE`; over 20 files on the operation, 409
195
+ * `ATTACHMENT_LIMIT_REACHED`; over the vault's quota (1 GB of live files by
196
+ * default), 409 `ATTACHMENT_QUOTA_EXCEEDED` with `details.quotaBytes` and
197
+ * `details.usedBytes`.
198
+ *
199
+ * Uploading takes `transfer` on the operation's address, as labelling does;
200
+ * a signer, an initiator whose grant was revoked and a view-only grant get
201
+ * 404. From a browser, a page of a site the API does not trust is refused
202
+ * with 403 `CROSS_SITE_REQUEST_REFUSED`, as every changing request is.
203
+ */
204
+ uploadAttachment(kind, operationId, file, options = {}) {
205
+ const path = `${this.#op(kind, operationId)}/attachments`;
206
+ const control = { signal: options.signal, timeoutMs: options.timeoutMs };
207
+ if (isFormData(file)) {
208
+ return this.#http.request('POST', path, { ...control, rawBody: file });
209
+ }
210
+ return this.#http.request('POST', path, {
211
+ ...control,
212
+ rawBody: file,
213
+ contentType: 'application/octet-stream',
214
+ query: { filename: options.filename ?? fileName(file) },
215
+ });
216
+ }
217
+ /**
218
+ * The file itself, as the untouched `Response`: read it with `.blob()` or
219
+ * `.arrayBuffer()`. `Content-Type` is the type detected at upload, and
220
+ * `Content-Disposition: attachment` carries the cleaned name. The same
221
+ * path is the attachment's `downloadPath`, relative to the API base.
222
+ *
223
+ * Who may read it is checked on every request, so a revoked access closes a
224
+ * cached copy too: the API answers with `ETag` = the file's SHA-256 and
225
+ * `Cache-Control: private, max-age=0, must-revalidate`. Do not send
226
+ * `If-None-Match` yourself — a 304 has no body and the transport reports it
227
+ * as an error; the browser's own revalidation is transparent. A file
228
+ * missing from storage is 502 `ATTACHMENT_STORAGE_UNAVAILABLE`.
229
+ */
230
+ downloadAttachment(kind, operationId, attachmentId, options = {}) {
231
+ return this.#http.fetchRaw('GET', `${this.#op(kind, operationId)}/attachments/${(0, http_js_1.seg)(attachmentId)}/content`, { signal: options.signal });
232
+ }
233
+ /**
234
+ * Removes an attachment: its uploader, while they still hold `transfer` on
235
+ * the operation's address, or an administrator — anyone else who sees the
236
+ * operation gets 403 `ATTACHMENT_DELETE_FORBIDDEN`. Soft: the file leaves
237
+ * the list and is no longer served, its bytes are erased, and the record
238
+ * stays as an audit trail. Repeating it answers the same.
239
+ *
240
+ * 502 `ATTACHMENT_STORAGE_UNAVAILABLE` with `details.deleted: true` means
241
+ * the attachment is already hidden but storage kept the bytes; repeat the
242
+ * call to clean them up.
243
+ */
244
+ deleteAttachment(kind, operationId, attachmentId) {
245
+ return this.#http.request('DELETE', `${this.#op(kind, operationId)}/attachments/${(0, http_js_1.seg)(attachmentId)}`);
246
+ }
66
247
  /**
67
248
  * An incoming payment in detail.
68
249
  *
@@ -91,4 +272,13 @@ class OperationsResource {
91
272
  }
92
273
  }
93
274
  exports.OperationsResource = OperationsResource;
275
+ /** `instanceof` alone fails where the global is missing (older Node) — guard it. */
276
+ function isFormData(value) {
277
+ return typeof FormData !== 'undefined' && value instanceof FormData;
278
+ }
279
+ /** The name a `File` carries; a bare `Blob` or buffer has none. */
280
+ function fileName(file) {
281
+ const name = file.name;
282
+ return typeof name === 'string' && name !== '' ? name : undefined;
283
+ }
94
284
  //# sourceMappingURL=operations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../src/resources/operations.ts"],"names":[],"mappings":";;;AAAA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IAED;;;;OAIG;IACH,aAAa,CAAC,MAAM,GAAwB,EAAE;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,sBAAsB,EACnD,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CACzB,CAAA;IACH,CAAC;IAED,cAAc,CAAC,KAAkC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,MAAM,EACN,kBAAkB,IAAI,CAAC,MAAM,sBAAsB,EACnD,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAA;IACH,CAAC;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,SAAiB;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,aAAa,IAAA,aAAG,EAAC,SAAS,CAAC,EAAE,CAC3D,CAAA;IACH,CAAC;IAED;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,GAAwB,EAAE;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,KAAK,EACL,kBAAkB,IAAI,CAAC,MAAM,qBAAqB,EAClD,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CACzB,CAAA;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../src/resources/operations.ts"],"names":[],"mappings":";;;AAAA,6CAAoE;AACpE,+CAAsD;AA8DtD;;;;;;;;GAQG;AACH;IACW,KAAK,CAAY;IACjB,MAAM,CAAQ;IAEvB,YAAY,IAAgB,EAAE,SAAiB;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,MAAM,GAAG,IAAA,aAAG,EAAC,SAAS,CAAC,CAAA;IAC9B,CAAC;IAED,GAAG,CAAC,IAAmB,EAAE,WAAmB;QAC1C,OAAO,kBAAkB,IAAI,CAAC,MAAM,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