@purpleschool/gptbot 0.5.49 → 0.5.51

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.
@@ -9,4 +9,5 @@ export const BLOG_ROUTES = {
9
9
  FIND_BY_UUID: (uuid: string) => `by/uuid/${uuid}`,
10
10
  FIND_BY_ALIAS: (alias: string) => `by/alias/${alias}`,
11
11
  LATEST: 'latest',
12
+ COUNT: 'count',
12
13
  } as const;
package/api/routes.ts CHANGED
@@ -146,6 +146,7 @@ export const REST_API = {
146
146
  GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
147
147
  GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
148
148
  LATEST: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
149
+ COUNT: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.COUNT}`,
149
150
  },
150
151
  BLOG_UPDATES: {
151
152
  CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}`,
@@ -159,6 +160,7 @@ export const REST_API = {
159
160
  GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
160
161
  GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
161
162
  LATEST: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
163
+ COUNT: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.COUNT}`,
162
164
  },
163
165
  PROMOCODE: {
164
166
  CREATE: `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
@@ -10,4 +10,5 @@ exports.BLOG_ROUTES = {
10
10
  FIND_BY_UUID: (uuid) => `by/uuid/${uuid}`,
11
11
  FIND_BY_ALIAS: (alias) => `by/alias/${alias}`,
12
12
  LATEST: 'latest',
13
+ COUNT: 'count',
13
14
  };
@@ -155,6 +155,7 @@ exports.REST_API = {
155
155
  GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
156
156
  GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
157
157
  LATEST: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
158
+ COUNT: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.COUNT}`,
158
159
  },
159
160
  BLOG_UPDATES: {
160
161
  CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}`,
@@ -165,6 +166,7 @@ exports.REST_API = {
165
166
  GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
166
167
  GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
167
168
  LATEST: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
169
+ COUNT: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.COUNT}`,
168
170
  },
169
171
  PROMOCODE: {
170
172
  CREATE: `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
@@ -5,6 +5,10 @@ const models_1 = require("../../models");
5
5
  const zod_1 = require("zod");
6
6
  var FindAllPostsCommand;
7
7
  (function (FindAllPostsCommand) {
8
+ FindAllPostsCommand.RequestQuerySchema = zod_1.z.object({
9
+ date__gt: models_1.DateSchema.optional(),
10
+ date__lt: models_1.DateSchema.optional(),
11
+ });
8
12
  FindAllPostsCommand.ResponseSchema = zod_1.z.object({
9
13
  data: zod_1.z.array(models_1.PostSchema),
10
14
  });
@@ -6,6 +6,8 @@ const models_1 = require("../../models");
6
6
  var FindPostsCommand;
7
7
  (function (FindPostsCommand) {
8
8
  FindPostsCommand.RequestQuerySchema = zod_1.z.object({
9
+ date__gt: models_1.DateSchema.optional(),
10
+ date__lt: models_1.DateSchema.optional(),
9
11
  limit: zod_1.z.string().transform((val) => parseInt(val, 10)),
10
12
  offset: zod_1.z.string().transform((val) => parseInt(val, 10)),
11
13
  });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetPostsCountCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetPostsCountCommand;
7
+ (function (GetPostsCountCommand) {
8
+ GetPostsCountCommand.RequestQuerySchema = zod_1.z.object({
9
+ date__gt: models_1.DateSchema.optional(),
10
+ date__lt: models_1.DateSchema.optional(),
11
+ });
12
+ GetPostsCountCommand.ResponseSchema = zod_1.z.object({
13
+ count: zod_1.z.number(),
14
+ });
15
+ })(GetPostsCountCommand || (exports.GetPostsCountCommand = GetPostsCountCommand = {}));
@@ -21,4 +21,5 @@ __exportStar(require("./find-post-by-alias.command"), exports);
21
21
  __exportStar(require("./find-post-by-uuid.command"), exports);
22
22
  __exportStar(require("./find-posts.command"), exports);
23
23
  __exportStar(require("./get-latest-updates.command"), exports);
24
+ __exportStar(require("./get-posts-count.command"), exports);
24
25
  __exportStar(require("./update-post.command"), exports);
@@ -12,7 +12,7 @@ exports.FREE_SUBSCRIPTION_DATA = {
12
12
  type: enums_1.SUBSCRIPTION_TYPE.main,
13
13
  discount: 0,
14
14
  maxDiscountPercent: 0,
15
- period: 0,
15
+ period: 1,
16
16
  plan: enums_1.SUBSCRIPTION_PLAN.system,
17
17
  icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
18
18
  interval: '',
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.DateSchema = zod_1.z.coerce.date().or(zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((val) => {
6
+ const timestamp = Number(val);
7
+ if (isNaN(timestamp))
8
+ throw new Error('Invalid date');
9
+ return new Date(timestamp > 9999999999 ? timestamp : timestamp * 1000);
10
+ }));
@@ -21,6 +21,7 @@ __exportStar(require("./chat.schema"), exports);
21
21
  __exportStar(require("./cloud-payments-receipt.schema"), exports);
22
22
  __exportStar(require("./course-author.schema"), exports);
23
23
  __exportStar(require("./course.schema"), exports);
24
+ __exportStar(require("./date.schema"), exports);
24
25
  __exportStar(require("./feedback.schema"), exports);
25
26
  __exportStar(require("./file.schema"), exports);
26
27
  __exportStar(require("./lesson.schema"), exports);
@@ -1,7 +1,14 @@
1
- import { PostSchema } from '../../models';
1
+ import { DateSchema, PostSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindAllPostsCommand {
5
+ export const RequestQuerySchema = z.object({
6
+ date__gt: DateSchema.optional(),
7
+ date__lt: DateSchema.optional(),
8
+ });
9
+
10
+ export type RequestParams = z.infer<typeof RequestQuerySchema>;
11
+
5
12
  export const ResponseSchema = z.object({
6
13
  data: z.array(PostSchema),
7
14
  });
@@ -1,8 +1,10 @@
1
1
  import { z } from 'zod';
2
- import { PostSchema } from '../../models';
2
+ import { DateSchema, PostSchema } from '../../models';
3
3
 
4
4
  export namespace FindPostsCommand {
5
5
  export const RequestQuerySchema = z.object({
6
+ date__gt: DateSchema.optional(),
7
+ date__lt: DateSchema.optional(),
6
8
  limit: z.string().transform((val) => parseInt(val, 10)),
7
9
  offset: z.string().transform((val) => parseInt(val, 10)),
8
10
  });
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { DateSchema } from '../../models';
3
+
4
+ export namespace GetPostsCountCommand {
5
+ export const RequestQuerySchema = z.object({
6
+ date__gt: DateSchema.optional(),
7
+ date__lt: DateSchema.optional(),
8
+ });
9
+
10
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
11
+
12
+ export const ResponseSchema = z.object({
13
+ count: z.number(),
14
+ });
15
+
16
+ export type Response = z.infer<typeof ResponseSchema>;
17
+ }
@@ -5,4 +5,5 @@ export * from './find-post-by-alias.command';
5
5
  export * from './find-post-by-uuid.command';
6
6
  export * from './find-posts.command';
7
7
  export * from './get-latest-updates.command';
8
+ export * from './get-posts-count.command';
8
9
  export * from './update-post.command';
@@ -10,7 +10,7 @@ export const FREE_SUBSCRIPTION_DATA = {
10
10
  type: SUBSCRIPTION_TYPE.main,
11
11
  discount: 0,
12
12
  maxDiscountPercent: 0,
13
- period: 0,
13
+ period: 1,
14
14
  plan: SUBSCRIPTION_PLAN.system,
15
15
  icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
16
16
  interval: '',
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+
3
+ export const DateSchema = z.coerce.date().or(
4
+ z.union([z.string(), z.number()]).transform((val) => {
5
+ const timestamp = Number(val);
6
+ if (isNaN(timestamp)) throw new Error('Invalid date');
7
+ return new Date(timestamp > 9999999999 ? timestamp : timestamp * 1000);
8
+ }),
9
+ );
package/models/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from './chat.schema';
5
5
  export * from './cloud-payments-receipt.schema';
6
6
  export * from './course-author.schema';
7
7
  export * from './course.schema';
8
+ export * from './date.schema';
8
9
  export * from './feedback.schema';
9
10
  export * from './file.schema';
10
11
  export * from './lesson.schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.49",
3
+ "version": "0.5.51",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",