@becomes/cms-cloud-client
Version:
SDK for accessing BCMS Cloud API
81 lines (80 loc) • 3.46 kB
TypeScript
import type { Storage } from '@banez/browser-storage/types';
import type { Throwable } from './throwable';
import type { UserJwt, UserProtected } from '../b-types/user';
import type { ArrayStore } from '@banez/vue-array-store/types';
import type { AxiosRequestConfig } from 'axios';
import { AuthHandler, FeatureHandler, InstanceAdditionalFileHandler, InstanceDepHandler, InstanceDomainHandler, InstanceEnvHandler, InstanceFjeHandler, InstanceHandler, InstancePluginHandler, InstanceProxyConfigHandler, InvitationHandler, LimitHandler, MediaHandler, OrgHandler, SocketHandler, UserHandler, type InstanceFjeWithOptionalCode, ShimHandler, AdminHandler } from './handlers';
import type { InstanceAdditionalFile, InstanceDep, InstanceDomain, InstanceEnv, InstancePlugin, InstanceProtectedWithStatus, InstanceProxyConfig } from '../b-types/instance';
import type { Org } from '../b-types/org';
import type { InvitationProtected } from '../b-types/invitation';
import type { Feature } from '../b-types/feature';
import type { Limit } from '../b-types/limit';
export interface BCMSCloudStore {
instance: ArrayStore<InstanceProtectedWithStatus>;
org: ArrayStore<Org>;
user: ArrayStore<UserProtected, {
me(): UserProtected | null;
}>;
invitation: ArrayStore<InvitationProtected>;
feature: ArrayStore<Feature>;
limit: ArrayStore<Limit>;
instanceAdditionalFile: ArrayStore<InstanceAdditionalFile>;
instanceFje: ArrayStore<InstanceFjeWithOptionalCode>;
instanceDep: ArrayStore<InstanceDep>;
instanceDomain: ArrayStore<InstanceDomain>;
instanceEnv: ArrayStore<InstanceEnv>;
instancePlugin: ArrayStore<InstancePlugin>;
instanceProxyConfig: ArrayStore<InstanceProxyConfig>;
}
export interface Router {
push(options: {
path: string;
replace?: boolean;
}): Promise<any>;
}
export declare class BCMSCloudSdk {
apiOrigin: string;
storage: Storage;
store: BCMSCloudStore;
throwable: Throwable;
router: Router;
private disableSocket?;
accessTokenRaw: string | null;
accessToken: UserJwt | null;
auth: AuthHandler;
user: UserHandler;
org: OrgHandler;
instanceAdditionalFile: InstanceAdditionalFileHandler;
instanceDep: InstanceDepHandler;
instanceDomain: InstanceDomainHandler;
instanceEnv: InstanceEnvHandler;
instanceFje: InstanceFjeHandler;
instance: InstanceHandler;
instancePlugin: InstancePluginHandler;
instanceProxyConfig: InstanceProxyConfigHandler;
media: MediaHandler;
invitation: InvitationHandler;
feature: FeatureHandler;
limit: LimitHandler;
shim: ShimHandler;
admin: AdminHandler;
socket: SocketHandler;
private refreshQueue;
constructor(apiOrigin: string, storage: Storage, store: BCMSCloudStore, throwable: Throwable, router: Router, disableSocket?: boolean | undefined);
private unpackAccessToken;
clearAndLogout(): Promise<void>;
/**
* Will try to refresh the Access Token. If Access Token
* is still valid, it will not be refreshed.
*/
refreshAccessToken(force?: boolean): Promise<boolean>;
/**
* Check if User is logged in. If this method returns `false`,
* called to protected resources will fail and User will be
* redirected to defined login path.
*/
isLoggedIn(): Promise<boolean>;
send<Result = unknown>(conf: AxiosRequestConfig & {
doNotAuth?: boolean;
}): Promise<Result>;
}