UNPKG

baasic-sdk-javascript

Version:

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

147 lines (146 loc) 7.71 kB
"use strict"; /* globals module */ /** * @module articleInstanceFilesRoute * @description Baasic Article Instance Files Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Article Files 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. */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var inversify_1 = require("inversify"); var common_1 = require("../../../common"); ; var contracts_1 = require("../../../core/contracts"); var __1 = require("../"); var ArticleInstanceFilesRoute = /** @class */ (function (_super) { tslib_1.__extends(ArticleInstanceFilesRoute, _super); function ArticleInstanceFilesRoute(articleInstanceFilesStreamsRoute, articleInstanceFilesBatchRoute, appOptions) { var _this = _super.call(this, appOptions) || this; _this.articleInstanceFilesStreamsRoute = articleInstanceFilesStreamsRoute; _this.articleInstanceFilesBatchRoute = articleInstanceFilesBatchRoute; _this.appOptions = appOptions; _this.findRoute = 'articles/{articleId}/files/{?searchQuery,fileName,minFileSize,maxFileSize,ids,from,to,page,rpp,sort,embed,fields}'; _this.getRoute = 'articles/{articleId}/files/{id}/{?embed,fields}'; _this.linkRoute = 'articles/{articleId}/files/link'; _this.unlinkRoute = 'articles/{articleId}/files/unlink/{id}'; _this.unlinkByArticleRoute = 'articles/{articleId}/files/unlink/{id}'; _this.updateRoute = 'articles/{articleId}/comments/{id}'; return _this; } Object.defineProperty(ArticleInstanceFilesRoute.prototype, "streams", { get: function () { return this.articleInstanceFilesStreamsRoute; }, enumerable: true, configurable: true }); Object.defineProperty(ArticleInstanceFilesRoute.prototype, "batch", { get: function () { return this.articleInstanceFilesBatchRoute; }, enumerable: true, configurable: true }); /** * Parses find route which can be expanded with additional options. Supported items are: * - `searchQuery` - A string referencing file properties using the phrase search. * - `page` - A value used to set the page number, i.e. to retrieve certain file subset from the storage. * - `rpp` - A value used to limit the size of result set per page. * - `sort` - A string used to set the file property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @param articleId Article slug or id which uniquely identifies article whose article files need to be retrieved. * @param options Query resource options object. * @example articleInstanceFilesRoute.find({searchQuery: '<search-phrase>'}); **/ ArticleInstanceFilesRoute.prototype.find = function (articleId, options) { var params = this.modelMapper.findParams(options); params.articleId = articleId; return _super.prototype.baseCreate.call(this, this.findRoute, params); }; /** * Parses get route; this route should be expanded with the Id of the file resource. * @method * @param articleId Article slug or id which uniquely identifies article whose article files need to be retrieved. * @param id Article file id which uniquely identifies article file that needs to be retrieved. * @param options options object that contains embed data. * @example articleInstanceFilesRoute.get({id: '<file-id>'}); **/ ArticleInstanceFilesRoute.prototype.get = function (articleId, id, options) { var params = this.utility.extend({}, options); params.articleId = articleId; params.id = id; return _super.prototype.baseGet.call(this, this.getRoute, params); }; /** * Parses link route; this URI template does not expose any additional options. * @method * @param articleId Article slug or id which uniquely identifies article whose article files need to be deleted. * @param data * @param options * @example articleInstanceFilesRoute.link(); **/ ArticleInstanceFilesRoute.prototype.link = function (articleId, data) { var params = this.utility.extend({}, data); params.articleId = articleId; return _super.prototype.baseCreate.call(this, this.linkRoute, {}); }; /** * Parses unlink route; this URI template does not expose any additional options. * @method * @param articleId Article slug or id which uniquely identifies article whose article files need to be deleted. * @param data * @param options * @example articleFilesRoute.unlink(data); **/ ArticleInstanceFilesRoute.prototype.unlink = function (articleId, data, options) { if (!options) { options = {}; } var params = this.modelMapper.removeParams(data); params.articleId = articleId; return _super.prototype.baseDelete.call(this, this.unlinkRoute, params, options, 'unlink'); }; /** * Parses unlink by article route; this URI template does not expose any additional options. * @method * @param articleId Article slug or id which uniquely identifies article whose article files need to be deleted. * @param data * @param options * @example articleFilesRoute.unlinkByArticle(data); **/ ArticleInstanceFilesRoute.prototype.unlinkByArticle = function (articleId, data, options) { if (!options) { options = {}; } var params = this.modelMapper.removeParams(data); params.articleId = articleId; return _super.prototype.baseDelete.call(this, this.unlinkByArticleRoute, params, options, 'unlink-by-article'); }; /** * Parses update route; this URI template does not expose any additional options. * @method * @example articleInstanceFilesRoute.update(data); **/ ArticleInstanceFilesRoute.prototype.update = function (articleId, data) { var params = this.modelMapper.updateParams(data); params.articleId = articleId; return _super.prototype.baseUpdate.call(this, this.updateRoute, params); }; ArticleInstanceFilesRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(__1.TYPES.ArticleInstanceFilesStreamsRoute)), tslib_1.__param(1, inversify_1.inject(__1.TYPES.ArticleInstanceFilesBatchRoute)), tslib_1.__param(2, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [__1.ArticleInstanceFilesStreamsRoute, __1.ArticleInstanceFilesBatchRoute, Object]) ], ArticleInstanceFilesRoute); return ArticleInstanceFilesRoute; }(common_1.BaseRoute)); exports.ArticleInstanceFilesRoute = ArticleInstanceFilesRoute; /** * @overview ***Notes:** - Refer to the [REST API documentation](https://github.com/Baasic/baasic-rest-api/wiki) 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. */