@purpleschool/gptbot 0.2.8 → 0.3.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.
@@ -1,4 +1,4 @@
1
1
  export const CLOUD_PAYMENTS_CONTROLLER = 'cloud-payments' as const;
2
2
  export const CLOUD_PAYMENTS_ROUTES = {
3
3
  CALLBACK: 'callback',
4
- } as const;
4
+ } as const;
@@ -4,4 +4,6 @@ export const SUBSCRIPTION_ROUTES = {
4
4
  FIND_BY_UUID: 'by/uuid',
5
5
  GET_ALL: 'all',
6
6
  BUY: 'buy',
7
+ GET_MY: 'my',
8
+ CANCEL: 'cancel',
7
9
  } as const;
package/api/routes.ts CHANGED
@@ -82,7 +82,8 @@ export const REST_API = {
82
82
  CREATE: `${ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}`,
83
83
  GET_BY_UUID: (uuid: string): string =>
84
84
  `${ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.FIND_BY_UUID}/${uuid}`,
85
- BUY: (uuid: string) => `${ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
85
+ BUY: (uuid: string) =>
86
+ `${ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
86
87
  },
87
88
  SUBSCRIPTION: {
88
89
  GET: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -91,7 +92,11 @@ export const REST_API = {
91
92
  CREATE: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}`,
92
93
  GET_BY_UUID: (uuid: string): string =>
93
94
  `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.FIND_BY_UUID}/${uuid}`,
94
- BUY: (uuid: string) => `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.BUY}/${uuid}`,
95
+ BUY: (uuid: string) =>
96
+ `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.BUY}/${uuid}`,
97
+ GET_MY: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_MY}`,
98
+ CANCEL: (uuid: string) =>
99
+ `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CANCEL}`,
95
100
  },
96
101
  FILES: {
97
102
  UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -6,4 +6,6 @@ exports.SUBSCRIPTION_ROUTES = {
6
6
  FIND_BY_UUID: 'by/uuid',
7
7
  GET_ALL: 'all',
8
8
  BUY: 'buy',
9
+ GET_MY: 'my',
10
+ CANCEL: 'cancel',
9
11
  };
@@ -103,6 +103,8 @@ exports.REST_API = {
103
103
  CREATE: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}`,
104
104
  GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.FIND_BY_UUID}/${uuid}`,
105
105
  BUY: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.BUY}/${uuid}`,
106
+ GET_MY: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_MY}`,
107
+ CANCEL: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CANCEL}`,
106
108
  },
107
109
  FILES: {
108
110
  UPLOAD_FILE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -26,3 +26,4 @@ __exportStar(require("./message"), exports);
26
26
  __exportStar(require("./product"), exports);
27
27
  __exportStar(require("./subscription"), exports);
28
28
  __exportStar(require("./blog"), exports);
29
+ __exportStar(require("./user-to-subscription"), exports);
@@ -4,24 +4,41 @@ exports.PayCommand = void 0;
4
4
  const zod_1 = require("zod");
5
5
  var PayCommand;
6
6
  (function (PayCommand) {
7
- PayCommand.RequestSchema = zod_1.z.object({
8
- transactionId: zod_1.z.number(),
9
- amount: zod_1.z.number(),
10
- currency: zod_1.z.string(),
11
- paymentAmount: zod_1.z.string(),
12
- paymentCurrency: zod_1.z.string(),
13
- dateTime: zod_1.z.string(),
14
- cardFirstSix: zod_1.z.string(),
15
- cardLastFour: zod_1.z.string(),
16
- cardType: zod_1.z.string(),
17
- cardExpDate: zod_1.z.string(),
18
- testMode: zod_1.z.number(),
19
- status: zod_1.z.string(),
20
- operationType: zod_1.z.string(),
21
- gatewayName: zod_1.z.string(),
22
- invoiceId: zod_1.z.string(),
23
- accountId: zod_1.z.string(),
24
- });
7
+ PayCommand.RequestSchema = zod_1.z
8
+ .object({
9
+ TransactionId: zod_1.z.string().transform((transactionId) => parseInt(transactionId, 10)),
10
+ Amount: zod_1.z.string().transform((amount) => parseInt(amount, 10)),
11
+ Currency: zod_1.z.string(),
12
+ PaymentAmount: zod_1.z.string(),
13
+ PaymentCurrency: zod_1.z.string(),
14
+ DateTime: zod_1.z.string(),
15
+ CardFirstSix: zod_1.z.string(),
16
+ CardLastFour: zod_1.z.string(),
17
+ CardType: zod_1.z.string(),
18
+ CardExpDate: zod_1.z.string(),
19
+ TestMode: zod_1.z.string().transform((testMode) => parseInt(testMode, 10)),
20
+ Status: zod_1.z.string(),
21
+ OperationType: zod_1.z.string(),
22
+ InvoiceId: zod_1.z.string(),
23
+ AccountId: zod_1.z.string(),
24
+ })
25
+ .transform((data) => ({
26
+ transactionId: data.TransactionId,
27
+ amount: data.Amount,
28
+ currency: data.Currency,
29
+ status: data.Status,
30
+ paymentAmount: data.PaymentAmount,
31
+ paymentCurrency: data.PaymentCurrency,
32
+ dateTime: data.DateTime,
33
+ cardFirstSix: data.CardFirstSix,
34
+ cardLastFour: data.CardLastFour,
35
+ cardType: data.CardType,
36
+ cardExpDate: data.CardExpDate,
37
+ testMode: data.TestMode,
38
+ operationType: data.OperationType,
39
+ invoiceId: data.InvoiceId,
40
+ accountId: data.AccountId,
41
+ }));
25
42
  PayCommand.ResponseSchema = zod_1.z.object({
26
43
  code: zod_1.z.number(),
27
44
  });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserToSubscriptionsCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const user_to_subscription_schema_1 = require("../../models/user-to-subscription.schema");
6
+ var GetUserToSubscriptionsCommand;
7
+ (function (GetUserToSubscriptionsCommand) {
8
+ GetUserToSubscriptionsCommand.ResponseSchema = zod_1.z.object({
9
+ data: zod_1.z.array(user_to_subscription_schema_1.UserToSubscriptionSchema),
10
+ });
11
+ })(GetUserToSubscriptionsCommand || (exports.GetUserToSubscriptionsCommand = GetUserToSubscriptionsCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-user-to-subscriptions.command"), exports);
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORMATS = void 0;
3
+ exports.CLOUD_PAYMENTS_CANCEL = exports.FORMATS = void 0;
4
4
  exports.FORMATS = {
5
5
  UTF8: 'utf-8',
6
6
  BASE64: 'base64',
7
7
  SHA256: 'sha256',
8
8
  };
9
+ exports.CLOUD_PAYMENTS_CANCEL = 'https://api.cloudpayments.ru/subscriptions/cancel';
@@ -26,3 +26,4 @@ __exportStar(require("./product.schema"), exports);
26
26
  __exportStar(require("./subscription.schema"), exports);
27
27
  __exportStar(require("./order.schema"), exports);
28
28
  __exportStar(require("./post.schema"), exports);
29
+ __exportStar(require("./user-to-subscription.schema"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserToSubscriptionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.UserToSubscriptionSchema = zod_1.z.object({
6
+ uuid: zod_1.z.string(),
7
+ userId: zod_1.z.string(),
8
+ subscriptionId: zod_1.z.string(),
9
+ initTokenBalance: zod_1.z.number(),
10
+ active: zod_1.z.boolean(),
11
+ tokenBalance: zod_1.z.number(),
12
+ status: zod_1.z.string(),
13
+ endDate: zod_1.z.date().nullable(),
14
+ createdAt: zod_1.z.date(),
15
+ updatedAt: zod_1.z.date(),
16
+ });
package/commands/index.ts CHANGED
@@ -10,3 +10,4 @@ export * from './message';
10
10
  export * from './product';
11
11
  export * from './subscription';
12
12
  export * from './blog';
13
+ export * from './user-to-subscription';
@@ -1,24 +1,41 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  export namespace PayCommand {
4
- export const RequestSchema = z.object({
5
- transactionId: z.number(),
6
- amount: z.number(),
7
- currency: z.string(),
8
- paymentAmount: z.string(),
9
- paymentCurrency: z.string(),
10
- dateTime: z.string(),
11
- cardFirstSix: z.string(),
12
- cardLastFour: z.string(),
13
- cardType: z.string(),
14
- cardExpDate: z.string(),
15
- testMode: z.number(),
16
- status: z.string(),
17
- operationType: z.string(),
18
- gatewayName: z.string(),
19
- invoiceId: z.string(),
20
- accountId: z.string(),
21
- });
4
+ export const RequestSchema = z
5
+ .object({
6
+ TransactionId: z.string().transform((transactionId) => parseInt(transactionId, 10)),
7
+ Amount: z.string().transform((amount) => parseInt(amount, 10)),
8
+ Currency: z.string(),
9
+ PaymentAmount: z.string(),
10
+ PaymentCurrency: z.string(),
11
+ DateTime: z.string(),
12
+ CardFirstSix: z.string(),
13
+ CardLastFour: z.string(),
14
+ CardType: z.string(),
15
+ CardExpDate: z.string(),
16
+ TestMode: z.string().transform((testMode) => parseInt(testMode, 10)),
17
+ Status: z.string(),
18
+ OperationType: z.string(),
19
+ InvoiceId: z.string(),
20
+ AccountId: z.string(),
21
+ })
22
+ .transform((data) => ({
23
+ transactionId: data.TransactionId,
24
+ amount: data.Amount,
25
+ currency: data.Currency,
26
+ status: data.Status,
27
+ paymentAmount: data.PaymentAmount,
28
+ paymentCurrency: data.PaymentCurrency,
29
+ dateTime: data.DateTime,
30
+ cardFirstSix: data.CardFirstSix,
31
+ cardLastFour: data.CardLastFour,
32
+ cardType: data.CardType,
33
+ cardExpDate: data.CardExpDate,
34
+ testMode: data.TestMode,
35
+ operationType: data.OperationType,
36
+ invoiceId: data.InvoiceId,
37
+ accountId: data.AccountId,
38
+ }));
22
39
 
23
40
  export type Request = z.infer<typeof RequestSchema>;
24
41
 
@@ -27,4 +44,4 @@ export namespace PayCommand {
27
44
  });
28
45
 
29
46
  export type Response = z.infer<typeof ResponseSchema>;
30
- }
47
+ }
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { UserToSubscriptionSchema } from '../../models/user-to-subscription.schema';
3
+
4
+ export namespace GetUserToSubscriptionsCommand {
5
+ export const ResponseSchema = z.object({
6
+ data: z.array(UserToSubscriptionSchema),
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -0,0 +1 @@
1
+ export * from './get-user-to-subscriptions.command';
@@ -2,4 +2,6 @@ export const FORMATS = {
2
2
  UTF8: 'utf-8',
3
3
  BASE64: 'base64',
4
4
  SHA256: 'sha256',
5
- } as const
5
+ } as const;
6
+
7
+ export const CLOUD_PAYMENTS_CANCEL = 'https://api.cloudpayments.ru/subscriptions/cancel';
package/models/index.ts CHANGED
@@ -10,3 +10,4 @@ export * from './product.schema';
10
10
  export * from './subscription.schema';
11
11
  export * from './order.schema';
12
12
  export * from './post.schema';
13
+ export * from './user-to-subscription.schema';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+
3
+ export const UserToSubscriptionSchema = z.object({
4
+ uuid: z.string(),
5
+ userId: z.string(),
6
+ subscriptionId: z.string(),
7
+ initTokenBalance: z.number(),
8
+ active: z.boolean(),
9
+ tokenBalance: z.number(),
10
+ status: z.string(),
11
+ endDate: z.date().nullable(),
12
+
13
+ createdAt: z.date(),
14
+ updatedAt: z.date(),
15
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {