contensis-management-api
Advanced tools
Comparing version 1.0.0-beta.11 to 1.0.0-beta.12
@@ -12,9 +12,8 @@ import { User } from './User'; | ||
list(options?: UserListOptions): Promise<PagedList<User>>; | ||
getGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
getUserGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
create(user: User): Promise<User>; | ||
update(user: User): Promise<User>; | ||
updatePassword(options: UserUpdatePasswordOptions): Promise<void>; | ||
delete(id: string): Promise<void>; | ||
isInGroup(userId: string, groupId: string): Promise<boolean>; | ||
isInGroups(userId: string, groupIds: string[]): Promise<boolean>; | ||
delete(userId: string): Promise<void>; | ||
userIsMemberOf(userId: string, ...groupIdsOrNames: string[]): Promise<boolean>; | ||
} |
@@ -6,6 +6,4 @@ export interface UserCredentials { | ||
active: boolean; | ||
deactivationReason: string; | ||
locked: boolean; | ||
passwordExpired: boolean; | ||
passwordExpiry: Date; | ||
} | ||
@@ -16,3 +14,2 @@ export interface User { | ||
email: string; | ||
title: string; | ||
firstname: string; | ||
@@ -30,5 +27,4 @@ lastname: string; | ||
modified: Date; | ||
activated: Date; | ||
lastLogin: Date; | ||
passwordChanged: Date; | ||
} |
@@ -11,3 +11,3 @@ import { ContensisClient, IUserOperations, User, UserListOptions, Group, UserGroupsOptions, UserUpdatePasswordOptions } from '../models'; | ||
list(options?: UserListOptions): Promise<PagedList<User>>; | ||
getGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
getUserGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
create(user: User): Promise<User>; | ||
@@ -17,5 +17,4 @@ update(user: User): Promise<User>; | ||
delete(id: string): Promise<void>; | ||
isInGroup(userId: string, groupId: string): Promise<boolean>; | ||
isInGroups(userId: string, groupIds: string[]): Promise<boolean>; | ||
userIsMemberOf(userId: string, ...groupIdsOrNames: string[]): Promise<boolean>; | ||
private getUser; | ||
} |
@@ -45,3 +45,3 @@ import { UrlBuilder } from 'contensis-core-api'; | ||
} | ||
getGroups(userIdOrOptions) { | ||
getUserGroups(userIdOrOptions) { | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups', { includeInherited: null }) | ||
@@ -130,12 +130,12 @@ .addOptions(userIdOrOptions, 'userId') | ||
} | ||
isInGroup(userId, groupId) { | ||
userIsMemberOf(userId, ...groupIdsOrNames) { | ||
if (!userId) { | ||
throw new Error('A valid users id needs to be specified.'); | ||
} | ||
if (!groupId) { | ||
throw new Error('A valid group id needs to be specified.'); | ||
if (!groupIdsOrNames || groupIdsOrNames.length === 0) { | ||
throw new Error('At least a valid group id or name needs to be specified.'); | ||
} | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups/:groupId', {}) | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups/:groupIdsOrNamesCsv', {}) | ||
.addOptions(userId, 'userId') | ||
.addOptions(groupId, 'groupId') | ||
.addOptions(groupIdsOrNames.join(','), 'groupIdsOrNamesCsv') | ||
.setParams(this.contensisClient.getParams()) | ||
@@ -150,21 +150,2 @@ .toUrl(); | ||
} | ||
isInGroups(userId, groupIds) { | ||
if (!userId) { | ||
throw new Error('A valid users id needs to be specified.'); | ||
} | ||
if (!groupIds || groupIds.length === 0) { | ||
throw new Error('At least a valid group id needs to be specified.'); | ||
} | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups/:groupIdCsv', {}) | ||
.addOptions(userId, 'userId') | ||
.addOptions(groupIds.join(','), 'groupIdCsv') | ||
.setParams(this.contensisClient.getParams()) | ||
.toUrl(); | ||
return this.contensisClient.ensureAuthenticationToken().then(() => { | ||
return this.httpClient.request(url, { | ||
headers: this.contensisClient.getHeaders(), | ||
method: 'HEAD' | ||
}).then(() => true, () => false); | ||
}); | ||
} | ||
getUser(idOrNameOrEmail) { | ||
@@ -171,0 +152,0 @@ let url = UrlBuilder.create('/api/management/security/users/:idOrNameOrEmail', {}) |
@@ -198,3 +198,3 @@ import * as Contensis from '../index'; | ||
}); | ||
describe('Is user in group', () => { | ||
describe('Is user member of group', () => { | ||
describe('for a positive result', () => { | ||
@@ -210,3 +210,3 @@ beforeEach(() => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let result = await client.users.isInGroup(defaultUsers[0].id, defaultGroups[0].id); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -231,3 +231,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let result = await client.users.isInGroup(defaultUsers[0].id, defaultGroups[0].id); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -254,3 +254,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let result = await client.users.isInGroups(defaultUsers[0].id, [defaultGroups[0].id, defaultGroups[1].id]); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id, defaultGroups[1].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -275,3 +275,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let result = await client.users.isInGroups(defaultUsers[0].id, [defaultGroups[0].id, defaultGroups[1].id]); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id, defaultGroups[1].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -302,3 +302,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let groups = await client.users.getGroups(defaultUsers[0].id); | ||
let groups = await client.users.getUserGroups(defaultUsers[0].id); | ||
expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
@@ -315,3 +315,3 @@ expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let groups = await client.users.getGroups({ | ||
let groups = await client.users.getUserGroups({ | ||
userId: defaultUsers[0].id, | ||
@@ -318,0 +318,0 @@ includeInherited: true |
@@ -7,2 +7,6 @@ # Changelog | ||
## [1.0.0-beta.10] - 2020-06-10 | ||
### Changes | ||
- users api: changed *isInGroup/isinGroups* to *userIsMemberOf*, changed *getGroup* to *getUserGroups*; | ||
## [1.0.0-beta.11] - 2020-06-04 | ||
@@ -9,0 +13,0 @@ ### Added |
@@ -12,9 +12,8 @@ import { User } from './User'; | ||
list(options?: UserListOptions): Promise<PagedList<User>>; | ||
getGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
getUserGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
create(user: User): Promise<User>; | ||
update(user: User): Promise<User>; | ||
updatePassword(options: UserUpdatePasswordOptions): Promise<void>; | ||
delete(id: string): Promise<void>; | ||
isInGroup(userId: string, groupId: string): Promise<boolean>; | ||
isInGroups(userId: string, groupIds: string[]): Promise<boolean>; | ||
delete(userId: string): Promise<void>; | ||
userIsMemberOf(userId: string, ...groupIdsOrNames: string[]): Promise<boolean>; | ||
} |
@@ -6,6 +6,4 @@ export interface UserCredentials { | ||
active: boolean; | ||
deactivationReason: string; | ||
locked: boolean; | ||
passwordExpired: boolean; | ||
passwordExpiry: Date; | ||
} | ||
@@ -16,3 +14,2 @@ export interface User { | ||
email: string; | ||
title: string; | ||
firstname: string; | ||
@@ -30,5 +27,4 @@ lastname: string; | ||
modified: Date; | ||
activated: Date; | ||
lastLogin: Date; | ||
passwordChanged: Date; | ||
} |
@@ -11,3 +11,3 @@ import { ContensisClient, IUserOperations, User, UserListOptions, Group, UserGroupsOptions, UserUpdatePasswordOptions } from '../models'; | ||
list(options?: UserListOptions): Promise<PagedList<User>>; | ||
getGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
getUserGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
create(user: User): Promise<User>; | ||
@@ -17,5 +17,4 @@ update(user: User): Promise<User>; | ||
delete(id: string): Promise<void>; | ||
isInGroup(userId: string, groupId: string): Promise<boolean>; | ||
isInGroups(userId: string, groupIds: string[]): Promise<boolean>; | ||
userIsMemberOf(userId: string, ...groupIdsOrNames: string[]): Promise<boolean>; | ||
private getUser; | ||
} |
@@ -47,3 +47,3 @@ "use strict"; | ||
} | ||
getGroups(userIdOrOptions) { | ||
getUserGroups(userIdOrOptions) { | ||
let url = contensis_core_api_1.UrlBuilder.create('/api/management/security/users/:userId/groups', { includeInherited: null }) | ||
@@ -132,12 +132,12 @@ .addOptions(userIdOrOptions, 'userId') | ||
} | ||
isInGroup(userId, groupId) { | ||
userIsMemberOf(userId, ...groupIdsOrNames) { | ||
if (!userId) { | ||
throw new Error('A valid users id needs to be specified.'); | ||
} | ||
if (!groupId) { | ||
throw new Error('A valid group id needs to be specified.'); | ||
if (!groupIdsOrNames || groupIdsOrNames.length === 0) { | ||
throw new Error('At least a valid group id or name needs to be specified.'); | ||
} | ||
let url = contensis_core_api_1.UrlBuilder.create('/api/management/security/users/:userId/groups/:groupId', {}) | ||
let url = contensis_core_api_1.UrlBuilder.create('/api/management/security/users/:userId/groups/:groupIdsOrNamesCsv', {}) | ||
.addOptions(userId, 'userId') | ||
.addOptions(groupId, 'groupId') | ||
.addOptions(groupIdsOrNames.join(','), 'groupIdsOrNamesCsv') | ||
.setParams(this.contensisClient.getParams()) | ||
@@ -152,21 +152,2 @@ .toUrl(); | ||
} | ||
isInGroups(userId, groupIds) { | ||
if (!userId) { | ||
throw new Error('A valid users id needs to be specified.'); | ||
} | ||
if (!groupIds || groupIds.length === 0) { | ||
throw new Error('At least a valid group id needs to be specified.'); | ||
} | ||
let url = contensis_core_api_1.UrlBuilder.create('/api/management/security/users/:userId/groups/:groupIdCsv', {}) | ||
.addOptions(userId, 'userId') | ||
.addOptions(groupIds.join(','), 'groupIdCsv') | ||
.setParams(this.contensisClient.getParams()) | ||
.toUrl(); | ||
return this.contensisClient.ensureAuthenticationToken().then(() => { | ||
return this.httpClient.request(url, { | ||
headers: this.contensisClient.getHeaders(), | ||
method: 'HEAD' | ||
}).then(() => true, () => false); | ||
}); | ||
} | ||
getUser(idOrNameOrEmail) { | ||
@@ -173,0 +154,0 @@ let url = contensis_core_api_1.UrlBuilder.create('/api/management/security/users/:idOrNameOrEmail', {}) |
@@ -201,3 +201,3 @@ "use strict"; | ||
}); | ||
describe('Is user in group', () => { | ||
describe('Is user member of group', () => { | ||
describe('for a positive result', () => { | ||
@@ -213,3 +213,3 @@ beforeEach(() => { | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let result = await client.users.isInGroup(specs_utils_spec_1.defaultUsers[0].id, specs_utils_spec_1.defaultGroups[0].id); | ||
let result = await client.users.userIsMemberOf(specs_utils_spec_1.defaultUsers[0].id, specs_utils_spec_1.defaultGroups[0].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -234,3 +234,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let result = await client.users.isInGroup(specs_utils_spec_1.defaultUsers[0].id, specs_utils_spec_1.defaultGroups[0].id); | ||
let result = await client.users.userIsMemberOf(specs_utils_spec_1.defaultUsers[0].id, specs_utils_spec_1.defaultGroups[0].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -257,3 +257,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let result = await client.users.isInGroups(specs_utils_spec_1.defaultUsers[0].id, [specs_utils_spec_1.defaultGroups[0].id, specs_utils_spec_1.defaultGroups[1].id]); | ||
let result = await client.users.userIsMemberOf(specs_utils_spec_1.defaultUsers[0].id, specs_utils_spec_1.defaultGroups[0].id, specs_utils_spec_1.defaultGroups[1].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -278,3 +278,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let result = await client.users.isInGroups(specs_utils_spec_1.defaultUsers[0].id, [specs_utils_spec_1.defaultGroups[0].id, specs_utils_spec_1.defaultGroups[1].id]); | ||
let result = await client.users.userIsMemberOf(specs_utils_spec_1.defaultUsers[0].id, specs_utils_spec_1.defaultGroups[0].id, specs_utils_spec_1.defaultGroups[1].id); | ||
expect(global.fetch).toHaveBeenCalledTimes(2); | ||
@@ -305,3 +305,3 @@ expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let groups = await client.users.getGroups(specs_utils_spec_1.defaultUsers[0].id); | ||
let groups = await client.users.getUserGroups(specs_utils_spec_1.defaultUsers[0].id); | ||
expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
@@ -318,3 +318,3 @@ expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let groups = await client.users.getGroups({ | ||
let groups = await client.users.getUserGroups({ | ||
userId: specs_utils_spec_1.defaultUsers[0].id, | ||
@@ -321,0 +321,0 @@ includeInherited: true |
{ | ||
"name": "contensis-management-api", | ||
"version": "1.0.0-beta.11", | ||
"version": "1.0.0-beta.12", | ||
"description": "Contensis Javascript Management API", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -13,9 +13,8 @@ import { User } from './User'; | ||
list(options?: UserListOptions): Promise<PagedList<User>>; | ||
getGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
getUserGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>; | ||
create(user: User): Promise<User>; | ||
update(user: User): Promise<User>; | ||
updatePassword(options: UserUpdatePasswordOptions): Promise<void>; | ||
delete(id: string): Promise<void>; | ||
isInGroup(userId: string, groupId: string): Promise<boolean>; | ||
isInGroups(userId: string, groupIds: string[]): Promise<boolean>; | ||
delete(userId: string): Promise<void>; | ||
userIsMemberOf(userId: string, ...groupIdsOrNames: string[]): Promise<boolean>; | ||
} |
@@ -7,6 +7,5 @@ export interface UserCredentials { | ||
active: boolean; | ||
deactivationReason: string; | ||
// deactivationReason: string; | ||
locked: boolean; | ||
passwordExpired: boolean; | ||
passwordExpiry: Date; | ||
} | ||
@@ -18,3 +17,2 @@ | ||
email: string; | ||
title: string; | ||
firstname: string; | ||
@@ -32,5 +30,4 @@ lastname: string; | ||
modified: Date; | ||
activated: Date; | ||
lastLogin: Date; | ||
passwordChanged: Date; | ||
} |
@@ -274,3 +274,3 @@ import * as Contensis from '../index'; | ||
describe('Is user in group', () => { | ||
describe('Is user member of group', () => { | ||
@@ -290,3 +290,3 @@ describe('for a positive result', () => { | ||
let result = await client.users.isInGroup(defaultUsers[0].id, defaultGroups[0].id); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id); | ||
@@ -320,3 +320,3 @@ expect(global.fetch).toHaveBeenCalledTimes(2); | ||
let result = await client.users.isInGroup(defaultUsers[0].id, defaultGroups[0].id); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id); | ||
@@ -352,3 +352,3 @@ expect(global.fetch).toHaveBeenCalledTimes(2); | ||
let result = await client.users.isInGroups(defaultUsers[0].id, [defaultGroups[0].id, defaultGroups[1].id]); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id, defaultGroups[1].id); | ||
@@ -382,3 +382,3 @@ expect(global.fetch).toHaveBeenCalledTimes(2); | ||
let result = await client.users.isInGroups(defaultUsers[0].id, [defaultGroups[0].id, defaultGroups[1].id]); | ||
let result = await client.users.userIsMemberOf(defaultUsers[0].id, defaultGroups[0].id, defaultGroups[1].id); | ||
@@ -416,3 +416,3 @@ expect(global.fetch).toHaveBeenCalledTimes(2); | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let groups = await client.users.getGroups(defaultUsers[0].id); | ||
let groups = await client.users.getUserGroups(defaultUsers[0].id); | ||
@@ -433,3 +433,3 @@ expect((global.fetch as any).calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let groups = await client.users.getGroups({ | ||
let groups = await client.users.getUserGroups({ | ||
userId: defaultUsers[0].id, | ||
@@ -436,0 +436,0 @@ includeInherited: true |
@@ -57,3 +57,3 @@ import { ContensisClient, IUserOperations, User, UserListOptions, Group, UserGroupsOptions, UserUpdatePasswordOptions } from '../models'; | ||
getGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>> { | ||
getUserGroups(userIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>> { | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups', | ||
@@ -163,3 +163,3 @@ { includeInherited: null }) | ||
isInGroup(userId: string, groupId: string): Promise<boolean> { | ||
userIsMemberOf(userId: string, ...groupIdsOrNames: string[]): Promise<boolean> { | ||
if (!userId) { | ||
@@ -169,10 +169,10 @@ throw new Error('A valid users id needs to be specified.'); | ||
if (!groupId) { | ||
throw new Error('A valid group id needs to be specified.'); | ||
if (!groupIdsOrNames || groupIdsOrNames.length === 0) { | ||
throw new Error('At least a valid group id or name needs to be specified.'); | ||
} | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups/:groupId', | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups/:groupIdsOrNamesCsv', | ||
{}) | ||
.addOptions(userId, 'userId') | ||
.addOptions(groupId, 'groupId') | ||
.addOptions(groupIdsOrNames.join(','), 'groupIdsOrNamesCsv') | ||
.setParams(this.contensisClient.getParams()) | ||
@@ -189,26 +189,2 @@ .toUrl(); | ||
isInGroups(userId: string, groupIds: string[]): Promise<boolean> { | ||
if (!userId) { | ||
throw new Error('A valid users id needs to be specified.'); | ||
} | ||
if (!groupIds || groupIds.length === 0) { | ||
throw new Error('At least a valid group id needs to be specified.'); | ||
} | ||
let url = UrlBuilder.create('/api/management/security/users/:userId/groups/:groupIdCsv', | ||
{}) | ||
.addOptions(userId, 'userId') | ||
.addOptions(groupIds.join(','), 'groupIdCsv') | ||
.setParams(this.contensisClient.getParams()) | ||
.toUrl(); | ||
return this.contensisClient.ensureAuthenticationToken().then(() => { | ||
return this.httpClient.request<void>(url, { | ||
headers: this.contensisClient.getHeaders(), | ||
method: 'HEAD' | ||
}).then(() => true, () => false); | ||
}); | ||
} | ||
private getUser(idOrNameOrEmail: string) { | ||
@@ -215,0 +191,0 @@ let url = UrlBuilder.create('/api/management/security/users/:idOrNameOrEmail', {}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
487110
10915