@rebasepro/client-postgresql 0.2.1 → 0.2.3

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.
@@ -1,7 +1,7 @@
1
1
  import { Transport, FindParams } from "./transport";
2
2
  import { RebaseWebSocketClient } from "./websocket";
3
- import { CollectionAccessor } from "@rebasepro/types";
4
- import { FilterOperator, QueryBuilder } from "./query_builder";
3
+ import { CollectionAccessor, FilterOperator } from "@rebasepro/types";
4
+ import { QueryBuilder } from "./query_builder";
5
5
  /**
6
6
  * CollectionClient extends `CollectionAccessor` from `@rebasepro/types` so that
7
7
  * `client.data` can be passed directly to the core Rebase component.
@@ -9,6 +9,7 @@ export * from "./auth";
9
9
  export * from "./admin";
10
10
  export * from "./cron";
11
11
  export * from "./collection";
12
+ export * from "./query_builder";
12
13
  export * from "./websocket";
13
14
  export * from "./storage";
14
15
  export * from "./reviver";
@@ -1,53 +1 @@
1
- import { FindResponse } from "@rebasepro/types";
2
- import { CollectionClient } from "./collection";
3
- export type FilterOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "cs" | "csa" | "==" | "!=" | ">" | ">=" | "<" | "<=" | "array-contains" | "array-contains-any" | "not-in";
4
- export declare class QueryBuilder<M extends Record<string, unknown> = Record<string, unknown>> {
5
- private collection;
6
- private params;
7
- constructor(collection: CollectionClient<M>);
8
- /**
9
- * Add a filter condition to your query.
10
- * @example
11
- * client.collection('users').where('age', '>=', 18).find()
12
- */
13
- where(column: keyof M & string, operator: FilterOperator, value: unknown): this;
14
- /**
15
- * Order the results by a specific column.
16
- * @example
17
- * client.collection('users').orderBy('createdAt', 'desc').find()
18
- */
19
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
20
- /**
21
- * Limit the number of results returned.
22
- */
23
- limit(count: number): this;
24
- /**
25
- * Skip the first N results.
26
- */
27
- offset(count: number): this;
28
- /**
29
- * Set a free-text search string if supported by the backend.
30
- */
31
- search(searchString: string): this;
32
- /**
33
- * Include related entities in the response.
34
- * Relations will be populated with full entity data instead of just IDs.
35
- *
36
- * @param relations - Relation names to include, or "*" for all.
37
- * @example
38
- * // Include specific relations
39
- * client.data.posts.include("tags", "author").find()
40
- *
41
- * // Include all relations
42
- * client.data.posts.include("*").find()
43
- */
44
- include(...relations: string[]): this;
45
- /**
46
- * Execute the find query and return the results.
47
- */
48
- find(): Promise<FindResponse<M>>;
49
- /**
50
- * Listen to realtime updates matching this query.
51
- */
52
- listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
53
- }
1
+ export { QueryBuilder } from "@rebasepro/common";
@@ -76,6 +76,21 @@ export interface FindResponse<M extends Record<string, unknown> = Record<string,
76
76
  hasMore: boolean;
77
77
  };
78
78
  }
79
+ export type FilterOperator = WhereFilterOpShort;
80
+ /**
81
+ * Fluent Query Builder Interface supported on both client and server accessors.
82
+ * @group Data
83
+ */
84
+ export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
85
+ where(column: keyof M & string, operator: FilterOperator, value: unknown): this;
86
+ orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
87
+ limit(count: number): this;
88
+ offset(count: number): this;
89
+ search(searchString: string): this;
90
+ include(...relations: string[]): this;
91
+ find(): Promise<FindResponse<M>>;
92
+ listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
93
+ }
79
94
  /**
80
95
  * A single collection's CRUD accessor.
81
96
  *
@@ -124,6 +139,12 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
124
139
  * Count the number of records matching the given filter.
125
140
  */
126
141
  count?(params?: FindParams): Promise<number>;
142
+ where(column: keyof M & string, operator: FilterOperator, value: unknown): QueryBuilderInterface<M>;
143
+ orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilderInterface<M>;
144
+ limit(count: number): QueryBuilderInterface<M>;
145
+ offset(count: number): QueryBuilderInterface<M>;
146
+ search(searchString: string): QueryBuilderInterface<M>;
147
+ include(...relations: string[]): QueryBuilderInterface<M>;
127
148
  }
128
149
  /**
129
150
  * The unified data access object.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/client-postgresql",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "description": "PostgreSQL data source client for Rebase",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -57,8 +57,8 @@
57
57
  "./package.json": "./package.json"
58
58
  },
59
59
  "dependencies": {
60
- "@rebasepro/client": "0.2.1",
61
- "@rebasepro/types": "0.2.1"
60
+ "@rebasepro/client": "0.2.3",
61
+ "@rebasepro/types": "0.2.3"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "react": ">=19.0.0",