@delopay/sdk 0.289.0 → 0.290.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
@@ -132,7 +132,9 @@ __export(internal_exports, {
132
132
  PlatformSettings: () => PlatformSettings,
133
133
  PresentationCache: () => PresentationCache,
134
134
  ProcessorCosts: () => ProcessorCosts,
135
+ ProcessorImports: () => ProcessorImports,
135
136
  Products: () => Products,
137
+ PspImportEventStream: () => PspImportEventStream,
136
138
  RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
137
139
  Regions: () => Regions,
138
140
  Risk: () => Risk,
@@ -2020,6 +2022,44 @@ var Disputes = class {
2020
2022
  options
2021
2023
  );
2022
2024
  }
2025
+ /**
2026
+ * What a bulk action would do to the selected cases, changing nothing:
2027
+ * each case as eligible or skipped with a reason, and what the eligible ones
2028
+ * add up to per currency. Name the cases by `ids` or by the list's
2029
+ * `filters`, exactly one of the two; at most `max_cases` are read.
2030
+ *
2031
+ * `POST /disputes/workspace/bulk/preview`. Needs a dashboard JWT.
2032
+ */
2033
+ async bulkPreview(request) {
2034
+ const { filters, ...rest } = request;
2035
+ return this.request("POST", "/disputes/workspace/bulk/preview", {
2036
+ body: filters ? { ...rest, filters: workspaceQuery(filters) } : rest
2037
+ });
2038
+ }
2039
+ /**
2040
+ * Accept the listed cases at their processors, at most the preview's
2041
+ * `max_run_cases` per call; send a larger set in parts under one
2042
+ * `request_id`. Eligibility is decided again at run time, and every case
2043
+ * gets its own result. An `unknown` result means the processor may have
2044
+ * acted: read the case before acting on it again.
2045
+ *
2046
+ * `POST /disputes/workspace/bulk/accept`. Needs a dashboard JWT.
2047
+ */
2048
+ async bulkAccept(request) {
2049
+ return this.request("POST", "/disputes/workspace/bulk/accept", { body: request });
2050
+ }
2051
+ /**
2052
+ * Add the buyer of each listed case's payment to the buyer blocklist: the
2053
+ * payment's email and customer id, and the device ids and IP address of the
2054
+ * browser that paid, when DeloPay can tie them to it. Identifiers already
2055
+ * blocked are not added again, and `unattributed` names those it could not
2056
+ * tie to the buyer.
2057
+ *
2058
+ * `POST /disputes/workspace/bulk/block-buyer`. Needs a dashboard JWT.
2059
+ */
2060
+ async bulkBlockBuyer(request) {
2061
+ return this.request("POST", "/disputes/workspace/bulk/block-buyer", { body: request });
2062
+ }
2023
2063
  /**
2024
2064
  * Retrieve a dispute by its ID.
2025
2065
  *
@@ -9744,6 +9784,132 @@ var Live = class {
9744
9784
  }
9745
9785
  };
9746
9786
 
9787
+ // src/resources/processorImports.ts
9788
+ function toPspImportStreamEvent(event) {
9789
+ switch (event.type) {
9790
+ case "progress": {
9791
+ let run;
9792
+ try {
9793
+ run = JSON.parse(event.data);
9794
+ } catch {
9795
+ return null;
9796
+ }
9797
+ if (run === null || typeof run !== "object" || Array.isArray(run)) return null;
9798
+ return { type: "progress", run };
9799
+ }
9800
+ case "done":
9801
+ return { type: "done" };
9802
+ default:
9803
+ return null;
9804
+ }
9805
+ }
9806
+ var PspImportEventStream = class {
9807
+ constructor(connection) {
9808
+ this.connection = connection;
9809
+ }
9810
+ /** Close the stream; the iteration ends without an error. */
9811
+ close() {
9812
+ this.connection.close();
9813
+ }
9814
+ [Symbol.asyncIterator]() {
9815
+ this.iterator ?? (this.iterator = this.events());
9816
+ return this.iterator;
9817
+ }
9818
+ async *events() {
9819
+ for await (const dispatch of this.connection.dispatches) {
9820
+ if (!dispatch.event) continue;
9821
+ const event = toPspImportStreamEvent(dispatch.event);
9822
+ if (event) yield event;
9823
+ }
9824
+ }
9825
+ };
9826
+ var ProcessorImports = class {
9827
+ constructor(request, openStream) {
9828
+ this.request = request;
9829
+ this.openStream = openStream;
9830
+ }
9831
+ /**
9832
+ * Every connected processor account the caller may see, with what each can
9833
+ * provide in the environment: listed, read payment by payment, or
9834
+ * unavailable with a reason.
9835
+ *
9836
+ * `GET /refunds-disputes/imports/sources`
9837
+ */
9838
+ async sources(params) {
9839
+ return this.request("GET", "/refunds-disputes/imports/sources", {
9840
+ query: { test_mode: params.test_mode }
9841
+ });
9842
+ }
9843
+ /**
9844
+ * Start an import. A source a processor cannot provide is stored as
9845
+ * `unavailable` with its reason. Refused while another import of the
9846
+ * merchant runs in the same environment.
9847
+ *
9848
+ * `POST /refunds-disputes/imports`
9849
+ */
9850
+ async create(request) {
9851
+ return this.request("POST", "/refunds-disputes/imports", { body: request });
9852
+ }
9853
+ /**
9854
+ * The newest import in the environment, running or finished.
9855
+ *
9856
+ * `GET /refunds-disputes/imports/latest`
9857
+ */
9858
+ async latest(params) {
9859
+ return this.request("GET", "/refunds-disputes/imports/latest", {
9860
+ query: { test_mode: params.test_mode }
9861
+ });
9862
+ }
9863
+ /** `GET /refunds-disputes/imports/{id}` */
9864
+ async retrieve(id) {
9865
+ return this.request("GET", `/refunds-disputes/imports/${encodeURIComponent(id)}`);
9866
+ }
9867
+ /**
9868
+ * The records an import left out or could not record, each with its reason.
9869
+ *
9870
+ * `GET /refunds-disputes/imports/{id}/issues`
9871
+ */
9872
+ async issues(id, params) {
9873
+ return this.request("GET", `/refunds-disputes/imports/${encodeURIComponent(id)}/issues`, {
9874
+ query: { limit: params?.limit, offset: params?.offset }
9875
+ });
9876
+ }
9877
+ /**
9878
+ * Ask a running import to stop. It stops after the page it is reading;
9879
+ * what it recorded stays recorded.
9880
+ *
9881
+ * `POST /refunds-disputes/imports/{id}/cancel`
9882
+ */
9883
+ async cancel(id) {
9884
+ return this.request("POST", `/refunds-disputes/imports/${encodeURIComponent(id)}/cancel`);
9885
+ }
9886
+ /**
9887
+ * Open the progress stream of an import. Resolves once the server answered;
9888
+ * a `401` rejects with `DelopayAuthenticationError`.
9889
+ *
9890
+ * `GET /refunds-disputes/imports/{id}/stream`
9891
+ *
9892
+ * @example
9893
+ * ```typescript
9894
+ * const stream = await delopay.processorImports.stream(run.id, { signal });
9895
+ * for await (const event of stream) {
9896
+ * if (event.type === 'progress') render(event.run);
9897
+ * }
9898
+ * ```
9899
+ */
9900
+ async stream(id, options = {}) {
9901
+ const connection = await this.openStream(
9902
+ `/refunds-disputes/imports/${encodeURIComponent(id)}/stream`,
9903
+ {
9904
+ ...options.signal ? { signal: options.signal } : {},
9905
+ ...options.idleTimeoutMs !== void 0 ? { idleTimeoutMs: options.idleTimeoutMs } : {},
9906
+ ...options.headers ? { headers: options.headers } : {}
9907
+ }
9908
+ );
9909
+ return new PspImportEventStream(connection);
9910
+ }
9911
+ };
9912
+
9747
9913
  // src/resources/deploymentBranding.ts
9748
9914
  function brandingAssetPath(asset, version) {
9749
9915
  const path = `/branding/assets/${encodeURIComponent(asset)}`;
@@ -10058,6 +10224,7 @@ var Delopay = class {
10058
10224
  this.messageTemplates = new MessageTemplates(request);
10059
10225
  this.risk = new Risk(request);
10060
10226
  this.live = new Live(request, openStream);
10227
+ this.processorImports = new ProcessorImports(request, openStream);
10061
10228
  this.branding = new Branding(request, this.baseUrl);
10062
10229
  this.subscriptions = new Subscriptions(request);
10063
10230
  this.buyerPortal = new BuyerPortal(request);
@@ -17189,7 +17356,9 @@ var DelopayInternal = class extends Delopay {
17189
17356
  PlatformSettings,
17190
17357
  PresentationCache,
17191
17358
  ProcessorCosts,
17359
+ ProcessorImports,
17192
17360
  Products,
17361
+ PspImportEventStream,
17193
17362
  RTL_CHECKOUT_LOCALES,
17194
17363
  Regions,
17195
17364
  Risk,