modelith-plugin-protocol 0.1.0

Contract between Modelith and its plugins: manifest, registry entry, rule set, edit and message types
Documentation
#![doc = include_str!("../README.md")]

// Modelith とプラグインの契約。
// ここで定義した Rust の型が唯一の定義元であり、JSON Schema(`schema/`)と
// TypeScript の型(`packages/typescript/src/generated/`)はここから生成する。
// Modelith 本体(ホスト側)とレジストリの CI もこの型・スキーマに依存する。
// クレートの説明は README.md に書き、crates.io・docs.rs・GitHub で同じものを見せる(README の例は doctest で検証する)。

mod edit;
mod id;
mod manifest;
mod message;
mod registry;
mod rules;
pub mod usage;

pub use edit::{Diagnostic, DiagnosticSeverity, Position, Range, TextEdit};
pub use id::{PLUGIN_ID_PATTERN, PluginId, PluginIdError};
pub use manifest::{
    Command, Contributes, Engines, Exporter, Importer, PaletteItem, Permission, PluginManifest,
    Runtime, View,
};
pub use message::{
    HostMessage, ModelElement, ModelPort, ModelRelation, ModelSnapshot, NotifyLevel, PluginMessage,
    PortDirection, RelationKind,
};
pub use registry::{Pricing, Publisher, RegistryEntry, RegistryVersion};
pub use rules::{
    CountRange, ElementMatch, OneOrMany, RULE_ID_PATTERN, Requirement, Rule, RuleId, RuleIdError,
    RuleSet,
};
pub use usage::{USAGE_SCHEMA_VERSION, UsageReport};

/// このクレートが定義するプラグイン API のバージョン(SDK の MAJOR と同じ値)。
/// マニフェストの `apiVersion` はこの値と一致しなければならない。
/// SDK が 1.0.0 未満の間は `"0"` で、互換性を約束しない(modelith の docs/reference/versioning.md)。
pub const API_VERSION: &str = "0";

#[cfg(feature = "codegen")]
pub mod generate;

#[cfg(test)]
mod tests {
    #[test]
    fn api_version_matches_crate_major() {
        // Arrange(バージョン規則: apiVersion = SDK の MAJOR)
        let major = env!("CARGO_PKG_VERSION_MAJOR");
        // Act
        let api_version = super::API_VERSION;
        // Assert
        assert_eq!(api_version, major);
    }
}