@fluxbase/sdk 0.0.1-rc.37 → 0.0.1-rc.39

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 CHANGED
@@ -4319,7 +4319,11 @@ var QueryBuilder = class {
4319
4319
  * @example not('completed_at', 'is', null)
4320
4320
  */
4321
4321
  not(column, operator, value) {
4322
- this.filters.push({ column, operator: "not", value: `${operator}.${this.formatValue(value)}` });
4322
+ this.filters.push({
4323
+ column,
4324
+ operator: "not",
4325
+ value: `${operator}.${this.formatValue(value)}`
4326
+ });
4323
4327
  return this;
4324
4328
  }
4325
4329
  /**
@@ -4378,6 +4382,91 @@ var QueryBuilder = class {
4378
4382
  this.filters.push({ column, operator: "ov", value });
4379
4383
  return this;
4380
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
+ }
4381
4470
  /**
4382
4471
  * Order results
4383
4472
  */
@@ -4677,7 +4766,10 @@ var QueryBuilder = class {
4677
4766
  throw new Error("Insert data is required for insert operation");
4678
4767
  }
4679
4768
  const body = Array.isArray(this.insertData) ? this.insertData : this.insertData;
4680
- const response = await this.fetch.post(`/api/v1/tables/${this.table}`, body);
4769
+ const response = await this.fetch.post(
4770
+ `/api/v1/tables/${this.table}`,
4771
+ body
4772
+ );
4681
4773
  return {
4682
4774
  data: response,
4683
4775
  error: null,
@@ -4831,7 +4923,10 @@ var QueryBuilder = class {
4831
4923
  params.append("select", this.selectQuery);
4832
4924
  }
4833
4925
  for (const filter of this.filters) {
4834
- params.append(filter.column, `${filter.operator}.${this.formatValue(filter.value)}`);
4926
+ params.append(
4927
+ filter.column,
4928
+ `${filter.operator}.${this.formatValue(filter.value)}`
4929
+ );
4835
4930
  }
4836
4931
  for (const orFilter of this.orFilters) {
4837
4932
  params.append("or", `(${orFilter})`);
@@ -4843,7 +4938,9 @@ var QueryBuilder = class {
4843
4938
  params.append("group_by", this.groupByColumns.join(","));
4844
4939
  }
4845
4940
  if (this.orderBys.length > 0) {
4846
- const orderStr = this.orderBys.map((o) => `${o.column}.${o.direction}${o.nulls ? `.nulls${o.nulls}` : ""}`).join(",");
4941
+ const orderStr = this.orderBys.map(
4942
+ (o) => `${o.column}.${o.direction}${o.nulls ? `.nulls${o.nulls}` : ""}`
4943
+ ).join(",");
4847
4944
  params.append("order", orderStr);
4848
4945
  }
4849
4946
  if (this.limitValue !== void 0) {