Backend Model

src/cuba directory contains TypeScript representation of project’s entities, fetch plans and facades to access REST services and queries. See more details in TypeScript SDK section. Here is the layout of the directory:

  • entities - project entities and views;

  • enums - project enums;

  • services.ts - middleware services exposed to REST;

  • queries.ts - REST queries.

Consider this example entity.

export class User {
  static NAME = "scr_User";
  id?: string;
  version?: number | null;
  username?: string | null;
  password?: string | null;
  firstName?: string | null;
  lastName?: string | null;
  email?: string | null;
  enabled?: boolean | null;
  phone?: string | null;
}
  • You can easily access the entity name using static NAME property: User.NAME,

  • The User class contains all properties of the domain model entity. Reference fields has corresponding types as well so that you can work with them in a type-safe manner.

user.enabled = true;   // ok
user.enabled = 'foo';  // compilation fails