Skip to main content

modelith_plugin_protocol/
lib.rs

1#![doc = include_str!("../README.md")]
2
3// Modelith とプラグインの契約。
4// ここで定義した Rust の型が唯一の定義元であり、JSON Schema(`schema/`)と
5// TypeScript の型(`packages/typescript/src/generated/`)はここから生成する。
6// Modelith 本体(ホスト側)とレジストリの CI もこの型・スキーマに依存する。
7// クレートの説明は README.md に書き、crates.io・docs.rs・GitHub で同じものを見せる(README の例は doctest で検証する)。
8
9mod edit;
10mod id;
11mod manifest;
12mod message;
13mod registry;
14mod rules;
15pub mod usage;
16
17pub use edit::{Diagnostic, DiagnosticSeverity, Position, Range, TextEdit};
18pub use id::{PLUGIN_ID_PATTERN, PluginId, PluginIdError};
19pub use manifest::{
20    Command, Contributes, Engines, Exporter, Importer, PaletteItem, Permission, PluginManifest,
21    Runtime, View,
22};
23pub use message::{
24    HostMessage, ModelElement, ModelPort, ModelRelation, ModelSnapshot, NotifyLevel, PluginMessage,
25    PortDirection, RelationKind,
26};
27pub use registry::{Pricing, Publisher, RegistryEntry, RegistryVersion};
28pub use rules::{
29    CountRange, ElementMatch, OneOrMany, RULE_ID_PATTERN, Requirement, Rule, RuleId, RuleIdError,
30    RuleSet,
31};
32pub use usage::{USAGE_SCHEMA_VERSION, UsageReport};
33
34/// このクレートが定義するプラグイン API のバージョン(SDK の MAJOR と同じ値)。
35/// マニフェストの `apiVersion` はこの値と一致しなければならない。
36/// SDK が 1.0.0 未満の間は `"0"` で、互換性を約束しない(modelith の docs/reference/versioning.md)。
37pub const API_VERSION: &str = "0";
38
39#[cfg(feature = "codegen")]
40pub mod generate;
41
42#[cfg(test)]
43mod tests {
44    #[test]
45    fn api_version_matches_crate_major() {
46        // Arrange(バージョン規則: apiVersion = SDK の MAJOR)
47        let major = env!("CARGO_PKG_VERSION_MAJOR");
48        // Act
49        let api_version = super::API_VERSION;
50        // Assert
51        assert_eq!(api_version, major);
52    }
53}