mod abi;
pub mod calendar_sync;
pub mod channel;
pub mod chatops;
pub mod connector;
mod context;
pub mod core;
mod error;
pub mod host;
mod persistent;
mod registry;
#[cfg(not(target_arch = "wasm32"))]
pub mod testing;
#[doc(hidden)]
pub use abi::{sdk_alloc, sdk_dealloc};
pub use context::{
Action, ActionField, ActionOutcome, ActionRequest, ActionResult, Actor, ContextBlock, ContextRequest,
ContextResult, Field, FieldOption, FieldSpec, TicketRef, FIELD_DATE, FIELD_MULTISELECT, FIELD_NUMBER,
FIELD_SELECT, FIELD_TEXT, FIELD_TEXTAREA, RICH_TEXT_FORMAT_JIRA_WIKI, RICH_TEXT_FORMAT_MARKDOWN,
};
pub use error::{code, HostError, OpError};
pub use host::{
core_call, get_config, http_fetch, http_upload, kv_delete, kv_get, kv_list, kv_set, log, oauth_fetch,
richtext_to_jira_wiki, richtext_to_markdown, self_info, ws_send, HttpRequest, HttpResponse, OAuthFetchRequest,
SelfInfo, UploadRequest,
};
pub use persistent::{
PersistentConnectRequest, PersistentConnectResult, PersistentReceiveRequest, PersistentReceiveResponse,
PersistentReceiveResult,
};
pub use registry::{Descriptor, Registry, ABI_VERSION};
#[doc(hidden)]
pub use registry::{describe_call, handle_call};
#[macro_export]
macro_rules! plugin {
(@build $name:expr, $version:expr,
ops: { $($op:literal => $handler:expr),* $(,)? },
context_ops: { $($cop:literal => $chandler:expr),* $(,)? },
action_ops: { $($aop:literal => $ahandler:expr),* $(,)? },
channel_ops: { $($chop:literal => $chhandler:expr),* $(,)? },
chatops_ops: { $($ctop:literal => $cthandler:expr),* $(,)? },
connector_ops: { $($cnop:literal => $cnhandler:expr),* $(,)? } $(,)?
) => {
#[doc(hidden)]
fn __salamandr_build_registry() -> $crate::Registry {
$crate::Registry::new()
$(.op($op, $handler))*
$(.context_op($cop, $chandler))*
$(.action_op($aop, $ahandler))*
$(.channel_op($chop, $chhandler))*
$(.chatops_op($ctop, $cthandler))*
$(.connector_op($cnop, $cnhandler))*
}
#[no_mangle]
pub extern "C" fn alloc(size: u32) -> u32 {
$crate::sdk_alloc(size)
}
#[no_mangle]
pub extern "C" fn dealloc(ptr: u32, size: u32) {
$crate::sdk_dealloc(ptr, size)
}
#[no_mangle]
pub extern "C" fn handle(op_ptr: u32, op_len: u32, in_ptr: u32, in_len: u32) -> u64 {
$crate::handle_call(op_ptr, op_len, in_ptr, in_len, __salamandr_build_registry)
}
#[no_mangle]
pub extern "C" fn describe() -> u64 {
$crate::describe_call($name, $version, __salamandr_build_registry)
}
};
(@blocks $n:expr, $v:expr,
ops: { $($o:tt)* }, context_ops: { $($c:tt)* }, action_ops: { $($a:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: { $($c)* }, action_ops: { $($a)* }, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, ops: { $($o:tt)* }, context_ops: { $($c:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: { $($c)* }, action_ops: {}, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, ops: { $($o:tt)* }, action_ops: { $($a:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: {}, action_ops: { $($a)* }, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, context_ops: { $($c:tt)* }, action_ops: { $($a:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: {}, context_ops: { $($c)* }, action_ops: { $($a)* }, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, ops: { $($o:tt)* }, channel_ops: { $($ch:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: {}, action_ops: {}, channel_ops: { $($ch)* }, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, ops: { $($o:tt)* }, chatops_ops: { $($ct:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: {}, action_ops: {}, channel_ops: {}, chatops_ops: { $($ct)* }, connector_ops: {});
};
(@blocks $n:expr, $v:expr, ops: { $($o:tt)* }, connector_ops: { $($cn:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: {}, action_ops: {}, channel_ops: {}, chatops_ops: {}, connector_ops: { $($cn)* });
};
(@blocks $n:expr, $v:expr, ops: { $($o:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: { $($o)* }, context_ops: {}, action_ops: {}, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, context_ops: { $($c:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: {}, context_ops: { $($c)* }, action_ops: {}, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, action_ops: { $($a:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: {}, context_ops: {}, action_ops: { $($a)* }, channel_ops: {}, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, channel_ops: { $($ch:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: {}, context_ops: {}, action_ops: {}, channel_ops: { $($ch)* }, chatops_ops: {}, connector_ops: {});
};
(@blocks $n:expr, $v:expr, chatops_ops: { $($ct:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: {}, context_ops: {}, action_ops: {}, channel_ops: {}, chatops_ops: { $($ct)* }, connector_ops: {});
};
(@blocks $n:expr, $v:expr, connector_ops: { $($cn:tt)* } $(,)?) => {
$crate::plugin!(@build $n, $v, ops: {}, context_ops: {}, action_ops: {}, channel_ops: {}, chatops_ops: {}, connector_ops: { $($cn)* });
};
(name: $name:expr, version: $version:expr, $($blocks:tt)*) => {
$crate::plugin!(@blocks $name, $version, $($blocks)*);
};
($($blocks:tt)*) => {
$crate::plugin!(@blocks "", "", $($blocks)*);
};
}