@getstrata/bootstrap 2.2.60 → 3.0.5
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/CHANGELOG.md +35 -0
- package/dist/bootstrap/app.d.ts +18 -7
- package/dist/bootstrap/buildModuleRoutes.d.ts +3 -5
- package/dist/bootstrap/buildWebModuleRoutes.d.ts +2 -3
- package/dist/bootstrap/cache/modelCacheTags.d.ts +3 -2
- package/dist/bootstrap/cachedJson.d.ts +7 -2
- package/dist/bootstrap/config.d.ts +1 -1
- package/dist/bootstrap/context.d.ts +25 -7
- package/dist/bootstrap/contracts.d.ts +1 -0
- package/dist/bootstrap/createWebRoutes.d.ts +2 -1
- package/dist/bootstrap/databaseReadiness.d.ts +3 -0
- package/dist/bootstrap/dependencies.d.ts +3 -2
- package/dist/bootstrap/discoverJobs.d.ts +3 -2
- package/dist/bootstrap/discoverListeners.d.ts +10 -7
- package/dist/bootstrap/discoverModels.d.ts +3 -2
- package/dist/bootstrap/discoverModules.d.ts +7 -6
- package/dist/bootstrap/health.d.ts +3 -2
- package/dist/bootstrap/http/securedRouteModelBinding.d.ts +1 -1
- package/dist/bootstrap/httpKernel.d.ts +43 -22
- package/dist/bootstrap/httpPersistence.d.ts +4 -0
- package/dist/bootstrap/inProcessCron.d.ts +5 -5
- package/dist/bootstrap/listeners/invalidateCacheOnModelWrite.d.ts +13 -12
- package/dist/bootstrap/metricsRoutes.d.ts +6 -1
- package/dist/bootstrap/moduleRouteMiddleware.d.ts +4 -4
- package/dist/bootstrap/modules.d.ts +1 -1
- package/dist/bootstrap/ownedHttpRoute.d.ts +23 -0
- package/dist/bootstrap/persistenceContracts.d.ts +70 -0
- package/dist/bootstrap/persistenceInvocation.d.ts +4 -0
- package/dist/bootstrap/providers/auth.d.ts +21 -0
- package/dist/bootstrap/providers/cache.d.ts +9 -3
- package/dist/bootstrap/providers/cacheProvider.d.ts +3 -0
- package/dist/bootstrap/providers/config.d.ts +6 -3
- package/dist/bootstrap/providers/events.d.ts +5 -2
- package/dist/bootstrap/providers/index.d.ts +3 -2
- package/dist/bootstrap/providers/listeners.d.ts +3 -3
- package/dist/bootstrap/providers/mail.d.ts +15 -0
- package/dist/bootstrap/providers/queue.d.ts +3 -2
- package/dist/bootstrap/providers/storage.d.ts +11 -2
- package/dist/bootstrap/providers/tracing.d.ts +4 -2
- package/dist/bootstrap/providers/view.d.ts +8 -5
- package/dist/bootstrap/public-api.d.ts +10 -7
- package/dist/bootstrap/queue/defaultJobs.d.ts +4 -2
- package/dist/bootstrap/rateLimit.d.ts +13 -3
- package/dist/bootstrap/routeCompiler.d.ts +20 -0
- package/dist/bootstrap/routeMetadata.d.ts +3 -3
- package/dist/bootstrap/routePlan.d.ts +11 -0
- package/dist/bootstrap/schedule.d.ts +11 -2
- package/dist/bootstrap/secretsGuard.d.ts +2 -3
- package/dist/bootstrap/web/routing.d.ts +6 -3
- package/dist/bootstrap/web/server.d.ts +14 -4
- package/dist/bootstrap/web/session.d.ts +23 -16
- package/dist/entries/buildModuleRoutes.js +602 -384
- package/dist/entries/buildWebModuleRoutes.js +596 -347
- package/dist/entries/cache/modelCacheTags.js +8 -186
- package/dist/entries/cachedJson.js +22 -0
- package/dist/entries/config.js +1 -3
- package/dist/entries/context.js +665 -700
- package/dist/entries/createSpaRoutes.js +194 -5
- package/dist/entries/createWebRoutes.js +618 -367
- package/dist/entries/databaseReadiness.js +267 -0
- package/dist/entries/dependencies.js +666 -701
- package/dist/entries/discoverJobs.js +18 -16
- package/dist/entries/discoverListeners.js +27 -38
- package/dist/entries/discoverModels.js +4 -3
- package/dist/entries/discoverModules.js +29 -67
- package/dist/entries/health.js +14 -34
- package/dist/entries/httpKernel.js +405 -89
- package/dist/entries/listeners/invalidateCacheOnModelWrite.js +43 -289
- package/dist/entries/metricsRoutes.js +9 -5
- package/dist/entries/persistenceContracts.js +1 -0
- package/dist/entries/persistenceInvocation.js +17 -0
- package/dist/entries/providers/auth.js +114 -0
- package/dist/entries/providers/cache.js +35 -0
- package/dist/entries/providers/events.js +55 -0
- package/dist/entries/providers/view.js +34 -44
- package/dist/entries/providers.js +392 -561
- package/dist/entries/queue/defaultJobs.js +9 -6
- package/dist/entries/routePlan.js +200 -0
- package/dist/entries/schedule.js +37 -37
- package/dist/entries/secretsGuard.js +10 -13
- package/dist/entries/web/routing.js +412 -96
- package/dist/entries/web/server.js +461 -29
- package/dist/entries/web/session.js +61 -73
- package/dist/index.js +1520 -1085
- package/dist/internal/ownedHttpRoute.js +66 -0
- package/package.json +52 -15
- package/dist/bootstrap/applicationRegistry.d.ts +0 -1
- package/dist/bootstrap/routeRegistry.d.ts +0 -10
- package/dist/entries/applicationRegistry.js +0 -24
- package/dist/entries/routeRegistry.js +0 -29
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import { type AuthGuard, AuthManager } from "@getstrata/core/auth/guard";
|
|
2
|
+
import type { readSession } from "@getstrata/core/auth/sessionCookie";
|
|
3
|
+
import type { AuthUserDirectory, AuthUserRecord } from "@getstrata/core/contracts/authUserDirectory";
|
|
4
|
+
import type { MfaSecretCodec } from "@getstrata/core/crypto/mfaSecret";
|
|
1
5
|
import type { ServiceProvider } from "../contracts";
|
|
6
|
+
export interface MetadataAuthOptions {
|
|
7
|
+
readonly mechanisms: readonly ("api" | "jwt" | "basic" | "session")[];
|
|
8
|
+
readonly sessionGuard?: AuthGuard;
|
|
9
|
+
readonly production: boolean;
|
|
10
|
+
readonly allowDevHeaders: boolean;
|
|
11
|
+
readonly jwtSecret: string;
|
|
12
|
+
readonly mfaSecrets: MfaSecretCodec;
|
|
13
|
+
readonly hasSessionCredential?: (request: Request) => boolean;
|
|
14
|
+
readonly readSession: (request: Request) => ReturnType<typeof readSession>;
|
|
15
|
+
readonly abilities: {
|
|
16
|
+
readonly admin: readonly string[];
|
|
17
|
+
readonly member: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
readonly roleAbilities: (role: string) => string[];
|
|
20
|
+
}
|
|
21
|
+
/** Construct once for each metadata invocation, with invocation-bound narrow ports. */
|
|
22
|
+
export declare function createMetadataAuthManager(directory: Partial<AuthUserDirectory>, options: MetadataAuthOptions, persistRecovery: (record: AuthUserRecord, hash: string) => Promise<boolean>): AuthManager;
|
|
2
23
|
declare const authProvider: ServiceProvider;
|
|
3
24
|
export default authProvider;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type CreateCacheStoreOptions } from "@getstrata/core/cache/createCacheStore";
|
|
2
|
+
import { type FactoryServiceDeclaration, type ResourceServiceDeclaration } from "@getstrata/core/contracts/services";
|
|
3
|
+
type CacheBindingOptions = Readonly<Omit<CreateCacheStoreOptions, "namespace"> & {
|
|
4
|
+
namespace: string;
|
|
5
|
+
}>;
|
|
6
|
+
/** One application backend and a guarded value facade for each entered execution. */
|
|
7
|
+
declare function createCacheBindings(options: CacheBindingOptions): readonly [ResourceServiceDeclaration, FactoryServiceDeclaration];
|
|
8
|
+
export type { CacheBindingOptions };
|
|
9
|
+
export { createCacheBindings };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ServiceProvider } from "../contracts";
|
|
2
2
|
import { appConfigKeys } from "../env";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { HttpPersistenceOptions } from "../persistenceContracts";
|
|
4
|
+
/** Entrypoint adapter: resolve once from the owning application's environment snapshot. */
|
|
5
|
+
declare function resolveHttpResponsePolicy(source: Readonly<Record<string, string | undefined>>): NonNullable<HttpPersistenceOptions["responsePolicy"]>;
|
|
6
|
+
/** Validate and capture all settings before any provider can acquire resources. */
|
|
7
|
+
declare function createConfigProvider(input: Readonly<Record<string, string | undefined>>): ServiceProvider;
|
|
8
|
+
export { appConfigKeys, createConfigProvider, resolveHttpResponsePolicy };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { EventBus } from "@getstrata/core/events";
|
|
1
2
|
import { CORE_EVENT_BUS_TOKEN } from "../config";
|
|
2
3
|
import type { ServiceProvider } from "../contracts";
|
|
3
|
-
declare const
|
|
4
|
-
|
|
4
|
+
export declare const APPLICATION_EVENT_BUS_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<EventBus>;
|
|
5
|
+
/** Non-ORM custom events keep one explicit app-owned dispatcher. */
|
|
6
|
+
export declare function createEventBindings(): readonly import("@getstrata/core/contracts/services").ValueServiceDeclaration[];
|
|
7
|
+
export declare function createEventsProvider(bus: EventBus): ServiceProvider;
|
|
5
8
|
export { CORE_EVENT_BUS_TOKEN };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ServiceProvider } from "../contracts";
|
|
2
|
-
declare
|
|
3
|
-
export {
|
|
2
|
+
declare function createCoreProviders(env?: Readonly<Record<string, string | undefined>>): ServiceProvider[];
|
|
3
|
+
export { resolveHttpResponsePolicy } from "./config";
|
|
4
|
+
export { createCoreProviders };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
/** Collect these inert declarations before passing their services/effects into application assembly. */
|
|
2
|
+
export type { DiscoverListenersOptions, ListenerDeclarations } from "../discoverListeners";
|
|
3
|
+
export { discoverListeners } from "../discoverListeners";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FactoryServiceDeclaration } from "@getstrata/core/contracts/services";
|
|
2
|
+
import { CORE_MAIL_TOKEN, type MailDriver, type SmtpConfig } from "@getstrata/core/mail/mailer";
|
|
3
|
+
type MailBindingOptions = {
|
|
4
|
+
readonly driver: "log";
|
|
5
|
+
} | {
|
|
6
|
+
readonly driver: "smtp";
|
|
7
|
+
readonly smtp: SmtpConfig;
|
|
8
|
+
} | {
|
|
9
|
+
readonly driver: "custom";
|
|
10
|
+
readonly mail: MailDriver;
|
|
11
|
+
};
|
|
12
|
+
/** No transport opens during assembly; SMTP configuration is validated and copied here. */
|
|
13
|
+
declare function createMailBindings(options: MailBindingOptions): readonly FactoryServiceDeclaration[];
|
|
14
|
+
export type { MailBindingOptions };
|
|
15
|
+
export { CORE_MAIL_TOKEN, createMailBindings };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { QueueHandoff } from "@getstrata/core/queue/queueHandoff";
|
|
1
2
|
import type { ServiceProvider } from "../contracts";
|
|
2
|
-
declare
|
|
3
|
-
export
|
|
3
|
+
declare function createQueueProvider(env?: Readonly<Record<string, string | undefined>>, handoff?: QueueHandoff): ServiceProvider;
|
|
4
|
+
export { createQueueProvider };
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { type FactoryServiceDeclaration } from "@getstrata/core/contracts/services";
|
|
2
|
+
import { CORE_STORAGE_TOKEN, type StorageConfig, type StorageDriver } from "@getstrata/core/storage/storage";
|
|
1
3
|
import type { ServiceProvider } from "../contracts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
type StorageBindingOptions = StorageConfig | {
|
|
5
|
+
readonly driver: "custom";
|
|
6
|
+
readonly storage: StorageDriver;
|
|
7
|
+
};
|
|
8
|
+
/** Capture validated settings before application resources can open. */
|
|
9
|
+
declare function createStorageBindings(config: StorageBindingOptions): readonly FactoryServiceDeclaration[];
|
|
10
|
+
declare function createStorageProvider(driver: StorageDriver): ServiceProvider;
|
|
11
|
+
export type { StorageBindingOptions };
|
|
12
|
+
export { CORE_STORAGE_TOKEN, createStorageBindings, createStorageProvider };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type TracingOptions } from "@getstrata/core/tracing/tracingMiddleware";
|
|
1
2
|
import type { ServiceProvider } from "../contracts";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
/** Capture app configuration now; acquire telemetry only when its context starts. */
|
|
4
|
+
declare function createTracingProvider(options?: TracingOptions): ServiceProvider;
|
|
5
|
+
export { createTracingProvider };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type { WebLayoutDataOptions } from "@getstrata/core/view";
|
|
1
|
+
import type { WebErrorViewOptions, WebLayoutDataOptions } from "@getstrata/core/view";
|
|
2
|
+
import { CORE_VIEW_TOKEN } from "@getstrata/core/view/tokens";
|
|
2
3
|
import type { ServiceProvider } from "../contracts";
|
|
3
|
-
declare const CORE_VIEW_TOKEN = "core.view";
|
|
4
4
|
declare const VIEW_DIRECTORY_CONFIG_KEY = "view.directory";
|
|
5
5
|
interface ViewProviderOptions {
|
|
6
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
6
7
|
/** Explicit document capability, for example a browser SSO continuation in an API app. */
|
|
7
8
|
enabled?: boolean;
|
|
9
|
+
/** Relative directories are resolved against this root at provider construction. */
|
|
10
|
+
rootDir?: string;
|
|
8
11
|
directory?: string;
|
|
9
12
|
layout?: string | false;
|
|
10
13
|
data?: WebLayoutDataOptions;
|
|
14
|
+
error?: WebErrorViewOptions;
|
|
11
15
|
}
|
|
12
|
-
/**
|
|
16
|
+
/** Captures configuration and paths once, before registration or request execution. */
|
|
13
17
|
declare function createViewProvider(options?: ViewProviderOptions): ServiceProvider;
|
|
14
|
-
declare const viewProvider: ServiceProvider;
|
|
15
18
|
export type { ViewProviderOptions };
|
|
16
|
-
export { CORE_VIEW_TOKEN, createViewProvider, VIEW_DIRECTORY_CONFIG_KEY
|
|
19
|
+
export { CORE_VIEW_TOKEN, createViewProvider, VIEW_DIRECTORY_CONFIG_KEY };
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type { ScheduledTask, ScheduledTaskContext, SchedulerLease, SchedulerLeaseStore, SchedulerRunOptions, } from "@getstrata/core/scheduler/schedule";
|
|
5
5
|
export { appSchedule, RedisSchedulerLeaseStore, runDueScheduledTasks, Schedule, SchedulerLeaseLostError, } from "@getstrata/core/scheduler/schedule";
|
|
6
|
-
export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationEventBus, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "./applicationRegistry.ts";
|
|
7
6
|
export type { BuildModuleRoutesOptions } from "./buildModuleRoutes.ts";
|
|
8
7
|
export { buildModuleRoutes } from "./buildModuleRoutes.ts";
|
|
9
8
|
export type { BuildWebModuleRoutesOptions } from "./buildWebModuleRoutes.ts";
|
|
10
9
|
export { buildWebModuleRoutes } from "./buildWebModuleRoutes.ts";
|
|
11
10
|
export { cacheTagsForModelWrite, discoverModelTableNames } from "./cache/modelCacheTags.ts";
|
|
12
|
-
export {
|
|
11
|
+
export { createCachedJson } from "./cachedJson.ts";
|
|
12
|
+
export { APP_PORT_CONFIG_KEY, CORE_ABILITY_CHECKER_TOKEN, CORE_AUTH_TOKEN, CORE_AUTH_USER_DIRECTORY_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CSRF_TARGET_ORIGIN_CONFIG_KEY, DATABASE_URL_CONFIG_KEY, DEFAULT_APP_PORT, REDIS_URL_CONFIG_KEY, } from "./config.ts";
|
|
13
13
|
export type { InitializedAppContext } from "./context.ts";
|
|
14
14
|
export { collectProviders, createAppContext, runProviderPhase } from "./context.ts";
|
|
15
15
|
export type { AppContext, AppDependencies, AppModule, AppRouteMap, CachedJson, ConfigStore, ModuleRouteContext, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, } from "./contracts.ts";
|
|
@@ -22,18 +22,21 @@ export { discoverJobs, resetDiscoverJobsForTests } from "./discoverJobs.ts";
|
|
|
22
22
|
export type { DiscoverModelsOptions } from "./discoverModels.ts";
|
|
23
23
|
export { discoverModels } from "./discoverModels.ts";
|
|
24
24
|
export type { DiscoverModulesOptions } from "./discoverModules.ts";
|
|
25
|
-
export {
|
|
25
|
+
export { createModuleDiscovery, ensureModulesLoaded } from "./discoverModules.ts";
|
|
26
26
|
export type { CreateHealthRoutesOptions } from "./health.ts";
|
|
27
27
|
export { checkDatabase, checkRedis, createHealthRoutes, pingDatabase } from "./health.ts";
|
|
28
|
-
export { type RouteModelAuthorization, securedBindRouteModel, securedBindRouteModelByKey, } from "./http/securedRouteModelBinding.ts";
|
|
28
|
+
export { type RouteModelAuthorization, type RouteModelBindingPorts, securedBindRouteModel, securedBindRouteModelByKey, } from "./http/securedRouteModelBinding.ts";
|
|
29
29
|
export { createHttpKernel, type HttpKernel, type MiddlewareGroupName } from "./httpKernel.ts";
|
|
30
30
|
export { resolveMembershipService } from "./membershipService.ts";
|
|
31
31
|
export type { MetricsRoutesOptions, MetricsRuntime, MetricsRuntimeOptions, } from "./metricsRoutes.ts";
|
|
32
32
|
export { createMetricsRoutes, createMetricsRuntime } from "./metricsRoutes.ts";
|
|
33
33
|
export { prefixRouteMap } from "./prefixRouteMap.ts";
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
34
|
+
export { type CacheBindingOptions, createCacheBindings } from "./providers/cache.ts";
|
|
35
|
+
export { createCoreProviders } from "./providers/index.ts";
|
|
36
|
+
export { CORE_MAIL_TOKEN, createMailBindings, type MailBindingOptions } from "./providers/mail.ts";
|
|
37
|
+
export { CORE_STORAGE_TOKEN, createStorageBindings, createStorageProvider, type StorageBindingOptions, } from "./providers/storage.ts";
|
|
38
|
+
export { createTracingProvider } from "./providers/tracing.ts";
|
|
36
39
|
export { registerDefaultJobs } from "./queue/defaultJobs.ts";
|
|
37
|
-
export {
|
|
40
|
+
export { compileRouteMap, composeRouteMaps, getRouteInventory } from "./routePlan.ts";
|
|
38
41
|
export { assertProductionSecrets } from "./secretsGuard.ts";
|
|
39
42
|
export { CookieSessionAuthManager, CookieSessionGuard, CookieSessionStore, createCookieSessionAuthManager, createCsrfProtection, createRouteKernel, createWebServer, type LoadSessionUser, type MapSessionUser, type NativeServerOptions, type ParsedForm, parseFormBody, routeParams, type SessionUser, slugify, toRouteRequest, type WebServerOptions, wrapSecuredRouteModelByKey, wrapWebLogin, wrapWebRegister, } from "./web/index.ts";
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { JobRegistry } from "@getstrata/core/queue/jobRegistry";
|
|
2
|
+
declare const SYSTEM_JOB_NAMES: readonly string[];
|
|
3
|
+
declare function registerDefaultJobs(registry: JobRegistry): void;
|
|
4
|
+
export { registerDefaultJobs, SYSTEM_JOB_NAMES };
|
|
@@ -4,7 +4,17 @@ interface LoginRateLimitConfig {
|
|
|
4
4
|
}
|
|
5
5
|
declare const LOCAL_LOGIN_RATE_LIMIT: LoginRateLimitConfig;
|
|
6
6
|
declare const PRODUCTION_LOGIN_RATE_LIMIT: LoginRateLimitConfig;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
interface RateLimitEnvironment {
|
|
8
|
+
readonly [key: string]: string | undefined;
|
|
9
|
+
APP_ENV?: string;
|
|
10
|
+
LOGIN_RATE_LIMIT_PER_WINDOW?: string;
|
|
11
|
+
LOGIN_RATE_LIMIT_WINDOW_SECONDS?: string;
|
|
12
|
+
LOGIN_RATE_LIMIT_WINDOW_MS?: string;
|
|
13
|
+
REGISTER_RATE_LIMIT_PER_WINDOW?: string;
|
|
14
|
+
REGISTER_RATE_LIMIT_WINDOW_SECONDS?: string;
|
|
15
|
+
REGISTER_RATE_LIMIT_WINDOW_MS?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function resolveLoginRateLimit(env?: RateLimitEnvironment): LoginRateLimitConfig;
|
|
18
|
+
declare function resolveRegisterRateLimit(env?: RateLimitEnvironment): LoginRateLimitConfig;
|
|
19
|
+
export type { LoginRateLimitConfig, RateLimitEnvironment };
|
|
10
20
|
export { LOCAL_LOGIN_RATE_LIMIT, PRODUCTION_LOGIN_RATE_LIMIT, resolveLoginRateLimit, resolveRegisterRateLimit, };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OpenApiRouteMap, RegisteredRoute } from "@getstrata/core/openapi/registeredRoute";
|
|
2
|
+
interface RouteSource {
|
|
3
|
+
name: string;
|
|
4
|
+
routes: Record<string, unknown>;
|
|
5
|
+
metadata?: OpenApiRouteMap;
|
|
6
|
+
middleware?: string[];
|
|
7
|
+
}
|
|
8
|
+
interface CompiledRoutePlan {
|
|
9
|
+
routes: Record<string, unknown>;
|
|
10
|
+
inventory: readonly RegisteredRoute[];
|
|
11
|
+
}
|
|
12
|
+
/** Copy diagnostics, rejecting executable/cyclic metadata before it reaches a registry. */
|
|
13
|
+
declare function immutableCopy<T>(value: T, ancestors?: Set<object>): T;
|
|
14
|
+
declare function normalizeRoutePath(path: string, prefix?: string): string;
|
|
15
|
+
/** A single validation pass shared by module builders and final route composition. */
|
|
16
|
+
declare function compileRoutePlan(sources: readonly RouteSource[], prefix?: string): CompiledRoutePlan;
|
|
17
|
+
declare function attachRouteInventory(routes: Record<string, unknown>, inventory: readonly RegisteredRoute[]): Record<string, unknown>;
|
|
18
|
+
declare function getRouteInventory(routes: Record<string, unknown>): readonly RegisteredRoute[];
|
|
19
|
+
export type { CompiledRoutePlan, RouteSource };
|
|
20
|
+
export { attachRouteInventory, compileRoutePlan, getRouteInventory, immutableCopy, normalizeRoutePath, };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare function
|
|
3
|
-
export {
|
|
1
|
+
import type { CompiledRoutePlan } from "./routeCompiler";
|
|
2
|
+
declare function publishRoutePlan(plan: CompiledRoutePlan, routes?: Record<string, unknown>): Record<string, unknown>;
|
|
3
|
+
export { publishRoutePlan };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OpenApiRouteMap, RegisteredRoute } from "@getstrata/core/openapi/registeredRoute";
|
|
2
|
+
import { getRouteInventory } from "./routeCompiler";
|
|
3
|
+
/** Validate and snapshot an owned route map, preserving any existing attached contracts. */
|
|
4
|
+
declare function compileRouteMap(routes: Record<string, unknown>, options?: {
|
|
5
|
+
middleware?: string[];
|
|
6
|
+
metadata?: OpenApiRouteMap;
|
|
7
|
+
}): Record<string, unknown>;
|
|
8
|
+
/** Compose already compiled or raw maps without losing per-operation metadata. */
|
|
9
|
+
declare function composeRouteMaps(...maps: Record<string, unknown>[]): Record<string, unknown>;
|
|
10
|
+
export type { RegisteredRoute };
|
|
11
|
+
export { compileRouteMap, composeRouteMaps, getRouteInventory };
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { ExecutionEnvelope } from "@getstrata/core/contracts/application";
|
|
2
|
+
import { Schedule } from "@getstrata/core/scheduler/schedule";
|
|
3
|
+
interface AppScheduleOptions {
|
|
4
|
+
readonly environment: Readonly<Record<string, string | undefined>>;
|
|
5
|
+
readonly auditExport: () => Promise<number>;
|
|
6
|
+
readonly invoke: <T>(envelope: ExecutionEnvelope, work: () => T | Promise<T>) => Promise<T>;
|
|
7
|
+
}
|
|
8
|
+
/** One schedule definition per application; actual tasks enter that owner's existing execution engine. */
|
|
9
|
+
export declare function createAppSchedule(options: AppScheduleOptions): Schedule;
|
|
10
|
+
export type { AppScheduleOptions };
|
|
11
|
+
export declare function createScheduleRunOptions(environment: Readonly<Record<string, string | undefined>>): import("@getstrata/core/scheduler/schedule").SchedulerRunOptions;
|
|
@@ -3,12 +3,11 @@ type LivePostgresRoleInspector = () => Promise<{
|
|
|
3
3
|
rolsuper: boolean;
|
|
4
4
|
rolbypassrls: boolean;
|
|
5
5
|
} | null>;
|
|
6
|
-
declare function setLivePostgresRoleInspectorForTests(inspect: LivePostgresRoleInspector | null): void;
|
|
7
6
|
/**
|
|
8
7
|
* After the runtime pool is open, refuse rolsuper / rolbypassrls whenever
|
|
9
8
|
* TENANCY_DRIVER=rls, including local. Fail closed if the live query cannot run.
|
|
10
9
|
* MIGRATION_DATABASE_URL may stay a superuser.
|
|
11
10
|
*/
|
|
12
|
-
declare function assertRlsLiveDatabaseRole(env
|
|
11
|
+
declare function assertRlsLiveDatabaseRole(env: Record<string, string | undefined>, inspect: LivePostgresRoleInspector): Promise<void>;
|
|
13
12
|
declare function assertProductionSecrets(env?: Record<string, string | undefined>): void;
|
|
14
|
-
export { assertProductionSecrets, assertRlsLiveDatabaseRole
|
|
13
|
+
export { assertProductionSecrets, assertRlsLiveDatabaseRole };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { RouteHandler } from "@getstrata/core/http/middleware";
|
|
2
2
|
import type { RouteRequest } from "@getstrata/core/http/route";
|
|
3
|
+
import type { ComposedRouteHandler } from "#strata-http-route";
|
|
3
4
|
import type { AppDependencies } from "../contracts.ts";
|
|
5
|
+
import { type RouteModelBindingPorts } from "../http/securedRouteModelBinding.ts";
|
|
4
6
|
import type { HttpKernel } from "../httpKernel.ts";
|
|
7
|
+
import type { BusinessRequestPorts, BusinessRouteHandler } from "../persistenceContracts";
|
|
5
8
|
/** Read Bun native `:param` values from a route handler request. */
|
|
6
9
|
export declare function routeParams(request: Request): Record<string, string>;
|
|
7
10
|
/**
|
|
@@ -19,10 +22,10 @@ export declare function wrapSecuredRouteModelByKey<TParams extends Record<string
|
|
|
19
22
|
resource: string;
|
|
20
23
|
action: "view" | "create" | "update" | "delete";
|
|
21
24
|
etag?: boolean;
|
|
22
|
-
}, handler: (request: RouteRequest<TParams>, model: TModel) => Response | Promise<Response
|
|
25
|
+
}, handler: (request: RouteRequest<TParams>, model: TModel) => Response | Promise<Response>, ports: RouteModelBindingPorts): RouteHandler;
|
|
23
26
|
/** Web group (CSRF + flash + HTML errors) plus login throttle. Do not wrap with wrapWeb again. */
|
|
24
|
-
export declare function wrapWebLogin<TRequest extends Request = Request>(kernel: HttpKernel, handler:
|
|
27
|
+
export declare function wrapWebLogin<TRequest extends Request = Request>(kernel: HttpKernel, handler: BusinessRouteHandler<TRequest>, onThrottled: (request: TRequest, ports: BusinessRequestPorts) => Response | Promise<Response>): ComposedRouteHandler<TRequest>;
|
|
25
28
|
/** Web group (CSRF + flash + HTML errors) plus register throttle. Do not wrap with wrapWeb again. */
|
|
26
|
-
export declare function wrapWebRegister<TRequest extends Request = Request>(kernel: HttpKernel, handler:
|
|
29
|
+
export declare function wrapWebRegister<TRequest extends Request = Request>(kernel: HttpKernel, handler: BusinessRouteHandler<TRequest>, onThrottled: (request: TRequest, ports: BusinessRequestPorts) => Response | Promise<Response>): ComposedRouteHandler<TRequest>;
|
|
27
30
|
/** Convenience alias for `createHttpKernel`. */
|
|
28
31
|
export declare function createRouteKernel(dependencies: AppDependencies): HttpKernel;
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import { type CorsOptions } from "@getstrata/core/http/corsMiddleware";
|
|
2
2
|
import type { LifecycleCoordinator } from "@getstrata/core/lifecycle/gracefulShutdown";
|
|
3
|
+
import type { WebErrorView } from "@getstrata/core/view";
|
|
3
4
|
import type { BunRequest, Serve, Server } from "bun";
|
|
4
5
|
import type { AppRouteMap } from "../contracts.ts";
|
|
6
|
+
import type { BusinessRequestPorts, BusinessRouteHandler } from "../persistenceContracts";
|
|
5
7
|
export type NativeServerOptions<T = unknown> = Omit<Serve.HostnamePortServeOptions<T>, "port"> & {
|
|
6
8
|
websocket?: Bun.WebSocketHandler<T>;
|
|
7
9
|
};
|
|
10
|
+
type RequestInterception = Response | void;
|
|
8
11
|
export interface WebServerOptions<T = unknown> {
|
|
9
12
|
port: number;
|
|
10
|
-
|
|
13
|
+
/** Environment adapter input captured before transport acquisition. */
|
|
14
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
15
|
+
enter?: (request: Request, handler: BusinessRouteHandler) => Promise<Response>;
|
|
16
|
+
handle?: (request: Request, server: Server<T>, ports?: BusinessRequestPorts) => Promise<Response | null | undefined> | Response | null | undefined;
|
|
11
17
|
/** Bun transport options. Framework dispatch and route composition remain owned here. */
|
|
12
18
|
native?: NativeServerOptions<T>;
|
|
13
|
-
lifecycle?: LifecycleCoordinator
|
|
19
|
+
lifecycle?: Pick<LifecycleCoordinator, "isShuttingDown" | "register">;
|
|
14
20
|
routes?: AppRouteMap;
|
|
15
21
|
publicDir?: string;
|
|
22
|
+
/** Owned renderer for transport fallbacks, including missing public assets. */
|
|
23
|
+
errorView?: WebErrorView;
|
|
16
24
|
/** Additional approved headers for synthesized route preflights; origins still use framework policy. */
|
|
17
25
|
cors?: CorsOptions;
|
|
18
|
-
onRequest?: (request: Request, server: Server<T
|
|
26
|
+
onRequest?: (request: Request, server: Server<T>, ports?: BusinessRequestPorts) => Promise<RequestInterception> | RequestInterception;
|
|
19
27
|
}
|
|
20
28
|
type TrackRequest = <T>(work: () => Promise<T>) => Promise<T>;
|
|
21
29
|
type BunRouteHandler<T = unknown> = (request: BunRequest, server: Server<T>) => Response | Promise<Response>;
|
|
22
|
-
declare function convertAppRoutesToBunRoutes<T = unknown>(routes: AppRouteMap, cors?: CorsOptions, onRequest?: WebServerOptions<T>["onRequest"], track?: TrackRequest): Record<string, Record<string, BunRouteHandler<T>>>;
|
|
30
|
+
declare function convertAppRoutesToBunRoutes<T = unknown>(routes: AppRouteMap, cors?: CorsOptions, onRequest?: WebServerOptions<T>["onRequest"], track?: TrackRequest, enter?: WebServerOptions<T>["enter"], validate?: (request: Request, server: Server<T>) => Response | undefined): Record<string, Record<string, BunRouteHandler<T>>>;
|
|
23
31
|
export declare function createWebServer<T = unknown>(options: WebServerOptions<T>): Server<T>;
|
|
24
32
|
export { convertAppRoutesToBunRoutes };
|
|
33
|
+
/** Native transport descriptor owned by the same Application journal as persistence. */
|
|
34
|
+
export declare function webServerResource<T = unknown>(options: Omit<WebServerOptions<T>, "lifecycle">): import("@getstrata/core/contracts/application").ResourceSpec<Server<T>>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { AuthUser } from "@getstrata/core/auth/authContext";
|
|
2
|
-
import { type AuthGuard, AuthManager } from "@getstrata/core/auth/guard";
|
|
2
|
+
import { type AuthGuard, AuthManager, type AuthOutcome } from "@getstrata/core/auth/guard";
|
|
3
|
+
import type { ScopedPolicy } from "@getstrata/core/contracts/persistence";
|
|
4
|
+
import type { DatabaseSession, TransactionSession } from "@getstrata/core/database/session";
|
|
5
|
+
type Selected = DatabaseSession | TransactionSession;
|
|
3
6
|
export interface SessionUser {
|
|
4
7
|
id: number;
|
|
5
8
|
name: string;
|
|
@@ -10,11 +13,7 @@ export interface SessionUser {
|
|
|
10
13
|
auth_version?: number;
|
|
11
14
|
email_verified_at?: Date | string | null;
|
|
12
15
|
}
|
|
13
|
-
type
|
|
14
|
-
unsafe<T>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
15
|
-
};
|
|
16
|
-
type SqlSource = SqlClient | (() => SqlClient);
|
|
17
|
-
export type LoadSessionUser = (sql: SqlClient, sessionId: string) => Promise<SessionUser | null>;
|
|
16
|
+
export type LoadSessionUser = (sql: Selected, policy: ScopedPolicy, rls: boolean, sessionId: string) => Promise<SessionUser | null>;
|
|
18
17
|
export interface SessionCreateMeta {
|
|
19
18
|
userAgent?: string | null;
|
|
20
19
|
ipAddress?: string | null;
|
|
@@ -27,26 +26,30 @@ export interface BrowserSessionRecord {
|
|
|
27
26
|
last_active_at: Date | string | null;
|
|
28
27
|
expires_at: Date | string;
|
|
29
28
|
}
|
|
30
|
-
declare function defaultSessionSql(): SqlClient;
|
|
31
29
|
export type MapSessionUser = (user: SessionUser) => AuthUser;
|
|
32
30
|
declare function defaultMapSessionUser(user: SessionUser): AuthUser;
|
|
33
31
|
export declare class CookieSessionStore {
|
|
34
|
-
private readonly
|
|
32
|
+
private readonly selected;
|
|
33
|
+
private readonly policy;
|
|
35
34
|
private readonly secret;
|
|
35
|
+
private readonly config;
|
|
36
36
|
private readonly cookieName;
|
|
37
37
|
private readonly maxAgeSeconds;
|
|
38
38
|
private readonly loadSessionUser;
|
|
39
|
-
constructor(
|
|
39
|
+
constructor(selected: Selected, policy: ScopedPolicy, secret: string, config: {
|
|
40
|
+
production: boolean;
|
|
41
|
+
rls: boolean;
|
|
42
|
+
}, cookieName?: string, maxAgeSeconds?: number, loadSessionUser?: LoadSessionUser);
|
|
40
43
|
cookieHeader(_user: SessionUser, sessionId: string): string;
|
|
41
44
|
clearCookieHeader(): string;
|
|
45
|
+
hasCredential(request: Request): boolean;
|
|
42
46
|
sessionIdFromRequest(request: Request): string | null;
|
|
43
47
|
private withSecureFlag;
|
|
44
|
-
private sql;
|
|
45
48
|
create(user: SessionUser, meta?: SessionCreateMeta): Promise<string>;
|
|
46
49
|
destroy(sessionId: string): Promise<void>;
|
|
47
50
|
destroyAllSessions(userId: number): Promise<void>;
|
|
48
51
|
destroyOtherSessions(userId: number, keepSessionId: string): Promise<void>;
|
|
49
|
-
listForUser(userId: number): Promise<BrowserSessionRecord[]>;
|
|
52
|
+
listForUser(userId: number): Promise<readonly BrowserSessionRecord[]>;
|
|
50
53
|
touch(sessionId: string): Promise<void>;
|
|
51
54
|
read(request: Request): Promise<SessionUser | null>;
|
|
52
55
|
private sign;
|
|
@@ -55,7 +58,9 @@ export declare class CookieSessionGuard implements AuthGuard {
|
|
|
55
58
|
private readonly store;
|
|
56
59
|
private readonly mapUser;
|
|
57
60
|
constructor(store: CookieSessionStore, mapUser?: MapSessionUser);
|
|
61
|
+
authenticate(request: Request): Promise<AuthOutcome>;
|
|
58
62
|
resolve(request: Request): Promise<AuthUser | null>;
|
|
63
|
+
private resolveUser;
|
|
59
64
|
}
|
|
60
65
|
export declare class CookieSessionAuthManager extends AuthManager {
|
|
61
66
|
readonly store: CookieSessionStore;
|
|
@@ -71,13 +76,15 @@ export declare class CookieSessionAuthManager extends AuthManager {
|
|
|
71
76
|
signOutRedirect(request: Request, location: string, status?: number): Promise<Response>;
|
|
72
77
|
}
|
|
73
78
|
export interface CreateCookieSessionAuthManagerOptions {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
secret
|
|
79
|
+
selected: Selected;
|
|
80
|
+
policy: ScopedPolicy;
|
|
81
|
+
secret: string;
|
|
82
|
+
production: boolean;
|
|
83
|
+
rls: boolean;
|
|
77
84
|
cookieName?: string;
|
|
78
85
|
maxAgeSeconds?: number;
|
|
79
86
|
mapUser?: MapSessionUser;
|
|
80
87
|
loadSessionUser?: LoadSessionUser;
|
|
81
88
|
}
|
|
82
|
-
declare function createCookieSessionAuthManager(options
|
|
83
|
-
export {
|
|
89
|
+
export declare function createCookieSessionAuthManager(options: CreateCookieSessionAuthManagerOptions): CookieSessionAuthManager;
|
|
90
|
+
export { defaultMapSessionUser };
|