@getstrata/core 0.5.4 → 0.5.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.
@@ -119,6 +119,9 @@ function resolveService(dependencies, token) {
119
119
 
120
120
  // ../../src/bootstrap/applicationRegistry.ts
121
121
  var activeContext;
122
+ function setActiveApplicationContext(context) {
123
+ activeContext = context;
124
+ }
122
125
  function requireActiveApplicationContext() {
123
126
  if (!activeContext) {
124
127
  throw new Error("The application context has not been bootstrapped.");
@@ -3671,6 +3671,9 @@ function resolveService(dependencies, token) {
3671
3671
 
3672
3672
  // ../../src/bootstrap/applicationRegistry.ts
3673
3673
  var activeContext;
3674
+ function setActiveApplicationContext(context) {
3675
+ activeContext = context;
3676
+ }
3674
3677
  function requireActiveApplicationContext() {
3675
3678
  if (!activeContext) {
3676
3679
  throw new Error("The application context has not been bootstrapped.");
@@ -119,6 +119,9 @@ function resolveService(dependencies, token) {
119
119
 
120
120
  // ../../src/bootstrap/applicationRegistry.ts
121
121
  var activeContext;
122
+ function setActiveApplicationContext(context) {
123
+ activeContext = context;
124
+ }
122
125
  function requireActiveApplicationContext() {
123
126
  if (!activeContext) {
124
127
  throw new Error("The application context has not been bootstrapped.");
@@ -129,6 +129,9 @@ function resolveService(dependencies, token) {
129
129
 
130
130
  // ../../src/bootstrap/applicationRegistry.ts
131
131
  var activeContext;
132
+ function setActiveApplicationContext(context) {
133
+ activeContext = context;
134
+ }
132
135
  function requireActiveApplicationContext() {
133
136
  if (!activeContext) {
134
137
  throw new Error("The application context has not been bootstrapped.");
@@ -2,6 +2,7 @@
2
2
  * Stable framework surface for application modules and future package extraction.
3
3
  * Import from `@getstrata/core` (workspace) or `src/framework/public-api`.
4
4
  */
5
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../bootstrap/applicationRegistry.ts";
5
6
  export type { ServiceProvider } from "../bootstrap/contracts.ts";
6
7
  export { ConfigStore, resolveService, ServiceContainer, } from "../bootstrap/contracts.ts";
7
8
  export type { AbilityChecker } from "../core/auth/abilityChecker.ts";
package/dist/index.js CHANGED
@@ -1,4 +1,47 @@
1
1
  // @bun
2
+ // ../../src/core/logging/logger.ts
3
+ class Logger {
4
+ channel;
5
+ constructor(channel = "app") {
6
+ this.channel = channel;
7
+ }
8
+ write(level, message, context = {}) {
9
+ const entry = {
10
+ level,
11
+ channel: this.channel,
12
+ message,
13
+ timestamp: new Date().toISOString(),
14
+ ...context
15
+ };
16
+ const line = JSON.stringify(entry);
17
+ if (level === "error") {
18
+ console.error(line);
19
+ return;
20
+ }
21
+ console.log(line);
22
+ }
23
+ debug(message, context) {
24
+ this.write("debug", message, context);
25
+ }
26
+ info(message, context) {
27
+ this.write("info", message, context);
28
+ }
29
+ warn(message, context) {
30
+ this.write("warn", message, context);
31
+ }
32
+ error(message, context) {
33
+ this.write("error", message, context);
34
+ }
35
+ }
36
+ var appLogger = new Logger("app");
37
+
38
+ // ../../src/bootstrap/config.ts
39
+ var CORE_QUEUE_TOKEN = "core.queue";
40
+ var CORE_POLICY_GATE_TOKEN = "core.policyGate";
41
+ var CORE_AUTH_TOKEN = "core.auth";
42
+ var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
43
+ var DEFAULT_QUEUE_DRIVER = "sync";
44
+
2
45
  // ../../src/bootstrap/contracts.ts
3
46
  class ServiceContainer {
4
47
  services = new Map;
@@ -73,6 +116,39 @@ function getRequiredDependency(dependencies, key) {
73
116
  function resolveService(dependencies, token) {
74
117
  return dependencies.container.resolve(token);
75
118
  }
119
+
120
+ // ../../src/bootstrap/applicationRegistry.ts
121
+ var activeContext;
122
+ function setActiveApplicationContext(context) {
123
+ activeContext = context;
124
+ }
125
+ function requireActiveApplicationContext() {
126
+ if (!activeContext) {
127
+ throw new Error("The application context has not been bootstrapped.");
128
+ }
129
+ return activeContext;
130
+ }
131
+ function resolveApplicationCache() {
132
+ return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
133
+ }
134
+ function resolveApplicationQueue() {
135
+ return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
136
+ }
137
+ function resolveApplicationAuth() {
138
+ return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
139
+ }
140
+ function resolveApplicationPolicyGate() {
141
+ return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
142
+ }
143
+ function resolveApplicationConfig() {
144
+ return requireActiveApplicationContext().config;
145
+ }
146
+ function resolveApplicationLogger() {
147
+ return appLogger;
148
+ }
149
+ function resolveApplicationDependencies() {
150
+ return requireActiveApplicationContext().dependencies;
151
+ }
76
152
  // ../../src/core/auth/authContext.ts
77
153
  import { AsyncLocalStorage } from "async_hooks";
78
154
  var authContext = new AsyncLocalStorage;
@@ -2503,79 +2579,6 @@ async function runInTransaction(operation) {
2503
2579
  return await operation(createDatabaseConnection2(transaction));
2504
2580
  });
2505
2581
  }
2506
- // ../../src/core/logging/logger.ts
2507
- class Logger {
2508
- channel;
2509
- constructor(channel = "app") {
2510
- this.channel = channel;
2511
- }
2512
- write(level, message, context = {}) {
2513
- const entry = {
2514
- level,
2515
- channel: this.channel,
2516
- message,
2517
- timestamp: new Date().toISOString(),
2518
- ...context
2519
- };
2520
- const line = JSON.stringify(entry);
2521
- if (level === "error") {
2522
- console.error(line);
2523
- return;
2524
- }
2525
- console.log(line);
2526
- }
2527
- debug(message, context) {
2528
- this.write("debug", message, context);
2529
- }
2530
- info(message, context) {
2531
- this.write("info", message, context);
2532
- }
2533
- warn(message, context) {
2534
- this.write("warn", message, context);
2535
- }
2536
- error(message, context) {
2537
- this.write("error", message, context);
2538
- }
2539
- }
2540
- var appLogger = new Logger("app");
2541
-
2542
- // ../../src/bootstrap/config.ts
2543
- var CORE_QUEUE_TOKEN = "core.queue";
2544
- var CORE_POLICY_GATE_TOKEN = "core.policyGate";
2545
- var CORE_AUTH_TOKEN = "core.auth";
2546
- var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
2547
- var DEFAULT_QUEUE_DRIVER = "sync";
2548
-
2549
- // ../../src/bootstrap/applicationRegistry.ts
2550
- var activeContext;
2551
- function requireActiveApplicationContext() {
2552
- if (!activeContext) {
2553
- throw new Error("The application context has not been bootstrapped.");
2554
- }
2555
- return activeContext;
2556
- }
2557
- function resolveApplicationCache() {
2558
- return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
2559
- }
2560
- function resolveApplicationQueue() {
2561
- return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
2562
- }
2563
- function resolveApplicationAuth() {
2564
- return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
2565
- }
2566
- function resolveApplicationPolicyGate() {
2567
- return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
2568
- }
2569
- function resolveApplicationConfig() {
2570
- return requireActiveApplicationContext().config;
2571
- }
2572
- function resolveApplicationLogger() {
2573
- return appLogger;
2574
- }
2575
- function resolveApplicationDependencies() {
2576
- return requireActiveApplicationContext().dependencies;
2577
- }
2578
-
2579
2582
  // ../../src/core/mail/mailer.ts
2580
2583
  function resolveSmtpConfig() {
2581
2584
  const host = process.env.MAIL_HOST?.trim();
@@ -5364,6 +5367,7 @@ export {
5364
5367
  toPaginatedResourceCollection,
5365
5368
  stringRule,
5366
5369
  storageFacade as storage,
5370
+ setActiveApplicationContext,
5367
5371
  serializeDate,
5368
5372
  securedBindRouteModelByKey,
5369
5373
  securedBindRouteModel,
@@ -5377,6 +5381,13 @@ export {
5377
5381
  resolveWebLayoutData,
5378
5382
  resolveService,
5379
5383
  resolveDatabaseDriver,
5384
+ resolveApplicationQueue,
5385
+ resolveApplicationPolicyGate,
5386
+ resolveApplicationLogger,
5387
+ resolveApplicationDependencies,
5388
+ resolveApplicationConfig,
5389
+ resolveApplicationCache,
5390
+ resolveApplicationAuth,
5380
5391
  required,
5381
5392
  registerShutdownHandler,
5382
5393
  registerModelRepository,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",