# Variable mocks

mocks: {
configuration_workflow: () => Workflow;
createDefaultView: (
table: Table,
viewtemplate: string,
min_role: number,
) => Promise<View>;
getActionCounter: () => number;
mockReqRes: {
getStored: () => any;
req: {
__: (s: any) => any;
body: string;
csrfToken: () => string;
flash: (...fs: any) => void;
get: (s: string) => string;
getLocale: () => any;
headers: {};
isAuthenticated: () => boolean;
query: {};
user: { attributes: {}; id: number; role_id: number };
xhr: boolean;
};
res: {
__: (s: any) => any;
sendWrap: (...sw: any[]) => void;
json(o: any): void;
redirect(url: string): void;
send(s: any): void;
status(st: any): void;
};
reset: () => void;
};
plugin_with_routes: () => {
actions: {
evalCounter: {
configFields: { name: string; type: string }[];
run: (
__namedParameters: {
configuration: { number_expr: string };
row: any;
user: any;
},
) => void;
};
incrementCounter: { run: () => void };
setCounter: {
configFields: { name: string; type: string }[];
run: (__namedParameters: { configuration: { number: number } }) => void;
};
};
external_tables: { exttab: any };
functions: {
add3: { run: (x: number) => number };
add5: (x: number) => number;
asyncAdd2: { isAsync: boolean; run: (x: number) => Promise<number> };
};
onLoad: () => Promise<void>;
sc_plugin_api_version: number;
table_providers: {
provtab: {
configuration_workflow: () => Workflow;
fields: (
cfg: any,
) => Promise<
(
| {
label: string;
name: string;
primary_key: boolean;
type: string;
}
| {
label: string;
name: string;
primary_key?: undefined;
type: string;
}
)[],
>;
get_table(
cfg: any,
): { getRows: () => Promise<{ age: number; name: any }[]> };
};
};
types: (
| {
attributes: never[];
fieldviews: {
edit: {
isEdit: boolean;
run: (nm: string, v: any, attrs: any, cls: string) => string;
};
editHTML?: undefined;
show: { isEdit: boolean; run: (v: any) => string };
};
name: string;
primaryKey?: undefined;
read: (v: any) => any;
sql_name: string;
validate_attributes?: undefined;
}
| {
attributes: {
attributes: { max: number; min: number };
label: string;
name: string;
required: boolean;
type: string;
}[];
fieldviews: {
edit?: undefined;
editHTML: {
isEdit: boolean;
run: (
nm: string,
v: any,
attrs: any,
cls: string,
required: boolean,
field: Field,
) => string;
};
show: { isEdit: boolean; run: (v: any) => any };
};
name: string;
primaryKey?: undefined;
read: (s: any) => any;
sql_name: (__namedParameters: any) => string;
validate_attributes: (__namedParameters: any) => boolean;
}
| {
attributes?: undefined;
fieldviews: {
edit?: undefined;
editHTML: {
isEdit: boolean;
run: (
nm: string,
v: any,
attrs: any,
cls: string,
required: boolean,
field: Field,
) => string;
};
show: { isEdit: boolean; run: (v: any) => any };
};
name: string;
primaryKey: { default_sql: string };
read: (v: any) => string | null | undefined;
sql_name: string;
validate_attributes?: undefined;
}
)[];
viewtemplates: (
| {
configuration_workflow: () => Workflow;
name: string;
routes: {
the_html_route: () => Promise<{ html: string }>;
the_json_route: () => Promise<{ json: { success: ... } }>;
the_null_route: () => null;
};
run: () => Promise<void>;
tableless?: undefined;
get_state_fields(): never[];
}
| {
configuration_workflow: () => Workflow;
name: string;
routes?: undefined;
run: () => Promise<void>;
tableless: boolean;
get_state_fields(): never[];
}
)[];
};
resetActionCounter: () => void;
rick_file: () => Promise<File>;
sleep: any;
}

#### Type Declaration

- ##### configuration_workflow: () => Workflow

- ##### createDefaultView: (table: Table, viewtemplate: string, min_role: number) => Promise<View>

- ##### getActionCounter: () => number

- ##### mockReqRes: {
  getStored: () => any;
  req: {
  __: (s: any) => any;
  body: string;
  csrfToken: () => string;
  flash: (...fs: any) => void;
  get: (s: string) => string;
  getLocale: () => any;
  headers: {};
  isAuthenticated: () => boolean;
  query: {};
  user: { attributes: {}; id: number; role_id: number };
  xhr: boolean;
  };
  res: {
  __: (s: any) => any;
  sendWrap: (...sw: any[]) => void;
  json(o: any): void;
  redirect(url: string): void;
  send(s: any): void;
  status(st: any): void;
  };
  reset: () => void;
  }

- ##### plugin_with_routes: () => {
  actions: {
  evalCounter: {
  configFields: { name: string; type: string }[];
  run: (
  __namedParameters: {
  configuration: { number_expr: string };
  row: any;
  user: any;
  },
  ) => void;
  };
  incrementCounter: { run: () => void };
  setCounter: {
  configFields: { name: string; type: string }[];
  run: (__namedParameters: { configuration: { number: number } }) => void;
  };
  };
  external_tables: { exttab: any };
  functions: {
  add3: { run: (x: number) => number };
  add5: (x: number) => number;
  asyncAdd2: { isAsync: boolean; run: (x: number) => Promise<number> };
  };
  onLoad: () => Promise<void>;
  sc_plugin_api_version: number;
  table_providers: {
  provtab: {
  configuration_workflow: () => Workflow;
  fields: (
  cfg: any,
  ) => Promise<
  (
  | {
  label: string;
  name: string;
  primary_key: boolean;
  type: string;
  }
  | {
  label: string;
  name: string;
  primary_key?: undefined;
  type: string;
  }
  )[],
  >;
  get_table(
  cfg: any,
  ): { getRows: () => Promise<{ age: number; name: any }[]> };
  };
  };
  types: (
  | {
  attributes: never[];
  fieldviews: {
  edit: {
  isEdit: boolean;
  run: (nm: string, v: any, attrs: any, cls: string) => string;
  };
  editHTML?: undefined;
  show: { isEdit: boolean; run: (v: any) => string };
  };
  name: string;
  primaryKey?: undefined;
  read: (v: any) => any;
  sql_name: string;
  validate_attributes?: undefined;
  }
  | {
  attributes: {
  attributes: { max: number; min: number };
  label: string;
  name: string;
  required: boolean;
  type: string;
  }[];
  fieldviews: {
  edit?: undefined;
  editHTML: {
  isEdit: boolean;
  run: (
  nm: string,
  v: any,
  attrs: any,
  cls: string,
  required: boolean,
  field: Field,
  ) => string;
  };
  show: { isEdit: boolean; run: (v: any) => any };
  };
  name: string;
  primaryKey?: undefined;
  read: (s: any) => any;
  sql_name: (__namedParameters: any) => string;
  validate_attributes: (__namedParameters: any) => boolean;
  }
  | {
  attributes?: undefined;
  fieldviews: {
  edit?: undefined;
  editHTML: {
  isEdit: boolean;
  run: (
  nm: string,
  v: any,
  attrs: any,
  cls: string,
  required: boolean,
  field: Field,
  ) => string;
  };
  show: { isEdit: boolean; run: (v: any) => any };
  };
  name: string;
  primaryKey: { default_sql: string };
  read: (v: any) => string | null | undefined;
  sql_name: string;
  validate_attributes?: undefined;
  }
  )[];
  viewtemplates: (
  | {
  configuration_workflow: () => Workflow;
  name: string;
  routes: {
  the_html_route: () => Promise<{ html: string }>;
  the_json_route: () => Promise<{ json: { success: ... } }>;
  the_null_route: () => null;
  };
  run: () => Promise<void>;
  tableless?: undefined;
  get_state_fields(): never[];
  }
  | {
  configuration_workflow: () => Workflow;
  name: string;
  routes?: undefined;
  run: () => Promise<void>;
  tableless: boolean;
  get_state_fields(): never[];
  }
  )[];
  }

- ##### resetActionCounter: () => void

- ##### rick_file: () => Promise<File>

- ##### sleep: any

- Defined in packages/saltcorn-data/tests/mocks.ts:372