syntax = "proto3";

package wix.common.spi;

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

option java_multiple_files = true;
option java_package = "com.wix.common";

message SpiBaseUri {
    option (.wix.api.decomposition_minimum_fields) = {
        field: "base_uri"
        field: "alternative_uris"
    };
    message AlternativeUri {
        /*
        Name of the method to create a custom URI for.  
        
        For `methodName`, use the name of the method in PascalCase. 
        For example, for Get Shipping Rates use `GetShippingRates`.
        */
        string method_name = 1 [(.wix.api.minLength) = 3, (.wix.api.maxLength) = 128];
        /*
        Custom URI that Wix uses to call your server for this method. The path-suffix documented in the method will not be appended to this URI. 
        Must be a secured endpoint beginning with `https://`. For example, `https://www.my-shipping-provider.com/my-shipping-rates`.
        */
        string absolute_uri = 2 [(.wix.api.minLength) = 6, (.wix.api.maxLength) = 2048];
    }
    /*
    Base URI where the methods are called. Wix appends the path to the `baseUri`. 
    For example, to call the Get Shipping Rates method at `https://my-shipping-provider.com/v1/getRates`, the base URI you provide here is `https://my-shipping-provider.com/`.
    */
    string base_uri = 1 [(.wix.api.minLength) = 6, (.wix.api.maxLength) = 2048];
    // Alternate, custom URIs to replace the default URIs for specific service plugin methods.
    repeated AlternativeUri alternative_uris = 2;
}

/**
this message is not directly used by any service,
it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.
e.g. SPIs, event-handlers, etc..
NOTE: this context object MUST be provided as the last argument in each Velo method signature.

Example:
```typescript
export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {
  ...
}
```
 */
message Context {
    message IdentificationData {
        option (.wix.api.decomposite_of) = "wix.common.IdentificationData";
        enum IdentityType {
            UNKNOWN = 0;
            ANONYMOUS_VISITOR = 1;
            MEMBER = 2;
            WIX_USER = 3;
            APP = 4;
        }
        reserved 1;
        IdentityType identity_type = 6 [(.wix.api.readOnly) = true];
        oneof id {
            // ID of a site visitor that has not logged in to the site.
            string anonymous_visitor_id = 2 [(.wix.api.format) = GUID];
            // ID of a site visitor that has logged in to the site.
            string member_id = 3 [(.wix.api.format) = GUID, (.wix.api.referenced_entity) = "wix.members.v1.member"];
            // ID of a Wix user (site owner, contributor, etc.).
            string wix_user_id = 4 [(.wix.api.format) = GUID];
            // ID of an app.
            string app_id = 5 [(.wix.api.format) = GUID];
        }
    }
    google.protobuf.StringValue request_id = 1; // A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs.
    google.protobuf.StringValue currency = 2 [(.wix.api.format) = CURRENCY]; // [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.
    IdentificationData identity = 3; // An object that describes the identity that triggered this request.
    repeated string languages = 4; // A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`.
    google.protobuf.StringValue instance_id = 5 [(.wix.api.format) = GUID]; // The service provider app's instance ID.
    google.protobuf.StringValue app_extension_id = 6 [(.wix.api.maxLength) = 256, (wix.api.field_maturity) = ALPHA]; // Extension ID in Dev Center.
    google.protobuf.StringValue app_extension_type = 7 [(.wix.api.maxLength) = 256, (wix.api.field_maturity) = ALPHA]; // Extension type in Dev Center.
    google.protobuf.StringValue function_name = 8 [(.wix.api.maxLength) = 256, (wix.api.field_maturity) = ALPHA]; // Invoked function.

}
