@purpleschool/gptbot 0.2.7 → 0.2.9

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.
@@ -0,0 +1,4 @@
1
+ export const CLOUD_PAYMENTS_CONTROLLER = 'cloud-payments' as const;
2
+ export const CLOUD_PAYMENTS_ROUTES = {
3
+ CALLBACK: 'callback',
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,6 +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) =>
86
+ `${ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
85
87
  },
86
88
  SUBSCRIPTION: {
87
89
  GET: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -90,6 +92,11 @@ export const REST_API = {
90
92
  CREATE: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}`,
91
93
  GET_BY_UUID: (uuid: string): string =>
92
94
  `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.FIND_BY_UUID}/${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}`,
93
100
  },
94
101
  FILES: {
95
102
  UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLOUD_PAYMENTS_ROUTES = exports.CLOUD_PAYMENTS_CONTROLLER = void 0;
4
+ exports.CLOUD_PAYMENTS_CONTROLLER = 'cloud-payments';
5
+ exports.CLOUD_PAYMENTS_ROUTES = {
6
+ CALLBACK: 'callback',
7
+ };
@@ -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
  };
@@ -94,6 +94,7 @@ exports.REST_API = {
94
94
  DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${uuid}`,
95
95
  CREATE: `${exports.ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}`,
96
96
  GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.FIND_BY_UUID}/${uuid}`,
97
+ BUY: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
97
98
  },
98
99
  SUBSCRIPTION: {
99
100
  GET: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -101,6 +102,9 @@ exports.REST_API = {
101
102
  DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${uuid}`,
102
103
  CREATE: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}`,
103
104
  GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.FIND_BY_UUID}/${uuid}`,
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}`,
104
108
  },
105
109
  FILES: {
106
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);
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PayCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var PayCommand;
6
+ (function (PayCommand) {
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
+ }));
42
+ PayCommand.ResponseSchema = zod_1.z.object({
43
+ code: zod_1.z.number(),
44
+ });
45
+ })(PayCommand || (exports.PayCommand = PayCommand = {}));
@@ -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);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLOUD_PAYMENTS_CANCEL = exports.FORMATS = void 0;
4
+ exports.FORMATS = {
5
+ UTF8: 'utf-8',
6
+ BASE64: 'base64',
7
+ SHA256: 'sha256',
8
+ };
9
+ exports.CLOUD_PAYMENTS_CANCEL = 'https://api.cloudpayments.ru/subscriptions/cancel';
@@ -6,4 +6,6 @@ var PAYMENT_STATUS;
6
6
  PAYMENT_STATUS["new"] = "new";
7
7
  PAYMENT_STATUS["success"] = "success";
8
8
  PAYMENT_STATUS["cancelled"] = "cancelled";
9
+ PAYMENT_STATUS["error"] = "error";
10
+ PAYMENT_STATUS["sub_error"] = "sub_error";
9
11
  })(PAYMENT_STATUS || (exports.PAYMENT_STATUS = PAYMENT_STATUS = {}));
@@ -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';
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace PayCommand {
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
+ }));
39
+
40
+ export type Request = z.infer<typeof RequestSchema>;
41
+
42
+ export const ResponseSchema = z.object({
43
+ code: z.number(),
44
+ });
45
+
46
+ export type Response = z.infer<typeof ResponseSchema>;
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';
@@ -0,0 +1,8 @@
1
+ export const FORMATS = {
2
+ UTF8: 'utf-8',
3
+ BASE64: 'base64',
4
+ SHA256: 'sha256',
5
+ } as const;
6
+
7
+ export const CLOUD_PAYMENTS_CANCEL = 'https://api.cloudpayments.ru/subscriptions/cancel';
8
+
@@ -2,4 +2,6 @@ export enum PAYMENT_STATUS {
2
2
  new = 'new',
3
3
  success = 'success',
4
4
  cancelled = 'cancelled',
5
+ error = 'error',
6
+ sub_error = 'sub_error',
5
7
  }
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.7",
3
+ "version": "0.2.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {