UNPKG

baasic-sdk-angular

Version:

Angular (v5+) SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).

129 lines (127 loc) 8.25 kB
import { BaasicAppService } from '../index'; import { IBaasicQueryModel, IGetRequestOptions, IHttpResponse, IOptions } from '../../infrastructure/common/contracts'; import { IDynamicObject, IDynamicResourceACLService, IDynamicResourceSchemaService, IDynamicResourceBatchService } from './contracts'; export declare class DynamicResourceService { private baasicApp; constructor(baasicApp: BaasicAppService); /** * Returns a promise that is resolved once the find action has been performed. Success response returns a list of dynamic resources matching the given criteria. * @method * @param schemaName Name of dynamic resource schema whose dynamic resources need to be retrieved. * @param options Query resource options object. * @returns Promise that is resolved once the find action has been performed. * @example DynamicResourceService.find('<schema-name>', { pageNumber : 1, pageSize : 10, orderBy : '<field>', orderDirection : '<asc|desc>', search : '<search-phrase>' }) .then(function (collection) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ find(schemaName: string, options?: IOptions): PromiseLike<IHttpResponse<IBaasicQueryModel<IDynamicObject>>>; /** * Returns a promise that is resolved once the get action has been performed. Success response returns the specified dynamic resource. * @method * @example DynamicResourceService.get('<schema-name>', '<dynamic-resource-id>') .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ get(schemaName: string, id: string, options?: IGetRequestOptions): PromiseLike<IHttpResponse<IDynamicObject>>; /** * Returns a promise that is resolved once the create dynamic resource action has been performed; this action creates a new dynamic resource item. * @method * @param schemaName Name of dynamic resource schema that needs to be updated with new dynamic resource. * @param data A JSON object that needs to be inserted into the system as dynamic resource. JSON object is an unordered collection of zero or more key/value pairs structured using the standard JSON syntax rules. * @example DynamicModuleService.create('<schema-name>', { id : '', description : '<description>' }) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ create(schemaName: string, data: any): PromiseLike<IHttpResponse<IDynamicObject>>; /** * Returns a promise that is resolved once the update action has been performed; this action updates a dynamic resource item. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicDynamicResourceRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects: * @method * @param data A JSON object used to update specified dynamic resource. JSON object is an unordered collection of zero or more key/value pairs structured using the standard JSON syntax rules. * @param options Options object. * @example // dynamicResource is a resource previously fetched using get action. dynamicResource.description = '<description>'; baasicDynamicResourceClient.update(dynamicResource, { query: "where field = 'value' " }) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ update(schemaName: string, data: any, options?: any): PromiseLike<IHttpResponse<void>>; /** * Returns a promise that is resolved once the patch action has been performed; this action patches an existing dynamic resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicDynamicResourceRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects: * @method * @param data JSON object used for partial update of specified dynamic resource. JSON object is an unordered collection of zero or more key/value pairs structured using the standard JSON syntax rules. * @param options Options object. * @example // dynamicResource is a resource previously fetched using get action. dynamicResource.description = '<new-description>'; dynamicResource.newField = '<newfield-value>'; DynamicResourceService.patch(dynamicResource, { query: "where field = 'value' " }) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ patch(schemaName: string, data: any, options?: any): PromiseLike<IHttpResponse<void>>; /** * Returns a promise that is resolved once the remove action has been performed. This action will remove a dynamic resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicDynamicResourceRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects: * @method * @param data JSON object used to delete specified dynamic resource. JSON object is an unordered collection of zero or more key/value pairs structured using the standard JSON syntax rules. * @example // dynamicResource is a resource previously fetched using get action. DynamicResourceService.remove(dynamicResource, { query: "where field = 'value' " }) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ remove(schemaName: string, data: any, options?: any): PromiseLike<IHttpResponse<void>>; /** * Returns a promise that is resolved once the purge action has been performed. This action will remove all dynamic resources from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `dynamicResourceRoute` route template. Here is an example of how a route can be obtained from HAL enabled objects: * @method * @param data JSON object used to purge dynamic resources. * @example // dynamicResource is a resource previously fetched using get action. DynamicResourceService.purge('<schema-name>') .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ purge(schemaName: string): PromiseLike<IHttpResponse<void>>; readonly batch: IDynamicResourceBatchService; readonly schema: IDynamicResourceSchemaService; readonly acl: IDynamicResourceACLService; }