message: actionscripts add ref
diff: @@ -54,21 +54,15 @@ export const actionScript = functions.https.onCall(
  message: "no schema found",
  };
  }
  - const {
  - script,
  - requiredRoles,
  - requiredFields,
  - undo,
  - redo,
  - } = schemaDocData.columns[column.key].config;
  + const config = schemaDocData.columns[column.key].config;
  + const { script, requiredRoles, requiredFields, undo, redo } = config;
  if (!hasAnyRole(requiredRoles, context)) {
  throw Error(`You don't have the required roles permissions`);
  }
  - const missingRequiredFields = requiredFields.reduce(
  - missingFieldsReducer(row),
  - []
  - );
  + const missingRequiredFields = requiredFields
  + ? requiredFields.reduce(missingFieldsReducer(row), [])
  + : [];
  if (missingRequiredFields.length > 0) {
  throw new Error(
  `Missing required fields:${missingRequiredFields.join(", ")}`
  @@ -78,6 +72,8 @@ export const actionScript = functions.https.onCall(
  // get auth
  console.log(
  JSON.stringify({
  + undo,
  + redo,
  row,
  ref,
  column,
  @@ -93,27 +89,23 @@ export const actionScript = functions.https.onCall(
  status: string;
  success: boolean;
  } = await eval(
  - `async({db, auth, utilFns})=>{${
  - action === "undo" ? undo.script : script
  + `async({row,db, ref,auth, utilFns})=>{${
  + action === "undo" ? config["undo.script"] : script
  }}`
  - )({
  - db,
  - auth,
  - utilFns,
  - });
  + )({ row, db, auth, utilFns, ref });
  if (result.success)
  return {
  success: result.success,
  message: result.message,
  cellValue: {
  - redo: redo.enabled,
  + redo: config["redo.enabled"],
  status: result.status,
  completedAt: serverTimestamp(),
  meta: { ranBy: context.auth!.token.email },
  - undo: undo.enabled,
  + undo: action !== "undo" && config["undo.enabled"],
  },
  - undo: undo.enabled,
  - redo: redo.enabled,
  + undo: config["undo.enabled"],
  + redo: config["redo.enabled"],
  };
  else
  return {
  