@orion-js/schema 4.0.0-next.7 → 4.0.0

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/dist/index.d.cts CHANGED
@@ -1,20 +1,3 @@
1
- interface FieldTypeOpts<TType = any> {
2
- name: string;
3
- validate?: ValidateFunction<TType>;
4
- clean?: CleanFunction<TType>;
5
- toGraphQLType?: (GraphQL: any) => any;
6
- meta?: any;
7
- }
8
- interface FieldType<TType = any> {
9
- name: string;
10
- validate: ValidateFunction;
11
- clean: CleanFunction;
12
- meta?: any;
13
- toGraphQLType?: (GraphQL: any) => any;
14
- __tsFieldType: TType;
15
- __isFieldType: boolean;
16
- }
17
-
18
1
  type Constructor<T> = new (...args: any[]) => T;
19
2
  type Blackbox = {
20
3
  [name: string]: any;
@@ -23,8 +6,10 @@ type FieldTypesList = 'string' | 'date' | 'integer' | 'number' | 'ID' | 'boolean
23
6
  type AClass$1 = abstract new (...args: any) => any;
24
7
  type TypedSchemaOnSchema = AClass$1;
25
8
  type ConstructorsTypesList = Constructor<String> | Constructor<Number> | Constructor<Boolean> | Constructor<Date> | StringConstructor | NumberConstructor | BooleanConstructor | DateConstructor | String | Number | Boolean | Date;
26
- type SchemaMetaFieldTypeSingle = FieldTypesList | ConstructorsTypesList | Schema | FieldType | TypedSchemaOnSchema;
9
+ type SchemaMetaFieldTypeSingleNonSchema = FieldTypesList | ConstructorsTypesList | FieldType;
10
+ type SchemaMetaFieldTypeSingle = SchemaMetaFieldTypeSingleNonSchema | Schema | TypedSchemaOnSchema;
27
11
  type SchemaFieldType = SchemaMetaFieldTypeSingle | SchemaMetaFieldTypeSingle[];
12
+ type SchemaFieldTypeNonSchema = SchemaMetaFieldTypeSingleNonSchema | SchemaMetaFieldTypeSingleNonSchema[];
28
13
  type ValidateFunction<TType = any> = (value: TType, info?: Partial<CurrentNodeInfo>, ...args: any[]) => object | string | null | undefined | void | Promise<object | string | null | undefined | void>;
29
14
  type CleanFunction<TType = any> = (value: TType, info?: Partial<CurrentNodeInfo>, ...args: any[]) => TType | Promise<TType>;
30
15
  type SchemaRecursiveNodeTypeExtras = {
@@ -104,22 +89,22 @@ interface CurrentNodeInfoOptions {
104
89
  forceDoc?: any;
105
90
  omitRequired?: boolean;
106
91
  }
107
- interface CurrentNodeInfo<TType extends SchemaFieldType = any> {
92
+ interface CurrentNodeInfo {
108
93
  /**
109
94
  * The global schema, prefaced by {type: {...}} to be compatible with subschemas
110
95
  * Sometimes it's given without {type: {...}}. TODO: Normalize this.
111
96
  */
112
- schema?: SchemaNode | Schema;
97
+ schema?: SchemaFieldType;
113
98
  /**
114
99
  * The current node subschema
115
100
  */
116
- currentSchema?: Partial<SchemaNode<TType>>;
117
- value: TType;
101
+ currentSchema?: Partial<SchemaNode<SchemaFieldType>>;
102
+ value: InferSchemaType<SchemaFieldType>;
118
103
  doc?: any;
119
104
  currentDoc?: any;
120
105
  options?: CurrentNodeInfoOptions;
121
106
  args?: any[];
122
- type?: TType;
107
+ type?: SchemaFieldType;
123
108
  keys?: string[];
124
109
  addError?: (keys: string[], code: string | object) => void;
125
110
  }
@@ -140,41 +125,64 @@ type SchemaMetadata = {
140
125
  type Schema = {
141
126
  [K: string]: SchemaNode;
142
127
  };
128
+ type SingleLevelSchema = {
129
+ [K: string]: SchemaNode<SchemaFieldTypeNonSchema>;
130
+ };
131
+ type SchemaInAnyOrionForm = Schema | TypedSchemaOnSchema;
143
132
  type SchemaWithMetadata = {
144
133
  [K: string]: SchemaNode | SchemaMetadata[keyof SchemaMetadata];
145
134
  } & SchemaMetadata;
146
135
 
136
+ interface FieldTypeOpts<TType = any> {
137
+ name: string;
138
+ validate?: ValidateFunction<TType>;
139
+ clean?: CleanFunction<TType>;
140
+ toGraphQLType?: (GraphQL: any) => any;
141
+ meta?: any;
142
+ }
143
+ interface FieldType<TType = any> {
144
+ name: string;
145
+ validate: ValidateFunction;
146
+ clean: CleanFunction;
147
+ meta?: any;
148
+ toGraphQLType?: (GraphQL: any) => any;
149
+ __tsFieldType: TType;
150
+ __isFieldType: boolean;
151
+ }
152
+
147
153
  type InferSchemaTypeForFieldType<T> = T extends {
148
154
  __tsFieldType: infer U;
149
155
  } ? U : T extends 'string' ? string : T extends 'date' ? Date : T extends 'integer' ? number : T extends 'number' ? number : T extends 'ID' ? string : T extends 'boolean' ? boolean : T extends 'email' ? string : T extends 'blackbox' ? Blackbox : T extends 'any' ? any : T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T extends Date ? Date : T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? Date : T extends Array<infer U> ? InferSchemaTypeForFieldType<U>[] : T extends Record<string, any> ? InferSchemaTypeForSchema<T> : T;
150
156
  type SchemaKeysNotOfSchemaItems = keyof SchemaRecursiveNodeTypeExtras;
151
157
  type NodeIsOptional<TNode> = TNode extends {
152
158
  optional: true;
153
- } ? true : TNode extends {
154
- defaultValue: any;
155
159
  } ? true : false;
156
160
  type InferSchemaTypeForSchema<TSchema extends Record<string, any>> = Omit<{
157
- -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? never : K]: InferSchemaTypeForFieldType<TSchema[K]['type']>;
161
+ -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? never : K]: InferSchemaType<TSchema[K]['type']>;
158
162
  } & {
159
- -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? K : never]?: InferSchemaTypeForFieldType<TSchema[K]['type']>;
163
+ -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? K : never]?: InferSchemaType<TSchema[K]['type']>;
160
164
  }, SchemaKeysNotOfSchemaItems>;
161
- type IsPossiblyASchema<TType> = TType extends Record<string, any> ? keyof {
165
+ type IsPossiblyASchema<TType> = TType extends FieldType ? false : TType extends Record<string, any> ? keyof {
162
166
  [K in keyof TType as 'type' extends keyof TType[K] ? K : never]: TType[K];
163
167
  } extends never ? false : true : false;
164
- type AClass = abstract new (...args: any) => any;
168
+ type AClass<T = any> = abstract new (...args: any) => T;
165
169
  /**
166
170
  * Returns the type of the schema
167
171
  */
168
172
  type InferSchemaType<TType> = TType extends {
169
173
  __isModel: true;
170
174
  type: infer U;
171
- } ? InferSchemaTypeForSchema<U> : TType extends AClass ? InstanceType<TType> : IsPossiblyASchema<TType> extends true ? InferSchemaTypeForSchema<TType> : InferSchemaTypeForFieldType<TType>;
175
+ } ? InferSchemaTypeForSchema<U> : TType extends SchemaMetaFieldTypeSingleNonSchema ? InferSchemaTypeForFieldType<TType> : TType extends AClass<infer U> ? U : IsPossiblyASchema<TType> extends true ? InferSchemaTypeForSchema<TType> : InferSchemaTypeForFieldType<TType>;
172
176
  /**
173
177
  * Returns the type of the schema but only if its a schema
174
178
  */
175
179
  type StrictInferSchemaType<TSchema extends Schema> = InferSchemaTypeForSchema<TSchema>;
180
+ /**
181
+ * Returns the type of the schema but only if its a schema
182
+ */
183
+ type InferSchemaTypeFromTypedSchema<TTypedSchema extends TypedSchemaOnSchema> = TTypedSchema;
176
184
 
177
- declare function validate<TSchema extends Schema = Schema>(schema: TSchema | Function, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<void>;
185
+ declare function validate<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<void>;
178
186
 
179
187
  interface ValidationErrorInfo {
180
188
  error: string;
@@ -191,10 +199,6 @@ declare class ValidationError extends Error {
191
199
  prependKey: (prepend: any) => ValidationError;
192
200
  }
193
201
 
194
- declare function getValidationErrors(schema: Schema | Function, doc: any, passedOptions?: {}, ...args: any[]): Promise<any>;
195
-
196
- declare function isValid(schema: Schema, doc: any, passedOptions?: {}, ...args: any[]): Promise<boolean>;
197
-
198
202
  declare const _default: {
199
203
  array: FieldType<any[]>;
200
204
  plainObject: FieldType<Blackbox>;
@@ -211,11 +215,15 @@ declare const _default: {
211
215
 
212
216
  type FieldValidatorType = keyof typeof _default | 'custom' | 'plainObject';
213
217
 
214
- declare function getFieldType(type: SchemaFieldType | FieldValidatorType | any): FieldType;
215
-
216
218
  type MergeSchemas<SchemaA extends Schema, SchemaB extends Schema> = SchemaA & SchemaB;
217
219
 
218
- declare function clean<TSchema extends Schema = Schema>(schema: TSchema | Function, doc: InferSchemaType<TSchema>, opts?: CurrentNodeInfoOptions, ...args: any[]): Promise<InferSchemaType<TSchema>>;
220
+ declare function getValidationErrors<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<any>;
221
+
222
+ declare function isValid<TSchema extends Schema>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<boolean>;
223
+
224
+ declare function getFieldType(type: SchemaFieldType | FieldValidatorType | any): FieldType;
225
+
226
+ declare function clean<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, opts?: CurrentNodeInfoOptions, ...args: any[]): Promise<InferSchemaType<TSchema>>;
219
227
 
220
228
  declare function export_default$2(schema: any, key: any, value: any, passedOptions?: {}, ...args: any[]): Promise<any>;
221
229
 
@@ -223,16 +231,17 @@ declare function export_default$1(schema: Schema, key: string, value: any, passe
223
231
 
224
232
  declare function export_default(schema: Schema, path: string): SchemaNode;
225
233
 
226
- declare function createEnum<const TValues extends readonly string[]>(name: string, values: TValues): FieldType<TValues[number]> & {
227
- type: TValues[number];
228
- };
234
+ declare function createEnum<const TValues extends readonly string[]>(name: string, values: TValues): FieldType<TValues[number]>;
229
235
 
230
236
  declare function isSchemaLike(type: any): boolean;
237
+ declare function isStrictSchemaLike<TType extends Schema | SchemaFieldTypeNonSchema>(type: TType): TType extends Schema ? true : false;
231
238
  declare function isSchemaOrFieldLike(type: any): boolean;
232
239
  declare function getSchemaModelName(type: any): string | null;
233
- declare function getSchemaFromAnyOrionForm(type: any): Schema;
240
+ declare function getSchemaFromAnyOrionForm(type: any): SchemaFieldType;
234
241
  declare function getSchemaWithMetadataFromAnyOrionForm(type: any): SchemaWithMetadata;
235
242
 
243
+ declare function cleanAndValidate<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>): Promise<InferSchemaType<TSchema>>;
244
+
236
245
  /**
237
246
  * Assigns a name to a schema for GraphQL type generation.
238
247
  *
@@ -248,4 +257,4 @@ declare function getSchemaWithMetadataFromAnyOrionForm(type: any): SchemaWithMet
248
257
  */
249
258
  declare function schemaWithName<TModelName extends string, TSchema extends Schema>(name: TModelName, schema: TSchema): TSchema;
250
259
 
251
- export { type Blackbox, type CleanFunction, type Constructor, type ConstructorsTypesList, type CurrentNodeInfo, type CurrentNodeInfoOptions, type FieldType, type FieldTypeOpts, type FieldTypesList, type FieldValidatorType, type InferSchemaType, type MergeSchemas, type Schema, type SchemaFieldType, type SchemaMetaFieldTypeSingle, type SchemaMetadata, type SchemaNode, type SchemaRecursiveNodeTypeExtras, type SchemaWithMetadata, type StrictInferSchemaType, type TypedSchemaOnSchema, type ValidateFunction, ValidationError, clean, export_default$2 as cleanKey, createEnum, export_default as dotGetSchema, _default as fieldTypes, getFieldType, getSchemaFromAnyOrionForm, getSchemaModelName, getSchemaWithMetadataFromAnyOrionForm, getValidationErrors, isSchemaLike, isSchemaOrFieldLike, isValid, schemaWithName, validate, export_default$1 as validateKey };
260
+ export { type Blackbox, type CleanFunction, type Constructor, type ConstructorsTypesList, type CurrentNodeInfo, type CurrentNodeInfoOptions, type FieldType, type FieldTypeOpts, type FieldTypesList, type FieldValidatorType, type InferSchemaType, type InferSchemaTypeFromTypedSchema, type MergeSchemas, type Schema, type SchemaFieldType, type SchemaFieldTypeNonSchema, type SchemaInAnyOrionForm, type SchemaMetaFieldTypeSingle, type SchemaMetaFieldTypeSingleNonSchema, type SchemaMetadata, type SchemaNode, type SchemaRecursiveNodeTypeExtras, type SchemaWithMetadata, type SingleLevelSchema, type StrictInferSchemaType, type TypedSchemaOnSchema, type ValidateFunction, ValidationError, clean, cleanAndValidate, export_default$2 as cleanKey, createEnum, export_default as dotGetSchema, _default as fieldTypes, getFieldType, getSchemaFromAnyOrionForm, getSchemaModelName, getSchemaWithMetadataFromAnyOrionForm, getValidationErrors, isSchemaLike, isSchemaOrFieldLike, isStrictSchemaLike, isValid, schemaWithName, validate, export_default$1 as validateKey };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,3 @@
1
- interface FieldTypeOpts<TType = any> {
2
- name: string;
3
- validate?: ValidateFunction<TType>;
4
- clean?: CleanFunction<TType>;
5
- toGraphQLType?: (GraphQL: any) => any;
6
- meta?: any;
7
- }
8
- interface FieldType<TType = any> {
9
- name: string;
10
- validate: ValidateFunction;
11
- clean: CleanFunction;
12
- meta?: any;
13
- toGraphQLType?: (GraphQL: any) => any;
14
- __tsFieldType: TType;
15
- __isFieldType: boolean;
16
- }
17
-
18
1
  type Constructor<T> = new (...args: any[]) => T;
19
2
  type Blackbox = {
20
3
  [name: string]: any;
@@ -23,8 +6,10 @@ type FieldTypesList = 'string' | 'date' | 'integer' | 'number' | 'ID' | 'boolean
23
6
  type AClass$1 = abstract new (...args: any) => any;
24
7
  type TypedSchemaOnSchema = AClass$1;
25
8
  type ConstructorsTypesList = Constructor<String> | Constructor<Number> | Constructor<Boolean> | Constructor<Date> | StringConstructor | NumberConstructor | BooleanConstructor | DateConstructor | String | Number | Boolean | Date;
26
- type SchemaMetaFieldTypeSingle = FieldTypesList | ConstructorsTypesList | Schema | FieldType | TypedSchemaOnSchema;
9
+ type SchemaMetaFieldTypeSingleNonSchema = FieldTypesList | ConstructorsTypesList | FieldType;
10
+ type SchemaMetaFieldTypeSingle = SchemaMetaFieldTypeSingleNonSchema | Schema | TypedSchemaOnSchema;
27
11
  type SchemaFieldType = SchemaMetaFieldTypeSingle | SchemaMetaFieldTypeSingle[];
12
+ type SchemaFieldTypeNonSchema = SchemaMetaFieldTypeSingleNonSchema | SchemaMetaFieldTypeSingleNonSchema[];
28
13
  type ValidateFunction<TType = any> = (value: TType, info?: Partial<CurrentNodeInfo>, ...args: any[]) => object | string | null | undefined | void | Promise<object | string | null | undefined | void>;
29
14
  type CleanFunction<TType = any> = (value: TType, info?: Partial<CurrentNodeInfo>, ...args: any[]) => TType | Promise<TType>;
30
15
  type SchemaRecursiveNodeTypeExtras = {
@@ -104,22 +89,22 @@ interface CurrentNodeInfoOptions {
104
89
  forceDoc?: any;
105
90
  omitRequired?: boolean;
106
91
  }
107
- interface CurrentNodeInfo<TType extends SchemaFieldType = any> {
92
+ interface CurrentNodeInfo {
108
93
  /**
109
94
  * The global schema, prefaced by {type: {...}} to be compatible with subschemas
110
95
  * Sometimes it's given without {type: {...}}. TODO: Normalize this.
111
96
  */
112
- schema?: SchemaNode | Schema;
97
+ schema?: SchemaFieldType;
113
98
  /**
114
99
  * The current node subschema
115
100
  */
116
- currentSchema?: Partial<SchemaNode<TType>>;
117
- value: TType;
101
+ currentSchema?: Partial<SchemaNode<SchemaFieldType>>;
102
+ value: InferSchemaType<SchemaFieldType>;
118
103
  doc?: any;
119
104
  currentDoc?: any;
120
105
  options?: CurrentNodeInfoOptions;
121
106
  args?: any[];
122
- type?: TType;
107
+ type?: SchemaFieldType;
123
108
  keys?: string[];
124
109
  addError?: (keys: string[], code: string | object) => void;
125
110
  }
@@ -140,41 +125,64 @@ type SchemaMetadata = {
140
125
  type Schema = {
141
126
  [K: string]: SchemaNode;
142
127
  };
128
+ type SingleLevelSchema = {
129
+ [K: string]: SchemaNode<SchemaFieldTypeNonSchema>;
130
+ };
131
+ type SchemaInAnyOrionForm = Schema | TypedSchemaOnSchema;
143
132
  type SchemaWithMetadata = {
144
133
  [K: string]: SchemaNode | SchemaMetadata[keyof SchemaMetadata];
145
134
  } & SchemaMetadata;
146
135
 
136
+ interface FieldTypeOpts<TType = any> {
137
+ name: string;
138
+ validate?: ValidateFunction<TType>;
139
+ clean?: CleanFunction<TType>;
140
+ toGraphQLType?: (GraphQL: any) => any;
141
+ meta?: any;
142
+ }
143
+ interface FieldType<TType = any> {
144
+ name: string;
145
+ validate: ValidateFunction;
146
+ clean: CleanFunction;
147
+ meta?: any;
148
+ toGraphQLType?: (GraphQL: any) => any;
149
+ __tsFieldType: TType;
150
+ __isFieldType: boolean;
151
+ }
152
+
147
153
  type InferSchemaTypeForFieldType<T> = T extends {
148
154
  __tsFieldType: infer U;
149
155
  } ? U : T extends 'string' ? string : T extends 'date' ? Date : T extends 'integer' ? number : T extends 'number' ? number : T extends 'ID' ? string : T extends 'boolean' ? boolean : T extends 'email' ? string : T extends 'blackbox' ? Blackbox : T extends 'any' ? any : T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T extends Date ? Date : T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? Date : T extends Array<infer U> ? InferSchemaTypeForFieldType<U>[] : T extends Record<string, any> ? InferSchemaTypeForSchema<T> : T;
150
156
  type SchemaKeysNotOfSchemaItems = keyof SchemaRecursiveNodeTypeExtras;
151
157
  type NodeIsOptional<TNode> = TNode extends {
152
158
  optional: true;
153
- } ? true : TNode extends {
154
- defaultValue: any;
155
159
  } ? true : false;
156
160
  type InferSchemaTypeForSchema<TSchema extends Record<string, any>> = Omit<{
157
- -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? never : K]: InferSchemaTypeForFieldType<TSchema[K]['type']>;
161
+ -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? never : K]: InferSchemaType<TSchema[K]['type']>;
158
162
  } & {
159
- -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? K : never]?: InferSchemaTypeForFieldType<TSchema[K]['type']>;
163
+ -readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? K : never]?: InferSchemaType<TSchema[K]['type']>;
160
164
  }, SchemaKeysNotOfSchemaItems>;
161
- type IsPossiblyASchema<TType> = TType extends Record<string, any> ? keyof {
165
+ type IsPossiblyASchema<TType> = TType extends FieldType ? false : TType extends Record<string, any> ? keyof {
162
166
  [K in keyof TType as 'type' extends keyof TType[K] ? K : never]: TType[K];
163
167
  } extends never ? false : true : false;
164
- type AClass = abstract new (...args: any) => any;
168
+ type AClass<T = any> = abstract new (...args: any) => T;
165
169
  /**
166
170
  * Returns the type of the schema
167
171
  */
168
172
  type InferSchemaType<TType> = TType extends {
169
173
  __isModel: true;
170
174
  type: infer U;
171
- } ? InferSchemaTypeForSchema<U> : TType extends AClass ? InstanceType<TType> : IsPossiblyASchema<TType> extends true ? InferSchemaTypeForSchema<TType> : InferSchemaTypeForFieldType<TType>;
175
+ } ? InferSchemaTypeForSchema<U> : TType extends SchemaMetaFieldTypeSingleNonSchema ? InferSchemaTypeForFieldType<TType> : TType extends AClass<infer U> ? U : IsPossiblyASchema<TType> extends true ? InferSchemaTypeForSchema<TType> : InferSchemaTypeForFieldType<TType>;
172
176
  /**
173
177
  * Returns the type of the schema but only if its a schema
174
178
  */
175
179
  type StrictInferSchemaType<TSchema extends Schema> = InferSchemaTypeForSchema<TSchema>;
180
+ /**
181
+ * Returns the type of the schema but only if its a schema
182
+ */
183
+ type InferSchemaTypeFromTypedSchema<TTypedSchema extends TypedSchemaOnSchema> = TTypedSchema;
176
184
 
177
- declare function validate<TSchema extends Schema = Schema>(schema: TSchema | Function, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<void>;
185
+ declare function validate<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<void>;
178
186
 
179
187
  interface ValidationErrorInfo {
180
188
  error: string;
@@ -191,10 +199,6 @@ declare class ValidationError extends Error {
191
199
  prependKey: (prepend: any) => ValidationError;
192
200
  }
193
201
 
194
- declare function getValidationErrors(schema: Schema | Function, doc: any, passedOptions?: {}, ...args: any[]): Promise<any>;
195
-
196
- declare function isValid(schema: Schema, doc: any, passedOptions?: {}, ...args: any[]): Promise<boolean>;
197
-
198
202
  declare const _default: {
199
203
  array: FieldType<any[]>;
200
204
  plainObject: FieldType<Blackbox>;
@@ -211,11 +215,15 @@ declare const _default: {
211
215
 
212
216
  type FieldValidatorType = keyof typeof _default | 'custom' | 'plainObject';
213
217
 
214
- declare function getFieldType(type: SchemaFieldType | FieldValidatorType | any): FieldType;
215
-
216
218
  type MergeSchemas<SchemaA extends Schema, SchemaB extends Schema> = SchemaA & SchemaB;
217
219
 
218
- declare function clean<TSchema extends Schema = Schema>(schema: TSchema | Function, doc: InferSchemaType<TSchema>, opts?: CurrentNodeInfoOptions, ...args: any[]): Promise<InferSchemaType<TSchema>>;
220
+ declare function getValidationErrors<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<any>;
221
+
222
+ declare function isValid<TSchema extends Schema>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<boolean>;
223
+
224
+ declare function getFieldType(type: SchemaFieldType | FieldValidatorType | any): FieldType;
225
+
226
+ declare function clean<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, opts?: CurrentNodeInfoOptions, ...args: any[]): Promise<InferSchemaType<TSchema>>;
219
227
 
220
228
  declare function export_default$2(schema: any, key: any, value: any, passedOptions?: {}, ...args: any[]): Promise<any>;
221
229
 
@@ -223,16 +231,17 @@ declare function export_default$1(schema: Schema, key: string, value: any, passe
223
231
 
224
232
  declare function export_default(schema: Schema, path: string): SchemaNode;
225
233
 
226
- declare function createEnum<const TValues extends readonly string[]>(name: string, values: TValues): FieldType<TValues[number]> & {
227
- type: TValues[number];
228
- };
234
+ declare function createEnum<const TValues extends readonly string[]>(name: string, values: TValues): FieldType<TValues[number]>;
229
235
 
230
236
  declare function isSchemaLike(type: any): boolean;
237
+ declare function isStrictSchemaLike<TType extends Schema | SchemaFieldTypeNonSchema>(type: TType): TType extends Schema ? true : false;
231
238
  declare function isSchemaOrFieldLike(type: any): boolean;
232
239
  declare function getSchemaModelName(type: any): string | null;
233
- declare function getSchemaFromAnyOrionForm(type: any): Schema;
240
+ declare function getSchemaFromAnyOrionForm(type: any): SchemaFieldType;
234
241
  declare function getSchemaWithMetadataFromAnyOrionForm(type: any): SchemaWithMetadata;
235
242
 
243
+ declare function cleanAndValidate<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>): Promise<InferSchemaType<TSchema>>;
244
+
236
245
  /**
237
246
  * Assigns a name to a schema for GraphQL type generation.
238
247
  *
@@ -248,4 +257,4 @@ declare function getSchemaWithMetadataFromAnyOrionForm(type: any): SchemaWithMet
248
257
  */
249
258
  declare function schemaWithName<TModelName extends string, TSchema extends Schema>(name: TModelName, schema: TSchema): TSchema;
250
259
 
251
- export { type Blackbox, type CleanFunction, type Constructor, type ConstructorsTypesList, type CurrentNodeInfo, type CurrentNodeInfoOptions, type FieldType, type FieldTypeOpts, type FieldTypesList, type FieldValidatorType, type InferSchemaType, type MergeSchemas, type Schema, type SchemaFieldType, type SchemaMetaFieldTypeSingle, type SchemaMetadata, type SchemaNode, type SchemaRecursiveNodeTypeExtras, type SchemaWithMetadata, type StrictInferSchemaType, type TypedSchemaOnSchema, type ValidateFunction, ValidationError, clean, export_default$2 as cleanKey, createEnum, export_default as dotGetSchema, _default as fieldTypes, getFieldType, getSchemaFromAnyOrionForm, getSchemaModelName, getSchemaWithMetadataFromAnyOrionForm, getValidationErrors, isSchemaLike, isSchemaOrFieldLike, isValid, schemaWithName, validate, export_default$1 as validateKey };
260
+ export { type Blackbox, type CleanFunction, type Constructor, type ConstructorsTypesList, type CurrentNodeInfo, type CurrentNodeInfoOptions, type FieldType, type FieldTypeOpts, type FieldTypesList, type FieldValidatorType, type InferSchemaType, type InferSchemaTypeFromTypedSchema, type MergeSchemas, type Schema, type SchemaFieldType, type SchemaFieldTypeNonSchema, type SchemaInAnyOrionForm, type SchemaMetaFieldTypeSingle, type SchemaMetaFieldTypeSingleNonSchema, type SchemaMetadata, type SchemaNode, type SchemaRecursiveNodeTypeExtras, type SchemaWithMetadata, type SingleLevelSchema, type StrictInferSchemaType, type TypedSchemaOnSchema, type ValidateFunction, ValidationError, clean, cleanAndValidate, export_default$2 as cleanKey, createEnum, export_default as dotGetSchema, _default as fieldTypes, getFieldType, getSchemaFromAnyOrionForm, getSchemaModelName, getSchemaWithMetadataFromAnyOrionForm, getValidationErrors, isSchemaLike, isSchemaOrFieldLike, isStrictSchemaLike, isValid, schemaWithName, validate, export_default$1 as validateKey };