apcore_toolkit/lib.rs
1// All-caps acronyms (AIEnhancer, HTTPProxy*, YAML*, JSON*) are intentional:
2// these names match the Python and TypeScript SDK public surfaces for cross-language
3// parity. Clippy's C-CASE recommendation is waived for this crate.
4#![allow(clippy::upper_case_acronyms)]
5
6//! apcore-toolkit — Shared scanner, schema extraction, and output toolkit.
7//!
8//! Rust implementation — tri-language parity with Python and TypeScript.
9//!
10//! The crate version is exported as [`VERSION`] to match the `__version__`
11//! / `VERSION` symbols in the Python and TypeScript SDKs.
12//!
13//! # Language-writer parity note
14//!
15//! Python ships [`PythonWriter`] and TypeScript ships [`TypeScriptWriter`]
16//! for generating language-specific binding code. The Rust SDK intentionally
17//! does **not** ship a `RustWriter`: Rust consumers import `apcore-toolkit`
18//! directly and work with the strongly-typed `ScannedModule` / registry APIs
19//! instead of generating source files. This parity gap is intentional and
20//! will not be filled in future releases.
21//!
22//! [`PythonWriter`]: https://github.com/aiperceivable/apcore-toolkit-python
23//! [`TypeScriptWriter`]: https://github.com/aiperceivable/apcore-toolkit-typescript
24//!
25//! # Crate-root re-exports
26//!
27//! The HTTP verb helpers and `SCANNER_VERB_MAP` are exported directly at
28//! the crate root. As of v0.5.0 they are no longer re-exported through the
29//! `scanner` module path — import from the crate root or `http_verb_map`:
30//!
31//! ```
32//! use apcore_toolkit::{generate_suggested_alias, has_path_params, resolve_http_verb, SCANNER_VERB_MAP};
33//!
34//! assert_eq!(resolve_http_verb("POST", false), "create");
35//! assert!(has_path_params("/tasks/{id}"));
36//! assert_eq!(SCANNER_VERB_MAP.get("POST").copied(), Some("create"));
37//! assert_eq!(
38//! generate_suggested_alias("/tasks/user_data", "POST"),
39//! "tasks.user_data.create"
40//! );
41//! ```
42
43/// Crate version, read from `Cargo.toml` at compile time.
44///
45/// Mirrors Python's `apcore_toolkit.__version__` and TypeScript's
46/// `VERSION` export so all three SDKs expose the current toolkit version
47/// via a public symbol.
48pub const VERSION: &str = env!("CARGO_PKG_VERSION");
49
50pub mod ai_enhancer;
51pub mod binding_loader;
52pub mod display;
53pub mod formatting;
54pub mod http_verb_map;
55pub mod openapi;
56pub mod output;
57pub mod resolve_target;
58pub mod scanner;
59pub mod schema_utils;
60pub mod serializers;
61pub mod types;
62
63// Re-export primary types at crate root for convenience.
64pub use ai_enhancer::{AIEnhancer, AIEnhancerError, Enhancer};
65pub use binding_loader::{BindingLoadError, BindingLoader};
66pub use display::{DisplayResolver, DisplayResolverError};
67pub use formatting::{
68 format_csv, format_jsonl, format_module, format_modules, format_schema, to_markdown,
69 FormatError, FormatOutput, GroupBy, MarkdownError, MarkdownOptions, ModuleStyle, SchemaStyle,
70};
71pub use http_verb_map::{
72 extract_path_param_names, generate_suggested_alias, has_path_params, resolve_http_verb,
73 substitute_path_params, SCANNER_VERB_MAP,
74};
75pub use openapi::{
76 deep_resolve_refs, extract_input_schema, extract_output_schema, resolve_ref, resolve_schema,
77};
78pub use output::errors::WriteError;
79pub use output::registry_writer::{HandlerFactory, HandlerFn, RegistryWriter};
80pub use output::types::{Verifier, VerifyResult, WriteResult};
81pub use output::verifiers::{
82 run_verifier_chain, JSONVerifier, MagicBytesVerifier, RegistryVerifier, SyntaxVerifier,
83 YAMLVerifier,
84};
85pub use output::yaml_writer::YAMLWriter;
86pub use output::{get_writer, InvalidFormatError, OutputFormat};
87pub use resolve_target::{resolve_target, ResolveTargetError, ResolvedTarget};
88pub use scanner::{deduplicate_ids, filter_modules, infer_annotations_from_method, BaseScanner};
89pub use schema_utils::enrich_schema_descriptions;
90pub use serializers::{annotations_to_dict, module_to_dict, modules_to_dicts};
91pub use types::{clone_module, create_scanned_module, ScannedModule};
92
93#[cfg(feature = "http-proxy")]
94pub use output::http_proxy_writer::{HTTPProxyRegistryWriter, HTTPProxyRegistryWriterError};