import {
  getDynamoControlService
} from "./chunk-EUIP2U5F.mjs";

// src/data/operations/control/role/role-create-operation.ts
import { extractSummary } from "@openhi/types";
async function createRoleOperation(params) {
  const { context, body, tableName } = params;
  const service = getDynamoControlService(tableName);
  const id = body.id ?? `role-${Date.now()}`;
  const parsedResource = typeof body.resource === "string" ? JSON.parse(body.resource) : body.resource ?? {};
  const lastUpdated = context.date ?? (/* @__PURE__ */ new Date()).toISOString();
  const vid = `1`;
  const resource = { resourceType: "Role", id, ...parsedResource };
  const summary = JSON.stringify(extractSummary(resource));
  await service.entities.role.put({
    id,
    resource: JSON.stringify(resource),
    summary,
    vid,
    lastUpdated
  }).go();
  return {
    id,
    resource,
    meta: { lastUpdated, versionId: vid }
  };
}

export {
  createRoleOperation
};
//# sourceMappingURL=chunk-SD7J3N3C.mjs.map