

import { CredoError } from "../../../error/CredoError.mjs";
import "../../../error/index.mjs";
import { injectable } from "../../../plugins/index.mjs";
import { __decorateMetadata } from "../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.mjs";
import { GenericRecord } from "../repository/GenericRecord.mjs";
import { GenericRecordsRepository } from "../repository/GenericRecordsRepository.mjs";

//#region src/modules/generic-records/services/GenericRecordService.ts
var _ref;
let GenericRecordService = class GenericRecordService$1 {
	constructor(genericRecordsRepository) {
		this.genericRecordsRepository = genericRecordsRepository;
	}
	async save(agentContext, { content, tags, id }) {
		const genericRecord = new GenericRecord({
			id,
			content,
			tags
		});
		try {
			await this.genericRecordsRepository.save(agentContext, genericRecord);
			return genericRecord;
		} catch (error) {
			throw new CredoError(`Unable to store the genericRecord record with id ${genericRecord.id}. Message: ${error}`);
		}
	}
	async delete(agentContext, record) {
		try {
			await this.genericRecordsRepository.delete(agentContext, record);
		} catch (error) {
			throw new CredoError(`Unable to delete the genericRecord record with id ${record.id}. Message: ${error}`);
		}
	}
	async deleteById(agentContext, id) {
		await this.genericRecordsRepository.deleteById(agentContext, id);
	}
	async update(agentContext, record) {
		try {
			await this.genericRecordsRepository.update(agentContext, record);
		} catch (error) {
			throw new CredoError(`Unable to update the genericRecord record with id ${record.id}. Message: ${error}`, { cause: error });
		}
	}
	async findAllByQuery(agentContext, query, queryOptions) {
		return this.genericRecordsRepository.findByQuery(agentContext, query, queryOptions);
	}
	async findById(agentContext, id) {
		return this.genericRecordsRepository.findById(agentContext, id);
	}
	async getAll(agentContext) {
		return this.genericRecordsRepository.getAll(agentContext);
	}
};
GenericRecordService = __decorate([injectable(), __decorateMetadata("design:paramtypes", [typeof (_ref = typeof GenericRecordsRepository !== "undefined" && GenericRecordsRepository) === "function" ? _ref : Object])], GenericRecordService);

//#endregion
export { GenericRecordService };
//# sourceMappingURL=GenericRecordService.mjs.map