ts-ioc-container 72.3.1 → 73.0.0
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/AGENTS.md +1 -1
- package/README.md +77 -4
- package/cjm/index.js +5 -4
- package/cjm/injector/MetadataInjector.js +3 -1
- package/cjm/utils/array.js +3 -3
- package/esm/index.js +2 -2
- package/esm/injector/MetadataInjector.js +1 -0
- package/esm/utils/array.js +1 -1
- package/lib/errors/ArgumentNotFoundError.ts +1 -1
- package/lib/index.ts +2 -2
- package/lib/injector/MetadataInjector.ts +17 -0
- package/lib/utils/array.ts +1 -1
- package/package.json +2 -2
- package/typings/errors/ArgumentNotFoundError.d.ts +1 -1
- package/typings/errors/ArgumentNotFoundError.d.ts.map +1 -1
- package/typings/index.d.ts +2 -2
- package/typings/index.d.ts.map +1 -1
- package/typings/injector/MetadataInjector.d.ts +13 -0
- package/typings/injector/MetadataInjector.d.ts.map +1 -1
- package/typings/utils/array.d.ts +1 -1
- package/typings/utils/array.d.ts.map +1 -1
package/AGENTS.md
CHANGED
|
@@ -174,6 +174,6 @@ All errors extend `ContainerError` and carry a stable `code`:
|
|
|
174
174
|
| `IOC_EVENT_DISPOSED` | `TypedEventDisposedError` | Subscribing to an event of a disposed scope |
|
|
175
175
|
| `IOC_SINGLETON_APPLIED_TWICE` | `CannotApplySingletonTwiceError` | `singleton()` appears twice in one registration |
|
|
176
176
|
| `IOC_UNSUPPORTED_TOKEN_TYPE` | `UnsupportedTokenTypeError` | `toToken(...)` got a value that is not a key, class or token |
|
|
177
|
-
| `IOC_ARGUMENT_NOT_FOUND` | `ArgumentNotFoundError` | `
|
|
177
|
+
| `IOC_ARGUMENT_NOT_FOUND` | `ArgumentNotFoundError` | `findArgOrFail` / `argsFn` predicate matched nothing |
|
|
178
178
|
| `IOC_CONTAINER_NOT_FOUND` | `ContainerNotFoundError` | No container is associated with the target |
|
|
179
179
|
| `IOC_METHOD_NOT_IMPLEMENTED` | `MethodNotImplementedError` | Called a method the object does not support (e.g. on `EmptyContainer`) |
|
package/README.md
CHANGED
|
@@ -1167,6 +1167,7 @@ returns is injected. There is no other form, only functions which build one:
|
|
|
1167
1167
|
[runtime args flow through tokens](#runtime-args-flow-through-tokens)):
|
|
1168
1168
|
`@inject(by(LoggerToken))`, `@inject(by('Logger'))`, `@inject(by(Logger))`.
|
|
1169
1169
|
- `arg(index)` / `args` / `argsFn(predicate)` — pick from the runtime args.
|
|
1170
|
+
- `byArgs(pick)` — resolve the token `pick` finds among the runtime args.
|
|
1170
1171
|
- `pipe(fn, ...mappers)` — map what another `InjectFn` returns.
|
|
1171
1172
|
- Your own: `@inject(({ scope }) => scope)` injects the current scope,
|
|
1172
1173
|
`@inject(({ scope }) => Token.resolve(scope))` resolves a token *without*
|
|
@@ -1820,6 +1821,78 @@ Args are passed to the constructor **as-is** — the library never resolves an `
|
|
|
1820
1821
|
|
|
1821
1822
|
`argToToken(value)` is the helper for a call site that wants "resolve tokens, pass literals through": it returns an `InjectionToken` as-is and wraps anything else in a `ConstantToken`, so `@inject(({ scope, args = [] }) => argToToken(args[0]).resolve(scope))` accepts either.
|
|
1822
1823
|
|
|
1824
|
+
`byArgs(pick)` is the `InjectFn` for a class whose dependency is **chosen by the caller**: the caller passes the dependency's token as a runtime arg, `pick` finds it in the args list, and `byArgs` resolves it in the current scope (without args). It pairs with `findArgOrFail`, which throws `ArgumentNotFoundError` when no arg matches — and the same picker keys the `singleton()`, so there is one instance per chosen dependency:
|
|
1825
|
+
|
|
1826
|
+
```typescript
|
|
1827
|
+
import {
|
|
1828
|
+
ArgumentNotFoundError,
|
|
1829
|
+
byArgs,
|
|
1830
|
+
Container,
|
|
1831
|
+
findArgOrFail,
|
|
1832
|
+
inject,
|
|
1833
|
+
type InjectionToken,
|
|
1834
|
+
register,
|
|
1835
|
+
Registration as R,
|
|
1836
|
+
singleton,
|
|
1837
|
+
SingleToken,
|
|
1838
|
+
} from 'ts-ioc-container';
|
|
1839
|
+
|
|
1840
|
+
interface IRepository {
|
|
1841
|
+
name: string;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
// a repository token carries its own marker, so it can be found among the runtime args
|
|
1845
|
+
class RepositoryToken<T extends IRepository> extends SingleToken<T> {}
|
|
1846
|
+
const isRepositoryToken = (value: unknown): value is InjectionToken<IRepository> => value instanceof RepositoryToken;
|
|
1847
|
+
const repositoryTokenOf = findArgOrFail<InjectionToken<IRepository>>(isRepositoryToken);
|
|
1848
|
+
|
|
1849
|
+
const IUserRepositoryToken = new RepositoryToken<IRepository>('IUserRepository');
|
|
1850
|
+
const IOrderRepositoryToken = new RepositoryToken<IRepository>('IOrderRepository');
|
|
1851
|
+
const IEntityManagerToken = new SingleToken<EntityManager>('IEntityManager');
|
|
1852
|
+
|
|
1853
|
+
@register(IUserRepositoryToken)
|
|
1854
|
+
class UserRepository implements IRepository {
|
|
1855
|
+
name = 'users';
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
@register(IOrderRepositoryToken)
|
|
1859
|
+
class OrderRepository implements IRepository {
|
|
1860
|
+
name = 'orders';
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
// the caller chooses the repository; one entity manager per repository token
|
|
1864
|
+
@register(IEntityManagerToken, singleton(repositoryTokenOf))
|
|
1865
|
+
class EntityManager {
|
|
1866
|
+
constructor(@inject(byArgs(repositoryTokenOf)) readonly repository: IRepository) {}
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
describe('byArgs', function () {
|
|
1870
|
+
const createContainer = () =>
|
|
1871
|
+
new Container()
|
|
1872
|
+
.addRegistration(R.fromClass(UserRepository))
|
|
1873
|
+
.addRegistration(R.fromClass(OrderRepository))
|
|
1874
|
+
.addRegistration(R.fromClass(EntityManager));
|
|
1875
|
+
|
|
1876
|
+
it('should resolve the token the caller passes as a runtime arg', function () {
|
|
1877
|
+
const container = createContainer();
|
|
1878
|
+
|
|
1879
|
+
const users = IEntityManagerToken.resolve(container, { args: [IUserRepositoryToken] });
|
|
1880
|
+
const orders = IEntityManagerToken.resolve(container, { args: [IOrderRepositoryToken] });
|
|
1881
|
+
|
|
1882
|
+
expect(users.repository.name).toBe('users');
|
|
1883
|
+
expect(orders.repository.name).toBe('orders');
|
|
1884
|
+
expect(IEntityManagerToken.resolve(container, { args: [IUserRepositoryToken] })).toBe(users);
|
|
1885
|
+
});
|
|
1886
|
+
|
|
1887
|
+
it('should throw when no runtime arg matches', function () {
|
|
1888
|
+
const container = createContainer();
|
|
1889
|
+
|
|
1890
|
+
expect(() => IEntityManagerToken.resolve(container, { args: ['not a token'] })).toThrow(ArgumentNotFoundError);
|
|
1891
|
+
});
|
|
1892
|
+
});
|
|
1893
|
+
|
|
1894
|
+
```
|
|
1895
|
+
|
|
1823
1896
|
### Positional arg injection with `arg(index)`, `args`, and `argsFn`
|
|
1824
1897
|
|
|
1825
1898
|
Constructor parameters that should pick up positional args from `ProviderOptions` must be annotated with `@inject(arg(index))`. Parameters without `@inject` resolve to `undefined`.
|
|
@@ -1830,7 +1903,7 @@ Constructor parameters that should pick up positional args from `ProviderOptions
|
|
|
1830
1903
|
|
|
1831
1904
|
`argsFn(predicate)` is the general form: it iterates the runtime `args` array and returns the **first argument matching** `predicate(value, index)` — think `args.find(predicate)`. `arg(index)` is just a shortcut for matching by position: `arg(0)` is `argsFn((value, index) => index === 0)`. `args` is `({ args }) => args`, i.e. it returns the runtime args array as-is. Every `InjectFn` receives one `ProviderOptions` object — `{ scope, args, lazy }` — where `args` is the runtime args array.
|
|
1832
1905
|
|
|
1833
|
-
`
|
|
1906
|
+
`findArgOrFail(predicate)` is the strict counterpart for `singleton()` cache keys — `singleton(findArgOrFail(isUserId))` keys a per-argument singleton, for example. It receives the full runtime `args` array, returns the first argument matching `predicate(value)`, and throws `ArgumentNotFoundError` when none does, instead of silently handing out `undefined`.
|
|
1834
1907
|
|
|
1835
1908
|
### Runtime args flow through tokens
|
|
1836
1909
|
|
|
@@ -1843,7 +1916,7 @@ import {
|
|
|
1843
1916
|
arg,
|
|
1844
1917
|
bindTo,
|
|
1845
1918
|
Container,
|
|
1846
|
-
|
|
1919
|
+
findArgOrFail,
|
|
1847
1920
|
inject,
|
|
1848
1921
|
register,
|
|
1849
1922
|
Registration as R,
|
|
@@ -1860,7 +1933,7 @@ const IUserRepositoryKey = new SingleToken<IUserRepository>('IUserRepository');
|
|
|
1860
1933
|
const isUserId = (value: unknown): value is string => typeof value === 'string';
|
|
1861
1934
|
|
|
1862
1935
|
// one repository per user id - the id is the singleton cache key
|
|
1863
|
-
@register(bindTo(IUserRepositoryKey), singleton(
|
|
1936
|
+
@register(bindTo(IUserRepositoryKey), singleton(findArgOrFail<string>(isUserId)))
|
|
1864
1937
|
class UserRepository implements IUserRepository {
|
|
1865
1938
|
constructor(@inject(arg(0)) public userId: string) {}
|
|
1866
1939
|
}
|
|
@@ -1892,7 +1965,7 @@ describe('Token Runtime Arguments', function () {
|
|
|
1892
1965
|
```
|
|
1893
1966
|
|
|
1894
1967
|
> [!IMPORTANT]
|
|
1895
|
-
> Runtime args come first. A dependency that reads `@inject(arg(0))` sees the *caller's* first runtime arg whenever the caller was resolved with args, even if its token was specialized with `token.args(...)`. Pick args by shape (`argsFn(predicate)`, `
|
|
1968
|
+
> Runtime args come first. A dependency that reads `@inject(arg(0))` sees the *caller's* first runtime arg whenever the caller was resolved with args, even if its token was specialized with `token.args(...)`. Pick args by shape (`argsFn(predicate)`, `findArgOrFail(predicate)`) rather than by position when a class can be resolved with runtime args and its dependencies are specialized with `token.args(...)`.
|
|
1896
1969
|
|
|
1897
1970
|
### Immutable token chaining
|
|
1898
1971
|
|
package/cjm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.isSerializable = exports.Is = exports.unwrapProxy = exports.ProxyRegistry = exports.
|
|
3
|
+
exports.HookContext = exports.toHookFn = exports.hasHooks = exports.hook = exports.getHooks = exports.ArgumentNotFoundError = exports.TypedEventDisposedError = exports.UnsupportedTokenTypeError = exports.CannonSingletonApplyTwiceError = exports.CannotApplySingletonTwiceError = exports.ProviderDisposedError = exports.ContainerDisposedError = exports.MethodNotImplementedError = exports.DependencyMissingKeyError = exports.ContainerNotFoundError = exports.DependencyNotFoundError = exports.ContainerError = exports.Registration = exports.onResolve = exports.appendArgsFn = exports.appendArgs = exports.decorate = exports.singleton = exports.autoResolve = exports.lazy = exports.scopeAccess = exports.scope = exports.bindTo = exports.register = exports.toRegistrationFn = exports.toProviderFn = exports.toBindToken = exports.registerPipe = exports.isProviderPipe = exports.Provider = exports.ProxyInjector = exports.SimpleInjector = exports.resolveArgs = exports.byArgs = exports.by = exports.argsFn = exports.args = exports.arg = exports.inject = exports.MetadataInjector = exports.Injector = exports.EmptyContainer = exports.AutoResolveModule = exports.Container = exports.isDependencyKey = void 0;
|
|
4
|
+
exports.handleError = exports.createComposeMethodDecorator = exports.getMethodTags = exports.addMethodTag = exports.getMethodLabels = exports.addMethodLabel = exports.getMethodMeta = exports.addMethodMeta = exports.createComposeParameterDecorator = exports.getParamTags = exports.addParamTag = exports.getParamLabels = exports.addParamLabel = exports.getParamMeta = exports.addParamMeta = exports.createComposeClassDecorator = exports.getClassTags = exports.addClassTag = exports.getClassLabels = exports.addClassLabel = exports.getClassMeta = exports.addClassMeta = exports.resolveConstructor = exports.IFeatureContextToken = exports.IFeatureFlagsToken = exports.ToggleFeatureToken = exports.MultiVariantFeatureToken = exports.GroupInstanceToken = exports.ConstantToken = exports.FunctionToken = exports.SingleToken = exports.BindableToken = exports.ClassToken = exports.toSingleAlias = exports.SingleAliasToken = exports.toGroupAlias = exports.GroupAliasToken = exports.argToToken = exports.toToken = exports.forwardArgs = exports.isInjectionToken = exports.InjectionToken = exports.toTask = exports.HookCollector = exports.oncePerInstance = exports.parallel = exports.sequential = exports.injectProp = exports.createHookExecutionContext = exports.createHookContextFactory = void 0;
|
|
5
|
+
exports.isSerializable = exports.Is = exports.unwrapProxy = exports.ProxyRegistry = exports.findArgOrFail = exports.pipe = exports.select = exports.TypedEvent = exports.getConstructorChain = exports.memoize = exports.once = exports.shallowCache = exports.debounce = exports.throttle = exports.runAtOnce = exports.runInOrder = exports.handleAsyncError = void 0;
|
|
6
6
|
var IContainer_1 = require("./container/IContainer");
|
|
7
7
|
Object.defineProperty(exports, "isDependencyKey", { enumerable: true, get: function () { return IContainer_1.isDependencyKey; } });
|
|
8
8
|
var Container_1 = require("./container/Container");
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "arg", { enumerable: true, get: function () { ret
|
|
|
20
20
|
Object.defineProperty(exports, "args", { enumerable: true, get: function () { return MetadataInjector_1.args; } });
|
|
21
21
|
Object.defineProperty(exports, "argsFn", { enumerable: true, get: function () { return MetadataInjector_1.argsFn; } });
|
|
22
22
|
Object.defineProperty(exports, "by", { enumerable: true, get: function () { return MetadataInjector_1.by; } });
|
|
23
|
+
Object.defineProperty(exports, "byArgs", { enumerable: true, get: function () { return MetadataInjector_1.byArgs; } });
|
|
23
24
|
Object.defineProperty(exports, "resolveArgs", { enumerable: true, get: function () { return MetadataInjector_1.resolveArgs; } });
|
|
24
25
|
var SimpleInjector_1 = require("./injector/SimpleInjector");
|
|
25
26
|
Object.defineProperty(exports, "SimpleInjector", { enumerable: true, get: function () { return SimpleInjector_1.SimpleInjector; } });
|
|
@@ -171,7 +172,7 @@ Object.defineProperty(exports, "select", { enumerable: true, get: function () {
|
|
|
171
172
|
var fp_1 = require("./utils/fp");
|
|
172
173
|
Object.defineProperty(exports, "pipe", { enumerable: true, get: function () { return fp_1.pipe; } });
|
|
173
174
|
var array_1 = require("./utils/array");
|
|
174
|
-
Object.defineProperty(exports, "
|
|
175
|
+
Object.defineProperty(exports, "findArgOrFail", { enumerable: true, get: function () { return array_1.findArgOrFail; } });
|
|
175
176
|
var ProxyRegistry_1 = require("./utils/ProxyRegistry");
|
|
176
177
|
Object.defineProperty(exports, "ProxyRegistry", { enumerable: true, get: function () { return ProxyRegistry_1.ProxyRegistry; } });
|
|
177
178
|
Object.defineProperty(exports, "unwrapProxy", { enumerable: true, get: function () { return ProxyRegistry_1.unwrapProxy; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveArgs = exports.args = exports.arg = exports.argsFn = exports.by = exports.MetadataInjector = void 0;
|
|
3
|
+
exports.resolveArgs = exports.args = exports.byArgs = exports.arg = exports.argsFn = exports.by = exports.MetadataInjector = void 0;
|
|
4
4
|
exports.inject = inject;
|
|
5
5
|
const IInjector_1 = require("./IInjector");
|
|
6
6
|
const target_1 = require("../metadata/target");
|
|
@@ -28,6 +28,8 @@ const argsFn = (predicate) => ({ args = [] }) => args.find((value, index) => pre
|
|
|
28
28
|
exports.argsFn = argsFn;
|
|
29
29
|
const arg = (index) => (0, exports.argsFn)((value, i) => i === index);
|
|
30
30
|
exports.arg = arg;
|
|
31
|
+
const byArgs = (pick) => ({ scope, args = [] }) => pick(args).resolve(scope);
|
|
32
|
+
exports.byArgs = byArgs;
|
|
31
33
|
const args = ({ args = [] }) => args;
|
|
32
34
|
exports.args = args;
|
|
33
35
|
const resolveArgs = (target, methodName) => {
|
package/cjm/utils/array.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.findArgOrFail = exports.Filter = void 0;
|
|
4
4
|
const ArgumentNotFoundError_1 = require("../errors/ArgumentNotFoundError");
|
|
5
5
|
exports.Filter = {
|
|
6
6
|
exclude: (arr) => {
|
|
@@ -8,11 +8,11 @@ exports.Filter = {
|
|
|
8
8
|
return (v) => !excludeSet.has(v);
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
|
-
const
|
|
11
|
+
const findArgOrFail = (predicate) => (args = []) => {
|
|
12
12
|
const index = args.findIndex((arg) => predicate(arg));
|
|
13
13
|
if (index === -1) {
|
|
14
14
|
throw new ArgumentNotFoundError_1.ArgumentNotFoundError(`No argument matches the predicate (received ${args.length} args).`);
|
|
15
15
|
}
|
|
16
16
|
return args[index];
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
18
|
+
exports.findArgOrFail = findArgOrFail;
|
package/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { Container } from './container/Container.js';
|
|
|
3
3
|
export { AutoResolveModule } from './container/AutoResolveModule.js';
|
|
4
4
|
export { EmptyContainer } from './container/EmptyContainer.js';
|
|
5
5
|
export { Injector, } from './injector/IInjector.js';
|
|
6
|
-
export { MetadataInjector, inject, arg, args, argsFn, by, resolveArgs } from './injector/MetadataInjector.js';
|
|
6
|
+
export { MetadataInjector, inject, arg, args, argsFn, by, byArgs, resolveArgs } from './injector/MetadataInjector.js';
|
|
7
7
|
export { SimpleInjector } from './injector/SimpleInjector.js';
|
|
8
8
|
export { ProxyInjector } from './injector/ProxyInjector.js';
|
|
9
9
|
export { Provider } from './provider/Provider.js';
|
|
@@ -54,6 +54,6 @@ export { getConstructorChain } from './utils/getConstructorChain.js';
|
|
|
54
54
|
export { TypedEvent } from './utils/TypedEvent.js';
|
|
55
55
|
export { select } from './select.js';
|
|
56
56
|
export { pipe } from './utils/fp.js';
|
|
57
|
-
export {
|
|
57
|
+
export { findArgOrFail } from './utils/array.js';
|
|
58
58
|
export { ProxyRegistry, unwrapProxy } from './utils/ProxyRegistry.js';
|
|
59
59
|
export { Is, isSerializable } from './utils/basic.js';
|
|
@@ -20,6 +20,7 @@ export const by = (target) => {
|
|
|
20
20
|
};
|
|
21
21
|
export const argsFn = (predicate) => ({ args = [] }) => args.find((value, index) => predicate(value, index));
|
|
22
22
|
export const arg = (index) => argsFn((value, i) => i === index);
|
|
23
|
+
export const byArgs = (pick) => ({ scope, args = [] }) => pick(args).resolve(scope);
|
|
23
24
|
export const args = ({ args = [] }) => args;
|
|
24
25
|
export const resolveArgs = (target, methodName) => {
|
|
25
26
|
const fns = getParamMeta(hookMetaKey(methodName), target);
|
package/esm/utils/array.js
CHANGED
|
@@ -5,7 +5,7 @@ export const Filter = {
|
|
|
5
5
|
return (v) => !excludeSet.has(v);
|
|
6
6
|
},
|
|
7
7
|
};
|
|
8
|
-
export const
|
|
8
|
+
export const findArgOrFail = (predicate) => (args = []) => {
|
|
9
9
|
const index = args.findIndex((arg) => predicate(arg));
|
|
10
10
|
if (index === -1) {
|
|
11
11
|
throw new ArgumentNotFoundError(`No argument matches the predicate (received ${args.length} args).`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContainerError } from './ContainerError';
|
|
2
2
|
|
|
3
|
-
/** Thrown by `
|
|
3
|
+
/** Thrown by `findArgOrFail` when no runtime arg matches the predicate. Code `IOC_ARGUMENT_NOT_FOUND`. */
|
|
4
4
|
export class ArgumentNotFoundError extends ContainerError {
|
|
5
5
|
name = 'ArgumentNotFoundError';
|
|
6
6
|
readonly code = 'IOC_ARGUMENT_NOT_FOUND';
|
package/lib/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ export {
|
|
|
28
28
|
type InjectorHook,
|
|
29
29
|
Injector,
|
|
30
30
|
} from './injector/IInjector';
|
|
31
|
-
export { MetadataInjector, inject, arg, args, argsFn, by, resolveArgs } from './injector/MetadataInjector';
|
|
31
|
+
export { MetadataInjector, inject, arg, args, argsFn, by, byArgs, resolveArgs } from './injector/MetadataInjector';
|
|
32
32
|
export { SimpleInjector } from './injector/SimpleInjector';
|
|
33
33
|
export { ProxyInjector } from './injector/ProxyInjector';
|
|
34
34
|
|
|
@@ -192,6 +192,6 @@ export { type ExecutionContext } from './ExecutionContext';
|
|
|
192
192
|
// Utils
|
|
193
193
|
export { select } from './select';
|
|
194
194
|
export { pipe, type MapFn } from './utils/fp';
|
|
195
|
-
export {
|
|
195
|
+
export { findArgOrFail, type Predicate } from './utils/array';
|
|
196
196
|
export { ProxyRegistry, unwrapProxy, type IProxyRegistry } from './utils/ProxyRegistry';
|
|
197
197
|
export { type Branded, type constructor, type Instance, type Serializable, Is, isSerializable } from './utils/basic';
|
|
@@ -84,6 +84,23 @@ export const argsFn =
|
|
|
84
84
|
*/
|
|
85
85
|
export const arg = <T = unknown>(index: number): InjectFn<T> => argsFn<T>((value, i) => i === index);
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Resolves, in the current scope, the token `pick` finds among the runtime args -
|
|
89
|
+
* for a class whose dependency is chosen by the caller passing its token as an arg.
|
|
90
|
+
* The token is resolved without args. Pairs with {@link findArgOrFail}.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* constructor(@inject(byArgs(findArgOrFail(isRepositoryToken))) readonly repository: IRepository) {}
|
|
94
|
+
* // IEntityManagerToken.resolve(scope, { args: [IUserRepositoryToken] })
|
|
95
|
+
*
|
|
96
|
+
* @throws {ArgumentNotFoundError} when `pick` is `findArgOrFail(...)` and no arg matches.
|
|
97
|
+
* @throws {DependencyNotFoundError} when the picked token is not registered in the scope chain.
|
|
98
|
+
*/
|
|
99
|
+
export const byArgs =
|
|
100
|
+
<T>(pick: (args: unknown[]) => InjectionToken<T>): InjectFn<T> =>
|
|
101
|
+
({ scope, args = [] }) =>
|
|
102
|
+
pick(args).resolve(scope);
|
|
103
|
+
|
|
87
104
|
/** Injects the whole runtime args array. */
|
|
88
105
|
export const args: InjectFn<unknown[]> = ({ args = [] }) => args;
|
|
89
106
|
|
package/lib/utils/array.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const Filter = {
|
|
|
15
15
|
*
|
|
16
16
|
* @throws {ArgumentNotFoundError} when no argument matches `predicate`
|
|
17
17
|
*/
|
|
18
|
-
export const
|
|
18
|
+
export const findArgOrFail =
|
|
19
19
|
<T>(predicate: Predicate<T>) =>
|
|
20
20
|
(args: unknown[] = []): T => {
|
|
21
21
|
const index = args.findIndex((arg) => predicate(arg as T));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "73.0.0",
|
|
4
4
|
"description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tsyringe": "^4.10.0",
|
|
81
81
|
"typescript": "5.8.3",
|
|
82
82
|
"unplugin-swc": "^1.6.0",
|
|
83
|
-
"vite": "^
|
|
83
|
+
"vite": "^8.3.0",
|
|
84
84
|
"vitest": "^4.1.11"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContainerError } from './ContainerError.js';
|
|
2
|
-
/** Thrown by `
|
|
2
|
+
/** Thrown by `findArgOrFail` when no runtime arg matches the predicate. Code `IOC_ARGUMENT_NOT_FOUND`. */
|
|
3
3
|
export declare class ArgumentNotFoundError extends ContainerError {
|
|
4
4
|
name: string;
|
|
5
5
|
readonly code = "IOC_ARGUMENT_NOT_FOUND";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgumentNotFoundError.d.ts","sourceRoot":"","sources":["../../lib/errors/ArgumentNotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,
|
|
1
|
+
{"version":3,"file":"ArgumentNotFoundError.d.ts","sourceRoot":"","sources":["../../lib/errors/ArgumentNotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,0GAA0G;AAC1G,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,IAAI,SAA2B;IAC/B,QAAQ,CAAC,IAAI,4BAA4B;gBAE7B,OAAO,SAAuB;CAK3C"}
|
package/typings/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { Container } from './container/Container.js';
|
|
|
3
3
|
export { AutoResolveModule } from './container/AutoResolveModule.js';
|
|
4
4
|
export { EmptyContainer } from './container/EmptyContainer.js';
|
|
5
5
|
export { type IInjector, type InjectOptions, type WithScope, type WithArgs, type IInjectFnResolver, type IInjectorModule, type InjectorHook, Injector, } from './injector/IInjector.js';
|
|
6
|
-
export { MetadataInjector, inject, arg, args, argsFn, by, resolveArgs } from './injector/MetadataInjector.js';
|
|
6
|
+
export { MetadataInjector, inject, arg, args, argsFn, by, byArgs, resolveArgs } from './injector/MetadataInjector.js';
|
|
7
7
|
export { SimpleInjector } from './injector/SimpleInjector.js';
|
|
8
8
|
export { ProxyInjector } from './injector/ProxyInjector.js';
|
|
9
9
|
export { type ResolveDependency, type IProvider, type DecorateFn, type ArgsFn, type ProviderOptions, type ResolveOptions, type GetCacheKey, type ScopeAccessOptions, type ScopeAccessRule, type ProviderHook, } from './provider/IProvider.js';
|
|
@@ -56,7 +56,7 @@ export { TypedEvent, type ITypedEvent, type TypedEventListener, type Unsubscribe
|
|
|
56
56
|
export { type ExecutionContext } from './ExecutionContext.js';
|
|
57
57
|
export { select } from './select.js';
|
|
58
58
|
export { pipe, type MapFn } from './utils/fp.js';
|
|
59
|
-
export {
|
|
59
|
+
export { findArgOrFail, type Predicate } from './utils/array.js';
|
|
60
60
|
export { ProxyRegistry, unwrapProxy, type IProxyRegistry } from './utils/ProxyRegistry.js';
|
|
61
61
|
export { type Branded, type constructor, type Instance, type Serializable, Is, isSerializable } from './utils/basic.js';
|
|
62
62
|
//# sourceMappingURL=index.d.ts.map
|
package/typings/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,K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,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7G,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -60,6 +60,19 @@ export declare const argsFn: <T = unknown>(predicate: (value: unknown, index: nu
|
|
|
60
60
|
* // Token.args('https://api.example.com').resolve(scope)
|
|
61
61
|
*/
|
|
62
62
|
export declare const arg: <T = unknown>(index: number) => InjectFn<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves, in the current scope, the token `pick` finds among the runtime args -
|
|
65
|
+
* for a class whose dependency is chosen by the caller passing its token as an arg.
|
|
66
|
+
* The token is resolved without args. Pairs with {@link findArgOrFail}.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* constructor(@inject(byArgs(findArgOrFail(isRepositoryToken))) readonly repository: IRepository) {}
|
|
70
|
+
* // IEntityManagerToken.resolve(scope, { args: [IUserRepositoryToken] })
|
|
71
|
+
*
|
|
72
|
+
* @throws {ArgumentNotFoundError} when `pick` is `findArgOrFail(...)` and no arg matches.
|
|
73
|
+
* @throws {DependencyNotFoundError} when the picked token is not registered in the scope chain.
|
|
74
|
+
*/
|
|
75
|
+
export declare const byArgs: <T>(pick: (args: unknown[]) => InjectionToken<T>) => InjectFn<T>;
|
|
63
76
|
/** Injects the whole runtime args array. */
|
|
64
77
|
export declare const args: InjectFn<unknown[]>;
|
|
65
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataInjector.d.ts","sourceRoot":"","sources":["../../lib/injector/MetadataInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,QAAS,YAAW,SAAS;IACjE,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAS,EAAE,EAAE,aAAa,GAAG,CAAC;CAIlG;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,kBAAkB,CA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{
|
|
|
8
8
|
*
|
|
9
9
|
* @throws {ArgumentNotFoundError} when no argument matches `predicate`
|
|
10
10
|
*/
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const findArgOrFail: <T>(predicate: Predicate<T>) => (args?: unknown[]) => T;
|
|
12
12
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../lib/utils/array.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAEjD,eAAO,MAAM,MAAM;cACP,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAEpB,GAAG,CAAC;CAEf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../lib/utils/array.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAEjD,eAAO,MAAM,MAAM;cACP,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAEpB,GAAG,CAAC;CAEf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACvB,CAAC,EAAE,WAAW,SAAS,CAAC,CAAC,CAAC,MAC1B,OAAM,OAAO,EAAO,KAAG,CAQvB,CAAC"}
|