@data-loom/js 0.0.2-alpha.1
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/LICENSE +21 -0
- package/README.md +354 -0
- package/dist/main/SupabaseClient.d.ts +116 -0
- package/dist/main/SupabaseClient.d.ts.map +1 -0
- package/dist/main/SupabaseClient.js +227 -0
- package/dist/main/SupabaseClient.js.map +1 -0
- package/dist/main/index.d.ts +14 -0
- package/dist/main/index.d.ts.map +1 -0
- package/dist/main/index.js +41 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/utils/SupabaseAuthClient.d.ts +6 -0
- package/dist/main/utils/SupabaseAuthClient.d.ts.map +1 -0
- package/dist/main/utils/SupabaseAuthClient.js +11 -0
- package/dist/main/utils/SupabaseAuthClient.js.map +1 -0
- package/dist/main/utils/constants.d.ts +20 -0
- package/dist/main/utils/constants.d.ts.map +1 -0
- package/dist/main/utils/constants.js +54 -0
- package/dist/main/utils/constants.js.map +1 -0
- package/dist/main/utils/fetch.d.ts +6 -0
- package/dist/main/utils/fetch.d.ts.map +1 -0
- package/dist/main/utils/fetch.js +77 -0
- package/dist/main/utils/fetch.js.map +1 -0
- package/dist/main/utils/helpers.d.ts +7 -0
- package/dist/main/utils/helpers.d.ts.map +1 -0
- package/dist/main/utils/helpers.js +52 -0
- package/dist/main/utils/helpers.js.map +1 -0
- package/dist/main/utils/types.d.ts +115 -0
- package/dist/main/utils/types.d.ts.map +1 -0
- package/dist/main/utils/types.js +3 -0
- package/dist/main/utils/types.js.map +1 -0
- package/dist/main/utils/version.d.ts +2 -0
- package/dist/main/utils/version.d.ts.map +1 -0
- package/dist/main/utils/version.js +5 -0
- package/dist/main/utils/version.js.map +1 -0
- package/dist/module/SupabaseClient.d.ts +116 -0
- package/dist/module/SupabaseClient.d.ts.map +1 -0
- package/dist/module/SupabaseClient.js +224 -0
- package/dist/module/SupabaseClient.js.map +1 -0
- package/dist/module/index.d.ts +14 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +13 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/utils/SupabaseAuthClient.d.ts +6 -0
- package/dist/module/utils/SupabaseAuthClient.d.ts.map +1 -0
- package/dist/module/utils/SupabaseAuthClient.js +7 -0
- package/dist/module/utils/SupabaseAuthClient.js.map +1 -0
- package/dist/module/utils/constants.d.ts +20 -0
- package/dist/module/utils/constants.d.ts.map +1 -0
- package/dist/module/utils/constants.js +51 -0
- package/dist/module/utils/constants.js.map +1 -0
- package/dist/module/utils/fetch.d.ts +6 -0
- package/dist/module/utils/fetch.d.ts.map +1 -0
- package/dist/module/utils/fetch.js +48 -0
- package/dist/module/utils/fetch.js.map +1 -0
- package/dist/module/utils/helpers.d.ts +7 -0
- package/dist/module/utils/helpers.d.ts.map +1 -0
- package/dist/module/utils/helpers.js +44 -0
- package/dist/module/utils/helpers.js.map +1 -0
- package/dist/module/utils/types.d.ts +115 -0
- package/dist/module/utils/types.d.ts.map +1 -0
- package/dist/module/utils/types.js +2 -0
- package/dist/module/utils/types.js.map +1 -0
- package/dist/module/utils/version.d.ts +2 -0
- package/dist/module/utils/version.d.ts.map +1 -0
- package/dist/module/utils/version.js +2 -0
- package/dist/module/utils/version.js.map +1 -0
- package/dist/umd/948.dataloom.js +1 -0
- package/dist/umd/dataloom.js +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dataloom
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
### Install
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @data-loom/js
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Initializing
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { createClient } from '@data-loom/js'
|
|
14
|
+
|
|
15
|
+
// Create a single dataloom client for interacting with your database
|
|
16
|
+
const dataloom = createClient('https://xyzcompany.feishu.cn/suda/api/v1/workspaces/workspace_abc', 'public-anon-key')
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Fetch data
|
|
20
|
+
Perform a SELECT query on the table or view.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const { data, error } = await dataloom
|
|
24
|
+
.from('characters')
|
|
25
|
+
.select()
|
|
26
|
+
```
|
|
27
|
+
参数
|
|
28
|
+
|
|
29
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
30
|
+
| -------- | ----| ------ | ---- |
|
|
31
|
+
| `columns` | Optional | Query | The columns to retrieve, separated by commas. Columns can be renamed when returned with `customName:columnName` |
|
|
32
|
+
| `options` | Required | object | Named parameters |
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
`options` 对象
|
|
36
|
+
|
|
37
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
38
|
+
| --------------- | ---- | ------ | ---- |
|
|
39
|
+
| `count` | Optional | `exact` `planned` `estimated` | Count algorithm to use to count rows in the table or view. |
|
|
40
|
+
| `head` | Optional | boolean | When set to `true`, data will not be returned. Useful if you only need the count. |
|
|
41
|
+
|
|
42
|
+
### Insert data
|
|
43
|
+
Perform an INSERT into the table or view.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const { error } = await dataloom
|
|
47
|
+
.from('countries')
|
|
48
|
+
.insert({ id: 1, name: 'Mordor' })
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
参数
|
|
53
|
+
|
|
54
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
55
|
+
| -------- | ----| ------ | ---- |
|
|
56
|
+
| `values` | Required | `Row` `Array<Row>` | The values to insert. Pass an object to insert a single row or an array to insert multiple rows. |
|
|
57
|
+
| `options` | Optional | object | Named parameters |
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
`options` 对象
|
|
61
|
+
|
|
62
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
63
|
+
| --------------- | ---- | ------ | ---- |
|
|
64
|
+
| `count` | Optional | `exact` `planned` `estimated` | Count algorithm to use to count inserted rows. |
|
|
65
|
+
| `defaultToNull` | Optional | boolean | Make missing fields default to `null`. Otherwise, use the default value for the column. Only applies for bulk inserts. |
|
|
66
|
+
|
|
67
|
+
### Update data
|
|
68
|
+
Perform an UPDATE on the table or view.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
const { error } = await dataloom
|
|
72
|
+
.from('instruments')
|
|
73
|
+
.update({ name: 'piano' })
|
|
74
|
+
.eq('id', 1)
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
参数
|
|
78
|
+
|
|
79
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
80
|
+
| -------- | ----| ------ | ---- |
|
|
81
|
+
| `values` | Required | `Row` | The values to update with |
|
|
82
|
+
| `options` | Required | object | Named parameters |
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
`options` 对象
|
|
86
|
+
|
|
87
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
88
|
+
| --------------- | ---- | ------ | ---- |
|
|
89
|
+
| `count` | Optional | `exact` `planned` `estimated` | Count algorithm to use to count updated rows. |
|
|
90
|
+
|
|
91
|
+
### Delete data
|
|
92
|
+
Perform a DELETE on the table or view.
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
const response = await dataloom
|
|
96
|
+
.from('countries')
|
|
97
|
+
.delete()
|
|
98
|
+
.eq('id', 1)
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
参数
|
|
102
|
+
|
|
103
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
104
|
+
| -------- | ----| ------ | ---- |
|
|
105
|
+
| `options` | Required | object | Named parameters |
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
`options` 对象
|
|
109
|
+
|
|
110
|
+
| 参数名称 | 必需 | 类型 | 描述 |
|
|
111
|
+
| --------------- | ---- | ------ | ---- |
|
|
112
|
+
| `count` | Optional | `exact` `planned` `estimated` | Count algorithm to use to count updated rows. |
|
|
113
|
+
|
|
114
|
+
### Using filters
|
|
115
|
+
Filters allow you to only return rows that match certain conditions.
|
|
116
|
+
Filters can be used on select(), update(), upsert(), and delete() queries.
|
|
117
|
+
|
|
118
|
+
* Column is equal to a value
|
|
119
|
+
```js
|
|
120
|
+
const { data, error } = await dataloom
|
|
121
|
+
.from('characters')
|
|
122
|
+
.select()
|
|
123
|
+
.eq('name', 'Leia')
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
* Column is not equal to a value
|
|
127
|
+
```js
|
|
128
|
+
const { data, error } = await dataloom
|
|
129
|
+
.from('characters')
|
|
130
|
+
.select()
|
|
131
|
+
.neq('name', 'Leia')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
* Column is greater than a value
|
|
135
|
+
```js
|
|
136
|
+
const { data, error } = await dataloom
|
|
137
|
+
.from('characters')
|
|
138
|
+
.select()
|
|
139
|
+
.gt('id', 2)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
* Column is greater than or equal to a value
|
|
143
|
+
```js
|
|
144
|
+
const { data, error } = await dataloom
|
|
145
|
+
.from('characters')
|
|
146
|
+
.select()
|
|
147
|
+
.gte('id', 2)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
* Column is less than a value
|
|
151
|
+
```js
|
|
152
|
+
const { data, error } = await dataloom
|
|
153
|
+
.from('characters')
|
|
154
|
+
.select()
|
|
155
|
+
.lt('id', 2)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
* Column is less than or equal to a value
|
|
159
|
+
```js
|
|
160
|
+
const { data, error } = await dataloom
|
|
161
|
+
.from('characters')
|
|
162
|
+
.select()
|
|
163
|
+
.lte('id', 2)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
* Column matches a pattern
|
|
167
|
+
```js
|
|
168
|
+
const { data, error } = await dataloom
|
|
169
|
+
.from('characters')
|
|
170
|
+
.select()
|
|
171
|
+
.like('name', '%Lu%')
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
* Column matches a case-insensitive pattern
|
|
175
|
+
```js
|
|
176
|
+
const { data, error } = await dataloom
|
|
177
|
+
.from('characters')
|
|
178
|
+
.select()
|
|
179
|
+
.ilike('name', '%lu%')
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
* Column is a value
|
|
183
|
+
```js
|
|
184
|
+
const { data, error } = await dataloom
|
|
185
|
+
.from('countries')
|
|
186
|
+
.select()
|
|
187
|
+
.is('name', null)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
* Column is in an array
|
|
191
|
+
```js
|
|
192
|
+
const { data, error } = await dataloom
|
|
193
|
+
.from('characters')
|
|
194
|
+
.select()
|
|
195
|
+
.in('name', ['Leia', 'Han'])
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
* Column contains every element in a value
|
|
199
|
+
```js
|
|
200
|
+
const { data, error } = await dataloom
|
|
201
|
+
.from('issues')
|
|
202
|
+
.select()
|
|
203
|
+
.contains('tags', ['is:open', 'priority:low'])
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
* Contained by value
|
|
207
|
+
```js
|
|
208
|
+
const { data, error } = await dataloom
|
|
209
|
+
.from('classes')
|
|
210
|
+
.select('name')
|
|
211
|
+
.containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
* Greater than a range
|
|
215
|
+
```js
|
|
216
|
+
const { data, error } = await dataloom
|
|
217
|
+
.from('reservations')
|
|
218
|
+
.select()
|
|
219
|
+
.rangeGt('during', '[2000-01-02 08:00, 2000-01-02 09:00)')
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
* Greater than or equal to a range
|
|
223
|
+
```js
|
|
224
|
+
const { data, error } = await dataloom
|
|
225
|
+
.from('reservations')
|
|
226
|
+
.select()
|
|
227
|
+
.rangeGte('during', '[2000-01-02 08:30, 2000-01-02 09:30)')
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
* Less than a range
|
|
231
|
+
```js
|
|
232
|
+
const { data, error } = await dataloom
|
|
233
|
+
.from('reservations')
|
|
234
|
+
.select()
|
|
235
|
+
.rangeLt('during', '[2000-01-01 15:00, 2000-01-01 16:00)')
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
* Less than or equal to a range
|
|
239
|
+
```js
|
|
240
|
+
const { data, error } = await dataloom
|
|
241
|
+
.from('reservations')
|
|
242
|
+
.select()
|
|
243
|
+
.rangeLte('during', '[2000-01-01 14:00, 2000-01-01 16:00)')
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
* Mutually exclusive to a range
|
|
247
|
+
```js
|
|
248
|
+
const { data, error } = await dataloom
|
|
249
|
+
.from('reservations')
|
|
250
|
+
.select()
|
|
251
|
+
.rangeAdjacent('during', '[2000-01-01 12:00, 2000-01-01 13:00)')
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
* With a common element
|
|
255
|
+
```js
|
|
256
|
+
const { data, error } = await dataloom
|
|
257
|
+
.from('issues')
|
|
258
|
+
.select('title')
|
|
259
|
+
.overlaps('tags', ['is:closed', 'severity:high'])
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
* Match a string
|
|
263
|
+
```js
|
|
264
|
+
const result = await dataloom
|
|
265
|
+
.from("texts")
|
|
266
|
+
.select("content")
|
|
267
|
+
.textSearch("content", `'eggs' & 'ham'`, {
|
|
268
|
+
config: "english",
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
* Match an associated value
|
|
273
|
+
```js
|
|
274
|
+
const { data, error } = await dataloom
|
|
275
|
+
.from('characters')
|
|
276
|
+
.select('name')
|
|
277
|
+
.match({ id: 2, name: 'Leia' })
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
* Don't match the filter
|
|
281
|
+
```js
|
|
282
|
+
const { data, error } = await dataloom
|
|
283
|
+
.from('countries')
|
|
284
|
+
.select()
|
|
285
|
+
.not('name', 'is', null)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
* Don't match the filter
|
|
289
|
+
```js
|
|
290
|
+
const { data, error } = await dataloom
|
|
291
|
+
.from('characters')
|
|
292
|
+
.select('name')
|
|
293
|
+
.or('id.eq.2,name.eq.Han')
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
* Match the filter
|
|
297
|
+
```js
|
|
298
|
+
const { data, error } = await dataloom
|
|
299
|
+
.from('characters')
|
|
300
|
+
.select()
|
|
301
|
+
.filter('name', 'in', '("Han","Yoda")')
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Using modifiers
|
|
305
|
+
Filters work on the row level—they allow you to return rows that only match certain conditions without changing the shape of the rows. Modifiers are everything that don't fit that definition—allowing you to change the format of the response (e.g., returning a CSV string).
|
|
306
|
+
Modifiers must be specified after filters. Some modifiers only apply for queries that return rows
|
|
307
|
+
|
|
308
|
+
* Order the results
|
|
309
|
+
```js
|
|
310
|
+
const { data, error } = await dataloom
|
|
311
|
+
.from('characters')
|
|
312
|
+
.select('id, name')
|
|
313
|
+
.order('id', { ascending: false })
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
* Limit the number of rows returned
|
|
317
|
+
```js
|
|
318
|
+
const { data, error } = await dataloom
|
|
319
|
+
.from('characters')
|
|
320
|
+
.select('name')
|
|
321
|
+
.limit(1)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
* Limit the query to a range
|
|
325
|
+
```js
|
|
326
|
+
const { data, error } = await dataloom
|
|
327
|
+
.from('countries')
|
|
328
|
+
.select('name')
|
|
329
|
+
.range(0, 1)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
* Retrieve one row of data
|
|
333
|
+
```js
|
|
334
|
+
const { data, error } = await dataloom
|
|
335
|
+
.from('characters')
|
|
336
|
+
.select('name')
|
|
337
|
+
.limit(1)
|
|
338
|
+
.single()
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
* Retrieve zero or one row of data
|
|
342
|
+
```js
|
|
343
|
+
const { data, error } = await dataloom
|
|
344
|
+
.from('characters')
|
|
345
|
+
.select()
|
|
346
|
+
.eq('name', 'Katniss')
|
|
347
|
+
.maybeSingle()
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Acknowledgements
|
|
351
|
+
|
|
352
|
+
This project references the implementation of [@supabase/supabase-js](https://github.com/supabase/supabase-js).
|
|
353
|
+
|
|
354
|
+
[@supabase/supabase-js](https://github.com/supabase/supabase-js) is licensed under the MIT License.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { FunctionsClient } from '@data-loom/functions-js';
|
|
2
|
+
import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder } from '@data-loom/postgrest-js';
|
|
3
|
+
import { RealtimeChannel, RealtimeChannelOptions, RealtimeClient } from '@data-loom/realtime-js';
|
|
4
|
+
import { SupabaseAuthClient } from './utils/SupabaseAuthClient';
|
|
5
|
+
import { Fetch, GenericSchema, SupabaseClientOptions } from './utils/types';
|
|
6
|
+
/**
|
|
7
|
+
* Supabase Client.
|
|
8
|
+
*
|
|
9
|
+
* An isomorphic Javascript client for interacting with Postgres.
|
|
10
|
+
*/
|
|
11
|
+
export default class SupabaseClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
|
|
12
|
+
protected supabaseUrl: string;
|
|
13
|
+
protected supabaseKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies.
|
|
16
|
+
*/
|
|
17
|
+
auth: SupabaseAuthClient;
|
|
18
|
+
realtime: RealtimeClient;
|
|
19
|
+
protected realtimeUrl: string;
|
|
20
|
+
protected authUrl: string;
|
|
21
|
+
protected storageUrl: string;
|
|
22
|
+
protected functionsUrl: string;
|
|
23
|
+
protected rest: PostgrestClient<Database, SchemaName, Schema>;
|
|
24
|
+
protected storageKey: string;
|
|
25
|
+
protected fetch?: Fetch;
|
|
26
|
+
protected changedAccessToken?: string;
|
|
27
|
+
protected accessToken?: () => Promise<string | null>;
|
|
28
|
+
protected headers: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new client for use in the browser.
|
|
31
|
+
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
32
|
+
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
33
|
+
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
34
|
+
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
35
|
+
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
36
|
+
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
37
|
+
* @param options.realtime Options passed along to realtime-js constructor.
|
|
38
|
+
* @param options.global.fetch A custom fetch implementation.
|
|
39
|
+
* @param options.global.headers Any additional headers to send with each network request.
|
|
40
|
+
*/
|
|
41
|
+
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>);
|
|
42
|
+
/**
|
|
43
|
+
* Supabase Functions allows you to deploy and invoke edge functions.
|
|
44
|
+
*/
|
|
45
|
+
get functions(): FunctionsClient;
|
|
46
|
+
/**
|
|
47
|
+
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
|
|
48
|
+
// */
|
|
49
|
+
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>;
|
|
50
|
+
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<Schema, View, ViewName>;
|
|
51
|
+
/**
|
|
52
|
+
* Select a schema to query or perform an function (rpc) call.
|
|
53
|
+
*
|
|
54
|
+
* The schema needs to be on the list of exposed schemas inside Supabase.
|
|
55
|
+
*
|
|
56
|
+
* @param schema - The schema to query
|
|
57
|
+
*/
|
|
58
|
+
schema<DynamicSchema extends string & keyof Database>(schema: DynamicSchema): PostgrestClient<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>;
|
|
59
|
+
/**
|
|
60
|
+
* Perform a function call.
|
|
61
|
+
*
|
|
62
|
+
* @param fn - The function name to call
|
|
63
|
+
* @param args - The arguments to pass to the function call
|
|
64
|
+
* @param options - Named parameters
|
|
65
|
+
* @param options.head - When set to `true`, `data` will not be returned.
|
|
66
|
+
* Useful if you only need the count.
|
|
67
|
+
* @param options.get - When set to `true`, the function will be called with
|
|
68
|
+
* read-only access mode.
|
|
69
|
+
* @param options.count - Count algorithm to use to count rows returned by the
|
|
70
|
+
* function. Only applicable for [set-returning
|
|
71
|
+
* functions](https://www.postgresql.org/docs/current/functions-srf.html).
|
|
72
|
+
*
|
|
73
|
+
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
|
|
74
|
+
* hood.
|
|
75
|
+
*
|
|
76
|
+
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres
|
|
77
|
+
* statistics under the hood.
|
|
78
|
+
*
|
|
79
|
+
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
80
|
+
* numbers.
|
|
81
|
+
*/
|
|
82
|
+
rpc<FnName extends string & keyof Schema['Functions'], Fn extends Schema['Functions'][FnName]>(fn: FnName, args?: Fn['Args'], options?: {
|
|
83
|
+
head?: boolean;
|
|
84
|
+
get?: boolean;
|
|
85
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
86
|
+
}): PostgrestFilterBuilder<Schema, Fn['Returns'] extends any[] ? Fn['Returns'][number] extends Record<string, unknown> ? Fn['Returns'][number] : never : never, Fn['Returns'], FnName, null>;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} name - The name of the Realtime channel.
|
|
91
|
+
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
channel(name: string, opts?: RealtimeChannelOptions): RealtimeChannel;
|
|
95
|
+
/**
|
|
96
|
+
* Returns all Realtime channels.
|
|
97
|
+
*/
|
|
98
|
+
getChannels(): RealtimeChannel[];
|
|
99
|
+
/**
|
|
100
|
+
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
101
|
+
*
|
|
102
|
+
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
105
|
+
removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'>;
|
|
106
|
+
/**
|
|
107
|
+
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
108
|
+
*/
|
|
109
|
+
removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]>;
|
|
110
|
+
private _getAccessToken;
|
|
111
|
+
private _initSupabaseAuthClient;
|
|
112
|
+
private _initRealtimeClient;
|
|
113
|
+
private _listenForAuthEvents;
|
|
114
|
+
private _handleTokenChanged;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=SupabaseClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,cAAc,EAEf,MAAM,wBAAwB,CAAA;AAU/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EACL,KAAK,EACL,aAAa,EACb,qBAAqB,EAEtB,MAAM,eAAe,CAAA;AAEtB;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc,CACjC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EAC3B,MAAM,SAAS,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa,GACrE,QAAQ,CAAC,UAAU,CAAC,GACpB,GAAG;IAiCL,SAAS,CAAC,WAAW,EAAE,MAAM;IAC7B,SAAS,CAAC,WAAW,EAAE,MAAM;IAhC/B;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAA;I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