@purpleschool/gptbot 0.5.43 → 0.5.45

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 (43) hide show
  1. package/api/controllers/http/blog.ts +6 -3
  2. package/api/controllers/http/files.ts +4 -0
  3. package/api/controllers/http/referral.ts +2 -1
  4. package/api/routes.ts +25 -8
  5. package/build/api/controllers/http/blog.js +5 -3
  6. package/build/api/controllers/http/files.js +4 -0
  7. package/build/api/controllers/http/referral.js +3 -2
  8. package/build/api/routes.js +20 -8
  9. package/build/commands/blog/create-post.command.js +3 -0
  10. package/build/commands/blog/find-all-posts.command.js +11 -0
  11. package/build/commands/blog/find-post-by-alias.command.js +1 -1
  12. package/build/commands/blog/find-post-by-uuid.command.js +1 -1
  13. package/build/commands/blog/find-posts.command.js +17 -0
  14. package/build/commands/blog/get-latest-updates.command.js +14 -0
  15. package/build/commands/blog/index.js +3 -1
  16. package/build/commands/file/delete-user-file.command.js +12 -0
  17. package/build/commands/file/index.js +1 -0
  18. package/build/constants/blog/enums/index.js +17 -0
  19. package/build/constants/blog/enums/post-type.enum.js +8 -0
  20. package/build/constants/blog/index.js +17 -0
  21. package/build/constants/domains/white-list.js +2 -1
  22. package/build/constants/file/file.constants.js +2 -1
  23. package/build/constants/index.js +1 -0
  24. package/build/models/post.schema.js +2 -0
  25. package/commands/blog/create-post.command.ts +5 -0
  26. package/commands/blog/find-all-posts.command.ts +10 -0
  27. package/commands/blog/find-post-by-alias.command.ts +1 -1
  28. package/commands/blog/find-post-by-uuid.command.ts +2 -2
  29. package/commands/blog/find-posts.command.ts +19 -0
  30. package/commands/blog/get-latest-updates.command.ts +16 -0
  31. package/commands/blog/index.ts +3 -1
  32. package/commands/file/delete-user-file.command.ts +12 -0
  33. package/commands/file/index.ts +1 -0
  34. package/constants/blog/enums/index.ts +1 -0
  35. package/constants/blog/enums/post-type.enum.ts +4 -0
  36. package/constants/blog/index.ts +1 -0
  37. package/constants/domains/white-list.ts +2 -0
  38. package/constants/file/file.constants.ts +2 -0
  39. package/constants/index.ts +1 -0
  40. package/models/post.schema.ts +2 -0
  41. package/package.json +1 -1
  42. package/build/commands/blog/find-post.command.js +0 -23
  43. package/commands/blog/find-post.command.ts +0 -28
@@ -1,9 +1,12 @@
1
- export const BLOG_CONTROLLER = 'blog' as const;
1
+ import { POST_TYPE } from '../../../constants';
2
+
3
+ export const BLOG_CONTROLLER = (type: POST_TYPE) => `blog/type/${type}` as const;
2
4
 
3
5
  export const BLOG_ROUTES = {
4
6
  CREATE: 'create',
5
7
  FIND: 'find',
6
8
  FIND_ALL: 'find/all',
7
- FIND_BY_UUID: 'by/uuid',
8
- FIND_BY_ALIAS: 'by/alias',
9
+ FIND_BY_UUID: (uuid: string) => `by/uuid/${uuid}`,
10
+ FIND_BY_ALIAS: (alias: string) => `by/alias/${alias}`,
11
+ LATEST: 'latest',
9
12
  } as const;
@@ -1,7 +1,11 @@
1
1
  export const FILE_CONTROLLER = 'file' as const;
2
2
 
3
3
  export const FILE_ROUTES = {
4
+ DELETE: (uuid: string) => `${uuid}`,
4
5
  UPLOAD: 'upload',
5
6
  UPLOAD_FILE: 'upload-file',
6
7
  UPLOAD_IMAGE: 'upload-image',
8
+ CRON: {
9
+ DELETE_UNUSED: 'cron/delete-unused',
10
+ },
7
11
  } as const;
@@ -1,4 +1,5 @@
1
- export const REFERRAL_CONTROLLER = 'referral' as const;
1
+ export const REFERRAL_PRIVATE_CONTROLLER = 'private/referral' as const;
2
+ export const REFERRAL_PUBLIC_CONTROLLER = 'public/referral' as const;
2
3
 
3
4
  export const REFERRAL_ROUTES = {
4
5
  GET_MY_BONUSES: 'bonuses/my',
package/api/routes.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { POST_TYPE } from '../constants';
1
2
  import * as CONTROLLERS from './controllers';
2
3
 
3
4
  export const ROOT = '/api' as const;
@@ -125,16 +126,32 @@ export const REST_API = {
125
126
  UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
126
127
  UPLOAD_IMAGE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_IMAGE}`,
127
128
  },
128
- BLOG: {
129
- CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}`,
130
- PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${uuid}`,
131
- DELETE: (uuid: string) => `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${uuid}`,
129
+ BLOG_ARTICLES: {
130
+ CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}`,
131
+ PATCH: (uuid: string) =>
132
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${uuid}`,
133
+ DELETE: (uuid: string) =>
134
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${uuid}`,
132
135
  GET_BY_UUID: (uuid: string) =>
133
- `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
136
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
134
137
  GET_BY_ALIAS: (alias: string) =>
135
- `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
136
- GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
137
- GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
138
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
139
+ GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
140
+ GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
141
+ LATEST: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
142
+ },
143
+ BLOG_UPDATES: {
144
+ CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}`,
145
+ PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${uuid}`,
146
+ DELETE: (uuid: string) =>
147
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${uuid}`,
148
+ GET_BY_UUID: (uuid: string) =>
149
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
150
+ GET_BY_ALIAS: (alias: string) =>
151
+ `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
152
+ GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
153
+ GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
154
+ LATEST: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
138
155
  },
139
156
  PROMOCODE: {
140
157
  CREATE: `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BLOG_ROUTES = exports.BLOG_CONTROLLER = void 0;
4
- exports.BLOG_CONTROLLER = 'blog';
4
+ const BLOG_CONTROLLER = (type) => `blog/type/${type}`;
5
+ exports.BLOG_CONTROLLER = BLOG_CONTROLLER;
5
6
  exports.BLOG_ROUTES = {
6
7
  CREATE: 'create',
7
8
  FIND: 'find',
8
9
  FIND_ALL: 'find/all',
9
- FIND_BY_UUID: 'by/uuid',
10
- FIND_BY_ALIAS: 'by/alias',
10
+ FIND_BY_UUID: (uuid) => `by/uuid/${uuid}`,
11
+ FIND_BY_ALIAS: (alias) => `by/alias/${alias}`,
12
+ LATEST: 'latest',
11
13
  };
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FILE_ROUTES = exports.FILE_CONTROLLER = void 0;
4
4
  exports.FILE_CONTROLLER = 'file';
5
5
  exports.FILE_ROUTES = {
6
+ DELETE: (uuid) => `${uuid}`,
6
7
  UPLOAD: 'upload',
7
8
  UPLOAD_FILE: 'upload-file',
8
9
  UPLOAD_IMAGE: 'upload-image',
10
+ CRON: {
11
+ DELETE_UNUSED: 'cron/delete-unused',
12
+ },
9
13
  };
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REFERRAL_ROUTES = exports.REFERRAL_CONTROLLER = void 0;
4
- exports.REFERRAL_CONTROLLER = 'referral';
3
+ exports.REFERRAL_ROUTES = exports.REFERRAL_PUBLIC_CONTROLLER = exports.REFERRAL_PRIVATE_CONTROLLER = void 0;
4
+ exports.REFERRAL_PRIVATE_CONTROLLER = 'private/referral';
5
+ exports.REFERRAL_PUBLIC_CONTROLLER = 'public/referral';
5
6
  exports.REFERRAL_ROUTES = {
6
7
  GET_MY_BONUSES: 'bonuses/my',
7
8
  VALIDATE: 'validate/users',
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.REST_API = exports.ROOT = void 0;
37
+ const constants_1 = require("../constants");
37
38
  const CONTROLLERS = __importStar(require("./controllers"));
38
39
  exports.ROOT = '/api';
39
40
  exports.REST_API = {
@@ -140,14 +141,25 @@ exports.REST_API = {
140
141
  UPLOAD_FILE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
141
142
  UPLOAD_IMAGE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_IMAGE}`,
142
143
  },
143
- BLOG: {
144
- CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}`,
145
- PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${uuid}`,
146
- DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${uuid}`,
147
- GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
148
- GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
149
- GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
150
- GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
144
+ BLOG_ARTICLES: {
145
+ CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}`,
146
+ PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${uuid}`,
147
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${uuid}`,
148
+ GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
149
+ GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
150
+ GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
151
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
152
+ LATEST: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
153
+ },
154
+ BLOG_UPDATES: {
155
+ CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}`,
156
+ PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${uuid}`,
157
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${uuid}`,
158
+ GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
159
+ GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
160
+ GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
161
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
162
+ LATEST: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
151
163
  },
152
164
  PROMOCODE: {
153
165
  CREATE: `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
@@ -11,6 +11,9 @@ var CreatePostCommand;
11
11
  createdAt: true,
12
12
  updatedAt: true,
13
13
  });
14
+ CreatePostCommand.RequestParamSchema = models_1.PostSchema.pick({
15
+ type: true,
16
+ });
14
17
  CreatePostCommand.ResponseSchema = zod_1.z.object({
15
18
  data: models_1.PostSchema,
16
19
  });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindAllPostsCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindAllPostsCommand;
7
+ (function (FindAllPostsCommand) {
8
+ FindAllPostsCommand.ResponseSchema = zod_1.z.object({
9
+ data: zod_1.z.array(models_1.PostSchema),
10
+ });
11
+ })(FindAllPostsCommand || (exports.FindAllPostsCommand = FindAllPostsCommand = {}));
@@ -9,7 +9,7 @@ var FindPostByAliasCommand;
9
9
  alias: true,
10
10
  });
11
11
  FindPostByAliasCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(models_1.PostSchema),
12
+ data: models_1.PostSchema,
13
13
  });
14
14
  FindPostByAliasCommand.ResponseByAliasSchema = zod_1.z.object({
15
15
  data: models_1.PostSchema,
@@ -8,7 +8,7 @@ var FindPostByUUIDCommand;
8
8
  FindPostByUUIDCommand.RequestSchema = models_1.PostSchema.pick({
9
9
  uuid: true,
10
10
  });
11
- FindPostByUUIDCommand.ResponseByUUIDSchema = zod_1.z.object({
11
+ FindPostByUUIDCommand.Responsechema = zod_1.z.object({
12
12
  data: models_1.PostSchema,
13
13
  });
14
14
  })(FindPostByUUIDCommand || (exports.FindPostByUUIDCommand = FindPostByUUIDCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindPostsCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var FindPostsCommand;
7
+ (function (FindPostsCommand) {
8
+ FindPostsCommand.RequestQuerySchema = zod_1.z.object({
9
+ limit: zod_1.z.string().transform((val) => parseInt(val, 10)),
10
+ offset: zod_1.z.string().transform((val) => parseInt(val, 10)),
11
+ });
12
+ FindPostsCommand.ResponseSchema = zod_1.z.object({
13
+ posts: zod_1.z.array(models_1.PostSchema),
14
+ totalPage: zod_1.z.number(),
15
+ page: zod_1.z.number(),
16
+ });
17
+ })(FindPostsCommand || (exports.FindPostsCommand = FindPostsCommand = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetLatestUpdatesCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var GetLatestUpdatesCommand;
7
+ (function (GetLatestUpdatesCommand) {
8
+ GetLatestUpdatesCommand.RequestQuerySchema = zod_1.z.object({
9
+ limit: zod_1.z.coerce.number().default(10),
10
+ });
11
+ GetLatestUpdatesCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.array(models_1.PostSchema),
13
+ });
14
+ })(GetLatestUpdatesCommand || (exports.GetLatestUpdatesCommand = GetLatestUpdatesCommand = {}));
@@ -16,7 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./create-post.command"), exports);
18
18
  __exportStar(require("./delete-post.command"), exports);
19
+ __exportStar(require("./find-all-posts.command"), exports);
19
20
  __exportStar(require("./find-post-by-alias.command"), exports);
20
21
  __exportStar(require("./find-post-by-uuid.command"), exports);
21
- __exportStar(require("./find-post.command"), exports);
22
+ __exportStar(require("./find-posts.command"), exports);
23
+ __exportStar(require("./get-latest-updates.command"), exports);
22
24
  __exportStar(require("./update-post.command"), exports);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteUserFileCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var DeleteUserFileCommand;
7
+ (function (DeleteUserFileCommand) {
8
+ DeleteUserFileCommand.RequestParamsSchema = models_1.FileSchema.pick({
9
+ uuid: true,
10
+ });
11
+ DeleteUserFileCommand.ResponseSchema = zod_1.z.void();
12
+ })(DeleteUserFileCommand || (exports.DeleteUserFileCommand = DeleteUserFileCommand = {}));
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./delete-user-file.command"), exports);
17
18
  __exportStar(require("./upload.command"), exports);
@@ -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("./post-type.enum"), exports);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POST_TYPE = void 0;
4
+ var POST_TYPE;
5
+ (function (POST_TYPE) {
6
+ POST_TYPE["ARTICLE"] = "article";
7
+ POST_TYPE["UPDATE"] = "update";
8
+ })(POST_TYPE || (exports.POST_TYPE = POST_TYPE = {}));
@@ -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("./enums"), exports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WHITE_LIST = void 0;
3
+ exports.EMAIL_STUDENT_DOMAINS = exports.WHITE_LIST = void 0;
4
4
  exports.WHITE_LIST = [
5
5
  'mail.ru',
6
6
  'yandex.ru',
@@ -53,3 +53,4 @@ exports.WHITE_LIST = [
53
53
  'ymail.com',
54
54
  'hushmail.com',
55
55
  ];
56
+ exports.EMAIL_STUDENT_DOMAINS = ['edu', 'study', 'student'];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VALID_MIMETYPES = exports.IMAGE_MIMETYPES = exports.MAX_UPLOAD_SIZE = void 0;
3
+ exports.DELETE_UNUSED_FILES_AFTER_HOURS = exports.VALID_MIMETYPES = exports.IMAGE_MIMETYPES = exports.MAX_UPLOAD_SIZE = void 0;
4
4
  exports.MAX_UPLOAD_SIZE = 5 * 1024 * 1024; // 5MB
5
5
  exports.IMAGE_MIMETYPES = ['image/jpeg', 'image/png', 'image/webp'];
6
6
  exports.VALID_MIMETYPES = [...exports.IMAGE_MIMETYPES];
7
+ exports.DELETE_UNUSED_FILES_AFTER_HOURS = 12;
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ai-model"), exports);
18
+ __exportStar(require("./blog"), exports);
18
19
  __exportStar(require("./category"), exports);
19
20
  __exportStar(require("./chat"), exports);
20
21
  __exportStar(require("./cloud-payments"), exports);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PostSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
5
6
  exports.PostSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
8
  title: zod_1.z.string(),
@@ -13,6 +14,7 @@ exports.PostSchema = zod_1.z.object({
13
14
  metaTitle: zod_1.z.nullable(zod_1.z.string()),
14
15
  metaDescription: zod_1.z.nullable(zod_1.z.string()),
15
16
  views: zod_1.z.number(),
17
+ type: zod_1.z.nativeEnum(constants_1.POST_TYPE),
16
18
  createdAt: zod_1.z.date(),
17
19
  updatedAt: zod_1.z.date(),
18
20
  });
@@ -10,6 +10,11 @@ export namespace CreatePostCommand {
10
10
  });
11
11
  export type Request = z.infer<typeof RequestSchema>;
12
12
 
13
+ export const RequestParamSchema = PostSchema.pick({
14
+ type: true,
15
+ });
16
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
17
+
13
18
  export const ResponseSchema = z.object({
14
19
  data: PostSchema,
15
20
  });
@@ -0,0 +1,10 @@
1
+ import { PostSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindAllPostsCommand {
5
+ export const ResponseSchema = z.object({
6
+ data: z.array(PostSchema),
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -9,7 +9,7 @@ export namespace FindPostByAliasCommand {
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
- data: z.array(PostSchema),
12
+ data: PostSchema,
13
13
  });
14
14
 
15
15
  export type Response = z.infer<typeof ResponseSchema>;
@@ -8,9 +8,9 @@ export namespace FindPostByUUIDCommand {
8
8
 
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
- export const ResponseByUUIDSchema = z.object({
11
+ export const Responsechema = z.object({
12
12
  data: PostSchema,
13
13
  });
14
14
 
15
- export type Response = z.infer<typeof ResponseByUUIDSchema>;
15
+ export type Response = z.infer<typeof Responsechema>;
16
16
  }
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { PostSchema } from '../../models';
3
+
4
+ export namespace FindPostsCommand {
5
+ export const RequestQuerySchema = z.object({
6
+ limit: z.string().transform((val) => parseInt(val, 10)),
7
+ offset: z.string().transform((val) => parseInt(val, 10)),
8
+ });
9
+
10
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
11
+
12
+ export const ResponseSchema = z.object({
13
+ posts: z.array(PostSchema),
14
+ totalPage: z.number(),
15
+ page: z.number(),
16
+ });
17
+
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -0,0 +1,16 @@
1
+ import { PostSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace GetLatestUpdatesCommand {
5
+ export const RequestQuerySchema = z.object({
6
+ limit: z.coerce.number().default(10),
7
+ });
8
+
9
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.array(PostSchema),
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -1,6 +1,8 @@
1
1
  export * from './create-post.command';
2
2
  export * from './delete-post.command';
3
+ export * from './find-all-posts.command';
3
4
  export * from './find-post-by-alias.command';
4
5
  export * from './find-post-by-uuid.command';
5
- export * from './find-post.command';
6
+ export * from './find-posts.command';
7
+ export * from './get-latest-updates.command';
6
8
  export * from './update-post.command';
@@ -0,0 +1,12 @@
1
+ import { FileSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace DeleteUserFileCommand {
5
+ export const RequestParamsSchema = FileSchema.pick({
6
+ uuid: true,
7
+ });
8
+
9
+ export const ResponseSchema = z.void();
10
+
11
+ export type Response = z.infer<typeof ResponseSchema>;
12
+ }
@@ -1 +1,2 @@
1
+ export * from './delete-user-file.command';
1
2
  export * from './upload.command';
@@ -0,0 +1 @@
1
+ export * from './post-type.enum';
@@ -0,0 +1,4 @@
1
+ export enum POST_TYPE {
2
+ ARTICLE = 'article',
3
+ UPDATE = 'update',
4
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -50,3 +50,5 @@ export const WHITE_LIST = [
50
50
  'ymail.com',
51
51
  'hushmail.com',
52
52
  ];
53
+
54
+ export const EMAIL_STUDENT_DOMAINS = ['edu', 'study', 'student'];
@@ -3,3 +3,5 @@ export const MAX_UPLOAD_SIZE = 5 * 1024 * 1024; // 5MB
3
3
  export const IMAGE_MIMETYPES = ['image/jpeg', 'image/png', 'image/webp'];
4
4
 
5
5
  export const VALID_MIMETYPES = [...IMAGE_MIMETYPES];
6
+
7
+ export const DELETE_UNUSED_FILES_AFTER_HOURS = 12;
@@ -1,4 +1,5 @@
1
1
  export * from './ai-model';
2
+ export * from './blog';
2
3
  export * from './category';
3
4
  export * from './chat';
4
5
  export * from './cloud-payments';
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { POST_TYPE } from '../constants';
2
3
 
3
4
  export const PostSchema = z.object({
4
5
  uuid: z.string().uuid(),
@@ -11,6 +12,7 @@ export const PostSchema = z.object({
11
12
  metaTitle: z.nullable(z.string()),
12
13
  metaDescription: z.nullable(z.string()),
13
14
  views: z.number(),
15
+ type: z.nativeEnum(POST_TYPE),
14
16
 
15
17
  createdAt: z.date(),
16
18
  updatedAt: z.date(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.43",
3
+ "version": "0.5.45",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FindPostCommand = void 0;
4
- const zod_1 = require("zod");
5
- const models_1 = require("../../models");
6
- const FindPostRequestSchema = zod_1.z.object({
7
- limit: zod_1.z.string().transform((val) => parseInt(val, 10)),
8
- offset: zod_1.z.string().transform((val) => parseInt(val, 10)),
9
- });
10
- const FindPostResponseSchema = zod_1.z.object({
11
- posts: zod_1.z.array(models_1.PostSchema),
12
- totalPage: zod_1.z.number(),
13
- page: zod_1.z.number(),
14
- });
15
- const FindAllPostResponseSchema = zod_1.z.object({
16
- data: zod_1.z.array(models_1.PostSchema),
17
- });
18
- var FindPostCommand;
19
- (function (FindPostCommand) {
20
- FindPostCommand.RequestSchema = FindPostRequestSchema;
21
- FindPostCommand.ResponseSchema = FindPostResponseSchema;
22
- FindPostCommand.ResponseAllSchema = FindAllPostResponseSchema;
23
- })(FindPostCommand || (exports.FindPostCommand = FindPostCommand = {}));
@@ -1,28 +0,0 @@
1
- import { z } from 'zod';
2
- import { PostSchema } from '../../models';
3
-
4
- const FindPostRequestSchema = z.object({
5
- limit: z.string().transform((val) => parseInt(val, 10)),
6
- offset: z.string().transform((val) => parseInt(val, 10)),
7
- });
8
-
9
- const FindPostResponseSchema = z.object({
10
- posts: z.array(PostSchema),
11
- totalPage: z.number(),
12
- page: z.number(),
13
- });
14
-
15
- const FindAllPostResponseSchema = z.object({
16
- data: z.array(PostSchema),
17
- });
18
-
19
- export namespace FindPostCommand {
20
- export const RequestSchema = FindPostRequestSchema;
21
- export type Request = z.infer<typeof RequestSchema>;
22
-
23
- export const ResponseSchema = FindPostResponseSchema;
24
- export type Response = z.infer<typeof ResponseSchema>;
25
-
26
- export const ResponseAllSchema = FindAllPostResponseSchema;
27
- export type ResponseAll = z.infer<typeof ResponseAllSchema>;
28
- }