diff --git a/packages/spec/src/data/validation.test.ts b/packages/spec/src/data/validation.test.ts index fd3b368218..128a8a1d73 100644 --- a/packages/spec/src/data/validation.test.ts +++ b/packages/spec/src/data/validation.test.ts @@ -736,8 +736,7 @@ describe('ValidationRuleSchema (Discriminated Union)', () => { type: 'custom' as const, name: 'custom_business_rule', message: 'Custom validation failed', - field: 'business_field', - validatorFunction: 'validateBusinessRule', + handler: 'validateBusinessRule', }; expect(() => ValidationRuleSchema.parse(customValidation)).not.toThrow(); @@ -748,8 +747,7 @@ describe('ValidationRuleSchema (Discriminated Union)', () => { type: 'custom' as const, name: 'complex_validation', message: 'Validation failed', - field: 'data', - validatorFunction: 'complexValidator', + handler: 'complexValidator', params: { threshold: 100, mode: 'strict', @@ -764,7 +762,7 @@ describe('ValidationRuleSchema (Discriminated Union)', () => { type: 'custom' as const, name: 'record_level_check', message: 'Record validation failed', - validatorFunction: 'validateEntireRecord', + handler: 'validateEntireRecord', }; expect(() => ValidationRuleSchema.parse(validation)).not.toThrow(); @@ -1058,7 +1056,7 @@ describe('ValidationRuleSchema (Discriminated Union)', () => { type: 'custom', name: 'business_logic', message: 'Business logic validation failed', - validatorFunction: 'validateBusinessRules', + handler: 'validateBusinessRules', }, { type: 'conditional', @@ -1212,8 +1210,7 @@ describe('ValidationRuleSchema - Edge Cases and Null Handling', () => { type: 'custom' as const, name: 'custom_validation', message: 'Validation failed', - field: undefined, // Optional for record-level validation - validatorFunction: 'validateRecord', + handler: 'validateRecord', params: undefined, }; @@ -1225,7 +1222,7 @@ describe('ValidationRuleSchema - Edge Cases and Null Handling', () => { type: 'custom' as const, name: 'custom_validation', message: 'Validation failed', - validatorFunction: 'validateRecord', + handler: 'validateRecord', params: {}, }; @@ -1339,7 +1336,7 @@ describe('ValidationRuleSchema - Type Coercion Edge Cases', () => { type: 'custom' as const, name: 'custom_test', message: 'Test', - validatorFunction: 'validate', + handler: 'validate', params, }; diff --git a/packages/spec/src/hub/tenant.zod.ts b/packages/spec/src/hub/tenant.zod.ts index fd411afac2..a2df74988f 100644 --- a/packages/spec/src/hub/tenant.zod.ts +++ b/packages/spec/src/hub/tenant.zod.ts @@ -48,9 +48,66 @@ export const TenantQuotaSchema = z.object({ export type TenantQuota = z.infer; -// Tenant Schema REMOVED. -// The concept of a "Tenant" is now an attribute of a "Space". -// See HubSpaceSchema in space.zod.ts which embeds TenantIsolationLevel and TenantQuotaSchema. +/** + * Tenant Schema + * + * @deprecated This schema is maintained for backward compatibility only. + * New implementations should use HubSpaceSchema which embeds tenant concepts. + * + * **Migration Guide:** + * ```typescript + * // Old approach (deprecated): + * const tenant: Tenant = { + * id: 'tenant_123', + * name: 'My Tenant', + * isolationLevel: 'shared_schema', + * quotas: { maxUsers: 100 } + * }; + * + * // New approach (recommended): + * const space: HubSpace = { + * id: '...uuid...', + * name: 'My Tenant', + * slug: 'my-tenant', + * ownerId: 'user_id', + * runtime: { + * isolation: 'shared_schema', + * quotas: { maxUsers: 100 } + * }, + * bom: { ... } + * }; + * ``` + * + * See HubSpaceSchema in space.zod.ts for the recommended approach. + */ +export const TenantSchema = z.object({ + /** + * Unique tenant identifier + */ + id: z.string().describe('Unique tenant identifier'), + + /** + * Tenant display name + */ + name: z.string().describe('Tenant display name'), + + /** + * Data isolation level + */ + isolationLevel: TenantIsolationLevel, + + /** + * Custom configuration values + */ + customizations: z.record(z.any()).optional().describe('Custom configuration values'), + + /** + * Resource quotas + */ + quotas: TenantQuotaSchema.optional(), +}); + +export type Tenant = z.infer; /** * Tenant Isolation Strategy Documentation