@rebasepro/server-core 0.0.1-canary.4d4fb3e
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/LICENSE +6 -0
- package/README.md +40 -0
- package/build-errors.txt +52 -0
- package/coverage/clover.xml +3739 -0
- package/coverage/coverage-final.json +31 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +266 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/api/ast-schema-editor.ts.html +952 -0
- package/coverage/lcov-report/src/api/errors.ts.html +472 -0
- package/coverage/lcov-report/src/api/graphql/graphql-schema-generator.ts.html +1069 -0
- package/coverage/lcov-report/src/api/graphql/index.html +116 -0
- package/coverage/lcov-report/src/api/index.html +176 -0
- package/coverage/lcov-report/src/api/openapi-generator.ts.html +565 -0
- package/coverage/lcov-report/src/api/rest/api-generator.ts.html +994 -0
- package/coverage/lcov-report/src/api/rest/index.html +131 -0
- package/coverage/lcov-report/src/api/rest/query-parser.ts.html +550 -0
- package/coverage/lcov-report/src/api/schema-editor-routes.ts.html +202 -0
- package/coverage/lcov-report/src/api/server.ts.html +823 -0
- package/coverage/lcov-report/src/auth/admin-routes.ts.html +973 -0
- package/coverage/lcov-report/src/auth/index.html +176 -0
- package/coverage/lcov-report/src/auth/jwt.ts.html +574 -0
- package/coverage/lcov-report/src/auth/middleware.ts.html +745 -0
- package/coverage/lcov-report/src/auth/password.ts.html +310 -0
- package/coverage/lcov-report/src/auth/services.ts.html +2074 -0
- package/coverage/lcov-report/src/collections/index.html +116 -0
- package/coverage/lcov-report/src/collections/loader.ts.html +232 -0
- package/coverage/lcov-report/src/db/auth-schema.ts.html +523 -0
- package/coverage/lcov-report/src/db/data-transformer.ts.html +1753 -0
- package/coverage/lcov-report/src/db/entityService.ts.html +700 -0
- package/coverage/lcov-report/src/db/index.html +146 -0
- package/coverage/lcov-report/src/db/services/EntityFetchService.ts.html +4048 -0
- package/coverage/lcov-report/src/db/services/EntityPersistService.ts.html +883 -0
- package/coverage/lcov-report/src/db/services/RelationService.ts.html +3121 -0
- package/coverage/lcov-report/src/db/services/entity-helpers.ts.html +442 -0
- package/coverage/lcov-report/src/db/services/index.html +176 -0
- package/coverage/lcov-report/src/db/services/index.ts.html +124 -0
- package/coverage/lcov-report/src/generate-drizzle-schema-logic.ts.html +1960 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/services/driver-registry.ts.html +631 -0
- package/coverage/lcov-report/src/services/index.html +131 -0
- package/coverage/lcov-report/src/services/postgresDataDriver.ts.html +3025 -0
- package/coverage/lcov-report/src/storage/LocalStorageController.ts.html +1189 -0
- package/coverage/lcov-report/src/storage/S3StorageController.ts.html +970 -0
- package/coverage/lcov-report/src/storage/index.html +161 -0
- package/coverage/lcov-report/src/storage/storage-registry.ts.html +646 -0
- package/coverage/lcov-report/src/storage/types.ts.html +451 -0
- package/coverage/lcov-report/src/utils/drizzle-conditions.ts.html +3082 -0
- package/coverage/lcov-report/src/utils/index.html +116 -0
- package/coverage/lcov.info +7179 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +48 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +36 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +12 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/index-BeMqpmfQ.js +239 -0
- package/dist/index-BeMqpmfQ.js.map +1 -0
- package/dist/index-bl4J3lNb.js +55823 -0
- package/dist/index-bl4J3lNb.js.map +1 -0
- package/dist/index.es.js +58 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +56062 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/server-core/src/api/ast-schema-editor.d.ts +21 -0
- package/dist/server-core/src/api/collections_for_test/callbacks_test_collection.d.ts +2 -0
- package/dist/server-core/src/api/errors.d.ts +35 -0
- package/dist/server-core/src/api/graphql/graphql-schema-generator.d.ts +35 -0
- package/dist/server-core/src/api/graphql/index.d.ts +1 -0
- package/dist/server-core/src/api/index.d.ts +9 -0
- package/dist/server-core/src/api/openapi-generator.d.ts +2 -0
- package/dist/server-core/src/api/rest/api-generator.d.ts +64 -0
- package/dist/server-core/src/api/rest/index.d.ts +1 -0
- package/dist/server-core/src/api/rest/query-parser.d.ts +9 -0
- package/dist/server-core/src/api/schema-editor-routes.d.ts +3 -0
- package/dist/server-core/src/api/server.d.ts +40 -0
- package/dist/server-core/src/api/types.d.ts +90 -0
- package/dist/server-core/src/auth/admin-routes.d.ts +7 -0
- package/dist/server-core/src/auth/google-oauth.d.ts +20 -0
- package/dist/server-core/src/auth/index.d.ts +12 -0
- package/dist/server-core/src/auth/interfaces.d.ts +270 -0
- package/dist/server-core/src/auth/jwt.d.ts +42 -0
- package/dist/server-core/src/auth/middleware.d.ts +56 -0
- package/dist/server-core/src/auth/password.d.ts +22 -0
- package/dist/server-core/src/auth/rate-limiter.d.ts +31 -0
- package/dist/server-core/src/auth/routes.d.ts +17 -0
- package/dist/server-core/src/bootstrappers/index.d.ts +0 -0
- package/dist/server-core/src/collections/BackendCollectionRegistry.d.ts +13 -0
- package/dist/server-core/src/collections/loader.d.ts +5 -0
- package/dist/server-core/src/db/interfaces.d.ts +18 -0
- package/dist/server-core/src/email/index.d.ts +6 -0
- package/dist/server-core/src/email/smtp-email-service.d.ts +25 -0
- package/dist/server-core/src/email/templates.d.ts +33 -0
- package/dist/server-core/src/email/types.d.ts +110 -0
- package/dist/server-core/src/functions/function-loader.d.ts +17 -0
- package/dist/server-core/src/functions/function-routes.d.ts +10 -0
- package/dist/server-core/src/functions/index.d.ts +3 -0
- package/dist/server-core/src/history/history-routes.d.ts +23 -0
- package/dist/server-core/src/history/index.d.ts +1 -0
- package/dist/server-core/src/index.d.ts +24 -0
- package/dist/server-core/src/init.d.ts +49 -0
- package/dist/server-core/src/serve-spa.d.ts +30 -0
- package/dist/server-core/src/services/driver-registry.d.ts +78 -0
- package/dist/server-core/src/storage/LocalStorageController.d.ts +46 -0
- package/dist/server-core/src/storage/S3StorageController.d.ts +36 -0
- package/dist/server-core/src/storage/index.d.ts +18 -0
- package/dist/server-core/src/storage/routes.d.ts +38 -0
- package/dist/server-core/src/storage/storage-registry.d.ts +78 -0
- package/dist/server-core/src/storage/types.d.ts +91 -0
- package/dist/server-core/src/types/index.d.ts +11 -0
- package/dist/server-core/src/utils/logging.d.ts +9 -0
- package/dist/server-core/src/utils/sql.d.ts +27 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +117 -0
- package/dist/types/src/controllers/client.d.ts +58 -0
- package/dist/types/src/controllers/collection_registry.d.ts +44 -0
- package/dist/types/src/controllers/customization_controller.d.ts +54 -0
- package/dist/types/src/controllers/data.d.ts +141 -0
- package/dist/types/src/controllers/data_driver.d.ts +168 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/index.d.ts +17 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +51 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +89 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +173 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +101 -0
- package/dist/types/src/types/backend.d.ts +533 -0
- package/dist/types/src/types/builders.d.ts +14 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +812 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +9 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +22 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +225 -0
- package/dist/types/src/types/properties.d.ts +1091 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +228 -0
- package/dist/types/src/types/translations.d.ts +826 -0
- package/dist/types/src/types/user_management_delegate.d.ts +120 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/history_diff.log +385 -0
- package/jest.config.cjs +16 -0
- package/package.json +86 -0
- package/scratch.ts +8 -0
- package/src/api/ast-schema-editor.ts +289 -0
- package/src/api/collections_for_test/callbacks_test_collection.ts +57 -0
- package/src/api/errors.ts +155 -0
- package/src/api/graphql/graphql-schema-generator.ts +334 -0
- package/src/api/graphql/index.ts +2 -0
- package/src/api/index.ts +11 -0
- package/src/api/openapi-generator.ts +160 -0
- package/src/api/rest/api-generator.ts +466 -0
- package/src/api/rest/index.ts +2 -0
- package/src/api/rest/query-parser.ts +155 -0
- package/src/api/schema-editor-routes.ts +39 -0
- package/src/api/server.ts +245 -0
- package/src/api/types.ts +90 -0
- package/src/auth/admin-routes.ts +488 -0
- package/src/auth/google-oauth.ts +60 -0
- package/src/auth/index.ts +21 -0
- package/src/auth/interfaces.ts +316 -0
- package/src/auth/jwt.ts +164 -0
- package/src/auth/middleware.ts +235 -0
- package/src/auth/password.ts +75 -0
- package/src/auth/rate-limiter.ts +129 -0
- package/src/auth/routes.ts +730 -0
- package/src/bootstrappers/index.ts +1 -0
- package/src/collections/BackendCollectionRegistry.ts +20 -0
- package/src/collections/loader.ts +49 -0
- package/src/db/interfaces.ts +60 -0
- package/src/email/index.ts +17 -0
- package/src/email/smtp-email-service.ts +88 -0
- package/src/email/templates.ts +301 -0
- package/src/email/types.ts +112 -0
- package/src/functions/function-loader.ts +91 -0
- package/src/functions/function-routes.ts +31 -0
- package/src/functions/index.ts +3 -0
- package/src/history/history-routes.ts +128 -0
- package/src/history/index.ts +2 -0
- package/src/index.ts +56 -0
- package/src/init.ts +309 -0
- package/src/serve-spa.ts +81 -0
- package/src/services/driver-registry.ts +182 -0
- package/src/storage/LocalStorageController.ts +368 -0
- package/src/storage/S3StorageController.ts +295 -0
- package/src/storage/index.ts +32 -0
- package/src/storage/routes.ts +247 -0
- package/src/storage/storage-registry.ts +187 -0
- package/src/storage/types.ts +122 -0
- package/src/types/index.ts +27 -0
- package/src/utils/logging.ts +35 -0
- package/src/utils/sql.ts +38 -0
- package/test/admin-routes.test.ts +591 -0
- package/test/api-generator.test.ts +458 -0
- package/test/ast-schema-editor.test.ts +61 -0
- package/test/auth-middleware-hono.test.ts +321 -0
- package/test/auth-routes.test.ts +868 -0
- package/test/driver-registry.test.ts +280 -0
- package/test/errors-hono.test.ts +133 -0
- package/test/errors.test.ts +150 -0
- package/test/jwt-security.test.ts +173 -0
- package/test/jwt.test.ts +311 -0
- package/test/middleware.test.ts +295 -0
- package/test/password.test.ts +165 -0
- package/test/query-parser.test.ts +258 -0
- package/test/rate-limiter.test.ts +102 -0
- package/test/storage-local.test.ts +278 -0
- package/test/storage-registry.test.ts +280 -0
- package/test/storage-routes.test.ts +218 -0
- package/test/storage-s3.test.ts +301 -0
- package/test-ast.ts +28 -0
- package/test_output.txt +1133 -0
- package/tsconfig.json +49 -0
- package/tsconfig.prod.json +20 -0
- package/vite.config.ts +78 -0
- package/vite.config.ts.timestamp-1775065397568-8a853255edf6e.mjs +46 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3-compatible storage controller (works with AWS S3 and MinIO)
|
|
3
|
+
*/
|
|
4
|
+
import { StorageController, S3StorageConfig } from './types';
|
|
5
|
+
import { UploadFileProps, UploadFileResult, DownloadConfig, StorageListResult } from '@rebasepro/types';
|
|
6
|
+
/**
|
|
7
|
+
* S3-compatible storage implementation
|
|
8
|
+
* Works with AWS S3 and MinIO (with forcePathStyle option)
|
|
9
|
+
*/
|
|
10
|
+
export declare class S3StorageController implements StorageController {
|
|
11
|
+
private config;
|
|
12
|
+
private client;
|
|
13
|
+
constructor(config: S3StorageConfig);
|
|
14
|
+
getType(): 's3';
|
|
15
|
+
/**
|
|
16
|
+
* Validate file before upload
|
|
17
|
+
*/
|
|
18
|
+
private validateFile;
|
|
19
|
+
/**
|
|
20
|
+
* Get the bucket name - either from parameter or config
|
|
21
|
+
*/
|
|
22
|
+
private getBucket;
|
|
23
|
+
uploadFile({ file, fileName, path: storagePath, metadata, bucket }: UploadFileProps): Promise<UploadFileResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Flatten nested metadata to string values (S3 requirement)
|
|
26
|
+
*/
|
|
27
|
+
private flattenMetadata;
|
|
28
|
+
getDownloadURL(storagePath: string, bucket?: string): Promise<DownloadConfig>;
|
|
29
|
+
getFile(storagePath: string, bucket?: string): Promise<File | null>;
|
|
30
|
+
deleteFile(storagePath: string, bucket?: string): Promise<void>;
|
|
31
|
+
list(storagePath: string, options?: {
|
|
32
|
+
bucket?: string;
|
|
33
|
+
maxResults?: number;
|
|
34
|
+
pageToken?: string;
|
|
35
|
+
}): Promise<StorageListResult>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage module for Rebase backend
|
|
3
|
+
*
|
|
4
|
+
* Provides file storage functionality with support for:
|
|
5
|
+
* - Local filesystem storage (default, zero config)
|
|
6
|
+
* - S3-compatible storage (AWS S3, MinIO)
|
|
7
|
+
*/
|
|
8
|
+
export * from './types';
|
|
9
|
+
export { LocalStorageController } from './LocalStorageController';
|
|
10
|
+
export { S3StorageController } from './S3StorageController';
|
|
11
|
+
export { createStorageRoutes } from './routes';
|
|
12
|
+
export type { StorageRoutesConfig } from './routes';
|
|
13
|
+
export * from './storage-registry';
|
|
14
|
+
import { BackendStorageConfig, StorageController } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Factory function to create a storage controller based on configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare function createStorageController(config: BackendStorageConfig): StorageController;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage REST API routes using Hono
|
|
3
|
+
*/
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
import { StorageController } from './types';
|
|
6
|
+
import { HonoEnv } from '../api/types';
|
|
7
|
+
export interface StorageRoutesConfig {
|
|
8
|
+
controller: StorageController;
|
|
9
|
+
/** Base path for storage routes (default: '/api/storage') */
|
|
10
|
+
basePath?: string;
|
|
11
|
+
/** Require authentication for write operations (default: true) */
|
|
12
|
+
requireAuth?: boolean;
|
|
13
|
+
/** Allow unauthenticated read access to stored files (default: false).
|
|
14
|
+
* When false and requireAuth is true, reads also require authentication. */
|
|
15
|
+
publicRead?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extract the wildcard portion of a route path from the full request path.
|
|
19
|
+
*
|
|
20
|
+
* Hono's `c.req.param('*')` does not work reliably in sub-routers mounted
|
|
21
|
+
* via `app.route(prefix, subRouter)`. Instead we derive the wildcard value
|
|
22
|
+
* from the fully-resolved `c.req.path` and `c.req.routePath`.
|
|
23
|
+
*
|
|
24
|
+
* For a route `/metadata/*` mounted at `/api/storage`, a request to
|
|
25
|
+
* `/api/storage/metadata/default/file.jpg` yields routePath
|
|
26
|
+
* `/api/storage/metadata/*`. We strip the prefix (everything before `/*`)
|
|
27
|
+
* plus one character for the trailing `/` to obtain `default/file.jpg`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractWildcardPath(c: {
|
|
30
|
+
req: {
|
|
31
|
+
path: string;
|
|
32
|
+
routePath: string;
|
|
33
|
+
};
|
|
34
|
+
}): string;
|
|
35
|
+
/**
|
|
36
|
+
* Create storage REST API routes
|
|
37
|
+
*/
|
|
38
|
+
export declare function createStorageRoutes(config: StorageRoutesConfig): Hono<HonoEnv>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Registry
|
|
3
|
+
*
|
|
4
|
+
* Manages multiple storage controllers for Rebase backend.
|
|
5
|
+
* Allows different storage backends for different use cases.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* - Single storage: Pass a single StorageController → maps to "(default)"
|
|
9
|
+
* - Multiple storages: Pass a map of { storageId: StorageController }
|
|
10
|
+
* - String properties use `storageId` in their config to specify which storage to use
|
|
11
|
+
* - Properties without `storageId` fallback to "(default)"
|
|
12
|
+
*/
|
|
13
|
+
import { StorageController } from "./types";
|
|
14
|
+
/**
|
|
15
|
+
* The default storage identifier used when:
|
|
16
|
+
* - A single storage controller is provided (not a map)
|
|
17
|
+
* - A property doesn't specify a storageId
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_STORAGE_ID = "(default)";
|
|
20
|
+
/**
|
|
21
|
+
* Registry for managing multiple storage controllers
|
|
22
|
+
*/
|
|
23
|
+
export interface StorageRegistry {
|
|
24
|
+
/**
|
|
25
|
+
* Register a storage controller with an ID
|
|
26
|
+
* @param id - Unique identifier for this storage (e.g., "media", "backups")
|
|
27
|
+
* @param controller - The StorageController instance
|
|
28
|
+
*/
|
|
29
|
+
register(id: string, controller: StorageController): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the default storage controller (id = "(default)")
|
|
32
|
+
* @throws Error if no default storage is registered
|
|
33
|
+
*/
|
|
34
|
+
getDefault(): StorageController;
|
|
35
|
+
/**
|
|
36
|
+
* Get a storage controller by ID
|
|
37
|
+
* @param id - Storage identifier, or undefined/null for default
|
|
38
|
+
* @returns The StorageController, or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
get(id: string | undefined | null): StorageController | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get a storage controller by ID, with fallback to default
|
|
43
|
+
* @param id - Storage identifier, or undefined/null for default
|
|
44
|
+
* @returns The StorageController (falls back to default if id not found)
|
|
45
|
+
* @throws Error if neither the specified nor default storage exists
|
|
46
|
+
*/
|
|
47
|
+
getOrDefault(id: string | undefined | null): StorageController;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a storage with the given ID exists
|
|
50
|
+
*/
|
|
51
|
+
has(id: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* List all registered storage IDs
|
|
54
|
+
*/
|
|
55
|
+
list(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Get the number of registered storage controllers
|
|
58
|
+
*/
|
|
59
|
+
size(): number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Default implementation of StorageRegistry
|
|
63
|
+
*/
|
|
64
|
+
export declare class DefaultStorageRegistry implements StorageRegistry {
|
|
65
|
+
private controllers;
|
|
66
|
+
/**
|
|
67
|
+
* Create a StorageRegistry from either a single controller or a map
|
|
68
|
+
* @param input - Single StorageController (maps to "(default)") or Record<string, StorageController>
|
|
69
|
+
*/
|
|
70
|
+
static create(input: StorageController | Record<string, StorageController>): DefaultStorageRegistry;
|
|
71
|
+
register(id: string, controller: StorageController): void;
|
|
72
|
+
getDefault(): StorageController;
|
|
73
|
+
get(id: string | undefined | null): StorageController | undefined;
|
|
74
|
+
getOrDefault(id: string | undefined | null): StorageController;
|
|
75
|
+
has(id: string): boolean;
|
|
76
|
+
list(): string[];
|
|
77
|
+
size(): number;
|
|
78
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage configuration and types for Rebase backend
|
|
3
|
+
*/
|
|
4
|
+
import { UploadFileProps, UploadFileResult, DownloadConfig, StorageListResult } from "@rebasepro/types";
|
|
5
|
+
/**
|
|
6
|
+
* Local filesystem storage configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface LocalStorageConfig {
|
|
9
|
+
type: 'local';
|
|
10
|
+
/** Base directory for file storage (e.g., './uploads') */
|
|
11
|
+
basePath: string;
|
|
12
|
+
/** Maximum file size in bytes (default: 50MB) */
|
|
13
|
+
maxFileSize?: number;
|
|
14
|
+
/** Allowed MIME types (if not set, all types allowed) */
|
|
15
|
+
allowedMimeTypes?: string[];
|
|
16
|
+
/** Base URL for generating download URLs (default: auto-detected from request) */
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* S3-compatible storage configuration (works with AWS S3 and MinIO)
|
|
21
|
+
*/
|
|
22
|
+
export interface S3StorageConfig {
|
|
23
|
+
type: 's3';
|
|
24
|
+
/** S3 bucket name */
|
|
25
|
+
bucket: string;
|
|
26
|
+
/** AWS region (e.g., 'us-east-1') */
|
|
27
|
+
region?: string;
|
|
28
|
+
/** Custom endpoint URL (required for MinIO) */
|
|
29
|
+
endpoint?: string;
|
|
30
|
+
/** AWS access key ID */
|
|
31
|
+
accessKeyId: string;
|
|
32
|
+
/** AWS secret access key */
|
|
33
|
+
secretAccessKey: string;
|
|
34
|
+
/** Use path-style URLs (required for MinIO) */
|
|
35
|
+
forcePathStyle?: boolean;
|
|
36
|
+
/** Maximum file size in bytes (default: 50MB) */
|
|
37
|
+
maxFileSize?: number;
|
|
38
|
+
/** Allowed MIME types (if not set, all types allowed) */
|
|
39
|
+
allowedMimeTypes?: string[];
|
|
40
|
+
/** URL expiration time in seconds for signed URLs (default: 3600) */
|
|
41
|
+
signedUrlExpiration?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Storage configuration - either local filesystem or S3-compatible
|
|
45
|
+
*/
|
|
46
|
+
export type BackendStorageConfig = LocalStorageConfig | S3StorageConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Storage controller interface for backend implementations
|
|
49
|
+
*/
|
|
50
|
+
export interface StorageController {
|
|
51
|
+
/**
|
|
52
|
+
* Upload a file
|
|
53
|
+
*/
|
|
54
|
+
uploadFile(props: UploadFileProps): Promise<UploadFileResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Get a download URL for a file
|
|
57
|
+
*/
|
|
58
|
+
getDownloadURL(path: string, bucket?: string): Promise<DownloadConfig>;
|
|
59
|
+
/**
|
|
60
|
+
* Get file as a File object
|
|
61
|
+
*/
|
|
62
|
+
getFile(path: string, bucket?: string): Promise<File | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete a file
|
|
65
|
+
*/
|
|
66
|
+
deleteFile(path: string, bucket?: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* List files in a path
|
|
69
|
+
*/
|
|
70
|
+
list(path: string, options?: {
|
|
71
|
+
bucket?: string;
|
|
72
|
+
maxResults?: number;
|
|
73
|
+
pageToken?: string;
|
|
74
|
+
}): Promise<StorageListResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Get the storage configuration type
|
|
77
|
+
*/
|
|
78
|
+
getType(): 'local' | 's3';
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Default maximum file size (50MB)
|
|
82
|
+
*/
|
|
83
|
+
export declare const DEFAULT_MAX_FILE_SIZE: number;
|
|
84
|
+
/**
|
|
85
|
+
* Common image MIME types
|
|
86
|
+
*/
|
|
87
|
+
export declare const IMAGE_MIME_TYPES: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Common document MIME types
|
|
90
|
+
*/
|
|
91
|
+
export declare const DOCUMENT_MIME_TYPES: string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Entity, FetchCollectionProps, FetchEntityProps } from "@rebasepro/types";
|
|
2
|
+
export interface ListenCollectionRequest<M extends Record<string, unknown> = Record<string, unknown>> extends FetchCollectionProps<M> {
|
|
3
|
+
subscriptionId: string;
|
|
4
|
+
onUpdate: (entities: Entity<M>[]) => void;
|
|
5
|
+
onError?: (error: Error) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface ListenEntityRequest<M extends Record<string, unknown> = Record<string, unknown>> extends FetchEntityProps<M> {
|
|
8
|
+
subscriptionId: string;
|
|
9
|
+
onUpdate: (entity: Entity<M> | null) => void;
|
|
10
|
+
onError?: (error: Error) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configure console log levels based on environment variable
|
|
3
|
+
* Call this early in your application to set up proper logging levels
|
|
4
|
+
*/
|
|
5
|
+
export declare function configureLogLevel(logLevel?: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Reset console methods to their original state
|
|
8
|
+
*/
|
|
9
|
+
export declare function resetConsole(): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SQL } from "drizzle-orm";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a SQL chunk calling `auth.uid()` — the current user's ID.
|
|
4
|
+
* This is a Supabase-style helper function created in the `auth` schema
|
|
5
|
+
* that reads `app.user_id` set per-transaction by `withAuth()`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* sql`${table.user_id} = ${authUid()}`
|
|
9
|
+
*/
|
|
10
|
+
export declare const authUid: () => SQL;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a SQL chunk calling `auth.roles()` — the current user's roles
|
|
13
|
+
* as a comma-separated string.
|
|
14
|
+
* Reads `app.user_roles` set per-transaction by `withAuth()`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* sql`auth.roles() ~ 'admin'`
|
|
18
|
+
*/
|
|
19
|
+
export declare const authRoles: () => SQL;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a SQL chunk calling `auth.jwt()` — the full JWT claims as JSONB.
|
|
22
|
+
* Reads `app.jwt` set per-transaction by `withAuth()`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* sql`auth.jwt()->>'sub'`
|
|
26
|
+
*/
|
|
27
|
+
export declare const authJwt: () => SQL;
|
|
@@ -0,0 +1,7 @@
|
|
|
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";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { StorageSource } from "./storage";
|
|
2
|
+
import { Role, User } from "../users";
|
|
3
|
+
import { RebaseData } from "./data";
|
|
4
|
+
/**
|
|
5
|
+
* Capabilities advertised by an auth provider.
|
|
6
|
+
* UI components use this to show/hide features dynamically
|
|
7
|
+
* (e.g. password reset, registration, session management).
|
|
8
|
+
* @group Hooks and utilities
|
|
9
|
+
*/
|
|
10
|
+
export interface AuthCapabilities {
|
|
11
|
+
emailPasswordLogin?: boolean;
|
|
12
|
+
googleLogin?: boolean;
|
|
13
|
+
registration?: boolean;
|
|
14
|
+
passwordReset?: boolean;
|
|
15
|
+
sessionManagement?: boolean;
|
|
16
|
+
profileUpdate?: boolean;
|
|
17
|
+
emailVerification?: boolean;
|
|
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: Role[]): 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 a Google ID token or trigger Google popup */
|
|
82
|
+
googleLogin?(idToken: string): Promise<void>;
|
|
83
|
+
/** Register a new user */
|
|
84
|
+
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
85
|
+
/** Skip login (for anonymous access if enabled) */
|
|
86
|
+
skipLogin?(): void;
|
|
87
|
+
/** Request password reset email */
|
|
88
|
+
forgotPassword?(email: string): Promise<void>;
|
|
89
|
+
/** Reset password using a token */
|
|
90
|
+
resetPassword?(token: string, password: string): Promise<void>;
|
|
91
|
+
/** Change password for the authenticated user */
|
|
92
|
+
changePassword?(oldPassword: string, newPassword: string): Promise<void>;
|
|
93
|
+
/** Update user profile */
|
|
94
|
+
updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Implement this function to allow access to specific users.
|
|
98
|
+
* @group Hooks and utilities
|
|
99
|
+
*/
|
|
100
|
+
export type Authenticator<USER extends User = User> = (props: {
|
|
101
|
+
/**
|
|
102
|
+
* Logged-in user or null
|
|
103
|
+
*/
|
|
104
|
+
user: USER | null;
|
|
105
|
+
/**
|
|
106
|
+
* AuthController
|
|
107
|
+
*/
|
|
108
|
+
authController: AuthController<USER>;
|
|
109
|
+
/**
|
|
110
|
+
* Unified data access API
|
|
111
|
+
*/
|
|
112
|
+
data: RebaseData;
|
|
113
|
+
/**
|
|
114
|
+
* Used storage implementation
|
|
115
|
+
*/
|
|
116
|
+
storageSource: StorageSource;
|
|
117
|
+
}) => boolean | Promise<boolean>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { User } from "../users";
|
|
2
|
+
import { RebaseData } from "./data";
|
|
3
|
+
/**
|
|
4
|
+
* Event type for authentication state changes
|
|
5
|
+
*/
|
|
6
|
+
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED';
|
|
7
|
+
/**
|
|
8
|
+
* Standard session interface representing an authenticated state
|
|
9
|
+
*/
|
|
10
|
+
export interface RebaseSession {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
user: User;
|
|
15
|
+
}
|
|
16
|
+
import { StorageSource } from "./storage";
|
|
17
|
+
/**
|
|
18
|
+
* Unified Authentication Client Interface
|
|
19
|
+
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
20
|
+
*/
|
|
21
|
+
export interface AuthClient {
|
|
22
|
+
/**
|
|
23
|
+
* Get the current user from the server or cache
|
|
24
|
+
*/
|
|
25
|
+
getUser(): Promise<User | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the currently active session
|
|
28
|
+
*/
|
|
29
|
+
getSession(): RebaseSession | null;
|
|
30
|
+
/**
|
|
31
|
+
* Sign out the current user and clear local session
|
|
32
|
+
*/
|
|
33
|
+
signOut(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to authentication state changes
|
|
36
|
+
*/
|
|
37
|
+
onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Manually refresh the session token
|
|
40
|
+
*/
|
|
41
|
+
refreshSession(): Promise<RebaseSession>;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Overarching abstraction that unites Data, Auth, and Storage.
|
|
46
|
+
* Adapters for Supabase or Firebase simply need to implement this interface.
|
|
47
|
+
*/
|
|
48
|
+
export interface RebaseClient<DB = any> {
|
|
49
|
+
/** Unified Data access layer */
|
|
50
|
+
data: RebaseData;
|
|
51
|
+
/** Unified Authentication layer */
|
|
52
|
+
auth: AuthClient;
|
|
53
|
+
/** Unified Storage layer */
|
|
54
|
+
storage?: StorageSource;
|
|
55
|
+
/** Optional admin panel specific tasks */
|
|
56
|
+
admin?: any;
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EntityCollection, EntityReference } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Controller that provides access to the registered entity collections.
|
|
4
|
+
* @group Models
|
|
5
|
+
*/
|
|
6
|
+
export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
7
|
+
/**
|
|
8
|
+
* List of the mapped collections in the CMS.
|
|
9
|
+
* Each entry relates to a collection in the root database.
|
|
10
|
+
* Each of the navigation entries in this field
|
|
11
|
+
* generates an entry in the main menu.
|
|
12
|
+
*/
|
|
13
|
+
collections?: EntityCollection[];
|
|
14
|
+
/**
|
|
15
|
+
* Is the registry ready to be used
|
|
16
|
+
*/
|
|
17
|
+
initialised: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get the collection configuration for a given path.
|
|
20
|
+
* The collection is resolved from the given path or alias.
|
|
21
|
+
*/
|
|
22
|
+
getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get the raw, un-normalized collection configuration.
|
|
25
|
+
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
26
|
+
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
27
|
+
*/
|
|
28
|
+
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve all the related parent references for a given path
|
|
31
|
+
* @param path
|
|
32
|
+
*/
|
|
33
|
+
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve all the related parent collection ids for a given path
|
|
36
|
+
* @param path
|
|
37
|
+
*/
|
|
38
|
+
getParentCollectionIds: (path: string) => string[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolve paths from a list of ids
|
|
41
|
+
* @param ids
|
|
42
|
+
*/
|
|
43
|
+
convertIdsToPaths: (ids: string[]) => string[];
|
|
44
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityLinkBuilder, Locale, EntityAction, EntityCustomView, RebasePlugin, PropertyConfig, SlotContribution } from "../types";
|
|
3
|
+
export type CustomizationController = {
|
|
4
|
+
/**
|
|
5
|
+
* Builder for generating utility links for entities
|
|
6
|
+
*/
|
|
7
|
+
entityLinkBuilder?: EntityLinkBuilder;
|
|
8
|
+
/**
|
|
9
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
10
|
+
*/
|
|
11
|
+
plugins?: RebasePlugin[];
|
|
12
|
+
/**
|
|
13
|
+
* Pre-merged slots from plugins + direct slot contributions.
|
|
14
|
+
*/
|
|
15
|
+
resolvedSlots: SlotContribution[];
|
|
16
|
+
/**
|
|
17
|
+
* List of additional custom views for entities.
|
|
18
|
+
* You can use the key to reference the custom view in
|
|
19
|
+
* the `entityViews` prop of a collection.
|
|
20
|
+
*
|
|
21
|
+
* You can also define an entity view from the UI.
|
|
22
|
+
*/
|
|
23
|
+
entityViews?: EntityCustomView[];
|
|
24
|
+
/**
|
|
25
|
+
* List of actions that can be performed on entities.
|
|
26
|
+
* These actions are displayed in the entity view and in the collection view.
|
|
27
|
+
* You can later reuse these actions in the `entityActions` prop of a collection,
|
|
28
|
+
* by specifying the `key` of the action.
|
|
29
|
+
*/
|
|
30
|
+
entityActions?: EntityAction[];
|
|
31
|
+
/**
|
|
32
|
+
* Format of the dates in the CMS.
|
|
33
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
34
|
+
*/
|
|
35
|
+
dateTimeFormat?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Locale of the CMS, currently only affecting dates
|
|
38
|
+
*/
|
|
39
|
+
locale?: Locale;
|
|
40
|
+
/**
|
|
41
|
+
* Record of custom form fields to be used in the CMS.
|
|
42
|
+
* You can use the key to reference the custom field in
|
|
43
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
44
|
+
*/
|
|
45
|
+
propertyConfigs: Record<string, PropertyConfig>;
|
|
46
|
+
components?: {
|
|
47
|
+
/**
|
|
48
|
+
* Component to render when a reference is missing
|
|
49
|
+
*/
|
|
50
|
+
missingReference?: React.ComponentType<{
|
|
51
|
+
path: string;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
};
|