@allthings/sdk
Version:
Allthings Node/Javascript SDK
168 lines (167 loc) • 7.71 kB
TypeScript
import { EntityResultList, EnumLocale, IAllthingsRestClient } from '../types';
import { UtilisationPeriodResult, UtilisationPeriodResults } from './utilisationPeriod';
export declare enum EnumGender {
female = "female",
male = "male"
}
export declare enum EnumUserType {
allthingsUser = "allthings_user",
allthingsContent = "allthings_content",
customer = "customer",
demoContent = "demo_content",
demoPublic = "demo_public",
partner = "partner"
}
export declare enum EnumCommunicationPreferenceChannel {
push = "push",
email = "email"
}
export interface IExternalData {
dataSource: string;
externalId: string;
name?: string;
phoneNumber?: string;
}
export interface IUser {
readonly communicationPreferences: readonly {
readonly channels: readonly EnumCommunicationPreferenceChannel[];
readonly event: string;
}[];
readonly createdAt: string;
readonly deletionRequestedAt: string | null;
readonly description: string;
readonly email: string;
readonly emailValidated: boolean;
readonly externalAgentsData: IExternalData[] | null;
readonly externalId: string | null;
readonly externalTenantsData: IExternalData[] | null;
readonly gender: EnumGender;
readonly id: string;
readonly inviteEmailSent: boolean;
readonly lastLogin: string | null;
readonly locale: EnumLocale;
readonly nativeAppInstallIds: readonly string[] | null;
readonly passwordChanged: boolean;
readonly phoneNumber: string | null;
readonly profileImage: string | null;
readonly properties: readonly string[] | null;
readonly publicProfile: boolean;
readonly readOnly: boolean;
readonly receiveAdminNotifications: boolean;
readonly roles: readonly string[];
readonly tenantIds: {
readonly [key: string]: string;
};
readonly type: EnumUserType | null;
readonly username: string;
}
export type PartialUser = Partial<IUser>;
export type UserResult = Promise<IUser>;
export type UserResultList = EntityResultList<IUser>;
export declare enum EnumUserPermissionRole {
appAdmin = "app-admin",
appOwner = "app-owner",
articlesAgent = "articles-agent",
articlesViewOnly = "articles-view-only",
bookableAssetAgent = "bookable-asset-agent",
bookingAgent = "booking-agent",
cockpitManager = "cockpit-manager",
dataConnectorAdmin = "data-connector-admin",
documentAdmin = "doc-admin",
externalAgent = "external-agent",
globalOrgAdmin = "global-org-admin",
globalUserAdmin = "global-user-admin",
orgAdmin = "org-admin",
orgTeamManager = "org-team-manager",
pinboardAgent = "pinboard-agent",
platformOwner = "platform-owner",
qa = "qa",
serviceCenterAgent = "service-center-agent",
serviceCenterManager = "service-center-manager",
setup = "setup",
tenantManager = "tenant-manager"
}
export declare enum EnumUserPermissionObjectType {
app = "App",
group = "Group",
property = "Property",
unit = "Unit"
}
export interface IUserPermission {
readonly endDate?: Date;
readonly id: string;
readonly label: string;
readonly objectId: string;
readonly objectType: EnumUserPermissionObjectType;
readonly restricted: boolean;
readonly restrictions: readonly object[];
readonly role: string;
readonly startDate?: Date;
}
export type PartialUserPermission = Partial<IUserPermission>;
export type UserPermissionResult = Promise<IUserPermission>;
export declare const remapEmbeddedUser: (embedded: {
readonly [key: string]: any;
}) => readonly IUser[];
export type MethodUserCreate = (appId: string, username: string, data: PartialUser & {
readonly email: string;
readonly locale: EnumLocale;
readonly plainPassword?: string;
}) => UserResult;
export declare function userCreate(client: IAllthingsRestClient, appId: string, username: string, data: PartialUser & {
readonly email: string;
readonly locale: EnumLocale;
readonly plainPassword?: string;
}): UserResult;
export type MethodGetUsers = (page?: number, limit?: number, filter?: Record<string, any>) => UserResultList;
export declare function getUsers(client: IAllthingsRestClient, page?: number, limit?: number, filter?: {}): UserResultList;
export type MethodGetCurrentUser = () => UserResult;
export declare function getCurrentUser(client: IAllthingsRestClient): UserResult;
export type MethodUserGetById = (id: string) => UserResult;
export declare function userGetById(client: IAllthingsRestClient, userId: string): UserResult;
export type MethodUserUpdateById = (userId: string, data: PartialUser) => UserResult;
export declare function userUpdateById(client: IAllthingsRestClient, userId: string, data: PartialUser): UserResult;
export type MethodUserCreatePermission = (userId: string, permission: PartialUserPermission & {
readonly endDate?: Date;
readonly objectId: string;
readonly objectType: EnumUserPermissionObjectType;
readonly restrictions: readonly object[];
readonly role: EnumUserPermissionRole;
readonly startDate?: Date;
}) => UserPermissionResult;
export declare function userCreatePermission(client: IAllthingsRestClient, userId: string, data: PartialUserPermission & {
readonly endDate?: Date;
readonly objectId: string;
readonly objectType: EnumUserPermissionObjectType;
readonly restrictions: readonly object[];
readonly role: EnumUserPermissionRole;
readonly startDate?: Date;
}): UserPermissionResult;
export type MethodUserCreatePermissionBatch = (userId: string, permissions: PartialUserPermission & {
readonly endDate?: Date;
readonly objectId: string;
readonly objectType: EnumUserPermissionObjectType;
readonly restrictions: readonly object[];
readonly roles: readonly EnumUserPermissionRole[];
readonly startDate?: Date;
}) => Promise<boolean>;
export declare function userCreatePermissionBatch(client: IAllthingsRestClient, userId: string, permissions: PartialUserPermission & {
readonly endDate?: Date;
readonly objectId: string;
readonly objectType: EnumUserPermissionObjectType;
readonly restrictions: readonly object[];
readonly roles: readonly EnumUserPermissionRole[];
readonly startDate?: Date;
}): Promise<boolean>;
export type MethodUserGetPermissions = (userId: string) => Promise<readonly IUserPermission[]>;
export declare function userGetPermissions(client: IAllthingsRestClient, userId: string): Promise<readonly IUserPermission[]>;
export type MethodUserDeletePermission = (permissionId: string) => Promise<boolean>;
export declare function userDeletePermission(client: IAllthingsRestClient, permissionId: string): Promise<boolean>;
export type MethodUserGetUtilisationPeriods = (userId: string) => UtilisationPeriodResults;
export declare function userGetUtilisationPeriods(client: IAllthingsRestClient, userId: string): UtilisationPeriodResults;
export type MethodUserCheckInToUtilisationPeriod = (userId: string, utilisationPeriodId: string) => UtilisationPeriodResults;
export declare function userCheckInToUtilisationPeriod(client: IAllthingsRestClient, userId: string, utilisationPeriodId: string): UtilisationPeriodResult;
export type MethodUserGetByEmail = (email: string) => UserResultList;
export declare function userGetByEmail(client: IAllthingsRestClient, email: string, page?: number, limit?: number): UserResultList;
export type MethodUserChangePassword = (userId: string, currentPassword: string, newPassword: string) => Promise<boolean>;
export declare function userChangePassword(client: IAllthingsRestClient, userId: string, currentPassword: string, newPassword: string): Promise<boolean>;