cratestack/lib.rs
1//! CrateStack embedded facade — rusqlite + shared schema surface.
2//!
3//! This crate is the embedded slice of the framework. It re-exports the
4//! shared schema / parser / policy / SQL surface plus the `rusqlite 0.39`
5//! runtime, which compiles to native targets *and* to
6//! `wasm32-unknown-unknown` (via rusqlite's transparent FFI switch to
7//! `sqlite-wasm-rs`).
8//!
9//! It deliberately does **not** depend on `cratestack-sqlx`,
10//! `cratestack-axum`, or `cratestack-client-rust`. None of those compile
11//! on `wasm32`, and keeping them out of the dep graph also lets backend
12//! services depend on the official `sqlx` umbrella crate alongside the
13//! server facade without `libsqlite3-sys` collisions.
14//!
15//! For backend services on Postgres, depend on
16//! [`cratestack-pg`](../cratestack-pg) instead. The two crates are
17//! strictly disjoint by design.
18//!
19//! Schema macros emit `::cratestack::*` paths, so consumers rename this
20//! crate via Cargo's `package =` field:
21//!
22//! ```toml
23//! [dependencies]
24//! cratestack = { package = "cratestack-sqlite", version = "0.4" }
25//! ```
26
27pub use chrono;
28// Generated HTTP client runtime — available on native targets so that
29// hybrid consumers (e.g. a NAPI / Tauri shell that ships an embedded
30// SQLite DB *and* calls a remote backend over HTTP) can use
31// `include_client_schema!` alongside `include_embedded_schema!`.
32// Target-gated off `wasm32` because `reqwest` doesn't compile there.
33#[cfg(not(target_arch = "wasm32"))]
34pub use cratestack_client_rust as client_rust;
35pub use cratestack_core::*;
36pub use cratestack_macros::{
37 include_client_schema, include_embedded_schema, include_server_schema,
38};
39pub use cratestack_parser::{SchemaError, parse_schema, parse_schema_file, parse_schema_named};
40pub use cratestack_policy::{
41 PolicyExpr, PolicyLiteral, ProcedureArgs, ProcedurePolicy, ProcedurePolicyExpr,
42 ProcedurePolicyLiteral, ProcedurePredicate, ReadPolicy, ReadPredicate, RelationQuantifier,
43 authorize_procedure,
44};
45
46// SQL primitives shared by every backend — re-exported directly from
47// `cratestack-sql` so consumers don't transit through any runtime crate.
48pub use cratestack_sql::{
49 CoalesceExpr, CoalesceFilter, ConflictTarget, CreateDefault, CreateDefaultType,
50 CreateModelInput, FieldRef, Filter, FilterExpr, FilterOp, IntoColumnName, IntoSqlValue,
51 JsonFilter, JsonTextPath, ModelColumn, ModelDescriptor, ModelPrimaryKey, NullOrder,
52 OrderClause, Projection, ReadSource, RelationFilter, RelationInclude, SortDirection,
53 SpatialFilter, SpatialPoint, SqlColumnValue, SqlValue, UpdateModelInput, UpsertModelInput,
54 ViewDescriptor, WriteSource, coalesce, point,
55};
56
57pub use regex;
58pub use serde;
59pub use serde_json;
60pub use tracing;
61pub use uuid;
62
63// `Json<T>` is a serde-only newtype here — sqlx isn't in the dep graph,
64// so the model struct can be assembled and read by the rusqlite-side
65// `FromRusqliteRow` decoder without pulling tokio-net.
66pub use cratestack_core::Json;
67
68// Embedded SQLite backend — wasm32-compatible alongside native (mobile,
69// desktop), via rusqlite 0.39's transparent FFI switch to `sqlite-wasm-rs`.
70pub use cratestack_rusqlite as rusqlite_backend;
71pub use cratestack_rusqlite::{
72 DateTimeColumn, DecimalColumn, FromPartialRusqliteRow, FromRusqliteRow, JsonColumn,
73 RusqliteError, RusqliteRuntime, SqlValueParam, UuidColumn, rusqlite,
74};