multivendor-wallet 0.0.3 → 0.0.4

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.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-CrJxUVwX.mjs';
2
- export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-CrJxUVwX.mjs';
3
- import { W as WalletAccountType } from './store-BQ3whei-.mjs';
4
- export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-BQ3whei-.mjs';
1
+ import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-D46FcrKZ.mjs';
2
+ export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-D46FcrKZ.mjs';
3
+ import { W as WalletAccountType } from './store-By30oqos.mjs';
4
+ export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-By30oqos.mjs';
5
5
  export { CreateWalletTables1790000000000, TypeOrmWalletStore, WalletAccountEntity, WalletHoldEntity, WalletLedgerEntryEntity, getWalletOrmMetadata } from './typeorm/index.mjs';
6
6
  import { Router } from 'express';
7
7
  import 'typeorm';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-iNUEzUgo.js';
2
- export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-iNUEzUgo.js';
3
- import { W as WalletAccountType } from './store-BQ3whei-.js';
4
- export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-BQ3whei-.js';
1
+ import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-BzaT7Aqh.js';
2
+ export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-BzaT7Aqh.js';
3
+ import { W as WalletAccountType } from './store-By30oqos.js';
4
+ export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-By30oqos.js';
5
5
  export { CreateWalletTables1790000000000, TypeOrmWalletStore, WalletAccountEntity, WalletHoldEntity, WalletLedgerEntryEntity, getWalletOrmMetadata } from './typeorm/index.js';
6
6
  import { Router } from 'express';
7
7
  import 'typeorm';
package/dist/index.js CHANGED
@@ -72,6 +72,9 @@ var WalletAccountType = /* @__PURE__ */ (function(WalletAccountType2) {
72
72
  WalletAccountType2["CUSTOMER"] = "customer";
73
73
  WalletAccountType2["VENDOR"] = "vendor";
74
74
  WalletAccountType2["PLATFORM"] = "platform";
75
+ WalletAccountType2["INVESTOR"] = "investor";
76
+ WalletAccountType2["PLATFORM_INVESTOR_LIABILITY"] = "platform_investor_liability";
77
+ WalletAccountType2["PLATFORM_TDS_PAYABLE"] = "platform_tds_payable";
75
78
  return WalletAccountType2;
76
79
  })({});
77
80
  var LedgerEntryType = /* @__PURE__ */ (function(LedgerEntryType2) {
@@ -1769,14 +1772,31 @@ var TypeOrmWalletStoreTx = (_a2 = class {
1769
1772
  }
1770
1773
  });
1771
1774
  if (!row) {
1772
- row = repo.create({
1773
- ownerType: type,
1774
- ownerId,
1775
- currency,
1776
- availableBalance: "0",
1777
- heldBalance: "0"
1778
- });
1779
- row = await repo.save(row);
1775
+ try {
1776
+ row = await repo.save(repo.create({
1777
+ ownerType: type,
1778
+ ownerId,
1779
+ currency,
1780
+ availableBalance: "0",
1781
+ heldBalance: "0"
1782
+ }));
1783
+ } catch (error) {
1784
+ const err = error;
1785
+ const code = err?.code || err?.errno;
1786
+ if (code === "ER_DUP_ENTRY" || code === 1062) {
1787
+ row = await repo.findOne({
1788
+ where: {
1789
+ ownerType: type,
1790
+ ownerId,
1791
+ currency
1792
+ }
1793
+ });
1794
+ if (row) {
1795
+ return toLedgerAccount(row);
1796
+ }
1797
+ }
1798
+ throw error;
1799
+ }
1780
1800
  }
1781
1801
  return toLedgerAccount(row);
1782
1802
  }