@rebasepro/studio 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.
@@ -1,4 +1,7 @@
1
- import { FindResponse, CollectionAccessor, QueryBuilderInterface, FilterOperator } from "@rebasepro/types";
1
+ import { FindResponse, CollectionAccessor, QueryBuilderInterface, FilterOperator, LogicalCondition, WhereValue, FilterCondition } from "@rebasepro/types";
2
+ export declare function or(...conditions: (FilterCondition | LogicalCondition)[]): LogicalCondition;
3
+ export declare function and(...conditions: (FilterCondition | LogicalCondition)[]): LogicalCondition;
4
+ export declare function cond(column: string, operator: FilterOperator, value: unknown): FilterCondition;
2
5
  export declare class QueryBuilder<M extends Record<string, unknown> = Record<string, unknown>> implements QueryBuilderInterface<M> {
3
6
  private collection;
4
7
  private params;
@@ -8,7 +11,8 @@ export declare class QueryBuilder<M extends Record<string, unknown> = Record<str
8
11
  * @example
9
12
  * client.collection('users').where('age', '>=', 18).find()
10
13
  */
11
- where(column: keyof M & string, operator: FilterOperator, value: unknown): this;
14
+ where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): this;
15
+ where(logicalCondition: LogicalCondition): this;
12
16
  /**
13
17
  * Order the results by a specific column.
14
18
  * @example
@@ -1,4 +1,4 @@
1
- import type { Property } from "@rebasepro/types";
1
+ import type { Property, Entity } from "@rebasepro/types";
2
2
  import { CollectionSize, SelectedCellProps } from "@rebasepro/types";
3
3
  export type EntityCollectionTableController<M extends Record<string, unknown>> = {
4
4
  /**
@@ -26,7 +26,7 @@ export type EntityCollectionTableController<M extends Record<string, unknown>> =
26
26
  * Callback used when the value of a cell has changed.
27
27
  * @param params
28
28
  */
29
- onValueChange?: (params: OnCellValueChangeParams<unknown, M>) => void;
29
+ onValueChange?: (params: OnCellValueChangeParams<unknown, Entity<M>>) => void;
30
30
  /**
31
31
  * Size of the elements in the collection
32
32
  */
@@ -56,7 +56,7 @@ export type UniqueFieldValidator = (props: {
56
56
  * Callback when a cell has changed in a table
57
57
  * @group Collection components
58
58
  */
59
- export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, M>) => Promise<void> | void;
59
+ export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, Entity<M>>) => Promise<void> | void;
60
60
  /**
61
61
  * @group Collection components
62
62
  */
@@ -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(column: keyof M & string, operator: FilterOperator, value: unknown): this;
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(column: keyof M & string, operator: FilterOperator, value: unknown): QueryBuilderInterface<M>;
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, EntityDetailViewConfig } from "./entity_views";
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
- * Customization options for the read-only detail view.
128
- * Only used when `defaultEntityAction` is `"view"`.
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
- detailView?: EntityDetailViewConfig;
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 for customizing the read-only detail view of an entity.
69
- * Only used when `defaultEntityAction` is set to `"view"` on the collection.
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 EntityDetailViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
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 rendered below the property display in the detail view.
71
+ * Custom component that replaces the default form.
79
72
  */
80
- Footer?: ComponentRef<EntityDetailViewParams<M>>;
73
+ Builder: ComponentRef<EntityCustomViewParams<M>>;
81
74
  /**
82
- * Completely replace the default detail view with a custom component.
83
- * When set, Header and Footer are ignored.
75
+ * If true, the save/delete action bar is rendered alongside the custom view.
76
+ * Defaults to true.
84
77
  */
85
- Builder?: ComponentRef<EntityDetailViewParams<M>>;
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: Entity<M>;
94
- path: string;
95
- onEditClick: () => void;
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>;
@@ -1,9 +1,8 @@
1
1
  import React from "react";
2
- type CardProps = {
2
+ declare const Card: React.ForwardRefExoticComponent<{
3
3
  children: React.ReactNode;
4
4
  style?: React.CSSProperties;
5
5
  onClick?: (e?: React.MouseEvent) => void;
6
6
  className?: string;
7
- };
8
- declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
7
+ } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
9
8
  export { Card };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- export interface FilterChipProps {
2
+ export interface FilterChipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
3
3
  /**
4
4
  * The text label displayed on the chip.
5
5
  */
@@ -8,10 +8,6 @@ export interface FilterChipProps {
8
8
  * Whether the chip is currently in an active/selected state.
9
9
  */
10
10
  active?: boolean;
11
- /**
12
- * Callback when the chip is clicked.
13
- */
14
- onClick?: () => void;
15
11
  /**
16
12
  * Optional icon rendered before the label.
17
13
  */
@@ -21,10 +17,6 @@ export interface FilterChipProps {
21
17
  * @default "medium"
22
18
  */
23
19
  size?: "small" | "medium";
24
- /**
25
- * Additional class names.
26
- */
27
- className?: string;
28
20
  /**
29
21
  * Whether the chip is disabled.
30
22
  */
@@ -39,4 +31,4 @@ export interface FilterChipProps {
39
31
  *
40
32
  * @group Interactive components
41
33
  */
42
- export declare function FilterChip({ children, active, onClick, icon, size, className, disabled }: FilterChipProps): import("react/jsx-runtime").JSX.Element;
34
+ export declare const FilterChip: React.ForwardRefExoticComponent<FilterChipProps & React.RefAttributes<HTMLButtonElement>>;
@@ -224,6 +224,12 @@ export type OnVirtualTableColumnResizeParams = {
224
224
  key: string;
225
225
  column: VirtualTableColumn;
226
226
  };
227
+ /**
228
+ * @see Table
229
+ * @group Components
230
+ */
231
+ export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any";
232
+ export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown] | [WhereFilterOp, unknown][]>>;
227
233
  /**
228
234
  * @see Table
229
235
  * @group Components
@@ -233,11 +239,11 @@ export type VirtualTableSort = "asc" | "desc" | undefined;
233
239
  * @see Table
234
240
  * @group Components
235
241
  */
236
- export type VirtualTableFilterValues<Key extends string> = Partial<Record<Key, [VirtualTableWhereFilterOp, unknown]>>;
242
+ export type VirtualTableFilterValues<Key extends string> = FilterValues<Key>;
237
243
  /**
238
244
  * Filter conditions in a `Query.where()` clause are specified using the
239
245
  * strings `<`, `<=`, `==`, `>=`, `>`, `array-contains`, `in`, and `array-contains-any`.
240
246
  * @see Table
241
247
  * @group Models
242
248
  */
243
- export type VirtualTableWhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any";
249
+ export type VirtualTableWhereFilterOp = WhereFilterOp;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/studio",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.4.0",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "dist/studio/src/index.d.ts",
@@ -15,19 +15,19 @@
15
15
  "pgsql-ast-parser": "12.0.2",
16
16
  "prism-react-renderer": "^2.4.1",
17
17
  "react-dropzone": "^14.4.1",
18
- "@rebasepro/common": "0.2.5",
19
- "@rebasepro/client": "0.2.5",
20
- "@rebasepro/core": "0.2.5",
21
- "@rebasepro/ui": "0.2.5",
22
- "@rebasepro/utils": "0.2.5",
23
- "@rebasepro/types": "0.2.5"
18
+ "@rebasepro/client": "0.4.0",
19
+ "@rebasepro/common": "0.4.0",
20
+ "@rebasepro/core": "0.4.0",
21
+ "@rebasepro/types": "0.4.0",
22
+ "@rebasepro/ui": "0.4.0",
23
+ "@rebasepro/utils": "0.4.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": ">=19.0.0",
27
27
  "react-dom": ">=19.0.0",
28
28
  "react-router": "^7.0.0",
29
29
  "react-router-dom": "^7.0.0",
30
- "@rebasepro/admin": "0.2.5"
30
+ "@rebasepro/admin": "0.4.0"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
33
  "@rebasepro/admin": {