import { JSONSchema7 } from "json-schema"; /** * Defines the properties expected in the Fields object for a model */ export declare type Fields = Record; /** * Represents generated schema with models */ export interface GeneratedModelSchema { [model: string]: ModelJsonSchema; } export interface ModelSchemaProperties extends JSONSchema7 { /** * Index field, whether or not the * field should be indexed */ index?: boolean; /** * Primary key field flag if the field is * the primary key */ primary?: boolean; /** * Default value for the field */ default?: any; /** * Flag for if the field should be encrypted */ encrypted?: boolean; /** * GraphQL field name used for graphql query generation */ key?: string; } export declare class ModelJsonSchema { /** * Model name */ name: string; /** * Namespace for the field in storage * default is `user_` */ namespace?: string; /** * Model version number */ version?: number; /** * Array of indexed fields */ indexes?: string[]; /** * Array of encrypted fields */ encrypted?: string[]; /** * Primary key reference */ primaryKey?: string; /** * JsonSchema requirement * This is hardcoded to "object" */ type: "object"; /** * List of all the fields and their specific * options i.e * id: { * primary: true, * ... other options * } */ properties?: Fields; } /** * ModelSchema class used to convert * JsonSchema options into schema that * can be used in the DataStore Models * */ export declare class ModelSchema { private name; private namespace; private primaryKey; private fields; private encrypted; private version; private indexes; constructor(schema: ModelJsonSchema); /** * Getter method for name * */ getName(): string; /** * Getter method for namesapce * */ getNamespace(): string; /** * Computed method for store name * which is a combination of the * namespace and the model name * */ getStoreName(): string; /** * Get the model index fields * */ getIndexes(): string[]; /** * Get primary key name * */ getPrimaryKey(): string; /** * Get all the the model fields * */ getFields(): Fields; /** * Get the model version * */ getVersion(): number; /** * Get the encrypted fields * */ getEncryptedFields(): string[]; } /** * Simple factory method, this can be expanded upon to * add additional validation if required * * @param schema json schema object */ export declare function createModelSchema(schema: ModelJsonSchema): ModelSchema;