@fluxbase/sdk 0.0.1-rc.37 → 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.d.cts CHANGED
@@ -179,7 +179,7 @@ interface PostgrestResponse<T> {
179
179
  status: number;
180
180
  statusText: string;
181
181
  }
182
- type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts';
182
+ type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts' | 'st_intersects' | 'st_contains' | 'st_within' | 'st_dwithin' | 'st_distance' | 'st_touches' | 'st_crosses' | 'st_overlaps';
183
183
  interface QueryFilter {
184
184
  column: string;
185
185
  operator: FilterOperator;
@@ -4531,6 +4531,48 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
4531
4531
  * @example overlaps('tags', '["news","sports"]')
4532
4532
  */
4533
4533
  overlaps(column: string, value: unknown): this;
4534
+ /**
4535
+ * Check if geometries intersect (PostGIS ST_Intersects)
4536
+ * @param column - Column containing geometry/geography data
4537
+ * @param geojson - GeoJSON object to test intersection with
4538
+ * @example intersects('location', { type: 'Point', coordinates: [-122.4, 37.8] })
4539
+ */
4540
+ intersects(column: string, geojson: unknown): this;
4541
+ /**
4542
+ * Check if geometry A contains geometry B (PostGIS ST_Contains)
4543
+ * @param column - Column containing geometry/geography data
4544
+ * @param geojson - GeoJSON object to test containment
4545
+ * @example contains('region', { type: 'Point', coordinates: [-122.4, 37.8] })
4546
+ */
4547
+ stContains(column: string, geojson: unknown): this;
4548
+ /**
4549
+ * Check if geometry A is within geometry B (PostGIS ST_Within)
4550
+ * @param column - Column containing geometry/geography data
4551
+ * @param geojson - GeoJSON object to test containment within
4552
+ * @example within('point', { type: 'Polygon', coordinates: [[...]] })
4553
+ */
4554
+ within(column: string, geojson: unknown): this;
4555
+ /**
4556
+ * Check if geometries touch (PostGIS ST_Touches)
4557
+ * @param column - Column containing geometry/geography data
4558
+ * @param geojson - GeoJSON object to test touching
4559
+ * @example touches('boundary', { type: 'LineString', coordinates: [[...]] })
4560
+ */
4561
+ touches(column: string, geojson: unknown): this;
4562
+ /**
4563
+ * Check if geometries cross (PostGIS ST_Crosses)
4564
+ * @param column - Column containing geometry/geography data
4565
+ * @param geojson - GeoJSON object to test crossing
4566
+ * @example crosses('road', { type: 'LineString', coordinates: [[...]] })
4567
+ */
4568
+ crosses(column: string, geojson: unknown): this;
4569
+ /**
4570
+ * Check if geometries spatially overlap (PostGIS ST_Overlaps)
4571
+ * @param column - Column containing geometry/geography data
4572
+ * @param geojson - GeoJSON object to test overlap
4573
+ * @example stOverlaps('area', { type: 'Polygon', coordinates: [[...]] })
4574
+ */
4575
+ stOverlaps(column: string, geojson: unknown): this;
4534
4576
  /**
4535
4577
  * Order results
4536
4578
  */
package/dist/index.d.ts CHANGED
@@ -179,7 +179,7 @@ interface PostgrestResponse<T> {
179
179
  status: number;
180
180
  statusText: string;
181
181
  }
182
- type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts';
182
+ type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts' | 'st_intersects' | 'st_contains' | 'st_within' | 'st_dwithin' | 'st_distance' | 'st_touches' | 'st_crosses' | 'st_overlaps';
183
183
  interface QueryFilter {
184
184
  column: string;
185
185
  operator: FilterOperator;
@@ -4531,6 +4531,48 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
4531
4531
  * @example overlaps('tags', '["news","sports"]')
4532
4532
  */
4533
4533
  overlaps(column: string, value: unknown): this;
4534
+ /**
4535
+ * Check if geometries intersect (PostGIS ST_Intersects)
4536
+ * @param column - Column containing geometry/geography data
4537
+ * @param geojson - GeoJSON object to test intersection with
4538
+ * @example intersects('location', { type: 'Point', coordinates: [-122.4, 37.8] })
4539
+ */
4540
+ intersects(column: string, geojson: unknown): this;
4541
+ /**
4542
+ * Check if geometry A contains geometry B (PostGIS ST_Contains)
4543
+ * @param column - Column containing geometry/geography data
4544
+ * @param geojson - GeoJSON object to test containment
4545
+ * @example contains('region', { type: 'Point', coordinates: [-122.4, 37.8] })
4546
+ */
4547
+ stContains(column: string, geojson: unknown): this;
4548
+ /**
4549
+ * Check if geometry A is within geometry B (PostGIS ST_Within)
4550
+ * @param column - Column containing geometry/geography data
4551
+ * @param geojson - GeoJSON object to test containment within
4552
+ * @example within('point', { type: 'Polygon', coordinates: [[...]] })
4553
+ */
4554
+ within(column: string, geojson: unknown): this;
4555
+ /**
4556
+ * Check if geometries touch (PostGIS ST_Touches)
4557
+ * @param column - Column containing geometry/geography data
4558
+ * @param geojson - GeoJSON object to test touching
4559
+ * @example touches('boundary', { type: 'LineString', coordinates: [[...]] })
4560
+ */
4561
+ touches(column: string, geojson: unknown): this;
4562
+ /**
4563
+ * Check if geometries cross (PostGIS ST_Crosses)
4564
+ * @param column - Column containing geometry/geography data
4565
+ * @param geojson - GeoJSON object to test crossing
4566
+ * @example crosses('road', { type: 'LineString', coordinates: [[...]] })
4567
+ */
4568
+ crosses(column: string, geojson: unknown): this;
4569
+ /**
4570
+ * Check if geometries spatially overlap (PostGIS ST_Overlaps)
4571
+ * @param column - Column containing geometry/geography data
4572
+ * @param geojson - GeoJSON object to test overlap
4573
+ * @example stOverlaps('area', { type: 'Polygon', coordinates: [[...]] })
4574
+ */
4575
+ stOverlaps(column: string, geojson: unknown): this;
4534
4576
  /**
4535
4577
  * Order results
4536
4578
  */
package/dist/index.js CHANGED
@@ -4317,7 +4317,11 @@ var QueryBuilder = class {
4317
4317
  * @example not('completed_at', 'is', null)
4318
4318
  */
4319
4319
  not(column, operator, value) {
4320
- this.filters.push({ column, operator: "not", value: `${operator}.${this.formatValue(value)}` });
4320
+ this.filters.push({
4321
+ column,
4322
+ operator: "not",
4323
+ value: `${operator}.${this.formatValue(value)}`
4324
+ });
4321
4325
  return this;
4322
4326
  }
4323
4327
  /**
@@ -4376,6 +4380,91 @@ var QueryBuilder = class {
4376
4380
  this.filters.push({ column, operator: "ov", value });
4377
4381
  return this;
4378
4382
  }
4383
+ // PostGIS Spatial Query Methods
4384
+ /**
4385
+ * Check if geometries intersect (PostGIS ST_Intersects)
4386
+ * @param column - Column containing geometry/geography data
4387
+ * @param geojson - GeoJSON object to test intersection with
4388
+ * @example intersects('location', { type: 'Point', coordinates: [-122.4, 37.8] })
4389
+ */
4390
+ intersects(column, geojson) {
4391
+ this.filters.push({
4392
+ column,
4393
+ operator: "st_intersects",
4394
+ value: geojson
4395
+ });
4396
+ return this;
4397
+ }
4398
+ /**
4399
+ * Check if geometry A contains geometry B (PostGIS ST_Contains)
4400
+ * @param column - Column containing geometry/geography data
4401
+ * @param geojson - GeoJSON object to test containment
4402
+ * @example contains('region', { type: 'Point', coordinates: [-122.4, 37.8] })
4403
+ */
4404
+ stContains(column, geojson) {
4405
+ this.filters.push({
4406
+ column,
4407
+ operator: "st_contains",
4408
+ value: geojson
4409
+ });
4410
+ return this;
4411
+ }
4412
+ /**
4413
+ * Check if geometry A is within geometry B (PostGIS ST_Within)
4414
+ * @param column - Column containing geometry/geography data
4415
+ * @param geojson - GeoJSON object to test containment within
4416
+ * @example within('point', { type: 'Polygon', coordinates: [[...]] })
4417
+ */
4418
+ within(column, geojson) {
4419
+ this.filters.push({
4420
+ column,
4421
+ operator: "st_within",
4422
+ value: geojson
4423
+ });
4424
+ return this;
4425
+ }
4426
+ /**
4427
+ * Check if geometries touch (PostGIS ST_Touches)
4428
+ * @param column - Column containing geometry/geography data
4429
+ * @param geojson - GeoJSON object to test touching
4430
+ * @example touches('boundary', { type: 'LineString', coordinates: [[...]] })
4431
+ */
4432
+ touches(column, geojson) {
4433
+ this.filters.push({
4434
+ column,
4435
+ operator: "st_touches",
4436
+ value: geojson
4437
+ });
4438
+ return this;
4439
+ }
4440
+ /**
4441
+ * Check if geometries cross (PostGIS ST_Crosses)
4442
+ * @param column - Column containing geometry/geography data
4443
+ * @param geojson - GeoJSON object to test crossing
4444
+ * @example crosses('road', { type: 'LineString', coordinates: [[...]] })
4445
+ */
4446
+ crosses(column, geojson) {
4447
+ this.filters.push({
4448
+ column,
4449
+ operator: "st_crosses",
4450
+ value: geojson
4451
+ });
4452
+ return this;
4453
+ }
4454
+ /**
4455
+ * Check if geometries spatially overlap (PostGIS ST_Overlaps)
4456
+ * @param column - Column containing geometry/geography data
4457
+ * @param geojson - GeoJSON object to test overlap
4458
+ * @example stOverlaps('area', { type: 'Polygon', coordinates: [[...]] })
4459
+ */
4460
+ stOverlaps(column, geojson) {
4461
+ this.filters.push({
4462
+ column,
4463
+ operator: "st_overlaps",
4464
+ value: geojson
4465
+ });
4466
+ return this;
4467
+ }
4379
4468
  /**
4380
4469
  * Order results
4381
4470
  */
@@ -4675,7 +4764,10 @@ var QueryBuilder = class {
4675
4764
  throw new Error("Insert data is required for insert operation");
4676
4765
  }
4677
4766
  const body = Array.isArray(this.insertData) ? this.insertData : this.insertData;
4678
- const response = await this.fetch.post(`/api/v1/tables/${this.table}`, body);
4767
+ const response = await this.fetch.post(
4768
+ `/api/v1/tables/${this.table}`,
4769
+ body
4770
+ );
4679
4771
  return {
4680
4772
  data: response,
4681
4773
  error: null,
@@ -4829,7 +4921,10 @@ var QueryBuilder = class {
4829
4921
  params.append("select", this.selectQuery);
4830
4922
  }
4831
4923
  for (const filter of this.filters) {
4832
- params.append(filter.column, `${filter.operator}.${this.formatValue(filter.value)}`);
4924
+ params.append(
4925
+ filter.column,
4926
+ `${filter.operator}.${this.formatValue(filter.value)}`
4927
+ );
4833
4928
  }
4834
4929
  for (const orFilter of this.orFilters) {
4835
4930
  params.append("or", `(${orFilter})`);
@@ -4841,7 +4936,9 @@ var QueryBuilder = class {
4841
4936
  params.append("group_by", this.groupByColumns.join(","));
4842
4937
  }
4843
4938
  if (this.orderBys.length > 0) {
4844
- const orderStr = this.orderBys.map((o) => `${o.column}.${o.direction}${o.nulls ? `.nulls${o.nulls}` : ""}`).join(",");
4939
+ const orderStr = this.orderBys.map(
4940
+ (o) => `${o.column}.${o.direction}${o.nulls ? `.nulls${o.nulls}` : ""}`
4941
+ ).join(",");
4845
4942
  params.append("order", orderStr);
4846
4943
  }
4847
4944
  if (this.limitValue !== void 0) {