supalite 0.7.0 → 0.7.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.2] - 2026-01-17
4
+
5
+ ### ✨ Added
6
+ - `--no-bigint` 옵션을 추가해 BIGINT를 `number`로 출력할 수 있습니다.
7
+
8
+ ### 🐞 Fixed
9
+ - `js-yaml` 의존성을 보안 패치 버전으로 업데이트했습니다. (prototype pollution 대응)
10
+
11
+ ## [0.7.1] - 2026-01-17
12
+
13
+ ### ✨ Added
14
+ - `supalite gen types` 기본 출력이 Supabase CLI 포맷과 최대한 동일하도록 정렬/포맷/헬퍼 타입/Constants를 추가했습니다.
15
+ - `--format supabase|supalite`, `--bigint-type`, `--json-bigint` 옵션을 추가했습니다.
16
+ - Supabase 포맷에서 insertable view에 `Insert`/`Update`를 포함하고, 함수 오버로드 출력 형태를 Supabase와 맞췄습니다.
17
+
18
+ ### 🔧 Changed
19
+ - Supabase 포맷 기본값 기준으로 관계/복합 타입/함수 시그니처가 기본 포함됩니다. (legacy 출력은 `--format supalite`)
20
+
3
21
  ## [0.7.0] - 2026-01-17
4
22
 
5
23
  ### ✨ Added
package/README.ko.md CHANGED
@@ -21,6 +21,12 @@ Supabase 쿼리 빌더에 집중한 가벼운 PostgreSQL 클라이언트입니
21
21
  - ✅ RPC (`single`/`maybeSingle` 포함)
22
22
  - ❌ Auth/Storage/Realtime
23
23
 
24
+ ## 0.7.2 하이라이트
25
+
26
+ - `supalite gen types --format supabase`가 Supabase CLI 출력과 바이트까지 완전히 일치합니다. (정렬/포맷 포함)
27
+ - 기본값인 `--format supalite`는 Supabase 포맷을 확장한 상위 호환 출력으로, 제약/인덱스, 관계의 `referencedSchema`, SETOF 반환 RPC 옵션을 제공합니다.
28
+ - 타입 생성 BigInt 옵션을 추가했습니다: `--no-bigint`, `--no-json-bigint`.
29
+
24
30
  클라우드 마이그레이션 안내 (GCP/AWS):
25
31
  Supabase에서 완전히 분리하려면 SupaLite는 **DB 쿼리 계층만** 대체합니다. Auth/Storage/Realtime은 별도 대안이 필요합니다.
26
32
  - Auth: 관리형 인증(AWS Cognito / Google Identity Platform) 또는 자체 호스팅(GoTrue/Keycloak)
@@ -57,7 +63,7 @@ ORM 기능(관계 모델링/중첩 쓰기 등)이 꼭 필요하면 Prisma/Drizzl
57
63
 
58
64
  `supabase db pull`에 대해서: 이는 ORM 기능이 아니라 마이그레이션/스키마 동기화 단계입니다. SupaLite 내부에 구현하기보다 “권장 워크플로우”로 문서화하고, 필요하다면 `pg-schema-sync` + 타입 생성기를 묶는 간단한 CLI 래퍼가 현실적입니다.
59
65
 
60
- SupaLite 타입 생성기가 필요하다면 `supalite gen types` CLI 로드맵에 추가할 있습니다.
66
+ SupaLite `supalite gen types`를 포함하며, 기본 출력은 SupaLite 포맷(Supabase CLI 출력의 상위 집합)입니다. Supabase CLI와 1:1로 맞추려면 `--format supabase`를 사용하세요.
61
67
 
62
68
  ## SupaLite vs Prisma / Drizzle
63
69
 
@@ -129,7 +135,8 @@ const data = await db
129
135
  - Node/pg 버전별 CI 매트릭스와 통합 테스트
130
136
  - 벤치마크 및 성능 가이드
131
137
  - Auth/Storage/Realtime 마이그레이션 가이드 (Cognito/GIP, S3/GCS, Realtime 대안)
132
- - `supalite gen types` (Supabase 호환 타입 생성기)
138
+ - `pg-schema-sync` 기반 `supalite db pull` 스키마 동기화 래퍼
139
+ - `supalite gen types` (SupaLite 중심 타입 생성기, Supabase 포맷 옵션 제공)
133
140
  - 기여 가이드/이슈 템플릿
134
141
 
135
142
  ## 성능 노트 (서버리스 Supabase vs 클라우드 Postgres)
@@ -254,14 +261,19 @@ npx supalite gen types --db-url "postgresql://user:pass@localhost:5432/db" --sch
254
261
  ```
255
262
 
256
263
  - `--out -`는 stdout으로 출력합니다.
257
- - BIGINT 컬럼은 `bigint`로 생성됩니다.
264
+ - 기본 출력은 SupaLite 포맷(= Supabase CLI의 상위 집합)입니다. Supabase CLI와 1:1로 맞추려면 `--format supabase`를 사용하세요.
265
+ - SupaLite 포맷은 `Constraints`/`Indexes`, `Relationships`의 `referencedSchema`, `bigint` + `Json` bigint 지원, setof RPC용 `SetofOptions`를 추가로 포함합니다.
266
+ - BIGINT 컬럼 타입은 `--bigint-type bigint|number|string`로 제어합니다. (기본: supabase=number, supalite=bigint)
267
+ - `--no-bigint`는 `--bigint-type number`의 간편 옵션입니다.
268
+ - `--json-bigint`는 `Json` 타입에 `bigint`를 포함합니다. (기본: supabase=false, supalite=true)
269
+ - `--no-json-bigint`는 `Json` 타입에서 `bigint`를 제외합니다.
258
270
  - `--date-as-date`는 `date`/`timestamp` 컬럼을 `Date`로 생성합니다.
259
- - `--include-relationships`는 FK 메타데이터를 `Relationships`에 포함합니다.
260
- - `--include-constraints`는 PK/UNIQUE/CHECK/FK 메타데이터를 포함합니다.
261
- - `--include-indexes`는 인덱스 메타데이터(이름/유니크/정의)를 포함합니다.
262
- - `--include-composite-types`는 `CompositeTypes` 정의를 포함합니다.
263
- - `--include-function-signatures`는 `Functions.Args/Returns`를 스키마 메타데이터로 매핑합니다.
264
- - `Functions`에는 감지된 함수명이 기본 포함되며, `--include-function-signatures`로 RPC Args/Returns 참고가 가능합니다.
271
+ - `--include-relationships`는 FK 메타데이터를 `Relationships`에 포함합니다. (기본: true)
272
+ - `--include-constraints`는 PK/UNIQUE/CHECK/FK 메타데이터를 포함합니다. (기본: supabase=false, supalite=true)
273
+ - `--include-indexes`는 인덱스 메타데이터(이름/유니크/정의)를 포함합니다. (기본: supabase=false, supalite=true)
274
+ - `--include-composite-types`는 `CompositeTypes` 정의를 포함합니다. (기본: true)
275
+ - `--include-function-signatures`는 `Functions.Args/Returns`를 스키마 메타데이터로 매핑합니다. (기본: true)
276
+ - `Functions`에는 감지된 함수명이 기본 포함되며, 시그니처도 기본 포함됩니다.
265
277
  - `--type-case`는 enum/composite 타입 키의 케이스를 제어합니다 (`preserve` | `snake` | `camel` | `pascal`)
266
278
  - `--function-case`는 함수 키의 케이스를 제어합니다 (`preserve` | `snake` | `camel` | `pascal`)
267
279
  - `--dump-functions-sql [path]`는 `pg_get_functiondef` 기반의 `CREATE FUNCTION/PROCEDURE` 정의를 로컬 파일로 저장합니다.
@@ -302,6 +314,21 @@ const client = new SupaliteClient<Database>({
302
314
  });
303
315
  ```
304
316
 
317
+ ```typescript
318
+ import { Pool } from 'pg';
319
+ import { SupaLitePG } from 'supalite';
320
+ import { Database } from './types/database';
321
+
322
+ const pool = new Pool({
323
+ connectionString: process.env.DB_CONNECTION || 'postgresql://user:pass@localhost:5432/db',
324
+ max: 5,
325
+ });
326
+
327
+ const client = new SupaLitePG<Database>({
328
+ pool,
329
+ });
330
+ ```
331
+
305
332
  ### 기본 CRUD 작업
306
333
 
307
334
  ```typescript
@@ -1026,7 +1053,7 @@ await client.close();
1026
1053
  ### 클라이언트 메소드
1027
1054
 
1028
1055
  - `testConnection()`: 데이터베이스 연결 확인
1029
- - `close()`: 커넥션 풀 종료
1056
+ - `close()`: 내부 커넥션 풀 종료 (외부 `pool` 사용 시 no-op)
1030
1057
 
1031
1058
  ## 환경 변수 설정
1032
1059
 
@@ -1046,6 +1073,7 @@ DB_SSL=true
1046
1073
 
1047
1074
  `SupaLitePG` 생성자는 다음 옵션을 받을 수 있습니다:
1048
1075
 
1076
+ - `pool?: Pool`: 외부 `pg` Pool 인스턴스를 사용합니다. 이 경우 다른 연결 옵션은 무시되고, 풀의 생성/종료는 호출자가 관리합니다.
1049
1077
  - `connectionString?: string`: PostgreSQL 연결 문자열 (예: `postgresql://user:password@host:port/database`). 제공되면 다른 연결 매개변수보다 우선합니다.
1050
1078
  - `user?: string`: 데이터베이스 사용자 이름 (환경 변수: `DB_USER`).
1051
1079
  - `host?: string`: 데이터베이스 호스트 (환경 변수: `DB_HOST`).
package/README.md CHANGED
@@ -22,6 +22,12 @@ Compatibility at a glance:
22
22
  - ✅ RPC (including `single`/`maybeSingle`)
23
23
  - ❌ Auth/Storage/Realtime
24
24
 
25
+ ## 0.7.2 Highlights
26
+
27
+ - `supalite gen types --format supabase` now matches Supabase CLI output byte-for-byte (ordering + formatting).
28
+ - Default `--format supalite` is a superset with extra schema metadata (constraints/indexes, referenced schema in relationships, set-returning RPC options).
29
+ - New BigInt controls for generated types: `--no-bigint` and `--no-json-bigint`.
30
+
25
31
  Cloud migration note (GCP/AWS):
26
32
  If you are moving off Supabase, SupaLite replaces only the **DB query layer**. You still need alternatives for Auth/Storage/Realtime. Typical choices are:
27
33
  - Auth: managed identity (AWS Cognito / Google Identity Platform) or self-hosted (GoTrue/Keycloak)
@@ -58,7 +64,7 @@ ORM features (relations, nested writes, etc.) are best handled by Prisma/Drizzle
58
64
 
59
65
  About `supabase db pull`: it is a schema/migration sync step, not an ORM feature. Rather than implementing it inside SupaLite, we recommend documenting the workflow and optionally providing a lightweight CLI wrapper that combines `pg-schema-sync` + type generation.
60
66
 
61
- If a SupaLite-native type generator makes sense, we can add a `supalite gen types` CLI in the roadmap.
67
+ SupaLite now includes `supalite gen types`, which defaults to the SupaLite format (a superset of Supabase CLI output). Use `--format supabase` for byte-for-byte Supabase CLI output.
62
68
 
63
69
  ## SupaLite vs Prisma / Drizzle
64
70
 
@@ -130,7 +136,8 @@ const data = await db
130
136
  - CI matrix for Node/pg versions with integration tests
131
137
  - Benchmarks and performance guidance
132
138
  - Auth/Storage/Realtime migration guidance (Cognito/GIP, S3/GCS, Realtime options)
133
- - `supalite gen types` (Supabase-compatible type generator)
139
+ - `supalite db pull` wrapper around `pg-schema-sync` for schema sync
140
+ - `supalite gen types` (SupaLite-first generator with Supabase-compatible output)
134
141
  - Contribution guide and issue templates
135
142
 
136
143
  ## Performance notes (serverless Supabase vs cloud Postgres)
@@ -255,14 +262,19 @@ npx supalite gen types --db-url "postgresql://user:pass@localhost:5432/db" --sch
255
262
  ```
256
263
 
257
264
  - `--out -` prints to stdout
258
- - BIGINT columns map to `bigint`
265
+ - Default output is SupaLite format (superset of Supabase CLI). Use `--format supabase` for byte-for-byte Supabase CLI output.
266
+ - SupaLite format also includes `Constraints`/`Indexes`, `referencedSchema` in `Relationships`, `bigint` + `Json` bigint support, and `SetofOptions` for setof RPCs.
267
+ - BIGINT type mapping is controlled by `--bigint-type bigint|number|string` (default: supabase=number, supalite=bigint)
268
+ - `--no-bigint` is a shortcut for `--bigint-type number`
269
+ - `--json-bigint` includes `bigint` in the `Json` union (default: supabase=false, supalite=true)
270
+ - `--no-json-bigint` disables bigint in the `Json` union
259
271
  - `--date-as-date` maps `date`/`timestamp` columns to `Date`
260
- - `--include-relationships` emits foreign-key metadata into `Relationships`
261
- - `--include-constraints` emits primary/unique/check/foreign key metadata
262
- - `--include-indexes` emits index metadata (name, uniqueness, definition)
263
- - `--include-composite-types` emits `CompositeTypes` definitions
264
- - `--include-function-signatures` maps `Functions.Args/Returns` from schema metadata
265
- - `Functions` always lists detected function names; use `--include-function-signatures` for RPC Args/Returns reference
272
+ - `--include-relationships` emits foreign-key metadata into `Relationships` (default: true)
273
+ - `--include-constraints` emits primary/unique/check/foreign key metadata (default: supabase=false, supalite=true)
274
+ - `--include-indexes` emits index metadata (name, uniqueness, definition) (default: supabase=false, supalite=true)
275
+ - `--include-composite-types` emits `CompositeTypes` definitions (default: true)
276
+ - `--include-function-signatures` maps `Functions.Args/Returns` from schema metadata (default: true)
277
+ - `Functions` always lists detected function names; signatures are included by default
266
278
  - `--type-case` controls enum/composite type key casing (`preserve` | `snake` | `camel` | `pascal`)
267
279
  - `--function-case` controls function key casing (`preserve` | `snake` | `camel` | `pascal`)
268
280
  - `--dump-functions-sql [path]` writes `CREATE FUNCTION/PROCEDURE` definitions (from `pg_get_functiondef`) to a local file
@@ -302,6 +314,21 @@ const client = new SupaliteClient<Database>({
302
314
  });
303
315
  ```
304
316
 
317
+ ```typescript
318
+ import { Pool } from 'pg';
319
+ import { SupaLitePG } from 'supalite';
320
+ import { Database } from './types/database';
321
+
322
+ const pool = new Pool({
323
+ connectionString: process.env.DB_CONNECTION || 'postgresql://user:pass@localhost:5432/db',
324
+ max: 5,
325
+ });
326
+
327
+ const client = new SupaLitePG<Database>({
328
+ pool,
329
+ });
330
+ ```
331
+
305
332
  ### Basic CRUD
306
333
 
307
334
  ```typescript
@@ -1042,6 +1069,7 @@ DB_SSL=true
1042
1069
 
1043
1070
  ### SupaLitePG constructor options
1044
1071
 
1072
+ - `pool?: Pool`: use an external `pg` Pool instance (other connection options are ignored; pool lifecycle is managed by the caller)
1045
1073
  - `connectionString?: string`: connection string (e.g. `postgresql://user:password@host:port/database`)
1046
1074
  - `user?: string`: DB user (env: `DB_USER`)
1047
1075
  - `host?: string`: DB host (env: `DB_HOST`)
package/SPEC.md CHANGED
@@ -13,6 +13,7 @@ SupaLite is a lightweight TypeScript PostgreSQL client that mirrors a subset of
13
13
 
14
14
  #### Construction
15
15
  - Accepts either `connectionString` or discrete connection params.
16
+ - Optional `pool` lets callers inject an existing `pg` Pool (SupaLite does not create or close the pool).
16
17
  - Env vars supported: `DB_CONNECTION`, `DB_USER`, `DB_HOST`, `DB_NAME`, `DB_PASS`, `DB_PORT`, `DB_SSL`.
17
18
  - `bigintTransform`: `'bigint' | 'string' | 'number'` controls how BIGINT values are parsed.
18
19
  - `verbose`: logs SQL, values, and warnings for risky bigint-to-number conversions.
@@ -40,7 +41,7 @@ Notes:
40
41
 
41
42
  ### 2.4 Utilities
42
43
  - `testConnection()` to validate connectivity.
43
- - `close()` to shut down the pool.
44
+ - `close()` to shut down the internal pool (no-op when using an external `pool`).
44
45
 
45
46
  ## 3. Result Shapes
46
47
 
@@ -155,7 +156,11 @@ Notes:
155
156
  - `supalite gen types --db-url <postgres_url> [--schema public,analytics] [--out supalite.types.ts]`
156
157
  - Reads schema metadata from `information_schema` and `pg_catalog`.
157
158
  - Emits `Json` and a `Database` type with `Tables`, `Views`, `Functions`, `Enums`, and `CompositeTypes`.
158
- - `BIGINT` maps to `bigint`; `json/jsonb` map to `Json`.
159
+ - `--format supalite|supabase` (default: supalite).
160
+ - `--format supabase` matches Supabase CLI output (including formatting).
161
+ - SupaLite format is a superset of Supabase: `Constraints`/`Indexes`, `referencedSchema` in `Relationships`, `bigint` defaults, `Json` bigint, and `SetofOptions` for setof RPCs.
162
+ - `BIGINT` maps to `bigint` by default (`--format supabase` defaults to `number`); `--no-bigint` is a shorthand for `--bigint-type number`.
163
+ - `json/jsonb` map to `Json` with optional `bigint` (`--json-bigint` default: supalite=true, supabase=false; disable via `--no-json-bigint`).
159
164
  - `--date-as-date` maps `date`/`timestamp` columns to `Date`.
160
165
  - `--include-relationships` emits FK metadata in `Relationships`.
161
166
  - `--include-constraints` emits PK/UNIQUE/CHECK/FK metadata per table.
package/dist/cli.js CHANGED
@@ -11,6 +11,11 @@ const printUsage = () => {
11
11
  --db-url <postgres_url> \\
12
12
  [--schema public,analytics] \\
13
13
  [--out supalite.types.ts] \\
14
+ [--format supabase|supalite] \\
15
+ [--bigint-type bigint|number|string] \\
16
+ [--no-bigint] \\
17
+ [--json-bigint] \\
18
+ [--no-json-bigint] \\
14
19
  [--date-as-date] \\
15
20
  [--include-relationships] \\
16
21
  [--include-constraints] \\
@@ -24,12 +29,16 @@ const printUsage = () => {
24
29
  Defaults:
25
30
  - schema: public
26
31
  - out: supalite.types.ts (use --out - to print to stdout)
32
+ - format: supalite
27
33
  - dateAsDate: false
28
- - includeRelationships: false
29
- - includeConstraints: false
30
- - includeIndexes: false
31
- - includeCompositeTypes: false
32
- - includeFunctionSignatures: false
34
+ - includeRelationships: true
35
+ - includeConstraints: false (supabase), true (supalite)
36
+ - includeIndexes: false (supabase), true (supalite)
37
+ - includeCompositeTypes: true
38
+ - includeFunctionSignatures: true
39
+ - bigintType: number (supabase), bigint (supalite)
40
+ - noBigint: false
41
+ - jsonBigint: false (supabase), true (supalite)
33
42
  - typeCase: preserve
34
43
  - functionCase: preserve
35
44
  - dumpFunctionsSql: false
@@ -44,16 +53,37 @@ const parseCase = (value) => {
44
53
  }
45
54
  return undefined;
46
55
  };
56
+ const parseFormat = (value) => {
57
+ if (!value) {
58
+ return undefined;
59
+ }
60
+ if (value === 'supabase' || value === 'supalite') {
61
+ return value;
62
+ }
63
+ return undefined;
64
+ };
65
+ const parseBigintType = (value) => {
66
+ if (!value) {
67
+ return undefined;
68
+ }
69
+ if (value === 'bigint' || value === 'number' || value === 'string') {
70
+ return value;
71
+ }
72
+ return undefined;
73
+ };
47
74
  const parseArgs = (args) => {
48
75
  const result = {
49
76
  schemas: [],
50
77
  out: 'supalite.types.ts',
78
+ format: undefined,
79
+ bigintType: undefined,
80
+ jsonBigint: undefined,
51
81
  dateAsDate: false,
52
- includeRelationships: false,
53
- includeConstraints: false,
54
- includeIndexes: false,
55
- includeCompositeTypes: false,
56
- includeFunctionSignatures: false,
82
+ includeRelationships: undefined,
83
+ includeConstraints: undefined,
84
+ includeIndexes: undefined,
85
+ includeCompositeTypes: undefined,
86
+ includeFunctionSignatures: undefined,
57
87
  dumpFunctionsSql: false,
58
88
  help: false,
59
89
  };
@@ -83,6 +113,28 @@ const parseArgs = (args) => {
83
113
  i += 1;
84
114
  continue;
85
115
  }
116
+ if (arg === '--format') {
117
+ result.format = parseFormat(args[i + 1]);
118
+ i += 1;
119
+ continue;
120
+ }
121
+ if (arg === '--bigint-type') {
122
+ result.bigintType = parseBigintType(args[i + 1]);
123
+ i += 1;
124
+ continue;
125
+ }
126
+ if (arg === '--no-bigint') {
127
+ result.bigintType = 'number';
128
+ continue;
129
+ }
130
+ if (arg === '--json-bigint') {
131
+ result.jsonBigint = true;
132
+ continue;
133
+ }
134
+ if (arg === '--no-json-bigint') {
135
+ result.jsonBigint = false;
136
+ continue;
137
+ }
86
138
  if (arg === '--date-as-date') {
87
139
  result.dateAsDate = true;
88
140
  continue;
@@ -150,6 +202,9 @@ const run = async () => {
150
202
  const output = await (0, gen_types_1.generateTypes)({
151
203
  dbUrl,
152
204
  schemas,
205
+ format: parsed.format,
206
+ bigintType: parsed.bigintType,
207
+ jsonBigint: parsed.jsonBigint,
153
208
  dateAsDate: parsed.dateAsDate,
154
209
  includeRelationships: parsed.includeRelationships,
155
210
  includeConstraints: parsed.includeConstraints,
@@ -1,4 +1,6 @@
1
1
  type NameCase = 'preserve' | 'snake' | 'camel' | 'pascal';
2
+ type OutputFormat = 'supalite' | 'supabase';
3
+ type BigintType = 'bigint' | 'number' | 'string';
2
4
  export type GenTypesOptions = {
3
5
  dbUrl: string;
4
6
  schemas?: string[];
@@ -10,6 +12,9 @@ export type GenTypesOptions = {
10
12
  includeFunctionSignatures?: boolean;
11
13
  typeCase?: NameCase;
12
14
  functionCase?: NameCase;
15
+ format?: OutputFormat;
16
+ bigintType?: BigintType;
17
+ jsonBigint?: boolean;
13
18
  };
14
19
  export type DumpFunctionsSqlOptions = {
15
20
  dbUrl: string;