@getstrata/bootstrap 0.2.22 → 0.2.23

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.
Files changed (234) hide show
  1. package/dist/bootstrap/applicationRegistry.d.ts +1 -1
  2. package/dist/bootstrap/buildModuleRoutes.d.ts +10 -0
  3. package/dist/bootstrap/config.d.ts +1 -1
  4. package/dist/bootstrap/contracts.d.ts +4 -4
  5. package/dist/bootstrap/public-api.d.ts +2 -0
  6. package/dist/entries/applicationRegistry.js +12 -115
  7. package/dist/entries/buildModuleRoutes.js +626 -0
  8. package/dist/entries/config.js +9 -9
  9. package/dist/entries/context.js +114 -178
  10. package/dist/entries/contracts.js +10 -85
  11. package/dist/entries/createWebRoutes.js +9 -9
  12. package/dist/entries/dependencies.js +114 -178
  13. package/dist/entries/http/securedRouteModelBinding.js +4 -34
  14. package/dist/entries/httpKernel.js +9 -9
  15. package/dist/entries/membershipService.js +0 -34
  16. package/dist/entries/providers/view.js +9 -9
  17. package/dist/entries/providers.js +104 -115
  18. package/dist/entries/queue/defaultJobs.js +0 -34
  19. package/dist/entries/web/routing.js +20 -41
  20. package/dist/index.js +1670 -1659
  21. package/package.json +9 -4
  22. package/dist/cli/commands/scheduleRun.d.ts +0 -3
  23. package/dist/config/app.d.ts +0 -10
  24. package/dist/config/auth.d.ts +0 -7
  25. package/dist/config/contentSecurityPolicy.d.ts +0 -5
  26. package/dist/config/cors.d.ts +0 -9
  27. package/dist/config/database.d.ts +0 -10
  28. package/dist/config/features.d.ts +0 -18
  29. package/dist/config/frontend.d.ts +0 -6
  30. package/dist/config/queue.d.ts +0 -8
  31. package/dist/config/rateLimit.d.ts +0 -10
  32. package/dist/config/uploads.d.ts +0 -5
  33. package/dist/core/admin/formatValue.d.ts +0 -3
  34. package/dist/core/admin/index.d.ts +0 -3
  35. package/dist/core/admin/registry.d.ts +0 -11
  36. package/dist/core/admin/types.d.ts +0 -24
  37. package/dist/core/audit/exportAuditLogs.d.ts +0 -8
  38. package/dist/core/audit/siemFormatter.d.ts +0 -30
  39. package/dist/core/auth/abilityChecker.d.ts +0 -6
  40. package/dist/core/auth/accessControl.d.ts +0 -8
  41. package/dist/core/auth/authContext.d.ts +0 -11
  42. package/dist/core/auth/guard.d.ts +0 -36
  43. package/dist/core/auth/membershipContext.d.ts +0 -15
  44. package/dist/core/auth/membershipContextMiddleware.d.ts +0 -3
  45. package/dist/core/auth/membershipMiddleware.d.ts +0 -2
  46. package/dist/core/auth/membershipScope.d.ts +0 -16
  47. package/dist/core/auth/membershipService.d.ts +0 -23
  48. package/dist/core/auth/oauth/oidcProvider.d.ts +0 -18
  49. package/dist/core/auth/oauth/providers.d.ts +0 -22
  50. package/dist/core/auth/oauth/samlProvider.d.ts +0 -9
  51. package/dist/core/auth/oauth/types.d.ts +0 -11
  52. package/dist/core/auth/password.d.ts +0 -3
  53. package/dist/core/auth/policy.d.ts +0 -15
  54. package/dist/core/auth/resolveMembershipService.d.ts +0 -3
  55. package/dist/core/auth/scimAuthMiddleware.d.ts +0 -3
  56. package/dist/core/auth/sessionCookie.d.ts +0 -6
  57. package/dist/core/auth/sessionGuard.d.ts +0 -9
  58. package/dist/core/auth/tokenHash.d.ts +0 -3
  59. package/dist/core/cache/createCacheStore.d.ts +0 -11
  60. package/dist/core/cache/redisCacheStore.d.ts +0 -23
  61. package/dist/core/cache/repository.d.ts +0 -17
  62. package/dist/core/cache/simpleCache.d.ts +0 -23
  63. package/dist/core/cache/simpleCacheStore.d.ts +0 -16
  64. package/dist/core/cache/store.d.ts +0 -12
  65. package/dist/core/cache/taggedCache.d.ts +0 -9
  66. package/dist/core/cache/tags.d.ts +0 -11
  67. package/dist/core/config/envSchema.d.ts +0 -12
  68. package/dist/core/contracts/container.d.ts +0 -30
  69. package/dist/core/contracts/di.d.ts +0 -31
  70. package/dist/core/contracts/serviceContainer.d.ts +0 -1
  71. package/dist/core/contracts/serviceTokens.d.ts +0 -8
  72. package/dist/core/crypto/fieldEncryption.d.ts +0 -13
  73. package/dist/core/crypto/mfaSecret.d.ts +0 -3
  74. package/dist/core/crypto/nonCryptographicHash.d.ts +0 -2
  75. package/dist/core/database/baseRepository.d.ts +0 -67
  76. package/dist/core/database/bindConnection.d.ts +0 -3
  77. package/dist/core/database/boundConnection.d.ts +0 -5
  78. package/dist/core/database/connection.d.ts +0 -7
  79. package/dist/core/database/connectionContext.d.ts +0 -8
  80. package/dist/core/database/defaultConnection.d.ts +0 -6
  81. package/dist/core/database/errors.d.ts +0 -12
  82. package/dist/core/database/index.d.ts +0 -18
  83. package/dist/core/database/migrations/advisoryLock.d.ts +0 -6
  84. package/dist/core/database/migrations/runner.d.ts +0 -25
  85. package/dist/core/database/migrations/types.d.ts +0 -15
  86. package/dist/core/database/model.d.ts +0 -57
  87. package/dist/core/database/query.d.ts +0 -63
  88. package/dist/core/database/queryProxy.d.ts +0 -3
  89. package/dist/core/database/relationships.d.ts +0 -100
  90. package/dist/core/database/repositoryConnection.d.ts +0 -4
  91. package/dist/core/database/repositoryQuery.d.ts +0 -38
  92. package/dist/core/database/schema/blueprint.d.ts +0 -47
  93. package/dist/core/database/schema/columnDefinition.d.ts +0 -36
  94. package/dist/core/database/schema/driver.d.ts +0 -8
  95. package/dist/core/database/schema/errors.d.ts +0 -4
  96. package/dist/core/database/schema/grammars/compileStatements.d.ts +0 -8
  97. package/dist/core/database/schema/grammars/createGrammar.d.ts +0 -4
  98. package/dist/core/database/schema/grammars/grammar.d.ts +0 -10
  99. package/dist/core/database/schema/grammars/index.d.ts +0 -7
  100. package/dist/core/database/schema/grammars/mysqlGrammar.d.ts +0 -2
  101. package/dist/core/database/schema/grammars/postgresGrammar.d.ts +0 -2
  102. package/dist/core/database/schema/grammars/sqliteGrammar.d.ts +0 -2
  103. package/dist/core/database/schema/index.d.ts +0 -12
  104. package/dist/core/database/schema/schema.d.ts +0 -21
  105. package/dist/core/database/seeders/runner.d.ts +0 -6
  106. package/dist/core/database/seeders/types.d.ts +0 -8
  107. package/dist/core/database/table.d.ts +0 -13
  108. package/dist/core/database/transaction.d.ts +0 -3
  109. package/dist/core/database/types.d.ts +0 -66
  110. package/dist/core/database/whereBuilder.d.ts +0 -17
  111. package/dist/core/errors/http.d.ts +0 -33
  112. package/dist/core/events/eventBus.d.ts +0 -10
  113. package/dist/core/events/index.d.ts +0 -4
  114. package/dist/core/facades/index.d.ts +0 -10
  115. package/dist/core/http/authMiddleware.d.ts +0 -5
  116. package/dist/core/http/authorizeMiddleware.d.ts +0 -5
  117. package/dist/core/http/bodySizeLimitMiddleware.d.ts +0 -4
  118. package/dist/core/http/conditionalResponse.d.ts +0 -2
  119. package/dist/core/http/contentNegotiation.d.ts +0 -2
  120. package/dist/core/http/cookies.d.ts +0 -4
  121. package/dist/core/http/corsMiddleware.d.ts +0 -3
  122. package/dist/core/http/csrfMiddleware.d.ts +0 -3
  123. package/dist/core/http/csrfProtection.d.ts +0 -12
  124. package/dist/core/http/csrfToken.d.ts +0 -14
  125. package/dist/core/http/etag.d.ts +0 -18
  126. package/dist/core/http/flashMiddleware.d.ts +0 -3
  127. package/dist/core/http/flashSession.d.ts +0 -12
  128. package/dist/core/http/formRequest.d.ts +0 -10
  129. package/dist/core/http/index.d.ts +0 -27
  130. package/dist/core/http/loginThrottleMiddleware.d.ts +0 -11
  131. package/dist/core/http/memoryThrottleMiddleware.d.ts +0 -9
  132. package/dist/core/http/metricsMiddleware.d.ts +0 -4
  133. package/dist/core/http/middleware.d.ts +0 -8
  134. package/dist/core/http/pagination.d.ts +0 -11
  135. package/dist/core/http/parseFormBody.d.ts +0 -6
  136. package/dist/core/http/parseMultipartUpload.d.ts +0 -10
  137. package/dist/core/http/requestMetaContext.d.ts +0 -15
  138. package/dist/core/http/requireAbilityMiddleware.d.ts +0 -4
  139. package/dist/core/http/requireAuthMiddleware.d.ts +0 -4
  140. package/dist/core/http/requireGlobalAdminMiddleware.d.ts +0 -3
  141. package/dist/core/http/requireWebAuthMiddleware.d.ts +0 -4
  142. package/dist/core/http/resources.d.ts +0 -7
  143. package/dist/core/http/route.d.ts +0 -6
  144. package/dist/core/http/routeMiddleware.d.ts +0 -3
  145. package/dist/core/http/routeModelBinding.d.ts +0 -3
  146. package/dist/core/http/scimThrottleMiddleware.d.ts +0 -9
  147. package/dist/core/http/securedRouteModelBinding.d.ts +0 -11
  148. package/dist/core/http/securityHeadersMiddleware.d.ts +0 -3
  149. package/dist/core/http/throttleMiddleware.d.ts +0 -11
  150. package/dist/core/http/validation.d.ts +0 -23
  151. package/dist/core/http/webErrorResponse.d.ts +0 -5
  152. package/dist/core/http/webFormRequest.d.ts +0 -7
  153. package/dist/core/jobs/dispatchWebhookJob.d.ts +0 -13
  154. package/dist/core/jobs/invalidateCacheTagsJob.d.ts +0 -12
  155. package/dist/core/lifecycle/gracefulShutdown.d.ts +0 -6
  156. package/dist/core/logging/logger.d.ts +0 -17
  157. package/dist/core/logging/requestLoggingMiddleware.d.ts +0 -3
  158. package/dist/core/mail/mailer.d.ts +0 -38
  159. package/dist/core/mail/markdownMail.d.ts +0 -15
  160. package/dist/core/mail/markdownMailable.d.ts +0 -12
  161. package/dist/core/metrics/prometheus.d.ts +0 -26
  162. package/dist/core/notifications/dispatcher.d.ts +0 -13
  163. package/dist/core/notifications/index.d.ts +0 -3
  164. package/dist/core/notifications/notification.d.ts +0 -7
  165. package/dist/core/notifications/types.d.ts +0 -25
  166. package/dist/core/openapi/registeredRoute.d.ts +0 -6
  167. package/dist/core/pagination/index.d.ts +0 -27
  168. package/dist/core/queue/createAppQueue.d.ts +0 -5
  169. package/dist/core/queue/failedJobRepository.d.ts +0 -6
  170. package/dist/core/queue/failedJobService.d.ts +0 -16
  171. package/dist/core/queue/failedJobTable.d.ts +0 -3
  172. package/dist/core/queue/index.d.ts +0 -19
  173. package/dist/core/queue/jobRegistry.d.ts +0 -13
  174. package/dist/core/queue/jobRunner.d.ts +0 -9
  175. package/dist/core/queue/publicQueue.d.ts +0 -16
  176. package/dist/core/queue/queueMetrics.d.ts +0 -15
  177. package/dist/core/queue/redisQueue.d.ts +0 -29
  178. package/dist/core/queue/resilientQueue.d.ts +0 -9
  179. package/dist/core/queue/types.d.ts +0 -8
  180. package/dist/core/runtime/applicationRegistry.d.ts +0 -17
  181. package/dist/core/runtime/asyncContextStore.d.ts +0 -3
  182. package/dist/core/scheduler/schedule.d.ts +0 -15
  183. package/dist/core/security/publicReads.d.ts +0 -3
  184. package/dist/core/security/safeFetch.d.ts +0 -10
  185. package/dist/core/security/safeUrl.d.ts +0 -20
  186. package/dist/core/security/scimTenantTokens.d.ts +0 -3
  187. package/dist/core/security/securityEvents.d.ts +0 -6
  188. package/dist/core/security/timingSafeCompare.d.ts +0 -2
  189. package/dist/core/security/tokenExpiry.d.ts +0 -2
  190. package/dist/core/security/totp.d.ts +0 -3
  191. package/dist/core/storage/storage.d.ts +0 -44
  192. package/dist/core/tenant/databaseTenantContext.d.ts +0 -2
  193. package/dist/core/tenant/resolveTenant.d.ts +0 -3
  194. package/dist/core/tenant/tenantContext.d.ts +0 -13
  195. package/dist/core/tenant/tenantDatabaseScope.d.ts +0 -8
  196. package/dist/core/tenant/tenantMiddleware.d.ts +0 -6
  197. package/dist/core/tracing/otel.d.ts +0 -26
  198. package/dist/core/tracing/traceContext.d.ts +0 -9
  199. package/dist/core/tracing/tracingMiddleware.d.ts +0 -3
  200. package/dist/core/validation/rules.d.ts +0 -17
  201. package/dist/core/view/etaViewEngine.d.ts +0 -15
  202. package/dist/core/view/htmlResponse.d.ts +0 -6
  203. package/dist/core/view/index.d.ts +0 -5
  204. package/dist/core/view/viewEngine.d.ts +0 -6
  205. package/dist/core/view/webLayoutData.d.ts +0 -17
  206. package/dist/db/connection/createConnection.d.ts +0 -6
  207. package/dist/db/connection/index.d.ts +0 -11
  208. package/dist/domain/abilities.d.ts +0 -5
  209. package/dist/domain/auth.d.ts +0 -4
  210. package/dist/domain/scim.d.ts +0 -9
  211. package/dist/domain/workhub.d.ts +0 -35
  212. package/dist/framework/public-api.d.ts +0 -116
  213. package/dist/modules/organization/memberRepository.d.ts +0 -14
  214. package/dist/modules/organization/memberTypes.d.ts +0 -9
  215. package/dist/modules/organization/repository.d.ts +0 -14
  216. package/dist/modules/organization/table.d.ts +0 -3
  217. package/dist/modules/organization/types.d.ts +0 -10
  218. package/dist/modules/scim/controller.d.ts +0 -16
  219. package/dist/modules/scim/scimResponse.d.ts +0 -10
  220. package/dist/modules/scim/service.d.ts +0 -214
  221. package/dist/modules/user/apiTokenRepository.d.ts +0 -8
  222. package/dist/modules/user/apiTokenTable.d.ts +0 -3
  223. package/dist/modules/user/authService.d.ts +0 -23
  224. package/dist/modules/user/notificationRepository.d.ts +0 -6
  225. package/dist/modules/user/notificationService.d.ts +0 -25
  226. package/dist/modules/user/notificationTable.d.ts +0 -3
  227. package/dist/modules/user/notificationTypes.d.ts +0 -12
  228. package/dist/modules/user/oauthIdentityRepository.d.ts +0 -9
  229. package/dist/modules/user/provider.d.ts +0 -11
  230. package/dist/modules/user/repository.d.ts +0 -13
  231. package/dist/modules/user/table.d.ts +0 -3
  232. package/dist/modules/user/tokenService.d.ts +0 -29
  233. package/dist/modules/user/types.d.ts +0 -46
  234. package/dist/types/services.d.ts +0 -16
@@ -1,183 +1,28 @@
1
1
  // @bun
2
- // ../../src/core/contracts/di.ts
3
- var requiredDependencyKeys = [
4
- "container",
5
- "cache",
6
- "storage"
7
- ];
8
- function getRequiredDependency(dependencies, key) {
9
- const dependency = dependencies[key];
10
- if (dependency === undefined) {
11
- throw new Error(`Required dependency "${key}" is not registered.`);
12
- }
13
- return dependency;
14
- }
15
- function assertAppDependenciesComplete(dependencies) {
16
- for (const key of requiredDependencyKeys) {
17
- getRequiredDependency(dependencies, key);
18
- }
19
- }
20
- function resolveService(dependencies, token) {
21
- return dependencies.container.resolve(token);
22
- }
23
-
24
- // ../../src/core/contracts/serviceTokens.ts
25
- var CORE_CONFIG_TOKEN = "core.config";
26
- var CORE_CACHE_TOKEN = "core.cache";
27
- var CORE_QUEUE_TOKEN = "core.queue";
28
- var CORE_EVENT_BUS_TOKEN = "core.eventBus";
29
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
30
- var CORE_AUTH_TOKEN = "core.auth";
31
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
32
-
33
- // ../../src/core/logging/logger.ts
34
- class Logger {
35
- channel;
36
- constructor(channel = "app") {
37
- this.channel = channel;
38
- }
39
- write(level, message, context = {}) {
40
- const entry = {
41
- level,
42
- channel: this.channel,
43
- message,
44
- timestamp: new Date().toISOString(),
45
- ...context
46
- };
47
- const line = JSON.stringify(entry);
48
- if (level === "error") {
49
- console.error(line);
50
- return;
51
- }
52
- console.log(line);
53
- }
54
- debug(message, context) {
55
- this.write("debug", message, context);
56
- }
57
- info(message, context) {
58
- this.write("info", message, context);
59
- }
60
- warn(message, context) {
61
- this.write("warn", message, context);
62
- }
63
- error(message, context) {
64
- this.write("error", message, context);
65
- }
66
- }
67
- var appLogger = new Logger("app");
2
+ // ../../src/bootstrap/applicationRegistry.ts
3
+ import {
4
+ resolveApplicationAuth,
5
+ resolveApplicationCache,
6
+ resolveApplicationConfig,
7
+ resolveApplicationDependencies,
8
+ resolveApplicationEventBus,
9
+ resolveApplicationLogger,
10
+ resolveApplicationPolicyGate,
11
+ resolveApplicationQueue,
12
+ setActiveApplicationContext
13
+ } from "@getstrata/core/runtime/applicationRegistry.ts";
68
14
 
69
- // ../../src/core/runtime/applicationRegistry.ts
70
- var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
71
- var activeContext;
72
- function readStoredApplicationContext() {
73
- if (activeContext) {
74
- return activeContext;
75
- }
76
- const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
77
- if (globalContext) {
78
- activeContext = globalContext;
79
- }
80
- return activeContext;
81
- }
82
- function setActiveApplicationContext(context) {
83
- activeContext = context;
84
- globalThis[APPLICATION_CONTEXT_KEY] = context;
85
- }
86
- function requireActiveApplicationContext() {
87
- const context = readStoredApplicationContext();
88
- if (!context) {
89
- throw new Error("The application context has not been bootstrapped.");
90
- }
91
- return context;
92
- }
93
- function resolveApplicationCache() {
94
- return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
95
- }
96
- function resolveApplicationQueue() {
97
- return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
98
- }
99
- function resolveApplicationEventBus() {
100
- return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
101
- }
102
- function resolveApplicationAuth() {
103
- return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
104
- }
105
- function resolveApplicationPolicyGate() {
106
- return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
107
- }
108
- function resolveApplicationConfig() {
109
- return requireActiveApplicationContext().config;
110
- }
111
- function resolveApplicationLogger() {
112
- return appLogger;
113
- }
114
- function resolveApplicationDependencies() {
115
- return requireActiveApplicationContext().dependencies;
116
- }
117
- // ../../src/core/contracts/container.ts
118
- class ServiceContainer {
119
- services = new Map;
120
- singletonFactories = new Map;
121
- bindings = new Map;
122
- set(key, value) {
123
- this.singletonFactories.delete(key);
124
- this.bindings.delete(key);
125
- this.services.set(key, value);
126
- return value;
127
- }
128
- singleton(key, factory) {
129
- this.bindings.delete(key);
130
- this.services.delete(key);
131
- this.singletonFactories.set(key, factory);
132
- }
133
- bind(key, factory) {
134
- this.singletonFactories.delete(key);
135
- this.services.delete(key);
136
- this.bindings.set(key, factory);
137
- }
138
- get(key) {
139
- if (this.services.has(key)) {
140
- return this.services.get(key);
141
- }
142
- const singletonFactory = this.singletonFactories.get(key);
143
- if (singletonFactory) {
144
- const value = singletonFactory(this);
145
- this.services.set(key, value);
146
- return value;
147
- }
148
- const binding = this.bindings.get(key);
149
- if (binding) {
150
- return binding(this);
151
- }
152
- throw new Error(`Service "${key}" is not registered.`);
153
- }
154
- resolve(key) {
155
- return this.get(key);
156
- }
157
- has(key) {
158
- return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
159
- }
160
- }
15
+ // ../../src/bootstrap/contracts.ts
16
+ import {
17
+ ConfigStore,
18
+ ServiceContainer
19
+ } from "@getstrata/core/contracts/container";
20
+ import {
21
+ assertAppDependenciesComplete,
22
+ getRequiredDependency,
23
+ resolveService
24
+ } from "@getstrata/core/contracts/di";
161
25
 
162
- class ConfigStore {
163
- values = new Map;
164
- set(key, value) {
165
- this.values.set(key, value);
166
- return value;
167
- }
168
- get(key) {
169
- return this.values.get(key);
170
- }
171
- require(key) {
172
- if (!this.values.has(key)) {
173
- throw new Error(`Config key "${key}" is not defined.`);
174
- }
175
- return this.values.get(key);
176
- }
177
- has(key) {
178
- return this.values.has(key);
179
- }
180
- }
181
26
  // ../../src/bootstrap/discoverModules.ts
182
27
  import { readdirSync } from "fs";
183
28
  import { join } from "path";
@@ -282,6 +127,15 @@ function resolveAbilitiesForRole(role) {
282
127
  }
283
128
 
284
129
  // ../../src/bootstrap/config.ts
130
+ import {
131
+ CORE_AUTH_TOKEN,
132
+ CORE_CACHE_TOKEN,
133
+ CORE_CONFIG_TOKEN,
134
+ CORE_EVENT_BUS_TOKEN,
135
+ CORE_POLICY_GATE_TOKEN,
136
+ CORE_QUEUE_TOKEN,
137
+ CORE_TOKEN_SERVICE_TOKEN
138
+ } from "@getstrata/core/contracts/serviceTokens.ts";
285
139
  var APP_PORT_CONFIG_KEY = "app.port";
286
140
  var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
287
141
  var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
@@ -3767,10 +3621,92 @@ class DispatchWebhookJob extends Job {
3767
3621
  }
3768
3622
  var dispatchWebhookJob_default = DispatchWebhookJob;
3769
3623
 
3624
+ // ../../src/core/contracts/di.ts
3625
+ function getRequiredDependency2(dependencies, key) {
3626
+ const dependency = dependencies[key];
3627
+ if (dependency === undefined) {
3628
+ throw new Error(`Required dependency "${key}" is not registered.`);
3629
+ }
3630
+ return dependency;
3631
+ }
3632
+
3633
+ // ../../src/core/contracts/serviceTokens.ts
3634
+ var CORE_POLICY_GATE_TOKEN2 = "core.policyGate";
3635
+ var CORE_AUTH_TOKEN2 = "core.auth";
3636
+
3637
+ // ../../src/core/logging/logger.ts
3638
+ class Logger {
3639
+ channel;
3640
+ constructor(channel = "app") {
3641
+ this.channel = channel;
3642
+ }
3643
+ write(level, message, context = {}) {
3644
+ const entry = {
3645
+ level,
3646
+ channel: this.channel,
3647
+ message,
3648
+ timestamp: new Date().toISOString(),
3649
+ ...context
3650
+ };
3651
+ const line = JSON.stringify(entry);
3652
+ if (level === "error") {
3653
+ console.error(line);
3654
+ return;
3655
+ }
3656
+ console.log(line);
3657
+ }
3658
+ debug(message, context) {
3659
+ this.write("debug", message, context);
3660
+ }
3661
+ info(message, context) {
3662
+ this.write("info", message, context);
3663
+ }
3664
+ warn(message, context) {
3665
+ this.write("warn", message, context);
3666
+ }
3667
+ error(message, context) {
3668
+ this.write("error", message, context);
3669
+ }
3670
+ }
3671
+ var appLogger = new Logger("app");
3672
+
3673
+ // ../../src/core/runtime/applicationRegistry.ts
3674
+ var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
3675
+ var activeContext;
3676
+ function readStoredApplicationContext() {
3677
+ if (activeContext) {
3678
+ return activeContext;
3679
+ }
3680
+ const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
3681
+ if (globalContext) {
3682
+ activeContext = globalContext;
3683
+ }
3684
+ return activeContext;
3685
+ }
3686
+ function requireActiveApplicationContext() {
3687
+ const context = readStoredApplicationContext();
3688
+ if (!context) {
3689
+ throw new Error("The application context has not been bootstrapped.");
3690
+ }
3691
+ return context;
3692
+ }
3693
+ function resolveApplicationCache2() {
3694
+ return getRequiredDependency2(requireActiveApplicationContext().dependencies, "cache");
3695
+ }
3696
+ function resolveApplicationAuth2() {
3697
+ return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN2);
3698
+ }
3699
+ function resolveApplicationPolicyGate2() {
3700
+ return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN2);
3701
+ }
3702
+ function resolveApplicationDependencies2() {
3703
+ return requireActiveApplicationContext().dependencies;
3704
+ }
3705
+
3770
3706
  // ../../src/bootstrap/queue/defaultJobs.ts
3771
3707
  function registerDefaultJobs() {
3772
3708
  jobRegistry.register("cache.invalidate-tags", () => {
3773
- return new invalidateCacheTagsJob_default(resolveApplicationCache());
3709
+ return new invalidateCacheTagsJob_default(resolveApplicationCache2());
3774
3710
  });
3775
3711
  jobRegistry.register("webhook.dispatch", () => new dispatchWebhookJob_default);
3776
3712
  }
@@ -1,89 +1,14 @@
1
1
  // @bun
2
- // ../../src/core/contracts/container.ts
3
- class ServiceContainer {
4
- services = new Map;
5
- singletonFactories = new Map;
6
- bindings = new Map;
7
- set(key, value) {
8
- this.singletonFactories.delete(key);
9
- this.bindings.delete(key);
10
- this.services.set(key, value);
11
- return value;
12
- }
13
- singleton(key, factory) {
14
- this.bindings.delete(key);
15
- this.services.delete(key);
16
- this.singletonFactories.set(key, factory);
17
- }
18
- bind(key, factory) {
19
- this.singletonFactories.delete(key);
20
- this.services.delete(key);
21
- this.bindings.set(key, factory);
22
- }
23
- get(key) {
24
- if (this.services.has(key)) {
25
- return this.services.get(key);
26
- }
27
- const singletonFactory = this.singletonFactories.get(key);
28
- if (singletonFactory) {
29
- const value = singletonFactory(this);
30
- this.services.set(key, value);
31
- return value;
32
- }
33
- const binding = this.bindings.get(key);
34
- if (binding) {
35
- return binding(this);
36
- }
37
- throw new Error(`Service "${key}" is not registered.`);
38
- }
39
- resolve(key) {
40
- return this.get(key);
41
- }
42
- has(key) {
43
- return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
44
- }
45
- }
46
-
47
- class ConfigStore {
48
- values = new Map;
49
- set(key, value) {
50
- this.values.set(key, value);
51
- return value;
52
- }
53
- get(key) {
54
- return this.values.get(key);
55
- }
56
- require(key) {
57
- if (!this.values.has(key)) {
58
- throw new Error(`Config key "${key}" is not defined.`);
59
- }
60
- return this.values.get(key);
61
- }
62
- has(key) {
63
- return this.values.has(key);
64
- }
65
- }
66
- // ../../src/core/contracts/di.ts
67
- var requiredDependencyKeys = [
68
- "container",
69
- "cache",
70
- "storage"
71
- ];
72
- function getRequiredDependency(dependencies, key) {
73
- const dependency = dependencies[key];
74
- if (dependency === undefined) {
75
- throw new Error(`Required dependency "${key}" is not registered.`);
76
- }
77
- return dependency;
78
- }
79
- function assertAppDependenciesComplete(dependencies) {
80
- for (const key of requiredDependencyKeys) {
81
- getRequiredDependency(dependencies, key);
82
- }
83
- }
84
- function resolveService(dependencies, token) {
85
- return dependencies.container.resolve(token);
86
- }
2
+ // ../../src/bootstrap/contracts.ts
3
+ import {
4
+ ConfigStore,
5
+ ServiceContainer
6
+ } from "@getstrata/core/contracts/container";
7
+ import {
8
+ assertAppDependenciesComplete,
9
+ getRequiredDependency,
10
+ resolveService
11
+ } from "@getstrata/core/contracts/di";
87
12
  export {
88
13
  resolveService,
89
14
  getRequiredDependency,
@@ -110,16 +110,16 @@ 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_EVENT_BUS_TOKEN = "core.eventBus";
118
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
119
- var CORE_AUTH_TOKEN = "core.auth";
120
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
121
-
122
113
  // ../../src/bootstrap/config.ts
114
+ import {
115
+ CORE_AUTH_TOKEN,
116
+ CORE_CACHE_TOKEN,
117
+ CORE_CONFIG_TOKEN,
118
+ CORE_EVENT_BUS_TOKEN,
119
+ CORE_POLICY_GATE_TOKEN,
120
+ CORE_QUEUE_TOKEN,
121
+ CORE_TOKEN_SERVICE_TOKEN
122
+ } from "@getstrata/core/contracts/serviceTokens.ts";
123
123
  var APP_PORT_CONFIG_KEY = "app.port";
124
124
  var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
125
125
  var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";