@rebasepro/server-core 0.7.0 → 0.9.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/README.md +2 -2
- 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/index.d.ts +7 -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 +68 -0
- package/{src/api/rest/index.ts → dist/api/rest/index.d.ts} +0 -1
- package/dist/api/rest/query-parser.d.ts +6 -0
- package/dist/api/schema-editor-routes.d.ts +3 -0
- package/dist/api/types.d.ts +56 -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/{src/auth/api-keys/api-key-permission-guard.ts → dist/auth/api-keys/api-key-permission-guard.d.ts} +2 -34
- 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/{src/auth/api-keys/api-key-types.ts → dist/auth/api-keys/api-key-types.d.ts} +0 -6
- package/{src/auth/api-keys/index.ts → dist/auth/api-keys/index.d.ts} +2 -22
- package/dist/auth/apple-oauth.d.ts +30 -0
- package/{src/auth/auth-hooks.ts → dist/auth/auth-hooks.d.ts} +15 -73
- package/dist/auth/bitbucket-oauth.d.ts +11 -0
- package/dist/auth/builtin-auth-adapter.d.ts +55 -0
- package/dist/auth/cookie-utils.d.ts +32 -0
- package/{src/auth/crypto-utils.ts → dist/auth/crypto-utils.d.ts} +1 -16
- 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/{src/auth/index.ts → dist/auth/index.d.ts} +4 -22
- package/{src/auth/interfaces.ts → dist/auth/interfaces.d.ts} +20 -89
- package/dist/auth/jwt.d.ts +67 -0
- package/dist/auth/linkedin-oauth.d.ts +18 -0
- package/dist/auth/magic-link-routes.d.ts +32 -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 +158 -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 +66 -0
- package/dist/auth/session-routes.d.ts +29 -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/collections/BackendCollectionRegistry.d.ts +13 -0
- package/dist/collections/loader.d.ts +5 -0
- package/dist/cron/cron-loader.d.ts +18 -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/define-cron.d.ts +28 -0
- package/{src/cron/index.ts → dist/cron/index.d.ts} +1 -0
- package/dist/db/interfaces.d.ts +18 -0
- package/dist/dynamic-import-Dvh-K5fl.js +22 -0
- package/dist/dynamic-import-Dvh-K5fl.js.map +1 -0
- package/dist/email/index.d.ts +6 -0
- package/dist/email/smtp-email-service.d.ts +30 -0
- package/dist/email/templates.d.ts +50 -0
- package/{src/email/types.ts → dist/email/types.d.ts} +40 -36
- package/dist/env.d.ts +102 -0
- package/dist/functions/define-function.d.ts +55 -0
- package/dist/functions/function-loader.d.ts +18 -0
- package/dist/functions/function-routes.d.ts +10 -0
- package/{src/functions/index.ts → dist/functions/index.d.ts} +2 -0
- package/dist/history/history-routes.d.ts +23 -0
- package/{src/history/index.ts → dist/history/index.d.ts} +0 -1
- package/dist/index.d.ts +35 -0
- package/dist/index.es.js +18184 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +48629 -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 +65 -0
- package/dist/init/storage.d.ts +5 -0
- package/dist/init.d.ts +344 -0
- package/dist/jwt-BwIn8xmk.js +4200 -0
- package/dist/jwt-BwIn8xmk.js.map +1 -0
- package/dist/logger-BYU66ENZ.js +94 -0
- package/dist/logger-BYU66ENZ.js.map +1 -0
- package/dist/ms-DnYXB-Wd.js +162 -0
- package/dist/ms-DnYXB-Wd.js.map +1 -0
- package/dist/openapi-generator-Z9oYWLf_.js +586 -0
- package/dist/openapi-generator-Z9oYWLf_.js.map +1 -0
- package/dist/schema-editor-routes-D3ef8zu1.js +219 -0
- package/dist/schema-editor-routes-D3ef8zu1.js.map +1 -0
- package/dist/serve-spa.d.ts +36 -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 +51 -0
- package/dist/src-B4OLmNVa.js +437 -0
- package/dist/src-B4OLmNVa.js.map +1 -0
- package/dist/src-B5WkP1Rv.js +24778 -0
- package/dist/src-B5WkP1Rv.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 +40 -0
- package/dist/storage/image-transform.d.ts +50 -0
- package/{src/storage/index.ts → dist/storage/index.d.ts} +6 -21
- 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/{src/storage/types.ts → dist/storage/types.d.ts} +32 -38
- package/dist/types/index.d.ts +11 -0
- package/dist/utils/dev-port.d.ts +45 -0
- package/dist/utils/dynamic-import.d.ts +25 -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/{src/utils/sql.ts → dist/utils/sql.d.ts} +5 -16
- package/package.json +49 -22
- package/coverage/clover.xml +0 -3739
- package/coverage/coverage-final.json +0 -31
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -266
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/api/ast-schema-editor.ts.html +0 -952
- package/coverage/lcov-report/src/api/errors.ts.html +0 -472
- package/coverage/lcov-report/src/api/graphql/graphql-schema-generator.ts.html +0 -1069
- package/coverage/lcov-report/src/api/graphql/index.html +0 -116
- package/coverage/lcov-report/src/api/index.html +0 -176
- package/coverage/lcov-report/src/api/openapi-generator.ts.html +0 -565
- package/coverage/lcov-report/src/api/rest/api-generator.ts.html +0 -994
- package/coverage/lcov-report/src/api/rest/index.html +0 -131
- package/coverage/lcov-report/src/api/rest/query-parser.ts.html +0 -550
- package/coverage/lcov-report/src/api/schema-editor-routes.ts.html +0 -202
- package/coverage/lcov-report/src/api/server.ts.html +0 -823
- package/coverage/lcov-report/src/auth/admin-routes.ts.html +0 -973
- package/coverage/lcov-report/src/auth/index.html +0 -176
- package/coverage/lcov-report/src/auth/jwt.ts.html +0 -574
- package/coverage/lcov-report/src/auth/middleware.ts.html +0 -745
- package/coverage/lcov-report/src/auth/password.ts.html +0 -310
- package/coverage/lcov-report/src/auth/services.ts.html +0 -2074
- package/coverage/lcov-report/src/collections/index.html +0 -116
- package/coverage/lcov-report/src/collections/loader.ts.html +0 -232
- package/coverage/lcov-report/src/db/auth-schema.ts.html +0 -523
- package/coverage/lcov-report/src/db/data-transformer.ts.html +0 -1753
- package/coverage/lcov-report/src/db/entityService.ts.html +0 -700
- package/coverage/lcov-report/src/db/index.html +0 -146
- package/coverage/lcov-report/src/db/services/EntityFetchService.ts.html +0 -4048
- package/coverage/lcov-report/src/db/services/EntityPersistService.ts.html +0 -883
- package/coverage/lcov-report/src/db/services/RelationService.ts.html +0 -3121
- package/coverage/lcov-report/src/db/services/entity-helpers.ts.html +0 -442
- package/coverage/lcov-report/src/db/services/index.html +0 -176
- package/coverage/lcov-report/src/db/services/index.ts.html +0 -124
- package/coverage/lcov-report/src/generate-drizzle-schema-logic.ts.html +0 -1960
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/services/driver-registry.ts.html +0 -631
- package/coverage/lcov-report/src/services/index.html +0 -131
- package/coverage/lcov-report/src/services/postgresDataDriver.ts.html +0 -3025
- package/coverage/lcov-report/src/storage/LocalStorageController.ts.html +0 -1189
- package/coverage/lcov-report/src/storage/S3StorageController.ts.html +0 -970
- package/coverage/lcov-report/src/storage/index.html +0 -161
- package/coverage/lcov-report/src/storage/storage-registry.ts.html +0 -646
- package/coverage/lcov-report/src/storage/types.ts.html +0 -451
- package/coverage/lcov-report/src/utils/drizzle-conditions.ts.html +0 -3082
- package/coverage/lcov-report/src/utils/index.html +0 -116
- package/coverage/lcov.info +0 -7179
- package/jest.config.cjs +0 -19
- package/src/api/ast-schema-editor.ts +0 -289
- package/src/api/collections_for_test/callbacks_test_collection.ts +0 -61
- package/src/api/errors.ts +0 -278
- package/src/api/graphql/graphql-schema-generator.ts +0 -383
- package/src/api/graphql/index.ts +0 -2
- package/src/api/index.ts +0 -11
- package/src/api/logs-routes.ts +0 -132
- package/src/api/openapi-generator.ts +0 -727
- package/src/api/rest/api-generator-count.test.ts +0 -126
- package/src/api/rest/api-generator.ts +0 -747
- package/src/api/rest/query-parser.ts +0 -300
- package/src/api/schema-editor-routes.ts +0 -41
- package/src/api/server.ts +0 -271
- package/src/api/types.ts +0 -104
- package/src/auth/adapter-middleware.ts +0 -114
- package/src/auth/admin-roles-route.ts +0 -36
- package/src/auth/admin-user-ops.ts +0 -236
- package/src/auth/admin-users-route.ts +0 -302
- package/src/auth/api-keys/api-key-middleware.ts +0 -133
- package/src/auth/api-keys/api-key-routes.ts +0 -193
- package/src/auth/api-keys/api-key-store.ts +0 -340
- package/src/auth/apple-oauth.ts +0 -122
- package/src/auth/bitbucket-oauth.ts +0 -84
- package/src/auth/builtin-auth-adapter.ts +0 -380
- package/src/auth/custom-auth-adapter.ts +0 -86
- package/src/auth/discord-oauth.ts +0 -85
- package/src/auth/facebook-oauth.ts +0 -74
- package/src/auth/github-oauth.ts +0 -112
- package/src/auth/gitlab-oauth.ts +0 -72
- package/src/auth/google-oauth.ts +0 -223
- package/src/auth/jwt.ts +0 -208
- package/src/auth/linkedin-oauth.ts +0 -83
- package/src/auth/magic-link-routes.ts +0 -167
- package/src/auth/mfa-crypto.ts +0 -91
- package/src/auth/mfa-routes.ts +0 -323
- package/src/auth/mfa.ts +0 -161
- package/src/auth/microsoft-oauth.ts +0 -90
- package/src/auth/middleware.ts +0 -369
- package/src/auth/password.ts +0 -77
- package/src/auth/rate-limiter.ts +0 -225
- package/src/auth/reset-password-admin.ts +0 -160
- package/src/auth/rls-scope.ts +0 -58
- package/src/auth/routes.ts +0 -802
- package/src/auth/session-routes.ts +0 -353
- package/src/auth/slack-oauth.ts +0 -73
- package/src/auth/spotify-oauth.ts +0 -69
- package/src/auth/twitter-oauth.ts +0 -128
- package/src/collections/BackendCollectionRegistry.ts +0 -20
- package/src/collections/loader.ts +0 -50
- package/src/cron/cron-loader.ts +0 -84
- package/src/cron/cron-routes.test.ts +0 -265
- package/src/cron/cron-routes.ts +0 -85
- package/src/cron/cron-scheduler.test.ts +0 -559
- package/src/cron/cron-scheduler.ts +0 -581
- package/src/cron/cron-store.ts +0 -166
- package/src/db/interfaces.ts +0 -60
- package/src/email/index.ts +0 -19
- package/src/email/smtp-email-service.ts +0 -123
- package/src/email/templates.ts +0 -470
- package/src/env.ts +0 -227
- package/src/functions/function-loader.ts +0 -116
- package/src/functions/function-routes.ts +0 -31
- package/src/history/history-routes.ts +0 -129
- package/src/index.ts +0 -70
- package/src/init/docs.ts +0 -47
- package/src/init/health.ts +0 -37
- package/src/init/middlewares.ts +0 -61
- package/src/init/shutdown.ts +0 -56
- package/src/init/storage.ts +0 -57
- package/src/init.ts +0 -1041
- package/src/serve-spa.ts +0 -89
- package/src/services/driver-registry.ts +0 -183
- package/src/services/routed-realtime-service.ts +0 -113
- package/src/services/webhook-service.ts +0 -155
- package/src/singleton.ts +0 -70
- package/src/storage/LocalStorageController.ts +0 -389
- package/src/storage/S3StorageController.ts +0 -300
- package/src/storage/image-transform.ts +0 -218
- package/src/storage/routes.ts +0 -368
- package/src/storage/storage-registry.ts +0 -188
- package/src/storage/tus-handler.ts +0 -315
- package/src/types/index.ts +0 -27
- package/src/utils/dev-port.ts +0 -196
- package/src/utils/logger.ts +0 -143
- package/src/utils/logging.ts +0 -40
- package/src/utils/request-id.ts +0 -40
- package/src/utils/request-logger.ts +0 -72
- package/test/api-generator.test.ts +0 -588
- package/test/api-key-permission-guard.test.ts +0 -144
- package/test/ast-schema-editor.test.ts +0 -89
- package/test/auth-middleware-hono.test.ts +0 -556
- package/test/auth-routes.test.ts +0 -1098
- package/test/backend-hooks-data.test.ts +0 -477
- package/test/custom-auth-adapter.test.ts +0 -189
- package/test/driver-registry.test.ts +0 -282
- package/test/email-templates.test.ts +0 -174
- package/test/env.test.ts +0 -128
- package/test/error-propagation.test.ts +0 -226
- package/test/errors-hono.test.ts +0 -133
- package/test/errors.test.ts +0 -155
- package/test/function-loader.test.ts +0 -127
- package/test/graphql-schema-generator.test.ts +0 -554
- package/test/jwt-security.test.ts +0 -182
- package/test/jwt.test.ts +0 -326
- package/test/mfa.test.ts +0 -197
- package/test/middleware.test.ts +0 -305
- package/test/multi-datasource-routing.test.ts +0 -113
- package/test/password.test.ts +0 -165
- package/test/query-parser.test.ts +0 -233
- package/test/rate-limiter.test.ts +0 -102
- package/test/reset-password-admin.test.ts +0 -113
- package/test/routed-realtime-service.test.ts +0 -86
- package/test/safe-compare.test.ts +0 -66
- package/test/singleton.test.ts +0 -59
- package/test/smtp-email-service.test.ts +0 -169
- package/test/storage-local.test.ts +0 -271
- package/test/storage-registry.test.ts +0 -282
- package/test/storage-routes.test.ts +0 -222
- package/test/storage-s3.test.ts +0 -304
- package/test/transform-auth-response.test.ts +0 -305
- package/test/webhook-service.test.ts +0 -260
- package/tsconfig.json +0 -54
- package/tsconfig.prod.json +0 -23
- package/vite.config.ts +0 -86
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CronJobDefinition } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Typed authoring helper for a cron job file. Identity at runtime —
|
|
4
|
+
* a plain default-exported {@link CronJobDefinition} works identically;
|
|
5
|
+
* this adds type inference and autocomplete.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link defineFunction} for the equivalent custom-functions helper.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { defineCron } from "@rebasepro/server-core";
|
|
12
|
+
*
|
|
13
|
+
* export default defineCron({
|
|
14
|
+
* name: "Nightly cleanup",
|
|
15
|
+
* schedule: "0 3 * * *",
|
|
16
|
+
* async handler({ client, log }) {
|
|
17
|
+
* const { data: expired } = await client.data.sessions.find({
|
|
18
|
+
* where: { expired: ["==", true] },
|
|
19
|
+
* });
|
|
20
|
+
* for (const session of expired) {
|
|
21
|
+
* await client.data.sessions.delete(session.id);
|
|
22
|
+
* }
|
|
23
|
+
* log(`Deleted ${expired.length} expired sessions`);
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function defineCron(definition: CronJobDefinition): CronJobDefinition;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { loadCronJobsFromDirectory } from "./cron-loader";
|
|
2
2
|
export type { LoadedCronJob } from "./cron-loader";
|
|
3
|
+
export { defineCron } from "./define-cron";
|
|
3
4
|
export { CronScheduler, validateCronExpression } from "./cron-scheduler";
|
|
4
5
|
export { createCronRoutes } from "./cron-routes";
|
|
5
6
|
export { createCronStore } 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, DataRepository, CollectionSubscriptionConfig, SingleSubscriptionConfig, 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, DataRepository, CollectionSubscriptionConfig, SingleSubscriptionConfig, RealtimeProvider, CollectionRegistryInterface, DataTransformer, BackendConfig, BackendInstance, BackendFactory };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
import "process";
|
|
3
|
+
__createRequire(import.meta.url);
|
|
4
|
+
//#region src/utils/dynamic-import.ts
|
|
5
|
+
/**
|
|
6
|
+
* Native ESM dynamic import.
|
|
7
|
+
*
|
|
8
|
+
* Wrapped in `new Function` so TypeScript / bundlers don't down-compile the
|
|
9
|
+
* `import()` to `require()` — the loaders must import user-authored `.ts`/`.js`
|
|
10
|
+
* files at runtime using the host's real ESM loader. This is the production
|
|
11
|
+
* default for {@link loadFunctionsFromDirectory} / {@link loadCronJobsFromDirectory}.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
var nativeDynamicImport = (() => {
|
|
16
|
+
const doImport = new Function("url", "return import(url)");
|
|
17
|
+
return (url) => doImport(url);
|
|
18
|
+
})();
|
|
19
|
+
//#endregion
|
|
20
|
+
export { nativeDynamicImport as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=dynamic-import-Dvh-K5fl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-import-Dvh-K5fl.js","names":[],"sources":["../src/utils/dynamic-import.ts"],"sourcesContent":["/**\n * Shape returned by a dynamic module import: an object whose `default`\n * property holds the module's default export (CJS `module.exports` is exposed\n * as `default` by Node's ESM interop).\n */\nexport interface ImportedModule {\n default?: unknown;\n [key: string]: unknown;\n}\n\n/**\n * Imports a module by file URL. Injected into the directory loaders so tests\n * can supply a deterministic importer.\n */\nexport type ModuleImporter = (url: string) => Promise<ImportedModule>;\n\n/**\n * Native ESM dynamic import.\n *\n * Wrapped in `new Function` so TypeScript / bundlers don't down-compile the\n * `import()` to `require()` — the loaders must import user-authored `.ts`/`.js`\n * files at runtime using the host's real ESM loader. This is the production\n * default for {@link loadFunctionsFromDirectory} / {@link loadCronJobsFromDirectory}.\n *\n * @internal\n */\nexport const nativeDynamicImport: ModuleImporter = (() => {\n const doImport = new Function(\"url\", \"return import(url)\") as (url: string) => Promise<ImportedModule>;\n return (url: string) => doImport(url);\n})();\n"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAa,6BAA6C;CACtD,MAAM,WAAW,IAAI,SAAS,OAAO,oBAAoB;CACzD,QAAQ,QAAgB,SAAS,GAAG;AACxC,GAAG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email module exports
|
|
3
|
+
*/
|
|
4
|
+
export type { EmailService, EmailSendOptions, SMTPConfig, EmailConfig, PasswordResetTemplateFunction, EmailVerificationTemplateFunction, UserInvitationTemplateFunction, WelcomeEmailTemplateFunction, MagicLinkTemplateFunction } from "./types";
|
|
5
|
+
export { SMTPEmailService, createEmailService } from "./smtp-email-service";
|
|
6
|
+
export { getPasswordResetTemplate, getEmailVerificationTemplate, getUserInvitationTemplate, getWelcomeEmailTemplate, getMagicLinkTemplate } from "./templates";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EmailConfig, EmailSendOptions, EmailService } 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
|
+
private _initialized;
|
|
9
|
+
constructor(config: EmailConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Lazily initialize the SMTP transporter on first use
|
|
12
|
+
*/
|
|
13
|
+
private ensureTransporter;
|
|
14
|
+
/**
|
|
15
|
+
* Check if the email service is properly configured
|
|
16
|
+
*/
|
|
17
|
+
isConfigured(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Send an email using SMTP or custom send function
|
|
20
|
+
*/
|
|
21
|
+
send(options: EmailSendOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Verify SMTP connection (useful for startup checks)
|
|
24
|
+
*/
|
|
25
|
+
verifyConnection(): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create an email service from configuration
|
|
29
|
+
*/
|
|
30
|
+
export declare function createEmailService(config: EmailConfig): EmailService;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
/**
|
|
34
|
+
* Default welcome email template
|
|
35
|
+
* Sent automatically when a new user registers
|
|
36
|
+
*/
|
|
37
|
+
export declare function getWelcomeEmailTemplate(user: TemplateUser, appName?: string, loginUrl?: string): {
|
|
38
|
+
subject: string;
|
|
39
|
+
html: string;
|
|
40
|
+
text: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Default magic link email template
|
|
44
|
+
*/
|
|
45
|
+
export declare function getMagicLinkTemplate(magicLinkUrl: string, user: TemplateUser, appName?: string): {
|
|
46
|
+
subject: string;
|
|
47
|
+
html: string;
|
|
48
|
+
text: string;
|
|
49
|
+
};
|
|
50
|
+
export {};
|
|
@@ -6,11 +6,8 @@
|
|
|
6
6
|
* This file re-exports them for backward compatibility and adds server-specific
|
|
7
7
|
* config types (SMTP, template functions, etc.).
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
9
|
import type { EmailService, EmailSendOptions } from "@rebasepro/types";
|
|
11
|
-
|
|
12
10
|
export type { EmailService, EmailSendOptions };
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* SMTP server configuration
|
|
16
13
|
*/
|
|
@@ -24,47 +21,61 @@ export interface SMTPConfig {
|
|
|
24
21
|
};
|
|
25
22
|
name?: string;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
25
|
* Template function for password reset emails
|
|
30
26
|
*/
|
|
31
|
-
export type PasswordResetTemplateFunction = (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
) => {
|
|
35
|
-
|
|
27
|
+
export type PasswordResetTemplateFunction = (resetUrl: string, user: {
|
|
28
|
+
email: string;
|
|
29
|
+
displayName?: string | null;
|
|
30
|
+
}) => {
|
|
31
|
+
subject: string;
|
|
32
|
+
html: string;
|
|
33
|
+
text?: string;
|
|
34
|
+
};
|
|
36
35
|
/**
|
|
37
36
|
* Template function for email verification emails
|
|
38
37
|
*/
|
|
39
|
-
export type EmailVerificationTemplateFunction = (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
) => {
|
|
43
|
-
|
|
38
|
+
export type EmailVerificationTemplateFunction = (verifyUrl: string, user: {
|
|
39
|
+
email: string;
|
|
40
|
+
displayName?: string | null;
|
|
41
|
+
}) => {
|
|
42
|
+
subject: string;
|
|
43
|
+
html: string;
|
|
44
|
+
text?: string;
|
|
45
|
+
};
|
|
44
46
|
/**
|
|
45
47
|
* Template function for user invitation emails
|
|
46
48
|
*/
|
|
47
|
-
export type UserInvitationTemplateFunction = (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
) => {
|
|
51
|
-
|
|
49
|
+
export type UserInvitationTemplateFunction = (setPasswordUrl: string, user: {
|
|
50
|
+
email: string;
|
|
51
|
+
displayName?: string | null;
|
|
52
|
+
}) => {
|
|
53
|
+
subject: string;
|
|
54
|
+
html: string;
|
|
55
|
+
text?: string;
|
|
56
|
+
};
|
|
52
57
|
/**
|
|
53
58
|
* Template function for welcome emails sent after registration
|
|
54
59
|
*/
|
|
55
|
-
export type WelcomeEmailTemplateFunction = (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
export type WelcomeEmailTemplateFunction = (user: {
|
|
61
|
+
email: string;
|
|
62
|
+
displayName?: string | null;
|
|
63
|
+
}, appName: string) => {
|
|
64
|
+
subject: string;
|
|
65
|
+
html: string;
|
|
66
|
+
text?: string;
|
|
67
|
+
};
|
|
60
68
|
/**
|
|
61
69
|
* Template function for magic link emails
|
|
62
70
|
*/
|
|
63
|
-
export type MagicLinkTemplateFunction = (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
) => {
|
|
67
|
-
|
|
71
|
+
export type MagicLinkTemplateFunction = (magicLinkUrl: string, user: {
|
|
72
|
+
email: string;
|
|
73
|
+
displayName?: string | null;
|
|
74
|
+
}) => {
|
|
75
|
+
subject: string;
|
|
76
|
+
html: string;
|
|
77
|
+
text?: string;
|
|
78
|
+
};
|
|
68
79
|
/**
|
|
69
80
|
* Complete email configuration
|
|
70
81
|
*/
|
|
@@ -73,42 +84,35 @@ export interface EmailConfig {
|
|
|
73
84
|
* From address for all emails (e.g., "noreply@example.com" or "MyApp <noreply@example.com>")
|
|
74
85
|
*/
|
|
75
86
|
from: string;
|
|
76
|
-
|
|
77
87
|
/**
|
|
78
88
|
* SMTP configuration for sending emails via SMTP server
|
|
79
89
|
*/
|
|
80
90
|
smtp?: SMTPConfig;
|
|
81
|
-
|
|
82
91
|
/**
|
|
83
92
|
* Alternative: custom function to send emails
|
|
84
93
|
* Use this for custom email providers (AWS SES SDK, Resend, etc.)
|
|
85
94
|
*/
|
|
86
95
|
sendEmail?: (options: EmailSendOptions) => Promise<void>;
|
|
87
|
-
|
|
88
96
|
/**
|
|
89
97
|
* Base URL for password reset links (e.g., "https://myapp.com")
|
|
90
98
|
* The reset link will be: {baseUrl}/reset-password?token={token}
|
|
91
99
|
*/
|
|
92
100
|
resetPasswordUrl?: string;
|
|
93
|
-
|
|
94
101
|
/**
|
|
95
102
|
* Base URL for email verification links (e.g., "https://myapp.com")
|
|
96
103
|
* The verification link will be: {baseUrl}/verify-email?token={token}
|
|
97
104
|
*/
|
|
98
105
|
verifyEmailUrl?: string;
|
|
99
|
-
|
|
100
106
|
/**
|
|
101
107
|
* Base URL for magic link login (e.g., "https://myapp.com")
|
|
102
108
|
* The magic link will be: {baseUrl}/auth/magic-link?token={token}
|
|
103
109
|
* Falls back to `resetPasswordUrl` if not set.
|
|
104
110
|
*/
|
|
105
111
|
magicLinkUrl?: string;
|
|
106
|
-
|
|
107
112
|
/**
|
|
108
113
|
* Application name to use in email templates
|
|
109
114
|
*/
|
|
110
115
|
appName?: string;
|
|
111
|
-
|
|
112
116
|
/**
|
|
113
117
|
* Custom email templates (optional - defaults are provided)
|
|
114
118
|
*/
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The full set of environment variables recognized by a Rebase backend.
|
|
4
|
+
*/
|
|
5
|
+
declare const rebaseEnvSchema: z.ZodObject<{
|
|
6
|
+
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
7
|
+
production: "production";
|
|
8
|
+
development: "development";
|
|
9
|
+
test: "test";
|
|
10
|
+
}>>;
|
|
11
|
+
PORT: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<number, string>>;
|
|
12
|
+
DATABASE_URL: z.ZodString;
|
|
13
|
+
ADMIN_CONNECTION_STRING: z.ZodOptional<z.ZodString>;
|
|
14
|
+
JWT_SECRET: z.ZodString;
|
|
15
|
+
JWT_ACCESS_EXPIRES_IN: z.ZodDefault<z.ZodString>;
|
|
16
|
+
JWT_REFRESH_EXPIRES_IN: z.ZodDefault<z.ZodString>;
|
|
17
|
+
GOOGLE_CLIENT_ID: z.ZodOptional<z.ZodString>;
|
|
18
|
+
GOOGLE_CLIENT_SECRET: z.ZodOptional<z.ZodString>;
|
|
19
|
+
REBASE_SERVICE_KEY: z.ZodOptional<z.ZodString>;
|
|
20
|
+
ALLOW_REGISTRATION: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
|
|
21
|
+
"": "";
|
|
22
|
+
true: "true";
|
|
23
|
+
false: "false";
|
|
24
|
+
}>>, z.ZodTransform<boolean, "" | "true" | "false">>;
|
|
25
|
+
ALLOW_LOCALHOST_IN_PRODUCTION: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
"": "";
|
|
27
|
+
true: "true";
|
|
28
|
+
false: "false";
|
|
29
|
+
}>>, z.ZodTransform<boolean, "" | "true" | "false" | undefined>>;
|
|
30
|
+
CORS_ORIGINS: z.ZodOptional<z.ZodString>;
|
|
31
|
+
FRONTEND_URL: z.ZodOptional<z.ZodString>;
|
|
32
|
+
DB_POOL_MAX: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<number, string>>;
|
|
33
|
+
DB_POOL_IDLE_TIMEOUT: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<number, string>>;
|
|
34
|
+
DB_POOL_CONNECT_TIMEOUT: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<number, string>>;
|
|
35
|
+
DATABASE_DIRECT_URL: z.ZodOptional<z.ZodString>;
|
|
36
|
+
DATABASE_READ_URL: z.ZodOptional<z.ZodString>;
|
|
37
|
+
FORCE_LOCAL_STORAGE: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
"": "";
|
|
39
|
+
true: "true";
|
|
40
|
+
false: "false";
|
|
41
|
+
}>>, z.ZodTransform<boolean, "" | "true" | "false" | undefined>>;
|
|
42
|
+
STORAGE_TYPE: z.ZodDefault<z.ZodEnum<{
|
|
43
|
+
local: "local";
|
|
44
|
+
s3: "s3";
|
|
45
|
+
}>>;
|
|
46
|
+
STORAGE_PATH: z.ZodOptional<z.ZodString>;
|
|
47
|
+
S3_BUCKET: z.ZodOptional<z.ZodString>;
|
|
48
|
+
S3_REGION: z.ZodOptional<z.ZodString>;
|
|
49
|
+
S3_ACCESS_KEY_ID: z.ZodOptional<z.ZodString>;
|
|
50
|
+
S3_SECRET_ACCESS_KEY: z.ZodOptional<z.ZodString>;
|
|
51
|
+
S3_ENDPOINT: z.ZodOptional<z.ZodString>;
|
|
52
|
+
S3_FORCE_PATH_STYLE: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
"": "";
|
|
54
|
+
true: "true";
|
|
55
|
+
false: "false";
|
|
56
|
+
}>>, z.ZodTransform<boolean, "" | "true" | "false" | undefined>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
/** Inferred type of the validated environment. */
|
|
59
|
+
export type RebaseEnv = z.infer<typeof rebaseEnvSchema>;
|
|
60
|
+
/**
|
|
61
|
+
* Load and validate the Rebase environment configuration from `process.env`.
|
|
62
|
+
*
|
|
63
|
+
* Call this **after** your `.env` file has been loaded (via `dotenv`, `--env-file`,
|
|
64
|
+
* container injection, etc.). This function does not load `.env` files itself —
|
|
65
|
+
* that is a deployment concern, not a framework concern.
|
|
66
|
+
*
|
|
67
|
+
* Behavior:
|
|
68
|
+
* - Auto-generates ephemeral `JWT_SECRET` and `REBASE_SERVICE_KEY` in
|
|
69
|
+
* non-production mode so developers can start without manual setup.
|
|
70
|
+
* - Blocks auto-generated secrets in production.
|
|
71
|
+
* - Returns a fully typed, validated env object.
|
|
72
|
+
*
|
|
73
|
+
* Use `extend` to add your own typed env variables on top of the base Rebase schema:
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import dotenv from "dotenv";
|
|
78
|
+
* import { z } from "zod";
|
|
79
|
+
* import { loadEnv } from "@rebasepro/server-core";
|
|
80
|
+
*
|
|
81
|
+
* dotenv.config({ path: "../../.env" });
|
|
82
|
+
*
|
|
83
|
+
* // Basic — just Rebase env vars:
|
|
84
|
+
* export const env = loadEnv();
|
|
85
|
+
*
|
|
86
|
+
* // Extended — add your own typed vars:
|
|
87
|
+
* export const env = loadEnv({
|
|
88
|
+
* extend: z.object({
|
|
89
|
+
* SMTP_HOST: z.string().optional(),
|
|
90
|
+
* SMTP_PORT: z.string().default("587").transform(Number),
|
|
91
|
+
* STRIPE_SECRET_KEY: z.string(),
|
|
92
|
+
* })
|
|
93
|
+
* });
|
|
94
|
+
* // env.SMTP_HOST → string | undefined (fully typed)
|
|
95
|
+
* // env.STRIPE_SECRET_KEY → string (validated, required)
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function loadEnv(): RebaseEnv;
|
|
99
|
+
export declare function loadEnv<E extends z.ZodObject<z.ZodRawShape>>(options: {
|
|
100
|
+
extend: E;
|
|
101
|
+
}): RebaseEnv & z.infer<E>;
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { RebaseServerClient } from "@rebasepro/types";
|
|
3
|
+
import type { HonoEnv } from "../api/types";
|
|
4
|
+
/**
|
|
5
|
+
* Typed context injected into a function authored with {@link defineFunction}.
|
|
6
|
+
*
|
|
7
|
+
* Surfaces the app-scoped Rebase singleton so handlers don't need to reach
|
|
8
|
+
* for the global `rebase` import. Request-scoped values (the authenticated
|
|
9
|
+
* `user`, the RLS-scoped `driver`, the `apiKey`, the `requestId`) are typed
|
|
10
|
+
* on the Hono context via {@link HonoEnv} — read them with `c.get("user")`
|
|
11
|
+
* / `c.var.driver` inside a handler.
|
|
12
|
+
*/
|
|
13
|
+
export interface RebaseFunctionContext {
|
|
14
|
+
/**
|
|
15
|
+
* The server-side Rebase singleton (`dataAsAdmin`, `auth`, `storage`,
|
|
16
|
+
* `email`, `sql`).
|
|
17
|
+
*
|
|
18
|
+
* `rebase.dataAsAdmin` runs with **admin privileges and bypasses RLS** — use
|
|
19
|
+
* it only for trusted admin work. For user-scoped queries inside a handler,
|
|
20
|
+
* use the request `driver` (`c.var.driver`), which carries the caller's
|
|
21
|
+
* identity so RLS applies. (`rebase.data` is a deprecated alias for
|
|
22
|
+
* `rebase.dataAsAdmin`.)
|
|
23
|
+
*/
|
|
24
|
+
rebase: RebaseServerClient;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Typed authoring contract for a custom backend function.
|
|
28
|
+
*
|
|
29
|
+
* A custom function is a file in the `functionsDir` that default-exports a
|
|
30
|
+
* Hono app; the loader mounts it at `/<filename>`. `defineFunction` is the
|
|
31
|
+
* typed opt-in for that contract: it hands you a pre-typed `Hono<HonoEnv>`
|
|
32
|
+
* app (so `c.var.user` / `c.var.driver` are typed) plus a
|
|
33
|
+
* {@link RebaseFunctionContext}, and returns exactly the Hono app the loader
|
|
34
|
+
* already accepts — so it is fully interchangeable with a plain
|
|
35
|
+
* `export default new Hono()`.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { defineFunction, requireAuth } from "@rebasepro/server-core";
|
|
40
|
+
*
|
|
41
|
+
* export default defineFunction((app, { rebase }) => {
|
|
42
|
+
* app.use("/*", requireAuth);
|
|
43
|
+
* app.get("/home", async (c) => {
|
|
44
|
+
* const [stats] = await rebase.sql!(`SELECT count(*) AS n FROM orders`);
|
|
45
|
+
* return c.json({ orders: Number(stats.n) });
|
|
46
|
+
* });
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param definition Receives the function's Hono app and the typed context.
|
|
51
|
+
* Register routes on the provided `app` and return nothing, or return your
|
|
52
|
+
* own `Hono<HonoEnv>` app to use instead.
|
|
53
|
+
* @returns The Hono app to default-export from the function file.
|
|
54
|
+
*/
|
|
55
|
+
export declare function defineFunction(definition: (app: Hono<HonoEnv>, ctx: RebaseFunctionContext) => void | Hono<HonoEnv>): Hono<HonoEnv>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { type ModuleImporter } from "../utils/dynamic-import.js";
|
|
3
|
+
export interface LoadedFunction {
|
|
4
|
+
/** Endpoint name derived from filename (e.g., "send-invoice") */
|
|
5
|
+
name: string;
|
|
6
|
+
/** The Hono sub-app to mount */
|
|
7
|
+
app: Hono<import("hono").Env>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Auto-discover Hono route files from a directory.
|
|
11
|
+
*
|
|
12
|
+
* Each file should default-export a Hono app (or router).
|
|
13
|
+
* The filename (without extension) becomes the mount path:
|
|
14
|
+
* `functions/send-invoice.ts` → mounted at `/send-invoice`
|
|
15
|
+
*
|
|
16
|
+
* This mirrors how `loadCollectionsFromDirectory` works for collections.
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadFunctionsFromDirectory(directory: string, importModule?: ModuleImporter): 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>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { loadFunctionsFromDirectory } from "./function-loader";
|
|
2
2
|
export type { LoadedFunction } from "./function-loader";
|
|
3
3
|
export { createFunctionRoutes } from "./function-routes";
|
|
4
|
+
export { defineFunction } from "./define-function";
|
|
5
|
+
export type { RebaseFunctionContext } from "./define-function";
|
|
@@ -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/:id/history`.
|
|
8
|
+
*/
|
|
9
|
+
export interface HistoryService {
|
|
10
|
+
fetchHistory(tableName: string, id: string, options: {
|
|
11
|
+
limit: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
data: Record<string, unknown>[];
|
|
15
|
+
total: number;
|
|
16
|
+
}>;
|
|
17
|
+
fetchHistoryEntry(historyId: string): Promise<Record<string, unknown> | null>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createHistoryRoutes(params: {
|
|
20
|
+
historyService: HistoryService;
|
|
21
|
+
registry: BackendCollectionRegistry;
|
|
22
|
+
driver: DataDriver;
|
|
23
|
+
}): Hono<HonoEnv>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 { initializeRebaseBackend, isAuthAdapter, isDatabaseAdapter } from "./init";
|
|
10
|
+
export type { RebaseBackendConfig, RebaseBackendInstance, RebaseAuthConfig } from "./init";
|
|
11
|
+
export { rebase, _setRebaseMock, _resetRebaseMock } from "./singleton";
|
|
12
|
+
export * from "./db/interfaces";
|
|
13
|
+
export * from "./auth/interfaces";
|
|
14
|
+
export { requireAuth, requireAdmin, optionalAuth, queryTokenAuth, fileTokenAuth, extractUserFromToken, hashPassword, verifyPassword, validatePasswordStrength, resolveAuthHooks, createBuiltinAuthAdapter, createCustomAuthAdapter, createGoogleProvider, createLinkedinProvider, createGitHubProvider, createMicrosoftProvider, createAppleProvider, createFacebookProvider, createTwitterProvider, createDiscordProvider, createGitLabProvider, createBitbucketProvider, createSlackProvider, createSpotifyProvider, isApiKeyToken, validateApiKey, httpMethodToOperation, isOperationAllowed } from "./auth";
|
|
15
|
+
export type { AccessTokenPayload, PasswordValidationResult, AuthHooks, AuthMethod, ResolvedAuthHooks, BuiltinAuthAdapterConfig, GoogleProviderConfig, AuthMiddlewareOptions, AuthResult, ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest, ApiKeyStore, ApiKeyOperation } from "./auth";
|
|
16
|
+
export * from "./api/types";
|
|
17
|
+
export * from "./api/errors";
|
|
18
|
+
export * from "./email";
|
|
19
|
+
export * from "./storage";
|
|
20
|
+
export { createHistoryRoutes } from "./history";
|
|
21
|
+
export { loadFunctionsFromDirectory, createFunctionRoutes, defineFunction } from "./functions";
|
|
22
|
+
export type { LoadedFunction, RebaseFunctionContext } from "./functions";
|
|
23
|
+
export { loadCronJobsFromDirectory, CronScheduler, validateCronExpression, createCronRoutes, createCronStore, defineCron } from "./cron";
|
|
24
|
+
export type { LoadedCronJob, CronStore } from "./cron";
|
|
25
|
+
export { authUid, authRoles, authJwt } from "./utils/sql";
|
|
26
|
+
export { logger } from "./utils/logger";
|
|
27
|
+
export type { Logger } from "./utils/logger";
|
|
28
|
+
export { loadEnv } from "./env";
|
|
29
|
+
export type { RebaseEnv } from "./env";
|
|
30
|
+
export * from "./types";
|
|
31
|
+
export * from "./services/driver-registry";
|
|
32
|
+
export { cleanupDevPortFile, listenWithPortRetry } from "./utils/dev-port";
|
|
33
|
+
export { serveSPA } from "./serve-spa";
|
|
34
|
+
export { installShutdownHandlers } from "./init/shutdown";
|
|
35
|
+
export type { ShutdownHandlerOptions } from "./init/shutdown";
|