# Module @saltcorn/data

This is saltcorn data

# @saltcorn/data

Data models for saltcorn

If you are a saltcorn user, you probably want to install this package instead: @saltcorn/cli

- Defined in saltcorn-data/index.ts:1

#####
Index

### Namespaces

models
plugin_helper
utils

### Properties

state
web_mobile_commons

### Variables

db
migrations

## Properties

### state

state: {
add_tenant: ((t) => void);
features: {
aggregation_query: boolean;
async_validate: boolean;
bootstrap5: boolean;
capacitor: boolean;
deep_public_plugin_serve: boolean;
dynamic_auth_parameters: boolean;
ellipsize: boolean;
esm_plugins: boolean;
fieldrepeats_in_field_attributes: boolean;
get_view_goto: boolean;
json_state_query: boolean;
list_builder: boolean;
no_plugin_fieldview_length_check: boolean;
prefix_or_in_queries: boolean;
public_user_role: number;
serve_static_dependencies: boolean;
stringify_json_fields: boolean;
table_undo: boolean;
version_plugin_serve_path: boolean;
workflows: boolean;
};
getAllTenants: (() => Record<string, State>);
getApp__: (() => ((s) => string));
getReq__: (() => ((s) => string));
getRootState: (() => State);
getState: (() => undefined | State);
getTenant: ((ten) => State);
get_other_domain_tenant: ((hostname) => string);
get_process_init_time: (() => Date);
init_multi_tenant: ((plugin_loader, disableMigrate, tenantList) => Promise<void>);
process_send: ((v) => void);
restart_tenant: ((plugin_loader) => Promise<void>);
set_tenant_base_url: ((tenant_subdomain, value?) => void);
}

#### Type declaration

- ##### add_tenant: ((t) => void)

  - - (t): void

    - Add tenant to State

      #### Parameters

      - ##### t: string

      #### Returns void

- ##### features: {
  aggregation_query: boolean;
  async_validate: boolean;
  bootstrap5: boolean;
  capacitor: boolean;
  deep_public_plugin_serve: boolean;
  dynamic_auth_parameters: boolean;
  ellipsize: boolean;
  esm_plugins: boolean;
  fieldrepeats_in_field_attributes: boolean;
  get_view_goto: boolean;
  json_state_query: boolean;
  list_builder: boolean;
  no_plugin_fieldview_length_check: boolean;
  prefix_or_in_queries: boolean;
  public_user_role: number;
  serve_static_dependencies: boolean;
  stringify_json_fields: boolean;
  table_undo: boolean;
  version_plugin_serve_path: boolean;
  workflows: boolean;
  }

  - ##### aggregation_query: boolean

  - ##### async_validate: boolean

  - ##### bootstrap5: boolean

  - ##### capacitor: boolean

  - ##### deep_public_plugin_serve: boolean

  - ##### dynamic_auth_parameters: boolean

  - ##### ellipsize: boolean

  - ##### esm_plugins: boolean

  - ##### fieldrepeats_in_field_attributes: boolean

  - ##### get_view_goto: boolean

  - ##### json_state_query: boolean

  - ##### list_builder: boolean

  - ##### no_plugin_fieldview_length_check: boolean

  - ##### prefix_or_in_queries: boolean

  - ##### public_user_role: number

  - ##### serve_static_dependencies: boolean

  - ##### stringify_json_fields: boolean

  - ##### table_undo: boolean

  - ##### version_plugin_serve_path: boolean

  - ##### workflows: boolean

- ##### getAllTenants: (() => Record<string, State>)

  - - (): Record<string, State>

    - Returns all Tenants (from State)

      #### Returns Record<string, State>

- ##### getApp__: (() => ((s) => string))

  - - (): ((s) => string)

    - #### Returns ((s) => string)

      - - (s): string

        - #### Parameters

          - ##### s: string

          #### Returns string

- ##### getReq__: (() => ((s) => string))

  - - (): ((s) => string)

    - #### Returns ((s) => string)

      - - (s): string

        - #### Parameters

          - ##### s: string

          #### Returns string

- ##### getRootState: (() => State)

  - - (): State

    - #### Returns State

- ##### getState: (() => undefined | State)

  - - (): undefined | State

    - Get the state in the current tenant

      #### Returns undefined | State

      #### Function

- ##### getTenant: ((ten) => State)

  - - (ten): State

    - Get tenant from State

      #### Parameters

      - ##### ten: string

      #### Returns State

- ##### get_other_domain_tenant: ((hostname) => string)

  - - (hostname): string

    - Get tenant that has another domain (not subdomain)

      #### Parameters

      - ##### hostname: string

      #### Returns string

- ##### get_process_init_time: (() => Date)

  - - (): Date

    - Get Process Init Time - moment when Saltcorn process was initiated

      #### Returns Date

- ##### init_multi_tenant: ((plugin_loader, disableMigrate, tenantList) => Promise<void>)

  - - (plugin_loader, disableMigrate, tenantList): Promise<void>

    - Switch to multi_tenant

      #### Parameters

      - ##### plugin_loader: ((s) => Promise<void>)

        - - (s): Promise<void>

          - #### Parameters

            - ##### s: string

            #### Returns Promise<void>

      - ##### disableMigrate: boolean

        if true then dont migrate db

      - ##### tenantList: string[]

      #### Returns Promise<void>

- ##### process_send: ((v) => void)

  - - (v): void

    - #### Parameters

      - ##### v: any

      #### Returns void

- ##### restart_tenant: ((plugin_loader) => Promise<void>)

  - - (plugin_loader): Promise<void>

    - Restart tenant (means reload of plugins)

      #### Parameters

      - ##### plugin_loader: Function

      #### Returns Promise<void>

- ##### set_tenant_base_url: ((tenant_subdomain, value?) => void)

  - - (tenant_subdomain, value?): void

    - Set tenant base url??? From my point of view it just add tenant to list of otherdomaintenant

      #### Parameters

      - ##### tenant_subdomain: string

      - ##### `Optional` value: string

        new

      #### Returns void

- Defined in saltcorn-data/db/state.ts:1339

### web_mobile_commons

web_mobile_commons: {
getWorkflowStepUserForm: ((run, trigger, step, req) => Promise<Form>);
get_extra_menu: ((role, __, user?, locale?) => any);
prepare_insert_row: ((row, fields) => Promise<any>);
prepare_update_row: ((table, row, id) => Promise<string[]>);
show_calculated_fieldview: ((req, res, param2) => Promise<any>);
}

#### Type declaration

- ##### getWorkflowStepUserForm: ((run, trigger, step, req) => Promise<Form>)

  - - (run, trigger, step, req): Promise<Form>

    - prepare a form for a workflow step

      #### Parameters

      - ##### run: WorkflowRun

      - ##### trigger: Trigger

      - ##### step: WorkflowStep

      - ##### req: any

      #### Returns Promise<Form>

- ##### get_extra_menu: ((role, __, user?, locale?) => any)

  - - (role, __, user?, locale?): any

    - Get extra menu

      #### Parameters

      - ##### role: number

      - ##### __: ((str) => string)

        translation function

        - - (str): string

          - #### Parameters

            - ##### str: string

            #### Returns string

      - ##### `Optional` user: User

      - ##### `Optional` locale: string

      #### Returns any

      array of extra menu items

- ##### prepare_insert_row: ((row, fields) => Promise<any>)

  - - (row, fields): Promise<any>

    - take a row from a form, and prepare it for a db insert needed for tabulator

      #### Parameters

      - ##### row: any

      - ##### fields: Field[]

      #### Returns Promise<any>

- ##### prepare_update_row: ((table, row, id) => Promise<string[]>)

  - - (table, row, id): Promise<string[]>

    - take a row from a form, and prepare it for a db update needed for tabulator

      #### Parameters

      - ##### table: Table

      - ##### row: any

        output parameter

      - ##### id: number

      #### Returns Promise<string[]>

- ##### show_calculated_fieldview: ((req, res, param2) => Promise<any>)

  - - (req, res, param2): Promise<any>

    - #### Parameters

      - ##### req: any

        express or mocked mobile requese

      - ##### res: any

        express or mocked mobile response

      - ##### param2: {
        fieldName: string;
        fieldview: string;
        tableName: string;
        }

        table field and fieldview

        - ##### fieldName: string

        - ##### fieldview: string

        - ##### tableName: string

      #### Returns Promise<any>

      void and writes to res

- Defined in saltcorn-data/web-mobile-commons.ts:438

Generated using TypeDoc