@unchainedshop/core-payment 4.4.0 → 4.5.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.
|
@@ -2,13 +2,11 @@ import { type PaymentSettingsOptions } from '../payment-settings.ts';
|
|
|
2
2
|
import type { ModuleInput } from '@unchainedshop/mongodb';
|
|
3
3
|
export declare const configurePaymentModule: ({ db, options: paymentOptions, }: ModuleInput<PaymentSettingsOptions>) => Promise<{
|
|
4
4
|
paymentProviders: {
|
|
5
|
-
count: (query
|
|
5
|
+
count: (query?: import("./configurePaymentProvidersModule.ts").PaymentProviderQuery) => Promise<number>;
|
|
6
6
|
findProvider: ({ paymentProviderId, ...query }: import("mongodb").Filter<import("../db/PaymentProvidersCollection.ts").PaymentProvider> & {
|
|
7
7
|
paymentProviderId: string;
|
|
8
8
|
}, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider | null>;
|
|
9
|
-
findProviders: (query
|
|
10
|
-
includeDeleted?: boolean;
|
|
11
|
-
}, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider[]>;
|
|
9
|
+
findProviders: (query?: import("./configurePaymentProvidersModule.ts").PaymentProviderQuery, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider[]>;
|
|
12
10
|
allProviders: () => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.ts").PaymentProvider>[]>;
|
|
13
11
|
providerExists: ({ paymentProviderId }: {
|
|
14
12
|
paymentProviderId: string;
|
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import type { PaymentProvider } from '../db/PaymentProvidersCollection.ts';
|
|
2
|
+
import type { PaymentProvider, PaymentProviderType } from '../db/PaymentProvidersCollection.ts';
|
|
3
3
|
export interface PaymentInterface {
|
|
4
4
|
_id: string;
|
|
5
5
|
label: string;
|
|
6
6
|
version: string;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export interface PaymentProviderQuery {
|
|
9
|
+
paymentProviderIds?: string[];
|
|
10
|
+
type?: PaymentProviderType;
|
|
9
11
|
includeDeleted?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
deleted?: Date | mongodb.FilterOperators<Date | null | undefined> | null | undefined;
|
|
14
|
-
updated?: mongodb.Condition<Date | undefined>;
|
|
15
|
-
adapterKey?: mongodb.Condition<string> | undefined;
|
|
16
|
-
configuration?: mongodb.Condition<import("../db/PaymentProvidersCollection.ts").PaymentConfiguration> | undefined;
|
|
17
|
-
_id?: mongodb.Condition<string> | undefined;
|
|
18
|
-
$and?: mongodb.Filter<mongodb.WithId<PaymentProvider>>[] | undefined;
|
|
19
|
-
$nor?: mongodb.Filter<mongodb.WithId<PaymentProvider>>[] | undefined;
|
|
20
|
-
$or?: mongodb.Filter<mongodb.WithId<PaymentProvider>>[] | undefined;
|
|
21
|
-
$text?: {
|
|
22
|
-
$search: string;
|
|
23
|
-
$language?: string;
|
|
24
|
-
$caseSensitive?: boolean;
|
|
25
|
-
$diacriticSensitive?: boolean;
|
|
26
|
-
};
|
|
27
|
-
$where?: string | ((this: mongodb.WithId<PaymentProvider>) => boolean) | undefined;
|
|
28
|
-
$comment?: string | mongodb.BSON.Document;
|
|
29
|
-
};
|
|
12
|
+
queryString?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const buildFindSelector: ({ includeDeleted, queryString, paymentProviderIds, type, }?: PaymentProviderQuery) => mongodb.Filter<PaymentProvider>;
|
|
30
15
|
export declare const configurePaymentProvidersModule: (PaymentProviders: mongodb.Collection<PaymentProvider>) => {
|
|
31
|
-
count: (query
|
|
16
|
+
count: (query?: PaymentProviderQuery) => Promise<number>;
|
|
32
17
|
findProvider: ({ paymentProviderId, ...query }: mongodb.Filter<PaymentProvider> & {
|
|
33
18
|
paymentProviderId: string;
|
|
34
19
|
}, options?: mongodb.FindOptions) => Promise<PaymentProvider | null>;
|
|
35
|
-
findProviders: (query
|
|
36
|
-
includeDeleted?: boolean;
|
|
37
|
-
}, options?: mongodb.FindOptions) => Promise<PaymentProvider[]>;
|
|
20
|
+
findProviders: (query?: PaymentProviderQuery, options?: mongodb.FindOptions) => Promise<PaymentProvider[]>;
|
|
38
21
|
allProviders: () => Promise<mongodb.WithId<PaymentProvider>[]>;
|
|
39
22
|
providerExists: ({ paymentProviderId }: {
|
|
40
23
|
paymentProviderId: string;
|
|
@@ -8,20 +8,31 @@ const PAYMENT_PROVIDER_EVENTS = [
|
|
|
8
8
|
'PAYMENT_PROVIDER_REMOVE',
|
|
9
9
|
];
|
|
10
10
|
const allProvidersCache = new ExpiryMap(process.env.NODE_ENV === 'production' ? 60000 : 1);
|
|
11
|
-
export const buildFindSelector = ({ includeDeleted = false,
|
|
12
|
-
|
|
11
|
+
export const buildFindSelector = ({ includeDeleted = false, queryString, paymentProviderIds, type, } = {}) => {
|
|
12
|
+
const selector = includeDeleted ? {} : { deleted: null };
|
|
13
|
+
if (paymentProviderIds) {
|
|
14
|
+
selector._id = { $in: paymentProviderIds };
|
|
15
|
+
}
|
|
16
|
+
if (type) {
|
|
17
|
+
selector.type = type;
|
|
18
|
+
}
|
|
19
|
+
if (queryString) {
|
|
20
|
+
const regex = new RegExp(queryString, 'i');
|
|
21
|
+
selector.$or = [{ _id: regex }, { adapterKey: regex }];
|
|
22
|
+
}
|
|
23
|
+
return selector;
|
|
13
24
|
};
|
|
14
25
|
export const configurePaymentProvidersModule = (PaymentProviders) => {
|
|
15
26
|
registerEvents(PAYMENT_PROVIDER_EVENTS);
|
|
16
27
|
return {
|
|
17
|
-
count: async (query) => {
|
|
28
|
+
count: async (query = {}) => {
|
|
18
29
|
const providerCount = await PaymentProviders.countDocuments(buildFindSelector(query));
|
|
19
30
|
return providerCount;
|
|
20
31
|
},
|
|
21
32
|
findProvider: async ({ paymentProviderId, ...query }, options) => {
|
|
22
33
|
return PaymentProviders.findOne(paymentProviderId ? generateDbFilterById(paymentProviderId) : query, options);
|
|
23
34
|
},
|
|
24
|
-
findProviders: async (query, options = { sort: { created: 1 } }) => {
|
|
35
|
+
findProviders: async (query = {}, options = { sort: { created: 1 } }) => {
|
|
25
36
|
const providers = PaymentProviders.find(buildFindSelector(query), options);
|
|
26
37
|
return providers.toArray();
|
|
27
38
|
},
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-payment",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"main": "lib/payment-index.js",
|
|
5
5
|
"types": "lib/payment-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"scripts": {
|
|
8
9
|
"clean": "tsc -b --clean",
|
|
9
10
|
"build": "tsc -b",
|
|
@@ -33,9 +34,9 @@
|
|
|
33
34
|
},
|
|
34
35
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@unchainedshop/events": "^4.
|
|
37
|
-
"@unchainedshop/logger": "^4.
|
|
38
|
-
"@unchainedshop/utils": "^4.
|
|
37
|
+
"@unchainedshop/events": "^4.5.0",
|
|
38
|
+
"@unchainedshop/logger": "^4.5.0",
|
|
39
|
+
"@unchainedshop/utils": "^4.5.0",
|
|
39
40
|
"expiry-map": "^2.0.0",
|
|
40
41
|
"p-memoize": "^8.0.0"
|
|
41
42
|
},
|