UNPKG

@omnia/fx-models

Version:
153 lines (152 loc) • 5.79 kB
import { IUrlHash, IUrlQuerystring, IUrlPath, AppRoute, GuidValue, Theming, IBusinessProfile, IMessageBusTopicSubscription, HttpHeaders, IOmniaPropertyBag, ITenant, OmniaServiceManifests, TenantWithProperties, UserWithProperties, RollupFilterComponentState, LoadableBundleManifest, UserWithPropertyBag, FilterEngineRouterState } from "."; import { AxiosResponse } from "axios"; import { BusinessProfileWithProperties } from "./BusinessProfile"; import { AppRoutePropertyBagModel, AppRouteWithProperties, ITokenBasedUrlPath, IAppRoute } from "./Routing"; import { Guid, OmniaSharedBootstrapData, OmniaToken } from "@omnia/fx-models/internal-do-not-import-from-here/shared/models"; import { BundleTargetTypes, OmniaBackendRuntimes, OmniaClientRuntimes } from "./Enums"; export interface OmniaBootstrapData extends OmniaSharedBootstrapData { manifests: OmniaServiceManifests; enviroment: OmniaEnvironmentContext; user: UserWithProperties; theming: Theming; businessProfile: BusinessProfileWithProperties; tenant: TenantWithProperties; appRoute: AppRouteWithProperties; activatedFeatures: Guid[]; localization: { [key: string]: {}; }; runtime?: OmniaRuntimeConfiguration; } export interface ILoadManifestResourceProvider { getBundleUrl(manifest: LoadableBundleManifest, bundleType: BundleTargetTypes): string; } export interface OmniaRuntimeConfiguration { enableSettingsService?: boolean; enableAppRoute?: boolean; enableTheming?: boolean; enableMultilingual?: boolean; enableWorker?: boolean; loadableManifestProvider?: ILoadManifestResourceProvider; blockedManifest?: { omniaServiceId: GuidValue; resourceId: GuidValue; }[]; } declare global { interface Window { omnia: OmniaBootstrapData; } } declare global { var omnia: OmniaSharedBootstrapData; } export interface OmniaEnvironmentContext { readonly isOmniaApp: boolean; clientRuntime: OmniaClientRuntimes; backendRuntime: OmniaBackendRuntimes; isBackendSharePointServer: boolean; isBackendM365: boolean; } export interface OmniaTenantContext { tenantId: string; profileId: string; } export interface AppInstanceContext { appRouteWithProperties: AppRouteWithProperties; businessProfileWithProperties: BusinessProfileWithProperties; activatedFeatures: Guid[]; } export interface OmniaTokenContext { omniaToken: Promise<OmniaToken>; } 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; appRoute: IAppRoute; tenant: ITenant; theming: Theming; user: Promise<UserWithPropertyBag>; tokens: OmniaTokenContext; activatedFeatures: Guid[]; customDomain?: string; defaultDomain: string; routePrefixes: 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>; } export interface RollupFilterRoute extends TokenBasedRoute { rollupFilterComponentStates: Array<RollupFilterComponentState>; } export interface FilterEngineRoute extends TokenBasedRoute { filterEngineStates: Array<FilterEngineRouterState>; } export interface IContextProviderCollection { getContextHttpHeaders: () => Promise<HttpHeaders>; getHttpHeaders: () => Promise<HttpHeaders>; getSerializedContextRepresentation: () => Promise<string>; createFromContextRepresentation: (serializedContextRepresentation: string) => void; shouldRetryHttpRequest: (httpResponse: AxiosResponse<any>) => Promise<boolean>; } export interface AnchorLinkRoute extends TokenBasedRoute { id: string; anchorPath: string; }