seedorm 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/dist/bin/seedorm.cjs +5513 -0
- package/dist/bin/static/app.js +126 -0
- package/dist/bin/static/index.html +55 -0
- package/dist/bin/static/style.css +204 -0
- package/dist/chunk-Y4EVX4PQ.js +367 -0
- package/dist/chunk-Y4EVX4PQ.js.map +1 -0
- package/dist/index.cjs +1063 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +225 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +616 -0
- package/dist/index.js.map +1 -0
- package/dist/postgres-adapter-QBZYJX6P.js +7 -0
- package/dist/postgres-adapter-QBZYJX6P.js.map +1 -0
- package/package.json +55 -0
- package/templates/seedorm.config.json +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Josh Matthew Talplacido
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# seedorm
|
|
2
|
+
|
|
3
|
+
Development-first ORM that lets you start with a JSON file and migrate to PostgreSQL or MySQL by changing one line of config. No rewrites.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
Every project starts the same way: you need to store data, but you don't want to set up a database just to prototype. SeedORM lets you start building immediately with a local JSON file, then switch to a real database when you're ready — without changing your application code.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone https://github.com/example/seedorm.git
|
|
13
|
+
cd seedorm
|
|
14
|
+
npm install
|
|
15
|
+
npm run build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { SeedORM } from "seedorm";
|
|
20
|
+
|
|
21
|
+
const db = new SeedORM();
|
|
22
|
+
await db.connect();
|
|
23
|
+
|
|
24
|
+
const User = db.model({
|
|
25
|
+
name: "User",
|
|
26
|
+
collection: "users",
|
|
27
|
+
schema: {
|
|
28
|
+
name: { type: "string", required: true },
|
|
29
|
+
email: { type: "string", unique: true },
|
|
30
|
+
role: { type: "string", enum: ["admin", "user"], default: "user" },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
await User.init();
|
|
34
|
+
|
|
35
|
+
// Create
|
|
36
|
+
const alice = await User.create({ name: "Alice", email: "alice@example.com" });
|
|
37
|
+
|
|
38
|
+
// Query with MongoDB-style operators
|
|
39
|
+
const admins = await User.find({
|
|
40
|
+
filter: { role: { $eq: "admin" } },
|
|
41
|
+
sort: { name: 1 },
|
|
42
|
+
limit: 10,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Update
|
|
46
|
+
await User.update(alice.id, { role: "admin" });
|
|
47
|
+
|
|
48
|
+
// Delete
|
|
49
|
+
await User.delete(alice.id);
|
|
50
|
+
|
|
51
|
+
await db.disconnect();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Switch to PostgreSQL
|
|
55
|
+
|
|
56
|
+
Change your config. That's it.
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"adapter": { "adapter": "json", "path": "./data" }
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"adapter": { "adapter": "postgres", "url": "postgres://localhost:5432/mydb" }
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Your models, queries, and application logic stay exactly the same.
|
|
71
|
+
|
|
72
|
+
## Features
|
|
73
|
+
|
|
74
|
+
- **Zero-config start** — data lives in a JSON file, no database setup needed
|
|
75
|
+
- **Schema validation** — type checking, required fields, unique constraints, min/max, enums
|
|
76
|
+
- **Query operators** — `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$like`, `$exists`
|
|
77
|
+
- **CLI tools** — `seedorm init`, `seedorm start` (REST server), `seedorm studio` (visual UI)
|
|
78
|
+
- **Migration engine** — `migrate create`, `migrate up`, `migrate to postgres` (SQL export)
|
|
79
|
+
- **PostgreSQL adapter** — full adapter with parameterized queries, lazy-loaded so `pg` is optional
|
|
80
|
+
- **TypeScript** — written in TypeScript with full type exports, dual CJS/ESM output
|
|
81
|
+
|
|
82
|
+
## CLI
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Initialize a project
|
|
86
|
+
seedorm init
|
|
87
|
+
|
|
88
|
+
# Start a REST API dev server (port 4100)
|
|
89
|
+
seedorm start
|
|
90
|
+
|
|
91
|
+
# Launch the visual data browser (port 4200)
|
|
92
|
+
seedorm studio
|
|
93
|
+
|
|
94
|
+
# Create a migration
|
|
95
|
+
seedorm migrate create add-users
|
|
96
|
+
|
|
97
|
+
# Run pending migrations
|
|
98
|
+
seedorm migrate up
|
|
99
|
+
|
|
100
|
+
# Export JSON data as PostgreSQL SQL
|
|
101
|
+
seedorm migrate to postgres --output export.sql
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## REST API
|
|
105
|
+
|
|
106
|
+
When running `seedorm start`, the following endpoints are available:
|
|
107
|
+
|
|
108
|
+
| Method | Endpoint | Description |
|
|
109
|
+
|--------|----------|-------------|
|
|
110
|
+
| `POST` | `/api/models` | Register a model |
|
|
111
|
+
| `GET` | `/api/collections` | List collections |
|
|
112
|
+
| `GET` | `/api/:collection` | List documents (supports `?filter=`, `?sort=`, `?limit=`, `?offset=`) |
|
|
113
|
+
| `GET` | `/api/:collection/:id` | Get document by ID |
|
|
114
|
+
| `POST` | `/api/:collection` | Create document |
|
|
115
|
+
| `PATCH` | `/api/:collection/:id` | Update document |
|
|
116
|
+
| `DELETE` | `/api/:collection/:id` | Delete document |
|
|
117
|
+
|
|
118
|
+
## Project structure
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
src/
|
|
122
|
+
├── index.ts # Public exports
|
|
123
|
+
├── seedorm.ts # Main SeedORM class
|
|
124
|
+
├── types.ts # All TypeScript interfaces
|
|
125
|
+
├── errors.ts # Error classes
|
|
126
|
+
├── model/
|
|
127
|
+
│ ├── model.ts # Model class (CRUD + validation)
|
|
128
|
+
│ ├── schema.ts # Schema parsing + validation
|
|
129
|
+
│ └── field-types.ts # Type definitions + coercion
|
|
130
|
+
├── adapters/
|
|
131
|
+
│ ├── json/
|
|
132
|
+
│ │ ├── json-adapter.ts # JSON file adapter
|
|
133
|
+
│ │ ├── file-engine.ts # Atomic read/write with write queue
|
|
134
|
+
│ │ └── indexer.ts # In-memory indexes for unique/indexed fields
|
|
135
|
+
│ └── postgres/
|
|
136
|
+
│ ├── postgres-adapter.ts # Full PostgreSQL adapter
|
|
137
|
+
│ ├── pg-query-builder.ts # Parameterized query builder
|
|
138
|
+
│ └── pg-connection.ts # Connection pool wrapper
|
|
139
|
+
├── query/
|
|
140
|
+
│ ├── operators.ts # Filter operator implementations
|
|
141
|
+
│ └── filter.ts # In-memory filter engine
|
|
142
|
+
├── migration/
|
|
143
|
+
│ ├── migration-engine.ts # Run/track migrations
|
|
144
|
+
│ ├── migration-generator.ts # Generate migration files
|
|
145
|
+
│ ├── schema-differ.ts # Diff schemas into migration steps
|
|
146
|
+
│ └── exporters/
|
|
147
|
+
│ └── postgres-exporter.ts # Generate CREATE TABLE + INSERT SQL
|
|
148
|
+
├── cli/
|
|
149
|
+
│ ├── index.ts # Commander.js program setup
|
|
150
|
+
│ └── commands/ # init, start, studio, migrate:*
|
|
151
|
+
└── studio/
|
|
152
|
+
├── server.ts # HTTP server for studio UI
|
|
153
|
+
├── api.ts # REST API routes
|
|
154
|
+
└── static/ # Vanilla HTML/CSS/JS frontend
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Testing
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npm test # 48 tests (unit + integration)
|
|
161
|
+
npm run build # TypeScript build via tsup
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Requirements
|
|
165
|
+
|
|
166
|
+
- Node.js 18+
|
|
167
|
+
- `pg` (optional, only for PostgreSQL adapter)
|
|
168
|
+
- `mysql2` (optional, only for MySQL adapter)
|
|
169
|
+
|
|
170
|
+
## Status
|
|
171
|
+
|
|
172
|
+
Early development. The JSON adapter and core ORM are functional and tested. PostgreSQL adapter is implemented but untested against a live database. MySQL adapter is not yet implemented.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT
|