@purpleschool/gptbot 0.5.50 → 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.
- package/api/controllers/http/blog.ts +1 -0
- package/api/routes.ts +2 -0
- package/build/api/controllers/http/blog.js +1 -0
- package/build/api/routes.js +2 -0
- package/build/commands/blog/find-all-posts.command.js +4 -0
- package/build/commands/blog/find-posts.command.js +2 -0
- package/build/commands/blog/get-posts-count.command.js +15 -0
- package/build/commands/blog/index.js +1 -0
- package/build/models/date.schema.js +10 -0
- package/build/models/index.js +1 -0
- package/commands/blog/find-all-posts.command.ts +8 -1
- package/commands/blog/find-posts.command.ts +3 -1
- package/commands/blog/get-posts-count.command.ts +17 -0
- package/commands/blog/index.ts +1 -0
- package/models/date.schema.ts +9 -0
- package/models/index.ts +1 -0
- package/package.json +1 -1
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}`,
|
package/build/api/routes.js
CHANGED
|
@@ -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);
|
|
@@ -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
|
+
}));
|
package/build/models/index.js
CHANGED
|
@@ -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
|
+
}
|
package/commands/blog/index.ts
CHANGED
|
@@ -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';
|