@rebilly/instruments 9.42.0 → 9.44.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
- ## [9.42.0](https://github.com/Rebilly/rebilly/compare/instruments/core-v9.41.6...instruments/core-v9.42.0) (2024-05-13)
1
+ ## [9.44.0](https://github.com/Rebilly/rebilly/compare/instruments/core-v9.43.0...instruments/core-v9.44.0) (2024-05-14)
2
2
 
3
3
 
4
4
  ### Features
5
5
 
6
- * **api-metadata, rebilly-js-sdk:** Update resources based on latest api definitions ([#5117](https://github.com/Rebilly/rebilly/issues/5117)) ([a8265e2](https://github.com/Rebilly/rebilly/commit/a8265e2d0e9cc197c6c3ab0ba3cdf32e59d54230))
6
+ * **api-metadata, rebilly-js-sdk:** Update resources based on latest api definitions ([#5242](https://github.com/Rebilly/rebilly/issues/5242)) ([f2dfa3b](https://github.com/Rebilly/rebilly/commit/f2dfa3bf5bae8f6defe9b6b717733d8567aac161))
package/dist/index.js CHANGED
@@ -16411,7 +16411,7 @@ async function fetchData({
16411
16411
  fetchDepositRequest: fetchDepositRequest$1 = fetchDepositRequest,
16412
16412
  fetchPayoutRequest: fetchPayoutRequest$1 = fetchPayoutRequest
16413
16413
  } = {}) {
16414
- var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n;
16414
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s2, _t3, _u;
16415
16415
  try {
16416
16416
  state.data = new DataInstance();
16417
16417
  if (state.storefront && ((_a = state.options) == null ? void 0 : _a.jwt)) {
@@ -16460,11 +16460,16 @@ async function fetchData({
16460
16460
  productsPromise = Promise.resolve(products2);
16461
16461
  state.data.invoice = invoice;
16462
16462
  }
16463
+ const isManageInstruments = [
16464
+ (_i = (_h = state.options) == null ? void 0 : _h.paymentInstruments) == null ? void 0 : _i.allowDeactivate,
16465
+ (_k = (_j = state.options) == null ? void 0 : _j.paymentInstruments) == null ? void 0 : _k.allowUpdate,
16466
+ (_m = (_l = state.options) == null ? void 0 : _l.paymentInstruments) == null ? void 0 : _m.allowMakeDefault
16467
+ ].some((v2) => v2);
16463
16468
  let readyToPayPromise = Promise.resolve(null);
16464
16469
  let readyToPayoutPromise = Promise.resolve(null);
16465
16470
  let fetchAccountAndWebsitePromise = Promise.resolve();
16466
16471
  let availableInstrumentsPromise = null;
16467
- if ((_h = state.options) == null ? void 0 : _h.jwt) {
16472
+ if ((_n = state.options) == null ? void 0 : _n.jwt) {
16468
16473
  fetchAccountAndWebsitePromise = fetchAccountAndWebsite$1().then(
16469
16474
  ({ account, website }) => {
16470
16475
  if (state.data == null) {
@@ -16474,32 +16479,32 @@ async function fetchData({
16474
16479
  state.data.website = website;
16475
16480
  }
16476
16481
  );
16477
- if ((_i = state.options) == null ? void 0 : _i.payout) {
16482
+ if ((_o = state.options) == null ? void 0 : _o.payout) {
16478
16483
  readyToPayoutPromise = fetchAccountAndWebsitePromise.then(
16479
16484
  () => fetchReadyToPayout()
16480
16485
  );
16481
- } else {
16486
+ } else if (state.data.money || state.data.invoice || state.data.transaction || state.data.payout || state.data.deposit) {
16482
16487
  readyToPayPromise = fetchAccountAndWebsitePromise.then(
16483
16488
  () => fetchReadyToPay()
16484
16489
  );
16485
16490
  }
16486
16491
  availableInstrumentsPromise = fetchInstruments();
16487
- } else if ((_j = state.options) == null ? void 0 : _j.payout) {
16492
+ } else if ((_p = state.options) == null ? void 0 : _p.payout) {
16488
16493
  readyToPayoutPromise = fetchReadyToPayout();
16489
16494
  } else {
16490
16495
  readyToPayPromise = fetchReadyToPay();
16491
16496
  }
16492
- const previewPurchasePromise = ((_k = state.options) == null ? void 0 : _k.items) ? fetchSummary() : null;
16493
- if (!((_l = state.options) == null ? void 0 : _l.jwt)) {
16497
+ const previewPurchasePromise = ((_q = state.options) == null ? void 0 : _q.items) ? fetchSummary() : null;
16498
+ if (!((_r = state.options) == null ? void 0 : _r.jwt)) {
16494
16499
  productsPromise = fetchProductsFromPlans();
16495
16500
  }
16496
16501
  let plansPromise = new Promise((resolve2) => {
16497
16502
  resolve2([]);
16498
16503
  });
16499
- if (((_m = state.options) == null ? void 0 : _m.addons) || ((_n = state.options) == null ? void 0 : _n.bumpOffer)) {
16504
+ if (((_s2 = state.options) == null ? void 0 : _s2.addons) || ((_t3 = state.options) == null ? void 0 : _t3.bumpOffer)) {
16500
16505
  plansPromise = fetchPlansFromAddonsBumpOffer();
16501
16506
  }
16502
- const [
16507
+ let [
16503
16508
  readyToPayout,
16504
16509
  readyToPay,
16505
16510
  previewPurchase,
@@ -16514,13 +16519,23 @@ async function fetchData({
16514
16519
  plansPromise,
16515
16520
  availableInstrumentsPromise
16516
16521
  ]);
16522
+ if (isManageInstruments && availableInstruments && !readyToPay && !((_u = state.options) == null ? void 0 : _u.payout)) {
16523
+ const set2 = /* @__PURE__ */ new Set();
16524
+ availableInstruments.forEach((instrument) => {
16525
+ set2.add(instrument.method);
16526
+ });
16527
+ readyToPay = filterReadyToPay(
16528
+ Array.from(set2).map((method) => ({ method }))
16529
+ );
16530
+ }
16517
16531
  return new DataInstance({
16518
16532
  readyToPayout,
16519
16533
  readyToPay,
16520
16534
  previewPurchase,
16521
16535
  products,
16522
16536
  plans,
16523
- availableInstruments
16537
+ availableInstruments,
16538
+ isManageInstruments
16524
16539
  });
16525
16540
  } catch (error2) {
16526
16541
  console.error(error2);