@rebasepro/server-postgresql 0.5.0 → 0.6.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/{server-postgresql/src/PostgresAdapter.d.ts → PostgresAdapter.d.ts} +1 -1
- package/dist/{server-postgresql/src/PostgresBackendDriver.d.ts → PostgresBackendDriver.d.ts} +2 -2
- package/dist/{server-postgresql/src/PostgresBootstrapper.d.ts → PostgresBootstrapper.d.ts} +11 -1
- package/dist/{server-postgresql/src/collections → collections}/PostgresCollectionRegistry.d.ts +4 -0
- package/dist/index.es.js +10168 -11145
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10735 -11429
- package/dist/index.umd.js.map +1 -1
- package/dist/{server-postgresql/src/services → services}/EntityPersistService.d.ts +0 -14
- package/dist/utils/pg-error-utils.d.ts +55 -0
- package/package.json +24 -21
- package/src/PostgresAdapter.ts +9 -10
- package/src/PostgresBackendDriver.ts +134 -121
- package/src/PostgresBootstrapper.ts +86 -13
- package/src/auth/ensure-tables.ts +28 -5
- package/src/auth/services.ts +28 -18
- package/src/cli.ts +99 -96
- package/src/collections/PostgresCollectionRegistry.ts +7 -0
- package/src/connection.ts +11 -6
- package/src/data-transformer.ts +16 -14
- package/src/databasePoolManager.ts +3 -2
- package/src/history/HistoryService.ts +3 -2
- package/src/history/ensure-history-table.ts +5 -4
- package/src/schema/auth-schema.ts +1 -2
- package/src/schema/doctor-cli.ts +2 -1
- package/src/schema/doctor.ts +40 -37
- package/src/schema/generate-drizzle-schema-logic.ts +56 -18
- package/src/schema/generate-drizzle-schema.ts +11 -11
- package/src/schema/introspect-db-inference.ts +25 -25
- package/src/schema/introspect-db-logic.ts +38 -38
- package/src/schema/introspect-db.ts +28 -27
- package/src/services/BranchService.ts +14 -0
- package/src/services/EntityFetchService.ts +28 -25
- package/src/services/EntityPersistService.ts +11 -141
- package/src/services/RelationService.ts +57 -37
- package/src/services/entity-helpers.ts +6 -2
- package/src/services/realtimeService.ts +45 -32
- package/src/utils/drizzle-conditions.ts +31 -15
- package/src/utils/pg-error-utils.ts +211 -0
- package/src/websocket.ts +15 -12
- package/test/auth-services.test.ts +36 -19
- package/test/batch-many-to-many-regression.test.ts +119 -39
- package/test/data-transformer-hardening.test.ts +67 -33
- package/test/data-transformer.test.ts +4 -2
- package/test/doctor.test.ts +10 -5
- package/test/drizzle-conditions.test.ts +59 -6
- package/test/generate-drizzle-schema.test.ts +65 -40
- package/test/introspect-db-generation.test.ts +179 -81
- package/test/introspect-db-utils.test.ts +92 -37
- package/test/mocks/chalk.cjs +7 -0
- package/test/pg-error-utils.test.ts +221 -0
- package/test/postgresDataDriver.test.ts +14 -5
- package/test/property-ordering.test.ts +126 -79
- package/test/realtimeService.test.ts +6 -2
- package/test/relation-pipeline-gaps.test.ts +84 -36
- package/test/relations.test.ts +247 -0
- package/test/unmapped-tables-safety.test.ts +14 -6
- package/test/websocket.test.ts +1 -1
- package/tsconfig.json +5 -0
- package/tsconfig.prod.json +3 -0
- package/vite.config.ts +5 -5
- package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
- package/dist/common/src/collections/default-collections.d.ts +0 -9
- package/dist/common/src/collections/index.d.ts +0 -2
- package/dist/common/src/data/buildRebaseData.d.ts +0 -14
- package/dist/common/src/data/query_builder.d.ts +0 -55
- package/dist/common/src/index.d.ts +0 -4
- package/dist/common/src/util/builders.d.ts +0 -57
- package/dist/common/src/util/callbacks.d.ts +0 -6
- package/dist/common/src/util/collections.d.ts +0 -11
- package/dist/common/src/util/common.d.ts +0 -2
- package/dist/common/src/util/conditions.d.ts +0 -26
- package/dist/common/src/util/entities.d.ts +0 -58
- package/dist/common/src/util/enums.d.ts +0 -3
- package/dist/common/src/util/index.d.ts +0 -16
- package/dist/common/src/util/navigation_from_path.d.ts +0 -34
- package/dist/common/src/util/navigation_utils.d.ts +0 -20
- package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
- package/dist/common/src/util/paths.d.ts +0 -14
- package/dist/common/src/util/permissions.d.ts +0 -14
- package/dist/common/src/util/references.d.ts +0 -2
- package/dist/common/src/util/relations.d.ts +0 -22
- package/dist/common/src/util/resolutions.d.ts +0 -72
- package/dist/common/src/util/storage.d.ts +0 -24
- package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
- package/dist/types/src/controllers/auth.d.ts +0 -104
- package/dist/types/src/controllers/client.d.ts +0 -168
- package/dist/types/src/controllers/collection_registry.d.ts +0 -46
- package/dist/types/src/controllers/customization_controller.d.ts +0 -60
- package/dist/types/src/controllers/data.d.ts +0 -207
- package/dist/types/src/controllers/data_driver.d.ts +0 -218
- package/dist/types/src/controllers/database_admin.d.ts +0 -11
- package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
- package/dist/types/src/controllers/effective_role.d.ts +0 -4
- package/dist/types/src/controllers/email.d.ts +0 -36
- package/dist/types/src/controllers/index.d.ts +0 -18
- package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
- package/dist/types/src/controllers/navigation.d.ts +0 -225
- package/dist/types/src/controllers/registry.d.ts +0 -63
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
- package/dist/types/src/controllers/snackbar.d.ts +0 -24
- package/dist/types/src/controllers/storage.d.ts +0 -171
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/rebase_context.d.ts +0 -122
- package/dist/types/src/types/auth_adapter.d.ts +0 -301
- package/dist/types/src/types/backend.d.ts +0 -571
- package/dist/types/src/types/backend_hooks.d.ts +0 -172
- package/dist/types/src/types/builders.d.ts +0 -15
- package/dist/types/src/types/chips.d.ts +0 -5
- package/dist/types/src/types/collections.d.ts +0 -961
- package/dist/types/src/types/component_ref.d.ts +0 -47
- package/dist/types/src/types/cron.d.ts +0 -102
- package/dist/types/src/types/data_source.d.ts +0 -64
- package/dist/types/src/types/database_adapter.d.ts +0 -94
- package/dist/types/src/types/entities.d.ts +0 -145
- package/dist/types/src/types/entity_actions.d.ts +0 -104
- package/dist/types/src/types/entity_callbacks.d.ts +0 -173
- package/dist/types/src/types/entity_link_builder.d.ts +0 -7
- package/dist/types/src/types/entity_overrides.d.ts +0 -10
- package/dist/types/src/types/entity_views.d.ts +0 -87
- package/dist/types/src/types/export_import.d.ts +0 -21
- package/dist/types/src/types/formex.d.ts +0 -40
- package/dist/types/src/types/index.d.ts +0 -28
- package/dist/types/src/types/locales.d.ts +0 -4
- package/dist/types/src/types/modify_collections.d.ts +0 -5
- package/dist/types/src/types/plugins.d.ts +0 -282
- package/dist/types/src/types/properties.d.ts +0 -1173
- package/dist/types/src/types/property_config.d.ts +0 -74
- package/dist/types/src/types/relations.d.ts +0 -336
- package/dist/types/src/types/slots.d.ts +0 -262
- package/dist/types/src/types/translations.d.ts +0 -900
- package/dist/types/src/types/user_management_delegate.d.ts +0 -86
- package/dist/types/src/types/websockets.d.ts +0 -78
- package/dist/types/src/users/index.d.ts +0 -1
- package/dist/types/src/users/user.d.ts +0 -50
- /package/dist/{server-postgresql/src/auth → auth}/ensure-tables.d.ts +0 -0
- /package/dist/{server-postgresql/src/auth → auth}/services.d.ts +0 -0
- /package/dist/{server-postgresql/src/cli.d.ts → cli.d.ts} +0 -0
- /package/dist/{server-postgresql/src/connection.d.ts → connection.d.ts} +0 -0
- /package/dist/{server-postgresql/src/data-transformer.d.ts → data-transformer.d.ts} +0 -0
- /package/dist/{server-postgresql/src/databasePoolManager.d.ts → databasePoolManager.d.ts} +0 -0
- /package/dist/{server-postgresql/src/history → history}/HistoryService.d.ts +0 -0
- /package/dist/{server-postgresql/src/history → history}/ensure-history-table.d.ts +0 -0
- /package/dist/{server-postgresql/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{server-postgresql/src/interfaces.d.ts → interfaces.d.ts} +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/auth-schema.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/doctor-cli.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/doctor.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema-logic.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/introspect-db-inference.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/introspect-db-logic.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/introspect-db.d.ts +0 -0
- /package/dist/{server-postgresql/src/schema → schema}/test-schema.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/BranchService.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/EntityFetchService.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/RelationService.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/entity-helpers.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/entityService.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/index.d.ts +0 -0
- /package/dist/{server-postgresql/src/services → services}/realtimeService.d.ts +0 -0
- /package/dist/{server-postgresql/src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{server-postgresql/src/utils → utils}/drizzle-conditions.d.ts +0 -0
- /package/dist/{server-postgresql/src/websocket.d.ts → websocket.d.ts} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
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 = any> = 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>;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { RebaseClient } from "../controllers/client";
|
|
2
|
-
/**
|
|
3
|
-
* Cron Job type definitions for Rebase.
|
|
4
|
-
*
|
|
5
|
-
* These types define the shape of cron job definitions, their runtime
|
|
6
|
-
* status, and execution log entries — used across server-core, client,
|
|
7
|
-
* and studio packages.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* A cron job definition file exports this shape as its default export.
|
|
11
|
-
* See the example cron files in `app/backend/crons/` for usage.
|
|
12
|
-
*/
|
|
13
|
-
export interface CronJobDefinition {
|
|
14
|
-
schedule: string;
|
|
15
|
-
/** Human-readable name shown in the Studio UI. */
|
|
16
|
-
name: string;
|
|
17
|
-
/** Optional description shown in the Studio UI. */
|
|
18
|
-
description?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Whether the job is enabled at startup. Defaults to `true`.
|
|
21
|
-
* Can be toggled at runtime via the Admin API.
|
|
22
|
-
*/
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Maximum number of seconds the handler may run before being
|
|
26
|
-
* considered timed-out. Default: 300 (5 min).
|
|
27
|
-
*/
|
|
28
|
-
timeoutSeconds?: number;
|
|
29
|
-
/**
|
|
30
|
-
* The handler function executed on each tick.
|
|
31
|
-
* Receives a context object with the data driver and logger.
|
|
32
|
-
* May return arbitrary JSON-serialisable data stored in the log.
|
|
33
|
-
*/
|
|
34
|
-
handler: (ctx: CronJobContext) => Promise<unknown> | unknown;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Context passed to each cron handler invocation.
|
|
38
|
-
*/
|
|
39
|
-
export interface CronJobContext {
|
|
40
|
-
/** The job's unique ID (derived from filename). */
|
|
41
|
-
jobId: string;
|
|
42
|
-
/** The current scheduled tick timestamp. */
|
|
43
|
-
scheduledAt: Date;
|
|
44
|
-
/** A simple logger scoped to this job run. */
|
|
45
|
-
log: (...args: unknown[]) => void;
|
|
46
|
-
/** The RebaseClient instance to interact with the database. */
|
|
47
|
-
client: RebaseClient;
|
|
48
|
-
}
|
|
49
|
-
export type CronJobRunState = "idle" | "running" | "success" | "error" | "disabled";
|
|
50
|
-
/**
|
|
51
|
-
* Full runtime information about a registered cron job.
|
|
52
|
-
*/
|
|
53
|
-
export interface CronJobStatus {
|
|
54
|
-
/** Unique identifier (derived from filename, e.g. "cleanup-sessions"). */
|
|
55
|
-
id: string;
|
|
56
|
-
/** Human-readable name from the definition. */
|
|
57
|
-
name: string;
|
|
58
|
-
/** Description from the definition. */
|
|
59
|
-
description?: string;
|
|
60
|
-
/** The cron schedule expression. */
|
|
61
|
-
schedule: string;
|
|
62
|
-
/** Whether the job is currently enabled. */
|
|
63
|
-
enabled: boolean;
|
|
64
|
-
/** Current run state. */
|
|
65
|
-
state: CronJobRunState;
|
|
66
|
-
/** ISO timestamp of the last execution start. */
|
|
67
|
-
lastRunAt?: string;
|
|
68
|
-
/** ISO timestamp of the next scheduled execution. */
|
|
69
|
-
nextRunAt?: string;
|
|
70
|
-
/** Duration of the last run in milliseconds. */
|
|
71
|
-
lastDurationMs?: number;
|
|
72
|
-
/** Error message from the last failed run. */
|
|
73
|
-
lastError?: string;
|
|
74
|
-
/** Total number of executions since server start. */
|
|
75
|
-
totalRuns: number;
|
|
76
|
-
/** Total number of failed executions since server start. */
|
|
77
|
-
totalFailures: number;
|
|
78
|
-
}
|
|
79
|
-
export type CronLogLevel = "info" | "error" | "warn";
|
|
80
|
-
/**
|
|
81
|
-
* A single execution log entry stored in the in-memory ring buffer.
|
|
82
|
-
*/
|
|
83
|
-
export interface CronJobLogEntry {
|
|
84
|
-
/** The job ID this log belongs to. */
|
|
85
|
-
jobId: string;
|
|
86
|
-
/** ISO timestamp when execution started. */
|
|
87
|
-
startedAt: string;
|
|
88
|
-
/** ISO timestamp when execution finished. */
|
|
89
|
-
finishedAt: string;
|
|
90
|
-
/** Duration in milliseconds. */
|
|
91
|
-
durationMs: number;
|
|
92
|
-
/** Whether this run succeeded. */
|
|
93
|
-
success: boolean;
|
|
94
|
-
/** Error message if the run failed. */
|
|
95
|
-
error?: string;
|
|
96
|
-
/** Arbitrary result data returned by the handler. */
|
|
97
|
-
result?: unknown;
|
|
98
|
-
/** Captured log lines. */
|
|
99
|
-
logs: string[];
|
|
100
|
-
/** Whether this was a manual trigger. */
|
|
101
|
-
manual?: boolean;
|
|
102
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Describes the capabilities and features supported by a data source (driver).
|
|
3
|
-
*
|
|
4
|
-
* Each driver (Postgres, Firebase, MongoDB, etc.) declares which features it
|
|
5
|
-
* supports. The CMS uses this descriptor to:
|
|
6
|
-
* - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
|
|
7
|
-
* - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
|
|
8
|
-
* - Toggle driver-specific form controls (e.g. `columnType` for SQL)
|
|
9
|
-
*
|
|
10
|
-
* @group Models
|
|
11
|
-
*/
|
|
12
|
-
export interface DataSourceCapabilities {
|
|
13
|
-
/** Unique driver key (e.g. "postgres", "firestore", "mongodb") */
|
|
14
|
-
key: string;
|
|
15
|
-
/** Human-readable label for the UI (e.g. "PostgreSQL", "Firebase / Firestore") */
|
|
16
|
-
label: string;
|
|
17
|
-
/** Does this source support SQL-style relations (JOINs)? */
|
|
18
|
-
supportsRelations: boolean;
|
|
19
|
-
/** Does this source support nested subcollections? */
|
|
20
|
-
supportsSubcollections: boolean;
|
|
21
|
-
/** Does this source support Row Level Security policies? */
|
|
22
|
-
supportsRLS: boolean;
|
|
23
|
-
/** Does this source support document references (Firebase-style)? */
|
|
24
|
-
supportsReferences: boolean;
|
|
25
|
-
/** Does this source support SQL column type annotations? */
|
|
26
|
-
supportsColumnTypes: boolean;
|
|
27
|
-
/** Does this source support real-time listeners? */
|
|
28
|
-
supportsRealtime: boolean;
|
|
29
|
-
/** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
|
|
30
|
-
supportsSQLAdmin: boolean;
|
|
31
|
-
/** Does this source support document admin operations (aggregation, stats)? */
|
|
32
|
-
supportsDocumentAdmin: boolean;
|
|
33
|
-
/** Does this source support schema admin (unmapped tables, table metadata)? */
|
|
34
|
-
supportsSchemaAdmin: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Subset of DataSourceCapabilities containing only feature flags.
|
|
38
|
-
* Useful when you only need to check capabilities without UI metadata.
|
|
39
|
-
* @group Models
|
|
40
|
-
*/
|
|
41
|
-
export type DataSourceFeatures = Omit<DataSourceCapabilities, "key" | "label">;
|
|
42
|
-
/** @group Models */
|
|
43
|
-
export declare const POSTGRES_CAPABILITIES: DataSourceCapabilities;
|
|
44
|
-
/** @group Models */
|
|
45
|
-
export declare const FIREBASE_CAPABILITIES: DataSourceCapabilities;
|
|
46
|
-
/** @group Models */
|
|
47
|
-
export declare const MONGODB_CAPABILITIES: DataSourceCapabilities;
|
|
48
|
-
/**
|
|
49
|
-
* Fallback capabilities when the driver is unknown.
|
|
50
|
-
* Enables everything so nothing is hidden unexpectedly.
|
|
51
|
-
* @group Models
|
|
52
|
-
*/
|
|
53
|
-
export declare const DEFAULT_CAPABILITIES: DataSourceCapabilities;
|
|
54
|
-
/**
|
|
55
|
-
* Look up capabilities for a given driver key.
|
|
56
|
-
* If `driver` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
57
|
-
* @group Models
|
|
58
|
-
*/
|
|
59
|
-
export declare function getDataSourceCapabilities(driver?: string): DataSourceCapabilities;
|
|
60
|
-
/**
|
|
61
|
-
* Register custom capabilities for a third-party driver.
|
|
62
|
-
* @group Models
|
|
63
|
-
*/
|
|
64
|
-
export declare function registerDataSourceCapabilities(capabilities: DataSourceCapabilities): void;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module DatabaseAdapter
|
|
3
|
-
*
|
|
4
|
-
* Pluggable database abstraction for Rebase.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* A `DatabaseAdapter` focuses purely on data persistence and related concerns (realtime, history).
|
|
8
|
-
* It does NOT handle authentication — auth is managed separately by an `AuthAdapter`.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { createPostgresAdapter } from "@rebasepro/server-postgresql";
|
|
13
|
-
*
|
|
14
|
-
* initializeRebaseBackend({
|
|
15
|
-
* database: createPostgresAdapter({ connection: db, schema }),
|
|
16
|
-
* auth: { jwtSecret: "..." },
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @group Backend
|
|
21
|
-
*/
|
|
22
|
-
import type { DataDriver } from "../controllers/data_driver";
|
|
23
|
-
import type { EntityCollection } from "./collections";
|
|
24
|
-
import type { CollectionRegistryInterface, DatabaseAdmin, InitializedDriver, RealtimeProvider, BootstrappedAuth } from "./backend";
|
|
25
|
-
/**
|
|
26
|
-
* A `DatabaseAdapter` provides data persistence for Rebase.
|
|
27
|
-
*
|
|
28
|
-
* @group Backend
|
|
29
|
-
*/
|
|
30
|
-
export interface DatabaseAdapter {
|
|
31
|
-
/**
|
|
32
|
-
* Which database engine this adapter handles.
|
|
33
|
-
*
|
|
34
|
-
* @example "postgres", "mysql", "mongodb", "sqlite"
|
|
35
|
-
*/
|
|
36
|
-
readonly type: string;
|
|
37
|
-
/**
|
|
38
|
-
* Create the DataDriver for CRUD operations.
|
|
39
|
-
*
|
|
40
|
-
* This is the only **required** method.
|
|
41
|
-
*
|
|
42
|
-
* @param config - Coordinator-provided config containing registered
|
|
43
|
-
* collections and the collection registry.
|
|
44
|
-
*/
|
|
45
|
-
initializeDriver(config: DatabaseAdapterInitConfig): Promise<InitializedDriver>;
|
|
46
|
-
/**
|
|
47
|
-
* Create a realtime provider for this database.
|
|
48
|
-
*
|
|
49
|
-
* Return `undefined` if the database does not support realtime
|
|
50
|
-
* change notifications.
|
|
51
|
-
*/
|
|
52
|
-
initializeRealtime?(driverResult: InitializedDriver): Promise<RealtimeProvider | undefined>;
|
|
53
|
-
/**
|
|
54
|
-
* Initialize auth tables / services if this driver supports them.
|
|
55
|
-
*/
|
|
56
|
-
initializeAuth?(config: unknown, driverResult: InitializedDriver): Promise<BootstrappedAuth | undefined>;
|
|
57
|
-
/**
|
|
58
|
-
* Initialize entity history tracking.
|
|
59
|
-
*
|
|
60
|
-
* Return `undefined` if the database does not support history.
|
|
61
|
-
*/
|
|
62
|
-
initializeHistory?(config: unknown, driverResult: InitializedDriver): Promise<{
|
|
63
|
-
historyService: unknown;
|
|
64
|
-
} | undefined>;
|
|
65
|
-
/**
|
|
66
|
-
* Initialize WebSocket server for realtime operations.
|
|
67
|
-
*/
|
|
68
|
-
initializeWebsockets?(server: unknown, realtimeService: RealtimeProvider, driver: DataDriver, config?: unknown): Promise<void> | void;
|
|
69
|
-
/**
|
|
70
|
-
* Return admin capabilities for this database (SQL editor, schema browser, branching).
|
|
71
|
-
*/
|
|
72
|
-
getAdmin?(driverResult: InitializedDriver): DatabaseAdmin | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* Mount any database-specific HTTP routes (e.g., custom admin endpoints).
|
|
75
|
-
*
|
|
76
|
-
* Called after all adapters are initialized.
|
|
77
|
-
*/
|
|
78
|
-
mountRoutes?(app: unknown, basePath: string, driverResult: InitializedDriver): void;
|
|
79
|
-
/**
|
|
80
|
-
* Graceful shutdown: close connections, release resources.
|
|
81
|
-
*/
|
|
82
|
-
destroy?(): Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Configuration passed by the coordinator to `DatabaseAdapter.initializeDriver()`.
|
|
86
|
-
*
|
|
87
|
-
* @group Backend
|
|
88
|
-
*/
|
|
89
|
-
export interface DatabaseAdapterInitConfig {
|
|
90
|
-
/** Registered collection definitions. */
|
|
91
|
-
collections: EntityCollection[];
|
|
92
|
-
/** The shared collection registry to register into. */
|
|
93
|
-
collectionRegistry: CollectionRegistryInterface;
|
|
94
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* New or existing status
|
|
3
|
-
* @group Models
|
|
4
|
-
*/
|
|
5
|
-
export type EntityStatus = "new" | "existing" | "copy";
|
|
6
|
-
/**
|
|
7
|
-
* Representation of an entity fetched from the driver
|
|
8
|
-
* @group Models
|
|
9
|
-
*/
|
|
10
|
-
export interface Entity<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
11
|
-
/**
|
|
12
|
-
* ID of the entity
|
|
13
|
-
*/
|
|
14
|
-
id: string | number;
|
|
15
|
-
/**
|
|
16
|
-
* A string representing the path of the referenced document (relative
|
|
17
|
-
* to the root of the database).
|
|
18
|
-
*/
|
|
19
|
-
path: string;
|
|
20
|
-
/**
|
|
21
|
-
* Current values
|
|
22
|
-
*/
|
|
23
|
-
values: EntityValues<M>;
|
|
24
|
-
/**
|
|
25
|
-
* Which driver this entity belongs to (e.g., 'postgres', 'firestore').
|
|
26
|
-
* If not specified, the default driver is assumed.
|
|
27
|
-
*/
|
|
28
|
-
driver?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Which database within the driver (e.g., for Firestore multi-database).
|
|
31
|
-
* If not specified, the default database of the driver is used.
|
|
32
|
-
*/
|
|
33
|
-
databaseId?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* This type represents a record of key value pairs as described in an
|
|
37
|
-
* entity collection.
|
|
38
|
-
* @group Models
|
|
39
|
-
*/
|
|
40
|
-
export type EntityValues<M extends Record<string, unknown>> = M;
|
|
41
|
-
/**
|
|
42
|
-
* Props for creating an EntityReference
|
|
43
|
-
*/
|
|
44
|
-
export interface EntityReferenceProps {
|
|
45
|
-
/** ID of the entity */
|
|
46
|
-
id: string;
|
|
47
|
-
/** Path of the collection (relative to the root of the database) */
|
|
48
|
-
path: string;
|
|
49
|
-
/** Which driver (e.g., 'postgres', 'firestore'). Defaults to "(default)" */
|
|
50
|
-
driver?: string;
|
|
51
|
-
/** Which database within the driver. Defaults to "(default)" */
|
|
52
|
-
databaseId?: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Class used to create a reference to an entity in a different path.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* // Simple reference (most common case - single driver, single db)
|
|
59
|
-
* new EntityReference({ id: "123", path: "users" })
|
|
60
|
-
*
|
|
61
|
-
* // Reference to a different driver (e.g., Firestore)
|
|
62
|
-
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
63
|
-
*
|
|
64
|
-
* // Reference to a specific database within a driver
|
|
65
|
-
* new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
|
|
66
|
-
*/
|
|
67
|
-
export declare class EntityReference {
|
|
68
|
-
readonly __type = "reference";
|
|
69
|
-
/**
|
|
70
|
-
* ID of the entity
|
|
71
|
-
*/
|
|
72
|
-
readonly id: string;
|
|
73
|
-
/**
|
|
74
|
-
* A string representing the path of the referenced document (relative
|
|
75
|
-
* to the root of the database).
|
|
76
|
-
*/
|
|
77
|
-
readonly path: string;
|
|
78
|
-
/**
|
|
79
|
-
* Which driver (e.g., 'postgres', 'firestore').
|
|
80
|
-
* Defaults to "(default)" if not specified.
|
|
81
|
-
*/
|
|
82
|
-
readonly driver?: string;
|
|
83
|
-
/**
|
|
84
|
-
* Which database within the driver.
|
|
85
|
-
* Defaults to "(default)" if not specified.
|
|
86
|
-
*/
|
|
87
|
-
readonly databaseId?: string;
|
|
88
|
-
/**
|
|
89
|
-
* Create a reference to an entity.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* // Simple reference (most common case)
|
|
93
|
-
* new EntityReference({ id: "123", path: "users" })
|
|
94
|
-
*
|
|
95
|
-
* // With driver
|
|
96
|
-
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
97
|
-
*/
|
|
98
|
-
constructor(props: EntityReferenceProps);
|
|
99
|
-
get pathWithId(): string;
|
|
100
|
-
/**
|
|
101
|
-
* Get the full path including driver and database prefixes if specified.
|
|
102
|
-
* For the common case (single driver, single db), this just returns pathWithId.
|
|
103
|
-
*/
|
|
104
|
-
get fullPath(): string;
|
|
105
|
-
isEntityReference(): boolean;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Class used to create a reference to an entity in a different path
|
|
109
|
-
*/
|
|
110
|
-
export declare class EntityRelation {
|
|
111
|
-
readonly __type = "relation";
|
|
112
|
-
/**
|
|
113
|
-
* ID of the entity
|
|
114
|
-
*/
|
|
115
|
-
readonly id: string | number;
|
|
116
|
-
/**
|
|
117
|
-
* A string representing the path of the referenced document (relative
|
|
118
|
-
* to the root of the database).
|
|
119
|
-
*/
|
|
120
|
-
readonly path: string;
|
|
121
|
-
/**
|
|
122
|
-
* Pre-fetched data payload to eliminate N+1 queries.
|
|
123
|
-
* When present, clients can use this directly instead of fetching.
|
|
124
|
-
*/
|
|
125
|
-
readonly data?: Entity;
|
|
126
|
-
constructor(id: string | number, path: string, data?: Entity);
|
|
127
|
-
get pathWithId(): string;
|
|
128
|
-
isEntityReference(): boolean;
|
|
129
|
-
isEntityRelation(): boolean;
|
|
130
|
-
}
|
|
131
|
-
export declare class GeoPoint {
|
|
132
|
-
/**
|
|
133
|
-
* The latitude of this GeoPoint instance.
|
|
134
|
-
*/
|
|
135
|
-
readonly latitude: number;
|
|
136
|
-
/**
|
|
137
|
-
* The longitude of this GeoPoint instance.
|
|
138
|
-
*/
|
|
139
|
-
readonly longitude: number;
|
|
140
|
-
constructor(latitude: number, longitude: number);
|
|
141
|
-
}
|
|
142
|
-
export declare class Vector {
|
|
143
|
-
readonly value: number[];
|
|
144
|
-
constructor(value: number[]);
|
|
145
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { Entity } from "./entities";
|
|
3
|
-
import type { EntityCollection, SelectionController } from "./collections";
|
|
4
|
-
import type { FormContext } from "./entity_views";
|
|
5
|
-
import type { User } from "../users";
|
|
6
|
-
import type { RebaseContext } from "../rebase_context";
|
|
7
|
-
import type { SideEntityController } from "../controllers/side_entity_controller";
|
|
8
|
-
/**
|
|
9
|
-
* An entity action is a custom action that can be performed on an entity.
|
|
10
|
-
* They are displayed in the entity view and in the collection view.
|
|
11
|
-
*/
|
|
12
|
-
export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
13
|
-
/**
|
|
14
|
-
* Title of the action
|
|
15
|
-
*/
|
|
16
|
-
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* Key of the action. You only need to provide this if you want to
|
|
19
|
-
* override the default actions, or if you are not passing the action
|
|
20
|
-
* directly to the `entityActions` prop of a collection.
|
|
21
|
-
* You can define your actions at the app level, in which case you
|
|
22
|
-
* must provide a key.
|
|
23
|
-
* The default actions are:
|
|
24
|
-
* - edit
|
|
25
|
-
* - delete
|
|
26
|
-
* - copy
|
|
27
|
-
*/
|
|
28
|
-
key?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Icon of the action
|
|
31
|
-
*/
|
|
32
|
-
icon?: React.ReactElement;
|
|
33
|
-
/**
|
|
34
|
-
* Callback when the action is clicked
|
|
35
|
-
* @param props
|
|
36
|
-
*/
|
|
37
|
-
onClick(props: EntityActionClickProps<M, USER>): Promise<void> | void;
|
|
38
|
-
/**
|
|
39
|
-
* Optional callback in case you want to disable the action
|
|
40
|
-
* @param props
|
|
41
|
-
*/
|
|
42
|
-
isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* When true, this action is rendered inline on each row in the list view.
|
|
45
|
-
* By default, entity actions only appear in the table view and entity form.
|
|
46
|
-
* Use this for actions that should be easily accessible regardless of view mode.
|
|
47
|
-
*/
|
|
48
|
-
showActionsInListView?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Show this action collapsed in the menu of the collection view.
|
|
51
|
-
* Defaults to true
|
|
52
|
-
* If false, the action will be shown in the menu
|
|
53
|
-
*/
|
|
54
|
-
collapsed?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Show this action in the form, defaults to true
|
|
57
|
-
*/
|
|
58
|
-
includeInForm?: boolean;
|
|
59
|
-
}
|
|
60
|
-
export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
|
|
61
|
-
entity?: Entity<M>;
|
|
62
|
-
context: RebaseContext<USER>;
|
|
63
|
-
path?: string;
|
|
64
|
-
collection?: EntityCollection<M>;
|
|
65
|
-
/**
|
|
66
|
-
* Optional form context, present if the action is being called from a form.
|
|
67
|
-
* This allows you to access the form state and methods, including modifying the form values.
|
|
68
|
-
*/
|
|
69
|
-
formContext?: FormContext;
|
|
70
|
-
/**
|
|
71
|
-
* Present if this actions is being called from a side dialog only
|
|
72
|
-
*/
|
|
73
|
-
sideEntityController?: SideEntityController;
|
|
74
|
-
/**
|
|
75
|
-
* Is the action being called from the collection view or from the entity form view?
|
|
76
|
-
*/
|
|
77
|
-
view: "collection" | "form";
|
|
78
|
-
/**
|
|
79
|
-
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
80
|
-
*/
|
|
81
|
-
openEntityMode: "side_panel" | "full_screen" | "split" | "dialog";
|
|
82
|
-
/**
|
|
83
|
-
* Optional selection controller, present if the action is being called from a collection view
|
|
84
|
-
*/
|
|
85
|
-
selectionController?: SelectionController;
|
|
86
|
-
/**
|
|
87
|
-
* Optional highlight function to highlight the entity in the collection view
|
|
88
|
-
* @param entity
|
|
89
|
-
*/
|
|
90
|
-
highlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
91
|
-
/**
|
|
92
|
-
* Optional unhighlight function to remove the highlight from the entity in the collection view
|
|
93
|
-
* @param entity
|
|
94
|
-
*/
|
|
95
|
-
unhighlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
96
|
-
/**
|
|
97
|
-
* Optional function to navigate back (e.g. when deleting an entity or navigating from a form)
|
|
98
|
-
*/
|
|
99
|
-
navigateBack?: () => void;
|
|
100
|
-
/**
|
|
101
|
-
* Callback to be called when the collection changes, e.g. after an entity is deleted or created.
|
|
102
|
-
*/
|
|
103
|
-
onCollectionChange?: () => void;
|
|
104
|
-
};
|