@purpleschool/gptbot 0.8.98 → 0.8.99
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/api/controllers/http/payment.ts +1 -0
- package/api/routes.ts +1 -0
- package/build/api/controllers/http/payment.js +1 -0
- package/build/api/routes.js +1 -0
- package/build/commands/payment/find-payments-by-criteria.command.js +53 -0
- package/build/commands/payment/index.js +1 -0
- package/build/commands/user/get-user-payments.command.js +3 -1
- package/build/models/payment.schema.js +8 -3
- package/commands/payment/find-payments-by-criteria.command.ts +63 -0
- package/commands/payment/index.ts +1 -0
- package/commands/user/get-user-payments.command.ts +4 -2
- package/models/payment.schema.ts +7 -2
- package/package.json +1 -1
package/api/routes.ts
CHANGED
|
@@ -863,6 +863,7 @@ export const REST_API = {
|
|
|
863
863
|
PAYMENT: {
|
|
864
864
|
HISTORY: `${ROOT}/${CONTROLLERS.PAYMENT_CONTROLLER}/${CONTROLLERS.PAYMENT_ROUTES.HISTORY}`,
|
|
865
865
|
REFUND: `${ROOT}/${CONTROLLERS.PAYMENT_CONTROLLER}/${CONTROLLERS.PAYMENT_ROUTES.REFUND}`,
|
|
866
|
+
FIND_BY_CRITERIA: `${ROOT}/${CONTROLLERS.PAYMENT_CONTROLLER}/${CONTROLLERS.PAYMENT_ROUTES.FIND_BY_CRITERIA}`,
|
|
866
867
|
},
|
|
867
868
|
COURSE: {
|
|
868
869
|
FIND_BY_UUID: `${ROOT}/${CONTROLLERS.COURSE_CONTROLLER}/${CONTROLLERS.COURSE_ROUTES.FIND_BY_UUID}`,
|
package/build/api/routes.js
CHANGED
|
@@ -660,6 +660,7 @@ exports.REST_API = {
|
|
|
660
660
|
PAYMENT: {
|
|
661
661
|
HISTORY: `${exports.ROOT}/${CONTROLLERS.PAYMENT_CONTROLLER}/${CONTROLLERS.PAYMENT_ROUTES.HISTORY}`,
|
|
662
662
|
REFUND: `${exports.ROOT}/${CONTROLLERS.PAYMENT_CONTROLLER}/${CONTROLLERS.PAYMENT_ROUTES.REFUND}`,
|
|
663
|
+
FIND_BY_CRITERIA: `${exports.ROOT}/${CONTROLLERS.PAYMENT_CONTROLLER}/${CONTROLLERS.PAYMENT_ROUTES.FIND_BY_CRITERIA}`,
|
|
663
664
|
},
|
|
664
665
|
COURSE: {
|
|
665
666
|
FIND_BY_UUID: `${exports.ROOT}/${CONTROLLERS.COURSE_CONTROLLER}/${CONTROLLERS.COURSE_ROUTES.FIND_BY_UUID}`,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindPaymentsByCriteriaCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
var FindPaymentsByCriteriaCommand;
|
|
8
|
+
(function (FindPaymentsByCriteriaCommand) {
|
|
9
|
+
FindPaymentsByCriteriaCommand.RequestSchema = zod_1.z.preprocess((input) => {
|
|
10
|
+
if (input && typeof input === 'object' && !Array.isArray(input)) {
|
|
11
|
+
const obj = Object.assign({}, input);
|
|
12
|
+
const onlyNormalize = ['createdAt', 'sum'];
|
|
13
|
+
const relevantBracketed = Object.keys(obj).some((key) => {
|
|
14
|
+
const match = key.match(/^(\w+)\[(\w+)\]$/);
|
|
15
|
+
return match && onlyNormalize.includes(match[1]);
|
|
16
|
+
});
|
|
17
|
+
if (!relevantBracketed) {
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
const result = Object.assign({}, obj);
|
|
21
|
+
for (const key of Object.keys(obj)) {
|
|
22
|
+
const match = key.match(/^(\w+)\[(\w+)\]$/);
|
|
23
|
+
if (match && onlyNormalize.includes(match[1])) {
|
|
24
|
+
const [, outer, inner] = match;
|
|
25
|
+
result[outer] = result[outer] || {};
|
|
26
|
+
result[outer][inner] = obj[key];
|
|
27
|
+
delete result[key];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
return input;
|
|
33
|
+
}, zod_1.z.object({
|
|
34
|
+
status: zod_1.z.nativeEnum(constants_1.PAYMENT_STATUS).optional(),
|
|
35
|
+
orderId: zod_1.z.string().optional(),
|
|
36
|
+
sum: models_1.NumberFilter.optional(),
|
|
37
|
+
userEmail: zod_1.z.string().optional(),
|
|
38
|
+
createdAt: models_1.DateFilter.optional(),
|
|
39
|
+
userId: zod_1.z.string().optional(),
|
|
40
|
+
signupMethod: zod_1.z.nativeEnum(constants_1.SIGNUP_METHOD).optional(),
|
|
41
|
+
vkId: zod_1.z.string().optional(),
|
|
42
|
+
yandexId: zod_1.z.string().optional(),
|
|
43
|
+
sortBy: zod_1.z.nativeEnum(constants_1.PAYMENT_SORT_BY).optional(),
|
|
44
|
+
sortOrder: zod_1.z.nativeEnum(constants_1.SORT_ORDER).default(constants_1.SORT_ORDER.DESC).optional(),
|
|
45
|
+
limit: zod_1.z.coerce.number().min(1),
|
|
46
|
+
offset: zod_1.z.coerce.number().min(0).default(0),
|
|
47
|
+
}));
|
|
48
|
+
FindPaymentsByCriteriaCommand.ResponseSchema = zod_1.z.object({
|
|
49
|
+
data: zod_1.z.array(models_1.PaymentWithUserDataSchema),
|
|
50
|
+
page: zod_1.z.number(),
|
|
51
|
+
totalPages: zod_1.z.number(),
|
|
52
|
+
});
|
|
53
|
+
})(FindPaymentsByCriteriaCommand || (exports.FindPaymentsByCriteriaCommand = FindPaymentsByCriteriaCommand = {}));
|
|
@@ -20,3 +20,4 @@ __exportStar(require("./pay.command"), exports);
|
|
|
20
20
|
__exportStar(require("./receipt.command"), exports);
|
|
21
21
|
__exportStar(require("./recurrent.command"), exports);
|
|
22
22
|
__exportStar(require("./refund-payment.command"), exports);
|
|
23
|
+
__exportStar(require("./find-payments-by-criteria.command"), exports);
|
|
@@ -21,6 +21,8 @@ var GetUserPaymentsCommand;
|
|
|
21
21
|
})
|
|
22
22
|
.partial();
|
|
23
23
|
GetUserPaymentsCommand.ResponseSchema = zod_1.default.object({
|
|
24
|
-
data: zod_1.default.array(models_1.
|
|
24
|
+
data: zod_1.default.array(models_1.PaymentWithUserDataSchema),
|
|
25
|
+
page: zod_1.default.number(),
|
|
26
|
+
totalPages: zod_1.default.number(),
|
|
25
27
|
});
|
|
26
28
|
})(GetUserPaymentsCommand || (exports.GetUserPaymentsCommand = GetUserPaymentsCommand = {}));
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PaymentWithUserDataSchema = exports.PaymentSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
5
6
|
exports.PaymentSchema = zod_1.z.object({
|
|
6
7
|
uuid: zod_1.z.string().uuid(),
|
|
7
|
-
link: zod_1.z.nullable(zod_1.z.string()),
|
|
8
8
|
status: zod_1.z.string(),
|
|
9
9
|
sum: zod_1.z.number(),
|
|
10
10
|
orderId: zod_1.z.string().uuid(),
|
|
11
11
|
createdAt: zod_1.z.date(),
|
|
12
12
|
updatedAt: zod_1.z.date(),
|
|
13
13
|
});
|
|
14
|
-
exports.
|
|
14
|
+
exports.PaymentWithUserDataSchema = exports.PaymentSchema.extend({
|
|
15
15
|
description: zod_1.z.string(),
|
|
16
|
+
userId: zod_1.z.string().uuid(),
|
|
17
|
+
email: zod_1.z.string().email(),
|
|
18
|
+
singupMethod: zod_1.z.nativeEnum(constants_1.SIGNUP_METHOD),
|
|
19
|
+
vkId: zod_1.z.string().nullable(),
|
|
20
|
+
yandexId: zod_1.z.string().nullable(),
|
|
16
21
|
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DateFilter, NumberFilter, PaymentWithUserDataSchema } from '../../models';
|
|
3
|
+
import { PAYMENT_SORT_BY, PAYMENT_STATUS, SIGNUP_METHOD, SORT_ORDER } from '../../constants';
|
|
4
|
+
|
|
5
|
+
export namespace FindPaymentsByCriteriaCommand {
|
|
6
|
+
export const RequestSchema = z.preprocess(
|
|
7
|
+
(input) => {
|
|
8
|
+
if (input && typeof input === 'object' && !Array.isArray(input)) {
|
|
9
|
+
const obj = { ...input } as Record<string, any>;
|
|
10
|
+
const onlyNormalize = ['createdAt', 'sum'];
|
|
11
|
+
|
|
12
|
+
const relevantBracketed = Object.keys(obj).some((key) => {
|
|
13
|
+
const match = key.match(/^(\w+)\[(\w+)\]$/);
|
|
14
|
+
return match && onlyNormalize.includes(match[1]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (!relevantBracketed) {
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = { ...obj };
|
|
22
|
+
for (const key of Object.keys(obj)) {
|
|
23
|
+
const match = key.match(/^(\w+)\[(\w+)\]$/);
|
|
24
|
+
if (match && onlyNormalize.includes(match[1])) {
|
|
25
|
+
const [, outer, inner] = match;
|
|
26
|
+
result[outer] = result[outer] || {};
|
|
27
|
+
result[outer][inner] = obj[key];
|
|
28
|
+
delete result[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
return input;
|
|
34
|
+
},
|
|
35
|
+
z.object({
|
|
36
|
+
status: z.nativeEnum(PAYMENT_STATUS).optional(),
|
|
37
|
+
orderId: z.string().optional(),
|
|
38
|
+
sum: NumberFilter.optional(),
|
|
39
|
+
userEmail: z.string().optional(),
|
|
40
|
+
createdAt: DateFilter.optional(),
|
|
41
|
+
userId: z.string().optional(),
|
|
42
|
+
signupMethod: z.nativeEnum(SIGNUP_METHOD).optional(),
|
|
43
|
+
vkId: z.string().optional(),
|
|
44
|
+
yandexId: z.string().optional(),
|
|
45
|
+
|
|
46
|
+
sortBy: z.nativeEnum(PAYMENT_SORT_BY).optional(),
|
|
47
|
+
sortOrder: z.nativeEnum(SORT_ORDER).default(SORT_ORDER.DESC).optional(),
|
|
48
|
+
|
|
49
|
+
limit: z.coerce.number().min(1),
|
|
50
|
+
offset: z.coerce.number().min(0).default(0),
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
55
|
+
|
|
56
|
+
export const ResponseSchema = z.object({
|
|
57
|
+
data: z.array(PaymentWithUserDataSchema),
|
|
58
|
+
page: z.number(),
|
|
59
|
+
totalPages: z.number(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
63
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { PAYMENT_SORT_BY, PAYMENT_STATUS, SORT_ORDER } from '../../constants';
|
|
3
|
-
import {
|
|
3
|
+
import { PaymentWithUserDataSchema } from '../../models';
|
|
4
4
|
|
|
5
5
|
export namespace GetUserPaymentsCommand {
|
|
6
6
|
export const RequestParamSchema = z.object({
|
|
@@ -20,7 +20,9 @@ export namespace GetUserPaymentsCommand {
|
|
|
20
20
|
.partial();
|
|
21
21
|
|
|
22
22
|
export const ResponseSchema = z.object({
|
|
23
|
-
data: z.array(
|
|
23
|
+
data: z.array(PaymentWithUserDataSchema),
|
|
24
|
+
page: z.number(),
|
|
25
|
+
totalPages: z.number(),
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
export type Response = z.infer<typeof ResponseSchema>;
|
package/models/payment.schema.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { SIGNUP_METHOD } from '../constants';
|
|
2
3
|
|
|
3
4
|
export const PaymentSchema = z.object({
|
|
4
5
|
uuid: z.string().uuid(),
|
|
5
|
-
link: z.nullable(z.string()),
|
|
6
6
|
status: z.string(),
|
|
7
7
|
sum: z.number(),
|
|
8
8
|
orderId: z.string().uuid(),
|
|
@@ -11,6 +11,11 @@ export const PaymentSchema = z.object({
|
|
|
11
11
|
updatedAt: z.date(),
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const PaymentWithUserDataSchema = PaymentSchema.extend({
|
|
15
15
|
description: z.string(),
|
|
16
|
+
userId: z.string().uuid(),
|
|
17
|
+
email: z.string().email(),
|
|
18
|
+
singupMethod: z.nativeEnum(SIGNUP_METHOD),
|
|
19
|
+
vkId: z.string().nullable(),
|
|
20
|
+
yandexId: z.string().nullable(),
|
|
16
21
|
});
|