mongodb-schema
Version:
Infer the probabilistic schema for a MongoDB collection.
229 lines (228 loc) • 5.71 kB
TypeScript
/// <reference types="node" />
import { JSONSchema4TypeName } from 'json-schema';
import { Schema as InternalSchema, SchemaType } from '../schema-analyzer';
import { StandardJSONSchema } from '../types';
type StandardTypeDefinition = {
type: JSONSchema4TypeName;
$ref?: never;
} | {
$ref: string;
type?: never;
};
type TypeToDefinitionMap = Record<SchemaType['name'] | 'Double' | 'BSONSymbol', StandardTypeDefinition>;
export declare const InternalTypeToStandardTypeMap: TypeToDefinitionMap;
export declare const RELAXED_EJSON_DEFINITIONS: {
ObjectId: {
type: string;
properties: {
$oid: {
type: string;
pattern: string;
};
};
required: string[];
additionalProperties: boolean;
};
BSONSymbol: {
type: string;
properties: {
$symbol: {
type: string;
};
};
required: string[];
additionalProperties: boolean;
};
Double: {
oneOf: ({
type: string;
properties?: undefined;
} | {
type: string;
properties: {
$numberDouble: {
enum: string[];
};
};
})[];
};
Decimal128: {
type: string;
properties: {
$numberDecimal: {
type: string;
};
};
required: string[];
additionalProperties: boolean;
};
Binary: {
type: string;
properties: {
$binary: {
type: string;
properties: {
base64: {
type: string;
};
subType: {
type: string;
pattern: string;
};
};
required: string[];
additionalProperties: boolean;
};
};
required: string[];
additionalProperties: boolean;
};
Code: {
type: string;
properties: {
$code: {
type: string;
};
};
required: string[];
additionalProperties: boolean;
};
CodeWScope: {
type: string;
properties: {
$code: {
type: string;
};
$scope: {
type: string;
};
};
required: string[];
additionalProperties: boolean;
};
Timestamp: {
type: string;
properties: {
$timestamp: {
type: string;
properties: {
t: {
type: string;
minimum: number;
};
i: {
type: string;
minimum: number;
};
};
required: string[];
additionalProperties: boolean;
};
};
required: string[];
additionalProperties: boolean;
};
RegExp: {
type: string;
properties: {
$regularExpression: {
type: string;
properties: {
pattern: {
type: string;
};
options: {
type: string;
pattern: string;
};
};
required: string[];
additionalProperties: boolean;
};
};
required: string[];
additionalProperties: boolean;
};
DBPointer: {
type: string;
properties: {
$dbPointer: {
type: string;
properties: {
$ref: {
type: string;
};
$id: {
$ref: string;
};
};
required: string[];
additionalProperties: boolean;
};
};
required: string[];
additionalProperties: boolean;
};
Date: {
type: string;
properties: {
$date: {
type: string;
format: string;
};
};
required: string[];
additionalProperties: boolean;
};
DBRef: {
type: string;
properties: {
$ref: {
type: string;
};
$id: {};
$db: {
type: string;
};
};
required: string[];
additionalProperties: boolean;
};
MinKey: {
type: string;
properties: {
$minKey: {
type: string;
const: number;
};
};
required: string[];
additionalProperties: boolean;
};
MaxKey: {
type: string;
properties: {
$maxKey: {
type: string;
const: number;
};
};
required: string[];
additionalProperties: boolean;
};
Undefined: {
type: string;
properties: {
$undefined: {
type: string;
const: boolean;
};
};
required: string[];
additionalProperties: boolean;
};
};
export declare function convertInternalToStandard(internalSchema: InternalSchema, options?: {
signal?: AbortSignal;
}): Promise<StandardJSONSchema>;
export {};