@ai-grator/api 0.1.45 → 0.1.47
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/ai-model/models/ai-model-response.schema.ts +21 -11
- 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/contact-form/endpoints/commands/submit-contact-form.command.d.ts +2 -0
- package/build/contact-form/endpoints/commands/submit-contact-form.command.d.ts.map +1 -1
- package/build/contact-form/endpoints/commands/submit-contact-form.command.js +1 -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/tsconfig.tsbuildinfo +1 -1
- package/contact-form/endpoints/commands/submit-contact-form.command.ts +1 -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/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
|
@@ -5,6 +5,7 @@ import { CONTACT_FORM_ROUTES } from '../contact-form';
|
|
|
5
5
|
export const SubmitContactFormCommandBody = z.object({
|
|
6
6
|
email: z.email(),
|
|
7
7
|
message: z.string().trim().min(1).max(2000),
|
|
8
|
+
marketingConsent: z.boolean(),
|
|
8
9
|
});
|
|
9
10
|
|
|
10
11
|
export const SubmitContactFormCommandResponse = HttpSuccessResponseSchema;
|
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({
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-openapi.d.ts","sourceRoot":"","sources":["../../scripts/generate-openapi.ts"],"names":[],"mappings":""}
|