@delopay/sdk 0.366.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/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
  }
@@ -3060,15 +3061,15 @@ var Payments = class {
3060
3061
  * ```
3061
3062
  */
3062
3063
  async retrieve(paymentId, options) {
3063
- const path = `/payments/${encodeURIComponent(paymentId)}`;
3064
- 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);
3065
3066
  const query = {};
3066
3067
  if (options.force_sync !== void 0) query["force_sync"] = options.force_sync;
3067
3068
  if (options.all_keys_required !== void 0) {
3068
3069
  query["all_keys_required"] = options.all_keys_required;
3069
3070
  }
3070
- if (Object.keys(query).length === 0) return this.request("GET", path);
3071
- 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 });
3072
3073
  }
3073
3074
  /**
3074
3075
  * The payment's buyer risk evaluations, newest first (at most 50): each
@@ -3423,6 +3424,36 @@ var Payments = class {
3423
3424
  options
3424
3425
  );
3425
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
+ }
3426
3457
  /**
3427
3458
  * Open a playback of the payment's stored checkout recording: the audited
3428
3459
  * act of watching. Answers the manifest — which slices exist, how long the
@@ -3948,9 +3979,9 @@ var Projects = class {
3948
3979
  * @returns The project.
3949
3980
  */
3950
3981
  async retrieve(projectId, merchantId) {
3951
- const path = `/projects/${encodeURIComponent(projectId)}`;
3952
- if (merchantId === void 0) return this.request("GET", path);
3953
- 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 } });
3954
3985
  }
3955
3986
  /**
3956
3987
  * Update a project's details, or move it with `parent_id` (omitted keeps the
@@ -3968,9 +3999,9 @@ var Projects = class {
3968
3999
  * @returns The updated project.
3969
4000
  */
3970
4001
  async update(projectId, params, merchantId, options) {
3971
- const path = `/projects/${encodeURIComponent(projectId)}`;
3972
- if (merchantId === void 0) return this.request("PUT", path, { body: params, ...options });
3973
- 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, {
3974
4005
  body: params,
3975
4006
  query: { merchant_id: merchantId },
3976
4007
  ...options
@@ -3987,9 +4018,9 @@ var Projects = class {
3987
4018
  * @returns The deleted project object.
3988
4019
  */
3989
4020
  async delete(projectId, merchantId) {
3990
- const path = `/projects/${encodeURIComponent(projectId)}`;
3991
- if (merchantId === void 0) return this.request("DELETE", path);
3992
- 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 } });
3993
4024
  }
3994
4025
  /**
3995
4026
  * List all projects for a merchant, at every level, as a flat array. Rebuild
@@ -4994,9 +5025,9 @@ var Shops = class {
4994
5025
  * ```
4995
5026
  */
4996
5027
  async stats(merchantId, shopId, period) {
4997
- const path = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
4998
- if (period === void 0) return this.request("GET", path);
4999
- 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) } });
5000
5031
  }
5001
5032
  /**
5002
5033
  * Upload a logo file for a shop. The file is stored in Delopay's configured
@@ -8281,6 +8312,69 @@ var Products = class {
8281
8312
  }
8282
8313
  };
8283
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
+
8284
8378
  // src/resources/invoices.ts
8285
8379
  var Invoices = class {
8286
8380
  constructor(request) {
@@ -10749,8 +10843,8 @@ var LiveEventStream = class {
10749
10843
  return toLiveStreamEvent(dispatch.event, this._lastEventId, this._retry);
10750
10844
  }
10751
10845
  };
10752
- async function openLiveStream(openStream, path, options = {}) {
10753
- const connection = await openStream(path, {
10846
+ async function openLiveStream(openStream, path2, options = {}) {
10847
+ const connection = await openStream(path2, {
10754
10848
  ...options.lastEventId ? { lastEventId: options.lastEventId } : {},
10755
10849
  ...options.signal ? { signal: options.signal } : {},
10756
10850
  ...options.idleTimeoutMs !== void 0 ? { idleTimeoutMs: options.idleTimeoutMs } : {},
@@ -10937,8 +11031,8 @@ var ProcessorImports = class {
10937
11031
 
10938
11032
  // src/resources/deploymentBranding.ts
10939
11033
  function brandingAssetPath(asset, version) {
10940
- const path = `/branding/assets/${encodeURIComponent(asset)}`;
10941
- return version ? `${path}?v=${encodeURIComponent(version)}` : path;
11034
+ const path2 = `/branding/assets/${encodeURIComponent(asset)}`;
11035
+ return version ? `${path2}?v=${encodeURIComponent(version)}` : path2;
10942
11036
  }
10943
11037
  var Branding = class {
10944
11038
  constructor(request, baseUrl) {
@@ -11272,6 +11366,7 @@ var Delopay = class {
11272
11366
  this.costRules = new CostRules(request);
11273
11367
  this.externalRecords = new ExternalRecords(request);
11274
11368
  this.products = new Products(request);
11369
+ this.support = new Support(request);
11275
11370
  this.invoices = new Invoices(request);
11276
11371
  this.invoiceSettings = new InvoiceSettingsResource(request);
11277
11372
  this.processorCosts = new ProcessorCosts(request);
@@ -11332,8 +11427,8 @@ var Delopay = class {
11332
11427
  return response;
11333
11428
  }
11334
11429
  /** `path` on the base URL, with the query string `query` makes. */
11335
- buildUrl(path, query) {
11336
- let url = `${this.baseUrl}${path}`;
11430
+ buildUrl(path2, query) {
11431
+ let url = `${this.baseUrl}${path2}`;
11337
11432
  if (query) {
11338
11433
  const params = new URLSearchParams();
11339
11434
  for (const [key, value] of Object.entries(query)) {
@@ -11403,8 +11498,8 @@ var Delopay = class {
11403
11498
  * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and
11404
11499
  * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.
11405
11500
  */
11406
- async openEventStream(path, options = {}) {
11407
- const url = this.buildUrl(path, options.query);
11501
+ async openEventStream(path2, options = {}) {
11502
+ const url = this.buildUrl(path2, options.query);
11408
11503
  const lastEventId = options.lastEventId ?? "";
11409
11504
  const headers = {
11410
11505
  ...this.authHeaders(),
@@ -11444,7 +11539,7 @@ var Delopay = class {
11444
11539
  `Network error: ${cause instanceof Error ? cause.message : String(cause ?? "stream failed")}`,
11445
11540
  { status: 0, code: "NETWORK", type: "network_error" }
11446
11541
  );
11447
- this.log("request", { method: "GET", url: redactUrlForLogging(url), path });
11542
+ this.log("request", { method: "GET", url: redactUrlForLogging(url), path: path2 });
11448
11543
  startIdleTimer();
11449
11544
  let response;
11450
11545
  try {
@@ -11456,7 +11551,7 @@ var Delopay = class {
11456
11551
  throw network(err);
11457
11552
  }
11458
11553
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11459
- this.log("response", { status: response.status, method: "GET", path, requestId });
11554
+ this.log("response", { status: response.status, method: "GET", path: path2, requestId });
11460
11555
  if (!response.ok) {
11461
11556
  const error = await errorFromResponse(response, requestId);
11462
11557
  release();
@@ -11542,8 +11637,8 @@ var Delopay = class {
11542
11637
  * @throws {DelopayAuthenticationError} On 401 responses.
11543
11638
  * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.
11544
11639
  */
11545
- async request(method, path, options) {
11546
- const url = this.buildUrl(path, options?.query);
11640
+ async request(method, path2, options) {
11641
+ const url = this.buildUrl(path2, options?.query);
11547
11642
  let headers = {
11548
11643
  ...this.authHeaders(),
11549
11644
  ...this.profileHeaders(options?.headers),
@@ -11607,7 +11702,7 @@ var Delopay = class {
11607
11702
  const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);
11608
11703
  retryAfterOverrideMs = null;
11609
11704
  await new Promise((resolve) => setTimeout(resolve, delay));
11610
- emit("retry", { attempt, maxRetries: this.maxRetries, method, path });
11705
+ emit("retry", { attempt, maxRetries: this.maxRetries, method, path: path2 });
11611
11706
  }
11612
11707
  const timeoutCtrl = new AbortController();
11613
11708
  let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);
@@ -11620,7 +11715,7 @@ var Delopay = class {
11620
11715
  callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal]
11621
11716
  );
11622
11717
  try {
11623
- emit("request", { method, url: safeUrl(), path });
11718
+ emit("request", { method, url: safeUrl(), path: path2 });
11624
11719
  const response = await fetch(url, {
11625
11720
  method,
11626
11721
  headers,
@@ -11629,7 +11724,7 @@ var Delopay = class {
11629
11724
  ...options?.keepalive !== void 0 ? { keepalive: options.keepalive } : {}
11630
11725
  });
11631
11726
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11632
- emit("response", { status: response.status, method, path, requestId });
11727
+ emit("response", { status: response.status, method, path: path2, requestId });
11633
11728
  if (!response.ok) {
11634
11729
  const error = await errorFromResponse(response, requestId);
11635
11730
  const isTransientStatus = response.status >= 500 || response.status === 429;
@@ -16961,7 +17056,7 @@ function encodePanes(panes) {
16961
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}$/;
16962
17057
  function focusedCheckoutUrl(params) {
16963
17058
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
16964
- 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(
16965
17060
  params.paymentId
16966
17061
  )}`;
16967
17062
  const query = new URLSearchParams({ pane: params.method });
@@ -16971,16 +17066,16 @@ function focusedCheckoutUrl(params) {
16971
17066
  if (merchantConnectorId) query.set("mca", merchantConnectorId);
16972
17067
  if (params.locale) query.set("locale", params.locale);
16973
17068
  if (params.customFieldsCollected) query.set("cf", "1");
16974
- return `${path}?${query.toString()}`;
17069
+ return `${path2}?${query.toString()}`;
16975
17070
  }
16976
17071
  function checkoutEntryUrl(params) {
16977
17072
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
16978
- 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(
16979
17074
  params.paymentId
16980
17075
  )}`;
16981
17076
  const query = new URLSearchParams({ entry: params.entry.trim() });
16982
17077
  if (params.locale) query.set("locale", params.locale);
16983
- return `${path}?${query.toString()}`;
17078
+ return `${path2}?${query.toString()}`;
16984
17079
  }
16985
17080
  function isCheckoutOpenEntryMessage(data) {
16986
17081
  if (typeof data !== "object" || data === null) return false;
@@ -17163,6 +17258,7 @@ var encodeNativePanes = encodePanes;
17163
17258
  Settlement,
17164
17259
  ShopLabels,
17165
17260
  Subscriptions,
17261
+ Support,
17166
17262
  UNKNOWN_SECTION_ORDER,
17167
17263
  WCAG_AA_TEXT,
17168
17264
  WCAG_AA_UI,