@purpleschool/gptbot 0.5.8 → 0.5.14

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 (125) hide show
  1. package/api/controllers/index.ts +11 -8
  2. package/api/controllers/payment.ts +5 -0
  3. package/api/controllers/referral.ts +5 -0
  4. package/api/controllers/subscription.ts +3 -0
  5. package/build/api/controllers/index.js +11 -8
  6. package/build/api/controllers/payment.js +7 -0
  7. package/build/api/controllers/referral.js +7 -0
  8. package/build/api/controllers/subscription.js +3 -0
  9. package/build/commands/ai-model/index.js +2 -2
  10. package/build/commands/auth/index.js +4 -3
  11. package/build/commands/auth/register-user.command.js +3 -4
  12. package/build/commands/blog/index.js +2 -2
  13. package/build/commands/category/index.js +2 -2
  14. package/build/commands/chat/index.js +9 -8
  15. package/build/commands/index.js +8 -6
  16. package/build/commands/message/index.js +1 -1
  17. package/build/commands/page/index.js +3 -3
  18. package/build/commands/payment/get-payment-history.command.js +11 -0
  19. package/build/commands/payment/index.js +18 -0
  20. package/build/commands/product/buy-product.command.js +1 -0
  21. package/build/commands/product/index.js +3 -3
  22. package/build/commands/question/index.js +2 -2
  23. package/build/commands/referral/get-by-bonuses.command.js +15 -0
  24. package/build/commands/referral/index.js +17 -0
  25. package/build/commands/subscription/buy-subscription.command.js +1 -0
  26. package/build/commands/subscription/create-custom-subscription-plan.command.js +24 -0
  27. package/build/commands/subscription/find-subscription.command.js +1 -1
  28. package/build/commands/subscription/get-available-upgrades.command.js +13 -0
  29. package/build/commands/subscription/index.js +7 -3
  30. package/build/commands/subscription/upgrade-subscription.command.js +41 -0
  31. package/build/commands/user/index.js +1 -1
  32. package/build/constants/category/enums/index.js +1 -1
  33. package/build/constants/chat/enums/index.js +1 -1
  34. package/build/constants/domains/index.js +17 -0
  35. package/build/constants/email/index.js +18 -0
  36. package/build/constants/errors/errors.js +65 -0
  37. package/build/constants/index.js +13 -7
  38. package/build/constants/order/enums/index.js +1 -0
  39. package/build/constants/order/enums/order-type.enum.js +8 -0
  40. package/build/constants/payment/enums/index.js +1 -0
  41. package/build/constants/payment/enums/payment-history-item-type.enum.js +8 -0
  42. package/build/constants/referral/enums/index.js +17 -0
  43. package/build/constants/referral/enums/referral-bonus-type.enum.js +8 -0
  44. package/build/constants/referral/index.js +17 -0
  45. package/build/constants/subscription/enums/index.js +4 -0
  46. package/build/constants/subscription/enums/subscription-action.enum.js +10 -0
  47. package/build/constants/subscription/enums/subscription-plan.enum.js +8 -0
  48. package/build/constants/subscription/enums/subscription-status.enum.js +1 -0
  49. package/build/constants/subscription/enums/subscription-type.enum.js +8 -0
  50. package/build/constants/subscription/enums/user-to-subscription-type.enum.js +8 -0
  51. package/build/constants/transaction/enums/index.js +17 -0
  52. package/build/constants/transaction/enums/user-balance-status.enum.js +1 -0
  53. package/build/constants/transaction/index.js +17 -0
  54. package/build/constants/user/enums/index.js +17 -0
  55. package/build/constants/user/index.js +18 -0
  56. package/build/helpers/index.js +17 -0
  57. package/build/helpers/subscription/calc-custom-subscription-price.helper.js +19 -0
  58. package/build/helpers/subscription/index.js +17 -0
  59. package/build/index.js +3 -2
  60. package/build/models/index.js +11 -7
  61. package/build/models/message.schema.js +1 -1
  62. package/build/models/payment-history-item.schema.js +14 -0
  63. package/build/models/referral-bonus.schema.js +19 -0
  64. package/build/models/subscription-upgrade-schema.js +8 -0
  65. package/build/models/subscription.schema.js +14 -2
  66. package/build/models/user-to-subscription.schema.js +1 -0
  67. package/commands/ai-model/index.ts +2 -2
  68. package/commands/auth/index.ts +4 -3
  69. package/commands/auth/register-user.command.ts +6 -4
  70. package/commands/blog/index.ts +2 -2
  71. package/commands/category/index.ts +2 -2
  72. package/commands/chat/index.ts +9 -8
  73. package/commands/index.ts +8 -6
  74. package/commands/message/index.ts +1 -1
  75. package/commands/page/index.ts +3 -3
  76. package/commands/payment/get-payment-history.command.ts +10 -0
  77. package/commands/payment/index.ts +2 -0
  78. package/commands/product/buy-product.command.ts +1 -0
  79. package/commands/product/index.ts +3 -3
  80. package/commands/question/index.ts +2 -2
  81. package/commands/referral/get-by-bonuses.command.ts +14 -0
  82. package/commands/referral/index.ts +1 -0
  83. package/commands/subscription/buy-subscription.command.ts +1 -0
  84. package/commands/subscription/create-custom-subscription-plan.command.ts +26 -0
  85. package/commands/subscription/find-subscription.command.ts +2 -2
  86. package/commands/subscription/get-available-upgrades.command.ts +15 -0
  87. package/commands/subscription/index.ts +7 -3
  88. package/commands/subscription/upgrade-subscription.command.ts +46 -0
  89. package/commands/user/index.ts +1 -1
  90. package/constants/category/enums/index.ts +1 -1
  91. package/constants/chat/enums/index.ts +1 -1
  92. package/constants/domains/index.ts +1 -0
  93. package/constants/email/index.ts +2 -0
  94. package/constants/errors/errors.ts +65 -0
  95. package/constants/index.ts +13 -7
  96. package/constants/order/enums/index.ts +1 -0
  97. package/constants/order/enums/order-type.enum.ts +4 -0
  98. package/constants/payment/enums/index.ts +1 -0
  99. package/constants/payment/enums/payment-history-item-type.enum.ts +4 -0
  100. package/constants/referral/enums/index.ts +1 -0
  101. package/constants/referral/enums/referral-bonus-type.enum.ts +4 -0
  102. package/constants/referral/index.ts +1 -0
  103. package/constants/subscription/enums/index.ts +4 -0
  104. package/constants/subscription/enums/subscription-action.enum.ts +6 -0
  105. package/constants/subscription/enums/subscription-plan.enum.ts +4 -0
  106. package/constants/subscription/enums/subscription-status.enum.ts +1 -0
  107. package/constants/subscription/enums/subscription-type.enum.ts +4 -0
  108. package/constants/subscription/enums/user-to-subscription-type.enum.ts +4 -0
  109. package/constants/transaction/enums/index.ts +2 -0
  110. package/constants/transaction/enums/user-balance-status.enum.ts +1 -0
  111. package/constants/transaction/index.ts +1 -0
  112. package/constants/user/enums/index.ts +1 -0
  113. package/constants/user/index.ts +2 -0
  114. package/helpers/index.ts +1 -0
  115. package/helpers/subscription/calc-custom-subscription-price.helper.ts +19 -0
  116. package/helpers/subscription/index.ts +1 -0
  117. package/index.ts +3 -2
  118. package/models/index.ts +11 -7
  119. package/models/message.schema.ts +1 -1
  120. package/models/payment-history-item.schema.ts +12 -0
  121. package/models/referral-bonus.schema.ts +18 -0
  122. package/models/subscription-upgrade-schema.ts +9 -0
  123. package/models/subscription.schema.ts +21 -1
  124. package/models/user-to-subscription.schema.ts +1 -0
  125. package/package.json +1 -1
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { SubscriptionSchema } from '../../models';
3
+
4
+ export namespace CreateCustomSubscriptionPlanCommand {
5
+ export const RequestSchema = z.object({
6
+ tokens: z
7
+ .number()
8
+ .refine((val) => val % 500 === 0, {
9
+ message: 'tokens must be a multiple of 500',
10
+ })
11
+ .refine((val) => val > 1000, {
12
+ message: 'tokens must be greater than 1000',
13
+ })
14
+ .refine((val) => val <= 10000, {
15
+ message: 'tokens must be equal or less than 10000',
16
+ }),
17
+ });
18
+
19
+ export type Request = z.infer<typeof RequestSchema>;
20
+
21
+ export const ResponseSchema = z.object({
22
+ data: SubscriptionSchema,
23
+ });
24
+
25
+ export type Response = z.infer<typeof ResponseSchema>;
26
+ }
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { SubscriptionSchema } from '../../models';
2
+ import { SubscriptionSchema, SubscriptionWithSubTypesSchema } from '../../models';
3
3
 
4
4
  export namespace FindSubscriptionCommand {
5
5
  export const RequestSchema = SubscriptionSchema.pick({
@@ -9,7 +9,7 @@ export namespace FindSubscriptionCommand {
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
- data: z.array(SubscriptionSchema),
12
+ data: z.array(SubscriptionWithSubTypesSchema),
13
13
  });
14
14
 
15
15
  export type Response = z.infer<typeof ResponseSchema>;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { SubscriptionSchema } from '../../models';
3
+ import { SubscriptionUpgradeSchema } from '../../models/subscription-upgrade-schema';
4
+
5
+ export namespace GetAvailableUpgradesCommand {
6
+ export const RequestSchema = SubscriptionSchema.pick({});
7
+
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.array(SubscriptionUpgradeSchema),
12
+ });
13
+
14
+ export type Response = z.infer<typeof ResponseSchema>;
15
+ }
@@ -1,6 +1,10 @@
1
- export * from './update-subscription.command';
2
- export * from './delete-subscription.command';
1
+ export * from './buy-subscription.command';
2
+ export * from './cancel-subscription.command';
3
+ export * from './create-custom-subscription-plan.command';
3
4
  export * from './create-subscription.command';
5
+ export * from './delete-subscription.command';
4
6
  export * from './find-subscription.command';
5
- export * from './cancel-subscription.command';
7
+ export * from './get-available-upgrades.command';
6
8
  export * from './recover-subscription.command';
9
+ export * from './update-subscription.command';
10
+ export * from './upgrade-subscription.command';
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { SubscriptionSchema } from '../../models';
3
+
4
+ export namespace UpgradeSubscriptionCommand {
5
+ export const RequestSchema = SubscriptionSchema.pick({
6
+ uuid: true,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ const IReceiptOrderSchema = z.object({
12
+ items: z.array(
13
+ z.object({
14
+ label: z.string(),
15
+ price: z.number(),
16
+ quantity: z.number(),
17
+ amount: z.number(),
18
+ vat: z.number(),
19
+ }),
20
+ ),
21
+ email: z.string(),
22
+ isBso: z.boolean(),
23
+ amounts: z.object({
24
+ electronic: z.number(),
25
+ }),
26
+ });
27
+
28
+ export const ResponseSchema = z.object({
29
+ publicId: z.string(),
30
+ amount: z.number(),
31
+ currency: z.string(),
32
+ accountId: z.string(),
33
+ description: z.string(),
34
+ invoiceId: z.string(),
35
+ email: z.string(),
36
+ skin: z.string(),
37
+ autoClose: z.number(),
38
+ data: z.object({
39
+ CloudPayments: z.object({
40
+ CustomerReceipt: IReceiptOrderSchema,
41
+ }),
42
+ }),
43
+ });
44
+
45
+ export type Response = z.infer<typeof ResponseSchema>;
46
+ }
@@ -1,3 +1,3 @@
1
+ export * from './check-email.command';
1
2
  export * from './find-user.command';
2
3
  export * from './up-token-bonus-balance.command';
3
- export * from './check-email.command';
@@ -1,2 +1,2 @@
1
- export * from './category-type.enum';
2
1
  export * from './category-content-type.enum';
2
+ export * from './category-type.enum';
@@ -1,3 +1,3 @@
1
1
  export * from './chat-status.enum';
2
- export * from './dalle-image-size.enum';
3
2
  export * from './dalle-image-format.enum';
3
+ export * from './dalle-image-size.enum';
@@ -0,0 +1 @@
1
+ export * from './white-list';
@@ -0,0 +1,2 @@
1
+ export * from './email-endpoint';
2
+ export * from './subjects';
@@ -515,4 +515,69 @@ export const ERRORS = {
515
515
  message: 'Электронная почта уже подтверждена',
516
516
  httpCode: 400,
517
517
  },
518
+ GET_UNREGISTERED_SESSION_ERROR: {
519
+ code: 'A117',
520
+ message: 'Не удалось получить сессию с данным идентификатором',
521
+ httpCode: 500,
522
+ },
523
+ UNREGISTERED_USER_LIMIT_UPDATE_ERROR: {
524
+ code: 'A118',
525
+ message: 'Не удалось обновить баланс пользователя',
526
+ httpCode: 500,
527
+ },
528
+ PAYMENT_HISTORY_ERROR: {
529
+ code: 'A119',
530
+ message: 'Не удалось получить историю платежей',
531
+ httpCode: 500,
532
+ },
533
+ SUBSCRIPTION_GET_UPGRADES_ERROR: {
534
+ code: 'A120',
535
+ message: 'Не удалось получить информацию о возможных улучшениях для подписки',
536
+ httpCode: 500,
537
+ },
538
+ SUBSCRIPTION_UPGRADE_ERROR: {
539
+ code: 'A121',
540
+ message: 'Не удалось улучшить подписку',
541
+ httpCode: 500,
542
+ },
543
+ RECURRENT_UPDATE_ERROR: {
544
+ code: 'A122',
545
+ message: 'Не удалось изменить данные подписки',
546
+ httpCode: 500,
547
+ },
548
+ ALREADY_HAS_SUBSCRIPTION: {
549
+ code: 'A123',
550
+ message: 'На данной учетной записи уже есть подписка',
551
+ httpCode: 409,
552
+ },
553
+ SUBSCRIPTION_UPGRADE_INVALID: {
554
+ code: 'A124',
555
+ message: 'Невозможно улучшить подписку с данными параметрами',
556
+ httpCode: 400,
557
+ },
558
+ PARTNER_NOT_FOUND: {
559
+ code: 'A125',
560
+ message: 'Не удалось найти партнера по реферальной программе',
561
+ httpCode: 404,
562
+ },
563
+ REFERRAL_BONUSES_NOT_FOUND: {
564
+ code: 'A126',
565
+ message: 'Не удалось найти бонусы по реферальной программе',
566
+ httpCode: 404,
567
+ },
568
+ REFERRAL_BONUS_UPDATE_ERROR: {
569
+ code: 'A127',
570
+ message: 'Не удалось обновить бонусы по реферальной программе',
571
+ httpCode: 500,
572
+ },
573
+ REFERRAL_BONUS_STATS_ERROR: {
574
+ code: 'A128',
575
+ message: 'Не удалось получить статистику по бонусам по реферальной программе',
576
+ httpCode: 500,
577
+ },
578
+ REFERRAL_BONUS_APPLY_ERROR: {
579
+ code: 'A129',
580
+ message: 'Не удалось применить бонусы по реферальной программе',
581
+ httpCode: 500,
582
+ },
518
583
  };
@@ -1,10 +1,16 @@
1
+ export * from './ai-model';
2
+ export * from './category';
3
+ export * from './chat';
4
+ export * from './cloud-payments';
5
+ export * from './domains';
6
+ export * from './email';
1
7
  export * from './errors';
2
- export * from './roles';
3
- export * from './payment';
8
+ export * from './message';
4
9
  export * from './order';
5
- export * from './chat';
6
- export * from './subscription';
10
+ export * from './payment';
7
11
  export * from './product';
8
- export * from './category';
9
- export * from './ai-model';
10
- export * from './message';
12
+ export * from './referral';
13
+ export * from './roles';
14
+ export * from './subscription';
15
+ export * from './transaction';
16
+ export * from './user';
@@ -1 +1,2 @@
1
1
  export * from './order-status.enum';
2
+ export * from './order-type.enum';
@@ -0,0 +1,4 @@
1
+ export enum ORDER_TYPE {
2
+ purchase = 'purchase',
3
+ upgrade = 'upgrade',
4
+ }
@@ -1 +1,2 @@
1
+ export * from './payment-history-item-type.enum';
1
2
  export * from './payment-status.enum';
@@ -0,0 +1,4 @@
1
+ export enum PAYMENT_HISTORY_ITEM_TYPE {
2
+ SUBSCRIPTION = 'subscription',
3
+ PRODUCT = 'product',
4
+ }
@@ -0,0 +1 @@
1
+ export * from './referral-bonus-type.enum';
@@ -0,0 +1,4 @@
1
+ export enum ReferralBonusType {
2
+ PARTNER = 'partner',
3
+ REFERRAL = 'referral',
4
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -1 +1,5 @@
1
+ export * from './subscription-action.enum';
2
+ export * from './subscription-plan.enum';
1
3
  export * from './subscription-status.enum';
4
+ export * from './subscription-type.enum';
5
+ export * from './user-to-subscription-type.enum';
@@ -0,0 +1,6 @@
1
+ export enum SUBSCRIPTION_ACTION {
2
+ disabled = 'disabled',
3
+ buy = 'buy',
4
+ upgrade = 'upgrade',
5
+ possible_upgrade = 'possible_upgrade',
6
+ }
@@ -0,0 +1,4 @@
1
+ export enum SUBSCRIPTION_PLAN {
2
+ system = 'system',
3
+ custom = 'custom',
4
+ }
@@ -2,4 +2,5 @@ export enum SUBSCRIPTION_STATUS {
2
2
  active = 'active',
3
3
  canceled = 'canceled',
4
4
  expired = 'expired',
5
+ upgraded = 'upgraded',
5
6
  }
@@ -0,0 +1,4 @@
1
+ export enum SUBSCRIPTION_TYPE {
2
+ main = 'main',
3
+ sub = 'sub',
4
+ }
@@ -0,0 +1,4 @@
1
+ export enum USER_TO_SUBSCRIPTION_TYPE {
2
+ paid = 'paid',
3
+ interval = 'interval',
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from './transaction-status.enum';
2
+ export * from './user-balance-status.enum';
@@ -2,4 +2,5 @@ export enum USER_BALANCE_STATUS {
2
2
  bonus_balance = 'bonus_balance',
3
3
  subscription_balance = 'subscription_balance',
4
4
  product_balance = 'product_balance',
5
+ referral_bonus_balance = 'referral_bonus_balance',
5
6
  }
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -0,0 +1 @@
1
+ export * from './user-status';
@@ -0,0 +1,2 @@
1
+ export * from './enums';
2
+ export * from './user-public';
@@ -0,0 +1 @@
1
+ export * from './subscription';
@@ -0,0 +1,19 @@
1
+ export function calcCustomSubscriptionPrice(tokenCount: number, period: number) {
2
+ const MIN_TOKEN_COUNT = 1000;
3
+ const MAX_DISCOUNT = 0.85;
4
+ const DISCOUNT_PER_STEP = 0.005;
5
+ const STEP = 500;
6
+ const BASE_PRICE = 0.95;
7
+
8
+ if (tokenCount < 0) {
9
+ throw new Error('Token count must be a non-negative integer');
10
+ }
11
+
12
+ if (tokenCount < MIN_TOKEN_COUNT) {
13
+ throw new Error(`Token count must be at least ${MIN_TOKEN_COUNT}`);
14
+ }
15
+
16
+ const discount = Math.max(0, (tokenCount - MIN_TOKEN_COUNT) / STEP) * DISCOUNT_PER_STEP;
17
+ const priceMultiplier = Math.max(BASE_PRICE - discount, MAX_DISCOUNT);
18
+ return Math.round(tokenCount * priceMultiplier * period);
19
+ }
@@ -0,0 +1 @@
1
+ export * from './calc-custom-subscription-price.helper';
package/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from './constants';
2
- export * from './commands';
3
1
  export * from './api';
2
+ export * from './commands';
3
+ export * from './constants';
4
+ export * from './helpers';
4
5
  export * from './models';
package/models/index.ts CHANGED
@@ -1,13 +1,17 @@
1
- export * from './user.schema';
2
- export * from './page.schema';
1
+ export * from './ai-model.schema';
3
2
  export * from './category.schema';
4
- export * from './question.schema';
5
- export * from './unregistered-user.schema';
6
3
  export * from './chat.schema';
7
4
  export * from './message.schema';
8
- export * from './ai-model.schema';
9
- export * from './product.schema';
10
- export * from './subscription.schema';
11
5
  export * from './order.schema';
6
+ export * from './page.schema';
7
+ export * from './payment-history-item.schema';
8
+ export * from './payment.schema';
12
9
  export * from './post.schema';
10
+ export * from './product.schema';
11
+ export * from './question.schema';
12
+ export * from './referral-bonus.schema';
13
+ export * from './subscription-upgrade-schema';
14
+ export * from './subscription.schema';
15
+ export * from './unregistered-user.schema';
13
16
  export * from './user-to-subscription.schema';
17
+ export * from './user.schema';
@@ -8,7 +8,7 @@ import {
8
8
 
9
9
  export const MessageSchema = z.object({
10
10
  uuid: z.string().uuid(),
11
- text: z.string(),
11
+ text: z.string().max(10000),
12
12
  chatId: z.nullable(z.string().uuid()),
13
13
  role: z.string(),
14
14
  tokenUsage: z.number(),
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ import { PAYMENT_HISTORY_ITEM_TYPE, PAYMENT_STATUS } from '../constants';
3
+
4
+ export const PaymentHistoryItemSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ status: z.nativeEnum(PAYMENT_STATUS),
7
+ sum: z.number(),
8
+ description: z.string(),
9
+ type: z.nativeEnum(PAYMENT_HISTORY_ITEM_TYPE),
10
+ createdAt: z.date(),
11
+ updatedAt: z.date(),
12
+ });
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { ReferralBonusType } from '../constants/referral';
3
+
4
+ export const ReferralBonusSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ partnerId: z.string().uuid(),
7
+ referralId: z.string().uuid(),
8
+ initial: z.number(),
9
+ total: z.number(),
10
+ type: z.nativeEnum(ReferralBonusType),
11
+ createdAt: z.date(),
12
+ updatedAt: z.date(),
13
+ });
14
+
15
+ export const ReferralBonusStatisticsSchema = z.object({
16
+ initial: z.number(),
17
+ weekStart: z.date(),
18
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { SubscriptionSchema } from './subscription.schema';
3
+
4
+ export const SubscriptionUpgradeSchema = z.intersection(
5
+ SubscriptionSchema,
6
+ z.object({
7
+ upgradePrice: z.number(),
8
+ }),
9
+ );
@@ -1,13 +1,33 @@
1
1
  import { z } from 'zod';
2
2
  import { FeaturesSchema } from './product.schema';
3
+ import { SUBSCRIPTION_ACTION, SUBSCRIPTION_PLAN, SUBSCRIPTION_TYPE } from '../constants';
3
4
 
4
5
  export const SubscriptionSchema = z.object({
5
6
  uuid: z.string().uuid(),
7
+ mainSubscriptionId: z.nullable(z.string().uuid()),
6
8
  name: z.string().min(3).max(16384),
7
9
  requests: z.number(),
8
10
  price: z.number(),
9
11
  features: z.array(FeaturesSchema),
10
- lengthInDays: z.number(),
12
+ plan: z.nativeEnum(SUBSCRIPTION_PLAN),
13
+ type: z.nativeEnum(SUBSCRIPTION_TYPE),
14
+ discount: z.number(),
15
+ period: z.number(),
16
+ tokens: z.number(),
11
17
  createdAt: z.date(),
12
18
  updatedAt: z.date(),
13
19
  });
20
+
21
+ export const SubscriptionWithActionSchema = z.intersection(
22
+ SubscriptionSchema,
23
+ z.object({
24
+ action: z.nativeEnum(SUBSCRIPTION_ACTION),
25
+ }),
26
+ );
27
+
28
+ export const SubscriptionWithSubTypesSchema = z.intersection(
29
+ SubscriptionWithActionSchema,
30
+ z.object({
31
+ subTypes: z.array(SubscriptionWithActionSchema),
32
+ }),
33
+ );
@@ -9,6 +9,7 @@ export const UserToSubscriptionSchema = z.object({
9
9
  tokenBalance: z.number(),
10
10
  status: z.string(),
11
11
  endDate: z.date().nullable(),
12
+ intervalEndDate: z.date().nullable(),
12
13
  createdAt: z.date(),
13
14
  updatedAt: z.date(),
14
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.8",
3
+ "version": "0.5.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {