import { VError , Options as VErrorOptions } from 'verror' ; import { ParseElement } from './conditions_types' ; /**
 * Thrown when insert() is called with a specified _id
 * that already exists
 */ export class ConflictException extends VError { constructor ( message , id ) { super ( { info : { id } , name : 'conflict.error' } , message ) ; } } /**
 * Thrown when an `_id` value is specified that is not
 * valid (_id values must be a string).
 */ export class InvalidIdException extends VError { constructor ( id ) { super ( { info : { id } , name : 'invalid_id.error' } , 'The provided document has an invalid ID' ) ; } } /**
 * Thrown when the child object to be inserted has a missing or invalid
 * parent key value.
 */ export class InvalidParentIdException extends VError { constructor ( parentId , collectionName , parentCollectionName ) { super ( { info : { parentId , collectionName , parentCollectionName , } , name : 'invalid_parent_id.error' , } , `The provided document has a missing parent ID or it is the incorrect type` ) ; } } /**
 * Thrown when the collection specified cannot be found in the context, or
 * isn't of the expected type (root or child) for the called API.
 */ export class CollectionNotFoundException extends VError { constructor ( collection ) { super ( { info : { collection } , name : 'collection_not_found.error' } , `Collection not found: '${ collection }'` ) ; } } /**
 * Thrown when the index is not found for the provided query.
 */ export class IndexNotFoundException extends VError { constructor ( index ) { super ( { info : { index } , name : 'index_not_found.error' } , `Index not found: ${ index }` ) ; } } /**
 * Thrown during context construction to indicate a configuration
 * issue in the specified collections, access patterns or layouts.
 */ export class ConfigurationException extends VError { constructor ( message , options = { } ) { super ( { ... options , name : 'configuration.error' , } , message ) ; } } /**
 * Thrown on invalid field values that are provided during
 * persistence (insert/update/replace).
 */ export class InvalidIndexedFieldValueException extends VError { constructor ( message , { collection , keyPath } ) { super ( { info : { collection , keyPath , } , name : 'invalid_indexed_field_value.error' , } , message ) ; } } /**
 * Thrown on an invalidly specified query provided to a
 * `find()` operation.
 */ export class InvalidQueryException extends VError { constructor ( message , { collection , query } ) { super ( { info : { collection , query , } , name : 'invalid_query.error' , } , message ) ; } } /**
 * Thrown when the updates provided to an `update()` operation
 * are invalid.
 */ export class InvalidUpdatesException extends VError { constructor ( message ) { super ( { name : 'invalid_updates.error' , } , message ) ; } } /**
 * Thrown when the update values provided in an `update()` operation
 * are invalid (e.g. `undefined`)
 */ export class InvalidUpdateValueException extends VError { constructor ( path , message ) { super ( { name : 'invalid_update_value' , info : { path , } , } , message ) ; } } /**
 * Throw when the find descriptor for a transactFindByIds or
 * batchFindByIds is invalid.
 */ export class InvalidFindDescriptorException extends VError { constructor ( message ) { super ( { name : 'invalid_find_descriptor' , } , message ) ; } } /**
 * Thrown when something from DynamoDB doesn't match
 * the context configuration during response processing
 */ export class InternalProcessingException extends VError { constructor ( message ) { super ( { name : 'internal_processing' } , message ) ; } } internal const printParsePath = ( parsePath ) : string => { return parsePath . map ( ( e ) => { if ( e . type === 'array' ) return e . index === 0 ? `[` : `[...@${ e . index }:` ; return `{ ${ e . key }: ` ; } ) . join ( '' ) ; } ; /**
 * Thrown when there is a problem with the expression given
 * as a `FilterExpression` or `ConditionExpression`.
 */ export class InvalidCompositeConditionException extends VError { constructor ( message , parsePath ) { super ( { name : 'invalid_composite_condition' , info : { parsePath } , } , `Condition parse exception: ${ message } at ${ printParsePath ( parsePath ) }` ) ; } } /**
 * An exception thrown when a bad set of
 * [[BatchReplaceDeleteDescriptor]] is given to
 * [[batchReplaceDelete]]
 */ export class InvalidBatchReplaceDeleteDescriptorException extends VError { constructor ( message , info ? ) { super ( { name : 'invalid_batch_replace_descriptor' , info } , message ) ; } }