squarefi-bff-api-module 1.36.53 → 1.36.54

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.
@@ -7,6 +7,11 @@ import { API } from './types/types';
7
7
  *
8
8
  * `list` / `items` filter by a single status value (not an array), so they need none of the
9
9
  * comma-joining the issuing list endpoints do.
10
+ *
11
+ * Two limits live outside this client. The recipient caps are per-tenant and come from
12
+ * `tenants.config.get()` under `mass_payouts` (`API.MassPayouts.Config`) — never hardcode them.
13
+ * The batch a payment belongs to is read off the order (`mass_payout`), and a feed is narrowed to
14
+ * one batch with the `mass_payout_id` order-list filter, not from here.
10
15
  */
11
16
  export declare const massPayouts: {
12
17
  list: ({ wallet_id, ...params }: API.MassPayouts.List.Request) => Promise<API.MassPayouts.List.Response>;
@@ -7,6 +7,11 @@ import { apiClientV1Frontend } from '../utils/apiClientFactory';
7
7
  *
8
8
  * `list` / `items` filter by a single status value (not an array), so they need none of the
9
9
  * comma-joining the issuing list endpoints do.
10
+ *
11
+ * Two limits live outside this client. The recipient caps are per-tenant and come from
12
+ * `tenants.config.get()` under `mass_payouts` (`API.MassPayouts.Config`) — never hardcode them.
13
+ * The batch a payment belongs to is read off the order (`mass_payout`), and a feed is narrowed to
14
+ * one batch with the `mass_payout_id` order-list filter, not from here.
10
15
  */
11
16
  export const massPayouts = {
12
17
  list: ({ wallet_id, ...params }) => apiClientV1Frontend.getRequest(`/frontend/mass-payouts/${wallet_id}`, { params }),
@@ -22,6 +27,11 @@ export const massPayouts = {
22
27
  }),
23
28
  preview: ({ wallet_id, id }) => apiClientV1Frontend.getRequest(`/frontend/mass-payouts/${wallet_id}/${id}/preview`),
24
29
  submit: ({ wallet_id, id }) => apiClientV1Frontend.postRequest(`/frontend/mass-payouts/${wallet_id}/${id}/submit`),
30
+ // Second factor is mandatory and per-batch: run the `totp.otp_verification` flow with the batch
31
+ // id as `request_id` and let the user complete it BEFORE calling this, or approve answers 403
32
+ // `VERIFICATION_NOT_APPROVED` (404 `REQUEST_ID_NOT_FOUND` when none was ever requested). The
33
+ // check runs before anything is claimed, so a refusal leaves the batch untouched and approve can
34
+ // simply be retried. Clerk tenants additionally need a step-up verified within the last 10 min.
25
35
  approve: ({ wallet_id, id }) => apiClientV1Frontend.postRequest(`/frontend/mass-payouts/${wallet_id}/${id}/approve`),
26
36
  cancel: ({ wallet_id, id }) => apiClientV1Frontend.postRequest(`/frontend/mass-payouts/${wallet_id}/${id}/cancel`),
27
37
  // `text/csv`, not the JSON envelope — the raw CSV body is resolved as a string. `responseType`
@@ -5,4 +5,13 @@ export declare const storage: {
5
5
  getFileUrl: ({ path }: API.Storage.KYC.GetFileUrl.Request) => Promise<API.Storage.KYC.GetFileUrl.Response>;
6
6
  getFileById: ({ folderId, fileId, }: API.Storage.KYC.GetFileById.Request) => Promise<API.Storage.KYC.GetFileById.Response>;
7
7
  };
8
+ /**
9
+ * Supporting documents for orders and mass payouts. Separate bucket from KYC. Upload the file
10
+ * first, then pass the returned path as `documents[].url` on the order or the mass payout row —
11
+ * the payout schemas carry the link only, never the bytes. PDF/JPEG/PNG, up to 20 MB.
12
+ */
13
+ orderDocuments: {
14
+ upload: (file: File) => Promise<API.Storage.OrderDocuments.Upload.Response>;
15
+ getFileById: ({ folderId, fileId, }: API.Storage.OrderDocuments.GetFileById.Request) => Promise<API.Storage.OrderDocuments.GetFileById.Response>;
16
+ };
8
17
  };
@@ -13,4 +13,19 @@ export const storage = {
13
13
  }),
14
14
  getFileById: ({ folderId, fileId, }) => apiClientV2.getRequest(`/storage/kyc/${folderId}/${fileId}`),
15
15
  },
16
+ /**
17
+ * Supporting documents for orders and mass payouts. Separate bucket from KYC. Upload the file
18
+ * first, then pass the returned path as `documents[].url` on the order or the mass payout row —
19
+ * the payout schemas carry the link only, never the bytes. PDF/JPEG/PNG, up to 20 MB.
20
+ */
21
+ orderDocuments: {
22
+ upload: (file) => {
23
+ const formData = new FormData();
24
+ formData.append('file', file);
25
+ return apiClientV2.postRequest('/storage/order-documents', {
26
+ data: formData,
27
+ });
28
+ },
29
+ getFileById: ({ folderId, fileId, }) => apiClientV2.getRequest(`/storage/order-documents/${folderId}/${fileId}`),
30
+ },
16
31
  };
@@ -4854,7 +4854,11 @@ export interface paths {
4854
4854
  limit?: number;
4855
4855
  sort_by?: string;
4856
4856
  sort_order?: "asc" | "desc";
4857
- /** @description JSON-encoded filters */
4857
+ /** @description JSON-encoded array of filters, e.g. `[{"status":"COMPLETE"}]`.
4858
+ * Besides order columns it accepts `mass_payout_id` (uuid), which narrows the
4859
+ * result to the orders of one mass payout batch — the same batch reported by
4860
+ * the `mass_payout_id` field of each order. A non-uuid value is rejected with 400.
4861
+ * */
4858
4862
  filters?: string;
4859
4863
  date_from?: string;
4860
4864
  date_to?: string;
@@ -8141,6 +8145,12 @@ export interface components {
8141
8145
  sub_account_id?: string | null;
8142
8146
  info?: string | null;
8143
8147
  meta?: components["schemas"]["OrderMeta"];
8148
+ /** @description Batch this order was created by, when it was sent as part of a mass payout; null for a standalone order. Filter the list by it with `filters=[{"mass_payout_id":"<uuid>"}]`. */
8149
+ mass_payout?: {
8150
+ /** Format: uuid */
8151
+ id?: string;
8152
+ name?: string | null;
8153
+ } | null;
8144
8154
  /**
8145
8155
  * Format: date-time
8146
8156
  * @description Requested execution time for scheduled payments (status EXPECTED); null for immediate orders
@@ -6699,7 +6699,10 @@ export interface paths {
6699
6699
  parameters: {
6700
6700
  query?: {
6701
6701
  status?: "DRAFT" | "PENDING_APPROVAL" | "SCHEDULED" | "PROCESSING" | "COMPLETED" | "FAILED" | "CANCELED";
6702
- /** @description Case-insensitive substring match against the batch name */
6702
+ /** @description Search box of the batch list: a case-insensitive PARTIAL match
6703
+ * against the batch name, so a fragment finds it. LIKE metacharacters
6704
+ * in the term are matched literally.
6705
+ * */
6703
6706
  name?: string;
6704
6707
  /** @description Only batches created at or after this moment */
6705
6708
  date_from?: string;
@@ -7176,9 +7179,18 @@ export interface paths {
7176
7179
  * standard order flow, funds are debited per order). The estimated total
7177
7180
  * debit is checked against the wallet balance first — a batch that
7178
7181
  * cannot cover all payouts is refused instead of paying only part of the
7179
- * list. Requires an administrative wallet role. On Clerk-authenticated
7180
- * tenants a second factor verified within the last 10 minutes is also
7181
- * required — a stale one is rejected with
7182
+ * list. Requires an administrative wallet role.
7183
+ *
7184
+ * **Second factor, per action and mandatory.** Request an OTP
7185
+ * verification for THIS batch id and have the user complete it before
7186
+ * calling approve — the endpoint checks that verification and refuses
7187
+ * unless it came back APPROVED. Releasing a whole batch of payments is
7188
+ * verified exactly like approving a single order. The check runs before
7189
+ * anything is claimed or estimated, so a failed one leaves the batch
7190
+ * untouched and approve can simply be retried.
7191
+ *
7192
+ * On Clerk-authenticated tenants a second factor verified within the last
7193
+ * 10 minutes is required on top of that — a stale one is rejected with
7182
7194
  * `TWO_FACTOR_REVERIFICATION_REQUIRED` (Supabase-authenticated tenants
7183
7195
  * have no step-up check). Execution continues past failed items;
7184
7196
  * progress is visible through the batch counters.
@@ -7219,7 +7231,10 @@ export interface paths {
7219
7231
  "application/json": components["schemas"]["ErrorResponse"];
7220
7232
  };
7221
7233
  };
7222
- /** @description Caller lacks an administrative wallet role, or (Clerk tenants) the second-factor verification is stale */
7234
+ /** @description Caller lacks an administrative wallet role, the OTP verification for
7235
+ * this batch is not APPROVED (`VERIFICATION_NOT_APPROVED`), or (Clerk
7236
+ * tenants) the second-factor verification is stale.
7237
+ * */
7223
7238
  403: {
7224
7239
  headers: {
7225
7240
  [name: string]: unknown;
@@ -7228,6 +7243,15 @@ export interface paths {
7228
7243
  "application/json": components["schemas"]["ErrorResponse"];
7229
7244
  };
7230
7245
  };
7246
+ /** @description Batch not found, or no OTP verification was requested for it (`REQUEST_ID_NOT_FOUND`) */
7247
+ 404: {
7248
+ headers: {
7249
+ [name: string]: unknown;
7250
+ };
7251
+ content: {
7252
+ "application/json": components["schemas"]["ErrorResponse"];
7253
+ };
7254
+ };
7231
7255
  /** @description Batch is not awaiting approval, or another operation on it is in flight */
7232
7256
  409: {
7233
7257
  headers: {
@@ -9117,7 +9141,11 @@ export interface paths {
9117
9141
  limit?: number;
9118
9142
  sort_by?: string;
9119
9143
  sort_order?: "asc" | "desc";
9120
- /** @description JSON-encoded filters */
9144
+ /** @description JSON-encoded array of filters, e.g. `[{"status":"COMPLETE"}]`.
9145
+ * Besides order columns it accepts `mass_payout_id` (uuid), which narrows the
9146
+ * result to the orders of one mass payout batch — the same batch reported by
9147
+ * the `mass_payout_id` field of each order. A non-uuid value is rejected with 400.
9148
+ * */
9121
9149
  filters?: string;
9122
9150
  date_from?: string;
9123
9151
  date_to?: string;
@@ -9184,7 +9212,11 @@ export interface paths {
9184
9212
  query?: {
9185
9213
  date_from?: string;
9186
9214
  date_to?: string;
9187
- /** @description JSON-encoded filters */
9215
+ /** @description JSON-encoded array of filters, e.g. `[{"status":"COMPLETE"}]`.
9216
+ * Besides order columns it accepts `mass_payout_id` (uuid), which narrows the
9217
+ * result to the orders of one mass payout batch — the same batch reported by
9218
+ * the `mass_payout_id` field of each order. A non-uuid value is rejected with 400.
9219
+ * */
9188
9220
  filters?: string;
9189
9221
  /** @description If `true`, includes dust orders (amount below render threshold for either currency). Defaults to `false` — dust orders are hidden. */
9190
9222
  show_low_balance?: "true" | "false";
@@ -14402,6 +14434,13 @@ export interface components {
14402
14434
  /** @description Computed dust flag — amount below the render threshold for either currency. Returned by the list endpoint (GET /frontend/orders/wallet/{wallet_uuid}); absent from single-order reads. */
14403
14435
  is_threshold_amount?: boolean;
14404
14436
  meta?: components["schemas"]["OrderMeta"];
14437
+ /** @description Batch this order was created by, when it was sent as part of a mass payout; null for a standalone order. Filter the list by it with `filters=[{"mass_payout_id":"<uuid>"}]`. */
14438
+ mass_payout?: {
14439
+ /** Format: uuid */
14440
+ id?: string;
14441
+ /** @description Batch name — null only when the batch can no longer be resolved. */
14442
+ name?: string | null;
14443
+ } | null;
14405
14444
  /**
14406
14445
  * Format: date-time
14407
14446
  * @description Requested execution time for scheduled payments (status EXPECTED); null for immediate orders
@@ -14821,9 +14860,17 @@ export interface components {
14821
14860
  currency_id?: string;
14822
14861
  /**
14823
14862
  * Format: uuid
14824
- * @description Source virtual account for banking payouts (required only when the batch contains banking recipients)
14863
+ * @description Source virtual account, required for a banking batch — its
14864
+ * methods are what such a batch sends through.
14865
+ *
14866
+ * A batch sends ONE way only: internal, crypto or banking, never a
14867
+ * mix. The first recipient by upload position sets the kind and the
14868
+ * rest must match it; a recipient of another kind is reported as a
14869
+ * problem by preview and blocks submit/approve.
14870
+ *
14825
14871
  */
14826
14872
  virtual_account_id?: string | null;
14873
+ /** @description Batch name — required, free-form and NOT unique. Two batches of one wallet may share a name. */
14827
14874
  name?: string;
14828
14875
  /**
14829
14876
  * @description SCHEDULED = approved with a future send date; execution starts automatically at that moment
@@ -14904,7 +14951,13 @@ export interface components {
14904
14951
  amount: number;
14905
14952
  /**
14906
14953
  * Format: uuid
14907
- * @description Payout currency of this row; omit for the batch source currency. A differing value makes the payout a cross-currency one (the debit is converted at execution time)
14954
+ * @description Payout currency of this row; omit for the batch source currency.
14955
+ * A differing value makes the payout a cross-currency one (the debit
14956
+ * is converted at execution time) and is accepted on banking rows
14957
+ * only — their off-ramp settles in the target currency. Crypto and
14958
+ * internal rows have no exchange leg, so they must stay in the batch
14959
+ * source currency.
14960
+ *
14908
14961
  */
14909
14962
  to_currency_id?: string;
14910
14963
  /** @description Optional payment reference for this row */
@@ -14912,10 +14965,19 @@ export interface components {
14912
14965
  /** @description Supporting documents; an INVOICE attachment is required for rows at or above the invoice threshold */
14913
14966
  documents?: components["schemas"]["MassPayoutDocument"][];
14914
14967
  };
14968
+ /** @description A template row has no documents field: an invoice belongs to one
14969
+ * concrete payment, never to the reusable recipient list. Attach
14970
+ * documents to the rows of a batch instead.
14971
+ * */
14915
14972
  MassPayoutTemplateItemInput: {
14916
14973
  /** Format: uuid */
14917
14974
  destination_id: string;
14918
- amount: number;
14975
+ /** @description Optional in a template: omit it (or send null) to save a recipient
14976
+ * list whose amounts are filled in later. When present it must be
14977
+ * positive. A batch created from the template still requires an
14978
+ * amount on every row.
14979
+ * */
14980
+ amount?: number | null;
14919
14981
  /** Format: uuid */
14920
14982
  to_currency_id?: string;
14921
14983
  reference?: string;
@@ -14925,7 +14987,8 @@ export interface components {
14925
14987
  id?: string;
14926
14988
  /** Format: uuid */
14927
14989
  destination_id?: string;
14928
- amount?: number;
14990
+ /** @description Null when the template row has no amount yet. */
14991
+ amount?: number | null;
14929
14992
  /** Format: uuid */
14930
14993
  to_currency_id?: string | null;
14931
14994
  reference?: string | null;
@@ -8794,6 +8794,12 @@ export interface components {
8794
8794
  info?: string | null;
8795
8795
  /** @description Filtered to META_ALLOWED_FIELDS */
8796
8796
  meta?: Record<string, never> | null;
8797
+ /** @description Batch this order was created by, when it was sent as part of a mass payout; null for a standalone order. Filter the list by it with `filters=[{"mass_payout_id":"<uuid>"}]`. */
8798
+ mass_payout?: {
8799
+ /** Format: uuid */
8800
+ id?: string;
8801
+ name?: string | null;
8802
+ } | null;
8797
8803
  /**
8798
8804
  * Format: date-time
8799
8805
  * @description Requested execution time for scheduled payments (status EXPECTED); null for immediate orders
@@ -313,6 +313,26 @@ export interface paths {
313
313
  patch?: never;
314
314
  trace?: never;
315
315
  };
316
+ "/storage/order-documents": {
317
+ parameters: {
318
+ query?: never;
319
+ header?: never;
320
+ path?: never;
321
+ cookie?: never;
322
+ };
323
+ get?: never;
324
+ put?: never;
325
+ /**
326
+ * Upload an order / mass payout document
327
+ * @description Uploads a document attachment for an order or a mass payout into the dedicated bucket (separate from KYC files) and returns a URL suitable for documents[].url when creating the order / mass payout.
328
+ */
329
+ post: operations["StorageController_uploadOrderDocument"];
330
+ delete?: never;
331
+ options?: never;
332
+ head?: never;
333
+ patch?: never;
334
+ trace?: never;
335
+ };
316
336
  "/storage/{type}/{folder_id}/{file_id}": {
317
337
  parameters: {
318
338
  query?: never;
@@ -1976,6 +1996,18 @@ export interface components {
1976
1996
  default: string;
1977
1997
  supported: string[];
1978
1998
  };
1999
+ SystemMassPayoutsConfigDto: {
2000
+ /** @description Whether mass payouts are available to this tenant. When false, every mass payout endpoint answers as if the feature did not exist. */
2001
+ enabled: boolean;
2002
+ /** @description Recipient rows one batch may carry. Exceeding it is rejected on create/update. */
2003
+ max_items: number;
2004
+ /** @description Rows one template may carry — a template is materialized into a batch, so it shares the batch cap. */
2005
+ max_template_items: number;
2006
+ /** @description Templates one wallet may keep. */
2007
+ max_templates_per_wallet: number;
2008
+ /** @description Supporting documents allowed per recipient row of a batch (template rows carry none). */
2009
+ max_item_documents: number;
2010
+ };
1979
2011
  SystemConfigDto: {
1980
2012
  tenant_id: string;
1981
2013
  app_url: string | null;
@@ -2002,6 +2034,7 @@ export interface components {
2002
2034
  /** @enum {string} */
2003
2035
  auth_provider: "supabase" | "clerk";
2004
2036
  base_currency: string;
2037
+ mass_payouts: components["schemas"]["SystemMassPayoutsConfigDto"];
2005
2038
  };
2006
2039
  SystemChainsResponseDto: {
2007
2040
  total: number;
@@ -2814,12 +2847,48 @@ export interface operations {
2814
2847
  };
2815
2848
  };
2816
2849
  };
2850
+ StorageController_uploadOrderDocument: {
2851
+ parameters: {
2852
+ query?: never;
2853
+ header?: never;
2854
+ path?: never;
2855
+ cookie?: never;
2856
+ };
2857
+ requestBody: {
2858
+ content: {
2859
+ "multipart/form-data": {
2860
+ /**
2861
+ * Format: binary
2862
+ * @description Allowed types: PDF, JPEG, PNG. Max size: 20 MB.
2863
+ */
2864
+ file: string;
2865
+ };
2866
+ };
2867
+ };
2868
+ responses: {
2869
+ 201: {
2870
+ headers: {
2871
+ [name: string]: unknown;
2872
+ };
2873
+ content: {
2874
+ "application/json": components["schemas"]["StorageUploadFileResponseDto"];
2875
+ };
2876
+ };
2877
+ /** @description Unauthorized */
2878
+ 401: {
2879
+ headers: {
2880
+ [name: string]: unknown;
2881
+ };
2882
+ content?: never;
2883
+ };
2884
+ };
2885
+ };
2817
2886
  StorageController_getFile: {
2818
2887
  parameters: {
2819
2888
  query?: never;
2820
2889
  header?: never;
2821
2890
  path: {
2822
- type: "kyc" | "logo";
2891
+ type: "kyc" | "logo" | "order-documents";
2823
2892
  folder_id: string;
2824
2893
  file_id: string;
2825
2894
  };
@@ -1403,6 +1403,17 @@ export declare namespace API {
1403
1403
  export type MassPayoutTemplateItem = componentsV1Frontend['schemas']['MassPayoutTemplateItem'];
1404
1404
  export type MassPayoutTemplateItemInput = componentsV1Frontend['schemas']['MassPayoutTemplateItemInput'];
1405
1405
  export type MassPayoutTemplateWithItems = componentsV1Frontend['schemas']['MassPayoutTemplateWithItems'];
1406
+ /**
1407
+ * The tenant's own mass payout limits and feature flag, delivered by `tenants.config.get()`
1408
+ * under `mass_payouts`. Read them rather than hardcoding a recipient cap — every whitelabel
1409
+ * tenant carries its own, and the only other way to learn one is to trip a 400.
1410
+ */
1411
+ export type Config = components['schemas']['SystemMassPayoutsConfigDto'];
1412
+ /**
1413
+ * Batch an order came from, as reported on the order itself — `null` for a standalone order.
1414
+ * Filter a feed down to one batch with the `mass_payout_id` order-list filter.
1415
+ */
1416
+ export type OrderMassPayoutRef = componentsV1Frontend['schemas']['Order']['mass_payout'];
1406
1417
  /**
1407
1418
  * Status unions read off the schemas rather than re-declared, so a spec change lands here
1408
1419
  * automatically. `SCHEDULED` = approved with a future send date; `CANCELED` on an item means
@@ -2123,7 +2134,13 @@ export declare namespace API {
2123
2134
  type OrderListOrderTypeFilter = Record<'order_type', OrderType[] | OrderType>;
2124
2135
  type OrderListFromUuidFilter = Record<'from_uuid', string[] | string>;
2125
2136
  type OrderListToUuidFilter = Record<'to_uuid', string[] | string>;
2126
- type OrderListFilter = OrderListStatusFilter | OrderListOrderTypeFilter | OrderListFromUuidFilter | OrderListToUuidFilter;
2137
+ /**
2138
+ * Narrows the feed to the orders of one mass payout batch — the batch each order
2139
+ * reports back in `mass_payout`. A single uuid only (not an array); a non-uuid value
2140
+ * is refused with 400.
2141
+ */
2142
+ type OrderListMassPayoutFilter = Record<'mass_payout_id', string>;
2143
+ type OrderListFilter = OrderListStatusFilter | OrderListOrderTypeFilter | OrderListFromUuidFilter | OrderListToUuidFilter | OrderListMassPayoutFilter;
2127
2144
  interface Request {
2128
2145
  wallet_uuid: string;
2129
2146
  offset?: number;
@@ -3031,6 +3048,22 @@ export declare namespace API {
3031
3048
  type Response = operations['StorageController_getFile']['responses']['200']['content']['application/octet-stream'];
3032
3049
  }
3033
3050
  }
3051
+ /**
3052
+ * Attachments for orders and mass payouts, in a bucket of their own (not the KYC one). The
3053
+ * uploaded file's link is what `documents[].url` expects on an order or a mass payout row.
3054
+ */
3055
+ namespace OrderDocuments {
3056
+ namespace Upload {
3057
+ type Response = operations['StorageController_uploadOrderDocument']['responses']['201']['content']['application/json'];
3058
+ }
3059
+ namespace GetFileById {
3060
+ interface Request {
3061
+ folderId: string;
3062
+ fileId: string;
3063
+ }
3064
+ type Response = operations['StorageController_getFile']['responses']['200']['content']['application/octet-stream'];
3065
+ }
3066
+ }
3034
3067
  }
3035
3068
  namespace Referrals {
3036
3069
  namespace Levels {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.36.53",
3
+ "version": "1.36.54",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",