N NezamDocumentation

Declarations#

Declarations are the main unit of Business Language source files. A source file is parsed as a sequence of declarations and statements, so declarations can appear at the top level and inside containers such as modules and namespaces.

Declaration map#

The grammar accepts these declaration families:

DeclarationPurpose
fieldReusable scalar field type with validation and properties
table / entityPersistent records, configuration tables, constraints, indexes, validations
struct, typeData shapes and type aliases
enumTrue invariant value sets
function, rule, validationExecutable behavior and reusable validation
messageLocalized user-facing text and error catalogs
service, api, subscriptionIntegration and event boundaries
form, control, appUI definitions
program, resource, deploymentRuntime and infrastructure declarations
module, package, namespace, using, import, exportOrganization and dependency structure

Module members can also include module-scoped label declarations.

Fields#

Fields define reusable scalar shapes.

bl
field CurrencyCode: string {
  max_length: 3;
  key: true;
}

Function return markers can be either : or ->. Function bodies can be block bodies, abstract semicolon bodies, fat-arrow expressions, fat-arrow statements, or fat-arrow query/delete statements.

Tables#

Tables define persisted records. Field modifiers such as key, origin, and default(...) describe storage behavior.

bl
table PaymentTermPolicy {
    field company_code: CompanyCode key;
    field payment_term_id: PaymentTermId key origin;
    field active: bool default(true);
    field created_at: datetime default(now());
}

Modifiers#

Common access modifiers are:

bl
public
private
protected
internal

Common function modifiers are:

bl
static
abstract
virtual
override
async
inline

Use annotations before declarations when metadata is needed:

bl
@http(GET)
public function list_vendors(company_code_param: CompanyCode): Json {
  return {};
}

Functions#

Functions can be public, private, or annotated for HTTP exposure.

bl
@http(GET)
function get_active_payment_terms(
  company_code_param: CompanyCode,
  limiter: limiter
): Json {
  select *
  from PaymentTermPolicy
  where PaymentTermPolicy.company_code = company_code_param
    and PaymentTermPolicy.active = true
  order by payment_term_id
  with limiter limiter;
}

Messages#

Messages define reusable user-facing failures.

bl
message payment_term_policy_required {
    code: "AP-ERR-1001";
    severity: error;
    category: custom("config");
    message: {
        en: "Payment term policy is required";
    };
}
Source: packages/business/language/declarations.md