an5-orm 1.0.6__py3-none-any.whl

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.
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: an5-orm
3
+ Version: 1.0.6
4
+ Summary: Lightweight ORM for SQL Server with Python support.
5
+ Author: an5ORM
6
+ License: MIT
7
+ Keywords: an5,orm,sqlserver
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: an5-adapters>=0.2.0
13
+
14
+ # @an5/orm
15
+
16
+ SQL Server ORM. Proxy client. CRUD. Vector search. Middleware. Raw queries. Transactions.
17
+
18
+ ## Features
19
+
20
+ - **Proxy Client.** Model access. `db.modelName` syntax.
21
+ - **CRUD.** `findMany`, `findFirst`, `findUnique`, `create`, `update`, `delete`, `upsert`.
22
+ - **Advanced Queries.** OR/AND, nested relations, aggregates, `groupBy`.
23
+ - **Vector Search.** Native SQL Server `VECTOR_DISTANCE`. In-memory fallback.
24
+ - **Middleware.** Hook ORM operations: logging, auth, validation.
25
+ - **Raw Queries.** `$queryRaw`, `$executeRaw`. Auto `NOLOCK`.
26
+ - **Transactions.** `$transaction`. Rollback support.
27
+ - **Schema Generator.** Parse `.an5` files. Generate TypeScript/Python/.NET code.
28
+
29
+ ## Quick Start
30
+
31
+ ### Installation
32
+
33
+ ```bash
34
+ npm install @an5/orm
35
+ ```
36
+
37
+ ### Configuration
38
+
39
+ ```bash
40
+ cp .env.example .env
41
+ # Edit .env. Set DATABASE_URL.
42
+ ```
43
+
44
+ ### Development Commands
45
+
46
+ ```bash
47
+ # Generate code from schema
48
+ npx an5 generate
49
+
50
+ # Push schema to database
51
+ npx an5 db:push
52
+
53
+ # Pull schema from database
54
+ npx an5 db:pull
55
+
56
+ # Seed database
57
+ npx an5 db:seed
58
+
59
+ # Compare schema with database
60
+ npx an5 db:migrate diff
61
+
62
+ # Run tests
63
+ npm test
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ ```typescript
69
+ import { An5ORM } from '@an5/orm';
70
+
71
+ const db = new An5ORM();
72
+
73
+ // CRUD Operations
74
+ const users = await db.user.findMany({
75
+ where: { email: { contains: '@example.com' } },
76
+ orderBy: { createdAt: 'desc' },
77
+ take: 10,
78
+ });
79
+
80
+ const user = await db.user.create({
81
+ data: { email: 'john@example.com', name: 'John' },
82
+ });
83
+
84
+ // Relations
85
+ const orders = await db.user.findMany({
86
+ include: { orders: true },
87
+ });
88
+
89
+ // Vector Search
90
+ const similar = await db.document.vectorSearch({
91
+ vector: [0.1, 0.2, 0.3],
92
+ take: 5,
93
+ distanceMetric: 'cosine',
94
+ });
95
+
96
+ // Transactions
97
+ await db.$transaction(async (tx) => {
98
+ const user = await tx.user.create({ data: { email: 'jane@example.com' } });
99
+ await tx.order.create({ data: { userId: user.id, total: 100 } });
100
+ });
101
+
102
+ // Raw Queries
103
+ const results = await db.$queryRaw`SELECT * FROM users WHERE id = ${id}`;
104
+ ```
105
+
106
+ ## Schema Definition
107
+
108
+ Schema files: `.an5`. Path: `an5Schema/`. SQL Server types.
109
+
110
+ ```an5
111
+ model User {
112
+ id NVARCHAR(1000) @id @default(uuid())
113
+ email NVARCHAR(255) @unique
114
+ name NVARCHAR(255)?
115
+ createdAt DATETIME2 @default(now())
116
+ orders Order[]
117
+
118
+ @@map("users")
119
+ }
120
+
121
+ model Order {
122
+ id NVARCHAR(1000) @id @default(uuid())
123
+ userId NVARCHAR(1000)
124
+ total INT @default(0)
125
+ user User @relation(fields: [userId], references: [id])
126
+
127
+ @@map("orders")
128
+ }
129
+ ```
130
+
131
+ ## Supported SQL Server Types
132
+
133
+ Type mapping: `.an5` to TypeScript.
134
+
135
+ | Schema Type | TypeScript |
136
+ |-------------|------------|
137
+ | `NVARCHAR(n)`, `VARCHAR(n)`, `CHAR(n)`, `TEXT` | `string` |
138
+ | `INT`, `SMALLINT`, `TINYINT`, `FLOAT`, `REAL`, `DECIMAL`, `NUMERIC` | `number` |
139
+ | `BIGINT` | `number \| bigint` |
140
+ | `BIT` | `boolean` |
141
+ | `DATETIME`, `DATETIME2`, `DATE`, `TIME` | `Date` |
142
+ | `UNIQUEIDENTIFIER` | `string` |
143
+ | `VARBINARY`, `BINARY`, `IMAGE` | `Buffer` |
144
+
145
+ ## Testing
146
+
147
+ ```bash
148
+ # Unit tests
149
+ node test/unit.test.js
150
+
151
+ # Generator tests
152
+ node test/generator.test.js
153
+
154
+ # Smoke test
155
+ npm test
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT
@@ -0,0 +1,5 @@
1
+ an5_orm.py,sha256=KDUYSQ5d2INkpi8zNmKQbg6EZ676tTmmDEvUPsCSvMI,841
2
+ an5_orm-1.0.6.dist-info/METADATA,sha256=gBjstZ9p5Vv9S7ljeAgqsy88gnMKZvdnZocOs7LN7yg,3651
3
+ an5_orm-1.0.6.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
4
+ an5_orm-1.0.6.dist-info/top_level.txt,sha256=IroQMc2qhf8XQUT53laenhLVLoSJOj96G3CPScjBLWQ,8
5
+ an5_orm-1.0.6.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ an5_orm
an5_orm.py ADDED
@@ -0,0 +1,24 @@
1
+ """
2
+ AN5 ORM Python Entrypoint
3
+ """
4
+ import os
5
+ import sys
6
+
7
+ # Ensure local monorepo adapter path is available for source execution & IDE linting
8
+ _local_adapters_dir = os.path.abspath(
9
+ os.path.join(os.path.dirname(__file__), "..", "..", "an5Adapters", "python")
10
+ )
11
+ if os.path.exists(_local_adapters_dir) and _local_adapters_dir not in sys.path:
12
+ sys.path.insert(0, _local_adapters_dir)
13
+
14
+ try:
15
+ from an5_adapter import An5Adapter, create_an5_adapter, AdapterTableClient
16
+ except ImportError: # pragma: no cover
17
+ try:
18
+ from .an5_adapter import An5Adapter, create_an5_adapter, AdapterTableClient
19
+ except ImportError:
20
+ An5Adapter = None # type: ignore
21
+ create_an5_adapter = None # type: ignore
22
+ AdapterTableClient = None # type: ignore
23
+
24
+ __all__ = ["An5Adapter", "create_an5_adapter", "AdapterTableClient"]