@codefast/di 0.3.14-canary.1 → 0.3.14
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/CHANGELOG.md +58 -0
- package/README.md +42 -26
- package/dist/binding-scope.d.mts +11 -0
- package/dist/binding-scope.mjs +19 -0
- package/dist/binding-select.d.mts +8 -26
- package/dist/binding-select.mjs +56 -49
- package/dist/binding.d.mts +107 -335
- package/dist/binding.mjs +19 -332
- package/dist/constraints.d.mts +11 -29
- package/dist/constraints.mjs +32 -36
- package/dist/constructor-type.d.mts +17 -0
- package/dist/constructor-type.mjs +1 -0
- package/dist/container.d.mts +43 -122
- package/dist/container.mjs +667 -482
- package/dist/decorators/inject.d.mts +19 -50
- package/dist/decorators/inject.mjs +131 -93
- package/dist/decorators/injectable.d.mts +16 -37
- package/dist/decorators/injectable.mjs +47 -66
- package/dist/decorators/lifecycle-decorators.d.mts +2 -22
- package/dist/decorators/lifecycle-decorators.mjs +81 -37
- package/dist/dependency-graph.d.mts +24 -54
- package/dist/dependency-graph.mjs +51 -153
- package/dist/environment.d.mts +38 -12
- package/dist/environment.mjs +82 -16
- package/dist/errors.d.mts +70 -189
- package/dist/errors.mjs +92 -219
- package/dist/graph-adapters/cytoscape.d.mts +21 -7
- package/dist/graph-adapters/cytoscape.mjs +18 -35
- package/dist/graph-adapters/dot.d.mts +1 -4
- package/dist/graph-adapters/dot.mjs +6 -86
- package/dist/graph-adapters/reactflow.d.mts +26 -7
- package/dist/graph-adapters/reactflow.mjs +21 -72
- package/dist/graph-adapters/types.d.mts +2 -91
- package/dist/index.d.mts +16 -8
- package/dist/index.mjs +8 -5
- package/dist/inspector.d.mts +35 -74
- package/dist/inspector.mjs +61 -88
- package/dist/lifecycle.d.mts +20 -53
- package/dist/lifecycle.mjs +129 -99
- package/dist/metadata/metadata-keys.d.mts +9 -26
- package/dist/metadata/metadata-keys.mjs +7 -28
- package/dist/metadata/metadata-reader-token.d.mts +7 -0
- package/dist/metadata/metadata-reader-token.mjs +5 -0
- package/dist/metadata/metadata-types.d.mts +26 -75
- package/dist/metadata/symbol-metadata-reader.d.mts +10 -26
- package/dist/metadata/symbol-metadata-reader.mjs +32 -45
- package/dist/module.d.mts +30 -96
- package/dist/module.mjs +26 -72
- package/dist/registry.d.mts +32 -63
- package/dist/registry.mjs +131 -82
- package/dist/resolve-options.d.mts +18 -0
- package/dist/resolve-options.mjs +22 -0
- package/dist/resolver.d.mts +67 -190
- package/dist/resolver.mjs +715 -424
- package/dist/scope.d.mts +19 -106
- package/dist/scope.mjs +37 -196
- package/dist/token.d.mts +8 -22
- package/dist/token.mjs +9 -11
- package/dist/types.d.mts +48 -0
- package/dist/types.mjs +1 -0
- package/package.json +36 -14
- package/dist/metadata/param-registry.d.mts +0 -16
- package/dist/metadata/param-registry.mjs +0 -31
- package/dist/scope-validation.d.mts +0 -21
- package/dist/scope-validation.mjs +0 -35
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { RegistryKey } from "./registry.mjs";
|
|
2
|
-
import { Binding } from "./binding.mjs";
|
|
3
|
-
import { MetadataReader } from "./metadata/metadata-types.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/scope-validation.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Walks every binding in the registry and throws {@link ScopeViolationError} on the first
|
|
8
|
-
* captive-dependency violation found **along a direct static edge**: for each binding, only
|
|
9
|
-
* targets returned by {@link listResolvedDependencies} are considered (not a full recursive
|
|
10
|
-
* graph walk). Constant bindings are exempt.
|
|
11
|
-
*
|
|
12
|
-
* Called by {@link Container.validate} and automatically after each `load()` in non-production
|
|
13
|
-
* environments.
|
|
14
|
-
*/
|
|
15
|
-
declare function validateScopeRules(context: {
|
|
16
|
-
collectAllRegistryKeys(): readonly RegistryKey[];
|
|
17
|
-
lookupBindings(key: RegistryKey): readonly Binding<unknown>[] | undefined;
|
|
18
|
-
getMetadataReader(): MetadataReader | undefined;
|
|
19
|
-
}): void;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { validateScopeRules };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ScopeViolationError } from "./errors.mjs";
|
|
2
|
-
import { registryKeyLabel } from "./binding-select.mjs";
|
|
3
|
-
import { listResolvedDependencies } from "./dependency-graph.mjs";
|
|
4
|
-
//#region src/scope-validation.ts
|
|
5
|
-
/**
|
|
6
|
-
* Walks every binding in the registry and throws {@link ScopeViolationError} on the first
|
|
7
|
-
* captive-dependency violation found **along a direct static edge**: for each binding, only
|
|
8
|
-
* targets returned by {@link listResolvedDependencies} are considered (not a full recursive
|
|
9
|
-
* graph walk). Constant bindings are exempt.
|
|
10
|
-
*
|
|
11
|
-
* Called by {@link Container.validate} and automatically after each `load()` in non-production
|
|
12
|
-
* environments.
|
|
13
|
-
*/
|
|
14
|
-
function validateScopeRules(context) {
|
|
15
|
-
const reader = context.getMetadataReader();
|
|
16
|
-
const lookupBindings = (key) => context.lookupBindings(key);
|
|
17
|
-
for (const registryKey of context.collectAllRegistryKeys()) {
|
|
18
|
-
const bindings = lookupBindings(registryKey);
|
|
19
|
-
if (bindings === void 0 || bindings.length === 0) continue;
|
|
20
|
-
for (const consumer of bindings) {
|
|
21
|
-
const deps = listResolvedDependencies(consumer, lookupBindings, reader, [registryKeyLabel(registryKey)]);
|
|
22
|
-
for (const dep of deps) if (consumer.scope === "singleton" && dep.binding.kind !== "constant" && (dep.binding.scope === "transient" || dep.binding.scope === "scoped")) throw new ScopeViolationError({
|
|
23
|
-
consumerBindingId: consumer.id,
|
|
24
|
-
consumerKind: consumer.kind,
|
|
25
|
-
consumerScope: consumer.scope,
|
|
26
|
-
dependencyBindingId: dep.binding.id,
|
|
27
|
-
dependencyKind: dep.binding.kind,
|
|
28
|
-
dependencyScope: dep.binding.scope,
|
|
29
|
-
resolutionPath: dep.path
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { validateScopeRules };
|