@rebasepro/server-postgresql 0.0.1-canary.4d4fb3e → 0.0.1-canary.ca2cb6e
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/common/src/collections/CollectionRegistry.d.ts +8 -0
- package/dist/common/src/util/entities.d.ts +22 -0
- package/dist/common/src/util/relations.d.ts +14 -4
- package/dist/common/src/util/resolutions.d.ts +1 -1
- package/dist/index.es.js +1254 -591
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1254 -591
- package/dist/index.umd.js.map +1 -1
- package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +17 -29
- package/dist/server-postgresql/src/auth/services.d.ts +7 -3
- package/dist/server-postgresql/src/collections/PostgresCollectionRegistry.d.ts +1 -1
- package/dist/server-postgresql/src/connection.d.ts +34 -1
- package/dist/server-postgresql/src/data-transformer.d.ts +26 -4
- package/dist/server-postgresql/src/databasePoolManager.d.ts +2 -2
- package/dist/server-postgresql/src/schema/auth-schema.d.ts +139 -38
- package/dist/server-postgresql/src/schema/doctor-cli.d.ts +2 -0
- package/dist/server-postgresql/src/schema/doctor.d.ts +43 -0
- package/dist/server-postgresql/src/schema/generate-drizzle-schema-logic.d.ts +1 -1
- package/dist/server-postgresql/src/schema/test-schema.d.ts +24 -0
- package/dist/server-postgresql/src/services/EntityFetchService.d.ts +22 -8
- package/dist/server-postgresql/src/services/EntityPersistService.d.ts +1 -1
- package/dist/server-postgresql/src/services/RelationService.d.ts +11 -5
- package/dist/server-postgresql/src/services/entity-helpers.d.ts +16 -2
- package/dist/server-postgresql/src/services/entityService.d.ts +8 -6
- package/dist/server-postgresql/src/services/realtimeService.d.ts +2 -0
- package/dist/server-postgresql/src/utils/drizzle-conditions.d.ts +2 -2
- package/dist/types/src/controllers/auth.d.ts +2 -0
- package/dist/types/src/controllers/client.d.ts +119 -7
- package/dist/types/src/controllers/collection_registry.d.ts +4 -3
- package/dist/types/src/controllers/customization_controller.d.ts +7 -1
- package/dist/types/src/controllers/data.d.ts +34 -7
- package/dist/types/src/controllers/data_driver.d.ts +20 -28
- package/dist/types/src/controllers/database_admin.d.ts +2 -2
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +1 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +4 -4
- package/dist/types/src/controllers/navigation.d.ts +5 -5
- package/dist/types/src/controllers/registry.d.ts +6 -3
- package/dist/types/src/controllers/side_entity_controller.d.ts +7 -6
- package/dist/types/src/controllers/storage.d.ts +24 -26
- package/dist/types/src/rebase_context.d.ts +8 -4
- package/dist/types/src/types/backend.d.ts +4 -1
- package/dist/types/src/types/builders.d.ts +5 -4
- package/dist/types/src/types/chips.d.ts +1 -1
- package/dist/types/src/types/collections.d.ts +169 -125
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +1 -1
- package/dist/types/src/types/entity_actions.d.ts +8 -8
- package/dist/types/src/types/entity_callbacks.d.ts +15 -15
- package/dist/types/src/types/entity_link_builder.d.ts +1 -1
- package/dist/types/src/types/entity_overrides.d.ts +2 -1
- package/dist/types/src/types/entity_views.d.ts +8 -8
- package/dist/types/src/types/export_import.d.ts +3 -3
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/plugins.d.ts +72 -18
- package/dist/types/src/types/properties.d.ts +118 -33
- package/dist/types/src/types/relations.d.ts +1 -1
- package/dist/types/src/types/slots.d.ts +30 -6
- package/dist/types/src/types/translations.d.ts +44 -0
- package/dist/types/src/types/user_management_delegate.d.ts +1 -0
- package/drizzle-test/0000_woozy_junta.sql +6 -0
- package/drizzle-test/0001_youthful_arachne.sql +1 -0
- package/drizzle-test/0002_lively_dragon_lord.sql +2 -0
- package/drizzle-test/0003_mean_king_cobra.sql +2 -0
- package/drizzle-test/meta/0000_snapshot.json +47 -0
- package/drizzle-test/meta/0001_snapshot.json +48 -0
- package/drizzle-test/meta/0002_snapshot.json +38 -0
- package/drizzle-test/meta/0003_snapshot.json +48 -0
- package/drizzle-test/meta/_journal.json +34 -0
- package/drizzle-test-out/0000_tan_trauma.sql +6 -0
- package/drizzle-test-out/0001_rapid_drax.sql +1 -0
- package/drizzle-test-out/meta/0000_snapshot.json +44 -0
- package/drizzle-test-out/meta/0001_snapshot.json +54 -0
- package/drizzle-test-out/meta/_journal.json +20 -0
- package/drizzle.test.config.ts +10 -0
- package/package.json +88 -89
- package/scratch.ts +41 -0
- package/src/PostgresBackendDriver.ts +63 -79
- package/src/PostgresBootstrapper.ts +7 -8
- package/src/auth/ensure-tables.ts +158 -86
- package/src/auth/services.ts +109 -50
- package/src/cli.ts +259 -16
- package/src/collections/PostgresCollectionRegistry.ts +6 -6
- package/src/connection.ts +70 -48
- package/src/data-transformer.ts +155 -116
- package/src/databasePoolManager.ts +6 -5
- package/src/history/HistoryService.ts +3 -12
- package/src/interfaces.ts +3 -3
- package/src/schema/auth-schema.ts +26 -3
- package/src/schema/doctor-cli.ts +47 -0
- package/src/schema/doctor.ts +595 -0
- package/src/schema/generate-drizzle-schema-logic.ts +204 -57
- package/src/schema/generate-drizzle-schema.ts +6 -6
- package/src/schema/test-schema.ts +11 -0
- package/src/services/BranchService.ts +5 -5
- package/src/services/EntityFetchService.ts +317 -188
- package/src/services/EntityPersistService.ts +15 -17
- package/src/services/RelationService.ts +299 -37
- package/src/services/entity-helpers.ts +39 -13
- package/src/services/entityService.ts +11 -9
- package/src/services/realtimeService.ts +58 -29
- package/src/utils/drizzle-conditions.ts +25 -24
- package/src/websocket.ts +52 -21
- package/test/auth-services.test.ts +131 -39
- package/test/batch-many-to-many-regression.test.ts +573 -0
- package/test/branchService.test.ts +22 -12
- package/test/data-transformer-hardening.test.ts +417 -0
- package/test/data-transformer.test.ts +175 -0
- package/test/doctor.test.ts +182 -0
- package/test/entityService.errors.test.ts +31 -16
- package/test/entityService.relations.test.ts +155 -59
- package/test/entityService.subcollection-search.test.ts +107 -57
- package/test/entityService.test.ts +105 -47
- package/test/generate-drizzle-schema.test.ts +262 -69
- package/test/historyService.test.ts +31 -16
- package/test/n-plus-one-regression.test.ts +314 -0
- package/test/postgresDataDriver.test.ts +260 -168
- package/test/realtimeService.test.ts +70 -39
- package/test/relation-pipeline-gaps.test.ts +637 -0
- package/test/relations.test.ts +492 -39
- package/test-drizzle-bug.ts +18 -0
- package/test-drizzle-out/0000_cultured_freak.sql +7 -0
- package/test-drizzle-out/0001_tiresome_professor_monster.sql +1 -0
- package/test-drizzle-out/meta/0000_snapshot.json +55 -0
- package/test-drizzle-out/meta/0001_snapshot.json +63 -0
- package/test-drizzle-out/meta/_journal.json +20 -0
- package/test-drizzle-prompt.sh +2 -0
- package/test-policy-prompt.sh +3 -0
- package/test-programmatic.ts +30 -0
- package/test-programmatic2.ts +59 -0
- package/test-schema-no-policies.ts +12 -0
- package/test_drizzle_mock.js +2 -2
- package/test_find_changed.mjs +3 -1
- package/test_hash.js +14 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +5 -5
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron Job type definitions for Rebase.
|
|
3
|
+
*
|
|
4
|
+
* These types define the shape of cron job definitions, their runtime
|
|
5
|
+
* status, and execution log entries — used across server-core, client,
|
|
6
|
+
* and studio packages.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A cron job definition file exports this shape as its default export.
|
|
10
|
+
* See the example cron files in `app/backend/crons/` for usage.
|
|
11
|
+
*/
|
|
12
|
+
export interface CronJobDefinition {
|
|
13
|
+
schedule: string;
|
|
14
|
+
/** Human-readable name shown in the Studio UI. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Optional description shown in the Studio UI. */
|
|
17
|
+
description?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the job is enabled at startup. Defaults to `true`.
|
|
20
|
+
* Can be toggled at runtime via the Admin API.
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of seconds the handler may run before being
|
|
25
|
+
* considered timed-out. Default: 300 (5 min).
|
|
26
|
+
*/
|
|
27
|
+
timeoutSeconds?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The handler function executed on each tick.
|
|
30
|
+
* Receives a context object with the data driver and logger.
|
|
31
|
+
* May return arbitrary JSON-serialisable data stored in the log.
|
|
32
|
+
*/
|
|
33
|
+
handler: (ctx: CronJobContext) => Promise<unknown> | unknown;
|
|
34
|
+
}
|
|
35
|
+
import type { RebaseClient } from "../controllers/client";
|
|
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<any>;
|
|
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
|
+
}
|
|
@@ -38,7 +38,7 @@ export interface DataSourceCapabilities {
|
|
|
38
38
|
* Useful when you only need to check capabilities without UI metadata.
|
|
39
39
|
* @group Models
|
|
40
40
|
*/
|
|
41
|
-
export type DataSourceFeatures =
|
|
41
|
+
export type DataSourceFeatures = Omit<DataSourceCapabilities, "key" | "label">;
|
|
42
42
|
/** @group Models */
|
|
43
43
|
export declare const POSTGRES_CAPABILITIES: DataSourceCapabilities;
|
|
44
44
|
/** @group Models */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Entity } from "./entities";
|
|
3
|
-
import { EntityCollection, SelectionController } from "./collections";
|
|
4
|
-
import { FormContext } from "./entity_views";
|
|
5
|
-
import { User } from "../users";
|
|
6
|
-
import { RebaseContext } from "../rebase_context";
|
|
7
|
-
import { SideEntityController } from "../controllers";
|
|
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
8
|
/**
|
|
9
9
|
* An entity action is a custom action that can be performed on an entity.
|
|
10
10
|
* They are displayed in the entity view and in the collection view.
|
|
@@ -55,7 +55,7 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
55
55
|
entity?: Entity<M>;
|
|
56
56
|
context: RebaseContext<USER>;
|
|
57
57
|
path?: string;
|
|
58
|
-
collection?: EntityCollection<
|
|
58
|
+
collection?: EntityCollection<M>;
|
|
59
59
|
/**
|
|
60
60
|
* Optional form context, present if the action is being called from a form.
|
|
61
61
|
* This allows you to access the form state and methods, including modifying the form values.
|
|
@@ -72,7 +72,7 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
72
72
|
/**
|
|
73
73
|
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
74
74
|
*/
|
|
75
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
75
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
76
76
|
/**
|
|
77
77
|
* Optional selection controller, present if the action is being called from a collection view
|
|
78
78
|
*/
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { EntityCollection } from "./collections";
|
|
2
|
-
import { Entity, EntityStatus, EntityValues } from "./entities";
|
|
3
|
-
import { User } from "../users";
|
|
4
|
-
import { RebaseCallContext } from "../rebase_context";
|
|
1
|
+
import type { EntityCollection } from "./collections";
|
|
2
|
+
import type { Entity, EntityStatus, EntityValues } from "./entities";
|
|
3
|
+
import type { User } from "../users";
|
|
4
|
+
import type { RebaseCallContext } from "../rebase_context";
|
|
5
5
|
/**
|
|
6
6
|
* This interface defines all the callbacks that can be used when an entity
|
|
7
7
|
* is being created, updated or deleted.
|
|
8
8
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
9
9
|
* @group Models
|
|
10
10
|
*/
|
|
11
|
-
export type EntityCallbacks<M extends Record<string,
|
|
11
|
+
export type EntityCallbacks<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
12
12
|
/**
|
|
13
13
|
* Callback used after fetching data
|
|
14
14
|
* @param props
|
|
@@ -51,11 +51,11 @@ export type EntityCallbacks<M extends Record<string, any> = any, USER extends Us
|
|
|
51
51
|
* Parameters passed to hooks when an entity is fetched
|
|
52
52
|
* @group Models
|
|
53
53
|
*/
|
|
54
|
-
export interface EntityAfterReadProps<M extends Record<string,
|
|
54
|
+
export interface EntityAfterReadProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
55
55
|
/**
|
|
56
56
|
* Collection of the entity
|
|
57
57
|
*/
|
|
58
|
-
collection: EntityCollection<
|
|
58
|
+
collection: EntityCollection<M>;
|
|
59
59
|
/**
|
|
60
60
|
* Full path of the CMS where this collection is being fetched.
|
|
61
61
|
* Might contain unresolved aliases.
|
|
@@ -74,25 +74,25 @@ export interface EntityAfterReadProps<M extends Record<string, any> = any, USER
|
|
|
74
74
|
* Parameters passed to hooks before an entity is saved
|
|
75
75
|
* @group Models
|
|
76
76
|
*/
|
|
77
|
-
export type EntityBeforeSaveProps<M extends Record<string,
|
|
77
|
+
export type EntityBeforeSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
|
|
78
78
|
entityId?: string | number;
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
81
|
* Parameters passed to hooks before an entity is saved
|
|
82
82
|
* @group Models
|
|
83
83
|
*/
|
|
84
|
-
export type EntityAfterSaveErrorProps<M extends Record<string,
|
|
84
|
+
export type EntityAfterSaveErrorProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
|
|
85
85
|
entityId?: string | number;
|
|
86
86
|
};
|
|
87
87
|
/**
|
|
88
88
|
* Parameters passed to hooks when an entity is saved
|
|
89
89
|
* @group Models
|
|
90
90
|
*/
|
|
91
|
-
export interface EntityAfterSaveProps<M extends Record<string,
|
|
91
|
+
export interface EntityAfterSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
92
92
|
/**
|
|
93
93
|
* Resolved collection of the entity
|
|
94
94
|
*/
|
|
95
|
-
collection: EntityCollection<
|
|
95
|
+
collection: EntityCollection<M>;
|
|
96
96
|
/**
|
|
97
97
|
* Full path of the CMS where this entity is being saved.
|
|
98
98
|
* Might contain unresolved aliases.
|
|
@@ -123,11 +123,11 @@ export interface EntityAfterSaveProps<M extends Record<string, any> = any, USER
|
|
|
123
123
|
* Parameters passed to hooks when an entity is deleted
|
|
124
124
|
* @group Models
|
|
125
125
|
*/
|
|
126
|
-
export interface EntityBeforeDeleteProps<M extends Record<string,
|
|
126
|
+
export interface EntityBeforeDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
127
127
|
/**
|
|
128
128
|
* collection of the entity being deleted
|
|
129
129
|
*/
|
|
130
|
-
collection: EntityCollection<
|
|
130
|
+
collection: EntityCollection<M>;
|
|
131
131
|
/**
|
|
132
132
|
* Path of the parent collection
|
|
133
133
|
*/
|
|
@@ -149,11 +149,11 @@ export interface EntityBeforeDeleteProps<M extends Record<string, any> = any, US
|
|
|
149
149
|
* Parameters passed to hooks after an entity is deleted
|
|
150
150
|
* @group Models
|
|
151
151
|
*/
|
|
152
|
-
export interface EntityAfterDeleteProps<M extends Record<string,
|
|
152
|
+
export interface EntityAfterDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
153
153
|
/**
|
|
154
154
|
* collection of the entity being deleted
|
|
155
155
|
*/
|
|
156
|
-
collection: EntityCollection<
|
|
156
|
+
collection: EntityCollection<M>;
|
|
157
157
|
/**
|
|
158
158
|
* Path of the parent collection
|
|
159
159
|
*/
|
|
@@ -2,6 +2,6 @@ import { Entity } from "./entities";
|
|
|
2
2
|
/**
|
|
3
3
|
* @group Models
|
|
4
4
|
*/
|
|
5
|
-
export type EntityLinkBuilder<M extends Record<string,
|
|
5
|
+
export type EntityLinkBuilder<M extends Record<string, unknown> = Record<string, unknown>> = ({ entity }: {
|
|
6
6
|
entity: Entity<M>;
|
|
7
7
|
}) => string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DataDriver
|
|
1
|
+
import type { DataDriver } from "../controllers/data_driver";
|
|
2
|
+
import type { StorageSource } from "../controllers/storage";
|
|
2
3
|
export type EntityOverrides = {
|
|
3
4
|
/**
|
|
4
5
|
* Internal driver override for this collection.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Entity, EntityValues } from "./entities";
|
|
3
|
-
import { EntityCollection } from "./collections";
|
|
2
|
+
import type { Entity, EntityValues } from "./entities";
|
|
3
|
+
import type { EntityCollection } from "./collections";
|
|
4
4
|
/**
|
|
5
5
|
* Context passed to custom fields and entity views.
|
|
6
|
-
* This is the base definition — `@rebasepro/
|
|
6
|
+
* This is the base definition — `@rebasepro/admin` re-exports a
|
|
7
7
|
* fully-typed version that narrows the `formex` field.
|
|
8
8
|
* @group Form custom fields
|
|
9
9
|
*/
|
|
10
|
-
export interface FormContext<M extends Record<string,
|
|
10
|
+
export interface FormContext<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
11
11
|
/**
|
|
12
12
|
* Current values of the entity
|
|
13
13
|
*/
|
|
@@ -35,16 +35,16 @@ export interface FormContext<M extends Record<string, any> = any> {
|
|
|
35
35
|
status: "new" | "existing" | "copy";
|
|
36
36
|
entity?: Entity<M>;
|
|
37
37
|
savingError?: Error;
|
|
38
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
38
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
39
39
|
/**
|
|
40
40
|
* The underlying formex controller that powers the form.
|
|
41
|
-
* Prefer importing `FormContext` from `@rebasepro/
|
|
41
|
+
* Prefer importing `FormContext` from `@rebasepro/admin` for the
|
|
42
42
|
* fully-typed `FormexController<M>` version.
|
|
43
43
|
*/
|
|
44
44
|
formex: Record<string, unknown>;
|
|
45
45
|
disabled: boolean;
|
|
46
46
|
}
|
|
47
|
-
export type EntityCustomView<M extends Record<string,
|
|
47
|
+
export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
48
48
|
key: string;
|
|
49
49
|
name: string;
|
|
50
50
|
tabComponent?: React.ReactNode;
|
|
@@ -52,7 +52,7 @@ export type EntityCustomView<M extends Record<string, any> = any> = {
|
|
|
52
52
|
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
53
53
|
position?: "start" | "end";
|
|
54
54
|
};
|
|
55
|
-
export interface EntityCustomViewParams<M extends Record<string,
|
|
55
|
+
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
56
56
|
collection: EntityCollection<M>;
|
|
57
57
|
entity?: Entity<M>;
|
|
58
58
|
modifiedValues?: EntityValues<M>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Entity } from "./entities";
|
|
2
|
-
import { User } from "../users";
|
|
3
|
-
import { RebaseContext } from "../rebase_context";
|
|
1
|
+
import type { Entity } from "./entities";
|
|
2
|
+
import type { User } from "../users";
|
|
3
|
+
import type { RebaseContext } from "../rebase_context";
|
|
4
4
|
/**
|
|
5
5
|
* You can use this configuration to add additional fields to the data
|
|
6
6
|
* exports
|
|
@@ -1,14 +1,68 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { EntityCollection } from "./collections";
|
|
3
|
-
import { EntityStatus } from "./entities";
|
|
4
|
-
import { Property } from "./properties";
|
|
5
|
-
import { FormContext } from "./entity_views";
|
|
6
|
-
import { RebaseContext } from "../rebase_context";
|
|
7
|
-
import { NavigationGroupMapping, AppView } from "../controllers";
|
|
8
|
-
import { UserManagementDelegate } from "./user_management_delegate";
|
|
9
|
-
import { User } from "../users";
|
|
10
|
-
import { SlotContribution } from "./slots";
|
|
11
|
-
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import type { EntityCollection } from "./collections";
|
|
3
|
+
import type { EntityStatus } from "./entities";
|
|
4
|
+
import type { InferPropertyType, Property } from "./properties";
|
|
5
|
+
import type { FormContext } from "./entity_views";
|
|
6
|
+
import type { RebaseContext } from "../rebase_context";
|
|
7
|
+
import type { NavigationGroupMapping, AppView } from "../controllers/navigation";
|
|
8
|
+
import type { UserManagementDelegate } from "./user_management_delegate";
|
|
9
|
+
import type { User } from "../users";
|
|
10
|
+
import type { SlotContribution } from "./slots";
|
|
11
|
+
/**
|
|
12
|
+
* Props interface for custom field components.
|
|
13
|
+
*
|
|
14
|
+
* The `@rebasepro/admin` package re-exports a narrower version of this
|
|
15
|
+
* interface that adds `formex` and layout-specific fields. This base
|
|
16
|
+
* definition captures the core contract that every field renderer must
|
|
17
|
+
* satisfy, regardless of where it is rendered.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam P - The property type this field is bound to
|
|
20
|
+
* @typeParam CustomProps - Extra props injected via the property's `customProps`
|
|
21
|
+
* @typeParam M - The entity model type
|
|
22
|
+
* @group Form custom fields
|
|
23
|
+
*/
|
|
24
|
+
export interface FieldProps<P extends Property = Property, CustomProps = unknown, M extends Record<string, unknown> = Record<string, unknown>> {
|
|
25
|
+
/** Key of the property (e.g. "user.name" for a nested path) */
|
|
26
|
+
propertyKey: string;
|
|
27
|
+
/** Current value of this field */
|
|
28
|
+
value: InferPropertyType<P> | null;
|
|
29
|
+
/** Set value of field directly */
|
|
30
|
+
setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
|
|
31
|
+
/** Set value of a different field directly */
|
|
32
|
+
setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
|
|
33
|
+
/** Is the form currently submitting */
|
|
34
|
+
isSubmitting?: boolean;
|
|
35
|
+
/** Should this field show the error indicator */
|
|
36
|
+
showError?: boolean;
|
|
37
|
+
/** Error message for this field, or undefined if valid */
|
|
38
|
+
error?: string;
|
|
39
|
+
/** Has this field been touched */
|
|
40
|
+
touched?: boolean;
|
|
41
|
+
/** Property related to this field */
|
|
42
|
+
property: P;
|
|
43
|
+
/** Should this field include a description */
|
|
44
|
+
includeDescription?: boolean;
|
|
45
|
+
/** Flag to indicate that the underlying value has been updated in the driver */
|
|
46
|
+
underlyingValueHasChanged?: boolean;
|
|
47
|
+
/** Is this field part of an array */
|
|
48
|
+
partOfArray?: boolean;
|
|
49
|
+
/** Is this field part of a block */
|
|
50
|
+
partOfBlock?: boolean;
|
|
51
|
+
/** Display the child properties directly, without being wrapped in an extendable panel */
|
|
52
|
+
minimalistView?: boolean;
|
|
53
|
+
/** Should this field autofocus on mount */
|
|
54
|
+
autoFocus?: boolean;
|
|
55
|
+
/** Additional properties set by the developer */
|
|
56
|
+
customProps?: CustomProps;
|
|
57
|
+
/** Additional values related to the state of the form or the entity */
|
|
58
|
+
context: FormContext<M>;
|
|
59
|
+
/** Flag to indicate if this field should be disabled */
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
/** Size of the field */
|
|
62
|
+
size?: "small" | "medium" | "large";
|
|
63
|
+
/** Callback when internal property state changes (e.g. panel expansion) */
|
|
64
|
+
onPropertyChange?: (property: Partial<Property>) => void;
|
|
65
|
+
}
|
|
12
66
|
/**
|
|
13
67
|
* Interface used to define plugins for Rebase.
|
|
14
68
|
* Plugins contribute UI via **slots**, wrap subtrees with **providers**,
|
|
@@ -72,11 +126,11 @@ export interface PluginProvider {
|
|
|
72
126
|
* Typed loosely because extra props are passed via the `props` field;
|
|
73
127
|
* strict signatures cause contravariance issues.
|
|
74
128
|
*/
|
|
75
|
-
Component: React.ComponentType<
|
|
129
|
+
Component: React.ComponentType<PropsWithChildren<Record<string, unknown>>>;
|
|
76
130
|
/**
|
|
77
131
|
* Additional props passed to the Component.
|
|
78
132
|
*/
|
|
79
|
-
props?: Record<string,
|
|
133
|
+
props?: Record<string, unknown>;
|
|
80
134
|
}
|
|
81
135
|
/**
|
|
82
136
|
* Behavioral hooks that a plugin can provide.
|
|
@@ -155,7 +209,7 @@ export interface PluginLifecycle {
|
|
|
155
209
|
* Called when a collection's visible entities change.
|
|
156
210
|
* Useful for analytics, caching, or cross-plugin coordination.
|
|
157
211
|
*/
|
|
158
|
-
onCollectionChange?: (slug: string, entities:
|
|
212
|
+
onCollectionChange?: (slug: string, entities: unknown[]) => void;
|
|
159
213
|
}
|
|
160
214
|
/**
|
|
161
215
|
* Configuration for wrapping form field components.
|
|
@@ -165,7 +219,7 @@ export interface FieldBuilderConfig {
|
|
|
165
219
|
/**
|
|
166
220
|
* Returns a wrapped field component, or null to skip wrapping.
|
|
167
221
|
*/
|
|
168
|
-
wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<
|
|
222
|
+
wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<Property>> | null;
|
|
169
223
|
/**
|
|
170
224
|
* Optional guard — return false to skip wrapping for this field.
|
|
171
225
|
*/
|
|
@@ -175,7 +229,7 @@ export interface FieldBuilderConfig {
|
|
|
175
229
|
* Props passed to home page collection card action components.
|
|
176
230
|
* @group Models
|
|
177
231
|
*/
|
|
178
|
-
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string,
|
|
232
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
179
233
|
slug: string;
|
|
180
234
|
collection: EC;
|
|
181
235
|
context: RebaseContext<USER>;
|
|
@@ -193,13 +247,13 @@ export interface PluginFormActionProps<USER extends User = User, EC extends Enti
|
|
|
193
247
|
disabled: boolean;
|
|
194
248
|
formContext?: FormContext;
|
|
195
249
|
context: RebaseContext<USER>;
|
|
196
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
250
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
197
251
|
}
|
|
198
252
|
/**
|
|
199
253
|
* Parameters passed to the field builder wrap function.
|
|
200
254
|
* @group Models
|
|
201
255
|
*/
|
|
202
|
-
export type PluginFieldBuilderParams<M extends Record<string,
|
|
256
|
+
export type PluginFieldBuilderParams<M extends Record<string, unknown> = Record<string, unknown>, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
203
257
|
fieldConfigId: string;
|
|
204
258
|
propertyKey: string;
|
|
205
259
|
property: Property;
|