@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,86 +0,0 @@
|
|
|
1
|
-
import type { User } from "../users";
|
|
2
|
-
/**
|
|
3
|
-
* Result of creating a new user via admin flow.
|
|
4
|
-
* Contains the created user plus information about how credentials were delivered.
|
|
5
|
-
*/
|
|
6
|
-
export interface UserCreationResult<USER extends User = User> {
|
|
7
|
-
/** The created user */
|
|
8
|
-
user: USER;
|
|
9
|
-
/** Whether an invitation email was sent to the user */
|
|
10
|
-
invitationSent: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Temporary password (only present when email service is not configured).
|
|
13
|
-
* This is returned one-time and should be shown to the admin to share manually.
|
|
14
|
-
*/
|
|
15
|
-
temporaryPassword?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Delegate to manage auth-specific user operations.
|
|
19
|
-
*
|
|
20
|
-
* This interface allows the CMS to be agnostic of the underlying
|
|
21
|
-
* authentication provider or backend. User/role CRUD is now handled
|
|
22
|
-
* by the collection system; this delegate only exposes auth-specific
|
|
23
|
-
* operations (password hashing, invitations, bootstrap).
|
|
24
|
-
*
|
|
25
|
-
* @group Models
|
|
26
|
-
*/
|
|
27
|
-
export interface UserManagementDelegate<USER extends User = User> {
|
|
28
|
-
/**
|
|
29
|
-
* Are auth-related operations currently loading?
|
|
30
|
-
*/
|
|
31
|
-
loading: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* In-memory list of users (used for client-side filtering fallback).
|
|
34
|
-
*/
|
|
35
|
-
users?: USER[];
|
|
36
|
-
/**
|
|
37
|
-
* Error from fetching the users list, if any.
|
|
38
|
-
*/
|
|
39
|
-
usersError?: Error;
|
|
40
|
-
/**
|
|
41
|
-
* Look up a single user by UID from the in-memory cache.
|
|
42
|
-
*/
|
|
43
|
-
getUser?: (uid: string) => USER | null;
|
|
44
|
-
/**
|
|
45
|
-
* Server-side user search with pagination.
|
|
46
|
-
*/
|
|
47
|
-
searchUsers?: (params: {
|
|
48
|
-
search?: string;
|
|
49
|
-
limit?: number;
|
|
50
|
-
offset?: number;
|
|
51
|
-
}) => Promise<{
|
|
52
|
-
users: USER[];
|
|
53
|
-
total: number;
|
|
54
|
-
}>;
|
|
55
|
-
/**
|
|
56
|
-
* Create a new user with invitation/password generation support.
|
|
57
|
-
* Returns additional info about how the credentials were delivered.
|
|
58
|
-
*/
|
|
59
|
-
createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
60
|
-
/**
|
|
61
|
-
* Reset the password for an existing user.
|
|
62
|
-
* Returns a temporary password if no email service is configured,
|
|
63
|
-
* or a flag indicating an email invitation was sent.
|
|
64
|
-
*/
|
|
65
|
-
resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
66
|
-
/**
|
|
67
|
-
* Is the currently logged in user an admin?
|
|
68
|
-
*/
|
|
69
|
-
isAdmin?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Optionally define roles for a given user. This is useful when the roles
|
|
72
|
-
* are coming from a separate provider than the one issuing the tokens.
|
|
73
|
-
*/
|
|
74
|
-
defineRolesFor?: (user: USER) => Promise<string[] | undefined> | string[] | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Whether any admin users exist. Used by the bootstrap banner to decide
|
|
77
|
-
* whether to prompt. Populated via a lightweight check (e.g. `limit=1`
|
|
78
|
-
* query) instead of loading all users.
|
|
79
|
-
*/
|
|
80
|
-
hasAdminUsers?: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Optional function to bootstrap an admin user.
|
|
83
|
-
* Often used when the database is empty.
|
|
84
|
-
*/
|
|
85
|
-
bootstrapAdmin?: () => Promise<void>;
|
|
86
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Entity } from "./entities";
|
|
2
|
-
export interface WebSocketErrorPayload {
|
|
3
|
-
error?: string | {
|
|
4
|
-
message: string;
|
|
5
|
-
code?: string;
|
|
6
|
-
};
|
|
7
|
-
message?: string;
|
|
8
|
-
code?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface WebSocketMessage {
|
|
11
|
-
type: string;
|
|
12
|
-
payload?: unknown;
|
|
13
|
-
subscriptionId?: string;
|
|
14
|
-
requestId?: string;
|
|
15
|
-
entities?: Entity<Record<string, unknown>>[];
|
|
16
|
-
entity?: Entity<Record<string, unknown>> | null;
|
|
17
|
-
error?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface CollectionUpdateMessage extends WebSocketMessage {
|
|
20
|
-
type: "collection_update";
|
|
21
|
-
subscriptionId: string;
|
|
22
|
-
entities: Entity<Record<string, unknown>>[];
|
|
23
|
-
}
|
|
24
|
-
export interface EntityUpdateMessage extends WebSocketMessage {
|
|
25
|
-
type: "entity_update";
|
|
26
|
-
subscriptionId: string;
|
|
27
|
-
entity: Entity<Record<string, unknown>> | null;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Lightweight patch message sent to collection subscribers when a single
|
|
31
|
-
* entity is created, updated, or deleted. The client can merge this into
|
|
32
|
-
* its cached collection data for near-instant cross-tab updates without
|
|
33
|
-
* waiting for a full collection refetch.
|
|
34
|
-
*/
|
|
35
|
-
export interface CollectionEntityPatchMessage extends WebSocketMessage {
|
|
36
|
-
type: "collection_entity_patch";
|
|
37
|
-
subscriptionId: string;
|
|
38
|
-
entityId: string;
|
|
39
|
-
/** The updated entity, or null if deleted */
|
|
40
|
-
entity: Entity<Record<string, unknown>> | null;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Column metadata returned by table introspection.
|
|
44
|
-
*/
|
|
45
|
-
export interface TableColumnInfo {
|
|
46
|
-
column_name: string;
|
|
47
|
-
data_type: string;
|
|
48
|
-
udt_name: string;
|
|
49
|
-
is_nullable: string;
|
|
50
|
-
column_default: string | null;
|
|
51
|
-
character_maximum_length: number | null;
|
|
52
|
-
/** Enum values, populated for USER-DEFINED (enum) columns */
|
|
53
|
-
enum_values?: string[];
|
|
54
|
-
}
|
|
55
|
-
export interface TableForeignKeyInfo {
|
|
56
|
-
column_name: string;
|
|
57
|
-
foreign_table_name: string;
|
|
58
|
-
foreign_column_name: string;
|
|
59
|
-
}
|
|
60
|
-
export interface TableJunctionInfo {
|
|
61
|
-
junction_table_name: string;
|
|
62
|
-
source_column_name: string;
|
|
63
|
-
target_table_name: string;
|
|
64
|
-
target_column_name: string;
|
|
65
|
-
}
|
|
66
|
-
export interface TablePolicyInfo {
|
|
67
|
-
policy_name: string;
|
|
68
|
-
roles: string[];
|
|
69
|
-
cmd: string;
|
|
70
|
-
qual?: string;
|
|
71
|
-
with_check?: string;
|
|
72
|
-
}
|
|
73
|
-
export interface TableMetadata {
|
|
74
|
-
columns: TableColumnInfo[];
|
|
75
|
-
foreignKeys: TableForeignKeyInfo[];
|
|
76
|
-
junctions: TableJunctionInfo[];
|
|
77
|
-
policies: TablePolicyInfo[];
|
|
78
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./user";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This interface represents a user.
|
|
3
|
-
* It has some of the same fields as a Firebase User.
|
|
4
|
-
* Note that in the default implementation, we simply take the Firebase user
|
|
5
|
-
* and use it as a Rebase user, so that means that even if they are not mapped
|
|
6
|
-
* in this interface, it contains all the methods of the former, such as `delete`,
|
|
7
|
-
* `getIdToken`, etc.
|
|
8
|
-
*
|
|
9
|
-
* @group Models
|
|
10
|
-
*/
|
|
11
|
-
export type User = {
|
|
12
|
-
/**
|
|
13
|
-
* The user's unique ID, scoped to the project.
|
|
14
|
-
*/
|
|
15
|
-
readonly uid: string;
|
|
16
|
-
/**
|
|
17
|
-
* The display name of the user.
|
|
18
|
-
*/
|
|
19
|
-
readonly displayName: string | null;
|
|
20
|
-
/**
|
|
21
|
-
* The email of the user.
|
|
22
|
-
*/
|
|
23
|
-
readonly email: string | null;
|
|
24
|
-
/**
|
|
25
|
-
* The profile photo URL of the user.
|
|
26
|
-
*/
|
|
27
|
-
readonly photoURL: string | null;
|
|
28
|
-
/**
|
|
29
|
-
* The provider used to authenticate the user.
|
|
30
|
-
*/
|
|
31
|
-
readonly providerId: string;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
readonly isAnonymous: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Role IDs assigned to this user (e.g. ["admin", "editor"]).
|
|
38
|
-
*/
|
|
39
|
-
roles?: string[];
|
|
40
|
-
/**
|
|
41
|
-
* The date and time when the user was created.
|
|
42
|
-
*/
|
|
43
|
-
createdAt?: Date | string | null;
|
|
44
|
-
/**
|
|
45
|
-
* Additional metadata/custom claims associated with the user.
|
|
46
|
-
* Accessible by the frontend, but only writable by the backend.
|
|
47
|
-
*/
|
|
48
|
-
readonly metadata?: Record<string, any>;
|
|
49
|
-
getIdToken?: (forceRefresh?: boolean) => Promise<string>;
|
|
50
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|