From d16ef247fb0e0fc710944cf5983d3f89cf6a2127 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Fri, 4 Apr 2025 13:36:06 +0100 Subject: [PATCH 1/2] export the JSONSchema type --- src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.ts b/src/index.ts index aa6ad6f..c94c10d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,6 +22,7 @@ import { convertInternalToMongodb } from './schema-converters/internalToMongoDB' import { convertInternalToStandard } from './schema-converters/internalToStandard'; import * as schemaStats from './stats'; import { AnyIterable, StandardJSONSchema, MongoDBJSONSchema, ExpandedJSONSchema } from './types'; +import type { JSONSchema } from './to-typescript'; import { toTypescriptTypeDefinition } from './to-typescript'; /** @@ -86,6 +87,7 @@ export type { StandardJSONSchema, MongoDBJSONSchema, ExpandedJSONSchema, + JSONSchema, SchemaAccessor }; From 3cca3f50daa49db883f3fbb37cf0a87c6163bfae Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Fri, 4 Apr 2025 13:45:10 +0100 Subject: [PATCH 2/2] move JSONSchema to types.ts --- src/index.ts | 3 +-- src/to-typescript.ts | 5 +---- src/types.ts | 2 ++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index c94c10d..9c403e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,8 +21,7 @@ import { convertInternalToExpanded } from './schema-converters/internalToExpande import { convertInternalToMongodb } from './schema-converters/internalToMongoDB'; import { convertInternalToStandard } from './schema-converters/internalToStandard'; import * as schemaStats from './stats'; -import { AnyIterable, StandardJSONSchema, MongoDBJSONSchema, ExpandedJSONSchema } from './types'; -import type { JSONSchema } from './to-typescript'; +import { AnyIterable, StandardJSONSchema, MongoDBJSONSchema, ExpandedJSONSchema, JSONSchema } from './types'; import { toTypescriptTypeDefinition } from './to-typescript'; /** diff --git a/src/to-typescript.ts b/src/to-typescript.ts index a1ad3d4..75cfef9 100644 --- a/src/to-typescript.ts +++ b/src/to-typescript.ts @@ -1,7 +1,4 @@ -import type { JSONSchema4 } from 'json-schema'; -import type { MongoDBJSONSchema } from './types'; - -export type JSONSchema = Partial & MongoDBJSONSchema; +import type { JSONSchema } from './types'; function getBSONType(property: JSONSchema): string | string[] | undefined { return property.bsonType || property.type; diff --git a/src/types.ts b/src/types.ts index 5c340f4..854917a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,6 +23,8 @@ export type ExpandedJSONSchema = StandardJSONSchema & { anyOf?: ExpandedJSONSchema[]; } +export type JSONSchema = Partial & MongoDBJSONSchema; + export type AnyIterable = Iterable | AsyncIterable; type AnySchema = InternalSchema | StandardJSONSchema | MongoDBJSONSchema | ExpandedJSONSchema;