@v3finance/core-sdk 0.1.0 → 0.2.1

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 (217) hide show
  1. package/CHANGELOG.md +441 -7
  2. package/README.md +219 -73
  3. package/dist/cjs/client.d.ts +67 -22
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +38 -2
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/core/errors.d.ts +30 -10
  8. package/dist/cjs/core/errors.d.ts.map +1 -1
  9. package/dist/cjs/core/errors.js +47 -15
  10. package/dist/cjs/core/errors.js.map +1 -1
  11. package/dist/cjs/core/gated.d.ts +30 -6
  12. package/dist/cjs/core/gated.d.ts.map +1 -1
  13. package/dist/cjs/core/gated.js +21 -6
  14. package/dist/cjs/core/gated.js.map +1 -1
  15. package/dist/cjs/core/http.d.ts +12 -8
  16. package/dist/cjs/core/http.d.ts.map +1 -1
  17. package/dist/cjs/core/http.js +147 -43
  18. package/dist/cjs/core/http.js.map +1 -1
  19. package/dist/cjs/core/pagination.d.ts +28 -1
  20. package/dist/cjs/core/pagination.d.ts.map +1 -1
  21. package/dist/cjs/core/pagination.js +36 -1
  22. package/dist/cjs/core/pagination.js.map +1 -1
  23. package/dist/cjs/generated/operations.js +1 -1
  24. package/dist/cjs/generated/types.d.ts +965 -179
  25. package/dist/cjs/generated/types.d.ts.map +1 -1
  26. package/dist/cjs/index.d.ts +32 -8
  27. package/dist/cjs/index.d.ts.map +1 -1
  28. package/dist/cjs/index.js +12 -0
  29. package/dist/cjs/index.js.map +1 -1
  30. package/dist/cjs/resources/addresses.d.ts +23 -8
  31. package/dist/cjs/resources/addresses.d.ts.map +1 -1
  32. package/dist/cjs/resources/addresses.js +8 -1
  33. package/dist/cjs/resources/addresses.js.map +1 -1
  34. package/dist/cjs/resources/admin.d.ts +150 -25
  35. package/dist/cjs/resources/admin.d.ts.map +1 -1
  36. package/dist/cjs/resources/admin.js +94 -23
  37. package/dist/cjs/resources/admin.js.map +1 -1
  38. package/dist/cjs/resources/approvals.d.ts +46 -5
  39. package/dist/cjs/resources/approvals.d.ts.map +1 -1
  40. package/dist/cjs/resources/approvals.js +27 -4
  41. package/dist/cjs/resources/approvals.js.map +1 -1
  42. package/dist/cjs/resources/balances.d.ts +152 -16
  43. package/dist/cjs/resources/balances.d.ts.map +1 -1
  44. package/dist/cjs/resources/balances.js +9 -5
  45. package/dist/cjs/resources/balances.js.map +1 -1
  46. package/dist/cjs/resources/categories.d.ts +93 -21
  47. package/dist/cjs/resources/categories.d.ts.map +1 -1
  48. package/dist/cjs/resources/categories.js +65 -18
  49. package/dist/cjs/resources/categories.js.map +1 -1
  50. package/dist/cjs/resources/counterparties.d.ts +26 -3
  51. package/dist/cjs/resources/counterparties.d.ts.map +1 -1
  52. package/dist/cjs/resources/counterparties.js +17 -0
  53. package/dist/cjs/resources/counterparties.js.map +1 -1
  54. package/dist/cjs/resources/folders.d.ts +51 -10
  55. package/dist/cjs/resources/folders.d.ts.map +1 -1
  56. package/dist/cjs/resources/folders.js +36 -5
  57. package/dist/cjs/resources/folders.js.map +1 -1
  58. package/dist/cjs/resources/history.d.ts +20 -2
  59. package/dist/cjs/resources/history.d.ts.map +1 -1
  60. package/dist/cjs/resources/history.js.map +1 -1
  61. package/dist/cjs/resources/me.d.ts +27 -4
  62. package/dist/cjs/resources/me.d.ts.map +1 -1
  63. package/dist/cjs/resources/me.js +22 -1
  64. package/dist/cjs/resources/me.js.map +1 -1
  65. package/dist/cjs/resources/members.d.ts +19 -4
  66. package/dist/cjs/resources/members.d.ts.map +1 -1
  67. package/dist/cjs/resources/members.js +15 -6
  68. package/dist/cjs/resources/members.js.map +1 -1
  69. package/dist/cjs/resources/operations.d.ts +64 -8
  70. package/dist/cjs/resources/operations.d.ts.map +1 -1
  71. package/dist/cjs/resources/operations.js +26 -2
  72. package/dist/cjs/resources/operations.js.map +1 -1
  73. package/dist/cjs/resources/registries.d.ts +87 -9
  74. package/dist/cjs/resources/registries.d.ts.map +1 -1
  75. package/dist/cjs/resources/registries.js +54 -11
  76. package/dist/cjs/resources/registries.js.map +1 -1
  77. package/dist/cjs/resources/reports.d.ts +300 -41
  78. package/dist/cjs/resources/reports.d.ts.map +1 -1
  79. package/dist/cjs/resources/reports.js +135 -7
  80. package/dist/cjs/resources/reports.js.map +1 -1
  81. package/dist/cjs/resources/sharing.d.ts +61 -10
  82. package/dist/cjs/resources/sharing.d.ts.map +1 -1
  83. package/dist/cjs/resources/sharing.js +51 -4
  84. package/dist/cjs/resources/sharing.js.map +1 -1
  85. package/dist/cjs/resources/transfers.d.ts +44 -6
  86. package/dist/cjs/resources/transfers.d.ts.map +1 -1
  87. package/dist/cjs/resources/transfers.js +41 -3
  88. package/dist/cjs/resources/transfers.js.map +1 -1
  89. package/dist/cjs/resources/types.d.ts +16 -0
  90. package/dist/cjs/resources/types.d.ts.map +1 -1
  91. package/dist/cjs/units.d.ts.map +1 -1
  92. package/dist/cjs/units.js +18 -2
  93. package/dist/cjs/units.js.map +1 -1
  94. package/dist/cjs/version.d.ts +1 -1
  95. package/dist/cjs/version.js +1 -1
  96. package/dist/esm/client.d.ts +67 -22
  97. package/dist/esm/client.d.ts.map +1 -1
  98. package/dist/esm/client.js +38 -2
  99. package/dist/esm/client.js.map +1 -1
  100. package/dist/esm/core/errors.d.ts +30 -10
  101. package/dist/esm/core/errors.d.ts.map +1 -1
  102. package/dist/esm/core/errors.js +47 -15
  103. package/dist/esm/core/errors.js.map +1 -1
  104. package/dist/esm/core/gated.d.ts +30 -6
  105. package/dist/esm/core/gated.d.ts.map +1 -1
  106. package/dist/esm/core/gated.js +21 -6
  107. package/dist/esm/core/gated.js.map +1 -1
  108. package/dist/esm/core/http.d.ts +12 -8
  109. package/dist/esm/core/http.d.ts.map +1 -1
  110. package/dist/esm/core/http.js +148 -44
  111. package/dist/esm/core/http.js.map +1 -1
  112. package/dist/esm/core/pagination.d.ts +28 -1
  113. package/dist/esm/core/pagination.d.ts.map +1 -1
  114. package/dist/esm/core/pagination.js +36 -1
  115. package/dist/esm/core/pagination.js.map +1 -1
  116. package/dist/esm/generated/operations.js +1 -1
  117. package/dist/esm/generated/types.d.ts +965 -179
  118. package/dist/esm/generated/types.d.ts.map +1 -1
  119. package/dist/esm/index.d.ts +32 -8
  120. package/dist/esm/index.d.ts.map +1 -1
  121. package/dist/esm/index.js +17 -5
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/esm/resources/addresses.d.ts +23 -8
  124. package/dist/esm/resources/addresses.d.ts.map +1 -1
  125. package/dist/esm/resources/addresses.js +8 -1
  126. package/dist/esm/resources/addresses.js.map +1 -1
  127. package/dist/esm/resources/admin.d.ts +150 -25
  128. package/dist/esm/resources/admin.d.ts.map +1 -1
  129. package/dist/esm/resources/admin.js +94 -23
  130. package/dist/esm/resources/admin.js.map +1 -1
  131. package/dist/esm/resources/approvals.d.ts +46 -5
  132. package/dist/esm/resources/approvals.d.ts.map +1 -1
  133. package/dist/esm/resources/approvals.js +27 -4
  134. package/dist/esm/resources/approvals.js.map +1 -1
  135. package/dist/esm/resources/balances.d.ts +152 -16
  136. package/dist/esm/resources/balances.d.ts.map +1 -1
  137. package/dist/esm/resources/balances.js +9 -5
  138. package/dist/esm/resources/balances.js.map +1 -1
  139. package/dist/esm/resources/categories.d.ts +93 -21
  140. package/dist/esm/resources/categories.d.ts.map +1 -1
  141. package/dist/esm/resources/categories.js +65 -18
  142. package/dist/esm/resources/categories.js.map +1 -1
  143. package/dist/esm/resources/counterparties.d.ts +26 -3
  144. package/dist/esm/resources/counterparties.d.ts.map +1 -1
  145. package/dist/esm/resources/counterparties.js +17 -0
  146. package/dist/esm/resources/counterparties.js.map +1 -1
  147. package/dist/esm/resources/folders.d.ts +51 -10
  148. package/dist/esm/resources/folders.d.ts.map +1 -1
  149. package/dist/esm/resources/folders.js +36 -5
  150. package/dist/esm/resources/folders.js.map +1 -1
  151. package/dist/esm/resources/history.d.ts +20 -2
  152. package/dist/esm/resources/history.d.ts.map +1 -1
  153. package/dist/esm/resources/history.js.map +1 -1
  154. package/dist/esm/resources/me.d.ts +27 -4
  155. package/dist/esm/resources/me.d.ts.map +1 -1
  156. package/dist/esm/resources/me.js +22 -1
  157. package/dist/esm/resources/me.js.map +1 -1
  158. package/dist/esm/resources/members.d.ts +19 -4
  159. package/dist/esm/resources/members.d.ts.map +1 -1
  160. package/dist/esm/resources/members.js +15 -6
  161. package/dist/esm/resources/members.js.map +1 -1
  162. package/dist/esm/resources/operations.d.ts +64 -8
  163. package/dist/esm/resources/operations.d.ts.map +1 -1
  164. package/dist/esm/resources/operations.js +26 -2
  165. package/dist/esm/resources/operations.js.map +1 -1
  166. package/dist/esm/resources/registries.d.ts +87 -9
  167. package/dist/esm/resources/registries.d.ts.map +1 -1
  168. package/dist/esm/resources/registries.js +54 -11
  169. package/dist/esm/resources/registries.js.map +1 -1
  170. package/dist/esm/resources/reports.d.ts +300 -41
  171. package/dist/esm/resources/reports.d.ts.map +1 -1
  172. package/dist/esm/resources/reports.js +135 -7
  173. package/dist/esm/resources/reports.js.map +1 -1
  174. package/dist/esm/resources/sharing.d.ts +61 -10
  175. package/dist/esm/resources/sharing.d.ts.map +1 -1
  176. package/dist/esm/resources/sharing.js +51 -4
  177. package/dist/esm/resources/sharing.js.map +1 -1
  178. package/dist/esm/resources/transfers.d.ts +44 -6
  179. package/dist/esm/resources/transfers.d.ts.map +1 -1
  180. package/dist/esm/resources/transfers.js +41 -3
  181. package/dist/esm/resources/transfers.js.map +1 -1
  182. package/dist/esm/resources/types.d.ts +16 -0
  183. package/dist/esm/resources/types.d.ts.map +1 -1
  184. package/dist/esm/units.d.ts.map +1 -1
  185. package/dist/esm/units.js +18 -2
  186. package/dist/esm/units.js.map +1 -1
  187. package/dist/esm/version.d.ts +1 -1
  188. package/dist/esm/version.js +1 -1
  189. package/docs/concepts.md +193 -0
  190. package/docs/errors.md +491 -0
  191. package/package.json +7 -6
  192. package/src/client.ts +89 -25
  193. package/src/core/errors.ts +49 -15
  194. package/src/core/gated.ts +31 -7
  195. package/src/core/http.ts +173 -49
  196. package/src/core/pagination.ts +38 -1
  197. package/src/generated/operations.ts +1 -1
  198. package/src/generated/types.ts +1001 -180
  199. package/src/index.ts +64 -7
  200. package/src/resources/addresses.ts +24 -8
  201. package/src/resources/admin.ts +186 -33
  202. package/src/resources/approvals.ts +55 -9
  203. package/src/resources/balances.ts +186 -14
  204. package/src/resources/categories.ts +125 -30
  205. package/src/resources/counterparties.ts +23 -6
  206. package/src/resources/folders.ts +74 -18
  207. package/src/resources/history.ts +27 -2
  208. package/src/resources/me.ts +30 -5
  209. package/src/resources/members.ts +26 -7
  210. package/src/resources/operations.ts +73 -8
  211. package/src/resources/registries.ts +90 -11
  212. package/src/resources/reports.ts +348 -67
  213. package/src/resources/sharing.ts +71 -18
  214. package/src/resources/transfers.ts +51 -7
  215. package/src/resources/types.ts +16 -0
  216. package/src/units.ts +19 -2
  217. package/src/version.ts +1 -1
@@ -4,8 +4,10 @@
4
4
  *
5
5
  * 201 — applied immediately (policy allowed it without signatures);
6
6
  * 202 — queued for approval, funds are reserved, nothing has moved yet;
7
- * 200 — a replay of the same idempotency key: nothing happened now, the
8
- * existing operation came back (no second broadcast).
7
+ * 200 — on a transfer: a replay of the same idempotency key, nothing
8
+ * happened now and the existing operation came back (no second
9
+ * broadcast). Everywhere else: an ordinary applied success, because
10
+ * an edit is not a creation and answers 200 (see `replayOn200`).
9
11
  *
10
12
  * The body can be identical: a transfer returns `{transaction}` in all three.
11
13
  * A client that reads only the body will say "sent" where the truth is
@@ -13,8 +15,10 @@
13
15
  * frozen.
14
16
  *
15
17
  * `replayed` is kept separate from `applied` on purpose. A replay means the
16
- * previous attempt DID reach the server and only the answer was lost, so the
17
- * person should be told "already sent", not "sent" a second time.
18
+ * previous attempt DID reach the server and only the answer was lost — not
19
+ * that it succeeded. The body is that operation as it stands now: a replayed
20
+ * transfer may have gone out, be waiting for signatures, be still executing
21
+ * or have failed, and only its own status says which.
18
22
  */
19
23
  /**
20
24
  * Labels a response by status. An unexpected status throws rather than guessing.
@@ -25,13 +29,20 @@
25
29
  * success. Telling a person "already sent" after a plain edit would be as
26
30
  * wrong as telling them "done" after a replay, so each caller states which
27
31
  * of the two it is instead of the helper guessing.
32
+ *
33
+ * Which also means `outcome: 'replayed'` is UNREACHABLE for every gated
34
+ * method other than `transfers.send`: replay protection needs an idempotency
35
+ * key, and the transfer body is the only place the API takes one. The
36
+ * three-way `switch` in `docs/concepts.md` is right for a transfer; beside a
37
+ * counterparty edit its `case 'replayed'` is dead, and it is not evidence
38
+ * that such an edit can come back as a replay.
28
39
  */
29
40
  export function toGated(status, data, options = {}) {
30
41
  switch (status) {
31
42
  case 200:
32
43
  return options.replayOn200
33
44
  ? { outcome: 'replayed', status: 200, data: data }
34
- : { outcome: 'applied', status: 201, data: data };
45
+ : { outcome: 'applied', status: 200, data: data };
35
46
  case 201:
36
47
  return { outcome: 'applied', status: 201, data: data };
37
48
  case 202:
@@ -41,7 +52,11 @@ export function toGated(status, data, options = {}) {
41
52
  'Expected 200, 201 (applied) or 202 (awaiting approval).');
42
53
  }
43
54
  }
44
- /** Narrowing: the operation ran, now or earlier, and money moved. */
55
+ /**
56
+ * Narrowing: `applied` or `replayed`. For `applied` the operation ran now.
57
+ * For `replayed` it only existed already — whether money moved is in the
58
+ * body's own status, not in this check.
59
+ */
45
60
  export function isApplied(r) {
46
61
  return r.outcome === 'applied' || r.outcome === 'replayed';
47
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gated.js","sourceRoot":"","sources":["../../../src/core/gated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CACrB,MAAc,EACd,IAAa,EACb,OAAO,GAA8B,EAAE;IAEvC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,OAAO,CAAC,WAAW;gBACxB,CAAC,CAAC,EA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AE,IAAI,EAAE,IAAgB,EAAE,CAAA;QACjE,KAAK,GAAG;YACN,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAgB,EAAE,CAAA;QACpE,KAAK,GAAG;YACN,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAgB,EAAE,CAAA;QACpE;YACE,MAAM,IAAI,KAAK,CACb,kDAAkD,MAAM,IAAI;gBAC1D,yDAAyD,CAC5D,CAAA;IACL,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,CAAc;IAEd,OAAO,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,KAAK,UAAU,CAAA;AAC5D,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CACvB,CAAc;IAEd,OAAO,CAAC,CAAC,OAAO,KAAK,SAAS,CAAA;AAChC,CAAC"}
@@ -39,15 +39,19 @@ export interface RequestOptions {
39
39
  signal?: AbortSignal | undefined;
40
40
  timeoutMs?: number | undefined;
41
41
  /**
42
- * Attempt key, sent as the `idempotency-key` header.
42
+ * Attempt key. ACCEPTED AND IGNORED BY THE TRANSPORT — the working place
43
+ * for it is the request BODY, the way `transfers.send` passes it.
43
44
  *
44
- * THE SERVER DOES NOT READ THIS HEADER TODAY. Replay protection on money
45
- * paths is resolved from the `idempotencyKey` FIELD OF THE BODY — that is
46
- * what `transfers.send` uses, and that is what protects it. The header is
47
- * here for the day the API starts honouring it; until then, calling a
48
- * money endpoint through the low-level client and passing the key only
49
- * here buys you nothing, and a retry after a timeout sends the money
50
- * twice. Put the key in the body.
45
+ * It used to go out as an `idempotency-key` header. The server has never
46
+ * read that header, which by itself merely bought nothing; in a browser it
47
+ * cost the whole request. The API's CORS preflight allows exactly
48
+ * `Content-Type` and `Authorization` (`allowHeaders`, backend
49
+ * `src/index.ts`), so the extra header failed the preflight and the call
50
+ * was never sent at all — a money request that could not reach the server,
51
+ * and a "network error" that no retry explains. Replay protection is
52
+ * resolved from the `idempotencyKey` FIELD of the body and nowhere else.
53
+ *
54
+ * @deprecated The transport sends this nowhere. Put the key in the body.
51
55
  */
52
56
  idempotencyKey?: string | undefined;
53
57
  headers?: Record<string, string> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/core/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,aAAa,CAAA;AAwBpB,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;AAE1C,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAE9C,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MACb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,SAAS,GACT,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAAA;IAE/C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAEhC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD,8EAA8E;IAC9E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3D,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IAE/B,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,sCAAsC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B;CA8FF"}
@@ -1,4 +1,4 @@
1
- import { abortedError, networkError, parseError, parseErrorBody, timeoutError, } from './errors.js';
1
+ import { abortedError, isCoreError, networkError, parseError, parseErrorBody, timeoutError, } from './errors.js';
2
2
  import { SDK_VERSION } from '../version.js';
3
3
  /**
4
4
  * The HTTP layer shared by every resource.
@@ -63,11 +63,25 @@ export class HttpClient {
63
63
  constructor(options) {
64
64
  this.baseUrl = options.baseUrl.replace(/\/+$/, '');
65
65
  this.#options = options;
66
- const f = options.fetch ?? globalThis.fetch;
67
- if (typeof f !== 'function') {
66
+ const custom = options.fetch;
67
+ if (typeof (custom ?? globalThis.fetch) !== 'function') {
68
68
  throw new Error('@v3finance/core-sdk: fetch is unavailable in this runtime — pass one to the client options.');
69
69
  }
70
- this.#fetch = f;
70
+ // NEVER store the function and call it as `this.#fetch(…)`. A private
71
+ // field call passes the client as the receiver, and a browser's `fetch`
72
+ // checks its receiver: anything but the window is
73
+ // `TypeError: Illegal invocation`, thrown before a single byte leaves.
74
+ // Node and React Native do not check, which is how every request from a
75
+ // web page failed while the whole test suite passed — and since a
76
+ // `TypeError` out of `fetch` is what a dropped connection looks like, the
77
+ // failure surfaced as a "network error" on a perfectly good network.
78
+ //
79
+ // The wrapper calls with no receiver at all. Without a custom fetch the
80
+ // global one is looked up per call rather than captured here, so whatever
81
+ // patches it later (instrumentation, a mock server) is still honoured.
82
+ this.#fetch = custom
83
+ ? (input, init) => custom(input, init)
84
+ : (input, init) => globalThis.fetch(input, init);
71
85
  this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
72
86
  }
73
87
  /** Performs a request and returns the parsed body. Statuses >= 400 throw `CoreError`. */
@@ -81,13 +95,18 @@ export class HttpClient {
81
95
  * time. Read it with `.blob()`, `.text()` or `.arrayBuffer()`.
82
96
  */
83
97
  async fetchRaw(method, path, options = {}) {
84
- const { response, endpoint } = await this.#send(method, path, options);
98
+ // The body is touched only when the call FAILED — and then by the same
99
+ // reader a JSON call uses, so one 502 from the edge produces one message
100
+ // whichever method asked for it. The two used to disagree: this one fell
101
+ // back to neutral wording while `requestRaw` put the proxy's HTML page
102
+ // into `message`.
103
+ //
104
+ // On success the response is handed over unread, which also means the
105
+ // timeout ends at the headers here: the file body is the caller's to read
106
+ // and to bound, with their own signal.
107
+ const { response, endpoint, payload } = await this.#send(method, path, options, (r, ep) => r.ok ? Promise.resolve(undefined) : readJsonBody(r, ep));
85
108
  if (!response.ok) {
86
- const body = await response
87
- .clone()
88
- .json()
89
- .catch(() => undefined);
90
- const error = parseErrorBody(response.status, body, endpoint);
109
+ const error = parseErrorBody(response.status, payload, endpoint);
91
110
  if (response.status === 401 && this.#options.onUnauthorized) {
92
111
  await this.#options.onUnauthorized(error);
93
112
  }
@@ -97,18 +116,28 @@ export class HttpClient {
97
116
  }
98
117
  /** Same, but exposes the status — needed where 200 and 202 mean different things. */
99
118
  async requestRaw(method, path, options = {}) {
100
- const { response, endpoint } = await this.#send(method, path, options);
101
- const data = await readBody(response, endpoint);
119
+ const { response, endpoint, payload } = await this.#send(method, path, options, readJsonBody);
102
120
  if (!response.ok) {
103
- const error = parseErrorBody(response.status, data, endpoint);
121
+ const error = parseErrorBody(response.status, payload, endpoint);
104
122
  if (response.status === 401 && this.#options.onUnauthorized) {
105
123
  await this.#options.onUnauthorized(error);
106
124
  }
107
125
  throw error;
108
126
  }
109
- return { status: response.status, data: data, headers: response.headers };
127
+ return { status: response.status, data: payload, headers: response.headers };
110
128
  }
111
- async #send(method, path, options) {
129
+ /**
130
+ * One attempt: headers out, body in, cleanup.
131
+ *
132
+ * The body is read HERE, through `readPayload`, instead of by the caller
133
+ * afterwards — because the timeout and the caller's signal have to stay
134
+ * armed until the body is in hand. Headers arrive first and the body streams
135
+ * after; with the timer cleared at the headers, a server that answers and
136
+ * then stalls mid-body left a request hanging with nothing to end it. On a
137
+ * money path that is a transfer whose outcome is never learned, and no
138
+ * retry decision either.
139
+ */
140
+ async #send(method, path, options, readPayload) {
112
141
  const endpoint = `${method.toUpperCase()} ${path}`;
113
142
  const url = `${this.baseUrl}${path}${serializeQuery(options.query)}`;
114
143
  const timeoutMs = options.timeoutMs ?? this.#timeoutMs;
@@ -121,8 +150,14 @@ export class HttpClient {
121
150
  };
122
151
  if (options.body !== undefined)
123
152
  headers['content-type'] = 'application/json';
124
- if (options.idempotencyKey)
125
- headers['idempotency-key'] = options.idempotencyKey;
153
+ // NOTHING ELSE IS ADDED BY DEFAULT, and that is a browser constraint
154
+ // rather than minimalism: the API's CORS preflight allows exactly
155
+ // `Content-Type` and `Authorization`, so any further header of ours makes
156
+ // the preflight fail and the request is never sent. These three are safe —
157
+ // `accept` is CORS-safelisted, and `user-agent` is a forbidden header name
158
+ // the browser drops before it can be preflighted (it still reaches the API
159
+ // from Node and React Native, which is where it is useful). A header
160
+ // passed in through `headers` is the caller's own risk.
126
161
  // A timer of our own on top of the caller's signal: `AbortSignal.timeout`
127
162
  // is missing in some React Native runtimes, and "the caller cancelled" has
128
163
  // to stay distinguishable from "time ran out" — on money paths those call
@@ -135,44 +170,88 @@ export class HttpClient {
135
170
  }, timeoutMs);
136
171
  const onExternalAbort = () => controller.abort();
137
172
  options.signal?.addEventListener('abort', onExternalAbort, { once: true });
138
- let response;
173
+ const classify = (cause) => transportError(cause, { timedOut, timeoutMs, endpoint, signal: options.signal });
174
+ // The cleanup is an OUTER finally, so it also runs when `onTokenRotated`
175
+ // throws — a caller's storage failure should not leave our timer armed,
176
+ // ready to abort an unrelated stream seconds later.
139
177
  try {
140
- response = await this.#fetch(url, {
141
- method: method.toUpperCase(),
142
- headers,
143
- ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
144
- ...(this.#options.credentials === undefined
145
- ? {}
146
- : { credentials: this.#options.credentials }),
147
- signal: controller.signal,
148
- });
149
- }
150
- catch (cause) {
151
- if (timedOut)
152
- throw timeoutError(timeoutMs, endpoint);
153
- if (options.signal?.aborted)
154
- throw abortedError(endpoint);
155
- throw networkError(cause, endpoint);
178
+ let response;
179
+ try {
180
+ response = await this.#fetch(url, {
181
+ method: method.toUpperCase(),
182
+ headers,
183
+ ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
184
+ ...(this.#options.credentials === undefined
185
+ ? {}
186
+ : { credentials: this.#options.credentials }),
187
+ signal: controller.signal,
188
+ });
189
+ }
190
+ catch (cause) {
191
+ throw classify(cause);
192
+ }
193
+ // Rotation arrives on successful responses too, and is taken BEFORE the
194
+ // body: the token is valid whatever the body turns out to be, and a
195
+ // rotation we drop signs the client out at the next one.
196
+ const rotated = response.headers.get(ROTATED_TOKEN_HEADER);
197
+ if (rotated && this.#options.onTokenRotated)
198
+ await this.#options.onTokenRotated(rotated);
199
+ let payload;
200
+ try {
201
+ payload = await readPayload(response, endpoint);
202
+ }
203
+ catch (cause) {
204
+ throw classify(cause);
205
+ }
206
+ return { response, endpoint, payload };
156
207
  }
157
208
  finally {
158
209
  clearTimeout(timer);
159
210
  options.signal?.removeEventListener('abort', onExternalAbort);
160
211
  }
161
- // Rotation arrives on successful responses too.
162
- const rotated = response.headers.get(ROTATED_TOKEN_HEADER);
163
- if (rotated && this.#options.onTokenRotated)
164
- await this.#options.onTokenRotated(rotated);
165
- return { response, endpoint };
166
212
  }
167
213
  }
214
+ /**
215
+ * Names a transport failure, of the request or of the body behind it.
216
+ *
217
+ * The distinction is not cosmetic on a money path: a timeout may have been
218
+ * applied server-side (retry only with the same idempotency key), a cancel is
219
+ * the caller's own decision and must not be shown as a failure, and a network
220
+ * error never left the device. A `CoreError` arrives already named — the body
221
+ * reader raises one when a successful response is not the JSON the contract
222
+ * promises — and is passed through, so "the contract is wrong" is not reported
223
+ * as "the network is down".
224
+ *
225
+ * Our own timeout wins over the caller's signal, and both win over the cause:
226
+ * an abort mid-body surfaces as the abort that caused it, not as the opaque
227
+ * `AbortError` the stream rejects with.
228
+ */
229
+ function transportError(cause, ctx) {
230
+ if (ctx.timedOut)
231
+ return timeoutError(ctx.timeoutMs, ctx.endpoint);
232
+ if (ctx.signal?.aborted)
233
+ return abortedError(ctx.endpoint);
234
+ if (isCoreError(cause))
235
+ return cause;
236
+ return networkError(cause, ctx.endpoint);
237
+ }
238
+ /** The longest fragment of a non-JSON error body worth carrying into a message. */
239
+ const MAX_PLAIN_ERROR_CHARS = 200;
168
240
  /**
169
241
  * An empty body (204, DELETE) is `undefined`, not a parse failure. Invalid
170
242
  * JSON on a SUCCESSFUL status is a failure: the contract is not what we think
171
- * it is, and returning `undefined` quietly is worse than throwing. On an error
172
- * status the text is kept as-is for `parseErrorBody` to read.
243
+ * it is, and returning `undefined` quietly is worse than throwing.
244
+ *
245
+ * A read that fails halfway is no longer swallowed. It used to be caught into
246
+ * an empty string, which turned a truncated response — a dropped connection,
247
+ * our own timeout firing while the body streamed — into `data: undefined`
248
+ * typed as the shape the caller asked for: a failure wearing the face of a
249
+ * successful empty answer, and on a balance or a transfer the worst possible
250
+ * disguise. The rejection now travels out to `transportError`, which names it
251
+ * a timeout, a cancel or a network failure.
173
252
  */
174
- async function readBody(response, endpoint) {
175
- const text = await response.text().catch(() => '');
253
+ async function readJsonBody(response, endpoint) {
254
+ const text = await response.text();
176
255
  if (!text)
177
256
  return undefined;
178
257
  try {
@@ -181,7 +260,32 @@ async function readBody(response, endpoint) {
181
260
  catch (cause) {
182
261
  if (response.ok)
183
262
  throw parseError(cause, endpoint);
184
- return { error: text };
263
+ return plainTextError(text);
185
264
  }
186
265
  }
266
+ /**
267
+ * A non-JSON error body reduced to something showable — or to nothing.
268
+ *
269
+ * Who sends these: everything in front of the API, never the API itself. A
270
+ * 502/504 while the worker is being replaced, a 403 from a WAF, a platform
271
+ * 429 — they answer with a whole HTML page (2318 bytes in one measured case).
272
+ * Passing that on as `{error: text}` put the page into `message`, which is the
273
+ * one field meant to be read by a person.
274
+ *
275
+ * Markup is therefore dropped and `parseErrorBody` falls back to its own
276
+ * wording for the status. A short line of plain text is kept instead of being
277
+ * dropped with it, because a proxy occasionally says something the status does
278
+ * not ("upstream connect error", "no healthy upstream").
279
+ */
280
+ function plainTextError(text) {
281
+ // A leading `<` catches HTML and XML error documents alike; neither is ours.
282
+ const collapsed = text.trim().replace(/\s+/g, ' ');
283
+ if (!collapsed || collapsed.startsWith('<'))
284
+ return undefined;
285
+ return {
286
+ error: collapsed.length > MAX_PLAIN_ERROR_CHARS
287
+ ? `${collapsed.slice(0, MAX_PLAIN_ERROR_CHARS)}…`
288
+ : collapsed,
289
+ };
290
+ }
187
291
  //# sourceMappingURL=http.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/core/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,GAEb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;;;;;;GAaG;AAEH,iDAAiD;AACjD,MAAM,oBAAoB,GAAG,gBAAgB,CAAA;AAE7C,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAiFjC,sFAAsF;AACtF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAA;IACrB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAQ;QACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,CA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AED;;;;;;;;;;;;;GAaG;AACH,SAAS,cAAc,CAAC,IAAY;IAClC,6EAA6E;IAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClD,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IAC7D,OAAO;QACL,KAAK,EACH,SAAS,CAAC,MAAM,GAAG,qBAAqB;YACtC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,GAAG;YACjD,CAAC,CAAC,SAAS;KAChB,CAAA;AACH,CAAC"}
@@ -1,5 +1,32 @@
1
1
  /**
2
- * Keyset pagination. Every list endpoint returns `{items, nextCursor}`.
2
+ * Keyset pagination — for the eleven endpoints that have it.
3
+ *
4
+ * "Every list returns `{items, nextCursor}`" is what this file used to claim,
5
+ * and it is not what the API does. Counted over the spec snapshot
6
+ * (`openapi/spec.json`), the reading endpoints fall into three shapes:
7
+ *
8
+ * • 11 GETs take `cursor`/`limit` and answer a `nextCursor` — addresses,
9
+ * history, approval requests, members, counterparties, counterparty
10
+ * groups, operation categories, operation relations, ledger entries, a
11
+ * vault's policies, balances. These are what `paginate` is for;
12
+ * • 18 answer `{items}` with NO cursor parameter at all — folders and their
13
+ * grants, address shares, shared-with-me / shared-by-me, visibility
14
+ * grants, category assignments and their versions, report templates and
15
+ * snapshots, user groups and their members, status history, the
16
+ * admin-level `/policies` list and one policy's versions (18 paths, two
17
+ * of them the older `/address-groups` prefix of the folder endpoints).
18
+ * What you get is everything there is; `paginate` over one of them yields
19
+ * that single page and stops, because an absent `nextCursor` is the
20
+ * end-of-list signal;
21
+ * • 8 answer a BARE ARRAY rather than an object: `/networks`, `/tokens`,
22
+ * `/vaults`, a vault's `/policy-groups` and `/invitations`, one
23
+ * operation's `/relations`, a policy group's `/policies`, a user's
24
+ * `/policy-groups`. There is no `items` to walk, so `paginate` refuses
25
+ * them by name instead of quietly yielding nothing.
26
+ *
27
+ * `/balances` is the one cursored endpoint `paginate` CANNOT walk: its page is
28
+ * `{vaultId, totals, accounts, nextCursor}` and the array is called
29
+ * `accounts`. Pass the cursor by hand there.
3
30
  *
4
31
  * The cursor is opaque: do not parse it, build it or compare it. A
5
32
  * `nextCursor` of `null` is the only end-of-list signal — an empty page is
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/core/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAA;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED;;;;;;;;;GASG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAC/B,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAyBpC;AAED,uEAAuE;AACvE,wBAAsB,UAAU,CAAC,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,OAAO,CAAC,CAAC,EAAE,CAAC,CAId"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/core/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAA;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED;;;;;;;;;GASG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAC/B,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAmCpC;AAED,uEAAuE;AACvE,wBAAsB,UAAU,CAAC,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,OAAO,CAAC,CAAC,EAAE,CAAC,CAId"}
@@ -1,5 +1,32 @@
1
1
  /**
2
- * Keyset pagination. Every list endpoint returns `{items, nextCursor}`.
2
+ * Keyset pagination — for the eleven endpoints that have it.
3
+ *
4
+ * "Every list returns `{items, nextCursor}`" is what this file used to claim,
5
+ * and it is not what the API does. Counted over the spec snapshot
6
+ * (`openapi/spec.json`), the reading endpoints fall into three shapes:
7
+ *
8
+ * • 11 GETs take `cursor`/`limit` and answer a `nextCursor` — addresses,
9
+ * history, approval requests, members, counterparties, counterparty
10
+ * groups, operation categories, operation relations, ledger entries, a
11
+ * vault's policies, balances. These are what `paginate` is for;
12
+ * • 18 answer `{items}` with NO cursor parameter at all — folders and their
13
+ * grants, address shares, shared-with-me / shared-by-me, visibility
14
+ * grants, category assignments and their versions, report templates and
15
+ * snapshots, user groups and their members, status history, the
16
+ * admin-level `/policies` list and one policy's versions (18 paths, two
17
+ * of them the older `/address-groups` prefix of the folder endpoints).
18
+ * What you get is everything there is; `paginate` over one of them yields
19
+ * that single page and stops, because an absent `nextCursor` is the
20
+ * end-of-list signal;
21
+ * • 8 answer a BARE ARRAY rather than an object: `/networks`, `/tokens`,
22
+ * `/vaults`, a vault's `/policy-groups` and `/invitations`, one
23
+ * operation's `/relations`, a policy group's `/policies`, a user's
24
+ * `/policy-groups`. There is no `items` to walk, so `paginate` refuses
25
+ * them by name instead of quietly yielding nothing.
26
+ *
27
+ * `/balances` is the one cursored endpoint `paginate` CANNOT walk: its page is
28
+ * `{vaultId, totals, accounts, nextCursor}` and the array is called
29
+ * `accounts`. Pass the cursor by hand there.
3
30
  *
4
31
  * The cursor is opaque: do not parse it, build it or compare it. A
5
32
  * `nextCursor` of `null` is the only end-of-list signal — an empty page is
@@ -24,6 +51,14 @@ export async function* paginate(fetchPage, options = {}) {
24
51
  ...(options.limit === undefined ? {} : { limit: options.limit }),
25
52
  ...(cursor === undefined ? {} : { cursor }),
26
53
  });
54
+ // A bare-array endpoint (or `/balances`, whose array is `accounts`) has no
55
+ // `items`, and `for…of undefined` would report that as an unexplained
56
+ // TypeError from inside the SDK. Say what is wrong instead.
57
+ if (!Array.isArray(result.items)) {
58
+ throw new Error('@v3finance/core-sdk: this response has no `items` array, so it cannot be paged. ' +
59
+ 'Endpoints answering a bare array, and /balances (its array is `accounts`), ' +
60
+ 'are read with a single call — see the note at the top of core/pagination.ts.');
61
+ }
27
62
  for (const item of result.items)
28
63
  yield item;
29
64
  seen += result.items.length;
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../src/core/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAcH;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,QAAQ,CAC7B,SAAmD,EACnD,OAAO,GAA0C,EAAE;IAEnD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAA;IACzC,IAAI,MAA0B,CAAA;IAC9B,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAY,MAAM,SAAS,CAAC;YACtC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;YAChE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;SAC5C,CAAC,CAAA;QACF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;YAAE,MAAM,IAAI,CAAA;QAC3C,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAA;QAE3B,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS;YAAE,OAAM;QACzE,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,wEAAwE,IAAI,SAAS,CACtF,CAAA;QACH,CAAC;QACD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAA;IAC5B,CAAC;IAED,MAAM,IAAI,KAAK,CACb,kCAAkC,QAAQ,0DAA0D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BAChF,6EAA6E;gBAC7E,8EAA8E,CACjF,CAAA;QACH,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;YAAE,MAAM,IAAI,CAAA;QAC3C,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAA;QAE3B,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS;YAAE,OAAM;QACzE,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,wEAAwE,IAAI,SAAS,CACtF,CAAA;QACH,CAAC;QACD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAA;IAC5B,CAAC;IAED,MAAM,IAAI,KAAK,CACb,kCAAkC,QAAQ,0DAA0D,CACrG,CAAA;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,SAAmD,EACnD,OAAO,GAA0C,EAAE;IAEnD,MAAM,GAAG,GAAQ,EAAE,CAAA;IACnB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrE,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -9,7 +9,7 @@
9
9
  // the API does not slip in unclassified.
10
10
  //
11
11
  // Operations: 171 · admin: 40 · both: 1 · member: 127 · service: 3
12
- // Spec sha256: 1b67f22c80335e08be9a9ecf1351324e01b6003a96dde1253ef0032b3ab6a6fc
12
+ // Spec sha256: 017bae30075b232ab4efdcfb7785335020be3060b46e3569b1cd887fcf037597
13
13
  export const OPERATIONS = {
14
14
  "DELETE /api/v1/me/push-tokens/{token}": {
15
15
  "method": "delete",