@amityco/ts-sdk
Version:
Amity Social Cloud Typescript SDK
176 lines • 6.76 kB
TypeScript
import { AxiosInstance } from 'axios';
import { Emitter } from 'mitt';
import { AmitySharableContentType } from './sharableContentType';
export declare const enum MembershipAcceptanceTypeEnum {
AUTOMATIC = "automatic",
INVITATION = "invitation"
}
export declare enum AmityAutoSubscription {
CHAT = "chat",
NETWORK = "network",
LIVESTREAM = "livestream",
BLOCK = "block"
}
declare global {
namespace Amity {
type Logger = (topic: string, ...args: any[]) => void;
type MembershipAcceptanceType = MembershipAcceptanceTypeEnum;
type AutoSubscription = AmityAutoSubscription;
type AutoSubscriptionState = {
feature: Amity.AutoSubscription;
isActive: boolean;
isSystem: boolean;
topicCount: number;
};
const enum TokenTerminationReason {
GLOBAL_BAN = "globalBan",
USER_DELETED = "userDeleted",
UNAUTHORIZED = "unauthorized"
}
const enum SessionStates {
NOT_LOGGED_IN = "notLoggedIn",
ESTABLISHING = "establishing",
ESTABLISHED = "established",
TOKEN_EXPIRED = "tokenExpired",
TERMINATED = "terminated"
}
type Client = {
version: string;
log: Logger;
http: AxiosInstance;
upload: AxiosInstance;
mqtt?: Amity.MqttClient;
emitter: Emitter<Amity.Events>;
hasPermission: (permission: string) => Amity.PermissionChecker;
validateUrls: (urls: string[]) => Promise<boolean>;
validateTexts: (texts: string[]) => Promise<boolean>;
sessionState: Amity.SessionStates;
sessionHandler?: Amity.SessionHandler;
accessTokenHandler?: Amity.AccessTokenHandler;
cache?: Amity.Cache;
apiKey?: string;
userId?: string;
token?: Amity.Tokens;
isUnreadCountEnabled: boolean;
useLegacyUnreadCount: boolean;
use: () => void;
accessTokenExpiryWatcher: () => Amity.Unsubscriber;
getFeedSettings: () => Promise<Amity.FeedSettings>;
getCoreUserSettings: () => Promise<Amity.CoreUserSettings>;
getSocialSettings: () => Promise<Amity.SocialSettings>;
getChatSettings: () => Promise<Amity.ChatSettings>;
getMessagePreviewSetting: (refresh?: boolean) => Promise<Amity.MessagePreviewSetting>;
getMarkerSyncConsistentMode: () => boolean;
prefixDeviceIdKey?: string;
getVisitorDeviceId: () => Promise<string>;
getProductCatalogueSetting: () => Promise<Amity.ProductCatalogueSetting>;
getForYouFeedSetting: () => Promise<Amity.ForYouFeedSetting>;
loginType?: 'accessToken' | 'userId';
};
type Device = {
deviceId: string;
deviceInfo: {
kind: 'node' | 'web';
model?: string;
sdkVersion: string;
};
};
type Tokens = {
accessToken: string;
issuedAt: string;
expiresAt: string;
};
type SessionResponse = Tokens & {
users: Amity.RawUser[];
userType: Amity.UserType;
files: Amity.File<'image'>[];
};
type AccessTokenRenewal = {
renew: () => void;
renewWithAuthToken: (authToken: string) => void;
unableToRetrieveAuthToken: () => void;
renewWithAuthSignature: ({ authSignature, authSignatureExpiresAt, }: Amity.ConnectClientAsVisitorParams) => void;
unableToRetrieveAuthSignature: () => void;
};
interface SessionHandler {
sessionWillRenewAccessToken(renewal: AccessTokenRenewal): void;
}
interface AccessTokenHandler {
/**
* Called when the token needs renewal (either expired or about to expire)
* @returns Promise resolving to new JWT access token
*/
onTokenRenew(userId: string): Promise<string>;
}
type ChatSettings = {
enabled: boolean;
mention: {
isAllowMentionedChannelEnabled: boolean;
};
messagePreview: {
enabled: boolean;
isIncludeDeleted: boolean;
};
};
type ShareableLinkConfiguration = {
readonly domain: string;
/** @deprecated Use getPattern(contentType) instead. */
readonly patterns: Record<string, string>;
isEnabled(contentType: AmitySharableContentType): boolean;
getPattern(contentType: AmitySharableContentType): string | null;
generateLink(contentType: AmitySharableContentType, referenceId: string): string | null;
};
type FeedSettings = {
[name in Amity.ContentFeedType]?: Amity.ContentSetting[];
};
type SocialSettings = {
enabled: boolean;
isAllowEditPostWhenReviewingEnabled: boolean;
isFollowWithRequestEnabled: boolean;
globalFeed: {
showCommunityPost: boolean;
showEveryonePost: boolean;
showFollowingPost: boolean;
showMyPost: boolean;
showOnlyMyFeed: boolean;
};
story: {
allowAllUserToCreateStory: boolean;
expiryTimeMinutes: number;
};
userPrivacySetting: 'public' | 'private';
membershipAcceptance: Amity.MembershipAcceptanceType;
};
type CoreUserSettings = {
isAllowUpdateDisplayName: boolean;
};
type ProductCatalogueSetting = {
product: {
enabled: boolean;
};
};
type ForYouFeedSetting = {
forYouFeed: {
enabled: boolean;
};
};
type ConnectClientParams = {
userId: Amity.InternalUser['userId'];
displayName?: Amity.InternalUser['displayName'];
authToken?: string;
deviceId?: Amity.Device['deviceId'];
};
type ConnectClientAsVisitorParams = {
authSignature?: string;
authSignatureExpiresAt?: string;
};
type ConnectClientConfig = {
disableRTE: boolean;
};
type ActiveUser = Pick<Amity.InternalUser, '_id' | 'userId' | 'path' | 'displayName'>;
type UserUnread = Pick<Amity.UserMarker, 'unreadCount'> & {
isMentioned: boolean;
};
}
}
//# sourceMappingURL=client.d.ts.map