@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,56 @@
|
|
|
1
|
+
import { MiddlewareHandler, Context } from "hono";
|
|
2
|
+
import { DataDriver } from "@rebasepro/types";
|
|
3
|
+
import { AccessTokenPayload } from "./jwt";
|
|
4
|
+
import { HonoEnv } from "../api/types";
|
|
5
|
+
/**
|
|
6
|
+
* Result from a custom auth validator.
|
|
7
|
+
* - `false`/`null`/`undefined` = not authenticated
|
|
8
|
+
* - `true` = authenticated as default user
|
|
9
|
+
* - object with `userId` or `uid` = authenticated with user info
|
|
10
|
+
*/
|
|
11
|
+
export type AuthResult = boolean | null | undefined | {
|
|
12
|
+
userId?: string;
|
|
13
|
+
uid?: string;
|
|
14
|
+
roles?: string[];
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Options for creating an auth middleware via createAuthMiddleware()
|
|
19
|
+
*/
|
|
20
|
+
export interface AuthMiddlewareOptions {
|
|
21
|
+
/** DataDriver to scope via withAuth() for RLS */
|
|
22
|
+
driver: DataDriver;
|
|
23
|
+
/** If true, return 401 when no valid token is present (default: false) */
|
|
24
|
+
requireAuth?: boolean;
|
|
25
|
+
/** Optional custom validator (for non-JWT auth, e.g. Firebase Auth) */
|
|
26
|
+
validator?: (c: Context<HonoEnv>) => Promise<AuthResult>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Express middleware that requires a valid JWT token
|
|
30
|
+
* Returns 401 if token is missing or invalid
|
|
31
|
+
*/
|
|
32
|
+
export declare const requireAuth: MiddlewareHandler<HonoEnv>;
|
|
33
|
+
/**
|
|
34
|
+
* Middleware that requires the user to have an admin or schema-admin role.
|
|
35
|
+
* Must be used AFTER requireAuth or on a route where user is guaranteed.
|
|
36
|
+
*/
|
|
37
|
+
export declare const requireAdmin: MiddlewareHandler<HonoEnv>;
|
|
38
|
+
/**
|
|
39
|
+
* Middleware that optionally extracts user from JWT
|
|
40
|
+
* Does not return 401 if token is missing - allows anonymous access
|
|
41
|
+
*/
|
|
42
|
+
export declare const optionalAuth: MiddlewareHandler<HonoEnv>;
|
|
43
|
+
/**
|
|
44
|
+
* Extract user from token - for WebSocket authentication
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractUserFromToken(token: string): AccessTokenPayload | null;
|
|
47
|
+
/**
|
|
48
|
+
* Create a configurable auth middleware that handles:
|
|
49
|
+
* 1. Token extraction (via custom validator or JWT Bearer token)
|
|
50
|
+
* 2. RLS-scoped DataDriver via withAuth()
|
|
51
|
+
* 3. Optional enforcement (401 when requireAuth is true and no user)
|
|
52
|
+
*
|
|
53
|
+
* This is the single source of truth for HTTP auth in Rebase.
|
|
54
|
+
* Use this instead of manually parsing tokens in route handlers.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createAuthMiddleware(options: AuthMiddlewareOptions): MiddlewareHandler<HonoEnv>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface PasswordValidationResult {
|
|
2
|
+
valid: boolean;
|
|
3
|
+
errors: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Password requirements:
|
|
7
|
+
* - Minimum 8 characters
|
|
8
|
+
* - At least 1 uppercase letter
|
|
9
|
+
* - At least 1 lowercase letter
|
|
10
|
+
* - At least 1 number
|
|
11
|
+
*/
|
|
12
|
+
export declare function validatePasswordStrength(password: string): PasswordValidationResult;
|
|
13
|
+
/**
|
|
14
|
+
* Hash a password using Node's built-in scrypt
|
|
15
|
+
* Returns format: salt:hash (both hex encoded)
|
|
16
|
+
*/
|
|
17
|
+
export declare function hashPassword(password: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Verify a password against a scrypt hash
|
|
20
|
+
* Expects format: salt:hash (both hex encoded)
|
|
21
|
+
*/
|
|
22
|
+
export declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MiddlewareHandler } from "hono";
|
|
2
|
+
import { HonoEnv } from "../api/types";
|
|
3
|
+
interface RateLimiterOptions {
|
|
4
|
+
/** Time window in milliseconds (default: 15 minutes) */
|
|
5
|
+
windowMs?: number;
|
|
6
|
+
/** Maximum requests per window (default: 100) */
|
|
7
|
+
limit?: number;
|
|
8
|
+
/** Key generator function. Defaults to IP-based keying. */
|
|
9
|
+
keyGenerator?: (c: Parameters<MiddlewareHandler<HonoEnv>>[0]) => string;
|
|
10
|
+
/** Custom message for rate limit responses */
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a rate-limiting middleware.
|
|
15
|
+
*
|
|
16
|
+
* Uses a sliding window algorithm: only timestamps within the last
|
|
17
|
+
* `windowMs` milliseconds are counted. Old entries are garbage-collected
|
|
18
|
+
* every `windowMs` to prevent unbounded memory growth.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRateLimiter(options?: RateLimiterOptions): MiddlewareHandler<HonoEnv>;
|
|
21
|
+
/**
|
|
22
|
+
* Pre-configured rate limiter for general auth endpoints (login, register).
|
|
23
|
+
* 20 requests per 15 minutes per IP.
|
|
24
|
+
*/
|
|
25
|
+
export declare const defaultAuthLimiter: MiddlewareHandler<HonoEnv>;
|
|
26
|
+
/**
|
|
27
|
+
* Pre-configured strict rate limiter for sensitive endpoints (password reset, verification).
|
|
28
|
+
* 5 requests per 15 minutes per IP.
|
|
29
|
+
*/
|
|
30
|
+
export declare const strictAuthLimiter: MiddlewareHandler<HonoEnv>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { AuthRepository } from "./interfaces";
|
|
3
|
+
import { EmailService, EmailConfig } from "../email";
|
|
4
|
+
import { HonoEnv } from "../api/types";
|
|
5
|
+
/**
|
|
6
|
+
* Shared configuration for auth and admin route factories.
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthModuleConfig {
|
|
9
|
+
authRepo: AuthRepository;
|
|
10
|
+
emailService?: EmailService;
|
|
11
|
+
emailConfig?: EmailConfig;
|
|
12
|
+
/** Allow new user registration (default: false). First user can always register for bootstrap. */
|
|
13
|
+
allowRegistration?: boolean;
|
|
14
|
+
/** Default role ID to assign to new users (default: none). The first user always gets "admin". */
|
|
15
|
+
defaultRole?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function createAuthRoutes(config: AuthModuleConfig): Hono<HonoEnv>;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CollectionRegistry } from "@rebasepro/common";
|
|
2
|
+
import { CollectionRegistryInterface } from "../db/interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Backend-agnostic collection registry.
|
|
5
|
+
* Satisfies CollectionRegistryInterface through inheritance from CollectionRegistry.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BackendCollectionRegistry extends CollectionRegistry implements CollectionRegistryInterface {
|
|
8
|
+
/**
|
|
9
|
+
* Get the available relation keys for a given collection path.
|
|
10
|
+
* Maps from the collection's relation property names to the relation names.
|
|
11
|
+
*/
|
|
12
|
+
getRelationKeysForCollection(collectionPath: string): string[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Abstraction Interfaces
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define the contracts that any database backend must implement
|
|
5
|
+
* to be used with Rebase. This allows for pluggable database backends like
|
|
6
|
+
* PostgreSQL, MongoDB, MySQL, etc.
|
|
7
|
+
*/
|
|
8
|
+
import { DatabaseConnection, QueryFilter, FetchCollectionOptions, SearchOptions, CountOptions, ConditionBuilder, ConditionBuilderStatic, EntityRepository, CollectionSubscriptionConfig, EntitySubscriptionConfig, RealtimeProvider, CollectionRegistryInterface, DataTransformer, BackendConfig, BackendInstance, BackendFactory } from "@rebasepro/types";
|
|
9
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
10
|
+
import { PgTransaction } from "drizzle-orm/pg-core";
|
|
11
|
+
/**
|
|
12
|
+
* Type representing either a direct database connection or a transaction.
|
|
13
|
+
* Used to allow services to operate within a transaction context.
|
|
14
|
+
* Note: `any` is intentional here — it represents a Drizzle client with
|
|
15
|
+
* a dynamic schema, enabling `db.query[tableName]` access without casts.
|
|
16
|
+
*/
|
|
17
|
+
export type DrizzleClient = NodePgDatabase<Record<string, unknown>> | PgTransaction<any, any, any>;
|
|
18
|
+
export type { DatabaseConnection, QueryFilter, FetchCollectionOptions, SearchOptions, CountOptions, ConditionBuilder, ConditionBuilderStatic, EntityRepository, CollectionSubscriptionConfig, EntitySubscriptionConfig, RealtimeProvider, CollectionRegistryInterface, DataTransformer, BackendConfig, BackendInstance, BackendFactory };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email module exports
|
|
3
|
+
*/
|
|
4
|
+
export type { EmailService, EmailSendOptions, SMTPConfig, EmailConfig, PasswordResetTemplateFunction, EmailVerificationTemplateFunction, UserInvitationTemplateFunction } from "./types";
|
|
5
|
+
export { SMTPEmailService, createEmailService } from "./smtp-email-service";
|
|
6
|
+
export { getPasswordResetTemplate, getEmailVerificationTemplate, getUserInvitationTemplate } from "./templates";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EmailService, EmailSendOptions, EmailConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* SMTP Email Service implementation using Nodemailer
|
|
4
|
+
*/
|
|
5
|
+
export declare class SMTPEmailService implements EmailService {
|
|
6
|
+
private transporter;
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: EmailConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Check if the email service is properly configured
|
|
11
|
+
*/
|
|
12
|
+
isConfigured(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Send an email using SMTP or custom send function
|
|
15
|
+
*/
|
|
16
|
+
send(options: EmailSendOptions): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Verify SMTP connection (useful for startup checks)
|
|
19
|
+
*/
|
|
20
|
+
verifyConnection(): Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create an email service from configuration
|
|
24
|
+
*/
|
|
25
|
+
export declare function createEmailService(config: EmailConfig): EmailService;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default email templates for authentication emails
|
|
3
|
+
*/
|
|
4
|
+
interface TemplateUser {
|
|
5
|
+
email: string;
|
|
6
|
+
displayName?: string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Default password reset email template
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPasswordResetTemplate(resetUrl: string, user: TemplateUser, appName?: string): {
|
|
12
|
+
subject: string;
|
|
13
|
+
html: string;
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Default email verification template
|
|
18
|
+
*/
|
|
19
|
+
export declare function getEmailVerificationTemplate(verifyUrl: string, user: TemplateUser, appName?: string): {
|
|
20
|
+
subject: string;
|
|
21
|
+
html: string;
|
|
22
|
+
text: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Default user invitation email template
|
|
26
|
+
* Sent when an admin creates a new user account
|
|
27
|
+
*/
|
|
28
|
+
export declare function getUserInvitationTemplate(setPasswordUrl: string, user: TemplateUser, appName?: string): {
|
|
29
|
+
subject: string;
|
|
30
|
+
html: string;
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email service types and interfaces
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Options for sending an email
|
|
6
|
+
*/
|
|
7
|
+
export interface EmailSendOptions {
|
|
8
|
+
to: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
html: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Email service interface - abstraction for sending emails
|
|
15
|
+
*/
|
|
16
|
+
export interface EmailService {
|
|
17
|
+
/**
|
|
18
|
+
* Send an email
|
|
19
|
+
*/
|
|
20
|
+
send(options: EmailSendOptions): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if the email service is properly configured
|
|
23
|
+
*/
|
|
24
|
+
isConfigured(): boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* SMTP server configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface SMTPConfig {
|
|
30
|
+
host: string;
|
|
31
|
+
port: number;
|
|
32
|
+
secure?: boolean;
|
|
33
|
+
auth?: {
|
|
34
|
+
user: string;
|
|
35
|
+
pass: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Template function for password reset emails
|
|
40
|
+
*/
|
|
41
|
+
export type PasswordResetTemplateFunction = (resetUrl: string, user: {
|
|
42
|
+
email: string;
|
|
43
|
+
displayName?: string | null;
|
|
44
|
+
}) => {
|
|
45
|
+
subject: string;
|
|
46
|
+
html: string;
|
|
47
|
+
text?: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Template function for email verification emails
|
|
51
|
+
*/
|
|
52
|
+
export type EmailVerificationTemplateFunction = (verifyUrl: string, user: {
|
|
53
|
+
email: string;
|
|
54
|
+
displayName?: string | null;
|
|
55
|
+
}) => {
|
|
56
|
+
subject: string;
|
|
57
|
+
html: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Template function for user invitation emails
|
|
62
|
+
*/
|
|
63
|
+
export type UserInvitationTemplateFunction = (setPasswordUrl: string, user: {
|
|
64
|
+
email: string;
|
|
65
|
+
displayName?: string | null;
|
|
66
|
+
}) => {
|
|
67
|
+
subject: string;
|
|
68
|
+
html: string;
|
|
69
|
+
text?: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Complete email configuration
|
|
73
|
+
*/
|
|
74
|
+
export interface EmailConfig {
|
|
75
|
+
/**
|
|
76
|
+
* From address for all emails (e.g., "noreply@example.com" or "MyApp <noreply@example.com>")
|
|
77
|
+
*/
|
|
78
|
+
from: string;
|
|
79
|
+
/**
|
|
80
|
+
* SMTP configuration for sending emails via SMTP server
|
|
81
|
+
*/
|
|
82
|
+
smtp?: SMTPConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Alternative: custom function to send emails
|
|
85
|
+
* Use this for custom email providers (AWS SES SDK, Resend, etc.)
|
|
86
|
+
*/
|
|
87
|
+
sendEmail?: (options: EmailSendOptions) => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Base URL for password reset links (e.g., "https://myapp.com")
|
|
90
|
+
* The reset link will be: {baseUrl}/reset-password?token={token}
|
|
91
|
+
*/
|
|
92
|
+
resetPasswordUrl?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Base URL for email verification links (e.g., "https://myapp.com")
|
|
95
|
+
* The verification link will be: {baseUrl}/verify-email?token={token}
|
|
96
|
+
*/
|
|
97
|
+
verifyEmailUrl?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Application name to use in email templates
|
|
100
|
+
*/
|
|
101
|
+
appName?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Custom email templates (optional - defaults are provided)
|
|
104
|
+
*/
|
|
105
|
+
templates?: {
|
|
106
|
+
passwordReset?: PasswordResetTemplateFunction;
|
|
107
|
+
emailVerification?: EmailVerificationTemplateFunction;
|
|
108
|
+
userInvitation?: UserInvitationTemplateFunction;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
export interface LoadedFunction {
|
|
3
|
+
/** Endpoint name derived from filename (e.g., "send-invoice") */
|
|
4
|
+
name: string;
|
|
5
|
+
/** The Hono sub-app to mount */
|
|
6
|
+
app: Hono<import("hono").Env>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Auto-discover Hono route files from a directory.
|
|
10
|
+
*
|
|
11
|
+
* Each file should default-export a Hono app (or router).
|
|
12
|
+
* The filename (without extension) becomes the mount path:
|
|
13
|
+
* `functions/send-invoice.ts` → mounted at `/send-invoice`
|
|
14
|
+
*
|
|
15
|
+
* This mirrors how `loadCollectionsFromDirectory` works for collections.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadFunctionsFromDirectory(directory: string): Promise<LoadedFunction[]>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { HonoEnv } from "../api/types";
|
|
3
|
+
import { LoadedFunction } from "./function-loader";
|
|
4
|
+
/**
|
|
5
|
+
* Mount all loaded function routes under a single Hono router.
|
|
6
|
+
*
|
|
7
|
+
* Each function is mounted at `/<function-name>`, preserving
|
|
8
|
+
* whatever HTTP methods and middleware the Hono sub-app defines.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createFunctionRoutes(functions: LoadedFunction[]): Hono<HonoEnv>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { HonoEnv } from "../api/types";
|
|
3
|
+
import { BackendCollectionRegistry } from "../collections/BackendCollectionRegistry";
|
|
4
|
+
import { DataDriver } from "@rebasepro/types";
|
|
5
|
+
/**
|
|
6
|
+
* Create Hono routes for entity history.
|
|
7
|
+
* Mounted at `{basePath}/data/:slug/:entityId/history`.
|
|
8
|
+
*/
|
|
9
|
+
export interface HistoryService {
|
|
10
|
+
fetchHistory(tableName: string, entityId: string, options: {
|
|
11
|
+
limit: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
data: any[];
|
|
15
|
+
total: number;
|
|
16
|
+
}>;
|
|
17
|
+
fetchHistoryEntry(historyId: string): Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createHistoryRoutes(params: {
|
|
20
|
+
historyService: HistoryService;
|
|
21
|
+
registry: BackendCollectionRegistry;
|
|
22
|
+
driver: DataDriver;
|
|
23
|
+
}): Hono<HonoEnv>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createHistoryRoutes } from "./history-routes";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rebasepro/server-core
|
|
3
|
+
*
|
|
4
|
+
* Database-Agnostic Backend Core for Rebase.
|
|
5
|
+
* This package provides the core backend services, generic driver routing,
|
|
6
|
+
* and API layers. Database implementations (e.g., PostgreSQL) are provided
|
|
7
|
+
* by specialized driver packages like `@rebasepro/server-postgresql`.
|
|
8
|
+
*/
|
|
9
|
+
export * from "./db/interfaces";
|
|
10
|
+
export * from "./auth/interfaces";
|
|
11
|
+
export * from "./init";
|
|
12
|
+
export * from "./services/driver-registry";
|
|
13
|
+
export * from "./api/types";
|
|
14
|
+
export * from "./api";
|
|
15
|
+
export * from "./types";
|
|
16
|
+
export * from "./types/index";
|
|
17
|
+
export * from "./auth";
|
|
18
|
+
export * from "./email";
|
|
19
|
+
export * from "./storage";
|
|
20
|
+
export * from "./utils/logging";
|
|
21
|
+
export * from "./utils/sql";
|
|
22
|
+
export * from "./history";
|
|
23
|
+
export * from "./functions";
|
|
24
|
+
export * from "./serve-spa";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DataDriver, EntityCollection, BackendBootstrapper, BootstrappedAuth, RealtimeProvider } from "@rebasepro/types";
|
|
2
|
+
import { BackendCollectionRegistry } from "./collections/BackendCollectionRegistry";
|
|
3
|
+
import { DriverRegistry } from "./services/driver-registry";
|
|
4
|
+
import { Server } from "http";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import { HonoEnv } from "./api/types";
|
|
7
|
+
import { BackendStorageConfig, StorageController, StorageRegistry } from "./storage";
|
|
8
|
+
import { EmailConfig } from "./email";
|
|
9
|
+
export interface RebaseAuthConfig {
|
|
10
|
+
jwtSecret?: string;
|
|
11
|
+
accessExpiresIn?: string;
|
|
12
|
+
refreshExpiresIn?: string;
|
|
13
|
+
requireAuth?: boolean;
|
|
14
|
+
allowRegistration?: boolean;
|
|
15
|
+
email?: EmailConfig;
|
|
16
|
+
google?: {
|
|
17
|
+
clientId: string;
|
|
18
|
+
};
|
|
19
|
+
defaultRole?: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface RebaseBackendConfig {
|
|
23
|
+
collections?: EntityCollection[];
|
|
24
|
+
collectionsDir?: string;
|
|
25
|
+
server: Server;
|
|
26
|
+
app: Hono<HonoEnv>;
|
|
27
|
+
basePath?: string;
|
|
28
|
+
bootstrappers: BackendBootstrapper[];
|
|
29
|
+
logging?: {
|
|
30
|
+
level?: "error" | "warn" | "info" | "debug";
|
|
31
|
+
};
|
|
32
|
+
auth?: RebaseAuthConfig;
|
|
33
|
+
storage?: BackendStorageConfig | Record<string, BackendStorageConfig>;
|
|
34
|
+
history?: unknown;
|
|
35
|
+
enableSwagger?: boolean;
|
|
36
|
+
functionsDir?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RebaseBackendInstance {
|
|
39
|
+
driverRegistry: DriverRegistry;
|
|
40
|
+
driver: DataDriver;
|
|
41
|
+
realtimeServices: Record<string, RealtimeProvider>;
|
|
42
|
+
realtimeService: RealtimeProvider;
|
|
43
|
+
auth?: BootstrappedAuth;
|
|
44
|
+
history?: unknown;
|
|
45
|
+
storageRegistry?: StorageRegistry;
|
|
46
|
+
storageController?: StorageController;
|
|
47
|
+
collectionRegistry: BackendCollectionRegistry;
|
|
48
|
+
}
|
|
49
|
+
export declare function initializeRebaseBackend(config: RebaseBackendConfig): Promise<RebaseBackendInstance>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for serving a Single Page Application
|
|
4
|
+
*/
|
|
5
|
+
export interface ServeSPAConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Absolute path to the frontend build directory
|
|
8
|
+
* @example path.join(__dirname, "../../frontend/dist")
|
|
9
|
+
*/
|
|
10
|
+
frontendPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* Base path for API routes (default: "/api")
|
|
13
|
+
* Requests to this path will be passed through to API handlers
|
|
14
|
+
*/
|
|
15
|
+
apiBasePath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Additional paths to exclude from SPA handling
|
|
18
|
+
* These paths will be passed through to other handlers
|
|
19
|
+
* @example ["/health", "/ws", "/metrics"]
|
|
20
|
+
*/
|
|
21
|
+
excludePaths?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Index file to serve for SPA routes (default: "index.html")
|
|
24
|
+
*/
|
|
25
|
+
indexFile?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Serve a Single Page Application from an Hono app.
|
|
29
|
+
*/
|
|
30
|
+
export declare function serveSPA<E extends import("hono").Env>(app: Hono<E>, config: ServeSPAConfig): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Driver Registry
|
|
3
|
+
*
|
|
4
|
+
* Manages multiple driver delegates for Rebase backend.
|
|
5
|
+
* Allows different databases for different collections.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* - Single DB: Pass a single DataDriver → maps to "(default)"
|
|
9
|
+
* - Multiple DBs: Pass a map of { dbId: DataDriver }
|
|
10
|
+
* - Collections use `databaseId` property to specify which driver to use
|
|
11
|
+
* - Collections without `databaseId` fallback to "(default)"
|
|
12
|
+
*/
|
|
13
|
+
import { DataDriver } from "@rebasepro/types";
|
|
14
|
+
/**
|
|
15
|
+
* The default driver identifier used when:
|
|
16
|
+
* - A single driver is provided (not a map)
|
|
17
|
+
* - A collection doesn't specify a databaseId
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_DRIVER_ID = "(default)";
|
|
20
|
+
/**
|
|
21
|
+
* Registry for managing multiple driver delegates
|
|
22
|
+
*/
|
|
23
|
+
export interface DriverRegistry {
|
|
24
|
+
/**
|
|
25
|
+
* Register a driver delegate with an ID
|
|
26
|
+
* @param id - Unique identifier for this driver (e.g., "analytics", "users")
|
|
27
|
+
* @param delegate - The DataDriver instance
|
|
28
|
+
*/
|
|
29
|
+
register(id: string, delegate: DataDriver): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the default driver delegate (id = "(default)")
|
|
32
|
+
* @throws Error if no default driver is registered
|
|
33
|
+
*/
|
|
34
|
+
getDefault(): DataDriver;
|
|
35
|
+
/**
|
|
36
|
+
* Get a driver delegate by ID
|
|
37
|
+
* @param id - Driver identifier, or undefined/null for default
|
|
38
|
+
* @returns The DataDriver, or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
get(id: string | undefined | null): DataDriver | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get a driver delegate by ID, with fallback to default
|
|
43
|
+
* @param id - Driver identifier, or undefined/null for default
|
|
44
|
+
* @returns The DataDriver (falls back to default if id not found)
|
|
45
|
+
* @throws Error if neither the specified nor default driver exists
|
|
46
|
+
*/
|
|
47
|
+
getOrDefault(id: string | undefined | null): DataDriver;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a driver with the given ID exists
|
|
50
|
+
*/
|
|
51
|
+
has(id: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* List all registered driver IDs
|
|
54
|
+
*/
|
|
55
|
+
list(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Get the number of registered drivers
|
|
58
|
+
*/
|
|
59
|
+
size(): number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Default implementation of DriverRegistry
|
|
63
|
+
*/
|
|
64
|
+
export declare class DefaultDriverRegistry implements DriverRegistry {
|
|
65
|
+
private delegates;
|
|
66
|
+
/**
|
|
67
|
+
* Create a DriverRegistry from either a single delegate or a map
|
|
68
|
+
* @param input - Single DataDriver (maps to "(default)") or Record<string, DataDriver>
|
|
69
|
+
*/
|
|
70
|
+
static create(input: DataDriver | Record<string, DataDriver>): DefaultDriverRegistry;
|
|
71
|
+
register(id: string, delegate: DataDriver): void;
|
|
72
|
+
getDefault(): DataDriver;
|
|
73
|
+
get(id: string | undefined | null): DataDriver | undefined;
|
|
74
|
+
getOrDefault(id: string | undefined | null): DataDriver;
|
|
75
|
+
has(id: string): boolean;
|
|
76
|
+
list(): string[];
|
|
77
|
+
size(): number;
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local filesystem storage controller
|
|
3
|
+
*/
|
|
4
|
+
import { StorageController, LocalStorageConfig } from './types';
|
|
5
|
+
import { UploadFileProps, UploadFileResult, DownloadConfig, StorageListResult } from '@rebasepro/types';
|
|
6
|
+
/**
|
|
7
|
+
* Local filesystem storage implementation
|
|
8
|
+
* Stores files in a directory structure: {basePath}/{bucket}/{path}
|
|
9
|
+
*/
|
|
10
|
+
export declare class LocalStorageController implements StorageController {
|
|
11
|
+
private config;
|
|
12
|
+
private basePath;
|
|
13
|
+
constructor(config: LocalStorageConfig);
|
|
14
|
+
getType(): 'local';
|
|
15
|
+
/**
|
|
16
|
+
* Ensure directory exists, creating it if necessary
|
|
17
|
+
*/
|
|
18
|
+
private ensureDir;
|
|
19
|
+
/**
|
|
20
|
+
* Get the full filesystem path for a storage path.
|
|
21
|
+
* Includes a path traversal guard to prevent escaping the base directory.
|
|
22
|
+
*/
|
|
23
|
+
private getFullPath;
|
|
24
|
+
/**
|
|
25
|
+
* Validate file before upload
|
|
26
|
+
*/
|
|
27
|
+
private validateFile;
|
|
28
|
+
uploadFile({ file, fileName, path: storagePath, metadata, bucket }: UploadFileProps): Promise<UploadFileResult>;
|
|
29
|
+
getDownloadURL(storagePath: string, bucket?: string): Promise<DownloadConfig>;
|
|
30
|
+
getFile(storagePath: string, bucket?: string): Promise<File | null>;
|
|
31
|
+
deleteFile(storagePath: string, bucket?: string): Promise<void>;
|
|
32
|
+
list(storagePath: string, options?: {
|
|
33
|
+
bucket?: string;
|
|
34
|
+
maxResults?: number;
|
|
35
|
+
pageToken?: string;
|
|
36
|
+
}): Promise<StorageListResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Get the absolute filesystem path for serving files
|
|
39
|
+
* Used by the storage routes to serve files directly
|
|
40
|
+
*/
|
|
41
|
+
getAbsolutePath(storagePath: string, bucket?: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the base path for the storage
|
|
44
|
+
*/
|
|
45
|
+
getBasePath(): string;
|
|
46
|
+
}
|