@wyrly/express 1.0.3 → 1.0.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.
- package/README.md +56 -0
- package/esm/_dnt.shims.d.ts +1 -5
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -5
- package/esm/core/container.d.ts +8 -0
- package/esm/core/container.d.ts.map +1 -1
- package/esm/core/container.js +1 -0
- package/esm/core/errors.d.ts +47 -0
- package/esm/core/errors.d.ts.map +1 -1
- package/esm/core/errors.js +45 -0
- package/esm/core/graph.d.ts +11 -0
- package/esm/core/graph.d.ts.map +1 -1
- package/esm/core/graph_format.d.ts +2 -0
- package/esm/core/graph_format.d.ts.map +1 -1
- package/esm/core/i18n.d.ts +7 -0
- package/esm/core/i18n.d.ts.map +1 -1
- package/esm/core/i18n.js +20 -1
- package/esm/core/lifetime.d.ts +1 -0
- package/esm/core/lifetime.d.ts.map +1 -1
- package/esm/core/metadata.d.ts +3 -0
- package/esm/core/metadata.d.ts.map +1 -1
- package/esm/core/mod.d.ts +32 -2
- package/esm/core/mod.d.ts.map +1 -1
- package/esm/core/mod.js +28 -0
- package/esm/core/provider.d.ts +27 -2
- package/esm/core/provider.d.ts.map +1 -1
- package/esm/core/scope.d.ts +6 -0
- package/esm/core/scope.d.ts.map +1 -1
- package/esm/core/token.d.ts +8 -2
- package/esm/core/token.d.ts.map +1 -1
- package/esm/core/token.js +1 -0
- package/esm/core/types_decorator.d.ts +4 -0
- package/esm/core/types_decorator.d.ts.map +1 -1
- package/esm/core/validate.d.ts +9 -0
- package/esm/core/validate.d.ts.map +1 -1
- package/esm/express/mod.d.ts +22 -0
- package/esm/express/mod.d.ts.map +1 -1
- package/esm/express/tokens.d.ts +4 -2
- package/esm/express/tokens.d.ts.map +1 -1
- package/package.json +19 -7
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @wyrly/express
|
|
2
|
+
|
|
3
|
+
Wyrly DI adapter for Express — one request scope per HTTP request via `diMiddleware`.
|
|
4
|
+
|
|
5
|
+
Japanese: [README.ja.md](./README.ja.md)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @wyrly/express @wyrly/core express
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer dependency: **express ^5.0.0**.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Everything required by [`@wyrly/core`](../core/README.md)
|
|
18
|
+
- **Express 5.x**
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import express from "express";
|
|
24
|
+
import { asExpressRequestWithDI, diMiddleware } from "@wyrly/express";
|
|
25
|
+
import { createContainer } from "@wyrly/core";
|
|
26
|
+
|
|
27
|
+
const app = express();
|
|
28
|
+
const container = createContainer();
|
|
29
|
+
app.use(diMiddleware(container));
|
|
30
|
+
|
|
31
|
+
app.get("/users/:id", (req, res) => {
|
|
32
|
+
const di = asExpressRequestWithDI(req).di;
|
|
33
|
+
res.json({ ok: true });
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
- [@wyrly/core](../core/README.md)
|
|
40
|
+
- [API reference](https://github.com/valid-lab/wyrly/blob/main/API.md)
|
|
41
|
+
- [Monorepo README](https://github.com/valid-lab/wyrly/blob/main/README.md)
|
|
42
|
+
|
|
43
|
+
## Related packages
|
|
44
|
+
|
|
45
|
+
| Package | npm | Description |
|
|
46
|
+
| ---------------- | -------- | --------------- |
|
|
47
|
+
| `@wyrly/core` | yes | Core DI |
|
|
48
|
+
| `@wyrly/express` | yes | This package |
|
|
49
|
+
| `@wyrly/hono` | yes | Hono adapter |
|
|
50
|
+
| `@wyrly/graphql` | yes | GraphQL adapter |
|
|
51
|
+
| `@wyrly/next` | yes | Next.js adapter |
|
|
52
|
+
| `@wyrly/fresh` | JSR only | Fresh 2.x |
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
Apache-2.0 — see [LICENSE](https://github.com/valid-lab/wyrly/blob/main/LICENSE).
|
package/esm/_dnt.shims.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
|
|
4
|
-
Deno: typeof Deno;
|
|
5
|
-
};
|
|
1
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, never>;
|
|
6
2
|
//# sourceMappingURL=_dnt.shims.d.ts.map
|
package/esm/_dnt.shims.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
|
package/esm/_dnt.shims.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
const dntGlobals = {
|
|
4
|
-
Deno,
|
|
5
|
-
};
|
|
1
|
+
const dntGlobals = {};
|
|
6
2
|
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
3
|
function createMergeProxy(baseObj, extObj) {
|
|
8
4
|
return new Proxy(baseObj, {
|
package/esm/core/container.d.ts
CHANGED
|
@@ -6,14 +6,22 @@ import type { Scope } from "./scope.js";
|
|
|
6
6
|
import { type RegistryKey } from "./internal_keys.js";
|
|
7
7
|
import { type DependencyGraph } from "./graph.js";
|
|
8
8
|
import { type ValidateOptions, type ValidationResult } from "./validate.js";
|
|
9
|
+
/** Root DI container: registrations, root resolve, scopes, inspect, and validate. */
|
|
9
10
|
export interface Container {
|
|
11
|
+
/** Registers a provider (or `@Injectable` class when `provider` is omitted). */
|
|
10
12
|
register<T>(token: InjectionToken<T>, provider?: Provider<T>): void;
|
|
13
|
+
/** Replaces an existing registration (tests and composition roots). */
|
|
11
14
|
override<T>(token: InjectionToken<T>, provider: Provider<T>): void;
|
|
15
|
+
/** Resolves from the root (singleton / transient only; not scoped). */
|
|
12
16
|
resolve<T>(token: InjectionToken<T>): T;
|
|
17
|
+
/** Creates a child scope (typically one per HTTP / GraphQL request). */
|
|
13
18
|
createScope(): Scope;
|
|
19
|
+
/** Exports the dependency graph for tooling and debugging. */
|
|
14
20
|
inspect(): DependencyGraph;
|
|
21
|
+
/** Runs design-time checks on the provider registry. */
|
|
15
22
|
validate(options?: ValidateOptions): ValidationResult;
|
|
16
23
|
}
|
|
24
|
+
/** Creates a new root container with an empty provider registry. */
|
|
17
25
|
export declare function createContainer(): Container;
|
|
18
26
|
type Disposer = () => void | Promise<void>;
|
|
19
27
|
export declare class ScopeImpl implements Scope {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/core/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAe,KAAK,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAShF,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,SAAS;IACxB,QAA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EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;IAIvC,WAAW,IAAI,KAAK;IAIpB,OAAO,IAAI,eAAe;IAU1B,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,gBAAgB;IAOrD,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;IAIvC,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIpD,gBAAgB,CAAC,CAAC,EAChB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EACxB,gBAAgB,EAAE,QAAQ,GAAG,IAAI,EACjC,IAAI,EAAE,MAAM,EAAE,GACb,CAAC;CAkHL"}
|
package/esm/core/container.js
CHANGED
|
@@ -16,6 +16,7 @@ import { graphNodeId, registryKey } from "./internal_keys.js";
|
|
|
16
16
|
import { CircularDependencyError, DuplicateProviderError, InvalidProviderError, LifetimeViolationError, ProviderNotFoundError, ScopeDisposedError, } from "./errors.js";
|
|
17
17
|
import { augmentGraphWithInjectableClasses, buildGraph, collectRegisteredProviders, dedupeEdges, } from "./graph.js";
|
|
18
18
|
import { validateNormalizedProviders, } from "./validate.js";
|
|
19
|
+
/** Creates a new root container with an empty provider registry. */
|
|
19
20
|
export function createContainer() {
|
|
20
21
|
return new ContainerImpl();
|
|
21
22
|
}
|
package/esm/core/errors.d.ts
CHANGED
|
@@ -2,32 +2,79 @@ import type { InjectionToken } from "./token.js";
|
|
|
2
2
|
import { type ErrorMessageKind, type Locale } from "./i18n.js";
|
|
3
3
|
/** Dependency chain while resolving (for debugging and error display). */
|
|
4
4
|
export type ResolutionPath = readonly string[];
|
|
5
|
+
/** Optional locale for localized error messages. */
|
|
5
6
|
export interface ErrorLocaleOptions {
|
|
7
|
+
/** BCP 47 or POSIX tag; normalized to `en` or `ja`. */
|
|
6
8
|
locale?: Locale;
|
|
7
9
|
}
|
|
10
|
+
/** Thrown when no provider is registered for a token. */
|
|
8
11
|
export declare class ProviderNotFoundError extends Error {
|
|
12
|
+
/** Token that could not be resolved. */
|
|
9
13
|
readonly token: InjectionToken<unknown>;
|
|
14
|
+
/** Resolution path at failure time. */
|
|
10
15
|
readonly path: ResolutionPath;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a provider-not-found error.
|
|
18
|
+
* @param token Missing token.
|
|
19
|
+
* @param path Resolution path.
|
|
20
|
+
* @param options Optional locale.
|
|
21
|
+
*/
|
|
11
22
|
constructor(token: InjectionToken<unknown>, path: ResolutionPath, options?: ErrorLocaleOptions);
|
|
12
23
|
}
|
|
24
|
+
/** Thrown when the dependency graph contains a cycle. */
|
|
13
25
|
export declare class CircularDependencyError extends Error {
|
|
26
|
+
/** Cycle path including the repeating node. */
|
|
14
27
|
readonly path: ResolutionPath;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a circular-dependency error.
|
|
30
|
+
* @param path Cycle path.
|
|
31
|
+
* @param options Optional locale.
|
|
32
|
+
*/
|
|
15
33
|
constructor(path: ResolutionPath, options?: ErrorLocaleOptions);
|
|
16
34
|
}
|
|
35
|
+
/** Thrown for invalid provider registration or resolve rules. */
|
|
17
36
|
export declare class InvalidProviderError extends Error {
|
|
37
|
+
/**
|
|
38
|
+
* Creates an invalid-provider error.
|
|
39
|
+
* @param messageOrKind Error kind or custom detail.
|
|
40
|
+
* @param params Template params and optional locale.
|
|
41
|
+
*/
|
|
18
42
|
constructor(messageOrKind: string | Extract<ErrorMessageKind, "InvalidProvider_class_token_only" | "InvalidProvider_scoped_from_root" | "InvalidProvider_unsupported_provider_type">, params?: Record<string, string> & ErrorLocaleOptions);
|
|
19
43
|
}
|
|
44
|
+
/** Thrown when resolving or registering on a disposed scope. */
|
|
20
45
|
export declare class ScopeDisposedError extends Error {
|
|
46
|
+
/**
|
|
47
|
+
* Creates a scope-disposed error.
|
|
48
|
+
* @param options Optional locale.
|
|
49
|
+
*/
|
|
21
50
|
constructor(options?: ErrorLocaleOptions);
|
|
22
51
|
}
|
|
52
|
+
/** Thrown when a shorter-lived provider depends on a longer-lived one at resolve time. */
|
|
23
53
|
export declare class LifetimeViolationError extends Error {
|
|
54
|
+
/** Lifetime of the dependent registration. */
|
|
24
55
|
readonly fromLifetime: string;
|
|
56
|
+
/** Lifetime of the dependency registration. */
|
|
25
57
|
readonly toLifetime: string;
|
|
58
|
+
/** Resolution path at violation time. */
|
|
26
59
|
readonly path: ResolutionPath;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a lifetime-violation error.
|
|
62
|
+
* @param fromLifetime Dependent lifetime.
|
|
63
|
+
* @param toLifetime Dependency lifetime.
|
|
64
|
+
* @param path Resolution path.
|
|
65
|
+
* @param options Optional locale.
|
|
66
|
+
*/
|
|
27
67
|
constructor(fromLifetime: string, toLifetime: string, path: ResolutionPath, options?: ErrorLocaleOptions);
|
|
28
68
|
}
|
|
69
|
+
/** Thrown when registering the same token twice in one registry. */
|
|
29
70
|
export declare class DuplicateProviderError extends Error {
|
|
71
|
+
/** Token that was registered again. */
|
|
30
72
|
readonly token: InjectionToken<unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a duplicate-provider error.
|
|
75
|
+
* @param token Duplicate token.
|
|
76
|
+
* @param options Optional locale.
|
|
77
|
+
*/
|
|
31
78
|
constructor(token: InjectionToken<unknown>, options?: ErrorLocaleOptions);
|
|
32
79
|
}
|
|
33
80
|
//# sourceMappingURL=errors.d.ts.map
|
package/esm/core/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,MAAM,EAGZ,MAAM,WAAW,CAAC;AAEnB,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,SAAS,MAAM,EAAE,CAAC;AAE/C,MAAM,WAAW,kBAAkB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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,kBAAkB;CASvD;AAED,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;;OAGG;gBACS,OAAO,CAAC,EAAE,kBAAkB;CAKzC;AAED,0FAA0F;AAC1F,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,8CAA8C;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAE9B;;;;;;OAMG;gBAED,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,kBAAkB;CAgB/B;AAED,oEAAoE;AACpE,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAExC;;;;OAIG;gBACS,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB;CAOzE"}
|
package/esm/core/errors.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { tokenLabel } from "./internal_keys.js";
|
|
2
2
|
import { errorMessage, lifetimeViolationHint, providerNotFoundHint, resolveLocale, } from "./i18n.js";
|
|
3
|
+
/** Thrown when no provider is registered for a token. */
|
|
3
4
|
export class ProviderNotFoundError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a provider-not-found error.
|
|
7
|
+
* @param token Missing token.
|
|
8
|
+
* @param path Resolution path.
|
|
9
|
+
* @param options Optional locale.
|
|
10
|
+
*/
|
|
4
11
|
constructor(token, path, options) {
|
|
5
12
|
const locale = resolveLocale(options);
|
|
6
13
|
const label = tokenLabel(token);
|
|
@@ -9,12 +16,14 @@ export class ProviderNotFoundError extends Error {
|
|
|
9
16
|
path: path.join(" -> "),
|
|
10
17
|
hint: providerNotFoundHint(locale),
|
|
11
18
|
}, locale));
|
|
19
|
+
/** Token that could not be resolved. */
|
|
12
20
|
Object.defineProperty(this, "token", {
|
|
13
21
|
enumerable: true,
|
|
14
22
|
configurable: true,
|
|
15
23
|
writable: true,
|
|
16
24
|
value: void 0
|
|
17
25
|
});
|
|
26
|
+
/** Resolution path at failure time. */
|
|
18
27
|
Object.defineProperty(this, "path", {
|
|
19
28
|
enumerable: true,
|
|
20
29
|
configurable: true,
|
|
@@ -26,12 +35,19 @@ export class ProviderNotFoundError extends Error {
|
|
|
26
35
|
this.path = path;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
38
|
+
/** Thrown when the dependency graph contains a cycle. */
|
|
29
39
|
export class CircularDependencyError extends Error {
|
|
40
|
+
/**
|
|
41
|
+
* Creates a circular-dependency error.
|
|
42
|
+
* @param path Cycle path.
|
|
43
|
+
* @param options Optional locale.
|
|
44
|
+
*/
|
|
30
45
|
constructor(path, options) {
|
|
31
46
|
const locale = resolveLocale(options);
|
|
32
47
|
super(errorMessage("CircularDependency", {
|
|
33
48
|
path: path.join(" -> "),
|
|
34
49
|
}, locale));
|
|
50
|
+
/** Cycle path including the repeating node. */
|
|
35
51
|
Object.defineProperty(this, "path", {
|
|
36
52
|
enumerable: true,
|
|
37
53
|
configurable: true,
|
|
@@ -42,7 +58,13 @@ export class CircularDependencyError extends Error {
|
|
|
42
58
|
this.path = path;
|
|
43
59
|
}
|
|
44
60
|
}
|
|
61
|
+
/** Thrown for invalid provider registration or resolve rules. */
|
|
45
62
|
export class InvalidProviderError extends Error {
|
|
63
|
+
/**
|
|
64
|
+
* Creates an invalid-provider error.
|
|
65
|
+
* @param messageOrKind Error kind or custom detail.
|
|
66
|
+
* @param params Template params and optional locale.
|
|
67
|
+
*/
|
|
46
68
|
constructor(messageOrKind, params) {
|
|
47
69
|
const locale = resolveLocale(params);
|
|
48
70
|
const text = typeof messageOrKind === "string"
|
|
@@ -52,14 +74,27 @@ export class InvalidProviderError extends Error {
|
|
|
52
74
|
this.name = "InvalidProviderError";
|
|
53
75
|
}
|
|
54
76
|
}
|
|
77
|
+
/** Thrown when resolving or registering on a disposed scope. */
|
|
55
78
|
export class ScopeDisposedError extends Error {
|
|
79
|
+
/**
|
|
80
|
+
* Creates a scope-disposed error.
|
|
81
|
+
* @param options Optional locale.
|
|
82
|
+
*/
|
|
56
83
|
constructor(options) {
|
|
57
84
|
const locale = resolveLocale(options);
|
|
58
85
|
super(errorMessage("ScopeDisposed", {}, locale));
|
|
59
86
|
this.name = "ScopeDisposedError";
|
|
60
87
|
}
|
|
61
88
|
}
|
|
89
|
+
/** Thrown when a shorter-lived provider depends on a longer-lived one at resolve time. */
|
|
62
90
|
export class LifetimeViolationError extends Error {
|
|
91
|
+
/**
|
|
92
|
+
* Creates a lifetime-violation error.
|
|
93
|
+
* @param fromLifetime Dependent lifetime.
|
|
94
|
+
* @param toLifetime Dependency lifetime.
|
|
95
|
+
* @param path Resolution path.
|
|
96
|
+
* @param options Optional locale.
|
|
97
|
+
*/
|
|
63
98
|
constructor(fromLifetime, toLifetime, path, options) {
|
|
64
99
|
const locale = resolveLocale(options);
|
|
65
100
|
super(errorMessage("LifetimeViolation", {
|
|
@@ -68,18 +103,21 @@ export class LifetimeViolationError extends Error {
|
|
|
68
103
|
path: path.join(" -> "),
|
|
69
104
|
hint: lifetimeViolationHint(locale),
|
|
70
105
|
}, locale));
|
|
106
|
+
/** Lifetime of the dependent registration. */
|
|
71
107
|
Object.defineProperty(this, "fromLifetime", {
|
|
72
108
|
enumerable: true,
|
|
73
109
|
configurable: true,
|
|
74
110
|
writable: true,
|
|
75
111
|
value: void 0
|
|
76
112
|
});
|
|
113
|
+
/** Lifetime of the dependency registration. */
|
|
77
114
|
Object.defineProperty(this, "toLifetime", {
|
|
78
115
|
enumerable: true,
|
|
79
116
|
configurable: true,
|
|
80
117
|
writable: true,
|
|
81
118
|
value: void 0
|
|
82
119
|
});
|
|
120
|
+
/** Resolution path at violation time. */
|
|
83
121
|
Object.defineProperty(this, "path", {
|
|
84
122
|
enumerable: true,
|
|
85
123
|
configurable: true,
|
|
@@ -92,11 +130,18 @@ export class LifetimeViolationError extends Error {
|
|
|
92
130
|
this.path = path;
|
|
93
131
|
}
|
|
94
132
|
}
|
|
133
|
+
/** Thrown when registering the same token twice in one registry. */
|
|
95
134
|
export class DuplicateProviderError extends Error {
|
|
135
|
+
/**
|
|
136
|
+
* Creates a duplicate-provider error.
|
|
137
|
+
* @param token Duplicate token.
|
|
138
|
+
* @param options Optional locale.
|
|
139
|
+
*/
|
|
96
140
|
constructor(token, options) {
|
|
97
141
|
const locale = resolveLocale(options);
|
|
98
142
|
const label = tokenLabel(token);
|
|
99
143
|
super(errorMessage("DuplicateProvider", { label }, locale));
|
|
144
|
+
/** Token that was registered again. */
|
|
100
145
|
Object.defineProperty(this, "token", {
|
|
101
146
|
enumerable: true,
|
|
102
147
|
configurable: true,
|
package/esm/core/graph.d.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import type { Lifetime } from "./lifetime.js";
|
|
2
2
|
import type { NormalizedProvider, ProviderType } from "./provider.js";
|
|
3
3
|
import type { InjectionToken } from "./token.js";
|
|
4
|
+
/** Node in a dependency graph produced by {@link Container.inspect}. */
|
|
4
5
|
export interface DependencyNode {
|
|
6
|
+
/** Stable node id (token label). */
|
|
5
7
|
id: string;
|
|
8
|
+
/** Display name for the token or class. */
|
|
6
9
|
name: string;
|
|
10
|
+
/** Resolved lifetime for this registration. */
|
|
7
11
|
lifetime: Lifetime;
|
|
12
|
+
/** Kind of provider backing this node. */
|
|
8
13
|
provider: ProviderType;
|
|
9
14
|
}
|
|
15
|
+
/** Directed dependency edge between two graph nodes. */
|
|
10
16
|
export interface DependencyEdge {
|
|
17
|
+
/** Source node id (dependent). */
|
|
11
18
|
from: string;
|
|
19
|
+
/** Target node id (dependency). */
|
|
12
20
|
to: string;
|
|
13
21
|
}
|
|
22
|
+
/** Full dependency graph (nodes and edges). */
|
|
14
23
|
export interface DependencyGraph {
|
|
24
|
+
/** All registered and inferred nodes. */
|
|
15
25
|
nodes: DependencyNode[];
|
|
26
|
+
/** Dependency edges between nodes. */
|
|
16
27
|
edges: DependencyEdge[];
|
|
17
28
|
}
|
|
18
29
|
export declare function inferLifetimeForToken(dep: InjectionToken<unknown>): Lifetime;
|
package/esm/core/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/core/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAM5E;AAED,wBAAgB,UAAU,CACxB,SAAS,EAAE,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAC/C,eAAe,CAgCjB;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAUrE;AAED,OAAO,KAAK,EAAE,WAAW,EAAE,MA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O,CAAC,CAAC,GAC/C,eAAe,CAgCjB;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAUrE;AAED,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,GACtD,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAE/B;AAED,6EAA6E;AAC7E,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GAC9C,eAAe,CAiBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_format.d.ts","sourceRoot":"","sources":["../../src/core/graph_format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAcD;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAYzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAa7D"}
|
|
1
|
+
{"version":3,"file":"graph_format.d.ts","sourceRoot":"","sources":["../../src/core/graph_format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAElE,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAcD;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAYzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAa7D"}
|
package/esm/core/i18n.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export type Locale = "en" | "ja";
|
|
2
|
+
/** Default locale when none is resolved from options or environment. */
|
|
2
3
|
export declare const DEFAULT_LOCALE: Locale;
|
|
4
|
+
/** Validation issue codes used by {@link validationMessage}. */
|
|
3
5
|
export type ValidationMessageCode = "unresolved_dependency" | "singleton_depends_on_scoped" | "transient_depends_on_scoped" | "circular_dependency" | "unused_provider";
|
|
6
|
+
/** Runtime error message kinds used by {@link errorMessage}. */
|
|
4
7
|
export type ErrorMessageKind = "ProviderNotFound" | "CircularDependency" | "ScopeDisposed" | "LifetimeViolation" | "DuplicateProvider" | "InvalidProvider_class_token_only" | "InvalidProvider_scoped_from_root" | "InvalidProvider_unsupported_provider_type" | "InvalidProvider_custom";
|
|
5
8
|
/** Normalize BCP 47 / POSIX locale tags to supported `en` | `ja`. */
|
|
6
9
|
export declare function normalizeLocaleTag(tag: string): Locale;
|
|
@@ -8,8 +11,12 @@ export declare function normalizeLocaleTag(tag: string): Locale;
|
|
|
8
11
|
export declare function resolveLocale(options?: {
|
|
9
12
|
locale?: Locale;
|
|
10
13
|
}): Locale;
|
|
14
|
+
/** Builds a localized validation issue message for the given code. */
|
|
11
15
|
export declare function validationMessage(code: ValidationMessageCode, params: Record<string, string>, locale: Locale): string;
|
|
16
|
+
/** Builds a localized runtime error message for the given kind. */
|
|
12
17
|
export declare function errorMessage(kind: ErrorMessageKind, params: Record<string, string>, locale: Locale): string;
|
|
18
|
+
/** Hint appended to {@link ProviderNotFoundError} messages. */
|
|
13
19
|
export declare function providerNotFoundHint(locale: Locale): string;
|
|
20
|
+
/** Hint appended to {@link LifetimeViolationError} messages. */
|
|
14
21
|
export declare function lifetimeViolationHint(locale: Locale): string;
|
|
15
22
|
//# sourceMappingURL=i18n.d.ts.map
|
package/esm/core/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/core/i18n.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/core/i18n.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,MAAa,CAAC;AAE3C,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAC7B,uBAAuB,GACvB,6BAA6B,GAC7B,6BAA6B,GAC7B,qBAAqB,GACrB,iBAAiB,CAAC;AAEtB,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,oBAAoB,GACpB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,kCAAkC,GAClC,kCAAkC,GAClC,2CAA2C,GAC3C,wBAAwB,CAAC;AAE7B,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAItD;AAqBD,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CA0BnE;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,qBAAqB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,MAAM,EAAE,MAAM,GACb,MAAM,CAsBR;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,MAAM,EAAE,MAAM,GACb,MAAM,CA6CR;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI3D;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
package/esm/core/i18n.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** Supported locales for errors and validation messages. */
|
|
1
2
|
import * as dntShim from "../_dnt.shims.js";
|
|
3
|
+
/** Default locale when none is resolved from options or environment. */
|
|
2
4
|
export const DEFAULT_LOCALE = "en";
|
|
3
5
|
/** Normalize BCP 47 / POSIX locale tags to supported `en` | `ja`. */
|
|
4
6
|
export function normalizeLocaleTag(tag) {
|
|
@@ -9,7 +11,20 @@ export function normalizeLocaleTag(tag) {
|
|
|
9
11
|
}
|
|
10
12
|
function envGet(key) {
|
|
11
13
|
try {
|
|
12
|
-
|
|
14
|
+
const proc = dntShim.dntGlobalThis
|
|
15
|
+
.process;
|
|
16
|
+
const fromProcess = proc?.env?.[key];
|
|
17
|
+
if (fromProcess !== undefined)
|
|
18
|
+
return fromProcess;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// ignore
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const runtime = dntShim.dntGlobalThis;
|
|
25
|
+
const env = runtime["Deno"]
|
|
26
|
+
?.env;
|
|
27
|
+
return env?.get(key);
|
|
13
28
|
}
|
|
14
29
|
catch {
|
|
15
30
|
return undefined;
|
|
@@ -42,6 +57,7 @@ export function resolveLocale(options) {
|
|
|
42
57
|
}
|
|
43
58
|
return DEFAULT_LOCALE;
|
|
44
59
|
}
|
|
60
|
+
/** Builds a localized validation issue message for the given code. */
|
|
45
61
|
export function validationMessage(code, params, locale) {
|
|
46
62
|
const { fromId, depId, cycle } = params;
|
|
47
63
|
switch (code) {
|
|
@@ -65,6 +81,7 @@ export function validationMessage(code, params, locale) {
|
|
|
65
81
|
: `${fromId} is not depended on by any other provider (may be unused).`;
|
|
66
82
|
}
|
|
67
83
|
}
|
|
84
|
+
/** Builds a localized runtime error message for the given kind. */
|
|
68
85
|
export function errorMessage(kind, params, locale) {
|
|
69
86
|
const label = params.label ?? "";
|
|
70
87
|
const path = params.path ?? "";
|
|
@@ -110,11 +127,13 @@ export function errorMessage(kind, params, locale) {
|
|
|
110
127
|
return `InvalidProviderError: ${detail}`;
|
|
111
128
|
}
|
|
112
129
|
}
|
|
130
|
+
/** Hint appended to {@link ProviderNotFoundError} messages. */
|
|
113
131
|
export function providerNotFoundHint(locale) {
|
|
114
132
|
return locale === "ja"
|
|
115
133
|
? "composition root で register() するか、@Injectable() の deps を確認してください。"
|
|
116
134
|
: "Register it in the composition root or check @Injectable() deps.";
|
|
117
135
|
}
|
|
136
|
+
/** Hint appended to {@link LifetimeViolationError} messages. */
|
|
118
137
|
export function lifetimeViolationHint(locale) {
|
|
119
138
|
return locale === "ja"
|
|
120
139
|
? "singleton は scoped インスタンスに依存できません。scoped にするか、依存を singleton/transient に変更してください。"
|
package/esm/core/lifetime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifetime.d.ts","sourceRoot":"","sources":["../../src/core/lifetime.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"lifetime.d.ts","sourceRoot":"","sources":["../../src/core/lifetime.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC"}
|
package/esm/core/metadata.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ClassToken } from "./token.js";
|
|
2
2
|
import type { Lifetime } from "./lifetime.js";
|
|
3
3
|
import type { InjectionToken } from "./token.js";
|
|
4
|
+
/** Options for the {@link Injectable} class decorator. */
|
|
4
5
|
export interface InjectableMetadata {
|
|
6
|
+
/** Constructor dependency tokens. */
|
|
5
7
|
deps?: InjectionToken<unknown>[];
|
|
8
|
+
/** Default lifetime when registered via class token only. */
|
|
6
9
|
lifetime?: Lifetime;
|
|
7
10
|
}
|
|
8
11
|
export declare function setInjectableMetadata(ctor: ClassToken<unknown>, meta: InjectableMetadata): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/core/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAOD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,EACzB,IAAI,EAAE,kBAAkB,GACvB,IAAI,CAEN;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GACxB,kBAAkB,GAAG,SAAS,CAEhC"}
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/core/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,IAAI,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAOD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,EACzB,IAAI,EAAE,kBAAkB,GACvB,IAAI,CAEN;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GACxB,kBAAkB,GAAG,SAAS,CAEhC"}
|
package/esm/core/mod.d.ts
CHANGED
|
@@ -1,14 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit DI for modern TypeScript — typed tokens, standard decorators, and request scopes.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { createContainer, Injectable, token } from "@wyrly/core";
|
|
7
|
+
*
|
|
8
|
+
* const RepoToken = token<{ findById(id: string): Promise<unknown> }>("Repo");
|
|
9
|
+
*
|
|
10
|
+
* @Injectable({ deps: [RepoToken], lifetime: "scoped" })
|
|
11
|
+
* class GetUser {
|
|
12
|
+
* constructor(private readonly repo: { findById(id: string): Promise<unknown> }) {}
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* const container = createContainer();
|
|
16
|
+
* container.register(RepoToken, { useValue: { findById: async () => null }, lifetime: "scoped" });
|
|
17
|
+
* container.register(GetUser);
|
|
18
|
+
*
|
|
19
|
+
* const scope = container.createScope();
|
|
20
|
+
* try {
|
|
21
|
+
* scope.resolve(GetUser);
|
|
22
|
+
* } finally {
|
|
23
|
+
* await scope.dispose();
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
1
29
|
export { type ClassToken, type InjectionToken, type Token, token } from "./token.js";
|
|
2
30
|
export type { Lifetime } from "./lifetime.js";
|
|
3
31
|
export { Injectable } from "./decorators.js";
|
|
32
|
+
export type { InjectableMetadata } from "./metadata.js";
|
|
33
|
+
export type { ClassDecoratorContext } from "./types_decorator.js";
|
|
4
34
|
export { type Container, createContainer } from "./container.js";
|
|
5
35
|
export type { Scope } from "./scope.js";
|
|
6
|
-
export type { ClassProvider, ExistingProvider, FactoryProvider, Provider, ValueProvider, } from "./provider.js";
|
|
36
|
+
export type { ClassProvider, ExistingProvider, FactoryProvider, NormalizedProvider, Provider, ProviderType, ValueProvider, } from "./provider.js";
|
|
7
37
|
export type { DependencyEdge, DependencyGraph, DependencyNode } from "./graph.js";
|
|
8
38
|
export { graphToDot, graphToJson, graphToMermaid } from "./graph_format.js";
|
|
9
39
|
export type { GraphToJsonOptions } from "./graph_format.js";
|
|
10
40
|
export type { ValidateOptions, ValidationIssue, ValidationResult } from "./validate.js";
|
|
11
41
|
export { validateNormalizedProviders } from "./validate.js";
|
|
12
42
|
export { DEFAULT_LOCALE, errorMessage, type ErrorMessageKind, lifetimeViolationHint, type Locale, normalizeLocaleTag, providerNotFoundHint, resolveLocale, validationMessage, type ValidationMessageCode, } from "./i18n.js";
|
|
13
|
-
export { CircularDependencyError, DuplicateProviderError, InvalidProviderError, LifetimeViolationError, ProviderNotFoundError, ScopeDisposedError, } from "./errors.js";
|
|
43
|
+
export { CircularDependencyError, DuplicateProviderError, type ErrorLocaleOptions, InvalidProviderError, LifetimeViolationError, ProviderNotFoundError, type ResolutionPath, ScopeDisposedError, } from "./errors.js";
|
|
14
44
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/core/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/core/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACrF,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,MAAM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AAO,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,KAAK,MAAM,EACX,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,cAAc,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
|
package/esm/core/mod.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit DI for modern TypeScript — typed tokens, standard decorators, and request scopes.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { createContainer, Injectable, token } from "@wyrly/core";
|
|
7
|
+
*
|
|
8
|
+
* const RepoToken = token<{ findById(id: string): Promise<unknown> }>("Repo");
|
|
9
|
+
*
|
|
10
|
+
* @Injectable({ deps: [RepoToken], lifetime: "scoped" })
|
|
11
|
+
* class GetUser {
|
|
12
|
+
* constructor(private readonly repo: { findById(id: string): Promise<unknown> }) {}
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* const container = createContainer();
|
|
16
|
+
* container.register(RepoToken, { useValue: { findById: async () => null }, lifetime: "scoped" });
|
|
17
|
+
* container.register(GetUser);
|
|
18
|
+
*
|
|
19
|
+
* const scope = container.createScope();
|
|
20
|
+
* try {
|
|
21
|
+
* scope.resolve(GetUser);
|
|
22
|
+
* } finally {
|
|
23
|
+
* await scope.dispose();
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
1
29
|
export { token } from "./token.js";
|
|
2
30
|
export { Injectable } from "./decorators.js";
|
|
3
31
|
export { createContainer } from "./container.js";
|
package/esm/core/provider.d.ts
CHANGED
|
@@ -2,39 +2,64 @@ import type { Scope } from "./scope.js";
|
|
|
2
2
|
import type { ClassToken } from "./token.js";
|
|
3
3
|
import type { InjectionToken } from "./token.js";
|
|
4
4
|
import type { Lifetime } from "./lifetime.js";
|
|
5
|
+
/** Registration shape accepted by {@link Container.register}. */
|
|
5
6
|
export type Provider<T> = ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
7
|
+
/** Registers a class constructor as the implementation. */
|
|
6
8
|
export interface ClassProvider<T> {
|
|
9
|
+
/** Class to instantiate. */
|
|
7
10
|
useClass: ClassToken<T>;
|
|
11
|
+
/** Explicit constructor dependencies (overrides `@Injectable` metadata). */
|
|
8
12
|
deps?: InjectionToken<unknown>[];
|
|
13
|
+
/** Lifetime override (overrides `@Injectable` metadata). */
|
|
9
14
|
lifetime?: Lifetime;
|
|
10
15
|
}
|
|
16
|
+
/** Registers a constant value (singleton only). */
|
|
11
17
|
export interface ValueProvider<T> {
|
|
18
|
+
/** Pre-built instance. */
|
|
12
19
|
useValue: T;
|
|
20
|
+
/** Must be `"singleton"` when set. */
|
|
13
21
|
lifetime?: "singleton";
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
|
-
*
|
|
24
|
+
* Registers a factory function (synchronous only in v1).
|
|
25
|
+
* `Promise<T>` is planned for a future `resolveAsync`.
|
|
17
26
|
*/
|
|
18
27
|
export interface FactoryProvider<T> {
|
|
28
|
+
/** Factory invoked with the active scope. */
|
|
19
29
|
useFactory: (scope: Scope) => T;
|
|
30
|
+
/** Tokens resolved before the factory runs. */
|
|
20
31
|
deps?: InjectionToken<unknown>[];
|
|
32
|
+
/** Lifetime for the factory result. */
|
|
21
33
|
lifetime?: Lifetime;
|
|
22
34
|
}
|
|
35
|
+
/** Aliases another registered token. */
|
|
23
36
|
export interface ExistingProvider<T> {
|
|
37
|
+
/** Token to resolve instead. */
|
|
24
38
|
useExisting: InjectionToken<T>;
|
|
39
|
+
/** Lifetime for this alias registration. */
|
|
25
40
|
lifetime?: Lifetime;
|
|
26
41
|
}
|
|
42
|
+
/** Normalized provider kind stored in the registry. */
|
|
27
43
|
export type ProviderType = "class" | "value" | "factory" | "existing";
|
|
28
|
-
/** Container-internal representation (normalized after registration) */
|
|
44
|
+
/** Container-internal representation (normalized after registration). */
|
|
29
45
|
export interface NormalizedProvider<T = unknown> {
|
|
46
|
+
/** Token this provider satisfies. */
|
|
30
47
|
readonly token: InjectionToken<T>;
|
|
48
|
+
/** Provider kind after normalization. */
|
|
31
49
|
readonly providerType: ProviderType;
|
|
50
|
+
/** Declared dependency tokens. */
|
|
32
51
|
readonly deps: readonly InjectionToken<unknown>[];
|
|
52
|
+
/** Effective lifetime. */
|
|
33
53
|
readonly lifetime: Lifetime;
|
|
54
|
+
/** Label used in graphs and errors. */
|
|
34
55
|
readonly displayName: string;
|
|
56
|
+
/** Set when `providerType` is `"class"`. */
|
|
35
57
|
readonly useClass?: ClassToken<T>;
|
|
58
|
+
/** Set when `providerType` is `"value"`. */
|
|
36
59
|
readonly useValue?: T;
|
|
60
|
+
/** Set when `providerType` is `"factory"`. */
|
|
37
61
|
readonly useFactory?: (scope: Scope) => T;
|
|
62
|
+
/** Set when `providerType` is `"existing"`. */
|
|
38
63
|
readonly useExisting?: InjectionToken<T>;
|
|
39
64
|
}
|
|
40
65
|
export declare function normalizeProvider<T>(token: InjectionToken<T>, provider: Provider<T>): NormalizedProvider<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/core/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,MAAM,MAAM,QAAQ,CAAC,CAAC,IAClB,aAAa,CAAC,CAAC,CAAC,GAChB,aAAa,CAAC,CAAC,CAAC,GAChB,eAAe,CAAC,CAAC,CAAC,GAClB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAExB,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC;IACZ,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB;AAED
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/core/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,C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AAG,OAAO;IAC7C,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAClC,yCAAyC;IACzC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IAClD,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAClC,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,CAAC;IAC1C,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;CAC1C;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EACxB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GACpB,kBAAkB,CAAC,CAAC,CAAC,CAwDvB;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GACnB,kBAAkB,CAAC,CAAC,CAAC,CAYvB"}
|
package/esm/core/scope.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Provider } from "./provider.js";
|
|
2
2
|
import type { InjectionToken } from "./token.js";
|
|
3
|
+
/** Request or nested DI scope; resolves scoped and transient providers. */
|
|
3
4
|
export interface Scope {
|
|
5
|
+
/** Resolves a provider from this scope (or parent container). */
|
|
4
6
|
resolve<T>(token: InjectionToken<T>): T;
|
|
7
|
+
/** Registers a provider local to this scope. */
|
|
5
8
|
register<T>(token: InjectionToken<T>, provider: Provider<T>): void;
|
|
9
|
+
/** Sets a pre-built instance for a token in this scope. */
|
|
6
10
|
set<T>(token: InjectionToken<T>, value: T): void;
|
|
11
|
+
/** Disposes scoped instances and runs registered disposers. */
|
|
7
12
|
dispose(): Promise<void>;
|
|
13
|
+
/** Whether {@link dispose} has already been called. */
|
|
8
14
|
isDisposed(): boolean;
|
|
9
15
|
}
|
|
10
16
|
//# sourceMappingURL=scope.d.ts.map
|
package/esm/core/scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/core/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,KAAK;IACpB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACjD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC;CACvB"}
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/core/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,2EAA2E;AAC3E,MAAM,WAAW,KAAK;IACpB,iEAAiE;IACjE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxC,gDAAgD;IAChD,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,2DAA2D;IAC3D,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACjD,+DAA+D;IAC/D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,uDAAuD;IACvD,UAAU,IAAI,OAAO,CAAC;CACvB"}
|
package/esm/core/token.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
/** Typed DI token (at runtime only `id` and `name` carry meaning) */
|
|
1
|
+
/** Typed DI token (at runtime only `id` and `name` carry meaning). */
|
|
2
2
|
export interface Token<T> {
|
|
3
|
+
/** Discriminator for token objects. */
|
|
3
4
|
readonly kind: "token";
|
|
5
|
+
/** Unique symbol id for this token. */
|
|
4
6
|
readonly id: symbol;
|
|
7
|
+
/** Human-readable name (used in errors and graphs). */
|
|
5
8
|
readonly name: string;
|
|
9
|
+
/** Phantom type parameter for compile-time typing only. */
|
|
6
10
|
readonly __type?: T;
|
|
7
11
|
}
|
|
8
|
-
/** Class constructor used as an injection token */
|
|
12
|
+
/** Class constructor used as an injection token. */
|
|
9
13
|
export type ClassToken<T> = abstract new (...args: never[]) => T;
|
|
14
|
+
/** Either a {@link Token} or a class constructor token. */
|
|
10
15
|
export type InjectionToken<T> = Token<T> | ClassToken<T>;
|
|
16
|
+
/** Creates a typed injection token for interface-based dependencies. */
|
|
11
17
|
export declare function token<T>(name: string): Token<T>;
|
|
12
18
|
//# sourceMappingURL=token.d.ts.map
|
package/esm/core/token.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/core/token.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/core/token.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CACrB;AAED,oDAAoD;AACpD,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEjE,2DAA2D;AAC3D,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAEzD,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAM/C"}
|
package/esm/core/token.js
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
* Defined locally so types work in environments without DOM in `lib`.
|
|
4
4
|
*/
|
|
5
5
|
export interface ClassDecoratorContext<T extends abstract new (...args: never[]) => unknown = abstract new (...args: never[]) => unknown> {
|
|
6
|
+
/** Always `"class"` for class decorators. */
|
|
6
7
|
readonly kind: "class";
|
|
8
|
+
/** Decorated class name, if available. */
|
|
7
9
|
readonly name: string | undefined;
|
|
10
|
+
/** Decorator metadata bag (standard decorators). */
|
|
8
11
|
readonly metadata: unknown;
|
|
12
|
+
/** Registers a class instance initializer. */
|
|
9
13
|
addInitializer(initializer: (this: T) => void): void;
|
|
10
14
|
}
|
|
11
15
|
//# sourceMappingURL=types_decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types_decorator.d.ts","sourceRoot":"","sources":["../../src/core/types_decorator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CACpC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GAAG,QAAQ,MAC7D,GAAG,IAAI,EAAE,KAAK,EAAE,KACb,OAAO;IAEZ,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;CACtD"}
|
|
1
|
+
{"version":3,"file":"types_decorator.d.ts","sourceRoot":"","sources":["../../src/core/types_decorator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CACpC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GAAG,QAAQ,MAC7D,GAAG,IAAI,EAAE,KAAK,EAAE,KACb,OAAO;IAEZ,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,8CAA8C;IAC9C,cAAc,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;CACtD"}
|
package/esm/core/validate.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import type { NormalizedProvider } from "./provider.js";
|
|
2
2
|
import { type Locale } from "./i18n.js";
|
|
3
|
+
/** Single design-time validation finding. */
|
|
3
4
|
export interface ValidationIssue {
|
|
5
|
+
/** `"error"` blocks `ok`; `"warning"` is informational. */
|
|
4
6
|
severity: "error" | "warning";
|
|
7
|
+
/** Stable machine-readable code. */
|
|
5
8
|
code: string;
|
|
9
|
+
/** Localized human-readable message. */
|
|
6
10
|
message: string;
|
|
7
11
|
}
|
|
12
|
+
/** Result of {@link Container.validate} or {@link validateNormalizedProviders}. */
|
|
8
13
|
export interface ValidationResult {
|
|
14
|
+
/** `true` when no issues have `severity: "error"`. */
|
|
9
15
|
ok: boolean;
|
|
16
|
+
/** All errors and warnings collected. */
|
|
10
17
|
issues: ValidationIssue[];
|
|
11
18
|
}
|
|
19
|
+
/** Options for validation and localized messages. */
|
|
12
20
|
export interface ValidateOptions {
|
|
21
|
+
/** Locale for issue messages (`en` or `ja`). */
|
|
13
22
|
locale?: Locale;
|
|
14
23
|
}
|
|
15
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIxD,OAAO,EACL,KAAK,MAAM,EAIZ,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAiDD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE,EACxC,OAAO,CAAC,EAAE,eAAe,GACxB,gBAAgB,CAiGlB"}
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIxD,OAAO,EACL,KAAK,MAAM,EAIZ,MAAM,WAAW,CAAC;AAEnB,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,EAAE,EAAE,OAAO,CAAC;IACZ,yCAAyC;IACzC,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAiDD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE,EACxC,OAAO,CAAC,EAAE,eAAe,GACxB,gBAAgB,CAiGlB"}
|
package/esm/express/mod.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Express adapter for Wyrly DI — one scope per HTTP request via `diMiddleware`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import express from "express";
|
|
7
|
+
* import { asExpressRequestWithDI, diMiddleware } from "@wyrly/express";
|
|
8
|
+
* import { createContainer } from "@wyrly/core";
|
|
9
|
+
*
|
|
10
|
+
* const app = express();
|
|
11
|
+
* const container = createContainer();
|
|
12
|
+
* app.use(diMiddleware(container));
|
|
13
|
+
*
|
|
14
|
+
* app.get("/users/:id", (req, res) => {
|
|
15
|
+
* const di = asExpressRequestWithDI(req).di;
|
|
16
|
+
* res.json({ ok: true });
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
export type { ClassProvider, ClassToken, Container, DependencyEdge, DependencyGraph, DependencyNode, ExistingProvider, FactoryProvider, InjectionToken, Lifetime, Locale, Provider, ProviderType, Scope, Token, ValidateOptions, ValidationIssue, ValidationResult, ValueProvider, } from "../core/mod.js";
|
|
1
23
|
export { diMiddleware } from "./middleware.js";
|
|
2
24
|
export { ExpressRequestToken, ExpressResponseToken } from "./tokens.js";
|
|
3
25
|
export { asExpressRequestWithDI, type ExpressRequestWithDI } from "./types.js";
|
package/esm/express/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/express/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/express/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,YAAY,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,KAAK,EACL,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
package/esm/express/tokens.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Request, Response } from "express";
|
|
2
|
+
import { type Token } from "../core/mod.js";
|
|
1
3
|
/** Current Express `Request` (resolvable only in request scope) */
|
|
2
|
-
export declare const ExpressRequestToken:
|
|
4
|
+
export declare const ExpressRequestToken: Token<Request>;
|
|
3
5
|
/** Current Express `Response` (resolvable only in request scope) */
|
|
4
|
-
export declare const ExpressResponseToken:
|
|
6
|
+
export declare const ExpressResponseToken: Token<Response>;
|
|
5
7
|
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/express/tokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/express/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,gBAAgB,CAAC;AAEnD,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAoC,CAAC;AAEpF,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAsC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wyrly/express",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Wyrly DI adapter for Express",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Wyrly DI adapter for Express — request scope via diMiddleware",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wyrly",
|
|
7
|
+
"dependency-injection",
|
|
8
|
+
"di",
|
|
9
|
+
"typescript",
|
|
10
|
+
"inversion-of-control",
|
|
11
|
+
"ioc",
|
|
12
|
+
"express",
|
|
13
|
+
"middleware",
|
|
14
|
+
"node",
|
|
15
|
+
"http"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/valid-lab/wyrly/tree/main/packages/express",
|
|
5
18
|
"repository": {
|
|
6
19
|
"type": "git",
|
|
7
20
|
"url": "git+https://github.com/valid-lab/wyrly.git",
|
|
8
21
|
"directory": "packages/express"
|
|
9
22
|
},
|
|
10
23
|
"license": "Apache-2.0",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/valid-lab/wyrly/issues"
|
|
26
|
+
},
|
|
11
27
|
"module": "./esm/express/mod.js",
|
|
12
28
|
"exports": {
|
|
13
29
|
".": {
|
|
@@ -18,14 +34,10 @@
|
|
|
18
34
|
"sideEffects": false,
|
|
19
35
|
"dependencies": {
|
|
20
36
|
"express": "5",
|
|
21
|
-
"@
|
|
22
|
-
"@wyrly/core": "^1.0.3"
|
|
37
|
+
"@wyrly/core": "^1.0.5"
|
|
23
38
|
},
|
|
24
39
|
"peerDependencies": {
|
|
25
40
|
"express": "^5.0.0"
|
|
26
41
|
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/node": "^20.9.0"
|
|
29
|
-
},
|
|
30
42
|
"_generatedBy": "dnt@dev"
|
|
31
43
|
}
|