an5-orm 1.0.6__tar.gz

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.
an5_orm-1.0.6/PKG-INFO ADDED
@@ -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,147 @@
1
+ # @an5/orm
2
+
3
+ SQL Server ORM. Proxy client. CRUD. Vector search. Middleware. Raw queries. Transactions.
4
+
5
+ ## Features
6
+
7
+ - **Proxy Client.** Model access. `db.modelName` syntax.
8
+ - **CRUD.** `findMany`, `findFirst`, `findUnique`, `create`, `update`, `delete`, `upsert`.
9
+ - **Advanced Queries.** OR/AND, nested relations, aggregates, `groupBy`.
10
+ - **Vector Search.** Native SQL Server `VECTOR_DISTANCE`. In-memory fallback.
11
+ - **Middleware.** Hook ORM operations: logging, auth, validation.
12
+ - **Raw Queries.** `$queryRaw`, `$executeRaw`. Auto `NOLOCK`.
13
+ - **Transactions.** `$transaction`. Rollback support.
14
+ - **Schema Generator.** Parse `.an5` files. Generate TypeScript/Python/.NET code.
15
+
16
+ ## Quick Start
17
+
18
+ ### Installation
19
+
20
+ ```bash
21
+ npm install @an5/orm
22
+ ```
23
+
24
+ ### Configuration
25
+
26
+ ```bash
27
+ cp .env.example .env
28
+ # Edit .env. Set DATABASE_URL.
29
+ ```
30
+
31
+ ### Development Commands
32
+
33
+ ```bash
34
+ # Generate code from schema
35
+ npx an5 generate
36
+
37
+ # Push schema to database
38
+ npx an5 db:push
39
+
40
+ # Pull schema from database
41
+ npx an5 db:pull
42
+
43
+ # Seed database
44
+ npx an5 db:seed
45
+
46
+ # Compare schema with database
47
+ npx an5 db:migrate diff
48
+
49
+ # Run tests
50
+ npm test
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ```typescript
56
+ import { An5ORM } from '@an5/orm';
57
+
58
+ const db = new An5ORM();
59
+
60
+ // CRUD Operations
61
+ const users = await db.user.findMany({
62
+ where: { email: { contains: '@example.com' } },
63
+ orderBy: { createdAt: 'desc' },
64
+ take: 10,
65
+ });
66
+
67
+ const user = await db.user.create({
68
+ data: { email: 'john@example.com', name: 'John' },
69
+ });
70
+
71
+ // Relations
72
+ const orders = await db.user.findMany({
73
+ include: { orders: true },
74
+ });
75
+
76
+ // Vector Search
77
+ const similar = await db.document.vectorSearch({
78
+ vector: [0.1, 0.2, 0.3],
79
+ take: 5,
80
+ distanceMetric: 'cosine',
81
+ });
82
+
83
+ // Transactions
84
+ await db.$transaction(async (tx) => {
85
+ const user = await tx.user.create({ data: { email: 'jane@example.com' } });
86
+ await tx.order.create({ data: { userId: user.id, total: 100 } });
87
+ });
88
+
89
+ // Raw Queries
90
+ const results = await db.$queryRaw`SELECT * FROM users WHERE id = ${id}`;
91
+ ```
92
+
93
+ ## Schema Definition
94
+
95
+ Schema files: `.an5`. Path: `an5Schema/`. SQL Server types.
96
+
97
+ ```an5
98
+ model User {
99
+ id NVARCHAR(1000) @id @default(uuid())
100
+ email NVARCHAR(255) @unique
101
+ name NVARCHAR(255)?
102
+ createdAt DATETIME2 @default(now())
103
+ orders Order[]
104
+
105
+ @@map("users")
106
+ }
107
+
108
+ model Order {
109
+ id NVARCHAR(1000) @id @default(uuid())
110
+ userId NVARCHAR(1000)
111
+ total INT @default(0)
112
+ user User @relation(fields: [userId], references: [id])
113
+
114
+ @@map("orders")
115
+ }
116
+ ```
117
+
118
+ ## Supported SQL Server Types
119
+
120
+ Type mapping: `.an5` to TypeScript.
121
+
122
+ | Schema Type | TypeScript |
123
+ |-------------|------------|
124
+ | `NVARCHAR(n)`, `VARCHAR(n)`, `CHAR(n)`, `TEXT` | `string` |
125
+ | `INT`, `SMALLINT`, `TINYINT`, `FLOAT`, `REAL`, `DECIMAL`, `NUMERIC` | `number` |
126
+ | `BIGINT` | `number \| bigint` |
127
+ | `BIT` | `boolean` |
128
+ | `DATETIME`, `DATETIME2`, `DATE`, `TIME` | `Date` |
129
+ | `UNIQUEIDENTIFIER` | `string` |
130
+ | `VARBINARY`, `BINARY`, `IMAGE` | `Buffer` |
131
+
132
+ ## Testing
133
+
134
+ ```bash
135
+ # Unit tests
136
+ node test/unit.test.js
137
+
138
+ # Generator tests
139
+ node test/generator.test.js
140
+
141
+ # Smoke test
142
+ npm test
143
+ ```
144
+
145
+ ## License
146
+
147
+ MIT
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "an5-orm"
7
+ version = "1.0.6"
8
+ description = "Lightweight ORM for SQL Server with Python support."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ authors = [{ name = "an5ORM" }]
12
+ license = { text = "MIT" }
13
+ keywords = ["an5", "orm", "sqlserver"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License"
17
+ ]
18
+ dependencies = [
19
+ "an5-adapters>=0.2.0"
20
+ ]
21
+
22
+ [tool.setuptools]
23
+ package-dir = {"" = "python"}
24
+ py-modules = ["an5_orm"]
@@ -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,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ python/an5_orm.py
4
+ python/an5_orm.egg-info/PKG-INFO
5
+ python/an5_orm.egg-info/SOURCES.txt
6
+ python/an5_orm.egg-info/dependency_links.txt
7
+ python/an5_orm.egg-info/requires.txt
8
+ python/an5_orm.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ an5-adapters>=0.2.0
@@ -0,0 +1 @@
1
+ an5_orm
@@ -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"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+