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