@or-sdk/users
v3.10.2
Published
OneReach SDK client for Users
Readme
@or-sdk/users
OneReach SDK client for Users.
When to use
- Use this package when integrating with the Users capability on the OneReach platform.
- Use its typed client and exported models instead of hand-writing requests to that service.
When not to use
- Do not use it for a different platform capability; choose the dedicated
@or-sdk/*package instead. - Do not use it for generic third-party HTTP calls.
Installation
$ npm i @or-sdk/usersUsage
import { Users } from '@or-sdk/users'
// with direct api url
const users = new Users({
token: 'my-account-token-string',
sdkUrl: 'http://example.sdk-api/endpoint',
usersUrl: 'http://example.users/endpoint'
});
// with service discovery(slower)
const users = new Users({
token: 'my-account-token-string',
discoveryUrl: 'http://example.discovery/endpoint'
});Configuration
- Prefer
sdkUrlwhen the service URL is known; it avoids a discovery request. - Use
discoveryUrlonly when the service URL is not available. - Provide
tokenas a bearer-token string or getter where supported.
Common pitfalls
- Keep the client token current when it can expire; a token getter is preferable where the constructor accepts one.
- Treat the generated TypeScript types as the authoritative contract for optional parameters and response shapes.
Common workflows
const page = await users.listUsers({ from: 0, size: 50, orderProperty: 'email' });
const user = await users.getUserById('user-id', ['email', 'name']);
await users.disableUser(user.id);Use getCurrentUser for the identity represented by the token. listAccounts is restricted
to super administrators; cross-account operations require the corresponding SDK configuration
and authorization.
Complete API reference
All public methods below are taken from the package source. Parameter and return types use the exported TypeScript names; import the corresponding types from this package when constructing requests.
| Method | Returns | Purpose |
|---|---|---|
| makeRequest(params: CalApiParams) | Promise<T> | See the exported TypeScript signature for behavior and constraints. |
| listUsers(params = {} as ListUsersParams) | Promise<ListUsersResult> | List users in account |
| getUserById(userId: GetUserByIdParams['userId'], projection: GetUserByIdParams['projection']) | Promise<User> | Get account user by Id |
| getCurrentMultiUserProfile({ validate }: ValidateParams = { validate: true }) | Promise<CurrentMultiUserProfile> | Get multi-user profile using user token |
| getAccountInfo() | Promise<AccountItem> | Get account info based on given token |
| listAccountProfiles() | Promise<ListAccountProfilesResult> | List account multi-user profiles |
| listProfiles(params: ListProfilesParams) | Promise<ListProfilesResult> | List profiles with ability for partial match by email, username or match by id. |
| listUsersAdvanced(params: ListUsersAdvancedParams) | Promise<UserAdvanced[]> | List users with profile information |
| getProfileByEmail(email: string) | Promise<AccountProfile> | Get profile by email |
| getProfileById(profileId: string) | Promise<Profile> | Get multi-user profile by Id |
| getProfile() | Promise<Profile> | Get profile |
| attachProfile(params: AttachParams) | Promise<AttachResult> | Attach profile. |
| listProfileUsers() | Promise<List<ProfileUserItem>> | List profiles users. |
| getCurrentUser() | Promise<TokenData> | Get current user |
| getUserEmail(userId?: string) | Promise<{ email: string; }> | Get profile email if exists or user email |
| deleteUser(userId: string, accountId?: string) | Promise<void> | Delete a user from account |
| updateUser(userId: string, user: UpdateUserParam, accountId?: string) | Promise<void> | Update user |
| requestForceChangePassword(userId: string, multi?: boolean) | Promise<void> | Request force change password for user |
| disableUser(userId: string, accountId?: string) | Promise<void> | Disable user |
| enableUser(userId: string, accountId?: string) | Promise<void> | Enable user |
| createUserWithMulti(userData: CreateUserWithMultData, accountId = this.targetAccountId) | Promise<CreateUserWithMultResult> | Initiate the creation of the multi-user |
| userListProfileAccounts() | Promise<ProfileAccountItem[]> | List accounts by profile |
| listAccounts(params: ListAccountsParams = {}) | Promise<ListAccountsResult> | List accounts (super admin only) |
| upsertMultiUser(params: UpsertMultiUserParams) | Promise<UpsertMultiUserResult> | Upsert multi-user. |
More detail
Full signatures and exported types are available in src/ and dist/types/.
Exported utility reference
| Function | Returns | Purpose |
|---|---|---|
| okRes(data: JsonBodyType, status = 200) | unknown | Exported utility; see its TypeScript signature for behavior. |
| errorRes(errorMessage: string, status = 500) | unknown | Exported utility; see its TypeScript signature for behavior. |
