import {
  OWNING_DELETE_PROJECTION_ENTITY,
  deleteOwningChildChunkOperation
} from "./chunk-Q3MKITPY.mjs";
import "./chunk-QJDHVMKT.mjs";
import "./chunk-FYHBHHWK.mjs";
import "./chunk-EUIP2U5F.mjs";
import "./chunk-TRY7JGWO.mjs";
import "./chunk-KMEWULMX.mjs";
import "./chunk-LZOMFHX3.mjs";

// src/workflows/control-plane/owning-delete-cascade/delete-chunk.handler.ts
function isKnownEntity(value) {
  for (const known of Object.values(OWNING_DELETE_PROJECTION_ENTITY)) {
    if (known === value) {
      return true;
    }
  }
  return false;
}
var handler = async (input) => {
  const rows = input.rows.map((row) => {
    if (!isKnownEntity(row.entity)) {
      throw new Error(
        `owning-delete cascade delete-chunk: unknown projection entity '${row.entity}'`
      );
    }
    return {
      entity: row.entity,
      key: { ...row.key }
    };
  });
  const result = await deleteOwningChildChunkOperation({
    rows,
    token: input.chunkToken
  });
  return {
    ownerType: input.ownerType,
    ownerId: input.ownerId,
    tenantId: input.tenantId,
    rowsDeleted: result.rowsDeleted
  };
};
export {
  handler
};
//# sourceMappingURL=delete-chunk.handler.mjs.map