@supabase/supabase-js 2.79.1-canary.1 → 2.80.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/README.md +50 -283
- package/dist/main/SupabaseClient.d.ts +6 -5
- package/dist/main/SupabaseClient.d.ts.map +1 -1
- package/dist/main/SupabaseClient.js +15 -21
- package/dist/main/SupabaseClient.js.map +1 -1
- package/dist/main/lib/fetch.d.ts +4 -1
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +5 -59
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.js +1 -10
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/rest/types/common/common.d.ts +55 -0
- package/dist/main/lib/rest/types/common/common.d.ts.map +1 -0
- package/dist/main/lib/rest/types/common/common.js +12 -0
- package/dist/main/lib/rest/types/common/common.js.map +1 -0
- package/dist/main/lib/rest/types/common/rpc.d.ts +46 -0
- package/dist/main/lib/rest/types/common/rpc.d.ts.map +1 -0
- package/dist/main/lib/rest/types/common/rpc.js +12 -0
- package/dist/main/lib/rest/types/common/rpc.js.map +1 -0
- package/dist/main/lib/types.d.ts +11 -34
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/module/SupabaseClient.d.ts +6 -5
- package/dist/module/SupabaseClient.d.ts.map +1 -1
- package/dist/module/SupabaseClient.js +16 -22
- package/dist/module/SupabaseClient.js.map +1 -1
- package/dist/module/lib/fetch.d.ts +4 -1
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +5 -26
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.js +1 -10
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/rest/types/common/common.d.ts +55 -0
- package/dist/module/lib/rest/types/common/common.d.ts.map +1 -0
- package/dist/module/lib/rest/types/common/common.js +11 -0
- package/dist/module/lib/rest/types/common/common.js.map +1 -0
- package/dist/module/lib/rest/types/common/rpc.d.ts +46 -0
- package/dist/module/lib/rest/types/common/rpc.d.ts.map +1 -0
- package/dist/module/lib/rest/types/common/rpc.js +11 -0
- package/dist/module/lib/rest/types/common/rpc.js.map +1 -0
- package/dist/module/lib/types.d.ts +11 -34
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +48 -24
- package/src/SupabaseClient.ts +46 -22
- package/src/lib/fetch.ts +2 -14
- package/src/lib/rest/types/common/common.ts +66 -0
- package/src/lib/rest/types/common/rpc.ts +145 -0
- package/src/lib/types.ts +27 -41
- package/src/lib/version.ts +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<br />
|
|
2
|
+
<p align="center">
|
|
3
|
+
<a href="https://supabase.io">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/supabase/supabase/master/packages/common/assets/images/supabase-logo-wordmark--dark.svg">
|
|
6
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/supabase/supabase/master/packages/common/assets/images/supabase-logo-wordmark--light.svg">
|
|
7
|
+
<img alt="Supabase Logo" width="300" src="https://raw.githubusercontent.com/supabase/supabase/master/packages/common/assets/images/logo-preview.jpg">
|
|
8
|
+
</picture>
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
<h1 align="center">Supabase JS SDK</h1>
|
|
12
|
+
|
|
13
|
+
<h3 align="center">Isomorphic JavaScript SDK for Supabase - combining Auth, Database, Storage, Functions, and Realtime.</h3>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://supabase.com/docs/guides/getting-started">Guides</a>
|
|
17
|
+
·
|
|
18
|
+
<a href="https://supabase.com/docs/reference/javascript/start">Reference Docs</a>
|
|
19
|
+
·
|
|
20
|
+
<a href="https://supabase.github.io/supabase-js/supabase-js/v2/spec.json">TypeDoc</a>
|
|
21
|
+
</p>
|
|
22
|
+
</p>
|
|
5
23
|
|
|
6
24
|
<div align="center">
|
|
7
25
|
|
|
26
|
+
[](https://github.com/supabase/supabase-js/actions?query=branch%3Amaster)
|
|
27
|
+
[](https://www.npmjs.com/package/@supabase/supabase-js)
|
|
28
|
+
[](#license)
|
|
8
29
|
[](https://pkg.pr.new/~/supabase/supabase-js)
|
|
9
30
|
|
|
10
31
|
</div>
|
|
@@ -99,311 +120,57 @@ We only support Node.js versions that are in **Active LTS** or **Maintenance** s
|
|
|
99
120
|
|
|
100
121
|
When a Node.js version reaches end-of-life and is no longer in Active LTS or Maintenance status, Supabase will drop it in a **minor release**, and **this won't be considered a breaking change**.
|
|
101
122
|
|
|
123
|
+
> ⚠️ **Node.js 18 Deprecation Notice**
|
|
124
|
+
>
|
|
125
|
+
> Node.js 18 reached end-of-life on April 30, 2025. As announced in [our deprecation notice](https://github.com/orgs/supabase/discussions/37217), support for Node.js 18 was dropped in version `2.79.0`.
|
|
126
|
+
>
|
|
127
|
+
> If you must use Node.js 18, please use version `2.78.0`, which is the last version that supported Node.js 18.
|
|
128
|
+
|
|
102
129
|
### Deno
|
|
103
130
|
|
|
104
131
|
We support Deno versions that are currently receiving active development and security updates. We follow the [official Deno release schedule](https://docs.deno.com/runtime/fundamentals/stability_and_releases/) and only support versions from the `stable` and `lts` release channels.
|
|
105
132
|
|
|
106
133
|
When a Deno version reaches end-of-life and is no longer receiving security updates, Supabase will drop it in a **minor release**, and **this won't be considered a breaking change**.
|
|
107
134
|
|
|
108
|
-
###
|
|
135
|
+
### Browsers
|
|
109
136
|
|
|
110
|
-
|
|
137
|
+
All modern browsers are supported. We support browsers that provide native `fetch` API. For Realtime features, browsers must also support native `WebSocket` API.
|
|
111
138
|
|
|
112
|
-
|
|
139
|
+
### Bun
|
|
113
140
|
|
|
114
|
-
|
|
141
|
+
We support Bun runtime environments. Bun provides native fetch support and is compatible with Node.js APIs. Since Bun does not follow a structured release schedule like Node.js or Deno, we support current stable versions of Bun and may drop support for older versions in minor releases without considering it a breaking change.
|
|
115
142
|
|
|
116
|
-
###
|
|
143
|
+
### React Native
|
|
117
144
|
|
|
118
|
-
|
|
119
|
-
# From the monorepo root
|
|
120
|
-
npx nx build supabase-js
|
|
121
|
-
|
|
122
|
-
# Or with watch mode for development
|
|
123
|
-
npx nx build supabase-js --watch
|
|
124
|
-
```
|
|
145
|
+
We support React Native environments with fetch polyfills provided by the framework. Since React Native does not follow a structured release schedule, we support current stable versions and may drop support for older versions in minor releases without considering it a breaking change.
|
|
125
146
|
|
|
126
|
-
###
|
|
127
|
-
|
|
128
|
-
**Important:** The test suite includes tests for multiple runtime environments (Node.js, Deno, Bun, Expo, Next.js). Each environment has its own test runner and specific requirements.
|
|
129
|
-
|
|
130
|
-
#### Prerequisites for All Integration Tests
|
|
131
|
-
|
|
132
|
-
1. **Docker** must be installed and running
|
|
133
|
-
2. **Supabase CLI** must be installed (`npm install -g supabase` or via package manager)
|
|
134
|
-
3. **Local Supabase instance** must be started:
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
# Navigate to the supabase-js package directory
|
|
138
|
-
cd packages/core/supabase-js
|
|
139
|
-
|
|
140
|
-
# Start Supabase (downloads and starts all required containers)
|
|
141
|
-
npx supabase start
|
|
142
|
-
|
|
143
|
-
# The output will show:
|
|
144
|
-
# - API URL: http://127.0.0.1:54321
|
|
145
|
-
# - Database URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
|
|
146
|
-
# - Studio URL: http://127.0.0.1:54323
|
|
147
|
-
# - Anon key: [your-anon-key]
|
|
148
|
-
# - Service role key: [your-service-role-key] # Important for some tests!
|
|
149
|
-
|
|
150
|
-
# Return to monorepo root for running tests
|
|
151
|
-
cd ../../..
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
#### Test Scripts Overview
|
|
155
|
-
|
|
156
|
-
| Script | Description | Requirements |
|
|
157
|
-
| -------------------------- | ----------------------------------------- | --------------------------------------- |
|
|
158
|
-
| `test` | Runs unit tests + type checking | None |
|
|
159
|
-
| `test:all` | Unit + integration + browser tests | Supabase running |
|
|
160
|
-
| `test:run` | Jest unit tests only | None |
|
|
161
|
-
| `test:unit` | Jest unit tests in test/unit directory | None |
|
|
162
|
-
| `test:coverage` | Unit tests with coverage report | None |
|
|
163
|
-
| `test:integration` | Node.js integration tests | Supabase running + SERVICE_ROLE_KEY |
|
|
164
|
-
| `test:integration:browser` | Browser tests using Deno + Puppeteer | Supabase running + Deno installed |
|
|
165
|
-
| `test:edge-functions` | Edge Functions tests | Supabase running + Deno installed |
|
|
166
|
-
| `test:types` | TypeScript type checking + JSR validation | None |
|
|
167
|
-
| `test:deno` | Deno runtime compatibility tests | Supabase running + Deno installed |
|
|
168
|
-
| `test:bun` | Bun runtime compatibility tests | Supabase running + Bun installed |
|
|
169
|
-
| Expo (see section below) | React Native/Expo tests | Supabase running + dependencies updated |
|
|
170
|
-
| Next.js (see below) | Next.js SSR tests | Supabase running + dependencies updated |
|
|
171
|
-
| `test:node:playwright` | WebSocket browser tests | Supabase running + Playwright |
|
|
172
|
-
|
|
173
|
-
#### Unit Testing
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
# Run all unit tests (Jest)
|
|
177
|
-
npx nx test supabase-js
|
|
147
|
+
### Cloudflare Workers
|
|
178
148
|
|
|
179
|
-
|
|
180
|
-
npx nx test:unit supabase-js
|
|
181
|
-
|
|
182
|
-
# Run tests in watch mode during development
|
|
183
|
-
npx nx test supabase-js --watch
|
|
184
|
-
|
|
185
|
-
# Run tests with coverage report
|
|
186
|
-
npx nx test:coverage supabase-js
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
#### Integration Testing
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
# Prerequisites: Start Supabase first (see above)
|
|
193
|
-
|
|
194
|
-
# Run Node.js integration tests
|
|
195
|
-
# IMPORTANT: Requires SUPABASE_SERVICE_ROLE_KEY environment variable
|
|
196
|
-
cd packages/core/supabase-js
|
|
197
|
-
export SUPABASE_SERVICE_ROLE_KEY="$(npx supabase status --output json | jq -r '.SERVICE_ROLE_KEY')"
|
|
198
|
-
cd ../../..
|
|
199
|
-
npx nx test:integration supabase-js
|
|
200
|
-
|
|
201
|
-
# Run browser-based integration tests (requires Deno)
|
|
202
|
-
npx nx test:integration:browser supabase-js
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
#### Running All Tests
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
# This runs type checking, unit tests, and integration tests sequentially
|
|
209
|
-
# NOTE: Will fail if Supabase is not running or dependencies not updated
|
|
210
|
-
npx nx test:all supabase-js
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**Common Issues and Solutions:**
|
|
214
|
-
|
|
215
|
-
| Issue | Solution |
|
|
216
|
-
| -------------------------------------------- | --------------------------------------------------------------- |
|
|
217
|
-
| "Cannot find module 'https://deno.land/...'" | Deno tests incorrectly run by Jest - check `jest.config.ts` |
|
|
218
|
-
| "Port 54322 already allocated" | Stop existing Supabase: `npx supabase stop --project-id <name>` |
|
|
219
|
-
| "503 Service Unavailable" for Edge Functions | Supabase not running - start with `npx supabase start` |
|
|
220
|
-
| "Uncommitted changes" during type check | Commit changes or add `--allow-dirty` to JSR publish |
|
|
221
|
-
| Integration tests fail with auth errors | Export `SUPABASE_SERVICE_ROLE_KEY` (see Integration Testing) |
|
|
222
|
-
|
|
223
|
-
### Platform-Specific Testing
|
|
224
|
-
|
|
225
|
-
#### Expo Testing (React Native)
|
|
226
|
-
|
|
227
|
-
```bash
|
|
228
|
-
# Prerequisites:
|
|
229
|
-
# 1. Supabase must be running (see Prerequisites)
|
|
230
|
-
# 2. Update test dependencies and pack current build
|
|
231
|
-
npx nx update:test-deps:expo supabase-js
|
|
232
|
-
|
|
233
|
-
# Run Expo tests from the Expo test project
|
|
234
|
-
cd packages/core/supabase-js/test/integration/expo
|
|
235
|
-
npm install
|
|
236
|
-
npm test
|
|
237
|
-
cd ../../..
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
#### Next.js Testing (SSR)
|
|
241
|
-
|
|
242
|
-
```bash
|
|
243
|
-
# Prerequisites:
|
|
244
|
-
# 1. Supabase must be running (see Prerequisites)
|
|
245
|
-
# 2. Update test dependencies and pack current build
|
|
246
|
-
npx nx update:test-deps:next supabase-js
|
|
247
|
-
|
|
248
|
-
# 3. Install Playwright browsers and dependencies
|
|
249
|
-
npx playwright install --with-deps
|
|
250
|
-
|
|
251
|
-
# Run Next.js tests from the Next test project
|
|
252
|
-
cd packages/core/supabase-js/test/integration/next
|
|
253
|
-
npm install --legacy-peer-deps
|
|
254
|
-
npm run test
|
|
255
|
-
cd ../../..
|
|
256
|
-
```
|
|
149
|
+
We support Cloudflare Workers runtime environments. Cloudflare Workers provides native fetch support. Since Cloudflare Workers does not follow a structured release schedule, we support current stable versions and may drop support for older versions in minor releases without considering it a breaking change.
|
|
257
150
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
# Prerequisites:
|
|
262
|
-
# 1. Deno must be installed (https://deno.land)
|
|
263
|
-
# 2. Supabase must be running (see Prerequisites)
|
|
264
|
-
# 3. Update test dependencies:
|
|
265
|
-
npx nx update:test-deps:deno supabase-js
|
|
266
|
-
|
|
267
|
-
# Run Deno tests
|
|
268
|
-
npx nx test:deno supabase-js
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Edge Functions Testing
|
|
272
|
-
|
|
273
|
-
The project includes Edge Functions integration tests that require a local Supabase instance to be running.
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
# Prerequisites:
|
|
277
|
-
# 1. Ensure Docker is installed and running
|
|
278
|
-
# 2. Navigate to the supabase-js package directory
|
|
279
|
-
cd packages/core/supabase-js
|
|
280
|
-
|
|
281
|
-
# 3. Start Supabase locally (this will download and start all required containers)
|
|
282
|
-
npx supabase start
|
|
283
|
-
|
|
284
|
-
# Wait for the output showing all services are ready, including:
|
|
285
|
-
# - API URL: http://127.0.0.1:54321
|
|
286
|
-
# - Database URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
|
|
287
|
-
# - Edge Runtime container
|
|
288
|
-
|
|
289
|
-
# 4. Run the Edge Functions tests from the monorepo root
|
|
290
|
-
cd ../../../ # Back to monorepo root
|
|
291
|
-
npx nx test:edge-functions supabase-js
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
**Important Notes:**
|
|
295
|
-
|
|
296
|
-
- The Edge Functions tests will fail with 503 errors if Supabase is not running
|
|
297
|
-
- If you encounter port conflicts (e.g., "port 54322 already allocated"), stop any existing Supabase instances:
|
|
151
|
+
### Important Notes
|
|
298
152
|
|
|
299
|
-
|
|
300
|
-
npx supabase stop --project-id <project-name>
|
|
301
|
-
# Or stop all Docker containers if unsure:
|
|
302
|
-
docker ps | grep supabase # List all Supabase containers
|
|
303
|
-
```
|
|
153
|
+
- **Experimental features**: Features marked as experimental may be removed or changed without notice
|
|
304
154
|
|
|
305
|
-
|
|
306
|
-
- Edge Functions are automatically served when `supabase start` is run
|
|
155
|
+
## Contributing
|
|
307
156
|
|
|
308
|
-
|
|
157
|
+
We welcome contributions! Please see our [Contributing Guide](../../../CONTRIBUTING.md) for details on how to get started.
|
|
309
158
|
|
|
310
|
-
|
|
311
|
-
# Prerequisites:
|
|
312
|
-
# 1. Bun must be installed (https://bun.sh)
|
|
313
|
-
# 2. Supabase must be running (see Prerequisites)
|
|
314
|
-
# 3. Update test dependencies:
|
|
315
|
-
npx nx update:test-deps:bun supabase-js
|
|
316
|
-
|
|
317
|
-
# Run Bun tests
|
|
318
|
-
npx nx test:bun supabase-js
|
|
319
|
-
```
|
|
159
|
+
For major changes or if you're unsure about something, please open an issue first to discuss your proposed changes.
|
|
320
160
|
|
|
321
|
-
|
|
161
|
+
### Building
|
|
322
162
|
|
|
323
163
|
```bash
|
|
324
|
-
#
|
|
325
|
-
# 1. Supabase must be running (see Prerequisites)
|
|
326
|
-
# 2. Build the UMD bundle first:
|
|
164
|
+
# From the monorepo root
|
|
327
165
|
npx nx build supabase-js
|
|
328
166
|
|
|
329
|
-
#
|
|
330
|
-
|
|
331
|
-
npm install
|
|
332
|
-
cp ../../../dist/umd/supabase.js .
|
|
333
|
-
npm run test
|
|
334
|
-
cd ../../..
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
#### CI/CD Testing
|
|
338
|
-
|
|
339
|
-
When running on CI, the tests automatically use the latest dependencies from the root project. The CI pipeline:
|
|
340
|
-
|
|
341
|
-
1. Builds the main project with current dependencies
|
|
342
|
-
2. Creates a package archive (`.tgz`) with the latest versions
|
|
343
|
-
3. Uses this archive in Expo, Next.js, Deno, and Bun tests to ensure consistency
|
|
344
|
-
|
|
345
|
-
### Updating Test Dependencies
|
|
346
|
-
|
|
347
|
-
The platform-specific tests (Expo, Next.js, Deno, Bun) use a packaged version of supabase-js rather than directly importing from source. This ensures they test the actual built package as it would be consumed by users.
|
|
348
|
-
|
|
349
|
-
#### How It Works
|
|
350
|
-
|
|
351
|
-
1. **Build** the current supabase-js package
|
|
352
|
-
2. **Pack** it into a `.tgz` file (like `npm pack` does)
|
|
353
|
-
3. **Copy** the `.tgz` to the test directory
|
|
354
|
-
4. **Install** it in the test project
|
|
355
|
-
|
|
356
|
-
This mimics how real users would install and use the package.
|
|
357
|
-
|
|
358
|
-
#### Update Scripts
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
# Update ALL test environment dependencies at once
|
|
362
|
-
# This builds, packs, and installs in all test directories
|
|
363
|
-
npx nx update:test-deps supabase-js
|
|
364
|
-
|
|
365
|
-
# Or update specific test environments:
|
|
366
|
-
npx nx update:test-deps:expo supabase-js # Expo/React Native only
|
|
367
|
-
npx nx update:test-deps:next supabase-js # Next.js only
|
|
368
|
-
npx nx update:test-deps:deno supabase-js # Deno only
|
|
369
|
-
npx nx update:test-deps:bun supabase-js # Bun only
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
**When to Update:**
|
|
373
|
-
|
|
374
|
-
- After making changes to the source code
|
|
375
|
-
- Before running platform-specific tests locally
|
|
376
|
-
- When debugging test failures that might be due to stale dependencies
|
|
377
|
-
|
|
378
|
-
**Note:** CI automatically handles this, so manual updates are only needed for local development.
|
|
379
|
-
|
|
380
|
-
### Test Coverage
|
|
381
|
-
|
|
382
|
-
#### Viewing Coverage Reports
|
|
383
|
-
|
|
384
|
-
```bash
|
|
385
|
-
# Generate coverage report
|
|
386
|
-
npx nx test:coverage supabase-js
|
|
387
|
-
|
|
388
|
-
# Serve coverage report locally (opens interactive HTML report)
|
|
389
|
-
npx nx serve:coverage supabase-js
|
|
390
|
-
# This starts a local server at http://localhost:3000 with the coverage report
|
|
167
|
+
# Or with watch mode for development
|
|
168
|
+
npx nx build supabase-js --watch
|
|
391
169
|
```
|
|
392
170
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
- Line coverage
|
|
396
|
-
- Branch coverage
|
|
397
|
-
- Function coverage
|
|
398
|
-
- Uncovered lines with highlights
|
|
399
|
-
|
|
400
|
-
Coverage results are also automatically uploaded to Coveralls in CI for tracking over time.
|
|
401
|
-
|
|
402
|
-
### Contributing
|
|
403
|
-
|
|
404
|
-
We welcome contributions! Please see our [Contributing Guide](../../../CONTRIBUTING.md) for details on how to get started.
|
|
171
|
+
### Testing
|
|
405
172
|
|
|
406
|
-
|
|
173
|
+
There's a complete guide on how to set up your environment for running locally the `supabase-js` integration tests. Please refer to [TESTING.md](./TESTING.md).
|
|
407
174
|
|
|
408
175
|
## Badges
|
|
409
176
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FunctionsClient } from '@supabase/functions-js';
|
|
2
|
-
import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
3
|
-
import { RealtimeChannel, RealtimeChannelOptions, RealtimeClient } from '@supabase/realtime-js';
|
|
2
|
+
import { PostgrestClient, type PostgrestFilterBuilder, type PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
3
|
+
import { type RealtimeChannel, type RealtimeChannelOptions, RealtimeClient } from '@supabase/realtime-js';
|
|
4
4
|
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
|
|
5
5
|
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
|
|
6
|
-
import { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
6
|
+
import type { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
7
|
+
import { GetRpcFunctionFilterBuilderByArgs } from './lib/rest/types/common/rpc';
|
|
7
8
|
/**
|
|
8
9
|
* Supabase Client.
|
|
9
10
|
*
|
|
@@ -94,11 +95,11 @@ export default class SupabaseClient<Database = any, SchemaNameOrClientOptions ex
|
|
|
94
95
|
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
95
96
|
* numbers.
|
|
96
97
|
*/
|
|
97
|
-
rpc<FnName extends string & keyof Schema['Functions'],
|
|
98
|
+
rpc<FnName extends string & keyof Schema['Functions'], Args extends Schema['Functions'][FnName]['Args'] = never, FilterBuilder extends GetRpcFunctionFilterBuilderByArgs<Schema, FnName, Args> = GetRpcFunctionFilterBuilderByArgs<Schema, FnName, Args>>(fn: FnName, args?: Args, options?: {
|
|
98
99
|
head?: boolean;
|
|
99
100
|
get?: boolean;
|
|
100
101
|
count?: 'exact' | 'planned' | 'estimated';
|
|
101
|
-
}): PostgrestFilterBuilder<ClientOptions, Schema,
|
|
102
|
+
}): PostgrestFilterBuilder<ClientOptions, Schema, FilterBuilder['Row'], FilterBuilder['Result'], FilterBuilder['RelationName'], FilterBuilder['Relationships'], 'RPC'>;
|
|
102
103
|
/**
|
|
103
104
|
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
104
105
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,cAAc,EAEf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAS7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EAEb,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAA;AAE/E;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc,CACjC,QAAQ,GAAG,GAAG,EAId,yBAAyB,SACrB,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,GACrD;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,SAAS,MAAM,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,GAC1F,QAAQ,GACR,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,EACvD,UAAU,SAAS,MAAM,GACvB,MAAM,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,GAAG,yBAAyB,SAAS,MAAM,GACrF,MAAM,IAAI,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AAmB;IAO3B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,mBAAmB;CAiB5B"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const functions_js_1 = require("@supabase/functions-js");
|
|
13
4
|
const postgrest_js_1 = require("@supabase/postgrest-js");
|
|
@@ -134,7 +125,11 @@ class SupabaseClient {
|
|
|
134
125
|
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
135
126
|
* numbers.
|
|
136
127
|
*/
|
|
137
|
-
rpc(fn, args = {}, options = {
|
|
128
|
+
rpc(fn, args = {}, options = {
|
|
129
|
+
head: false,
|
|
130
|
+
get: false,
|
|
131
|
+
count: undefined,
|
|
132
|
+
}) {
|
|
138
133
|
return this.rest.rpc(fn, args, options);
|
|
139
134
|
}
|
|
140
135
|
/**
|
|
@@ -168,17 +163,15 @@ class SupabaseClient {
|
|
|
168
163
|
removeAllChannels() {
|
|
169
164
|
return this.realtime.removeAllChannels();
|
|
170
165
|
}
|
|
171
|
-
_getAccessToken() {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return (_b = (_a = data.session) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : this.supabaseKey;
|
|
179
|
-
});
|
|
166
|
+
async _getAccessToken() {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
if (this.accessToken) {
|
|
169
|
+
return await this.accessToken();
|
|
170
|
+
}
|
|
171
|
+
const { data } = await this.auth.getSession();
|
|
172
|
+
return (_b = (_a = data.session) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : this.supabaseKey;
|
|
180
173
|
}
|
|
181
|
-
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, userStorage, storageKey, flowType, lock, debug, }, headers, fetch) {
|
|
174
|
+
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, userStorage, storageKey, flowType, lock, debug, throwOnError, }, headers, fetch) {
|
|
182
175
|
const authHeaders = {
|
|
183
176
|
Authorization: `Bearer ${this.supabaseKey}`,
|
|
184
177
|
apikey: `${this.supabaseKey}`,
|
|
@@ -195,6 +188,7 @@ class SupabaseClient {
|
|
|
195
188
|
flowType,
|
|
196
189
|
lock,
|
|
197
190
|
debug,
|
|
191
|
+
throwOnError,
|
|
198
192
|
fetch,
|
|
199
193
|
// auth checks if there is a custom authorizaiton header using this flag
|
|
200
194
|
// so it knows whether to return an error when getUser is called with no session
|
|
@@ -205,7 +199,7 @@ class SupabaseClient {
|
|
|
205
199
|
return new realtime_js_1.RealtimeClient(this.realtimeUrl.href, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey }, options === null || options === void 0 ? void 0 : options.params) }));
|
|
206
200
|
}
|
|
207
201
|
_listenForAuthEvents() {
|
|
208
|
-
|
|
202
|
+
const data = this.auth.onAuthStateChange((event, session) => {
|
|
209
203
|
this._handleTokenChanged(event, 'CLIENT', session === null || session === void 0 ? void 0 : session.access_token);
|
|
210
204
|
});
|
|
211
205
|
return data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/Supab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,KAAK,YAAY,EAAE,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;YACvB,IAAI,MAAM,IAAI,SAAS;gBAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;YAC5C,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;QACrC,CAAC;IACH,CAAC;CACF;AAhXD,iCAgXC"}
|
package/dist/main/lib/fetch.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
type Fetch = typeof fetch;
|
|
2
2
|
export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
|
|
3
|
-
export declare const resolveHeadersConstructor: () =>
|
|
3
|
+
export declare const resolveHeadersConstructor: () => {
|
|
4
|
+
new (init?: HeadersInit): Headers;
|
|
5
|
+
prototype: Headers;
|
|
6
|
+
};
|
|
4
7
|
export declare const fetchWithAuth: (supabaseKey: string, getAccessToken: () => Promise<string | null>, customFetch?: Fetch) => Fetch;
|
|
5
8
|
export {};
|
|
6
9
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,OAAO,KAAK,CAAA;AAEzB,eAAO,MAAM,YAAY,GAAI,cAAc,KAAK,KAAG,KAKlD,CAAA;AAED,eAAO,MAAM,yBAAyB;;;CAErC,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,aAAa,MAAM,EACnB,gBAAgB,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAC5C,cAAc,KAAK,KAClB,KAkBF,CAAA"}
|
package/dist/main/lib/fetch.js
CHANGED
|
@@ -1,77 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
3
|
exports.fetchWithAuth = exports.resolveHeadersConstructor = exports.resolveFetch = void 0;
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
const node_fetch_1 = __importStar(require("@supabase/node-fetch"));
|
|
48
4
|
const resolveFetch = (customFetch) => {
|
|
49
|
-
let _fetch;
|
|
50
5
|
if (customFetch) {
|
|
51
|
-
|
|
6
|
+
return (...args) => customFetch(...args);
|
|
52
7
|
}
|
|
53
|
-
|
|
54
|
-
_fetch = node_fetch_1.default;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
_fetch = fetch;
|
|
58
|
-
}
|
|
59
|
-
return (...args) => _fetch(...args);
|
|
8
|
+
return (...args) => fetch(...args);
|
|
60
9
|
};
|
|
61
10
|
exports.resolveFetch = resolveFetch;
|
|
62
11
|
const resolveHeadersConstructor = () => {
|
|
63
|
-
if (typeof Headers === 'undefined') {
|
|
64
|
-
return node_fetch_1.Headers;
|
|
65
|
-
}
|
|
66
12
|
return Headers;
|
|
67
13
|
};
|
|
68
14
|
exports.resolveHeadersConstructor = resolveHeadersConstructor;
|
|
69
15
|
const fetchWithAuth = (supabaseKey, getAccessToken, customFetch) => {
|
|
70
16
|
const fetch = (0, exports.resolveFetch)(customFetch);
|
|
71
17
|
const HeadersConstructor = (0, exports.resolveHeadersConstructor)();
|
|
72
|
-
return (input, init) =>
|
|
18
|
+
return async (input, init) => {
|
|
73
19
|
var _a;
|
|
74
|
-
const accessToken = (_a = (
|
|
20
|
+
const accessToken = (_a = (await getAccessToken())) !== null && _a !== void 0 ? _a : supabaseKey;
|
|
75
21
|
let headers = new HeadersConstructor(init === null || init === void 0 ? void 0 : init.headers);
|
|
76
22
|
if (!headers.has('apikey')) {
|
|
77
23
|
headers.set('apikey', supabaseKey);
|
|
@@ -80,7 +26,7 @@ const fetchWithAuth = (supabaseKey, getAccessToken, customFetch) => {
|
|
|
80
26
|
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
81
27
|
}
|
|
82
28
|
return fetch(input, Object.assign(Object.assign({}, init), { headers }));
|
|
83
|
-
}
|
|
29
|
+
};
|
|
84
30
|
};
|
|
85
31
|
exports.fetchWithAuth = fetchWithAuth;
|
|
86
32
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";;;AAEO,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAS,EAAE;IACzD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,IAAuB,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,CAAC,GAAG,IAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AACvD,CAAC,CAAA;AALY,QAAA,YAAY,gBAKxB;AAEM,MAAM,yBAAyB,GAAG,GAAG,EAAE;IAC5C,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAFY,QAAA,yBAAyB,6BAErC;AAEM,MAAM,aAAa,GAAG,CAC3B,WAAmB,EACnB,cAA4C,EAC5C,WAAmB,EACZ,EAAE;IACT,MAAM,KAAK,GAAG,IAAA,oBAAY,EAAC,WAAW,CAAC,CAAA;IACvC,MAAM,kBAAkB,GAAG,IAAA,iCAAyB,GAAE,CAAA;IAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,E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