UNPKG

baasic-sdk-javascript

Version:

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

141 lines (140 loc) 6.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); /* globals module */ /** * @module meteringRoute * @description Baasic Metering Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Metering Route Definition to obtain a 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 _1 = require("./"); var contracts_1 = require("../../core/contracts"); var MeteringRoute = /** @class */ (function (_super) { tslib_1.__extends(MeteringRoute, _super); function MeteringRoute(appOptions, meteringBatchRoute, meteringStatisticsRoute, meteringACLRoute) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.meteringBatchRoute = meteringBatchRoute; _this.meteringStatisticsRoute = meteringStatisticsRoute; _this.meteringACLRoute = meteringACLRoute; _this.findRoute = 'metering/data/{?applicationId,searchQuery,categories,from,to,names,moduleNames,statuses,endpoints,sources,page,rpp,sort,embed,fields}'; _this.getRoute = 'metering/data/{id}/{?embed,fields}'; _this.createRoute = 'metering/data'; _this.updateRoute = 'metering/data/{id}'; _this.deleteRoute = '/metering/data/{id}'; _this.purgeRoute = 'metering/data/purge'; return _this; } Object.defineProperty(MeteringRoute.prototype, "batch", { get: function () { return this.meteringBatchRoute; }, enumerable: true, configurable: true }); Object.defineProperty(MeteringRoute.prototype, "statistics", { get: function () { return this.meteringStatisticsRoute; }, enumerable: true, configurable: true }); Object.defineProperty(MeteringRoute.prototype, "acl", { get: function () { return this.meteringACLRoute; }, enumerable: true, configurable: true }); /** * Parses find metering route which can be expanded with additional options. Supported items are: * - `applicationId` - The application identifier. * - `categories` - The metering categories in CSV format. * - `from` - The from date. * - `to` - The to date. * - `names` - The name of the resource inside the category in CSV format. * - `moduleNames` - The name of the resource inside the category in CSV format. * - `statuses` - The operation status in CSV format. * - `endpoints` - The back-end endpoint in CSV format. * - `sources` - The metering collector source in CSV format. * - `searchQuery` - A string value used to identify metering resources using the phrase search. * - `page` - A value used to set the page number, i.e. to retrieve certain metering subset from the storage. * - `rpp` - A value used to limit the size of result set per page. * - `sort` - A string used to set the metering property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @param options Query resource options object. * @example meteringRoute.find({searchQuery: '<search-phrase>'}); **/ MeteringRoute.prototype.find = function (options) { return _super.prototype.baseFind.call(this, this.findRoute, options); }; /** * Parses get route; this route doesn't expose any properties. * @method * @param id MeteringData id which uniquely identifies MeteringData resource that needs to be retrieved. * @param options Query resource options object. * @example meteringRoute.get(); **/ MeteringRoute.prototype.get = function (id, options) { return _super.prototype.baseGet.call(this, this.getRoute, id, options); }; /** * Parses create metering route; this URI template does not expose any additional options. * @method * @example meteringRoute.create(); **/ MeteringRoute.prototype.create = function () { return _super.prototype.baseCreate.call(this, this.createRoute, {}); }; /** * Parses update metering route; this URI template does not expose any additional options. * @method * @param data An metering data object used to update specified MeteringData resource. * @example meteringRoute.update(data); **/ MeteringRoute.prototype.update = function (data) { return _super.prototype.baseUpdate.call(this, this.updateRoute, data); }; /** * Parses delete metering route; this URI template does not expose any additional options. * @method * @param data An metering data object used to delete specified MeteringData resource. * @example meteringRoute.delete(data); **/ MeteringRoute.prototype.delete = function (data) { return _super.prototype.baseDelete.call(this, this.deleteRoute, data); }; /** * Parses purge metering data route: this URI template does not expose any additional options. * @method * @example meteringRoute.purge(); **/ MeteringRoute.prototype.purge = function () { return _super.prototype.baseDelete.call(this, this.purgeRoute, {}); }; MeteringRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__param(1, inversify_1.inject(_1.TYPES.MeteringBatchRoute)), tslib_1.__param(2, inversify_1.inject(_1.TYPES.MeteringStatisticsRoute)), tslib_1.__param(3, inversify_1.inject(_1.TYPES.MeteringACLRoute)), tslib_1.__metadata("design:paramtypes", [Object, _1.MeteringBatchRoute, _1.MeteringStatisticsRoute, _1.MeteringACLRoute]) ], MeteringRoute); return MeteringRoute; }(common_1.BaseRoute)); exports.MeteringRoute = MeteringRoute; /** * @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. */