// Copyright 2020-2026 Buf Technologies, Inc.
//
// 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 buf.alpha.breaking.v1;

// Config represents the breaking change configuration for a module. The rule and category IDs are defined
// by the version and apply across the config. The version is independent of the version of
// the package. The package version refers to the config shape, the version encoded in the Config message
// indicates which rule and category IDs should be used.
//
// The rule and category IDs are not encoded as enums in this package because we may want to support custom rule
// and category IDs in the future. Callers will need to resolve the rule and category ID strings.
message Config {
  // version represents the version of the breaking change rule and category IDs that should be used with this config.
  string version = 1;
  // use_ids lists the rule and/or category IDs that are included in the breaking change check.
  repeated string use_ids = 2;
  // except_ids lists the rule and/or category IDs that are excluded from the breaking change check.
  repeated string except_ids = 3;
  // ignore_paths lists the paths of directories and/or files that should be ignored by the breaking change check.
  // All paths are relative to the root of the module.
  repeated string ignore_paths = 4;
  // ignore_id_paths is a map of rule and/or category IDs to directory and/or file paths to exclude from the
  // breaking change check. This corresponds with the ignore_only configuration key.
  repeated IDPaths ignore_id_paths = 5;
  // ignore_unstable_packages ignores packages with a last component that is one of the unstable forms recognised
  // by the PACKAGE_VERSION_SUFFIX:
  //   v\d+test.*
  //   v\d+(alpha|beta)\d+
  //   v\d+p\d+(alpha|beta)\d+
  bool ignore_unstable_packages = 6;
}

// IDPaths represents a rule or category ID and the file and/or directory paths that are ignored for the rule.
message IDPaths {
  string id = 1;
  repeated string paths = 2;
}
