Skip to Content

Node.js Scripts

The scripts/ directory contains Node.js utilities that produce generated config files consumed by the frontend. These output files are fully re-generatable — commit only the scripts, not the output.


generate-table-names.js — Table Names

Scans all config/versioned/json/**/data.json files (latest version of each entity), reads tableName, and writes config/tableNames.js — a dropdown-ready [{ label, value }] array sorted alphabetically.

./index.js gen:table-names

Output (config/tableNames.js):

export const TableNames = [ { label: "Accounting Account", value: "accounts" }, { label: "Accounting Account Type", value: "account_types" }, { label: "Bill", value: "bills" }, { label: "Invoice", value: "invoices" }, // count grows as entities are generated ];

generate-entity-names.js — Entity / Resource Names

Same scan but reads resourceName (the API resource slug) and writes config/entityNames.js.

node scripts/generate-entity-names.js

Output (config/entityNames.js):

export const EntityNames = [ { label: "Accounting Account", value: "accounting_accounts" }, { label: "Bill", value: "bills" }, // ... ];

Label Derivation

Both scripts use entityToLabel():

function entityToLabel(entity) { const parts = entity.split('/'); const bundleName = (parts[0] || '').replace(/Bundle$/i, ''); const entityName = parts[1] || parts[0]; const combined = entityName.startsWith(bundleName) ? entityName : bundleName + entityName; return capitalize(combined); // camelCase-aware word splitting }

Example: AccountingBundle/AccountTypeAccountingAccountTypeAccounting Account Type


How to Use the Output

Import the generated constants in entity index.tsx files or frontend components:

import { TableNames } from "../tableNames"; import { PropertyTypes } from "../propertyTypes"; // Used in formInputs optionsArrayFinite: { key: "tableName", type: ColumnTypeEnum.SELECT, optionsArrayFinite: TableNames, }

Both files are generated artifacts — the entry count grows or shrinks as entities are added or removed from config/versioned/json/. Re-run after generating new entities.


Static Files

config/propertyTypes.js

A manually maintained static list of custom property types used as form field options:

export const PropertyTypes = [ { label: 'Text', value: 'text' }, { label: 'Number', value: 'int' }, { label: 'Date', value: 'date' }, { label: 'Date Time', value: 'datetime' }, { label: 'Boolean', value: 'bool' }, { label: 'Float', value: 'float' }, { label: 'HTML', value: 'html' }, { label: 'Money', value: 'money' }, { label: 'Dropdown', value: 'dropdown' }, ];

Unlike tableNames.js and entityNames.js, this file is not generated — it is maintained manually and committed to the repository.

Last updated on