@getstrata/bootstrap 0.2.12 → 0.2.13

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,16 +1 @@
1
- import type { AuthManager } from "../core/auth/guard";
2
- import type { PolicyGate } from "../core/auth/policy";
3
- import { type Logger } from "../core/logging/logger";
4
- import type { Queue } from "../core/queue";
5
- import type { CacheLike } from "../types/services";
6
- import type { AppContext } from "./contracts";
7
- import { type ConfigStore } from "./contracts";
8
- declare function setActiveApplicationContext(context: AppContext): void;
9
- declare function resolveApplicationCache(): CacheLike;
10
- declare function resolveApplicationQueue(): Queue;
11
- declare function resolveApplicationAuth(): AuthManager;
12
- declare function resolveApplicationPolicyGate(): PolicyGate;
13
- declare function resolveApplicationConfig(): ConfigStore;
14
- declare function resolveApplicationLogger(): Logger;
15
- declare function resolveApplicationDependencies(): import("./contracts").AppDependencies;
16
- export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, };
1
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../core/runtime/applicationRegistry.ts";
@@ -4,12 +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
- declare const CORE_CONFIG_TOKEN = "core.config";
8
- declare const CORE_CACHE_TOKEN = "core.cache";
9
- declare const CORE_QUEUE_TOKEN = "core.queue";
10
- declare const CORE_POLICY_GATE_TOKEN = "core.policyGate";
11
- declare const CORE_AUTH_TOKEN = "core.auth";
12
- 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, } from "../core/contracts/serviceTokens.ts";
13
8
  declare const AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
14
9
  declare const DEFAULT_APP_PORT = 3000;
15
10
  declare const DEFAULT_CACHE_TTL_MS = 3600000;
@@ -17,4 +12,4 @@ declare const DEFAULT_CACHE_MAX_ENTRIES = 100;
17
12
  declare const DEFAULT_CACHE_DRIVER = "array";
18
13
  declare const DEFAULT_API_TOKEN = "";
19
14
  declare const DEFAULT_QUEUE_DRIVER = "sync";
20
- export { APP_PORT_CONFIG_KEY, AUTH_DEV_HEADERS_CONFIG_KEY, CACHE_DRIVER_CONFIG_KEY, CACHE_MAX_ENTRIES_CONFIG_KEY, CACHE_TTL_MS_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_API_TOKEN, DEFAULT_APP_PORT, DEFAULT_CACHE_DRIVER, DEFAULT_CACHE_MAX_ENTRIES, DEFAULT_CACHE_TTL_MS, DEFAULT_QUEUE_DRIVER, REDIS_URL_CONFIG_KEY, };
15
+ export { APP_PORT_CONFIG_KEY, AUTH_DEV_HEADERS_CONFIG_KEY, CACHE_DRIVER_CONFIG_KEY, CACHE_MAX_ENTRIES_CONFIG_KEY, CACHE_TTL_MS_CONFIG_KEY, DATABASE_URL_CONFIG_KEY, DEFAULT_API_TOKEN, DEFAULT_APP_PORT, DEFAULT_CACHE_DRIVER, DEFAULT_CACHE_MAX_ENTRIES, DEFAULT_CACHE_TTL_MS, DEFAULT_QUEUE_DRIVER, REDIS_URL_CONFIG_KEY, };
@@ -0,0 +1,18 @@
1
+ import type { CacheLike } from "../../types/services";
2
+ import type { ServiceContainerLike } from "./serviceContainer";
3
+ interface ConfigStoreLike {
4
+ get<T>(key: string): T | undefined;
5
+ }
6
+ interface ApplicationDependenciesLike {
7
+ container: ServiceContainerLike;
8
+ cache: CacheLike;
9
+ storage?: unknown;
10
+ }
11
+ interface ApplicationContext {
12
+ container: ServiceContainerLike;
13
+ config: ConfigStoreLike;
14
+ dependencies: ApplicationDependenciesLike;
15
+ }
16
+ declare function getRequiredDependency<K extends keyof ApplicationDependenciesLike>(dependencies: Partial<ApplicationDependenciesLike>, key: K): ApplicationDependenciesLike[K];
17
+ export type { ApplicationContext, ApplicationDependenciesLike, ConfigStoreLike };
18
+ export { getRequiredDependency };
@@ -0,0 +1,7 @@
1
+ declare const CORE_CONFIG_TOKEN = "core.config";
2
+ declare const CORE_CACHE_TOKEN = "core.cache";
3
+ declare const CORE_QUEUE_TOKEN = "core.queue";
4
+ declare const CORE_POLICY_GATE_TOKEN = "core.policyGate";
5
+ declare const CORE_AUTH_TOKEN = "core.auth";
6
+ 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, };
@@ -0,0 +1,15 @@
1
+ import type { CacheLike } from "../../types/services";
2
+ import type { AuthManager } from "../auth/guard";
3
+ import type { PolicyGate } from "../auth/policy";
4
+ import type { ApplicationContext } from "../contracts/applicationContext";
5
+ import { type Logger } from "../logging/logger";
6
+ import type { Queue } from "../queue";
7
+ declare function setActiveApplicationContext(context: ApplicationContext): void;
8
+ declare function resolveApplicationCache(): CacheLike;
9
+ declare function resolveApplicationQueue(): Queue;
10
+ declare function resolveApplicationAuth(): AuthManager;
11
+ declare function resolveApplicationPolicyGate(): PolicyGate;
12
+ declare function resolveApplicationConfig(): import("../contracts/applicationContext").ConfigStoreLike;
13
+ declare function resolveApplicationLogger(): Logger;
14
+ declare function resolveApplicationDependencies(): import("../contracts/applicationContext").ApplicationDependenciesLike;
15
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, };
@@ -1,4 +1,21 @@
1
1
  // @bun
2
+ // ../../src/core/contracts/applicationContext.ts
3
+ function getRequiredDependency(dependencies, key) {
4
+ const dependency = dependencies[key];
5
+ if (dependency === undefined) {
6
+ throw new Error(`Required dependency "${String(key)}" is not registered.`);
7
+ }
8
+ return dependency;
9
+ }
10
+
11
+ // ../../src/core/contracts/serviceTokens.ts
12
+ var CORE_CONFIG_TOKEN = "core.config";
13
+ var CORE_CACHE_TOKEN = "core.cache";
14
+ var CORE_QUEUE_TOKEN = "core.queue";
15
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
16
+ var CORE_AUTH_TOKEN = "core.auth";
17
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
18
+
2
19
  // ../../src/core/logging/logger.ts
3
20
  class Logger {
4
21
  channel;
@@ -35,113 +52,7 @@ class Logger {
35
52
  }
36
53
  var appLogger = new Logger("app");
37
54
 
38
- // ../../src/bootstrap/config.ts
39
- var APP_PORT_CONFIG_KEY = "app.port";
40
- var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
41
- var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
42
- var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
43
- var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
44
- var DATABASE_URL_CONFIG_KEY = "database.url";
45
- var CORE_CONFIG_TOKEN = "core.config";
46
- var CORE_CACHE_TOKEN = "core.cache";
47
- var CORE_QUEUE_TOKEN = "core.queue";
48
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
49
- var CORE_AUTH_TOKEN = "core.auth";
50
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
51
- var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
52
- var DEFAULT_APP_PORT = 3000;
53
- var DEFAULT_CACHE_TTL_MS = 3600000;
54
- var DEFAULT_CACHE_MAX_ENTRIES = 100;
55
- var DEFAULT_CACHE_DRIVER = "array";
56
- var DEFAULT_API_TOKEN = "";
57
- var DEFAULT_QUEUE_DRIVER = "sync";
58
-
59
- // ../../src/bootstrap/contracts.ts
60
- class ServiceContainer {
61
- services = new Map;
62
- singletonFactories = new Map;
63
- bindings = new Map;
64
- set(key, value) {
65
- this.singletonFactories.delete(key);
66
- this.bindings.delete(key);
67
- this.services.set(key, value);
68
- return value;
69
- }
70
- singleton(key, factory) {
71
- this.bindings.delete(key);
72
- this.services.delete(key);
73
- this.singletonFactories.set(key, factory);
74
- }
75
- bind(key, factory) {
76
- this.singletonFactories.delete(key);
77
- this.services.delete(key);
78
- this.bindings.set(key, factory);
79
- }
80
- get(key) {
81
- if (this.services.has(key)) {
82
- return this.services.get(key);
83
- }
84
- const singletonFactory = this.singletonFactories.get(key);
85
- if (singletonFactory) {
86
- const value = singletonFactory(this);
87
- this.services.set(key, value);
88
- return value;
89
- }
90
- const binding = this.bindings.get(key);
91
- if (binding) {
92
- return binding(this);
93
- }
94
- throw new Error(`Service "${key}" is not registered.`);
95
- }
96
- resolve(key) {
97
- return this.get(key);
98
- }
99
- has(key) {
100
- return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
101
- }
102
- }
103
-
104
- class ConfigStore {
105
- values = new Map;
106
- set(key, value) {
107
- this.values.set(key, value);
108
- return value;
109
- }
110
- get(key) {
111
- return this.values.get(key);
112
- }
113
- require(key) {
114
- if (!this.values.has(key)) {
115
- throw new Error(`Config key "${key}" is not defined.`);
116
- }
117
- return this.values.get(key);
118
- }
119
- has(key) {
120
- return this.values.has(key);
121
- }
122
- }
123
- var requiredDependencyKeys = [
124
- "container",
125
- "cache",
126
- "storage"
127
- ];
128
- function getRequiredDependency(dependencies, key) {
129
- const dependency = dependencies[key];
130
- if (dependency === undefined) {
131
- throw new Error(`Required dependency "${key}" is not registered.`);
132
- }
133
- return dependency;
134
- }
135
- function assertAppDependenciesComplete(dependencies) {
136
- for (const key of requiredDependencyKeys) {
137
- getRequiredDependency(dependencies, key);
138
- }
139
- }
140
- function resolveService(dependencies, token) {
141
- return dependencies.container.resolve(token);
142
- }
143
-
144
- // ../../src/bootstrap/applicationRegistry.ts
55
+ // ../../src/core/runtime/applicationRegistry.ts
145
56
  var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
146
57
  var activeContext;
147
58
  function readStoredApplicationContext() {
@@ -1,4 +1,12 @@
1
1
  // @bun
2
+ // ../../src/core/contracts/serviceTokens.ts
3
+ var CORE_CONFIG_TOKEN = "core.config";
4
+ var CORE_CACHE_TOKEN = "core.cache";
5
+ var CORE_QUEUE_TOKEN = "core.queue";
6
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
7
+ var CORE_AUTH_TOKEN = "core.auth";
8
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
9
+
2
10
  // ../../src/bootstrap/config.ts
3
11
  var APP_PORT_CONFIG_KEY = "app.port";
4
12
  var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
@@ -6,12 +14,6 @@ var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
6
14
  var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
7
15
  var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
8
16
  var DATABASE_URL_CONFIG_KEY = "database.url";
9
- var CORE_CONFIG_TOKEN = "core.config";
10
- var CORE_CACHE_TOKEN = "core.cache";
11
- var CORE_QUEUE_TOKEN = "core.queue";
12
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
13
- var CORE_AUTH_TOKEN = "core.auth";
14
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
15
17
  var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
16
18
  var DEFAULT_APP_PORT = 3000;
17
19
  var DEFAULT_CACHE_TTL_MS = 3600000;
@@ -1,4 +1,21 @@
1
1
  // @bun
2
+ // ../../src/core/contracts/applicationContext.ts
3
+ function getRequiredDependency(dependencies, key) {
4
+ const dependency = dependencies[key];
5
+ if (dependency === undefined) {
6
+ throw new Error(`Required dependency "${String(key)}" is not registered.`);
7
+ }
8
+ return dependency;
9
+ }
10
+
11
+ // ../../src/core/contracts/serviceTokens.ts
12
+ var CORE_CONFIG_TOKEN = "core.config";
13
+ var CORE_CACHE_TOKEN = "core.cache";
14
+ var CORE_QUEUE_TOKEN = "core.queue";
15
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
16
+ var CORE_AUTH_TOKEN = "core.auth";
17
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
18
+
2
19
  // ../../src/core/logging/logger.ts
3
20
  class Logger {
4
21
  channel;
@@ -35,27 +52,51 @@ class Logger {
35
52
  }
36
53
  var appLogger = new Logger("app");
37
54
 
38
- // ../../src/bootstrap/config.ts
39
- var APP_PORT_CONFIG_KEY = "app.port";
40
- var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
41
- var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
42
- var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
43
- var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
44
- var DATABASE_URL_CONFIG_KEY = "database.url";
45
- var CORE_CONFIG_TOKEN = "core.config";
46
- var CORE_CACHE_TOKEN = "core.cache";
47
- var CORE_QUEUE_TOKEN = "core.queue";
48
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
49
- var CORE_AUTH_TOKEN = "core.auth";
50
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
51
- var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
52
- var DEFAULT_APP_PORT = 3000;
53
- var DEFAULT_CACHE_TTL_MS = 3600000;
54
- var DEFAULT_CACHE_MAX_ENTRIES = 100;
55
- var DEFAULT_CACHE_DRIVER = "array";
56
- var DEFAULT_API_TOKEN = "";
57
- var DEFAULT_QUEUE_DRIVER = "sync";
58
-
55
+ // ../../src/core/runtime/applicationRegistry.ts
56
+ var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
57
+ var activeContext;
58
+ function readStoredApplicationContext() {
59
+ if (activeContext) {
60
+ return activeContext;
61
+ }
62
+ const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
63
+ if (globalContext) {
64
+ activeContext = globalContext;
65
+ }
66
+ return activeContext;
67
+ }
68
+ function setActiveApplicationContext(context) {
69
+ activeContext = context;
70
+ globalThis[APPLICATION_CONTEXT_KEY] = context;
71
+ }
72
+ function requireActiveApplicationContext() {
73
+ const context = readStoredApplicationContext();
74
+ if (!context) {
75
+ throw new Error("The application context has not been bootstrapped.");
76
+ }
77
+ return context;
78
+ }
79
+ function resolveApplicationCache() {
80
+ return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
81
+ }
82
+ function resolveApplicationQueue() {
83
+ return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
84
+ }
85
+ function resolveApplicationAuth() {
86
+ return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
87
+ }
88
+ function resolveApplicationPolicyGate() {
89
+ return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
90
+ }
91
+ function resolveApplicationConfig() {
92
+ return requireActiveApplicationContext().config;
93
+ }
94
+ function resolveApplicationLogger() {
95
+ return appLogger;
96
+ }
97
+ function resolveApplicationDependencies() {
98
+ return requireActiveApplicationContext().dependencies;
99
+ }
59
100
  // ../../src/bootstrap/contracts.ts
60
101
  class ServiceContainer {
61
102
  services = new Map;
@@ -125,7 +166,7 @@ var requiredDependencyKeys = [
125
166
  "cache",
126
167
  "storage"
127
168
  ];
128
- function getRequiredDependency(dependencies, key) {
169
+ function getRequiredDependency2(dependencies, key) {
129
170
  const dependency = dependencies[key];
130
171
  if (dependency === undefined) {
131
172
  throw new Error(`Required dependency "${key}" is not registered.`);
@@ -134,59 +175,13 @@ function getRequiredDependency(dependencies, key) {
134
175
  }
135
176
  function assertAppDependenciesComplete(dependencies) {
136
177
  for (const key of requiredDependencyKeys) {
137
- getRequiredDependency(dependencies, key);
178
+ getRequiredDependency2(dependencies, key);
138
179
  }
139
180
  }
140
181
  function resolveService(dependencies, token) {
141
182
  return dependencies.container.resolve(token);
142
183
  }
143
184
 
144
- // ../../src/bootstrap/applicationRegistry.ts
145
- var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
146
- var activeContext;
147
- function readStoredApplicationContext() {
148
- if (activeContext) {
149
- return activeContext;
150
- }
151
- const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
152
- if (globalContext) {
153
- activeContext = globalContext;
154
- }
155
- return activeContext;
156
- }
157
- function setActiveApplicationContext(context) {
158
- activeContext = context;
159
- globalThis[APPLICATION_CONTEXT_KEY] = context;
160
- }
161
- function requireActiveApplicationContext() {
162
- const context = readStoredApplicationContext();
163
- if (!context) {
164
- throw new Error("The application context has not been bootstrapped.");
165
- }
166
- return context;
167
- }
168
- function resolveApplicationCache() {
169
- return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
170
- }
171
- function resolveApplicationQueue() {
172
- return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
173
- }
174
- function resolveApplicationAuth() {
175
- return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
176
- }
177
- function resolveApplicationPolicyGate() {
178
- return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
179
- }
180
- function resolveApplicationConfig() {
181
- return requireActiveApplicationContext().config;
182
- }
183
- function resolveApplicationLogger() {
184
- return appLogger;
185
- }
186
- function resolveApplicationDependencies() {
187
- return requireActiveApplicationContext().dependencies;
188
- }
189
-
190
185
  // ../../src/bootstrap/discoverModules.ts
191
186
  var appModules = [];
192
187
  function discoverModules() {
@@ -236,6 +231,21 @@ function resolveAbilitiesForRole(role) {
236
231
  return [...MEMBER_ABILITIES];
237
232
  }
238
233
 
234
+ // ../../src/bootstrap/config.ts
235
+ var APP_PORT_CONFIG_KEY = "app.port";
236
+ var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
237
+ var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
238
+ var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
239
+ var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
240
+ var DATABASE_URL_CONFIG_KEY = "database.url";
241
+ var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
242
+ var DEFAULT_APP_PORT = 3000;
243
+ var DEFAULT_CACHE_TTL_MS = 3600000;
244
+ var DEFAULT_CACHE_MAX_ENTRIES = 100;
245
+ var DEFAULT_CACHE_DRIVER = "array";
246
+ var DEFAULT_API_TOKEN = "";
247
+ var DEFAULT_QUEUE_DRIVER = "sync";
248
+
239
249
  // ../../src/modules/user/provider.ts
240
250
  import { OidcProvider } from "@getstrata/core/auth/oauth/oidcProvider";
241
251
  import { GitHubOAuthProvider, MockOAuthProvider } from "@getstrata/core/auth/oauth/providers";
@@ -110,6 +110,14 @@ function htmlResponse(html, init = {}) {
110
110
  }
111
111
  });
112
112
  }
113
+ // ../../src/core/contracts/serviceTokens.ts
114
+ var CORE_CONFIG_TOKEN = "core.config";
115
+ var CORE_CACHE_TOKEN = "core.cache";
116
+ var CORE_QUEUE_TOKEN = "core.queue";
117
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
118
+ var CORE_AUTH_TOKEN = "core.auth";
119
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
120
+
113
121
  // ../../src/bootstrap/config.ts
114
122
  var APP_PORT_CONFIG_KEY = "app.port";
115
123
  var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
@@ -117,12 +125,6 @@ var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
117
125
  var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
118
126
  var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
119
127
  var DATABASE_URL_CONFIG_KEY = "database.url";
120
- var CORE_CONFIG_TOKEN = "core.config";
121
- var CORE_CACHE_TOKEN = "core.cache";
122
- var CORE_QUEUE_TOKEN = "core.queue";
123
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
124
- var CORE_AUTH_TOKEN = "core.auth";
125
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
126
128
  var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
127
129
  var DEFAULT_APP_PORT = 3000;
128
130
  var DEFAULT_CACHE_TTL_MS = 3600000;
@@ -167,6 +167,23 @@ function parsePositiveIntParam(value, name = "id") {
167
167
  return parsed;
168
168
  }
169
169
 
170
+ // ../../src/core/contracts/applicationContext.ts
171
+ function getRequiredDependency(dependencies, key) {
172
+ const dependency = dependencies[key];
173
+ if (dependency === undefined) {
174
+ throw new Error(`Required dependency "${String(key)}" is not registered.`);
175
+ }
176
+ return dependency;
177
+ }
178
+
179
+ // ../../src/core/contracts/serviceTokens.ts
180
+ var CORE_CONFIG_TOKEN = "core.config";
181
+ var CORE_CACHE_TOKEN = "core.cache";
182
+ var CORE_QUEUE_TOKEN = "core.queue";
183
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
184
+ var CORE_AUTH_TOKEN = "core.auth";
185
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
186
+
170
187
  // ../../src/core/logging/logger.ts
171
188
  class Logger {
172
189
  channel;
@@ -203,113 +220,7 @@ class Logger {
203
220
  }
204
221
  var appLogger = new Logger("app");
205
222
 
206
- // ../../src/bootstrap/config.ts
207
- var APP_PORT_CONFIG_KEY = "app.port";
208
- var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
209
- var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
210
- var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
211
- var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
212
- var DATABASE_URL_CONFIG_KEY = "database.url";
213
- var CORE_CONFIG_TOKEN = "core.config";
214
- var CORE_CACHE_TOKEN = "core.cache";
215
- var CORE_QUEUE_TOKEN = "core.queue";
216
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
217
- var CORE_AUTH_TOKEN = "core.auth";
218
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
219
- var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
220
- var DEFAULT_APP_PORT = 3000;
221
- var DEFAULT_CACHE_TTL_MS = 3600000;
222
- var DEFAULT_CACHE_MAX_ENTRIES = 100;
223
- var DEFAULT_CACHE_DRIVER = "array";
224
- var DEFAULT_API_TOKEN = "";
225
- var DEFAULT_QUEUE_DRIVER = "sync";
226
-
227
- // ../../src/bootstrap/contracts.ts
228
- class ServiceContainer {
229
- services = new Map;
230
- singletonFactories = new Map;
231
- bindings = new Map;
232
- set(key, value) {
233
- this.singletonFactories.delete(key);
234
- this.bindings.delete(key);
235
- this.services.set(key, value);
236
- return value;
237
- }
238
- singleton(key, factory) {
239
- this.bindings.delete(key);
240
- this.services.delete(key);
241
- this.singletonFactories.set(key, factory);
242
- }
243
- bind(key, factory) {
244
- this.singletonFactories.delete(key);
245
- this.services.delete(key);
246
- this.bindings.set(key, factory);
247
- }
248
- get(key) {
249
- if (this.services.has(key)) {
250
- return this.services.get(key);
251
- }
252
- const singletonFactory = this.singletonFactories.get(key);
253
- if (singletonFactory) {
254
- const value = singletonFactory(this);
255
- this.services.set(key, value);
256
- return value;
257
- }
258
- const binding = this.bindings.get(key);
259
- if (binding) {
260
- return binding(this);
261
- }
262
- throw new Error(`Service "${key}" is not registered.`);
263
- }
264
- resolve(key) {
265
- return this.get(key);
266
- }
267
- has(key) {
268
- return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
269
- }
270
- }
271
-
272
- class ConfigStore {
273
- values = new Map;
274
- set(key, value) {
275
- this.values.set(key, value);
276
- return value;
277
- }
278
- get(key) {
279
- return this.values.get(key);
280
- }
281
- require(key) {
282
- if (!this.values.has(key)) {
283
- throw new Error(`Config key "${key}" is not defined.`);
284
- }
285
- return this.values.get(key);
286
- }
287
- has(key) {
288
- return this.values.has(key);
289
- }
290
- }
291
- var requiredDependencyKeys = [
292
- "container",
293
- "cache",
294
- "storage"
295
- ];
296
- function getRequiredDependency(dependencies, key) {
297
- const dependency = dependencies[key];
298
- if (dependency === undefined) {
299
- throw new Error(`Required dependency "${key}" is not registered.`);
300
- }
301
- return dependency;
302
- }
303
- function assertAppDependenciesComplete(dependencies) {
304
- for (const key of requiredDependencyKeys) {
305
- getRequiredDependency(dependencies, key);
306
- }
307
- }
308
- function resolveService(dependencies, token) {
309
- return dependencies.container.resolve(token);
310
- }
311
-
312
- // ../../src/bootstrap/applicationRegistry.ts
223
+ // ../../src/core/runtime/applicationRegistry.ts
313
224
  var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
314
225
  var activeContext;
315
226
  function readStoredApplicationContext() {
@@ -354,7 +265,6 @@ function resolveApplicationLogger() {
354
265
  function resolveApplicationDependencies() {
355
266
  return requireActiveApplicationContext().dependencies;
356
267
  }
357
-
358
268
  // ../../src/bootstrap/http/securedRouteModelBinding.ts
359
269
  function isMutatingPolicyAction(action) {
360
270
  return action === "update" || action === "delete";
@@ -74,6 +74,14 @@ function resolveRegisterRateLimit() {
74
74
  };
75
75
  }
76
76
 
77
+ // ../../src/core/contracts/serviceTokens.ts
78
+ var CORE_CONFIG_TOKEN = "core.config";
79
+ var CORE_CACHE_TOKEN = "core.cache";
80
+ var CORE_QUEUE_TOKEN = "core.queue";
81
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
82
+ var CORE_AUTH_TOKEN = "core.auth";
83
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
84
+
77
85
  // ../../src/bootstrap/config.ts
78
86
  var APP_PORT_CONFIG_KEY = "app.port";
79
87
  var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
@@ -81,12 +89,6 @@ var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
81
89
  var CACHE_DRIVER_CONFIG_KEY = "cache.driver";
82
90
  var REDIS_URL_CONFIG_KEY = "cache.redisUrl";
83
91
  var DATABASE_URL_CONFIG_KEY = "database.url";
84
- var CORE_CONFIG_TOKEN = "core.config";
85
- var CORE_CACHE_TOKEN = "core.cache";
86
- var CORE_QUEUE_TOKEN = "core.queue";
87
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
88
- var CORE_AUTH_TOKEN = "core.auth";
89
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
90
92
  var AUTH_DEV_HEADERS_CONFIG_KEY = "auth.allowDevHeaders";
91
93
  var DEFAULT_APP_PORT = 3000;
92
94
  var DEFAULT_CACHE_TTL_MS = 3600000;