import { recordProxy } from "../../../shared/src/record-proxy.js";
const CRUD_KINDS = ["insert", "upsert", "update", "delete"];
function makeCRUDMutate(schema, addSchemaCRUD, executor) {
  const mutate = (request) => {
    const { table, kind, args } = request;
    return executor(table, kind, args);
  };
  {
    for (const tableName of Object.keys(schema.tables)) {
      mutate[tableName] = void 0;
    }
    return recordProxy(
      mutate,
      (_value, tableName) => makeTableCRUD(tableName, executor)
    );
  }
}
function makeTransactionMutate(schema, executor) {
  const target = {};
  for (const tableName of Object.keys(schema.tables)) {
    target[tableName] = void 0;
  }
  return recordProxy(
    target,
    (_value, tableName) => makeTableCRUD(tableName, executor)
  );
}
function makeTableCRUD(tableName, executor) {
  return Object.fromEntries(
    CRUD_KINDS.map((kind) => [
      kind,
      (value) => executor(tableName, kind, value)
    ])
  );
}
export {
  CRUD_KINDS,
  makeCRUDMutate,
  makeTransactionMutate
};
//# sourceMappingURL=crud.js.map
