@rebasepro/server-core 0.7.0 → 0.8.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/build-errors.txt +52 -0
- package/dist/api/ast-schema-editor.d.ts +21 -0
- package/dist/api/collections_for_test/callbacks_test_collection.d.ts +2 -0
- package/dist/api/errors.d.ts +53 -0
- package/dist/api/graphql/graphql-schema-generator.d.ts +44 -0
- package/dist/api/graphql/index.d.ts +1 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/api/logs-routes.d.ts +37 -0
- package/dist/api/openapi-generator.d.ts +16 -0
- package/dist/api/rest/api-generator.d.ts +76 -0
- package/dist/api/rest/index.d.ts +1 -0
- package/dist/api/rest/query-parser.d.ts +8 -0
- package/dist/api/schema-editor-routes.d.ts +3 -0
- package/dist/api/server.d.ts +40 -0
- package/dist/api/types.d.ts +104 -0
- package/dist/auth/adapter-middleware.d.ts +43 -0
- package/dist/auth/admin-roles-route.d.ts +18 -0
- package/dist/auth/admin-user-ops.d.ts +79 -0
- package/dist/auth/admin-users-route.d.ts +28 -0
- package/dist/auth/api-keys/api-key-middleware.d.ts +39 -0
- package/dist/auth/api-keys/api-key-permission-guard.d.ts +32 -0
- package/dist/auth/api-keys/api-key-routes.d.ts +20 -0
- package/dist/auth/api-keys/api-key-store.d.ts +35 -0
- package/dist/auth/api-keys/api-key-types.d.ts +96 -0
- package/dist/auth/api-keys/index.d.ts +17 -0
- package/dist/auth/apple-oauth.d.ts +30 -0
- package/dist/auth/auth-hooks.d.ts +242 -0
- package/dist/auth/bitbucket-oauth.d.ts +11 -0
- package/dist/auth/builtin-auth-adapter.d.ts +51 -0
- package/dist/auth/crypto-utils.d.ts +16 -0
- package/dist/auth/custom-auth-adapter.d.ts +39 -0
- package/dist/auth/discord-oauth.d.ts +14 -0
- package/dist/auth/facebook-oauth.d.ts +14 -0
- package/dist/auth/github-oauth.d.ts +15 -0
- package/dist/auth/gitlab-oauth.d.ts +13 -0
- package/dist/auth/google-oauth.d.ts +47 -0
- package/dist/auth/index.d.ts +37 -0
- package/dist/auth/interfaces.d.ts +431 -0
- package/dist/auth/jwt.d.ts +55 -0
- package/dist/auth/linkedin-oauth.d.ts +18 -0
- package/dist/auth/magic-link-routes.d.ts +30 -0
- package/dist/auth/mfa-crypto.d.ts +23 -0
- package/dist/auth/mfa-routes.d.ts +7 -0
- package/dist/auth/mfa.d.ts +49 -0
- package/dist/auth/microsoft-oauth.d.ts +16 -0
- package/dist/auth/middleware.d.ts +113 -0
- package/dist/auth/password.d.ts +22 -0
- package/dist/auth/rate-limiter.d.ts +50 -0
- package/dist/auth/reset-password-admin.d.ts +29 -0
- package/dist/auth/rls-scope.d.ts +31 -0
- package/dist/auth/routes.d.ts +35 -0
- package/dist/auth/session-routes.d.ts +27 -0
- package/dist/auth/slack-oauth.d.ts +12 -0
- package/dist/auth/spotify-oauth.d.ts +12 -0
- package/dist/auth/twitter-oauth.d.ts +18 -0
- package/dist/backend-CIxN4FVm.js +15 -0
- package/dist/backend-CIxN4FVm.js.map +1 -0
- package/dist/base64-js-C_frYBkI.js +1687 -0
- package/dist/base64-js-C_frYBkI.js.map +1 -0
- package/dist/chunk-Dze3rakg.js +42 -0
- package/dist/collections/BackendCollectionRegistry.d.ts +13 -0
- package/dist/collections/loader.d.ts +5 -0
- package/dist/cron/cron-loader.d.ts +17 -0
- package/dist/cron/cron-routes.d.ts +14 -0
- package/dist/cron/cron-scheduler.d.ts +106 -0
- package/dist/cron/cron-store.d.ts +32 -0
- package/dist/cron/index.d.ts +6 -0
- package/dist/db/interfaces.d.ts +18 -0
- package/dist/dist-DMO-zF6D.js +832 -0
- package/dist/dist-DMO-zF6D.js.map +1 -0
- package/dist/email/index.d.ts +6 -0
- package/dist/email/smtp-email-service.d.ts +25 -0
- package/dist/email/templates.d.ts +50 -0
- package/dist/email/types.d.ts +126 -0
- package/dist/env.d.ts +102 -0
- package/dist/from-VbwD7xRf.js +3849 -0
- package/dist/from-VbwD7xRf.js.map +1 -0
- package/dist/functions/define-function.d.ts +50 -0
- package/dist/functions/function-loader.d.ts +17 -0
- package/dist/functions/function-routes.d.ts +10 -0
- package/dist/functions/index.d.ts +5 -0
- package/dist/history/history-routes.d.ts +23 -0
- package/dist/history/index.d.ts +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.es.js +61322 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +103633 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/init/docs.d.ts +4 -0
- package/dist/init/health.d.ts +2 -0
- package/dist/init/middlewares.d.ts +10 -0
- package/dist/init/shutdown.d.ts +11 -0
- package/dist/init/storage.d.ts +5 -0
- package/dist/init.d.ts +314 -0
- package/dist/jws-BqRRaK11.js +616 -0
- package/dist/jws-BqRRaK11.js.map +1 -0
- package/dist/jwt-BETC8a1J.js +3560 -0
- package/dist/jwt-BETC8a1J.js.map +1 -0
- package/dist/logger-BYU66ENZ.js +94 -0
- package/dist/logger-BYU66ENZ.js.map +1 -0
- package/dist/ms-BeBSuOXN.js +125 -0
- package/dist/ms-BeBSuOXN.js.map +1 -0
- package/dist/multipart-parser-CedBDOeC.js +299 -0
- package/dist/multipart-parser-CedBDOeC.js.map +1 -0
- package/dist/serve-spa.d.ts +30 -0
- package/dist/services/driver-registry.d.ts +78 -0
- package/dist/services/routed-realtime-service.d.ts +43 -0
- package/dist/services/webhook-service.d.ts +29 -0
- package/dist/singleton.d.ts +35 -0
- package/dist/src-CB2PIpBe.js +1182 -0
- package/dist/src-CB2PIpBe.js.map +1 -0
- package/dist/src-DjzOT1kG.js +29746 -0
- package/dist/src-DjzOT1kG.js.map +1 -0
- package/dist/storage/GCSStorageController.d.ts +43 -0
- package/dist/storage/LocalStorageController.d.ts +46 -0
- package/dist/storage/S3StorageController.d.ts +36 -0
- package/dist/storage/image-transform.d.ts +50 -0
- package/dist/storage/index.d.ts +31 -0
- package/dist/storage/routes.d.ts +70 -0
- package/dist/storage/storage-registry.d.ts +78 -0
- package/dist/storage/tus-handler.d.ts +53 -0
- package/dist/storage/types.d.ts +128 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/utils/dev-port.d.ts +37 -0
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logging.d.ts +9 -0
- package/dist/utils/request-id.d.ts +4 -0
- package/dist/utils/request-logger.d.ts +19 -0
- package/dist/utils/sql.d.ts +27 -0
- package/package.json +22 -14
- package/src/api/graphql/graphql-schema-generator.ts +5 -5
- package/src/api/openapi-generator.ts +2 -2
- package/src/api/rest/api-generator.ts +44 -123
- package/src/api/rest/query-parser.ts +6 -23
- package/src/api/types.ts +2 -2
- package/src/auth/auth-hooks.ts +1 -1
- package/src/auth/builtin-auth-adapter.ts +1 -2
- package/src/auth/interfaces.ts +11 -2
- package/src/auth/middleware.ts +4 -4
- package/src/auth/routes.ts +1 -2
- package/src/functions/define-function.ts +59 -0
- package/src/functions/function-loader.ts +16 -0
- package/src/functions/index.ts +2 -0
- package/src/index.ts +70 -37
- package/src/init.ts +78 -21
- package/src/storage/GCSStorageController.ts +334 -0
- package/src/storage/index.ts +9 -3
- package/src/storage/routes.ts +191 -23
- package/src/storage/tus-handler.ts +16 -4
- package/src/storage/types.ts +25 -3
- package/test/api-generator.test.ts +1 -1
- package/test/auth-config-types.test.ts +40 -0
- package/test/define-function.test.ts +45 -0
- package/test/storage-routes.test.ts +160 -0
- package/test/backend-hooks-data.test.ts +0 -477
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { CronJobStatus, CronJobLogEntry } from "@rebasepro/types";
|
|
2
|
+
import type { RebaseClient } from "@rebasepro/types";
|
|
3
|
+
import type { LoadedCronJob } from "./cron-loader";
|
|
4
|
+
import type { CronStore } from "./cron-store";
|
|
5
|
+
/**
|
|
6
|
+
* Validates a standard 5-field cron expression structurally and semantically.
|
|
7
|
+
* Returns `{ valid: true }` or `{ valid: false, reason: string }`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateCronExpression(schedule: string): {
|
|
10
|
+
valid: true;
|
|
11
|
+
} | {
|
|
12
|
+
valid: false;
|
|
13
|
+
reason: string;
|
|
14
|
+
};
|
|
15
|
+
export declare class CronScheduler {
|
|
16
|
+
private jobs;
|
|
17
|
+
private started;
|
|
18
|
+
private store?;
|
|
19
|
+
private client?;
|
|
20
|
+
/**
|
|
21
|
+
* Set the RebaseClient instance to make it available to cron job handlers.
|
|
22
|
+
*/
|
|
23
|
+
setClient(client: RebaseClient): void;
|
|
24
|
+
/**
|
|
25
|
+
* Attach a persistence store for cron logs.
|
|
26
|
+
* When set, execution logs are written to the database after each run,
|
|
27
|
+
* and counters are seeded from the database on start.
|
|
28
|
+
*/
|
|
29
|
+
setStore(store: CronStore): void;
|
|
30
|
+
/**
|
|
31
|
+
* Register a batch of loaded cron jobs.
|
|
32
|
+
*
|
|
33
|
+
* If the scheduler is already started, newly registered jobs are
|
|
34
|
+
* automatically scheduled (so late-registered jobs don't sit idle).
|
|
35
|
+
*
|
|
36
|
+
* Validates the cron schedule on registration — invalid schedules
|
|
37
|
+
* are rejected with a warning and the job is NOT registered.
|
|
38
|
+
*/
|
|
39
|
+
registerJobs(loadedJobs: LoadedCronJob[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Start the scheduler — begins ticking all enabled jobs.
|
|
42
|
+
*/
|
|
43
|
+
start(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Stop the scheduler and clear all timers.
|
|
46
|
+
*
|
|
47
|
+
* Currently-executing handlers run to completion (they are async),
|
|
48
|
+
* but no further scheduling occurs after stop.
|
|
49
|
+
*/
|
|
50
|
+
stop(): void;
|
|
51
|
+
/**
|
|
52
|
+
* List all registered jobs with their current status.
|
|
53
|
+
*/
|
|
54
|
+
listJobs(): CronJobStatus[];
|
|
55
|
+
/**
|
|
56
|
+
* Get a single job status by ID.
|
|
57
|
+
*/
|
|
58
|
+
getJob(id: string): CronJobStatus | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Get log entries for a job.
|
|
61
|
+
*/
|
|
62
|
+
getJobLogs(id: string, limit?: number): CronJobLogEntry[];
|
|
63
|
+
/**
|
|
64
|
+
* Get log entries for a job from the database (if store is available).
|
|
65
|
+
* Falls back to in-memory logs if no store is configured.
|
|
66
|
+
*/
|
|
67
|
+
getJobLogsFromDb(id: string, limit?: number): Promise<CronJobLogEntry[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Enable or disable a job at runtime.
|
|
70
|
+
*/
|
|
71
|
+
setJobEnabled(id: string, enabled: boolean): CronJobStatus | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Manually trigger a job execution immediately.
|
|
74
|
+
*
|
|
75
|
+
* Returns `undefined` if the job doesn't exist.
|
|
76
|
+
* If the job is currently executing, returns the log entry with
|
|
77
|
+
* a `skipped: true` result rather than running concurrently.
|
|
78
|
+
*/
|
|
79
|
+
triggerJob(id: string): Promise<CronJobLogEntry | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Schedule the next execution for a job.
|
|
82
|
+
*
|
|
83
|
+
* Safety guarantees:
|
|
84
|
+
* 1. Clears any existing timer first (prevents leaked/duplicate timers)
|
|
85
|
+
* 2. Enforces a minimum delay to prevent tight loops from jitter
|
|
86
|
+
* 3. Unref's the timer so it doesn't prevent process exit
|
|
87
|
+
* 4. Re-checks enabled & started state before executing
|
|
88
|
+
* 5. Concurrency guard prevents overlapping handler executions
|
|
89
|
+
*/
|
|
90
|
+
private scheduleNext;
|
|
91
|
+
/**
|
|
92
|
+
* Stop a single job's timer and clear its next run state.
|
|
93
|
+
*/
|
|
94
|
+
private stopJob;
|
|
95
|
+
/**
|
|
96
|
+
* Execute a job's handler with full isolation and safety.
|
|
97
|
+
*
|
|
98
|
+
* - Sets a concurrency flag to prevent overlapping runs
|
|
99
|
+
* - Wraps handler in a timeout race
|
|
100
|
+
* - Captures all logs, errors, and results
|
|
101
|
+
* - Persists to store (non-blocking) if available
|
|
102
|
+
* - Always restores state even on catastrophic errors
|
|
103
|
+
*/
|
|
104
|
+
private executeJob;
|
|
105
|
+
private toStatus;
|
|
106
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CronJobLogEntry } from "@rebasepro/types";
|
|
2
|
+
import type { DataDriver } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* Persistence layer for cron job execution logs.
|
|
5
|
+
*
|
|
6
|
+
* Uses the DataDriver's `admin.executeSql` capability to store logs in a
|
|
7
|
+
* `rebase.cron_logs` table. Falls back gracefully if the driver doesn't
|
|
8
|
+
* support SQL (e.g. MongoDB) — in that case, no persistence occurs.
|
|
9
|
+
*/
|
|
10
|
+
export interface CronStore {
|
|
11
|
+
/** Ensure the backing table exists. Called once on startup. */
|
|
12
|
+
ensureTable(): Promise<void>;
|
|
13
|
+
/** Persist a single log entry after execution. */
|
|
14
|
+
insertLog(entry: CronJobLogEntry): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the most recent logs for a job.
|
|
17
|
+
* @param jobId The job identifier
|
|
18
|
+
* @param limit Max entries to return (default 50)
|
|
19
|
+
* @returns Logs sorted newest-first
|
|
20
|
+
*/
|
|
21
|
+
fetchLogs(jobId: string, limit?: number): Promise<CronJobLogEntry[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Fetch aggregate stats for all jobs (totalRuns, totalFailures, lastRunAt).
|
|
24
|
+
* Used to seed in-memory counters on startup.
|
|
25
|
+
*/
|
|
26
|
+
fetchJobStats(): Promise<Map<string, {
|
|
27
|
+
totalRuns: number;
|
|
28
|
+
totalFailures: number;
|
|
29
|
+
lastRunAt?: string;
|
|
30
|
+
}>>;
|
|
31
|
+
}
|
|
32
|
+
export declare function createCronStore(driver: DataDriver): CronStore | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { loadCronJobsFromDirectory } from "./cron-loader";
|
|
2
|
+
export type { LoadedCronJob } from "./cron-loader";
|
|
3
|
+
export { CronScheduler, validateCronExpression } from "./cron-scheduler";
|
|
4
|
+
export { createCronRoutes } from "./cron-routes";
|
|
5
|
+
export { createCronStore } from "./cron-store";
|
|
6
|
+
export type { CronStore } from "./cron-store";
|
|
@@ -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 };
|