mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
feat: copy connector
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import Ajv, {AnySchema} from 'ajv';
|
||||
import addFormats from 'ajv-formats';
|
||||
import schema, {SchemaMap} from '@openstapps/core/schema.json';
|
||||
import schema from '@openstapps/core/schema.json' assert {type: 'json'};
|
||||
import type {SchemaMap} from '@openstapps/core/schema.json';
|
||||
|
||||
export type RemoveNeverProperties<T> = {
|
||||
[K in Exclude<
|
||||
@@ -32,6 +33,7 @@ export class Validator {
|
||||
this.ajv = new Ajv.default({
|
||||
schemas: [schema, ...additionalSchemas],
|
||||
verbose: true,
|
||||
keywords: ['elasticsearch'],
|
||||
allowUnionTypes: true,
|
||||
});
|
||||
addFormats.default(this.ajv, {
|
||||
@@ -54,7 +56,8 @@ export class Validator {
|
||||
*/
|
||||
public validate<T extends SchemaMap[keyof SchemaMap]>(instance: unknown, schema: NameOf<T>): instance is T;
|
||||
public validate(instance: unknown, schema: Ajv.Schema): boolean;
|
||||
public validate(instance: unknown, schema: string): boolean;
|
||||
public validate(instance: unknown, schema: Ajv.Schema | string): boolean {
|
||||
return this.ajv.validate(schema, instance);
|
||||
return this.ajv.validate(typeof schema === 'string' ? `#/definitions/${schema}` : schema, instance);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user