@delopay/sdk 0.365.0 → 0.368.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/index.cjs CHANGED
@@ -168,6 +168,7 @@ __export(index_exports, {
168
168
  Settlement: () => Settlement,
169
169
  ShopLabels: () => ShopLabels,
170
170
  Subscriptions: () => Subscriptions,
171
+ Support: () => Support,
171
172
  UNKNOWN_SECTION_ORDER: () => UNKNOWN_SECTION_ORDER,
172
173
  WCAG_AA_TEXT: () => WCAG_AA_TEXT,
173
174
  WCAG_AA_UI: () => WCAG_AA_UI,
@@ -1255,9 +1256,9 @@ var Connectors = class {
1255
1256
  * to a single event.
1256
1257
  */
1257
1258
  async registerWebhook(merchantId, connectorId, params) {
1258
- const path = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;
1259
- if (params === void 0) return this.request("POST", path);
1260
- return this.request("POST", path, { body: params });
1259
+ const path2 = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;
1260
+ if (params === void 0) return this.request("POST", path2);
1261
+ return this.request("POST", path2, { body: params });
1261
1262
  }
1262
1263
  /**
1263
1264
  * Register checkout/shop domains as Stripe payment method domains, so Apple
@@ -2055,11 +2056,11 @@ function negotiated(options, format, presentation) {
2055
2056
  }
2056
2057
  return format === "json" ? { ...options, headers } : { ...options, headers, responseType: "blob" };
2057
2058
  }
2058
- function runExport(request, method, path, base, options) {
2059
+ function runExport(request, method, path2, base, options) {
2059
2060
  const format = options?.format ?? "json";
2060
2061
  return downloadExport(
2061
2062
  request,
2062
- { method, path, request: negotiated(base, format, options?.presentation), format },
2063
+ { method, path: path2, request: negotiated(base, format, options?.presentation), format },
2063
2064
  options
2064
2065
  );
2065
2066
  }
@@ -2320,6 +2321,34 @@ var ChargebackPrevention = class {
2320
2321
  async retrieveCase(caseId) {
2321
2322
  return this.request("GET", `/chargeback-prevention/cases/${encodeURIComponent(caseId)}`);
2322
2323
  }
2324
+ /**
2325
+ * The refund rule of every connected account and environment; version `0`
2326
+ * and off for one never saved. Needs a merchant-wide key or sign-in.
2327
+ */
2328
+ async listRefundRules() {
2329
+ return this.request("GET", "/chargeback-prevention/refund-rules");
2330
+ }
2331
+ /**
2332
+ * Save a refund rule over the version read. Dashboard sign-in only, by a
2333
+ * merchant-wide user who may write refunds; an API key is refused. A rule
2334
+ * saved since the version named is not overwritten: the call fails.
2335
+ */
2336
+ async saveRefundRule(body) {
2337
+ return this.request("PUT", "/chargeback-prevention/refund-rules", { body });
2338
+ }
2339
+ /**
2340
+ * What the stored rule, or unsaved `settings`, would do with each open
2341
+ * alert of the account now. Nothing is refunded.
2342
+ */
2343
+ async previewRefundRule(body) {
2344
+ return this.request("POST", "/chargeback-prevention/refund-rules/preview", { body });
2345
+ }
2346
+ /** What the merchant's refund rules did, newest first. */
2347
+ async listRefundActions(params) {
2348
+ return this.request("GET", "/chargeback-prevention/refund-actions", {
2349
+ query: params
2350
+ });
2351
+ }
2323
2352
  };
2324
2353
 
2325
2354
  // src/resources/paypalDisputes.ts
@@ -3032,15 +3061,15 @@ var Payments = class {
3032
3061
  * ```
3033
3062
  */
3034
3063
  async retrieve(paymentId, options) {
3035
- const path = `/payments/${encodeURIComponent(paymentId)}`;
3036
- if (options === void 0) return this.request("GET", path);
3064
+ const path2 = `/payments/${encodeURIComponent(paymentId)}`;
3065
+ if (options === void 0) return this.request("GET", path2);
3037
3066
  const query = {};
3038
3067
  if (options.force_sync !== void 0) query["force_sync"] = options.force_sync;
3039
3068
  if (options.all_keys_required !== void 0) {
3040
3069
  query["all_keys_required"] = options.all_keys_required;
3041
3070
  }
3042
- if (Object.keys(query).length === 0) return this.request("GET", path);
3043
- return this.request("GET", path, { query });
3071
+ if (Object.keys(query).length === 0) return this.request("GET", path2);
3072
+ return this.request("GET", path2, { query });
3044
3073
  }
3045
3074
  /**
3046
3075
  * The payment's buyer risk evaluations, newest first (at most 50): each
@@ -3395,6 +3424,36 @@ var Payments = class {
3395
3424
  options
3396
3425
  );
3397
3426
  }
3427
+ /**
3428
+ * The statement name and suffix each attempt of a payment asked for and was
3429
+ * sent to its provider with. A name the merchant, the shop or the connector
3430
+ * account configures replaces the payment's own: `name_ignored` /
3431
+ * `suffix_ignored` say the payment's value was not used, and a `null` sent
3432
+ * value leaves the provider account's own default.
3433
+ *
3434
+ * Only attempts with a record are listed: one that carried no name and was
3435
+ * sent none, or ran before the record existed, is absent.
3436
+ *
3437
+ * `GET /payments/{paymentId}/statement-descriptors`
3438
+ *
3439
+ * @param paymentId - The payment intent ID.
3440
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
3441
+ * override, and an `AbortSignal`.
3442
+ *
3443
+ * @example
3444
+ * ```typescript
3445
+ * const { attempts } = await delopay.payments.statementDescriptors('pay_abc123');
3446
+ * const last = attempts.at(-1);
3447
+ * if (last?.name_ignored) console.log(`Sent as ${last.sent_name}`);
3448
+ * ```
3449
+ */
3450
+ async statementDescriptors(paymentId, options) {
3451
+ return this.request(
3452
+ "GET",
3453
+ `/payments/${encodeURIComponent(paymentId)}/statement-descriptors`,
3454
+ options
3455
+ );
3456
+ }
3398
3457
  /**
3399
3458
  * Open a playback of the payment's stored checkout recording: the audited
3400
3459
  * act of watching. Answers the manifest — which slices exist, how long the
@@ -3920,9 +3979,9 @@ var Projects = class {
3920
3979
  * @returns The project.
3921
3980
  */
3922
3981
  async retrieve(projectId, merchantId) {
3923
- const path = `/projects/${encodeURIComponent(projectId)}`;
3924
- if (merchantId === void 0) return this.request("GET", path);
3925
- return this.request("GET", path, { query: { merchant_id: merchantId } });
3982
+ const path2 = `/projects/${encodeURIComponent(projectId)}`;
3983
+ if (merchantId === void 0) return this.request("GET", path2);
3984
+ return this.request("GET", path2, { query: { merchant_id: merchantId } });
3926
3985
  }
3927
3986
  /**
3928
3987
  * Update a project's details, or move it with `parent_id` (omitted keeps the
@@ -3940,9 +3999,9 @@ var Projects = class {
3940
3999
  * @returns The updated project.
3941
4000
  */
3942
4001
  async update(projectId, params, merchantId, options) {
3943
- const path = `/projects/${encodeURIComponent(projectId)}`;
3944
- if (merchantId === void 0) return this.request("PUT", path, { body: params, ...options });
3945
- return this.request("PUT", path, {
4002
+ const path2 = `/projects/${encodeURIComponent(projectId)}`;
4003
+ if (merchantId === void 0) return this.request("PUT", path2, { body: params, ...options });
4004
+ return this.request("PUT", path2, {
3946
4005
  body: params,
3947
4006
  query: { merchant_id: merchantId },
3948
4007
  ...options
@@ -3959,9 +4018,9 @@ var Projects = class {
3959
4018
  * @returns The deleted project object.
3960
4019
  */
3961
4020
  async delete(projectId, merchantId) {
3962
- const path = `/projects/${encodeURIComponent(projectId)}`;
3963
- if (merchantId === void 0) return this.request("DELETE", path);
3964
- return this.request("DELETE", path, { query: { merchant_id: merchantId } });
4021
+ const path2 = `/projects/${encodeURIComponent(projectId)}`;
4022
+ if (merchantId === void 0) return this.request("DELETE", path2);
4023
+ return this.request("DELETE", path2, { query: { merchant_id: merchantId } });
3965
4024
  }
3966
4025
  /**
3967
4026
  * List all projects for a merchant, at every level, as a flat array. Rebuild
@@ -4966,9 +5025,9 @@ var Shops = class {
4966
5025
  * ```
4967
5026
  */
4968
5027
  async stats(merchantId, shopId, period) {
4969
- const path = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
4970
- if (period === void 0) return this.request("GET", path);
4971
- return this.request("GET", path, { query: { period: String(period) } });
5028
+ const path2 = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
5029
+ if (period === void 0) return this.request("GET", path2);
5030
+ return this.request("GET", path2, { query: { period: String(period) } });
4972
5031
  }
4973
5032
  /**
4974
5033
  * Upload a logo file for a shop. The file is stored in Delopay's configured
@@ -8253,6 +8312,69 @@ var Products = class {
8253
8312
  }
8254
8313
  };
8255
8314
 
8315
+ // src/resources/support.ts
8316
+ var path = (id) => `/support/conversations/${encodeURIComponent(id)}`;
8317
+ var Support = class {
8318
+ constructor(request) {
8319
+ this.request = request;
8320
+ }
8321
+ /** Start a conversation with its first message. `POST /support/conversations` */
8322
+ async create(body) {
8323
+ return this.request("POST", "/support/conversations", { body });
8324
+ }
8325
+ /** The conversations the caller may read. `GET /support/conversations` */
8326
+ async list(query) {
8327
+ return this.request("GET", "/support/conversations", {
8328
+ query: query === void 0 ? void 0 : { ...query }
8329
+ });
8330
+ }
8331
+ /** One conversation. `GET /support/conversations/{id}` */
8332
+ async retrieve(id) {
8333
+ return this.request("GET", path(id));
8334
+ }
8335
+ /** A conversation's messages. `GET /support/conversations/{id}/messages` */
8336
+ async messages(id, query) {
8337
+ return this.request("GET", `${path(id)}/messages`, {
8338
+ query: query === void 0 ? void 0 : { ...query }
8339
+ });
8340
+ }
8341
+ /** Answer in a conversation. `POST /support/conversations/{id}/messages` */
8342
+ async reply(id, body) {
8343
+ return this.request("POST", `${path(id)}/messages`, { body });
8344
+ }
8345
+ /**
8346
+ * Upload a file for a message. PNG, JPEG, WebP, PDF, text, MP4 or WebM, read from the
8347
+ * content; 10 MB, a video 25 MB. It belongs to the caller until a message names it in
8348
+ * `attachments`. Uploading again with the same `clientUploadId` returns the same file.
8349
+ * `POST /support/conversations/{id}/attachments`
8350
+ */
8351
+ async uploadAttachment(id, file, clientUploadId, fileName) {
8352
+ const form = new FormData();
8353
+ form.append("client_upload_id", clientUploadId);
8354
+ if (fileName === void 0) form.append("file", file);
8355
+ else form.append("file", file, fileName);
8356
+ return this.request("POST", `${path(id)}/attachments`, { body: form });
8357
+ }
8358
+ /**
8359
+ * Fetch a file once its scan is clean. Refused with `support_attachment_checking` while
8360
+ * the scan runs, and `support_attachment_blocked` after a block.
8361
+ * `GET /support/conversations/{id}/attachments/{fileId}`
8362
+ */
8363
+ async downloadAttachment(id, fileId) {
8364
+ return this.request("GET", `${path(id)}/attachments/${encodeURIComponent(fileId)}`, {
8365
+ responseType: "blob"
8366
+ });
8367
+ }
8368
+ /**
8369
+ * Clear the merchant's unread mark and read the conversation as it is now.
8370
+ * Someone acting as somebody else leaves the mark in place.
8371
+ * `POST /support/conversations/{id}/read`
8372
+ */
8373
+ async markRead(id) {
8374
+ return this.request("POST", `${path(id)}/read`);
8375
+ }
8376
+ };
8377
+
8256
8378
  // src/resources/invoices.ts
8257
8379
  var Invoices = class {
8258
8380
  constructor(request) {
@@ -10721,8 +10843,8 @@ var LiveEventStream = class {
10721
10843
  return toLiveStreamEvent(dispatch.event, this._lastEventId, this._retry);
10722
10844
  }
10723
10845
  };
10724
- async function openLiveStream(openStream, path, options = {}) {
10725
- const connection = await openStream(path, {
10846
+ async function openLiveStream(openStream, path2, options = {}) {
10847
+ const connection = await openStream(path2, {
10726
10848
  ...options.lastEventId ? { lastEventId: options.lastEventId } : {},
10727
10849
  ...options.signal ? { signal: options.signal } : {},
10728
10850
  ...options.idleTimeoutMs !== void 0 ? { idleTimeoutMs: options.idleTimeoutMs } : {},
@@ -10909,8 +11031,8 @@ var ProcessorImports = class {
10909
11031
 
10910
11032
  // src/resources/deploymentBranding.ts
10911
11033
  function brandingAssetPath(asset, version) {
10912
- const path = `/branding/assets/${encodeURIComponent(asset)}`;
10913
- return version ? `${path}?v=${encodeURIComponent(version)}` : path;
11034
+ const path2 = `/branding/assets/${encodeURIComponent(asset)}`;
11035
+ return version ? `${path2}?v=${encodeURIComponent(version)}` : path2;
10914
11036
  }
10915
11037
  var Branding = class {
10916
11038
  constructor(request, baseUrl) {
@@ -11244,6 +11366,7 @@ var Delopay = class {
11244
11366
  this.costRules = new CostRules(request);
11245
11367
  this.externalRecords = new ExternalRecords(request);
11246
11368
  this.products = new Products(request);
11369
+ this.support = new Support(request);
11247
11370
  this.invoices = new Invoices(request);
11248
11371
  this.invoiceSettings = new InvoiceSettingsResource(request);
11249
11372
  this.processorCosts = new ProcessorCosts(request);
@@ -11304,8 +11427,8 @@ var Delopay = class {
11304
11427
  return response;
11305
11428
  }
11306
11429
  /** `path` on the base URL, with the query string `query` makes. */
11307
- buildUrl(path, query) {
11308
- let url = `${this.baseUrl}${path}`;
11430
+ buildUrl(path2, query) {
11431
+ let url = `${this.baseUrl}${path2}`;
11309
11432
  if (query) {
11310
11433
  const params = new URLSearchParams();
11311
11434
  for (const [key, value] of Object.entries(query)) {
@@ -11375,8 +11498,8 @@ var Delopay = class {
11375
11498
  * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and
11376
11499
  * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.
11377
11500
  */
11378
- async openEventStream(path, options = {}) {
11379
- const url = this.buildUrl(path, options.query);
11501
+ async openEventStream(path2, options = {}) {
11502
+ const url = this.buildUrl(path2, options.query);
11380
11503
  const lastEventId = options.lastEventId ?? "";
11381
11504
  const headers = {
11382
11505
  ...this.authHeaders(),
@@ -11416,7 +11539,7 @@ var Delopay = class {
11416
11539
  `Network error: ${cause instanceof Error ? cause.message : String(cause ?? "stream failed")}`,
11417
11540
  { status: 0, code: "NETWORK", type: "network_error" }
11418
11541
  );
11419
- this.log("request", { method: "GET", url: redactUrlForLogging(url), path });
11542
+ this.log("request", { method: "GET", url: redactUrlForLogging(url), path: path2 });
11420
11543
  startIdleTimer();
11421
11544
  let response;
11422
11545
  try {
@@ -11428,7 +11551,7 @@ var Delopay = class {
11428
11551
  throw network(err);
11429
11552
  }
11430
11553
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11431
- this.log("response", { status: response.status, method: "GET", path, requestId });
11554
+ this.log("response", { status: response.status, method: "GET", path: path2, requestId });
11432
11555
  if (!response.ok) {
11433
11556
  const error = await errorFromResponse(response, requestId);
11434
11557
  release();
@@ -11514,8 +11637,8 @@ var Delopay = class {
11514
11637
  * @throws {DelopayAuthenticationError} On 401 responses.
11515
11638
  * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.
11516
11639
  */
11517
- async request(method, path, options) {
11518
- const url = this.buildUrl(path, options?.query);
11640
+ async request(method, path2, options) {
11641
+ const url = this.buildUrl(path2, options?.query);
11519
11642
  let headers = {
11520
11643
  ...this.authHeaders(),
11521
11644
  ...this.profileHeaders(options?.headers),
@@ -11579,7 +11702,7 @@ var Delopay = class {
11579
11702
  const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);
11580
11703
  retryAfterOverrideMs = null;
11581
11704
  await new Promise((resolve) => setTimeout(resolve, delay));
11582
- emit("retry", { attempt, maxRetries: this.maxRetries, method, path });
11705
+ emit("retry", { attempt, maxRetries: this.maxRetries, method, path: path2 });
11583
11706
  }
11584
11707
  const timeoutCtrl = new AbortController();
11585
11708
  let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);
@@ -11592,7 +11715,7 @@ var Delopay = class {
11592
11715
  callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal]
11593
11716
  );
11594
11717
  try {
11595
- emit("request", { method, url: safeUrl(), path });
11718
+ emit("request", { method, url: safeUrl(), path: path2 });
11596
11719
  const response = await fetch(url, {
11597
11720
  method,
11598
11721
  headers,
@@ -11601,7 +11724,7 @@ var Delopay = class {
11601
11724
  ...options?.keepalive !== void 0 ? { keepalive: options.keepalive } : {}
11602
11725
  });
11603
11726
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11604
- emit("response", { status: response.status, method, path, requestId });
11727
+ emit("response", { status: response.status, method, path: path2, requestId });
11605
11728
  if (!response.ok) {
11606
11729
  const error = await errorFromResponse(response, requestId);
11607
11730
  const isTransientStatus = response.status >= 500 || response.status === 429;
@@ -16933,7 +17056,7 @@ function encodePanes(panes) {
16933
17056
  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}$/;
16934
17057
  function focusedCheckoutUrl(params) {
16935
17058
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
16936
- const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
17059
+ const path2 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
16937
17060
  params.paymentId
16938
17061
  )}`;
16939
17062
  const query = new URLSearchParams({ pane: params.method });
@@ -16943,16 +17066,16 @@ function focusedCheckoutUrl(params) {
16943
17066
  if (merchantConnectorId) query.set("mca", merchantConnectorId);
16944
17067
  if (params.locale) query.set("locale", params.locale);
16945
17068
  if (params.customFieldsCollected) query.set("cf", "1");
16946
- return `${path}?${query.toString()}`;
17069
+ return `${path2}?${query.toString()}`;
16947
17070
  }
16948
17071
  function checkoutEntryUrl(params) {
16949
17072
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
16950
- const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
17073
+ const path2 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
16951
17074
  params.paymentId
16952
17075
  )}`;
16953
17076
  const query = new URLSearchParams({ entry: params.entry.trim() });
16954
17077
  if (params.locale) query.set("locale", params.locale);
16955
- return `${path}?${query.toString()}`;
17078
+ return `${path2}?${query.toString()}`;
16956
17079
  }
16957
17080
  function isCheckoutOpenEntryMessage(data) {
16958
17081
  if (typeof data !== "object" || data === null) return false;
@@ -17135,6 +17258,7 @@ var encodeNativePanes = encodePanes;
17135
17258
  Settlement,
17136
17259
  ShopLabels,
17137
17260
  Subscriptions,
17261
+ Support,
17138
17262
  UNKNOWN_SECTION_ORDER,
17139
17263
  WCAG_AA_TEXT,
17140
17264
  WCAG_AA_UI,