@purpleschool/multisite 0.0.34 → 0.0.41
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/controller/http/auth.ts +1 -0
- package/api/controller/http/catalog.ts +6 -0
- package/api/controller/http/file.ts +1 -0
- package/api/controller/http/index.ts +2 -0
- package/api/controller/http/text-chat.ts +18 -0
- package/api/routes.ts +1 -0
- package/build/api/controller/http/auth.d.ts +1 -0
- package/build/api/controller/http/auth.d.ts.map +1 -1
- package/build/api/controller/http/auth.js +1 -0
- package/build/api/controller/http/catalog.d.ts +7 -0
- package/build/api/controller/http/catalog.d.ts.map +1 -0
- package/build/api/controller/http/catalog.js +9 -0
- package/build/api/controller/http/file.d.ts +1 -0
- package/build/api/controller/http/file.d.ts.map +1 -1
- package/build/api/controller/http/file.js +1 -0
- package/build/api/controller/http/index.d.ts +2 -0
- package/build/api/controller/http/index.d.ts.map +1 -1
- package/build/api/controller/http/index.js +2 -0
- package/build/api/controller/http/text-chat.d.ts +18 -0
- package/build/api/controller/http/text-chat.d.ts.map +1 -0
- package/build/api/controller/http/text-chat.js +20 -0
- package/build/api/routes.d.ts +1 -0
- package/build/api/routes.d.ts.map +1 -1
- package/build/api/routes.js +1 -0
- package/build/commands/auth/change-password.command.d.ts +5 -0
- package/build/commands/auth/change-password.command.d.ts.map +1 -1
- package/build/commands/auth/change-password.command.js +1 -0
- package/build/commands/auth/index.d.ts +1 -0
- package/build/commands/auth/index.d.ts.map +1 -1
- package/build/commands/auth/index.js +1 -0
- package/build/commands/auth/login.command.d.ts +5 -0
- package/build/commands/auth/login.command.d.ts.map +1 -1
- package/build/commands/auth/login.command.js +1 -0
- package/build/commands/auth/refresh.command.d.ts +30 -0
- package/build/commands/auth/refresh.command.d.ts.map +1 -0
- package/build/commands/auth/refresh.command.js +15 -0
- package/build/commands/auth/register.command.d.ts +5 -0
- package/build/commands/auth/register.command.d.ts.map +1 -1
- package/build/commands/auth/register.command.js +1 -0
- package/build/commands/auth/reset-password.command.d.ts +5 -0
- package/build/commands/auth/reset-password.command.d.ts.map +1 -1
- package/build/commands/auth/reset-password.command.js +1 -0
- package/build/commands/auth/verify-email.command.d.ts.map +1 -1
- package/build/commands/auth/verify-email.command.js +2 -1
- package/build/commands/auth/vk-login.command.d.ts +5 -0
- package/build/commands/auth/vk-login.command.d.ts.map +1 -1
- package/build/commands/auth/vk-login.command.js +1 -0
- package/build/commands/auth/yandex-login.command.d.ts +5 -0
- package/build/commands/auth/yandex-login.command.d.ts.map +1 -1
- package/build/commands/auth/yandex-login.command.js +1 -0
- package/build/commands/catalog/index.d.ts +156 -0
- package/build/commands/catalog/index.d.ts.map +1 -0
- package/build/commands/catalog/index.js +23 -0
- package/build/commands/index.d.ts +2 -0
- package/build/commands/index.d.ts.map +1 -1
- package/build/commands/index.js +2 -0
- package/build/commands/page/create-page.command.d.ts +8 -0
- package/build/commands/page/create-page.command.d.ts.map +1 -1
- package/build/commands/page/find-page-by-alias.command.d.ts +16 -0
- package/build/commands/page/find-page-by-alias.command.d.ts.map +1 -1
- package/build/commands/page/find-page-by-criteria.command.d.ts +5 -0
- package/build/commands/page/find-page-by-criteria.command.d.ts.map +1 -1
- package/build/commands/page/find-page.command.d.ts +11 -0
- package/build/commands/page/find-page.command.d.ts.map +1 -1
- package/build/commands/page/update-page.command.d.ts +8 -0
- package/build/commands/page/update-page.command.d.ts.map +1 -1
- package/build/commands/product/fast-buy-product.command.d.ts.map +1 -1
- package/build/commands/product/fast-buy-product.command.js +2 -1
- package/build/commands/subscription/fast-buy-subscription.command.d.ts.map +1 -1
- package/build/commands/subscription/fast-buy-subscription.command.js +2 -1
- package/build/commands/text-chat/category.d.ts +321 -0
- package/build/commands/text-chat/category.d.ts.map +1 -0
- package/build/commands/text-chat/category.js +29 -0
- package/build/commands/text-chat/index.d.ts +292 -0
- package/build/commands/text-chat/index.d.ts.map +1 -0
- package/build/commands/text-chat/index.js +73 -0
- package/build/constants/catalog.d.ts +5 -0
- package/build/constants/catalog.d.ts.map +1 -0
- package/build/constants/catalog.js +8 -0
- package/build/constants/errors/errors.d.ts +77 -0
- package/build/constants/errors/errors.d.ts.map +1 -1
- package/build/constants/errors/errors.js +77 -0
- package/build/constants/files/enums/file-type.enum.d.ts +3 -1
- package/build/constants/files/enums/file-type.enum.d.ts.map +1 -1
- package/build/constants/files/enums/file-type.enum.js +2 -0
- package/build/constants/index.d.ts +3 -0
- package/build/constants/index.d.ts.map +1 -1
- package/build/constants/index.js +3 -0
- package/build/constants/text-chat/attachments.d.ts +12 -0
- package/build/constants/text-chat/attachments.d.ts.map +1 -0
- package/build/constants/text-chat/attachments.js +52 -0
- package/build/constants/text-chat/index.d.ts +38 -0
- package/build/constants/text-chat/index.d.ts.map +1 -0
- package/build/constants/text-chat/index.js +59 -0
- package/build/constants/text-provider/index.d.ts +37 -0
- package/build/constants/text-provider/index.d.ts.map +1 -0
- package/build/constants/text-provider/index.js +46 -0
- package/build/constants/tools/enums/tool-type.enum.d.ts +1 -0
- package/build/constants/tools/enums/tool-type.enum.d.ts.map +1 -1
- package/build/constants/tools/enums/tool-type.enum.js +1 -0
- package/build/helpers/index.d.ts +1 -0
- package/build/helpers/index.d.ts.map +1 -1
- package/build/helpers/index.js +1 -0
- package/build/helpers/text-chat/index.d.ts +23 -0
- package/build/helpers/text-chat/index.d.ts.map +1 -0
- package/build/helpers/text-chat/index.js +91 -0
- package/build/models/catalog/index.d.ts +181 -0
- package/build/models/catalog/index.d.ts.map +1 -0
- package/build/models/catalog/index.js +36 -0
- package/build/models/index.d.ts +2 -0
- package/build/models/index.d.ts.map +1 -1
- package/build/models/index.js +2 -0
- package/build/models/page.schema.d.ts +6 -0
- package/build/models/page.schema.d.ts.map +1 -1
- package/build/models/page.schema.js +1 -0
- package/build/models/text-chat/category.schema.d.ts +79 -0
- package/build/models/text-chat/category.schema.d.ts.map +1 -0
- package/build/models/text-chat/category.schema.js +38 -0
- package/build/models/text-chat/index.d.ts +319 -0
- package/build/models/text-chat/index.d.ts.map +1 -0
- package/build/models/text-chat/index.js +79 -0
- package/build/models/text-chat/provider-config.schema.d.ts +92 -0
- package/build/models/text-chat/provider-config.schema.d.ts.map +1 -0
- package/build/models/text-chat/provider-config.schema.js +42 -0
- package/build/models/text-chat/stream.schema.d.ts +83 -0
- package/build/models/text-chat/stream.schema.d.ts.map +1 -0
- package/build/models/text-chat/stream.schema.js +24 -0
- package/build/models/user.schema.d.ts +1 -0
- package/build/models/user.schema.d.ts.map +1 -1
- package/build/models/user.schema.js +3 -2
- package/build/queries/catalog/index.d.ts +259 -0
- package/build/queries/catalog/index.d.ts.map +1 -0
- package/build/queries/catalog/index.js +31 -0
- package/build/queries/index.d.ts +2 -0
- package/build/queries/index.d.ts.map +1 -1
- package/build/queries/index.js +2 -0
- package/build/queries/subscription/get-subscriptions-summary.command.d.ts +5 -0
- package/build/queries/subscription/get-subscriptions-summary.command.d.ts.map +1 -1
- package/build/queries/subscription/get-subscriptions-summary.command.js +1 -0
- package/build/queries/text-chat/category.d.ts +297 -0
- package/build/queries/text-chat/category.d.ts.map +1 -0
- package/build/queries/text-chat/category.js +45 -0
- package/build/queries/text-chat/index.d.ts +472 -0
- package/build/queries/text-chat/index.d.ts.map +1 -0
- package/build/queries/text-chat/index.js +61 -0
- package/commands/auth/change-password.command.ts +1 -0
- package/commands/auth/index.ts +1 -0
- package/commands/auth/login.command.ts +1 -0
- package/commands/auth/refresh.command.ts +15 -0
- package/commands/auth/register.command.ts +1 -0
- package/commands/auth/reset-password.command.ts +1 -0
- package/commands/auth/verify-email.command.ts +2 -1
- package/commands/auth/vk-login.command.ts +1 -0
- package/commands/auth/yandex-login.command.ts +1 -0
- package/commands/catalog/index.ts +26 -0
- package/commands/index.ts +2 -0
- package/commands/product/fast-buy-product.command.ts +2 -1
- package/commands/subscription/fast-buy-subscription.command.ts +2 -1
- package/commands/text-chat/category.ts +42 -0
- package/commands/text-chat/index.ts +71 -0
- package/constants/catalog.ts +4 -0
- package/constants/errors/errors.ts +78 -0
- package/constants/files/enums/file-type.enum.ts +2 -0
- package/constants/index.ts +3 -0
- package/constants/text-chat/attachments.ts +55 -0
- package/constants/text-chat/index.ts +43 -0
- package/constants/text-provider/index.ts +42 -0
- package/constants/tools/enums/tool-type.enum.ts +1 -0
- package/helpers/index.ts +1 -0
- package/helpers/text-chat/index.ts +91 -0
- package/models/catalog/index.ts +35 -0
- package/models/index.ts +2 -0
- package/models/page.schema.ts +1 -0
- package/models/text-chat/category.schema.ts +40 -0
- package/models/text-chat/index.ts +82 -0
- package/models/text-chat/provider-config.schema.ts +47 -0
- package/models/text-chat/stream.schema.ts +43 -0
- package/models/user.schema.ts +3 -1
- package/package.json +1 -1
- package/queries/catalog/index.ts +29 -0
- package/queries/index.ts +2 -0
- package/queries/subscription/get-subscriptions-summary.command.ts +1 -0
- package/queries/text-chat/category.ts +51 -0
- package/queries/text-chat/index.ts +56 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
FILE_TYPE,
|
|
4
|
+
TEXT_CHAT_ERROR_CODE,
|
|
5
|
+
TEXT_CHAT_MESSAGE_ROLE,
|
|
6
|
+
TEXT_CHAT_MESSAGE_STATUS,
|
|
7
|
+
TOOL_MODEL_STATUS,
|
|
8
|
+
} from '../../constants';
|
|
9
|
+
import { FileSchema } from '../file.schema';
|
|
10
|
+
import { UnlockedBySchema } from '../unlocked-by-subscription.schema';
|
|
11
|
+
|
|
12
|
+
export * from './stream.schema';
|
|
13
|
+
export * from './provider-config.schema';
|
|
14
|
+
export * from './category.schema';
|
|
15
|
+
|
|
16
|
+
const CountSchema = z.number().int().safe().nonnegative();
|
|
17
|
+
const TimestampSchema = z.string().datetime().or(z.date());
|
|
18
|
+
|
|
19
|
+
export const TextChatFileSchema = FileSchema.extend({
|
|
20
|
+
type: z.enum([FILE_TYPE.IMAGE, FILE_TYPE.TEXT, FILE_TYPE.DOCUMENT]),
|
|
21
|
+
contentLength: CountSchema.nullable(),
|
|
22
|
+
});
|
|
23
|
+
export type TextChatFile = z.infer<typeof TextChatFileSchema>;
|
|
24
|
+
|
|
25
|
+
export const TextChatModelSchema = z.object({
|
|
26
|
+
uuid: z.string().uuid(),
|
|
27
|
+
title: z.string(),
|
|
28
|
+
model: z.string(),
|
|
29
|
+
description: z.string(),
|
|
30
|
+
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
31
|
+
canUse: z.boolean(),
|
|
32
|
+
unlockedBy: UnlockedBySchema.nullable(),
|
|
33
|
+
supportsImageAttachment: z.boolean(),
|
|
34
|
+
maxPromptLength: CountSchema.positive(),
|
|
35
|
+
maxContextCharacters: CountSchema.positive(),
|
|
36
|
+
order: z.number().int(),
|
|
37
|
+
});
|
|
38
|
+
export type TextChatModel = z.infer<typeof TextChatModelSchema>;
|
|
39
|
+
|
|
40
|
+
export const TextChatConfigSchema = z.object({
|
|
41
|
+
models: z.array(TextChatModelSchema),
|
|
42
|
+
maxFileAttachments: CountSchema.positive(),
|
|
43
|
+
maxImageUploadSize: CountSchema.positive(),
|
|
44
|
+
maxDocumentUploadSize: CountSchema.positive(),
|
|
45
|
+
maxTextUploadSize: CountSchema.positive(),
|
|
46
|
+
isAttachmentAvailable: z.literal(true),
|
|
47
|
+
});
|
|
48
|
+
export type TextChatConfig = z.infer<typeof TextChatConfigSchema>;
|
|
49
|
+
|
|
50
|
+
export const TextChatSchema = z.object({
|
|
51
|
+
uuid: z.string().uuid(),
|
|
52
|
+
title: z.string(),
|
|
53
|
+
// Independent Page.categoryId; immutable after creation.
|
|
54
|
+
categoryId: z.string().uuid().nullable(),
|
|
55
|
+
// Optional for legacy servers; only successful assistant messages determine this value.
|
|
56
|
+
lastUsedAiModelId: z.string().uuid().nullable().optional(),
|
|
57
|
+
createdAt: TimestampSchema,
|
|
58
|
+
updatedAt: TimestampSchema,
|
|
59
|
+
});
|
|
60
|
+
export type TextChat = z.infer<typeof TextChatSchema>;
|
|
61
|
+
|
|
62
|
+
export const TextChatMessageSchema = z.object({
|
|
63
|
+
uuid: z.string().uuid(),
|
|
64
|
+
chatId: z.string().uuid(),
|
|
65
|
+
role: z.nativeEnum(TEXT_CHAT_MESSAGE_ROLE),
|
|
66
|
+
status: z.nativeEnum(TEXT_CHAT_MESSAGE_STATUS),
|
|
67
|
+
text: z.string(),
|
|
68
|
+
modelId: z.string().uuid().nullable(),
|
|
69
|
+
files: z.array(TextChatFileSchema),
|
|
70
|
+
errorCode: z.nativeEnum(TEXT_CHAT_ERROR_CODE).nullable(),
|
|
71
|
+
price: CountSchema.nullable(),
|
|
72
|
+
createdAt: TimestampSchema,
|
|
73
|
+
});
|
|
74
|
+
export type TextChatMessage = z.infer<typeof TextChatMessageSchema>;
|
|
75
|
+
|
|
76
|
+
export const TextChatPriceSchema = z.object({
|
|
77
|
+
price: CountSchema.positive(),
|
|
78
|
+
// Distances from the requested draft inputLength; null means no boundary in that direction.
|
|
79
|
+
charsUntilNextPriceIncrease: CountSchema.positive().nullable(),
|
|
80
|
+
charsUntilNextPriceDecrease: CountSchema.positive().nullable(),
|
|
81
|
+
});
|
|
82
|
+
export type TextChatPrice = z.infer<typeof TextChatPriceSchema>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TEXT_PROVIDER_CODE } from '../../constants/text-provider';
|
|
3
|
+
import { TOOL_MODEL_STATUS } from '../../constants/tools';
|
|
4
|
+
|
|
5
|
+
/** Deployment configuration only. Never accepted as a chat request or exposed by public config. */
|
|
6
|
+
export const TextProviderSeedSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
providers: z
|
|
9
|
+
.array(
|
|
10
|
+
z
|
|
11
|
+
.object({
|
|
12
|
+
code: z.nativeEnum(TEXT_PROVIDER_CODE),
|
|
13
|
+
title: z.string().trim().min(1),
|
|
14
|
+
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
15
|
+
})
|
|
16
|
+
.strict(),
|
|
17
|
+
)
|
|
18
|
+
.max(3),
|
|
19
|
+
links: z.array(
|
|
20
|
+
z
|
|
21
|
+
.object({
|
|
22
|
+
modelId: z.string().uuid(),
|
|
23
|
+
providerCode: z.nativeEnum(TEXT_PROVIDER_CODE),
|
|
24
|
+
providerModel: z.string().trim().min(1),
|
|
25
|
+
priority: z.number().int().safe(),
|
|
26
|
+
trafficPercent: z.number().int().min(0).max(100),
|
|
27
|
+
})
|
|
28
|
+
.strict(),
|
|
29
|
+
),
|
|
30
|
+
})
|
|
31
|
+
.strict()
|
|
32
|
+
.superRefine((config, context) => {
|
|
33
|
+
if (
|
|
34
|
+
new Set(config.providers.map((provider) => provider.code)).size !==
|
|
35
|
+
config.providers.length
|
|
36
|
+
) {
|
|
37
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: 'Duplicate provider' });
|
|
38
|
+
}
|
|
39
|
+
const pairs = config.links.map((link) => `${link.modelId}:${link.providerCode}`);
|
|
40
|
+
if (new Set(pairs).size !== pairs.length) {
|
|
41
|
+
context.addIssue({
|
|
42
|
+
code: z.ZodIssueCode.custom,
|
|
43
|
+
message: 'Duplicate model/provider link',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export type TextProviderSeed = z.infer<typeof TextProviderSeedSchema>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TEXT_CHAT_ERROR_CODE, TEXT_CHAT_STREAM_EVENT } from '../../constants/text-chat';
|
|
3
|
+
|
|
4
|
+
const correlation = {
|
|
5
|
+
chatId: z.string().uuid(),
|
|
6
|
+
messageId: z.string().uuid(),
|
|
7
|
+
sequence: z.number().int().safe().nonnegative(),
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const TextChatStreamFrameSchema = z.discriminatedUnion('type', [
|
|
11
|
+
z
|
|
12
|
+
.object({
|
|
13
|
+
...correlation,
|
|
14
|
+
type: z.literal(TEXT_CHAT_STREAM_EVENT.START),
|
|
15
|
+
userMessageId: z.string().uuid(),
|
|
16
|
+
modelId: z.string().uuid(),
|
|
17
|
+
})
|
|
18
|
+
.strict(),
|
|
19
|
+
z
|
|
20
|
+
.object({
|
|
21
|
+
...correlation,
|
|
22
|
+
type: z.literal(TEXT_CHAT_STREAM_EVENT.DELTA),
|
|
23
|
+
delta: z.string().min(1),
|
|
24
|
+
})
|
|
25
|
+
.strict(),
|
|
26
|
+
z
|
|
27
|
+
.object({
|
|
28
|
+
...correlation,
|
|
29
|
+
type: z.literal(TEXT_CHAT_STREAM_EVENT.FINISH),
|
|
30
|
+
price: z.number().int().safe().positive(),
|
|
31
|
+
})
|
|
32
|
+
.strict(),
|
|
33
|
+
z
|
|
34
|
+
.object({
|
|
35
|
+
...correlation,
|
|
36
|
+
type: z.literal(TEXT_CHAT_STREAM_EVENT.ERROR),
|
|
37
|
+
code: z.nativeEnum(TEXT_CHAT_ERROR_CODE),
|
|
38
|
+
message: z.string().min(1).optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict(),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
export type TextChatStreamFrame = z.infer<typeof TextChatStreamFrameSchema>;
|
package/models/user.schema.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { USER_ROLE, USER_STATUS } from '../constants';
|
|
3
3
|
|
|
4
|
+
export const EmailInputSchema = z.string().trim().toLowerCase().email();
|
|
5
|
+
|
|
4
6
|
export const UserSchema = z.object({
|
|
5
7
|
uuid: z.string().uuid().optional(),
|
|
6
8
|
siteId: z.string().uuid().optional(),
|
|
7
|
-
email:
|
|
9
|
+
email: EmailInputSchema,
|
|
8
10
|
password: z.string().min(6).max(128),
|
|
9
11
|
role: z.nativeEnum(USER_ROLE).optional(),
|
|
10
12
|
status: z.nativeEnum(USER_STATUS).optional(),
|
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CatalogGroupAdminSchema, PublicCatalogGroupSchema } from '../../models/catalog';
|
|
3
|
+
|
|
4
|
+
export namespace GetCatalogCommand {
|
|
5
|
+
export const ResponseSchema = z.object({ data: z.array(PublicCatalogGroupSchema) });
|
|
6
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
7
|
+
}
|
|
8
|
+
export namespace GetCatalogGroupCommand {
|
|
9
|
+
export const RequestParamsSchema = z.object({ uuid: z.string().uuid() }).strict();
|
|
10
|
+
export const ResponseSchema = z.object({ data: CatalogGroupAdminSchema });
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
|
13
|
+
export namespace FindCatalogGroupsCommand {
|
|
14
|
+
export const RequestQuerySchema = z
|
|
15
|
+
.object({
|
|
16
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
17
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
export const ResponseSchema = z.object({
|
|
21
|
+
data: z.array(CatalogGroupAdminSchema),
|
|
22
|
+
meta: z.object({
|
|
23
|
+
limit: z.number().int().positive(),
|
|
24
|
+
offset: z.number().int().nonnegative(),
|
|
25
|
+
total: z.number().int().nonnegative(),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
29
|
+
}
|
package/queries/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ const UserToSubscriptionSummarySchema = z.object({
|
|
|
14
14
|
carriedOverTokenBalance: z.number().int(),
|
|
15
15
|
status: z.nativeEnum(USER_TO_SUBSCRIPTION_STATUS),
|
|
16
16
|
active: z.boolean(),
|
|
17
|
+
endDate: z.date().or(z.string().datetime()).nullable(),
|
|
17
18
|
createdAt: z.date().or(z.string().datetime()),
|
|
18
19
|
subscription: SubscriptionSchema,
|
|
19
20
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TOOL_TYPE } from '../../constants/tools';
|
|
3
|
+
import { TEXT_CHAT_CATEGORY_SCOPE } from '../../constants/text-chat';
|
|
4
|
+
import {
|
|
5
|
+
TextChatCategoryAdminSchema,
|
|
6
|
+
TextChatCategoryPublicSchema,
|
|
7
|
+
} from '../../models/text-chat/category.schema';
|
|
8
|
+
|
|
9
|
+
const PaginationSchema = z.object({
|
|
10
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
11
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
12
|
+
});
|
|
13
|
+
const MetaSchema = z.object({
|
|
14
|
+
limit: z.number().int().positive(),
|
|
15
|
+
offset: z.number().int().nonnegative(),
|
|
16
|
+
total: z.number().int().nonnegative(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export namespace FindTextChatCategoriesCommand {
|
|
20
|
+
export const RequestQuerySchema = PaginationSchema.strict();
|
|
21
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
22
|
+
export const ResponseSchema = z.object({
|
|
23
|
+
data: z.array(TextChatCategoryPublicSchema),
|
|
24
|
+
meta: MetaSchema,
|
|
25
|
+
});
|
|
26
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
27
|
+
}
|
|
28
|
+
export namespace GetTextChatCategoryCommand {
|
|
29
|
+
export const RequestParamsSchema = z.object({ uuid: z.string().uuid() }).strict();
|
|
30
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
31
|
+
export const ResponseSchema = z.object({ data: TextChatCategoryPublicSchema });
|
|
32
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
33
|
+
}
|
|
34
|
+
export namespace FindAdminTextChatCategoriesCommand {
|
|
35
|
+
export const RequestQuerySchema = PaginationSchema.extend({
|
|
36
|
+
toolType: z.nativeEnum(TOOL_TYPE).optional(),
|
|
37
|
+
scope: z.nativeEnum(TEXT_CHAT_CATEGORY_SCOPE).default(TEXT_CHAT_CATEGORY_SCOPE.ACTIVE),
|
|
38
|
+
}).strict();
|
|
39
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
40
|
+
export const ResponseSchema = z.object({
|
|
41
|
+
data: z.array(TextChatCategoryAdminSchema),
|
|
42
|
+
meta: MetaSchema,
|
|
43
|
+
});
|
|
44
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
45
|
+
}
|
|
46
|
+
export namespace GetAdminTextChatCategoryCommand {
|
|
47
|
+
export const RequestParamsSchema = GetTextChatCategoryCommand.RequestParamsSchema;
|
|
48
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
49
|
+
export const ResponseSchema = z.object({ data: TextChatCategoryAdminSchema });
|
|
50
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export * from './category';
|
|
3
|
+
import {
|
|
4
|
+
TextChatConfigSchema,
|
|
5
|
+
TextChatMessageSchema,
|
|
6
|
+
TextChatSchema,
|
|
7
|
+
} from '../../models/text-chat';
|
|
8
|
+
|
|
9
|
+
export namespace GetTextChatConfigCommand {
|
|
10
|
+
export const ResponseSchema = z.object({ data: TextChatConfigSchema });
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export namespace FindTextChatsCommand {
|
|
15
|
+
export const RequestQuerySchema = z.object({
|
|
16
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
17
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
18
|
+
search: z.string().trim().max(200).optional(),
|
|
19
|
+
});
|
|
20
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
21
|
+
export const ResponseSchema = z.object({
|
|
22
|
+
data: z.array(TextChatSchema),
|
|
23
|
+
meta: z.object({
|
|
24
|
+
limit: z.number().int().positive(),
|
|
25
|
+
offset: z.number().int().nonnegative(),
|
|
26
|
+
total: z.number().int().nonnegative(),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export namespace GetTextChatCommand {
|
|
33
|
+
export const RequestParamsSchema = z.object({ uuid: z.string().uuid() });
|
|
34
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
35
|
+
export const ResponseSchema = z.object({ data: TextChatSchema });
|
|
36
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export namespace FindTextChatMessagesCommand {
|
|
40
|
+
export const RequestParamsSchema = z.object({ uuid: z.string().uuid() });
|
|
41
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
42
|
+
export const RequestQuerySchema = z.object({
|
|
43
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
44
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
45
|
+
});
|
|
46
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
47
|
+
export const ResponseSchema = z.object({
|
|
48
|
+
data: z.array(TextChatMessageSchema),
|
|
49
|
+
meta: z.object({
|
|
50
|
+
limit: z.number().int().positive(),
|
|
51
|
+
offset: z.number().int().nonnegative(),
|
|
52
|
+
total: z.number().int().nonnegative(),
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
56
|
+
}
|