@delopay/sdk 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/internal.cjs CHANGED
@@ -196,16 +196,21 @@ var Authentication = class {
196
196
  body: params
197
197
  });
198
198
  }
199
- async sync(authId, params) {
200
- return this.request("POST", `/authentication/${encodeURIComponent(authId)}/sync`, {
201
- body: params
202
- });
199
+ /** Sync authentication status. `POST /authentication/{merchantId}/{authId}/sync` */
200
+ async sync(merchantId, authId, params) {
201
+ return this.request(
202
+ "POST",
203
+ `/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/sync`,
204
+ { body: params }
205
+ );
203
206
  }
204
- /** Redirect after authentication. `POST /authentication/{authId}/redirect` */
205
- async redirect(authId, params) {
206
- return this.request("POST", `/authentication/${encodeURIComponent(authId)}/redirect`, {
207
- body: params
208
- });
207
+ /** Redirect after authentication. `POST /authentication/{merchantId}/{authId}/redirect` */
208
+ async redirect(merchantId, authId, params) {
209
+ return this.request(
210
+ "POST",
211
+ `/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/redirect`,
212
+ { body: params }
213
+ );
209
214
  }
210
215
  /** Enable authn methods token. `POST /authentication/{authId}/enabled-authn-methods-token` */
211
216
  async enabledAuthnMethodsToken(authId, params) {
@@ -842,11 +847,11 @@ var PaymentLinks = class {
842
847
  `/payment-link/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`
843
848
  );
844
849
  }
845
- /** Get payment link status. `GET /payment-linkstatus/{merchantId}/{paymentId}` */
850
+ /** Get payment link status. `GET /payment-link/status/{merchantId}/{paymentId}` */
846
851
  async status(merchantId, paymentId) {
847
852
  return this.request(
848
853
  "GET",
849
- `/payment-linkstatus/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`
854
+ `/payment-link/status/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`
850
855
  );
851
856
  }
852
857
  };
@@ -1009,19 +1014,21 @@ var Payments = class {
1009
1014
  * Create a new payment intent.
1010
1015
  *
1011
1016
  * @param params - Payment creation parameters including amount and currency.
1017
+ * @param options - Optional per-call extras: extra `headers` (e.g. an
1018
+ * `Idempotency-Key` to make the create safe to retry), a `timeout` override,
1019
+ * and an `AbortSignal`.
1012
1020
  * @returns The created payment intent.
1013
1021
  *
1014
1022
  * @example
1015
1023
  * ```typescript
1016
- * const payment = await delopay.payments.create({
1017
- * amount: 5000,
1018
- * currency: 'EUR',
1019
- * customer_id: 'cus_123',
1020
- * });
1024
+ * const payment = await delopay.payments.create(
1025
+ * { amount: 5000, currency: 'EUR', customer_id: 'cus_123' },
1026
+ * { headers: { 'Idempotency-Key': 'order_1001' } },
1027
+ * );
1021
1028
  * ```
1022
1029
  */
1023
- async create(params) {
1024
- return this.request("POST", "/payments", { body: params });
1030
+ async create(params, options) {
1031
+ return this.request("POST", "/payments", { body: params, ...options });
1025
1032
  }
1026
1033
  /**
1027
1034
  * Retrieve a payment by its ID.
@@ -1105,6 +1112,8 @@ var Payments = class {
1105
1112
  * List payment intents, optionally filtered by customer or date range.
1106
1113
  *
1107
1114
  * @param params - Optional filter and pagination parameters.
1115
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
1116
+ * override, and an `AbortSignal` for cancellation.
1108
1117
  * @returns Paginated list of payment intents.
1109
1118
  *
1110
1119
  * @example
@@ -1112,9 +1121,10 @@ var Payments = class {
1112
1121
  * const { data } = await delopay.payments.list({ customer_id: 'cus_123', limit: 25 });
1113
1122
  * ```
1114
1123
  */
1115
- async list(params) {
1124
+ async list(params, options) {
1116
1125
  return this.request("GET", "/payments/list", {
1117
- query: params
1126
+ query: params,
1127
+ ...options
1118
1128
  });
1119
1129
  }
1120
1130
  // --- Advanced operations (Task 3.2) ---
@@ -1319,13 +1329,13 @@ var Payouts = class {
1319
1329
  async listByFilter(params) {
1320
1330
  return this.request("POST", "/payouts/list", { body: params });
1321
1331
  }
1322
- /** Get payout filter options. `POST /payouts/filter` */
1332
+ /** Get payout filter options. `GET /payouts/filter` */
1323
1333
  async getFilters(params) {
1324
- return this.request("POST", "/payouts/filter", { body: params });
1334
+ return this.request("GET", "/payouts/filter", { query: params });
1325
1335
  }
1326
- /** Get payout filters (profile-scoped). `POST /payouts/profile/filter` */
1336
+ /** Get payout filters (profile-scoped). `GET /payouts/profile/filter` */
1327
1337
  async getFiltersByProfile(params) {
1328
- return this.request("POST", "/payouts/profile/filter", { body: params });
1338
+ return this.request("GET", "/payouts/profile/filter", { query: params });
1329
1339
  }
1330
1340
  /** Get payout aggregates. `GET /payouts/aggregate` */
1331
1341
  async aggregate(params) {
@@ -1835,7 +1845,7 @@ var Shops = class {
1835
1845
  *
1836
1846
  * @example
1837
1847
  * ```typescript
1838
- * const shop = await delopay.shops.create('merch_123', { profile_name: 'EU Store' });
1848
+ * const shop = await delopay.shops.create('merch_123', { shop_name: 'EU Store' });
1839
1849
  * ```
1840
1850
  */
1841
1851
  async create(merchantId, params) {
@@ -2099,7 +2109,7 @@ var Users = class {
2099
2109
  return this.request("POST", "/user/employees/invite", { body: params });
2100
2110
  }
2101
2111
  async acceptInvitation(params) {
2102
- return this.request("POST", "/user/invite/accept", { body: params });
2112
+ return this.request("POST", "/user/employees/invite/accept", { body: params });
2103
2113
  }
2104
2114
  /**
2105
2115
  * Accept an invitation via the email-link flow.
@@ -2228,9 +2238,9 @@ var Users = class {
2228
2238
  query: params
2229
2239
  });
2230
2240
  }
2231
- /** Resend invite. `POST /user/employees/resend-invite` */
2241
+ /** Resend invite. `POST /user/resend-invite` */
2232
2242
  async resendInvite(params) {
2233
- return this.request("POST", "/user/employees/resend-invite", { body: params });
2243
+ return this.request("POST", "/user/resend-invite", { body: params });
2234
2244
  }
2235
2245
  /**
2236
2246
  * Get the caller's parent permission groups + scopes.
@@ -2259,14 +2269,6 @@ var Users = class {
2259
2269
  async listUpdatableRoles() {
2260
2270
  return this.request("GET", "/user/role/list/update");
2261
2271
  }
2262
- /** Get permission info. `GET /user/permission-info` */
2263
- async getPermissionInfo() {
2264
- return this.request("GET", "/user/permission-info");
2265
- }
2266
- /** Get module list. `GET /user/module/list` */
2267
- async getModuleList() {
2268
- return this.request("GET", "/user/module/list");
2269
- }
2270
2272
  /** Get parent list. `GET /user/parent/list` */
2271
2273
  async getParentList() {
2272
2274
  return this.request("GET", "/user/parent/list");
@@ -2736,7 +2738,7 @@ var Delopay = class {
2736
2738
  /**
2737
2739
  * Create a new Delopay client.
2738
2740
  *
2739
- * @param apiKey - Your Delopay API key (e.g. `sk_live_...` or `sk_test_...`).
2741
+ * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).
2740
2742
  * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).
2741
2743
  * @param options - Optional configuration (sandbox mode, base URL override, timeout).
2742
2744
  */
@@ -2993,34 +2995,64 @@ var Delopay = class {
2993
2995
  * Auto-paginate a list endpoint. Yields items one by one, fetching
2994
2996
  * the next page automatically when the current one is exhausted.
2995
2997
  *
2996
- * @param listFn - A function that takes `{ limit, offset }` and returns `{ data: T[] }` or `T[]`.
2998
+ * Delopay list endpoints use one of two pagination styles, so this helper
2999
+ * supports both:
3000
+ * - **Offset** (default) — for endpoints like `customers.list` that accept
3001
+ * `offset`/`limit`. Each page advances `offset` by the number of items returned.
3002
+ * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page
3003
+ * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor
3004
+ * that returns the id of an item; the next page is requested with
3005
+ * `starting_after` set to the last item's id.
3006
+ *
3007
+ * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.
2997
3008
  * @param params - Additional parameters to pass to every page request.
2998
- * @param pageSize - Number of items per page. Defaults to `50`.
3009
+ * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.
3010
+ * Provide `cursor` to switch to cursor pagination.
2999
3011
  *
3000
3012
  * @example
3001
3013
  * ```typescript
3014
+ * // Offset endpoint (customers):
3015
+ * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {
3016
+ * console.log(c.customer_id);
3017
+ * }
3018
+ *
3019
+ * // Cursor endpoint (payments): extract the id used as the next cursor.
3002
3020
  * for await (const payment of delopay.paginate(
3003
3021
  * (p) => delopay.payments.list(p),
3022
+ * undefined,
3023
+ * { cursor: (p) => p.payment_id },
3004
3024
  * )) {
3005
3025
  * console.log(payment.payment_id);
3006
3026
  * }
3007
3027
  * ```
3008
3028
  */
3009
- async *paginate(listFn, params, pageSize = 50) {
3029
+ async *paginate(listFn, params, options) {
3030
+ const pageSize = typeof options === "number" ? options : options?.pageSize ?? 50;
3031
+ const cursorOf = typeof options === "object" ? options.cursor : void 0;
3010
3032
  let offset = 0;
3033
+ let after;
3011
3034
  while (true) {
3012
- const result = await listFn({
3013
- ...params ?? {},
3014
- limit: pageSize,
3015
- offset
3016
- });
3035
+ const page = { ...params ?? {}, limit: pageSize };
3036
+ if (cursorOf) {
3037
+ if (after !== void 0) page.starting_after = after;
3038
+ } else {
3039
+ page.offset = offset;
3040
+ }
3041
+ const result = await listFn(page);
3017
3042
  const items = Array.isArray(result) ? result : result.data;
3018
3043
  if (items.length === 0) break;
3019
3044
  for (const item of items) {
3020
3045
  yield item;
3021
3046
  }
3022
3047
  if (items.length < pageSize) break;
3023
- offset += items.length;
3048
+ if (cursorOf) {
3049
+ const last = items[items.length - 1];
3050
+ if (last === void 0) break;
3051
+ after = cursorOf(last);
3052
+ if (after === void 0) break;
3053
+ } else {
3054
+ offset += items.length;
3055
+ }
3024
3056
  }
3025
3057
  }
3026
3058
  };
@@ -3667,22 +3699,22 @@ var Admin = class {
3667
3699
  return this.request("POST", "/admin/signin", { body: params });
3668
3700
  }
3669
3701
  async createInternalUser(params) {
3670
- return this.request("POST", "/admin/internal_signup", { body: params });
3702
+ return this.request("POST", "/admin/internal-signup", { body: params });
3671
3703
  }
3672
3704
  async createTenant(params) {
3673
- return this.request("POST", "/admin/tenant_signup", { body: params });
3705
+ return this.request("POST", "/admin/tenant-signup", { body: params });
3674
3706
  }
3675
3707
  /**
3676
3708
  * Create a new merchant admin user and merchant account atomically.
3677
3709
  *
3678
3710
  * This is the correct endpoint for bootstrapping the first admin user in a
3679
- * fresh deployment — `internal_signup`/`tenant_signup` both require
3711
+ * fresh deployment — `internal-signup`/`tenant-signup` both require
3680
3712
  * pre-existing merchant records that don't exist on a clean database.
3681
3713
  *
3682
- * `POST /admin/signup_with_merchant_id`
3714
+ * `POST /admin/signup-with-merchant-id`
3683
3715
  */
3684
3716
  async signupWithMerchantId(params) {
3685
- return this.request("POST", "/admin/signup_with_merchant_id", { body: params });
3717
+ return this.request("POST", "/admin/signup-with-merchant-id", { body: params });
3686
3718
  }
3687
3719
  /** Toggle public signup on/off. `POST /admin/settings/signup` */
3688
3720
  async setSignupSettings(params) {
@@ -3692,9 +3724,9 @@ var Admin = class {
3692
3724
  async getSignupSettings() {
3693
3725
  return this.request("GET", "/admin/settings/signup");
3694
3726
  }
3695
- /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard_merchant` */
3727
+ /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard-merchant` */
3696
3728
  async onboardMerchant(params) {
3697
- return this.request("POST", "/admin/onboard_merchant", { body: params });
3729
+ return this.request("POST", "/admin/onboard-merchant", { body: params });
3698
3730
  }
3699
3731
  };
3700
3732
 
@@ -3831,13 +3863,13 @@ var CardIssuers = class {
3831
3863
  this.request = request;
3832
3864
  }
3833
3865
  async create(params) {
3834
- return this.request("POST", "/card_issuers", { body: params });
3866
+ return this.request("POST", "/card-issuers", { body: params });
3835
3867
  }
3836
3868
  async update(issuerId, params) {
3837
- return this.request("PUT", `/card_issuers/${encodeURIComponent(issuerId)}`, { body: params });
3869
+ return this.request("PUT", `/card-issuers/${encodeURIComponent(issuerId)}`, { body: params });
3838
3870
  }
3839
3871
  async list() {
3840
- return this.request("GET", "/card_issuers");
3872
+ return this.request("GET", "/card-issuers");
3841
3873
  }
3842
3874
  };
3843
3875
 
@@ -3875,22 +3907,22 @@ var ConnectorRestrictions = class {
3875
3907
  * everyone again, call `delete()`.
3876
3908
  */
3877
3909
  async upsert(body) {
3878
- return this.request("POST", "/admin/connector_restrictions", { body });
3910
+ return this.request("POST", "/admin/connector-restrictions", { body });
3879
3911
  }
3880
3912
  async list() {
3881
- return this.request("GET", "/admin/connector_restrictions");
3913
+ return this.request("GET", "/admin/connector-restrictions");
3882
3914
  }
3883
3915
  async retrieve(connectorName) {
3884
3916
  return this.request(
3885
3917
  "GET",
3886
- `/admin/connector_restrictions/${encodeURIComponent(connectorName)}`
3918
+ `/admin/connector-restrictions/${encodeURIComponent(connectorName)}`
3887
3919
  );
3888
3920
  }
3889
3921
  /** Removing the row makes the connector public again. */
3890
3922
  async delete(connectorName) {
3891
3923
  return this.request(
3892
3924
  "DELETE",
3893
- `/admin/connector_restrictions/${encodeURIComponent(connectorName)}`
3925
+ `/admin/connector-restrictions/${encodeURIComponent(connectorName)}`
3894
3926
  );
3895
3927
  }
3896
3928
  };