@purpleschool/multisite 0.0.19 → 0.0.21

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.
Files changed (85) hide show
  1. package/api/controller/http/payment.ts +1 -0
  2. package/api/controller/http/product.ts +2 -0
  3. package/api/controller/http/subscription.ts +4 -2
  4. package/api/routes.ts +11 -2
  5. package/build/api/controller/http/payment.d.ts +1 -0
  6. package/build/api/controller/http/payment.d.ts.map +1 -1
  7. package/build/api/controller/http/payment.js +1 -0
  8. package/build/api/controller/http/product.d.ts +2 -0
  9. package/build/api/controller/http/product.d.ts.map +1 -1
  10. package/build/api/controller/http/product.js +2 -0
  11. package/build/api/controller/http/subscription.d.ts +4 -2
  12. package/build/api/controller/http/subscription.d.ts.map +1 -1
  13. package/build/api/controller/http/subscription.js +4 -2
  14. package/build/api/routes.d.ts +5 -0
  15. package/build/api/routes.d.ts.map +1 -1
  16. package/build/api/routes.js +7 -2
  17. package/build/commands/payment/index.d.ts +1 -0
  18. package/build/commands/payment/index.d.ts.map +1 -1
  19. package/build/commands/payment/index.js +1 -0
  20. package/build/commands/payment/refund-payment.command.d.ts +20 -0
  21. package/build/commands/payment/refund-payment.command.d.ts.map +1 -0
  22. package/build/commands/payment/refund-payment.command.js +13 -0
  23. package/build/commands/product/delete-product.command.d.ts +20 -0
  24. package/build/commands/product/delete-product.command.d.ts.map +1 -0
  25. package/build/commands/product/delete-product.command.js +13 -0
  26. package/build/commands/product/index.d.ts +2 -0
  27. package/build/commands/product/index.d.ts.map +1 -1
  28. package/build/commands/product/index.js +2 -0
  29. package/build/commands/product/update-product.command.d.ts +116 -0
  30. package/build/commands/product/update-product.command.d.ts.map +1 -0
  31. package/build/commands/product/update-product.command.js +26 -0
  32. package/build/commands/subscription/delete-subscription.command.d.ts +20 -0
  33. package/build/commands/subscription/delete-subscription.command.d.ts.map +1 -0
  34. package/build/commands/subscription/delete-subscription.command.js +13 -0
  35. package/build/commands/subscription/index.d.ts +2 -0
  36. package/build/commands/subscription/index.d.ts.map +1 -1
  37. package/build/commands/subscription/index.js +2 -0
  38. package/build/commands/subscription/update-subscription.command.d.ts +148 -0
  39. package/build/commands/subscription/update-subscription.command.d.ts.map +1 -0
  40. package/build/commands/subscription/update-subscription.command.js +30 -0
  41. package/build/constants/cloud-payments/index.d.ts +1 -0
  42. package/build/constants/cloud-payments/index.d.ts.map +1 -1
  43. package/build/constants/cloud-payments/index.js +2 -1
  44. package/build/constants/errors/errors.d.ts +10 -0
  45. package/build/constants/errors/errors.d.ts.map +1 -1
  46. package/build/constants/errors/errors.js +10 -0
  47. package/build/constants/payment/enums/payment-status.enum.d.ts +2 -1
  48. package/build/constants/payment/enums/payment-status.enum.d.ts.map +1 -1
  49. package/build/constants/payment/enums/payment-status.enum.js +1 -0
  50. package/build/queries/user/find-users.command.d.ts +16 -0
  51. package/build/queries/user/find-users.command.d.ts.map +1 -1
  52. package/build/queries/user/find-users.command.js +2 -0
  53. package/build/queries/user/get-all-users.command.d.ts +11 -1
  54. package/build/queries/user/get-all-users.command.d.ts.map +1 -1
  55. package/build/queries/user/get-all-users.command.js +2 -0
  56. package/build/queries/user/get-my-subscriptions.command.d.ts +5 -0
  57. package/build/queries/user/get-my-subscriptions.command.d.ts.map +1 -1
  58. package/build/queries/user/get-my-subscriptions.command.js +1 -0
  59. package/build/queries/user/get-user-payments.command.d.ts +134 -0
  60. package/build/queries/user/get-user-payments.command.d.ts.map +1 -0
  61. package/build/queries/user/get-user-payments.command.js +27 -0
  62. package/build/queries/user/get-user.command.d.ts +11 -1
  63. package/build/queries/user/get-user.command.d.ts.map +1 -1
  64. package/build/queries/user/get-user.command.js +2 -0
  65. package/build/queries/user/index.d.ts +1 -0
  66. package/build/queries/user/index.d.ts.map +1 -1
  67. package/build/queries/user/index.js +1 -0
  68. package/commands/payment/index.ts +1 -0
  69. package/commands/payment/refund-payment.command.ts +13 -0
  70. package/commands/product/delete-product.command.ts +13 -0
  71. package/commands/product/index.ts +2 -0
  72. package/commands/product/update-product.command.ts +30 -0
  73. package/commands/subscription/delete-subscription.command.ts +13 -0
  74. package/commands/subscription/index.ts +2 -0
  75. package/commands/subscription/update-subscription.command.ts +34 -0
  76. package/constants/cloud-payments/index.ts +1 -0
  77. package/constants/errors/errors.ts +10 -0
  78. package/constants/payment/enums/payment-status.enum.ts +1 -0
  79. package/package.json +1 -1
  80. package/queries/user/find-users.command.ts +2 -0
  81. package/queries/user/get-all-users.command.ts +3 -1
  82. package/queries/user/get-my-subscriptions.command.ts +1 -0
  83. package/queries/user/get-user-payments.command.ts +26 -0
  84. package/queries/user/get-user.command.ts +3 -1
  85. package/queries/user/index.ts +1 -0
@@ -1,22 +1,28 @@
1
1
  import { z } from 'zod';
2
- import { USER_ROLE } from '../../constants';
2
+ import { USER_ROLE, USER_STATUS } from '../../constants';
3
3
  export declare namespace GetUserCommand {
4
4
  const ResponseSchema: z.ZodObject<{
5
5
  data: z.ZodObject<{
6
6
  uuid: z.ZodString;
7
7
  email: z.ZodString;
8
8
  role: z.ZodNativeEnum<typeof USER_ROLE>;
9
+ status: z.ZodNativeEnum<typeof USER_STATUS>;
9
10
  siteId: z.ZodString;
11
+ tokenBonusBalance: z.ZodNumber;
10
12
  }, "strip", z.ZodTypeAny, {
11
13
  email: string;
12
14
  uuid: string;
13
15
  siteId: string;
14
16
  role: USER_ROLE;
17
+ status: USER_STATUS;
18
+ tokenBonusBalance: number;
15
19
  }, {
16
20
  email: string;
17
21
  uuid: string;
18
22
  siteId: string;
19
23
  role: USER_ROLE;
24
+ status: USER_STATUS;
25
+ tokenBonusBalance: number;
20
26
  }>;
21
27
  }, "strip", z.ZodTypeAny, {
22
28
  data: {
@@ -24,6 +30,8 @@ export declare namespace GetUserCommand {
24
30
  uuid: string;
25
31
  siteId: string;
26
32
  role: USER_ROLE;
33
+ status: USER_STATUS;
34
+ tokenBonusBalance: number;
27
35
  };
28
36
  }, {
29
37
  data: {
@@ -31,6 +39,8 @@ export declare namespace GetUserCommand {
31
39
  uuid: string;
32
40
  siteId: string;
33
41
  role: USER_ROLE;
42
+ status: USER_STATUS;
43
+ tokenBonusBalance: number;
34
44
  };
35
45
  }>;
36
46
  type Response = z.infer<typeof ResponseSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"get-user.command.d.ts","sourceRoot":"","sources":["../../../queries/user/get-user.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,yBAAiB,cAAc,CAAC;IACrB,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAOzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
1
+ {"version":3,"file":"get-user.command.d.ts","sourceRoot":"","sources":["../../../queries/user/get-user.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEzD,yBAAiB,cAAc,CAAC;IACrB,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MASzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
@@ -10,7 +10,9 @@ var GetUserCommand;
10
10
  uuid: zod_1.z.string().uuid(),
11
11
  email: zod_1.z.string().email(),
12
12
  role: zod_1.z.nativeEnum(constants_1.USER_ROLE),
13
+ status: zod_1.z.nativeEnum(constants_1.USER_STATUS),
13
14
  siteId: zod_1.z.string().uuid(),
15
+ tokenBonusBalance: zod_1.z.number().int(),
14
16
  }),
15
17
  });
16
18
  })(GetUserCommand || (exports.GetUserCommand = GetUserCommand = {}));
@@ -4,4 +4,5 @@ export * from './get-user-balance.command';
4
4
  export * from './get-my-products.command';
5
5
  export * from './get-my-subscriptions.command';
6
6
  export * from './find-users.command';
7
+ export * from './get-user-payments.command';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../queries/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../queries/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC"}
@@ -20,3 +20,4 @@ __exportStar(require("./get-user-balance.command"), exports);
20
20
  __exportStar(require("./get-my-products.command"), exports);
21
21
  __exportStar(require("./get-my-subscriptions.command"), exports);
22
22
  __exportStar(require("./find-users.command"), exports);
23
+ __exportStar(require("./get-user-payments.command"), exports);
@@ -1 +1,2 @@
1
1
  export * from './cloud-payments.command';
2
+ export * from './refund-payment.command';
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace RefundPaymentCommand {
4
+ export const RequestSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+
9
+ export const ResponseSchema = z.object({
10
+ data: z.boolean(),
11
+ });
12
+ export type Response = z.infer<typeof ResponseSchema>;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace DeleteProductCommand {
4
+ export const RequestParamSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
8
+
9
+ export const ResponseSchema = z.object({
10
+ data: z.boolean(),
11
+ });
12
+ export type Response = z.infer<typeof ResponseSchema>;
13
+ }
@@ -1,2 +1,4 @@
1
1
  export * from './buy-product.command';
2
2
  export * from './fast-buy-product.command';
3
+ export * from './update-product.command';
4
+ export * from './delete-product.command';
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ import { ProductSchema } from '../../models';
3
+
4
+ export namespace UpdateProductCommand {
5
+ export const RequestParamSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ });
8
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
9
+
10
+ export const RequestSchema = z.object({
11
+ name: z.string().min(1).max(200).optional(),
12
+ description: z.string().min(1).max(2000).optional(),
13
+ price: z.number().int().min(0).optional(),
14
+ tokens: z.number().int().min(0).optional(),
15
+ features: z
16
+ .array(
17
+ z.object({
18
+ type: z.string(),
19
+ name: z.string(),
20
+ }),
21
+ )
22
+ .optional(),
23
+ });
24
+ export type Request = z.infer<typeof RequestSchema>;
25
+
26
+ export const ResponseSchema = z.object({
27
+ data: ProductSchema,
28
+ });
29
+ export type Response = z.infer<typeof ResponseSchema>;
30
+ }
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace DeleteSubscriptionCommand {
4
+ export const RequestParamSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
8
+
9
+ export const ResponseSchema = z.object({
10
+ data: z.boolean(),
11
+ });
12
+ export type Response = z.infer<typeof ResponseSchema>;
13
+ }
@@ -2,3 +2,5 @@ export * from './buy-subscription.command';
2
2
  export * from './fast-buy-subscription.command';
3
3
  export * from './cancel-subscription.command';
4
4
  export * from './recover-subscription.command';
5
+ export * from './update-subscription.command';
6
+ export * from './delete-subscription.command';
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+ import { SubscriptionSchema } from '../../models';
3
+
4
+ export namespace UpdateSubscriptionCommand {
5
+ export const RequestParamSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ });
8
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
9
+
10
+ export const RequestSchema = z.object({
11
+ name: z.string().min(1).max(200).optional(),
12
+ description: z.string().min(1).max(2000).optional(),
13
+ price: z.number().int().min(0).optional(),
14
+ interval: z.string().max(20).optional(),
15
+ period: z.number().int().min(1).max(36).optional(),
16
+ tokens: z.number().int().min(0).optional(),
17
+ discount: z.number().int().min(0).optional(),
18
+ features: z
19
+ .array(
20
+ z.object({
21
+ type: z.string(),
22
+ name: z.string(),
23
+ }),
24
+ )
25
+ .optional(),
26
+ carryoverPercent: z.number().int().min(0).max(100).optional(),
27
+ });
28
+ export type Request = z.infer<typeof RequestSchema>;
29
+
30
+ export const ResponseSchema = z.object({
31
+ data: SubscriptionSchema,
32
+ });
33
+ export type Response = z.infer<typeof ResponseSchema>;
34
+ }
@@ -1 +1,2 @@
1
1
  export const CLOUD_PAYMENTS_CANCEL = 'https://api.cloudpayments.ru/subscriptions/cancel';
2
+ export const CLOUD_PAYMENTS_REFUND = 'https://api.cloudpayments.ru/payments/refund';
@@ -221,6 +221,11 @@ export const ERRORS = {
221
221
  code: 'SUBSCRIPTION_007',
222
222
  httpCode: 500,
223
223
  },
224
+ SUBSCRIPTION_REFUND_ERROR: {
225
+ message: 'Ошибка при возврате подписки',
226
+ code: 'SUBSCRIPTION_008',
227
+ httpCode: 500,
228
+ },
224
229
 
225
230
  // ORDER
226
231
  ORDER_NOT_FOUND: {
@@ -255,6 +260,11 @@ export const ERRORS = {
255
260
  code: 'PAYMENT_002',
256
261
  httpCode: 500,
257
262
  },
263
+ PAYMENT_REFUND_ERROR: {
264
+ message: 'Ошибка при возврате платежа',
265
+ code: 'PAYMENT_003',
266
+ httpCode: 500,
267
+ },
258
268
 
259
269
  // TRANSACTION
260
270
  TRANSACTION_WRITE_OFF_ERROR: {
@@ -1,3 +1,4 @@
1
1
  export enum PAYMENT_STATUS {
2
2
  SUCCESS = 'success',
3
+ REFUNDED = 'refunded',
3
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/multisite",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Multisite API contracts (DTO schemas, routes, constants)",
5
5
  "type": "commonjs",
6
6
  "main": "build/index.js",
@@ -17,7 +17,9 @@ export namespace FindUsersCommand {
17
17
  uuid: z.string().uuid(),
18
18
  email: z.string().email(),
19
19
  role: z.nativeEnum(USER_ROLE),
20
+ status: z.nativeEnum(USER_STATUS),
20
21
  siteId: z.string().uuid(),
22
+ tokenBonusBalance: z.number().int(),
21
23
  });
22
24
 
23
25
  export const ResponseSchema = z.object({
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { USER_ROLE } from '../../constants';
2
+ import { USER_ROLE, USER_STATUS } from '../../constants';
3
3
 
4
4
  export namespace GetAllUsersCommand {
5
5
  export const ResponseSchema = z.object({
@@ -8,7 +8,9 @@ export namespace GetAllUsersCommand {
8
8
  uuid: z.string().uuid(),
9
9
  email: z.string().email(),
10
10
  role: z.nativeEnum(USER_ROLE),
11
+ status: z.nativeEnum(USER_STATUS),
11
12
  siteId: z.string().uuid(),
13
+ tokenBonusBalance: z.number().int(),
12
14
  }),
13
15
  ),
14
16
  });
@@ -12,6 +12,7 @@ export namespace GetMySubscriptionsCommand {
12
12
  carriedOverTokenBalance: z.number().int(),
13
13
  status: z.nativeEnum(USER_TO_SUBSCRIPTION_STATUS),
14
14
  active: z.boolean(),
15
+ endDate: z.date().or(z.string().datetime()).nullable(),
15
16
  createdAt: z.date().or(z.string().datetime()),
16
17
  subscription: SubscriptionSchema,
17
18
  }),
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { ORDER_STATUS, ORDER_TYPE, PAYMENT_STATUS } from '../../constants';
3
+
4
+ export namespace GetUserPaymentsCommand {
5
+ export const ResponseItemSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ orderType: z.nativeEnum(ORDER_TYPE),
8
+ orderStatus: z.nativeEnum(ORDER_STATUS),
9
+ description: z.string(),
10
+ productId: z.string().uuid().nullable(),
11
+ productName: z.string().nullable(),
12
+ subscriptionId: z.string().uuid().nullable(),
13
+ subscriptionName: z.string().nullable(),
14
+ paymentStatus: z.nativeEnum(PAYMENT_STATUS),
15
+ userId: z.string().uuid(),
16
+ userEmail: z.string().email(),
17
+ sum: z.number(),
18
+ currency: z.string(),
19
+ updatedAt: z.date().or(z.string().datetime()),
20
+ });
21
+
22
+ export const ResponseSchema = z.object({
23
+ data: z.array(ResponseItemSchema),
24
+ });
25
+ export type Response = z.infer<typeof ResponseSchema>;
26
+ }
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { USER_ROLE } from '../../constants';
2
+ import { USER_ROLE, USER_STATUS } from '../../constants';
3
3
 
4
4
  export namespace GetUserCommand {
5
5
  export const ResponseSchema = z.object({
@@ -7,7 +7,9 @@ export namespace GetUserCommand {
7
7
  uuid: z.string().uuid(),
8
8
  email: z.string().email(),
9
9
  role: z.nativeEnum(USER_ROLE),
10
+ status: z.nativeEnum(USER_STATUS),
10
11
  siteId: z.string().uuid(),
12
+ tokenBonusBalance: z.number().int(),
11
13
  }),
12
14
  });
13
15
  export type Response = z.infer<typeof ResponseSchema>;
@@ -4,3 +4,4 @@ export * from './get-user-balance.command';
4
4
  export * from './get-my-products.command';
5
5
  export * from './get-my-subscriptions.command';
6
6
  export * from './find-users.command';
7
+ export * from './get-user-payments.command';