@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
85 lines (84 loc) • 3.26 kB
TypeScript
/**
* @module Collection
*/
import type { IFlexibleSerde, ISerializable } from "../../serde/contracts/_module-exports.js";
import { type ISerializedError, type OneOrMore } from "../../utilities/_module-exports.js";
/**
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare class CollectionError extends Error implements ISerializable<ISerializedError> {
static deserialize(deserializedValue: ISerializedError): CollectionError;
constructor(message: string, cause?: unknown);
serialize(): ISerializedError;
}
/**
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare class UnexpectedCollectionError extends CollectionError {
static deserialize(deserializedValue: ISerializedError): CollectionError;
constructor(message: string, cause?: unknown);
}
/**
* The error is thrown when the item is not found.
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare class ItemNotFoundCollectionError extends CollectionError {
static deserialize(deserializedValue: ISerializedError): CollectionError;
constructor(message: string, cause?: unknown);
}
/**
* The error is thrown when multiple items are found.
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare class MultipleItemsFoundCollectionError extends CollectionError {
static deserialize(deserializedValue: ISerializedError): CollectionError;
constructor(message: string, cause?: unknown);
}
/**
* The error is thrown when calling a method that needs all items to be of a specific type. For example, the `sum` method requires all items to be numbers.
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare class TypeCollectionError extends CollectionError {
static deserialize(deserializedValue: ISerializedError): CollectionError;
constructor(message: string, cause?: unknown);
}
/**
* The error is thrown when calling a method that needs the collection not to be empty. For example, the `average` method requires the collection not to be empty.
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare class EmptyCollectionError extends CollectionError {
static deserialize(deserializedValue: ISerializedError): CollectionError;
constructor(message: string, cause?: unknown);
}
/**
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare const COLLECTION_ERRORS: {
readonly Base: typeof CollectionError;
readonly Unexpected: typeof UnexpectedCollectionError;
readonly ItemNotFound: typeof ItemNotFoundCollectionError;
readonly MultipleItemsFound: typeof MultipleItemsFoundCollectionError;
readonly Type: typeof TypeCollectionError;
readonly Empty: typeof EmptyCollectionError;
};
/**
* The `registerCollectionErrorsToSerde` function registers all `ICollection` related errors with `IFlexibleSerde`, ensuring they will properly be serialized and deserialized.
*
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
* @group Errors
*/
export declare function registerCollectionErrorsToSerde(serde: OneOrMore<IFlexibleSerde>): void;