@delopay/sdk 0.368.0 → 0.370.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
@@ -37,6 +37,7 @@ __export(internal_exports, {
37
37
  APPLE_PAY_BUTTON_TYPES: () => APPLE_PAY_BUTTON_TYPES,
38
38
  Admin: () => Admin,
39
39
  AdminBranding: () => AdminBranding,
40
+ AdminIndustries: () => AdminIndustries,
40
41
  AdminLive: () => AdminLive,
41
42
  AdminPortal: () => AdminPortal,
42
43
  AdminSupport: () => AdminSupport,
@@ -1275,9 +1276,9 @@ var Connectors = class {
1275
1276
  * to a single event.
1276
1277
  */
1277
1278
  async registerWebhook(merchantId, connectorId, params) {
1278
- const path3 = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;
1279
- if (params === void 0) return this.request("POST", path3);
1280
- return this.request("POST", path3, { body: params });
1279
+ const path4 = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;
1280
+ if (params === void 0) return this.request("POST", path4);
1281
+ return this.request("POST", path4, { body: params });
1281
1282
  }
1282
1283
  /**
1283
1284
  * Register checkout/shop domains as Stripe payment method domains, so Apple
@@ -2075,11 +2076,11 @@ function negotiated(options, format, presentation) {
2075
2076
  }
2076
2077
  return format === "json" ? { ...options, headers } : { ...options, headers, responseType: "blob" };
2077
2078
  }
2078
- function runExport(request, method, path3, base, options) {
2079
+ function runExport(request, method, path4, base, options) {
2079
2080
  const format = options?.format ?? "json";
2080
2081
  return downloadExport(
2081
2082
  request,
2082
- { method, path: path3, request: negotiated(base, format, options?.presentation), format },
2083
+ { method, path: path4, request: negotiated(base, format, options?.presentation), format },
2083
2084
  options
2084
2085
  );
2085
2086
  }
@@ -3080,15 +3081,15 @@ var Payments = class {
3080
3081
  * ```
3081
3082
  */
3082
3083
  async retrieve(paymentId, options) {
3083
- const path3 = `/payments/${encodeURIComponent(paymentId)}`;
3084
- if (options === void 0) return this.request("GET", path3);
3084
+ const path4 = `/payments/${encodeURIComponent(paymentId)}`;
3085
+ if (options === void 0) return this.request("GET", path4);
3085
3086
  const query = {};
3086
3087
  if (options.force_sync !== void 0) query["force_sync"] = options.force_sync;
3087
3088
  if (options.all_keys_required !== void 0) {
3088
3089
  query["all_keys_required"] = options.all_keys_required;
3089
3090
  }
3090
- if (Object.keys(query).length === 0) return this.request("GET", path3);
3091
- return this.request("GET", path3, { query });
3091
+ if (Object.keys(query).length === 0) return this.request("GET", path4);
3092
+ return this.request("GET", path4, { query });
3092
3093
  }
3093
3094
  /**
3094
3095
  * The payment's buyer risk evaluations, newest first (at most 50): each
@@ -3998,9 +3999,9 @@ var Projects = class {
3998
3999
  * @returns The project.
3999
4000
  */
4000
4001
  async retrieve(projectId, merchantId) {
4001
- const path3 = `/projects/${encodeURIComponent(projectId)}`;
4002
- if (merchantId === void 0) return this.request("GET", path3);
4003
- return this.request("GET", path3, { query: { merchant_id: merchantId } });
4002
+ const path4 = `/projects/${encodeURIComponent(projectId)}`;
4003
+ if (merchantId === void 0) return this.request("GET", path4);
4004
+ return this.request("GET", path4, { query: { merchant_id: merchantId } });
4004
4005
  }
4005
4006
  /**
4006
4007
  * Update a project's details, or move it with `parent_id` (omitted keeps the
@@ -4018,9 +4019,9 @@ var Projects = class {
4018
4019
  * @returns The updated project.
4019
4020
  */
4020
4021
  async update(projectId, params, merchantId, options) {
4021
- const path3 = `/projects/${encodeURIComponent(projectId)}`;
4022
- if (merchantId === void 0) return this.request("PUT", path3, { body: params, ...options });
4023
- return this.request("PUT", path3, {
4022
+ const path4 = `/projects/${encodeURIComponent(projectId)}`;
4023
+ if (merchantId === void 0) return this.request("PUT", path4, { body: params, ...options });
4024
+ return this.request("PUT", path4, {
4024
4025
  body: params,
4025
4026
  query: { merchant_id: merchantId },
4026
4027
  ...options
@@ -4037,9 +4038,9 @@ var Projects = class {
4037
4038
  * @returns The deleted project object.
4038
4039
  */
4039
4040
  async delete(projectId, merchantId) {
4040
- const path3 = `/projects/${encodeURIComponent(projectId)}`;
4041
- if (merchantId === void 0) return this.request("DELETE", path3);
4042
- return this.request("DELETE", path3, { query: { merchant_id: merchantId } });
4041
+ const path4 = `/projects/${encodeURIComponent(projectId)}`;
4042
+ if (merchantId === void 0) return this.request("DELETE", path4);
4043
+ return this.request("DELETE", path4, { query: { merchant_id: merchantId } });
4043
4044
  }
4044
4045
  /**
4045
4046
  * List all projects for a merchant, at every level, as a flat array. Rebuild
@@ -5044,9 +5045,9 @@ var Shops = class {
5044
5045
  * ```
5045
5046
  */
5046
5047
  async stats(merchantId, shopId, period) {
5047
- const path3 = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
5048
- if (period === void 0) return this.request("GET", path3);
5049
- return this.request("GET", path3, { query: { period: String(period) } });
5048
+ const path4 = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
5049
+ if (period === void 0) return this.request("GET", path4);
5050
+ return this.request("GET", path4, { query: { period: String(period) } });
5050
5051
  }
5051
5052
  /**
5052
5053
  * Upload a logo file for a shop. The file is stored in Delopay's configured
@@ -10862,8 +10863,8 @@ var LiveEventStream = class {
10862
10863
  return toLiveStreamEvent(dispatch.event, this._lastEventId, this._retry);
10863
10864
  }
10864
10865
  };
10865
- async function openLiveStream(openStream, path3, options = {}) {
10866
- const connection = await openStream(path3, {
10866
+ async function openLiveStream(openStream, path4, options = {}) {
10867
+ const connection = await openStream(path4, {
10867
10868
  ...options.lastEventId ? { lastEventId: options.lastEventId } : {},
10868
10869
  ...options.signal ? { signal: options.signal } : {},
10869
10870
  ...options.idleTimeoutMs !== void 0 ? { idleTimeoutMs: options.idleTimeoutMs } : {},
@@ -11050,8 +11051,8 @@ var ProcessorImports = class {
11050
11051
 
11051
11052
  // src/resources/deploymentBranding.ts
11052
11053
  function brandingAssetPath(asset, version) {
11053
- const path3 = `/branding/assets/${encodeURIComponent(asset)}`;
11054
- return version ? `${path3}?v=${encodeURIComponent(version)}` : path3;
11054
+ const path4 = `/branding/assets/${encodeURIComponent(asset)}`;
11055
+ return version ? `${path4}?v=${encodeURIComponent(version)}` : path4;
11055
11056
  }
11056
11057
  var Branding = class {
11057
11058
  constructor(request, baseUrl) {
@@ -11446,8 +11447,8 @@ var Delopay = class {
11446
11447
  return response;
11447
11448
  }
11448
11449
  /** `path` on the base URL, with the query string `query` makes. */
11449
- buildUrl(path3, query) {
11450
- let url = `${this.baseUrl}${path3}`;
11450
+ buildUrl(path4, query) {
11451
+ let url = `${this.baseUrl}${path4}`;
11451
11452
  if (query) {
11452
11453
  const params = new URLSearchParams();
11453
11454
  for (const [key, value] of Object.entries(query)) {
@@ -11517,8 +11518,8 @@ var Delopay = class {
11517
11518
  * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and
11518
11519
  * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.
11519
11520
  */
11520
- async openEventStream(path3, options = {}) {
11521
- const url = this.buildUrl(path3, options.query);
11521
+ async openEventStream(path4, options = {}) {
11522
+ const url = this.buildUrl(path4, options.query);
11522
11523
  const lastEventId = options.lastEventId ?? "";
11523
11524
  const headers = {
11524
11525
  ...this.authHeaders(),
@@ -11558,7 +11559,7 @@ var Delopay = class {
11558
11559
  `Network error: ${cause instanceof Error ? cause.message : String(cause ?? "stream failed")}`,
11559
11560
  { status: 0, code: "NETWORK", type: "network_error" }
11560
11561
  );
11561
- this.log("request", { method: "GET", url: redactUrlForLogging(url), path: path3 });
11562
+ this.log("request", { method: "GET", url: redactUrlForLogging(url), path: path4 });
11562
11563
  startIdleTimer();
11563
11564
  let response;
11564
11565
  try {
@@ -11570,7 +11571,7 @@ var Delopay = class {
11570
11571
  throw network(err);
11571
11572
  }
11572
11573
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11573
- this.log("response", { status: response.status, method: "GET", path: path3, requestId });
11574
+ this.log("response", { status: response.status, method: "GET", path: path4, requestId });
11574
11575
  if (!response.ok) {
11575
11576
  const error = await errorFromResponse(response, requestId);
11576
11577
  release();
@@ -11656,8 +11657,8 @@ var Delopay = class {
11656
11657
  * @throws {DelopayAuthenticationError} On 401 responses.
11657
11658
  * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.
11658
11659
  */
11659
- async request(method, path3, options) {
11660
- const url = this.buildUrl(path3, options?.query);
11660
+ async request(method, path4, options) {
11661
+ const url = this.buildUrl(path4, options?.query);
11661
11662
  let headers = {
11662
11663
  ...this.authHeaders(),
11663
11664
  ...this.profileHeaders(options?.headers),
@@ -11721,7 +11722,7 @@ var Delopay = class {
11721
11722
  const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);
11722
11723
  retryAfterOverrideMs = null;
11723
11724
  await new Promise((resolve) => setTimeout(resolve, delay));
11724
- emit("retry", { attempt, maxRetries: this.maxRetries, method, path: path3 });
11725
+ emit("retry", { attempt, maxRetries: this.maxRetries, method, path: path4 });
11725
11726
  }
11726
11727
  const timeoutCtrl = new AbortController();
11727
11728
  let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);
@@ -11734,7 +11735,7 @@ var Delopay = class {
11734
11735
  callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal]
11735
11736
  );
11736
11737
  try {
11737
- emit("request", { method, url: safeUrl(), path: path3 });
11738
+ emit("request", { method, url: safeUrl(), path: path4 });
11738
11739
  const response = await fetch(url, {
11739
11740
  method,
11740
11741
  headers,
@@ -11743,7 +11744,7 @@ var Delopay = class {
11743
11744
  ...options?.keepalive !== void 0 ? { keepalive: options.keepalive } : {}
11744
11745
  });
11745
11746
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11746
- emit("response", { status: response.status, method, path: path3, requestId });
11747
+ emit("response", { status: response.status, method, path: path4, requestId });
11747
11748
  if (!response.ok) {
11748
11749
  const error = await errorFromResponse(response, requestId);
11749
11750
  const isTransientStatus = response.status >= 500 || response.status === 429;
@@ -17075,7 +17076,7 @@ function encodePanes(panes) {
17075
17076
  var OPAQUE_PAYMENT_LINK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
17076
17077
  function focusedCheckoutUrl(params) {
17077
17078
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
17078
- const path3 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
17079
+ const path4 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
17079
17080
  params.paymentId
17080
17081
  )}`;
17081
17082
  const query = new URLSearchParams({ pane: params.method });
@@ -17085,16 +17086,16 @@ function focusedCheckoutUrl(params) {
17085
17086
  if (merchantConnectorId) query.set("mca", merchantConnectorId);
17086
17087
  if (params.locale) query.set("locale", params.locale);
17087
17088
  if (params.customFieldsCollected) query.set("cf", "1");
17088
- return `${path3}?${query.toString()}`;
17089
+ return `${path4}?${query.toString()}`;
17089
17090
  }
17090
17091
  function checkoutEntryUrl(params) {
17091
17092
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
17092
- const path3 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
17093
+ const path4 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
17093
17094
  params.paymentId
17094
17095
  )}`;
17095
17096
  const query = new URLSearchParams({ entry: params.entry.trim() });
17096
17097
  if (params.locale) query.set("locale", params.locale);
17097
- return `${path3}?${query.toString()}`;
17098
+ return `${path4}?${query.toString()}`;
17098
17099
  }
17099
17100
  function isCheckoutOpenEntryMessage(data) {
17100
17101
  if (typeof data !== "object" || data === null) return false;
@@ -17195,6 +17196,60 @@ var AdminBranding = class {
17195
17196
  }
17196
17197
  };
17197
17198
 
17199
+ // src/internal/resources/adminIndustries.ts
17200
+ var path2 = (id) => `/admin-portal/industries/${encodeURIComponent(id)}`;
17201
+ var AdminIndustries = class {
17202
+ constructor(request) {
17203
+ this.request = request;
17204
+ }
17205
+ /** The whole catalog, archived entries included. `GET /admin-portal/industries` */
17206
+ async list() {
17207
+ return this.request("GET", "/admin-portal/industries");
17208
+ }
17209
+ /**
17210
+ * Create an industry, or a sub-industry under `parent_id`. Without
17211
+ * `availability` it can be selected nowhere until availability is set.
17212
+ * `POST /admin-portal/industries`
17213
+ */
17214
+ async create(body) {
17215
+ return this.request("POST", "/admin-portal/industries", { body });
17216
+ }
17217
+ /** Rename an entry; its id stays. `PATCH /admin-portal/industries/{industry_id}` */
17218
+ async rename(industryId, body) {
17219
+ return this.request("PATCH", path2(industryId), { body });
17220
+ }
17221
+ /**
17222
+ * Stop offering an entry, and for an industry its sub-industries, for new
17223
+ * selections. Existing selections keep it. `POST /admin-portal/industries/{industry_id}/archive`
17224
+ */
17225
+ async archive(industryId) {
17226
+ return this.request("POST", `${path2(industryId)}/archive`);
17227
+ }
17228
+ /**
17229
+ * Offer an archived entry again. Refused while an active sibling holds its
17230
+ * name, or for a sub-industry while its industry is archived.
17231
+ * `POST /admin-portal/industries/{industry_id}/restore`
17232
+ */
17233
+ async restore(industryId) {
17234
+ return this.request("POST", `${path2(industryId)}/restore`);
17235
+ }
17236
+ /**
17237
+ * Replace where an entry can be selected.
17238
+ * `PUT /admin-portal/industries/{industry_id}/availability`
17239
+ */
17240
+ async setAvailability(industryId, body) {
17241
+ return this.request("PUT", `${path2(industryId)}/availability`, { body });
17242
+ }
17243
+ /**
17244
+ * Every entry as seen from one merchant, or one of its projects or shops:
17245
+ * whether it can be selected there, why, and which scope grants it.
17246
+ * `GET /admin-portal/industries/preview`
17247
+ */
17248
+ async preview(query) {
17249
+ return this.request("GET", "/admin-portal/industries/preview", { query: { ...query } });
17250
+ }
17251
+ };
17252
+
17198
17253
  // src/internal/resources/adminLive.ts
17199
17254
  var AdminLive = class {
17200
17255
  constructor(request, openStream) {
@@ -18576,7 +18631,7 @@ function adminAccount(merchantId) {
18576
18631
  }
18577
18632
 
18578
18633
  // src/internal/resources/adminSupport.ts
18579
- var path2 = (id) => `/admin-portal/support/conversations/${encodeURIComponent(id)}`;
18634
+ var path3 = (id) => `/admin-portal/support/conversations/${encodeURIComponent(id)}`;
18580
18635
  var AdminSupport = class {
18581
18636
  constructor(request) {
18582
18637
  this.request = request;
@@ -18589,21 +18644,21 @@ var AdminSupport = class {
18589
18644
  }
18590
18645
  /** One conversation. `GET /admin-portal/support/conversations/{id}` */
18591
18646
  async retrieve(id) {
18592
- return this.request("GET", path2(id));
18647
+ return this.request("GET", path3(id));
18593
18648
  }
18594
18649
  /** Change status, kind, category or assignee. `PATCH /admin-portal/support/conversations/{id}` */
18595
18650
  async update(id, body) {
18596
- return this.request("PATCH", path2(id), { body });
18651
+ return this.request("PATCH", path3(id), { body });
18597
18652
  }
18598
18653
  /** Messages, notes included. `GET /admin-portal/support/conversations/{id}/messages` */
18599
18654
  async messages(id, query) {
18600
- return this.request("GET", `${path2(id)}/messages`, {
18655
+ return this.request("GET", `${path3(id)}/messages`, {
18601
18656
  query: query === void 0 ? void 0 : { ...query }
18602
18657
  });
18603
18658
  }
18604
18659
  /** Answer, or leave a note. `POST /admin-portal/support/conversations/{id}/messages` */
18605
18660
  async reply(id, body) {
18606
- return this.request("POST", `${path2(id)}/messages`, { body });
18661
+ return this.request("POST", `${path3(id)}/messages`, { body });
18607
18662
  }
18608
18663
  /**
18609
18664
  * Upload a file for a message from staff, scanned like a merchant's.
@@ -18614,14 +18669,14 @@ var AdminSupport = class {
18614
18669
  form.append("client_upload_id", clientUploadId);
18615
18670
  if (fileName === void 0) form.append("file", file);
18616
18671
  else form.append("file", file, fileName);
18617
- return this.request("POST", `${path2(id)}/attachments`, { body: form });
18672
+ return this.request("POST", `${path3(id)}/attachments`, { body: form });
18618
18673
  }
18619
18674
  /**
18620
18675
  * Fetch a file once its scan is clean. A blocked file stays shut for staff too.
18621
18676
  * `GET /admin-portal/support/conversations/{id}/attachments/{fileId}`
18622
18677
  */
18623
18678
  async downloadAttachment(id, fileId) {
18624
- return this.request("GET", `${path2(id)}/attachments/${encodeURIComponent(fileId)}`, {
18679
+ return this.request("GET", `${path3(id)}/attachments/${encodeURIComponent(fileId)}`, {
18625
18680
  responseType: "blob"
18626
18681
  });
18627
18682
  }
@@ -18630,7 +18685,7 @@ var AdminSupport = class {
18630
18685
  * `POST /admin-portal/support/conversations/{id}/read`
18631
18686
  */
18632
18687
  async markRead(id) {
18633
- return this.request("POST", `${path2(id)}/read`);
18688
+ return this.request("POST", `${path3(id)}/read`);
18634
18689
  }
18635
18690
  };
18636
18691
 
@@ -19414,6 +19469,7 @@ var DelopayInternal = class extends Delopay {
19414
19469
  this.admin = new Admin(request);
19415
19470
  this.adminPortal = new AdminPortal(request);
19416
19471
  this.adminSupport = new AdminSupport(request);
19472
+ this.adminIndustries = new AdminIndustries(request);
19417
19473
  const openStream = this.openEventStream.bind(this);
19418
19474
  this.adminLive = new AdminLive(request, openStream);
19419
19475
  this.adminBranding = new AdminBranding(request);
@@ -19451,6 +19507,7 @@ var DelopayInternal = class extends Delopay {
19451
19507
  APPLE_PAY_BUTTON_TYPES,
19452
19508
  Admin,
19453
19509
  AdminBranding,
19510
+ AdminIndustries,
19454
19511
  AdminLive,
19455
19512
  AdminPortal,
19456
19513
  AdminSupport,