@rebasepro/client-postgresql 0.2.5 → 0.4.0
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/client/src/auth.d.ts +8 -0
- package/dist/client/src/collection.d.ts +4 -3
- package/dist/client/src/query_builder.d.ts +1 -1
- package/dist/client/src/websocket.d.ts +6 -0
- package/dist/types/src/controllers/data.d.ts +17 -3
- package/dist/types/src/controllers/email.d.ts +2 -0
- package/dist/types/src/types/collections.d.ts +9 -5
- package/dist/types/src/types/entity_views.d.ts +19 -28
- package/dist/types/src/types/properties.d.ts +2 -2
- package/package.json +3 -3
|
@@ -168,3 +168,11 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
|
|
|
168
168
|
getSession: () => RebaseSession | null;
|
|
169
169
|
onAuthStateChange: (callback: (event: AuthChangeEvent, session: RebaseSession | null) => void) => () => boolean;
|
|
170
170
|
};
|
|
171
|
+
export interface CookieStorageOptions {
|
|
172
|
+
path?: string;
|
|
173
|
+
domain?: string;
|
|
174
|
+
secure?: boolean;
|
|
175
|
+
sameSite?: "Lax" | "Strict" | "None";
|
|
176
|
+
maxAge?: number;
|
|
177
|
+
}
|
|
178
|
+
export declare function createCookieStorage(options?: CookieStorageOptions): AuthStorage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FindParams, Transport } from "./transport";
|
|
2
2
|
import { RebaseWebSocketClient } from "./websocket";
|
|
3
|
-
import { CollectionAccessor, FilterOperator } from "@rebasepro/types";
|
|
3
|
+
import { CollectionAccessor, FilterOperator, LogicalCondition, WhereValue } from "@rebasepro/types";
|
|
4
4
|
import { QueryBuilder } from "./query_builder";
|
|
5
5
|
/**
|
|
6
6
|
* CollectionClient extends `CollectionAccessor` from `@rebasepro/types` so that
|
|
@@ -9,7 +9,8 @@ import { QueryBuilder } from "./query_builder";
|
|
|
9
9
|
* Additionally it exposes fluent query builder methods like `.where()`, `.orderBy()`.
|
|
10
10
|
*/
|
|
11
11
|
export interface CollectionClient<M extends Record<string, unknown> = Record<string, unknown>> extends CollectionAccessor<M> {
|
|
12
|
-
where
|
|
12
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilder<M>;
|
|
13
|
+
where(logicalCondition: LogicalCondition): QueryBuilder<M>;
|
|
13
14
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilder<M>;
|
|
14
15
|
limit(count: number): QueryBuilder<M>;
|
|
15
16
|
offset(count: number): QueryBuilder<M>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { QueryBuilder } from "@rebasepro/common";
|
|
1
|
+
export { QueryBuilder, or, and, cond } from "@rebasepro/common";
|
|
@@ -5,6 +5,8 @@ export interface RebaseWebSocketConfig {
|
|
|
5
5
|
getAuthToken?: () => Promise<string>;
|
|
6
6
|
/** Optional WebSocket constructor to override globalThis.WebSocket (e.g. for Node environments) */
|
|
7
7
|
WebSocket?: typeof WebSocket;
|
|
8
|
+
/** Callback to handle unauthorized requests or token expiration (refreshes auth session) */
|
|
9
|
+
onUnauthorized?: () => Promise<boolean>;
|
|
8
10
|
}
|
|
9
11
|
export declare class ApiError extends Error {
|
|
10
12
|
code?: string;
|
|
@@ -32,6 +34,8 @@ export declare class RebaseWebSocketClient {
|
|
|
32
34
|
private isAuthenticated;
|
|
33
35
|
private authPromise;
|
|
34
36
|
private WebSocketConstructor;
|
|
37
|
+
onUnauthorized?: () => Promise<boolean>;
|
|
38
|
+
private refreshInProgress;
|
|
35
39
|
constructor(config: RebaseWebSocketConfig);
|
|
36
40
|
/**
|
|
37
41
|
* Authenticate the WebSocket connection
|
|
@@ -45,6 +49,8 @@ export declare class RebaseWebSocketClient {
|
|
|
45
49
|
private initWebSocket;
|
|
46
50
|
private processMessageQueue;
|
|
47
51
|
private attemptReconnect;
|
|
52
|
+
private isAuthError;
|
|
53
|
+
private handleAuthFailure;
|
|
48
54
|
private handleWebSocketMessage;
|
|
49
55
|
private ensureAuthenticated;
|
|
50
56
|
/**
|
|
@@ -16,7 +16,17 @@ import { Entity, EntityValues } from "../types/entities";
|
|
|
16
16
|
*
|
|
17
17
|
* @group Data
|
|
18
18
|
*/
|
|
19
|
-
export type WhereFieldValue = string | number | boolean | null | [WhereFilterOpShort, any];
|
|
19
|
+
export type WhereFieldValue = string | number | boolean | null | [WhereFilterOpShort, any] | [WhereFilterOpShort, any][];
|
|
20
|
+
export type WhereValue<T> = T | T[] | null;
|
|
21
|
+
export interface LogicalCondition {
|
|
22
|
+
type: "and" | "or";
|
|
23
|
+
conditions: (FilterCondition | LogicalCondition)[];
|
|
24
|
+
}
|
|
25
|
+
export interface FilterCondition {
|
|
26
|
+
column: string;
|
|
27
|
+
operator: FilterOperator;
|
|
28
|
+
value: unknown;
|
|
29
|
+
}
|
|
20
30
|
/** Short operator strings accepted in the tuple syntax. */
|
|
21
31
|
export type WhereFilterOpShort = "==" | "!=" | ">" | ">=" | "<" | "<=" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "not-in" | "array-contains" | "array-contains-any" | "cs" | "csa";
|
|
22
32
|
export interface FindParams {
|
|
@@ -51,6 +61,8 @@ export interface FindParams {
|
|
|
51
61
|
* ```
|
|
52
62
|
*/
|
|
53
63
|
where?: Record<string, WhereFieldValue>;
|
|
64
|
+
/** Logical grouping conditions (AND/OR) */
|
|
65
|
+
logical?: LogicalCondition;
|
|
54
66
|
/**
|
|
55
67
|
* Sort order. Format: "field:direction".
|
|
56
68
|
* @example "created_at:desc", "name:asc"
|
|
@@ -82,7 +94,8 @@ export type FilterOperator = WhereFilterOpShort;
|
|
|
82
94
|
* @group Data
|
|
83
95
|
*/
|
|
84
96
|
export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
85
|
-
where
|
|
97
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): this;
|
|
98
|
+
where(logicalCondition: LogicalCondition): this;
|
|
86
99
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
|
|
87
100
|
limit(count: number): this;
|
|
88
101
|
offset(count: number): this;
|
|
@@ -143,7 +156,8 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
143
156
|
* Count the number of records matching the given filter.
|
|
144
157
|
*/
|
|
145
158
|
count?(params?: FindParams): Promise<number>;
|
|
146
|
-
where
|
|
159
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
|
|
160
|
+
where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
|
|
147
161
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilderInterface<M>;
|
|
148
162
|
limit(count: number): QueryBuilderInterface<M>;
|
|
149
163
|
offset(count: number): QueryBuilderInterface<M>;
|
|
@@ -31,4 +31,6 @@ export interface EmailService {
|
|
|
31
31
|
send(options: EmailSendOptions): Promise<void>;
|
|
32
32
|
/** Returns `true` when the service has valid credentials / is ready to send. */
|
|
33
33
|
isConfigured(): boolean;
|
|
34
|
+
/** Verify connection/credentials with the email provider. */
|
|
35
|
+
verifyConnection?(): Promise<boolean>;
|
|
34
36
|
}
|
|
@@ -7,7 +7,7 @@ import type { EntityOverrides } from "./entity_overrides";
|
|
|
7
7
|
import type { User } from "../users";
|
|
8
8
|
import type { RebaseContext } from "../rebase_context";
|
|
9
9
|
import type { Relation } from "./relations";
|
|
10
|
-
import type { EntityCustomView,
|
|
10
|
+
import type { EntityCustomView, FormViewConfig } from "./entity_views";
|
|
11
11
|
import type { EntityAction } from "./entity_actions";
|
|
12
12
|
import type { ComponentRef } from "./component_ref";
|
|
13
13
|
/**
|
|
@@ -124,10 +124,14 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
124
124
|
*/
|
|
125
125
|
defaultEntityAction?: "view" | "edit";
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
127
|
+
* Replace the default entity form with a custom component.
|
|
128
|
+
* The Builder receives the same props as entity view tabs
|
|
129
|
+
* (entity, formContext, collection, etc.) and has full control over the UI.
|
|
130
|
+
*
|
|
131
|
+
* Works in both edit mode and read-only mode (when `defaultEntityAction`
|
|
132
|
+
* is `"view"`). In read-only mode, `formContext.readOnly` will be `true`.
|
|
129
133
|
*/
|
|
130
|
-
|
|
134
|
+
formView?: FormViewConfig;
|
|
131
135
|
/**
|
|
132
136
|
* Prevent default actions from being displayed or executed on this collection.
|
|
133
137
|
*/
|
|
@@ -566,7 +570,7 @@ export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-conta
|
|
|
566
570
|
*
|
|
567
571
|
* @group Models
|
|
568
572
|
*/
|
|
569
|
-
export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown]>>;
|
|
573
|
+
export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown] | [WhereFilterOp, unknown][]>>;
|
|
570
574
|
/**
|
|
571
575
|
* A pre-defined filter preset for quick access in the collection toolbar.
|
|
572
576
|
* Users can select a preset to instantly apply a set of filters and
|
|
@@ -56,41 +56,32 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
|
|
|
56
56
|
Builder?: ComponentRef<EntityCustomViewParams<M>>;
|
|
57
57
|
position?: "start" | "end";
|
|
58
58
|
};
|
|
59
|
-
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
60
|
-
collection: EntityCollection<M>;
|
|
61
|
-
entity?: Entity<M>;
|
|
62
|
-
modifiedValues?: EntityValues<M>;
|
|
63
|
-
formContext: FormContext<M>;
|
|
64
|
-
parentCollectionSlugs?: string[];
|
|
65
|
-
parentEntityIds?: string[];
|
|
66
|
-
}
|
|
67
59
|
/**
|
|
68
|
-
* Configuration
|
|
69
|
-
*
|
|
60
|
+
* Configuration to replace the default entity form with a custom component.
|
|
61
|
+
* The Builder receives the same props as entity view tabs (entity, formContext, etc.)
|
|
62
|
+
* and has full control over the UI.
|
|
63
|
+
*
|
|
64
|
+
* The form tab still appears in the tab bar but renders your Builder
|
|
65
|
+
* instead of the auto-generated field form.
|
|
66
|
+
*
|
|
70
67
|
* @group Models
|
|
71
68
|
*/
|
|
72
|
-
export type
|
|
73
|
-
/**
|
|
74
|
-
* Custom component rendered above the property display in the detail view.
|
|
75
|
-
*/
|
|
76
|
-
Header?: ComponentRef<EntityDetailViewParams<M>>;
|
|
69
|
+
export type FormViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
77
70
|
/**
|
|
78
|
-
* Custom component
|
|
71
|
+
* Custom component that replaces the default form.
|
|
79
72
|
*/
|
|
80
|
-
|
|
73
|
+
Builder: ComponentRef<EntityCustomViewParams<M>>;
|
|
81
74
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
75
|
+
* If true, the save/delete action bar is rendered alongside the custom view.
|
|
76
|
+
* Defaults to true.
|
|
84
77
|
*/
|
|
85
|
-
|
|
78
|
+
includeActions?: boolean;
|
|
86
79
|
};
|
|
87
|
-
|
|
88
|
-
* Props passed to detail view customization components (Header, Footer, Builder).
|
|
89
|
-
* @group Models
|
|
90
|
-
*/
|
|
91
|
-
export interface EntityDetailViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
80
|
+
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
92
81
|
collection: EntityCollection<M>;
|
|
93
|
-
entity
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
entity?: Entity<M>;
|
|
83
|
+
modifiedValues?: EntityValues<M>;
|
|
84
|
+
formContext: FormContext<M>;
|
|
85
|
+
parentCollectionSlugs?: string[];
|
|
86
|
+
parentEntityIds?: string[];
|
|
96
87
|
}
|
|
@@ -104,8 +104,8 @@ export interface BaseUIConfig<CustomProps = unknown> {
|
|
|
104
104
|
disabled?: boolean | PropertyDisabledConfig;
|
|
105
105
|
widthPercentage?: number;
|
|
106
106
|
customProps?: CustomProps;
|
|
107
|
-
Field?: ComponentRef
|
|
108
|
-
Preview?: ComponentRef
|
|
107
|
+
Field?: ComponentRef<any>;
|
|
108
|
+
Preview?: ComponentRef<any>;
|
|
109
109
|
}
|
|
110
110
|
export interface BaseProperty<CustomProps = unknown> {
|
|
111
111
|
ui?: BaseUIConfig<CustomProps>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/client-postgresql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
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.
|
|
61
|
-
"@rebasepro/types": "0.
|
|
60
|
+
"@rebasepro/client": "0.4.0",
|
|
61
|
+
"@rebasepro/types": "0.4.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"react": ">=19.0.0",
|