@nerdware/ddb-single-table
Version:
A schema-based DynamoDB modeling tool, high-level API, and type-generator built to supercharge single-table designs!⚡
27 lines • 1.67 kB
TypeScript
import type { TableKeysSchemaType, ModelSchemaType, SchemaMetadata } from "./types/index.js";
/**
* The base class for `TableKeysSchema` and `ModelSchema`. This class and its subclasses currently
* only serve to organize schema-related types, validation methods, etc., but may be used to create
* schema instances in the future. This is currently not the case, as schema attributes would need
* to be nested under an instance property (e.g. `this.attributes`), which would require a lot of
* refactoring. If/when this is implemented, schema instances would also be given "metadata" props
* like "name", "version", "format", "schemaType", etc.
*/
export declare class BaseSchema {
/**
* This method ensures the provided `schema` is a valid `Schema` object by performing the
* following validation checks:
*
* 1. Ensure the provided `schema` is a non-empty enumerable object.
* 2. Ensure a valid "type" is specified for all attributes.
* 3. Ensure "map", "array", and "tuple" attributes include a valid "schema" config.
* 4. Ensure "enum" attributes include a valid "oneOf" config.
* 5. Ensure "default" values comply with "type".
*
* @param schema - The schema to validate.
* @param schemaType - The type of schema being validated ("TableKeysSchema" or "ModelSchema").
* @param name - A name to identify the schema in any error messages (defaults to "schemaType" if not provided).
*/
static readonly validateAttributeTypes: <const S extends TableKeysSchemaType | ModelSchemaType>(schema: S, { schemaType, name: schemaName }: SchemaMetadata) => void;
}
//# sourceMappingURL=BaseSchema.d.ts.map