@tstdl/base 0.86.1 → 0.87.1

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.
Files changed (70) hide show
  1. package/application/application.d.ts +3 -3
  2. package/application/application.js +9 -9
  3. package/authentication/client/authentication.service.js +3 -3
  4. package/cancellation/index.d.ts +1 -0
  5. package/cancellation/index.js +18 -0
  6. package/{utils/cancellation-token.d.ts → cancellation/token.d.ts} +33 -41
  7. package/{utils/cancellation-token.js → cancellation/token.js} +93 -49
  8. package/core.d.ts +6 -3
  9. package/core.js +12 -6
  10. package/data-structures/circular-buffer.d.ts +4 -4
  11. package/data-structures/circular-buffer.js +10 -10
  12. package/database/mongo/module.js +2 -2
  13. package/disposable/async-disposer.d.ts +4 -4
  14. package/disposable/async-disposer.js +6 -6
  15. package/distributed-loop/distributed-loop.d.ts +4 -4
  16. package/distributed-loop/distributed-loop.js +6 -6
  17. package/enumerable/async-enumerable.d.ts +2 -2
  18. package/enumerable/async-enumerable.js +2 -2
  19. package/enumerable/enumerable.d.ts +2 -2
  20. package/enumerable/enumerable.js +2 -2
  21. package/examples/api/streaming.js +3 -3
  22. package/http/client/adapters/undici-http-client.adapter.js +1 -1
  23. package/http/client/http-client-request.d.ts +5 -5
  24. package/http/client/http-client-request.js +9 -9
  25. package/http/server/node/node-http-server.js +2 -2
  26. package/injector/injector.js +5 -5
  27. package/injector/types.d.ts +3 -3
  28. package/lock/mongo/lock.js +2 -2
  29. package/lock/web/web-lock.js +2 -2
  30. package/message-bus/message-bus-base.d.ts +2 -2
  31. package/message-bus/message-bus-base.js +2 -2
  32. package/migration/migrator.js +2 -2
  33. package/module/module-base.d.ts +3 -3
  34. package/module/module-base.js +2 -2
  35. package/module/module-metric-reporter.d.ts +2 -2
  36. package/module/module-metric-reporter.js +3 -3
  37. package/module/modules/function.module.d.ts +4 -4
  38. package/module/modules/function.module.js +2 -2
  39. package/module/modules/web-server.module.d.ts +2 -2
  40. package/module/modules/web-server.module.js +2 -2
  41. package/package.json +4 -4
  42. package/process-shutdown.d.ts +4 -2
  43. package/process-shutdown.js +15 -5
  44. package/queue/mongo/queue.d.ts +5 -5
  45. package/queue/mongo/queue.js +7 -7
  46. package/queue/queue.d.ts +3 -3
  47. package/search-index/elastic/module.js +2 -2
  48. package/signals/to-signal-2.d.ts +6 -4
  49. package/utils/async-iterable-helpers/buffer.js +2 -2
  50. package/utils/async-iterable-helpers/metadata.d.ts +0 -2
  51. package/utils/async-iterable-helpers/metadata.js +1 -3
  52. package/utils/async-iterable-helpers/observable-iterable.js +3 -3
  53. package/utils/async-iterable-helpers/skip.js +2 -2
  54. package/utils/async-iterable-helpers/take-until.d.ts +2 -2
  55. package/utils/async-iterable-helpers/take-until.js +7 -7
  56. package/utils/async-iterable-helpers/take.js +17 -1
  57. package/utils/backoff.d.ts +7 -7
  58. package/utils/backoff.js +7 -7
  59. package/utils/event-loop.d.ts +2 -2
  60. package/utils/event-loop.js +2 -2
  61. package/utils/feedable-async-iterable.js +3 -3
  62. package/utils/index.d.ts +0 -1
  63. package/utils/index.js +0 -1
  64. package/utils/iterable-helpers/take-until.d.ts +2 -2
  65. package/utils/iterable-helpers/take-until.js +2 -2
  66. package/utils/patch-worker.d.ts +1 -1
  67. package/utils/patch-worker.js +2 -2
  68. package/utils/periodic-reporter.js +2 -2
  69. package/utils/timing.d.ts +3 -3
  70. package/utils/timing.js +5 -5
@@ -22,8 +22,8 @@ __export(async_disposer_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(async_disposer_exports);
24
24
  var import_type_guards = require("../utils/type-guards.js");
25
+ var import_token = require("../cancellation/token.js");
25
26
  var import_multi_error = require("../error/multi.error.js");
26
- var import_cancellation_token = require("../utils/cancellation-token.js");
27
27
  var import_disposable = require("./disposable.js");
28
28
  const deferrerToken = Symbol("DeferrerToken");
29
29
  class AsyncDisposer {
@@ -31,10 +31,10 @@ class AsyncDisposer {
31
31
  #disposedToken;
32
32
  #deferrers;
33
33
  #tasks;
34
- get disposingToken() {
34
+ get disposingSignal() {
35
35
  return this.#disposingToken;
36
36
  }
37
- get disposedToken() {
37
+ get disposedSignal() {
38
38
  return this.#disposedToken;
39
39
  }
40
40
  get disposing() {
@@ -47,8 +47,8 @@ class AsyncDisposer {
47
47
  constructor() {
48
48
  this.#deferrers = /* @__PURE__ */ new Set();
49
49
  this.#tasks = [];
50
- this.#disposingToken = new import_cancellation_token.CancellationToken();
51
- this.#disposedToken = new import_cancellation_token.CancellationToken();
50
+ this.#disposingToken = new import_token.CancellationToken();
51
+ this.#disposedToken = new import_token.CancellationToken();
52
52
  }
53
53
  use(value) {
54
54
  if ((0, import_type_guards.isNullOrUndefined)(value)) {
@@ -73,7 +73,7 @@ class AsyncDisposer {
73
73
  }
74
74
  getDeferrer() {
75
75
  const deferrer = {
76
- [deferrerToken]: new import_cancellation_token.CancellationToken(),
76
+ [deferrerToken]: new import_token.CancellationToken(),
77
77
  yield: () => {
78
78
  deferrer[deferrerToken].set();
79
79
  this.#deferrers.delete(deferrer);
@@ -1,7 +1,7 @@
1
+ import type { CancellationSignal } from '../cancellation/index.js';
1
2
  import { resolveArgumentType } from '../injector/index.js';
2
3
  import type { Resolvable } from '../injector/interfaces.js';
3
4
  import { LockProvider } from '../lock/index.js';
4
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
5
5
  import type { LoopController } from './controller.js';
6
6
  export type LoopFunction = (controller: LoopController) => any | Promise<any>;
7
7
  /** loop key */
@@ -22,11 +22,11 @@ export declare class DistributedLoop implements Resolvable<DistributedLoopArgume
22
22
  constructor(key: string, lockProvider: LockProvider);
23
23
  /**
24
24
  * run the function {@link func} every {@link interval} milliseconds with an accuracy of {@link accuracy}
25
- * until {@link cancellationToken} is set or stop on the {@link LoopController} is called
25
+ * until {@link cancellationSignal} is set or stop on the {@link LoopController} is called
26
26
  * @param interval in millseconds
27
27
  * @param accuracy in millseconds
28
28
  * @param func handler to run
29
- * @param cancellationToken token to cancel loop (same as calling stop on the {@link LoopController})
29
+ * @param cancellationSignal token to cancel loop (same as calling stop on the {@link LoopController})
30
30
  */
31
- run(interval: number, accuracy: number, func: LoopFunction, cancellationToken?: ReadonlyCancellationToken): LoopController;
31
+ run(interval: number, accuracy: number, func: LoopFunction, cancellationSignal?: CancellationSignal): LoopController;
32
32
  }
@@ -21,10 +21,10 @@ __export(distributed_loop_exports, {
21
21
  DistributedLoop: () => DistributedLoop
22
22
  });
23
23
  module.exports = __toCommonJS(distributed_loop_exports);
24
+ var import_cancellation = require("../cancellation/index.js");
24
25
  var import_injector = require("../injector/index.js");
25
26
  var import_lock = require("../lock/index.js");
26
27
  var import_deferred_promise = require("../promise/deferred-promise.js");
27
- var import_cancellation_token = require("../utils/cancellation-token.js");
28
28
  var import_timer = require("../utils/timer.js");
29
29
  var import_timing = require("../utils/timing.js");
30
30
  var __decorate = function(decorators, target, key, desc) {
@@ -64,15 +64,15 @@ let DistributedLoop = class DistributedLoop2 {
64
64
  }
65
65
  /**
66
66
  * run the function {@link func} every {@link interval} milliseconds with an accuracy of {@link accuracy}
67
- * until {@link cancellationToken} is set or stop on the {@link LoopController} is called
67
+ * until {@link cancellationSignal} is set or stop on the {@link LoopController} is called
68
68
  * @param interval in millseconds
69
69
  * @param accuracy in millseconds
70
70
  * @param func handler to run
71
- * @param cancellationToken token to cancel loop (same as calling stop on the {@link LoopController})
71
+ * @param cancellationSignal token to cancel loop (same as calling stop on the {@link LoopController})
72
72
  */
73
- run(interval, accuracy, func, cancellationToken) {
73
+ run(interval, accuracy, func, cancellationSignal) {
74
74
  const $stopped = new import_deferred_promise.DeferredPromise();
75
- const stopToken = cancellationToken?.createChild() ?? new import_cancellation_token.CancellationToken();
75
+ const stopToken = cancellationSignal?.createChild() ?? new import_cancellation.CancellationToken();
76
76
  const stopFunction = async () => {
77
77
  if (!stopToken.isSet) {
78
78
  stopToken.set();
@@ -83,7 +83,7 @@ let DistributedLoop = class DistributedLoop2 {
83
83
  stop: stopFunction,
84
84
  $stopped
85
85
  };
86
- (async () => {
86
+ void (async () => {
87
87
  const lock = this.lockProvider.get(this.key);
88
88
  const timer = new import_timer.Timer();
89
89
  try {
@@ -1,5 +1,5 @@
1
+ import type { CancellationSignal } from '../cancellation/token.js';
1
2
  import type { AnyIterable } from '../utils/any-iterable-iterator.js';
2
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
3
3
  import type { AsyncComparator } from '../utils/sort.js';
4
4
  import type { Observable } from 'rxjs';
5
5
  import type { AsyncIteratorFunction, AsyncPredicate, AsyncReducer, AsyncRetryPredicate, ParallelizableIteratorFunction, ParallelizablePredicate, ThrottleFunction } from '../utils/async-iterable-helpers/index.js';
@@ -56,7 +56,7 @@ export declare class AsyncEnumerable<T> implements EnumerableMethods, AsyncItera
56
56
  sort(comparator?: AsyncComparator<T>): AsyncEnumerable<T>;
57
57
  sortToArray(comparator?: AsyncComparator<T>): Promise<T[]>;
58
58
  take(count: number): AsyncEnumerable<T>;
59
- takeUntil(cancellationToken: ReadonlyCancellationToken): AsyncEnumerable<T>;
59
+ takeUntil(cancellationSignal: CancellationSignal): AsyncEnumerable<T>;
60
60
  takeWhile(yieldLastOnFalse: boolean, predicate: AsyncPredicate<T>): AsyncEnumerable<T>;
61
61
  throttle(delayOrThrottleFunction: number | ThrottleFunction): AsyncEnumerable<T>;
62
62
  toArray(): Promise<T[]>;
@@ -198,8 +198,8 @@ class AsyncEnumerable {
198
198
  const taken = (0, import_async_iterable_helpers.takeAsync)(this.source, count);
199
199
  return new AsyncEnumerable(taken);
200
200
  }
201
- takeUntil(cancellationToken) {
202
- const taken = (0, import_async_iterable_helpers.takeUntilAsync)(this.source, cancellationToken);
201
+ takeUntil(cancellationSignal) {
202
+ const taken = (0, import_async_iterable_helpers.takeUntilAsync)(this.source, cancellationSignal);
203
203
  return new AsyncEnumerable(taken);
204
204
  }
205
205
  takeWhile(yieldLastOnFalse, predicate) {
@@ -1,5 +1,5 @@
1
+ import type { CancellationSignal } from '../cancellation/token.js';
1
2
  import type { Comparator } from '../utils/sort.js';
2
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
3
3
  import type { IterableItemMetadata, IteratorFunction, Predicate, Reducer, TypePredicate } from '../utils/iterable-helpers/index.js';
4
4
  import { AsyncEnumerable } from './async-enumerable.js';
5
5
  import type { EnumerableMethods } from './enumerable-methods.js';
@@ -47,7 +47,7 @@ export declare class Enumerable<T> implements EnumerableMethods, Iterable<T> {
47
47
  sort(comparator?: Comparator<T>): Enumerable<T>;
48
48
  sortToArray(comparator?: Comparator<T>): T[];
49
49
  take(count: number): Enumerable<T>;
50
- takeUntil(cancellationToken: ReadonlyCancellationToken): Enumerable<T>;
50
+ takeUntil(cancellationSignal: CancellationSignal): Enumerable<T>;
51
51
  takeWhile(yieldLastOnFalse: boolean, predicate: Predicate<T>): Enumerable<T>;
52
52
  toArray(): T[];
53
53
  toAsync(): AsyncEnumerable<T>;
@@ -169,8 +169,8 @@ class Enumerable {
169
169
  const taken = (0, import_iterable_helpers.take)(this.source, count);
170
170
  return new Enumerable(taken);
171
171
  }
172
- takeUntil(cancellationToken) {
173
- const taken = (0, import_iterable_helpers.takeUntil)(this.source, cancellationToken);
172
+ takeUntil(cancellationSignal) {
173
+ const taken = (0, import_iterable_helpers.takeUntil)(this.source, cancellationSignal);
174
174
  return new Enumerable(taken);
175
175
  }
176
176
  takeWhile(yieldLastOnFalse, predicate) {
@@ -27,7 +27,7 @@ var __decorate = function(decorators, target, key, desc) {
27
27
  return c > 3 && r && Object.defineProperty(target, key, r), r;
28
28
  };
29
29
  (0, import_core.configureTstdl)();
30
- const logger = import_core.rootInjector.resolve(import_core.CORE_LOGGER);
30
+ const logger = (0, import_core.getGlobalInjector)().resolve(import_core.CORE_LOGGER);
31
31
  const streamingApiDefinition = (0, import_api.defineApi)({
32
32
  resource: "streams",
33
33
  endpoints: {
@@ -69,10 +69,10 @@ StreamingApi = __decorate([
69
69
  ], StreamingApi);
70
70
  async function* counter() {
71
71
  let currentNumber = 0;
72
- while (import_application.Application.shutdownToken.isUnset && currentNumber < 10) {
72
+ while (import_application.Application.shutdownSignal.isUnset && currentNumber < 10) {
73
73
  yield `${++currentNumber}`.toString();
74
74
  logger.info(`yield: "${currentNumber}"`);
75
- await (0, import_timing.cancelableTimeout)(1e3, import_application.Application.shutdownToken);
75
+ await (0, import_timing.cancelableTimeout)(1e3, import_application.Application.shutdownSignal);
76
76
  }
77
77
  }
78
78
  const StreamingApiClient = (0, import_client.compileClient)(streamingApiDefinition);
@@ -83,7 +83,7 @@ let UndiciHttpClientAdapter = class UndiciHttpClientAdapter2 extends import_http
83
83
  try {
84
84
  const response = await (0, import_undici.request)(httpClientRequest.url, {
85
85
  method: httpClientRequest.method,
86
- signal: httpClientRequest.abortToken.asAbortSignal(),
86
+ signal: httpClientRequest.abortSignal.asAbortSignal(),
87
87
  headers: httpClientRequest.headers.asNormalizedObject(),
88
88
  body,
89
89
  headersTimeout: httpClientRequest.timeout,
@@ -1,7 +1,7 @@
1
+ import type { CancellationSignal } from '../../cancellation/index.js';
1
2
  import type { Disposable } from '../../disposable/index.js';
2
3
  import { dispose } from '../../disposable/index.js';
3
4
  import type { Record, TypedOmit, UndefinableJson, UndefinableJsonObject } from '../../types.js';
4
- import type { ReadonlyCancellationToken } from '../../utils/cancellation-token.js';
5
5
  import type { HttpFormObject } from '../http-form.js';
6
6
  import { HttpForm } from '../http-form.js';
7
7
  import type { HttpHeadersObject } from '../http-headers.js';
@@ -28,7 +28,7 @@ export type HttpRequestAuthorization = {
28
28
  bearer?: string;
29
29
  token?: string;
30
30
  };
31
- export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url' | 'method' | 'abortToken' | 'abort' | 'headers' | 'query' | 'body'>> & {
31
+ export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url' | 'method' | 'abortSignal' | 'abort' | 'headers' | 'query' | 'body'>> & {
32
32
  urlParameter?: HttpUrlParametersObject | HttpUrlParameters;
33
33
  headers?: HttpHeadersObject | HttpHeaders;
34
34
  query?: HttpQueryObject | HttpQuery;
@@ -41,7 +41,7 @@ export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url
41
41
  buffer?: Uint8Array;
42
42
  stream?: ReadableStream<Uint8Array>;
43
43
  };
44
- abortToken?: ReadonlyCancellationToken;
44
+ abortSignal?: CancellationSignal;
45
45
  };
46
46
  export type HttpRequestCredentials = 'omit' | 'same-origin' | 'include';
47
47
  export type HttpClientRequestObject = HttpClientRequestOptions & {
@@ -49,7 +49,7 @@ export type HttpClientRequestObject = HttpClientRequestOptions & {
49
49
  method?: HttpMethod;
50
50
  };
51
51
  export declare class HttpClientRequest implements Disposable {
52
- private readonly _abortToken;
52
+ #private;
53
53
  url: string;
54
54
  method: HttpMethod;
55
55
  headers: HttpHeaders;
@@ -118,7 +118,7 @@ export declare class HttpClientRequest implements Disposable {
118
118
  /**
119
119
  * can be used to cancel the request. Throws HttpError
120
120
  */
121
- get abortToken(): ReadonlyCancellationToken;
121
+ get abortSignal(): CancellationSignal;
122
122
  constructor(url: string, method?: HttpMethod, options?: HttpClientRequestOptions);
123
123
  constructor(requestObject: HttpClientRequestObject);
124
124
  [dispose](): void;
@@ -21,8 +21,8 @@ __export(http_client_request_exports, {
21
21
  HttpClientRequest: () => HttpClientRequest
22
22
  });
23
23
  module.exports = __toCommonJS(http_client_request_exports);
24
+ var import_cancellation = require("../../cancellation/index.js");
24
25
  var import_disposable = require("../../disposable/index.js");
25
- var import_cancellation_token = require("../../utils/cancellation-token.js");
26
26
  var import_clone = require("../../utils/clone.js");
27
27
  var import_type_guards = require("../../utils/type-guards.js");
28
28
  var import_http_form = require("../http-form.js");
@@ -30,7 +30,7 @@ var import_http_headers = require("../http-headers.js");
30
30
  var import_http_query = require("../http-query.js");
31
31
  var import_http_url_parameters = require("../http-url-parameters.js");
32
32
  class HttpClientRequest {
33
- _abortToken;
33
+ #abortToken;
34
34
  url;
35
35
  method;
36
36
  headers;
@@ -99,8 +99,8 @@ class HttpClientRequest {
99
99
  /**
100
100
  * can be used to cancel the request. Throws HttpError
101
101
  */
102
- get abortToken() {
103
- return this._abortToken.asReadonly();
102
+ get abortSignal() {
103
+ return this.#abortToken.signal;
104
104
  }
105
105
  constructor(urlOrObject, method, options = {}) {
106
106
  if ((0, import_type_guards.isString)(urlOrObject)) {
@@ -126,16 +126,16 @@ class HttpClientRequest {
126
126
  this.timeout = requestOptions.timeout ?? 3e4;
127
127
  this.throwOnNon200 = requestOptions.throwOnNon200 ?? true;
128
128
  this.context = requestOptions.context ?? {};
129
- this._abortToken = requestOptions.abortToken?.createChild() ?? new import_cancellation_token.CancellationToken();
129
+ this.#abortToken = requestOptions.abortSignal?.createChild() ?? new import_cancellation.CancellationToken();
130
130
  }
131
131
  [import_disposable.dispose]() {
132
- this._abortToken.set();
133
- this._abortToken.complete();
132
+ this.#abortToken.set();
133
+ this.#abortToken.complete();
134
134
  }
135
135
  /** abort the request */
136
136
  abort() {
137
- this._abortToken.set();
138
- this._abortToken.complete();
137
+ this.#abortToken.set();
138
+ this.#abortToken.complete();
139
139
  }
140
140
  clone() {
141
141
  const request = new HttpClientRequest(this);
@@ -32,12 +32,12 @@ __export(node_http_server_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(node_http_server_exports);
34
34
  var Http = __toESM(require("node:http"), 1);
35
+ var import_cancellation = require("../../../cancellation/index.js");
35
36
  var import_disposable = require("../../../disposable/index.js");
36
37
  var import_http_headers = require("../../../http/http-headers.js");
37
38
  var import_http_query = require("../../../http/http-query.js");
38
39
  var import_injector = require("../../../injector/index.js");
39
40
  var import_logger = require("../../../logger/index.js");
40
- var import_cancellation_token = require("../../../utils/cancellation-token.js");
41
41
  var import_encoding = require("../../../utils/encoding.js");
42
42
  var import_feedable_async_iterable = require("../../../utils/feedable-async-iterable.js");
43
43
  var import_readable_stream_adapter = require("../../../utils/stream/readable-stream-adapter.js");
@@ -129,7 +129,7 @@ let NodeHttpServer = class NodeHttpServer2 extends import_http_server.HttpServer
129
129
  }
130
130
  if (connections > 0) {
131
131
  this.logger.info(`Waiting for ${connections} connections to end`);
132
- await (0, import_timing.cancelableTimeout)(250, import_cancellation_token.CancellationToken.from(close$));
132
+ await (0, import_timing.cancelableTimeout)(250, import_cancellation.CancellationToken.from(close$));
133
133
  }
134
134
  }
135
135
  this.untrackConnectedSockets?.();
@@ -27,7 +27,7 @@ var import_disposable = require("../disposable/disposable.js");
27
27
  var import_deferred_promise = require("../promise/deferred-promise.js");
28
28
  var import_registry = require("../reflection/registry.js");
29
29
  var import_array = require("../utils/array/array.js");
30
- var import_cancellation_token = require("../utils/cancellation-token.js");
30
+ var import_cancellation = require("../cancellation/index.js");
31
31
  var import_factory_map = require("../utils/factory-map.js");
32
32
  var import_forward_ref = require("../utils/object/forward-ref.js");
33
33
  var import_object = require("../utils/object/object.js");
@@ -43,7 +43,7 @@ class Injector {
43
43
  static #globalRegistrations = /* @__PURE__ */ new Map();
44
44
  #parent;
45
45
  #children = [];
46
- #disposeToken = new import_cancellation_token.CancellationToken();
46
+ #disposeToken = new import_cancellation.CancellationToken();
47
47
  #disposableStack = new AsyncDisposableStack();
48
48
  #registrations = /* @__PURE__ */ new Map();
49
49
  #injectorScopedResolutions = new import_multi_key_map.MultiKeyMap();
@@ -56,7 +56,7 @@ class Injector {
56
56
  this.name = name;
57
57
  this.#parent = parent;
58
58
  this.register(Injector, { useValue: this });
59
- this.register(import_cancellation_token.CancellationToken, { useValue: this.#disposeToken });
59
+ this.register(import_cancellation.CancellationSignal, { useValue: this.#disposeToken.signal });
60
60
  this.#addDisposeHandler = (handler) => {
61
61
  if ((0, import_disposable.isSyncOrAsyncDisposable)(handler)) {
62
62
  this.#disposableStack.use(handler);
@@ -389,7 +389,7 @@ class Injector {
389
389
  const context = {
390
390
  resolve: (token, argument, options) => this._resolve(token, argument, options ?? {}, resolveContext, chain.addToken(token)),
391
391
  resolveAll: (token, argument, options) => this._resolveAll(token, argument, options ?? {}, resolveContext, chain.addToken(token)),
392
- cancellationToken: this.#disposeToken,
392
+ cancellationSignal: this.#disposeToken,
393
393
  addDisposeHandler: this.#addDisposeHandler,
394
394
  get data() {
395
395
  return resolveContext.resolutionContextData.get(resolutionTag);
@@ -399,7 +399,7 @@ class Injector {
399
399
  }
400
400
  getAfterResolveContext(resolutionTag, resolveContext) {
401
401
  const context = {
402
- cancellationToken: this.#disposeToken,
402
+ cancellationSignal: this.#disposeToken,
403
403
  addDisposeHandler: this.#addDisposeHandler,
404
404
  get data() {
405
405
  return resolveContext.resolutionContextData.get(resolutionTag);
@@ -1,6 +1,6 @@
1
+ import type { CancellationSignal } from '../cancellation/index.js';
1
2
  import type { AsyncDisposeHandler } from '../disposable/async-disposer.js';
2
3
  import type { Record } from '../types.js';
3
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
4
4
  import type { Injector } from './injector.js';
5
5
  import type { ResolveArgument } from './interfaces.js';
6
6
  import type { InjectionToken } from './token.js';
@@ -13,12 +13,12 @@ import type { InjectionToken } from './token.js';
13
13
  export type Lifecycle = 'transient' | 'resolution' | 'injector' | 'singleton';
14
14
  export type ResolveContext<D extends Record> = Pick<Injector, 'resolve' | 'resolveAll'> & {
15
15
  readonly data: ResolveContextData<D>;
16
- readonly cancellationToken: ReadonlyCancellationToken;
16
+ readonly cancellationSignal: CancellationSignal;
17
17
  addDisposeHandler(handler: AsyncDisposeHandler): void;
18
18
  };
19
19
  export type AfterResolveContext<D extends Record> = {
20
20
  readonly data: ResolveContextData<D>;
21
- readonly cancellationToken: ReadonlyCancellationToken;
21
+ readonly cancellationSignal: CancellationSignal;
22
22
  addDisposeHandler(handler: AsyncDisposeHandler): void;
23
23
  };
24
24
  export type Mapper<T = any, U = unknown> = (value: T) => U;
@@ -21,11 +21,11 @@ __export(lock_exports, {
21
21
  MongoLock: () => MongoLock
22
22
  });
23
23
  module.exports = __toCommonJS(lock_exports);
24
+ var import_cancellation = require("../../cancellation/index.js");
24
25
  var import_decorators = require("../../injector/decorators.js");
25
26
  var import_lock = require("../../lock/index.js");
26
27
  var import_logger = require("../../logger/index.js");
27
28
  var import_alphabet = require("../../utils/alphabet.js");
28
- var import_cancellation_token = require("../../utils/cancellation-token.js");
29
29
  var import_date_time = require("../../utils/date-time.js");
30
30
  var import_random = require("../../utils/random.js");
31
31
  var import_timer = require("../../utils/timer.js");
@@ -78,7 +78,7 @@ let MongoLock = class MongoLock2 extends import_lock.Lock {
78
78
  return false;
79
79
  }
80
80
  let expiration = result;
81
- const releaseToken = new import_cancellation_token.CancellationToken();
81
+ const releaseToken = new import_cancellation.CancellationToken();
82
82
  const controller = {
83
83
  get lost() {
84
84
  return (0, import_date_time.currentTimestamp)() >= expiration.valueOf();
@@ -21,9 +21,9 @@ __export(web_lock_exports, {
21
21
  WebLock: () => WebLock
22
22
  });
23
23
  module.exports = __toCommonJS(web_lock_exports);
24
+ var import_cancellation = require("../../cancellation/index.js");
24
25
  var import_injector = require("../../injector/index.js");
25
26
  var import_deferred_promise = require("../../promise/deferred-promise.js");
26
- var import_cancellation_token = require("../../utils/cancellation-token.js");
27
27
  var import_type_guards = require("../../utils/type-guards.js");
28
28
  var import_rxjs = require("rxjs");
29
29
  var import_lock = require("../lock.js");
@@ -55,7 +55,7 @@ let WebLock = class WebLock2 extends import_lock.Lock {
55
55
  releasePromise.resolve();
56
56
  }
57
57
  };
58
- const timeoutToken = (0, import_type_guards.isDefined)(timeout) && timeout > 0 ? import_cancellation_token.CancellationToken.from((0, import_rxjs.timer)(timeout).pipe((0, import_rxjs.map)(() => true))) : void 0;
58
+ const timeoutToken = (0, import_type_guards.isDefined)(timeout) && timeout > 0 ? import_cancellation.CancellationToken.from((0, import_rxjs.timer)(timeout).pipe((0, import_rxjs.map)(() => true))) : void 0;
59
59
  void navigator.locks.request(this.resource, {
60
60
  signal: (0, import_type_guards.isDefined)(timeoutToken) ? timeoutToken.asAbortSignal() : void 0,
61
61
  ifAvailable: (0, import_type_guards.isDefined)(timeout) && timeout <= 0
@@ -1,7 +1,7 @@
1
- import type { Logger } from '../logger/index.js';
2
1
  import type { Observable } from 'rxjs';
2
+ import type { Logger } from '../logger/index.js';
3
+ import { CancellationToken } from '../cancellation/token.js';
3
4
  import { disposeAsync } from '../disposable/disposable.js';
4
- import { CancellationToken } from '../utils/cancellation-token.js';
5
5
  import { MessageBus } from './message-bus.js';
6
6
  export declare abstract class MessageBusBase<T> extends MessageBus<T> {
7
7
  private readonly logger;
@@ -22,8 +22,8 @@ __export(message_bus_base_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(message_bus_base_exports);
24
24
  var import_rxjs = require("rxjs");
25
+ var import_token = require("../cancellation/token.js");
25
26
  var import_disposable = require("../disposable/disposable.js");
26
- var import_cancellation_token = require("../utils/cancellation-token.js");
27
27
  var import_message_bus = require("./message-bus.js");
28
28
  class MessageBusBase extends import_message_bus.MessageBus {
29
29
  logger;
@@ -35,7 +35,7 @@ class MessageBusBase extends import_message_bus.MessageBus {
35
35
  super();
36
36
  this.logger = logger;
37
37
  this.publishSubject = new import_rxjs.Subject();
38
- this.disposeToken = new import_cancellation_token.CancellationToken();
38
+ this.disposeToken = new import_token.CancellationToken();
39
39
  this.messages$ = (0, import_rxjs.defer)(() => this._messages$).pipe((0, import_rxjs.takeUntil)(this.disposeToken.set$), (0, import_rxjs.share)());
40
40
  this.allMessages$ = (0, import_rxjs.merge)(this.messages$, this.publishSubject);
41
41
  }
@@ -21,11 +21,11 @@ __export(migrator_exports, {
21
21
  Migrator: () => Migrator
22
22
  });
23
23
  module.exports = __toCommonJS(migrator_exports);
24
+ var import_cancellation = require("../cancellation/index.js");
24
25
  var import_injector = require("../injector/index.js");
25
26
  var import_lock = require("../lock/index.js");
26
27
  var import_logger = require("../logger/index.js");
27
28
  var import_array = require("../utils/array/array.js");
28
- var import_cancellation_token = require("../utils/cancellation-token.js");
29
29
  var import_comparison = require("../utils/comparison.js");
30
30
  var import_math = require("../utils/math.js");
31
31
  var import_timer = require("../utils/timer.js");
@@ -68,7 +68,7 @@ let Migrator = class Migrator2 {
68
68
  const { result } = await lock.use(3e4, true, async () => {
69
69
  const results = [];
70
70
  while (true) {
71
- const restartToken = new import_cancellation_token.CancellationToken();
71
+ const restartToken = new import_cancellation.CancellationToken();
72
72
  const control = {
73
73
  restart: () => restartToken.set()
74
74
  };
@@ -1,6 +1,6 @@
1
+ import type { CancellationSignal } from '../cancellation/index.js';
2
+ import { CancellationToken } from '../cancellation/index.js';
1
3
  import type { StringMap } from '../types.js';
2
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
3
- import { CancellationToken } from '../utils/cancellation-token.js';
4
4
  import type { Module, ModuleMetric } from './module.js';
5
5
  import { ModuleState } from './module.js';
6
6
  export declare abstract class ModuleBase implements Module {
@@ -14,5 +14,5 @@ export declare abstract class ModuleBase implements Module {
14
14
  constructor(name: string);
15
15
  run(): Promise<void>;
16
16
  stop(): Promise<void>;
17
- protected abstract _run(cancellationToken: ReadonlyCancellationToken): Promise<void>;
17
+ protected abstract _run(cancellationSignal: CancellationSignal): Promise<void>;
18
18
  }
@@ -21,7 +21,7 @@ __export(module_base_exports, {
21
21
  ModuleBase: () => ModuleBase
22
22
  });
23
23
  module.exports = __toCommonJS(module_base_exports);
24
- var import_cancellation_token = require("../utils/cancellation-token.js");
24
+ var import_cancellation = require("../cancellation/index.js");
25
25
  var import_module = require("./module.js");
26
26
  class ModuleBase {
27
27
  runPromise;
@@ -38,7 +38,7 @@ class ModuleBase {
38
38
  this.name = name;
39
39
  this.runPromise = Promise.resolve();
40
40
  this._state = import_module.ModuleState.Stopped;
41
- this.cancellationToken = new import_cancellation_token.CancellationToken();
41
+ this.cancellationToken = new import_cancellation.CancellationToken();
42
42
  }
43
43
  async run() {
44
44
  if (this._state != import_module.ModuleState.Stopped) {
@@ -1,4 +1,4 @@
1
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
1
+ import type { CancellationSignal } from '../cancellation/index.js';
2
2
  import type { MetricAggregation, MetricAggregationOptions } from '../utils/moving-metric.js';
3
3
  import { MovingMetric } from '../utils/moving-metric.js';
4
4
  import type { ModuleMetric } from './module.js';
@@ -24,6 +24,6 @@ export declare class ModuleMetricReporter {
24
24
  metric: ModuleMetric;
25
25
  reports: MetricReport<MetricAggregation>[];
26
26
  }[]): void;
27
- run(cancellationToken: ReadonlyCancellationToken): Promise<void>;
27
+ run(cancellationSignal: CancellationSignal): Promise<void>;
28
28
  private updateNameLengths;
29
29
  }
@@ -51,9 +51,9 @@ class ModuleMetricReporter {
51
51
  this.metricGroups.push({ groupName, registrations });
52
52
  this.updateNameLengths();
53
53
  }
54
- async run(cancellationToken) {
54
+ async run(cancellationSignal) {
55
55
  let counter = 0;
56
- while (cancellationToken.isUnset) {
56
+ while (cancellationSignal.isUnset) {
57
57
  for (const { registrations } of this.metricGroups) {
58
58
  for (const { metric, moving } of registrations) {
59
59
  moving.add(metric.getValue());
@@ -71,7 +71,7 @@ class ModuleMetricReporter {
71
71
  }
72
72
  }
73
73
  }
74
- await (0, import_timing.cancelableTimeout)(this.sampleInterval, cancellationToken);
74
+ await (0, import_timing.cancelableTimeout)(this.sampleInterval, cancellationSignal);
75
75
  }
76
76
  }
77
77
  updateNameLengths() {
@@ -1,10 +1,10 @@
1
- import type { ReadonlyCancellationToken } from '../../utils/cancellation-token.js';
2
- import type { Module } from '../module.js';
1
+ import type { CancellationSignal } from '../../cancellation/index.js';
3
2
  import { ModuleBase } from '../module-base.js';
4
- export type FunctionModuleFunction = (cancellationToken: ReadonlyCancellationToken) => void | Promise<void>;
3
+ import type { Module } from '../module.js';
4
+ export type FunctionModuleFunction = (cancellationToken: CancellationSignal) => void | Promise<void>;
5
5
  export declare class FunctionModule extends ModuleBase implements Module {
6
6
  private readonly fn;
7
7
  readonly metrics: {};
8
8
  constructor(fn: FunctionModuleFunction, name?: string);
9
- protected _run(cancellationToken: ReadonlyCancellationToken): Promise<void>;
9
+ protected _run(cancellationSignal: CancellationSignal): Promise<void>;
10
10
  }
@@ -29,7 +29,7 @@ class FunctionModule extends import_module_base.ModuleBase {
29
29
  super(name);
30
30
  this.fn = fn;
31
31
  }
32
- async _run(cancellationToken) {
33
- return this.fn(cancellationToken);
32
+ async _run(cancellationSignal) {
33
+ return this.fn(cancellationSignal);
34
34
  }
35
35
  }
@@ -1,6 +1,6 @@
1
+ import type { CancellationSignal } from '../../cancellation/index.js';
1
2
  import type { Resolvable } from '../../injector/interfaces.js';
2
3
  import { resolveArgumentType } from '../../injector/interfaces.js';
3
- import type { ReadonlyCancellationToken } from '../../utils/cancellation-token.js';
4
4
  import { ModuleBase } from '../module-base.js';
5
5
  import type { Module } from '../module.js';
6
6
  import { ModuleMetricType } from '../module.js';
@@ -23,6 +23,6 @@ export declare class WebServerModule extends ModuleBase implements Module, Resol
23
23
  readonly [resolveArgumentType]: WebServerModuleConfiguration;
24
24
  constructor();
25
25
  initialize(): void;
26
- protected _run(cancellationToken: ReadonlyCancellationToken): Promise<void>;
26
+ protected _run(cancellationSignal: CancellationSignal): Promise<void>;
27
27
  }
28
28
  export declare function configureWebServerModule(config?: Partial<WebServerModuleConfiguration>): void;
@@ -72,10 +72,10 @@ let WebServerModule = class WebServerModule2 extends import_module_base.ModuleBa
72
72
  this.apiGateway.registerApi((0, import_server.getApiControllerDefinition)(controller), controller);
73
73
  }
74
74
  }
75
- async _run(cancellationToken) {
75
+ async _run(cancellationSignal) {
76
76
  this.initialize();
77
77
  await this.httpServer.listen(this.config.port);
78
- const closePromise = cancellationToken.$set.then(async () => {
78
+ const closePromise = cancellationSignal.$set.then(async () => {
79
79
  await this.httpServer[import_disposable.disposeAsync]();
80
80
  });
81
81
  for await (const context of this.httpServer) {