@rebasepro/server-postgresql 0.0.1-canary.892f711 → 0.0.1-canary.a6becfb

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.
Files changed (33) hide show
  1. package/dist/index.es.js +381 -1074
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +312 -1005
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +2 -1
  6. package/dist/server-postgresql/src/schema/introspect-db-inference.d.ts +5 -0
  7. package/dist/server-postgresql/src/schema/introspect-db-logic.d.ts +44 -9
  8. package/dist/server-postgresql/src/services/EntityPersistService.d.ts +9 -0
  9. package/dist/types/src/controllers/auth.d.ts +8 -2
  10. package/dist/types/src/controllers/client.d.ts +13 -0
  11. package/dist/types/src/controllers/navigation.d.ts +18 -6
  12. package/dist/types/src/controllers/registry.d.ts +9 -1
  13. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  14. package/dist/types/src/rebase_context.d.ts +17 -0
  15. package/dist/types/src/types/collections.d.ts +64 -1
  16. package/dist/types/src/types/component_ref.d.ts +47 -0
  17. package/dist/types/src/types/entity_views.d.ts +2 -1
  18. package/dist/types/src/types/index.d.ts +1 -0
  19. package/dist/types/src/types/properties.d.ts +3 -3
  20. package/dist/types/src/types/translations.d.ts +8 -0
  21. package/package.json +5 -5
  22. package/src/PostgresBackendDriver.ts +23 -6
  23. package/src/cli.ts +9 -1
  24. package/src/data-transformer.ts +84 -1
  25. package/src/schema/generate-drizzle-schema-logic.ts +35 -0
  26. package/src/schema/introspect-db-inference.ts +238 -0
  27. package/src/schema/introspect-db-logic.ts +337 -36
  28. package/src/schema/introspect-db.ts +66 -23
  29. package/src/services/EntityFetchService.ts +16 -0
  30. package/src/services/EntityPersistService.ts +88 -12
  31. package/test/generate-drizzle-schema.test.ts +128 -0
  32. package/test/introspect-db-generation.test.ts +5 -5
  33. package/test/property-ordering.test.ts +395 -0
@@ -3,7 +3,7 @@ import { BranchService } from "./services/BranchService";
3
3
  import { RealtimeService } from "./services/realtimeService";
4
4
  import { DatabasePoolManager } from "./databasePoolManager";
5
5
  import { DrizzleClient } from "./interfaces";
6
- import { User } from "@rebasepro/types";
6
+ import { User, RebaseClient } from "@rebasepro/types";
7
7
  import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry";
8
8
  import { DataDriver, DeleteEntityProps, Entity, EntityCollection, FetchCollectionProps, FetchEntityProps, ListenCollectionProps, ListenEntityProps, SaveEntityProps, RebaseData, TableMetadata, DatabaseAdmin } from "@rebasepro/types";
9
9
  import { HistoryService } from "./history/HistoryService";
@@ -19,6 +19,7 @@ export declare class PostgresBackendDriver implements DataDriver {
19
19
  branchService?: BranchService;
20
20
  user?: User;
21
21
  data: RebaseData;
22
+ client?: RebaseClient;
22
23
  /**
23
24
  * When true, realtime notifications are deferred until after the
24
25
  * wrapping transaction commits. Set by `withAuth` → `withTransaction`.
@@ -0,0 +1,5 @@
1
+ export interface InferenceResult {
2
+ propType?: string;
3
+ extra?: string;
4
+ }
5
+ export declare function inferPropertyFromData(columnName: string, pgDataType: string, currentPropType: string, sampleValues: unknown[], isPk: boolean): InferenceResult;
@@ -1,11 +1,3 @@
1
- /**
2
- * Introspection logic — pure functions and the pipeline that transforms
3
- * raw PostgreSQL metadata into Rebase collection definition files.
4
- *
5
- * This module contains NO side-effects: no fs writes, no pg.Client creation,
6
- * no process.exit. It is imported by introspect-db.ts (the CLI entry-point)
7
- * and consumed directly by tests.
8
- */
9
1
  export interface TableRow {
10
2
  table_name: string;
11
3
  }
@@ -57,6 +49,49 @@ export declare function mapPgType(dataType: string): string;
57
49
  export declare function buildEnumMap(enumValues: EnumValue[]): Map<string, string[]>;
58
50
  export declare function buildTablesMap(tables: TableRow[], columns: TableColumn[], pks: PrimaryKeyRow[], fks: ForeignKeyRow[]): Map<string, TableMeta>;
59
51
  export declare function identifyJoinTables(tablesMap: Map<string, TableMeta>): Set<string>;
52
+ /**
53
+ * Property metadata used to compute display priority.
54
+ * Keeps computePropertyPriority free of any TableMeta coupling.
55
+ */
56
+ export interface PropertyOrderingContext {
57
+ /** The resolved Rebase property type (e.g. "string", "number", "date", "relation"). */
58
+ propType: string;
59
+ /** Whether this column is a primary key. */
60
+ isPk: boolean;
61
+ /** Whether this column is an enum (USER-DEFINED with matching values). */
62
+ isEnum: boolean;
63
+ /** Whether this is a storage/file-upload field (detected from column name). */
64
+ isStorage: boolean;
65
+ /** The PostgreSQL data_type (e.g. "text", "character varying", "jsonb"). */
66
+ pgDataType: string;
67
+ /** The original column index in PostgreSQL (for stable tiebreaking). */
68
+ originalIndex: number;
69
+ }
70
+ /**
71
+ * Compute a numeric priority score for a property.
72
+ * Lower scores appear first in the generated `propertiesOrder` array.
73
+ *
74
+ * The system uses 14 tiers (0–139), with the original column index
75
+ * added as a fractional tiebreaker (originalIndex / 10000) to
76
+ * guarantee stable ordering within the same tier.
77
+ *
78
+ * Pure function — no side effects.
79
+ */
80
+ export declare function computePropertyPriority(columnName: string, ctx: PropertyOrderingContext): number;
81
+ /**
82
+ * Sort a `propertiesOrder` array using the priority heuristic.
83
+ * Returns a new sorted array; does not mutate the input.
84
+ *
85
+ * @param entries - Array of { key, columnName, propType, ... } objects
86
+ * carrying the information needed to compute priority.
87
+ */
88
+ export interface PropertyOrderEntry {
89
+ /** The property key in the generated collection (may differ from columnName for relations). */
90
+ key: string;
91
+ /** The ordering context for this property. */
92
+ ctx: PropertyOrderingContext;
93
+ }
94
+ export declare function sortPropertiesOrder(entries: PropertyOrderEntry[]): string[];
60
95
  export interface GeneratedFile {
61
96
  tableName: string;
62
97
  fileName: string;
@@ -66,7 +101,7 @@ export interface GeneratedFile {
66
101
  * Generate the full TypeScript file content for a single collection.
67
102
  * Pure function — no I/O.
68
103
  */
69
- export declare function generateCollectionFile(tableName: string, meta: TableMeta, allFks: ForeignKeyRow[], joinTables: Set<string>, tablesMap: Map<string, TableMeta>, enumMap: Map<string, string[]>): string;
104
+ export declare function generateCollectionFile(tableName: string, meta: TableMeta, allFks: ForeignKeyRow[], joinTables: Set<string>, tablesMap: Map<string, TableMeta>, enumMap: Map<string, string[]>, sampleData?: Record<string, unknown>[]): string;
70
105
  /**
71
106
  * Generate the content for an index.ts file that re-exports all collections.
72
107
  */
@@ -33,6 +33,15 @@ export declare class EntityPersistService {
33
33
  * Translate raw PostgreSQL / Drizzle errors into user-friendly messages.
34
34
  */
35
35
  private toUserFriendlyError;
36
+ /**
37
+ * Walk the error cause chain and return the deepest meaningful message.
38
+ */
39
+ private extractCauseMessage;
40
+ /**
41
+ * Strip the raw SQL query from a Drizzle "Failed query: ..." message,
42
+ * keeping only the error description.
43
+ */
44
+ private stripSqlFromMessage;
36
45
  /**
37
46
  * Extract the underlying PostgreSQL error from a Drizzle wrapper.
38
47
  * Drizzle wraps PG errors in a `cause` property.
@@ -80,8 +80,14 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
80
80
  export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
81
81
  /** Login with email and password */
82
82
  emailPasswordLogin?(email: string, password: string): Promise<void>;
83
- /** Login with a Google token (ID token or access token from popup) */
84
- googleLogin?(token: string, tokenType?: "idToken" | "accessToken"): Promise<void>;
83
+ /** Login with a Google token or authorization code */
84
+ googleLogin?: {
85
+ (token: string, tokenType?: "idToken" | "accessToken"): Promise<void>;
86
+ (payload: {
87
+ code: string;
88
+ redirectUri: string;
89
+ }): Promise<void>;
90
+ };
85
91
  /** Register a new user */
86
92
  register?(email: string, password: string, displayName?: string): Promise<void>;
87
93
  /** Skip login (for anonymous access if enabled) */
@@ -167,4 +167,17 @@ export interface RebaseClient<DB = unknown> {
167
167
  email?: EmailService;
168
168
  /** Admin API for user and role management */
169
169
  admin?: AdminAPI;
170
+ /**
171
+ * The base HTTP URL of the backend server.
172
+ * Exposed by the SDK client (`@rebasepro/client`) and used to auto-derive
173
+ * the `ApiConfigProvider` URL.
174
+ */
175
+ baseUrl?: string;
176
+ /**
177
+ * WebSocket client for realtime subscriptions and admin capabilities.
178
+ * Exposed by the SDK client (`@rebasepro/client`). The shape is intentionally
179
+ * left as `unknown` in the base interface — callers should narrow via feature
180
+ * detection (e.g. `typeof ws.executeSql === "function"`).
181
+ */
182
+ ws?: unknown;
170
183
  }
@@ -144,17 +144,18 @@ export interface AppView {
144
144
  * It will still be accessible if you reach the specified path
145
145
  */
146
146
  hideFromNavigation?: boolean;
147
+ /**
148
+ * Navigation group for this view.
149
+ * Views sharing the same group name will be visually grouped
150
+ * together in the drawer and home page. If not set, the view
151
+ * falls into the default "Views" group.
152
+ */
153
+ group?: string;
147
154
  /**
148
155
  * Component to be rendered. This can be any React component, and can use
149
156
  * any of the provided hooks
150
157
  */
151
158
  view: React.ReactNode;
152
- /**
153
- * Optional field used to group top level navigation entries under a
154
- * navigation view.
155
- * This prop is ignored for admin views.
156
- */
157
- group?: string;
158
159
  /**
159
160
  * If true, a wildcard route (slug/*) is automatically registered
160
161
  * alongside the base route, enabling nested navigation within this view.
@@ -193,6 +194,17 @@ export interface NavigationGroupMapping {
193
194
  * List of collection ids or view paths that belong to this group.
194
195
  */
195
196
  entries: string[];
197
+ /**
198
+ * Configure which groups start collapsed.
199
+ * Set to `true` to collapse in both drawer and home page,
200
+ * or use an object to control each independently.
201
+ *
202
+ * @defaultValue false (expanded)
203
+ */
204
+ collapsedByDefault?: boolean | {
205
+ drawer?: boolean;
206
+ home?: boolean;
207
+ };
196
208
  }
197
209
  export interface NavigationEntry {
198
210
  id: string;
@@ -3,7 +3,7 @@ import type { EntityCollection } from "../types/collections";
3
3
  import type { EntityCollectionsBuilder } from "../types/builders";
4
4
  import type { EntityCustomView } from "../types/entity_views";
5
5
  import type { EntityAction } from "../types/entity_actions";
6
- import type { AppView } from "./navigation";
6
+ import type { AppView, NavigationGroupMapping } from "./navigation";
7
7
  /**
8
8
  * Options to enable the built-in collection editor.
9
9
  * When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
@@ -25,6 +25,14 @@ export interface RebaseCMSConfig<EC extends EntityCollection = any> {
25
25
  entityViews?: EntityCustomView<any>[];
26
26
  entityActions?: EntityAction[];
27
27
  plugins?: any[];
28
+ /**
29
+ * Centralized configuration for how collections and views are grouped
30
+ * in the navigation sidebar and home page.
31
+ * Each mapping defines a named group and the collection/view slugs
32
+ * that belong to it. The array order determines group display order.
33
+ * Entry order within each group determines card order.
34
+ */
35
+ navigationGroupMappings?: NavigationGroupMapping[];
28
36
  /**
29
37
  * Enable the built-in visual collection/schema editor.
30
38
  * Pass `true` for zero-config, or an options object for fine-grained control.
@@ -62,6 +62,13 @@ export interface EntitySidePanelProps<M extends Record<string, unknown> = Record
62
62
  * Allow the user to open the entity fullscreen
63
63
  */
64
64
  allowFullScreen?: boolean;
65
+ /**
66
+ * Pre-populate the form with these values when creating a new entity.
67
+ * Only applied when `entityId` is not set (i.e. the form is in "new" mode).
68
+ * Useful for actions that fetch data from an external source (e.g. a URL)
69
+ * and want to pre-fill the document before the user saves.
70
+ */
71
+ defaultValues?: Partial<M>;
65
72
  }
66
73
  /**
67
74
  * Controller to open the side dialog displaying entity forms
@@ -3,6 +3,7 @@ import type { AuthController } from "./controllers/auth";
3
3
  import type { StorageSource } from "./controllers/storage";
4
4
  import type { UserConfigurationPersistence } from "./controllers/local_config_persistence";
5
5
  import type { DatabaseAdmin } from "./types/backend";
6
+ import type { RebaseClient } from "./controllers/client";
6
7
  import type { RebaseData } from "./controllers/data";
7
8
  import type { User } from "./users";
8
9
  import type { UserManagementDelegate } from "./types/user_management_delegate";
@@ -12,6 +13,22 @@ import type { UserManagementDelegate } from "./types/user_management_delegate";
12
13
  * @group Hooks and utilities
13
14
  */
14
15
  export type RebaseCallContext<USER extends User = User> = {
16
+ /**
17
+ * The Rebase client instance.
18
+ * Available in all entity callbacks (beforeSave, afterSave, afterRead,
19
+ * beforeDelete, afterDelete) and in CollectionActionsProps via context.
20
+ * Use it to call backend functions, access data, storage, etc.
21
+ *
22
+ * @example
23
+ * // In a beforeSave callback:
24
+ * const result = await context.client.functions.invoke('my-function', { ... });
25
+ *
26
+ * @example
27
+ * // In a CollectionAction component:
28
+ * const { client } = props.context;
29
+ * const result = await client.functions.invoke('extract-job', { url });
30
+ */
31
+ client: RebaseClient<any>;
15
32
  /**
16
33
  * Unified data access — `context.data.products.create(...)`.
17
34
  * Access any collection as a dynamic property.
@@ -9,6 +9,7 @@ import type { RebaseContext } from "../rebase_context";
9
9
  import type { Relation } from "./relations";
10
10
  import type { EntityCustomView } from "./entity_views";
11
11
  import type { EntityAction } from "./entity_actions";
12
+ import type { ComponentRef } from "./component_ref";
12
13
  /**
13
14
  * Base interface containing all driver-agnostic collection properties.
14
15
  * Use {@link PostgresCollection} or {@link FirebaseCollection} for
@@ -86,6 +87,9 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
86
87
  icon?: string | React.ReactNode;
87
88
  /**
88
89
  * Navigation group for this collection.
90
+ * Collections sharing the same group name will be visually grouped
91
+ * together in the drawer and home page. If not set, the collection
92
+ * falls into the default "Views" group.
89
93
  */
90
94
  group?: string;
91
95
  /**
@@ -168,6 +172,24 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
168
172
  * e.g. `defaultFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
169
173
  */
170
174
  readonly defaultFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
175
+ /**
176
+ * Pre-defined filter presets that appear as quick-access options in the
177
+ * collection toolbar. Each preset applies a set of filters (and
178
+ * optionally a sort order) with a single click.
179
+ *
180
+ * ```ts
181
+ * filterPresets: [
182
+ * {
183
+ * label: "Shipped this month",
184
+ * filterValues: {
185
+ * status: ["==", "shipped"],
186
+ * order_date: [">=", new Date(Date.now() - 30 * 86400000)]
187
+ * }
188
+ * }
189
+ * ]
190
+ * ```
191
+ */
192
+ readonly filterPresets?: FilterPreset<Extract<keyof M, string> | (string & {})>[];
171
193
  /**
172
194
  * Default sort applied to this collection.
173
195
  * When setting this prop, entities will have a default order
@@ -301,7 +323,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
301
323
  /**
302
324
  * Builder for the collection actions rendered in the toolbar
303
325
  */
304
- Actions?: React.ComponentType<any>[];
326
+ Actions?: ComponentRef<CollectionActionsProps>[];
305
327
  }
306
328
  /**
307
329
  * A collection backed by PostgreSQL (or any SQL database).
@@ -482,6 +504,21 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
482
504
  * undefined means the count is still loading.
483
505
  */
484
506
  collectionEntitiesCount?: number;
507
+ /**
508
+ * Programmatically open the new-document form for this collection,
509
+ * optionally pre-populating it with initial field values.
510
+ * The form opens in the same mode configured for the collection
511
+ * (side panel, full screen, or split).
512
+ *
513
+ * This is the primary hook for workflows that need to create a document
514
+ * from external data — e.g. fetching content from a URL, importing from
515
+ * a third-party API, or duplicating from another system.
516
+ *
517
+ * @example
518
+ * // Inside a custom CollectionAction component:
519
+ * openNewDocument({ title: "Fetched title", body: "..." });
520
+ */
521
+ openNewDocument: (defaultValues?: Record<string, unknown>) => void;
485
522
  }
486
523
  /**
487
524
  * Use this controller to retrieve the selected entities or modify them in
@@ -509,6 +546,32 @@ export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-conta
509
546
  * @group Models
510
547
  */
511
548
  export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown]>>;
549
+ /**
550
+ * A pre-defined filter preset for quick access in the collection toolbar.
551
+ * Users can select a preset to instantly apply a set of filters and
552
+ * optionally a sort order.
553
+ *
554
+ * @group Models
555
+ */
556
+ export interface FilterPreset<Key extends string = string> {
557
+ /**
558
+ * Display label shown in the preset menu.
559
+ * If omitted, a summary is auto-generated from the filter keys.
560
+ */
561
+ label?: string;
562
+ /**
563
+ * The filter values to apply when this preset is selected.
564
+ */
565
+ filterValues: FilterValues<Key>;
566
+ /**
567
+ * Optional sort override to apply alongside the filter values.
568
+ */
569
+ sort?: [Key, "asc" | "desc"];
570
+ }
571
+ /**
572
+ * @deprecated Use {@link FilterPreset} instead.
573
+ */
574
+ export type QuickFilter<Key extends string = string> = FilterPreset<Key>;
512
575
  /**
513
576
  * Used to indicate valid filter combinations (e.g. created in Firestore)
514
577
  * If the user selects a specific filter/sort combination, the CMS checks if it's
@@ -0,0 +1,47 @@
1
+ import type React from "react";
2
+ /**
3
+ * Internal marker for a lazily-loaded component reference.
4
+ * Created by the Vite transform plugin when converting string paths
5
+ * to deferred `import()` calls. Users should NOT create these manually.
6
+ *
7
+ * @internal
8
+ */
9
+ export interface LazyComponentRef<P = unknown> {
10
+ readonly __rebaseLazy: true;
11
+ readonly load: () => Promise<{
12
+ default: React.ComponentType<P>;
13
+ }>;
14
+ }
15
+ /**
16
+ * A reference to a React component that can be provided in three forms:
17
+ *
18
+ * 1. **String path** (recommended for collection configs):
19
+ * ```ts
20
+ * Field: "../../frontend/src/components/MyField"
21
+ * ```
22
+ * The Vite plugin transforms this into a `LazyComponentRef` at build time.
23
+ * On the backend, the string stays inert and is never evaluated.
24
+ *
25
+ * 2. **Lazy import function**:
26
+ * ```ts
27
+ * Field: () => import("../../frontend/src/components/MyField")
28
+ * ```
29
+ * Standard ES dynamic import. Backend never calls the function.
30
+ *
31
+ * 3. **Direct component reference** (use only in frontend-only code):
32
+ * ```ts
33
+ * Field: MyFieldComponent
34
+ * ```
35
+ * Importing a component at the top level will pull React into the
36
+ * backend runtime — only safe in code that the backend never imports.
37
+ *
38
+ * @group Types
39
+ */
40
+ export type ComponentRef<P = unknown> = React.ComponentType<P> | LazyComponentRef<P> | (() => Promise<{
41
+ default: React.ComponentType<P>;
42
+ }>) | string;
43
+ /**
44
+ * Type guard: checks if a value is a `LazyComponentRef` produced by the
45
+ * Vite transform plugin.
46
+ */
47
+ export declare function isLazyComponentRef<P = unknown>(ref: unknown): ref is LazyComponentRef<P>;
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import type { Entity, EntityValues } from "./entities";
3
3
  import type { EntityCollection } from "./collections";
4
4
  import type { FormexController } from "./formex";
5
+ import type { ComponentRef } from "./component_ref";
5
6
  /**
6
7
  * Context passed to custom fields and entity views.
7
8
  * @group Form custom fields
@@ -46,7 +47,7 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
46
47
  name: string;
47
48
  tabComponent?: React.ReactNode;
48
49
  includeActions?: boolean | "bottom";
49
- Builder?: React.ComponentType<EntityCustomViewParams<M>>;
50
+ Builder?: ComponentRef<EntityCustomViewParams<M>>;
50
51
  position?: "start" | "end";
51
52
  };
52
53
  export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
@@ -23,3 +23,4 @@ export * from "./entity_views";
23
23
  export * from "./data_source";
24
24
  export * from "./cron";
25
25
  export * from "./backend_hooks";
26
+ export * from "./component_ref";
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import type { ComponentRef } from "./component_ref";
2
2
  import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
3
3
  import type { Relation, JoinStep, OnAction } from "./relations";
4
4
  import type { EntityCollection, FilterValues } from "./collections";
@@ -104,8 +104,8 @@ export interface BaseUIConfig<CustomProps = unknown> {
104
104
  disabled?: boolean | PropertyDisabledConfig;
105
105
  widthPercentage?: number;
106
106
  customProps?: CustomProps;
107
- Field?: React.ComponentType<any>;
108
- Preview?: React.ComponentType<any>;
107
+ Field?: ComponentRef<any>;
108
+ Preview?: ComponentRef<any>;
109
109
  }
110
110
  export interface BaseProperty<CustomProps = unknown> {
111
111
  ui?: BaseUIConfig<CustomProps>;
@@ -51,6 +51,8 @@ export interface RebaseTranslations {
51
51
  all_entries_loaded: string;
52
52
  create_your_first_entry: string;
53
53
  no_results_filter_sort: string;
54
+ /** Shown when a text search yields no results. Supports `{{search}}` interpolation. */
55
+ no_results_search?: string;
54
56
  add: string;
55
57
  remove: string;
56
58
  copy_id: string;
@@ -390,6 +392,12 @@ export interface RebaseTranslations {
390
392
  submit: string;
391
393
  no_filterable_properties: string;
392
394
  apply_filters: string;
395
+ /** Label shown on the filter presets dropdown trigger */
396
+ filter_presets?: string;
397
+ /** Tooltip shown when hovering over a preset entry */
398
+ filter_preset_apply?: string;
399
+ /** Shown when a preset is active, with {{label}} interpolation */
400
+ filter_preset_active?: string;
393
401
  list: string;
394
402
  table_view_mode: string;
395
403
  cards: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/server-postgresql",
3
3
  "type": "module",
4
- "version": "0.0.1-canary.892f711",
4
+ "version": "0.0.1-canary.a6becfb",
5
5
  "description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -64,10 +64,10 @@
64
64
  "drizzle-orm": "^0.44.4",
65
65
  "execa": "^4.1.0",
66
66
  "pg": "^8.11.3",
67
- "@rebasepro/common": "0.0.1-canary.892f711",
68
- "@rebasepro/server-core": "0.0.1-canary.892f711",
69
- "@rebasepro/types": "0.0.1-canary.892f711",
70
- "@rebasepro/utils": "0.0.1-canary.892f711"
67
+ "@rebasepro/common": "0.0.1-canary.a6becfb",
68
+ "@rebasepro/server-core": "0.0.1-canary.a6becfb",
69
+ "@rebasepro/utils": "0.0.1-canary.a6becfb",
70
+ "@rebasepro/types": "0.0.1-canary.a6becfb"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/jest": "^29.5.14",
@@ -4,9 +4,9 @@ import { BranchService } from "./services/BranchService";
4
4
  import { RealtimeService } from "./services/realtimeService";
5
5
  import { DatabasePoolManager } from "./databasePoolManager";
6
6
  import { DrizzleClient } from "./interfaces";
7
- import { User } from "@rebasepro/types";
7
+ import { User, RebaseClient } from "@rebasepro/types";
8
8
  import { sql as drizzleSql } from "drizzle-orm";
9
- import { buildPropertyCallbacks } from "@rebasepro/common";
9
+ import { buildPropertyCallbacks, updateDateAutoValues } from "@rebasepro/common";
10
10
  import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry";
11
11
  import {
12
12
  DataDriver,
@@ -44,6 +44,7 @@ export class PostgresBackendDriver implements DataDriver {
44
44
  public branchService?: BranchService;
45
45
  public user?: User;
46
46
  public data: RebaseData;
47
+ public client?: RebaseClient;
47
48
 
48
49
  /**
49
50
  * When true, realtime notifications are deferred until after the
@@ -163,7 +164,8 @@ propertyCallbacks: undefined };
163
164
  const contextForCallback = {
164
165
  user: this.user,
165
166
  driver: this,
166
- data: this.data
167
+ data: this.data,
168
+ client: this.client
167
169
  } as unknown as RebaseCallContext; // Backend context
168
170
  return Promise.all(entities.map(async (entity) => {
169
171
  let fetched = entity;
@@ -272,7 +274,8 @@ propertyCallbacks: undefined };
272
274
  const contextForCallback = {
273
275
  user: this.user,
274
276
  driver: this,
275
- data: this.data
277
+ data: this.data,
278
+ client: this.client
276
279
  } as unknown as RebaseCallContext; // Backend context
277
280
  if (callbacks?.afterRead) {
278
281
  entity = await callbacks.afterRead({
@@ -354,7 +357,8 @@ propertyCallbacks: undefined };
354
357
  const contextForCallback = {
355
358
  user: this.user,
356
359
  driver: this,
357
- data: this.data
360
+ data: this.data,
361
+ client: this.client
358
362
  } as unknown as RebaseCallContext;
359
363
 
360
364
  // Fetch previous values for callbacks AND history recording
@@ -395,6 +399,17 @@ propertyCallbacks: undefined };
395
399
 
396
400
  }
397
401
 
402
+ // Apply autoValue timestamps (on_create / on_update) at the application layer.
403
+ // This handles updated_at fields for all writes that flow through the Rebase backend.
404
+ if (resolvedCollection?.properties) {
405
+ updatedValues = updateDateAutoValues({
406
+ inputValues: updatedValues,
407
+ properties: resolvedCollection.properties,
408
+ status: status ?? "new",
409
+ timestampNowValue: new Date()
410
+ });
411
+ }
412
+
398
413
  try {
399
414
  let savedEntity = await this.entityService.saveEntity<M>(
400
415
  path,
@@ -517,7 +532,8 @@ propertyCallbacks: undefined };
517
532
  const contextForCallback = {
518
533
  user: this.user,
519
534
  driver: this,
520
- data: this.data
535
+ data: this.data,
536
+ client: this.client
521
537
  } as unknown as RebaseCallContext;
522
538
 
523
539
  if (callbacks?.beforeDelete || propertyCallbacks?.beforeDelete) {
@@ -940,6 +956,7 @@ roles: userRoles })}, true)
940
956
  txDelegate.entityService = txEntityService;
941
957
  txDelegate._deferNotifications = true;
942
958
  txDelegate._pendingNotifications = pendingNotifications;
959
+ txDelegate.client = this.delegate.client;
943
960
 
944
961
  return await operation(txDelegate);
945
962
  });
package/src/cli.ts CHANGED
@@ -68,6 +68,12 @@ async function dbCommand(subcommand: string, rawArgs: string[]): Promise<void> {
68
68
  console.log("");
69
69
  console.log(` You can now run ${chalk.bold.green("rebase db migrate")} to apply the migrations to your database.`);
70
70
  console.log("");
71
+ } else if (subcommand === "pull") {
72
+ console.log("");
73
+ console.log(chalk.yellow(" ⚠ \"rebase db pull\" has been removed."));
74
+ console.log(chalk.gray(" Use \"rebase schema introspect\" instead."));
75
+ console.log("");
76
+ process.exit(1);
71
77
  } else {
72
78
  console.log("");
73
79
  console.log(chalk.bold(` 🗄️ Rebase DB ${subcommand.charAt(0).toUpperCase() + subcommand.slice(1)}`));
@@ -538,9 +544,11 @@ async function schemaCommand(subcommand: string, rawArgs: string[]): Promise<voi
538
544
  const argsList = arg(
539
545
  {
540
546
  "--output": String,
547
+ "--collections": String,
541
548
  "--force": Boolean,
542
549
  "--schema": String,
543
550
  "-o": "--output",
551
+ "-c": "--collections",
544
552
  "-f": "--force"
545
553
  },
546
554
  {
@@ -561,7 +569,7 @@ async function schemaCommand(subcommand: string, rawArgs: string[]): Promise<voi
561
569
  process.exit(1);
562
570
  }
563
571
 
564
- const outputPath = argsList["--output"] || path.join("..", "config", "collections");
572
+ const outputPath = argsList["--output"] || argsList["--collections"] || path.join("..", "config", "collections");
565
573
 
566
574
  console.log("");
567
575
  console.log(chalk.bold(" 🔍 Rebase Schema Introspector"));