JavaScript Object Schema

$form
type $form {
  id: string,
  name: string;
  nameDisplay: string;
  activityKey: string;
  description: string;
  articleKey: string;
  candidateGroup: string;
  pass: boolean;
  comments: string;
  completed: string;
  assignee: string;
  status: string;
  initialValue: string | number | boolean;
  attributes: Record<string, string | number | boolean | null>;
  order: OrderInstance;
  asset: Asset;
  shift: ShiftInstance;
  startingEvent: EventInstance;
  formItems: Array<ActivityInstanceFormItem>;
  items: Array<ActivityInstanceFormItem>;
  orderComponents: Array<OrderComponent>;
  scripts: {
    onLoad: string;
  };
  keepForm: boolean;
  skippableBy: string;
  activityTemplate?: ActivityTemplate;
}

//Example

//Get the name of the asset activity is on
$form.asset.name

// Get the order number of the activity
$form.order.orderNumber

//Get the attribute from the asset/material/order
$form.attributes['My Attribute']
$item
type $item {
  id: number;
  itemKey: string;
  name: string;
  nameDisplay: string;
  hint: string;
  active: boolean;
  barcodeFieldLength: string;
  barcodeFields: string;
  calculation: string;
  imageEnabled: boolean;
  visibilityExpression: string;
  hiddenExpression: string;
  readOnly: boolean;
  toleranceRelativeToOrderQuantity: boolean;
  toleranceNotFound: boolean;
  lowerLimit: string;
  upperLimit: string;
  lowerWarningLimit: string;
  upperWarningLimit: string;
  initialValue: any;
  value: any;
  target: string;
  hideTarget: boolean;
  displayOrder: number;
  isRequired: boolean;
  enableImageCapture: boolean;
  hideWithoutTolerance: boolean;
  movementType: MovementType;
  movementTypeField: MovementTypeField;
  itemType: ActivityInstanceFormItem.ItemTypeEnum;
  dataType: ActivityInstanceFormItem.DataTypeEnum;
  toleranceType: ActivityInstanceFormItem.ToleranceTypeEnum;
  processVariable: ProcessVariable;
  options: ActivityItemOptionGroup;
  uom: UnitOfMeasure;
  forEachComponent: boolean;
  activityTemplate: ActivityTemplate;
  itemOptions: Array<ActivityItemOptionItem>;
  component: OrderComponent;
  material: Material;
  forEachMaterialGroup: MaterialGroup;
  componentConversion: MaterialConversion;
  attribute: Attribute;
  raiseEventType: EventType;
  enableOcr: boolean;
  images: string[];
  createdAt: string;
  updatedAt: string;
  items: ActivityInstanceFormItem[];
  expanded: boolean;
  sectionIndex: number;
  section: any;
  downtimeClosedAt: string;
  board: EntitySchemaDto;
  boardField: string;
  index: number;
  assetList: Asset[];
}

//When inside a section, which section number is it
$item.index
$formValue
type $formValue: {
    [itemKey: string]: any
}

//Example

//Get the value on the form for item key input1
$formValue.input1
$util
type $util: {
    isItemPass: (itemKey: string) => boolean,
    isItemActive: (itemKey: string) => boolean,
    isItemHidden: (itemKey: string) => boolean,
    getFormValue: (itemKey: string) => any,
    getFormItem: (itemKey: string) => $item,
    getItemLimits: (itemKey: string) => {
        upperLimit: number,
        lowerLimit: number,
        upperWarningLimit: number,
        lowerWarningLimit: number,
        target: number,
        pass: boolean,
        lowerPass: boolean,
        upperPass: boolean,
        upperWarningPass: boolean,
        lowerWarningPass: boolean
    },
    
}

//Examples

//Show this item when item 'input1' fails
ActiveItemExpression: `!$form.isItemPass('input1')`

//Get value for itemKey 'input1' and multiply by 60. Will only get the item inside it's section 
Calculation: `$util.getFormValue('input1') * 60`
$math
type $math: {
    avg: (...values: number[]) => number,
    min: (...values: number[]) => number,
    max: (...values: number[]) => number,
}

//Examples

//Find the average of over each itemKey
Calculation: `$math.avg(input1, input2, input3)`

//On a form which includes itemKeys like sample1, sample2 ... sample10 
//we can get avg of all fields by looping over the items
Calculation: `$math.avg($formItem.filter(f => f.includes('sample')).map(f => $util.getFormValue(f.itemKey)))`
$tillitApi
type $tillitApi {
    get: (path: string, params?: Record<string, string | number | boolean>) => Promise<unknown>
}

Last updated