@tstdl/base 0.87.3 → 0.87.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/authentication/client/module.js +2 -3
- package/browser/document-controller.d.ts +2 -0
- package/browser/document-controller.js +3 -0
- package/core.js +3 -2
- package/http/client/http-client.d.ts +3 -4
- package/http/client/http-client.js +8 -22
- package/http/client/module.d.ts +2 -2
- package/http/client/module.js +3 -2
- package/http/client/tokens.d.ts +1 -0
- package/http/client/tokens.js +5 -1
- package/injector/inject.d.ts +23 -1
- package/injector/inject.js +12 -0
- package/injector/injector.js +1 -1
- package/injector/provider.d.ts +14 -6
- package/injector/token.d.ts +1 -1
- package/logger/console/logger.js +3 -2
- package/logger/index.d.ts +1 -0
- package/logger/index.js +1 -0
- package/logger/tokens.d.ts +2 -0
- package/logger/tokens.js +25 -0
- package/package.json +3 -3
|
@@ -36,12 +36,11 @@ function configureAuthenticationClient(config, injector = (0, import_inject.getC
|
|
|
36
36
|
(injector ?? import_injector.Injector).register(import_tokens2.INITIAL_AUTHENTICATION_DATA, { useValue: config.initialAuthenticationData });
|
|
37
37
|
}
|
|
38
38
|
if ((0, import_type_guards.isDefined)(config.registerMiddleware)) {
|
|
39
|
-
(
|
|
40
|
-
injector.register(import_tokens.HTTP_CLIENT_MIDDLEWARE, {
|
|
39
|
+
(injector ?? import_injector.Injector).register(import_tokens.HTTP_CLIENT_MIDDLEWARE, {
|
|
41
40
|
useFactory(_, context) {
|
|
42
41
|
const authenticationService = context.resolve(import_authentication_service.AuthenticationService);
|
|
43
42
|
return (0, import_http_client_middleware.waitForAuthenticationCredentialsMiddleware)(authenticationService);
|
|
44
43
|
}
|
|
45
|
-
});
|
|
44
|
+
}, { multi: true });
|
|
46
45
|
}
|
|
47
46
|
}
|
|
@@ -16,6 +16,8 @@ export declare class DocumentController<T extends Page | Frame = Page | Frame> e
|
|
|
16
16
|
readonly context: BrowserContextController;
|
|
17
17
|
readonly options: DocumentControllerOptions;
|
|
18
18
|
constructor(document: T, context: BrowserContextController, options: DocumentControllerOptions);
|
|
19
|
+
evaluate<R, A>(fn: string | ((argument: A) => R | Promise<R>), argument: A): Promise<R>;
|
|
20
|
+
evaluate<R, A>(fn: string | ((argument?: A) => R | Promise<R>), argument?: A): Promise<R>;
|
|
19
21
|
frames(): FrameController[];
|
|
20
22
|
/**
|
|
21
23
|
* Get a controller for the frame.
|
|
@@ -42,6 +42,9 @@ class DocumentController extends import_locator_controller.LocatorController {
|
|
|
42
42
|
this.context = context;
|
|
43
43
|
this.options = options;
|
|
44
44
|
}
|
|
45
|
+
async evaluate(fn, argument) {
|
|
46
|
+
return this.document.evaluate(fn, argument);
|
|
47
|
+
}
|
|
45
48
|
frames() {
|
|
46
49
|
const frames = (0, import_utils.isPage)(this.document) ? this.document.frames() : this.document.childFrames();
|
|
47
50
|
return frames.map((page) => this.getControllerByFrame(page));
|
package/core.js
CHANGED
|
@@ -31,6 +31,7 @@ var import_injector = require("./injector/injector.js");
|
|
|
31
31
|
var import_token = require("./injector/token.js");
|
|
32
32
|
var import_logger = require("./logger/console/logger.js");
|
|
33
33
|
var import_logger2 = require("./logger/index.js");
|
|
34
|
+
var import_tokens = require("./logger/tokens.js");
|
|
34
35
|
var import_process_shutdown = require("./process-shutdown.js");
|
|
35
36
|
var import_timing = require("./utils/timing.js");
|
|
36
37
|
var import_type_guards = require("./utils/type-guards.js");
|
|
@@ -80,11 +81,11 @@ function configureTstdl(config = {}) {
|
|
|
80
81
|
(0, import_process_shutdown.setProcessShutdownLogger)(logger);
|
|
81
82
|
(0, import_process_shutdown.initializeSignals)();
|
|
82
83
|
import_injector.Injector.register(import_logger2.Logger, { useToken: config.logger ?? import_logger.ConsoleLogger });
|
|
83
|
-
import_injector.Injector.
|
|
84
|
+
import_injector.Injector.register(import_tokens.LOG_LEVEL, { useFactory: (level) => (0, import_type_guards.assertDefinedPass)(level, "LogLevel argument not provided") }, { defaultArgumentProvider: () => config.logLevel ?? import_logger2.LogLevel.Trace });
|
|
84
85
|
if ((0, import_type_guards.isDefined)(config.coreLogPrefix)) {
|
|
85
86
|
coreLogPrefix = config.coreLogPrefix;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
import_injector.Injector.register(import_logger2.Logger, { useToken: import_logger.ConsoleLogger });
|
|
89
|
-
import_injector.Injector.register(
|
|
90
|
+
import_injector.Injector.register(import_tokens.LOG_LEVEL, { useValue: import_logger2.LogLevel.Trace });
|
|
90
91
|
import_injector.Injector.register(CORE_LOGGER, { useToken: import_logger2.Logger, defaultArgumentProvider: () => coreLogPrefix });
|
|
@@ -2,22 +2,21 @@ import { resolveArgumentType } from '../../injector/index.js';
|
|
|
2
2
|
import type { Resolvable } from '../../injector/interfaces.js';
|
|
3
3
|
import type { OneOrMany, UndefinableJson } from '../../types.js';
|
|
4
4
|
import type { HttpMethod, HttpValue } from '../types.js';
|
|
5
|
-
import { HttpClientOptions } from './http-client-options.js';
|
|
5
|
+
import type { HttpClientOptions } from './http-client-options.js';
|
|
6
6
|
import type { HttpClientRequestOptions } from './http-client-request.js';
|
|
7
7
|
import { HttpClientRequest } from './http-client-request.js';
|
|
8
8
|
import type { HttpClientResponse } from './http-client-response.js';
|
|
9
|
-
import { HttpClientAdapter } from './http-client.adapter.js';
|
|
10
9
|
import type { HttpClientMiddleware } from './middleware.js';
|
|
11
10
|
export type HttpClientArgument = HttpClientOptions;
|
|
12
11
|
export declare class HttpClient implements Resolvable<HttpClientArgument> {
|
|
13
12
|
private readonly adapter;
|
|
14
|
-
private readonly headers;
|
|
15
13
|
private readonly middleware;
|
|
14
|
+
private readonly headers;
|
|
16
15
|
private readonly internalMiddleware;
|
|
17
16
|
private callHandler;
|
|
18
17
|
readonly options: HttpClientOptions;
|
|
19
18
|
readonly [resolveArgumentType]: HttpClientOptions;
|
|
20
|
-
constructor(
|
|
19
|
+
constructor();
|
|
21
20
|
addMiddleware(middleware: HttpClientMiddleware): void;
|
|
22
21
|
setDefaultHeader(name: string, value: OneOrMany<HttpValue>): void;
|
|
23
22
|
deleteDefaultHeader(name: string): void;
|
|
@@ -34,7 +34,6 @@ var import_url_builder = require("../../utils/url-builder.js");
|
|
|
34
34
|
var import_http_headers = require("../http-headers.js");
|
|
35
35
|
var import_http_error = require("../http.error.js");
|
|
36
36
|
var import_types = require("../types.js");
|
|
37
|
-
var import_http_client_options = require("./http-client-options.js");
|
|
38
37
|
var import_http_client_request = require("./http-client-request.js");
|
|
39
38
|
var import_http_client_adapter = require("./http-client.adapter.js");
|
|
40
39
|
var import_tokens = require("./tokens.js");
|
|
@@ -52,27 +51,18 @@ var __metadata = function(k, v) {
|
|
|
52
51
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
53
52
|
return Reflect.metadata(k, v);
|
|
54
53
|
};
|
|
55
|
-
var __param = function(paramIndex, decorator) {
|
|
56
|
-
return function(target, key) {
|
|
57
|
-
decorator(target, key, paramIndex);
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
54
|
let HttpClient = class HttpClient2 {
|
|
61
|
-
adapter;
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
adapter = (0, import_injector.inject)(import_http_client_adapter.HttpClientAdapter);
|
|
56
|
+
middleware = (0, import_injector.inject)(import_tokens.HTTP_CLIENT_MIDDLEWARES);
|
|
57
|
+
headers = new import_http_headers.HttpHeaders();
|
|
64
58
|
internalMiddleware;
|
|
65
59
|
callHandler;
|
|
66
|
-
options;
|
|
67
|
-
constructor(
|
|
68
|
-
this.adapter = adapter;
|
|
69
|
-
this.options = options;
|
|
70
|
-
this.middleware = middlewares;
|
|
71
|
-
this.headers = new import_http_headers.HttpHeaders();
|
|
60
|
+
options = (0, import_injector.injectArgument)(this, { optional: true }) ?? {};
|
|
61
|
+
constructor() {
|
|
72
62
|
this.internalMiddleware = [
|
|
73
|
-
getBuildRequestUrlMiddleware(options.baseUrl),
|
|
63
|
+
getBuildRequestUrlMiddleware(this.options.baseUrl),
|
|
74
64
|
addRequestHeadersMiddleware,
|
|
75
|
-
...options.enableErrorHandling ?? true ? [errorMiddleware] : []
|
|
65
|
+
...this.options.enableErrorHandling ?? true ? [errorMiddleware] : []
|
|
76
66
|
];
|
|
77
67
|
this.updateHandlers();
|
|
78
68
|
}
|
|
@@ -226,11 +216,7 @@ let HttpClient = class HttpClient2 {
|
|
|
226
216
|
};
|
|
227
217
|
HttpClient = __decorate([
|
|
228
218
|
(0, import_injector.Singleton)(),
|
|
229
|
-
|
|
230
|
-
__param(1, (0, import_injector.InjectArg)()),
|
|
231
|
-
__param(2, (0, import_injector.InjectAll)(import_tokens.HTTP_CLIENT_MIDDLEWARE)),
|
|
232
|
-
__param(2, (0, import_injector.Optional)()),
|
|
233
|
-
__metadata("design:paramtypes", [import_http_client_adapter.HttpClientAdapter, import_http_client_options.HttpClientOptions, Array])
|
|
219
|
+
__metadata("design:paramtypes", [])
|
|
234
220
|
], HttpClient);
|
|
235
221
|
function getBuildRequestUrlMiddleware(baseUrl) {
|
|
236
222
|
async function buildUrlParametersMiddleware(request, next) {
|
package/http/client/module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Type } from '../../types.js';
|
|
1
|
+
import type { OneOrMany, Type } from '../../types.js';
|
|
2
2
|
import { HttpClientOptions } from './http-client-options.js';
|
|
3
3
|
import { HttpClientAdapter } from './http-client.adapter.js';
|
|
4
4
|
import type { HttpClientMiddleware } from './middleware.js';
|
|
@@ -7,6 +7,6 @@ export type HttpClientModuleConfig = HttpClientOptions & {
|
|
|
7
7
|
/**
|
|
8
8
|
* middlewares to add
|
|
9
9
|
*/
|
|
10
|
-
middleware?: HttpClientMiddleware
|
|
10
|
+
middleware?: OneOrMany<HttpClientMiddleware>;
|
|
11
11
|
};
|
|
12
12
|
export declare function configureHttpClient({ adapter, middleware, ...rest }: HttpClientModuleConfig): void;
|
package/http/client/module.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(module_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(module_exports);
|
|
24
24
|
var import_injector = require("../../injector/injector.js");
|
|
25
|
+
var import_array = require("../../utils/array/array.js");
|
|
25
26
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
26
27
|
var import_http_client_options = require("./http-client-options.js");
|
|
27
28
|
var import_http_client_adapter = require("./http-client.adapter.js");
|
|
@@ -37,8 +38,8 @@ function configureHttpClient({ adapter, middleware, ...rest }) {
|
|
|
37
38
|
enableErrorHandling: rest.enableErrorHandling ?? options.enableErrorHandling
|
|
38
39
|
};
|
|
39
40
|
if ((0, import_type_guards.isDefined)(middleware)) {
|
|
40
|
-
for (const m of middleware) {
|
|
41
|
-
import_injector.Injector.register(import_tokens.HTTP_CLIENT_MIDDLEWARE, {
|
|
41
|
+
for (const m of (0, import_array.toArray)(middleware)) {
|
|
42
|
+
import_injector.Injector.register(import_tokens.HTTP_CLIENT_MIDDLEWARE, { useValue: m }, { multi: true });
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
import_injector.Injector.register(import_http_client_options.HttpClientOptions, { useValue: options });
|
package/http/client/tokens.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { HttpClientMiddleware } from './middleware.js';
|
|
2
2
|
export declare const HTTP_CLIENT_MIDDLEWARE: import("../../injector/token.js").InjectionToken<HttpClientMiddleware, never>;
|
|
3
|
+
export declare const HTTP_CLIENT_MIDDLEWARES: import("../../injector/token.js").InjectionToken<HttpClientMiddleware[], never>;
|
package/http/client/tokens.js
CHANGED
|
@@ -18,8 +18,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var tokens_exports = {};
|
|
20
20
|
__export(tokens_exports, {
|
|
21
|
-
HTTP_CLIENT_MIDDLEWARE: () => HTTP_CLIENT_MIDDLEWARE
|
|
21
|
+
HTTP_CLIENT_MIDDLEWARE: () => HTTP_CLIENT_MIDDLEWARE,
|
|
22
|
+
HTTP_CLIENT_MIDDLEWARES: () => HTTP_CLIENT_MIDDLEWARES
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(tokens_exports);
|
|
25
|
+
var import_injector = require("../../injector/injector.js");
|
|
24
26
|
var import_token = require("../../injector/token.js");
|
|
25
27
|
const HTTP_CLIENT_MIDDLEWARE = (0, import_token.injectionToken)("HttpClientMiddleware");
|
|
28
|
+
const HTTP_CLIENT_MIDDLEWARES = (0, import_token.injectionToken)("HttpClientMiddlewares");
|
|
29
|
+
import_injector.Injector.register(HTTP_CLIENT_MIDDLEWARES, { useToken: HTTP_CLIENT_MIDDLEWARE, resolveAll: true });
|
package/injector/inject.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ export type InjectionContext = {
|
|
|
17
17
|
injectAsync<T, A>(token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions): Promise<T>;
|
|
18
18
|
injectAllAsync<T, A>(token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions): Promise<T[]>;
|
|
19
19
|
};
|
|
20
|
+
export type InjectManyArrayItem<T, A> = [token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions];
|
|
21
|
+
export type InjectManyItem<T, A> = InjectionToken<T, A> | InjectManyArrayItem<T, A>;
|
|
22
|
+
export type InjectManyItemReturnType<T extends InjectManyItem<any, any>> = T extends InjectManyItem<infer U, any> ? U | (T extends (InjectManyArrayItem<any, any> & [any, any, {
|
|
23
|
+
optional: true;
|
|
24
|
+
}]) ? undefined : never) : never;
|
|
25
|
+
export type InjectManyReturnType<T extends InjectManyItem<any, any>[]> = {
|
|
26
|
+
[I in keyof T]: InjectManyItemReturnType<T[I]>;
|
|
27
|
+
};
|
|
20
28
|
/**
|
|
21
29
|
* Resolves a token using the {@link Injector} of the current injection context
|
|
22
30
|
*
|
|
@@ -27,7 +35,15 @@ export type InjectionContext = {
|
|
|
27
35
|
export declare function inject<T = unknown, A = unknown>(token: InjectionToken<T, A>, argument: ResolveArgument<T, A>, options: InjectOptions & {
|
|
28
36
|
optional: true;
|
|
29
37
|
}): T | undefined;
|
|
30
|
-
export declare function inject<T = unknown, A = unknown>(token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions
|
|
38
|
+
export declare function inject<T = unknown, A = unknown>(token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions & {
|
|
39
|
+
optional?: false;
|
|
40
|
+
}): T;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves tokens using the {@link Injector} of the current injection context
|
|
43
|
+
*
|
|
44
|
+
* @param token tokens to resolve
|
|
45
|
+
*/
|
|
46
|
+
export declare function injectMany<T extends InjectManyItem<any, any>[]>(...tokens: T): InjectManyReturnType<T>;
|
|
31
47
|
/**
|
|
32
48
|
* Resolves a token using the {@link Injector} of the current injection context
|
|
33
49
|
*
|
|
@@ -39,6 +55,12 @@ export declare function injectAsync<T = unknown, A = unknown>(token: InjectionTo
|
|
|
39
55
|
optional: true;
|
|
40
56
|
}): Promise<T | undefined>;
|
|
41
57
|
export declare function injectAsync<T = unknown, A = unknown>(token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions): Promise<T>;
|
|
58
|
+
/**
|
|
59
|
+
* Resolves tokens using the {@link Injector} of the current injection context
|
|
60
|
+
*
|
|
61
|
+
* @param token tokens to resolve
|
|
62
|
+
*/
|
|
63
|
+
export declare function injectManyAsync<T extends InjectManyItem<any, any>[]>(...tokens: T): Promise<InjectManyReturnType<T>>;
|
|
42
64
|
/**
|
|
43
65
|
* Resolves a token using the {@link Injector} of the current injection context
|
|
44
66
|
*
|
package/injector/inject.js
CHANGED
|
@@ -26,11 +26,15 @@ __export(inject_exports, {
|
|
|
26
26
|
injectAllAsync: () => injectAllAsync,
|
|
27
27
|
injectArgument: () => injectArgument,
|
|
28
28
|
injectAsync: () => injectAsync,
|
|
29
|
+
injectMany: () => injectMany,
|
|
30
|
+
injectManyAsync: () => injectManyAsync,
|
|
29
31
|
isInInjectionContext: () => isInInjectionContext,
|
|
30
32
|
runInInjectionContext: () => runInInjectionContext,
|
|
31
33
|
setCurrentInjectionContext: () => setCurrentInjectionContext
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(inject_exports);
|
|
36
|
+
var import_map = require("../utils/async-iterable-helpers/map.js");
|
|
37
|
+
var import_to_array = require("../utils/async-iterable-helpers/to-array.js");
|
|
34
38
|
var import_type_guards = require("../utils/type-guards.js");
|
|
35
39
|
var import_injector = require("./injector.js");
|
|
36
40
|
let currentInjectionContext = null;
|
|
@@ -38,10 +42,18 @@ function inject(token, argument, options) {
|
|
|
38
42
|
assertInInjectionContext(inject);
|
|
39
43
|
return currentInjectionContext.inject(token, argument, options);
|
|
40
44
|
}
|
|
45
|
+
function injectMany(...tokens) {
|
|
46
|
+
assertInInjectionContext(inject);
|
|
47
|
+
return tokens.map((item) => (0, import_type_guards.isArray)(item) ? currentInjectionContext.inject(item[0], item[1], item[2]) : currentInjectionContext.inject(item));
|
|
48
|
+
}
|
|
41
49
|
async function injectAsync(token, argument, options) {
|
|
42
50
|
assertInInjectionContext(inject);
|
|
43
51
|
return currentInjectionContext.injectAsync(token, argument, options);
|
|
44
52
|
}
|
|
53
|
+
async function injectManyAsync(...tokens) {
|
|
54
|
+
assertInInjectionContext(inject);
|
|
55
|
+
return (0, import_to_array.toArrayAsync)((0, import_map.mapAsync)(tokens, async (item) => (0, import_type_guards.isArray)(item) ? currentInjectionContext.injectAsync(item[0], item[1], item[2]) : currentInjectionContext.injectAsync(item)));
|
|
56
|
+
}
|
|
45
57
|
function injectAll(token, argument, options) {
|
|
46
58
|
assertInInjectionContext(injectAll);
|
|
47
59
|
return currentInjectionContext.injectAll(token, argument, options);
|
package/injector/injector.js
CHANGED
|
@@ -21,13 +21,13 @@ __export(injector_exports, {
|
|
|
21
21
|
Injector: () => Injector
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(injector_exports);
|
|
24
|
+
var import_cancellation = require("../cancellation/index.js");
|
|
24
25
|
var import_circular_buffer = require("../data-structures/circular-buffer.js");
|
|
25
26
|
var import_multi_key_map = require("../data-structures/multi-key-map.js");
|
|
26
27
|
var import_disposable = require("../disposable/disposable.js");
|
|
27
28
|
var import_deferred_promise = require("../promise/deferred-promise.js");
|
|
28
29
|
var import_registry = require("../reflection/registry.js");
|
|
29
30
|
var import_array = require("../utils/array/array.js");
|
|
30
|
-
var import_cancellation = require("../cancellation/index.js");
|
|
31
31
|
var import_factory_map = require("../utils/factory-map.js");
|
|
32
32
|
var import_forward_ref = require("../utils/object/forward-ref.js");
|
|
33
33
|
var import_object = require("../utils/object/object.js");
|
package/injector/provider.d.ts
CHANGED
|
@@ -20,20 +20,28 @@ export type ValueProvider<T = any> = {
|
|
|
20
20
|
export type TokenProvider<T = any, A = any, D extends Record = Record> = ProviderWithArgument<T, A> & ProviderWithInitializer<T, A, D> & ({
|
|
21
21
|
useToken: InjectionToken<T, A>;
|
|
22
22
|
useTokenProvider?: undefined;
|
|
23
|
+
resolveAll?: false;
|
|
23
24
|
} | {
|
|
24
25
|
useToken?: undefined;
|
|
25
26
|
useTokenProvider: () => InjectionToken<T, A>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
resolveAll
|
|
31
|
-
}
|
|
27
|
+
resolveAll?: false;
|
|
28
|
+
} | {
|
|
29
|
+
useToken: InjectionToken<T extends (infer U)[] ? U : T, A>;
|
|
30
|
+
useTokenProvider?: undefined;
|
|
31
|
+
resolveAll: true;
|
|
32
|
+
} | {
|
|
33
|
+
useToken?: undefined;
|
|
34
|
+
useTokenProvider: () => InjectionToken<T extends (infer U)[] ? U : T, A>;
|
|
35
|
+
resolveAll: true;
|
|
36
|
+
});
|
|
32
37
|
export type FactoryProvider<T = any, A = unknown, D extends Record = Record> = ProviderWithArgument<T, A> & ProviderWithInitializer<T, A, D> & {
|
|
33
38
|
useFactory: Factory<T, A, D>;
|
|
34
39
|
};
|
|
35
40
|
export declare function classProvider<T, A, D extends Record>(constructor: Constructor<T>, options?: TypedOmit<ClassProvider<T, A, D>, 'useClass'>): ClassProvider<T, A, D>;
|
|
36
41
|
export declare function valueProvider<T>(value: T, options?: TypedOmit<ValueProvider<T>, 'useValue'>): ValueProvider<T>;
|
|
42
|
+
export declare function tokenProvider<T, A, D extends Record>(token: InjectionToken<T, A>, options: TypedOmit<TokenProvider<T, A, D>, 'useToken' | 'useTokenProvider'> & {
|
|
43
|
+
resolveAll: true;
|
|
44
|
+
}): TokenProvider<T[]>;
|
|
37
45
|
export declare function tokenProvider<T, A, D extends Record>(token: InjectionToken<T, A>, options?: TypedOmit<TokenProvider<T, A, D>, 'useToken' | 'useTokenProvider'>): TokenProvider<T>;
|
|
38
46
|
export declare function factoryProvider<T, A, D extends Record>(factory: Factory<T, A, D>, options?: TypedOmit<FactoryProvider<T, A, D>, 'useFactory'>): FactoryProvider<T, A, D>;
|
|
39
47
|
export declare function isClassProvider<T, A>(value: Provider<T, A>): value is ClassProvider<T, A>;
|
package/injector/token.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AbstractConstructor } from '../types.js';
|
|
2
2
|
declare const type: unique symbol;
|
|
3
3
|
declare const argument: unique symbol;
|
|
4
|
+
export type SimpleInjectionToken<T> = AbstractConstructor<T>;
|
|
4
5
|
export type ArgumentedInjectionToken<T, A> = SimpleInjectionToken<T> & {
|
|
5
6
|
[argument]: A;
|
|
6
7
|
};
|
|
7
|
-
export type SimpleInjectionToken<T> = AbstractConstructor<T> | object;
|
|
8
8
|
export type InjectionToken<T = any, A = any> = SimpleInjectionToken<T> | ArgumentedInjectionToken<T, A> | ReifyingInjectionToken<T, A>;
|
|
9
9
|
export type InjectionTokenArgument<T extends ArgumentedInjectionToken<any, any> | ReifyingInjectionToken> = T[typeof argument];
|
|
10
10
|
export declare class ReifyingInjectionToken<T = any, A = any> {
|
package/logger/console/logger.js
CHANGED
|
@@ -27,6 +27,7 @@ var import_format_error = require("../../utils/format-error.js");
|
|
|
27
27
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
28
28
|
var import_level = require("../level.js");
|
|
29
29
|
var import_logger = require("../logger.js");
|
|
30
|
+
var import_tokens = require("../tokens.js");
|
|
30
31
|
var __decorate = function(decorators, target, key, desc) {
|
|
31
32
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
32
33
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -79,9 +80,9 @@ ConsoleLogger = ConsoleLogger_1 = __decorate([
|
|
|
79
80
|
provider: {
|
|
80
81
|
useFactory: (argument, context) => {
|
|
81
82
|
if ((0, import_type_guards.isObject)(argument)) {
|
|
82
|
-
return new ConsoleLogger(argument.level ?? context.resolve(
|
|
83
|
+
return new ConsoleLogger(argument.level ?? context.resolve(import_tokens.LOG_LEVEL), argument.module, argument.prefix);
|
|
83
84
|
}
|
|
84
|
-
return new ConsoleLogger(context.resolve(
|
|
85
|
+
return new ConsoleLogger(context.resolve(import_tokens.LOG_LEVEL), argument, void 0);
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
}),
|
package/logger/index.d.ts
CHANGED
package/logger/index.js
CHANGED
|
@@ -17,3 +17,4 @@ var logger_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(logger_exports);
|
|
18
18
|
__reExport(logger_exports, require("./level.js"), module.exports);
|
|
19
19
|
__reExport(logger_exports, require("./logger.js"), module.exports);
|
|
20
|
+
__reExport(logger_exports, require("./tokens.js"), module.exports);
|
package/logger/tokens.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tokens_exports = {};
|
|
20
|
+
__export(tokens_exports, {
|
|
21
|
+
LOG_LEVEL: () => LOG_LEVEL
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tokens_exports);
|
|
24
|
+
var import_token = require("../injector/token.js");
|
|
25
|
+
const LOG_LEVEL = (0, import_token.injectionToken)("log level");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.87.
|
|
3
|
+
"version": "0.87.5",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@types/mjml": "4.7",
|
|
35
35
|
"@types/node": "20",
|
|
36
36
|
"@types/nodemailer": "6.4",
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
38
|
-
"@typescript-eslint/parser": "6.
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "6.6",
|
|
38
|
+
"@typescript-eslint/parser": "6.6",
|
|
39
39
|
"concurrently": "8.2",
|
|
40
40
|
"esbuild": "0.19",
|
|
41
41
|
"eslint": "8.48",
|