@unchainedshop/core-payment 5.0.0-alpha.1 → 5.0.0-alpha.3

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.
@@ -2,8 +2,8 @@ import { mongodb, buildDbIndexes } from '@unchainedshop/mongodb';
2
2
  export const PaymentCredentialsCollection = async (db) => {
3
3
  const PaymentCredentialsCol = db.collection('payment_credentials');
4
4
  await buildDbIndexes(PaymentCredentialsCol, [
5
+ { index: { userId: 1, paymentProviderId: 1 } },
5
6
  { index: { paymentProviderId: 1 } },
6
- { index: { userId: 1 } },
7
7
  ]);
8
8
  return PaymentCredentialsCol;
9
9
  };
@@ -6,17 +6,8 @@ export const PaymentProviderType = {
6
6
  export const PaymentProvidersCollection = async (db) => {
7
7
  const PaymentProviders = db.collection('payment-providers');
8
8
  await buildDbIndexes(PaymentProviders, [
9
- { index: { type: 1 } },
10
- {
11
- index: {
12
- created: 1,
13
- },
14
- },
15
- {
16
- index: {
17
- deleted: 1,
18
- },
19
- },
9
+ { index: { deleted: 1, type: 1 } },
10
+ { index: { deleted: 1, created: 1 } },
20
11
  ]);
21
12
  return PaymentProviders;
22
13
  };
@@ -7,9 +7,7 @@ export declare const configurePaymentModule: ({ db, options: paymentOptions, }:
7
7
  paymentProviderId: string;
8
8
  }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider | null>;
9
9
  findProviders: (query?: import("./configurePaymentProvidersModule.ts").PaymentProviderQuery, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider[]>;
10
- allProviders: (() => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.ts").PaymentProvider>[]>) & {
11
- clear: () => void;
12
- };
10
+ allProviders: import("@unchainedshop/utils/lib/memoize-with-ttl.js").MemoizedWithTTL<[], import("mongodb").WithId<import("../db/PaymentProvidersCollection.ts").PaymentProvider>[]>;
13
11
  providerExists: ({ paymentProviderId }: {
14
12
  paymentProviderId: string;
15
13
  }) => Promise<boolean>;
@@ -18,9 +18,7 @@ export declare const configurePaymentProvidersModule: (PaymentProviders: mongodb
18
18
  paymentProviderId: string;
19
19
  }, options?: mongodb.FindOptions) => Promise<PaymentProvider | null>;
20
20
  findProviders: (query?: PaymentProviderQuery, options?: mongodb.FindOptions) => Promise<PaymentProvider[]>;
21
- allProviders: (() => Promise<mongodb.WithId<PaymentProvider>[]>) & {
22
- clear: () => void;
23
- };
21
+ allProviders: import("@unchainedshop/utils/lib/memoize-with-ttl.js").MemoizedWithTTL<[], mongodb.WithId<PaymentProvider>[]>;
24
22
  providerExists: ({ paymentProviderId }: {
25
23
  paymentProviderId: string;
26
24
  }) => Promise<boolean>;
@@ -6,7 +6,6 @@ const PAYMENT_PROVIDER_EVENTS = [
6
6
  'PAYMENT_PROVIDER_UPDATE',
7
7
  'PAYMENT_PROVIDER_REMOVE',
8
8
  ];
9
- const allProvidersTtlMs = process.env.NODE_ENV === 'production' ? 60000 : 1;
10
9
  export const buildFindSelector = ({ includeDeleted = false, queryString, paymentProviderIds, type, } = {}) => {
11
10
  const selector = includeDeleted ? {} : { deleted: null };
12
11
  if (paymentProviderIds) {
@@ -23,9 +22,7 @@ export const buildFindSelector = ({ includeDeleted = false, queryString, payment
23
22
  };
24
23
  export const configurePaymentProvidersModule = (PaymentProviders) => {
25
24
  registerEvents(PAYMENT_PROVIDER_EVENTS);
26
- const allProviders = memoizeWithTTL(async function () {
27
- return PaymentProviders.find({ deleted: null }, { sort: { created: 1 } }).toArray();
28
- }, allProvidersTtlMs);
25
+ const allProviders = memoizeWithTTL(async () => PaymentProviders.find({ deleted: null }, { sort: { created: 1 } }).toArray(), { ttl: process.env.NODE_ENV === 'production' ? 60000 : 1 });
29
26
  return {
30
27
  count: async (query = {}) => {
31
28
  const providerCount = await PaymentProviders.countDocuments(buildFindSelector(query));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-payment",
3
3
  "description": "Payment provider management module for the Unchained Engine",
4
- "version": "5.0.0-alpha.1",
4
+ "version": "5.0.0-alpha.3",
5
5
  "main": "lib/payment-index.js",
6
6
  "types": "lib/payment-index.d.ts",
7
7
  "type": "module",
@@ -36,11 +36,11 @@
36
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
37
  "dependencies": {
38
38
  "@unchainedshop/events": "^5.0.0-alpha.1",
39
- "@unchainedshop/logger": "^5.0.0-alpha.1",
39
+ "@unchainedshop/mongodb": "^5.0.0-alpha.1",
40
40
  "@unchainedshop/utils": "^5.0.0-alpha.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "^25.0.0",
43
+ "@types/node": "^26.2.0",
44
44
  "typescript": "^5.8.3"
45
45
  }
46
46
  }