@rebasepro/server-core 0.6.1 → 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/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/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/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 -61731
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -73221
- 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
package/dist/storage/types.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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, Cloudflare R2, Hetzner Object Storage) */
|
|
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 — local filesystem or S3-compatible.
|
|
45
|
-
*
|
|
46
|
-
* **Built-in providers:**
|
|
47
|
-
* - `local` — Zero-config filesystem storage. Great for dev and single-server deployments (Hetzner, bare metal).
|
|
48
|
-
* - `s3` — Any S3-compatible provider. AWS S3, Cloudflare R2, MinIO, Hetzner Object Storage,
|
|
49
|
-
* Backblaze B2, DigitalOcean Spaces, and even GCS (via its S3-compatible interoperability API).
|
|
50
|
-
*
|
|
51
|
-
* **Custom providers:**
|
|
52
|
-
* For cloud-native storage (GCS, Azure Blob, etc.), implement the `StorageController`
|
|
53
|
-
* interface and pass the instance directly to the `storage` config.
|
|
54
|
-
*/
|
|
55
|
-
export type BackendStorageConfig = LocalStorageConfig | S3StorageConfig;
|
|
56
|
-
/**
|
|
57
|
-
* Storage controller interface for backend implementations
|
|
58
|
-
*/
|
|
59
|
-
export interface StorageController {
|
|
60
|
-
/**
|
|
61
|
-
* Upload an object
|
|
62
|
-
*/
|
|
63
|
-
putObject(props: UploadFileProps): Promise<UploadFileResult>;
|
|
64
|
-
/**
|
|
65
|
-
* Get a download URL (signed URL equivalent) for an object
|
|
66
|
-
*/
|
|
67
|
-
getSignedUrl(key: string, bucket?: string): Promise<DownloadConfig>;
|
|
68
|
-
/**
|
|
69
|
-
* Get object as a File
|
|
70
|
-
*/
|
|
71
|
-
getObject(key: string, bucket?: string): Promise<File | null>;
|
|
72
|
-
/**
|
|
73
|
-
* Delete an object
|
|
74
|
-
*/
|
|
75
|
-
deleteObject(key: string, bucket?: string): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* List objects in a prefix
|
|
78
|
-
*/
|
|
79
|
-
listObjects(prefix: string, options?: {
|
|
80
|
-
bucket?: string;
|
|
81
|
-
maxResults?: number;
|
|
82
|
-
pageToken?: string;
|
|
83
|
-
}): Promise<StorageListResult>;
|
|
84
|
-
/**
|
|
85
|
-
* Get the storage provider identifier.
|
|
86
|
-
*
|
|
87
|
-
* Built-in values are `'local'` and `'s3'`. Custom implementations
|
|
88
|
-
* should return their own identifier (e.g. `'gcs'`, `'azure'`).
|
|
89
|
-
*/
|
|
90
|
-
getType(): string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Default maximum file size (50MB)
|
|
94
|
-
*/
|
|
95
|
-
export declare const DEFAULT_MAX_FILE_SIZE: number;
|
|
96
|
-
/**
|
|
97
|
-
* Common image MIME types
|
|
98
|
-
*/
|
|
99
|
-
export declare const IMAGE_MIME_TYPES: string[];
|
|
100
|
-
/**
|
|
101
|
-
* Common document MIME types
|
|
102
|
-
*/
|
|
103
|
-
export declare const DOCUMENT_MIME_TYPES: string[];
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/utils/dev-port.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dev-mode port resolution utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides a `listen` wrapper that automatically retries the next port when
|
|
5
|
-
* the requested one is already in use, and writes the resolved port to a
|
|
6
|
-
* well-known temp file so the CLI / frontend can discover it.
|
|
7
|
-
*
|
|
8
|
-
* Port affinity: when a port file already exists (e.g. after a tsx watch
|
|
9
|
-
* restart), the saved port is tried FIRST so the backend stays on the same
|
|
10
|
-
* port the frontend was configured with.
|
|
11
|
-
*
|
|
12
|
-
* This module is dev-only and should never run in production.
|
|
13
|
-
*/
|
|
14
|
-
import type { Server } from "http";
|
|
15
|
-
/** Filename written next to the project `.env` so the CLI can read it. */
|
|
16
|
-
export declare const DEV_PORT_FILENAME = ".rebase-dev-port";
|
|
17
|
-
/**
|
|
18
|
-
* Try to `listen` on `startPort`. If the port is busy (`EADDRINUSE`), increment
|
|
19
|
-
* and retry up to `maxAttempts` times.
|
|
20
|
-
*
|
|
21
|
-
* When a port file already exists (written by a previous run), the saved port
|
|
22
|
-
* is tried first to maintain port affinity across tsx watch restarts.
|
|
23
|
-
*
|
|
24
|
-
* Resolves with the port that was actually bound.
|
|
25
|
-
*/
|
|
26
|
-
export declare function listenWithPortRetry(server: Server, startPort: number, options?: {
|
|
27
|
-
host?: string;
|
|
28
|
-
maxAttempts?: number;
|
|
29
|
-
/** Absolute path to write the resolved port file into. Defaults to `process.cwd()`. */
|
|
30
|
-
portFileDir?: string;
|
|
31
|
-
}): Promise<number>;
|
|
32
|
-
/**
|
|
33
|
-
* Clean up the dev port file and state file (call on graceful shutdown).
|
|
34
|
-
*/
|
|
35
|
-
export declare function cleanupDevPortFile(dir: string): void;
|
package/dist/utils/logger.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured Logger for Rebase Backend
|
|
3
|
-
*
|
|
4
|
-
* Outputs JSON lines when `NODE_ENV=production`, human-readable prefixed
|
|
5
|
-
* lines otherwise. Designed to work with Google Cloud Logging severity levels.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* import { logger } from "./utils/logger";
|
|
9
|
-
* logger.info("Server started", { port: 3001 });
|
|
10
|
-
* logger.error("Request failed", { path: "/api/test", error: err });
|
|
11
|
-
*/
|
|
12
|
-
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
13
|
-
export interface LogEntry {
|
|
14
|
-
severity: string;
|
|
15
|
-
message: string;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
export interface Logger {
|
|
20
|
-
debug(message: string, data?: Record<string, unknown>): void;
|
|
21
|
-
info(message: string, data?: Record<string, unknown>): void;
|
|
22
|
-
warn(message: string, data?: Record<string, unknown>): void;
|
|
23
|
-
error(message: string, data?: Record<string, unknown>): void;
|
|
24
|
-
child(defaultFields: Record<string, unknown>): Logger;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Singleton logger instance.
|
|
28
|
-
* In production: emits JSON lines with `severity`, `message`, `timestamp`.
|
|
29
|
-
* In development: emits human-readable prefixed lines.
|
|
30
|
-
*/
|
|
31
|
-
export declare const logger: Logger;
|
package/dist/utils/logging.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured HTTP request logging middleware for Hono.
|
|
3
|
-
*
|
|
4
|
-
* Logs every request with method, path, status code, latency, and
|
|
5
|
-
* content-length. In production, outputs JSON for Cloud Logging; in
|
|
6
|
-
* development, emits a coloured one-liner.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { requestLogger } from "@rebasepro/server-core";
|
|
11
|
-
* app.use("/*", requestLogger());
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
import type { MiddlewareHandler } from "hono";
|
|
15
|
-
export interface RequestLoggerOptions {
|
|
16
|
-
/** Paths to skip logging (e.g. "/health"). Supports exact match. */
|
|
17
|
-
skip?: string[];
|
|
18
|
-
}
|
|
19
|
-
export declare function requestLogger(options?: RequestLoggerOptions): MiddlewareHandler;
|
package/dist/utils/sql.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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;
|