feat(ai): add mcp-metadata (#13150)
Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
|
||||
class ValidationSchemaManager {
|
||||
private static instance: ValidationSchemaManager;
|
||||
private schemas: Record<string, JSONSchema7> | null = null;
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public static getInstance(): ValidationSchemaManager {
|
||||
if (!ValidationSchemaManager.instance) {
|
||||
ValidationSchemaManager.instance = new ValidationSchemaManager();
|
||||
}
|
||||
|
||||
return ValidationSchemaManager.instance;
|
||||
}
|
||||
|
||||
public getSchemas(): Record<string, JSONSchema7> {
|
||||
if (!this.schemas) {
|
||||
this.schemas = validationMetadatasToSchemas() as Record<
|
||||
string,
|
||||
JSONSchema7
|
||||
>;
|
||||
}
|
||||
|
||||
return this.schemas;
|
||||
}
|
||||
}
|
||||
|
||||
export const validationSchemaManager = ValidationSchemaManager.getInstance();
|
||||
Reference in New Issue
Block a user