Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions packages/spec/src/data/validation.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -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();
Expand All@@ -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',
Expand All@@ -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();
Expand DownExpand Up@@ -1058,7 +1056,7 @@ describe('ValidationRuleSchema (Discriminated Union)', () => {
type: 'custom',
name: 'business_logic',
message: 'Business logic validation failed',
validatorFunction: 'validateBusinessRules',
handler: 'validateBusinessRules',
},
{
type: 'conditional',
Expand DownExpand Up@@ -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,
};

Expand All@@ -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: {},
};

Expand DownExpand Up@@ -1339,7 +1336,7 @@ describe('ValidationRuleSchema - Type Coercion Edge Cases', () => {
type: 'custom' as const,
name: 'custom_test',
message: 'Test',
validatorFunction: 'validate',
handler: 'validate',
params,
};

Expand Down
63 changes: 60 additions & 3 deletions packages/spec/src/hub/tenant.zod.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,9 +48,66 @@ export const TenantQuotaSchema = z.object({

export type TenantQuota = z.infer<typeof TenantQuotaSchema>;

// 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<typeof TenantSchema>;

/**
* Tenant Isolation Strategy Documentation
Expand Down
Loading