@bakery-framework/orm 1.0.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 ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 Kyle Cyrus Santos Obille
2
+
3
+ The Software is provided subject to the standard MIT License, as detailed below, with the addition of the Commons Clause v1.0.
4
+
5
+ The Commons Clause v1.0
6
+
7
+ The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
8
+
9
+ Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.
10
+
11
+ For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.
12
+
13
+ Standard MIT License
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software (subject to the Commons Clause condition above), and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # @bakery-framework/orm
2
+
3
+ The database layer for [Bakery](https://github.com/obillekyle/bakery):
4
+ adapters, query builder, schema sync and backups.
5
+
6
+ **Bun only.** Ships TypeScript source with no build step.
7
+
8
+ ```bash
9
+ bun add @bakery-framework/orm
10
+ ```
11
+
12
+ ## Define a schema
13
+
14
+ ```ts
15
+ // orm/schema.ts
16
+ import { Field, table } from '@bakery-framework/orm'
17
+
18
+ export const posts = table('posts', {
19
+ id: Field.Primary(),
20
+ title: Field.Varchar(255, null),
21
+ body: Field.Varchar(8192, ''),
22
+ createdAt: Field.Date.now(),
23
+ })
24
+ ```
25
+
26
+ Register it so the query builder is typed. Without this block everything still
27
+ runs — the columns are just permissive `any`:
28
+
29
+ ```ts no-check — ./schema is the sibling file from the block above, which only exists in a real app
30
+ // orm/index.ts
31
+ import type { InferOptionals, InferSchema, InferViews } from '@bakery-framework/orm'
32
+ import * as model from './schema'
33
+
34
+ export * from './schema'
35
+
36
+ declare module '@bakery-framework/orm/schema-registry' {
37
+ interface SchemaRegistry {
38
+ schema: {
39
+ DBSchema: InferSchema<typeof model>
40
+ DBOptionals: InferOptionals<typeof model>
41
+ Views: InferViews<typeof model>
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## Query
48
+
49
+ ```ts
50
+ import DB from '@bakery-framework/orm'
51
+
52
+ const rows = await DB.from('posts').selectAll('posts').array()
53
+
54
+ await DB.Insert.into('posts').values({ title: 'Hello', body: 'World' }).run()
55
+ ```
56
+
57
+ Identifiers are snake_cased on the way to SQL — `createdAt` becomes
58
+ `created_at`. Values always bind as parameters.
59
+
60
+ ## Schema sync
61
+
62
+ ```ts
63
+ import { SyncService } from '@bakery-framework/orm/sync'
64
+
65
+ await SyncService.run()
66
+ process.exit(0)
67
+ ```
68
+
69
+ Diffs the database against your schema and applies the difference, prompting
70
+ before anything destructive. `NODE_ENV=production` makes destructive changes
71
+ refuse rather than prompt — set it on any deployed host.
72
+
73
+ ## Adapters
74
+
75
+ SQLite, MySQL and Postgres. **SQLite is the one covered by execution tests**;
76
+ the other two are verified against the SQL they emit and against live
77
+ round-trips in CI, which is not the same as being battle-tested.
78
+
79
+ ## License
80
+
81
+ MIT with the Commons Clause v1.0 — see [LICENSE](./LICENSE).
82
+
83
+ **Not an OSI-approved licence.** The Commons Clause removes the right to *sell*
84
+ the software — meaning to charge for a product or service whose value derives
85
+ substantially from it, hosting and support included. Everything else the MIT
86
+ licence grants is unchanged: use it, modify it, ship it inside your own product.
87
+ If your organisation only permits OSI-approved dependencies, this will not pass
88
+ that check.
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@bakery-framework/orm",
3
+ "version": "1.0.0",
4
+ "description": "Bakery database layer: adapters, query builder, schema sync and backup.",
5
+ "keywords": [
6
+ "bakery",
7
+ "bun",
8
+ "orm",
9
+ "database",
10
+ "sqlite",
11
+ "mysql",
12
+ "postgres",
13
+ "query-builder",
14
+ "schema-migration"
15
+ ],
16
+ "author": "obillekyle",
17
+ "license": "SEE LICENSE IN LICENSE",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/obillekyle/bakery.git",
21
+ "directory": "packages/orm"
22
+ },
23
+ "homepage": "https://github.com/obillekyle/bakery#readme",
24
+ "bugs": "https://github.com/obillekyle/bakery/issues",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "type": "module",
29
+ "main": "./src/index.ts",
30
+ "exports": {
31
+ ".": "./src/index.ts",
32
+ "./adapters": "./src/adapters.ts",
33
+ "./orm": "./src/orm/index.ts",
34
+ "./sync": "./src/sync/index.ts",
35
+ "./sync/load": "./src/sync/load.ts",
36
+ "./sync/ledger": "./src/sync/ledger.ts",
37
+ "./sync/history": "./src/sync/history.ts",
38
+ "./sync/rollback": "./src/sync/rollback.ts",
39
+ "./templates/*": "./templates/*",
40
+ "./package.json": "./package.json",
41
+ "./schema-registry": "./src/schema-registry.ts",
42
+ "./schema-util": "./src/schema-util.ts",
43
+ "./connection": "./src/connection.ts",
44
+ "./pool": "./src/pool.ts",
45
+ "./backup": "./src/backup.ts"
46
+ },
47
+ "files": [
48
+ "src",
49
+ "templates",
50
+ "!src/**/*.test.ts",
51
+ "!src/tests"
52
+ ],
53
+ "engines": {
54
+ "bun": ">=1.3.14"
55
+ },
56
+ "dependencies": {
57
+ "@bakery-framework/core": "^1.0.0"
58
+ }
59
+ }