@purpleschool/gptbot 0.8.10 → 0.8.12
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/community.ts +22 -0
- package/api/controllers/http/index.ts +1 -0
- package/api/routes.ts +26 -0
- package/build/api/controllers/http/community.js +23 -0
- package/build/api/controllers/http/index.js +1 -0
- package/build/api/routes.js +18 -0
- package/build/commands/community/archive-community-post.command.js +13 -0
- package/build/commands/community/create-community-post.command.js +35 -0
- package/build/commands/community/delete-community-post.command.js +13 -0
- package/build/commands/community/get-all-community-posts-by-criteria.command.js +25 -0
- package/build/commands/community/get-community-post-by-uuid.command.js +14 -0
- package/build/commands/community/get-my-community-posts-by-criteria.command.js +32 -0
- package/build/commands/community/get-my-favorite-community-posts.command.js +19 -0
- package/build/commands/community/get-my-likes-community-posts.command.js +19 -0
- package/build/commands/community/index.js +27 -0
- package/build/commands/community/set-favorite-community-post.command.js +13 -0
- package/build/commands/community/set-like-community-post.command.js +14 -0
- package/build/commands/community/share-my-community-post.command.js +13 -0
- package/build/commands/index.js +1 -0
- package/build/constants/community/default-pagination.constant.js +6 -0
- package/build/constants/community/enums/community-aspect-ratio.enum.js +11 -0
- package/build/constants/community/enums/community-post-visibility.enum.js +8 -0
- package/build/constants/community/enums/community-status.enum.js +9 -0
- package/build/constants/community/enums/community-tool-type.enum.js +10 -0
- package/build/constants/community/enums/community-type.enum.js +11 -0
- package/build/constants/community/enums/index.js +21 -0
- package/build/constants/community/index.js +18 -0
- package/build/constants/errors/errors.js +95 -0
- package/build/constants/index.js +1 -0
- package/build/models/community/community-post-media-data.schema.js +53 -0
- package/build/models/community/community-post.schema.js +43 -0
- package/build/models/community/index.js +18 -0
- package/build/models/index.js +1 -0
- package/build/models/tools/image-editor/image-editor-config.schema.js +1 -0
- package/commands/community/archive-community-post.command.ts +13 -0
- package/commands/community/create-community-post.command.ts +45 -0
- package/commands/community/delete-community-post.command.ts +13 -0
- package/commands/community/get-all-community-posts-by-criteria.command.ts +29 -0
- package/commands/community/get-community-post-by-uuid.command.ts +16 -0
- package/commands/community/get-my-community-posts-by-criteria.command.ts +40 -0
- package/commands/community/get-my-favorite-community-posts.command.ts +19 -0
- package/commands/community/get-my-likes-community-posts.command.ts +19 -0
- package/commands/community/index.ts +11 -0
- package/commands/community/set-favorite-community-post.command.ts +13 -0
- package/commands/community/set-like-community-post.command.ts +14 -0
- package/commands/community/share-my-community-post.command.ts +13 -0
- package/commands/index.ts +1 -0
- package/constants/community/default-pagination.constant.ts +4 -0
- package/constants/community/enums/community-aspect-ratio.enum.ts +7 -0
- package/constants/community/enums/community-post-visibility.enum.ts +4 -0
- package/constants/community/enums/community-status.enum.ts +5 -0
- package/constants/community/enums/community-tool-type.enum.ts +6 -0
- package/constants/community/enums/community-type.enum.ts +7 -0
- package/constants/community/enums/index.ts +5 -0
- package/constants/community/index.ts +2 -0
- package/constants/errors/errors.ts +95 -0
- package/constants/index.ts +1 -0
- package/models/community/community-post-media-data.schema.ts +65 -0
- package/models/community/community-post.schema.ts +47 -0
- package/models/community/index.ts +2 -0
- package/models/index.ts +1 -0
- package/models/tools/image-editor/image-editor-config.schema.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommunityPostMediaDataSchema = exports.MusicCommunityMediaSchema = exports.VideoEditorCommunityMediaSchema = exports.VideoCommunityMediaSchema = exports.ImageEditorCommunityMediaSchema = exports.ImageCommunityMediaSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const music_track_schema_1 = require("../tools/music/music-track.schema");
|
|
7
|
+
const video_job_schema_1 = require("../tools/video/video-job.schema");
|
|
8
|
+
const file_schema_1 = require("../file.schema");
|
|
9
|
+
const tools_1 = require("../tools");
|
|
10
|
+
exports.ImageCommunityMediaSchema = zod_1.z.object({
|
|
11
|
+
type: zod_1.z.literal(constants_1.COMMUNITY_POST_TYPE.IMAGE),
|
|
12
|
+
text: zod_1.z.string().max(10000),
|
|
13
|
+
files: zod_1.z.array(file_schema_1.FileSchema.pick({ url: true })),
|
|
14
|
+
imageFormat: zod_1.z.nativeEnum(constants_1.IMAGE_FORMAT).nullable(),
|
|
15
|
+
});
|
|
16
|
+
exports.ImageEditorCommunityMediaSchema = zod_1.z.object({
|
|
17
|
+
type: zod_1.z.literal(constants_1.COMMUNITY_POST_TYPE.IMAGE_EDITOR),
|
|
18
|
+
prompt: zod_1.z.string(),
|
|
19
|
+
imageUrls: zod_1.z.array(zod_1.z.string()).nullable(),
|
|
20
|
+
});
|
|
21
|
+
exports.VideoCommunityMediaSchema = zod_1.z.object({
|
|
22
|
+
type: zod_1.z.literal(constants_1.COMMUNITY_POST_TYPE.VIDEO),
|
|
23
|
+
title: zod_1.z.string(),
|
|
24
|
+
prompt: zod_1.z.string(),
|
|
25
|
+
videoUrl: zod_1.z.string().nullable(),
|
|
26
|
+
params: video_job_schema_1.VideoJobParamsSchema,
|
|
27
|
+
});
|
|
28
|
+
exports.VideoEditorCommunityMediaSchema = zod_1.z.object({
|
|
29
|
+
type: zod_1.z.literal(constants_1.COMMUNITY_POST_TYPE.VIDEO_EDITOR),
|
|
30
|
+
title: zod_1.z.string(),
|
|
31
|
+
prompt: zod_1.z.string(),
|
|
32
|
+
inputVideoUrl: zod_1.z.string(),
|
|
33
|
+
outputVideoUrl: zod_1.z.string().nullable(),
|
|
34
|
+
});
|
|
35
|
+
exports.MusicCommunityMediaSchema = zod_1.z.object({
|
|
36
|
+
type: zod_1.z.literal(constants_1.COMMUNITY_POST_TYPE.MUSIC),
|
|
37
|
+
params: tools_1.MusicJobParamsSchema,
|
|
38
|
+
prompt: zod_1.z.string(),
|
|
39
|
+
tracks: zod_1.z.array(music_track_schema_1.MusicTrackSchema.pick({
|
|
40
|
+
audioUrl: true,
|
|
41
|
+
coverUrl: true,
|
|
42
|
+
duration: true,
|
|
43
|
+
title: true,
|
|
44
|
+
tags: true,
|
|
45
|
+
})),
|
|
46
|
+
});
|
|
47
|
+
exports.CommunityPostMediaDataSchema = zod_1.z.discriminatedUnion('type', [
|
|
48
|
+
exports.ImageCommunityMediaSchema,
|
|
49
|
+
exports.ImageEditorCommunityMediaSchema,
|
|
50
|
+
exports.VideoCommunityMediaSchema,
|
|
51
|
+
exports.VideoEditorCommunityMediaSchema,
|
|
52
|
+
exports.MusicCommunityMediaSchema,
|
|
53
|
+
]);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseCommunityPostSchema = exports.CommunityPostSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const community_post_media_data_schema_1 = require("./community-post-media-data.schema");
|
|
7
|
+
const icon_variants_schema_1 = require("../icon-variants.schema");
|
|
8
|
+
exports.CommunityPostSchema = zod_1.z.object({
|
|
9
|
+
uuid: zod_1.z.string().uuid(),
|
|
10
|
+
userId: zod_1.z.string().uuid(),
|
|
11
|
+
caption: zod_1.z.string().nullable(),
|
|
12
|
+
status: zod_1.z.nativeEnum(constants_1.COMMUNITY_POST_STATUS),
|
|
13
|
+
visibility: zod_1.z.nativeEnum(constants_1.COMMUNITY_POST_VISIBILITY),
|
|
14
|
+
type: zod_1.z.nativeEnum(constants_1.COMMUNITY_POST_TYPE),
|
|
15
|
+
mediaData: community_post_media_data_schema_1.CommunityPostMediaDataSchema,
|
|
16
|
+
aiModelId: zod_1.z.string().uuid(),
|
|
17
|
+
aiModelTitle: zod_1.z.string(),
|
|
18
|
+
aiModelIcons: icon_variants_schema_1.IconVariantsSchema,
|
|
19
|
+
messageId: zod_1.z.string().nullable(),
|
|
20
|
+
toolJobId: zod_1.z.string().nullable(),
|
|
21
|
+
toolType: zod_1.z.nativeEnum(constants_1.COMMUNITY_TOOL_TYPE).nullable(),
|
|
22
|
+
views: zod_1.z.number(),
|
|
23
|
+
likesCount: zod_1.z.number(),
|
|
24
|
+
publishedAt: zod_1.z.date().nullable(),
|
|
25
|
+
archivedAt: zod_1.z.date().nullable(),
|
|
26
|
+
createdAt: zod_1.z.date(),
|
|
27
|
+
updatedAt: zod_1.z.date(),
|
|
28
|
+
});
|
|
29
|
+
exports.ResponseCommunityPostSchema = zod_1.z.object({
|
|
30
|
+
uuid: zod_1.z.string().uuid(),
|
|
31
|
+
userId: zod_1.z.string().uuid(),
|
|
32
|
+
caption: zod_1.z.string().nullable(),
|
|
33
|
+
status: zod_1.z.nativeEnum(constants_1.COMMUNITY_POST_STATUS),
|
|
34
|
+
visibility: zod_1.z.nativeEnum(constants_1.COMMUNITY_POST_VISIBILITY),
|
|
35
|
+
type: zod_1.z.nativeEnum(constants_1.COMMUNITY_POST_TYPE),
|
|
36
|
+
mediaData: community_post_media_data_schema_1.CommunityPostMediaDataSchema,
|
|
37
|
+
aiModelId: zod_1.z.string().uuid(),
|
|
38
|
+
aiModelTitle: zod_1.z.string(),
|
|
39
|
+
aiModelIcons: icon_variants_schema_1.IconVariantsSchema,
|
|
40
|
+
views: zod_1.z.number(),
|
|
41
|
+
likesCount: zod_1.z.number(),
|
|
42
|
+
publishedAt: zod_1.z.date().nullable(),
|
|
43
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./community-post.schema"), exports);
|
|
18
|
+
__exportStar(require("./community-post-media-data.schema"), exports);
|
package/build/models/index.js
CHANGED
|
@@ -70,4 +70,5 @@ __exportStar(require("./webmaster.schema"), exports);
|
|
|
70
70
|
__exportStar(require("./webmaster-balance.schema"), exports);
|
|
71
71
|
__exportStar(require("./user-referrals.schema"), exports);
|
|
72
72
|
__exportStar(require("./webmaster-click.schema"), exports);
|
|
73
|
+
__exportStar(require("./community"), exports);
|
|
73
74
|
__exportStar(require("./user-profile.schema"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace ArchiveCommunityPostCommand {
|
|
4
|
+
export const RequestParamsSchema = z.object({
|
|
5
|
+
uuid: z.string().uuid(),
|
|
6
|
+
});
|
|
7
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = z.object({
|
|
10
|
+
data: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
3
|
+
import {
|
|
4
|
+
COMMUNITY_POST_STATUS,
|
|
5
|
+
COMMUNITY_POST_VISIBILITY,
|
|
6
|
+
COMMUNITY_TOOL_TYPE,
|
|
7
|
+
} from '../../constants';
|
|
8
|
+
|
|
9
|
+
export namespace CreateCommunityPostCommand {
|
|
10
|
+
export const RequestBodySchema = z
|
|
11
|
+
.object({
|
|
12
|
+
status: z.nativeEnum(COMMUNITY_POST_STATUS),
|
|
13
|
+
visibility: z.nativeEnum(COMMUNITY_POST_VISIBILITY),
|
|
14
|
+
caption: z.string().max(500).nullable().optional(),
|
|
15
|
+
messageId: z.string().uuid().nullable().optional(),
|
|
16
|
+
toolJobId: z.string().uuid().nullable().optional(),
|
|
17
|
+
toolType: z.nativeEnum(COMMUNITY_TOOL_TYPE).nullable().optional(),
|
|
18
|
+
})
|
|
19
|
+
.refine(
|
|
20
|
+
(data) => {
|
|
21
|
+
const hasMessageId = data.messageId != null;
|
|
22
|
+
const hasToolJobId = data.toolJobId != null;
|
|
23
|
+
|
|
24
|
+
if (!(hasMessageId !== hasToolJobId)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (hasToolJobId && data.toolType == null) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
message: 'Either messageId or toolJobId must be provided, but not both.',
|
|
36
|
+
path: ['messageId'],
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
export type RequestBody = z.infer<typeof RequestBodySchema>;
|
|
40
|
+
|
|
41
|
+
export const ResponseSchema = z.object({
|
|
42
|
+
data: ResponseCommunityPostSchema,
|
|
43
|
+
});
|
|
44
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace DeleteCommunityPostCommand {
|
|
4
|
+
export const RequestParamsSchema = z.object({
|
|
5
|
+
uuid: z.string().uuid(),
|
|
6
|
+
});
|
|
7
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = z.object({
|
|
10
|
+
data: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
3
|
+
import { SORT_ORDER, COMMUNITY_POST_TYPE } from '../../constants';
|
|
4
|
+
|
|
5
|
+
export namespace GetAllCommunityPostsCommand {
|
|
6
|
+
export const RequestQuerySchema = z.object({
|
|
7
|
+
// Pagination
|
|
8
|
+
cursor: z.string().uuid().nullable().optional(),
|
|
9
|
+
limit: z.coerce.number().int().positive().max(100).default(30).optional(),
|
|
10
|
+
|
|
11
|
+
// Sorting
|
|
12
|
+
sortBy: z.enum(['publishedAt', 'views', 'likesCount']).optional(),
|
|
13
|
+
sortOrder: z.nativeEnum(SORT_ORDER).optional(),
|
|
14
|
+
|
|
15
|
+
// Criteria
|
|
16
|
+
userId: z.string().uuid().optional(),
|
|
17
|
+
type: z.nativeEnum(COMMUNITY_POST_TYPE).optional(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
21
|
+
|
|
22
|
+
export const ResponseSchema = z.object({
|
|
23
|
+
data: z.array(ResponseCommunityPostSchema),
|
|
24
|
+
cursor: z.string().uuid().nullable(),
|
|
25
|
+
hasNext: z.boolean(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace GetCommunityPostByUuidCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
uuid: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: ResponseCommunityPostSchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
3
|
+
import {
|
|
4
|
+
COMMUNITY_POST_STATUS,
|
|
5
|
+
COMMUNITY_POST_TYPE,
|
|
6
|
+
COMMUNITY_POST_VISIBILITY,
|
|
7
|
+
DEFAULT_PAGINATION_LIMIT,
|
|
8
|
+
SORT_ORDER,
|
|
9
|
+
} from '../../constants';
|
|
10
|
+
|
|
11
|
+
export namespace GetMyCommunityPostsByCriteriaCommand {
|
|
12
|
+
export const RequestQuerySchema = z.object({
|
|
13
|
+
// Pagination
|
|
14
|
+
cursor: z.string().uuid().nullable().optional(),
|
|
15
|
+
limit: z.coerce
|
|
16
|
+
.number()
|
|
17
|
+
.int()
|
|
18
|
+
.positive()
|
|
19
|
+
.max(100)
|
|
20
|
+
.default(DEFAULT_PAGINATION_LIMIT)
|
|
21
|
+
.optional(),
|
|
22
|
+
|
|
23
|
+
// Sorting
|
|
24
|
+
sortBy: z.enum(['publishedAt', 'views', 'likesCount']).optional(),
|
|
25
|
+
sortOrder: z.nativeEnum(SORT_ORDER).optional(),
|
|
26
|
+
|
|
27
|
+
// Criteria
|
|
28
|
+
visibility: z.nativeEnum(COMMUNITY_POST_VISIBILITY).optional(),
|
|
29
|
+
type: z.nativeEnum(COMMUNITY_POST_TYPE).optional(),
|
|
30
|
+
status: z.nativeEnum(COMMUNITY_POST_STATUS).optional(),
|
|
31
|
+
});
|
|
32
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
33
|
+
|
|
34
|
+
export const ResponseSchema = z.object({
|
|
35
|
+
data: z.array(ResponseCommunityPostSchema),
|
|
36
|
+
cursor: z.string().uuid().nullable(),
|
|
37
|
+
hasNext: z.boolean(),
|
|
38
|
+
});
|
|
39
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DEFAULT_PAGINATION_LIMIT, SORT_ORDER } from '../../constants';
|
|
3
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetMyFavoriteCommunityPostsCommand {
|
|
6
|
+
export const RequestQuerySchema = z.object({
|
|
7
|
+
offset: z.coerce.number().int().min(0).default(0).optional(),
|
|
8
|
+
limit: z.coerce.number().int().min(1).max(100).default(DEFAULT_PAGINATION_LIMIT).optional(),
|
|
9
|
+
sortOrder: z.nativeEnum(SORT_ORDER).optional(),
|
|
10
|
+
});
|
|
11
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = z.object({
|
|
14
|
+
data: z.array(ResponseCommunityPostSchema),
|
|
15
|
+
page: z.number(),
|
|
16
|
+
totalPages: z.number(),
|
|
17
|
+
});
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DEFAULT_PAGINATION_LIMIT, SORT_ORDER } from '../../constants';
|
|
3
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetMyLikesCommunityPostsCommand {
|
|
6
|
+
export const RequestQuerySchema = z.object({
|
|
7
|
+
offset: z.coerce.number().int().min(0).default(0).optional(),
|
|
8
|
+
limit: z.coerce.number().int().min(1).max(100).default(DEFAULT_PAGINATION_LIMIT).optional(),
|
|
9
|
+
sortOrder: z.nativeEnum(SORT_ORDER).optional(),
|
|
10
|
+
});
|
|
11
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = z.object({
|
|
14
|
+
data: z.array(ResponseCommunityPostSchema),
|
|
15
|
+
page: z.number(),
|
|
16
|
+
totalPages: z.number(),
|
|
17
|
+
});
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './get-all-community-posts-by-criteria.command';
|
|
2
|
+
export * from './get-community-post-by-uuid.command';
|
|
3
|
+
export * from './create-community-post.command';
|
|
4
|
+
export * from './set-like-community-post.command';
|
|
5
|
+
export * from './set-favorite-community-post.command';
|
|
6
|
+
export * from './delete-community-post.command';
|
|
7
|
+
export * from './archive-community-post.command';
|
|
8
|
+
export * from './get-my-community-posts-by-criteria.command';
|
|
9
|
+
export * from './share-my-community-post.command';
|
|
10
|
+
export * from './get-my-likes-community-posts.command';
|
|
11
|
+
export * from './get-my-favorite-community-posts.command';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace SetFavoriteCommunityPostCommand {
|
|
4
|
+
export const RequestParamsSchema = z.object({
|
|
5
|
+
uuid: z.string().uuid(),
|
|
6
|
+
});
|
|
7
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = z.object({
|
|
10
|
+
data: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResponseCommunityPostSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace SetLikeCommunityPostCommand {
|
|
5
|
+
export const RequestParamsSchema = z.object({
|
|
6
|
+
uuid: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
9
|
+
|
|
10
|
+
export const ResponseSchema = z.object({
|
|
11
|
+
data: ResponseCommunityPostSchema,
|
|
12
|
+
});
|
|
13
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace ShareMyCommunityPostCommand {
|
|
4
|
+
export const RequestParamsSchema = z.object({
|
|
5
|
+
uuid: z.string().uuid(),
|
|
6
|
+
});
|
|
7
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = z.object({
|
|
10
|
+
data: z.string().url(),
|
|
11
|
+
});
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
package/commands/index.ts
CHANGED
|
@@ -2375,4 +2375,99 @@ export const ERRORS = {
|
|
|
2375
2375
|
message: 'Ошибка при обновлении профиля пользователя',
|
|
2376
2376
|
httpCode: 500,
|
|
2377
2377
|
},
|
|
2378
|
+
COMMUNITY_POST_CREATE_ERROR: {
|
|
2379
|
+
code: 'A484',
|
|
2380
|
+
message: 'Произошла ошибка при создании поста в сообществе',
|
|
2381
|
+
httpCode: 500,
|
|
2382
|
+
},
|
|
2383
|
+
COMMUNITY_POST_UPDATE_ERROR: {
|
|
2384
|
+
code: 'A485',
|
|
2385
|
+
message: 'Произошла ошибка при обновлении поста в сообществе',
|
|
2386
|
+
httpCode: 500,
|
|
2387
|
+
},
|
|
2388
|
+
COMMUNITY_POST_FIND_ERROR: {
|
|
2389
|
+
code: 'A486',
|
|
2390
|
+
message: 'Произошла ошибка при получении поста в сообществе',
|
|
2391
|
+
httpCode: 500,
|
|
2392
|
+
},
|
|
2393
|
+
COMMUNITY_POST_SET_LIKE_ERROR: {
|
|
2394
|
+
code: 'A487',
|
|
2395
|
+
message: 'Произошла ошибка при установке лайка к посту в сообществе',
|
|
2396
|
+
httpCode: 500,
|
|
2397
|
+
},
|
|
2398
|
+
COMMUNITY_POST_SET_FAVORITE_ERROR: {
|
|
2399
|
+
code: 'A488',
|
|
2400
|
+
message: 'Произошла ошибка при переключении избранного поста в сообществе',
|
|
2401
|
+
httpCode: 500,
|
|
2402
|
+
},
|
|
2403
|
+
COMMUNITY_POST_OWNERSHIP_ERROR: {
|
|
2404
|
+
code: 'A489',
|
|
2405
|
+
message: 'Вы не можете переключать избранное для своего поста',
|
|
2406
|
+
httpCode: 403,
|
|
2407
|
+
},
|
|
2408
|
+
COMMUNITY_POST_PERMISSION_ERROR: {
|
|
2409
|
+
code: 'A490',
|
|
2410
|
+
message: 'У вас нет доступа к этому посту в сообществе',
|
|
2411
|
+
httpCode: 403,
|
|
2412
|
+
},
|
|
2413
|
+
COMMUNITY_POST_DELETE_ERROR: {
|
|
2414
|
+
code: 'A491',
|
|
2415
|
+
message: 'Произошла ошибка при удалении поста в сообществе',
|
|
2416
|
+
httpCode: 500,
|
|
2417
|
+
},
|
|
2418
|
+
COMMUNITY_TOOL_TYPE_REQUIRED: {
|
|
2419
|
+
code: 'A492',
|
|
2420
|
+
message: 'Тип инструмента обязателен',
|
|
2421
|
+
httpCode: 400,
|
|
2422
|
+
},
|
|
2423
|
+
COMMUNITY_TOOL_TYPE_NOT_SUPPORTED: {
|
|
2424
|
+
code: 'A493',
|
|
2425
|
+
message: 'Неподдерживаемый тип инструмента',
|
|
2426
|
+
httpCode: 400,
|
|
2427
|
+
},
|
|
2428
|
+
VIDEO_MODEL_FIND_ERROR: {
|
|
2429
|
+
code: 'A494',
|
|
2430
|
+
message: 'Произошла ошибка при получении модели для генерации видео',
|
|
2431
|
+
httpCode: 500,
|
|
2432
|
+
},
|
|
2433
|
+
VIDEO_EDITOR_MODEL_FIND_ERROR: {
|
|
2434
|
+
code: 'A495',
|
|
2435
|
+
message: 'Произошла ошибка при получении модели для редактирования видео',
|
|
2436
|
+
httpCode: 500,
|
|
2437
|
+
},
|
|
2438
|
+
IMAGE_EDITOR_MODEL_FIND_ERROR: {
|
|
2439
|
+
code: 'A496',
|
|
2440
|
+
message: 'Произошла ошибка при получении модели для редактирования изображения',
|
|
2441
|
+
httpCode: 500,
|
|
2442
|
+
},
|
|
2443
|
+
MUSIC_MODEL_FIND_ERROR: {
|
|
2444
|
+
code: 'A497',
|
|
2445
|
+
message: 'Произошла ошибка при получении модели для генерации музыки',
|
|
2446
|
+
httpCode: 500,
|
|
2447
|
+
},
|
|
2448
|
+
COMMUNITY_POST_NOT_AVAILABLE: {
|
|
2449
|
+
code: 'A498',
|
|
2450
|
+
message: 'Пост в сообществе недоступен',
|
|
2451
|
+
httpCode: 400,
|
|
2452
|
+
},
|
|
2453
|
+
COMMUNITY_POST_NOT_FOUND: {
|
|
2454
|
+
code: 'A499',
|
|
2455
|
+
message: 'Пост в сообществе не найден',
|
|
2456
|
+
httpCode: 404,
|
|
2457
|
+
},
|
|
2458
|
+
COMMUNITY_POST_JOB_NOT_READY: {
|
|
2459
|
+
code: 'A500',
|
|
2460
|
+
message: 'Работа не готова к публикации',
|
|
2461
|
+
httpCode: 404,
|
|
2462
|
+
},
|
|
2463
|
+
MESSAGE_STATUS_ERROR: {
|
|
2464
|
+
code: 'A501',
|
|
2465
|
+
message: 'Статус неудовлетворительный',
|
|
2466
|
+
httpCode: 400,
|
|
2467
|
+
},
|
|
2468
|
+
MESSAGE_ROLE_ERROR: {
|
|
2469
|
+
code: 'A502',
|
|
2470
|
+
message: 'Статус не удовлетворительный',
|
|
2471
|
+
httpCode: 400,
|
|
2472
|
+
},
|
|
2378
2473
|
};
|
package/constants/index.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { COMMUNITY_POST_TYPE, IMAGE_FORMAT } from '../../constants';
|
|
3
|
+
import { MusicTrackSchema } from '../tools/music/music-track.schema';
|
|
4
|
+
import { VideoJobParamsSchema } from '../tools/video/video-job.schema';
|
|
5
|
+
import { FileSchema } from '../file.schema';
|
|
6
|
+
import { MusicJobParamsSchema } from '../tools';
|
|
7
|
+
|
|
8
|
+
export const ImageCommunityMediaSchema = z.object({
|
|
9
|
+
type: z.literal(COMMUNITY_POST_TYPE.IMAGE),
|
|
10
|
+
text: z.string().max(10000),
|
|
11
|
+
files: z.array(FileSchema.pick({ url: true })),
|
|
12
|
+
imageFormat: z.nativeEnum(IMAGE_FORMAT).nullable(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const ImageEditorCommunityMediaSchema = z.object({
|
|
16
|
+
type: z.literal(COMMUNITY_POST_TYPE.IMAGE_EDITOR),
|
|
17
|
+
prompt: z.string(),
|
|
18
|
+
imageUrls: z.array(z.string()).nullable(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const VideoCommunityMediaSchema = z.object({
|
|
22
|
+
type: z.literal(COMMUNITY_POST_TYPE.VIDEO),
|
|
23
|
+
title: z.string(),
|
|
24
|
+
prompt: z.string(),
|
|
25
|
+
videoUrl: z.string().nullable(),
|
|
26
|
+
params: VideoJobParamsSchema,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const VideoEditorCommunityMediaSchema = z.object({
|
|
30
|
+
type: z.literal(COMMUNITY_POST_TYPE.VIDEO_EDITOR),
|
|
31
|
+
title: z.string(),
|
|
32
|
+
prompt: z.string(),
|
|
33
|
+
inputVideoUrl: z.string(),
|
|
34
|
+
outputVideoUrl: z.string().nullable(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const MusicCommunityMediaSchema = z.object({
|
|
38
|
+
type: z.literal(COMMUNITY_POST_TYPE.MUSIC),
|
|
39
|
+
params: MusicJobParamsSchema,
|
|
40
|
+
prompt: z.string(),
|
|
41
|
+
tracks: z.array(
|
|
42
|
+
MusicTrackSchema.pick({
|
|
43
|
+
audioUrl: true,
|
|
44
|
+
coverUrl: true,
|
|
45
|
+
duration: true,
|
|
46
|
+
title: true,
|
|
47
|
+
tags: true,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const CommunityPostMediaDataSchema = z.discriminatedUnion('type', [
|
|
53
|
+
ImageCommunityMediaSchema,
|
|
54
|
+
ImageEditorCommunityMediaSchema,
|
|
55
|
+
VideoCommunityMediaSchema,
|
|
56
|
+
VideoEditorCommunityMediaSchema,
|
|
57
|
+
MusicCommunityMediaSchema,
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
export type CommunityPostMediaData = z.infer<typeof CommunityPostMediaDataSchema>;
|
|
61
|
+
export type ImageCommunityMedia = z.infer<typeof ImageCommunityMediaSchema>;
|
|
62
|
+
export type ImageEditorCommunityMedia = z.infer<typeof ImageEditorCommunityMediaSchema>;
|
|
63
|
+
export type VideoCommunityMedia = z.infer<typeof VideoCommunityMediaSchema>;
|
|
64
|
+
export type VideoEditorCommunityMedia = z.infer<typeof VideoEditorCommunityMediaSchema>;
|
|
65
|
+
export type MusicCommunityMedia = z.infer<typeof MusicCommunityMediaSchema>;
|