@getstrata/core 0.5.25 → 0.5.26
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/contracts.d.ts +6 -50
- package/dist/core/contracts/applicationContext.d.ts +7 -18
- package/dist/core/contracts/container.d.ts +30 -0
- package/dist/core/contracts/di.d.ts +31 -0
- package/dist/core/contracts/serviceContainer.d.ts +1 -5
- package/dist/core/runtime/applicationRegistry.d.ts +2 -2
- package/dist/entries/contracts/container.js +69 -0
- package/dist/entries/contracts/di.js +27 -0
- package/dist/framework/public-api.d.ts +3 -2
- package/dist/index.js +69 -70
- package/package.json +12 -2
|
@@ -1,48 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
declare class ServiceContainer {
|
|
7
|
-
private readonly services;
|
|
8
|
-
private readonly singletonFactories;
|
|
9
|
-
private readonly bindings;
|
|
10
|
-
set<T>(key: string, value: T): T;
|
|
11
|
-
singleton<T>(key: string, factory: ServiceFactory<T>): void;
|
|
12
|
-
bind<T>(key: string, factory: ServiceFactory<T>): void;
|
|
13
|
-
get<T>(key: string): T;
|
|
14
|
-
resolve<T>(key: string): T;
|
|
15
|
-
has(key: string): boolean;
|
|
16
|
-
}
|
|
17
|
-
declare class ConfigStore {
|
|
18
|
-
private readonly values;
|
|
19
|
-
set<T>(key: string, value: T): T;
|
|
20
|
-
get<T>(key: string): T | undefined;
|
|
21
|
-
require<T>(key: string): T;
|
|
22
|
-
has(key: string): boolean;
|
|
23
|
-
}
|
|
24
|
-
interface AppDependencies {
|
|
25
|
-
container: ServiceContainer;
|
|
26
|
-
cache: CacheLike;
|
|
27
|
-
storage: StorageManager;
|
|
28
|
-
}
|
|
29
|
-
type MutableAppDependencies = Partial<Omit<AppDependencies, "container">> & Pick<AppDependencies, "container">;
|
|
30
|
-
interface ProviderContext {
|
|
31
|
-
container: ServiceContainer;
|
|
32
|
-
config: ConfigStore;
|
|
33
|
-
dependencies: MutableAppDependencies;
|
|
34
|
-
}
|
|
35
|
-
import type { HttpKernel } from "./httpKernel";
|
|
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";
|
|
36
6
|
interface ModuleRouteContext {
|
|
37
7
|
dependencies: AppDependencies;
|
|
38
8
|
cachedJson: CachedJson;
|
|
39
9
|
kernel: HttpKernel;
|
|
40
10
|
}
|
|
41
|
-
interface ServiceProvider {
|
|
42
|
-
name: string;
|
|
43
|
-
register?(context: ProviderContext): void;
|
|
44
|
-
boot?(context: ProviderContext): void;
|
|
45
|
-
}
|
|
46
11
|
interface AppModule {
|
|
47
12
|
name: string;
|
|
48
13
|
order?: number;
|
|
@@ -53,13 +18,4 @@ interface AppModule {
|
|
|
53
18
|
routes?(context: ModuleRouteContext): AppRouteMap;
|
|
54
19
|
webRoutes?(context: ModuleRouteContext): AppRouteMap;
|
|
55
20
|
}
|
|
56
|
-
|
|
57
|
-
container: ServiceContainer;
|
|
58
|
-
config: ConfigStore;
|
|
59
|
-
dependencies: AppDependencies;
|
|
60
|
-
}
|
|
61
|
-
declare function getRequiredDependency<K extends keyof AppDependencies>(dependencies: Partial<AppDependencies>, key: K): AppDependencies[K];
|
|
62
|
-
declare function assertAppDependenciesComplete(dependencies: MutableAppDependencies): asserts dependencies is AppDependencies;
|
|
63
|
-
declare function resolveService<T>(dependencies: AppDependencies, token: string): T;
|
|
64
|
-
export type { AppContext, AppDependencies, AppModule, AppRouteMap, CachedJson, ModuleRouteContext, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, };
|
|
65
|
-
export { assertAppDependenciesComplete, ConfigStore, getRequiredDependency, resolveService, ServiceContainer, };
|
|
21
|
+
export type { AppModule, ModuleRouteContext };
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 };
|
|
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 };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type ServiceFactory<T> = (container: ServiceContainer) => T;
|
|
2
|
+
interface ServiceContainerLike {
|
|
3
|
+
has(key: string): boolean;
|
|
4
|
+
resolve<T>(key: string): T;
|
|
5
|
+
}
|
|
6
|
+
declare class ServiceContainer implements ServiceContainerLike {
|
|
7
|
+
private readonly services;
|
|
8
|
+
private readonly singletonFactories;
|
|
9
|
+
private readonly bindings;
|
|
10
|
+
set<T>(key: string, value: T): T;
|
|
11
|
+
singleton<T>(key: string, factory: ServiceFactory<T>): void;
|
|
12
|
+
bind<T>(key: string, factory: ServiceFactory<T>): void;
|
|
13
|
+
get<T>(key: string): T;
|
|
14
|
+
resolve<T>(key: string): T;
|
|
15
|
+
has(key: string): boolean;
|
|
16
|
+
}
|
|
17
|
+
interface ConfigStoreLike {
|
|
18
|
+
get<T>(key: string): T | undefined;
|
|
19
|
+
require<T>(key: string): T;
|
|
20
|
+
has(key: string): boolean;
|
|
21
|
+
}
|
|
22
|
+
declare class ConfigStore implements ConfigStoreLike {
|
|
23
|
+
private readonly values;
|
|
24
|
+
set<T>(key: string, value: T): T;
|
|
25
|
+
get<T>(key: string): T | undefined;
|
|
26
|
+
require<T>(key: string): T;
|
|
27
|
+
has(key: string): boolean;
|
|
28
|
+
}
|
|
29
|
+
export type { ConfigStoreLike, ServiceContainerLike, ServiceFactory };
|
|
30
|
+
export { ConfigStore, ServiceContainer };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CacheLike } from "../../types/services";
|
|
2
|
+
import type { StorageManager } from "../storage/storage";
|
|
3
|
+
import type { ConfigStore, ConfigStoreLike, ServiceContainer, ServiceFactory } from "./container";
|
|
4
|
+
type AppRouteMap = Record<string, any>;
|
|
5
|
+
type CachedJson = <T>(cacheKey: string, loader: () => Promise<T>, tags?: string[], request?: Request) => Promise<Response>;
|
|
6
|
+
interface AppDependencies {
|
|
7
|
+
container: ServiceContainer;
|
|
8
|
+
cache: CacheLike;
|
|
9
|
+
storage: StorageManager;
|
|
10
|
+
}
|
|
11
|
+
type MutableAppDependencies = Partial<Omit<AppDependencies, "container">> & Pick<AppDependencies, "container">;
|
|
12
|
+
interface ProviderContext {
|
|
13
|
+
container: ServiceContainer;
|
|
14
|
+
config: ConfigStore;
|
|
15
|
+
dependencies: MutableAppDependencies;
|
|
16
|
+
}
|
|
17
|
+
interface ServiceProvider {
|
|
18
|
+
name: string;
|
|
19
|
+
register?(context: ProviderContext): void;
|
|
20
|
+
boot?(context: ProviderContext): void;
|
|
21
|
+
}
|
|
22
|
+
interface AppContext {
|
|
23
|
+
container: ServiceContainer;
|
|
24
|
+
config: ConfigStoreLike;
|
|
25
|
+
dependencies: AppDependencies;
|
|
26
|
+
}
|
|
27
|
+
declare function getRequiredDependency<K extends keyof AppDependencies>(dependencies: Partial<AppDependencies>, key: K): AppDependencies[K];
|
|
28
|
+
declare function assertAppDependenciesComplete(dependencies: MutableAppDependencies): asserts dependencies is AppDependencies;
|
|
29
|
+
declare function resolveService<T>(dependencies: AppDependencies, token: string): T;
|
|
30
|
+
export type { AppContext, AppDependencies, AppRouteMap, CachedJson, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, };
|
|
31
|
+
export { assertAppDependenciesComplete, getRequiredDependency, resolveService };
|
|
@@ -9,7 +9,7 @@ declare function resolveApplicationCache(): CacheLike;
|
|
|
9
9
|
declare function resolveApplicationQueue(): Queue;
|
|
10
10
|
declare function resolveApplicationAuth(): AuthManager;
|
|
11
11
|
declare function resolveApplicationPolicyGate(): PolicyGate;
|
|
12
|
-
declare function resolveApplicationConfig(): import("../contracts/
|
|
12
|
+
declare function resolveApplicationConfig(): import("../contracts/container").ConfigStoreLike;
|
|
13
13
|
declare function resolveApplicationLogger(): Logger;
|
|
14
|
-
declare function resolveApplicationDependencies(): import("../contracts/
|
|
14
|
+
declare function resolveApplicationDependencies(): import("../contracts/di").AppDependencies;
|
|
15
15
|
export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, };
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
export {
|
|
67
|
+
ServiceContainer,
|
|
68
|
+
ConfigStore
|
|
69
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
export {
|
|
24
|
+
resolveService,
|
|
25
|
+
getRequiredDependency,
|
|
26
|
+
assertAppDependenciesComplete
|
|
27
|
+
};
|
|
@@ -2,8 +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 type { ServiceProvider } from "../bootstrap/contracts.ts";
|
|
6
|
-
export { ConfigStore, resolveService, ServiceContainer, } from "../bootstrap/contracts.ts";
|
|
7
5
|
export type { AdminColumn, AdminColumnType, AdminResource, AdminResourceDefinition, AdminResourceHandlers, } from "../core/admin/index.ts";
|
|
8
6
|
export { AdminResourceRegistry, formatAdminValue, } from "../core/admin/index.ts";
|
|
9
7
|
export type { AbilityChecker } from "../core/auth/abilityChecker.ts";
|
|
@@ -21,6 +19,9 @@ export { createScimAuthMiddleware } from "../core/auth/scimAuthMiddleware.ts";
|
|
|
21
19
|
export { type CacheDriver, type CreateCacheStoreOptions, createCacheStore, } from "../core/cache/createCacheStore.ts";
|
|
22
20
|
export { default as CacheRepository } from "../core/cache/repository.ts";
|
|
23
21
|
export { CACHE_TAGS } from "../core/cache/tags.ts";
|
|
22
|
+
export { ConfigStore, ServiceContainer } from "../core/contracts/container.ts";
|
|
23
|
+
export type { ServiceProvider } from "../core/contracts/di.ts";
|
|
24
|
+
export { resolveService } from "../core/contracts/di.ts";
|
|
24
25
|
export type { DatabaseConnection } from "../core/database/baseRepository.ts";
|
|
25
26
|
export { default as BaseRepository } from "../core/database/baseRepository.ts";
|
|
26
27
|
export { bindDatabaseConnection } from "../core/database/bindConnection.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,71 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// ../../src/bootstrap/contracts.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
|
-
function resolveService(dependencies, token) {
|
|
67
|
-
return dependencies.container.resolve(token);
|
|
68
|
-
}
|
|
69
2
|
// ../../src/core/admin/formatValue.ts
|
|
70
3
|
function formatAdminValue(value, type = "text") {
|
|
71
4
|
if (value === null || value === undefined) {
|
|
@@ -3221,15 +3154,17 @@ function assertOrganizationReadable(organizationId) {
|
|
|
3221
3154
|
throw new NotFoundError(`Organization ${organizationId} not found.`);
|
|
3222
3155
|
}
|
|
3223
3156
|
}
|
|
3224
|
-
// ../../src/core/contracts/
|
|
3157
|
+
// ../../src/core/contracts/di.ts
|
|
3225
3158
|
function getRequiredDependency(dependencies, key) {
|
|
3226
3159
|
const dependency = dependencies[key];
|
|
3227
3160
|
if (dependency === undefined) {
|
|
3228
|
-
throw new Error(`Required dependency "${
|
|
3161
|
+
throw new Error(`Required dependency "${key}" is not registered.`);
|
|
3229
3162
|
}
|
|
3230
3163
|
return dependency;
|
|
3231
3164
|
}
|
|
3232
|
-
|
|
3165
|
+
function resolveService(dependencies, token) {
|
|
3166
|
+
return dependencies.container.resolve(token);
|
|
3167
|
+
}
|
|
3233
3168
|
// ../../src/core/logging/logger.ts
|
|
3234
3169
|
class Logger {
|
|
3235
3170
|
channel;
|
|
@@ -3989,6 +3924,70 @@ var CACHE_TAGS = {
|
|
|
3989
3924
|
attachments: "attachments",
|
|
3990
3925
|
reports: "reports"
|
|
3991
3926
|
};
|
|
3927
|
+
// ../../src/core/contracts/container.ts
|
|
3928
|
+
class ServiceContainer {
|
|
3929
|
+
services = new Map;
|
|
3930
|
+
singletonFactories = new Map;
|
|
3931
|
+
bindings = new Map;
|
|
3932
|
+
set(key, value) {
|
|
3933
|
+
this.singletonFactories.delete(key);
|
|
3934
|
+
this.bindings.delete(key);
|
|
3935
|
+
this.services.set(key, value);
|
|
3936
|
+
return value;
|
|
3937
|
+
}
|
|
3938
|
+
singleton(key, factory) {
|
|
3939
|
+
this.bindings.delete(key);
|
|
3940
|
+
this.services.delete(key);
|
|
3941
|
+
this.singletonFactories.set(key, factory);
|
|
3942
|
+
}
|
|
3943
|
+
bind(key, factory) {
|
|
3944
|
+
this.singletonFactories.delete(key);
|
|
3945
|
+
this.services.delete(key);
|
|
3946
|
+
this.bindings.set(key, factory);
|
|
3947
|
+
}
|
|
3948
|
+
get(key) {
|
|
3949
|
+
if (this.services.has(key)) {
|
|
3950
|
+
return this.services.get(key);
|
|
3951
|
+
}
|
|
3952
|
+
const singletonFactory = this.singletonFactories.get(key);
|
|
3953
|
+
if (singletonFactory) {
|
|
3954
|
+
const value = singletonFactory(this);
|
|
3955
|
+
this.services.set(key, value);
|
|
3956
|
+
return value;
|
|
3957
|
+
}
|
|
3958
|
+
const binding = this.bindings.get(key);
|
|
3959
|
+
if (binding) {
|
|
3960
|
+
return binding(this);
|
|
3961
|
+
}
|
|
3962
|
+
throw new Error(`Service "${key}" is not registered.`);
|
|
3963
|
+
}
|
|
3964
|
+
resolve(key) {
|
|
3965
|
+
return this.get(key);
|
|
3966
|
+
}
|
|
3967
|
+
has(key) {
|
|
3968
|
+
return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3972
|
+
class ConfigStore {
|
|
3973
|
+
values = new Map;
|
|
3974
|
+
set(key, value) {
|
|
3975
|
+
this.values.set(key, value);
|
|
3976
|
+
return value;
|
|
3977
|
+
}
|
|
3978
|
+
get(key) {
|
|
3979
|
+
return this.values.get(key);
|
|
3980
|
+
}
|
|
3981
|
+
require(key) {
|
|
3982
|
+
if (!this.values.has(key)) {
|
|
3983
|
+
throw new Error(`Config key "${key}" is not defined.`);
|
|
3984
|
+
}
|
|
3985
|
+
return this.values.get(key);
|
|
3986
|
+
}
|
|
3987
|
+
has(key) {
|
|
3988
|
+
return this.values.has(key);
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3992
3991
|
// ../../src/core/database/migrations/advisoryLock.ts
|
|
3993
3992
|
var MIGRATION_LOCK_KEY = 42424242;
|
|
3994
3993
|
async function withMigrationLock(db2, callback, lockKey = MIGRATION_LOCK_KEY) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getstrata/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.26",
|
|
4
4
|
"description": "Strata — Laravel-inspired Bun framework public API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -100,6 +100,16 @@
|
|
|
100
100
|
"import": "./dist/entries/contracts/serviceTokens.js",
|
|
101
101
|
"default": "./dist/entries/contracts/serviceTokens.js"
|
|
102
102
|
},
|
|
103
|
+
"./contracts/container": {
|
|
104
|
+
"types": "./dist/core/contracts/container.d.ts",
|
|
105
|
+
"import": "./dist/entries/contracts/container.js",
|
|
106
|
+
"default": "./dist/entries/contracts/container.js"
|
|
107
|
+
},
|
|
108
|
+
"./contracts/di": {
|
|
109
|
+
"types": "./dist/core/contracts/di.d.ts",
|
|
110
|
+
"import": "./dist/entries/contracts/di.js",
|
|
111
|
+
"default": "./dist/entries/contracts/di.js"
|
|
112
|
+
},
|
|
103
113
|
"./crypto/fieldEncryption": {
|
|
104
114
|
"types": "./dist/core/crypto/fieldEncryption.d.ts",
|
|
105
115
|
"import": "./dist/entries/crypto/fieldEncryption.js",
|
|
@@ -327,7 +337,7 @@
|
|
|
327
337
|
"build:bundle": "bun build index.ts --outdir dist --target bun --external bun --external eta",
|
|
328
338
|
"build:types": "tsc -p tsconfig.types.json",
|
|
329
339
|
"prepublishOnly": "bun run build && bun ../../scripts/prepare-core-package-publish.ts",
|
|
330
|
-
"build:subpaths": "bun build entries/auth/oauth/oidcProvider.ts entries/auth/oauth/providers.ts entries/auth/oauth/samlProvider.ts entries/auth/oauth/types.ts entries/auth/password.ts entries/auth/sessionCookie.ts entries/auth/tokenHash.ts entries/cache/tags.ts entries/cache/createCacheStore.ts entries/contracts/serviceTokens.ts entries/crypto/fieldEncryption.ts entries/crypto/mfaSecret.ts entries/database/factory.ts entries/database/seeders.ts entries/database/types.ts entries/errors/http.ts entries/http/contentNegotiation.ts entries/http/csrfToken.ts entries/http/etag.ts entries/http/flashSession.ts entries/http/parseFormBody.ts entries/http/resources.ts entries/http/webErrorResponse.ts entries/http/webFormRequest.ts entries/jobs/dispatchWebhookJob.ts entries/lifecycle/gracefulShutdown.ts entries/metrics/prometheus.ts entries/pagination.ts entries/queue/createAppQueue.ts entries/queue/failedJobService.ts entries/queue/jobRunner.ts entries/queue/queueMetrics.ts entries/queue/publicQueue.ts entries/queue/types.ts entries/security/oauthState.ts entries/security/publicReads.ts entries/security/safeUrl.ts entries/security/stripeWebhook.ts entries/security/tokenExpiry.ts entries/security/totp.ts entries/storage/storage.ts entries/validation/rules.ts entries/view.ts --outdir dist --root . --target bun --external bun --external eta",
|
|
340
|
+
"build:subpaths": "bun build entries/auth/oauth/oidcProvider.ts entries/auth/oauth/providers.ts entries/auth/oauth/samlProvider.ts entries/auth/oauth/types.ts entries/auth/password.ts entries/auth/sessionCookie.ts entries/auth/tokenHash.ts entries/cache/tags.ts entries/cache/createCacheStore.ts entries/contracts/serviceTokens.ts entries/contracts/container.ts entries/contracts/di.ts entries/crypto/fieldEncryption.ts entries/crypto/mfaSecret.ts entries/database/factory.ts entries/database/seeders.ts entries/database/types.ts entries/errors/http.ts entries/http/contentNegotiation.ts entries/http/csrfToken.ts entries/http/etag.ts entries/http/flashSession.ts entries/http/parseFormBody.ts entries/http/resources.ts entries/http/webErrorResponse.ts entries/http/webFormRequest.ts entries/jobs/dispatchWebhookJob.ts entries/lifecycle/gracefulShutdown.ts entries/metrics/prometheus.ts entries/pagination.ts entries/queue/createAppQueue.ts entries/queue/failedJobService.ts entries/queue/jobRunner.ts entries/queue/queueMetrics.ts entries/queue/publicQueue.ts entries/queue/types.ts entries/security/oauthState.ts entries/security/publicReads.ts entries/security/safeUrl.ts entries/security/stripeWebhook.ts entries/security/tokenExpiry.ts entries/security/totp.ts entries/storage/storage.ts entries/validation/rules.ts entries/view.ts --outdir dist --root . --target bun --external bun --external eta",
|
|
331
341
|
"build:shims": "bun ../../scripts/write-core-shared-shims.ts"
|
|
332
342
|
},
|
|
333
343
|
"publishConfig": {
|