// Copyright 2016 The Closure Rules Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package closure;

option java_package = "io.bazel.rules.closure";

// Information produced by JsChecker about a single JS library rule.
//
// This data structure allows JsChecker to propagate information up the build
// graph to other JsChecker and JsCompiler invocations. Some of this
// information is extracted from the abstract syntax tree of sources.
message ClosureJsLibrary {

  // Canonical build target for this rule,
  // e.g. @io_bazel_rules_closure//closure/library
  string label = 1;

  // Indicates if this proto was outputted by a legacy rule, e.g. js_library.
  // This helps JsCompiler know which source files in the transitive closure
  // should be treated with greater leniency.
  bool legacy = 2;

  // JavaScript namespaces provided by this rule. This field is used to
  // determine what things srcs in parent closure_js_library rules are allowed
  // to include or require. A namespace can either be a Google namespace,
  // e.g. goog:goog.dom, or it can be an ES6 module namespace,
  // e.g. some/es6/module/path. ES6 module names are created by stripping off
  // the longest root prefix and extension suffix from the Bazel path. How
  // roots are determined is documented by the find_js_module_roots() function.
  // If a source file contains a goog.provide() or goog.module() statement,
  // then it's not included in this list as an ES6 module name.
  repeated string namespace = 3;

  // DiagnosticType keys that JsChecker wants to propagate up to JsCompiler.
  // This will not include codes that JsChecker was solely responsible for
  // checking, e.g. linting. This also does not necessarily map to the values
  // in the suppress attribute of closure_js_library, which is permitted to
  // have DiagnosticGroup names. Those values are expanded into their
  // DiagnosticType keys before being written to this field.
  repeated string suppress = 4;

  // Canonical ES6 module name of all srcs. This field is used by JsCompiler so
  // it can map Bazel source paths back to the ClosureJsLibrary proto that
  // originated it, even across Bazel repositories. This field is almost
  // identical to the namespace field, except it includes ES6 module names for
  // files that declare Google namespaces. Even though these names can be short
  // and arbitrary---depending on how repositories are configured and whether
  // or not the includes attribute is being used---they can still be used as a
  // key lookup for this proto because closure_js_library guarantees they're
  // unique within any transitive closure.
  repeated string module = 5;
}
