@rebasepro/server 0.10.0 → 0.10.1-canary.14e53ae

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.
@@ -0,0 +1,20 @@
1
+ import type { CollectionConfig } from "@rebasepro/types";
2
+ import type { RebaseAuthConfig } from "../init";
3
+ import type { EmailConfig } from "../email";
4
+ import type { RebaseBootEnv } from "./env";
5
+ /**
6
+ * Build the email configuration, or `undefined` when no SMTP host is set.
7
+ *
8
+ * Without it the auth adapter still works; password-reset and verification mail
9
+ * simply has nowhere to go, which the auth routes report for themselves.
10
+ */
11
+ export declare function resolveEmailOptions(env: RebaseBootEnv): EmailConfig | undefined;
12
+ /**
13
+ * Build the auth configuration from the environment and the bundle's users
14
+ * collection.
15
+ *
16
+ * OAuth providers are included only when both halves of a credential pair are
17
+ * present. Google is the exception the template already made: a client id alone
18
+ * is enough, because the ID-token flow needs no secret.
19
+ */
20
+ export declare function resolveAuthOptions(env: RebaseBootEnv, usersCollection: CollectionConfig | undefined): RebaseAuthConfig;
@@ -0,0 +1,77 @@
1
+ import { type DataSourceDefinition, type StorageSourceDefinition } from "@rebasepro/types";
2
+ import type { BackendStorageConfig } from "../storage/types";
3
+ /**
4
+ * Resolving *named* data and storage sources from the environment.
5
+ *
6
+ * A project is not required to have one database and one bucket. Collections
7
+ * already route by `collection.dataSource`, storage properties already route by
8
+ * `storageSource`, and the backend already registers one driver per source key —
9
+ * so the only piece missing was a way to *configure* the second, third and fourth
10
+ * of each without hand-writing an entrypoint.
11
+ *
12
+ * The naming rule is mechanical, and deliberately derives the variable name from
13
+ * the declared key rather than trying to discover keys by scanning the
14
+ * environment. Scanning would have to guess how `DATABASE_URL_READ_REPLICA` splits
15
+ * into a key; deriving cannot be ambiguous, and a typo shows up as a missing
16
+ * source at boot instead of a silently ignored variable.
17
+ *
18
+ * ```
19
+ * <BASE> the default source DATABASE_URL, S3_BUCKET
20
+ * <BASE>__<KEY> a named source DATABASE_URL__ANALYTICS, S3_BUCKET__MEDIA
21
+ * ```
22
+ *
23
+ * The double underscore matters: single-underscore suffixes collide with real
24
+ * variable names (`S3_BUCKET_NAME` would parse as bucket "name").
25
+ */
26
+ /** Environment lookup, injectable so tests need not mutate `process.env`. */
27
+ export type EnvBag = Record<string, string | undefined>;
28
+ /**
29
+ * Convert a source key into the suffix used in environment variable names.
30
+ *
31
+ * The default key maps to no suffix at all, which is what keeps every existing
32
+ * single-database deployment working untouched.
33
+ */
34
+ export declare function envSuffixForKey(key: string, defaultKey: string): string;
35
+ /** A data source resolved to everything needed to build a driver for it. */
36
+ export interface ResolvedDataSourceConfig {
37
+ /** Data-source key — becomes the driver-registry id collections route by. */
38
+ key: string;
39
+ engine: string;
40
+ /** npm package implementing the driver. */
41
+ driverPackage: string;
42
+ connectionString: string;
43
+ adminConnectionString?: string;
44
+ readConnectionString?: string;
45
+ isDefault: boolean;
46
+ poolConfig?: Record<string, number>;
47
+ }
48
+ /**
49
+ * Resolve every server-transport data source to a connection.
50
+ *
51
+ * `direct` and `custom` transports are skipped: the client talks to those
52
+ * itself, so the backend holds no connection for them and must not demand one.
53
+ *
54
+ * A declared source with no connection string is an error rather than a warning.
55
+ * The alternative — starting without it — means every collection routed to that
56
+ * source silently falls back to the default database, which is data landing in
57
+ * the wrong place with a healthy-looking server in front of it.
58
+ */
59
+ export declare function resolveDataSources(env: EnvBag, definitions: DataSourceDefinition[] | undefined): ResolvedDataSourceConfig[];
60
+ /**
61
+ * Build one storage configuration from the variables for a single source.
62
+ *
63
+ * Returns `undefined` when the source has no configuration at all, so an
64
+ * optional bucket that was never set does not fail a boot. The production
65
+ * "local storage is off" rule deliberately does *not* live here — it is enforced
66
+ * once, in `initializeStorage`, which logs precisely why storage is disabled.
67
+ * Duplicating it would mean two places to keep in agreement.
68
+ */
69
+ export declare function resolveStorageBackend(env: EnvBag, key: string, engineHint: string | undefined, defaultBasePath: string): BackendStorageConfig | undefined;
70
+ /**
71
+ * Resolve every server-transport storage source into a controller config map.
72
+ *
73
+ * The returned shape is the `Record<key, config>` the backend already accepts,
74
+ * so multiple buckets need nothing new downstream — they were always supported,
75
+ * they just had no way to be configured from the environment.
76
+ */
77
+ export declare function resolveStorageSources(env: EnvBag, definitions: StorageSourceDefinition[] | undefined, defaultBasePath: string): Record<string, BackendStorageConfig> | undefined;
package/dist/index.d.ts CHANGED
@@ -36,3 +36,18 @@ export { cleanupDevPortFile, listenWithPortRetry } from "./utils/dev-port";
36
36
  export { serveSPA } from "./serve-spa";
37
37
  export { installShutdownHandlers } from "./init/shutdown";
38
38
  export type { ShutdownHandlerOptions } from "./init/shutdown";
39
+ export { bootFromBundle, runFromBundle } from "./boot/boot";
40
+ export type { BootedRuntime, BootOptions } from "./boot/boot";
41
+ export { BundleError, loadBundle, readBundleManifest, loadBundleConfigExports, createSourceBundle, loadBundleSchema, loadUsersCollection } from "./boot/bundle";
42
+ export type { LoadedBundle, BundleConfigExports } from "./boot/bundle";
43
+ export { loadBootEnv, resolveCorsOrigin, isLocalhostOrigin } from "./boot/env";
44
+ export type { RebaseBootEnv, CorsOriginResolver } from "./boot/env";
45
+ export { resolveAuthOptions, resolveEmailOptions } from "./boot/options";
46
+ export { envSuffixForKey, resolveDataSources, resolveStorageSources, resolveStorageBackend } from "./boot/sources";
47
+ export type { ResolvedDataSourceConfig, EnvBag } from "./boot/sources";
48
+ export { initializeDataSource, initializeDataSources } from "./boot/driver";
49
+ export type { InitializedDataSource, DatabaseConnection, BundleSchema } from "./boot/driver";
50
+ export { MetricsRegistry, createMetricsMiddleware, createMetricsRoutes, classifySurface } from "./metrics";
51
+ export type { MetricSurface, MetricsHandle } from "./metrics";
52
+ export { createContractRoutes } from "./api/contract-routes";
53
+ export type { ContractRoutesConfig } from "./api/contract-routes";