@purpleschool/gptbot 0.5.52 → 0.5.54

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 (35) hide show
  1. package/api/controllers/http/blog.ts +2 -0
  2. package/api/controllers/http/product.ts +1 -0
  3. package/api/controllers/http/subscription.ts +1 -0
  4. package/api/routes.ts +7 -4
  5. package/build/api/controllers/http/blog.js +2 -0
  6. package/build/api/controllers/http/product.js +1 -0
  7. package/build/api/controllers/http/subscription.js +1 -0
  8. package/build/api/routes.js +6 -4
  9. package/build/commands/ai-model/find-ai-model.command.js +1 -1
  10. package/build/commands/product/get-my-products.command.js +11 -0
  11. package/build/commands/product/index.js +1 -0
  12. package/build/commands/subscription/get-subscriptions-summary.command.js +13 -0
  13. package/build/commands/subscription/index.js +1 -0
  14. package/build/constants/product/enums/product-status.enum.js +1 -0
  15. package/build/constants/subscription/enums/subscription-plan.enum.js +1 -0
  16. package/build/constants/subscription/enums/user-to-subscription-marks.enum.js +1 -0
  17. package/build/constants/subscription/free-subscription.constant.js +16 -2
  18. package/build/models/ai-model-formatted.schema.js +1 -1
  19. package/build/models/ai-model.schema.js +9 -1
  20. package/build/models/index.js +2 -1
  21. package/build/models/user-to-product.schema.js +19 -0
  22. package/commands/ai-model/find-ai-model.command.ts +2 -2
  23. package/commands/product/get-my-products.command.ts +10 -0
  24. package/commands/product/index.ts +1 -0
  25. package/commands/subscription/get-subscriptions-summary.command.ts +16 -0
  26. package/commands/subscription/index.ts +1 -0
  27. package/constants/product/enums/product-status.enum.ts +1 -0
  28. package/constants/subscription/enums/subscription-plan.enum.ts +1 -0
  29. package/constants/subscription/enums/user-to-subscription-marks.enum.ts +1 -0
  30. package/constants/subscription/free-subscription.constant.ts +22 -2
  31. package/models/ai-model-formatted.schema.ts +1 -1
  32. package/models/ai-model.schema.ts +9 -0
  33. package/models/index.ts +2 -1
  34. package/models/user-to-product.schema.ts +18 -0
  35. package/package.json +1 -1
@@ -4,6 +4,8 @@ export const BLOG_CONTROLLER = (type: POST_TYPE) => `blog/type/${type}` as const
4
4
 
5
5
  export const BLOG_ROUTES = {
6
6
  CREATE: 'create',
7
+ DELETE: (uuid: string) => `${uuid}`,
8
+ UPDATE: (uuid: string) => `${uuid}`,
7
9
  FIND: 'find',
8
10
  FIND_ALL: 'find/all',
9
11
  FIND_BY_UUID: (uuid: string) => `by/uuid/${uuid}`,
@@ -7,4 +7,5 @@ export const PRODUCT_ROUTES = {
7
7
  GET_ALL: 'all',
8
8
  BUY: `buy`,
9
9
  FAST_BUY: `fast/buy`,
10
+ MY: 'my',
10
11
  } as const;
@@ -14,4 +14,5 @@ export const SUBSCRIPTION_ROUTES = {
14
14
  UPGRADE: 'upgrade',
15
15
  CREATE_CUSTOM: 'custom',
16
16
  FREE: 'free',
17
+ SUMMARY: 'summary',
17
18
  } as const;
package/api/routes.ts CHANGED
@@ -103,6 +103,7 @@ export const REST_API = {
103
103
  CREATE: `${ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}`,
104
104
  BUY: (uuid: string) =>
105
105
  `${ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
106
+ MY: `${ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.MY}`,
106
107
  },
107
108
  SUBSCRIPTION_PUBLIC: {
108
109
  GET: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PUBLIC_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -128,6 +129,7 @@ export const REST_API = {
128
129
  GET_AVAILABLE_UPGRADES: (uuid: string) =>
129
130
  `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_AVAILABLE_UPGRADES}`,
130
131
  CREATE_CUSTOM: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CREATE_CUSTOM}`,
132
+ SUMMARY: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.SUMMARY}`,
131
133
  },
132
134
  FILES: {
133
135
  UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -136,9 +138,9 @@ export const REST_API = {
136
138
  BLOG_ARTICLES: {
137
139
  CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}`,
138
140
  PATCH: (uuid: string) =>
139
- `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${uuid}`,
141
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.UPDATE(uuid)}`,
140
142
  DELETE: (uuid: string) =>
141
- `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${uuid}`,
143
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.DELETE(uuid)}`,
142
144
  GET_BY_UUID: (uuid: string) =>
143
145
  `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID(uuid)}`,
144
146
  GET_BY_ALIAS: (alias: string) =>
@@ -150,9 +152,10 @@ export const REST_API = {
150
152
  },
151
153
  BLOG_UPDATES: {
152
154
  CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}`,
153
- PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${uuid}`,
155
+ PATCH: (uuid: string) =>
156
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.UPDATE(uuid)}`,
154
157
  DELETE: (uuid: string) =>
155
- `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${uuid}`,
158
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.DELETE(uuid)}`,
156
159
  GET_BY_UUID: (uuid: string) =>
157
160
  `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID(uuid)}`,
158
161
  GET_BY_ALIAS: (alias: string) =>
@@ -5,6 +5,8 @@ const BLOG_CONTROLLER = (type) => `blog/type/${type}`;
5
5
  exports.BLOG_CONTROLLER = BLOG_CONTROLLER;
6
6
  exports.BLOG_ROUTES = {
7
7
  CREATE: 'create',
8
+ DELETE: (uuid) => `${uuid}`,
9
+ UPDATE: (uuid) => `${uuid}`,
8
10
  FIND: 'find',
9
11
  FIND_ALL: 'find/all',
10
12
  FIND_BY_UUID: (uuid) => `by/uuid/${uuid}`,
@@ -8,4 +8,5 @@ exports.PRODUCT_ROUTES = {
8
8
  GET_ALL: 'all',
9
9
  BUY: `buy`,
10
10
  FAST_BUY: `fast/buy`,
11
+ MY: 'my',
11
12
  };
@@ -15,4 +15,5 @@ exports.SUBSCRIPTION_ROUTES = {
15
15
  UPGRADE: 'upgrade',
16
16
  CREATE_CUSTOM: 'custom',
17
17
  FREE: 'free',
18
+ SUMMARY: 'summary',
18
19
  };
@@ -123,6 +123,7 @@ exports.REST_API = {
123
123
  DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${uuid}`,
124
124
  CREATE: `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}`,
125
125
  BUY: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
126
+ MY: `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.MY}`,
126
127
  },
127
128
  SUBSCRIPTION_PUBLIC: {
128
129
  GET: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PUBLIC_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -141,6 +142,7 @@ exports.REST_API = {
141
142
  UPGRADE: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.UPGRADE}`,
142
143
  GET_AVAILABLE_UPGRADES: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_AVAILABLE_UPGRADES}`,
143
144
  CREATE_CUSTOM: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CREATE_CUSTOM}`,
145
+ SUMMARY: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.SUMMARY}`,
144
146
  },
145
147
  FILES: {
146
148
  UPLOAD_FILE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -148,8 +150,8 @@ exports.REST_API = {
148
150
  },
149
151
  BLOG_ARTICLES: {
150
152
  CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}`,
151
- PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${uuid}`,
152
- DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${uuid}`,
153
+ PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.UPDATE(uuid)}`,
154
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.DELETE(uuid)}`,
153
155
  GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID(uuid)}`,
154
156
  GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS(alias)}`,
155
157
  GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
@@ -159,8 +161,8 @@ exports.REST_API = {
159
161
  },
160
162
  BLOG_UPDATES: {
161
163
  CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}`,
162
- PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${uuid}`,
163
- DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${uuid}`,
164
+ PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.UPDATE(uuid)}`,
165
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.DELETE(uuid)}`,
164
166
  GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID(uuid)}`,
165
167
  GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS(alias)}`,
166
168
  GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
@@ -9,7 +9,7 @@ var FindAIModelCommand;
9
9
  uuid: true,
10
10
  });
11
11
  FindAIModelCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(models_1.AiModelSchema),
12
+ data: zod_1.z.array(models_1.AiModelWithUnlockedBySchema),
13
13
  });
14
14
  FindAIModelCommand.ResponseByUUIDSchema = zod_1.z.object({
15
15
  data: models_1.AiModelSchema,
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetMyProductsCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetMyProductsCommand;
7
+ (function (GetMyProductsCommand) {
8
+ GetMyProductsCommand.ResponseSchema = zod_1.z.object({
9
+ data: zod_1.z.array(models_1.UserToProductWithProductSchema),
10
+ });
11
+ })(GetMyProductsCommand || (exports.GetMyProductsCommand = GetMyProductsCommand = {}));
@@ -18,4 +18,5 @@ __exportStar(require("./buy-product.command"), exports);
18
18
  __exportStar(require("./create-product.command"), exports);
19
19
  __exportStar(require("./delete-product.command"), exports);
20
20
  __exportStar(require("./find-product.command"), exports);
21
+ __exportStar(require("./get-my-products.command"), exports);
21
22
  __exportStar(require("./update-product.command"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSubscriptionsSummaryCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetSubscriptionsSummaryCommand;
7
+ (function (GetSubscriptionsSummaryCommand) {
8
+ GetSubscriptionsSummaryCommand.ResponseSchema = zod_1.z.object({
9
+ features: zod_1.z.array(models_1.SubscriptionFeatureSchema),
10
+ subscriptions: zod_1.z.array(models_1.UserToSubscriptionWithSubscriptionSchema),
11
+ products: zod_1.z.array(models_1.UserToProductWithProductSchema),
12
+ });
13
+ })(GetSubscriptionsSummaryCommand || (exports.GetSubscriptionsSummaryCommand = GetSubscriptionsSummaryCommand = {}));
@@ -22,6 +22,7 @@ __exportStar(require("./delete-subscription.command"), exports);
22
22
  __exportStar(require("./find-subscription.command"), exports);
23
23
  __exportStar(require("./get-available-upgrades.command"), exports);
24
24
  __exportStar(require("./get-free-subscription.command"), exports);
25
+ __exportStar(require("./get-subscriptions-summary.command"), exports);
25
26
  __exportStar(require("./recover-subscription.command"), exports);
26
27
  __exportStar(require("./update-subscription.command"), exports);
27
28
  __exportStar(require("./upgrade-subscription.command"), exports);
@@ -5,4 +5,5 @@ var PRODUCT_STATUS;
5
5
  (function (PRODUCT_STATUS) {
6
6
  PRODUCT_STATUS["active"] = "active";
7
7
  PRODUCT_STATUS["canceled"] = "canceled";
8
+ PRODUCT_STATUS["depleted"] = "depleted";
8
9
  })(PRODUCT_STATUS || (exports.PRODUCT_STATUS = PRODUCT_STATUS = {}));
@@ -5,4 +5,5 @@ var SUBSCRIPTION_PLAN;
5
5
  (function (SUBSCRIPTION_PLAN) {
6
6
  SUBSCRIPTION_PLAN["system"] = "system";
7
7
  SUBSCRIPTION_PLAN["custom"] = "custom";
8
+ SUBSCRIPTION_PLAN["mock"] = "mock";
8
9
  })(SUBSCRIPTION_PLAN || (exports.SUBSCRIPTION_PLAN = SUBSCRIPTION_PLAN = {}));
@@ -4,4 +4,5 @@ exports.USER_TO_SUBSCRIPTION_MARKS = void 0;
4
4
  var USER_TO_SUBSCRIPTION_MARKS;
5
5
  (function (USER_TO_SUBSCRIPTION_MARKS) {
6
6
  USER_TO_SUBSCRIPTION_MARKS["WITHOUT_AUTO_RENEWAL"] = "WITHOUT_AUTO_RENEWAL";
7
+ USER_TO_SUBSCRIPTION_MARKS["MOCK"] = "MOCK";
7
8
  })(USER_TO_SUBSCRIPTION_MARKS || (exports.USER_TO_SUBSCRIPTION_MARKS = USER_TO_SUBSCRIPTION_MARKS = {}));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FREE_SUBSCRIPTION_DATA = void 0;
3
+ exports.FREE_USER_TO_SUBSCRIPTION_DATA = exports.FREE_SUBSCRIPTION_DATA = void 0;
4
4
  const enums_1 = require("./enums");
5
5
  exports.FREE_SUBSCRIPTION_DATA = {
6
6
  uuid: '00000000-0000-0000-0000-000000000000',
@@ -13,9 +13,23 @@ exports.FREE_SUBSCRIPTION_DATA = {
13
13
  discount: 0,
14
14
  maxDiscountPercent: 0,
15
15
  period: 1,
16
- plan: enums_1.SUBSCRIPTION_PLAN.system,
16
+ plan: enums_1.SUBSCRIPTION_PLAN.mock,
17
17
  icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
18
18
  interval: '',
19
19
  createdAt: new Date(),
20
20
  updatedAt: new Date(),
21
21
  };
22
+ exports.FREE_USER_TO_SUBSCRIPTION_DATA = {
23
+ uuid: '00000000-0000-0000-0000-000000000000',
24
+ userId: '00000000-0000-0000-0000-000000000000',
25
+ subscriptionId: '00000000-0000-0000-0000-000000000000',
26
+ initTokenBalance: 0,
27
+ active: true,
28
+ tokenBalance: 0,
29
+ status: enums_1.SUBSCRIPTION_STATUS.active,
30
+ endDate: null,
31
+ marks: [enums_1.USER_TO_SUBSCRIPTION_MARKS.MOCK],
32
+ intervalEndDate: null,
33
+ createdAt: new Date(),
34
+ updatedAt: new Date(),
35
+ };
@@ -4,4 +4,4 @@ exports.AiModelFormmattedSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const ai_model_schema_1 = require("./ai-model.schema");
6
6
  const page_schema_1 = require("./page.schema");
7
- exports.AiModelFormmattedSchema = zod_1.z.intersection(ai_model_schema_1.AiModelSchema, zod_1.z.object({ page: page_schema_1.PageSchema.pick({ alias: true }).optional() }));
7
+ exports.AiModelFormmattedSchema = zod_1.z.intersection(ai_model_schema_1.AiModelSchema, zod_1.z.object({ page: page_schema_1.PageSchema.pick({ alias: true }).optional().nullable() }));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AiModelSchema = void 0;
3
+ exports.AiModelWithUnlockedBySchema = exports.AiModelSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
6
  exports.AiModelSchema = zod_1.z.object({
@@ -21,3 +21,11 @@ exports.AiModelSchema = zod_1.z.object({
21
21
  createdAt: zod_1.z.date(),
22
22
  updatedAt: zod_1.z.date(),
23
23
  });
24
+ exports.AiModelWithUnlockedBySchema = exports.AiModelSchema.extend({
25
+ unlockedBy: zod_1.z
26
+ .object({
27
+ uuid: zod_1.z.string().uuid(),
28
+ name: zod_1.z.string(),
29
+ })
30
+ .nullable(),
31
+ });
@@ -33,6 +33,7 @@ __exportStar(require("./payment-history-item.schema"), exports);
33
33
  __exportStar(require("./payment.schema"), exports);
34
34
  __exportStar(require("./post.schema"), exports);
35
35
  __exportStar(require("./product.schema"), exports);
36
+ __exportStar(require("./promocode.schema"), exports);
36
37
  __exportStar(require("./question.schema"), exports);
37
38
  __exportStar(require("./referral-bonus.schema"), exports);
38
39
  __exportStar(require("./section.schema"), exports);
@@ -42,6 +43,6 @@ __exportStar(require("./subscription.schema"), exports);
42
43
  __exportStar(require("./telegram-user-data.schema"), exports);
43
44
  __exportStar(require("./unregistered-user.schema"), exports);
44
45
  __exportStar(require("./user-task.schema"), exports);
46
+ __exportStar(require("./user-to-product.schema"), exports);
45
47
  __exportStar(require("./user-to-subscription.schema"), exports);
46
48
  __exportStar(require("./user.schema"), exports);
47
- __exportStar(require("./promocode.schema"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserToProductWithProductSchema = exports.UserToProductSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const product_schema_1 = require("./product.schema");
6
+ const constants_1 = require("../constants");
7
+ exports.UserToProductSchema = zod_1.z.object({
8
+ uuid: zod_1.z.string().uuid(),
9
+ userId: zod_1.z.string().uuid(),
10
+ productId: zod_1.z.string().uuid(),
11
+ initTokenBalance: zod_1.z.number(),
12
+ tokenBalance: zod_1.z.number(),
13
+ status: zod_1.z.nativeEnum(constants_1.PRODUCT_STATUS),
14
+ createdAt: zod_1.z.date(),
15
+ updatedAt: zod_1.z.date(),
16
+ });
17
+ exports.UserToProductWithProductSchema = exports.UserToProductSchema.extend({
18
+ product: product_schema_1.ProductSchema,
19
+ });
@@ -1,4 +1,4 @@
1
- import { AiModelSchema } from '../../models';
1
+ import { AiModelSchema, AiModelWithUnlockedBySchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindAIModelCommand {
@@ -9,7 +9,7 @@ export namespace FindAIModelCommand {
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
- data: z.array(AiModelSchema),
12
+ data: z.array(AiModelWithUnlockedBySchema),
13
13
  });
14
14
 
15
15
  export type Response = z.infer<typeof ResponseSchema>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { UserToProductWithProductSchema } from '../../models';
3
+
4
+ export namespace GetMyProductsCommand {
5
+ export const ResponseSchema = z.object({
6
+ data: z.array(UserToProductWithProductSchema),
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -2,4 +2,5 @@ export * from './buy-product.command';
2
2
  export * from './create-product.command';
3
3
  export * from './delete-product.command';
4
4
  export * from './find-product.command';
5
+ export * from './get-my-products.command';
5
6
  export * from './update-product.command';
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ SubscriptionFeatureSchema,
4
+ UserToProductWithProductSchema,
5
+ UserToSubscriptionWithSubscriptionSchema,
6
+ } from '../../models';
7
+
8
+ export namespace GetSubscriptionsSummaryCommand {
9
+ export const ResponseSchema = z.object({
10
+ features: z.array(SubscriptionFeatureSchema),
11
+ subscriptions: z.array(UserToSubscriptionWithSubscriptionSchema),
12
+ products: z.array(UserToProductWithProductSchema),
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -6,6 +6,7 @@ export * from './delete-subscription.command';
6
6
  export * from './find-subscription.command';
7
7
  export * from './get-available-upgrades.command';
8
8
  export * from './get-free-subscription.command';
9
+ export * from './get-subscriptions-summary.command';
9
10
  export * from './recover-subscription.command';
10
11
  export * from './update-subscription.command';
11
12
  export * from './upgrade-subscription.command';
@@ -1,4 +1,5 @@
1
1
  export enum PRODUCT_STATUS {
2
2
  active = 'active',
3
3
  canceled = 'canceled',
4
+ depleted = 'depleted',
4
5
  }
@@ -1,4 +1,5 @@
1
1
  export enum SUBSCRIPTION_PLAN {
2
2
  system = 'system',
3
3
  custom = 'custom',
4
+ mock = 'mock', // Does not exist in DB
4
5
  }
@@ -1,3 +1,4 @@
1
1
  export enum USER_TO_SUBSCRIPTION_MARKS {
2
2
  WITHOUT_AUTO_RENEWAL = 'WITHOUT_AUTO_RENEWAL',
3
+ MOCK = 'MOCK',
3
4
  }
@@ -1,4 +1,9 @@
1
- import { SUBSCRIPTION_PLAN, SUBSCRIPTION_TYPE } from './enums';
1
+ import {
2
+ SUBSCRIPTION_PLAN,
3
+ SUBSCRIPTION_STATUS,
4
+ SUBSCRIPTION_TYPE,
5
+ USER_TO_SUBSCRIPTION_MARKS,
6
+ } from './enums';
2
7
 
3
8
  export const FREE_SUBSCRIPTION_DATA = {
4
9
  uuid: '00000000-0000-0000-0000-000000000000',
@@ -11,9 +16,24 @@ export const FREE_SUBSCRIPTION_DATA = {
11
16
  discount: 0,
12
17
  maxDiscountPercent: 0,
13
18
  period: 1,
14
- plan: SUBSCRIPTION_PLAN.system,
19
+ plan: SUBSCRIPTION_PLAN.mock,
15
20
  icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
16
21
  interval: '',
17
22
  createdAt: new Date(),
18
23
  updatedAt: new Date(),
19
24
  };
25
+
26
+ export const FREE_USER_TO_SUBSCRIPTION_DATA = {
27
+ uuid: '00000000-0000-0000-0000-000000000000',
28
+ userId: '00000000-0000-0000-0000-000000000000',
29
+ subscriptionId: '00000000-0000-0000-0000-000000000000',
30
+ initTokenBalance: 0,
31
+ active: true,
32
+ tokenBalance: 0,
33
+ status: SUBSCRIPTION_STATUS.active,
34
+ endDate: null,
35
+ marks: [USER_TO_SUBSCRIPTION_MARKS.MOCK],
36
+ intervalEndDate: null,
37
+ createdAt: new Date(),
38
+ updatedAt: new Date(),
39
+ };
@@ -4,5 +4,5 @@ import { PageSchema } from './page.schema';
4
4
 
5
5
  export const AiModelFormmattedSchema = z.intersection(
6
6
  AiModelSchema,
7
- z.object({ page: PageSchema.pick({ alias: true }).optional() }),
7
+ z.object({ page: PageSchema.pick({ alias: true }).optional().nullable() }),
8
8
  );
@@ -24,3 +24,12 @@ export const AiModelSchema = z.object({
24
24
  createdAt: z.date(),
25
25
  updatedAt: z.date(),
26
26
  });
27
+
28
+ export const AiModelWithUnlockedBySchema = AiModelSchema.extend({
29
+ unlockedBy: z
30
+ .object({
31
+ uuid: z.string().uuid(),
32
+ name: z.string(),
33
+ })
34
+ .nullable(),
35
+ });
package/models/index.ts CHANGED
@@ -17,6 +17,7 @@ export * from './payment-history-item.schema';
17
17
  export * from './payment.schema';
18
18
  export * from './post.schema';
19
19
  export * from './product.schema';
20
+ export * from './promocode.schema';
20
21
  export * from './question.schema';
21
22
  export * from './referral-bonus.schema';
22
23
  export * from './section.schema';
@@ -26,6 +27,6 @@ export * from './subscription.schema';
26
27
  export * from './telegram-user-data.schema';
27
28
  export * from './unregistered-user.schema';
28
29
  export * from './user-task.schema';
30
+ export * from './user-to-product.schema';
29
31
  export * from './user-to-subscription.schema';
30
32
  export * from './user.schema';
31
- export * from './promocode.schema';
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { ProductSchema } from './product.schema';
3
+ import { PRODUCT_STATUS } from '../constants';
4
+
5
+ export const UserToProductSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ userId: z.string().uuid(),
8
+ productId: z.string().uuid(),
9
+ initTokenBalance: z.number(),
10
+ tokenBalance: z.number(),
11
+ status: z.nativeEnum(PRODUCT_STATUS),
12
+ createdAt: z.date(),
13
+ updatedAt: z.date(),
14
+ });
15
+
16
+ export const UserToProductWithProductSchema = UserToProductSchema.extend({
17
+ product: ProductSchema,
18
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.52",
3
+ "version": "0.5.54",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",