

import { InjectionSymbols } from "../../constants.mjs";
import { AgentContext } from "../../agent/context/AgentContext.mjs";
import { inject, injectable } from "../../plugins/index.mjs";
import { __decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.mjs";
import "../../agent/index.mjs";
import { __decorateParam } from "../../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateParam.mjs";
import { GenericRecordService } from "./services/GenericRecordService.mjs";

//#region src/modules/generic-records/GenericRecordsApi.ts
var _ref, _ref2;
let GenericRecordsApi = class GenericRecordsApi$1 {
	constructor(genericRecordsService, logger, agentContext) {
		this.genericRecordsService = genericRecordsService;
		this.logger = logger;
		this.agentContext = agentContext;
	}
	async save({ content, tags, id }) {
		try {
			return await this.genericRecordsService.save(this.agentContext, {
				id,
				content,
				tags
			});
		} catch (error) {
			this.logger.error("Error while saving generic-record", {
				error,
				content,
				errorMessage: error instanceof Error ? error.message : error
			});
			throw error;
		}
	}
	async delete(record) {
		try {
			await this.genericRecordsService.delete(this.agentContext, record);
		} catch (error) {
			this.logger.error("Error while saving generic-record", {
				error,
				content: record.content,
				errorMessage: error instanceof Error ? error.message : error
			});
			throw error;
		}
	}
	async deleteById(id) {
		await this.genericRecordsService.deleteById(this.agentContext, id);
	}
	async update(record) {
		try {
			await this.genericRecordsService.update(this.agentContext, record);
		} catch (error) {
			this.logger.error("Error while update generic-record", {
				error,
				content: record.content,
				errorMessage: error instanceof Error ? error.message : error
			});
			throw error;
		}
	}
	async findById(id) {
		return this.genericRecordsService.findById(this.agentContext, id);
	}
	async findAllByQuery(query, queryOptions) {
		return this.genericRecordsService.findAllByQuery(this.agentContext, query, queryOptions);
	}
	async getAll() {
		return this.genericRecordsService.getAll(this.agentContext);
	}
};
GenericRecordsApi = __decorate([
	injectable(),
	__decorateParam(1, inject(InjectionSymbols.Logger)),
	__decorateMetadata("design:paramtypes", [
		typeof (_ref = typeof GenericRecordService !== "undefined" && GenericRecordService) === "function" ? _ref : Object,
		Object,
		typeof (_ref2 = typeof AgentContext !== "undefined" && AgentContext) === "function" ? _ref2 : Object
	])
], GenericRecordsApi);

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