@omnia/fx-models
Version:
Provide Omnia Fx Models Stuffs.
115 lines (114 loc) • 4.26 kB
TypeScript
import { IUrlHash, IUrlQuerystring, IUrlPath, AppRoute, GuidValue, Theming, IBusinessProfile, IMessageBusTopicSubscription, HttpHeaders, IOmniaPropertyBag, ITenant, OmniaServiceManifests, TenantWithProperties } from '.';
import { AxiosResponse } from 'axios';
import { BusinessProfileWithProperties } from './BusinessProfile';
import { AppRoutePropertyBagModel, AppRouteWithProperties, ITokenBasedUrlPath } from './Routing';
import { MailboxSettings, UserPropertyBagModel } from './User';
import { Guid } from './Guid';
export interface OmniaBootstrapData {
manifests: OmniaServiceManifests;
enviroment: OmniaEnvironmentContext;
user: OmniaUserContext;
language: string;
serviceDnsMapping: OmniaServiceToDnsMapping;
customDomain?: string;
defaultDomain: string;
theming: Theming;
businessProfile: BusinessProfileWithProperties;
tenant: TenantWithProperties;
activatedFeatures: Guid[];
}
export interface OmniaServiceToDnsMapping {
[serviceId: string]: string;
}
export interface OmniaEnvironmentContext {
omniaApp: boolean;
}
export interface OmniaTenantContext {
tenantId: string;
profileId: string;
}
export interface AppInstanceContext {
appRouteWithProperties: AppRouteWithProperties;
businessProfileWithProperties: BusinessProfileWithProperties;
activatedFeatures: Guid[];
}
export interface OmniaUserContext {
id: string;
loginName: string;
mailboxSettings: MailboxSettings;
readonly propertyBag: IOmniaPropertyBag<UserPropertyBagModel>;
}
export interface OmniaTokenContext {
omniaToken: Promise<void>;
}
export interface IAppRouteContext {
readonly appRoute: AppRoute;
readonly propertyBag: IOmniaPropertyBag<AppRoutePropertyBagModel>;
}
/**
* Provides filtered Routing Context based on Router implementation
*/
export interface IRouteContext {
path: IUrlPath;
querystring: IUrlQuerystring;
hash: IUrlHash;
state?: any;
readonly appInstanceContext?: AppInstanceContext;
}
export interface TokenBasedRouteStateData {
}
export interface TokenBasedRoute {
}
export interface ITokenBasedRouteContext<T1 extends TokenBasedRoute, T2 extends TokenBasedRouteStateData> {
readonly path: ITokenBasedUrlPath;
readonly route: T1;
readonly stateData: T2;
}
export interface AdminRoute extends TokenBasedRoute {
manifestId: GuidValue;
relativePath: string;
}
export interface BusinessProfileRoute extends TokenBasedRoute {
profileId: GuidValue;
}
export interface IContextProvider<T> extends IContextProviderHttpActions {
getProviderUniqueId: () => string;
getSerializeableContextRepresentation: () => Promise<any>;
createFromContextRepresentation: (contextRepresentation: any) => void;
getContext: () => T;
}
export interface IMutableContextProvider<T extends IMutableContext<T>> extends IContextProvider<T> {
getMutableContext: () => IMutableContext<T>;
}
export interface IOmniaContext extends IMutableContext<IOmniaContext> {
language: string;
environment: OmniaEnvironmentContext;
businessProfile: IBusinessProfile;
tenant: ITenant;
theming: Theming;
user: Promise<OmniaUserContext>;
tokens: OmniaTokenContext;
activatedFeatures: Guid[];
customDomain?: string;
defaultDomain: string;
}
export interface IMutableContext<T> {
onContextChanged: () => IMessageBusTopicSubscription<T>;
}
export interface IContextProviderHttpActions {
/**
* This type of headers may be encoded in the http request to avoid preflight etc
*
* These headers should match the serverside headers used in middleware to create context
* */
getContextHttpHeaders: () => Promise<HttpHeaders>;
/**
* These headers will be passed normally, take care not to add custom headers triggering preflight
* */
getHttpHeaders: () => Promise<HttpHeaders>;
/**
* A hook used to analyse responses for any error related to context, i.e. refresh needed etc
* (If context error make sure the context is refreshed, and pass back true)
* */
shouldRetryHttpRequest: (httpResponse: AxiosResponse<any>) => Promise<boolean>;
}