@rebasepro/server-core 0.6.0 → 0.7.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/package.json +14 -14
- package/src/api/errors.ts +16 -2
- package/src/api/graphql/graphql-schema-generator.ts +45 -10
- package/src/api/rest/api-generator.ts +19 -2
- package/src/api/server.ts +10 -2
- package/src/api/types.ts +6 -0
- package/src/auth/adapter-middleware.ts +10 -2
- package/src/auth/admin-roles-route.ts +36 -0
- package/src/auth/admin-users-route.ts +302 -0
- package/src/auth/api-keys/api-key-middleware.ts +4 -3
- package/src/auth/api-keys/api-key-routes.ts +12 -2
- package/src/auth/api-keys/api-key-store.ts +83 -66
- package/src/auth/api-keys/api-key-types.ts +8 -0
- package/src/auth/apple-oauth.ts +2 -1
- package/src/auth/auth-hooks.ts +21 -0
- package/src/auth/bitbucket-oauth.ts +2 -1
- package/src/auth/builtin-auth-adapter.ts +28 -4
- package/src/auth/custom-auth-adapter.ts +2 -0
- package/src/auth/discord-oauth.ts +2 -1
- package/src/auth/facebook-oauth.ts +2 -1
- package/src/auth/github-oauth.ts +2 -1
- package/src/auth/gitlab-oauth.ts +2 -1
- package/src/auth/google-oauth.ts +8 -4
- package/src/auth/index.ts +2 -0
- package/src/auth/interfaces.ts +27 -0
- package/src/auth/linkedin-oauth.ts +2 -1
- package/src/auth/magic-link-routes.ts +167 -0
- package/src/auth/mfa-crypto.ts +91 -0
- package/src/auth/mfa-routes.ts +34 -10
- package/src/auth/microsoft-oauth.ts +2 -1
- package/src/auth/middleware.ts +10 -1
- package/src/auth/reset-password-admin.ts +17 -1
- package/src/auth/routes.ts +77 -8
- package/src/auth/session-routes.ts +15 -3
- package/src/auth/slack-oauth.ts +2 -1
- package/src/auth/spotify-oauth.ts +2 -1
- package/src/auth/twitter-oauth.ts +8 -1
- package/src/cron/cron-store.ts +25 -23
- package/src/email/index.ts +3 -2
- package/src/email/templates.ts +82 -0
- package/src/email/types.ts +16 -0
- package/src/init.ts +137 -5
- package/src/services/routed-realtime-service.ts +113 -0
- package/src/storage/routes.ts +4 -0
- package/src/utils/dev-port.ts +13 -7
- package/test/auth-routes.test.ts +54 -4
- package/test/custom-auth-adapter.test.ts +20 -1
- package/test/env.test.ts +9 -19
- package/test/multi-datasource-routing.test.ts +113 -0
- package/test/routed-realtime-service.test.ts +86 -0
- package/test/transform-auth-response.test.ts +305 -0
- package/vite.config.ts +5 -0
- package/build-errors.txt +0 -52
- package/dist/api/ast-schema-editor.d.ts +0 -21
- package/dist/api/collections_for_test/callbacks_test_collection.d.ts +0 -2
- package/dist/api/errors.d.ts +0 -53
- package/dist/api/graphql/graphql-schema-generator.d.ts +0 -35
- package/dist/api/graphql/index.d.ts +0 -1
- package/dist/api/index.d.ts +0 -9
- package/dist/api/logs-routes.d.ts +0 -37
- package/dist/api/openapi-generator.d.ts +0 -16
- package/dist/api/rest/api-generator.d.ts +0 -88
- package/dist/api/rest/index.d.ts +0 -1
- package/dist/api/rest/query-parser.d.ts +0 -11
- package/dist/api/schema-editor-routes.d.ts +0 -3
- package/dist/api/server.d.ts +0 -40
- package/dist/api/types.d.ts +0 -98
- package/dist/auth/adapter-middleware.d.ts +0 -37
- package/dist/auth/admin-user-ops.d.ts +0 -79
- package/dist/auth/api-keys/api-key-middleware.d.ts +0 -39
- package/dist/auth/api-keys/api-key-permission-guard.d.ts +0 -32
- package/dist/auth/api-keys/api-key-routes.d.ts +0 -20
- package/dist/auth/api-keys/api-key-store.d.ts +0 -35
- package/dist/auth/api-keys/api-key-types.d.ts +0 -88
- package/dist/auth/api-keys/index.d.ts +0 -17
- package/dist/auth/apple-oauth.d.ts +0 -30
- package/dist/auth/auth-hooks.d.ts +0 -225
- package/dist/auth/bitbucket-oauth.d.ts +0 -11
- package/dist/auth/builtin-auth-adapter.d.ts +0 -49
- package/dist/auth/crypto-utils.d.ts +0 -16
- package/dist/auth/custom-auth-adapter.d.ts +0 -39
- package/dist/auth/discord-oauth.d.ts +0 -14
- package/dist/auth/facebook-oauth.d.ts +0 -14
- package/dist/auth/github-oauth.d.ts +0 -15
- package/dist/auth/gitlab-oauth.d.ts +0 -13
- package/dist/auth/google-oauth.d.ts +0 -47
- package/dist/auth/index.d.ts +0 -36
- package/dist/auth/interfaces.d.ts +0 -401
- package/dist/auth/jwt.d.ts +0 -55
- package/dist/auth/linkedin-oauth.d.ts +0 -18
- package/dist/auth/mfa-routes.d.ts +0 -6
- package/dist/auth/mfa.d.ts +0 -49
- package/dist/auth/microsoft-oauth.d.ts +0 -16
- package/dist/auth/middleware.d.ts +0 -106
- package/dist/auth/password.d.ts +0 -22
- package/dist/auth/rate-limiter.d.ts +0 -50
- package/dist/auth/reset-password-admin.d.ts +0 -29
- package/dist/auth/rls-scope.d.ts +0 -31
- package/dist/auth/routes.d.ts +0 -33
- package/dist/auth/session-routes.d.ts +0 -25
- package/dist/auth/slack-oauth.d.ts +0 -12
- package/dist/auth/spotify-oauth.d.ts +0 -12
- package/dist/auth/twitter-oauth.d.ts +0 -18
- package/dist/backend-CIxN4FVm.js +0 -15
- package/dist/backend-CIxN4FVm.js.map +0 -1
- package/dist/chunk-Dze3rakg.js +0 -42
- package/dist/collections/BackendCollectionRegistry.d.ts +0 -13
- package/dist/collections/loader.d.ts +0 -5
- package/dist/cron/cron-loader.d.ts +0 -17
- package/dist/cron/cron-routes.d.ts +0 -14
- package/dist/cron/cron-scheduler.d.ts +0 -106
- package/dist/cron/cron-store.d.ts +0 -32
- package/dist/cron/index.d.ts +0 -6
- package/dist/db/interfaces.d.ts +0 -18
- package/dist/dist-CZKP-Xz4.js +0 -832
- package/dist/dist-CZKP-Xz4.js.map +0 -1
- package/dist/email/index.d.ts +0 -6
- package/dist/email/smtp-email-service.d.ts +0 -25
- package/dist/email/templates.d.ts +0 -42
- package/dist/email/types.d.ts +0 -108
- package/dist/env.d.ts +0 -102
- package/dist/from-VbwD7xRf.js +0 -3849
- package/dist/from-VbwD7xRf.js.map +0 -1
- package/dist/functions/function-loader.d.ts +0 -17
- package/dist/functions/function-routes.d.ts +0 -10
- package/dist/functions/index.d.ts +0 -3
- package/dist/history/history-routes.d.ts +0 -23
- package/dist/history/index.d.ts +0 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.es.js +0 -61726
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -73216
- package/dist/index.umd.js.map +0 -1
- package/dist/init/docs.d.ts +0 -4
- package/dist/init/health.d.ts +0 -2
- package/dist/init/middlewares.d.ts +0 -10
- package/dist/init/shutdown.d.ts +0 -11
- package/dist/init/storage.d.ts +0 -5
- package/dist/init.d.ts +0 -258
- package/dist/jwt-DHcQRGC3.js +0 -4168
- package/dist/jwt-DHcQRGC3.js.map +0 -1
- package/dist/logger-BYU66ENZ.js +0 -94
- package/dist/logger-BYU66ENZ.js.map +0 -1
- package/dist/ms-BeBSuOXN.js +0 -125
- package/dist/ms-BeBSuOXN.js.map +0 -1
- package/dist/multipart-parser-CedBDOeC.js +0 -299
- package/dist/multipart-parser-CedBDOeC.js.map +0 -1
- package/dist/serve-spa.d.ts +0 -30
- package/dist/services/driver-registry.d.ts +0 -78
- package/dist/services/webhook-service.d.ts +0 -29
- package/dist/singleton.d.ts +0 -35
- package/dist/src-COaj0G3P.js +0 -1182
- package/dist/src-COaj0G3P.js.map +0 -1
- package/dist/storage/LocalStorageController.d.ts +0 -46
- package/dist/storage/S3StorageController.d.ts +0 -36
- package/dist/storage/image-transform.d.ts +0 -50
- package/dist/storage/index.d.ts +0 -28
- package/dist/storage/routes.d.ts +0 -38
- package/dist/storage/storage-registry.d.ts +0 -78
- package/dist/storage/tus-handler.d.ts +0 -51
- package/dist/storage/types.d.ts +0 -103
- package/dist/types/index.d.ts +0 -11
- package/dist/utils/dev-port.d.ts +0 -35
- package/dist/utils/logger.d.ts +0 -31
- package/dist/utils/logging.d.ts +0 -9
- package/dist/utils/request-id.d.ts +0 -4
- package/dist/utils/request-logger.d.ts +0 -19
- package/dist/utils/sql.d.ts +0 -27
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface WebhookConfig {
|
|
2
|
-
id: string;
|
|
3
|
-
url: string;
|
|
4
|
-
secret?: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
events: string[];
|
|
7
|
-
table: string;
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface WebhookDeliveryResult {
|
|
11
|
-
webhookId: string;
|
|
12
|
-
event: string;
|
|
13
|
-
payload: Record<string, unknown>;
|
|
14
|
-
statusCode: number;
|
|
15
|
-
responseBody: string;
|
|
16
|
-
success: boolean;
|
|
17
|
-
attemptNumber: number;
|
|
18
|
-
}
|
|
19
|
-
export declare class WebhookDispatcher {
|
|
20
|
-
private webhooks;
|
|
21
|
-
private maxRetries;
|
|
22
|
-
private retryDelays;
|
|
23
|
-
/** Register webhooks to watch */
|
|
24
|
-
setWebhooks(webhooks: WebhookConfig[]): void;
|
|
25
|
-
/** Called when an entity changes — checks if any webhook matches */
|
|
26
|
-
onEntityChange(table: string, event: "INSERT" | "UPDATE" | "DELETE", entityId: string, entity: Record<string, unknown> | null, previousEntity?: Record<string, unknown> | null): Promise<WebhookDeliveryResult[]>;
|
|
27
|
-
private deliverWithRetry;
|
|
28
|
-
private deliver;
|
|
29
|
-
}
|
package/dist/singleton.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { RebaseClient } from "@rebasepro/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal Called once during server initialization to set the backing instance.
|
|
4
|
-
* This is invoked by `initializeRebaseBackend()` — never call it manually.
|
|
5
|
-
*/
|
|
6
|
-
export declare function _initRebase(client: RebaseClient): void;
|
|
7
|
-
/**
|
|
8
|
-
* @internal Allows overriding the underlying instance for unit testing.
|
|
9
|
-
* Throws an error if used in a non-test environment to prevent production abuse.
|
|
10
|
-
*/
|
|
11
|
-
export declare function _setRebaseMock(mockInstance: Partial<RebaseClient>): void;
|
|
12
|
-
/**
|
|
13
|
-
* @internal Resets the singleton instance, useful for afterEach() in test suites.
|
|
14
|
-
*/
|
|
15
|
-
export declare function _resetRebaseMock(): void;
|
|
16
|
-
/**
|
|
17
|
-
* The server-side Rebase singleton.
|
|
18
|
-
*
|
|
19
|
-
* Initialized automatically during server startup. Provides access to all
|
|
20
|
-
* app-scoped services: **data**, **auth**, **storage**, and **email**.
|
|
21
|
-
*
|
|
22
|
-
* `rebase.data` runs with **admin privileges** (no RLS). For user-scoped
|
|
23
|
-
* queries inside request handlers, continue using the handler's context
|
|
24
|
-
* or the RLS-scoped driver.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* import { rebase } from "@rebasepro/server-core";
|
|
29
|
-
*
|
|
30
|
-
* // In a Hono handler, cron job, hook, or service file:
|
|
31
|
-
* await rebase.email?.send({ to: "admin@co.com", subject: "Alert", html: "<p>Hi</p>" });
|
|
32
|
-
* const jobs = await rebase.data.jobs.find({ limit: 10 });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare const rebase: RebaseClient;
|