import { ClientManifestTypes, BundleTargetTypes, RuleLogicalOperator, ManifestLoadStatus, OmniaClientRuntimes, OmniaBackendRuntimes } from "./Enums";
import { WebComponentDefinition } from "./ComponentComposer";
import { GuidValue } from "@omnia/fx-models/internal-do-not-import-from-here/shared/models";
import { OmniaNamedModel } from ".";
export interface OmniaManifests {
    webcomponent: Array<WebComponentBundleManifest>;
    resource: Array<ResourcesBundleManifest>;
    groupedResouresAndComponents: Array<GroupedBundleManifest>;
    blockedManifest: Array<BlockedBundleManifest>;
    configuration: Array<any>;
}
export interface OmniaServiceManifests {
    [omniaServiceId: string]: OmniaManifests;
}
export interface ClientManifest {
    manifestType: ClientManifestTypes;
}
export interface RegiterApiConfiguration {
    disableAutoLoadingManifests?: boolean;
}
export interface BundleIdentity {
    /**
        The unique id of the manifest, this will be the id of the resources added.
    */
    resourceId: string;
    /**
        The unique id of the omnia service to which the resource id belong.
    */
    omniaServiceId: string;
}
export interface BundleManifest extends ClientManifest, BundleIdentity {
    /**
    The friendly name of the manifest
    */
    resourceName?: string;
    /**
    Whether the manifest is available in AuthDisabled route
    */
    authDisabled?: boolean;
}
export interface ClientManifestByTypeCollection {
    [manifestType: string]: Array<ClientManifest>;
}
export interface ManifestLoadResult {
    manifest: LoadableBundleManifest;
    status: ManifestLoadStatus;
}
export interface LoadableBundleManifest extends BundleManifest, ManifestSupportingCombinedLoadRules {
    version: {
        [bundleType: string]: string;
    };
    dependingOnManifests: Array<BundleIdentity>;
    availableBundleTargetTypes: Array<BundleTargetTypes>;
}
export interface ApiBundleManifest {
    api?: string[];
    extendApi?: string[];
    extendApiRules?: Array<ClientResolvableLoadRule>;
    extendApiConfiguration?: {
        [api: string]: any;
    };
    registerApiConfiguration?: {
        [api: string]: RegiterApiConfiguration;
    };
}
export interface SecurityBundleManifest {
    /**
     whether the resource manifest has the authentication disabled (used in non login routes, e.g. Login/OnBoarding)
     */
    authDisabled?: boolean;
}
export interface ResourcesBundleManifest extends LoadableBundleManifest, ApiBundleManifest, SecurityBundleManifest {
}
export interface WebComponentBundleManifest extends LoadableBundleManifest, ApiBundleManifest, SecurityBundleManifest {
    /** The name for this component, this should be a none conflicting name
        e.g. use project as prefix myuniqueprojectname-componentName.
        i.e. <myuniqueprojectname-componentName></myuniqueprojectname-componentName> */
    elementName: string;
    definition: WebComponentDefinition;
}
export interface GroupedBundleManifest extends LoadableBundleManifest, SecurityBundleManifest {
    /** The manifest id's in this group */
    manifestIdsInGroup: Array<string>;
}
export interface BlockedBundleManifest extends BundleIdentity, ClientManifest {
}
/**
    Rule applied client side
    The rule is related to a manifest being loaded, if the rule matches
    a manifest being loaded, the manifest attached to this rule will also load.

    (Note: make as restrictive rules as possible, only match when truly needed, think performance)
*/
export interface LoadIfManifestLoaded extends BundleIdentity, CombinableLoadRule {
}
/**
    Rules applied clientside
    Every rule is compared to the current server relative url of the page

    (Note: make as restrictive rules as possible, only match when truly needed, think performance)
*/
export interface LoadByUrlMatchingRule extends CombinableLoadRule {
    /**
        For all urls starting with e.g. / <- from and rest of path,
        /site1/page2 etc
    */
    startsWith?: string;
    /**
        Loaded if regEx matches current serverrelative path

        Example url:https://somthing.sharepoint.com/sites/test-pub?debug=true&play=true
        Rule:  regEx = regEx: ".*?(play=true)"
        Result: Loads if url contains "play=true"
    */
    regEx?: string;
}
export interface CombinableLoadRule {
}
export interface ClientResolvableLoadRule {
    rule: CombinableLoadRule;
    logicalOperator: RuleLogicalOperator;
    resolver?: () => Promise<boolean>;
}
export interface ManifestSupportingCombinedLoadRules {
    combinedLoadRules: Array<ClientResolvableLoadRule>;
}
/**
    Rules applied clientside
    Every rule is executed and matched against the DOM
    (Note: make as restrictive rules as possible, only match when truly needed, think performance)
*/
export interface DomMatchingRule extends CombinableLoadRule {
    /**
        Loaded if an element is found which matches this selector.
        see: https://www.w3schools.com/cssref/css_selectors.asp

    */
    cssSelector: string;
}
/**
    Rules applied clientside
    Every rule is matched against the enabled features
    (Note: make as restrictive rules as possible, only match when truly needed, think performance)
*/
export interface FeatureActiveRule extends CombinableLoadRule {
    /**
        The id of the feature which should be active
    */
    featureId: GuidValue;
}
/**
    Rules applied clientside
    Every rule is matched against licenses
    (Note: make as restrictive rules as possible, only match when truly needed, think performance)
*/
export interface LicenseRule extends CombinableLoadRule {
    /**
        The id of the license
    */
    licenseId: GuidValue;
}
export interface ClientRuntimeRule extends CombinableLoadRule {
    clientRuntimeTypes: Array<OmniaClientRuntimes>;
}
export interface BackendRuntimeRule extends CombinableLoadRule {
    backendRuntimeTypes: Array<OmniaBackendRuntimes>;
}
/**
    Rules applied clientside
    Every rule is matched against user properties
    (Note: make as restrictive rules as possible, only match when truly needed, think performance)
*/
export interface UserMatchingRule extends CombinableLoadRule {
    /**
        name of user property
        ex: name, email,etc...
    */
    userPropertyName: string;
    value: any;
    userPropertyBagModel?: OmniaNamedModel;
}
