autumn_plugin_shopify/lib.rs
1//! `autumn-plugin-shopify`: build Shopify apps on Autumn.
2//!
3//! - Signed webhooks, routed by topic, with a duplicate guard.
4//! - OAuth install with expiring offline tokens and refresh.
5//! - An Admin GraphQL client that retries throttled calls.
6//!
7//! ```no_run
8//! use autumn_plugin_shopify::{ShopifyPlugin, WebhookContext};
9//! use autumn_web::prelude::*;
10//!
11//! async fn order_created(ctx: WebhookContext) -> AutumnResult<()> {
12//! let order: serde_json::Value = ctx.json().map_err(|e| e.to_autumn_error())?;
13//! tracing::info!(shop = %ctx.shop, id = %order["id"], "order created");
14//! Ok(())
15//! }
16//!
17//! #[autumn_web::main]
18//! async fn main() {
19//! autumn_web::app()
20//! .plugin(ShopifyPlugin::new().webhook("orders/create", order_created))
21//! .run()
22//! .await;
23//! }
24//! ```
25//!
26//! ## Modules
27//!
28//! | Module | Purpose |
29//! |---|---|
30//! | [`config`] | `[shopify]` config, `SHOPIFY_*` env, builder closures |
31//! | [`types`] | [`ShopDomain`], [`Topic`], [`ApiVersion`] |
32//! | [`verify`] | Webhook and OAuth HMAC checks |
33//! | [`webhooks`] | The webhook route, extractor, and topic registry |
34//! | [`delivery`] | Duplicate-delivery guard |
35//! | [`oauth`] | Install and callback routes, token exchange, refresh |
36//! | [`tokens`] | Token storage |
37//! | [`client`] | Admin GraphQL client |
38//! | [`health`] | Health check |
39//! | [`plugin`] | [`ShopifyPlugin`], [`ShopifyRuntime`], [`Shopify`] |
40//! | [`error`] | [`Error`], [`ErrorKind`], HTTP status mapping |
41
42#![forbid(unsafe_code)]
43
44pub mod client;
45pub mod config;
46pub mod delivery;
47pub mod error;
48pub mod health;
49pub mod oauth;
50pub mod plugin;
51pub mod tokens;
52pub mod types;
53pub mod verify;
54pub mod webhooks;
55
56#[cfg(test)]
57mod test_support;
58
59pub use client::{RetryPolicy, ShopInfo, ShopifyClient};
60pub use config::ShopifyConfig;
61pub use delivery::{Claim, DeliveryStore, InMemoryDeliveryStore};
62pub use error::{Error, ErrorKind, Result};
63pub use health::ShopifyHealth;
64pub use plugin::{InstallContext, Shopify, ShopifyPlugin, ShopifyRuntime};
65pub use tokens::{InMemoryTokenStore, ShopToken, TokenStore};
66pub use types::{ApiVersion, DEFAULT_API_VERSION, ShopDomain, Topic};
67pub use verify::{SecretSet, sign_query, sign_webhook, verify_query, verify_webhook};
68pub use webhooks::{VerifiedWebhook, WebhookContext, WebhookOutcome, WebhookRegistry};