UNPKG

@ords/core

Version:

Microservice architecture with service proposals in nodejs and typescript

137 lines (136 loc) 3.24 kB
import { main } from './main.proposal'; /** * Proposal for Database * root: db */ export declare namespace database { /** * Types used in proposals */ namespace types { /** * Identifier of the row affected row */ type RowId = any; /** * Document in the database */ type Doc = { [key: string]: any; }; /** * Query for Other operations */ type Query = { [key: string]: any; }; /** * Number of effected rows */ type NumAffected = number; } /** * Request packages for operations */ namespace Packages { interface _base { [key: string]: any; resource: string; runValidations?: boolean; } interface Create extends _base { data: types.Doc; query?: types.Query; } interface Read extends _base { /** * Limits the number of output in the read */ limit?: number; /** * Specific elements from the resource */ elements?: { [element: string]: Boolean; }; sort?: [{ element: boolean; }]; /** * Join the results on specific element */ joins?: { [originElement: string]: { targetResource: string; targetElement: string; scope: Read; }; }; /** * Query to be performed */ query?: types.Query; } interface Update extends _base { query: types.Query; data: types.Doc; } interface Patch extends _base { query: types.Query; data: types.Doc; } interface Delete extends _base { query: types.Query; } } /** * Returned from the operations in proposal */ namespace Returns { /** * Create operations return the inserted row id */ type Create = types.RowId; /** * Read operations returned an array of documents */ type Read = Array<types.Doc>; /** * Update operations return the effected row id */ type Update = types.RowId; /** * Patch operations return the effected row id */ type Patch = types.RowId; /** * Delete operations return the number of affected rows */ type Delete = types.NumAffected; } /** * Operations included in proposal */ interface Proposal { /** * */ read: main.types.MicroService; /** * */ create: main.types.MicroService; /** * */ update: main.types.MicroService; /** * */ delete: main.types.MicroService; /** * */ patch: main.types.MicroService; } }