@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
61 lines (60 loc) • 2.17 kB
text/typescript
import { Metadata } from "./Metadata.mjs";
//#region src/storage/BaseRecord.d.ts
type TagValue = string | boolean | undefined | Array<string> | null;
type TagsBase = {
[key: string]: TagValue;
[key: number]: never;
};
type Tags<DefaultTags extends TagsBase, CustomTags extends TagsBase> = CustomTags & DefaultTags;
type RecordTags<Record extends BaseRecord> = ReturnType<Record['getTags']>;
type BaseRecordAny = BaseRecord<any, any, any>;
declare abstract class BaseRecord<DefaultTags extends TagsBase = TagsBase, CustomTags extends TagsBase = TagsBase, MetadataValues = {}> {
protected _tags: CustomTags & TagsBase;
id: string;
createdAt: Date;
updatedAt?: Date;
readonly type: string;
static readonly type: string;
readonly allowCache: boolean;
static readonly allowCache: boolean;
/** @inheritdoc {Metadata#Metadata} */
metadata: Metadata<MetadataValues>;
/**
* Get all tags. This is includes custom and default tags
* @returns tags object
*/
abstract getTags(): Tags<DefaultTags, CustomTags>;
/**
* Set the value for a tag
* @param name name of the tag
* @param value value of the tag
*/
setTag(name: keyof CustomTags | (string & {}), value: CustomTags[keyof CustomTags]): void;
/**
* Get the value for a tag
* @param name name of the tag
* @returns The tag value, or undefined if not found
*/
getTag(name: keyof CustomTags | keyof DefaultTags | (string & {})): Tags<DefaultTags, CustomTags>[keyof CustomTags | keyof DefaultTags | (string & {})];
/**
* Set custom tags. This will merge the tags object with passed in tag properties
*
* @param tags the tags to set
*/
setTags(tags: Partial<CustomTags | TagsBase>): void;
/**
* Replace tags. This will replace the whole tags object.
* Default tags will still be overridden when retrieving tags
*
* @param tags the tags to set
*/
replaceTags(tags: CustomTags & Partial<TagsBase>): void;
toJSON(): Record<string, unknown>;
/**
* Clones the record.
*/
clone(): this;
}
//#endregion
export { BaseRecord, BaseRecordAny, RecordTags, TagValue, Tags, TagsBase };
//# sourceMappingURL=BaseRecord.d.mts.map