Skip to content

Commit 957d9e3

Browse files
committed
refactor(di)!: replace Provider by Factory
Provider has been deprecated by inversify
1 parent e78df78 commit 957d9e3

File tree

12 files changed

+53
-36
lines changed

12 files changed

+53
-36
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## v0.28.0 (unreleased)
4+
5+
Replace `Provider` by `Factory` in Dependency Injection (`inversify`). If you're using `bindProvider`, simply replace it by `bindFactory`.
6+
7+
See all the changes here : https://github.com/c100k/libmodulor/compare/v0.27.0...master
8+
39
## v0.27.0 (2026-02-09)
410

511
**Highlights**

dist/esm/target/lib/server/AuthenticationChecker.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Provider } from 'inversify';
1+
import { type Factory } from 'inversify';
22
import type { AppManifest } from '../../../app/index.js';
33
import type { Logger, Worker } from '../../../std/index.js';
44
import { type UC, type UCAuth, type UCDef, type UCInput, type UCOPIBase, type UCPolicy } from '../../../uc/index.js';
@@ -23,8 +23,8 @@ export declare class AuthenticationChecker implements Worker<Input, Promise<Outp
2323
private jwtAuthenticationChecker;
2424
private privateApiKeyAuthenticationChecker;
2525
private logger;
26-
private ucPolicyProvider;
27-
constructor(basicAuthenticationChecker: BasicAuthenticationChecker, jwtAuthenticationChecker: JWTAuthenticationChecker, privateApiKeyAuthenticationChecker: PrivateApiKeyAuthenticationChecker, logger: Logger, ucPolicyProvider: Provider<UCPolicy>);
26+
private ucPolicyFactory;
27+
constructor(basicAuthenticationChecker: BasicAuthenticationChecker, jwtAuthenticationChecker: JWTAuthenticationChecker, privateApiKeyAuthenticationChecker: PrivateApiKeyAuthenticationChecker, logger: Logger, ucPolicyFactory: Factory<UCPolicy>);
2828
exec<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ authCookie, authorizationHeader, uc, }: Input<I, OPI0, OPI1>): Promise<Output>;
2929
}
3030
export {};

dist/esm/target/lib/server/AuthenticationChecker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ let AuthenticationChecker = class AuthenticationChecker {
2121
jwtAuthenticationChecker;
2222
privateApiKeyAuthenticationChecker;
2323
logger;
24-
ucPolicyProvider;
25-
constructor(basicAuthenticationChecker, jwtAuthenticationChecker, privateApiKeyAuthenticationChecker, logger, ucPolicyProvider) {
24+
ucPolicyFactory;
25+
constructor(basicAuthenticationChecker, jwtAuthenticationChecker, privateApiKeyAuthenticationChecker, logger, ucPolicyFactory) {
2626
this.basicAuthenticationChecker = basicAuthenticationChecker;
2727
this.jwtAuthenticationChecker = jwtAuthenticationChecker;
2828
this.privateApiKeyAuthenticationChecker = privateApiKeyAuthenticationChecker;
2929
this.logger = logger;
30-
this.ucPolicyProvider = ucPolicyProvider;
30+
this.ucPolicyFactory = ucPolicyFactory;
3131
}
3232
async exec({ authCookie, authorizationHeader, uc, }) {
3333
this.logger.trace('Checking auth', {
@@ -43,7 +43,7 @@ let AuthenticationChecker = class AuthenticationChecker {
4343
return output;
4444
}
4545
const authType = sec?.authType ?? DEFAULT_UC_SEC_AT;
46-
const policy = (await this.ucPolicyProvider(server.policy));
46+
const policy = (await this.ucPolicyFactory(server.policy));
4747
const canBeExecutedPreAuth = await policy.canBeExecutedPreAuth();
4848
if (canBeExecutedPreAuth) {
4949
const { allowed } = await policy.exec({
@@ -101,7 +101,7 @@ AuthenticationChecker = __decorate([
101101
__param(1, inject(JWTAuthenticationChecker)),
102102
__param(2, inject(PrivateApiKeyAuthenticationChecker)),
103103
__param(3, inject('Logger')),
104-
__param(4, inject('Provider<UCPolicy>')),
104+
__param(4, inject('Factory<UCPolicy>')),
105105
__metadata("design:paramtypes", [BasicAuthenticationChecker,
106106
JWTAuthenticationChecker,
107107
PrivateApiKeyAuthenticationChecker, Object, Function])

dist/esm/uc/impl/SimpleUCManager.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Provider } from 'inversify';
1+
import { type Factory } from 'inversify';
22
import type { ClockManager, CryptoManager, Logger } from '../../std/index.js';
33
import type { UCClientConfirmManager } from '../client.js';
44
import type { UCData } from '../data.js';
@@ -23,10 +23,10 @@ export declare class SimpleUCManager implements UCManager {
2323
private ucExecChecker;
2424
private ucInputFilesProcessor;
2525
private ucInputValidator;
26-
private ucInitProvider;
27-
private ucMainProvider;
26+
private ucInitFactory;
27+
private ucMainFactory;
2828
private tx?;
29-
constructor(ucClientConfirmManager: UCClientConfirmManager, clockManager: ClockManager, cryptoManager: CryptoManager, logger: Logger, ucDataStore: UCDataStore, ucExecChecker: UCExecChecker, ucInputFilesProcessor: UCInputFilesProcessor, ucInputValidator: UCInputValidator, ucInitProvider: Provider<UCInit>, ucMainProvider: Provider<UCMain>);
29+
constructor(ucClientConfirmManager: UCClientConfirmManager, clockManager: ClockManager, cryptoManager: CryptoManager, logger: Logger, ucDataStore: UCDataStore, ucExecChecker: UCExecChecker, ucInputFilesProcessor: UCInputFilesProcessor, ucInputValidator: UCInputValidator, ucInitFactory: Factory<UCInit>, ucMainFactory: Factory<UCMain>);
3030
commitTx(): Promise<void>;
3131
confirmClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<boolean>;
3232
execClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts?: UCManagerExecClientOpts<I, OPI0, OPI1>): Promise<UCOutputReader<I, OPI0, OPI1>>;

dist/esm/uc/impl/SimpleUCManager.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ let SimpleUCManager = class SimpleUCManager {
2727
ucExecChecker;
2828
ucInputFilesProcessor;
2929
ucInputValidator;
30-
ucInitProvider;
31-
ucMainProvider;
30+
ucInitFactory;
31+
ucMainFactory;
3232
// WARNING : This property makes this class "thread unsafe". Be careful how you inject it into your components.
3333
tx;
34-
constructor(ucClientConfirmManager, clockManager, cryptoManager, logger, ucDataStore, ucExecChecker, ucInputFilesProcessor, ucInputValidator, ucInitProvider, ucMainProvider) {
34+
constructor(ucClientConfirmManager, clockManager, cryptoManager, logger, ucDataStore, ucExecChecker, ucInputFilesProcessor, ucInputValidator, ucInitFactory, ucMainFactory) {
3535
this.ucClientConfirmManager = ucClientConfirmManager;
3636
this.clockManager = clockManager;
3737
this.cryptoManager = cryptoManager;
@@ -40,8 +40,8 @@ let SimpleUCManager = class SimpleUCManager {
4040
this.ucExecChecker = ucExecChecker;
4141
this.ucInputFilesProcessor = ucInputFilesProcessor;
4242
this.ucInputValidator = ucInputValidator;
43-
this.ucInitProvider = ucInitProvider;
44-
this.ucMainProvider = ucMainProvider;
43+
this.ucInitFactory = ucInitFactory;
44+
this.ucMainFactory = ucMainFactory;
4545
this.tx = undefined;
4646
}
4747
async commitTx() {
@@ -80,7 +80,7 @@ let SimpleUCManager = class SimpleUCManager {
8080
if (server === undefined) {
8181
await this.ucInputFilesProcessor.exec({ uc });
8282
}
83-
const main = (await this.ucMainProvider(client.main));
83+
const main = (await this.ucMainFactory(client.main));
8484
const streamOpts = opts?.stream;
8585
const output = await main.exec({
8686
opts: {
@@ -113,7 +113,7 @@ let SimpleUCManager = class SimpleUCManager {
113113
}
114114
this.ucInputValidator.exec({ uc });
115115
await this.ucInputFilesProcessor.exec({ uc });
116-
const main = (await this.ucMainProvider(server.main));
116+
const main = (await this.ucMainFactory(server.main));
117117
const output = main.exec({
118118
opts: {
119119
stream: opts?.stream,
@@ -132,7 +132,7 @@ let SimpleUCManager = class SimpleUCManager {
132132
return;
133133
}
134134
this.logger.info('Initializing ucd', { name: metadata.name });
135-
const init = (await this.ucInitProvider(server.init));
135+
const init = (await this.ucInitFactory(server.init));
136136
await init.exec();
137137
}
138138
async startTx() {
@@ -179,8 +179,8 @@ SimpleUCManager = __decorate([
179179
__param(5, inject(UCExecChecker)),
180180
__param(6, inject(UCInputFilesProcessor)),
181181
__param(7, inject(UCInputValidator)),
182-
__param(8, inject('Provider<UCInit>')),
183-
__param(9, inject('Provider<UCMain>')),
182+
__param(8, inject('Factory<UCInit>')),
183+
__param(9, inject('Factory<UCMain>')),
184184
__metadata("design:paramtypes", [Object, Object, Object, Object, Object, UCExecChecker,
185185
UCInputFilesProcessor,
186186
UCInputValidator, Function, Function])

dist/esm/uc/workers/UCExecChecker.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Provider } from 'inversify';
1+
import { type Factory } from 'inversify';
22
import type { ProductManifest } from '../../product/index.js';
33
import type { Configurable, SettingsManager, Worker } from '../../std/index.js';
44
import type { UCDefLifecycle } from '../def.js';
@@ -16,8 +16,8 @@ type S = Pick<UCSettings, 'uc_disabled_use_cases'>;
1616
export declare class UCExecChecker implements Configurable<S>, Worker<Input, Promise<Output>> {
1717
private productManifest;
1818
private settingsManager;
19-
private ucPolicyProvider;
20-
constructor(productManifest: ProductManifest, settingsManager: SettingsManager<S>, ucPolicyProvider: Provider<UCPolicy>);
19+
private ucPolicyFactory;
20+
constructor(productManifest: ProductManifest, settingsManager: SettingsManager<S>, ucPolicyFactory: Factory<UCPolicy>);
2121
s(): S;
2222
exec<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ lifecycle, uc }: Input<I, OPI0, OPI1>): Promise<Output>;
2323
}

dist/esm/uc/workers/UCExecChecker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import { inject, injectable } from 'inversify';
1414
let UCExecChecker = class UCExecChecker {
1515
productManifest;
1616
settingsManager;
17-
ucPolicyProvider;
18-
constructor(productManifest, settingsManager, ucPolicyProvider) {
17+
ucPolicyFactory;
18+
constructor(productManifest, settingsManager, ucPolicyFactory) {
1919
this.productManifest = productManifest;
2020
this.settingsManager = settingsManager;
21-
this.ucPolicyProvider = ucPolicyProvider;
21+
this.ucPolicyFactory = ucPolicyFactory;
2222
}
2323
s() {
2424
return {
@@ -47,7 +47,7 @@ let UCExecChecker = class UCExecChecker {
4747
const ucds = app.ucds?.exclude ?? [];
4848
output.allowed = !ucds.includes(metadata.name);
4949
if (output.allowed) {
50-
const policy = (await this.ucPolicyProvider(client.policy));
50+
const policy = (await this.ucPolicyFactory(client.policy));
5151
const { allowed } = await policy.exec({ uc });
5252
output.allowed = allowed;
5353
}
@@ -68,7 +68,7 @@ UCExecChecker = __decorate([
6868
injectable(),
6969
__param(0, inject('ProductManifest')),
7070
__param(1, inject('SettingsManager')),
71-
__param(2, inject('Provider<UCPolicy>')),
71+
__param(2, inject('Factory<UCPolicy>')),
7272
__metadata("design:paramtypes", [Object, Object, Function])
7373
], UCExecChecker);
7474
export { UCExecChecker };

dist/esm/utils/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export { SSEStreamManager } from './http/SSEStreamManager.js';
1212
export { fmtSingleDataMsg, fmtSSEError, isSSEError, parseDataLine, SSE_HEADERS, } from './http/sse.js';
1313
export { isClientError, isError, isServerError } from './http/status.js';
1414
export type { HTTPDataEnvelope, HTTPReqData } from './http/types.js';
15-
export { bindProvider } from './ioc/bindProvider.js';
15+
export { bindFactory } from './ioc/bindFactory.js';
1616
export { CONTAINER_OPTS } from './ioc/container.js';
1717
export type { Class } from './ioc/types.js';
1818
export { fmt as fmtNumber } from './numbers/fmt.js';

dist/esm/utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export { fromQueryParams, toQueryParams } from './http/query-params.js';
77
export { SSEStreamManager } from './http/SSEStreamManager.js';
88
export { fmtSingleDataMsg, fmtSSEError, isSSEError, parseDataLine, SSE_HEADERS, } from './http/sse.js';
99
export { isClientError, isError, isServerError } from './http/status.js';
10-
export { bindProvider } from './ioc/bindProvider.js';
10+
export { bindFactory } from './ioc/bindFactory.js';
1111
export { CONTAINER_OPTS } from './ioc/container.js';
1212
export { fmt as fmtNumber } from './numbers/fmt.js';
1313
export { baseFromSquareUnit, isSquareUnit, } from './numbers/units.js';

dist/esm/utils/ioc/bindCommon.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { InMemoryUCDataStore } from '../../uc/impl/InMemoryUCDataStore.js';
1616
import { SimpleUCManager } from '../../uc/impl/SimpleUCManager.js';
1717
import { StaticUCClientConfirmManager } from '../../uc/impl/StaticUCClientConfirmManager.js';
1818
import { UC_DEFAULT_SETTINGS, } from '../../uc/index.js';
19-
import { bindProvider } from './bindProvider.js';
19+
import { bindFactory } from './bindFactory.js';
2020
export function bindCommon(container) {
2121
// settings
2222
container.bind('Settings').toConstantValue({
@@ -55,9 +55,9 @@ export function bindCommon(container) {
5555
.to(SettingsServerClientManager);
5656
container.bind('XMLManager').to(NoopXMLManager);
5757
// uc
58-
bindProvider(container, 'UCInit');
59-
bindProvider(container, 'UCMain');
60-
bindProvider(container, 'UCPolicy');
58+
bindFactory(container, 'UCInit');
59+
bindFactory(container, 'UCMain');
60+
bindFactory(container, 'UCPolicy');
6161
container
6262
.bind('UCClientConfirmManager')
6363
.to(StaticUCClientConfirmManager);

0 commit comments

Comments
 (0)