@tstdl/base 0.85.26 → 0.86.0-beta10
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/_container/decorators.d.ts +76 -0
- package/_container/decorators.js +110 -0
- package/_container/index.d.ts +10 -0
- package/_container/index.js +27 -0
- package/_container/interfaces.d.ts +16 -0
- package/_container/interfaces.js +26 -0
- package/_container/token.d.ts +18 -0
- package/_container/token.js +41 -0
- package/api/client/client.d.ts +2 -2
- package/api/client/client.js +5 -3
- package/api/server/api-controller.d.ts +2 -2
- package/api/server/api-controller.js +5 -4
- package/api/server/api-request-token.provider.js +2 -2
- package/api/server/gateway.d.ts +5 -6
- package/api/server/gateway.js +25 -12
- package/api/server/module.js +4 -4
- package/api/server/tokens.d.ts +4 -1
- package/api/server/tokens.js +8 -2
- package/application/application.d.ts +13 -10
- package/application/application.js +38 -45
- package/authentication/client/api.client.js +3 -3
- package/authentication/client/authentication.service.d.ts +4 -4
- package/authentication/client/authentication.service.js +20 -21
- package/authentication/client/http-client.middleware.d.ts +3 -5
- package/authentication/client/http-client.middleware.js +3 -12
- package/authentication/client/module.d.ts +2 -1
- package/authentication/client/module.js +15 -7
- package/authentication/client/tokens.d.ts +2 -2
- package/authentication/client/tokens.js +5 -4
- package/authentication/server/authentication-api-request-token.provider.js +2 -2
- package/authentication/server/authentication-secret-requirements.validator.js +2 -2
- package/authentication/server/authentication.service.d.ts +2 -2
- package/authentication/server/authentication.service.js +9 -9
- package/authentication/server/module.d.ts +2 -1
- package/authentication/server/module.js +8 -7
- package/authentication/server/mongo/mongo-authentication-credentials.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-credentials.repository.js +4 -4
- package/authentication/server/mongo/mongo-authentication-session.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-session.repository.js +4 -4
- package/browser/browser-context-controller.d.ts +4 -4
- package/browser/browser-context-controller.js +15 -9
- package/browser/browser-controller.d.ts +12 -5
- package/browser/browser-controller.js +24 -10
- package/browser/browser.service.d.ts +12 -6
- package/browser/browser.service.js +13 -10
- package/browser/module.js +2 -2
- package/container/decorators.d.ts +2 -76
- package/container/decorators.js +12 -88
- package/container/index.d.ts +0 -7
- package/container/index.js +0 -7
- package/container/interfaces.d.ts +2 -16
- package/container/interfaces.js +3 -4
- package/container/token.d.ts +2 -18
- package/container/token.js +4 -19
- package/core.d.ts +4 -2
- package/core.js +15 -8
- package/database/mongo/classes.d.ts +5 -5
- package/database/mongo/classes.js +5 -4
- package/database/mongo/module.js +24 -16
- package/database/mongo/mongo-entity-repository.d.ts +2 -2
- package/database/mongo/mongo-entity-repository.js +2 -2
- package/disposable/async-disposer.d.ts +4 -4
- package/distributed-loop/distributed-loop.d.ts +3 -3
- package/distributed-loop/distributed-loop.js +3 -3
- package/distributed-loop/provider.js +2 -2
- package/examples/api/authentication.js +17 -10
- package/examples/api/basic-overview.js +4 -5
- package/examples/api/custom-authentication.js +9 -6
- package/examples/api/streaming.js +5 -5
- package/examples/browser/basic.js +5 -5
- package/examples/http/client.js +6 -4
- package/examples/mail/basic.js +9 -4
- package/examples/pdf/basic.js +9 -5
- package/examples/template/basic.js +8 -6
- package/function/log.js +1 -1
- package/http/client/adapters/undici-http-client.adapter.js +7 -6
- package/http/client/http-client-options.d.ts +0 -5
- package/http/client/http-client-options.js +0 -4
- package/http/client/http-client.d.ts +5 -8
- package/http/client/http-client.js +10 -7
- package/http/client/middleware.d.ts +6 -0
- package/http/client/middleware.js +16 -0
- package/http/client/module.d.ts +6 -1
- package/http/client/module.js +10 -5
- package/http/client/tokens.d.ts +2 -0
- package/http/client/tokens.js +25 -0
- package/http/server/node/module.js +2 -2
- package/http/server/node/node-http-server.d.ts +1 -4
- package/http/server/node/node-http-server.js +3 -7
- package/image-service/imgproxy/imgproxy-image-service.d.ts +6 -8
- package/image-service/imgproxy/imgproxy-image-service.js +17 -16
- package/injector/decorators.d.ts +12 -6
- package/injector/decorators.js +14 -0
- package/injector/index.d.ts +11 -0
- package/injector/index.js +28 -0
- package/injector/inject.d.ts +6 -1
- package/injector/inject.js +14 -2
- package/injector/injector.d.ts +14 -34
- package/injector/injector.js +91 -48
- package/injector/interfaces.d.ts +7 -5
- package/injector/provider.d.ts +19 -14
- package/injector/token.d.ts +10 -3
- package/injector/token.js +1 -1
- package/injector/type-info.d.ts +2 -0
- package/injector/types.d.ts +13 -7
- package/key-value-store/key-value.store.d.ts +3 -3
- package/key-value-store/key-value.store.js +1 -1
- package/key-value-store/mongo/module.js +4 -4
- package/key-value-store/mongo/mongo-key-value-store.provider.js +2 -2
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +3 -3
- package/key-value-store/mongo/mongo-key-value.repository.js +4 -4
- package/key-value-store/mongo/mongo-key-value.store.js +3 -3
- package/key-value-store/mongo/tokens.d.ts +1 -1
- package/key-value-store/mongo/tokens.js +1 -1
- package/lock/lock.d.ts +3 -2
- package/lock/lock.js +1 -0
- package/lock/mongo/lock.js +4 -4
- package/lock/mongo/module.js +3 -3
- package/lock/mongo/mongo-lock-repository.d.ts +3 -3
- package/lock/mongo/mongo-lock-repository.js +3 -3
- package/lock/mongo/provider.js +5 -5
- package/lock/provider.d.ts +3 -2
- package/lock/provider.js +1 -0
- package/lock/web/module.js +3 -3
- package/lock/web/web-lock.js +2 -2
- package/lock/web/web-lock.provider.js +3 -3
- package/logger/console/logger.js +2 -2
- package/logger/logger.d.ts +3 -2
- package/logger/logger.js +1 -0
- package/mail/clients/nodemailer.mail-client.js +6 -5
- package/mail/mail.client.d.ts +3 -2
- package/mail/mail.client.js +1 -0
- package/mail/mail.service.js +7 -7
- package/mail/module.js +5 -5
- package/mail/repositories/mongo-mail-log.repository.d.ts +3 -3
- package/mail/repositories/mongo-mail-log.repository.js +3 -3
- package/mail/tokens.d.ts +1 -1
- package/mail/tokens.js +2 -2
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +3 -3
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +3 -3
- package/message-bus/broadcast-channel/module.js +3 -3
- package/message-bus/local/local-message-bus-provider.js +4 -4
- package/message-bus/local/local-message-bus.d.ts +1 -1
- package/message-bus/local/local-message-bus.js +3 -3
- package/message-bus/local/module.js +3 -3
- package/message-bus/message-bus.d.ts +3 -3
- package/message-bus/message-bus.js +1 -0
- package/migration/index.d.ts +1 -1
- package/migration/index.js +1 -1
- package/migration/migrator.js +4 -4
- package/migration/mongo/migration-state-repository.d.ts +3 -3
- package/migration/mongo/migration-state-repository.js +4 -4
- package/migration/mongo/module.js +2 -2
- package/module/modules/web-server.module.d.ts +5 -10
- package/module/modules/web-server.module.js +16 -36
- package/notification/notification.service.js +2 -2
- package/object-storage/object-storage.d.ts +3 -3
- package/object-storage/object-storage.js +1 -0
- package/object-storage/s3/s3.object-storage-provider.js +6 -5
- package/object-storage/s3/s3.object-storage.d.ts +2 -2
- package/object-storage/s3/s3.object-storage.js +4 -4
- package/openid-connect/cached-oidc-configuration.service.js +3 -3
- package/openid-connect/index.d.ts +1 -1
- package/openid-connect/index.js +3 -3
- package/openid-connect/mongo-oidc-state.repository.d.ts +3 -3
- package/openid-connect/mongo-oidc-state.repository.js +6 -5
- package/openid-connect/oidc-configuration.service.js +2 -2
- package/openid-connect/oidc.service.js +4 -4
- package/package.json +1 -1
- package/pdf/pdf.service.d.ts +3 -3
- package/pdf/pdf.service.js +5 -5
- package/process-shutdown.d.ts +2 -2
- package/process-shutdown.js +6 -8
- package/queue/mongo/mongo-job.repository.d.ts +3 -3
- package/queue/mongo/mongo-job.repository.js +4 -4
- package/queue/mongo/queue.js +4 -4
- package/queue/mongo/queue.provider.d.ts +3 -3
- package/queue/mongo/queue.provider.js +8 -6
- package/queue/queue.d.ts +3 -3
- package/queue/queue.js +1 -1
- package/search-index/elastic/config.d.ts +3 -3
- package/search-index/elastic/config.js +4 -3
- package/search-index/elastic/module.d.ts +1 -3
- package/search-index/elastic/module.js +21 -18
- package/search-index/elastic/search-index.d.ts +2 -2
- package/search-index/elastic/search-index.js +2 -2
- package/templates/module.d.ts +2 -2
- package/templates/module.js +12 -26
- package/templates/providers/file.template-provider.d.ts +3 -3
- package/templates/providers/file.template-provider.js +5 -4
- package/templates/providers/memory.template-provider.js +2 -2
- package/templates/renderers/handlebars.template-renderer.js +2 -2
- package/templates/renderers/jsx.template-renderer.js +2 -2
- package/templates/renderers/mjml.template-renderer.js +3 -3
- package/templates/renderers/string.template-renderer.js +2 -2
- package/templates/resolvers/file.template-resolver.d.ts +3 -3
- package/templates/resolvers/file.template-resolver.js +6 -5
- package/templates/resolvers/jsx.template-resolver.js +2 -2
- package/templates/resolvers/string.template-resolver.js +2 -2
- package/templates/template-renderer.provider.js +3 -3
- package/templates/template-resolver.provider.js +3 -3
- package/templates/template.service.js +4 -4
- package/templates/tokens.d.ts +2 -2
- package/templates/tokens.js +3 -3
- package/text/dynamic-text.model.js +3 -4
- package/text/localization.service.js +3 -3
- package/theme/theme-service.d.ts +1 -1
- package/theme/theme-service.js +7 -6
- package/tokens.d.ts +1 -1
- package/tokens.js +2 -2
- /package/{container → _container}/container.d.ts +0 -0
- /package/{container → _container}/container.js +0 -0
- /package/{container → _container}/provider.d.ts +0 -0
- /package/{container → _container}/provider.js +0 -0
- /package/{container → _container}/resolve-chain.d.ts +0 -0
- /package/{container → _container}/resolve-chain.js +0 -0
- /package/{container → _container}/resolve.error.d.ts +0 -0
- /package/{container → _container}/resolve.error.js +0 -0
- /package/{container → _container}/type-info.d.ts +0 -0
- /package/{container → _container}/type-info.js +0 -0
- /package/{container → _container}/types.d.ts +0 -0
- /package/{container → _container}/types.js +0 -0
- /package/{container → _container}/utils.d.ts +0 -0
- /package/{container → _container}/utils.js +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Decorator } from '../reflection/index.js';
|
|
2
|
+
import type { Constructor, OneOrMany, Simplify, TypedOmit } from '../types.js';
|
|
3
|
+
import type { RegistrationOptions } from './container.js';
|
|
4
|
+
import type { Provider } from './provider.js';
|
|
5
|
+
import type { InjectionToken } from './token.js';
|
|
6
|
+
import type { ArgumentProvider, ForwardRefInjectionToken, Mapper } from './types.js';
|
|
7
|
+
type InjectDecorator = Decorator<'property' | 'accessor' | 'constructorParameter'>;
|
|
8
|
+
export type InjectableOptions<T, A> = RegistrationOptions<T> & {
|
|
9
|
+
/** aliases (tokens) for the class. Useful for example for circular dependencies when you can't use the class itself as a token */
|
|
10
|
+
alias?: OneOrMany<InjectionToken>;
|
|
11
|
+
/** custom provider. Useful for example if initialization is required */
|
|
12
|
+
provider?: Provider<T, A>;
|
|
13
|
+
};
|
|
14
|
+
export type InjectableOptionsWithoutLifecycle<T, A> = Simplify<TypedOmit<InjectableOptions<T, A>, 'lifecycle'>>;
|
|
15
|
+
/**
|
|
16
|
+
* Helper decorator to replace a class definition with an other
|
|
17
|
+
* can be used for example to type external classes with the {@link Injectable} interface
|
|
18
|
+
* @param constructor class to replace with
|
|
19
|
+
*/
|
|
20
|
+
export declare function replaceClass<T>(constructor: Constructor<T>): ClassDecorator;
|
|
21
|
+
/**
|
|
22
|
+
* registers the class in the global container. Decorated class is not modified in any way
|
|
23
|
+
* @param options registration options
|
|
24
|
+
*/
|
|
25
|
+
export declare function injectable<T = any, A = any>(options?: InjectableOptions<T, A>): ClassDecorator;
|
|
26
|
+
/**
|
|
27
|
+
* registers the class in the global container with singleton lifecycle. Decorated class is not modified in any way
|
|
28
|
+
* @param options registration options
|
|
29
|
+
*/
|
|
30
|
+
export declare function singleton<T = any, A = any>(options?: InjectableOptionsWithoutLifecycle<T, A>): ClassDecorator;
|
|
31
|
+
/**
|
|
32
|
+
* registers the class in the global container with scoped lifecycle. Decorated class is not modified in any way
|
|
33
|
+
* @param options registration options
|
|
34
|
+
*/
|
|
35
|
+
export declare function scoped<T = any, A = any>(lifecycle: 'resolution', options?: InjectableOptionsWithoutLifecycle<T, A>): ClassDecorator;
|
|
36
|
+
/**
|
|
37
|
+
* sets the token used to resolve the parameter
|
|
38
|
+
* @param token token used for resolving
|
|
39
|
+
* @param argument resolve argument
|
|
40
|
+
* @param mapperOrKey map the resolved value. If {@link PropertyKey} is provided, that property of the resolved value will be injected
|
|
41
|
+
*/
|
|
42
|
+
export declare function inject<T, A>(token?: InjectionToken<T, A>, argument?: A, mapperOrKey?: Mapper<T> | keyof T): InjectDecorator;
|
|
43
|
+
/**
|
|
44
|
+
* sets the argument used for resolving the parameter
|
|
45
|
+
* @param argument
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveArg<T>(argument: T): InjectDecorator;
|
|
48
|
+
/**
|
|
49
|
+
* sets the argument provider used for resolving the parameter
|
|
50
|
+
* @param argumentProvider
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveArgProvider<T>(argumentProvider: ArgumentProvider<T>): InjectDecorator;
|
|
53
|
+
/**
|
|
54
|
+
* injects the argument used for resolving the class instead of resolving the parameter
|
|
55
|
+
* @param argument
|
|
56
|
+
* @param mapperOrKey map the resolved value. If {@link PropertyKey} is provided, that property of the resolved value will be injected
|
|
57
|
+
*/
|
|
58
|
+
export declare function injectArg<T>(mapperOrKey?: Mapper<T> | keyof T): InjectDecorator;
|
|
59
|
+
/**
|
|
60
|
+
* sets the argument used for resolving the decorated parameter to the the argument provided for parent resolve
|
|
61
|
+
* @param mapper map the argument (for example to select a property instead of forwarding the whole object)
|
|
62
|
+
*/
|
|
63
|
+
export declare function forwardArg(): InjectDecorator;
|
|
64
|
+
export declare function forwardArg<T, U>(mapper: Mapper<T, U>): InjectDecorator;
|
|
65
|
+
/**
|
|
66
|
+
* marks the argument as optional
|
|
67
|
+
* @param argument
|
|
68
|
+
*/
|
|
69
|
+
export declare function optional(): InjectDecorator;
|
|
70
|
+
/**
|
|
71
|
+
* resolve using ForwardRef to handle circular dependencies. Resolve logic derefs all ForwardRefs which are direct properties of resolved instances automatically
|
|
72
|
+
* @param token token to resolve
|
|
73
|
+
* @param argument resolve argument
|
|
74
|
+
*/
|
|
75
|
+
export declare function forwardRef<T extends object, A>(token: ForwardRefInjectionToken<T>, argument?: A): InjectDecorator;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
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 decorators_exports = {};
|
|
20
|
+
__export(decorators_exports, {
|
|
21
|
+
forwardArg: () => forwardArg,
|
|
22
|
+
forwardRef: () => forwardRef,
|
|
23
|
+
inject: () => inject,
|
|
24
|
+
injectArg: () => injectArg,
|
|
25
|
+
injectable: () => injectable,
|
|
26
|
+
optional: () => optional,
|
|
27
|
+
replaceClass: () => replaceClass,
|
|
28
|
+
resolveArg: () => resolveArg,
|
|
29
|
+
resolveArgProvider: () => resolveArgProvider,
|
|
30
|
+
scoped: () => scoped,
|
|
31
|
+
singleton: () => singleton
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(decorators_exports);
|
|
34
|
+
var import_reflection = require("../reflection/index.js");
|
|
35
|
+
var import_array = require("../utils/array/array.js");
|
|
36
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
37
|
+
var import_container = require("./container.js");
|
|
38
|
+
function replaceClass(constructor) {
|
|
39
|
+
return (0, import_reflection.createClassDecorator)({ handler: () => constructor });
|
|
40
|
+
}
|
|
41
|
+
function injectable(options = {}) {
|
|
42
|
+
return (0, import_reflection.createClassDecorator)({
|
|
43
|
+
data: { [import_container.injectMetadataSymbol]: {} },
|
|
44
|
+
mergeData: true,
|
|
45
|
+
handler: (data) => {
|
|
46
|
+
const { alias: aliases, provider, ...registrationOptions } = options;
|
|
47
|
+
const targetProvider = provider ?? { useClass: data.constructor };
|
|
48
|
+
import_container.container.register(data.constructor, targetProvider, registrationOptions);
|
|
49
|
+
if ((0, import_type_guards.isDefined)(aliases)) {
|
|
50
|
+
for (const alias of (0, import_array.toArray)(aliases)) {
|
|
51
|
+
import_container.container.register(alias, { useToken: data.constructor }, registrationOptions);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function singleton(options = {}) {
|
|
58
|
+
return injectable({ ...options, lifecycle: "singleton" });
|
|
59
|
+
}
|
|
60
|
+
function scoped(lifecycle, options = {}) {
|
|
61
|
+
return injectable({ ...options, lifecycle });
|
|
62
|
+
}
|
|
63
|
+
function inject(token, argument, mapperOrKey) {
|
|
64
|
+
const injectMetadata = {};
|
|
65
|
+
if ((0, import_type_guards.isDefined)(token)) {
|
|
66
|
+
injectMetadata.injectToken = token;
|
|
67
|
+
}
|
|
68
|
+
if ((0, import_type_guards.isDefined)(argument)) {
|
|
69
|
+
injectMetadata.resolveArgumentProvider = () => argument;
|
|
70
|
+
}
|
|
71
|
+
if ((0, import_type_guards.isDefined)(mapperOrKey)) {
|
|
72
|
+
injectMetadata.mapper = (0, import_type_guards.isFunction)(mapperOrKey) ? mapperOrKey : (value) => value[mapperOrKey];
|
|
73
|
+
}
|
|
74
|
+
return createInjectDecorator(injectMetadata);
|
|
75
|
+
}
|
|
76
|
+
function resolveArg(argument) {
|
|
77
|
+
return resolveArgProvider(() => argument);
|
|
78
|
+
}
|
|
79
|
+
function resolveArgProvider(argumentProvider) {
|
|
80
|
+
return createInjectDecorator({ resolveArgumentProvider: argumentProvider });
|
|
81
|
+
}
|
|
82
|
+
function injectArg(mapperOrKey) {
|
|
83
|
+
return createInjectDecorator({
|
|
84
|
+
injectArgumentMapper: (0, import_type_guards.isFunction)(mapperOrKey) ? mapperOrKey : (0, import_type_guards.isDefined)(mapperOrKey) ? (value) => value[mapperOrKey] : (value) => value
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function forwardArg(mapper = (value) => value) {
|
|
88
|
+
return createInjectDecorator({ forwardArgumentMapper: mapper });
|
|
89
|
+
}
|
|
90
|
+
function optional() {
|
|
91
|
+
return createInjectDecorator({ optional: true });
|
|
92
|
+
}
|
|
93
|
+
function forwardRef(token, argument) {
|
|
94
|
+
const injectMetadata = {
|
|
95
|
+
forwardRefToken: token
|
|
96
|
+
};
|
|
97
|
+
if ((0, import_type_guards.isDefined)(argument)) {
|
|
98
|
+
injectMetadata.resolveArgumentProvider = () => argument;
|
|
99
|
+
}
|
|
100
|
+
return createInjectDecorator(injectMetadata);
|
|
101
|
+
}
|
|
102
|
+
function createInjectDecorator(metadata) {
|
|
103
|
+
return (0, import_reflection.createDecorator)({
|
|
104
|
+
property: true,
|
|
105
|
+
accessor: true,
|
|
106
|
+
constructorParameter: true,
|
|
107
|
+
data: { [import_container.injectMetadataSymbol]: metadata },
|
|
108
|
+
mergeData: true
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './container.js';
|
|
2
|
+
export * from './decorators.js';
|
|
3
|
+
export * from './interfaces.js';
|
|
4
|
+
export * from './provider.js';
|
|
5
|
+
export * from './resolve-chain.js';
|
|
6
|
+
export * from './resolve.error.js';
|
|
7
|
+
export * from './token.js';
|
|
8
|
+
export * from './type-info.js';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
export * from './utils.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var container_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(container_exports);
|
|
18
|
+
__reExport(container_exports, require("./container.js"), module.exports);
|
|
19
|
+
__reExport(container_exports, require("./decorators.js"), module.exports);
|
|
20
|
+
__reExport(container_exports, require("./interfaces.js"), module.exports);
|
|
21
|
+
__reExport(container_exports, require("./provider.js"), module.exports);
|
|
22
|
+
__reExport(container_exports, require("./resolve-chain.js"), module.exports);
|
|
23
|
+
__reExport(container_exports, require("./resolve.error.js"), module.exports);
|
|
24
|
+
__reExport(container_exports, require("./token.js"), module.exports);
|
|
25
|
+
__reExport(container_exports, require("./type-info.js"), module.exports);
|
|
26
|
+
__reExport(container_exports, require("./types.js"), module.exports);
|
|
27
|
+
__reExport(container_exports, require("./utils.js"), module.exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const resolveArgumentType: unique symbol;
|
|
2
|
+
export declare const afterResolve: unique symbol;
|
|
3
|
+
export type InjectableArgument<T, Fallback> = T extends Injectable<infer A> ? A : Fallback;
|
|
4
|
+
export interface Injectable<T = unknown> {
|
|
5
|
+
/**
|
|
6
|
+
* type of resolve argument
|
|
7
|
+
* @deprecated only used for type inference
|
|
8
|
+
*/
|
|
9
|
+
readonly [resolveArgumentType]: T;
|
|
10
|
+
}
|
|
11
|
+
export interface AfterResolve {
|
|
12
|
+
/**
|
|
13
|
+
* called after resolve through container
|
|
14
|
+
*/
|
|
15
|
+
[afterResolve](): void | Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 interfaces_exports = {};
|
|
20
|
+
__export(interfaces_exports, {
|
|
21
|
+
afterResolve: () => afterResolve,
|
|
22
|
+
resolveArgumentType: () => resolveArgumentType
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
25
|
+
const resolveArgumentType = Symbol("resolveArgumentType");
|
|
26
|
+
const afterResolve = Symbol("after resolve");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AbstractConstructor, EnumerationObject } from '../types.js';
|
|
2
|
+
declare const type: unique symbol;
|
|
3
|
+
declare const argument: unique symbol;
|
|
4
|
+
export type ArgumentedInjectionToken<T, A> = SimpleInjectionToken<T> & {
|
|
5
|
+
[argument]?: A;
|
|
6
|
+
};
|
|
7
|
+
export type SimpleInjectionToken<T> = AbstractConstructor<T> | EnumerationObject;
|
|
8
|
+
export type InjectionToken<T = any, A = any> = SimpleInjectionToken<T> | ArgumentedInjectionToken<T, A> | ReifyingInjectionToken<T, A>;
|
|
9
|
+
export declare class ReifyingInjectionToken<T = any, A = any> {
|
|
10
|
+
private readonly [type];
|
|
11
|
+
private readonly [argument];
|
|
12
|
+
readonly description: string;
|
|
13
|
+
constructor(description: string);
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
16
|
+
export declare function injectionToken<T, A = any>(description: string): InjectionToken<T, A>;
|
|
17
|
+
export declare function getTokenName(token: InjectionToken | undefined): string;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 token_exports = {};
|
|
20
|
+
__export(token_exports, {
|
|
21
|
+
ReifyingInjectionToken: () => ReifyingInjectionToken,
|
|
22
|
+
getTokenName: () => getTokenName,
|
|
23
|
+
injectionToken: () => injectionToken
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(token_exports);
|
|
26
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
27
|
+
class ReifyingInjectionToken {
|
|
28
|
+
description;
|
|
29
|
+
constructor(description) {
|
|
30
|
+
this.description = description;
|
|
31
|
+
}
|
|
32
|
+
toString() {
|
|
33
|
+
return `InjectionToken["${this.description}"]`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function injectionToken(description) {
|
|
37
|
+
return new ReifyingInjectionToken(description);
|
|
38
|
+
}
|
|
39
|
+
function getTokenName(token) {
|
|
40
|
+
return (0, import_type_guards.isFunction)(token) ? token.name : (0, import_type_guards.isString)(token) ? `"${token}"` : String(token);
|
|
41
|
+
}
|
package/api/client/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Injectable } from '../../container/index.js';
|
|
2
1
|
import type { HttpClientOptions } from '../../http/client/index.js';
|
|
3
2
|
import { HttpClient } from '../../http/client/index.js';
|
|
3
|
+
import type { Resolvable } from '../../injector/interfaces.js';
|
|
4
4
|
import type { ApiClientImplementation, ApiDefinition, ApiEndpointDefinition } from '../types.js';
|
|
5
|
-
export type ApiClient<T extends ApiDefinition> = new (httpClient: HttpClient) => ApiClientImplementation<T> &
|
|
5
|
+
export type ApiClient<T extends ApiDefinition> = new (httpClient: HttpClient) => ApiClientImplementation<T> & Resolvable<HttpClientOptions>;
|
|
6
6
|
export type ClientOptions = {
|
|
7
7
|
/**
|
|
8
8
|
* url prefix
|
package/api/client/client.js
CHANGED
|
@@ -23,9 +23,11 @@ __export(client_exports, {
|
|
|
23
23
|
httpClientSymbol: () => httpClientSymbol
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(client_exports);
|
|
26
|
-
var import_container = require("../../container/index.js");
|
|
27
26
|
var import_client = require("../../http/client/index.js");
|
|
28
27
|
var import_types = require("../../http/types.js");
|
|
28
|
+
var import_inject = require("../../injector/inject.js");
|
|
29
|
+
var import_injector = require("../../injector/injector.js");
|
|
30
|
+
var import_interfaces = require("../../injector/interfaces.js");
|
|
29
31
|
var import_schema = require("../../schema/index.js");
|
|
30
32
|
var import_server_sent_events = require("../../sse/server-sent-events.js");
|
|
31
33
|
var import_array = require("../../utils/array/array.js");
|
|
@@ -46,12 +48,12 @@ function compileClient(definition, options = {}) {
|
|
|
46
48
|
[httpClientSymbol];
|
|
47
49
|
[apiDefinitionSymbol];
|
|
48
50
|
constructor(httpClientOrOptions) {
|
|
49
|
-
this[httpClientSymbol] = httpClientOrOptions instanceof import_client.HttpClient ? httpClientOrOptions :
|
|
51
|
+
this[httpClientSymbol] = httpClientOrOptions instanceof import_client.HttpClient ? httpClientOrOptions : (0, import_inject.inject)(import_client.HttpClient, httpClientOrOptions);
|
|
50
52
|
this[apiDefinitionSymbol] = definition;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}[apiName];
|
|
54
|
-
|
|
56
|
+
import_injector.Injector.registerSingleton(api, {
|
|
55
57
|
useFactory: (argument, context) => {
|
|
56
58
|
const httpClient = argument instanceof import_client.HttpClient ? argument : context.resolve(import_client.HttpClient, argument ?? options.defaultHttpClientOptions);
|
|
57
59
|
return new api(httpClient);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { InjectableOptionsWithoutLifecycle } from '../../
|
|
1
|
+
import type { InjectableOptionsWithoutLifecycle } from '../../injector/decorators.js';
|
|
2
2
|
import type { Constructor, Type } from '../../types.js';
|
|
3
3
|
import type { ApiController, ApiDefinition } from '../types.js';
|
|
4
4
|
type ApiDefinitionProvider = () => ApiDefinition;
|
|
5
5
|
export declare const apiControllerDefinition: unique symbol;
|
|
6
|
-
export declare function getApiControllerDefinition(controller: Type): ApiDefinition;
|
|
6
|
+
export declare function getApiControllerDefinition(controller: Type | ApiController): ApiDefinition;
|
|
7
7
|
export declare function isApiController(controller: Type): boolean;
|
|
8
8
|
export declare function ensureApiController(controller: Type): void;
|
|
9
9
|
export declare function apiController<T = Type<ApiController>, A = any>(definition: ApiDefinition | ApiDefinitionProvider, injectableOptions?: InjectableOptionsWithoutLifecycle<T, A>): ClassDecorator;
|
|
@@ -26,14 +26,15 @@ __export(api_controller_exports, {
|
|
|
26
26
|
isApiController: () => isApiController
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(api_controller_exports);
|
|
29
|
-
var
|
|
29
|
+
var import_decorators = require("../../injector/decorators.js");
|
|
30
30
|
var import_object = require("../../utils/object/object.js");
|
|
31
31
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
32
32
|
const apiControllerDefinition = Symbol("ApiController definition");
|
|
33
33
|
const registeredApiControllers = /* @__PURE__ */ new Map();
|
|
34
34
|
function getApiControllerDefinition(controller) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const controllerType = (0, import_type_guards.isFunction)(controller) ? controller : controller.constructor;
|
|
36
|
+
ensureApiController(controllerType);
|
|
37
|
+
const definitionOrProvider = registeredApiControllers.get(controllerType);
|
|
37
38
|
if ((0, import_type_guards.isFunction)(definitionOrProvider)) {
|
|
38
39
|
return definitionOrProvider();
|
|
39
40
|
}
|
|
@@ -50,7 +51,7 @@ function ensureApiController(controller) {
|
|
|
50
51
|
function apiController(definition, injectableOptions = {}) {
|
|
51
52
|
function apiControllerDecorator(constructor) {
|
|
52
53
|
registeredApiControllers.set(constructor, definition);
|
|
53
|
-
(0,
|
|
54
|
+
(0, import_decorators.Singleton)(injectableOptions)(constructor);
|
|
54
55
|
}
|
|
55
56
|
return apiControllerDecorator;
|
|
56
57
|
}
|
|
@@ -22,7 +22,7 @@ __export(api_request_token_provider_exports, {
|
|
|
22
22
|
NoopApiRequestTokenProvider: () => NoopApiRequestTokenProvider
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(api_request_token_provider_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_decorators = require("../../injector/decorators.js");
|
|
26
26
|
var __decorate = function(decorators, target, key, desc) {
|
|
27
27
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
28
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -41,5 +41,5 @@ let NoopApiRequestTokenProvider = class NoopApiRequestTokenProvider2 extends Api
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
NoopApiRequestTokenProvider = __decorate([
|
|
44
|
-
(0,
|
|
44
|
+
(0, import_decorators.Singleton)({ alias: ApiRequestTokenProvider })
|
|
45
45
|
], NoopApiRequestTokenProvider);
|
package/api/server/gateway.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'urlpattern-polyfill';
|
|
2
|
-
import type { Injectable } from '../../container/index.js';
|
|
3
|
-
import { resolveArgumentType } from '../../container/index.js';
|
|
4
2
|
import type { HttpServerRequestContext } from '../../http/server/http-server.js';
|
|
5
3
|
import type { HttpServerRequest } from '../../http/server/index.js';
|
|
6
4
|
import { HttpServerResponse } from '../../http/server/index.js';
|
|
5
|
+
import type { Resolvable } from '../../injector/index.js';
|
|
6
|
+
import { resolveArgumentType } from '../../injector/index.js';
|
|
7
7
|
import { Logger } from '../../logger/index.js';
|
|
8
8
|
import type { Type } from '../../types.js';
|
|
9
9
|
import type { AsyncMiddleware, AsyncMiddlewareNext } from '../../utils/middleware.js';
|
|
@@ -18,7 +18,7 @@ export type ApiGatewayMiddlewareContext = {
|
|
|
18
18
|
};
|
|
19
19
|
export type ApiGatewayMiddlewareNext = AsyncMiddlewareNext<HttpServerRequest, HttpServerResponse>;
|
|
20
20
|
export type ApiGatewayMiddleware = AsyncMiddleware<HttpServerRequest, HttpServerResponse, ApiGatewayMiddlewareContext>;
|
|
21
|
-
export
|
|
21
|
+
export declare abstract class ApiGatewayOptions {
|
|
22
22
|
/**
|
|
23
23
|
* Api prefix. Pass `null` to disable prefix.
|
|
24
24
|
* @default api
|
|
@@ -35,7 +35,7 @@ export type ApiGatewayOptions = {
|
|
|
35
35
|
* @default 10 MB
|
|
36
36
|
*/
|
|
37
37
|
defaultMaxBytes?: number;
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
export type GatewayEndpoint = {
|
|
40
40
|
definition: ApiEndpointDefinition;
|
|
41
41
|
implementation: ApiEndpointServerImplementation;
|
|
@@ -55,7 +55,7 @@ export type ApiMetadata = {
|
|
|
55
55
|
* router for {@link ApiTransport} requests to {@link ApiImplementation}
|
|
56
56
|
* @todo error handling (standardized format, serialization etc.)
|
|
57
57
|
*/
|
|
58
|
-
export declare class ApiGateway implements
|
|
58
|
+
export declare class ApiGateway implements Resolvable<ApiGatewayOptions> {
|
|
59
59
|
private readonly requestTokenProvider;
|
|
60
60
|
private readonly logger;
|
|
61
61
|
private readonly prefix;
|
|
@@ -69,7 +69,6 @@ export declare class ApiGateway implements Injectable<ApiGatewayOptions> {
|
|
|
69
69
|
constructor(requestTokenProvider: ApiRequestTokenProvider, logger: Logger, options?: ApiGatewayOptions);
|
|
70
70
|
addMiddleware(middleware: ApiGatewayMiddleware): void;
|
|
71
71
|
supressErrors(...errorTypes: Type<Error>[]): void;
|
|
72
|
-
registerApiController(controller: Type): Promise<void>;
|
|
73
72
|
registerApi<T extends ApiDefinition>(definition: ApiDefinition, implementation: ApiController<T>): void;
|
|
74
73
|
handleHttpServerRequestContext({ request, respond, close }: HttpServerRequestContext): Promise<void>;
|
|
75
74
|
getApiMetadata(resource: URL): ApiMetadata;
|
package/api/server/gateway.js
CHANGED
|
@@ -18,15 +18,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var gateway_exports = {};
|
|
20
20
|
__export(gateway_exports, {
|
|
21
|
-
ApiGateway: () => ApiGateway
|
|
21
|
+
ApiGateway: () => ApiGateway,
|
|
22
|
+
ApiGatewayOptions: () => ApiGatewayOptions
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(gateway_exports);
|
|
24
25
|
var import_urlpattern_polyfill = require("urlpattern-polyfill");
|
|
25
|
-
var import_container = require("../../container/index.js");
|
|
26
26
|
var import_bad_request_error = require("../../error/bad-request.error.js");
|
|
27
27
|
var import_not_found_error = require("../../error/not-found.error.js");
|
|
28
28
|
var import_not_implemented_error = require("../../error/not-implemented.error.js");
|
|
29
29
|
var import_server = require("../../http/server/index.js");
|
|
30
|
+
var import_injector = require("../../injector/index.js");
|
|
30
31
|
var import_logger = require("../../logger/index.js");
|
|
31
32
|
var import_schema = require("../../schema/index.js");
|
|
32
33
|
var import_server_sent_events_source = require("../../sse/server-sent-events-source.js");
|
|
@@ -37,7 +38,6 @@ var import_type_guards = require("../../utils/type-guards.js");
|
|
|
37
38
|
var import_units = require("../../utils/units.js");
|
|
38
39
|
var import_types = require("../types.js");
|
|
39
40
|
var import_utils = require("../utils.js");
|
|
40
|
-
var import_api_controller = require("./api-controller.js");
|
|
41
41
|
var import_api_request_token_provider = require("./api-request-token.provider.js");
|
|
42
42
|
var import_error_handler = require("./error-handler.js");
|
|
43
43
|
var import_middlewares = require("./middlewares/index.js");
|
|
@@ -62,6 +62,24 @@ var __param = function(paramIndex, decorator) {
|
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
const defaultMaxBytes = 10 * import_units.mebibyte;
|
|
65
|
+
class ApiGatewayOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Api prefix. Pass `null` to disable prefix.
|
|
68
|
+
* @default api
|
|
69
|
+
*/
|
|
70
|
+
prefix;
|
|
71
|
+
/** Initial middlewares */
|
|
72
|
+
middlewares;
|
|
73
|
+
/** Errors to supress in log output */
|
|
74
|
+
supressedErrors;
|
|
75
|
+
/** Cors middleware options */
|
|
76
|
+
cors;
|
|
77
|
+
/**
|
|
78
|
+
* Maximum size of request body. Useful to prevent harmful requests.
|
|
79
|
+
* @default 10 MB
|
|
80
|
+
*/
|
|
81
|
+
defaultMaxBytes;
|
|
82
|
+
}
|
|
65
83
|
let ApiGateway = class ApiGateway2 {
|
|
66
84
|
requestTokenProvider;
|
|
67
85
|
logger;
|
|
@@ -92,11 +110,6 @@ let ApiGateway = class ApiGateway2 {
|
|
|
92
110
|
this.supressedErrors.add(type);
|
|
93
111
|
}
|
|
94
112
|
}
|
|
95
|
-
async registerApiController(controller) {
|
|
96
|
-
const definition = (0, import_api_controller.getApiControllerDefinition)(controller);
|
|
97
|
-
const instance = await import_container.container.resolveAsync(controller);
|
|
98
|
-
this.registerApi(definition, instance);
|
|
99
|
-
}
|
|
100
113
|
registerApi(definition, implementation) {
|
|
101
114
|
for (const [name, endpointDefinition] of (0, import_types.normalizedApiDefinitionEndpointsEntries)(definition.endpoints)) {
|
|
102
115
|
const versionArray = (0, import_type_guards.isUndefined)(endpointDefinition.version) ? [1] : (0, import_array.toArray)(endpointDefinition.version);
|
|
@@ -221,10 +234,10 @@ let ApiGateway = class ApiGateway2 {
|
|
|
221
234
|
}
|
|
222
235
|
};
|
|
223
236
|
ApiGateway = __decorate([
|
|
224
|
-
(0,
|
|
237
|
+
(0, import_injector.Singleton)({
|
|
225
238
|
defaultArgumentProvider: (context) => context.resolve(import_tokens.API_MODULE_OPTIONS).gatewayOptions
|
|
226
239
|
}),
|
|
227
|
-
__param(1, (0,
|
|
228
|
-
__param(2, (0,
|
|
229
|
-
__metadata("design:paramtypes", [import_api_request_token_provider.ApiRequestTokenProvider, import_logger.Logger,
|
|
240
|
+
__param(1, (0, import_injector.ResolveArg)("ApiGateway")),
|
|
241
|
+
__param(2, (0, import_injector.InjectArg)()),
|
|
242
|
+
__metadata("design:paramtypes", [import_api_request_token_provider.ApiRequestTokenProvider, import_logger.Logger, ApiGatewayOptions])
|
|
230
243
|
], ApiGateway);
|
package/api/server/module.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(module_exports, {
|
|
|
22
22
|
configureApiServer: () => configureApiServer
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(module_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_injector = require("../../injector/injector.js");
|
|
26
26
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
27
27
|
var import_api_controller = require("./api-controller.js");
|
|
28
28
|
var import_api_request_token_provider = require("./api-request-token.provider.js");
|
|
@@ -34,12 +34,12 @@ function configureApiServer(options) {
|
|
|
34
34
|
if ((0, import_type_guards.isDefined)(options.controllers)) {
|
|
35
35
|
for (const controller of options.controllers) {
|
|
36
36
|
(0, import_api_controller.ensureApiController)(controller);
|
|
37
|
+
import_injector.Injector.register(import_tokens.API_CONTROLLER, { useToken: controller }, { multi: true });
|
|
37
38
|
}
|
|
38
|
-
apiModuleOptions.controllers = options.controllers;
|
|
39
39
|
}
|
|
40
40
|
if ((0, import_type_guards.isDefined)(options.requestTokenProvider)) {
|
|
41
|
-
|
|
41
|
+
import_injector.Injector.register(import_api_request_token_provider.ApiRequestTokenProvider, { useToken: options.requestTokenProvider });
|
|
42
42
|
}
|
|
43
43
|
apiModuleOptions.gatewayOptions = options.gatewayOptions ?? apiModuleOptions.gatewayOptions;
|
|
44
|
-
|
|
44
|
+
import_injector.Injector.register(import_tokens.API_MODULE_OPTIONS, { useValue: apiModuleOptions });
|
|
45
45
|
}
|
package/api/server/tokens.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import type { ApiController } from '../types.js';
|
|
1
2
|
import type { ApiModuleOptions } from './module.js';
|
|
2
|
-
export declare const API_MODULE_OPTIONS: import("../../
|
|
3
|
+
export declare const API_MODULE_OPTIONS: import("../../injector/token.js").InjectionToken<ApiModuleOptions, never>;
|
|
4
|
+
export declare const API_CONTROLLER: import("../../injector/token.js").InjectionToken<ApiController, never>;
|
|
5
|
+
export declare const API_CONTROLLERS: import("../../injector/token.js").InjectionToken<ApiController[], never>;
|
package/api/server/tokens.js
CHANGED
|
@@ -18,8 +18,14 @@ 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
|
+
API_CONTROLLER: () => API_CONTROLLER,
|
|
22
|
+
API_CONTROLLERS: () => API_CONTROLLERS,
|
|
21
23
|
API_MODULE_OPTIONS: () => API_MODULE_OPTIONS
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(tokens_exports);
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
+
var import_injector = require("../../injector/injector.js");
|
|
27
|
+
var import_token = require("../../injector/token.js");
|
|
28
|
+
const API_MODULE_OPTIONS = (0, import_token.injectionToken)("ApiModuleOptions");
|
|
29
|
+
const API_CONTROLLER = (0, import_token.injectionToken)("ApiController");
|
|
30
|
+
const API_CONTROLLERS = (0, import_token.injectionToken)("ApiControllers");
|
|
31
|
+
import_injector.Injector.register(API_CONTROLLERS, { useToken: API_CONTROLLER, resolveAll: true });
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Resolvable } from '../injector/interfaces.js';
|
|
2
|
+
import { resolveArgumentType } from '../injector/interfaces.js';
|
|
3
|
+
import type { LoggerArgument } from '../logger/index.js';
|
|
2
4
|
import type { Module } from '../module/module.js';
|
|
3
5
|
import type { FunctionModuleFunction } from '../module/modules/function.module.js';
|
|
4
6
|
import type { OneOrMany, Type } from '../types.js';
|
|
5
7
|
import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
+
export type BootstrapFn = () => void | Promise<void>;
|
|
9
|
+
export type RunOptions = {
|
|
10
|
+
bootstrap?: BootstrapFn;
|
|
11
|
+
};
|
|
12
|
+
export declare class Application implements Resolvable<LoggerArgument> {
|
|
13
|
+
#private;
|
|
14
|
+
static _instance: Application | undefined;
|
|
8
15
|
private static get instance();
|
|
9
|
-
|
|
10
|
-
private readonly moduleTypesAndInstances;
|
|
11
|
-
private readonly shutdownPromise;
|
|
12
|
-
private readonly _shutdownToken;
|
|
16
|
+
readonly [resolveArgumentType]: string;
|
|
13
17
|
get shutdownToken(): ReadonlyCancellationToken;
|
|
14
18
|
static get shutdownToken(): ReadonlyCancellationToken;
|
|
15
|
-
constructor(logger: Logger);
|
|
16
19
|
static registerModule(moduleType: Type<Module>): void;
|
|
17
20
|
static registerModuleFunction(fn: FunctionModuleFunction): void;
|
|
18
|
-
static run(...functionsAndModules: OneOrMany<FunctionModuleFunction | Type<Module>>[]): void;
|
|
21
|
+
static run(...functionsAndModules: [RunOptions | OneOrMany<FunctionModuleFunction | Type<Module>>, ...OneOrMany<FunctionModuleFunction | Type<Module>>[]]): void;
|
|
19
22
|
static waitForShutdown(): Promise<void>;
|
|
20
23
|
static shutdown(): Promise<void>;
|
|
21
24
|
static requestShutdown(): void;
|
|
22
25
|
registerModule(moduleType: Module | Type<Module>): void;
|
|
23
26
|
registerModuleFunction(fn: FunctionModuleFunction): void;
|
|
24
|
-
run(...
|
|
27
|
+
run(...optionsFunctionsAndModules: [RunOptions | OneOrMany<FunctionModuleFunction | Type<Module>>, ...OneOrMany<FunctionModuleFunction | Type<Module>>[]]): void;
|
|
25
28
|
shutdown(): Promise<void>;
|
|
26
29
|
requestShutdown(): void;
|
|
27
30
|
waitForShutdown(): Promise<void>;
|