@getstrata/core 0.5.28 → 0.5.30

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.
@@ -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,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, };
@@ -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";
@@ -10,6 +11,7 @@ export {
10
11
  CORE_TOKEN_SERVICE_TOKEN,
11
12
  CORE_QUEUE_TOKEN,
12
13
  CORE_POLICY_GATE_TOKEN,
14
+ CORE_EVENT_BUS_TOKEN,
13
15
  CORE_CONFIG_TOKEN,
14
16
  CORE_CACHE_TOKEN,
15
17
  CORE_AUTH_TOKEN
@@ -186,6 +186,7 @@ function isHtmxRequest(request) {
186
186
  var CORE_CONFIG_TOKEN = "core.config";
187
187
  var CORE_CACHE_TOKEN = "core.cache";
188
188
  var CORE_QUEUE_TOKEN = "core.queue";
189
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
189
190
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
190
191
  var CORE_AUTH_TOKEN = "core.auth";
191
192
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -1950,6 +1950,7 @@ var jobRegistry = readSharedJobRegistry();
1950
1950
  var CORE_CONFIG_TOKEN = "core.config";
1951
1951
  var CORE_CACHE_TOKEN = "core.cache";
1952
1952
  var CORE_QUEUE_TOKEN = "core.queue";
1953
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
1953
1954
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
1954
1955
  var CORE_AUTH_TOKEN = "core.auth";
1955
1956
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -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";
@@ -1950,6 +1950,7 @@ var jobRegistry = readSharedJobRegistry();
1950
1950
  var CORE_CONFIG_TOKEN = "core.config";
1951
1951
  var CORE_CACHE_TOKEN = "core.cache";
1952
1952
  var CORE_QUEUE_TOKEN = "core.queue";
1953
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
1953
1954
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
1954
1955
  var CORE_AUTH_TOKEN = "core.auth";
1955
1956
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -6,6 +6,7 @@ var {RedisClient: RedisClient2 } = globalThis.Bun;
6
6
  var CORE_CONFIG_TOKEN = "core.config";
7
7
  var CORE_CACHE_TOKEN = "core.cache";
8
8
  var CORE_QUEUE_TOKEN = "core.queue";
9
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
9
10
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
10
11
  var CORE_AUTH_TOKEN = "core.auth";
11
12
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -48,6 +48,7 @@ function isHtmxRequest(request) {
48
48
  var CORE_CONFIG_TOKEN = "core.config";
49
49
  var CORE_CACHE_TOKEN = "core.cache";
50
50
  var CORE_QUEUE_TOKEN = "core.queue";
51
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
51
52
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
52
53
  var CORE_AUTH_TOKEN = "core.auth";
53
54
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -95,7 +95,7 @@ export { AsyncQueue, createQueue, Job, SyncQueue } from "../core/queue/index.ts"
95
95
  export { createFailedJobService, createProductionQueue, createQueueWorker, createTrackedJob, FailedJobRepository, FailedJobService, jobRegistry, QueueWorker, RedisQueue, ResilientQueue, runQueueJob, } from "../core/queue/publicQueue.ts";
96
96
  export type { QueueMetricsSnapshot } from "../core/queue/queueMetrics.ts";
97
97
  export { collectQueueMetrics } from "../core/queue/queueMetrics.ts";
98
- export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../core/runtime/applicationRegistry.ts";
98
+ export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationEventBus, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../core/runtime/applicationRegistry.ts";
99
99
  export type { ScheduledTask } from "../core/scheduler/schedule.ts";
100
100
  export { appSchedule, runDueScheduledTasks, Schedule } from "../core/scheduler/schedule.ts";
101
101
  export { guestCanViewResource, isPublicReadsEnabled } from "../core/security/publicReads.ts";
package/dist/index.js CHANGED
@@ -206,6 +206,7 @@ function resolveAbilitiesForRole(role) {
206
206
 
207
207
  // ../../src/core/contracts/serviceTokens.ts
208
208
  var CORE_QUEUE_TOKEN = "core.queue";
209
+ var CORE_EVENT_BUS_TOKEN = "core.eventBus";
209
210
  var CORE_POLICY_GATE_TOKEN = "core.policyGate";
210
211
  var CORE_AUTH_TOKEN = "core.auth";
211
212
  var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
@@ -3232,6 +3233,9 @@ function resolveApplicationCache() {
3232
3233
  function resolveApplicationQueue() {
3233
3234
  return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
3234
3235
  }
3236
+ function resolveApplicationEventBus() {
3237
+ return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
3238
+ }
3235
3239
  function resolveApplicationAuth() {
3236
3240
  return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
3237
3241
  }
@@ -4462,7 +4466,11 @@ function queue() {
4462
4466
  return resolveApplicationQueue();
4463
4467
  }
4464
4468
  function events() {
4465
- return eventBus;
4469
+ try {
4470
+ return resolveApplicationEventBus();
4471
+ } catch {
4472
+ return eventBus;
4473
+ }
4466
4474
  }
4467
4475
  function config(key) {
4468
4476
  return resolveApplicationConfig().get(key);
@@ -6733,6 +6741,7 @@ export {
6733
6741
  resolveApplicationQueue,
6734
6742
  resolveApplicationPolicyGate,
6735
6743
  resolveApplicationLogger,
6744
+ resolveApplicationEventBus,
6736
6745
  resolveApplicationDependencies,
6737
6746
  resolveApplicationConfig,
6738
6747
  resolveApplicationCache,
@@ -1,4 +1,4 @@
1
- import type { ServiceProvider } from "@getstrata/bootstrap/contracts";
1
+ import type { ServiceProvider } from "@getstrata/core/contracts/di";
2
2
  declare const userRepositoryToken = "user.repository";
3
3
  declare const apiTokenRepositoryToken = "user.apiTokenRepository";
4
4
  declare const tokenServiceToken = "core.tokenService";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.28",
3
+ "version": "0.5.30",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,21 +0,0 @@
1
- export { ConfigStore, type ConfigStoreLike, ServiceContainer, type ServiceContainerLike, } from "../core/contracts/container.ts";
2
- export type { AppContext, AppDependencies, AppRouteMap, CachedJson, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, } from "../core/contracts/di.ts";
3
- export { assertAppDependenciesComplete, getRequiredDependency, resolveService, } from "../core/contracts/di.ts";
4
- import type { AppDependencies, AppRouteMap, CachedJson, ServiceProvider } from "../core/contracts/di.ts";
5
- import type { HttpKernel } from "./httpKernel.ts";
6
- interface ModuleRouteContext {
7
- dependencies: AppDependencies;
8
- cachedJson: CachedJson;
9
- kernel: HttpKernel;
10
- }
11
- interface AppModule {
12
- name: string;
13
- order?: number;
14
- tableName?: string;
15
- cacheTags?: readonly string[];
16
- cacheDeleteExtraTags?: readonly string[];
17
- providers?: ServiceProvider[];
18
- routes?(context: ModuleRouteContext): AppRouteMap;
19
- webRoutes?(context: ModuleRouteContext): AppRouteMap;
20
- }
21
- export type { AppModule, ModuleRouteContext };
@@ -1,27 +0,0 @@
1
- import { type Middleware, type Policy, type RouteHandler } from "@getstrata/core";
2
- import type { AppDependencies } from "./contracts";
3
- type MiddlewareGroupName = "api" | "authenticated" | "web";
4
- declare class HttpKernel {
5
- private readonly dependencies;
6
- constructor(dependencies: AppDependencies);
7
- globalMiddleware(): Middleware[];
8
- group(name: MiddlewareGroupName): Middleware[];
9
- wrap(groups: MiddlewareGroupName | MiddlewareGroupName[], handler: RouteHandler): RouteHandler;
10
- wrapApi(handler: RouteHandler): RouteHandler;
11
- wrapWeb(handler: RouteHandler): RouteHandler;
12
- wrapWebPublicRead(handler: RouteHandler): RouteHandler;
13
- wrapWebAuthenticated(handler: RouteHandler): RouteHandler;
14
- wrapWebAbility(ability: string, handler: RouteHandler): RouteHandler;
15
- wrapWebGlobalAdmin(handler: RouteHandler): RouteHandler;
16
- wrapAuthenticated(handler: RouteHandler): RouteHandler;
17
- wrapPublicRead(handler: RouteHandler): RouteHandler;
18
- wrapGlobalAdmin(handler: RouteHandler): RouteHandler;
19
- wrapAbility(ability: string, handler: RouteHandler): RouteHandler;
20
- wrapPolicy(resource: string, action: keyof Policy, handler: RouteHandler): RouteHandler;
21
- wrapLogin(handler: RouteHandler): RouteHandler;
22
- wrapRegister(handler: RouteHandler): RouteHandler;
23
- private wrapThrottle;
24
- }
25
- declare function createHttpKernel(dependencies: AppDependencies): HttpKernel;
26
- export type { MiddlewareGroupName };
27
- export { createHttpKernel, HttpKernel };
@@ -1,10 +0,0 @@
1
- interface LoginRateLimitConfig {
2
- maxAttempts: number;
3
- decaySeconds: number;
4
- }
5
- declare const LOCAL_LOGIN_RATE_LIMIT: LoginRateLimitConfig;
6
- declare const PRODUCTION_LOGIN_RATE_LIMIT: LoginRateLimitConfig;
7
- declare function resolveLoginRateLimit(): LoginRateLimitConfig;
8
- declare function resolveRegisterRateLimit(): LoginRateLimitConfig;
9
- export type { LoginRateLimitConfig };
10
- export { LOCAL_LOGIN_RATE_LIMIT, PRODUCTION_LOGIN_RATE_LIMIT, resolveLoginRateLimit, resolveRegisterRateLimit, };
@@ -1,7 +0,0 @@
1
- import type { AppContext, AppDependencies } from "./di";
2
- /** @deprecated Use AppContext from @getstrata/core/contracts/di */
3
- type ApplicationContext = AppContext;
4
- /** @deprecated Use AppDependencies from @getstrata/core/contracts/di */
5
- type ApplicationDependenciesLike = AppDependencies;
6
- export { getRequiredDependency } from "./di";
7
- export type { ApplicationContext, ApplicationDependenciesLike };