@ai-grator/api 0.1.46 → 0.1.48
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/admin/endpoints/commands/create-admin-page.command.ts +1 -1
- package/admin/endpoints/commands/update-admin-page.command.ts +11 -2
- package/admin/models/admin-page-issue.schema.ts +15 -0
- package/admin/models/admin-page-response.schema.ts +2 -0
- package/admin/models/index.ts +1 -0
- package/ai-model/models/ai-model-response.schema.ts +21 -11
- package/build/admin/endpoints/commands/create-admin-page.command.d.ts +28 -12
- package/build/admin/endpoints/commands/create-admin-page.command.d.ts.map +1 -1
- package/build/admin/endpoints/commands/create-admin-page.command.js +1 -1
- package/build/admin/endpoints/commands/update-admin-page-status.command.d.ts +16 -0
- package/build/admin/endpoints/commands/update-admin-page-status.command.d.ts.map +1 -1
- package/build/admin/endpoints/commands/update-admin-page.command.d.ts +51 -30
- package/build/admin/endpoints/commands/update-admin-page.command.d.ts.map +1 -1
- package/build/admin/endpoints/commands/update-admin-page.command.js +3 -1
- package/build/admin/endpoints/queries/get-admin-page.query.d.ts +16 -0
- package/build/admin/endpoints/queries/get-admin-page.query.d.ts.map +1 -1
- package/build/admin/models/admin-page-issue.schema.d.ts +16 -0
- package/build/admin/models/admin-page-issue.schema.d.ts.map +1 -0
- package/build/admin/models/admin-page-issue.schema.js +13 -0
- package/build/admin/models/admin-page-response.schema.d.ts +8 -0
- package/build/admin/models/admin-page-response.schema.d.ts.map +1 -1
- package/build/admin/models/admin-page-response.schema.js +2 -0
- package/build/admin/models/index.d.ts +1 -0
- package/build/admin/models/index.d.ts.map +1 -1
- package/build/admin/models/index.js +1 -0
- package/build/ai-model/endpoints/queries/get-ai-model-by-uuid.query.d.ts +24 -6
- package/build/ai-model/endpoints/queries/get-ai-model-by-uuid.query.d.ts.map +1 -1
- package/build/ai-model/endpoints/queries/get-ai-models.query.d.ts +24 -6
- package/build/ai-model/endpoints/queries/get-ai-models.query.d.ts.map +1 -1
- package/build/ai-model/models/ai-model-response.schema.d.ts +32 -3
- package/build/ai-model/models/ai-model-response.schema.d.ts.map +1 -1
- package/build/ai-model/models/ai-model-response.schema.js +18 -11
- package/build/errors/errors.d.ts +5 -0
- package/build/errors/errors.d.ts.map +1 -1
- package/build/errors/errors.js +5 -0
- package/build/file/enums/file.enum.d.ts +3 -2
- package/build/file/enums/file.enum.d.ts.map +1 -1
- package/build/file/helpers/index.d.ts +1 -0
- package/build/file/helpers/index.d.ts.map +1 -1
- package/build/file/helpers/index.js +1 -0
- package/build/file/helpers/supported-files.helper.d.ts +13 -0
- package/build/file/helpers/supported-files.helper.d.ts.map +1 -0
- package/build/file/helpers/supported-files.helper.js +78 -0
- package/build/file/models/index.d.ts +1 -0
- package/build/file/models/index.d.ts.map +1 -1
- package/build/file/models/index.js +1 -0
- package/build/file/models/supported-files.schema.d.ts +19 -0
- package/build/file/models/supported-files.schema.d.ts.map +1 -0
- package/build/file/models/supported-files.schema.js +15 -0
- package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts +18 -0
- package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts.map +1 -1
- package/build/model-page/models/public-model-detail.schema.d.ts +27 -0
- package/build/model-page/models/public-model-detail.schema.d.ts.map +1 -1
- package/build/model-page/models/public-model-detail.schema.js +1 -0
- package/build/model-page/models/seo-meta.schema.d.ts +24 -4
- package/build/model-page/models/seo-meta.schema.d.ts.map +1 -1
- package/build/model-page/models/seo-meta.schema.js +7 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/errors/errors.ts +5 -0
- package/file/enums/file.enum.ts +7 -8
- package/file/helpers/index.ts +1 -0
- package/file/helpers/supported-files.helper.ts +102 -0
- package/file/models/index.ts +1 -0
- package/file/models/supported-files.schema.ts +17 -0
- package/model-page/models/public-model-detail.schema.ts +2 -1
- package/model-page/models/seo-meta.schema.ts +11 -4
- package/package.json +1 -1
- package/build/scripts/generate-openapi.d.ts +0 -2
- package/build/scripts/generate-openapi.d.ts.map +0 -1
- package/build/scripts/generate-openapi.js +0 -533
- package/scripts/generate-openapi.ts +0 -908
package/errors/errors.ts
CHANGED
|
@@ -893,6 +893,11 @@ export const ERRORS = {
|
|
|
893
893
|
code: 'MODEL_PAGE.MODEL_ALREADY_LINKED',
|
|
894
894
|
message: 'К этой модели уже привязана другая страница',
|
|
895
895
|
},
|
|
896
|
+
SEO_INCOMPLETE: {
|
|
897
|
+
httpCode: 409,
|
|
898
|
+
code: 'MODEL_PAGE.SEO_INCOMPLETE',
|
|
899
|
+
message: 'Нельзя опубликовать страницу с незаполненными title, h1 и meta description',
|
|
900
|
+
},
|
|
896
901
|
CREATE_ERROR: {
|
|
897
902
|
httpCode: 500,
|
|
898
903
|
code: 'MODEL_PAGE.CREATE_ERROR',
|
package/file/enums/file.enum.ts
CHANGED
|
@@ -14,14 +14,13 @@ export const MAX_DOCUMENT_UPLOAD_SIZE = 10 * 1024 * 1024; // 10 MB
|
|
|
14
14
|
export const MAX_AUDIO_UPLOAD_SIZE = 50 * 1024 * 1024; // 50 MB
|
|
15
15
|
export const MAX_VIDEO_UPLOAD_SIZE = 100 * 1024 * 1024; // 100 MB
|
|
16
16
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
>([
|
|
17
|
+
export interface SupportedFileDescriptor {
|
|
18
|
+
type: FILE_TYPE;
|
|
19
|
+
size: number;
|
|
20
|
+
extension: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const SUPPORTED_FILES = new Map<string, SupportedFileDescriptor>([
|
|
25
24
|
['application/json', { type: FILE_TYPE.TEXT, size: MAX_TEXT_UPLOAD_SIZE, extension: 'json' }],
|
|
26
25
|
['application/x-ndjson', { type: FILE_TYPE.TEXT, size: MAX_TEXT_UPLOAD_SIZE, extension: 'ndjson' }],
|
|
27
26
|
['application/x-yaml', { type: FILE_TYPE.TEXT, size: MAX_TEXT_UPLOAD_SIZE, extension: 'yaml' }],
|
package/file/helpers/index.ts
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FILE_TYPE, SUPPORTED_FILES, SupportedFileDescriptor } from '../enums';
|
|
3
|
+
import { FileFormatListSchemaType, SupportedFilesByTypeSchemaType, SupportedFilesSchemaType } from '../models';
|
|
4
|
+
|
|
5
|
+
type SupportedFileEntry = [string, SupportedFileDescriptor];
|
|
6
|
+
|
|
7
|
+
function catalogEntries(): SupportedFileEntry[] {
|
|
8
|
+
return [...SUPPORTED_FILES.entries()];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function unique<T>(values: T[]): T[] {
|
|
12
|
+
return [...new Set(values)];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function extensionsOfType(fileType: FILE_TYPE): string[] {
|
|
16
|
+
return unique(
|
|
17
|
+
catalogEntries()
|
|
18
|
+
.filter(([, descriptor]) => descriptor.type === fileType)
|
|
19
|
+
.map(([, descriptor]) => descriptor.extension),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function entriesFor(fileType: FILE_TYPE, extensions: readonly string[]): SupportedFileEntry[] {
|
|
24
|
+
return catalogEntries().filter(
|
|
25
|
+
([, descriptor]) => descriptor.type === fileType && extensions.includes(descriptor.extension),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type SupportedFilesMap = Partial<Record<FILE_TYPE, string[]>>;
|
|
30
|
+
|
|
31
|
+
export function unknownSupportedFiles(supportedFiles: SupportedFilesMap): Array<{
|
|
32
|
+
fileType: FILE_TYPE;
|
|
33
|
+
extension: string;
|
|
34
|
+
}> {
|
|
35
|
+
return Object.values(FILE_TYPE).flatMap((fileType) =>
|
|
36
|
+
(supportedFiles[fileType] ?? [])
|
|
37
|
+
.filter((extension) => entriesFor(fileType, [extension]).length === 0)
|
|
38
|
+
.map((extension) => ({ fileType, extension })),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const SupportedFilesMapSchema = z
|
|
43
|
+
.partialRecord(z.enum(FILE_TYPE), z.array(z.string().min(1)))
|
|
44
|
+
.superRefine((supportedFiles, ctx) => {
|
|
45
|
+
for (const { fileType, extension } of unknownSupportedFiles(supportedFiles)) {
|
|
46
|
+
ctx.addIssue({
|
|
47
|
+
code: 'custom',
|
|
48
|
+
path: [fileType],
|
|
49
|
+
message: `"${extension}" is not registered as ${fileType} in SUPPORTED_FILES`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function toByType(fileType: FILE_TYPE, entries: SupportedFileEntry[]): SupportedFilesByTypeSchemaType {
|
|
55
|
+
return {
|
|
56
|
+
type: fileType,
|
|
57
|
+
extensions: unique(entries.map(([, descriptor]) => descriptor.extension)),
|
|
58
|
+
maxSize: Math.min(...entries.map(([, descriptor]) => descriptor.size)),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function resolveSupportedFiles(supportedFiles: SupportedFilesMap): SupportedFilesSchemaType {
|
|
63
|
+
const byType: SupportedFilesByTypeSchemaType[] = [];
|
|
64
|
+
const allEntries: SupportedFileEntry[] = [];
|
|
65
|
+
|
|
66
|
+
for (const fileType of Object.values(FILE_TYPE)) {
|
|
67
|
+
const extensions = supportedFiles[fileType];
|
|
68
|
+
|
|
69
|
+
if (!extensions || extensions.length === 0) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const entries = entriesFor(fileType, extensions);
|
|
74
|
+
|
|
75
|
+
if (entries.length === 0) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
allEntries.push(...entries);
|
|
80
|
+
byType.push(toByType(fileType, entries));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
mimeTypes: unique(allEntries.map(([mimeType]) => mimeType)),
|
|
85
|
+
extensions: unique(allEntries.map(([, descriptor]) => descriptor.extension)),
|
|
86
|
+
byType,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function toFileFormatList(supportedFiles: SupportedFilesMap): FileFormatListSchemaType {
|
|
91
|
+
const resolved = resolveSupportedFiles(supportedFiles);
|
|
92
|
+
|
|
93
|
+
if (resolved.byType.length === 0) {
|
|
94
|
+
throw new Error('A file format list needs at least one supported file type');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
mimeTypes: resolved.mimeTypes,
|
|
99
|
+
extensions: resolved.extensions,
|
|
100
|
+
maxSize: Math.min(...resolved.byType.map((group) => group.maxSize)),
|
|
101
|
+
};
|
|
102
|
+
}
|
package/file/models/index.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FILE_TYPE } from '../enums';
|
|
3
|
+
|
|
4
|
+
export const SupportedFilesByTypeSchema = z.object({
|
|
5
|
+
type: z.enum(FILE_TYPE),
|
|
6
|
+
extensions: z.array(z.string()),
|
|
7
|
+
maxSize: z.int().positive(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const SupportedFilesSchema = z.object({
|
|
11
|
+
mimeTypes: z.array(z.string()),
|
|
12
|
+
extensions: z.array(z.string()),
|
|
13
|
+
byType: z.array(SupportedFilesByTypeSchema),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type SupportedFilesByTypeSchemaType = z.infer<typeof SupportedFilesByTypeSchema>;
|
|
17
|
+
export type SupportedFilesSchemaType = z.infer<typeof SupportedFilesSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { FILE_TYPE } from '../../file';
|
|
2
|
+
import { FILE_TYPE, SupportedFilesSchema } from '../../file';
|
|
3
3
|
import { ModelFamilySchema } from './model-family.schema';
|
|
4
4
|
import { PageCardSchema } from './page-card.schema';
|
|
5
5
|
import { PageContentSchema } from './page-content.schema';
|
|
@@ -11,6 +11,7 @@ export const PublicChatModelCapabilitiesSchema = z.object({
|
|
|
11
11
|
reasoning: z.boolean(),
|
|
12
12
|
webSearch: z.boolean(),
|
|
13
13
|
supportedFileTypes: z.array(z.enum(FILE_TYPE)),
|
|
14
|
+
supportedFiles: SupportedFilesSchema,
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
export const PublicChatModelDetailsSchema = z.object({
|
|
@@ -43,22 +43,29 @@ export const DraftSeoMetaSchema = SeoMetaSchema.extend({
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
export const SeoMetaInputSchema = z.object({
|
|
46
|
-
title: z.string().min(1),
|
|
47
|
-
metaDescription: z.string().min(1),
|
|
48
|
-
h1: z.string().min(1),
|
|
46
|
+
title: z.string().min(1).nullable().default(null),
|
|
47
|
+
metaDescription: z.string().min(1).nullable().default(null),
|
|
48
|
+
h1: z.string().min(1).nullable().default(null),
|
|
49
49
|
focusKeyword: z.string().min(1).nullable().default(null),
|
|
50
50
|
canonicalUrl: CanonicalUrlSchema.default(CANONICAL_URL_AUTO),
|
|
51
51
|
robotsIndex: z.enum(ROBOTS_INDEX).default(ROBOTS_INDEX.INDEX),
|
|
52
52
|
robotsFollow: z.enum(ROBOTS_FOLLOW).default(ROBOTS_FOLLOW.FOLLOW),
|
|
53
53
|
ogTitle: z.string().min(1).nullable().default(null),
|
|
54
54
|
ogDescription: z.string().min(1).nullable().default(null),
|
|
55
|
-
ogImage: z.string().min(1),
|
|
55
|
+
ogImage: z.string().min(1).nullable().default(null),
|
|
56
56
|
twitterCard: z.enum(TWITTER_CARD).default(TWITTER_CARD.SUMMARY_LARGE_IMAGE),
|
|
57
57
|
hreflangAlternates: z.array(HreflangAlternateSchema).default([]),
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
export const SeoMetaPatchSchema = DraftSeoMetaSchema.partial();
|
|
61
|
+
|
|
62
|
+
export const PUBLICATION_REQUIRED_SEO_FIELDS = ['title', 'h1', 'metaDescription'] as const;
|
|
63
|
+
|
|
64
|
+
export type PublicationRequiredSeoField = (typeof PUBLICATION_REQUIRED_SEO_FIELDS)[number];
|
|
65
|
+
|
|
60
66
|
export type HreflangAlternateSchemaType = z.infer<typeof HreflangAlternateSchema>;
|
|
61
67
|
export type SeoMetaSchemaType = z.infer<typeof SeoMetaSchema>;
|
|
62
68
|
export type PublicSeoMetaSchemaType = z.infer<typeof PublicSeoMetaSchema>;
|
|
63
69
|
export type DraftSeoMetaSchemaType = z.infer<typeof DraftSeoMetaSchema>;
|
|
64
70
|
export type SeoMetaInputSchemaType = z.infer<typeof SeoMetaInputSchema>;
|
|
71
|
+
export type SeoMetaPatchSchemaType = z.infer<typeof SeoMetaPatchSchema>;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-openapi.d.ts","sourceRoot":"","sources":["../../scripts/generate-openapi.ts"],"names":[],"mappings":""}
|