import { FourDInterface, FourDQuery } from './JSFourDInterface'; import { FourDCollection } from './JSFourDCollection'; import * as i0 from "@angular/core"; /** * This is the description for each field in a Data Model */ export interface IFieldDescription { /** the field name, must be unique in the Data Model */ name: string; /** the field dot long name, in the format 'table.field', applicable if a database field */ longname: string; /** the field type, possible values are: string, number, Number, Date, time, boolean, blob, json, picture */ type: string; /** if field is a calculated value, this is a 4D expresstion that returns the field contents */ formula: string; /** if field is a subtable (related many table), this is the FourDModel that represents records in that table */ subTable: FourDModel; /** not used */ className: string; /** if field is a subtable, this is the foreign key field in the main table */ joinFK: string; /** if field is a subtable, this is the primary key field in the related many table */ joinPK: string; /** indicates field comes from a related table */ isrelated: boolean; /** if field is a foreign key that relates to a one table, this is the related one field name in dot long format */ relatesTo: string; /** indicates field is read only, and can't me modified */ readonly: boolean; /** the choice list associated to the field */ list: string; /** field is a required field, cannot be empty or null */ required: boolean; /** indicates that the field is indexed on 4D side */ indexed: boolean; /** field is unique */ unique: boolean; /** if an alpha field, the field length as defined in the 4D Structure */ length: number; } /** * Individual 4D Datamodel that replicates a 4D Table's structure and provides a CRUD API to 4D data */ export declare class FourDModel { /** 4D's Table name */ tableName: string; /** 4D's table number */ tableNumber: number; /** Table's primary key field name */ primaryKey_: string; /** record number field/attribute name, usually '_recnum' */ idAttribute: string; /** Table definition, array describing all fields in the Data Model and how they map to the 4D Structure */ fields: Array; /** callback method to be executed on 4D side before a Save operation */ fourdSaveCallbackMethod_: string; /** callback method to be executed on 4D side before a Delete operation */ fourdDeleteCallbackMethod_: string; fourD: FourDInterface; private _recnum; private _attributes; private _modified; /** * constructor: initialize model properties */ constructor(); /** * Get a field value */ get(field: string): any; /** * Set a field value, updates field modified flag */ set(field: string, value: any): void; /** * Returns the description for a given field * * @param fieldName the field name to get properties for * * @returns the field name properties, an IFieldDescription instance * */ getFieldProperties(fieldName: any): IFieldDescription; /** * Clears up all record fields */ clearRecord(): void; /** * Serializes record data into its JSON representation as used in 4D * * @param mode can be 'insert' or 'update', if mode is 'update' the JSON string will contain only fields that have been modified * @param noAudit 'no audit' flag to be sent to 4D, if 'true' record audit log will be disabled * * @returns record contents as JSON string * */ recordToJSON(mode: string, noAudit: boolean): string; /** * Retrieve a record from 4D and populates the Data Model. * * @param recordNumber the record # to retrieve (optional, it defaults to the currentRecordNumber property) * @param recordID primary key value for the record to retrieve (optional, it defaults to the currentRecordNumber property) * if specified the record is retrieved by querying on its primary key field * @param query query string for the record to retrieve (optional, it defaults to the currentRecordNumber property) * * @returns returns a Promise for the database operation, whose result is the FourDModel instance * * */ getRecord(recordNumber?: number, recordID?: string, query?: FourDQuery): Promise; /** * Refresh current record, grab a fresh copy from 4D * * @returns returns a Promise for the database operation, whose result is the FourDModel instance * */ refresh(): Promise; /** * Insert a new record in the database. * * @returns returns a Promise for the database operation, whose result is the FourDModel instance.

the primary key property is set after the record is inserted

* */ insertRecord(): Promise; /** * Update record in the database. * * @returns returns a Promise for the database operation, whose result is the FourDModel instance * */ updateRecord(): Promise; /** * Delete record from the database * * @param cascade true|false indicates if 4D should perform a cascade delete (optional, default=false) * * @returns returns a Promise for the database operation, whose result is the FourDModel instance * */ deleteRecord(cascade?: boolean): Promise; /** * Populates model with attributes/properties from a json Object * * @param recordData json object whose properties will be used to populate the Data Model */ populateModelData(recordData: any): void; extractModelData(): any; /** * Retrieves a list of records using a query string * * @param query the FourDQuery object that defines the query to be used for retrieving from 4D * @param columns custom column list to retrieve, JSON array of the columns to retrieve.

if informed, only the columns listed will be retrieved instead of the whole record

* @param startRec the starting record number to retrieve, used for paging. * @param numOfRecords the number of records to retrieve, the default -1 will retrieve all records in the resulting query. * @param filter optional, FourDQuery to further filter records to he retrieved * @param orderby optional order By clause to retrieve records in a set order.

in the format:

>table.field : to sort records by table.field in ascending order

<table.field : to sort records by table.field in descending order

* * * @returns returns a Promise for the database operation, whose result is a FourDCollection with the query results */ getRecords(query?: FourDQuery, columns?: Array, startRec?: number, numOfRecords?: number, filter?: string, orderby?: string): Promise; /** * Retrieves a set of variables or 4D execute formula values * * @param values an Array of objects with the following format: {formula: 'a 4d formula', value:'the resulting value returned by 4D'} * @param method the name of a 4D method to be called before processing the formulas * * @returns returns a Promise for the database operation, whose result is the values Array populated by 4D */ getValuesFrom4D(values: Array, method?: string): Promise>; /** * Get the current record's record number * * @returns current record number (4D's record number, equivalent to ROWID) * */ get recordNumber(): number; set recordNumber(v: number); /** * Checks to see if a record is currently loaded * * @returns true if a record is loaded into this FourDModel instance * */ isRecordLoaded(): boolean; /** * Clears record modified flag. * * This can be used when one changes a record programmatically, but does not want to set the record modified flag. * For example on record initialization. * */ clearRecordDirtyFlag(): void; /** * Check if current record has been modified. * * @returns true indicates that record contents have been modified. * */ recordIsDirty(): boolean; /** * Prepares the record's JSON field description to send to 4D * * @returns JSON string representing all fields in the Data Model */ getColumnListJSON(): string; /** * Gets a list of fields in the Data Model * * @param includeSubTables if 'true', includes fields in subtables defined in the Data Model * * @returns an array with all fields defined for this data model */ getColumnList(includeSubTables?: boolean): Array; /** * Returns a field's longname, given its field name * * @param fieldName the field name * * @returns the field dot longname, as 'table.field' */ getLongname(fieldName: string): string; /** * Returns a field's data model description * * @param fieldName the field name * * @returns the field's iFieldDescription */ private getFieldDescription; /** * Checks to see if a field is from a related table * * @param field field description for the Class definition * @return true if field is on a related table * */ private isRelatedField; /** * Checks to see if a field contents have been modified * * @param field field/property name * @returns true if field has been modified * */ private isModifiedField; /** * Checks to see if a field is a calculated field * * @param field field description from the Data Model * * @returns true if field is formula, a calculated field * */ private isCalculatedField; /** * Checks to see if a field is a related many subtable * * @param field field description from the Data Model * @returna true if field is a related many subtable * */ private isSubtable; /** * Checks to see if a field is read only * * @param field field description from the Data Model * @returns true if field is read only * */ private isReadOnly; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }