UNPKG

kuzzle-sdk

Version:
48 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Profile = void 0; class Profile { /** * * @param {Kuzzle} kuzzle * @param {Object} data */ constructor(kuzzle, _id = null, content = {}) { Reflect.defineProperty(this, "_kuzzle", { value: kuzzle, }); this._id = _id; this.rateLimit = content && content.rateLimit ? content.rateLimit : 0; this.policies = content && content.policies ? content.policies : []; for (const [key, value] of Object.entries(content)) { if (this[key]) { continue; } this[key] = value; } } get kuzzle() { return this._kuzzle; } /** * Gets the associated roles definitions from the API. */ getRoles(options = {}) { if (!this.policies || this.policies.length === 0) { return Promise.resolve([]); } return this.kuzzle.security.mGetRoles(this.policies.map((policy) => policy.roleId), options); } /** * Serialize the instance */ serialize() { return { _id: this._id, policies: this.policies, rateLimit: this.rateLimit, }; } } exports.Profile = Profile; //# sourceMappingURL=Profile.js.map