@getstrata/bootstrap 0.2.20 → 0.2.21

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.
@@ -1 +1 @@
1
- export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../core/runtime/applicationRegistry.ts";
1
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationEventBus, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../core/runtime/applicationRegistry.ts";
@@ -4,7 +4,7 @@ declare const CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
4
4
  declare const CACHE_DRIVER_CONFIG_KEY = "cache.driver";
5
5
  declare const REDIS_URL_CONFIG_KEY = "cache.redisUrl";
6
6
  declare const DATABASE_URL_CONFIG_KEY = "database.url";
7
- export { CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, } from "../core/contracts/serviceTokens.ts";
7
+ export { CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, } from "../core/contracts/serviceTokens.ts";
8
8
  declare const AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
9
9
  declare const DEFAULT_APP_PORT = 3000;
10
10
  declare const DEFAULT_CACHE_TTL_MS = 3600000;
@@ -1,5 +1,5 @@
1
+ import { CORE_EVENT_BUS_TOKEN } from "../config";
1
2
  import type { ServiceProvider } from "../contracts";
2
- declare const CORE_EVENT_BUS_TOKEN = "core.eventBus";
3
3
  declare const eventsProvider: ServiceProvider;
4
4
  export default eventsProvider;
5
5
  export { CORE_EVENT_BUS_TOKEN };
@@ -4,17 +4,20 @@
4
4
  export { scheduleRunCommand } from "../cli/commands/scheduleRun.ts";
5
5
  export type { ScheduledTask } from "../core/scheduler/schedule.ts";
6
6
  export { appSchedule, runDueScheduledTasks, Schedule } from "../core/scheduler/schedule.ts";
7
- export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "./applicationRegistry.ts";
7
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationEventBus, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "./applicationRegistry.ts";
8
8
  export { cacheTagsForModelWrite, discoverModelTableNames } from "./cache/modelCacheTags.ts";
9
- export { APP_PORT_CONFIG_KEY, CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, DATABASE_URL_CONFIG_KEY, DEFAULT_APP_PORT, REDIS_URL_CONFIG_KEY, } from "./config.ts";
9
+ export { APP_PORT_CONFIG_KEY, CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, DATABASE_URL_CONFIG_KEY, DEFAULT_APP_PORT, REDIS_URL_CONFIG_KEY, } from "./config.ts";
10
10
  export { collectProviders, createAppContext, runProviderPhase } from "./context.ts";
11
11
  export type { AppContext, AppDependencies, AppModule, AppRouteMap, CachedJson, ConfigStore, ModuleRouteContext, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, } from "./contracts.ts";
12
12
  export { assertAppDependenciesComplete, getRequiredDependency, resolveService, ServiceContainer, } from "./contracts.ts";
13
13
  export { createWebRoutes, mergeWebRoutes } from "./createWebRoutes.ts";
14
+ export { createAppDependencies } from "./dependencies.ts";
14
15
  export { type RouteModelAuthorization, securedBindRouteModel, securedBindRouteModelByKey, } from "./http/securedRouteModelBinding.ts";
15
16
  export { createHttpKernel, type HttpKernel, type MiddlewareGroupName } from "./httpKernel.ts";
16
17
  export { resolveMembershipService } from "./membershipService.ts";
17
18
  export { prefixRouteMap } from "./prefixRouteMap.ts";
18
19
  export { coreProviders } from "./providers/index.ts";
19
20
  export { registerDefaultJobs } from "./queue/defaultJobs.ts";
21
+ export { RouteRegistry, routeRegistry } from "./routeRegistry.ts";
22
+ export { assertProductionSecrets } from "./secretsGuard.ts";
20
23
  export { CookieSessionStore, createCsrfProtection, createRouteKernel, createWebServer, type ParsedForm, parseFormBody, routeParams, type SessionUser, slugify, toRouteRequest, type WebServerOptions, wrapSecuredRouteModelByKey, wrapWebLogin, wrapWebRegister, } from "./web/index.ts";
@@ -1,7 +1,8 @@
1
1
  declare const CORE_CONFIG_TOKEN = "core.config";
2
2
  declare const CORE_CACHE_TOKEN = "core.cache";
3
3
  declare const CORE_QUEUE_TOKEN = "core.queue";
4
+ declare const CORE_EVENT_BUS_TOKEN = "core.eventBus";
4
5
  declare const CORE_POLICY_GATE_TOKEN = "core.policyGate";
5
6
  declare const CORE_AUTH_TOKEN = "core.auth";
6
7
  declare const CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
7
- export { CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, };
8
+ export { CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, };
@@ -2,14 +2,16 @@ import type { CacheLike } from "../../types/services";
2
2
  import type { AuthManager } from "../auth/guard";
3
3
  import type { PolicyGate } from "../auth/policy";
4
4
  import type { AppContext } from "../contracts/di";
5
+ import type { EventBus } from "../events";
5
6
  import { type Logger } from "../logging/logger";
6
7
  import type { Queue } from "../queue";
7
8
  declare function setActiveApplicationContext(context: AppContext): void;
8
9
  declare function resolveApplicationCache(): CacheLike;
9
10
  declare function resolveApplicationQueue(): Queue;
11
+ declare function resolveApplicationEventBus(): EventBus;
10
12
  declare function resolveApplicationAuth(): AuthManager;
11
13
  declare function resolveApplicationPolicyGate(): PolicyGate;
12
14
  declare function resolveApplicationConfig(): import("../contracts/container").ConfigStoreLike;
13
15
  declare function resolveApplicationLogger(): Logger;
14
16
  declare function resolveApplicationDependencies(): import("../contracts/di").AppDependencies;
15
- export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, };
17
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationEventBus, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, };
@@ -25,6 +25,7 @@ function resolveService(dependencies, token) {
25
25
  var CORE_CONFIG_TOKEN = "core.config";
26
26
  var CORE_CACHE_TOKEN = "core.cache";
27
27
  var CORE_QUEUE_TOKEN = "core.queue";
28
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
28
29
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
29
30
  var CORE_AUTH_TOKEN = "core.auth";
30
31
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -95,6 +96,9 @@ function resolveApplicationCache() {
95
96
  function resolveApplicationQueue() {
96
97
  return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
97
98
  }
99
+ function resolveApplicationEventBus() {
100
+ return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
101
+ }
98
102
  function resolveApplicationAuth() {
99
103
  return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
100
104
  }
@@ -115,6 +119,7 @@ export {
115
119
  resolveApplicationQueue,
116
120
  resolveApplicationPolicyGate,
117
121
  resolveApplicationLogger,
122
+ resolveApplicationEventBus,
118
123
  resolveApplicationDependencies,
119
124
  resolveApplicationConfig,
120
125
  resolveApplicationCache,
@@ -3,6 +3,7 @@
3
3
  var CORE_CONFIG_TOKEN = "core.config";
4
4
  var CORE_CACHE_TOKEN = "core.cache";
5
5
  var CORE_QUEUE_TOKEN = "core.queue";
6
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
6
7
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
7
8
  var CORE_AUTH_TOKEN = "core.auth";
8
9
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -33,6 +34,7 @@ export {
33
34
  CORE_TOKEN_SERVICE_TOKEN,
34
35
  CORE_QUEUE_TOKEN,
35
36
  CORE_POLICY_GATE_TOKEN,
37
+ CORE_EVENT_BUS_TOKEN,
36
38
  CORE_CONFIG_TOKEN,
37
39
  CORE_CACHE_TOKEN,
38
40
  CORE_AUTH_TOKEN,
@@ -25,6 +25,7 @@ function resolveService(dependencies, token) {
25
25
  var CORE_CONFIG_TOKEN = "core.config";
26
26
  var CORE_CACHE_TOKEN = "core.cache";
27
27
  var CORE_QUEUE_TOKEN = "core.queue";
28
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
28
29
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
29
30
  var CORE_AUTH_TOKEN = "core.auth";
30
31
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -95,6 +96,9 @@ function resolveApplicationCache() {
95
96
  function resolveApplicationQueue() {
96
97
  return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
97
98
  }
99
+ function resolveApplicationEventBus() {
100
+ return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
101
+ }
98
102
  function resolveApplicationAuth() {
99
103
  return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
100
104
  }
@@ -1449,7 +1453,6 @@ function modelEventName(tableName, action) {
1449
1453
  }
1450
1454
 
1451
1455
  // ../../src/bootstrap/providers/events.ts
1452
- var CORE_EVENT_BUS_TOKEN = "core.eventBus";
1453
1456
  var eventsProvider = {
1454
1457
  name: "core.events",
1455
1458
  register({ container }) {
@@ -114,6 +114,7 @@ function htmlResponse(html, init = {}) {
114
114
  var CORE_CONFIG_TOKEN = "core.config";
115
115
  var CORE_CACHE_TOKEN = "core.cache";
116
116
  var CORE_QUEUE_TOKEN = "core.queue";
117
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
117
118
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
118
119
  var CORE_AUTH_TOKEN = "core.auth";
119
120
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -924,7 +925,17 @@ class RouteRegistry {
924
925
  return [...this.routes].sort((left, right) => left.path.localeCompare(right.path));
925
926
  }
926
927
  }
927
- var routeRegistry = new RouteRegistry;
928
+ var ROUTE_REGISTRY_KEY = Symbol.for("@getstrata/routeRegistry");
929
+ function readSharedRouteRegistry() {
930
+ const globalRegistry = globalThis[ROUTE_REGISTRY_KEY];
931
+ if (globalRegistry) {
932
+ return globalRegistry;
933
+ }
934
+ const registry = new RouteRegistry;
935
+ globalThis[ROUTE_REGISTRY_KEY] = registry;
936
+ return registry;
937
+ }
938
+ var routeRegistry = readSharedRouteRegistry();
928
939
 
929
940
  // ../../src/bootstrap/createWebRoutes.ts
930
941
  function registerRoute(method, path, middleware) {