• Public
  • Public/Protected
  • All

Interface EntityConfig<TEntity, TRawData, TId, TDataSet, T, TRawData, TInput>

Type parameters


Implemented by



Optional allItemsEndpoint

allItemsEndpoint: string

Normally, Paris follows the REST standard, and tries to fetch data for an Entity from the given endpoint + '/'. i.e: If endpoint === 'todo', querying the Entity would result in an HTTP GET from /api/todo/ However, if allItemsEndpoint is set to 'all', the HTTP GET would be from /api/todo/all.

Optional allItemsEndpointTrailingSlash

allItemsEndpointTrailingSlash: boolean

Normally, Paris follows the REST standard, and tries to fetch data for an Entity from the given endpoint + '/'. i.e: If endpoint === 'todo', querying the Entity would result in an HTTP GET from /api/todo/ However, if allItemsEndpointTrailingSlash is set to false, the trailing slash is removed and the HTTP GET would be from /api/todo.



Optional allItemsProperty

allItemsProperty: string

When fetching multiple items, Paris expects in the response either an array or an object with an 'items' property, that has an array value. allItemsProperty can be specified for changing the default 'items' property to whatever your response contains.


Without allItemsProperty, the data returned from querying your API would have to be either an array or: { "items": [...] }

However, if we set allItemsProperty like this: { "allItemsProperty": "results" }

Then Paris will expect the data to be:

        "results: [...]


Optional baseUrl

The domain to use for all calls for this Entity/ApiCall. Used as a prefix for all HTTP requests. Set to an empty string to avoid this altogether (in case the data arrives from an external URL, for example). If not set and not an empty string, Paris will use config.apiRoot instead.

Optional cache

cache: boolean | DataCacheSettings<T>

If cache is specified, entities will be cached according to the cache settings. Note: cache refers to individual items (such as received from getItemById or with an ApiCall), not queries.

Optional customHeaders

customHeaders: function | Record<string, string>

Custom headers for API call. It can be either a dictionary of string, with header names as the keys, or a function (which be applied by Paris) which receives data and config, and returns the headers for the API call.


Optional endpoint

The URL to use for HTTP requests.

Optional entityConstructor

entityConstructor: DataEntityType<TEntity, TRawData, TId>

Optional fixedData

fixedData: object

Query params to always send when requesting data.

Type declaration

  • [index: string]: any

Optional getDefaultValue

getDefaultValue: function

Type declaration

    • (): TEntity
    • Returns TEntity

Optional getRemoveData

getRemoveData: function

A function that returns data to send in the request body when DELETEing entities (by using repository.remove).


The entities that are removed.

Type declaration

    • (items: Array<TEntity>): any
    • Parameters

      • items: Array<TEntity>

      Returns any

Optional getValueById

getValueById: function

Type declaration

Optional hasValue

hasValue: function

Tests whether the entity contains a hard-coded value with the specified ID (in the entities values configuration).


Type declaration

Optional idProperty

idProperty: keyof TRawData

The property in the raw data used for the Entity's ID.

Optional loadAll

loadAll: boolean

If true, all the Entity's items are fetched whenever any is needed, and then cached so subsequent requests are retrieved from cache rather than backend. This makes sense to use for Entities whose values are few and not expected to change, such as enums.



Optional modelWith

modelWith: function

Optional function to supply the model type to construct, given the raw data. Useful for APIs that can return multiple entity types, with a common discriminator to differentiate them.

GET /things
{ "kind": "one", "id": 1 },
{ "kind": "two", "id": 2 },
modelWith: rawData => rawData.kind === 'one' : One ? Two
class Base { }

class One extends Base {}

class Two extends Base {}

paris.getItemById<One | Two>(Base, 1)
.subscribe(item =>
console.log(item instanceof One) // true

paris.getRepository(Base).query().subscribe(dataSet => {
const [ one, two ] = dataSet.items;

console.log(one instanceof One) // true
console.log(two instanceof Two) // true

Type declaration

Optional parseData

parseData: function

A function that if specifies, parses whatever is received from the API call, before Paris starts handling it.


Type declaration

Optional parseDataQuery

parseDataQuery: function

When a query is performed, a DataQuery object can be specified with options for the query. parseDataQuery receives that DataQuery object and allows to modify it, so Paris can send to the API what it expects.


Type declaration

Optional parseDataSet

parseDataSet: function

For query results, Paris accepts either an array of items or an object. That object may contain properties such as 'count', 'next' and 'previous'. parseDataSet, if available, receives the object as it was returned from the API and parses it to a DataSet interface, so the original properties are available in the DataSet.


Parsing a DataSet from a raw object returned by the backend

    parseDataSet: (rawDataSet:TodoRawDataSet) => ({ items: rawDataSet.todoItems, next: rawDataSet.$nextPage, count: rawDataSet.total })

Type declaration

    • (dataSet: TDataSet): DataSet<TRawData>
    • Parameters

      • dataSet: TDataSet

      Returns DataSet<TRawData>

Optional parseItemQuery

parseItemQuery: function

When getting an Entity from backend (when calling repository.getItemById), Paris follows the REST standard and fetches it by GET from /{the Entity's endpoint}/{ID}. parseItemQuery allows to specify a different URL. This is useful if your API doesn't follow the REST standard.


Fetching an entity by specifying the ID in a query param rather than as a folder

parseItemQuery: itemId => `/todo?id=${itemId}`

Type declaration

Optional parseRemoveQuery

parseRemoveQuery: function

Similar to parseDataQuery, but for a remove call, rather than getItemById. Use it to specify the URL to use when removing entities.


Type declaration

Optional parseSaveItemsQuery

parseSaveItemsQuery: function

Type declaration

Optional parseSaveQuery

parseSaveQuery: function

Similar to parseDataQuery, but for a save call, rather than getItemById. Use it to specify the URL to use when creating or updating an Entity.


Type declaration


pluralName: string

Human-readable name for the Entity type, plural. e.g 'Users', 'To do items', 'Movies', 'Comments', etc. Used internally for error messages, for example, or can be used in reflection.

Optional readonly

readonly: boolean

If readonly is set to true, all models of this entity type will be immutable - frozen with Object.freeze. Readonly models don't have a $parent property.



Optional saveMethod

saveMethod: function | SaveRequestMethod

Set the saveMethod of an Entity to determine the HTTP method to use in the request to the backend when saving an entity. Since this can be either a function or one of the RequestMethods, the method can be either hardcoded for all save calls of this Entity, or determined at runtime for each call. For example, you might want to use POST instead of Paris' default PUT when updating an existing entity, or you might want to use PATCH instead.

Optional separateArrayParams

separateArrayParams: boolean

If true, a value that's specified in DataQuery.params and is an array will result in multiple params in the HTTP request


Using separateArrayParams

    singularName: 'My entity',
    pluralName: 'My entities',
    endpoint: 'myentity',
    separateArrayParams: true
export class MyEntity extends EntityModelBase{}

paris.query(MyEntity, { where: { foo: ['bar', 'lish'] }})
    .subscribe((dataSet:DataSet<MyEntity>) => console.log(dataSet));

In this example, the API call will be to (config.apiRoot)/myentity?foo=bar&foo=lish. If separateArrayParams wasn't specified as true, the api call would have been to: (config.apiRoot)/myentity?foo=bar,lish

Optional serializeItem

serializeItem: function

Type declaration

    • (item: Partial<TEntity>, serializedItem?: any, entity?: IEntityConfigBase<TEntity, TRawData, TId>, config?: ParisConfig, serializationData?: any): TRawData
    • Parameters

      • item: Partial<TEntity>
      • Optional serializedItem: any
      • Optional entity: IEntityConfigBase<TEntity, TRawData, TId>
      • Optional config: ParisConfig
      • Optional serializationData: any

      Returns TRawData


singularName: string

Human-readable name for the Entity type, singular. e.g 'User', 'To do item', 'Movie', 'Comment', etc. Used internally for error messages, for example, or can be used in reflection.

Optional supportedEntityGetMethods

supportedEntityGetMethods: Array<EntityGetMethod>

Optional timeout

timeout: number

If the HTTP request takes longer than this number (milliseconds), the request will fail with status 0.



Optional values

values: Array<TEntity>

Hard-coded items for this Entity. When values are specified, no endpoint is required, and items are always returned from these values, instead of backend.

Hard-coding values for an Entity:

singularName: "Status",
pluralName: "Statuses",
values: [
{ id: 1, name: 'Open' },
{ id: 2, name: 'In progress' },
{ id: 3, name: 'Done' }
export class Status extends EntityModelBase<number>{
name: string;

Then when requesting an item for Status, either directly (with getValue or getItemById) or when sub-modeling, the hard-coded values are used:

// Async:
paris.getItemById(Status, 1).subscribe(status => console.log('Status with ID 1: ', status);

// Sync:
console.log('Status with ID 1: ', paris.getValue(Status, 1));

Generated using TypeDoc