syntax = "proto3";

package com.wixpress.appservice.api;

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

/*
Client Service is a broad category encompassing any value, function, or feature that an application needs. A service is typically a class with a narrow, well-defined purpose. A component is one type of class that can use DI.
 */
message ClientSideService {
  string id = 1 [(wix.api.format) = GUID]; // ID of a  UI service.
  string exported_name = 2 [(wix.api.minLength) = 2, (wix.api.maxLength) = 100]; // Exported name of a service
  Definition definition = 3; // Definition of a service
  Implementation implementation = 4; // Implementation metadata of a service, a service with no runtime definition will be considered as an atom.

  message Definition {
    Npm npm = 1; // Reflecting a service definition using npm package
  }

  message Implementation {
    Npm npm = 1; //  Reflecting a service runtime using npm package
    google.protobuf.StringValue bundle_url = 2 [(wix.api.format) = WEB_URL]; // Bundle URL
    repeated string service_dependencies = 5 [(.wix.api.referenced_entity) = 'wix.devcenter.v1.component', (wix.api.format) = GUID, (.wix.api.maxSize) = 100]; // reference to other client side services
  }

  message Npm {
    string package_name = 1 [(wix.api.minLength) = 2, (wix.api.maxLength) = 100]; // Npm package name
    string package_version = 2  [(wix.api.minLength) = 2, (wix.api.maxLength) = 100]; // Npm semantic version
    google.protobuf.StringValue specifier = 3 [(wix.api.minLength) = 2, (wix.api.maxLength) = 100]; // Package entry point, default to main entry
    google.protobuf.StringValue imported_name = 4 [(wix.api.minLength) = 2, (wix.api.maxLength) = 100]; // Imported name, default to default import
  }
}

