docorm
Version:
Persistence layer with ORM features for JSON documents
58 lines • 3.03 kB
TypeScript
export type JSONSchema = object;
export type EntitySchema = JSONSchema;
export type ConcreteEntitySchema = EntitySchema;
export type SchemaPath = string | string[];
export type SchemaType = 'model' | 'view-model';
export interface SchemaDirectory {
namespace?: string;
schemaType: SchemaType;
path: string;
schemas: object;
}
/**
*
* @param path - The directory path containing schemas.
* @param schemaType - The schema type
* @param namespace
*/
export declare function registerSchemaDirectory(path: string, schemaType: SchemaType, namespace?: string | undefined): Promise<void>;
export declare function getSchema(path: SchemaPath, schemaType: SchemaType, namespace?: string | undefined): EntitySchema | null;
export interface MakeSchemaConcreteState {
knownConcreteSubschemas: {
[path: string]: EntitySchema;
};
cachedSchemaKeyToStore?: string;
}
export declare function makeSchemaConcrete(schema: EntitySchema, schemaType?: SchemaType, namespace?: string | undefined, state?: MakeSchemaConcreteState): object;
export type RelationshipStorage = 'copy' | 'ref' | 'inverse-ref';
export interface Relationship {
path: string;
toMany: boolean;
storage: RelationshipStorage;
entityTypeName: string;
schema: ConcreteEntitySchema;
foreignKeyPath?: string;
depthFromParent: number;
}
export declare function findPropertyInSchema(schema: ConcreteEntitySchema, path: string | string[]): ConcreteEntitySchema | null;
export declare function findRelationships(schema: ConcreteEntitySchema, allowedStorage?: RelationshipStorage[], maxDepth?: number | undefined, currentPath?: string, nodesTraversedInPath?: ConcreteEntitySchema[], depthFromParent?: number): Relationship[];
/**
* Find all related item definitions along one path in a concrete schema.
*/
export declare function findRelationshipsAlongPath(schema: ConcreteEntitySchema, path: string | string[], allowedStorage?: RelationshipStorage[], currentPath?: string[]): Relationship[];
/**
* List all the transient properties of a concrete schema. Do not traverse relationships stored by reference.
*
* Transient properties are identified by the custom JSON schema attribute "custom".
*
* Because the schema must be concrete, it does not contain incorporate the contents of any other schemas; but it may
* define entity-relationship properties that refer to other schemas. TODO Is this true? Clarify this point.
*
* @param {*} schema A concrete JSON schema (one that does not contain any references to other schemas).
* @param {propertyPathElement[]} [currentPath=[]] - A path to a subschema to catalogue, used when this function calls
* itself recursively. The default value is an empty path, indicating that the whole schema shoulc be catalogued from
* its root down.
* @return {string[]} A list of transient property paths in dot notation.
*/
export declare function listTransientPropertiesOfSchema(schema: ConcreteEntitySchema, currentPath?: string[]): string[];
//# sourceMappingURL=schemas.d.ts.map