@tstdl/base 0.92.166 → 0.92.168
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/api/server/middlewares/content-type.middleware.js +1 -1
- package/application/application.d.ts +12 -18
- package/application/application.js +48 -69
- package/application/index.d.ts +1 -5
- package/application/index.js +1 -5
- package/application/providers.d.ts +10 -0
- package/application/providers.js +54 -0
- package/authentication/client/authentication.service.d.ts +1 -3
- package/authentication/client/authentication.service.js +4 -5
- package/browser/browser-context-controller.d.ts +2 -4
- package/browser/browser-context-controller.js +5 -6
- package/browser/browser-controller.d.ts +2 -4
- package/browser/browser-controller.js +3 -4
- package/browser/browser.service.d.ts +1 -3
- package/browser/browser.service.js +1 -2
- package/browser/page-controller.d.ts +2 -4
- package/browser/page-controller.js +7 -8
- package/browser/utils.js +3 -3
- package/cancellation/token.d.ts +104 -41
- package/cancellation/token.js +125 -54
- package/core.d.ts +1 -13
- package/core.js +1 -46
- package/disposable/disposable.d.ts +0 -8
- package/disposable/disposable.js +1 -3
- package/disposable/index.d.ts +0 -6
- package/disposable/index.js +0 -6
- package/disposable/using.d.ts +0 -1
- package/disposable/using.js +2 -3
- package/distributed-loop/distributed-loop.js +2 -2
- package/errors/utils.js +4 -1
- package/examples/api/authentication.js +11 -5
- package/examples/api/basic-overview.js +17 -12
- package/examples/api/custom-authentication.js +13 -7
- package/examples/api/streaming.js +15 -12
- package/examples/browser/basic.js +6 -3
- package/examples/document-management/main.js +6 -3
- package/examples/http/client.js +7 -3
- package/examples/mail/basic.js +9 -7
- package/examples/pdf/basic.js +8 -6
- package/examples/template/basic.js +7 -5
- package/http/client/http-client-request.d.ts +1 -2
- package/http/client/http-client-request.js +1 -2
- package/http/server/http-server.d.ts +1 -3
- package/http/server/http-server.js +0 -1
- package/http/server/node/node-http-server.d.ts +1 -2
- package/http/server/node/node-http-server.js +1 -2
- package/import.js +1 -1
- package/injector/injector.d.ts +1 -1
- package/injector/types.d.ts +3 -4
- package/lock/lock.d.ts +40 -21
- package/lock/lock.js +74 -1
- package/lock/postgres/drizzle/0000_busy_tattoo.sql +7 -0
- package/lock/postgres/drizzle/meta/0000_snapshot.json +65 -0
- package/lock/postgres/drizzle/meta/_journal.json +13 -0
- package/lock/postgres/drizzle.config.js +11 -0
- package/lock/postgres/index.d.ts +2 -0
- package/lock/postgres/index.js +2 -0
- package/lock/postgres/lock.d.ts +14 -0
- package/lock/postgres/lock.js +127 -0
- package/lock/postgres/models/index.d.ts +2 -0
- package/lock/postgres/models/index.js +2 -0
- package/lock/postgres/models/lock.model.d.ts +7 -0
- package/{examples/orm/user.model.js → lock/postgres/models/lock.model.js} +22 -30
- package/lock/postgres/models/schemas.d.ts +3 -0
- package/lock/postgres/models/schemas.js +4 -0
- package/lock/postgres/module.d.ts +6 -0
- package/lock/postgres/module.js +26 -0
- package/lock/postgres/provider.d.ts +6 -0
- package/lock/postgres/provider.js +29 -0
- package/lock/provider.d.ts +12 -2
- package/lock/provider.js +24 -1
- package/lock/web/web-lock.d.ts +4 -3
- package/lock/web/web-lock.js +49 -42
- package/lock/web/web-lock.provider.d.ts +0 -3
- package/lock/web/web-lock.provider.js +5 -22
- package/logger/formatter.d.ts +13 -0
- package/logger/formatter.js +3 -0
- package/logger/formatters/index.d.ts +2 -0
- package/logger/formatters/index.js +2 -0
- package/logger/formatters/json.d.ts +5 -0
- package/logger/formatters/json.js +33 -0
- package/logger/formatters/pretty-print.d.ts +5 -0
- package/logger/formatters/pretty-print.js +55 -0
- package/logger/index.d.ts +5 -2
- package/logger/index.js +5 -2
- package/logger/level.d.ts +10 -8
- package/logger/level.js +9 -9
- package/logger/logger.d.ts +21 -30
- package/logger/logger.js +98 -26
- package/logger/manager.d.ts +20 -0
- package/logger/manager.js +77 -0
- package/logger/tokens.d.ts +1 -1
- package/logger/tokens.js +1 -1
- package/logger/transport.d.ts +14 -0
- package/logger/transport.js +16 -0
- package/logger/transports/console.d.ts +14 -0
- package/logger/transports/console.js +36 -0
- package/logger/transports/index.d.ts +1 -0
- package/logger/transports/index.js +1 -0
- package/mail/clients/nodemailer.mail-client.d.ts +0 -1
- package/mail/clients/nodemailer.mail-client.js +9 -7
- package/message-bus/local/local-message-bus.js +2 -2
- package/message-bus/message-bus-base.d.ts +2 -3
- package/message-bus/message-bus-base.js +5 -6
- package/message-bus/message-bus.d.ts +1 -2
- package/message-bus/message-bus.js +1 -2
- package/module/index.d.ts +0 -2
- package/module/index.js +0 -2
- package/module/module.d.ts +17 -18
- package/module/module.js +47 -12
- package/module/modules/function.module.d.ts +6 -6
- package/module/modules/function.module.js +25 -9
- package/module/modules/web-server.module.d.ts +2 -10
- package/module/modules/web-server.module.js +3 -11
- package/openid-connect/index.d.ts +0 -2
- package/openid-connect/index.js +0 -2
- package/openid-connect/oidc-state.model.d.ts +4 -5
- package/openid-connect/oidc-state.model.js +51 -1
- package/openid-connect/oidc.service-model.d.ts +1 -1
- package/openid-connect/oidc.service.d.ts +2 -6
- package/openid-connect/oidc.service.js +24 -37
- package/orm/decorators.d.ts +10 -1
- package/orm/decorators.js +8 -0
- package/orm/server/repository.d.ts +3 -1
- package/orm/server/repository.js +32 -3
- package/package.json +17 -28
- package/pdf/pdf.service.js +9 -9
- package/pool/pool.d.ts +1 -3
- package/pool/pool.js +3 -4
- package/queue/postgres/job.model.d.ts +1 -2
- package/queue/postgres/job.model.js +1 -2
- package/queue/postgres/module.js +1 -1
- package/threading/thread-pool.d.ts +1 -3
- package/threading/thread-pool.js +7 -8
- package/utils/format-error.d.ts +7 -0
- package/utils/format-error.js +59 -17
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/object/dereference.d.ts +51 -19
- package/utils/object/dereference.js +52 -43
- package/utils/timing.js +2 -2
- package/utils/try-chain.d.ts +22 -0
- package/utils/try-chain.js +46 -0
- package/database/entity-repository.d.ts +0 -50
- package/database/entity-repository.js +0 -3
- package/database/entity.d.ts +0 -7
- package/database/entity.js +0 -1
- package/database/id.d.ts +0 -1
- package/database/id.js +0 -9
- package/database/index.d.ts +0 -11
- package/database/index.js +0 -11
- package/database/module.d.ts +0 -8
- package/database/module.js +0 -11
- package/database/mongo/classes.d.ts +0 -21
- package/database/mongo/classes.js +0 -26
- package/database/mongo/index.d.ts +0 -15
- package/database/mongo/index.js +0 -15
- package/database/mongo/model/document.d.ts +0 -29
- package/database/mongo/model/document.js +0 -63
- package/database/mongo/model/index.d.ts +0 -1
- package/database/mongo/model/index.js +0 -1
- package/database/mongo/module.d.ts +0 -8
- package/database/mongo/module.js +0 -68
- package/database/mongo/mongo-base.repository.d.ts +0 -103
- package/database/mongo/mongo-base.repository.js +0 -263
- package/database/mongo/mongo-bulk.d.ts +0 -35
- package/database/mongo/mongo-bulk.js +0 -90
- package/database/mongo/mongo-entity-repository.d.ts +0 -98
- package/database/mongo/mongo-entity-repository.js +0 -278
- package/database/mongo/operations.d.ts +0 -10
- package/database/mongo/operations.js +0 -54
- package/database/mongo/query-converter.d.ts +0 -6
- package/database/mongo/query-converter.js +0 -83
- package/database/mongo/simple-entity-repository.d.ts +0 -7
- package/database/mongo/simple-entity-repository.js +0 -6
- package/database/mongo/types.d.ts +0 -50
- package/database/mongo/types.js +0 -3
- package/database/query.d.ts +0 -121
- package/database/query.js +0 -7
- package/database/utils.d.ts +0 -2
- package/database/utils.js +0 -3
- package/disposable/async-disposer.d.ts +0 -35
- package/disposable/async-disposer.js +0 -125
- package/examples/orm/drizzle.config.js +0 -6
- package/examples/orm/schemas.d.ts +0 -3
- package/examples/orm/schemas.js +0 -4
- package/examples/orm/test.d.ts +0 -1
- package/examples/orm/test.js +0 -11
- package/examples/orm/user.model.d.ts +0 -13
- package/key-value-store/mongo/index.d.ts +0 -6
- package/key-value-store/mongo/index.js +0 -6
- package/key-value-store/mongo/module.d.ts +0 -8
- package/key-value-store/mongo/module.js +0 -18
- package/key-value-store/mongo/mongo-key-value-store.provider.d.ts +0 -8
- package/key-value-store/mongo/mongo-key-value-store.provider.js +0 -26
- package/key-value-store/mongo/mongo-key-value.model.d.ts +0 -7
- package/key-value-store/mongo/mongo-key-value.model.js +0 -1
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +0 -10
- package/key-value-store/mongo/mongo-key-value.repository.js +0 -31
- package/key-value-store/mongo/mongo-key-value.store.d.ts +0 -15
- package/key-value-store/mongo/mongo-key-value.store.js +0 -82
- package/key-value-store/mongo/tokens.d.ts +0 -3
- package/key-value-store/mongo/tokens.js +0 -2
- package/lock/mongo/index.d.ts +0 -5
- package/lock/mongo/index.js +0 -5
- package/lock/mongo/lock.d.ts +0 -14
- package/lock/mongo/lock.js +0 -125
- package/lock/mongo/model.d.ts +0 -6
- package/lock/mongo/model.js +0 -1
- package/lock/mongo/module.d.ts +0 -12
- package/lock/mongo/module.js +0 -20
- package/lock/mongo/mongo-lock-repository.d.ts +0 -14
- package/lock/mongo/mongo-lock-repository.js +0 -67
- package/lock/mongo/provider.d.ts +0 -8
- package/lock/mongo/provider.js +0 -36
- package/logger/console/index.d.ts +0 -1
- package/logger/console/index.js +0 -1
- package/logger/console/logger.d.ts +0 -11
- package/logger/console/logger.js +0 -64
- package/logger/noop/index.d.ts +0 -1
- package/logger/noop/index.js +0 -1
- package/logger/noop/logger.d.ts +0 -9
- package/logger/noop/logger.js +0 -21
- package/migration/index.d.ts +0 -9
- package/migration/index.js +0 -9
- package/migration/migration-state-repository.d.ts +0 -4
- package/migration/migration-state-repository.js +0 -3
- package/migration/migration-state.d.ts +0 -6
- package/migration/migration-state.js +0 -1
- package/migration/migrator.d.ts +0 -23
- package/migration/migrator.js +0 -76
- package/migration/mongo/index.d.ts +0 -2
- package/migration/mongo/index.js +0 -2
- package/migration/mongo/migration-state-repository.d.ts +0 -11
- package/migration/mongo/migration-state-repository.js +0 -32
- package/migration/mongo/module.d.ts +0 -12
- package/migration/mongo/module.js +0 -17
- package/module/module-base.d.ts +0 -18
- package/module/module-base.js +0 -40
- package/module/module-metric-reporter.d.ts +0 -29
- package/module/module-metric-reporter.js +0 -62
- package/openid-connect/mongo-oidc-state.repository.d.ts +0 -21
- package/openid-connect/mongo-oidc-state.repository.js +0 -52
- package/openid-connect/oidc-state.repository.d.ts +0 -4
- package/openid-connect/oidc-state.repository.js +0 -3
- package/process-shutdown.d.ts +0 -9
- package/process-shutdown.js +0 -65
- package/queue/mongo/index.d.ts +0 -4
- package/queue/mongo/index.js +0 -4
- package/queue/mongo/job.d.ts +0 -12
- package/queue/mongo/job.js +0 -1
- package/queue/mongo/mongo-job.repository.d.ts +0 -13
- package/queue/mongo/mongo-job.repository.js +0 -54
- package/queue/mongo/queue.d.ts +0 -38
- package/queue/mongo/queue.js +0 -266
- package/queue/mongo/queue.provider.d.ts +0 -18
- package/queue/mongo/queue.provider.js +0 -38
- package/search-index/elastic/config.d.ts +0 -8
- package/search-index/elastic/config.js +0 -26
- package/search-index/elastic/index.d.ts +0 -8
- package/search-index/elastic/index.js +0 -8
- package/search-index/elastic/keyword-rewriter.d.ts +0 -8
- package/search-index/elastic/keyword-rewriter.js +0 -18
- package/search-index/elastic/model/elastic-query.d.ts +0 -16
- package/search-index/elastic/model/elastic-query.js +0 -1
- package/search-index/elastic/model/index-mapping.d.ts +0 -26
- package/search-index/elastic/model/index-mapping.js +0 -4
- package/search-index/elastic/model/index.d.ts +0 -3
- package/search-index/elastic/model/index.js +0 -3
- package/search-index/elastic/model/sort.d.ts +0 -8
- package/search-index/elastic/model/sort.js +0 -1
- package/search-index/elastic/module.d.ts +0 -10
- package/search-index/elastic/module.js +0 -49
- package/search-index/elastic/query-builder/boolean-query-builder.d.ts +0 -11
- package/search-index/elastic/query-builder/boolean-query-builder.js +0 -52
- package/search-index/elastic/query-builder/index.d.ts +0 -1
- package/search-index/elastic/query-builder/index.js +0 -1
- package/search-index/elastic/query-converter.d.ts +0 -9
- package/search-index/elastic/query-converter.js +0 -183
- package/search-index/elastic/search-index.d.ts +0 -30
- package/search-index/elastic/search-index.js +0 -144
- package/search-index/elastic/sort-converter.d.ts +0 -4
- package/search-index/elastic/sort-converter.js +0 -14
- package/search-index/elastic/types.d.ts +0 -5
- package/search-index/elastic/types.js +0 -1
- package/search-index/error.d.ts +0 -10
- package/search-index/error.js +0 -14
- package/search-index/index.d.ts +0 -3
- package/search-index/index.js +0 -3
- package/search-index/memory/index.d.ts +0 -1
- package/search-index/memory/index.js +0 -1
- package/search-index/memory/memory-search-index.d.ts +0 -19
- package/search-index/memory/memory-search-index.js +0 -144
- package/search-index/search-index.d.ts +0 -46
- package/search-index/search-index.js +0 -31
- package/search-index/search-result.d.ts +0 -12
- package/search-index/search-result.js +0 -1
- package/theme/adapters/css-adapter.d.ts +0 -5
- package/theme/adapters/css-adapter.js +0 -29
- package/theme/adapters/index.d.ts +0 -2
- package/theme/adapters/index.js +0 -2
- package/theme/adapters/tailwind-adapter.d.ts +0 -18
- package/theme/adapters/tailwind-adapter.js +0 -32
- package/theme/index.d.ts +0 -1
- package/theme/index.js +0 -1
- package/theme/theme-service.d.ts +0 -43
- package/theme/theme-service.js +0 -128
- /package/{examples/orm → lock/postgres}/drizzle.config.d.ts +0 -0
package/disposable/using.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { AsyncDisposable, Disposable } from './disposable.js';
|
|
2
1
|
export declare function using<T extends Disposable, U>(disposable: T, user: (disposable: T) => U): U;
|
|
3
2
|
export declare function usingAsync<T extends AsyncDisposable, U>(disposable: T, user: (disposable: T) => U | Promise<U>): Promise<U>;
|
package/disposable/using.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { dispose, disposeAsync } from './disposable.js';
|
|
2
1
|
export function using(disposable, user) {
|
|
3
2
|
try {
|
|
4
3
|
return user(disposable);
|
|
5
4
|
}
|
|
6
5
|
finally {
|
|
7
|
-
disposable[dispose]();
|
|
6
|
+
disposable[Symbol.dispose]();
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
9
|
export async function usingAsync(disposable, user) {
|
|
@@ -12,6 +11,6 @@ export async function usingAsync(disposable, user) {
|
|
|
12
11
|
return await user(disposable);
|
|
13
12
|
}
|
|
14
13
|
finally {
|
|
15
|
-
await disposable[
|
|
14
|
+
await disposable[Symbol.asyncDispose]();
|
|
16
15
|
}
|
|
17
16
|
}
|
|
@@ -51,7 +51,7 @@ let DistributedLoop = class DistributedLoop {
|
|
|
51
51
|
};
|
|
52
52
|
const controller = {
|
|
53
53
|
stop: stopFunction,
|
|
54
|
-
$stopped
|
|
54
|
+
$stopped,
|
|
55
55
|
};
|
|
56
56
|
void (async () => {
|
|
57
57
|
const lock = this.lockProvider.get(this.key);
|
|
@@ -59,7 +59,7 @@ let DistributedLoop = class DistributedLoop {
|
|
|
59
59
|
try {
|
|
60
60
|
while (!stopToken.isSet) {
|
|
61
61
|
timer.restart();
|
|
62
|
-
await lock.
|
|
62
|
+
await lock.tryUse(undefined, async () => {
|
|
63
63
|
await func(controller);
|
|
64
64
|
const timeLeft = interval - timer.milliseconds;
|
|
65
65
|
const timeoutDuration = timeLeft - (accuracy / 2);
|
package/errors/utils.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export function unwrapError(error) {
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
3
3
|
const wrappedError = error?.rejection ?? error?.reason ?? error?.error;
|
|
4
|
+
// If the original error is a real Error, prefer it unless it's a generic
|
|
5
|
+
// "Uncaught" wrapper around another, more specific Error.
|
|
4
6
|
if ((error instanceof Error) && !(error.message.startsWith('Uncaught') && (wrappedError instanceof Error))) {
|
|
5
7
|
return error;
|
|
6
8
|
}
|
|
7
|
-
|
|
9
|
+
// Fall back to the original error if no wrapped error was found.
|
|
10
|
+
return wrappedError ?? error;
|
|
8
11
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import '../../polyfills.js';
|
|
3
3
|
import { configureApiServer } from '../../api/server/index.js';
|
|
4
4
|
import { Application } from '../../application/application.js';
|
|
5
|
+
import { provideInitializer, provideModules, provideSignalHandler } from '../../application/index.js';
|
|
5
6
|
import { AuthenticationApiClient } from '../../authentication/client/api.client.js';
|
|
6
7
|
import { AuthenticationClientService, configureAuthenticationClient } from '../../authentication/client/index.js';
|
|
7
8
|
import { AuthenticationApiController, AuthenticationService as AuthenticationServerService, configureAuthenticationServer } from '../../authentication/server/index.js';
|
|
@@ -28,24 +29,29 @@ async function clientTest() {
|
|
|
28
29
|
authenticationService.token$.subscribe((token) => console.log({ token }));
|
|
29
30
|
}
|
|
30
31
|
async function test() {
|
|
32
|
+
const application = inject(Application);
|
|
31
33
|
await Promise.all([
|
|
32
34
|
serverTest(),
|
|
33
|
-
clientTest()
|
|
35
|
+
clientTest(),
|
|
34
36
|
]);
|
|
35
|
-
await
|
|
37
|
+
await application.shutdown();
|
|
36
38
|
}
|
|
37
39
|
function bootstrap() {
|
|
38
40
|
configureDefaultSignalsImplementation();
|
|
39
41
|
configureAuthenticationServer({
|
|
40
|
-
serviceOptions: { secret: 'djp0fq23576aq' }
|
|
42
|
+
serviceOptions: { secret: 'djp0fq23576aq' },
|
|
41
43
|
});
|
|
42
44
|
configureLocalMessageBus();
|
|
43
45
|
configureAuthenticationClient({
|
|
44
|
-
authenticationApiClient: AuthenticationApiClient
|
|
46
|
+
authenticationApiClient: AuthenticationApiClient,
|
|
45
47
|
});
|
|
46
48
|
configureNodeHttpServer();
|
|
47
49
|
configureApiServer({ controllers: [AuthenticationApiController] });
|
|
48
50
|
configureUndiciHttpClientAdapter({ dispatcher: new Agent({ keepAliveMaxTimeout: 1 }) });
|
|
49
51
|
configureHttpClient({ baseUrl: 'http://localhost:8000' });
|
|
50
52
|
}
|
|
51
|
-
Application.run(
|
|
53
|
+
Application.run('Test', [
|
|
54
|
+
provideModules(WebServerModule, test),
|
|
55
|
+
provideInitializer(bootstrap),
|
|
56
|
+
provideSignalHandler(),
|
|
57
|
+
]);
|
|
@@ -13,6 +13,7 @@ import { compileClient } from '../../api/client/index.js';
|
|
|
13
13
|
import { defineApi } from '../../api/index.js';
|
|
14
14
|
import { apiController, configureApiServer } from '../../api/server/index.js';
|
|
15
15
|
import { Application } from '../../application/application.js';
|
|
16
|
+
import { provideInitializer, provideModules, provideSignalHandler } from '../../application/index.js';
|
|
16
17
|
import { configureUndiciHttpClientAdapter } from '../../http/client/adapters/undici.adapter.js';
|
|
17
18
|
import { configureHttpClient } from '../../http/client/module.js';
|
|
18
19
|
import { configureNodeHttpServer } from '../../http/server/node/module.js';
|
|
@@ -35,7 +36,7 @@ __decorate([
|
|
|
35
36
|
], User.prototype, "name", void 0);
|
|
36
37
|
const users = [
|
|
37
38
|
{ id: 1, name: 'Alice' },
|
|
38
|
-
{ id: 3, name: 'Bob' }
|
|
39
|
+
{ id: 3, name: 'Bob' },
|
|
39
40
|
];
|
|
40
41
|
const usersApiDefinition = defineApi({
|
|
41
42
|
resource: 'users', // /api/:version/users
|
|
@@ -45,22 +46,22 @@ const usersApiDefinition = defineApi({
|
|
|
45
46
|
resource: ':id', // => /api/v1/users/:id
|
|
46
47
|
version: 1,
|
|
47
48
|
parameters: object({
|
|
48
|
-
id: number({ coerce: true })
|
|
49
|
+
id: number({ coerce: true }),
|
|
49
50
|
}),
|
|
50
|
-
result: User
|
|
51
|
+
result: User,
|
|
51
52
|
},
|
|
52
53
|
loadAll: {
|
|
53
|
-
result: array(User)
|
|
54
|
+
result: array(User),
|
|
54
55
|
},
|
|
55
56
|
delete: {
|
|
56
57
|
method: 'DELETE',
|
|
57
58
|
resource: ':id', // => /api/v1/users/:id
|
|
58
59
|
parameters: object({
|
|
59
|
-
id: number({ coerce: true })
|
|
60
|
+
id: number({ coerce: true }),
|
|
60
61
|
}),
|
|
61
|
-
result: boolean()
|
|
62
|
-
}
|
|
63
|
-
}
|
|
62
|
+
result: boolean(),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
64
65
|
});
|
|
65
66
|
let UserApi = class UserApi {
|
|
66
67
|
load({ parameters }) {
|
|
@@ -83,6 +84,7 @@ UserApi = __decorate([
|
|
|
83
84
|
], UserApi);
|
|
84
85
|
const UserApiClient = compileClient(usersApiDefinition);
|
|
85
86
|
async function clientTest() {
|
|
87
|
+
const application = inject(Application);
|
|
86
88
|
const userApiClient = inject(UserApiClient);
|
|
87
89
|
await timeout(250); // allow server to start
|
|
88
90
|
const allUsers = await userApiClient.loadAll();
|
|
@@ -90,13 +92,16 @@ async function clientTest() {
|
|
|
90
92
|
await userApiClient.delete({ id: allUsers[0].id });
|
|
91
93
|
const allUsersAfterDelete = await userApiClient.loadAll();
|
|
92
94
|
console.log(allUsersAfterDelete);
|
|
93
|
-
|
|
95
|
+
application.requestShutdown();
|
|
94
96
|
}
|
|
95
|
-
function
|
|
97
|
+
function bootstrap() {
|
|
96
98
|
configureNodeHttpServer();
|
|
97
99
|
configureApiServer({ controllers: [UserApi] });
|
|
98
100
|
configureUndiciHttpClientAdapter({ dispatcher: new Agent({ keepAliveMaxTimeout: 1 }) });
|
|
99
101
|
configureHttpClient({ baseUrl: 'http://localhost:8000' });
|
|
100
|
-
Application.run(WebServerModule, clientTest);
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
+
Application.run('Test', [
|
|
104
|
+
provideInitializer(bootstrap),
|
|
105
|
+
provideModules(WebServerModule, clientTest),
|
|
106
|
+
provideSignalHandler(),
|
|
107
|
+
]);
|
|
@@ -12,6 +12,7 @@ import '../../polyfills.js';
|
|
|
12
12
|
import { Agent } from 'undici';
|
|
13
13
|
import { configureApiServer } from '../../api/server/index.js';
|
|
14
14
|
import { Application } from '../../application/application.js';
|
|
15
|
+
import { provideInitializer, provideModules, provideSignalHandler } from '../../application/index.js';
|
|
15
16
|
import { AuthenticationClientService, configureAuthenticationClient, getAuthenticationApiClient } from '../../authentication/index.js';
|
|
16
17
|
import { AuthenticationAncillaryService, AuthenticationApiController, AuthenticationService as AuthenticationServerService, configureAuthenticationServer } from '../../authentication/server/index.js';
|
|
17
18
|
import { configureUndiciHttpClientAdapter } from '../../http/client/adapters/undici.adapter.js';
|
|
@@ -84,35 +85,40 @@ async function serverTest() {
|
|
|
84
85
|
const authenticationService = await injectAsync(AuthenticationServerService);
|
|
85
86
|
await authenticationService.setCredentials('foobar', 'supersecret-dupidupudoo9275');
|
|
86
87
|
}
|
|
87
|
-
async function clientTest() {
|
|
88
|
+
async function clientTest(application) {
|
|
88
89
|
const authenticationService = inject(AuthenticationClientService);
|
|
89
90
|
await timeout(1500); // allow server to initialize
|
|
90
91
|
authenticationService.initialize();
|
|
91
92
|
await authenticationService.login('foobar', 'supersecret-dupidupudoo9275');
|
|
92
93
|
authenticationService.token$.subscribe((token) => console.log({ token }));
|
|
93
|
-
|
|
94
|
+
application.requestShutdown();
|
|
94
95
|
}
|
|
95
96
|
async function test() {
|
|
97
|
+
const application = inject(Application);
|
|
96
98
|
await Promise.all([
|
|
97
99
|
serverTest(),
|
|
98
|
-
clientTest()
|
|
100
|
+
clientTest(application),
|
|
99
101
|
]);
|
|
100
|
-
await
|
|
102
|
+
await application.shutdown();
|
|
101
103
|
}
|
|
102
104
|
function bootstrap() {
|
|
103
105
|
configureDefaultSignalsImplementation();
|
|
104
106
|
configureAuthenticationServer({
|
|
105
107
|
serviceOptions: { secret: 'djp0fq23576aq' },
|
|
106
|
-
authenticationAncillaryService: CustomAuthenticationAncillaryService
|
|
108
|
+
authenticationAncillaryService: CustomAuthenticationAncillaryService,
|
|
107
109
|
});
|
|
108
110
|
configureLocalMessageBus();
|
|
109
111
|
configureAuthenticationClient({
|
|
110
112
|
authenticationApiClient: CustomAuthenticationApiClient,
|
|
111
|
-
initialAuthenticationData: ({ deviceId: 'my-device' })
|
|
113
|
+
initialAuthenticationData: ({ deviceId: 'my-device' }),
|
|
112
114
|
});
|
|
113
115
|
configureNodeHttpServer();
|
|
114
116
|
configureApiServer({ controllers: [AuthenticationApiController] });
|
|
115
117
|
configureUndiciHttpClientAdapter({ dispatcher: new Agent({ keepAliveMaxTimeout: 1 }) });
|
|
116
118
|
configureHttpClient({ baseUrl: 'http://localhost:8000' });
|
|
117
119
|
}
|
|
118
|
-
Application.run(
|
|
120
|
+
Application.run('Test', [
|
|
121
|
+
provideInitializer(bootstrap),
|
|
122
|
+
provideModules(WebServerModule, test),
|
|
123
|
+
provideSignalHandler(),
|
|
124
|
+
]);
|
|
@@ -11,7 +11,7 @@ import { compileClient } from '../../api/client/client.js';
|
|
|
11
11
|
import { defineApi } from '../../api/index.js';
|
|
12
12
|
import { apiController, configureApiServer } from '../../api/server/index.js';
|
|
13
13
|
import { Application } from '../../application/application.js';
|
|
14
|
-
import {
|
|
14
|
+
import { provideInitializer, provideModules, provideSignalHandler } from '../../application/index.js';
|
|
15
15
|
import { configureUndiciHttpClientAdapter } from '../../http/client/adapters/undici.adapter.js';
|
|
16
16
|
import { configureHttpClient } from '../../http/client/module.js';
|
|
17
17
|
import { HttpServerResponse } from '../../http/server/index.js';
|
|
@@ -24,9 +24,7 @@ import { decodeTextStream, encodeUtf8Stream } from '../../utils/encoding.js';
|
|
|
24
24
|
import { getReadableStreamFromIterable, getReadableStreamIterable } from '../../utils/stream/index.js';
|
|
25
25
|
import { cancelableTimeout, timeout } from '../../utils/timing.js';
|
|
26
26
|
import { isDefined } from '../../utils/type-guards.js';
|
|
27
|
-
configureTstdl();
|
|
28
27
|
configureDefaultSignalsImplementation();
|
|
29
|
-
const logger = getGlobalInjector().resolve(CORE_LOGGER);
|
|
30
28
|
const streamingApiDefinition = defineApi({
|
|
31
29
|
resource: 'streams', // /api/:version/users
|
|
32
30
|
endpoints: {
|
|
@@ -66,23 +64,24 @@ let StreamingApi = class StreamingApi {
|
|
|
66
64
|
StreamingApi = __decorate([
|
|
67
65
|
apiController(streamingApiDefinition)
|
|
68
66
|
], StreamingApi);
|
|
69
|
-
async function* counter() {
|
|
67
|
+
async function* counter(cancellationSignal) {
|
|
70
68
|
let currentNumber = 0;
|
|
71
|
-
while (
|
|
72
|
-
yield (
|
|
73
|
-
|
|
74
|
-
await cancelableTimeout(1000,
|
|
69
|
+
while (cancellationSignal.isUnset && (currentNumber < 10)) {
|
|
70
|
+
yield String(++currentNumber);
|
|
71
|
+
console.log(`yield: "${currentNumber}"`);
|
|
72
|
+
await cancelableTimeout(1000, cancellationSignal);
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
const StreamingApiClient = compileClient(streamingApiDefinition);
|
|
78
76
|
async function clientTest() {
|
|
77
|
+
const application = inject(Application);
|
|
79
78
|
const streamingApiClient = inject(StreamingApiClient);
|
|
80
79
|
await timeout(250); // allow server to start
|
|
81
|
-
const response = await streamingApiClient.echo(undefined, getReadableStreamFromIterable(counter()).pipeThrough(encodeUtf8Stream()));
|
|
80
|
+
const response = await streamingApiClient.echo(undefined, getReadableStreamFromIterable(counter(application.shutdownSignal)).pipeThrough(encodeUtf8Stream()));
|
|
82
81
|
for await (const responseChunk of getReadableStreamIterable(response.pipeThrough(decodeTextStream()))) {
|
|
83
|
-
|
|
82
|
+
console.log(`response: "${responseChunk}"\n`);
|
|
84
83
|
}
|
|
85
|
-
await
|
|
84
|
+
await application.shutdown();
|
|
86
85
|
}
|
|
87
86
|
function bootstrap() {
|
|
88
87
|
configureNodeHttpServer();
|
|
@@ -90,7 +89,6 @@ function bootstrap() {
|
|
|
90
89
|
configureUndiciHttpClientAdapter({ dispatcher: new Agent({ keepAliveMaxTimeout: 1 }) });
|
|
91
90
|
configureHttpClient({ baseUrl: 'http://localhost:8000' });
|
|
92
91
|
}
|
|
93
|
-
Application.run({ bootstrap }, WebServerModule, clientTest);
|
|
94
92
|
function eventsSource() {
|
|
95
93
|
const events = new ServerSentEventsSource();
|
|
96
94
|
void (async () => {
|
|
@@ -105,3 +103,8 @@ function eventsSource() {
|
|
|
105
103
|
})().catch((error) => console.error(error));
|
|
106
104
|
return events;
|
|
107
105
|
}
|
|
106
|
+
Application.run('Test', [
|
|
107
|
+
provideInitializer(bootstrap),
|
|
108
|
+
provideModules(WebServerModule, clientTest),
|
|
109
|
+
provideSignalHandler(),
|
|
110
|
+
]);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import '../../polyfills.js';
|
|
2
2
|
import { writeFile } from 'node:fs/promises';
|
|
3
|
-
import { Application } from '../../application/index.js';
|
|
3
|
+
import { Application, provideModules, provideSignalHandler } from '../../application/index.js';
|
|
4
4
|
import { BrowserService } from '../../browser/browser.service.js';
|
|
5
5
|
import { inject, injectAsync } from '../../injector/inject.js';
|
|
6
6
|
import { Logger } from '../../logger/logger.js';
|
|
7
7
|
import { timeout } from '../../utils/timing.js';
|
|
8
8
|
async function main() {
|
|
9
|
-
const logger = inject(Logger
|
|
9
|
+
const logger = inject(Logger, 'BROWSER');
|
|
10
10
|
const browserService = await injectAsync(BrowserService);
|
|
11
11
|
const browser = await browserService.newBrowser({ headless: false });
|
|
12
12
|
const context = await browser.newContext();
|
|
@@ -20,4 +20,7 @@ async function main() {
|
|
|
20
20
|
await page.navigate('file:///tmp/pdf.pdf');
|
|
21
21
|
await page.waitForClose();
|
|
22
22
|
}
|
|
23
|
-
Application.run(
|
|
23
|
+
Application.run('Test', [
|
|
24
|
+
provideModules(main),
|
|
25
|
+
provideSignalHandler(),
|
|
26
|
+
]);
|
|
@@ -9,7 +9,7 @@ import { configureAiService } from '../../ai/index.js';
|
|
|
9
9
|
import { MockApiRequestTokenProvider } from '../../api/server/api-request-token.provider.js';
|
|
10
10
|
import { configureApiServer } from '../../api/server/module.js';
|
|
11
11
|
import { Application } from '../../application/application.js';
|
|
12
|
-
import {
|
|
12
|
+
import { provideInitializer, provideModules, provideSignalHandler } from '../../application/index.js';
|
|
13
13
|
import { DocumentManagementAuthorizationService } from '../../document-management/index.js';
|
|
14
14
|
import { configureDocumentManagement } from '../../document-management/server/configure.js';
|
|
15
15
|
import { DocumentCategoryTypeService, DocumentCollectionService, DocumentManagementAncillaryService, DocumentManagementApiController, DocumentRequestService } from '../../document-management/server/index.js';
|
|
@@ -83,7 +83,6 @@ AllowAllDocumentManagementAuthorizationService = __decorate([
|
|
|
83
83
|
export { AllowAllDocumentManagementAuthorizationService };
|
|
84
84
|
async function bootstrap() {
|
|
85
85
|
const injector = inject(Injector);
|
|
86
|
-
configureTstdl();
|
|
87
86
|
configureNodeHttpServer();
|
|
88
87
|
configurePostgresQueue();
|
|
89
88
|
configureLocalMessageBus();
|
|
@@ -154,4 +153,8 @@ async function main() {
|
|
|
154
153
|
}
|
|
155
154
|
console.log(`Collections: ${collections.map((collection) => collection.id).join(',')}`);
|
|
156
155
|
}
|
|
157
|
-
Application.run(
|
|
156
|
+
Application.run('DocumentManagementTest', [
|
|
157
|
+
provideInitializer(bootstrap),
|
|
158
|
+
provideModules(main, WebServerModule),
|
|
159
|
+
provideSignalHandler(),
|
|
160
|
+
]);
|
package/examples/http/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '../../polyfills.js';
|
|
2
2
|
import { Application } from '../../application/application.js';
|
|
3
|
+
import { provideModules, provideSignalHandler } from '../../application/index.js';
|
|
3
4
|
import { configureUndiciHttpClientAdapter } from '../../http/client/adapters/undici.adapter.js';
|
|
4
5
|
import { HttpClient } from '../../http/client/index.js';
|
|
5
6
|
import { inject } from '../../injector/inject.js';
|
|
@@ -9,10 +10,13 @@ async function main() {
|
|
|
9
10
|
const response = await httpClient.get('https://httpbin.org/anything/:whatever', {
|
|
10
11
|
parameters: {
|
|
11
12
|
whatever: 'foobar',
|
|
12
|
-
anotherParameter: 'hello-world'
|
|
13
|
-
}
|
|
13
|
+
anotherParameter: 'hello-world',
|
|
14
|
+
},
|
|
14
15
|
});
|
|
15
16
|
const body = await response.body.readAsJson();
|
|
16
17
|
console.log(response.asObject(), body);
|
|
17
18
|
}
|
|
18
|
-
Application.run(
|
|
19
|
+
Application.run('Test', [
|
|
20
|
+
provideModules(main),
|
|
21
|
+
provideSignalHandler(),
|
|
22
|
+
]);
|
package/examples/mail/basic.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { Application } from '../../application/application.js';
|
|
4
|
+
import { provideModules, provideSignalHandler } from '../../application/index.js';
|
|
4
5
|
import { injectAsync } from '../../injector/inject.js';
|
|
5
6
|
import { NodemailerMailClient } from '../../mail/clients/nodemailer.mail-client.js';
|
|
6
7
|
import { MailService, configureMail } from '../../mail/index.js';
|
|
@@ -13,7 +14,6 @@ import { StringTemplateRenderer } from '../../templates/renderers/string.templat
|
|
|
13
14
|
import { configureFileTemplateResolver } from '../../templates/resolvers/file.template-resolver.js';
|
|
14
15
|
import { StringTemplateResolver } from '../../templates/resolvers/string.template-resolver.js';
|
|
15
16
|
import { integer, string } from '../../utils/config-parser.js';
|
|
16
|
-
import { configureTstdl } from '../../core.js';
|
|
17
17
|
let dirname;
|
|
18
18
|
try {
|
|
19
19
|
dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
@@ -21,22 +21,21 @@ try {
|
|
|
21
21
|
catch {
|
|
22
22
|
dirname = __dirname;
|
|
23
23
|
}
|
|
24
|
-
configureTstdl();
|
|
25
24
|
configureMail({
|
|
26
25
|
defaultClientConfig: {
|
|
27
26
|
host: string('HOST', '127.0.0.01'),
|
|
28
27
|
port: integer('PORT', 25),
|
|
29
28
|
auth: {
|
|
30
29
|
user: string('USER', 'user'),
|
|
31
|
-
password: string('PASS', 'password')
|
|
32
|
-
}
|
|
30
|
+
password: string('PASS', 'password'),
|
|
31
|
+
},
|
|
33
32
|
},
|
|
34
|
-
client: NodemailerMailClient
|
|
33
|
+
client: NodemailerMailClient,
|
|
35
34
|
});
|
|
36
35
|
configureTemplates({
|
|
37
36
|
templateProvider: FileTemplateProvider,
|
|
38
37
|
templateRenderers: [MjmlTemplateRenderer, HandlebarsTemplateRenderer, JsxTemplateRenderer, StringTemplateRenderer],
|
|
39
|
-
templateResolvers: [StringTemplateResolver]
|
|
38
|
+
templateResolvers: [StringTemplateResolver],
|
|
40
39
|
});
|
|
41
40
|
configureFileTemplateProvider({ basePath: resolve(dirname, 'templates') });
|
|
42
41
|
configureFileTemplateResolver({ basePath: resolve(dirname.replace('/dist', '/source'), 'templates') });
|
|
@@ -45,4 +44,7 @@ async function test() {
|
|
|
45
44
|
const result = await service.sendTemplate('hello-name', { from: string('FROM', string('USER', 'user@example.com')), to: string('TO', 'user@example.com') }, { name: 'Max Mustermann' });
|
|
46
45
|
console.log(result);
|
|
47
46
|
}
|
|
48
|
-
Application.run(
|
|
47
|
+
Application.run('Test', [
|
|
48
|
+
provideModules(test),
|
|
49
|
+
provideSignalHandler(),
|
|
50
|
+
]);
|
package/examples/pdf/basic.js
CHANGED
|
@@ -2,8 +2,8 @@ import { writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { Application } from '../../application/application.js';
|
|
5
|
+
import { provideModules, provideSignalHandler } from '../../application/index.js';
|
|
5
6
|
import { BrowserService } from '../../browser/browser.service.js';
|
|
6
|
-
import { configureTstdl } from '../../core.js';
|
|
7
7
|
import { inject } from '../../injector/inject.js';
|
|
8
8
|
import { Injector } from '../../injector/injector.js';
|
|
9
9
|
import { PdfService } from '../../pdf/pdf.service.js';
|
|
@@ -21,11 +21,10 @@ try {
|
|
|
21
21
|
catch {
|
|
22
22
|
dirname = __dirname;
|
|
23
23
|
}
|
|
24
|
-
configureTstdl();
|
|
25
24
|
configureTemplates({
|
|
26
25
|
templateProvider: FileTemplateProvider,
|
|
27
26
|
templateResolvers: [FileTemplateResolver, StringTemplateResolver],
|
|
28
|
-
templateRenderers: [MjmlTemplateRenderer, HandlebarsTemplateRenderer, StringTemplateRenderer]
|
|
27
|
+
templateRenderers: [MjmlTemplateRenderer, HandlebarsTemplateRenderer, StringTemplateRenderer],
|
|
29
28
|
});
|
|
30
29
|
configureFileTemplateProvider({ basePath: resolve(dirname, 'templates') });
|
|
31
30
|
configureFileTemplateResolver({ basePath: resolve(dirname.replace('dist', 'source'), 'templates') });
|
|
@@ -35,7 +34,7 @@ async function main() {
|
|
|
35
34
|
const pdfService = await injector.resolveAsync(PdfService);
|
|
36
35
|
const [result1, result2] = await Promise.all([
|
|
37
36
|
pdfService.renderTemplate('hello-name', { name: 'Max Mustermann' }),
|
|
38
|
-
pdfService.renderUrl('https://google.de')
|
|
37
|
+
pdfService.renderUrl('https://google.de'),
|
|
39
38
|
]);
|
|
40
39
|
console.log(`Resulting PDFs have ${result1.length} and ${result2.length} bytes.`);
|
|
41
40
|
writeFileSync('/tmp/template.pdf', result1);
|
|
@@ -46,9 +45,12 @@ async function main() {
|
|
|
46
45
|
const page2 = await context.newPage();
|
|
47
46
|
await Promise.all([
|
|
48
47
|
page1.navigate('file:///tmp/template.pdf'),
|
|
49
|
-
page2.navigate('file:///tmp/page.pdf')
|
|
48
|
+
page2.navigate('file:///tmp/page.pdf'),
|
|
50
49
|
]);
|
|
51
50
|
await page1.waitForClose();
|
|
52
51
|
await page2.waitForClose();
|
|
53
52
|
}
|
|
54
|
-
Application.run(
|
|
53
|
+
Application.run('Test', [
|
|
54
|
+
provideModules(main),
|
|
55
|
+
provideSignalHandler(),
|
|
56
|
+
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { Application } from '../../application/application.js';
|
|
4
|
-
import {
|
|
4
|
+
import { provideModules, provideSignalHandler } from '../../application/index.js';
|
|
5
5
|
import { inject } from '../../injector/inject.js';
|
|
6
6
|
import { configureTemplates, TemplateService } from '../../templates/index.js';
|
|
7
7
|
import { configureFileTemplateProvider, FileTemplateProvider } from '../../templates/providers/file.template-provider.js';
|
|
@@ -18,11 +18,10 @@ try {
|
|
|
18
18
|
catch {
|
|
19
19
|
dirname = __dirname;
|
|
20
20
|
}
|
|
21
|
-
configureTstdl();
|
|
22
21
|
configureTemplates({
|
|
23
22
|
templateProvider: FileTemplateProvider,
|
|
24
23
|
templateResolvers: [FileTemplateResolver, JsxTemplateResolver, StringTemplateResolver],
|
|
25
|
-
templateRenderers: [HandlebarsTemplateRenderer, JsxTemplateRenderer, StringTemplateRenderer]
|
|
24
|
+
templateRenderers: [HandlebarsTemplateRenderer, JsxTemplateRenderer, StringTemplateRenderer],
|
|
26
25
|
});
|
|
27
26
|
configureFileTemplateProvider({ basePath: resolve(dirname, 'templates') });
|
|
28
27
|
configureFileTemplateResolver({ basePath: resolve(dirname.replace('dist', 'source'), 'templates') });
|
|
@@ -32,7 +31,10 @@ async function test() {
|
|
|
32
31
|
const jsxResult = await templateService.render('hello-jsx', { name: 'Max Mustermann' });
|
|
33
32
|
console.log({
|
|
34
33
|
handlebars: handlebarsResult.fields,
|
|
35
|
-
jsx: jsxResult.fields
|
|
34
|
+
jsx: jsxResult.fields,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
Application.run(
|
|
37
|
+
Application.run('Test', [
|
|
38
|
+
provideModules(test),
|
|
39
|
+
provideSignalHandler(),
|
|
40
|
+
]);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type CancellationSignal } from '../../cancellation/index.js';
|
|
2
|
-
import { dispose, type Disposable } from '../../disposable/index.js';
|
|
3
2
|
import type { OneOrMany, Record, TypedOmit, UndefinableJson, UndefinableJsonObject } from '../../types/index.js';
|
|
4
3
|
import { HttpForm, type HttpFormObject } from '../http-form.js';
|
|
5
4
|
import { HttpHeaders, type HttpHeadersObject } from '../http-headers.js';
|
|
@@ -114,7 +113,7 @@ export declare class HttpClientRequest implements Disposable {
|
|
|
114
113
|
get abortSignal(): CancellationSignal;
|
|
115
114
|
constructor(url: string, method?: HttpMethod, options?: HttpClientRequestOptions);
|
|
116
115
|
constructor(requestObject: HttpClientRequestObject);
|
|
117
|
-
[dispose](): void;
|
|
116
|
+
[Symbol.dispose](): void;
|
|
118
117
|
/** Abort the request */
|
|
119
118
|
abort(): void;
|
|
120
119
|
clone(): HttpClientRequest;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CancellationToken } from '../../cancellation/index.js';
|
|
2
|
-
import { dispose } from '../../disposable/index.js';
|
|
3
2
|
import { clone } from '../../utils/clone.js';
|
|
4
3
|
import { objectEntries } from '../../utils/object/object.js';
|
|
5
4
|
import { isArray, isBlob, isDefined, isString, isUint8Array, isUndefined } from '../../utils/type-guards.js';
|
|
@@ -107,7 +106,7 @@ export class HttpClientRequest {
|
|
|
107
106
|
this.context = requestOptions.context ?? {};
|
|
108
107
|
this.#abortToken = requestOptions.abortSignal?.createChild() ?? new CancellationToken();
|
|
109
108
|
}
|
|
110
|
-
[dispose]() {
|
|
109
|
+
[Symbol.dispose]() {
|
|
111
110
|
this.#abortToken.set();
|
|
112
111
|
this.#abortToken.complete();
|
|
113
112
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { AsyncDisposable } from '../../disposable/index.js';
|
|
2
|
-
import { disposeAsync } from '../../disposable/index.js';
|
|
3
1
|
import type { HttpServerRequest, HttpServerResponse } from '../../http/server/index.js';
|
|
4
2
|
export type HttpServerRequestContext<Context = unknown> = {
|
|
5
3
|
request: HttpServerRequest;
|
|
@@ -12,5 +10,5 @@ export declare abstract class HttpServer<Context = unknown> implements AsyncIter
|
|
|
12
10
|
abstract listen(port: number): Promise<void>;
|
|
13
11
|
abstract close(timeout: number): Promise<void>;
|
|
14
12
|
abstract [Symbol.asyncIterator](): AsyncIterator<HttpServerRequestContext<Context>>;
|
|
15
|
-
abstract [
|
|
13
|
+
abstract [Symbol.asyncDispose](): Promise<void>;
|
|
16
14
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Http from 'node:http';
|
|
2
|
-
import { disposeAsync, type AsyncDisposable } from '../../../disposable/index.js';
|
|
3
2
|
import { afterResolve } from '../../../injector/index.js';
|
|
4
3
|
import { HttpServer, type HttpServerRequestContext } from '../http-server.js';
|
|
5
4
|
export type NodeHttpServerContext = {
|
|
@@ -11,7 +10,7 @@ export declare class NodeHttpServer extends HttpServer<NodeHttpServerContext> im
|
|
|
11
10
|
private untrackConnectedSockets?;
|
|
12
11
|
get connectedSocketsCount(): number;
|
|
13
12
|
[afterResolve](): void;
|
|
14
|
-
[
|
|
13
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
15
14
|
listen(port: number): Promise<void>;
|
|
16
15
|
close(timeout: number): Promise<void>;
|
|
17
16
|
[Symbol.asyncIterator](): AsyncIterator<HttpServerRequestContext<NodeHttpServerContext>>;
|
|
@@ -11,7 +11,6 @@ import { Writable } from 'node:stream';
|
|
|
11
11
|
import { bindNodeCallback, share } from 'rxjs';
|
|
12
12
|
import { match, P } from 'ts-pattern';
|
|
13
13
|
import { CancellationToken } from '../../../cancellation/index.js';
|
|
14
|
-
import { disposeAsync } from '../../../disposable/index.js';
|
|
15
14
|
import { HttpHeaders } from '../../../http/http-headers.js';
|
|
16
15
|
import { HttpQuery } from '../../../http/http-query.js';
|
|
17
16
|
import { afterResolve, inject, Singleton } from '../../../injector/index.js';
|
|
@@ -38,7 +37,7 @@ let NodeHttpServer = NodeHttpServer_1 = class NodeHttpServer extends HttpServer
|
|
|
38
37
|
[afterResolve]() {
|
|
39
38
|
this.#httpServer.on('request', (request, response) => this.#requestIterable.feed({ request, response }));
|
|
40
39
|
}
|
|
41
|
-
async [
|
|
40
|
+
async [Symbol.asyncDispose]() {
|
|
42
41
|
if (this.#httpServer.listening) {
|
|
43
42
|
await this.close(3000);
|
|
44
43
|
this.#requestIterable.end();
|
package/import.js
CHANGED
package/injector/injector.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type AsyncDisposable } from '../disposable/disposable.js';
|
|
2
1
|
import type { OneOrMany, Record, TypedOmit } from '../types/index.js';
|
|
3
2
|
import { type InjectOptions } from './inject.js';
|
|
4
3
|
import { type ResolveArgument } from './interfaces.js';
|
|
5
4
|
import { type Provider } from './provider.js';
|
|
6
5
|
import { type InjectionToken } from './token.js';
|
|
7
6
|
import type { RegistrationOptions, ResolveOptions } from './types.js';
|
|
7
|
+
export type DisposeHandler = Disposable | AsyncDisposable | (() => PromiseLike<void> | void);
|
|
8
8
|
export type ProvidersItem<T = any, A = any, D extends Record = Record> = Provider<T, A, D> & {
|
|
9
9
|
provide: InjectionToken<T, A>;
|
|
10
10
|
multi?: boolean;
|
package/injector/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { CancellationSignal } from '../cancellation/index.js';
|
|
2
|
-
import type { AsyncDisposeHandler } from '../disposable/async-disposer.js';
|
|
3
2
|
import type { Record } from '../types/index.js';
|
|
4
3
|
import type { ForwardRefTypeHint } from '../utils/object/forward-ref.js';
|
|
5
|
-
import type { Injector, ProvidersItem } from './injector.js';
|
|
4
|
+
import type { DisposeHandler, Injector, ProvidersItem } from './injector.js';
|
|
6
5
|
import type { ResolveArgument } from './interfaces.js';
|
|
7
6
|
import type { InjectionToken } from './token.js';
|
|
8
7
|
/**
|
|
@@ -15,12 +14,12 @@ export type Lifecycle = 'transient' | 'resolution' | 'injector' | 'singleton';
|
|
|
15
14
|
export type ResolveContext<D extends Record> = Pick<Injector, 'resolve' | 'resolveAll'> & {
|
|
16
15
|
readonly data: ResolveContextData<D>;
|
|
17
16
|
readonly cancellationSignal: CancellationSignal;
|
|
18
|
-
addDisposeHandler(handler:
|
|
17
|
+
addDisposeHandler(handler: DisposeHandler): void;
|
|
19
18
|
};
|
|
20
19
|
export type AfterResolveContext<D extends Record> = {
|
|
21
20
|
readonly data: ResolveContextData<D>;
|
|
22
21
|
readonly cancellationSignal: CancellationSignal;
|
|
23
|
-
addDisposeHandler(handler:
|
|
22
|
+
addDisposeHandler(handler: DisposeHandler): void;
|
|
24
23
|
};
|
|
25
24
|
export type Mapper<T = any, U = unknown> = (value: T) => U;
|
|
26
25
|
export type ArgumentProvider<T = unknown, D extends Record = Record> = (context: ResolveContext<D>) => T;
|