syntax = "proto3";

package com.wixpress.appservice.api;

import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "google/protobuf/struct.proto";
import "components_catalog_common.proto";

/*
 Experimental-WIP: Specifies the app module configuration of business manager module
 */
message DashboardApplicationData {
    //List of bundles to be loaded for your module
    repeated Bundle bundles = 1 [(.wix.api.minSize) = 1];
    //Your module id as defined in business-manager-api
    google.protobuf.StringValue id = 2 [(.wix.api.minLength) = 2, (.wix.api.maxLength) = 64];
    //List of available page components that your module is registering
    repeated PageDashboardApplicationComponent page_components = 3;
    //The default component to load when another app navigates to your module
    google.protobuf.StringValue default_page_component_id = 4;
    //Config section that will be provided to your lazy component and component along with all other properties from business-manager, if your config object will contain topology parameter, you'll be able to benefit from statics override machanism
    AppConfiguration config = 5;
    //Allows an application to declare that when it's opened inside the business-manager without a deeplink the business-manager home should be shown. It currently only affects opening the app from Editor/ADI
    google.protobuf.BoolValue use_home_as_landing_page = 6;
    //If there are some experiments that define if this page should be enabled, list of experiment lists with OR relationship between them, experiments should be in business manager scope
    repeated ExperimentGroupWrapper enabled_by_experiments = 7;
    //If this module should load in absence of any pages, by default this won't run
    google.protobuf.BoolValue load_without_pages = 8;
    //List of hosted component of the application
    repeated HostedComponent components = 9;
}

/*
 Specifes business hosted component configuration
 */
message HostedComponent {
    enum HostContainerId {
        BUSINESS_MANAGER = 0;
        BUSINESS_DASHBOARD_HOST = 1;
        SIDEBAR_FOOTER = 2;
    }
    //A unique id for the component, maps between the host and name
    string id = 1 [(.wix.api.minLength) = 1];
    //The component name used in registerComponentWithModuleParams components can be shared by using the same name but a unique id
    string name = 2 [(.wix.api.minLength) = 1];
    //Permissions required for the component, this is not strictly enforced
    string required_permission = 3;
    //Represents the collection of components where the component will be hosted, get this value from the host provider.
    HostContainerId host_container_id = 4;
    //If there are some experiments that define if this page should be enabled, list of experiment lists with OR relationship between them, experiments should be in business manager scope
    repeated ExperimentGroupWrapper enabled_by_experiments = 5;
    //A URI used to send component error events
    ErrorReporting error_reporting = 6;
}

/*
 Specifes business manager module file bundle
 */
message Bundle {
    //The JavaScript file to load
    string file = 1 [(wix.api.format) = WEB_URL];
    //If there are some experiments that define if this page should be enabled, list of experiment lists with OR relationship between them, experiments should be in business manager scope
    repeated ExperimentGroupWrapper enabled_by_experiments = 2;
    //A alternative debug file for debugging issues
    google.protobuf.StringValue debug_file = 3 [(wix.api.format) = WEB_URL];
}

/*
 Specifies page components for a business manager module
 */
message PageDashboardApplicationComponent {
    //The id of the page
    string id = 1 [(.wix.api.minLength) = 1];
    //The route of the page, the part of the url after /dashboard/{msid}/ (must be unique in the specific application)
    string route = 2 [(.wix.api.minLength) = 1];
    //The name you used to register this component to the ModuleRegistry (must be unique across apps)
    string name = 3 [(.wix.api.minLength) = 1];
    //If there are some experiments that define if this page should be enabled, list of experiment lists with OR relationship between them, experiments should be in business manager scope.
    repeated ExperimentGroupWrapper enabled_by_experiments = 4;
    //Additional routes to the page
    repeated string route_aliases = 5;
}

/*
 Specifies a list of experiments that have AND relationship between them, and OR relationship between each list
 */
message ExperimentGroupWrapper{
    //list of experiments with AND relationship between them, for false value use ! before experiment spec
    repeated string experiments_group = 1 [(.wix.api.minSize) = 1];
}

/*
 Specifies config for topology and config data
 */
message AppConfiguration {
    //A map of topology key to template url
    map<string, string> topology = 1;
    //Config section that will be provided to your lazy component and component along with all other properties from business-manager, if your config object will contain topology parameter
    map<string, string> config_data = 2;
}
