@ai-grator/api 0.3.77 → 0.3.78
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/admin.ts +16 -0
- package/admin/endpoints/commands/create-admin-preset-category.command.ts +29 -0
- package/admin/endpoints/commands/create-admin-preset.command.ts +30 -0
- package/admin/endpoints/commands/delete-admin-preset-category.command.ts +29 -0
- package/admin/endpoints/commands/delete-admin-preset.command.ts +28 -0
- package/admin/endpoints/commands/index.ts +9 -0
- package/admin/endpoints/commands/reorder-admin-preset-categories.command.ts +33 -0
- package/admin/endpoints/commands/reorder-admin-presets.command.ts +33 -0
- package/admin/endpoints/commands/update-admin-preset-category.command.ts +36 -0
- package/admin/endpoints/commands/update-admin-preset-status.command.ts +37 -0
- package/admin/endpoints/commands/update-admin-preset.command.ts +36 -0
- package/admin/endpoints/queries/get-admin-preset-categories.query.ts +22 -0
- package/admin/endpoints/queries/get-admin-preset.query.ts +29 -0
- package/admin/endpoints/queries/get-admin-presets.query.ts +37 -0
- package/admin/endpoints/queries/index.ts +3 -0
- package/admin/models/admin-preset-category-response.schema.ts +14 -0
- package/admin/models/admin-preset-response.schema.ts +67 -0
- package/admin/models/index.ts +2 -0
- package/build/admin/endpoints/admin.d.ts +12 -0
- package/build/admin/endpoints/admin.d.ts.map +1 -1
- package/build/admin/endpoints/admin.js +14 -0
- package/build/admin/endpoints/commands/create-admin-preset-category.command.d.ts +51 -0
- package/build/admin/endpoints/commands/create-admin-preset-category.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/create-admin-preset-category.command.js +25 -0
- package/build/admin/endpoints/commands/create-admin-preset.command.d.ts +490 -0
- package/build/admin/endpoints/commands/create-admin-preset.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/create-admin-preset.command.js +26 -0
- package/build/admin/endpoints/commands/delete-admin-preset-category.command.d.ts +27 -0
- package/build/admin/endpoints/commands/delete-admin-preset-category.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/delete-admin-preset-category.command.js +26 -0
- package/build/admin/endpoints/commands/delete-admin-preset.command.d.ts +26 -0
- package/build/admin/endpoints/commands/delete-admin-preset.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/delete-admin-preset.command.js +25 -0
- package/build/admin/endpoints/commands/index.d.ts +9 -0
- package/build/admin/endpoints/commands/index.d.ts.map +1 -1
- package/build/admin/endpoints/commands/index.js +9 -0
- package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.d.ts +26 -0
- package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.js +28 -0
- package/build/admin/endpoints/commands/reorder-admin-presets.command.d.ts +29 -0
- package/build/admin/endpoints/commands/reorder-admin-presets.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/reorder-admin-presets.command.js +30 -0
- package/build/admin/endpoints/commands/update-admin-preset-category.command.d.ts +59 -0
- package/build/admin/endpoints/commands/update-admin-preset-category.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/update-admin-preset-category.command.js +31 -0
- package/build/admin/endpoints/commands/update-admin-preset-status.command.d.ts +312 -0
- package/build/admin/endpoints/commands/update-admin-preset-status.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/update-admin-preset-status.command.js +32 -0
- package/build/admin/endpoints/commands/update-admin-preset.command.d.ts +497 -0
- package/build/admin/endpoints/commands/update-admin-preset.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/update-admin-preset.command.js +31 -0
- package/build/admin/endpoints/queries/get-admin-preset-categories.query.d.ts +38 -0
- package/build/admin/endpoints/queries/get-admin-preset-categories.query.d.ts.map +1 -0
- package/build/admin/endpoints/queries/get-admin-preset-categories.query.js +21 -0
- package/build/admin/endpoints/queries/get-admin-preset.query.d.ts +304 -0
- package/build/admin/endpoints/queries/get-admin-preset.query.d.ts.map +1 -0
- package/build/admin/endpoints/queries/get-admin-preset.query.js +26 -0
- package/build/admin/endpoints/queries/get-admin-presets.query.d.ts +141 -0
- package/build/admin/endpoints/queries/get-admin-presets.query.d.ts.map +1 -0
- package/build/admin/endpoints/queries/get-admin-presets.query.js +34 -0
- package/build/admin/endpoints/queries/index.d.ts +3 -0
- package/build/admin/endpoints/queries/index.d.ts.map +1 -1
- package/build/admin/endpoints/queries/index.js +3 -0
- package/build/admin/models/admin-preset-category-response.schema.d.ts +13 -0
- package/build/admin/models/admin-preset-category-response.schema.d.ts.map +1 -0
- package/build/admin/models/admin-preset-category-response.schema.js +14 -0
- package/build/admin/models/admin-preset-response.schema.d.ts +205 -0
- package/build/admin/models/admin-preset-response.schema.d.ts.map +1 -0
- package/build/admin/models/admin-preset-response.schema.js +52 -0
- package/build/admin/models/index.d.ts +2 -0
- package/build/admin/models/index.d.ts.map +1 -1
- package/build/admin/models/index.js +2 -0
- package/build/chat/endpoints/commands/create-chat.command.d.ts +8 -0
- package/build/chat/endpoints/commands/create-chat.command.d.ts.map +1 -1
- package/build/chat/endpoints/commands/update-chat.command.d.ts +8 -0
- package/build/chat/endpoints/commands/update-chat.command.d.ts.map +1 -1
- package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts +8 -0
- package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts.map +1 -1
- package/build/chat/endpoints/queries/get-chats.query.d.ts +10 -0
- package/build/chat/endpoints/queries/get-chats.query.d.ts.map +1 -1
- package/build/chat/endpoints/queries/get-chats.query.js +4 -1
- package/build/chat/models/chat-response.schema.d.ts +4 -0
- package/build/chat/models/chat-response.schema.d.ts.map +1 -1
- package/build/chat/models/chat-response.schema.js +2 -0
- package/build/errors/errors.d.ts +202 -0
- package/build/errors/errors.d.ts.map +1 -1
- package/build/errors/errors.js +202 -0
- package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts +8 -0
- package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts.map +1 -1
- package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts +8 -0
- package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts.map +1 -1
- package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts +8 -0
- package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts.map +1 -1
- package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts +14 -0
- package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts.map +1 -1
- package/build/generation-job/endpoints/queries/get-generation-job-history.query.js +2 -0
- package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts +10 -0
- package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts.map +1 -1
- package/build/generation-job/endpoints/queries/get-generation-jobs.query.js +2 -0
- package/build/generation-job/models/generation-job-response.schema.d.ts +4 -0
- package/build/generation-job/models/generation-job-response.schema.d.ts.map +1 -1
- package/build/generation-job/models/generation-job-response.schema.js +2 -0
- package/build/generation-job-chat/endpoints/commands/create-generation-job-chat.command.d.ts +8 -0
- package/build/generation-job-chat/endpoints/commands/create-generation-job-chat.command.d.ts.map +1 -1
- package/build/generation-job-chat/endpoints/commands/update-generation-job-chat.command.d.ts +8 -0
- package/build/generation-job-chat/endpoints/commands/update-generation-job-chat.command.d.ts.map +1 -1
- package/build/generation-job-chat/endpoints/queries/get-generation-job-chat-by-uuid.query.d.ts +8 -0
- package/build/generation-job-chat/endpoints/queries/get-generation-job-chat-by-uuid.query.d.ts.map +1 -1
- package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.d.ts +10 -0
- package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.d.ts.map +1 -1
- package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.js +2 -0
- package/build/generation-job-chat/models/generation-job-chat-response.schema.d.ts +4 -0
- package/build/generation-job-chat/models/generation-job-chat-response.schema.d.ts.map +1 -1
- package/build/generation-job-chat/models/generation-job-chat-response.schema.js +2 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/preset/endpoints/commands/add-preset-favorite.command.d.ts +25 -0
- package/build/preset/endpoints/commands/add-preset-favorite.command.d.ts.map +1 -0
- package/build/preset/endpoints/commands/add-preset-favorite.command.js +22 -0
- package/build/preset/endpoints/commands/index.d.ts +5 -0
- package/build/preset/endpoints/commands/index.d.ts.map +1 -0
- package/build/preset/endpoints/commands/index.js +20 -0
- package/build/preset/endpoints/commands/prepare-preset.command.d.ts +198 -0
- package/build/preset/endpoints/commands/prepare-preset.command.d.ts.map +1 -0
- package/build/preset/endpoints/commands/prepare-preset.command.js +41 -0
- package/build/preset/endpoints/commands/remove-preset-favorite.command.d.ts +25 -0
- package/build/preset/endpoints/commands/remove-preset-favorite.command.d.ts.map +1 -0
- package/build/preset/endpoints/commands/remove-preset-favorite.command.js +22 -0
- package/build/preset/endpoints/commands/run-preset.command.d.ts +387 -0
- package/build/preset/endpoints/commands/run-preset.command.d.ts.map +1 -0
- package/build/preset/endpoints/commands/run-preset.command.js +55 -0
- package/build/preset/endpoints/index.d.ts +4 -0
- package/build/preset/endpoints/index.d.ts.map +1 -0
- package/build/preset/endpoints/index.js +19 -0
- package/build/preset/endpoints/preset.d.ts +16 -0
- package/build/preset/endpoints/preset.d.ts.map +1 -0
- package/build/preset/endpoints/preset.js +18 -0
- package/build/preset/endpoints/queries/get-preset-price.query.d.ts +62 -0
- package/build/preset/endpoints/queries/get-preset-price.query.d.ts.map +1 -0
- package/build/preset/endpoints/queries/get-preset-price.query.js +30 -0
- package/build/preset/endpoints/queries/get-preset-results.query.d.ts +74 -0
- package/build/preset/endpoints/queries/get-preset-results.query.d.ts.map +1 -0
- package/build/preset/endpoints/queries/get-preset-results.query.js +32 -0
- package/build/preset/endpoints/queries/get-public-preset-by-slug.query.d.ts +334 -0
- package/build/preset/endpoints/queries/get-public-preset-by-slug.query.d.ts.map +1 -0
- package/build/preset/endpoints/queries/get-public-preset-by-slug.query.js +25 -0
- package/build/preset/endpoints/queries/index.d.ts +6 -0
- package/build/preset/endpoints/queries/index.d.ts.map +1 -0
- package/build/preset/endpoints/queries/index.js +21 -0
- package/build/preset/endpoints/queries/list-public-preset-categories.query.d.ts +28 -0
- package/build/preset/endpoints/queries/list-public-preset-categories.query.d.ts.map +1 -0
- package/build/preset/endpoints/queries/list-public-preset-categories.query.js +19 -0
- package/build/preset/endpoints/queries/list-public-presets.query.d.ts +122 -0
- package/build/preset/endpoints/queries/list-public-presets.query.d.ts.map +1 -0
- package/build/preset/endpoints/queries/list-public-presets.query.js +32 -0
- package/build/preset/enums/index.d.ts +10 -0
- package/build/preset/enums/index.d.ts.map +1 -0
- package/build/preset/enums/index.js +25 -0
- package/build/preset/enums/preset-card-media-type.enum.d.ts +6 -0
- package/build/preset/enums/preset-card-media-type.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-card-media-type.enum.js +9 -0
- package/build/preset/enums/preset-example-type.enum.d.ts +5 -0
- package/build/preset/enums/preset-example-type.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-example-type.enum.js +8 -0
- package/build/preset/enums/preset-field-type.enum.d.ts +6 -0
- package/build/preset/enums/preset-field-type.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-field-type.enum.js +9 -0
- package/build/preset/enums/preset-filter.enum.d.ts +6 -0
- package/build/preset/enums/preset-filter.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-filter.enum.js +9 -0
- package/build/preset/enums/preset-limits.d.ts +30 -0
- package/build/preset/enums/preset-limits.d.ts.map +1 -0
- package/build/preset/enums/preset-limits.js +32 -0
- package/build/preset/enums/preset-result-type.enum.d.ts +5 -0
- package/build/preset/enums/preset-result-type.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-result-type.enum.js +8 -0
- package/build/preset/enums/preset-select-display.enum.d.ts +7 -0
- package/build/preset/enums/preset-select-display.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-select-display.enum.js +10 -0
- package/build/preset/enums/preset-status.enum.d.ts +5 -0
- package/build/preset/enums/preset-status.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-status.enum.js +8 -0
- package/build/preset/enums/preset-tool.enum.d.ts +6 -0
- package/build/preset/enums/preset-tool.enum.d.ts.map +1 -0
- package/build/preset/enums/preset-tool.enum.js +9 -0
- package/build/preset/helpers/index.d.ts +3 -0
- package/build/preset/helpers/index.d.ts.map +1 -0
- package/build/preset/helpers/index.js +18 -0
- package/build/preset/helpers/preset-prompt-placeholder.helper.d.ts +4 -0
- package/build/preset/helpers/preset-prompt-placeholder.helper.d.ts.map +1 -0
- package/build/preset/helpers/preset-prompt-placeholder.helper.js +12 -0
- package/build/preset/helpers/preset-tag.helper.d.ts +3 -0
- package/build/preset/helpers/preset-tag.helper.d.ts.map +1 -0
- package/build/preset/helpers/preset-tag.helper.js +9 -0
- package/build/preset/index.d.ts +5 -0
- package/build/preset/index.d.ts.map +1 -0
- package/build/preset/index.js +20 -0
- package/build/preset/models/index.d.ts +9 -0
- package/build/preset/models/index.d.ts.map +1 -0
- package/build/preset/models/index.js +24 -0
- package/build/preset/models/preset-common.schema.d.ts +23 -0
- package/build/preset/models/preset-common.schema.d.ts.map +1 -0
- package/build/preset/models/preset-common.schema.js +26 -0
- package/build/preset/models/preset-field-value.schema.d.ts +51 -0
- package/build/preset/models/preset-field-value.schema.d.ts.map +1 -0
- package/build/preset/models/preset-field-value.schema.js +44 -0
- package/build/preset/models/preset-field.schema.d.ts +310 -0
- package/build/preset/models/preset-field.schema.d.ts.map +1 -0
- package/build/preset/models/preset-field.schema.js +186 -0
- package/build/preset/models/preset-input.schema.d.ts +106 -0
- package/build/preset/models/preset-input.schema.d.ts.map +1 -0
- package/build/preset/models/preset-input.schema.js +97 -0
- package/build/preset/models/preset-media.schema.d.ts +81 -0
- package/build/preset/models/preset-media.schema.d.ts.map +1 -0
- package/build/preset/models/preset-media.schema.js +75 -0
- package/build/preset/models/preset-result.schema.d.ts +23 -0
- package/build/preset/models/preset-result.schema.d.ts.map +1 -0
- package/build/preset/models/preset-result.schema.js +21 -0
- package/build/preset/models/preset-tag.schema.d.ts +10 -0
- package/build/preset/models/preset-tag.schema.d.ts.map +1 -0
- package/build/preset/models/preset-tag.schema.js +11 -0
- package/build/preset/models/public-preset.schema.d.ts +322 -0
- package/build/preset/models/public-preset.schema.d.ts.map +1 -0
- package/build/preset/models/public-preset.schema.js +50 -0
- package/build/trend/endpoints/commands/generate-trend.command.d.ts +8 -0
- package/build/trend/endpoints/commands/generate-trend.command.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/chat/endpoints/queries/get-chats.query.ts +4 -1
- package/chat/models/chat-response.schema.ts +2 -0
- package/errors/errors.ts +202 -0
- package/generation-job/endpoints/queries/get-generation-job-history.query.ts +2 -0
- package/generation-job/endpoints/queries/get-generation-jobs.query.ts +2 -0
- package/generation-job/models/generation-job-response.schema.ts +2 -0
- package/generation-job-chat/endpoints/queries/get-generation-job-chats.query.ts +2 -0
- package/generation-job-chat/models/generation-job-chat-response.schema.ts +2 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/preset/endpoints/commands/add-preset-favorite.command.ts +26 -0
- package/preset/endpoints/commands/index.ts +4 -0
- package/preset/endpoints/commands/prepare-preset.command.ts +47 -0
- package/preset/endpoints/commands/remove-preset-favorite.command.ts +26 -0
- package/preset/endpoints/commands/run-preset.command.ts +65 -0
- package/preset/endpoints/index.ts +3 -0
- package/preset/endpoints/preset.ts +18 -0
- package/preset/endpoints/queries/get-preset-price.query.ts +35 -0
- package/preset/endpoints/queries/get-preset-results.query.ts +37 -0
- package/preset/endpoints/queries/get-public-preset-by-slug.query.ts +30 -0
- package/preset/endpoints/queries/index.ts +5 -0
- package/preset/endpoints/queries/list-public-preset-categories.query.ts +20 -0
- package/preset/endpoints/queries/list-public-presets.query.ts +35 -0
- package/preset/enums/index.ts +9 -0
- package/preset/enums/preset-card-media-type.enum.ts +5 -0
- package/preset/enums/preset-example-type.enum.ts +4 -0
- package/preset/enums/preset-field-type.enum.ts +5 -0
- package/preset/enums/preset-filter.enum.ts +5 -0
- package/preset/enums/preset-limits.ts +33 -0
- package/preset/enums/preset-result-type.enum.ts +4 -0
- package/preset/enums/preset-select-display.enum.ts +6 -0
- package/preset/enums/preset-status.enum.ts +4 -0
- package/preset/enums/preset-tool.enum.ts +5 -0
- package/preset/helpers/index.ts +2 -0
- package/preset/helpers/preset-prompt-placeholder.helper.ts +9 -0
- package/preset/helpers/preset-tag.helper.ts +9 -0
- package/preset/index.ts +4 -0
- package/preset/models/index.ts +8 -0
- package/preset/models/preset-common.schema.ts +45 -0
- package/preset/models/preset-field-value.schema.ts +51 -0
- package/preset/models/preset-field.schema.ts +251 -0
- package/preset/models/preset-input.schema.ts +129 -0
- package/preset/models/preset-media.schema.ts +94 -0
- package/preset/models/preset-result.schema.ts +21 -0
- package/preset/models/preset-tag.schema.ts +13 -0
- package/preset/models/public-preset.schema.ts +68 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresetFileSchema = exports.PresetChatOptionsSchema = exports.PresetModelParamsSchema = exports.PresetCategoryIconSchema = exports.PresetCategoryNameSchema = exports.PresetFieldKeySchema = exports.PresetSlugSchema = exports.PresetFieldTypeSchema = exports.PresetToolSchema = exports.PresetStatusSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
exports.PresetStatusSchema = zod_1.z.enum(enums_1.PRESET_STATUS);
|
|
7
|
+
exports.PresetToolSchema = zod_1.z.enum(enums_1.PRESET_TOOL);
|
|
8
|
+
exports.PresetFieldTypeSchema = zod_1.z.enum(enums_1.PRESET_FIELD_TYPE);
|
|
9
|
+
exports.PresetSlugSchema = zod_1.z.string().min(1).max(enums_1.PRESET_SLUG_MAX_LENGTH).regex(enums_1.PRESET_SLUG_PATTERN);
|
|
10
|
+
exports.PresetFieldKeySchema = zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.max(enums_1.PRESET_FIELD_KEY_MAX_LENGTH)
|
|
14
|
+
.regex(enums_1.PRESET_FIELD_KEY_PATTERN, 'Field key must start with a-z and contain only a-z, 0-9 and _');
|
|
15
|
+
exports.PresetCategoryNameSchema = zod_1.z.string().trim().min(1).max(enums_1.PRESET_CATEGORY_NAME_MAX_LENGTH);
|
|
16
|
+
exports.PresetCategoryIconSchema = zod_1.z.string().trim().min(1).max(enums_1.PRESET_CATEGORY_ICON_MAX_LENGTH);
|
|
17
|
+
exports.PresetModelParamsSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
18
|
+
exports.PresetChatOptionsSchema = zod_1.z.object({
|
|
19
|
+
reasoning: zod_1.z.boolean().default(false),
|
|
20
|
+
webSearch: zod_1.z.boolean().default(false),
|
|
21
|
+
});
|
|
22
|
+
exports.PresetFileSchema = zod_1.z.object({
|
|
23
|
+
uuid: zod_1.z.uuid(),
|
|
24
|
+
url: zod_1.z.url(),
|
|
25
|
+
thumbnailUrl: zod_1.z.url().nullable(),
|
|
26
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PRESET_FIELD_TYPE } from '../enums';
|
|
3
|
+
export declare const PresetFileFieldValueSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
5
|
+
key: z.ZodString;
|
|
6
|
+
fileIds: z.ZodArray<z.ZodUUID>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const PresetSelectFieldValueSchema: z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
10
|
+
key: z.ZodString;
|
|
11
|
+
values: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
12
|
+
customValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const PresetTextFieldValueSchema: z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
16
|
+
key: z.ZodString;
|
|
17
|
+
text: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const PresetFieldValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
21
|
+
key: z.ZodString;
|
|
22
|
+
fileIds: z.ZodArray<z.ZodUUID>;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
values: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
27
|
+
customValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
30
|
+
key: z.ZodString;
|
|
31
|
+
text: z.ZodString;
|
|
32
|
+
}, z.core.$strip>], "type">;
|
|
33
|
+
export declare const PresetFieldValuesSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
35
|
+
key: z.ZodString;
|
|
36
|
+
fileIds: z.ZodArray<z.ZodUUID>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
39
|
+
key: z.ZodString;
|
|
40
|
+
values: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
41
|
+
customValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
44
|
+
key: z.ZodString;
|
|
45
|
+
text: z.ZodString;
|
|
46
|
+
}, z.core.$strip>], "type">>;
|
|
47
|
+
export type PresetFileFieldValueSchemaType = z.infer<typeof PresetFileFieldValueSchema>;
|
|
48
|
+
export type PresetSelectFieldValueSchemaType = z.infer<typeof PresetSelectFieldValueSchema>;
|
|
49
|
+
export type PresetTextFieldValueSchemaType = z.infer<typeof PresetTextFieldValueSchema>;
|
|
50
|
+
export type PresetFieldValueSchemaType = z.infer<typeof PresetFieldValueSchema>;
|
|
51
|
+
//# sourceMappingURL=preset-field-value.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-field-value.schema.d.ts","sourceRoot":"","sources":["../../../preset/models/preset-field-value.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA4D,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,0BAA0B;;;;iBAOrC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;iBAanC,CAAC;AAEP,eAAO,MAAM,0BAA0B;;;;iBAIrC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;2BAIjC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;4BAK9B,CAAC;AAEP,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACxF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAC5F,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACxF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresetFieldValuesSchema = exports.PresetFieldValueSchema = exports.PresetTextFieldValueSchema = exports.PresetSelectFieldValueSchema = exports.PresetFileFieldValueSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const preset_common_schema_1 = require("./preset-common.schema");
|
|
7
|
+
exports.PresetFileFieldValueSchema = zod_1.z.object({
|
|
8
|
+
type: zod_1.z.literal(enums_1.PRESET_FIELD_TYPE.FILE),
|
|
9
|
+
key: preset_common_schema_1.PresetFieldKeySchema,
|
|
10
|
+
fileIds: zod_1.z
|
|
11
|
+
.array(zod_1.z.uuid())
|
|
12
|
+
.min(1)
|
|
13
|
+
.refine((fileIds) => new Set(fileIds).size === fileIds.length, { message: 'File ids must be unique' }),
|
|
14
|
+
});
|
|
15
|
+
exports.PresetSelectFieldValueSchema = zod_1.z
|
|
16
|
+
.object({
|
|
17
|
+
type: zod_1.z.literal(enums_1.PRESET_FIELD_TYPE.SELECT),
|
|
18
|
+
key: preset_common_schema_1.PresetFieldKeySchema,
|
|
19
|
+
values: zod_1.z.array(zod_1.z.string().min(1)).default([]),
|
|
20
|
+
customValue: zod_1.z.string().trim().min(1).max(enums_1.PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH).nullable().default(null),
|
|
21
|
+
})
|
|
22
|
+
.refine((value) => new Set(value.values).size === value.values.length, {
|
|
23
|
+
path: ['values'],
|
|
24
|
+
message: 'Selected values must be unique',
|
|
25
|
+
})
|
|
26
|
+
.refine((value) => value.values.length > 0 || value.customValue !== null, {
|
|
27
|
+
message: 'Select value must contain selected options or custom value',
|
|
28
|
+
});
|
|
29
|
+
exports.PresetTextFieldValueSchema = zod_1.z.object({
|
|
30
|
+
type: zod_1.z.literal(enums_1.PRESET_FIELD_TYPE.TEXT),
|
|
31
|
+
key: preset_common_schema_1.PresetFieldKeySchema,
|
|
32
|
+
text: zod_1.z.string().trim().min(1),
|
|
33
|
+
});
|
|
34
|
+
exports.PresetFieldValueSchema = zod_1.z.discriminatedUnion('type', [
|
|
35
|
+
exports.PresetFileFieldValueSchema,
|
|
36
|
+
exports.PresetSelectFieldValueSchema,
|
|
37
|
+
exports.PresetTextFieldValueSchema,
|
|
38
|
+
]);
|
|
39
|
+
exports.PresetFieldValuesSchema = zod_1.z
|
|
40
|
+
.array(exports.PresetFieldValueSchema)
|
|
41
|
+
.max(enums_1.PRESET_MAX_FIELDS)
|
|
42
|
+
.refine((values) => new Set(values.map((value) => value.key)).size === values.length, {
|
|
43
|
+
message: 'Each field can have only one value',
|
|
44
|
+
});
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PRESET_FIELD_TYPE, PRESET_SELECT_DISPLAY } from '../enums';
|
|
3
|
+
export declare const PresetSelectDisplaySchema: z.ZodEnum<typeof PRESET_SELECT_DISPLAY>;
|
|
4
|
+
export declare const PresetFieldShowIfSchema: z.ZodObject<{
|
|
5
|
+
key: z.ZodString;
|
|
6
|
+
values: z.ZodArray<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const PresetFileFieldObjectSchema: z.ZodObject<{
|
|
9
|
+
key: z.ZodString;
|
|
10
|
+
label: z.ZodString;
|
|
11
|
+
required: z.ZodBoolean;
|
|
12
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
13
|
+
key: z.ZodString;
|
|
14
|
+
values: z.ZodArray<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>>;
|
|
16
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
17
|
+
slot: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
minCount: z.ZodDefault<z.ZodInt>;
|
|
19
|
+
maxCount: z.ZodInt;
|
|
20
|
+
hint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
21
|
+
promptValue: z.ZodString;
|
|
22
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const PresetFileFieldSchema: z.ZodObject<{
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
label: z.ZodString;
|
|
27
|
+
required: z.ZodBoolean;
|
|
28
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
29
|
+
key: z.ZodString;
|
|
30
|
+
values: z.ZodArray<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>>;
|
|
32
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
33
|
+
slot: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
minCount: z.ZodDefault<z.ZodInt>;
|
|
35
|
+
maxCount: z.ZodInt;
|
|
36
|
+
hint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
promptValue: z.ZodString;
|
|
38
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const PresetSelectOptionSchema: z.ZodObject<{
|
|
41
|
+
value: z.ZodString;
|
|
42
|
+
label: z.ZodString;
|
|
43
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
45
|
+
previewFileId: z.ZodDefault<z.ZodNullable<z.ZodUUID>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export declare const PresetSelectOptionResponseSchema: z.ZodObject<{
|
|
48
|
+
value: z.ZodString;
|
|
49
|
+
label: z.ZodString;
|
|
50
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
52
|
+
previewFile: z.ZodNullable<z.ZodObject<{
|
|
53
|
+
uuid: z.ZodUUID;
|
|
54
|
+
url: z.ZodURL;
|
|
55
|
+
thumbnailUrl: z.ZodNullable<z.ZodURL>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export declare const PresetSelectFieldSchema: z.ZodObject<{
|
|
59
|
+
key: z.ZodString;
|
|
60
|
+
label: z.ZodString;
|
|
61
|
+
required: z.ZodBoolean;
|
|
62
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
63
|
+
key: z.ZodString;
|
|
64
|
+
values: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>>>;
|
|
66
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
67
|
+
display: z.ZodDefault<z.ZodEnum<typeof PRESET_SELECT_DISPLAY>>;
|
|
68
|
+
multiple: z.ZodDefault<z.ZodBoolean>;
|
|
69
|
+
defaultValues: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
70
|
+
allowCustom: z.ZodDefault<z.ZodBoolean>;
|
|
71
|
+
customMaxLength: z.ZodDefault<z.ZodInt>;
|
|
72
|
+
customPlaceholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
73
|
+
options: z.ZodArray<z.ZodObject<{
|
|
74
|
+
value: z.ZodString;
|
|
75
|
+
label: z.ZodString;
|
|
76
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
77
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
78
|
+
previewFileId: z.ZodDefault<z.ZodNullable<z.ZodUUID>>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export declare const PresetSelectFieldResponseSchema: z.ZodObject<{
|
|
82
|
+
key: z.ZodString;
|
|
83
|
+
label: z.ZodString;
|
|
84
|
+
required: z.ZodBoolean;
|
|
85
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
86
|
+
key: z.ZodString;
|
|
87
|
+
values: z.ZodArray<z.ZodString>;
|
|
88
|
+
}, z.core.$strip>>>;
|
|
89
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
90
|
+
display: z.ZodDefault<z.ZodEnum<typeof PRESET_SELECT_DISPLAY>>;
|
|
91
|
+
multiple: z.ZodDefault<z.ZodBoolean>;
|
|
92
|
+
defaultValues: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
93
|
+
allowCustom: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
+
customMaxLength: z.ZodDefault<z.ZodInt>;
|
|
95
|
+
customPlaceholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
96
|
+
options: z.ZodArray<z.ZodObject<{
|
|
97
|
+
value: z.ZodString;
|
|
98
|
+
label: z.ZodString;
|
|
99
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
100
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
101
|
+
previewFile: z.ZodNullable<z.ZodObject<{
|
|
102
|
+
uuid: z.ZodUUID;
|
|
103
|
+
url: z.ZodURL;
|
|
104
|
+
thumbnailUrl: z.ZodNullable<z.ZodURL>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export declare const PresetTextFieldObjectSchema: z.ZodObject<{
|
|
109
|
+
key: z.ZodString;
|
|
110
|
+
label: z.ZodString;
|
|
111
|
+
required: z.ZodBoolean;
|
|
112
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
113
|
+
key: z.ZodString;
|
|
114
|
+
values: z.ZodArray<z.ZodString>;
|
|
115
|
+
}, z.core.$strip>>>;
|
|
116
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
117
|
+
placeholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
118
|
+
multiline: z.ZodDefault<z.ZodBoolean>;
|
|
119
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
120
|
+
defaultValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
121
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export declare const PresetTextFieldSchema: z.ZodObject<{
|
|
124
|
+
key: z.ZodString;
|
|
125
|
+
label: z.ZodString;
|
|
126
|
+
required: z.ZodBoolean;
|
|
127
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
128
|
+
key: z.ZodString;
|
|
129
|
+
values: z.ZodArray<z.ZodString>;
|
|
130
|
+
}, z.core.$strip>>>;
|
|
131
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
132
|
+
placeholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
multiline: z.ZodDefault<z.ZodBoolean>;
|
|
134
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
135
|
+
defaultValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
136
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
export declare const PresetFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
139
|
+
key: z.ZodString;
|
|
140
|
+
label: z.ZodString;
|
|
141
|
+
required: z.ZodBoolean;
|
|
142
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
143
|
+
key: z.ZodString;
|
|
144
|
+
values: z.ZodArray<z.ZodString>;
|
|
145
|
+
}, z.core.$strip>>>;
|
|
146
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
147
|
+
slot: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
minCount: z.ZodDefault<z.ZodInt>;
|
|
149
|
+
maxCount: z.ZodInt;
|
|
150
|
+
hint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
151
|
+
promptValue: z.ZodString;
|
|
152
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
153
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
154
|
+
key: z.ZodString;
|
|
155
|
+
label: z.ZodString;
|
|
156
|
+
required: z.ZodBoolean;
|
|
157
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
158
|
+
key: z.ZodString;
|
|
159
|
+
values: z.ZodArray<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>>>;
|
|
161
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
162
|
+
display: z.ZodDefault<z.ZodEnum<typeof PRESET_SELECT_DISPLAY>>;
|
|
163
|
+
multiple: z.ZodDefault<z.ZodBoolean>;
|
|
164
|
+
defaultValues: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
165
|
+
allowCustom: z.ZodDefault<z.ZodBoolean>;
|
|
166
|
+
customMaxLength: z.ZodDefault<z.ZodInt>;
|
|
167
|
+
customPlaceholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
options: z.ZodArray<z.ZodObject<{
|
|
169
|
+
value: z.ZodString;
|
|
170
|
+
label: z.ZodString;
|
|
171
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
172
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
173
|
+
previewFileId: z.ZodDefault<z.ZodNullable<z.ZodUUID>>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
176
|
+
key: z.ZodString;
|
|
177
|
+
label: z.ZodString;
|
|
178
|
+
required: z.ZodBoolean;
|
|
179
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
180
|
+
key: z.ZodString;
|
|
181
|
+
values: z.ZodArray<z.ZodString>;
|
|
182
|
+
}, z.core.$strip>>>;
|
|
183
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
184
|
+
placeholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
185
|
+
multiline: z.ZodDefault<z.ZodBoolean>;
|
|
186
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
187
|
+
defaultValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
188
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
189
|
+
}, z.core.$strip>], "type">;
|
|
190
|
+
export declare const PresetFieldResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
191
|
+
key: z.ZodString;
|
|
192
|
+
label: z.ZodString;
|
|
193
|
+
required: z.ZodBoolean;
|
|
194
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
195
|
+
key: z.ZodString;
|
|
196
|
+
values: z.ZodArray<z.ZodString>;
|
|
197
|
+
}, z.core.$strip>>>;
|
|
198
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
199
|
+
slot: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
200
|
+
minCount: z.ZodDefault<z.ZodInt>;
|
|
201
|
+
maxCount: z.ZodInt;
|
|
202
|
+
hint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
203
|
+
promptValue: z.ZodString;
|
|
204
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
205
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
206
|
+
key: z.ZodString;
|
|
207
|
+
label: z.ZodString;
|
|
208
|
+
required: z.ZodBoolean;
|
|
209
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
210
|
+
key: z.ZodString;
|
|
211
|
+
values: z.ZodArray<z.ZodString>;
|
|
212
|
+
}, z.core.$strip>>>;
|
|
213
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
214
|
+
display: z.ZodDefault<z.ZodEnum<typeof PRESET_SELECT_DISPLAY>>;
|
|
215
|
+
multiple: z.ZodDefault<z.ZodBoolean>;
|
|
216
|
+
defaultValues: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
217
|
+
allowCustom: z.ZodDefault<z.ZodBoolean>;
|
|
218
|
+
customMaxLength: z.ZodDefault<z.ZodInt>;
|
|
219
|
+
customPlaceholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
220
|
+
options: z.ZodArray<z.ZodObject<{
|
|
221
|
+
value: z.ZodString;
|
|
222
|
+
label: z.ZodString;
|
|
223
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
224
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
225
|
+
previewFile: z.ZodNullable<z.ZodObject<{
|
|
226
|
+
uuid: z.ZodUUID;
|
|
227
|
+
url: z.ZodURL;
|
|
228
|
+
thumbnailUrl: z.ZodNullable<z.ZodURL>;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
}, z.core.$strip>>;
|
|
231
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
232
|
+
key: z.ZodString;
|
|
233
|
+
label: z.ZodString;
|
|
234
|
+
required: z.ZodBoolean;
|
|
235
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
236
|
+
key: z.ZodString;
|
|
237
|
+
values: z.ZodArray<z.ZodString>;
|
|
238
|
+
}, z.core.$strip>>>;
|
|
239
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
240
|
+
placeholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
241
|
+
multiline: z.ZodDefault<z.ZodBoolean>;
|
|
242
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
243
|
+
defaultValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
244
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
245
|
+
}, z.core.$strip>], "type">;
|
|
246
|
+
export declare const PresetFieldsSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
247
|
+
key: z.ZodString;
|
|
248
|
+
label: z.ZodString;
|
|
249
|
+
required: z.ZodBoolean;
|
|
250
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
251
|
+
key: z.ZodString;
|
|
252
|
+
values: z.ZodArray<z.ZodString>;
|
|
253
|
+
}, z.core.$strip>>>;
|
|
254
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.FILE>;
|
|
255
|
+
slot: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
256
|
+
minCount: z.ZodDefault<z.ZodInt>;
|
|
257
|
+
maxCount: z.ZodInt;
|
|
258
|
+
hint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
259
|
+
promptValue: z.ZodString;
|
|
260
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
261
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
262
|
+
key: z.ZodString;
|
|
263
|
+
label: z.ZodString;
|
|
264
|
+
required: z.ZodBoolean;
|
|
265
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
266
|
+
key: z.ZodString;
|
|
267
|
+
values: z.ZodArray<z.ZodString>;
|
|
268
|
+
}, z.core.$strip>>>;
|
|
269
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.SELECT>;
|
|
270
|
+
display: z.ZodDefault<z.ZodEnum<typeof PRESET_SELECT_DISPLAY>>;
|
|
271
|
+
multiple: z.ZodDefault<z.ZodBoolean>;
|
|
272
|
+
defaultValues: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
273
|
+
allowCustom: z.ZodDefault<z.ZodBoolean>;
|
|
274
|
+
customMaxLength: z.ZodDefault<z.ZodInt>;
|
|
275
|
+
customPlaceholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
276
|
+
options: z.ZodArray<z.ZodObject<{
|
|
277
|
+
value: z.ZodString;
|
|
278
|
+
label: z.ZodString;
|
|
279
|
+
promptValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
280
|
+
params: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
281
|
+
previewFileId: z.ZodDefault<z.ZodNullable<z.ZodUUID>>;
|
|
282
|
+
}, z.core.$strip>>;
|
|
283
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
284
|
+
key: z.ZodString;
|
|
285
|
+
label: z.ZodString;
|
|
286
|
+
required: z.ZodBoolean;
|
|
287
|
+
showIf: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
288
|
+
key: z.ZodString;
|
|
289
|
+
values: z.ZodArray<z.ZodString>;
|
|
290
|
+
}, z.core.$strip>>>;
|
|
291
|
+
type: z.ZodLiteral<PRESET_FIELD_TYPE.TEXT>;
|
|
292
|
+
placeholder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
293
|
+
multiline: z.ZodDefault<z.ZodBoolean>;
|
|
294
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
295
|
+
defaultValue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
296
|
+
promptFallback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
297
|
+
}, z.core.$strip>], "type">>;
|
|
298
|
+
export declare const PresetRequireOneOfSchema: z.ZodDefault<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
299
|
+
export type PresetFieldShowIfSchemaType = z.infer<typeof PresetFieldShowIfSchema>;
|
|
300
|
+
export type PresetFileFieldSchemaType = z.infer<typeof PresetFileFieldSchema>;
|
|
301
|
+
export type PresetSelectOptionSchemaType = z.infer<typeof PresetSelectOptionSchema>;
|
|
302
|
+
export type PresetSelectOptionResponseSchemaType = z.infer<typeof PresetSelectOptionResponseSchema>;
|
|
303
|
+
export type PresetSelectFieldSchemaType = z.infer<typeof PresetSelectFieldSchema>;
|
|
304
|
+
export type PresetSelectFieldResponseSchemaType = z.infer<typeof PresetSelectFieldResponseSchema>;
|
|
305
|
+
export type PresetTextFieldSchemaType = z.infer<typeof PresetTextFieldSchema>;
|
|
306
|
+
export type PresetFieldSchemaType = z.infer<typeof PresetFieldSchema>;
|
|
307
|
+
export type PresetFieldResponseSchemaType = z.infer<typeof PresetFieldResponseSchema>;
|
|
308
|
+
export type PresetFieldsSchemaType = z.infer<typeof PresetFieldsSchema>;
|
|
309
|
+
export type PresetRequireOneOfSchemaType = z.infer<typeof PresetRequireOneOfSchema>;
|
|
310
|
+
//# sourceMappingURL=preset-field.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-field.schema.d.ts","sourceRoot":"","sources":["../../../preset/models/preset-field.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIH,iBAAiB,EAKjB,qBAAqB,EAKxB,MAAM,UAAU,CAAC;AAOlB,eAAO,MAAM,yBAAyB,yCAAgC,CAAC;AAEvE,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAWH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;iBAQtC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;iBAYhC,CAAC;AASH,eAAO,MAAM,wBAAwB;;;;;;iBAInC,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;;;;;;;;iBAE3C,CAAC;AAwBH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;iBAuDlC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE1C,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;iBAOtC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;iBAGjC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAI5B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAIpC,CAAC;AA0BH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAqBzB,CAAC;AAEP,eAAO,MAAM,wBAAwB,mDAGrB,CAAC;AAEjB,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAClF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC9E,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACpF,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AACpG,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAClF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAClG,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACtE,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACtF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACxE,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresetRequireOneOfSchema = exports.PresetFieldsSchema = exports.PresetFieldResponseSchema = exports.PresetFieldSchema = exports.PresetTextFieldSchema = exports.PresetTextFieldObjectSchema = exports.PresetSelectFieldResponseSchema = exports.PresetSelectFieldSchema = exports.PresetSelectOptionResponseSchema = exports.PresetSelectOptionSchema = exports.PresetFileFieldSchema = exports.PresetFileFieldObjectSchema = exports.PresetFieldShowIfSchema = exports.PresetSelectDisplaySchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const preset_common_schema_1 = require("./preset-common.schema");
|
|
7
|
+
function hasUniqueItems(items) {
|
|
8
|
+
return new Set(items).size === items.length;
|
|
9
|
+
}
|
|
10
|
+
exports.PresetSelectDisplaySchema = zod_1.z.enum(enums_1.PRESET_SELECT_DISPLAY);
|
|
11
|
+
exports.PresetFieldShowIfSchema = zod_1.z.object({
|
|
12
|
+
key: preset_common_schema_1.PresetFieldKeySchema,
|
|
13
|
+
values: zod_1.z.array(zod_1.z.string().min(1)).min(1).refine(hasUniqueItems, { message: 'showIf values must be unique' }),
|
|
14
|
+
});
|
|
15
|
+
const PresetFieldBaseSchema = zod_1.z.object({
|
|
16
|
+
key: preset_common_schema_1.PresetFieldKeySchema,
|
|
17
|
+
label: zod_1.z.string().trim().min(1).max(enums_1.PRESET_FIELD_LABEL_MAX_LENGTH),
|
|
18
|
+
required: zod_1.z.boolean(),
|
|
19
|
+
showIf: exports.PresetFieldShowIfSchema.nullable().default(null),
|
|
20
|
+
});
|
|
21
|
+
const PresetPromptValueSchema = zod_1.z.string().trim().min(1).max(enums_1.PRESET_FIELD_PROMPT_VALUE_MAX_LENGTH);
|
|
22
|
+
exports.PresetFileFieldObjectSchema = PresetFieldBaseSchema.extend({
|
|
23
|
+
type: zod_1.z.literal(enums_1.PRESET_FIELD_TYPE.FILE),
|
|
24
|
+
slot: zod_1.z.string().trim().min(1).nullable().default(null),
|
|
25
|
+
minCount: zod_1.z.int().min(1).default(1),
|
|
26
|
+
maxCount: zod_1.z.int().min(1),
|
|
27
|
+
hint: zod_1.z.string().trim().min(1).max(enums_1.PRESET_FIELD_HINT_MAX_LENGTH).nullable().default(null),
|
|
28
|
+
promptValue: PresetPromptValueSchema,
|
|
29
|
+
promptFallback: PresetPromptValueSchema.nullable().default(null),
|
|
30
|
+
});
|
|
31
|
+
exports.PresetFileFieldSchema = exports.PresetFileFieldObjectSchema.superRefine((field, ctx) => {
|
|
32
|
+
if (field.minCount > field.maxCount) {
|
|
33
|
+
ctx.addIssue({ code: 'custom', path: ['minCount'], message: 'minCount must not exceed maxCount' });
|
|
34
|
+
}
|
|
35
|
+
if (field.required && field.promptFallback !== null) {
|
|
36
|
+
ctx.addIssue({
|
|
37
|
+
code: 'custom',
|
|
38
|
+
path: ['promptFallback'],
|
|
39
|
+
message: 'promptFallback is allowed only for optional fields',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const PresetSelectOptionObjectSchema = zod_1.z.object({
|
|
44
|
+
value: zod_1.z.string().trim().min(1).max(enums_1.PRESET_SELECT_OPTION_VALUE_MAX_LENGTH),
|
|
45
|
+
label: zod_1.z.string().trim().min(1).max(enums_1.PRESET_FIELD_LABEL_MAX_LENGTH),
|
|
46
|
+
promptValue: PresetPromptValueSchema.nullable().default(null),
|
|
47
|
+
params: preset_common_schema_1.PresetModelParamsSchema.nullable().default(null),
|
|
48
|
+
});
|
|
49
|
+
exports.PresetSelectOptionSchema = PresetSelectOptionObjectSchema.extend({
|
|
50
|
+
previewFileId: zod_1.z.uuid().nullable().default(null),
|
|
51
|
+
}).refine((option) => option.promptValue !== null || option.params !== null, {
|
|
52
|
+
message: 'Option must have promptValue or params',
|
|
53
|
+
});
|
|
54
|
+
exports.PresetSelectOptionResponseSchema = PresetSelectOptionObjectSchema.extend({
|
|
55
|
+
previewFile: preset_common_schema_1.PresetFileSchema.nullable(),
|
|
56
|
+
});
|
|
57
|
+
function hasModelParams(option) {
|
|
58
|
+
return option.params !== null;
|
|
59
|
+
}
|
|
60
|
+
function hasPreview(option) {
|
|
61
|
+
return option.previewFileId !== null;
|
|
62
|
+
}
|
|
63
|
+
const PresetSelectFieldObjectSchema = PresetFieldBaseSchema.extend({
|
|
64
|
+
type: zod_1.z.literal(enums_1.PRESET_FIELD_TYPE.SELECT),
|
|
65
|
+
display: exports.PresetSelectDisplaySchema.default(enums_1.PRESET_SELECT_DISPLAY.CHIPS),
|
|
66
|
+
multiple: zod_1.z.boolean().default(false),
|
|
67
|
+
defaultValues: zod_1.z.array(zod_1.z.string()).default([]),
|
|
68
|
+
allowCustom: zod_1.z.boolean().default(false),
|
|
69
|
+
customMaxLength: zod_1.z
|
|
70
|
+
.int()
|
|
71
|
+
.min(1)
|
|
72
|
+
.max(enums_1.PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH)
|
|
73
|
+
.default(enums_1.PRESET_SELECT_CUSTOM_VALUE_DEFAULT_MAX_LENGTH),
|
|
74
|
+
customPlaceholder: zod_1.z.string().trim().min(1).max(enums_1.PRESET_FIELD_HINT_MAX_LENGTH).nullable().default(null),
|
|
75
|
+
});
|
|
76
|
+
exports.PresetSelectFieldSchema = PresetSelectFieldObjectSchema.extend({
|
|
77
|
+
options: zod_1.z.array(exports.PresetSelectOptionSchema).min(1).max(enums_1.PRESET_SELECT_MAX_OPTIONS),
|
|
78
|
+
}).superRefine((field, ctx) => {
|
|
79
|
+
const optionValues = field.options.map((option) => option.value);
|
|
80
|
+
if (!hasUniqueItems(optionValues)) {
|
|
81
|
+
ctx.addIssue({ code: 'custom', path: ['options'], message: 'Option values must be unique' });
|
|
82
|
+
}
|
|
83
|
+
if (field.defaultValues.some((value) => !optionValues.includes(value))) {
|
|
84
|
+
ctx.addIssue({ code: 'custom', path: ['defaultValues'], message: 'Default values must be among options' });
|
|
85
|
+
}
|
|
86
|
+
if (!hasUniqueItems(field.defaultValues)) {
|
|
87
|
+
ctx.addIssue({ code: 'custom', path: ['defaultValues'], message: 'Default values must be unique' });
|
|
88
|
+
}
|
|
89
|
+
if (!field.multiple && field.defaultValues.length > 1) {
|
|
90
|
+
ctx.addIssue({
|
|
91
|
+
code: 'custom',
|
|
92
|
+
path: ['defaultValues'],
|
|
93
|
+
message: 'Single select can have at most one default value',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (field.multiple && field.options.some(hasModelParams)) {
|
|
97
|
+
ctx.addIssue({
|
|
98
|
+
code: 'custom',
|
|
99
|
+
path: ['options'],
|
|
100
|
+
message: 'Options with model params are allowed only in single select',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (field.allowCustom && field.options.some(hasModelParams)) {
|
|
104
|
+
ctx.addIssue({
|
|
105
|
+
code: 'custom',
|
|
106
|
+
path: ['allowCustom'],
|
|
107
|
+
message: 'Custom value is not allowed when options carry model params',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (field.display === enums_1.PRESET_SELECT_DISPLAY.SWITCH &&
|
|
111
|
+
(field.options.length !== 2 || field.multiple || field.allowCustom)) {
|
|
112
|
+
ctx.addIssue({
|
|
113
|
+
code: 'custom',
|
|
114
|
+
path: ['display'],
|
|
115
|
+
message: 'Switch requires exactly two options, single select and no custom value',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (field.display === enums_1.PRESET_SELECT_DISPLAY.TILES && !field.options.every(hasPreview)) {
|
|
119
|
+
ctx.addIssue({ code: 'custom', path: ['options'], message: 'Tiles require previewFileId on every option' });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
exports.PresetSelectFieldResponseSchema = PresetSelectFieldObjectSchema.extend({
|
|
123
|
+
options: zod_1.z.array(exports.PresetSelectOptionResponseSchema),
|
|
124
|
+
});
|
|
125
|
+
exports.PresetTextFieldObjectSchema = PresetFieldBaseSchema.extend({
|
|
126
|
+
type: zod_1.z.literal(enums_1.PRESET_FIELD_TYPE.TEXT),
|
|
127
|
+
placeholder: zod_1.z.string().trim().min(1).max(enums_1.PRESET_FIELD_HINT_MAX_LENGTH).nullable().default(null),
|
|
128
|
+
multiline: zod_1.z.boolean().default(false),
|
|
129
|
+
maxLength: zod_1.z.int().min(1).max(enums_1.PRESET_TEXT_FIELD_MAX_LENGTH).default(enums_1.PRESET_TEXT_FIELD_DEFAULT_MAX_LENGTH),
|
|
130
|
+
defaultValue: zod_1.z.string().trim().min(1).nullable().default(null),
|
|
131
|
+
promptFallback: PresetPromptValueSchema.nullable().default(null),
|
|
132
|
+
});
|
|
133
|
+
exports.PresetTextFieldSchema = exports.PresetTextFieldObjectSchema.refine((field) => field.defaultValue === null || field.defaultValue.length <= field.maxLength, { path: ['defaultValue'], message: 'Default value must not exceed maxLength' });
|
|
134
|
+
exports.PresetFieldSchema = zod_1.z.discriminatedUnion('type', [
|
|
135
|
+
exports.PresetFileFieldSchema,
|
|
136
|
+
exports.PresetSelectFieldSchema,
|
|
137
|
+
exports.PresetTextFieldSchema,
|
|
138
|
+
]);
|
|
139
|
+
exports.PresetFieldResponseSchema = zod_1.z.discriminatedUnion('type', [
|
|
140
|
+
exports.PresetFileFieldObjectSchema,
|
|
141
|
+
exports.PresetSelectFieldResponseSchema,
|
|
142
|
+
exports.PresetTextFieldObjectSchema,
|
|
143
|
+
]);
|
|
144
|
+
function isRequired(field) {
|
|
145
|
+
return field.required;
|
|
146
|
+
}
|
|
147
|
+
function findShowIfIssue(field, fieldsAbove) {
|
|
148
|
+
const showIf = field.showIf;
|
|
149
|
+
if (showIf === null) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const target = fieldsAbove.find((fieldAbove) => fieldAbove.key === showIf.key);
|
|
153
|
+
if (target === undefined || target.type !== enums_1.PRESET_FIELD_TYPE.SELECT) {
|
|
154
|
+
return `showIf must reference a select field placed above: ${showIf.key}`;
|
|
155
|
+
}
|
|
156
|
+
const optionValues = target.options.map((option) => option.value);
|
|
157
|
+
const unknownValues = showIf.values.filter((value) => !optionValues.includes(value));
|
|
158
|
+
if (unknownValues.length > 0) {
|
|
159
|
+
return `showIf values are not options of ${showIf.key}: ${unknownValues.join(', ')}`;
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
exports.PresetFieldsSchema = zod_1.z
|
|
164
|
+
.array(exports.PresetFieldSchema)
|
|
165
|
+
.max(enums_1.PRESET_MAX_FIELDS)
|
|
166
|
+
.superRefine((fields, ctx) => {
|
|
167
|
+
if (!hasUniqueItems(fields.map((field) => field.key))) {
|
|
168
|
+
ctx.addIssue({ code: 'custom', message: 'Field keys must be unique' });
|
|
169
|
+
}
|
|
170
|
+
if (fields.filter(isRequired).length > enums_1.PRESET_MAX_REQUIRED_FIELDS) {
|
|
171
|
+
ctx.addIssue({
|
|
172
|
+
code: 'custom',
|
|
173
|
+
message: `Preset can have at most ${enums_1.PRESET_MAX_REQUIRED_FIELDS} required fields`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
fields.forEach((field, index) => {
|
|
177
|
+
const issue = findShowIfIssue(field, fields.slice(0, index));
|
|
178
|
+
if (issue !== null) {
|
|
179
|
+
ctx.addIssue({ code: 'custom', path: [index, 'showIf'], message: issue });
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
exports.PresetRequireOneOfSchema = zod_1.z
|
|
184
|
+
.array(zod_1.z.array(preset_common_schema_1.PresetFieldKeySchema).min(2).refine(hasUniqueItems, { message: 'Keys in a group must be unique' }))
|
|
185
|
+
.max(enums_1.PRESET_MAX_FIELDS)
|
|
186
|
+
.default([]);
|