|
| 1 | +"use strict"; |
| 2 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 | +exports.frameworkEditorModelSchemas = exports.FrameworkEditorControlTemplateSchema = exports.FrameworkEditorTaskTemplateSchema = exports.FrameworkEditorPolicyTemplateSchema = exports.FrameworkEditorRequirementSchema = exports.FrameworkEditorFrameworkSchema = exports.FrameworkEditorVideoSchema = void 0; |
| 4 | +const zod_1 = require("zod"); |
| 5 | +// Assuming Frequency and Departments enums are defined elsewhere and imported |
| 6 | +// For now, we'll use z.string() as a placeholder if their definitions aren't available. |
| 7 | +// import { Frequency, Departments } from './path-to-shared-enums'; // Example import |
| 8 | +const datePreprocess = (arg) => { |
| 9 | + if (typeof arg === 'string' && /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}$/.test(arg)) { |
| 10 | + return arg.replace(' ', 'T') + 'Z'; |
| 11 | + } |
| 12 | + return arg; |
| 13 | +}; |
| 14 | +exports.FrameworkEditorVideoSchema = zod_1.z.object({ |
| 15 | + id: zod_1.z.string().optional(), // @id @default |
| 16 | + title: zod_1.z.string(), |
| 17 | + description: zod_1.z.string(), |
| 18 | + youtubeId: zod_1.z.string(), |
| 19 | + url: zod_1.z.string(), |
| 20 | + createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now()) |
| 21 | + updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt |
| 22 | +}); |
| 23 | +exports.FrameworkEditorFrameworkSchema = zod_1.z.object({ |
| 24 | + id: zod_1.z.string().optional(), // @id @default |
| 25 | + name: zod_1.z.string(), |
| 26 | + version: zod_1.z.string(), |
| 27 | + description: zod_1.z.string(), |
| 28 | + // requirements: FrameworkEditorRequirement[] - relational, omitted |
| 29 | + // frameworkInstances: FrameworkInstance[] - relational, omitted |
| 30 | + createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now()) |
| 31 | + updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt |
| 32 | +}); |
| 33 | +exports.FrameworkEditorRequirementSchema = zod_1.z.object({ |
| 34 | + id: zod_1.z.string().optional(), // @id @default |
| 35 | + frameworkId: zod_1.z.string(), |
| 36 | + // framework: FrameworkEditorFramework - relational, omitted |
| 37 | + name: zod_1.z.string(), |
| 38 | + identifier: zod_1.z.string().optional(), // @default("") |
| 39 | + description: zod_1.z.string(), |
| 40 | + // controlTemplates: FrameworkEditorControlTemplate[] - relational, omitted |
| 41 | + // requirementMaps: RequirementMap[] - relational, omitted |
| 42 | + createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now()) |
| 43 | + updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt |
| 44 | +}); |
| 45 | +exports.FrameworkEditorPolicyTemplateSchema = zod_1.z.object({ |
| 46 | + id: zod_1.z.string().optional(), // @id @default |
| 47 | + name: zod_1.z.string(), |
| 48 | + description: zod_1.z.string(), |
| 49 | + frequency: zod_1.z.string(), // Placeholder for Frequency enum |
| 50 | + department: zod_1.z.string(), // Placeholder for Departments enum |
| 51 | + content: zod_1.z.any(), // Json |
| 52 | + // controlTemplates: FrameworkEditorControlTemplate[] - relational, omitted |
| 53 | + createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now()) |
| 54 | + updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt |
| 55 | + // policies: Policy[] - relational, omitted |
| 56 | +}); |
| 57 | +exports.FrameworkEditorTaskTemplateSchema = zod_1.z.object({ |
| 58 | + id: zod_1.z.string().optional(), // @id @default |
| 59 | + name: zod_1.z.string(), |
| 60 | + description: zod_1.z.string(), |
| 61 | + frequency: zod_1.z.string(), // Placeholder for Frequency enum |
| 62 | + department: zod_1.z.string(), // Placeholder for Departments enum |
| 63 | + // controlTemplates: FrameworkEditorControlTemplate[] - relational, omitted |
| 64 | + createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now()) |
| 65 | + updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt |
| 66 | + // tasks: Task[] - relational, omitted |
| 67 | +}); |
| 68 | +exports.FrameworkEditorControlTemplateSchema = zod_1.z.object({ |
| 69 | + id: zod_1.z.string().optional(), // @id @default |
| 70 | + name: zod_1.z.string(), |
| 71 | + description: zod_1.z.string(), |
| 72 | + // policyTemplates: FrameworkEditorPolicyTemplate[] - relational, omitted |
| 73 | + // requirements: FrameworkEditorRequirement[] - relational, omitted |
| 74 | + // taskTemplates: FrameworkEditorTaskTemplate[] - relational, omitted |
| 75 | + createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now()) |
| 76 | + updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt |
| 77 | + // controls: Control[] - relational, omitted |
| 78 | +}); |
| 79 | +// For use in seed script validation |
| 80 | +exports.frameworkEditorModelSchemas = { |
| 81 | + FrameworkEditorVideo: exports.FrameworkEditorVideoSchema, |
| 82 | + FrameworkEditorFramework: exports.FrameworkEditorFrameworkSchema, |
| 83 | + FrameworkEditorRequirement: exports.FrameworkEditorRequirementSchema, |
| 84 | + FrameworkEditorPolicyTemplate: exports.FrameworkEditorPolicyTemplateSchema, |
| 85 | + FrameworkEditorTaskTemplate: exports.FrameworkEditorTaskTemplateSchema, |
| 86 | + FrameworkEditorControlTemplate: exports.FrameworkEditorControlTemplateSchema, |
| 87 | +}; |
0 commit comments