ObjectRecords

@thotnr-aws-accl/custom-app-api / Exports / ObjectRecords

Class: ObjectRecords

Manage the list of records for an object

Table of contents

Methods

Methods

createBulkGraphqlcall

Static createBulkGraphqlcall(structName, data): Promise<ObjectRecord[]>

Creates records in bulk for an object

Parameters

Name
Type

structName

string

data

any[]

Returns

Promise<ObjectRecord[]>

The created objects


createGraphqlcall

Static createGraphqlcall(structName, data): Promise<ObjectRecord>

Creates records for an object

Parameters

Name
Type
Description

structName

string

The name of the object to be created

data

any

The data to be updated

Returns

Promise<ObjectRecord>

The created object


createRecords

Static createRecords(structName, data, failOnError, timeOutInSeconds?, callbacks?, validationLabel?, honorNulls?): Promise<{ appObjectWriteStateId?: number ; errors: Record<string, any>[] }>

Create records in bulk by using a csv writer

Parameters

Name
Type
Description

structName

string

The name of the struct or the object

data

string | Record<string, any>[] | File

Either a csv file, csv string or an array of records.

failOnError

boolean

If true, only errors are reported, and the data is not loaded into the object

timeOutInSeconds?

number

The timeout in seconds for the request

callbacks?

Object

Callbacks for the request

callbacks.onComplete

() => void

-

callbacks.onError

(error: Error, file: string | File) => void

-

callbacks.onWriteChunk

() => void

-

validationLabel?

string

An optional label for validation, used to validate the records using custom validations defined by the user for this object and label

honorNulls?

boolean

If true, null values for fields are stored as nulls, as opposed to the current behavior where nulls are saved as empty strings.

Returns

Promise<{ appObjectWriteStateId?: number ; errors: Record<string, any>[] }>

The errors


createRecordsV2

Static createRecordsV2(«destructured»): Promise<{ appObjectWriteStateId?: number ; errors: Record<string, any>[] ; objectUploader?: ObjectUploader }>

Create records in bulk by using a csv writer

Parameters

Name
Type

«destructured»

Object

callbacks?

Object

callbacks.onComplete

() => void

callbacks.onError

(error: Error, file: string | File) => void

callbacks.onWriteChunk

() => void

data

string | Record<string, any>[] | File

failOnError

boolean

honorNulls?

boolean

runUntilStep

UploadSteps

structName

string

timeOutInSeconds?

number

validationLabel?

string

Returns

Promise<{ appObjectWriteStateId?: number ; errors: Record<string, any>[] ; objectUploader?: ObjectUploader }>

The errors


deleteBulkGraphqlcall

Static deleteBulkGraphqlcall(structName, data): Promise<ObjectRecord[]>

Delete records in bulk for an object

Parameters

Name
Type

structName

string

data

any[]

Returns

Promise<ObjectRecord[]>

The deleted objects


deleteGraphqlcall

Static deleteGraphqlcall(structName, data): Promise<ObjectRecord>

Delete the records for an object of given name

Parameters

Name
Type
Description

structName

string

The name of the struct or the object

data

any

Either a csv file, csv string or an array of records.

Returns

Promise<ObjectRecord>

The updated object


deleteRuleOrMetric

Static deleteRuleOrMetric(«destructured»): Promise<void>

Deletes a rule or a metric this method assumes there exists only one instance of thotnr-expression-conditional-lambda in the HTML DOM

Parameters

Name
Type

«destructured»

Object

isVersioned

boolean

onError?

(error: any) => void

onSuccess?

(ruleId: number) => void

ruleOrMetricId?

number

Returns

Promise<void>


downloadRecords

Static downloadRecords(«destructured»): Promise<void>

Download records to a file

Parameters

Name
Type

«destructured»

Object

config?

DownloadCSVConfig

fileHandle

FileSystemFileHandle

filterToApply?

string

objectToDownload

string

pageSize?

number

totalRecordsAllowed?

number

Returns

Promise<void>


getAllCurrentMetrics

Static getAllCurrentMetrics(): Promise<ObjectRules[]>

Returns a list of all metrics present in an app

Returns

Promise<ObjectRules[]>

The list of metrics


getAllCurrentRules

Static getAllCurrentRules(): Promise<ObjectRules[]>

Returns a list of all instance rules present in an app instance

Returns

Promise<ObjectRules[]>

The list of rules


getAllCurrentVersionedRules

Static getAllCurrentVersionedRules(): Promise<ObjectRules[]>

Returns a list of all version rules present in an app

Returns

Promise<ObjectRules[]>

The list of rules


getAppObjectWriteBatches

Static getAppObjectWriteBatches(«destructured»): Promise<AppObjectWriteBatch[]>

Retrieves the write batches by filtering on the job execution id, written after, written before and object id. If any of the parameters are undefined, they are ignored for filtering.

Parameters

Name
Type

«destructured»

Object

hasErrors?

boolean

jobExecutionId?

number

objectId?

number

pageSize?

number

writeBatchStatus?

BatchStatus

writtenAfter?

Date

writtenBefore?

Date

Returns

Promise<AppObjectWriteBatch[]>

A Promise that resolves to an array of AppObjectWriteBatch.


getCSVErrors

Static getCSVErrors(appObjectWriteBatchId): Promise<RecordWithErrors[]>

Retrieves the CSV errors for the specified appObjectWriteStateId.

Parameters

Name
Type
Description

appObjectWriteBatchId

number

The identifier of the app object write batch.

Returns

Promise<RecordWithErrors[]>

A promise that resolves with the CSV errors.


getLinkToDownloadRecords

Static getLinkToDownloadRecords(«destructured»): Promise<string>

Prepares a download link for the given objectId and CSV configuration. This download link must be used immediately. It will become inactive in 10 minutes.

Parameters

Name
Type

«destructured»

Object

csvConfig

DownloadLinkCSVConfig

objectId

number

Returns

Promise<string>


getObjectRecordsByJobIdAndStepId

Static getObjectRecordsByJobIdAndStepId(«destructured»): Promise<ObjectRecordPagedList>

Get list of records for an incremental or complete snapshot obbject

Parameters

Name
Type

«destructured»

Object

jobExecutionId

number

recordQueryArguments?

RecordQueryArgumentFilters

stepId

number

structName

string

Returns

Promise<ObjectRecordPagedList>


getStructString

Static getStructString(structString): Promise<number>

Retrieves the ID of a specific object by matching its name within a list of objects.

Parameters

Name
Type
Description

structString

string

The name of the structure to search for.

Returns

Promise<number>

A promise that resolves to the ID of the matched structure, or 0 if no match is found or the schema list is empty.


getUserList

Static getUserList(): Promise<AppUser[]>

Get the list of users for the current tenant

Returns

Promise<AppUser[]>

The list of users


mutationQuery

Static mutationQuery(graphqlQuery, structNames?): Promise<any>

Create Records by Mutation for an object from graphql

Parameters

Name
Type
Description

graphqlQuery

string

Mutation query

structNames?

string[]

Optional list of struct names to optimize the query

Returns

Promise<any>

The id of the struct


query

Static query(graphqlQuery, structNames?): Promise<any>

Queries/fetches the list of records for an object from graphql

Parameters

Name
Type
Description

graphqlQuery

string

The name of the struct or the object

structNames?

string[]

Optional list of struct names to optimize the query

Returns

Promise<any>

The id of the struct


queryRecordsForStructName

Static queryRecordsForStructName(structName, recordQueryArguments?): Promise<ObjectRecordPagedList>

This method is used to query records for a given struct name. The result is then mapped to an ObjectRecordPagedList.

Parameters

Name
Type
Description

structName

string

The name of the struct for which records are to be queried.

recordQueryArguments?

RecordQueryArgumentFilters

Optional argument filters for the record query.

Returns

Promise<ObjectRecordPagedList>

A Promise that resolves to an ObjectRecordPagedList containing the queried records.


removeGlobalObjectFilter

Static removeGlobalObjectFilter(): void

removes the applied global filter

Returns

void


saveRuleOrMetric

Static saveRuleOrMetric(«destructured»): Promise<void>

Creates or updates a rule/metric this method assumes there exists only one instance of thotnr-expression-conditional-lambda

Parameters

Name
Type

«destructured»

Object

isEnabled

boolean

isForMetric

boolean

isVersioned

boolean

jobStepName?

string

onError?

(error: any) => void

onSuccess?

(rule: ObjectRules) => void

ruleMetadata?

string

ruleOrMetricCode?

string

ruleOrMetricDescription

string

ruleOrMetricId?

Number

ruleOrMetricName

string

ruleOrder?

number

ruleType

RuleType

Returns

Promise<void>


setGlobalFiltersUsingURL

Static setGlobalFiltersUsingURL(): void

In order to filter on a particular field of an object and a value The url needs to be of the following structure instance/?globalObjects={ObjectName}&globalObjectFields={ObjectField1-ObjectField2}&globalObjectFieldValues={ObjectName}.{ObjectField1}.{ObjectFieldValue1}-{ObjectName}.{ObjectField2}.{ObjectFieldValue2} {ObjectName} can be set to 'all' so that all object records can be filtered by this criteria an and condition is applied in case of multiple fields

Returns

void


setGlobalObjectFilter

Static setGlobalObjectFilter(globalFilter): void

This applies a global filter while fetching records Here's an example of what it should look like { applicableObjects: ['all',{ObjectName}] applicableFields: ['all.test2_id',{ObjectField1}], filterValues: ['all.test2_id.3',{ObjectName}.{ObjectField1}.{ObjectFieldValue1}] } {ObjectName} can be set to 'all' so that all object records can be filtered by this criteria

Parameters

Name
Type

globalFilter

GlobalAppObjectFilter

Returns

void


updateBulkGraphqlcall

Static updateBulkGraphqlcall(structName, data): Promise<ObjectRecord[]>

Updates records in bulk for an object

Parameters

Name
Type

structName

string

data

any[]

Returns

Promise<ObjectRecord[]>

The updated objects


updateGraphqlcall

Static updateGraphqlcall(structName, data): Promise<ObjectRecord>

Updates records for an object

Parameters

Name
Type
Description

structName

string

The name of the struct or the object

data

any

The data to be updated

Returns

Promise<ObjectRecord>

The updated object

Last updated