feat: deal attributes with select and options

This commit is contained in:
2025-10-29 19:36:58 +04:00
parent 8019fa566c
commit 4cc6360bb4
14 changed files with 489 additions and 20 deletions

View File

@ -1,6 +1,7 @@
import { CSSProperties, FC, JSX } from "react"; import { CSSProperties, FC, JSX } from "react";
import { Checkbox, NumberInput, TextInput } from "@mantine/core"; import { Checkbox, NumberInput, TextInput } from "@mantine/core";
import { DatePickerInput, DateTimePicker } from "@mantine/dates"; import { DatePickerInput, DateTimePicker } from "@mantine/dates";
import AttrOptionSelect from "@/app/module-editor/[moduleId]/components/shared/AttrOptionSelect/AttrOptionSelect";
import { DealModuleAttributeSchema } from "@/lib/client"; import { DealModuleAttributeSchema } from "@/lib/client";
import { naiveDateTimeStringToUtc } from "@/utils/datetime"; import { naiveDateTimeStringToUtc } from "@/utils/datetime";
@ -25,15 +26,13 @@ const AttributeValueInput: FC<Props> = ({
error, error,
}; };
const renderCheckbox = () => { const renderCheckbox = () => (
return (
<Checkbox <Checkbox
{...commonProps} {...commonProps}
checked={Boolean(value)} checked={Boolean(value)}
onChange={e => onChange(e.currentTarget.checked)} onChange={e => onChange(e.currentTarget.checked)}
/> />
); );
};
const renderDatePicker = () => ( const renderDatePicker = () => (
<DatePickerInput <DatePickerInput
@ -84,6 +83,18 @@ const AttributeValueInput: FC<Props> = ({
/> />
); );
const renderSelect = () => {
if (!attrInfo.select?.id) return <></>;
return (
<AttrOptionSelect
{...commonProps}
value={value}
onChange={onChange}
selectId={attrInfo.select.id}
/>
);
};
const renderingFuncMap: Record<string, () => JSX.Element> = { const renderingFuncMap: Record<string, () => JSX.Element> = {
bool: renderCheckbox, bool: renderCheckbox,
date: renderDatePicker, date: renderDatePicker,
@ -91,6 +102,7 @@ const AttributeValueInput: FC<Props> = ({
str: renderTextInput, str: renderTextInput,
int: renderNumberInput, int: renderNumberInput,
float: renderNumberInput, float: renderNumberInput,
select: renderSelect,
}; };
const render = renderingFuncMap[attrInfo.type.type]; const render = renderingFuncMap[attrInfo.type.type];

View File

@ -0,0 +1,51 @@
import { useEffect, useState } from "react";
import { omit } from "lodash";
import useAttributeOptionsList from "@/app/module-editor/[moduleId]/components/shared/AttrOptionSelect/useAttributeOptionsList";
import ObjectSelect from "@/components/selects/ObjectSelect/ObjectSelect";
import { AttrOptionSchema } from "@/lib/client";
type Props = {
value: any;
onChange: (val: any) => void;
selectId: number;
error?: string;
label?: string;
};
const AttrOptionSelect = (props: Props) => {
const { options } = useAttributeOptionsList(props);
const [selectedOption, setSelectedOption] = useState<AttrOptionSchema>();
useEffect(() => {
if (!props.value) {
setSelectedOption(undefined);
return;
}
setSelectedOption(options.find(option => option.value === props.value));
}, [props.value, options]);
const restProps = omit(props, ["value, onChange", "selectId"]);
return (
<ObjectSelect
label={"Значение"}
{...restProps}
data={options}
value={selectedOption}
onChange={option => {
setSelectedOption(option);
props.onChange(option.value);
}}
onClear={() => {
setSelectedOption(undefined);
props.onChange(null);
}}
getLabelFn={option => option.label}
clearable
searchable
/>
);
};
export default AttrOptionSelect;

View File

@ -0,0 +1,19 @@
import { useQuery } from "@tanstack/react-query";
import { getAttrSelectOptionsOptions } from "@/lib/client/@tanstack/react-query.gen";
type Props = {
selectId: number;
};
const useAttributeSelectsList = ({ selectId }: Props) => {
const { data, refetch } = useQuery(
getAttrSelectOptionsOptions({ path: { selectId } })
);
return {
options: data?.items ?? [],
refetch,
};
};
export default useAttributeSelectsList;

View File

@ -0,0 +1,24 @@
import ObjectSelect, { ObjectSelectProps } from "@/components/selects/ObjectSelect/ObjectSelect";
import { AttributeSelectSchema } from "@/lib/client";
import useAttributeSelectsList from "./useAttributeSelectsList";
type Props = Omit<
ObjectSelectProps<AttributeSelectSchema>,
"data" | "getLabelFn"
>;
const AttrSelectSelect = (props: Props) => {
const { selects } = useAttributeSelectsList();
return (
<ObjectSelect
label={"Объект для выбора"}
getLabelFn={select => select.label}
data={selects}
{...props}
/>
);
};
export default AttrSelectSelect;

View File

@ -0,0 +1,13 @@
import { useQuery } from "@tanstack/react-query";
import { getAttrSelectsOptions } from "@/lib/client/@tanstack/react-query.gen";
const useAttributeSelectsList = () => {
const { data, refetch } = useQuery(getAttrSelectsOptions());
return {
selects: data?.items ?? [],
refetch,
};
};
export default useAttributeSelectsList;

View File

@ -20,6 +20,10 @@ const useAttributesTableColumns = () => {
{ {
title: "Тип", title: "Тип",
accessor: "type.name", accessor: "type.name",
render: attr =>
attr.type.type === "select"
? `Выбор "${attr.label}"`
: attr.type.name,
}, },
{ {
accessor: "actions", accessor: "actions",

View File

@ -1,11 +1,12 @@
import { Checkbox, NumberInput, TextInput } from "@mantine/core"; import { Checkbox, NumberInput, TextInput } from "@mantine/core";
import { DatePickerInput, DateTimePicker } from "@mantine/dates"; import { DatePickerInput, DateTimePicker } from "@mantine/dates";
import { UseFormReturnType } from "@mantine/form"; import { UseFormReturnType } from "@mantine/form";
import { UpdateAttributeSchema } from "@/lib/client"; import AttrOptionSelect from "@/app/module-editor/[moduleId]/components/shared/AttrOptionSelect/AttrOptionSelect";
import { AttributeSchema } from "@/lib/client";
import { naiveDateTimeStringToUtc } from "@/utils/datetime"; import { naiveDateTimeStringToUtc } from "@/utils/datetime";
type Props = { type Props = {
form: UseFormReturnType<Partial<UpdateAttributeSchema>>; form: UseFormReturnType<Partial<AttributeSchema>>;
}; };
const DefaultAttributeValueInput = ({ form }: Props) => { const DefaultAttributeValueInput = ({ form }: Props) => {
@ -87,8 +88,18 @@ const DefaultAttributeValueInput = ({ form }: Props) => {
} }
/> />
); );
} else if (type === "select") {
if (!form.values.select?.id) return <></>;
return (
<AttrOptionSelect
label={"Значение по умолчанию"}
{...form.getInputProps("defaultValue")}
value={form.values.defaultValue}
onChange={value => form.setFieldValue("defaultValue", value)}
selectId={form.values.select?.id}
/>
);
} }
return <></>; return <></>;
}; };

View File

@ -40,7 +40,10 @@ const ModuleAttribute: FC<Props> = ({ attribute }) => {
align={"center"}> align={"center"}>
<Stack gap={7}> <Stack gap={7}>
<>{getAttrLabelText()}</> <>{getAttrLabelText()}</>
<Text>Тип: {attribute.type.name}</Text> <Text>
Тип: {attribute.type.name}{" "}
{attribute.select && `"${attribute.select.label}"`}
</Text>
</Stack> </Stack>
<Group <Group
justify={"end"} justify={"end"}

View File

@ -5,6 +5,7 @@ import { Checkbox, Stack, Textarea, TextInput } from "@mantine/core";
import { useForm } from "@mantine/form"; import { useForm } from "@mantine/form";
import { ContextModalProps } from "@mantine/modals"; import { ContextModalProps } from "@mantine/modals";
import AttributeTypeSelect from "@/app/module-editor/[moduleId]/components/shared/AttributeTypeSelect/AttributeTypeSelect"; import AttributeTypeSelect from "@/app/module-editor/[moduleId]/components/shared/AttributeTypeSelect/AttributeTypeSelect";
import AttrSelectSelect from "@/app/module-editor/[moduleId]/components/shared/AttrSelectSelect/AttrSelectSelect";
import DefaultAttributeValueInput from "@/app/module-editor/[moduleId]/components/shared/DefaultAttributeValueInput/DefaultAttributeValueInput"; import DefaultAttributeValueInput from "@/app/module-editor/[moduleId]/components/shared/DefaultAttributeValueInput/DefaultAttributeValueInput";
import { import {
AttributeSchema, AttributeSchema,
@ -30,7 +31,7 @@ const AttributeEditorModal = ({
const [isNullableInputShown, setIsNullableInputShown] = useState(true); const [isNullableInputShown, setIsNullableInputShown] = useState(true);
const [copyTypeId, setCopyTypeId] = useState<number>(); const [copyTypeId, setCopyTypeId] = useState<number>();
const form = useForm<Partial<UpdateAttributeSchema>>({ const form = useForm<any>({
initialValues: innerProps.isEditing initialValues: innerProps.isEditing
? innerProps.entity ? innerProps.entity
: ({ : ({
@ -38,11 +39,13 @@ const AttributeEditorModal = ({
name: "", name: "",
typeId: undefined, typeId: undefined,
type: undefined, type: undefined,
selectId: undefined,
select: undefined,
isApplicableToGroup: false, isApplicableToGroup: false,
isNullable: false, isNullable: false,
defaultValue: null, defaultValue: null,
description: "", description: "",
} as Partial<CreateAttributeSchema>), } as Partial<AttributeSchema>),
validate: { validate: {
label: label => !label?.trim() && "Название не заполнено", label: label => !label?.trim() && "Название не заполнено",
type: type => !type && "Тип атрибута не выбран", type: type => !type && "Тип атрибута не выбран",
@ -62,7 +65,7 @@ const AttributeEditorModal = ({
if (!isInitial) { if (!isInitial) {
if (type === "bool") { if (type === "bool") {
form.setFieldValue("isNullable", false); form.setFieldValue("isNullable", false);
form.setFieldValue("defaultValue", { value: false }); form.setFieldValue("defaultValue", false);
} else { } else {
form.setFieldValue("defaultValue", null); form.setFieldValue("defaultValue", null);
} }
@ -88,10 +91,27 @@ const AttributeEditorModal = ({
disabled={innerProps.isEditing} disabled={innerProps.isEditing}
{...form.getInputProps("type")} {...form.getInputProps("type")}
onChange={type => { onChange={type => {
if (type.type !== "select") {
form.setFieldValue("select", undefined);
form.setFieldValue("selectId", undefined);
}
form.setFieldValue("type", type); form.setFieldValue("type", type);
form.setFieldValue("typeId", type.id); form.setFieldValue("typeId", type.id);
}} }}
/> />
{form.values.type?.type === "select" && (
<AttrSelectSelect
withAsterisk
searchable
disabled={innerProps.isEditing}
{...form.getInputProps("select")}
onChange={select => {
form.setFieldValue("select", select);
form.setFieldValue("selectId", select.id);
form.setFieldValue("defaultValue", null);
}}
/>
)}
<Checkbox <Checkbox
label={"Значение синхронизировано в группе"} label={"Значение синхронизировано в группе"}
{...form.getInputProps("isApplicableToGroup", { {...form.getInputProps("isApplicableToGroup", {

View File

@ -27,6 +27,10 @@ const useAttributesInnerTableColumns = () => {
{ {
title: "Тип", title: "Тип",
accessor: "type.name", accessor: "type.name",
render: attr =>
attr.type.type === "select"
? `Выбор "${attr.label}"`
: attr.type.name,
}, },
{ {
title: "Значение по умолчанию", title: "Значение по умолчанию",

View File

@ -53,6 +53,8 @@ import {
duplicateProductServices, duplicateProductServices,
getAttributes, getAttributes,
getAttributeTypes, getAttributeTypes,
getAttrSelectOptions,
getAttrSelects,
getBarcodeTemplateAttributes, getBarcodeTemplateAttributes,
getBarcodeTemplates, getBarcodeTemplates,
getBarcodeTemplateSizes, getBarcodeTemplateSizes,
@ -230,6 +232,8 @@ import type {
DuplicateProductServicesResponse, DuplicateProductServicesResponse,
GetAttributesData, GetAttributesData,
GetAttributeTypesData, GetAttributeTypesData,
GetAttrSelectOptionsData,
GetAttrSelectsData,
GetBarcodeTemplateAttributesData, GetBarcodeTemplateAttributesData,
GetBarcodeTemplatesData, GetBarcodeTemplatesData,
GetBarcodeTemplateSizesData, GetBarcodeTemplateSizesData,
@ -374,6 +378,53 @@ const createQueryKey = <TOptions extends Options>(
return [params]; return [params];
}; };
export const getAttrSelectsQueryKey = (options?: Options<GetAttrSelectsData>) =>
createQueryKey("getAttrSelects", options);
/**
* Get Attr Selects
*/
export const getAttrSelectsOptions = (
options?: Options<GetAttrSelectsData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getAttrSelects({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getAttrSelectsQueryKey(options),
});
};
export const getAttrSelectOptionsQueryKey = (
options: Options<GetAttrSelectOptionsData>
) => createQueryKey("getAttrSelectOptions", options);
/**
* Get Attr Select Options
*/
export const getAttrSelectOptionsOptions = (
options: Options<GetAttrSelectOptionsData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getAttrSelectOptions({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getAttrSelectOptionsQueryKey(options),
});
};
export const getAttributesQueryKey = (options?: Options<GetAttributesData>) => export const getAttributesQueryKey = (options?: Options<GetAttributesData>) =>
createQueryKey("getAttributes", options); createQueryKey("getAttributes", options);

View File

@ -135,6 +135,11 @@ import type {
GetAttributesResponses, GetAttributesResponses,
GetAttributeTypesData, GetAttributeTypesData,
GetAttributeTypesResponses, GetAttributeTypesResponses,
GetAttrSelectOptionsData,
GetAttrSelectOptionsErrors,
GetAttrSelectOptionsResponses,
GetAttrSelectsData,
GetAttrSelectsResponses,
GetBarcodeTemplateAttributesData, GetBarcodeTemplateAttributesData,
GetBarcodeTemplateAttributesResponses, GetBarcodeTemplateAttributesResponses,
GetBarcodeTemplatesData, GetBarcodeTemplatesData,
@ -359,6 +364,10 @@ import {
zGetAttributesResponse, zGetAttributesResponse,
zGetAttributeTypesData, zGetAttributeTypesData,
zGetAttributeTypesResponse, zGetAttributeTypesResponse,
zGetAttrSelectOptionsData,
zGetAttrSelectOptionsResponse,
zGetAttrSelectsData,
zGetAttrSelectsResponse,
zGetBarcodeTemplateAttributesData, zGetBarcodeTemplateAttributesData,
zGetBarcodeTemplateAttributesResponse, zGetBarcodeTemplateAttributesResponse,
zGetBarcodeTemplatesData, zGetBarcodeTemplatesData,
@ -476,6 +485,52 @@ export type Options<
meta?: Record<string, unknown>; meta?: Record<string, unknown>;
}; };
/**
* Get Attr Selects
*/
export const getAttrSelects = <ThrowOnError extends boolean = false>(
options?: Options<GetAttrSelectsData, ThrowOnError>
) => {
return (options?.client ?? _heyApiClient).get<
GetAttrSelectsResponses,
unknown,
ThrowOnError
>({
requestValidator: async data => {
return await zGetAttrSelectsData.parseAsync(data);
},
responseType: "json",
responseValidator: async data => {
return await zGetAttrSelectsResponse.parseAsync(data);
},
url: "/crm/v1/attr-select/",
...options,
});
};
/**
* Get Attr Select Options
*/
export const getAttrSelectOptions = <ThrowOnError extends boolean = false>(
options: Options<GetAttrSelectOptionsData, ThrowOnError>
) => {
return (options.client ?? _heyApiClient).get<
GetAttrSelectOptionsResponses,
GetAttrSelectOptionsErrors,
ThrowOnError
>({
requestValidator: async data => {
return await zGetAttrSelectOptionsData.parseAsync(data);
},
responseType: "json",
responseValidator: async data => {
return await zGetAttrSelectOptionsResponse.parseAsync(data);
},
url: "/crm/v1/attr-select/{selectId}",
...options,
});
};
/** /**
* Get Attributes * Get Attributes
*/ */

View File

@ -24,6 +24,42 @@ export type AddAttributeResponse = {
message: string; message: string;
}; };
/**
* AttrOptionSchema
*/
export type AttrOptionSchema = {
/**
* Id
*/
id: number;
/**
* Label
*/
label: string;
/**
* Value
*/
value: unknown;
};
/**
* AttrSelectSchema
*/
export type AttrSelectSchema = {
/**
* Id
*/
id: number;
/**
* Label
*/
label: string;
/**
* Isbuiltin
*/
isBuiltIn: boolean;
};
/** /**
* AttributeSchema * AttributeSchema
*/ */
@ -52,6 +88,10 @@ export type AttributeSchema = {
* Typeid * Typeid
*/ */
typeId: number; typeId: number;
/**
* Selectid
*/
selectId: number | null;
/** /**
* Id * Id
*/ */
@ -61,6 +101,21 @@ export type AttributeSchema = {
*/ */
isBuiltIn: boolean; isBuiltIn: boolean;
type: AttributeTypeSchema; type: AttributeTypeSchema;
select: AttributeSelectSchema | null;
};
/**
* AttributeSelectSchema
*/
export type AttributeSelectSchema = {
/**
* Id
*/
id: number;
/**
* Label
*/
label: string;
}; };
/** /**
@ -312,6 +367,10 @@ export type CreateAttributeSchema = {
* Typeid * Typeid
*/ */
typeId: number; typeId: number;
/**
* Selectid
*/
selectId: number | null;
}; };
/** /**
@ -1039,6 +1098,7 @@ export type DealModuleAttributeSchema = {
*/ */
value: unknown | null; value: unknown | null;
type: AttributeTypeSchema; type: AttributeTypeSchema;
select: AttributeSelectSchema | null;
/** /**
* Defaultvalue * Defaultvalue
*/ */
@ -1426,6 +1486,26 @@ export type DeleteStatusResponse = {
message: string; message: string;
}; };
/**
* GetAllAttrSelectOptionsResponse
*/
export type GetAllAttrSelectOptionsResponse = {
/**
* Items
*/
items: Array<AttrOptionSchema>;
};
/**
* GetAllAttrSelectsResponse
*/
export type GetAllAttrSelectsResponse = {
/**
* Items
*/
items: Array<AttrSelectSchema>;
};
/** /**
* GetAllAttributeTypesResponse * GetAllAttributeTypesResponse
*/ */
@ -1775,6 +1855,10 @@ export type ModuleAttributeSchema = {
* Typeid * Typeid
*/ */
typeId: number; typeId: number;
/**
* Selectid
*/
selectId: number | null;
/** /**
* Id * Id
*/ */
@ -1784,6 +1868,7 @@ export type ModuleAttributeSchema = {
*/ */
isBuiltIn: boolean; isBuiltIn: boolean;
type: AttributeTypeSchema; type: AttributeTypeSchema;
select: AttributeSelectSchema | null;
/** /**
* Originallabel * Originallabel
*/ */
@ -2373,7 +2458,6 @@ export type UpdateAttributeSchema = {
* Description * Description
*/ */
description?: string | null; description?: string | null;
type?: AttributeTypeSchema | null;
}; };
/** /**
@ -3076,6 +3160,55 @@ export type ValidationError = {
type: string; type: string;
}; };
export type GetAttrSelectsData = {
body?: never;
path?: never;
query?: never;
url: "/crm/v1/attr-select/";
};
export type GetAttrSelectsResponses = {
/**
* Successful Response
*/
200: GetAllAttrSelectsResponse;
};
export type GetAttrSelectsResponse =
GetAttrSelectsResponses[keyof GetAttrSelectsResponses];
export type GetAttrSelectOptionsData = {
body?: never;
path: {
/**
* Selectid
*/
selectId: number;
};
query?: never;
url: "/crm/v1/attr-select/{selectId}";
};
export type GetAttrSelectOptionsErrors = {
/**
* Validation Error
*/
422: HttpValidationError;
};
export type GetAttrSelectOptionsError =
GetAttrSelectOptionsErrors[keyof GetAttrSelectOptionsErrors];
export type GetAttrSelectOptionsResponses = {
/**
* Successful Response
*/
200: GetAllAttrSelectOptionsResponse;
};
export type GetAttrSelectOptionsResponse =
GetAttrSelectOptionsResponses[keyof GetAttrSelectOptionsResponses];
export type GetAttributesData = { export type GetAttributesData = {
body?: never; body?: never;
path?: never; path?: never;

View File

@ -17,6 +17,24 @@ export const zAddAttributeResponse = z.object({
message: z.string(), message: z.string(),
}); });
/**
* AttrOptionSchema
*/
export const zAttrOptionSchema = z.object({
id: z.int(),
label: z.string(),
value: z.unknown(),
});
/**
* AttrSelectSchema
*/
export const zAttrSelectSchema = z.object({
id: z.int(),
label: z.string(),
isBuiltIn: z.boolean(),
});
/** /**
* AttributeTypeSchema * AttributeTypeSchema
*/ */
@ -26,6 +44,14 @@ export const zAttributeTypeSchema = z.object({
name: z.string(), name: z.string(),
}); });
/**
* AttributeSelectSchema
*/
export const zAttributeSelectSchema = z.object({
id: z.int(),
label: z.string(),
});
/** /**
* AttributeSchema * AttributeSchema
*/ */
@ -36,9 +62,11 @@ export const zAttributeSchema = z.object({
defaultValue: z.union([z.unknown(), z.null()]), defaultValue: z.union([z.unknown(), z.null()]),
description: z.string(), description: z.string(),
typeId: z.int(), typeId: z.int(),
selectId: z.union([z.int(), z.null()]),
id: z.int(), id: z.int(),
isBuiltIn: z.boolean(), isBuiltIn: z.boolean(),
type: zAttributeTypeSchema, type: zAttributeTypeSchema,
select: z.union([zAttributeSelectSchema, z.null()]),
}); });
/** /**
@ -102,14 +130,14 @@ export const zBoardSchema = z.object({
* Body_upload_product_barcode_image * Body_upload_product_barcode_image
*/ */
export const zBodyUploadProductBarcodeImage = z.object({ export const zBodyUploadProductBarcodeImage = z.object({
upload_file: z.string(), upload_file: z.any(),
}); });
/** /**
* Body_upload_product_image * Body_upload_product_image
*/ */
export const zBodyUploadProductImage = z.object({ export const zBodyUploadProductImage = z.object({
upload_file: z.string(), upload_file: z.any(),
}); });
/** /**
@ -144,6 +172,7 @@ export const zCreateAttributeSchema = z.object({
defaultValue: z.union([z.unknown(), z.null()]), defaultValue: z.union([z.unknown(), z.null()]),
description: z.string(), description: z.string(),
typeId: z.int(), typeId: z.int(),
selectId: z.union([z.int(), z.null()]),
}); });
/** /**
@ -833,6 +862,7 @@ export const zDealModuleAttributeSchema = z.object({
originalLabel: z.string(), originalLabel: z.string(),
value: z.union([z.unknown(), z.null()]), value: z.union([z.unknown(), z.null()]),
type: zAttributeTypeSchema, type: zAttributeTypeSchema,
select: z.union([zAttributeSelectSchema, z.null()]),
defaultValue: z.unknown(), defaultValue: z.unknown(),
description: z.string(), description: z.string(),
isApplicableToGroup: z.boolean(), isApplicableToGroup: z.boolean(),
@ -996,6 +1026,20 @@ export const zDeleteStatusResponse = z.object({
message: z.string(), message: z.string(),
}); });
/**
* GetAllAttrSelectOptionsResponse
*/
export const zGetAllAttrSelectOptionsResponse = z.object({
items: z.array(zAttrOptionSchema),
});
/**
* GetAllAttrSelectsResponse
*/
export const zGetAllAttrSelectsResponse = z.object({
items: z.array(zAttrSelectSchema),
});
/** /**
* GetAllAttributeTypesResponse * GetAllAttributeTypesResponse
*/ */
@ -1027,9 +1071,11 @@ export const zModuleAttributeSchema = z.object({
defaultValue: z.union([z.unknown(), z.null()]), defaultValue: z.union([z.unknown(), z.null()]),
description: z.string(), description: z.string(),
typeId: z.int(), typeId: z.int(),
selectId: z.union([z.int(), z.null()]),
id: z.int(), id: z.int(),
isBuiltIn: z.boolean(), isBuiltIn: z.boolean(),
type: zAttributeTypeSchema, type: zAttributeTypeSchema,
select: z.union([zAttributeSelectSchema, z.null()]),
originalLabel: z.string(), originalLabel: z.string(),
}); });
@ -1344,7 +1390,6 @@ export const zUpdateAttributeSchema = z.object({
isNullable: z.optional(z.union([z.boolean(), z.null()])), isNullable: z.optional(z.union([z.boolean(), z.null()])),
defaultValue: z.optional(z.union([z.unknown(), z.null()])), defaultValue: z.optional(z.union([z.unknown(), z.null()])),
description: z.optional(z.union([z.string(), z.null()])), description: z.optional(z.union([z.string(), z.null()])),
type: z.optional(z.union([zAttributeTypeSchema, z.null()])),
}); });
/** /**
@ -1805,6 +1850,30 @@ export const zUpdateStatusResponse = z.object({
message: z.string(), message: z.string(),
}); });
export const zGetAttrSelectsData = z.object({
body: z.optional(z.never()),
path: z.optional(z.never()),
query: z.optional(z.never()),
});
/**
* Successful Response
*/
export const zGetAttrSelectsResponse = zGetAllAttrSelectsResponse;
export const zGetAttrSelectOptionsData = z.object({
body: z.optional(z.never()),
path: z.object({
selectId: z.int(),
}),
query: z.optional(z.never()),
});
/**
* Successful Response
*/
export const zGetAttrSelectOptionsResponse = zGetAllAttrSelectOptionsResponse;
export const zGetAttributesData = z.object({ export const zGetAttributesData = z.object({
body: z.optional(z.never()), body: z.optional(z.never()),
path: z.optional(z.never()), path: z.optional(z.never()),