@an5/adapters 0.2.6 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +96 -2
  2. package/dist/an5Adapter.d.ts +57 -0
  3. package/dist/an5Adapter.js +263 -4
  4. package/dist/base/sql.js +16 -15
  5. package/dist/base/types.d.ts +6 -0
  6. package/dist/googlesheets/helpers.js +13 -8
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +9 -1
  9. package/dist/nbase/client.d.ts +92 -0
  10. package/dist/nbase/client.js +147 -0
  11. package/dist/nbase/index.d.ts +47 -0
  12. package/dist/nbase/index.js +80 -0
  13. package/dist/sqlite/engine.js +2 -1
  14. package/dotnet/An5Adapter.cs +41 -18
  15. package/dotnet/Base/Core.cs +56 -26
  16. package/dotnet/Postgres/PostgresEngine.cs +58 -30
  17. package/dotnet/Sqlite/SqliteEngine.cs +214 -0
  18. package/golang/base/where.go +32 -49
  19. package/golang/base/where_test.go +57 -0
  20. package/package.json +26 -11
  21. package/python/an5_adapter.py +74 -9
  22. package/python/base/__init__.py +1 -1
  23. package/python/base/metadata.py +25 -1
  24. package/python/base/sql.py +50 -21
  25. package/python/sqlite/__init__.py +3 -0
  26. package/python/sqlite/provider.py +83 -0
  27. package/python/table_client.py +53 -36
  28. package/rust/Cargo.toml +31 -0
  29. package/rust/README.md +71 -0
  30. package/rust/src/adapter.rs +1314 -0
  31. package/rust/src/base/dialect.rs +201 -0
  32. package/rust/src/base/metadata.rs +138 -0
  33. package/rust/src/base/mod.rs +17 -0
  34. package/rust/src/base/where_builder.rs +386 -0
  35. package/rust/src/lib.rs +75 -0
  36. package/typescript/src/an5Adapter.ts +300 -4
  37. package/typescript/src/base/sql.ts +15 -14
  38. package/typescript/src/base/types.ts +6 -0
  39. package/typescript/src/googlesheets/helpers.ts +11 -8
  40. package/typescript/src/index.ts +17 -0
  41. package/typescript/src/nbase/client.ts +214 -0
  42. package/typescript/src/nbase/index.ts +104 -0
  43. package/typescript/src/sqlite/engine.ts +2 -1
package/rust/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # an5-adapters
2
+
3
+ Database adapter runtime for [AN5 ORM](https://github.com/an5ORM/an5) in Rust.
4
+
5
+ `An5Adapter` owns the connection and the dialect; `TableClient` provides the ORM
6
+ CRUD surface on top of [`sqlx`](https://github.com/launchbadge/sqlx). Dialects are
7
+ detected from the connection string, so SQL Server, PostgreSQL and SQLite are
8
+ handled without configuration. This crate mirrors the TypeScript, Python, .NET
9
+ and Go adapter packages.
10
+
11
+ ## Install
12
+
13
+ ```toml
14
+ [dependencies]
15
+ an5-adapters = "0.1"
16
+ ```
17
+
18
+ The crate is driver-agnostic: it depends on `sqlx` with `any`, so the application
19
+ picks the driver it needs and enables the matching `sqlx` feature.
20
+
21
+ ```toml
22
+ [dependencies]
23
+ sqlx = { version = "0.8", default-features = false, features = ["any", "runtime-tokio", "postgres"] }
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```rust
29
+ use an5_adapters::{An5Adapter, FindManyArgs};
30
+ use serde_json::json;
31
+
32
+ #[tokio::main]
33
+ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
34
+ // Register the drivers this binary needs, then hand the URL to the adapter.
35
+ sqlx::any::install_drivers(&[sqlx::postgres::any::DRIVER])?;
36
+ let db = An5Adapter::connect("postgres://localhost:5432/mydb").await?;
37
+
38
+ // Dynamic access, the Rust equivalent of `db.user` in TypeScript.
39
+ let users = db
40
+ .table("User")
41
+ .find_many(&FindManyArgs {
42
+ r#where: Some(json!({ "email": { "contains": "@example.com" } })),
43
+ take: 10,
44
+ ..Default::default()
45
+ })
46
+ .await?;
47
+
48
+ println!("{} users", users.len());
49
+ Ok(())
50
+ }
51
+ ```
52
+
53
+ Generated Rust clients (`an5-client`) wrap this crate and expose one typed handle
54
+ per model — `db.user().find_many(&UserFindManyArgs { .. })` — instead of the
55
+ dynamic `db.table("User")` access shown above.
56
+
57
+ ### Features
58
+
59
+ - `An5Adapter::connect` / `create_an5_adapter`, with the connection string read
60
+ from `DATABASE_URL` when omitted
61
+ - Dialect detection and identifier quoting for MSSQL, PostgreSQL and SQLite
62
+ - `TableClient`: `find_many`, `find_first`, `find_unique`, `count`, `create`,
63
+ `create_many`, `update`, `update_many`, `delete_many`, `upsert`, `aggregate`,
64
+ `group_by` and `vector_search`
65
+ - Transactions, raw SQL execution and view clients
66
+ - `base` module with the where/order-by builders, adapter metadata and vector
67
+ distance math
68
+
69
+ ## License
70
+
71
+ MIT