Initial state for GitNexus analysis
This commit is contained in:
56
packages/features/module-builder/src/schema/module.schema.ts
Normal file
56
packages/features/module-builder/src/schema/module.schema.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* All CMS field types supported by the module engine.
|
||||
* Maps 1:1 to the cms_field_type Postgres enum.
|
||||
*/
|
||||
export const CmsFieldTypeEnum = z.enum([
|
||||
'text', 'textarea', 'richtext', 'checkbox', 'radio', 'hidden',
|
||||
'select', 'password', 'file', 'date', 'time', 'decimal',
|
||||
'integer', 'email', 'phone', 'url', 'currency', 'iban',
|
||||
'color', 'computed',
|
||||
]);
|
||||
|
||||
export type CmsFieldType = z.infer<typeof CmsFieldTypeEnum>;
|
||||
|
||||
export const CmsModuleStatusEnum = z.enum(['active', 'inactive', 'archived']);
|
||||
export type CmsModuleStatus = z.infer<typeof CmsModuleStatusEnum>;
|
||||
|
||||
export const CmsRecordStatusEnum = z.enum(['active', 'locked', 'deleted', 'archived']);
|
||||
export type CmsRecordStatus = z.infer<typeof CmsRecordStatusEnum>;
|
||||
|
||||
/**
|
||||
* Schema for creating / updating a module definition.
|
||||
*/
|
||||
export const CreateModuleSchema = z.object({
|
||||
accountId: z.string().uuid(),
|
||||
name: z.string().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/, {
|
||||
message: 'Module name must start with a letter and contain only lowercase letters, numbers, and underscores',
|
||||
}),
|
||||
displayName: z.string().min(1).max(128),
|
||||
description: z.string().max(1024).optional(),
|
||||
icon: z.string().max(64).default('table'),
|
||||
status: CmsModuleStatusEnum.default('active'),
|
||||
sortOrder: z.number().int().default(0),
|
||||
defaultSortField: z.string().optional(),
|
||||
defaultSortDirection: z.enum(['asc', 'desc']).default('asc'),
|
||||
defaultPageSize: z.number().int().min(5).max(200).default(25),
|
||||
enableSearch: z.boolean().default(true),
|
||||
enableFilter: z.boolean().default(true),
|
||||
enableExport: z.boolean().default(true),
|
||||
enableImport: z.boolean().default(false),
|
||||
enablePrint: z.boolean().default(true),
|
||||
enableCopy: z.boolean().default(false),
|
||||
enableBulkEdit: z.boolean().default(false),
|
||||
enableHistory: z.boolean().default(true),
|
||||
enableSoftDelete: z.boolean().default(true),
|
||||
enableLock: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export type CreateModuleInput = z.infer<typeof CreateModuleSchema>;
|
||||
|
||||
export const UpdateModuleSchema = CreateModuleSchema.partial().extend({
|
||||
moduleId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export type UpdateModuleInput = z.infer<typeof UpdateModuleSchema>;
|
||||
Reference in New Issue
Block a user