supalite 0.5.7 → 0.7.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/.github/workflows/ci.yml +41 -0
- package/AGENTS.md +39 -0
- package/CHANGELOG.md +35 -0
- package/README.ko.md +1126 -0
- package/README.md +875 -159
- package/SKILLS.md +34 -0
- package/SPEC.md +174 -0
- package/bin/supalite +2 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +183 -0
- package/dist/errors.js +6 -0
- package/dist/gen-types.d.ts +21 -0
- package/dist/gen-types.js +810 -0
- package/dist/postgres-client.d.ts +4 -1
- package/dist/postgres-client.js +40 -3
- package/dist/query-builder.d.ts +24 -3
- package/dist/query-builder.js +485 -124
- package/dist/types.d.ts +1 -0
- package/docs/limitations.ko.md +10 -0
- package/docs/limitations.md +10 -0
- package/docs/spec/TEMPLATE.md +59 -0
- package/package.json +12 -2
- package/scripts/cleanup-gen-types.sql +13 -0
- package/scripts/jest-errors.js +70 -0
- package/scripts/seed-gen-types.sql +80 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
services:
|
|
12
|
+
postgres:
|
|
13
|
+
image: postgres:16
|
|
14
|
+
env:
|
|
15
|
+
POSTGRES_PASSWORD: postgres
|
|
16
|
+
ports:
|
|
17
|
+
- 5432:5432
|
|
18
|
+
options: >-
|
|
19
|
+
--health-cmd="pg_isready -U postgres"
|
|
20
|
+
--health-interval=10s
|
|
21
|
+
--health-timeout=5s
|
|
22
|
+
--health-retries=5
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: "20"
|
|
29
|
+
cache: "npm"
|
|
30
|
+
|
|
31
|
+
- run: npm ci
|
|
32
|
+
- name: Initialize test database
|
|
33
|
+
env:
|
|
34
|
+
PGPASSWORD: postgres
|
|
35
|
+
run: psql -h localhost -U postgres -f setup-postgres-test.sql
|
|
36
|
+
|
|
37
|
+
- run: npm run build
|
|
38
|
+
- run: npm test
|
|
39
|
+
env:
|
|
40
|
+
DB_CONNECTION: postgresql://testuser:testpassword@localhost:5432/testdb
|
|
41
|
+
- run: npm run lint
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# AGENTS
|
|
2
|
+
|
|
3
|
+
Guidance for automated agents working in this repository.
|
|
4
|
+
|
|
5
|
+
## Repo map (high level)
|
|
6
|
+
- `src/postgres-client.ts`: core client, connection config, transactions, RPC, schema/foreign-key caches.
|
|
7
|
+
- `src/query-builder.ts`: query builder, SQL generation, query execution.
|
|
8
|
+
- `src/types.ts`: public types, schema typing helpers, result shapes.
|
|
9
|
+
- `src/errors.ts`: `PostgresError` wrapper.
|
|
10
|
+
- `src/client.ts`: `SupaliteClient` wrapper over `SupaLitePG`.
|
|
11
|
+
- `src/__tests__`: Jest tests (some use a real Postgres DB).
|
|
12
|
+
|
|
13
|
+
## Runtime behavior to keep in mind
|
|
14
|
+
- QueryBuilder builds SQL and runs it via `pool.query`. Transaction state is tracked on `SupaLitePG`, but QueryBuilder does not currently switch to the transaction client; only schema metadata queries use the transaction client.
|
|
15
|
+
- JSON/JSONB values are stringified on INSERT/UPDATE when the value is an array/object; native arrays (e.g. `text[]`) are passed through as arrays.
|
|
16
|
+
- BigInt handling is configured via `bigintTransform` using pg type parsers.
|
|
17
|
+
- `count: 'exact'` uses a window function and strips `exact_count` from result rows.
|
|
18
|
+
- `head: true` returns `COUNT(*)` only and `data: []`.
|
|
19
|
+
- `single()` / `maybeSingle()` enforce row count and return Supabase-like errors.
|
|
20
|
+
- `or()` expects `col.op.value` segments and only supports a fixed set of operators.
|
|
21
|
+
|
|
22
|
+
## Development workflow
|
|
23
|
+
- Build: `npm run build`
|
|
24
|
+
- Test: `npm test` (integration tests need `DB_CONNECTION` or other DB env vars)
|
|
25
|
+
- Lint: `npm run lint`
|
|
26
|
+
|
|
27
|
+
## Change checklist
|
|
28
|
+
- If you add/modify query behavior:
|
|
29
|
+
- Update `src/query-builder.ts` and relevant types in `src/types.ts`.
|
|
30
|
+
- Add/adjust Jest tests in `src/__tests__` (raw SQL tests are preferred for SQL shape).
|
|
31
|
+
- Update `README.md` and `SPEC.md` to reflect the new behavior.
|
|
32
|
+
- If you add/modify RPC behavior:
|
|
33
|
+
- Update `src/postgres-client.ts` and `src/__tests__/rpc.test.ts`.
|
|
34
|
+
- If you touch JSON/BigInt behavior:
|
|
35
|
+
- Update conversion rules and document in `SPEC.md`.
|
|
36
|
+
|
|
37
|
+
## Safe defaults
|
|
38
|
+
- Prefer explicit, deterministic SQL generation (avoid relying on implicit column order).
|
|
39
|
+
- Keep new docs and examples ASCII unless the file already uses Unicode.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.0] - 2026-01-17
|
|
4
|
+
|
|
5
|
+
### ✨ Added
|
|
6
|
+
- `supalite gen types` CLI to generate TypeScript Database types from PostgreSQL schemas.
|
|
7
|
+
- BIGINT columns are emitted as `bigint` in the generated types.
|
|
8
|
+
- `--date-as-date` option to map `date`/`timestamp` columns to `Date` in generated types.
|
|
9
|
+
- `--include-relationships`, `--include-constraints`, `--include-indexes` options to emit schema metadata.
|
|
10
|
+
- `--include-composite-types` and `--include-function-signatures` options for composite types and typed function signatures.
|
|
11
|
+
- `--type-case` and `--function-case` options to control enum/composite and function key casing.
|
|
12
|
+
- `--dump-functions-sql` option to export `CREATE FUNCTION/PROCEDURE` definitions to a local file.
|
|
13
|
+
- Added gen-types seed/cleanup scripts and limitations docs.
|
|
14
|
+
|
|
15
|
+
## [0.6.1] - 2026-01-16
|
|
16
|
+
|
|
17
|
+
### ✨ Added
|
|
18
|
+
- `count: 'planned' | 'estimated'`가 `EXPLAIN (FORMAT JSON)` 기반 추정치를 반환하도록 추가했습니다.
|
|
19
|
+
|
|
20
|
+
### 🐞 Fixed
|
|
21
|
+
- 트랜잭션 내 쿼리가 트랜잭션 클라이언트로 실행되도록 수정했습니다.
|
|
22
|
+
- `in()`에 `null`이 포함될 때 `IS NULL`을 포함하도록 개선했습니다.
|
|
23
|
+
|
|
24
|
+
## [0.6.0] - 2026-01-16
|
|
25
|
+
|
|
26
|
+
### ✨ Added
|
|
27
|
+
- PostgREST-style embed에 중첩 관계, `!inner`, 관계 테이블 필터(`table.column`) 지원을 추가했습니다.
|
|
28
|
+
- `insert()`에 `onConflict`/`ignoreDuplicates` 옵션을 추가했습니다. (`ON CONFLICT DO NOTHING`)
|
|
29
|
+
- `upsert()`에 `ignoreDuplicates` 옵션을 추가했습니다. (`ON CONFLICT DO NOTHING`)
|
|
30
|
+
- `or()`에서 `now()`를 `NOW()`로 인라인 처리합니다.
|
|
31
|
+
- README 영어화 및 `README.ko.md` 추가.
|
|
32
|
+
- `or()`에 따옴표 값 파싱을 추가해 `,`/`.` 포함 값을 안전하게 처리합니다.
|
|
33
|
+
|
|
34
|
+
### 🐞 Fixed
|
|
35
|
+
- `single()`/`maybeSingle()`/RPC 내부 PGRST 에러에 `error.code`를 채워 분기 처리를 안정화했습니다.
|
|
36
|
+
- RPC가 빈 결과에서 `data: []`를 반환하고, 스칼라 언랩은 스칼라 반환 함수에만 적용합니다.
|
|
37
|
+
|
|
3
38
|
## [0.5.7] - 2026-01-14
|
|
4
39
|
|
|
5
40
|
### ✨ Added
|