UNPKG

baasic-sdk-javascript

Version:

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

113 lines (112 loc) 6.36 kB
"use strict"; /* globals module */ /** * @module userProfileACLRoute * @description Baasic User ACL Profile Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic User Profile ACL Route Definition 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 UserProfileACLRoute = /** @class */ (function (_super) { tslib_1.__extends(UserProfileACLRoute, _super); function UserProfileACLRoute(appOptions) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.getRoute = 'profiles/{id}/acl/{?fields}'; _this.updateRoute = 'profiles/{id}/acl/{?fields}'; _this.deleteByUserRoute = 'profiles/{id}/acl/actions/{accessAction}/users/{user}/'; _this.deleteByRoleRoute = 'profiles/{id}/acl/actions/{accessAction}/roles/{role}/'; return _this; } /** * Parses get user profile acl route; this URI template should be expanded with the Id of the user profile resource. * @method * @param options Query resource options object. * @example userProfileACLRoute.get({id: '<profile-id>'}); **/ UserProfileACLRoute.prototype.get = function (options) { var params = this.utility.extend({}, options); return _super.prototype.baseCreate.call(this, this.getRoute, params); }; /** * Parses update user profile acl route; this URI template should be expanded with the Id of the user profile. * @method * @param options ACL options object. * @example userProfileACLRoute.update({id: '<profile-id>'}); **/ UserProfileACLRoute.prototype.update = function (options) { var params = this.utility.extend({}, options); return _super.prototype.baseCreate.call(this, this.updateRoute, params); }; UserProfileACLRoute.prototype.updateParams = function (options) { var params = this.utility.extend({}, options); return params[this.modelMapper.modelPropertyName]; }; /** * Parses deleteByUser user profile acl route which can be expanded with additional options. Supported items are: * - `id` - Id of the user profile resource. * - `accessAction` - Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource. * - `user` - A value which uniquely identifies user for which ACL policy needs to be removed. * @method * @param profileId User profile id which uniquely identifies user profile resource whose security privileges need to be retrieved and updated. * @param action Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource. * Supported Values: * "Create" * "Delete" * "Read" * "Update" * @param user A value that uniquely identifies user for which ACL policy needs to be removed. * @param data ACL policy object used to delete specified ACL policy resource. * @example userProfileACLRoute.deleteByUser({ id: '<profile-id>', accessAction: '<access-action>', user: '<username>' }); **/ UserProfileACLRoute.prototype.deleteByUser = function (profileId, action, user, data) { var params = this.modelMapper.removeParams(data); params.profileId = profileId; params.user = user; params.accessAction = action; return _super.prototype.baseCreate.call(this, this.deleteByUserRoute, params); }; /** * Parses deleteByUser user profile acl route which can be expanded with additional options. Supported items are: * - `id` - Id of the user profile. * - `accessAction` - Action abbreviation which identifies ACL policy assigned to the specified role and user profile resource. * - `role` - A value which uniquely identifies role for which ACL policy needs to be removed. * @method * @param profileId User profile id which uniquely identifies user profile resource whose security privileges need to be retrieved and updated. * @param action Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource. * Supported Values: * "Create" * "Delete" * "Read" * "Update" * @param role A value that uniquely identifies role for which ACL policy needs to be removed. * @param data ACL policy object used to delete specified ACL policy resource. * @example userProfileACLRoute.deleteByRole.expand({ id: '<profile-id>', accessAction: '<access-action>', role: '<role-name>' }); **/ UserProfileACLRoute.prototype.deleteByRole = function (profileId, action, role, data) { var params = this.modelMapper.removeParams(data); params.profileId = profileId; params.role = role; params.accessAction = action; return _super.prototype.baseCreate.call(this, this.deleteByRoleRoute, params); }; UserProfileACLRoute = tslib_1.__decorate([ tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [Object]) ], UserProfileACLRoute); return UserProfileACLRoute; }(common_1.BaseRoute)); exports.UserProfileACLRoute = UserProfileACLRoute; /** * @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. */