UNPKG

baasic-sdk-javascript

Version:

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

99 lines (98 loc) 4.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); /** * @module valueSetItemRoute * @description Baasic Value Set Item Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Value Set Item Route Service to obtain needed routes while other routes will be obtained through HAL. By convention, all route services use the same function names as their corresponding services. */ var inversify_1 = require("inversify"); var common_1 = require("../../common"); ; var contracts_1 = require("../../core/contracts"); var ValueSetItemRoute = /** @class */ (function (_super) { tslib_1.__extends(ValueSetItemRoute, _super); function ValueSetItemRoute(appOptions) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.findRoute = 'value-sets/{setName}/items/{?searchQuery,page,rpp,sort,embed,fields}'; _this.getRoute = 'value-sets/{setName}/items/{id}/{?embed,fields}'; _this.createRoute = 'value-sets/{setName}/items/'; _this.updateRoute = 'value-sets/{setId}/items/{id}'; _this.deleteRoute = 'value-sets/{setId}/items/{id}'; return _this; } /** * Parses find value set items route which can be expanded with additional options. Supported items are: * - `setName` - Value set name. * - `searchQuery` - A string value used to identify value set items using the phrase search. * - `page` - A value used to set the page number, i.e. to retrieve certain value set item subset from the storage. * - `rpp` - A value used to limit the size of result set per page. * - `sort` - A string used to set the value set item property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method items.find * @param options Options object. * @example valueSetItemRoute.find(options); **/ ValueSetItemRoute.prototype.find = function (options) { return _super.prototype.baseFind.call(this, this.findRoute, options); }; /** * Parses get route which must be expanded with the following items: * - `setName` - Value set name. * - `id` - Value set item id. * @method * @param setName Value set name. * @param id Value set id. * @param options Query resource options object. * @example valueSetItemRoute.get(setName, id, options); **/ ValueSetItemRoute.prototype.get = function (setName, id, options) { var params = this.utility.extend({}, options); params.setName = setName; return _super.prototype.baseGet.call(this, this.getRoute, id, options); }; /** * Parses create value set item route; the URI template should be expanded with the value set name. * @method * @param data A value set item object that needs to be inserted into the system. * @example valueSetItemRoute.create(data); **/ ValueSetItemRoute.prototype.create = function (data) { return _super.prototype.baseCreate.call(this, this.createRoute, data); }; /** * Parses update value set item route. * @method * @param data A value set item object used to update specified value set resource. * @example valueSetItemRoute.update(data); */ ValueSetItemRoute.prototype.update = function (data) { return _super.prototype.baseUpdate.call(this, this.updateRoute, data); }; /** * Parses delete value set item route. * @method * @param data A value set item object used to delete specified value set resource. * @example valueSetItemRoute.delete(data); */ ValueSetItemRoute.prototype.delete = function (data) { return _super.prototype.baseDelete.call(this, this.deleteRoute, data); }; ValueSetItemRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [Object]) ], ValueSetItemRoute); return ValueSetItemRoute; }(common_1.BaseRoute)); exports.ValueSetItemRoute = ValueSetItemRoute; /** * @copyright (c) 2017 Mono Ltd * @license MIT * @author Mono Ltd * @overview ***Notes:** - Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points. - [URI Template](https://github.com/Baasic/uritemplate-js) syntax enables expanding the Baasic route templates to Baasic REST URIs providing it with an object that contains URI parameters. - All end-point objects are transformed by the associated route service. */