@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
71 lines (70 loc) • 2.36 kB
JavaScript
import { JsonTransformer } from "../utils/JsonTransformer.mjs";
import { Metadata } from "./Metadata.mjs";
import { DateTransformer, MetadataTransformer } from "../utils/transformers.mjs";
import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.mjs";
import __decorate from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.mjs";
import { Exclude } from "class-transformer";
//#region src/storage/BaseRecord.ts
var BaseRecord = class BaseRecord {
constructor() {
this._tags = {};
this.type = BaseRecord.type;
this.allowCache = BaseRecord.allowCache;
this.metadata = new Metadata({});
}
/**
* Set the value for a tag
* @param name name of the tag
* @param value value of the tag
*/
setTag(name, value) {
this._tags[name] = value;
}
/**
* Get the value for a tag
* @param name name of the tag
* @returns The tag value, or undefined if not found
*/
getTag(name) {
return this.getTags()[name];
}
/**
* Set custom tags. This will merge the tags object with passed in tag properties
*
* @param tags the tags to set
*/
setTags(tags) {
this._tags = {
...this._tags,
...tags
};
}
/**
* 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) {
this._tags = tags;
}
toJSON() {
return JsonTransformer.toJSON(this);
}
/**
* Clones the record.
*/
clone() {
return JsonTransformer.clone(this);
}
};
BaseRecord.type = "BaseRecord";
BaseRecord.allowCache = false;
__decorate([DateTransformer(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)], BaseRecord.prototype, "createdAt", void 0);
__decorate([DateTransformer(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)], BaseRecord.prototype, "updatedAt", void 0);
__decorate([Exclude(), __decorateMetadata("design:type", Object)], BaseRecord.prototype, "type", void 0);
__decorate([Exclude(), __decorateMetadata("design:type", Object)], BaseRecord.prototype, "allowCache", void 0);
__decorate([MetadataTransformer(), __decorateMetadata("design:type", typeof Metadata === "undefined" ? Object : Metadata)], BaseRecord.prototype, "metadata", void 0);
//#endregion
export { BaseRecord };
//# sourceMappingURL=BaseRecord.mjs.map