@fluxbase/sdk 0.0.1-rc.36 → 0.0.1-rc.38
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/dist/index.cjs +126 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -5
- package/dist/index.d.ts +64 -5
- package/dist/index.js +126 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -243,9 +243,16 @@ var FluxbaseAuth = class {
|
|
|
243
243
|
*/
|
|
244
244
|
async signUp(credentials) {
|
|
245
245
|
return wrapAsync(async () => {
|
|
246
|
+
const requestBody = {
|
|
247
|
+
email: credentials.email,
|
|
248
|
+
password: credentials.password
|
|
249
|
+
};
|
|
250
|
+
if (credentials.options?.data) {
|
|
251
|
+
requestBody.user_metadata = credentials.options.data;
|
|
252
|
+
}
|
|
246
253
|
const response = await this.fetch.post(
|
|
247
254
|
"/api/v1/auth/signup",
|
|
248
|
-
|
|
255
|
+
requestBody
|
|
249
256
|
);
|
|
250
257
|
if (response.access_token && response.refresh_token) {
|
|
251
258
|
const session = {
|
|
@@ -314,14 +321,28 @@ var FluxbaseAuth = class {
|
|
|
314
321
|
});
|
|
315
322
|
}
|
|
316
323
|
/**
|
|
317
|
-
* Update the current user
|
|
324
|
+
* Update the current user (Supabase-compatible)
|
|
325
|
+
* @param attributes - User attributes to update (email, password, data for metadata)
|
|
318
326
|
*/
|
|
319
|
-
async updateUser(
|
|
327
|
+
async updateUser(attributes) {
|
|
320
328
|
return wrapAsync(async () => {
|
|
321
329
|
if (!this.session) {
|
|
322
330
|
throw new Error("Not authenticated");
|
|
323
331
|
}
|
|
324
|
-
const
|
|
332
|
+
const requestBody = {};
|
|
333
|
+
if (attributes.email) {
|
|
334
|
+
requestBody.email = attributes.email;
|
|
335
|
+
}
|
|
336
|
+
if (attributes.password) {
|
|
337
|
+
requestBody.password = attributes.password;
|
|
338
|
+
}
|
|
339
|
+
if (attributes.data) {
|
|
340
|
+
requestBody.user_metadata = attributes.data;
|
|
341
|
+
}
|
|
342
|
+
if (attributes.nonce) {
|
|
343
|
+
requestBody.nonce = attributes.nonce;
|
|
344
|
+
}
|
|
345
|
+
const user = await this.fetch.patch("/api/v1/auth/user", requestBody);
|
|
325
346
|
if (this.session) {
|
|
326
347
|
this.session.user = user;
|
|
327
348
|
this.saveSession();
|
|
@@ -4298,7 +4319,11 @@ var QueryBuilder = class {
|
|
|
4298
4319
|
* @example not('completed_at', 'is', null)
|
|
4299
4320
|
*/
|
|
4300
4321
|
not(column, operator, value) {
|
|
4301
|
-
this.filters.push({
|
|
4322
|
+
this.filters.push({
|
|
4323
|
+
column,
|
|
4324
|
+
operator: "not",
|
|
4325
|
+
value: `${operator}.${this.formatValue(value)}`
|
|
4326
|
+
});
|
|
4302
4327
|
return this;
|
|
4303
4328
|
}
|
|
4304
4329
|
/**
|
|
@@ -4357,6 +4382,91 @@ var QueryBuilder = class {
|
|
|
4357
4382
|
this.filters.push({ column, operator: "ov", value });
|
|
4358
4383
|
return this;
|
|
4359
4384
|
}
|
|
4385
|
+
// PostGIS Spatial Query Methods
|
|
4386
|
+
/**
|
|
4387
|
+
* Check if geometries intersect (PostGIS ST_Intersects)
|
|
4388
|
+
* @param column - Column containing geometry/geography data
|
|
4389
|
+
* @param geojson - GeoJSON object to test intersection with
|
|
4390
|
+
* @example intersects('location', { type: 'Point', coordinates: [-122.4, 37.8] })
|
|
4391
|
+
*/
|
|
4392
|
+
intersects(column, geojson) {
|
|
4393
|
+
this.filters.push({
|
|
4394
|
+
column,
|
|
4395
|
+
operator: "st_intersects",
|
|
4396
|
+
value: geojson
|
|
4397
|
+
});
|
|
4398
|
+
return this;
|
|
4399
|
+
}
|
|
4400
|
+
/**
|
|
4401
|
+
* Check if geometry A contains geometry B (PostGIS ST_Contains)
|
|
4402
|
+
* @param column - Column containing geometry/geography data
|
|
4403
|
+
* @param geojson - GeoJSON object to test containment
|
|
4404
|
+
* @example contains('region', { type: 'Point', coordinates: [-122.4, 37.8] })
|
|
4405
|
+
*/
|
|
4406
|
+
stContains(column, geojson) {
|
|
4407
|
+
this.filters.push({
|
|
4408
|
+
column,
|
|
4409
|
+
operator: "st_contains",
|
|
4410
|
+
value: geojson
|
|
4411
|
+
});
|
|
4412
|
+
return this;
|
|
4413
|
+
}
|
|
4414
|
+
/**
|
|
4415
|
+
* Check if geometry A is within geometry B (PostGIS ST_Within)
|
|
4416
|
+
* @param column - Column containing geometry/geography data
|
|
4417
|
+
* @param geojson - GeoJSON object to test containment within
|
|
4418
|
+
* @example within('point', { type: 'Polygon', coordinates: [[...]] })
|
|
4419
|
+
*/
|
|
4420
|
+
within(column, geojson) {
|
|
4421
|
+
this.filters.push({
|
|
4422
|
+
column,
|
|
4423
|
+
operator: "st_within",
|
|
4424
|
+
value: geojson
|
|
4425
|
+
});
|
|
4426
|
+
return this;
|
|
4427
|
+
}
|
|
4428
|
+
/**
|
|
4429
|
+
* Check if geometries touch (PostGIS ST_Touches)
|
|
4430
|
+
* @param column - Column containing geometry/geography data
|
|
4431
|
+
* @param geojson - GeoJSON object to test touching
|
|
4432
|
+
* @example touches('boundary', { type: 'LineString', coordinates: [[...]] })
|
|
4433
|
+
*/
|
|
4434
|
+
touches(column, geojson) {
|
|
4435
|
+
this.filters.push({
|
|
4436
|
+
column,
|
|
4437
|
+
operator: "st_touches",
|
|
4438
|
+
value: geojson
|
|
4439
|
+
});
|
|
4440
|
+
return this;
|
|
4441
|
+
}
|
|
4442
|
+
/**
|
|
4443
|
+
* Check if geometries cross (PostGIS ST_Crosses)
|
|
4444
|
+
* @param column - Column containing geometry/geography data
|
|
4445
|
+
* @param geojson - GeoJSON object to test crossing
|
|
4446
|
+
* @example crosses('road', { type: 'LineString', coordinates: [[...]] })
|
|
4447
|
+
*/
|
|
4448
|
+
crosses(column, geojson) {
|
|
4449
|
+
this.filters.push({
|
|
4450
|
+
column,
|
|
4451
|
+
operator: "st_crosses",
|
|
4452
|
+
value: geojson
|
|
4453
|
+
});
|
|
4454
|
+
return this;
|
|
4455
|
+
}
|
|
4456
|
+
/**
|
|
4457
|
+
* Check if geometries spatially overlap (PostGIS ST_Overlaps)
|
|
4458
|
+
* @param column - Column containing geometry/geography data
|
|
4459
|
+
* @param geojson - GeoJSON object to test overlap
|
|
4460
|
+
* @example stOverlaps('area', { type: 'Polygon', coordinates: [[...]] })
|
|
4461
|
+
*/
|
|
4462
|
+
stOverlaps(column, geojson) {
|
|
4463
|
+
this.filters.push({
|
|
4464
|
+
column,
|
|
4465
|
+
operator: "st_overlaps",
|
|
4466
|
+
value: geojson
|
|
4467
|
+
});
|
|
4468
|
+
return this;
|
|
4469
|
+
}
|
|
4360
4470
|
/**
|
|
4361
4471
|
* Order results
|
|
4362
4472
|
*/
|
|
@@ -4656,7 +4766,10 @@ var QueryBuilder = class {
|
|
|
4656
4766
|
throw new Error("Insert data is required for insert operation");
|
|
4657
4767
|
}
|
|
4658
4768
|
const body = Array.isArray(this.insertData) ? this.insertData : this.insertData;
|
|
4659
|
-
const response = await this.fetch.post(
|
|
4769
|
+
const response = await this.fetch.post(
|
|
4770
|
+
`/api/v1/tables/${this.table}`,
|
|
4771
|
+
body
|
|
4772
|
+
);
|
|
4660
4773
|
return {
|
|
4661
4774
|
data: response,
|
|
4662
4775
|
error: null,
|
|
@@ -4810,7 +4923,10 @@ var QueryBuilder = class {
|
|
|
4810
4923
|
params.append("select", this.selectQuery);
|
|
4811
4924
|
}
|
|
4812
4925
|
for (const filter of this.filters) {
|
|
4813
|
-
params.append(
|
|
4926
|
+
params.append(
|
|
4927
|
+
filter.column,
|
|
4928
|
+
`${filter.operator}.${this.formatValue(filter.value)}`
|
|
4929
|
+
);
|
|
4814
4930
|
}
|
|
4815
4931
|
for (const orFilter of this.orFilters) {
|
|
4816
4932
|
params.append("or", `(${orFilter})`);
|
|
@@ -4822,7 +4938,9 @@ var QueryBuilder = class {
|
|
|
4822
4938
|
params.append("group_by", this.groupByColumns.join(","));
|
|
4823
4939
|
}
|
|
4824
4940
|
if (this.orderBys.length > 0) {
|
|
4825
|
-
const orderStr = this.orderBys.map(
|
|
4941
|
+
const orderStr = this.orderBys.map(
|
|
4942
|
+
(o) => `${o.column}.${o.direction}${o.nulls ? `.nulls${o.nulls}` : ""}`
|
|
4943
|
+
).join(",");
|
|
4826
4944
|
params.append("order", orderStr);
|
|
4827
4945
|
}
|
|
4828
4946
|
if (this.limitValue !== void 0) {
|