stabilize-orm 1.0.5 → 1.0.7

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/README.md CHANGED
@@ -1,9 +1,52 @@
1
1
  # Stabilize ORM
2
2
 
3
- A lightweight, type-safe ORM for Bun.js, supporting SQLite, MySQL, PostgreSQL, and Redis caching.
3
+ Stabilize is a lightweight, retry-aware ORM built on Bun's native SQL API. It provides a unified interface for SQLite, MySQL, and PostgreSQL with features like connection pooling, automatic retries, transactions, savepoints, and logging. It's designed for simplicity, performance, and stability in Bun applications.
4
+
5
+ ## Features
6
+
7
+ - **Unified API**: Works seamlessly with SQLite, MySQL, and PostgreSQL via Bun SQL.
8
+ - **Retry Logic**: Automatic exponential backoff retries for queries and transactions.
9
+ - **Connection Management**: Pooling, switching connections, and metrics.
10
+ - **Transactions & Savepoints**: Built-in support with retry handling.
11
+ - **Prepared Statements**: Cached for SQLite to improve performance.
12
+ - **Logging**: Pluggable logger (default: ConsoleLogger).
13
+ - **Error Handling**: Custom `StabilizeError` with database-specific codes.
14
+ - **CLI**: Simple command-line tool for database operations (e.g., migrations, queries).
4
15
 
5
16
  ## Installation
6
17
 
18
+ Stabilize requires Bun (v1.0+).
19
+
7
20
  ```bash
8
- bun add stabilize
21
+ # Install via bun
22
+ bun add stabilize-orm
9
23
  ```
24
+ ## Usage
25
+
26
+ ```bash
27
+ # Imports
28
+ import { DBClient } from 'stabilize-orm/src/client';
29
+ import { DBConfig } from 'stabilize-orm/src/types';
30
+
31
+ const config: DBConfig = {
32
+ type: 'sqlite', // or 'mysql', 'postgres'
33
+ connectionString: 'myapp.db',
34
+ poolSize: 10,
35
+ retryAttempts: 3,
36
+ };
37
+
38
+ const db = new DBClient(config);
39
+
40
+ async function run() {
41
+ const users = await db.query<{ id: number; name: string }>('SELECT * FROM users');
42
+ console.log(users);
43
+
44
+ await db.transaction(async () => {
45
+ await db.query('INSERT INTO users (name) VALUES (?)', ['Alice']);
46
+ });
47
+
48
+ await db.close();
49
+ }
50
+
51
+ run();
52
+ ```
Binary file
package/package.json CHANGED
@@ -1,16 +1,28 @@
1
1
  {
2
2
  "name": "stabilize-orm",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A lightweight, type-safe ORM for Bun.js with support for SQLite, MySQL, PostgreSQL, and Redis caching",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
7
14
  "bin": {
8
15
  "stabilize": "./dist/cli/stabilize-cli.js"
9
16
  },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
10
22
  "scripts": {
11
23
  "build": "bun build src/index.ts --outdir dist --target bun --minify && bun build cli/stabilize-cli.ts --outdir dist/cli --target bun --minify",
12
-
13
24
  "prepublishOnly": "bun run build && bun run test",
25
+ "build:exe": "bun build cli/stabilize-cli.ts --compile --outfile dist/stabilize-cli --target bun",
14
26
  "format": "bunx prettier --write .",
15
27
  "lint": "eslint src tests cli examples",
16
28
  "cli": "bun run cli/stabilize-cli.ts"
@@ -28,19 +40,20 @@
28
40
  "author": "th3b0tk1ill3r <lwazicd@icloud.com>",
29
41
  "license": "MIT",
30
42
  "dependencies": {
31
- "ioredis": "^5.4.1",
32
- "reflect-metadata": "^0.2.2",
33
43
  "commander": "^12.1.0",
34
- "glob": "^11.0.0"
44
+ "figlet": "^1.9.3",
45
+ "glob": "^11.0.0",
46
+ "ioredis": "^5.4.1",
47
+ "reflect-metadata": "^0.2.2"
35
48
  },
36
49
  "devDependencies": {
37
- "vitest": "^2.1.3",
50
+ "@typescript-eslint/eslint-plugin": "^8.7.0",
51
+ "@typescript-eslint/parser": "^8.7.0",
38
52
  "@vitest/coverage-v8": "^2.1.3",
39
- "typescript": "^5.6.3",
40
- "prettier": "^3.3.3",
41
53
  "eslint": "^9.12.0",
42
- "@typescript-eslint/parser": "^8.7.0",
43
- "@typescript-eslint/eslint-plugin": "^8.7.0"
54
+ "prettier": "^3.3.3",
55
+ "typescript": "^5.6.3",
56
+ "vitest": "^2.1.3"
44
57
  },
45
58
  "repository": {
46
59
  "type": "git",
package/.eslintrc.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "env": { "node": true },
3
- "parser": "@typescript-eslint/parser",
4
- "plugins": ["@typescript-eslint"],
5
- "extends": ["plugin:@typescript-eslint/recommended"],
6
- "rules": {
7
- "no-unused-vars": "off",
8
- "@typescript-eslint/no-unused-vars": "error"
9
- }
10
- }
@@ -1,73 +0,0 @@
1
- name: CI/CD Pipeline for Stabilize ORM
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- tags:
8
- - "v*.*.*"
9
- pull_request:
10
- branches:
11
- - main
12
-
13
- jobs:
14
- test:
15
- runs-on: ubuntu-latest
16
- services:
17
- redis:
18
- image: redis:latest
19
- ports:
20
- - 6379:6379
21
- steps:
22
- - name: Checkout code
23
- uses: actions/checkout@v4
24
- - name: Setup Bun
25
- uses: oven-sh/setup-bun@v2
26
- with:
27
- bun-version: "latest"
28
- - name: Install dependencies
29
- run: bun install
30
- - name: Check formatting
31
- run: bunx prettier --check .
32
- - name: Lint code
33
- run: bun run lint
34
- - name: Run tests
35
- run: bun run test
36
- env:
37
- REDIS_URL: redis://localhost:6379
38
- - name: Build project
39
- run: bun run build
40
- - name: Test CLI
41
- run: |
42
- bun run dist/cli/stabilize-cli.js generate model TestModel
43
- bun run dist/cli/stabilize-cli.js generate seed TestSeed
44
- bun run dist/cli/stabilize-cli.js seed -c examples/config/database.ts
45
- - name: Upload coverage
46
- uses: codecov/codecov-action@v4
47
- with:
48
- token: ${{ secrets.CODECOV_TOKEN }}
49
-
50
- publish:
51
- needs: test
52
- runs-on: ubuntu-latest
53
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
54
- steps:
55
- - name: Checkout code
56
- uses: actions/checkout@v4
57
- - name: Setup Bun
58
- uses: oven-sh/setup-bun@v2
59
- with:
60
- bun-version: "latest"
61
- - name: Install dependencies
62
- run: bun install
63
- - name: Build project
64
- run: bun run build
65
- - name: Setup Node.js
66
- uses: actions/setup-node@v4
67
- with:
68
- node-version: "20"
69
- registry-url: "https://registry.npmjs.org"
70
- - name: Publish to npm
71
- run: npm publish --access public
72
- env:
73
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}