@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,58 +0,0 @@
|
|
|
1
|
-
import { DataType, Entity, EntityReference, EntityRelation, EntityStatus, EntityValues, Properties, Property } from "@rebasepro/types";
|
|
2
|
-
export declare function isReadOnly(property: Property): boolean;
|
|
3
|
-
export declare function isHidden(property: Property): boolean;
|
|
4
|
-
export declare function isPropertyBuilder(property?: Property): boolean;
|
|
5
|
-
export declare function getDefaultValuesFor<M extends Record<string, unknown>>(properties: Properties): Partial<EntityValues<M>>;
|
|
6
|
-
export declare function getDefaultValueFor(property?: Property): unknown;
|
|
7
|
-
export declare function getDefaultValueFortype(type: DataType): unknown;
|
|
8
|
-
/**
|
|
9
|
-
* Update the automatic values in an entity before save
|
|
10
|
-
* @group Driver
|
|
11
|
-
*/
|
|
12
|
-
export declare function updateDateAutoValues<M extends Record<string, unknown>>({ inputValues, properties, status, timestampNowValue }: {
|
|
13
|
-
inputValues: Partial<EntityValues<M>>;
|
|
14
|
-
properties: Properties;
|
|
15
|
-
status: EntityStatus;
|
|
16
|
-
timestampNowValue: unknown;
|
|
17
|
-
}): EntityValues<M>;
|
|
18
|
-
/**
|
|
19
|
-
* Add missing required fields, expected in the collection, to the values of an entity
|
|
20
|
-
* @param values
|
|
21
|
-
* @param properties
|
|
22
|
-
* @group Driver
|
|
23
|
-
*/
|
|
24
|
-
export declare function sanitizeData<M extends Record<string, unknown>>(values: EntityValues<M>, properties: Properties): Record<string, unknown>;
|
|
25
|
-
export declare function getReferenceFrom<M extends Record<string, unknown>>(entity: Entity<M>): EntityReference;
|
|
26
|
-
export declare function getRelationFrom<M extends Record<string, unknown>>(entity: Entity<M>): EntityRelation;
|
|
27
|
-
/**
|
|
28
|
-
* Normalize a value into a proper EntityRelation instance.
|
|
29
|
-
* Handles EntityRelation class instances, and plain objects
|
|
30
|
-
* with `__type === "relation"` or an `isEntityRelation()` method.
|
|
31
|
-
*
|
|
32
|
-
* Returns null if the value cannot be coerced.
|
|
33
|
-
*/
|
|
34
|
-
export declare function normalizeToEntityRelation(value: unknown): EntityRelation | null;
|
|
35
|
-
export declare function traverseValuesProperties<M extends Record<string, unknown>>(inputValues: Partial<EntityValues<M>>, properties: Properties, operation: (value: unknown, property: Property) => unknown): EntityValues<M> | undefined;
|
|
36
|
-
export declare function traverseValueProperty(inputValue: unknown, property: Property, operation: (value: unknown, property: Property) => unknown): unknown;
|
|
37
|
-
/**
|
|
38
|
-
* Relation reference types used throughout the server layer.
|
|
39
|
-
* These replace the 50+ manual `{ id, path, __type: "relation" }` constructions.
|
|
40
|
-
*/
|
|
41
|
-
export interface RelationRef {
|
|
42
|
-
readonly id: string | number;
|
|
43
|
-
readonly path: string;
|
|
44
|
-
readonly __type: "relation";
|
|
45
|
-
}
|
|
46
|
-
export interface RelationRefWithData extends RelationRef {
|
|
47
|
-
readonly data: Entity;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Create a lightweight relation stub for CMS views.
|
|
51
|
-
* Replaces inline `{ id, path, __type: "relation" }` object literals.
|
|
52
|
-
*/
|
|
53
|
-
export declare function createRelationRef(id: string | number, path: string): RelationRef;
|
|
54
|
-
/**
|
|
55
|
-
* Create a hydrated relation reference that includes the full entity data.
|
|
56
|
-
* Used when entity data has been pre-fetched (e.g., via batch loading or JOINs).
|
|
57
|
-
*/
|
|
58
|
-
export declare function createRelationRefWithData(id: string | number, path: string, data: Entity): RelationRefWithData;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { EnumValueConfig, EnumValues } from "@rebasepro/types";
|
|
2
|
-
export declare function enumToObjectEntries(enumValues: EnumValues): EnumValueConfig[];
|
|
3
|
-
export declare function getLabelOrConfigFrom(enumValues: EnumValueConfig[], key?: string | number): EnumValueConfig | undefined;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from "./collections";
|
|
2
|
-
export * from "./common";
|
|
3
|
-
export * from "./entities";
|
|
4
|
-
export * from "./enums";
|
|
5
|
-
export * from "./paths";
|
|
6
|
-
export * from "./resolutions";
|
|
7
|
-
export * from "./permissions";
|
|
8
|
-
export * from "./references";
|
|
9
|
-
export * from "./navigation_from_path";
|
|
10
|
-
export * from "./parent_references_from_path";
|
|
11
|
-
export * from "./builders";
|
|
12
|
-
export * from "./storage";
|
|
13
|
-
export * from "./callbacks";
|
|
14
|
-
export * from "./relations";
|
|
15
|
-
export * from "./conditions";
|
|
16
|
-
export * from "./navigation_utils";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { EntityCollection } from "@rebasepro/types";
|
|
2
|
-
type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
3
|
-
key: string;
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
export type NavigationViewInternal<M extends Record<string, unknown> = Record<string, unknown>> = NavigationViewEntityInternal<M> | NavigationViewCollectionInternal<M> | NavigationViewEntityCustomInternal<M>;
|
|
7
|
-
export interface NavigationViewEntityInternal<M extends Record<string, unknown>> {
|
|
8
|
-
type: "entity";
|
|
9
|
-
entityId: string | number;
|
|
10
|
-
slug: string;
|
|
11
|
-
path: string;
|
|
12
|
-
parentCollection: EntityCollection<M>;
|
|
13
|
-
}
|
|
14
|
-
export interface NavigationViewCollectionInternal<M extends Record<string, unknown>> {
|
|
15
|
-
type: "collection";
|
|
16
|
-
id: string;
|
|
17
|
-
slug: string;
|
|
18
|
-
path: string;
|
|
19
|
-
collection: EntityCollection<M>;
|
|
20
|
-
}
|
|
21
|
-
export interface NavigationViewEntityCustomInternal<M extends Record<string, unknown>> {
|
|
22
|
-
type: "custom_view";
|
|
23
|
-
slug: string;
|
|
24
|
-
path: string;
|
|
25
|
-
entityId: string | number;
|
|
26
|
-
view: EntityCustomView<M>;
|
|
27
|
-
}
|
|
28
|
-
export declare function getNavigationEntriesFromPath(props: {
|
|
29
|
-
path: string;
|
|
30
|
-
collections: EntityCollection[] | undefined;
|
|
31
|
-
currentFullPath?: string;
|
|
32
|
-
contextEntityViews?: EntityCustomView[];
|
|
33
|
-
}): NavigationViewInternal[];
|
|
34
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EntityCollection } from "@rebasepro/types";
|
|
2
|
-
export declare function removeInitialAndTrailingSlashes(s: string): string;
|
|
3
|
-
export declare function removeInitialSlash(s: string): string;
|
|
4
|
-
export declare function removeTrailingSlash(s: string): string;
|
|
5
|
-
export declare function addInitialSlash(s: string): string;
|
|
6
|
-
export declare function getLastSegment(path: string): string;
|
|
7
|
-
export declare function resolveCollectionPathIds(path: string, allCollections: EntityCollection[]): string;
|
|
8
|
-
/**
|
|
9
|
-
* Find the corresponding view at any depth for a given path.
|
|
10
|
-
* Note that path or segments of the paths can be collection aliases.
|
|
11
|
-
* @param slugOrPath
|
|
12
|
-
* @param collections
|
|
13
|
-
*/
|
|
14
|
-
export declare function getCollectionBySlugWithin(slugOrPath: string, collections: EntityCollection[]): EntityCollection | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Get the subcollection combinations from a path:
|
|
17
|
-
* "sites/es/locales" => ["sites/es/locales", "sites"]
|
|
18
|
-
* @param subpaths
|
|
19
|
-
*/
|
|
20
|
-
export declare function getCollectionPathsCombinations(subpaths: string[]): string[];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const COLLECTION_PATH_SEPARATOR = "::";
|
|
2
|
-
/**
|
|
3
|
-
* Remove the entity ids from a given path
|
|
4
|
-
* `products/B44RG6APH/locales` => `products::locales`
|
|
5
|
-
* @param path
|
|
6
|
-
*/
|
|
7
|
-
export declare function stripCollectionPath(path: string): string;
|
|
8
|
-
export declare function segmentsToStrippedPath(paths: string[]): string;
|
|
9
|
-
/**
|
|
10
|
-
* Extract the collection path routes
|
|
11
|
-
* `products/B44RG6APH/locales` => [`products`, `locales`]
|
|
12
|
-
* @param path
|
|
13
|
-
*/
|
|
14
|
-
export declare function fullPathToCollectionSegments(path: string): string[];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Entity, EntityCollection, User } from "@rebasepro/types";
|
|
2
|
-
/**
|
|
3
|
-
* Minimal auth context for permission checking.
|
|
4
|
-
* Only requires the user object — avoids forcing callers to construct
|
|
5
|
-
* a full AuthController just to check permissions.
|
|
6
|
-
*/
|
|
7
|
-
export interface AuthContext<USER extends User = User> {
|
|
8
|
-
user: USER | null;
|
|
9
|
-
}
|
|
10
|
-
export declare function checkOperation<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, entity: Entity<M> | null, targetOperation: "select" | "insert" | "update" | "delete"): boolean;
|
|
11
|
-
export declare function canReadCollection<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>): boolean;
|
|
12
|
-
export declare function canEditEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, path: string, entity: Entity<M> | null): boolean;
|
|
13
|
-
export declare function canCreateEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, path: string, entity: Entity<M> | null): boolean;
|
|
14
|
-
export declare function canDeleteEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, path: string, entity: Entity<M> | null): boolean;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { EntityCollection, Property, Relation } from "@rebasepro/types";
|
|
2
|
-
export declare function sanitizeRelation(relation: Partial<Relation>, sourceCollection: EntityCollection, resolveCollection?: (slugOrTable: string) => EntityCollection | undefined): Relation;
|
|
3
|
-
export declare function resolveCollectionRelations(collection: EntityCollection): Record<string, Relation>;
|
|
4
|
-
export declare function resolvePropertyRelation({ propertyKey, property, sourceCollection }: {
|
|
5
|
-
propertyKey: string;
|
|
6
|
-
property: Property;
|
|
7
|
-
sourceCollection: EntityCollection;
|
|
8
|
-
}): Relation | undefined;
|
|
9
|
-
export declare function getTableName(collection: EntityCollection): string;
|
|
10
|
-
export declare function getTableVarName(tableName: string): string;
|
|
11
|
-
export declare function getEnumVarName(tableName: string, propName: string): string;
|
|
12
|
-
export declare function getColumnName(fullColumn: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Look up a relation by key with forgiving normalization.
|
|
15
|
-
*
|
|
16
|
-
* `resolveCollectionRelations` stores each relation under a single canonical
|
|
17
|
-
* key (no aliases). This helper tries the given key as-is, then falls back to
|
|
18
|
-
* slug form (underscores → hyphens) and snake_case form (hyphens → underscores)
|
|
19
|
-
* so that callers that receive a key from external input (URL path segments,
|
|
20
|
-
* user-provided config, etc.) can still find the right entry.
|
|
21
|
-
*/
|
|
22
|
-
export declare function findRelation(resolvedRelations: Record<string, Relation>, key: string): Relation | undefined;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ArrayProperty, AuthController, EntityCollection, EnumValueConfig, EnumValues, NumberProperty, Properties, Property, Relation, RelationProperty, StringProperty } from "@rebasepro/types";
|
|
2
|
-
type PropertyConfig = {
|
|
3
|
-
property: unknown;
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Resolve property builders, enums and arrays.
|
|
8
|
-
*/
|
|
9
|
-
export type ResolvePropertyProps<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
10
|
-
property: Property;
|
|
11
|
-
propertyKey?: string;
|
|
12
|
-
values?: Partial<M>;
|
|
13
|
-
previousValues?: Partial<M>;
|
|
14
|
-
path?: string;
|
|
15
|
-
entityId?: string | number;
|
|
16
|
-
index?: number;
|
|
17
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
18
|
-
ignoreMissingFields?: boolean;
|
|
19
|
-
authController: AuthController;
|
|
20
|
-
};
|
|
21
|
-
export declare function resolveProperty<M extends Record<string, unknown> = Record<string, unknown>>(props: ResolvePropertyProps<M>): Property | null;
|
|
22
|
-
export declare function resolveRelationProperty(property: RelationProperty, relations: Relation[], propertyKey?: string): RelationProperty;
|
|
23
|
-
/**
|
|
24
|
-
* Resolve enum aliases for a string or number property
|
|
25
|
-
* @param property
|
|
26
|
-
*/
|
|
27
|
-
export declare function resolvePropertyEnum(property: StringProperty | NumberProperty): StringProperty | NumberProperty;
|
|
28
|
-
/**
|
|
29
|
-
* Resolve enums and arrays for properties
|
|
30
|
-
* @param properties
|
|
31
|
-
* @param value
|
|
32
|
-
*/
|
|
33
|
-
export declare function resolveProperties<M extends Record<string, unknown>>({ propertyKey, properties, ignoreMissingFields, ...props }: {
|
|
34
|
-
propertyKey?: string;
|
|
35
|
-
properties: Properties;
|
|
36
|
-
values?: Partial<M>;
|
|
37
|
-
previousValues?: Partial<M>;
|
|
38
|
-
path?: string;
|
|
39
|
-
entityId?: string | number;
|
|
40
|
-
index?: number;
|
|
41
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
42
|
-
ignoreMissingFields?: boolean;
|
|
43
|
-
authController: AuthController;
|
|
44
|
-
}): Properties;
|
|
45
|
-
export declare function resolveArrayProperties<M>({ propertyKey, property, ignoreMissingFields, ...props }: {
|
|
46
|
-
propertyKey?: string;
|
|
47
|
-
property: ArrayProperty;
|
|
48
|
-
values?: Partial<M>;
|
|
49
|
-
previousValues?: Partial<M>;
|
|
50
|
-
path?: string;
|
|
51
|
-
entityId?: string | number;
|
|
52
|
-
index?: number;
|
|
53
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
54
|
-
ignoreMissingFields?: boolean;
|
|
55
|
-
authController: AuthController;
|
|
56
|
-
}): Property[];
|
|
57
|
-
export declare function getArrayResolvedProperties({ propertyKey, propertyValue, property, ...props }: {
|
|
58
|
-
propertyValue: unknown;
|
|
59
|
-
propertyKey?: string;
|
|
60
|
-
property: ArrayProperty;
|
|
61
|
-
ignoreMissingFields: boolean;
|
|
62
|
-
values?: object;
|
|
63
|
-
previousValues?: object;
|
|
64
|
-
path?: string;
|
|
65
|
-
entityId?: string | number;
|
|
66
|
-
index?: number;
|
|
67
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
68
|
-
authController: AuthController;
|
|
69
|
-
}): Property[];
|
|
70
|
-
export declare function resolveEnumValues(input: EnumValues): EnumValueConfig[] | undefined;
|
|
71
|
-
export declare function getSubcollections<M extends Record<string, unknown> = Record<string, unknown>>(collection: EntityCollection<M>): EntityCollection<Record<string, unknown>>[];
|
|
72
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ArrayProperty, EntityValues, StorageConfig, StringProperty, UploadedFileContext } from "@rebasepro/types";
|
|
2
|
-
interface ResolveFilenameStringParams<M extends Record<string, unknown>> {
|
|
3
|
-
input: string | ((context: UploadedFileContext) => (Promise<string> | string));
|
|
4
|
-
storage: StorageConfig;
|
|
5
|
-
values: EntityValues<M>;
|
|
6
|
-
entityId?: string | number;
|
|
7
|
-
path?: string;
|
|
8
|
-
property: StringProperty | ArrayProperty;
|
|
9
|
-
file: File;
|
|
10
|
-
propertyKey: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function resolveStorageFilenameString<M extends Record<string, unknown>>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
|
|
13
|
-
interface ResolveStoragePathStringParams<M extends Record<string, unknown>> {
|
|
14
|
-
input: string | ((context: UploadedFileContext) => string);
|
|
15
|
-
storage: StorageConfig;
|
|
16
|
-
values: EntityValues<M>;
|
|
17
|
-
entityId?: string | number;
|
|
18
|
-
path?: string;
|
|
19
|
-
property: StringProperty | ArrayProperty;
|
|
20
|
-
file: File;
|
|
21
|
-
propertyKey: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function resolveStoragePathString<M extends Record<string, unknown>>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveStoragePathStringParams<M>): string;
|
|
24
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type AnalyticsController = {
|
|
2
|
-
/**
|
|
3
|
-
* Callback used to get analytics events from the CMS
|
|
4
|
-
*/
|
|
5
|
-
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
6
|
-
};
|
|
7
|
-
export type AnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "view_mode_changed" | "kanban_card_moved" | "kanban_column_reorder" | "kanban_property_changed" | "kanban_new_entity_in_column" | "kanban_backfill_order" | "card_view_entity_click" | "unmapped_event";
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { User } from "../users";
|
|
2
|
-
/**
|
|
3
|
-
* Capabilities advertised by an auth provider.
|
|
4
|
-
* UI components use this to show/hide features dynamically
|
|
5
|
-
* (e.g. password reset, registration, session management).
|
|
6
|
-
* @group Hooks and utilities
|
|
7
|
-
*/
|
|
8
|
-
export interface AuthCapabilities {
|
|
9
|
-
emailPasswordLogin?: boolean;
|
|
10
|
-
googleLogin?: boolean;
|
|
11
|
-
registration?: boolean;
|
|
12
|
-
passwordReset?: boolean;
|
|
13
|
-
sessionManagement?: boolean;
|
|
14
|
-
profileUpdate?: boolean;
|
|
15
|
-
emailVerification?: boolean;
|
|
16
|
-
/** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
|
|
17
|
-
enabledProviders?: string[];
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Controller for retrieving the logged user or performing auth related operations.
|
|
21
|
-
* Note that if you are implementing your AuthController, you probably will want
|
|
22
|
-
* to do it as the result of a hook.
|
|
23
|
-
* @group Hooks and utilities
|
|
24
|
-
*/
|
|
25
|
-
export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
26
|
-
/**
|
|
27
|
-
* The user currently logged in
|
|
28
|
-
* The values can be: the user object, null if they skipped login
|
|
29
|
-
*/
|
|
30
|
-
user: USER | null;
|
|
31
|
-
/**
|
|
32
|
-
* Initial loading flag. It is used not to display the login screen
|
|
33
|
-
* when the app first loads, and it has not been checked whether the user
|
|
34
|
-
* is logged in or not.
|
|
35
|
-
*/
|
|
36
|
-
initialLoading?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Loading flag. It is used to display a loading screen when the user is
|
|
39
|
-
* logging in or out.
|
|
40
|
-
*/
|
|
41
|
-
authLoading: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Sign out
|
|
44
|
-
*/
|
|
45
|
-
signOut: () => Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Error initializing the authentication
|
|
48
|
-
*/
|
|
49
|
-
authError?: unknown;
|
|
50
|
-
/**
|
|
51
|
-
* Error dispatched by the auth provider
|
|
52
|
-
*/
|
|
53
|
-
authProviderError?: unknown;
|
|
54
|
-
/**
|
|
55
|
-
* You can use this method to retrieve the auth token for the current user.
|
|
56
|
-
*/
|
|
57
|
-
getAuthToken: () => Promise<string>;
|
|
58
|
-
/**
|
|
59
|
-
* Has the user skipped the login process
|
|
60
|
-
*/
|
|
61
|
-
loginSkipped: boolean;
|
|
62
|
-
extra: ExtraData;
|
|
63
|
-
setExtra: (extra: ExtraData) => void;
|
|
64
|
-
setUser?(user: USER | null): void;
|
|
65
|
-
setUserRoles?(roles: string[]): void;
|
|
66
|
-
/**
|
|
67
|
-
* Capabilities advertised by the auth provider.
|
|
68
|
-
* UI components use this to feature-detect what the backend supports.
|
|
69
|
-
*/
|
|
70
|
-
capabilities?: AuthCapabilities;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Extended auth controller with common optional auth methods.
|
|
74
|
-
* Backend implementations (Rebase backend, Firebase, Supabase, etc.)
|
|
75
|
-
* extend this with their own backend-specific extras.
|
|
76
|
-
* @group Hooks and utilities
|
|
77
|
-
*/
|
|
78
|
-
export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
|
|
79
|
-
/** Login with email and password */
|
|
80
|
-
emailPasswordLogin?(email: string, password: string): Promise<void>;
|
|
81
|
-
/** Login with Google — accepts an ID token, access token, or authorization code payload */
|
|
82
|
-
googleLogin?: (payload: {
|
|
83
|
-
idToken: string;
|
|
84
|
-
} | {
|
|
85
|
-
accessToken: string;
|
|
86
|
-
} | {
|
|
87
|
-
code: string;
|
|
88
|
-
redirectUri: string;
|
|
89
|
-
}) => Promise<void>;
|
|
90
|
-
/** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
|
|
91
|
-
oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
|
|
92
|
-
/** Register a new user */
|
|
93
|
-
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
94
|
-
/** Skip login (for anonymous access if enabled) */
|
|
95
|
-
skipLogin?(): void;
|
|
96
|
-
/** Request password reset email */
|
|
97
|
-
forgotPassword?(email: string): Promise<void>;
|
|
98
|
-
/** Reset password using a token */
|
|
99
|
-
resetPassword?(token: string, password: string): Promise<void>;
|
|
100
|
-
/** Change password for the authenticated user */
|
|
101
|
-
changePassword?(oldPassword: string, newPassword: string): Promise<void>;
|
|
102
|
-
/** Update user profile */
|
|
103
|
-
updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
|
|
104
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { User } from "../users";
|
|
2
|
-
import type { RebaseData } from "./data";
|
|
3
|
-
import type { EmailService } from "./email";
|
|
4
|
-
/**
|
|
5
|
-
* Event type for authentication state changes
|
|
6
|
-
*/
|
|
7
|
-
export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
|
|
8
|
-
/**
|
|
9
|
-
* Standard session interface representing an authenticated state
|
|
10
|
-
*/
|
|
11
|
-
export interface RebaseSession {
|
|
12
|
-
accessToken: string;
|
|
13
|
-
refreshToken: string;
|
|
14
|
-
expiresAt: number;
|
|
15
|
-
user: User;
|
|
16
|
-
}
|
|
17
|
-
import type { StorageSource } from "./storage";
|
|
18
|
-
/**
|
|
19
|
-
* Unified Authentication Client Interface
|
|
20
|
-
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
21
|
-
*/
|
|
22
|
-
export interface AuthClient {
|
|
23
|
-
/**
|
|
24
|
-
* Get the current user from the server or cache
|
|
25
|
-
*/
|
|
26
|
-
getUser(): Promise<User | null>;
|
|
27
|
-
/**
|
|
28
|
-
* Get the currently active session
|
|
29
|
-
*/
|
|
30
|
-
getSession(): RebaseSession | null;
|
|
31
|
-
/**
|
|
32
|
-
* Sign out the current user and clear local session
|
|
33
|
-
*/
|
|
34
|
-
signOut(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Subscribe to authentication state changes
|
|
37
|
-
*/
|
|
38
|
-
onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
|
|
39
|
-
/**
|
|
40
|
-
* Manually refresh the session token
|
|
41
|
-
*/
|
|
42
|
-
refreshSession(): Promise<RebaseSession>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* User record as returned by the Admin API.
|
|
46
|
-
* @group Admin
|
|
47
|
-
*/
|
|
48
|
-
export interface AdminUser {
|
|
49
|
-
uid: string;
|
|
50
|
-
email: string;
|
|
51
|
-
displayName: string | null;
|
|
52
|
-
photoURL: string | null;
|
|
53
|
-
provider: string;
|
|
54
|
-
roles: string[];
|
|
55
|
-
metadata?: Record<string, any>;
|
|
56
|
-
createdAt: string;
|
|
57
|
-
updatedAt: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Client-side Admin API interface.
|
|
61
|
-
* Provides user management operations.
|
|
62
|
-
* @group Admin
|
|
63
|
-
*/
|
|
64
|
-
export interface AdminAPI {
|
|
65
|
-
listUsers(): Promise<{
|
|
66
|
-
users: AdminUser[];
|
|
67
|
-
}>;
|
|
68
|
-
listUsersPaginated(options?: {
|
|
69
|
-
search?: string;
|
|
70
|
-
limit?: number;
|
|
71
|
-
offset?: number;
|
|
72
|
-
orderBy?: string;
|
|
73
|
-
orderDir?: "asc" | "desc";
|
|
74
|
-
}): Promise<{
|
|
75
|
-
users: AdminUser[];
|
|
76
|
-
total: number;
|
|
77
|
-
limit: number;
|
|
78
|
-
offset: number;
|
|
79
|
-
}>;
|
|
80
|
-
getUser(userId: string): Promise<{
|
|
81
|
-
user: AdminUser;
|
|
82
|
-
}>;
|
|
83
|
-
createUser(data: {
|
|
84
|
-
email: string;
|
|
85
|
-
displayName?: string;
|
|
86
|
-
password?: string;
|
|
87
|
-
roles?: string[];
|
|
88
|
-
metadata?: Record<string, any>;
|
|
89
|
-
}): Promise<{
|
|
90
|
-
user: AdminUser;
|
|
91
|
-
}>;
|
|
92
|
-
updateUser(userId: string, data: {
|
|
93
|
-
email?: string;
|
|
94
|
-
displayName?: string;
|
|
95
|
-
password?: string;
|
|
96
|
-
roles?: string[];
|
|
97
|
-
metadata?: Record<string, any>;
|
|
98
|
-
}): Promise<{
|
|
99
|
-
user: AdminUser;
|
|
100
|
-
}>;
|
|
101
|
-
deleteUser(userId: string): Promise<{
|
|
102
|
-
success: boolean;
|
|
103
|
-
}>;
|
|
104
|
-
bootstrap(): Promise<{
|
|
105
|
-
success: boolean;
|
|
106
|
-
message: string;
|
|
107
|
-
user: {
|
|
108
|
-
uid: string;
|
|
109
|
-
roles: string[];
|
|
110
|
-
};
|
|
111
|
-
}>;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Overarching abstraction that unites Data, Auth, Storage, and Email.
|
|
115
|
-
* Adapters for Supabase or Firebase simply need to implement this interface.
|
|
116
|
-
*/
|
|
117
|
-
export interface RebaseClient<DB = unknown> {
|
|
118
|
-
/** Unified Data access layer */
|
|
119
|
-
data: RebaseData;
|
|
120
|
-
/** Unified Authentication layer */
|
|
121
|
-
auth: AuthClient;
|
|
122
|
-
/** Unified Storage layer */
|
|
123
|
-
storage?: StorageSource;
|
|
124
|
-
/**
|
|
125
|
-
* Server-side email service.
|
|
126
|
-
*
|
|
127
|
-
* Available when SMTP (or a custom `sendEmail` function) is configured
|
|
128
|
-
* in the backend auth config. `undefined` when email is not configured.
|
|
129
|
-
*
|
|
130
|
-
* > **Note:** This is only available on the server-side `rebase` singleton.
|
|
131
|
-
* > The client-side SDK does not include an email service.
|
|
132
|
-
*/
|
|
133
|
-
email?: EmailService;
|
|
134
|
-
/** Admin API for user management */
|
|
135
|
-
admin?: AdminAPI;
|
|
136
|
-
/**
|
|
137
|
-
* The base HTTP URL of the backend server.
|
|
138
|
-
* Exposed by the SDK client (`@rebasepro/client`) and used to auto-derive
|
|
139
|
-
* the `ApiConfigProvider` URL.
|
|
140
|
-
*/
|
|
141
|
-
baseUrl?: string;
|
|
142
|
-
/**
|
|
143
|
-
* WebSocket client for realtime subscriptions and admin capabilities.
|
|
144
|
-
* Exposed by the SDK client (`@rebasepro/client`). The shape is intentionally
|
|
145
|
-
* left as `unknown` in the base interface — callers should narrow via feature
|
|
146
|
-
* detection (e.g. `typeof ws.executeSql === "function"`).
|
|
147
|
-
*/
|
|
148
|
-
ws?: unknown;
|
|
149
|
-
/**
|
|
150
|
-
* Execute raw SQL against the database.
|
|
151
|
-
*
|
|
152
|
-
* Only available server-side when the backend uses a SQL database
|
|
153
|
-
* (PostgreSQL, MySQL, etc.). `undefined` for document databases
|
|
154
|
-
* (MongoDB, Firestore) and on the client-side SDK.
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* // In a cron job or custom function:
|
|
159
|
-
* if (ctx.client.sql) {
|
|
160
|
-
* const rows = await ctx.client.sql("SELECT count(*) FROM orders");
|
|
161
|
-
* }
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
sql?(query: string, options?: {
|
|
165
|
-
database?: string;
|
|
166
|
-
role?: string;
|
|
167
|
-
}): Promise<Record<string, unknown>[]>;
|
|
168
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { EntityCollection } from "../types/collections";
|
|
2
|
-
import type { EntityReference } from "../types/entities";
|
|
3
|
-
/**
|
|
4
|
-
* Controller that provides access to the registered entity collections.
|
|
5
|
-
* @group Models
|
|
6
|
-
*/
|
|
7
|
-
export type CollectionRegistryController<DB = Record<string, unknown>, EC extends EntityCollection = EntityCollection> = {
|
|
8
|
-
/**
|
|
9
|
-
* List of the mapped collections in the CMS.
|
|
10
|
-
* Each entry relates to a collection in the root database.
|
|
11
|
-
* Each of the navigation entries in this field
|
|
12
|
-
* generates an entry in the main menu.
|
|
13
|
-
*/
|
|
14
|
-
collections?: EntityCollection[];
|
|
15
|
-
/**
|
|
16
|
-
* Is the registry ready to be used
|
|
17
|
-
*/
|
|
18
|
-
initialised: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Get the collection configuration for a given path.
|
|
21
|
-
* The collection is resolved from the given path or alias.
|
|
22
|
-
*/
|
|
23
|
-
getCollection: <K extends keyof DB>(slugOrPath: Extract<K, string>, includeUserOverride?: boolean) => EC | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Get the raw, un-normalized collection configuration.
|
|
26
|
-
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
27
|
-
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
28
|
-
*/
|
|
29
|
-
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Retrieve all the related parent references for a given path
|
|
32
|
-
* @param path
|
|
33
|
-
*/
|
|
34
|
-
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
35
|
-
/**
|
|
36
|
-
* Retrieve all the related parent collection ids for a given path
|
|
37
|
-
* @param path
|
|
38
|
-
*/
|
|
39
|
-
getParentCollectionSlugs: (path: string) => string[];
|
|
40
|
-
getParentEntityIds: (path: string) => string[];
|
|
41
|
-
/**
|
|
42
|
-
* Resolve paths from a list of ids
|
|
43
|
-
* @param ids
|
|
44
|
-
*/
|
|
45
|
-
convertIdsToPaths: (ids: string[]) => string[];
|
|
46
|
-
};
|