@ai-grator/api 0.3.90 → 0.3.91

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.
Files changed (33) hide show
  1. package/admin/models/admin-trend-response.schema.ts +2 -0
  2. package/build/admin/endpoints/commands/create-admin-trend.command.d.ts +16 -0
  3. package/build/admin/endpoints/commands/create-admin-trend.command.d.ts.map +1 -1
  4. package/build/admin/endpoints/commands/update-admin-trend-status.command.d.ts +12 -0
  5. package/build/admin/endpoints/commands/update-admin-trend-status.command.d.ts.map +1 -1
  6. package/build/admin/endpoints/commands/update-admin-trend.command.d.ts +16 -0
  7. package/build/admin/endpoints/commands/update-admin-trend.command.d.ts.map +1 -1
  8. package/build/admin/endpoints/queries/get-admin-trend.query.d.ts +12 -0
  9. package/build/admin/endpoints/queries/get-admin-trend.query.d.ts.map +1 -1
  10. package/build/admin/models/admin-trend-response.schema.d.ts +12 -0
  11. package/build/admin/models/admin-trend-response.schema.d.ts.map +1 -1
  12. package/build/admin/models/admin-trend-response.schema.js +2 -0
  13. package/build/errors/errors.d.ts +5 -0
  14. package/build/errors/errors.d.ts.map +1 -1
  15. package/build/errors/errors.js +5 -0
  16. package/build/trend/endpoints/commands/generate-trend.command.d.ts +4 -4
  17. package/build/trend/endpoints/commands/generate-trend.command.js +2 -2
  18. package/build/trend/endpoints/queries/get-public-trend-by-slug.query.d.ts +12 -0
  19. package/build/trend/endpoints/queries/get-public-trend-by-slug.query.d.ts.map +1 -1
  20. package/build/trend/endpoints/queries/list-public-trends.query.d.ts +12 -0
  21. package/build/trend/endpoints/queries/list-public-trends.query.d.ts.map +1 -1
  22. package/build/trend/models/public-trend.schema.d.ts +24 -0
  23. package/build/trend/models/public-trend.schema.d.ts.map +1 -1
  24. package/build/trend/models/public-trend.schema.js +8 -1
  25. package/build/trend/models/trend-input.schema.d.ts +7 -2
  26. package/build/trend/models/trend-input.schema.d.ts.map +1 -1
  27. package/build/trend/models/trend-input.schema.js +23 -0
  28. package/build/tsconfig.tsbuildinfo +1 -1
  29. package/errors/errors.ts +5 -0
  30. package/package.json +1 -1
  31. package/trend/endpoints/commands/generate-trend.command.ts +2 -2
  32. package/trend/models/public-trend.schema.ts +9 -0
  33. package/trend/models/trend-input.schema.ts +32 -1
package/errors/errors.ts CHANGED
@@ -1465,6 +1465,11 @@ export const ERRORS = {
1465
1465
  code: 'TREND.FIELD_VALUE_TYPE_MISMATCH',
1466
1466
  message: 'Тип значения не совпадает с типом поля',
1467
1467
  },
1468
+ FIELD_DEFAULT_FILE_NOT_IMAGE: {
1469
+ httpCode: 400,
1470
+ code: 'TREND.FIELD_DEFAULT_FILE_NOT_IMAGE',
1471
+ message: 'Файл по умолчанию для поля должен быть изображением',
1472
+ },
1468
1473
  FIELD_FILE_NOT_IMAGE: {
1469
1474
  httpCode: 400,
1470
1475
  code: 'TREND.FIELD_FILE_NOT_IMAGE',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-grator/api",
3
- "version": "0.3.90",
3
+ "version": "0.3.91",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -31,11 +31,11 @@ export const GenerateTrendCommandBody = z.object({
31
31
  quality: TrendQualitySchema,
32
32
  values: z
33
33
  .array(TrendFieldValueSchema)
34
- .min(1)
35
34
  .max(TREND_MAX_FIELDS)
36
35
  .refine((values) => new Set(values.map(({ fieldId }) => fieldId)).size === values.length, {
37
36
  message: 'Each field can have only one value',
38
- }),
37
+ })
38
+ .default([]),
39
39
  });
40
40
 
41
41
  export const GenerateTrendCommandResponse = GenerationJobResponseSchema;
@@ -13,11 +13,19 @@ export const PublicTrendCategorySchema = z.object({
13
13
  name: z.string(),
14
14
  });
15
15
 
16
+ export const PublicTrendFieldFileSchema = z.object({
17
+ uuid: z.uuid(),
18
+ url: z.url(),
19
+ thumbnailUrl: z.url().nullable(),
20
+ });
21
+
16
22
  export const PublicTrendFieldSchema = z.object({
17
23
  uuid: z.uuid(),
18
24
  type: TrendFieldTypeSchema,
19
25
  name: z.string(),
20
26
  order: z.int().nonnegative(),
27
+ defaultFile: PublicTrendFieldFileSchema.nullable(),
28
+ defaultText: z.string().nullable(),
21
29
  });
22
30
 
23
31
  export const PublicTrendCardSchema = z.object({
@@ -54,6 +62,7 @@ export const PublicTrendSchema = PublicTrendCardSchema.extend({
54
62
  });
55
63
 
56
64
  export type PublicTrendCategorySchemaType = z.infer<typeof PublicTrendCategorySchema>;
65
+ export type PublicTrendFieldFileSchemaType = z.infer<typeof PublicTrendFieldFileSchema>;
57
66
  export type PublicTrendFieldSchemaType = z.infer<typeof PublicTrendFieldSchema>;
58
67
  export type PublicTrendCardSchemaType = z.infer<typeof PublicTrendCardSchema>;
59
68
  export type PublicTrendModelSchemaType = z.infer<typeof PublicTrendModelSchema>;
@@ -1,5 +1,12 @@
1
1
  import { z } from 'zod';
2
- import { TREND_MAX_FIELDS, TREND_MIN_FIELDS, TREND_PROMPT_MAX_LENGTH, TREND_TITLE_MAX_LENGTH } from '../enums';
2
+ import {
3
+ TREND_FIELD_TYPE,
4
+ TREND_MAX_FIELDS,
5
+ TREND_MIN_FIELDS,
6
+ TREND_PROMPT_MAX_LENGTH,
7
+ TREND_TEXT_VALUE_MAX_LENGTH,
8
+ TREND_TITLE_MAX_LENGTH,
9
+ } from '../enums';
3
10
  import {
4
11
  TrendAspectRatioSchema,
5
12
  TrendDurationSecSchema,
@@ -13,6 +20,13 @@ export const TrendFieldInputSchema = z.object({
13
20
  uuid: z.uuid().optional(),
14
21
  type: TrendFieldTypeSchema,
15
22
  name: TrendFieldNameSchema,
23
+ defaultFileId: z.uuid().nullish(),
24
+ defaultText: z
25
+ .string()
26
+ .trim()
27
+ .max(TREND_TEXT_VALUE_MAX_LENGTH)
28
+ .transform((text) => text || null)
29
+ .nullish(),
16
30
  });
17
31
 
18
32
  export const TrendModelInputSchema = z.object({
@@ -49,6 +63,23 @@ export const TrendInputSchema = z
49
63
  });
50
64
  }
51
65
 
66
+ trend.fields.forEach((field, index) => {
67
+ if (field.type !== TREND_FIELD_TYPE.FILE && field.defaultFileId) {
68
+ ctx.addIssue({
69
+ code: 'custom',
70
+ path: ['fields', index, 'defaultFileId'],
71
+ message: 'Default file is allowed only for file fields',
72
+ });
73
+ }
74
+ if (field.type !== TREND_FIELD_TYPE.TEXT && field.defaultText) {
75
+ ctx.addIssue({
76
+ code: 'custom',
77
+ path: ['fields', index, 'defaultText'],
78
+ message: 'Default text is allowed only for text fields',
79
+ });
80
+ }
81
+ });
82
+
52
83
  const fieldUuids = trend.fields.flatMap((field) => (field.uuid ? [field.uuid] : []));
53
84
  if (findDuplicates(fieldUuids).length > 0) {
54
85
  ctx.addIssue({ code: 'custom', path: ['fields'], message: 'Field uuids must be unique' });