@supabase/postgrest-js 2.89.1-canary.1 → 2.89.1-canary.3
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 +77 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -6
- package/src/index.ts +0 -1
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -47,10 +47,10 @@ const REST_URL = 'http://localhost:3000'
|
|
|
47
47
|
const postgrest = new PostgrestClient(REST_URL)
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
- select()
|
|
51
|
-
- insert()
|
|
52
|
-
- update()
|
|
53
|
-
- delete()
|
|
50
|
+
- [select()](https://supabase.com/docs/reference/javascript/select)
|
|
51
|
+
- [insert()](https://supabase.com/docs/reference/javascript/insert)
|
|
52
|
+
- [update()](https://supabase.com/docs/reference/javascript/update)
|
|
53
|
+
- [delete()](https://supabase.com/docs/reference/javascript/delete)
|
|
54
54
|
|
|
55
55
|
#### Custom `fetch` implementation
|
|
56
56
|
|
|
@@ -72,45 +72,22 @@ This package is part of the [Supabase JavaScript monorepo](https://github.com/su
|
|
|
72
72
|
### Building
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
#
|
|
75
|
+
# Build (from monorepo root)
|
|
76
76
|
npx nx build postgrest-js
|
|
77
77
|
|
|
78
78
|
# Build with watch mode for development
|
|
79
|
-
npx nx build postgrest-js
|
|
80
|
-
|
|
81
|
-
# Individual build targets
|
|
82
|
-
npx nx build:cjs postgrest-js # CommonJS build
|
|
83
|
-
npx nx build:esm postgrest-js # ES Modules wrapper
|
|
84
|
-
|
|
85
|
-
# Other useful commands
|
|
86
|
-
npx nx clean postgrest-js # Clean build artifacts
|
|
87
|
-
npx nx format postgrest-js # Format code with Prettier
|
|
88
|
-
npx nx lint postgrest-js # Run ESLint
|
|
89
|
-
npx nx type-check postgrest-js # TypeScript type checking
|
|
90
|
-
npx nx docs postgrest-js # Generate documentation
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
#### Build Outputs
|
|
94
|
-
|
|
95
|
-
- **CommonJS (`dist/cjs/`)** - For Node.js environments
|
|
96
|
-
- `index.js` - Main entry point
|
|
97
|
-
- `index.d.ts` - TypeScript definitions
|
|
98
|
-
- **ES Modules (`dist/esm/`)** - For modern bundlers
|
|
99
|
-
- `wrapper.mjs` - ESM wrapper that imports CommonJS
|
|
100
|
-
|
|
101
|
-
#### Special Build Setup
|
|
79
|
+
npx nx build:watch postgrest-js
|
|
102
80
|
|
|
103
|
-
|
|
81
|
+
# TypeScript type checking
|
|
82
|
+
npx nx type-check postgrest-js
|
|
104
83
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
The `wrapper.mjs` file simply re-exports the CommonJS build, allowing the package to work seamlessly in both CommonJS and ESM contexts.
|
|
84
|
+
# Generate documentation
|
|
85
|
+
npx nx docs postgrest-js
|
|
86
|
+
```
|
|
110
87
|
|
|
111
88
|
### Testing
|
|
112
89
|
|
|
113
|
-
**
|
|
90
|
+
**Supabase CLI Required!** The `postgrest-js` tests use the [Supabase CLI](https://supabase.com/docs/guides/local-development/cli/getting-started) to run a local PostgreSQL database and PostgREST server.
|
|
114
91
|
|
|
115
92
|
#### Quick Start
|
|
116
93
|
|
|
@@ -121,72 +98,99 @@ npx nx test:ci:postgrest postgrest-js
|
|
|
121
98
|
|
|
122
99
|
This single command automatically:
|
|
123
100
|
|
|
124
|
-
1.
|
|
125
|
-
2. Starts PostgreSQL database and PostgREST server
|
|
126
|
-
3.
|
|
127
|
-
4. Runs
|
|
128
|
-
5.
|
|
129
|
-
6. Generates and validates TypeScript types from the database schema
|
|
130
|
-
7. Runs all Jest unit tests with coverage
|
|
131
|
-
8. Runs CommonJS and ESM smoke tests
|
|
132
|
-
9. Cleans up Docker containers
|
|
101
|
+
1. Stops any existing Supabase CLI containers
|
|
102
|
+
2. Starts PostgreSQL database and PostgREST server via Supabase CLI
|
|
103
|
+
3. Resets and seeds the database
|
|
104
|
+
4. Runs all Jest unit tests with coverage
|
|
105
|
+
5. Cleans up containers
|
|
133
106
|
|
|
134
107
|
#### Individual Test Commands
|
|
135
108
|
|
|
136
109
|
```bash
|
|
137
|
-
# Run tests with coverage
|
|
110
|
+
# Run Jest tests with coverage (requires infrastructure running)
|
|
138
111
|
npx nx test:run postgrest-js
|
|
139
112
|
|
|
140
|
-
#
|
|
141
|
-
npx nx test:update postgrest-js
|
|
142
|
-
|
|
143
|
-
# Type checking only
|
|
113
|
+
# Run type tests with tstyche
|
|
144
114
|
npx nx test:types postgrest-js
|
|
145
115
|
|
|
116
|
+
# Run smoke tests (CommonJS and ESM imports)
|
|
117
|
+
npx nx test:smoke postgrest-js
|
|
118
|
+
|
|
119
|
+
# Format code
|
|
120
|
+
npx nx format postgrest-js
|
|
121
|
+
|
|
122
|
+
# Check formatting
|
|
123
|
+
npx nx format:check postgrest-js
|
|
146
124
|
```
|
|
147
125
|
|
|
148
126
|
#### Test Infrastructure
|
|
149
127
|
|
|
150
|
-
The tests use
|
|
128
|
+
The tests use Supabase CLI to spin up:
|
|
151
129
|
|
|
152
|
-
- **PostgreSQL** - Database with test schema and
|
|
153
|
-
- **PostgREST** - REST API server that the client connects to
|
|
130
|
+
- **PostgreSQL** - Database with test schema and seed data (port 54322)
|
|
131
|
+
- **PostgREST** - REST API server that the client connects to (port 54321)
|
|
154
132
|
|
|
155
133
|
```bash
|
|
156
|
-
# Manually manage test infrastructure
|
|
157
|
-
npx nx
|
|
158
|
-
npx nx
|
|
134
|
+
# Manually manage test infrastructure (from monorepo root)
|
|
135
|
+
npx nx test:infra postgrest-js # Start containers
|
|
136
|
+
npx nx test:clean-pre postgrest-js # Stop and remove containers
|
|
159
137
|
```
|
|
160
138
|
|
|
161
|
-
|
|
139
|
+
Or directly via Supabase CLI:
|
|
162
140
|
|
|
163
|
-
|
|
141
|
+
```bash
|
|
142
|
+
cd packages/core/postgrest-js/test
|
|
143
|
+
supabase start # Start all services
|
|
144
|
+
supabase db reset # Reset and seed database
|
|
145
|
+
supabase stop # Stop all services
|
|
146
|
+
```
|
|
164
147
|
|
|
165
|
-
|
|
166
|
-
- Test snapshots need to be updated after intentional changes
|
|
148
|
+
#### Regenerating TypeScript Types
|
|
167
149
|
|
|
168
|
-
|
|
150
|
+
When the database schema changes, regenerate TypeScript types from the actual database:
|
|
169
151
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
152
|
+
```bash
|
|
153
|
+
npx nx db:generate-test-types postgrest-js
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This connects to the running Supabase instance and generates types in `test/types.generated.ts`.
|
|
174
157
|
|
|
175
158
|
#### Test Types Explained
|
|
176
159
|
|
|
177
|
-
- **
|
|
178
|
-
- **Type Tests** - Validates TypeScript types using
|
|
179
|
-
- **
|
|
180
|
-
- **Unit Tests** - Jest tests covering all client functionality
|
|
181
|
-
- **Smoke Tests** - Basic import/require tests for CommonJS and ESM
|
|
160
|
+
- **Unit Tests** - Jest tests covering all client functionality (`npx nx test:run postgrest-js`)
|
|
161
|
+
- **Type Tests** - Validates TypeScript types using tstyche (`npx nx test:types postgrest-js`)
|
|
162
|
+
- **Smoke Tests** - Basic import/require tests for CommonJS and ESM (`npx nx test:smoke postgrest-js`)
|
|
182
163
|
|
|
183
164
|
#### Prerequisites
|
|
184
165
|
|
|
185
|
-
- **
|
|
186
|
-
- **
|
|
187
|
-
- **Port
|
|
166
|
+
- **Supabase CLI** must be installed ([instructions](https://supabase.com/docs/guides/local-development/cli/getting-started)) or can be used through `npx` (`npx supabase`)
|
|
167
|
+
- **Docker** must be installed and running (Supabase CLI uses Docker under the hood)
|
|
168
|
+
- **Port 54321** - PostgREST API
|
|
169
|
+
- **Port 54322** - PostgreSQL database
|
|
170
|
+
- **Port 54323** - Supabase Studio (used for type generation)
|
|
171
|
+
|
|
172
|
+
#### PostgREST v12 Backward Compatibility Tests
|
|
173
|
+
|
|
174
|
+
We maintain backward compatibility tests for PostgREST v12 (the current Supabase CLI uses v14+). These tests ensure the SDK works correctly for users still running older PostgREST versions.
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Run v12 compatibility tests (requires Docker)
|
|
178
|
+
npx nx test:ci:v12 postgrest-js
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
This command:
|
|
182
|
+
|
|
183
|
+
1. Starts PostgREST v12 + PostgreSQL in Docker (ports 3012/5433)
|
|
184
|
+
2. Runs runtime tests that verify v12-specific behavior
|
|
185
|
+
3. Cleans up containers
|
|
186
|
+
|
|
187
|
+
**Type-only tests** for v12 compatibility also run as part of the regular type tests:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npx nx test:types postgrest-js # Includes v12-compat.test-d.ts
|
|
191
|
+
```
|
|
188
192
|
|
|
189
|
-
**Note:**
|
|
193
|
+
**Note:** These v12 tests will be removed when v3 ships (sometime in 2026).
|
|
190
194
|
|
|
191
195
|
### Contributing
|
|
192
196
|
|