UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

78 lines 2.21 kB
export default class FakeRoleStore { constructor() { this.roles = []; } count() { return Promise.resolve(0); } filteredCount(_search) { return Promise.resolve(0); } filteredCountInUse(_search) { return Promise.resolve(0); } getGroupRolesForProject(_projectId) { throw new Error('Method not implemented.'); } nameInUse(name, _existingId) { return Promise.resolve(this.roles.find((r) => r.name === name) !== undefined); } async getAll() { return this.roles; } async create(role) { const roleCreated = { ...role, type: role.roleType, id: this.roles.length, roleType: undefined, // roleType is not part of ICustomRole and simulates what the DB responds }; this.roles.push(roleCreated); return Promise.resolve(roleCreated); } update(_role) { throw new Error('Method not implemented.'); } delete(_id) { throw new Error('Method not implemented.'); } getRoles() { throw new Error('Method not implemented.'); } async getRoleByName(name) { return this.roles.find((r) => r.name === name); } getRolesForProject(_projectId) { throw new Error('Method not implemented.'); } removeRolesForProject(_projectId) { throw new Error('Method not implemented.'); } getProjectRoles() { throw new Error('Method not implemented.'); } async getRootRoles() { return this.roles; } getRootRoleForAllUsers() { throw new Error('Method not implemented.'); } get(id) { const found = this.roles.find((r) => r.id === id); if (!found) { // this edge case is not properly contemplated in the type definition throw new Error('Not found'); } return Promise.resolve(found); } exists(_key) { throw new Error('Method not implemented.'); } deleteAll() { throw new Error('Method not implemented.'); } destroy() { throw new Error('Method not implemented.'); } } //# sourceMappingURL=fake-role-store.js.map