@seedprotocol/sdk 0.4.4 → 0.4.5
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/README.md +38 -348
- package/dist/{ArweaveClient-DkNLWiSZ.js → ArweaveClient-CgWK-JgT.js} +8 -8
- package/dist/{ArweaveClient-DkNLWiSZ.js.map → ArweaveClient-CgWK-JgT.js.map} +1 -1
- package/dist/{ArweaveClient-CczHvccG.js → ArweaveClient-WcG8CZAE.js} +8 -8
- package/dist/{ArweaveClient-CczHvccG.js.map → ArweaveClient-WcG8CZAE.js.map} +1 -1
- package/dist/{Db-DJvjXVlp.js → Db-DjFdIdR9.js} +9 -9
- package/dist/{Db-DJvjXVlp.js.map → Db-DjFdIdR9.js.map} +1 -1
- package/dist/{Db-BzQR2KX9.js → Db-DjofXdeU.js} +9 -9
- package/dist/{Db-BzQR2KX9.js.map → Db-DjofXdeU.js.map} +1 -1
- package/dist/{EasClient-CHQYmjj2.js → EasClient-Aojewp6P.js} +8 -8
- package/dist/{EasClient-CodrIgW-.js.map → EasClient-Aojewp6P.js.map} +1 -1
- package/dist/{EasClient-CodrIgW-.js → EasClient-BVFXp2O6.js} +8 -8
- package/dist/{EasClient-CHQYmjj2.js.map → EasClient-BVFXp2O6.js.map} +1 -1
- package/dist/{FileManager-BbvkZJCH.js → FileManager-C9zr4AJe.js} +8 -8
- package/dist/{FileManager-BbvkZJCH.js.map → FileManager-C9zr4AJe.js.map} +1 -1
- package/dist/{FileManager-BIVsDnMu.js → FileManager-CxGJLw5C.js} +8 -8
- package/dist/{FileManager-BIVsDnMu.js.map → FileManager-CxGJLw5C.js.map} +1 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/Model/Model.d.ts.map +1 -1
- package/dist/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/saveToSchema.d.ts.map +1 -1
- package/dist/{ModelProperty-gjcA83Mq.js → ModelProperty-CGdkocQ8.js} +31 -766
- package/dist/ModelProperty-CGdkocQ8.js.map +1 -0
- package/dist/{PathResolver-kGzba-zC.js → PathResolver-CX6GHoTS.js} +8 -8
- package/dist/{PathResolver-kGzba-zC.js.map → PathResolver-CX6GHoTS.js.map} +1 -1
- package/dist/{PathResolver-9zAzPhee.js → PathResolver-z_WX47_o.js} +8 -8
- package/dist/{PathResolver-9zAzPhee.js.map → PathResolver-z_WX47_o.js.map} +1 -1
- package/dist/{QueryClient-C7ZkTT0z.js → QueryClient-ByKPdRmE.js} +8 -8
- package/dist/{QueryClient-C7ZkTT0z.js.map → QueryClient-ByKPdRmE.js.map} +1 -1
- package/dist/{QueryClient-CEtsek7Q.js → QueryClient-Cb1iJO-x.js} +8 -8
- package/dist/{QueryClient-CEtsek7Q.js.map → QueryClient-Cb1iJO-x.js.map} +1 -1
- package/dist/Schema/Schema.d.ts.map +1 -1
- package/dist/Schema/service/actors/writePropertiesToDb.d.ts.map +1 -1
- package/dist/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/{Schema-ClTcpgbt.js → Schema-D1eqDHyt.js} +758 -60
- package/dist/Schema-D1eqDHyt.js.map +1 -0
- package/dist/{SchemaValidationService-BfoEiHNr.js → SchemaValidationService-DyttFaV_.js} +7 -7
- package/dist/{SchemaValidationService-BfoEiHNr.js.map → SchemaValidationService-DyttFaV_.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BRKRREYP.js → ModelProperty-BeJvgKMw.js} +62 -436
- package/dist/cjs/ModelProperty-BeJvgKMw.js.map +1 -0
- package/dist/cjs/{Schema-CV9hMg8m.js → Schema-CVs9J6eP.js} +426 -91
- package/dist/cjs/Schema-CVs9J6eP.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-DUtQUerg.js → SchemaValidationService-CDKcVRFQ.js} +3 -3
- package/dist/cjs/{SchemaValidationService-DUtQUerg.js.map → SchemaValidationService-CDKcVRFQ.js.map} +1 -1
- package/dist/cjs/{getItem-BThT-UOt.js → getItem-B5RYPvrG.js} +3 -3
- package/dist/cjs/{getItem-BThT-UOt.js.map → getItem-B5RYPvrG.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-CKZ7rVbU.js → getPublishPayload-BD1qRob1.js} +6 -6
- package/dist/cjs/getPublishPayload-BD1qRob1.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CuGIvV-Q.js → getPublishUploads-CnC9aYxs.js} +4 -4
- package/dist/cjs/{getPublishUploads-CuGIvV-Q.js.map → getPublishUploads-CnC9aYxs.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-BCJXJlTR.js → getSegmentedItemProperties-B_njnntx.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-BCJXJlTR.js.map → getSegmentedItemProperties-B_njnntx.js.map} +1 -1
- package/dist/cjs/{index-C3j3m34a.js → index-BeKPbbk0.js} +11466 -11546
- package/dist/cjs/index-BeKPbbk0.js.map +1 -0
- package/dist/cjs/{index-CbTBDqTJ.js → index-Dnywap_P.js} +3 -3
- package/dist/cjs/index-Dnywap_P.js.map +1 -0
- package/dist/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/eas.d.ts.map +1 -1
- package/dist/{getItem-BWPo8wd0.js → getItem-BB5HBCbK.js} +8 -8
- package/dist/{getItem-BWPo8wd0.js.map → getItem-BB5HBCbK.js.map} +1 -1
- package/dist/{getPublishPayload-Caw2laZM.js → getPublishPayload-uLm0AqN_.js} +10 -10
- package/dist/getPublishPayload-uLm0AqN_.js.map +1 -0
- package/dist/{getPublishUploads-MlyBuoXh.js → getPublishUploads-Dc-HqhO8.js} +9 -9
- package/dist/{getPublishUploads-MlyBuoXh.js.map → getPublishUploads-Dc-HqhO8.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-COLLdDo4.js → getSegmentedItemProperties-BrIqFNfD.js} +2 -2
- package/dist/{getSegmentedItemProperties-COLLdDo4.js.map → getSegmentedItemProperties-BrIqFNfD.js.map} +1 -1
- package/dist/helpers/schema.d.ts.map +1 -1
- package/dist/helpers/updateSchema.d.ts.map +1 -1
- package/dist/imports/json.d.ts.map +1 -1
- package/dist/{index-D2OGsG4v.js → index-2FcQHgKp.js} +2 -2
- package/dist/index-2FcQHgKp.js.map +1 -0
- package/dist/{ClientManager-DoHUt8tU.js → index-DPll6EAp.js} +11460 -11538
- package/dist/index-DPll6EAp.js.map +1 -0
- package/dist/{index-B9i_mXXp.js → index-LEY0Og1p.js} +9 -9
- package/dist/index-LEY0Og1p.js.map +1 -0
- package/dist/main.cjs +2 -2
- package/dist/main.js +13 -13
- package/dist/main.js.map +1 -1
- package/dist/node.js +15 -15
- package/dist/{property-fK7tSUDX.js → property-B15X7jLX.js} +4 -4
- package/dist/property-B15X7jLX.js.map +1 -0
- package/dist/{queries-DGOk16cd.js → queries-BPDSpiEX.js} +2 -2
- package/dist/{queries-DGOk16cd.js.map → queries-BPDSpiEX.js.map} +1 -1
- package/dist/services/write/actors/writeToDatabase.d.ts.map +1 -1
- package/package.json +6 -2
- package/dist/ClientManager-DoHUt8tU.js.map +0 -1
- package/dist/ModelProperty-gjcA83Mq.js.map +0 -1
- package/dist/Schema-ClTcpgbt.js.map +0 -1
- package/dist/cjs/ModelProperty-BRKRREYP.js.map +0 -1
- package/dist/cjs/Schema-CV9hMg8m.js.map +0 -1
- package/dist/cjs/getPublishPayload-CKZ7rVbU.js.map +0 -1
- package/dist/cjs/index-C3j3m34a.js.map +0 -1
- package/dist/cjs/index-CbTBDqTJ.js.map +0 -1
- package/dist/getPublishPayload-Caw2laZM.js.map +0 -1
- package/dist/index-B9i_mXXp.js.map +0 -1
- package/dist/index-D2OGsG4v.js.map +0 -1
- package/dist/property-fK7tSUDX.js.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Value } from '@sinclair/typebox/value';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
import { a as ModelPropertyDataTypes, T as TPropertyDataType, c as TProperty } from './
|
|
3
|
+
import { a as ModelPropertyDataTypes, T as TPropertyDataType, c as TProperty } from './index-DPll6EAp.js';
|
|
4
4
|
import 'pluralize';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
6
|
import { Type } from '@sinclair/typebox';
|
|
7
7
|
import debug from 'debug';
|
|
8
8
|
import 'xstate';
|
|
9
|
-
import 'rxjs';
|
|
10
|
-
import 'lodash-es';
|
|
11
|
-
import 'drizzle-orm/casing';
|
|
12
|
-
import 'arweave';
|
|
13
|
-
import 'eventemitter3';
|
|
14
9
|
import 'drizzle-orm/sqlite-core';
|
|
15
10
|
import 'nanoid';
|
|
16
11
|
import 'nanoid-dictionary';
|
|
17
12
|
import 'ethers';
|
|
13
|
+
import 'rxjs';
|
|
14
|
+
import 'lodash-es';
|
|
15
|
+
import 'drizzle-orm/casing';
|
|
16
|
+
import 'eventemitter3';
|
|
17
|
+
import 'arweave';
|
|
18
18
|
|
|
19
19
|
const logger = debug('seedSdk:schema:validation');
|
|
20
20
|
/**
|
|
@@ -560,4 +560,4 @@ class SchemaValidationService {
|
|
|
560
560
|
}
|
|
561
561
|
|
|
562
562
|
export { SchemaValidationService };
|
|
563
|
-
//# sourceMappingURL=SchemaValidationService-
|
|
563
|
+
//# sourceMappingURL=SchemaValidationService-DyttFaV_.js.map
|
package/dist/{SchemaValidationService-BfoEiHNr.js.map → SchemaValidationService-DyttFaV_.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaValidationService-BfoEiHNr.js","sources":["../src/Schema/service/validation/SchemaValidationService.ts"],"sourcesContent":["import { Value } from '@sinclair/typebox/value'\nimport { TProperty } from '@/Schema'\nimport { ModelPropertyDataTypes, TPropertyDataType } from '@/helpers/property'\nimport { ValidationResult, ValidationError, ValidationRules } from '@/Schema/validation'\nimport { SchemaMachineContext } from '../schemaMachine'\nimport { ModelPropertyMachineContext } from '@/ModelProperty/service/modelPropertyMachine'\nimport { ModelMachineContext } from '@/Model/service/modelMachine'\nimport { Type, TSchema, TUnion, TLiteral } from '@sinclair/typebox'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:schema:validation')\n\n/**\n * Service for validating schemas, models, and properties using TypeBox\n */\nexport class SchemaValidationService {\n /**\n * Enhance TypeBox error message with expected values for union/literal types\n */\n private enhanceErrorMessage(\n error: any,\n schema: TSchema,\n fieldPath: string\n ): string {\n const originalMessage = error.message || 'Validation failed'\n \n // Handle Union type errors (like TPropertyDataType)\n if (error.type === 'Union' || originalMessage.includes('union')) {\n const expectedValues = this.extractExpectedValues(schema, fieldPath)\n if (expectedValues.length > 0) {\n return `Expected one of: ${expectedValues.join(', ')}. Received: ${JSON.stringify(error.value)}`\n }\n }\n \n // Handle Literal type errors\n if (error.type === 'Literal') {\n const expectedValue = this.extractLiteralValue(schema, fieldPath)\n if (expectedValue !== undefined) {\n return `Expected: ${JSON.stringify(expectedValue)}. Received: ${JSON.stringify(error.value)}`\n }\n }\n \n // Return enhanced message with value info if available\n if (error.value !== undefined) {\n return `${originalMessage}. Received: ${JSON.stringify(error.value)}`\n }\n \n return originalMessage\n }\n\n /**\n * Extract expected values from a schema for a given field path\n */\n private extractExpectedValues(schema: TSchema | null, fieldPath: string): string[] {\n try {\n // Handle TProperty schema - check if this is the dataType field\n if (fieldPath === '/dataType' || fieldPath.endsWith('/dataType')) {\n // Return all ModelPropertyDataTypes enum values\n return Object.values(ModelPropertyDataTypes) as string[]\n }\n \n // Handle TStorageType\n if (fieldPath === '/storageType' || fieldPath.endsWith('/storageType')) {\n return ['ItemStorage', 'PropertyStorage']\n }\n \n // If we have a schema, try to extract from it\n if (!schema) {\n return []\n }\n \n // Try to extract from TypeBox Union type using the schema directly\n const schemaObj = schema as any\n const kind = schemaObj[Symbol.for('TypeBox.Kind')]\n \n if (kind === 'Union') {\n const union = schemaObj as TUnion<any>\n const anyOf = union.anyOf || []\n const values: string[] = []\n \n for (const item of anyOf) {\n const itemKind = item?.[Symbol.for('TypeBox.Kind')]\n if (itemKind === 'Literal') {\n const literal = item as TLiteral<any>\n if (literal.const !== undefined) {\n values.push(String(literal.const))\n }\n }\n }\n \n if (values.length > 0) {\n return values\n }\n }\n \n // Fallback: try to extract from JSON schema format\n if (typeof schema === 'object' && 'anyOf' in schema) {\n const union = schema as any\n if (Array.isArray(union.anyOf)) {\n return union.anyOf\n .map((item: any) => {\n if (item.const !== undefined) return String(item.const)\n if (item.enum && Array.isArray(item.enum)) return item.enum.map(String)\n return null\n })\n .filter((val: any) => val !== null)\n .flat()\n .map(String)\n }\n }\n } catch (error) {\n logger('Error extracting expected values:', error)\n }\n \n return []\n }\n\n /**\n * Extract literal value from a schema\n */\n private extractLiteralValue(schema: TSchema, fieldPath: string): any {\n try {\n if (schema && typeof schema === 'object') {\n const schemaObj = schema as any\n if (schemaObj[Symbol.for('TypeBox.Kind')] === 'Literal') {\n return (schemaObj as TLiteral<any>).const\n }\n if (schemaObj.const !== undefined) {\n return schemaObj.const\n }\n }\n } catch (error) {\n logger('Error extracting literal value:', error)\n }\n \n return undefined\n }\n\n /**\n * Get the schema for a specific field path\n */\n private getSchemaForField(schema: TSchema, fieldPath: string): TSchema | null {\n try {\n if (!schema || typeof schema !== 'object') return null\n \n // Remove leading slash\n const path = fieldPath.replace(/^\\//, '')\n if (!path) return schema\n \n const schemaObj = schema as any\n const kind = schemaObj[Symbol.for('TypeBox.Kind')]\n \n // For TProperty (Object type), check properties\n if (kind === 'Object') {\n const properties = schemaObj.properties\n if (properties && properties[path]) {\n return properties[path]\n }\n }\n \n // Special handling for known fields - return the actual schema\n if (path === 'dataType') {\n return TPropertyDataType as TSchema\n }\n \n // Fallback: check if schema has the property\n if (path in schemaObj) {\n return schemaObj[path]\n }\n } catch (error) {\n logger('Error getting schema for field:', error)\n }\n \n return null\n }\n\n /**\n * Validate a property structure against TProperty schema\n */\n validatePropertyStructure(\n property: ModelPropertyMachineContext\n ): ValidationResult {\n try {\n const isValid = Value.Check(TProperty, property)\n \n const errors: ValidationError[] = []\n \n if (!isValid) {\n const typeBoxErrors = [...Value.Errors(TProperty, property)]\n errors.push(...typeBoxErrors.map(err => {\n const fieldPath = err.path || 'unknown'\n const fieldSchema = this.getSchemaForField(TProperty, fieldPath)\n const enhancedMessage = this.enhanceErrorMessage(err, fieldSchema || TProperty, fieldPath)\n \n return {\n field: fieldPath,\n message: enhancedMessage,\n code: String(err.type || 'validation_error'),\n severity: 'error' as const,\n }\n }))\n }\n \n // Validate that Relation and List properties have a ref defined\n if (property.dataType === ModelPropertyDataTypes.Relation || property.dataType === ModelPropertyDataTypes.List) {\n const hasRef = property.ref && property.ref.trim() !== ''\n const hasRefModelName = property.refModelName && property.refModelName.trim() !== ''\n const hasRefModelId = property.refModelId !== undefined && property.refModelId !== null\n \n if (!hasRef && !hasRefModelName && !hasRefModelId) {\n errors.push({\n field: 'ref',\n message: `Property with dataType \"${property.dataType}\" requires either a \"ref\", \"refModelName\", or \"refModelId\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n }\n \n // For Relation type, prefer having refModelId when ref/refModelName is provided\n // This is a warning, not an error, as refModelId can be resolved asynchronously\n if (property.dataType === ModelPropertyDataTypes.Relation && (hasRef || hasRefModelName) && !hasRefModelId) {\n // This is acceptable - refModelId will be resolved asynchronously\n // We don't add an error here, just log for debugging\n logger(`Property \"${property.name}\" has ref/refModelName but no refModelId - will be resolved asynchronously`)\n }\n }\n \n return {\n isValid: errors.length === 0,\n errors,\n }\n } catch (error) {\n logger('Error validating property structure:', error)\n return {\n isValid: false,\n errors: [{\n field: 'property',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n }\n }\n }\n\n /**\n * Validate a property value against its validation rules\n */\n validatePropertyValue(\n value: any,\n dataType: ModelPropertyDataTypes,\n validationRules?: ValidationRules\n ): ValidationResult {\n const errors: ValidationError[] = []\n const warnings: ValidationError[] = []\n\n try {\n // Build base TypeBox schema from dataType\n let schema: TSchema = this.getBaseSchemaForDataType(dataType)\n\n // Apply validation rules\n if (validationRules) {\n schema = this.applyValidationRules(schema, dataType, validationRules)\n }\n\n // Validate using TypeBox\n const isValid = Value.Check(schema, value)\n \n if (!isValid) {\n const typeBoxErrors = [...Value.Errors(schema, value)]\n errors.push(...typeBoxErrors.map(err => {\n const fieldPath = err.path || 'value'\n const enhancedMessage = this.enhanceErrorMessage(err, schema, fieldPath)\n \n return {\n field: fieldPath,\n message: enhancedMessage,\n code: String(err.type || 'value_validation_error'),\n severity: 'error' as const,\n }\n }))\n }\n\n // Additional custom validations\n if (validationRules) {\n const customErrors = this.validateCustomRules(value, validationRules)\n errors.push(...customErrors)\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n } catch (error) {\n logger('Error validating property value:', error)\n return {\n isValid: false,\n errors: [{\n field: 'value',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n }\n }\n }\n\n /**\n * Validate a specific property within a schema\n */\n validateProperty(\n schema: SchemaMachineContext,\n modelName: string,\n propertyName: string,\n propertyData?: ModelPropertyMachineContext\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Check if model exists\n if (!schema.models || !schema.models[modelName]) {\n errors.push({\n field: 'model',\n message: `Model \"${modelName}\" not found in schema`,\n code: 'model_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n const model = schema.models[modelName]\n\n // Check if property exists in model\n // If the property name has changed (renamed), check if the original name exists\n let propertyDefinition = model.properties?.[propertyName]\n let actualPropertyName = propertyName\n \n if (!propertyDefinition && propertyData?._originalValues?.name) {\n const originalName = propertyData._originalValues.name\n // If the current name differs from the original, check if original exists\n if (originalName !== propertyName && model.properties?.[originalName]) {\n propertyDefinition = model.properties[originalName]\n actualPropertyName = originalName\n // Property is being renamed, which is allowed - continue validation\n }\n }\n \n if (!propertyDefinition) {\n errors.push({\n field: 'property',\n message: `Property \"${propertyName}\" not found in model \"${modelName}\"`,\n code: 'property_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n // If propertyData is provided, validate its structure\n if (propertyData) {\n const structureResult = this.validatePropertyStructure(propertyData)\n errors.push(...structureResult.errors)\n }\n\n // Validate property definition structure\n if (!propertyDefinition.type) {\n errors.push({\n field: 'property.type',\n message: 'Property type is required',\n code: 'missing_type',\n severity: 'error' as const,\n })\n }\n\n // Validate Relation and List properties have a ref/model defined\n if (propertyDefinition.type === 'Relation' || propertyDefinition.type === 'List') {\n if (!propertyDefinition.model || propertyDefinition.model.trim() === '') {\n errors.push({\n field: 'property.model',\n message: `Property with type \"${propertyDefinition.type}\" requires a \"model\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n } else if (!schema.models[propertyDefinition.model]) {\n errors.push({\n field: 'property.model',\n message: `Referenced model \"${propertyDefinition.model}\" not found in schema`,\n code: 'invalid_reference',\n severity: 'error' as const,\n })\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate model structure (basic structure checks)\n */\n validateModelStructure(\n model: ModelMachineContext & { properties?: { [key: string]: any } }\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Validate model name\n if (!model.modelName || model.modelName.trim() === '') {\n errors.push({\n field: 'modelName',\n message: 'Model name is required',\n code: 'missing_model_name',\n severity: 'error' as const,\n })\n }\n\n // Validate schema name\n if (!model.schemaName || model.schemaName.trim() === '') {\n errors.push({\n field: 'schemaName',\n message: 'Schema name is required',\n code: 'missing_schema_name',\n severity: 'error' as const,\n })\n }\n\n // Validate properties is an object\n if (model.properties && typeof model.properties !== 'object') {\n errors.push({\n field: 'properties',\n message: 'Properties must be an object',\n code: 'invalid_properties',\n severity: 'error' as const,\n })\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate a model against a schema WITHOUT requiring it to be in the schema's context\n * This allows validation before registration, preventing update loops\n */\n validateModelAgainstSchema(\n schema: SchemaMachineContext,\n modelName: string,\n modelData: ModelMachineContext & { properties?: { [key: string]: any } }\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Create a temporary schema context that includes this model for validation purposes\n // This allows validateProperty to work without actually adding the model to the real schema\n const tempSchemaContext: SchemaMachineContext = {\n ...schema,\n models: {\n ...schema.models,\n [modelName]: {\n properties: modelData.properties || {},\n },\n },\n }\n\n // Use validateModel which now works because the model is in the temp context\n return this.validateModel(tempSchemaContext, modelName, modelData)\n }\n\n /**\n * Validate a model within a schema (requires model to already be in schema context)\n */\n validateModel(\n schema: SchemaMachineContext,\n modelName: string,\n modelData?: ModelMachineContext\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n if (!schema.models || !schema.models[modelName]) {\n errors.push({\n field: 'model',\n message: `Model \"${modelName}\" not found in schema`,\n code: 'model_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n const model = schema.models[modelName]\n\n // Validate all properties in the model\n if (model.properties) {\n for (const [propertyName, propertyDef] of Object.entries(model.properties)) {\n const propertyResult = this.validateProperty(schema, modelName, propertyName)\n if (!propertyResult.isValid) {\n errors.push(...propertyResult.errors.map(err => ({\n ...err,\n field: `${modelName}.${propertyName}.${err.field}`,\n })))\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate entire schema\n */\n validateSchema(schema: SchemaMachineContext): ValidationResult {\n const errors: ValidationError[] = []\n\n // Validate schema name\n if (!schema.schemaName || schema.schemaName.trim() === '') {\n errors.push({\n field: 'schemaName',\n message: 'Schema name is required',\n code: 'missing_schema_name',\n severity: 'error' as const,\n })\n }\n\n // Validate metadata\n if (!schema.metadata) {\n errors.push({\n field: 'metadata',\n message: 'Schema metadata is required',\n code: 'missing_metadata',\n severity: 'error' as const,\n })\n } else {\n if (!schema.metadata.name || schema.metadata.name.trim() === '') {\n errors.push({\n field: 'metadata.name',\n message: 'Schema metadata name is required',\n code: 'missing_metadata_name',\n severity: 'error' as const,\n })\n }\n }\n\n // Validate models if they exist\n if (schema.models && Object.keys(schema.models).length > 0) {\n // Validate each model\n for (const modelName of Object.keys(schema.models)) {\n const modelResult = this.validateModel(schema, modelName)\n if (!modelResult.isValid) {\n errors.push(...modelResult.errors)\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Get base TypeBox schema for a data type\n */\n private getBaseSchemaForDataType(dataType: ModelPropertyDataTypes): TSchema {\n switch (dataType) {\n case ModelPropertyDataTypes.Text:\n case ModelPropertyDataTypes.Html:\n return Type.String()\n case ModelPropertyDataTypes.Number:\n return Type.Number()\n case ModelPropertyDataTypes.Boolean:\n return Type.Boolean()\n case ModelPropertyDataTypes.Date:\n return Type.String({ format: 'date-time' })\n case ModelPropertyDataTypes.Json:\n return Type.Any()\n case ModelPropertyDataTypes.List:\n return Type.Array(Type.Any())\n case ModelPropertyDataTypes.Relation:\n case ModelPropertyDataTypes.Image:\n case ModelPropertyDataTypes.File:\n return Type.Union([Type.String(), Type.Null()])\n default:\n return Type.Any()\n }\n }\n\n /**\n * Apply validation rules to a TypeBox schema\n */\n private applyValidationRules(\n schema: TSchema,\n dataType: ModelPropertyDataTypes,\n rules: ValidationRules\n ): TSchema {\n let result = schema\n\n // Apply pattern (regex) for strings\n if (rules.pattern && (dataType === ModelPropertyDataTypes.Text || dataType === ModelPropertyDataTypes.Html)) {\n try {\n const regex = new RegExp(rules.pattern)\n result = Type.RegExp(regex)\n } catch (error) {\n logger('Invalid regex pattern:', rules.pattern, error)\n }\n }\n\n // Apply minLength/maxLength for strings\n if (dataType === ModelPropertyDataTypes.Text || dataType === ModelPropertyDataTypes.Html) {\n const stringSchema = Type.String()\n if (rules.minLength !== undefined) {\n result = Type.String({ minLength: rules.minLength })\n }\n if (rules.maxLength !== undefined) {\n if (rules.minLength !== undefined) {\n result = Type.String({ minLength: rules.minLength, maxLength: rules.maxLength })\n } else {\n result = Type.String({ maxLength: rules.maxLength })\n }\n }\n }\n\n // Apply enum\n if (rules.enum && Array.isArray(rules.enum) && rules.enum.length > 0) {\n result = Type.Union(rules.enum.map(val => Type.Literal(val)))\n }\n\n return result\n }\n\n /**\n * Validate custom validation rules\n */\n private validateCustomRules(\n value: any,\n rules: ValidationRules\n ): ValidationError[] {\n const errors: ValidationError[] = []\n\n // Custom validator reference (would need to be implemented based on your needs)\n if (rules.custom) {\n // TODO: Implement custom validator lookup and execution\n logger('Custom validator not yet implemented:', rules.custom)\n }\n\n return errors\n }\n}\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,MAAM,GAAG,KAAK,CAAC,2BAA2B,CAAC;AAEjD;;AAEG;MACU,uBAAuB,CAAA;AAClC;;AAEG;AACK,IAAA,mBAAmB,CACzB,KAAU,EACV,MAAe,EACf,SAAiB,EAAA;AAEjB,QAAA,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,IAAI,mBAAmB;;AAG5D,QAAA,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC/D,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC;AACpE,YAAA,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;AAC7B,gBAAA,OAAO,oBAAoB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,YAAA,EAAe,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAClG;QACF;;AAGA,QAAA,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;YAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC;AACjE,YAAA,IAAI,aAAa,KAAK,SAAS,EAAE;AAC/B,gBAAA,OAAO,aAAa,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA,YAAA,EAAe,IAA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AAE,CAAC;gBAClF;qBAAO;AACL,oBAAA,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;gBACtD;YACF;QACF;;QAGA,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACpE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/D;AAEA,QAAA,OAAO,MAAM;IACf;AAEA;;AAEG;IACK,mBAAmB,CACzB,KAAU,EACV,KAAsB,EAAA;QAEtB,MAAM,MAAM,GAAsB,EAAE;;AAGpC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE;;AAEhB,YAAA,MAAM,CAAC,uCAAuC,EAAE,KAAK,CAAC,MAAM,CAAC;QAC/D;AAEA,QAAA,OAAO,MAAM;IACf;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"SchemaValidationService-DyttFaV_.js","sources":["../src/Schema/service/validation/SchemaValidationService.ts"],"sourcesContent":["import { Value } from '@sinclair/typebox/value'\nimport { TProperty } from '@/Schema'\nimport { ModelPropertyDataTypes, TPropertyDataType } from '@/helpers/property'\nimport { ValidationResult, ValidationError, ValidationRules } from '@/Schema/validation'\nimport { SchemaMachineContext } from '../schemaMachine'\nimport { ModelPropertyMachineContext } from '@/ModelProperty/service/modelPropertyMachine'\nimport { ModelMachineContext } from '@/Model/service/modelMachine'\nimport { Type, TSchema, TUnion, TLiteral } from '@sinclair/typebox'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:schema:validation')\n\n/**\n * Service for validating schemas, models, and properties using TypeBox\n */\nexport class SchemaValidationService {\n /**\n * Enhance TypeBox error message with expected values for union/literal types\n */\n private enhanceErrorMessage(\n error: any,\n schema: TSchema,\n fieldPath: string\n ): string {\n const originalMessage = error.message || 'Validation failed'\n \n // Handle Union type errors (like TPropertyDataType)\n if (error.type === 'Union' || originalMessage.includes('union')) {\n const expectedValues = this.extractExpectedValues(schema, fieldPath)\n if (expectedValues.length > 0) {\n return `Expected one of: ${expectedValues.join(', ')}. Received: ${JSON.stringify(error.value)}`\n }\n }\n \n // Handle Literal type errors\n if (error.type === 'Literal') {\n const expectedValue = this.extractLiteralValue(schema, fieldPath)\n if (expectedValue !== undefined) {\n return `Expected: ${JSON.stringify(expectedValue)}. Received: ${JSON.stringify(error.value)}`\n }\n }\n \n // Return enhanced message with value info if available\n if (error.value !== undefined) {\n return `${originalMessage}. Received: ${JSON.stringify(error.value)}`\n }\n \n return originalMessage\n }\n\n /**\n * Extract expected values from a schema for a given field path\n */\n private extractExpectedValues(schema: TSchema | null, fieldPath: string): string[] {\n try {\n // Handle TProperty schema - check if this is the dataType field\n if (fieldPath === '/dataType' || fieldPath.endsWith('/dataType')) {\n // Return all ModelPropertyDataTypes enum values\n return Object.values(ModelPropertyDataTypes) as string[]\n }\n \n // Handle TStorageType\n if (fieldPath === '/storageType' || fieldPath.endsWith('/storageType')) {\n return ['ItemStorage', 'PropertyStorage']\n }\n \n // If we have a schema, try to extract from it\n if (!schema) {\n return []\n }\n \n // Try to extract from TypeBox Union type using the schema directly\n const schemaObj = schema as any\n const kind = schemaObj[Symbol.for('TypeBox.Kind')]\n \n if (kind === 'Union') {\n const union = schemaObj as TUnion<any>\n const anyOf = union.anyOf || []\n const values: string[] = []\n \n for (const item of anyOf) {\n const itemKind = item?.[Symbol.for('TypeBox.Kind')]\n if (itemKind === 'Literal') {\n const literal = item as TLiteral<any>\n if (literal.const !== undefined) {\n values.push(String(literal.const))\n }\n }\n }\n \n if (values.length > 0) {\n return values\n }\n }\n \n // Fallback: try to extract from JSON schema format\n if (typeof schema === 'object' && 'anyOf' in schema) {\n const union = schema as any\n if (Array.isArray(union.anyOf)) {\n return union.anyOf\n .map((item: any) => {\n if (item.const !== undefined) return String(item.const)\n if (item.enum && Array.isArray(item.enum)) return item.enum.map(String)\n return null\n })\n .filter((val: any) => val !== null)\n .flat()\n .map(String)\n }\n }\n } catch (error) {\n logger('Error extracting expected values:', error)\n }\n \n return []\n }\n\n /**\n * Extract literal value from a schema\n */\n private extractLiteralValue(schema: TSchema, fieldPath: string): any {\n try {\n if (schema && typeof schema === 'object') {\n const schemaObj = schema as any\n if (schemaObj[Symbol.for('TypeBox.Kind')] === 'Literal') {\n return (schemaObj as TLiteral<any>).const\n }\n if (schemaObj.const !== undefined) {\n return schemaObj.const\n }\n }\n } catch (error) {\n logger('Error extracting literal value:', error)\n }\n \n return undefined\n }\n\n /**\n * Get the schema for a specific field path\n */\n private getSchemaForField(schema: TSchema, fieldPath: string): TSchema | null {\n try {\n if (!schema || typeof schema !== 'object') return null\n \n // Remove leading slash\n const path = fieldPath.replace(/^\\//, '')\n if (!path) return schema\n \n const schemaObj = schema as any\n const kind = schemaObj[Symbol.for('TypeBox.Kind')]\n \n // For TProperty (Object type), check properties\n if (kind === 'Object') {\n const properties = schemaObj.properties\n if (properties && properties[path]) {\n return properties[path]\n }\n }\n \n // Special handling for known fields - return the actual schema\n if (path === 'dataType') {\n return TPropertyDataType as TSchema\n }\n \n // Fallback: check if schema has the property\n if (path in schemaObj) {\n return schemaObj[path]\n }\n } catch (error) {\n logger('Error getting schema for field:', error)\n }\n \n return null\n }\n\n /**\n * Validate a property structure against TProperty schema\n */\n validatePropertyStructure(\n property: ModelPropertyMachineContext\n ): ValidationResult {\n try {\n const isValid = Value.Check(TProperty, property)\n \n const errors: ValidationError[] = []\n \n if (!isValid) {\n const typeBoxErrors = [...Value.Errors(TProperty, property)]\n errors.push(...typeBoxErrors.map(err => {\n const fieldPath = err.path || 'unknown'\n const fieldSchema = this.getSchemaForField(TProperty, fieldPath)\n const enhancedMessage = this.enhanceErrorMessage(err, fieldSchema || TProperty, fieldPath)\n \n return {\n field: fieldPath,\n message: enhancedMessage,\n code: String(err.type || 'validation_error'),\n severity: 'error' as const,\n }\n }))\n }\n \n // Validate that Relation and List properties have a ref defined\n if (property.dataType === ModelPropertyDataTypes.Relation || property.dataType === ModelPropertyDataTypes.List) {\n const hasRef = property.ref && property.ref.trim() !== ''\n const hasRefModelName = property.refModelName && property.refModelName.trim() !== ''\n const hasRefModelId = property.refModelId !== undefined && property.refModelId !== null\n \n if (!hasRef && !hasRefModelName && !hasRefModelId) {\n errors.push({\n field: 'ref',\n message: `Property with dataType \"${property.dataType}\" requires either a \"ref\", \"refModelName\", or \"refModelId\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n }\n \n // For Relation type, prefer having refModelId when ref/refModelName is provided\n // This is a warning, not an error, as refModelId can be resolved asynchronously\n if (property.dataType === ModelPropertyDataTypes.Relation && (hasRef || hasRefModelName) && !hasRefModelId) {\n // This is acceptable - refModelId will be resolved asynchronously\n // We don't add an error here, just log for debugging\n logger(`Property \"${property.name}\" has ref/refModelName but no refModelId - will be resolved asynchronously`)\n }\n }\n \n return {\n isValid: errors.length === 0,\n errors,\n }\n } catch (error) {\n logger('Error validating property structure:', error)\n return {\n isValid: false,\n errors: [{\n field: 'property',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n }\n }\n }\n\n /**\n * Validate a property value against its validation rules\n */\n validatePropertyValue(\n value: any,\n dataType: ModelPropertyDataTypes,\n validationRules?: ValidationRules\n ): ValidationResult {\n const errors: ValidationError[] = []\n const warnings: ValidationError[] = []\n\n try {\n // Build base TypeBox schema from dataType\n let schema: TSchema = this.getBaseSchemaForDataType(dataType)\n\n // Apply validation rules\n if (validationRules) {\n schema = this.applyValidationRules(schema, dataType, validationRules)\n }\n\n // Validate using TypeBox\n const isValid = Value.Check(schema, value)\n \n if (!isValid) {\n const typeBoxErrors = [...Value.Errors(schema, value)]\n errors.push(...typeBoxErrors.map(err => {\n const fieldPath = err.path || 'value'\n const enhancedMessage = this.enhanceErrorMessage(err, schema, fieldPath)\n \n return {\n field: fieldPath,\n message: enhancedMessage,\n code: String(err.type || 'value_validation_error'),\n severity: 'error' as const,\n }\n }))\n }\n\n // Additional custom validations\n if (validationRules) {\n const customErrors = this.validateCustomRules(value, validationRules)\n errors.push(...customErrors)\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n } catch (error) {\n logger('Error validating property value:', error)\n return {\n isValid: false,\n errors: [{\n field: 'value',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n }\n }\n }\n\n /**\n * Validate a specific property within a schema\n */\n validateProperty(\n schema: SchemaMachineContext,\n modelName: string,\n propertyName: string,\n propertyData?: ModelPropertyMachineContext\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Check if model exists\n if (!schema.models || !schema.models[modelName]) {\n errors.push({\n field: 'model',\n message: `Model \"${modelName}\" not found in schema`,\n code: 'model_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n const model = schema.models[modelName]\n\n // Check if property exists in model\n // If the property name has changed (renamed), check if the original name exists\n let propertyDefinition = model.properties?.[propertyName]\n let actualPropertyName = propertyName\n \n if (!propertyDefinition && propertyData?._originalValues?.name) {\n const originalName = propertyData._originalValues.name\n // If the current name differs from the original, check if original exists\n if (originalName !== propertyName && model.properties?.[originalName]) {\n propertyDefinition = model.properties[originalName]\n actualPropertyName = originalName\n // Property is being renamed, which is allowed - continue validation\n }\n }\n \n if (!propertyDefinition) {\n errors.push({\n field: 'property',\n message: `Property \"${propertyName}\" not found in model \"${modelName}\"`,\n code: 'property_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n // If propertyData is provided, validate its structure\n if (propertyData) {\n const structureResult = this.validatePropertyStructure(propertyData)\n errors.push(...structureResult.errors)\n }\n\n // Validate property definition structure\n if (!propertyDefinition.type) {\n errors.push({\n field: 'property.type',\n message: 'Property type is required',\n code: 'missing_type',\n severity: 'error' as const,\n })\n }\n\n // Validate Relation and List properties have a ref/model defined\n if (propertyDefinition.type === 'Relation' || propertyDefinition.type === 'List') {\n if (!propertyDefinition.model || propertyDefinition.model.trim() === '') {\n errors.push({\n field: 'property.model',\n message: `Property with type \"${propertyDefinition.type}\" requires a \"model\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n } else if (!schema.models[propertyDefinition.model]) {\n errors.push({\n field: 'property.model',\n message: `Referenced model \"${propertyDefinition.model}\" not found in schema`,\n code: 'invalid_reference',\n severity: 'error' as const,\n })\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate model structure (basic structure checks)\n */\n validateModelStructure(\n model: ModelMachineContext & { properties?: { [key: string]: any } }\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Validate model name\n if (!model.modelName || model.modelName.trim() === '') {\n errors.push({\n field: 'modelName',\n message: 'Model name is required',\n code: 'missing_model_name',\n severity: 'error' as const,\n })\n }\n\n // Validate schema name\n if (!model.schemaName || model.schemaName.trim() === '') {\n errors.push({\n field: 'schemaName',\n message: 'Schema name is required',\n code: 'missing_schema_name',\n severity: 'error' as const,\n })\n }\n\n // Validate properties is an object\n if (model.properties && typeof model.properties !== 'object') {\n errors.push({\n field: 'properties',\n message: 'Properties must be an object',\n code: 'invalid_properties',\n severity: 'error' as const,\n })\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate a model against a schema WITHOUT requiring it to be in the schema's context\n * This allows validation before registration, preventing update loops\n */\n validateModelAgainstSchema(\n schema: SchemaMachineContext,\n modelName: string,\n modelData: ModelMachineContext & { properties?: { [key: string]: any } }\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Create a temporary schema context that includes this model for validation purposes\n // This allows validateProperty to work without actually adding the model to the real schema\n const tempSchemaContext: SchemaMachineContext = {\n ...schema,\n models: {\n ...schema.models,\n [modelName]: {\n properties: modelData.properties || {},\n },\n },\n }\n\n // Use validateModel which now works because the model is in the temp context\n return this.validateModel(tempSchemaContext, modelName, modelData)\n }\n\n /**\n * Validate a model within a schema (requires model to already be in schema context)\n */\n validateModel(\n schema: SchemaMachineContext,\n modelName: string,\n modelData?: ModelMachineContext\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n if (!schema.models || !schema.models[modelName]) {\n errors.push({\n field: 'model',\n message: `Model \"${modelName}\" not found in schema`,\n code: 'model_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n const model = schema.models[modelName]\n\n // Validate all properties in the model\n if (model.properties) {\n for (const [propertyName, propertyDef] of Object.entries(model.properties)) {\n const propertyResult = this.validateProperty(schema, modelName, propertyName)\n if (!propertyResult.isValid) {\n errors.push(...propertyResult.errors.map(err => ({\n ...err,\n field: `${modelName}.${propertyName}.${err.field}`,\n })))\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate entire schema\n */\n validateSchema(schema: SchemaMachineContext): ValidationResult {\n const errors: ValidationError[] = []\n\n // Validate schema name\n if (!schema.schemaName || schema.schemaName.trim() === '') {\n errors.push({\n field: 'schemaName',\n message: 'Schema name is required',\n code: 'missing_schema_name',\n severity: 'error' as const,\n })\n }\n\n // Validate metadata\n if (!schema.metadata) {\n errors.push({\n field: 'metadata',\n message: 'Schema metadata is required',\n code: 'missing_metadata',\n severity: 'error' as const,\n })\n } else {\n if (!schema.metadata.name || schema.metadata.name.trim() === '') {\n errors.push({\n field: 'metadata.name',\n message: 'Schema metadata name is required',\n code: 'missing_metadata_name',\n severity: 'error' as const,\n })\n }\n }\n\n // Validate models if they exist\n if (schema.models && Object.keys(schema.models).length > 0) {\n // Validate each model\n for (const modelName of Object.keys(schema.models)) {\n const modelResult = this.validateModel(schema, modelName)\n if (!modelResult.isValid) {\n errors.push(...modelResult.errors)\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Get base TypeBox schema for a data type\n */\n private getBaseSchemaForDataType(dataType: ModelPropertyDataTypes): TSchema {\n switch (dataType) {\n case ModelPropertyDataTypes.Text:\n case ModelPropertyDataTypes.Html:\n return Type.String()\n case ModelPropertyDataTypes.Number:\n return Type.Number()\n case ModelPropertyDataTypes.Boolean:\n return Type.Boolean()\n case ModelPropertyDataTypes.Date:\n return Type.String({ format: 'date-time' })\n case ModelPropertyDataTypes.Json:\n return Type.Any()\n case ModelPropertyDataTypes.List:\n return Type.Array(Type.Any())\n case ModelPropertyDataTypes.Relation:\n case ModelPropertyDataTypes.Image:\n case ModelPropertyDataTypes.File:\n return Type.Union([Type.String(), Type.Null()])\n default:\n return Type.Any()\n }\n }\n\n /**\n * Apply validation rules to a TypeBox schema\n */\n private applyValidationRules(\n schema: TSchema,\n dataType: ModelPropertyDataTypes,\n rules: ValidationRules\n ): TSchema {\n let result = schema\n\n // Apply pattern (regex) for strings\n if (rules.pattern && (dataType === ModelPropertyDataTypes.Text || dataType === ModelPropertyDataTypes.Html)) {\n try {\n const regex = new RegExp(rules.pattern)\n result = Type.RegExp(regex)\n } catch (error) {\n logger('Invalid regex pattern:', rules.pattern, error)\n }\n }\n\n // Apply minLength/maxLength for strings\n if (dataType === ModelPropertyDataTypes.Text || dataType === ModelPropertyDataTypes.Html) {\n const stringSchema = Type.String()\n if (rules.minLength !== undefined) {\n result = Type.String({ minLength: rules.minLength })\n }\n if (rules.maxLength !== undefined) {\n if (rules.minLength !== undefined) {\n result = Type.String({ minLength: rules.minLength, maxLength: rules.maxLength })\n } else {\n result = Type.String({ maxLength: rules.maxLength })\n }\n }\n }\n\n // Apply enum\n if (rules.enum && Array.isArray(rules.enum) && rules.enum.length > 0) {\n result = Type.Union(rules.enum.map(val => Type.Literal(val)))\n }\n\n return result\n }\n\n /**\n * Validate custom validation rules\n */\n private validateCustomRules(\n value: any,\n rules: ValidationRules\n ): ValidationError[] {\n const errors: ValidationError[] = []\n\n // Custom validator reference (would need to be implemented based on your needs)\n if (rules.custom) {\n // TODO: Implement custom validator lookup and execution\n logger('Custom validator not yet implemented:', rules.custom)\n }\n\n return errors\n }\n}\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,MAAM,GAAG,KAAK,CAAC,2BAA2B,CAAC;AAEjD;;AAEG;MACU,uBAAuB,CAAA;AAClC;;AAEG;AACK,IAAA,mBAAmB,CACzB,KAAU,EACV,MAAe,EACf,SAAiB,EAAA;AAEjB,QAAA,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,IAAI,mBAAmB;;AAG5D,QAAA,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC/D,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC;AACpE,YAAA,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;AAC7B,gBAAA,OAAO,oBAAoB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,YAAA,EAAe,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAClG;QACF;;AAGA,QAAA,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;YAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC;AACjE,YAAA,IAAI,aAAa,KAAK,SAAS,EAAE;AAC/B,gBAAA,OAAO,aAAa,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA,YAAA,EAAe,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC/F;QACF;;AAGA,QAAA,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE;AAC7B,YAAA,OAAO,CAAA,EAAG,eAAe,CAAA,YAAA,EAAe,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA,CAAE;QACvE;AAEA,QAAA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