Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Paris<TConfigData>

Type parameters

  • TConfigData

Hierarchy

  • Paris

Index

Constructors

constructor

Properties

dataStore

dataStore: DataStoreService

error$

error$: Observable<EntityErrorEvent>

Observable that fires whenever there is an error in Paris. Relevant both to errors parsing data and to HTTP errors

modeler

modeler: Modeler

remove$

remove$: Observable<RemoveEntitiesEvent>

Observable that fires whenever an Entity is removed

save$

save$: Observable<SaveEntityEvent>

Observable that fires whenever an Entity is saved

Accessors

config

Methods

allItems

  • allItems<TEntity, TId>(entityConstructor: DataEntityType<TEntity, any, TId>): Observable<Array<TEntity>>
  • Gets all the items for an entity type. If all the items are cached, no backend call shall be performed (as in the case the the Entity is configured with loadAll: true and has already fetched data).

    Type parameters

    Parameters

    Returns Observable<Array<TEntity>>

apiCall

  • apiCall<TResult, TInput>(apiCallType: ApiCallType<TResult, TInput>, input?: TInput, dataOptions?: DataOptions): Observable<TResult>
  • Calls a backend API, which is defined by an ApiCallType.

    Type parameters

    • TResult

    • TInput

    Parameters

    • apiCallType: ApiCallType<TResult, TInput>

      The class which defines the ApiCallType. Should be decorated with @ApiCall and extend ApiCallModel.

    • Optional input: TInput

      Any data required to be sent to the backend in the API call

    • Default value dataOptions: DataOptions = defaultDataOptions

      General options for the call

    Returns Observable<TResult>

    An Observable of the api call's result data type

callQuery

clearApiCallCache

  • Clears all or specific ApiCallType caches

    Parameters

    • Optional apiCallType: ApiCallType | Array<ApiCallType>

      Optional ApiCallType class or array of classes. if omitted, all ApiCallType caches will be cleared. otherwise, only the caches of the specified ApiCallType(s) will be cleared.

    Returns void

createItem

  • Creates an instance of a model - given an Entity/ValueObject class and data, creates a root model, with full model tree, meaning - all sub-models are modeled as well. Sub-models that require being fetched from backend will be fetched.

    Type parameters

    Parameters

    • entityConstructor: DataEntityType<TEntity>
    • data: TRawData

      The raw JSON data for creating the item, as it arrives from backend.

    • Default value dataOptions: DataOptions = defaultDataOptions
    • Optional query: DataQuery

    Returns Observable<TEntity>

getItemById

  • getItemById<TEntity, TId, TTId>(entityConstructor: DataEntityType<TEntity, any, TId>, itemId: TTId, options?: DataOptions, params?: object): Observable<TEntity>
  • Gets an item by ID from backend and returns an Observable with the model

    example

    Get a TodoItem with ID 1

    const toDo$:Observable<TodoItem> = paris.getItemById<TodoItem>(TodoItem, 1);
    toDo$.subscribe((toDo:TodoItem) => console.log('Found TodoItem item: ', toDo);
    

    Type parameters

    Parameters

    • entityConstructor: DataEntityType<TEntity, any, TId>
    • itemId: TTId
    • Optional options: DataOptions
    • Optional params: object
      • [index: string]: any

    Returns Observable<TEntity>

getModelBaseConfig

  • Returns the configuration for the specified Entity/ValueObject class, if the specified class is indeed one of those.

    Parameters

    Returns EntityConfigBase

getRelatedItem

  • getRelatedItem<TSource, TResult>(relationshipConstructor: Function, item: TSource, query?: DataQuery, dataOptions?: DataOptions): Observable<TResult>
  • Gets an item that's related to another item, as defined in a relationship.

    example

    Get an item for another item

    const toDoListId = 1;
    const toDoList$:Observable<TodoList> = paris.getItemById(TodoList, toDoListId);
    
    const toDoListHistory$:Observable<ToDoListHistory> = toDoList$.pipe(
        mergeMap((toDoList:TodoList) => paris.getRelatedItem<TodoList, ToDoListHistory>(TodoListItemsRelationship, toDoList))
    );
    
    toDoListHistory$.subscribe((toDoListHistory$:ToDoListHistory) => console.log(`History for TodoList #${toDoListId}:`, toDoListHistory));
    

    Type parameters

    Parameters

    • relationshipConstructor: Function
    • item: TSource
    • Optional query: DataQuery
    • Default value dataOptions: DataOptions = defaultDataOptions

    Returns Observable<TResult>

getRelationshipRepository

getRepository

  • Returns the Repository for the specified class. If no Repository can be found, returns null.

    Type parameters

    Parameters

    • entityConstructor: DataEntityType<TEntity>

      A class, should have a decorator of either @Entity or @ValueObject.

    Returns Repository<TEntity> | null

getValue

  • getValue<TEntity, TId>(entityConstructor: DataEntityType<TEntity, any, TId>, valueId: TId | function): TEntity
  • Gets an entity value by its ID. The value has to be defined in the Entity's values property

    example

    Get the value with id === 'open' from Entity ToDoStatus

    const openStatusId = 'open';
    const toDoStatus = paris.getValue(ToDoStatus, openStatusId);
    
    console.log("TodoItem 'open' status: ", toDoStatus);
    

    Type parameters

    Parameters

    • entityConstructor: DataEntityType<TEntity, any, TId>
    • valueId: TId | function

    Returns TEntity

query

  • Fetches multiple item data from backend

    Type parameters

    Parameters

    • entityConstructor: DataEntityType<TEntity>

      The Entity class for which to fetch data

    • Optional query: DataQuery

      object with configuration for the backend API, such as page, page size, order, or any custom data required

    • Default value dataOptions: DataOptions = defaultDataOptions

      General options for the query.

    Returns Observable<DataSet<TEntity>>

    An Observable of DataSet

queryForItem

  • queryForItem<TSource, TResult>(relationshipConstructor: Function, item: TSource, query?: DataQuery, dataOptions?: DataOptions): Observable<DataSet<TResult>>
  • Query items in a relationship - fetches multiple items that relate to a specified item.

    example
    Get all the TodoItem items in a TodoList
    const toDoListId = 1;
    const toDoList$:Observable<TodoList> = paris.getItemById(TodoList, toDoListId);
    
    const toDoListItems$:Observable<DataSet<TodoItem>> = toDoList$.pipe(
        mergeMap((toDoList:TodoList) => paris.queryForItem<TodoList, Todo>(TodoListItemsRelationship, toDoList))
    );
    
    toDoListItems$.subscribe((toDoListItems:DataSet<TodoItem>) => console.log(`Items in TodoList #${toDoListId}:`, toDoListItems.items));
    

    Type parameters

    Parameters

    • relationshipConstructor: Function
    • item: TSource
    • Optional query: DataQuery
    • Optional dataOptions: DataOptions

    Returns Observable<DataSet<TResult>>

resetConfig

  • resetConfig(): void
  • Reset the config object back to default

    Returns void

setConfig

  • Set the config object, merged with the default config object

    Parameters

    Returns void

Generated using TypeDoc