Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace formStoreService

Helper functions for handling Form Store Records

import { formStoreService } from '@oneblink/apps'

Index

Type aliases

FormStoreFilter<T>: { $elemMatch?: { $in?: string[] }; $eq?: T; $gt?: T; $gte?: T; $in?: string[]; $lt?: T; $lte?: T; $options?: string; $regex?: string }

Filter for a single property in a Form Store Record

Type parameters

  • T

Type declaration

  • Optional $elemMatch?: { $in?: string[] }
    • Optional $in?: string[]
  • Optional $eq?: T
  • Optional $gt?: T
  • Optional $gte?: T
  • Optional $in?: string[]
  • Optional $lt?: T
  • Optional $lte?: T
  • Optional $options?: string
  • Optional $regex?: string
FormStoreFilters: { dateTimeSubmitted?: FormStoreFilter<string>; externalId?: FormStoreFilter<string>; submission?: Record<string, FormStoreFilter<unknown> | undefined>; submissionId?: FormStoreFilter<string>; submittedBy?: FormStoreFilter<string> }

Filters available for filter Form Store Records

Type declaration

  • Optional dateTimeSubmitted?: FormStoreFilter<string>

    Filter results by the date/time they were submitted

  • Optional externalId?: FormStoreFilter<string>

    Filter results by the externalId

  • Optional submission?: Record<string, FormStoreFilter<unknown> | undefined>

    Filter results by the submission data

  • Optional submissionId?: FormStoreFilter<string>

    Filter results by the submissionId, must be a valid GUID

  • Optional submittedBy?: FormStoreFilter<string>

    Filter results by the user that submitted

FormStoreParameters: { filters?: FormStoreFilters; sorting?: { direction: "ascending" | "descending"; property: string }[]; unwindRepeatableSets?: boolean }

Type declaration

  • Optional filters?: FormStoreFilters

    Filters available for filter Form Store Records

  • Optional sorting?: { direction: "ascending" | "descending"; property: string }[]

    Sort the results by multiple properties

  • Optional unwindRepeatableSets?: boolean

    Unwind repeatable set entries to denormalise data, this makes data cleaner for tabular data purposes

Functions

  • exportFormStoreRecords(fileName: string, searchParameters: { formId: number; includeColumns?: string[] } & FormStoreParameters, abortSignal?: AbortSignal): Promise<void>
  • Export Form Store Records as a CSV file. This function will download the file automatically.

    Example

    await formStoreService.exportFormStoreRecords({
    formId: 1,
    })

    Parameters

    • fileName: string

      Name of the file to download. ".csv" will be added to the end of the file name if not passed

    • searchParameters: { formId: number; includeColumns?: string[] } & FormStoreParameters

      Search parameters for filtering, sorting, and including columns

    • Optional abortSignal: AbortSignal

      An AbortSignal to abort the request

    Returns Promise<void>

  • getFormStoreDefinition(formId: number, abortSignal?: AbortSignal): Promise<{ formElements: FormElementWithName[] }>
  • Get the available form elements for a form to display form store records

    Example

    const formId = 1
    const { formElements } =
    await formStoreService.getFormStoreDefinition(formId)

    Parameters

    • formId: number

      The identified of the form you want to get the definition of

    • Optional abortSignal: AbortSignal

      An AbortSignal to abort the request

    Returns Promise<{ formElements: FormElementWithName[] }>

  • searchFormStoreRecords(searchParameters: { formId: number; paging: { limit: number; offset: number } } & FormStoreParameters, abortSignal: AbortSignal): Promise<{ formStoreRecords: FormStoreRecord[]; meta: { limit: number; nextOffset?: number; offset: number } }>
  • Search for Form Store Records

    Example

    const { formStoreRecords } =
    await formStoreService.searchFormStoreRecords({
    formId: 1,
    paging: {
    limit: 50,
    offset: 0,
    },
    })

    Parameters

    • searchParameters: { formId: number; paging: { limit: number; offset: number } } & FormStoreParameters

      Search parameters for filtering, sorting, and paging

    • abortSignal: AbortSignal

      An AbortSignal to abort the request

    Returns Promise<{ formStoreRecords: FormStoreRecord[]; meta: { limit: number; nextOffset?: number; offset: number } }>