@getstrata/core 0.5.20 → 0.5.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.
- package/dist/bootstrap/applicationRegistry.d.ts +1 -16
- package/dist/bootstrap/config.d.ts +2 -7
- package/dist/core/contracts/applicationContext.d.ts +18 -0
- package/dist/core/contracts/serviceTokens.d.ts +7 -0
- package/dist/core/runtime/applicationRegistry.d.ts +15 -0
- package/dist/entries/http/webErrorResponse.js +2 -1
- package/dist/entries/queue/createAppQueue.js +12 -75
- package/dist/entries/queue/jobRunner.js +2 -1
- package/dist/entries/queue/publicQueue.js +2 -1
- package/dist/entries/queue/queueMetrics.js +12 -75
- package/dist/entries/runtime/applicationRegistry.js +1 -0
- package/dist/entries/view.js +2 -1
- package/dist/framework/public-api.d.ts +1 -1
- package/dist/index.js +98 -96
- package/package.json +6 -1
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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,
|
|
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, };
|
|
@@ -182,8 +182,9 @@ function htmlResponse(html, init = {}) {
|
|
|
182
182
|
function isHtmxRequest(request) {
|
|
183
183
|
return request.headers.get("HX-Request") === "true";
|
|
184
184
|
}
|
|
185
|
-
// ../../src/
|
|
185
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
186
186
|
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
187
|
+
// ../../src/bootstrap/config.ts
|
|
187
188
|
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
188
189
|
|
|
189
190
|
// ../../src/core/auth/oauth/oidcProvider.ts
|
|
@@ -1937,8 +1937,9 @@ class JobRegistry {
|
|
|
1937
1937
|
}
|
|
1938
1938
|
var jobRegistry = new JobRegistry;
|
|
1939
1939
|
|
|
1940
|
-
// ../../src/
|
|
1940
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
1941
1941
|
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
1942
|
+
// ../../src/bootstrap/config.ts
|
|
1942
1943
|
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
1943
1944
|
|
|
1944
1945
|
// ../../src/config/queue.ts
|
|
@@ -2375,6 +2376,15 @@ class InvalidateCacheTagsJob extends Job {
|
|
|
2375
2376
|
}
|
|
2376
2377
|
var invalidateCacheTagsJob_default = InvalidateCacheTagsJob;
|
|
2377
2378
|
|
|
2379
|
+
// ../../src/core/contracts/applicationContext.ts
|
|
2380
|
+
function getRequiredDependency(dependencies, key) {
|
|
2381
|
+
const dependency = dependencies[key];
|
|
2382
|
+
if (dependency === undefined) {
|
|
2383
|
+
throw new Error(`Required dependency "${String(key)}" is not registered.`);
|
|
2384
|
+
}
|
|
2385
|
+
return dependency;
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2378
2388
|
// ../../src/core/logging/logger.ts
|
|
2379
2389
|
class Logger {
|
|
2380
2390
|
channel;
|
|
@@ -2411,79 +2421,7 @@ class Logger {
|
|
|
2411
2421
|
}
|
|
2412
2422
|
var appLogger = new Logger("app");
|
|
2413
2423
|
|
|
2414
|
-
// ../../src/
|
|
2415
|
-
class ServiceContainer {
|
|
2416
|
-
services = new Map;
|
|
2417
|
-
singletonFactories = new Map;
|
|
2418
|
-
bindings = new Map;
|
|
2419
|
-
set(key, value) {
|
|
2420
|
-
this.singletonFactories.delete(key);
|
|
2421
|
-
this.bindings.delete(key);
|
|
2422
|
-
this.services.set(key, value);
|
|
2423
|
-
return value;
|
|
2424
|
-
}
|
|
2425
|
-
singleton(key, factory) {
|
|
2426
|
-
this.bindings.delete(key);
|
|
2427
|
-
this.services.delete(key);
|
|
2428
|
-
this.singletonFactories.set(key, factory);
|
|
2429
|
-
}
|
|
2430
|
-
bind(key, factory) {
|
|
2431
|
-
this.singletonFactories.delete(key);
|
|
2432
|
-
this.services.delete(key);
|
|
2433
|
-
this.bindings.set(key, factory);
|
|
2434
|
-
}
|
|
2435
|
-
get(key) {
|
|
2436
|
-
if (this.services.has(key)) {
|
|
2437
|
-
return this.services.get(key);
|
|
2438
|
-
}
|
|
2439
|
-
const singletonFactory = this.singletonFactories.get(key);
|
|
2440
|
-
if (singletonFactory) {
|
|
2441
|
-
const value = singletonFactory(this);
|
|
2442
|
-
this.services.set(key, value);
|
|
2443
|
-
return value;
|
|
2444
|
-
}
|
|
2445
|
-
const binding = this.bindings.get(key);
|
|
2446
|
-
if (binding) {
|
|
2447
|
-
return binding(this);
|
|
2448
|
-
}
|
|
2449
|
-
throw new Error(`Service "${key}" is not registered.`);
|
|
2450
|
-
}
|
|
2451
|
-
resolve(key) {
|
|
2452
|
-
return this.get(key);
|
|
2453
|
-
}
|
|
2454
|
-
has(key) {
|
|
2455
|
-
return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2459
|
-
class ConfigStore {
|
|
2460
|
-
values = new Map;
|
|
2461
|
-
set(key, value) {
|
|
2462
|
-
this.values.set(key, value);
|
|
2463
|
-
return value;
|
|
2464
|
-
}
|
|
2465
|
-
get(key) {
|
|
2466
|
-
return this.values.get(key);
|
|
2467
|
-
}
|
|
2468
|
-
require(key) {
|
|
2469
|
-
if (!this.values.has(key)) {
|
|
2470
|
-
throw new Error(`Config key "${key}" is not defined.`);
|
|
2471
|
-
}
|
|
2472
|
-
return this.values.get(key);
|
|
2473
|
-
}
|
|
2474
|
-
has(key) {
|
|
2475
|
-
return this.values.has(key);
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
function getRequiredDependency(dependencies, key) {
|
|
2479
|
-
const dependency = dependencies[key];
|
|
2480
|
-
if (dependency === undefined) {
|
|
2481
|
-
throw new Error(`Required dependency "${key}" is not registered.`);
|
|
2482
|
-
}
|
|
2483
|
-
return dependency;
|
|
2484
|
-
}
|
|
2485
|
-
|
|
2486
|
-
// ../../src/bootstrap/applicationRegistry.ts
|
|
2424
|
+
// ../../src/core/runtime/applicationRegistry.ts
|
|
2487
2425
|
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
2488
2426
|
var activeContext;
|
|
2489
2427
|
function readStoredApplicationContext() {
|
|
@@ -2506,7 +2444,6 @@ function requireActiveApplicationContext() {
|
|
|
2506
2444
|
function resolveApplicationCache() {
|
|
2507
2445
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
2508
2446
|
}
|
|
2509
|
-
|
|
2510
2447
|
// ../../src/bootstrap/queue/defaultJobs.ts
|
|
2511
2448
|
function registerDefaultJobs() {
|
|
2512
2449
|
jobRegistry.register("cache.invalidate-tags", () => {
|
|
@@ -1937,8 +1937,9 @@ class JobRegistry {
|
|
|
1937
1937
|
}
|
|
1938
1938
|
var jobRegistry = new JobRegistry;
|
|
1939
1939
|
|
|
1940
|
-
// ../../src/
|
|
1940
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
1941
1941
|
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
1942
|
+
// ../../src/bootstrap/config.ts
|
|
1942
1943
|
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
1943
1944
|
|
|
1944
1945
|
// ../../src/config/queue.ts
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// ../../src/core/queue/queueMetrics.ts
|
|
3
3
|
var {RedisClient: RedisClient2 } = globalThis.Bun;
|
|
4
4
|
|
|
5
|
-
// ../../src/
|
|
5
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
6
6
|
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
7
|
+
// ../../src/bootstrap/config.ts
|
|
7
8
|
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
8
9
|
|
|
9
10
|
// ../../src/config/queue.ts
|
|
@@ -2378,6 +2379,15 @@ class InvalidateCacheTagsJob extends Job {
|
|
|
2378
2379
|
}
|
|
2379
2380
|
var invalidateCacheTagsJob_default = InvalidateCacheTagsJob;
|
|
2380
2381
|
|
|
2382
|
+
// ../../src/core/contracts/applicationContext.ts
|
|
2383
|
+
function getRequiredDependency(dependencies, key) {
|
|
2384
|
+
const dependency = dependencies[key];
|
|
2385
|
+
if (dependency === undefined) {
|
|
2386
|
+
throw new Error(`Required dependency "${String(key)}" is not registered.`);
|
|
2387
|
+
}
|
|
2388
|
+
return dependency;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2381
2391
|
// ../../src/core/logging/logger.ts
|
|
2382
2392
|
class Logger {
|
|
2383
2393
|
channel;
|
|
@@ -2414,79 +2424,7 @@ class Logger {
|
|
|
2414
2424
|
}
|
|
2415
2425
|
var appLogger = new Logger("app");
|
|
2416
2426
|
|
|
2417
|
-
// ../../src/
|
|
2418
|
-
class ServiceContainer {
|
|
2419
|
-
services = new Map;
|
|
2420
|
-
singletonFactories = new Map;
|
|
2421
|
-
bindings = new Map;
|
|
2422
|
-
set(key, value) {
|
|
2423
|
-
this.singletonFactories.delete(key);
|
|
2424
|
-
this.bindings.delete(key);
|
|
2425
|
-
this.services.set(key, value);
|
|
2426
|
-
return value;
|
|
2427
|
-
}
|
|
2428
|
-
singleton(key, factory) {
|
|
2429
|
-
this.bindings.delete(key);
|
|
2430
|
-
this.services.delete(key);
|
|
2431
|
-
this.singletonFactories.set(key, factory);
|
|
2432
|
-
}
|
|
2433
|
-
bind(key, factory) {
|
|
2434
|
-
this.singletonFactories.delete(key);
|
|
2435
|
-
this.services.delete(key);
|
|
2436
|
-
this.bindings.set(key, factory);
|
|
2437
|
-
}
|
|
2438
|
-
get(key) {
|
|
2439
|
-
if (this.services.has(key)) {
|
|
2440
|
-
return this.services.get(key);
|
|
2441
|
-
}
|
|
2442
|
-
const singletonFactory = this.singletonFactories.get(key);
|
|
2443
|
-
if (singletonFactory) {
|
|
2444
|
-
const value = singletonFactory(this);
|
|
2445
|
-
this.services.set(key, value);
|
|
2446
|
-
return value;
|
|
2447
|
-
}
|
|
2448
|
-
const binding = this.bindings.get(key);
|
|
2449
|
-
if (binding) {
|
|
2450
|
-
return binding(this);
|
|
2451
|
-
}
|
|
2452
|
-
throw new Error(`Service "${key}" is not registered.`);
|
|
2453
|
-
}
|
|
2454
|
-
resolve(key) {
|
|
2455
|
-
return this.get(key);
|
|
2456
|
-
}
|
|
2457
|
-
has(key) {
|
|
2458
|
-
return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
class ConfigStore {
|
|
2463
|
-
values = new Map;
|
|
2464
|
-
set(key, value) {
|
|
2465
|
-
this.values.set(key, value);
|
|
2466
|
-
return value;
|
|
2467
|
-
}
|
|
2468
|
-
get(key) {
|
|
2469
|
-
return this.values.get(key);
|
|
2470
|
-
}
|
|
2471
|
-
require(key) {
|
|
2472
|
-
if (!this.values.has(key)) {
|
|
2473
|
-
throw new Error(`Config key "${key}" is not defined.`);
|
|
2474
|
-
}
|
|
2475
|
-
return this.values.get(key);
|
|
2476
|
-
}
|
|
2477
|
-
has(key) {
|
|
2478
|
-
return this.values.has(key);
|
|
2479
|
-
}
|
|
2480
|
-
}
|
|
2481
|
-
function getRequiredDependency(dependencies, key) {
|
|
2482
|
-
const dependency = dependencies[key];
|
|
2483
|
-
if (dependency === undefined) {
|
|
2484
|
-
throw new Error(`Required dependency "${key}" is not registered.`);
|
|
2485
|
-
}
|
|
2486
|
-
return dependency;
|
|
2487
|
-
}
|
|
2488
|
-
|
|
2489
|
-
// ../../src/bootstrap/applicationRegistry.ts
|
|
2427
|
+
// ../../src/core/runtime/applicationRegistry.ts
|
|
2490
2428
|
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
2491
2429
|
var activeContext;
|
|
2492
2430
|
function readStoredApplicationContext() {
|
|
@@ -2509,7 +2447,6 @@ function requireActiveApplicationContext() {
|
|
|
2509
2447
|
function resolveApplicationCache() {
|
|
2510
2448
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
2511
2449
|
}
|
|
2512
|
-
|
|
2513
2450
|
// ../../src/bootstrap/queue/defaultJobs.ts
|
|
2514
2451
|
function registerDefaultJobs() {
|
|
2515
2452
|
jobRegistry.register("cache.invalidate-tags", () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../index.js";
|
package/dist/entries/view.js
CHANGED
|
@@ -44,8 +44,9 @@ function htmlResponse(html, init = {}) {
|
|
|
44
44
|
function isHtmxRequest(request) {
|
|
45
45
|
return request.headers.get("HX-Request") === "true";
|
|
46
46
|
}
|
|
47
|
-
// ../../src/
|
|
47
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
48
48
|
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
49
|
+
// ../../src/bootstrap/config.ts
|
|
49
50
|
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
50
51
|
|
|
51
52
|
// ../../src/core/auth/oauth/oidcProvider.ts
|
|
@@ -2,7 +2,6 @@
|
|
|
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";
|
|
6
5
|
export type { ServiceProvider } from "../bootstrap/contracts.ts";
|
|
7
6
|
export { ConfigStore, resolveService, ServiceContainer, } from "../bootstrap/contracts.ts";
|
|
8
7
|
export type { AdminColumn, AdminColumnType, AdminResource, AdminResourceDefinition, AdminResourceHandlers, } from "../core/admin/index.ts";
|
|
@@ -96,6 +95,7 @@ export { AsyncQueue, createQueue, Job, SyncQueue } from "../core/queue/index.ts"
|
|
|
96
95
|
export { createFailedJobService, createProductionQueue, createQueueWorker, createTrackedJob, FailedJobRepository, FailedJobService, jobRegistry, QueueWorker, RedisQueue, ResilientQueue, runQueueJob, } from "../core/queue/publicQueue.ts";
|
|
97
96
|
export type { QueueMetricsSnapshot } from "../core/queue/queueMetrics.ts";
|
|
98
97
|
export { collectQueueMetrics } from "../core/queue/queueMetrics.ts";
|
|
98
|
+
export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, 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
|
@@ -1,47 +1,4 @@
|
|
|
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
|
-
|
|
45
2
|
// ../../src/bootstrap/contracts.ts
|
|
46
3
|
class ServiceContainer {
|
|
47
4
|
services = new Map;
|
|
@@ -106,62 +63,9 @@ class ConfigStore {
|
|
|
106
63
|
return this.values.has(key);
|
|
107
64
|
}
|
|
108
65
|
}
|
|
109
|
-
function getRequiredDependency(dependencies, key) {
|
|
110
|
-
const dependency = dependencies[key];
|
|
111
|
-
if (dependency === undefined) {
|
|
112
|
-
throw new Error(`Required dependency "${key}" is not registered.`);
|
|
113
|
-
}
|
|
114
|
-
return dependency;
|
|
115
|
-
}
|
|
116
66
|
function resolveService(dependencies, token) {
|
|
117
67
|
return dependencies.container.resolve(token);
|
|
118
68
|
}
|
|
119
|
-
|
|
120
|
-
// ../../src/bootstrap/applicationRegistry.ts
|
|
121
|
-
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
122
|
-
var activeContext;
|
|
123
|
-
function readStoredApplicationContext() {
|
|
124
|
-
if (activeContext) {
|
|
125
|
-
return activeContext;
|
|
126
|
-
}
|
|
127
|
-
const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
|
|
128
|
-
if (globalContext) {
|
|
129
|
-
activeContext = globalContext;
|
|
130
|
-
}
|
|
131
|
-
return activeContext;
|
|
132
|
-
}
|
|
133
|
-
function setActiveApplicationContext(context) {
|
|
134
|
-
activeContext = context;
|
|
135
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
136
|
-
}
|
|
137
|
-
function requireActiveApplicationContext() {
|
|
138
|
-
const context = readStoredApplicationContext();
|
|
139
|
-
if (!context) {
|
|
140
|
-
throw new Error("The application context has not been bootstrapped.");
|
|
141
|
-
}
|
|
142
|
-
return context;
|
|
143
|
-
}
|
|
144
|
-
function resolveApplicationCache() {
|
|
145
|
-
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
146
|
-
}
|
|
147
|
-
function resolveApplicationQueue() {
|
|
148
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
149
|
-
}
|
|
150
|
-
function resolveApplicationAuth() {
|
|
151
|
-
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
152
|
-
}
|
|
153
|
-
function resolveApplicationPolicyGate() {
|
|
154
|
-
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
155
|
-
}
|
|
156
|
-
function resolveApplicationConfig() {
|
|
157
|
-
return requireActiveApplicationContext().config;
|
|
158
|
-
}
|
|
159
|
-
function resolveApplicationLogger() {
|
|
160
|
-
return appLogger;
|
|
161
|
-
}
|
|
162
|
-
function resolveApplicationDependencies() {
|
|
163
|
-
return requireActiveApplicationContext().dependencies;
|
|
164
|
-
}
|
|
165
69
|
// ../../src/core/admin/formatValue.ts
|
|
166
70
|
function formatAdminValue(value, type = "text") {
|
|
167
71
|
if (value === null || value === undefined) {
|
|
@@ -367,6 +271,14 @@ function resolveAbilitiesForRole(role) {
|
|
|
367
271
|
return [...MEMBER_ABILITIES];
|
|
368
272
|
}
|
|
369
273
|
|
|
274
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
275
|
+
var CORE_QUEUE_TOKEN = "core.queue";
|
|
276
|
+
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
277
|
+
var CORE_AUTH_TOKEN = "core.auth";
|
|
278
|
+
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
279
|
+
// ../../src/bootstrap/config.ts
|
|
280
|
+
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
281
|
+
|
|
370
282
|
// ../../src/config/features.ts
|
|
371
283
|
function readFeatureFlags() {
|
|
372
284
|
return {
|
|
@@ -3309,6 +3221,96 @@ function assertOrganizationReadable(organizationId) {
|
|
|
3309
3221
|
throw new NotFoundError(`Organization ${organizationId} not found.`);
|
|
3310
3222
|
}
|
|
3311
3223
|
}
|
|
3224
|
+
// ../../src/core/contracts/applicationContext.ts
|
|
3225
|
+
function getRequiredDependency(dependencies, key) {
|
|
3226
|
+
const dependency = dependencies[key];
|
|
3227
|
+
if (dependency === undefined) {
|
|
3228
|
+
throw new Error(`Required dependency "${String(key)}" is not registered.`);
|
|
3229
|
+
}
|
|
3230
|
+
return dependency;
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
// ../../src/core/logging/logger.ts
|
|
3234
|
+
class Logger {
|
|
3235
|
+
channel;
|
|
3236
|
+
constructor(channel = "app") {
|
|
3237
|
+
this.channel = channel;
|
|
3238
|
+
}
|
|
3239
|
+
write(level, message, context = {}) {
|
|
3240
|
+
const entry = {
|
|
3241
|
+
level,
|
|
3242
|
+
channel: this.channel,
|
|
3243
|
+
message,
|
|
3244
|
+
timestamp: new Date().toISOString(),
|
|
3245
|
+
...context
|
|
3246
|
+
};
|
|
3247
|
+
const line = JSON.stringify(entry);
|
|
3248
|
+
if (level === "error") {
|
|
3249
|
+
console.error(line);
|
|
3250
|
+
return;
|
|
3251
|
+
}
|
|
3252
|
+
console.log(line);
|
|
3253
|
+
}
|
|
3254
|
+
debug(message, context) {
|
|
3255
|
+
this.write("debug", message, context);
|
|
3256
|
+
}
|
|
3257
|
+
info(message, context) {
|
|
3258
|
+
this.write("info", message, context);
|
|
3259
|
+
}
|
|
3260
|
+
warn(message, context) {
|
|
3261
|
+
this.write("warn", message, context);
|
|
3262
|
+
}
|
|
3263
|
+
error(message, context) {
|
|
3264
|
+
this.write("error", message, context);
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
var appLogger = new Logger("app");
|
|
3268
|
+
|
|
3269
|
+
// ../../src/core/runtime/applicationRegistry.ts
|
|
3270
|
+
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
3271
|
+
var activeContext;
|
|
3272
|
+
function readStoredApplicationContext() {
|
|
3273
|
+
if (activeContext) {
|
|
3274
|
+
return activeContext;
|
|
3275
|
+
}
|
|
3276
|
+
const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
|
|
3277
|
+
if (globalContext) {
|
|
3278
|
+
activeContext = globalContext;
|
|
3279
|
+
}
|
|
3280
|
+
return activeContext;
|
|
3281
|
+
}
|
|
3282
|
+
function setActiveApplicationContext(context) {
|
|
3283
|
+
activeContext = context;
|
|
3284
|
+
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
3285
|
+
}
|
|
3286
|
+
function requireActiveApplicationContext() {
|
|
3287
|
+
const context = readStoredApplicationContext();
|
|
3288
|
+
if (!context) {
|
|
3289
|
+
throw new Error("The application context has not been bootstrapped.");
|
|
3290
|
+
}
|
|
3291
|
+
return context;
|
|
3292
|
+
}
|
|
3293
|
+
function resolveApplicationCache() {
|
|
3294
|
+
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
3295
|
+
}
|
|
3296
|
+
function resolveApplicationQueue() {
|
|
3297
|
+
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
3298
|
+
}
|
|
3299
|
+
function resolveApplicationAuth() {
|
|
3300
|
+
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
3301
|
+
}
|
|
3302
|
+
function resolveApplicationPolicyGate() {
|
|
3303
|
+
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
3304
|
+
}
|
|
3305
|
+
function resolveApplicationConfig() {
|
|
3306
|
+
return requireActiveApplicationContext().config;
|
|
3307
|
+
}
|
|
3308
|
+
function resolveApplicationLogger() {
|
|
3309
|
+
return appLogger;
|
|
3310
|
+
}
|
|
3311
|
+
function resolveApplicationDependencies() {
|
|
3312
|
+
return requireActiveApplicationContext().dependencies;
|
|
3313
|
+
}
|
|
3312
3314
|
// ../../src/bootstrap/membershipService.ts
|
|
3313
3315
|
function resolveMembershipService() {
|
|
3314
3316
|
const dependencies = resolveApplicationDependencies();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getstrata/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"description": "Strata — Laravel-inspired Bun framework public API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -240,6 +240,11 @@
|
|
|
240
240
|
"import": "./dist/entries/queue/types.js",
|
|
241
241
|
"default": "./dist/entries/queue/types.js"
|
|
242
242
|
},
|
|
243
|
+
"./runtime/applicationRegistry": {
|
|
244
|
+
"types": "./dist/core/runtime/applicationRegistry.d.ts",
|
|
245
|
+
"import": "./dist/entries/runtime/applicationRegistry.js",
|
|
246
|
+
"default": "./dist/entries/runtime/applicationRegistry.js"
|
|
247
|
+
},
|
|
243
248
|
"./security/oauthState": {
|
|
244
249
|
"types": "./dist/core/security/oauthState.d.ts",
|
|
245
250
|
"import": "./dist/entries/security/oauthState.js",
|