@tstdl/base 0.88.7 → 0.89.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 (114) hide show
  1. package/api/index.d.ts +7 -3
  2. package/api/index.js +7 -3
  3. package/application/index.d.ts +5 -0
  4. package/application/index.js +5 -0
  5. package/authentication/client/authentication.service.d.ts +1 -1
  6. package/authentication/client/authentication.service.js +4 -4
  7. package/authentication/client/http-client.middleware.d.ts +2 -2
  8. package/authentication/client/module.d.ts +2 -2
  9. package/authentication/client/module.js +2 -2
  10. package/authentication/index.d.ts +7 -0
  11. package/authentication/index.js +7 -0
  12. package/browser/index.d.ts +5 -0
  13. package/browser/index.js +5 -0
  14. package/cancellation/index.d.ts +4 -0
  15. package/cancellation/index.js +4 -0
  16. package/collections/index.d.ts +5 -0
  17. package/collections/index.js +5 -0
  18. package/cookie/index.d.ts +5 -0
  19. package/cookie/index.js +5 -0
  20. package/data-structures/index.d.ts +5 -0
  21. package/data-structures/index.js +5 -0
  22. package/database/index.d.ts +5 -0
  23. package/database/index.js +5 -0
  24. package/database/mongo/index.d.ts +5 -0
  25. package/database/mongo/index.js +5 -0
  26. package/database/mongo/module.js +1 -1
  27. package/decorators/index.d.ts +5 -0
  28. package/decorators/index.js +5 -0
  29. package/disposable/index.d.ts +5 -0
  30. package/disposable/index.js +5 -0
  31. package/distributed-loop/index.d.ts +5 -0
  32. package/distributed-loop/index.js +5 -0
  33. package/enumerable/index.d.ts +5 -0
  34. package/enumerable/index.js +5 -0
  35. package/error/index.d.ts +5 -0
  36. package/error/index.js +5 -0
  37. package/examples/api/authentication.js +2 -2
  38. package/examples/api/basic-overview.js +1 -1
  39. package/examples/api/custom-authentication.js +2 -2
  40. package/examples/api/streaming.js +1 -1
  41. package/examples/http/client.js +1 -1
  42. package/function/index.d.ts +5 -0
  43. package/function/index.js +5 -0
  44. package/http/client/adapters/{undici-http-client.adapter.d.ts → undici.adapter.d.ts} +4 -2
  45. package/http/client/adapters/{undici-http-client.adapter.js → undici.adapter.js} +3 -15
  46. package/http/index.d.ts +6 -0
  47. package/http/index.js +6 -0
  48. package/http/server/index.d.ts +2 -1
  49. package/http/server/index.js +2 -1
  50. package/image-service/index.d.ts +6 -0
  51. package/image-service/index.js +6 -0
  52. package/index.d.ts +5 -0
  53. package/index.js +5 -0
  54. package/injector/index.d.ts +5 -0
  55. package/injector/index.js +5 -0
  56. package/json-path/index.d.ts +5 -0
  57. package/json-path/index.js +5 -0
  58. package/key-value-store/index.d.ts +6 -0
  59. package/key-value-store/index.js +6 -0
  60. package/lock/index.d.ts +7 -0
  61. package/lock/index.js +7 -0
  62. package/lock/mongo/lock.d.ts +1 -2
  63. package/lock/mongo/lock.js +9 -9
  64. package/lock/mongo/provider.d.ts +3 -7
  65. package/lock/mongo/provider.js +14 -24
  66. package/logger/index.d.ts +7 -0
  67. package/logger/index.js +7 -0
  68. package/mail/index.d.ts +6 -1
  69. package/mail/index.js +6 -1
  70. package/mail/repositories/index.d.ts +2 -1
  71. package/mail/repositories/index.js +2 -1
  72. package/memory/index.d.ts +5 -0
  73. package/memory/index.js +5 -0
  74. package/message-bus/index.d.ts +7 -0
  75. package/message-bus/index.js +7 -0
  76. package/migration/index.d.ts +6 -0
  77. package/migration/index.js +6 -0
  78. package/module/index.d.ts +6 -0
  79. package/module/index.js +6 -0
  80. package/object-storage/index.d.ts +8 -2
  81. package/object-storage/index.js +8 -2
  82. package/openid-connect/index.d.ts +5 -0
  83. package/openid-connect/index.js +5 -0
  84. package/package.json +7 -24
  85. package/password/index.d.ts +5 -0
  86. package/password/index.js +5 -0
  87. package/pdf/pdf.service.d.ts +5 -0
  88. package/pdf/pdf.service.js +5 -0
  89. package/pool/index.d.ts +5 -0
  90. package/pool/index.js +5 -0
  91. package/promise/cancelable-promise.d.ts +10 -2
  92. package/promise/cancelable-promise.js +23 -19
  93. package/promise/custom-promise.d.ts +6 -0
  94. package/promise/custom-promise.js +14 -0
  95. package/promise/deferred-promise.d.ts +3 -3
  96. package/promise/deferred-promise.js +5 -8
  97. package/promise/index.d.ts +6 -0
  98. package/promise/index.js +6 -0
  99. package/promise/lazy-promise.d.ts +6 -6
  100. package/promise/lazy-promise.js +23 -15
  101. package/promise/types.d.ts +3 -0
  102. package/promise/types.js +1 -0
  103. package/utils/type-guards.d.ts +6 -0
  104. package/utils/type-guards.js +7 -0
  105. package/container/decorators.d.ts +0 -2
  106. package/container/decorators.js +0 -1
  107. package/container/index.d.ts +0 -3
  108. package/container/index.js +0 -3
  109. package/container/interfaces.d.ts +0 -2
  110. package/container/interfaces.js +0 -1
  111. package/container/token.d.ts +0 -2
  112. package/container/token.js +0 -1
  113. package/http/client/adapters/index.d.ts +0 -1
  114. package/http/client/adapters/index.js +0 -1
@@ -1,10 +1,10 @@
1
+ import type { PromiseExecutor } from './types.js';
1
2
  export declare const enum PromiseState {
2
3
  Pending = 0,
3
4
  Resolved = 1,
4
5
  Rejected = 2
5
6
  }
6
- export declare class DeferredPromise<T = void> implements Promise<T> {
7
- static readonly [Symbol.species]: PromiseConstructor;
7
+ export declare class DeferredPromise<T = void> extends Promise<T> {
8
8
  private backingPromise;
9
9
  private resolvePromise;
10
10
  private rejectPromise;
@@ -14,7 +14,7 @@ export declare class DeferredPromise<T = void> implements Promise<T> {
14
14
  get rejected(): boolean;
15
15
  get pending(): boolean;
16
16
  get settled(): boolean;
17
- constructor(executor?: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void);
17
+ constructor(executor?: PromiseExecutor<T>);
18
18
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
19
19
  catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
20
20
  finally(onfinally?: (() => void) | null | undefined): Promise<T>;
@@ -4,8 +4,7 @@ export var PromiseState;
4
4
  PromiseState[PromiseState["Resolved"] = 1] = "Resolved";
5
5
  PromiseState[PromiseState["Rejected"] = 2] = "Rejected";
6
6
  })(PromiseState || (PromiseState = {}));
7
- export class DeferredPromise {
8
- static [Symbol.species] = Promise;
7
+ export class DeferredPromise extends Promise {
9
8
  backingPromise;
10
9
  resolvePromise;
11
10
  rejectPromise;
@@ -24,21 +23,19 @@ export class DeferredPromise {
24
23
  return this.state != PromiseState.Pending;
25
24
  }
26
25
  constructor(executor) {
26
+ super(() => { });
27
27
  this.reset();
28
28
  if (executor != undefined) {
29
29
  executor((value) => this.resolve(value), (reason) => this.reject(reason));
30
30
  }
31
31
  }
32
- // eslint-disable-next-line @typescript-eslint/promise-function-async
33
- then(onfulfilled, onrejected) {
32
+ async then(onfulfilled, onrejected) {
34
33
  return this.backingPromise.then(onfulfilled, onrejected);
35
34
  }
36
- // eslint-disable-next-line @typescript-eslint/promise-function-async
37
- catch(onrejected) {
35
+ async catch(onrejected) {
38
36
  return this.backingPromise.catch(onrejected);
39
37
  }
40
- // eslint-disable-next-line @typescript-eslint/promise-function-async
41
- finally(onfinally) {
38
+ async finally(onfinally) {
42
39
  return this.backingPromise.finally(onfinally);
43
40
  }
44
41
  resolve(value) {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Advanced Promises
3
+ *
4
+ * @module Promise
5
+ */
1
6
  export * from './cancelable-promise.js';
2
7
  export * from './deferred-promise.js';
3
8
  export * from './lazy-promise.js';
9
+ export * from './types.js';
package/promise/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Advanced Promises
3
+ *
4
+ * @module Promise
5
+ */
1
6
  export * from './cancelable-promise.js';
2
7
  export * from './deferred-promise.js';
3
8
  export * from './lazy-promise.js';
9
+ export * from './types.js';
@@ -1,11 +1,11 @@
1
- type PromiseExecutor<T> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void;
2
- export declare class LazyPromise<T> implements Promise<T> {
3
- static readonly [Symbol.species]: PromiseConstructor;
4
- private readonly backingPromise;
1
+ import { CustomPromise } from './custom-promise.js';
2
+ import type { PromiseExecutor } from './types.js';
3
+ export declare class LazyPromise<T> extends CustomPromise<T> {
4
+ #private;
5
5
  readonly [Symbol.toStringTag] = "LazyPromise";
6
- constructor(executorOrPromiseProvider: () => (Promise<T> | PromiseExecutor<T>));
6
+ constructor(executorOrPromiseProvider: PromiseExecutor<T> | (() => PromiseLike<T>));
7
7
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
8
8
  catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
9
9
  finally(onfinally?: (() => void) | null | undefined): Promise<T>;
10
+ private execute;
10
11
  }
11
- export {};
@@ -1,25 +1,33 @@
1
- import { lazyProperty } from '../utils/object/lazy-property.js';
2
- import { isPromise } from '../utils/type-guards.js';
3
- export class LazyPromise {
4
- static [Symbol.species] = Promise;
5
- backingPromise;
1
+ import { isPromiseLike } from '../utils/type-guards.js';
2
+ import { CustomPromise } from './custom-promise.js';
3
+ export class LazyPromise extends CustomPromise {
4
+ #executed = false;
5
+ #executorOrPromiseProvider;
6
6
  [Symbol.toStringTag] = 'LazyPromise';
7
7
  constructor(executorOrPromiseProvider) {
8
- lazyProperty(this, 'backingPromise', async () => {
9
- const providedValue = executorOrPromiseProvider();
10
- if (isPromise(providedValue)) {
11
- return providedValue;
12
- }
13
- return new Promise(providedValue);
14
- });
8
+ super();
9
+ this.#executorOrPromiseProvider = executorOrPromiseProvider;
15
10
  }
16
11
  async then(onfulfilled, onrejected) {
17
- return this.backingPromise.then(onfulfilled, onrejected);
12
+ this.execute();
13
+ return super.then(onfulfilled, onrejected);
18
14
  }
19
15
  async catch(onrejected) {
20
- return this.backingPromise.catch(onrejected);
16
+ this.execute();
17
+ return super.catch(onrejected);
21
18
  }
22
19
  async finally(onfinally) {
23
- return this.backingPromise.finally(onfinally);
20
+ this.execute();
21
+ return super.finally(onfinally);
22
+ }
23
+ execute() {
24
+ if (this.#executed) {
25
+ return;
26
+ }
27
+ this.#executed = true;
28
+ const result = this.#executorOrPromiseProvider(this.resolve, this.reject);
29
+ if (isPromiseLike(result)) {
30
+ this.resolve(result);
31
+ }
24
32
  }
25
33
  }
@@ -0,0 +1,3 @@
1
+ export type PromiseExecutor<T> = ConstructorParameters<typeof Promise<T>>[0];
2
+ export type PromiseResolveFunction<T> = (value: T | PromiseLike<T>) => void;
3
+ export type PromiseRejectFunction = (reason?: any) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -252,6 +252,12 @@ export declare const assertPromise: AssertFunction<Promise<any>>;
252
252
  export declare const assertNotPromise: AssertNotFunction<Promise<any>>;
253
253
  export declare const assertPromisePass: AssertPassFunction<Promise<any>>;
254
254
  export declare const assertNotPromisePass: AssertNotPassFunction<Promise<any>>;
255
+ export declare const isPromiseLike: IsFunction<PromiseLike<any>>;
256
+ export declare const isNotPromiseLike: IsNotFunction<PromiseLike<any>>;
257
+ export declare const assertPromiseLike: AssertFunction<PromiseLike<any>>;
258
+ export declare const assertNotPromiseLike: AssertNotFunction<PromiseLike<any>>;
259
+ export declare const assertPromiseLikePass: AssertPassFunction<PromiseLike<any>>;
260
+ export declare const assertNotPromiseLikePass: AssertNotPassFunction<PromiseLike<any>>;
255
261
  export declare const isError: IsFunction<Error>;
256
262
  export declare const isNotError: IsNotFunction<Error>;
257
263
  export declare const assertError: AssertFunction<Error>;
@@ -313,6 +313,13 @@ export const assertPromise = promiseGuards.assertPromise;
313
313
  export const assertNotPromise = promiseGuards.assertNotPromise;
314
314
  export const assertPromisePass = promiseGuards.assertPromisePass;
315
315
  export const assertNotPromisePass = promiseGuards.assertNotPromisePass;
316
+ const promiseLikeGuards = createGuards('PromiseLike', (value) => isPromise(value) || ((((typeof value == 'object') && (value != null)) || isFunction(value)) && ((typeof value.then) == 'function')));
317
+ export const isPromiseLike = promiseLikeGuards.isPromiseLike;
318
+ export const isNotPromiseLike = promiseLikeGuards.isNotPromiseLike;
319
+ export const assertPromiseLike = promiseLikeGuards.assertPromiseLike;
320
+ export const assertNotPromiseLike = promiseLikeGuards.assertNotPromiseLike;
321
+ export const assertPromiseLikePass = promiseLikeGuards.assertPromiseLikePass;
322
+ export const assertNotPromiseLikePass = promiseLikeGuards.assertNotPromiseLikePass;
316
323
  const errorGuards = createInstanceGuards('error', Error);
317
324
  export const isError = errorGuards.isError;
318
325
  export const isNotError = errorGuards.isNotError;
@@ -1,2 +0,0 @@
1
- export { ForwardArg as forwardArg, ForwardRef as forwardRef, Inject as inject, InjectArg as injectArg, Injectable as injectable, Optional as optional, ReplaceClass as replaceClass, ResolveArg as resolveArg, ResolveArgProvider as resolveArgProvider, Scoped as scoped, Singleton as singleton } from '../injector/decorators.js';
2
- export type { InjectableOptionsWithoutLifecycle } from '../injector/decorators.js';
@@ -1 +0,0 @@
1
- export { ForwardArg as forwardArg, ForwardRef as forwardRef, Inject as inject, InjectArg as injectArg, Injectable as injectable, Optional as optional, ReplaceClass as replaceClass, ResolveArg as resolveArg, ResolveArgProvider as resolveArgProvider, Scoped as scoped, Singleton as singleton } from '../injector/decorators.js';
@@ -1,3 +0,0 @@
1
- export * from './decorators.js';
2
- export * from './interfaces.js';
3
- export * from './token.js';
@@ -1,3 +0,0 @@
1
- export * from './decorators.js';
2
- export * from './interfaces.js';
3
- export * from './token.js';
@@ -1,2 +0,0 @@
1
- export { afterResolve, resolveArgumentType } from '../injector/interfaces.js';
2
- export type { AfterResolve, Resolvable as Injectable, ResolveArgument as InjectableArgument } from '../injector/interfaces.js';
@@ -1 +0,0 @@
1
- export { afterResolve, resolveArgumentType } from '../injector/interfaces.js';
@@ -1,2 +0,0 @@
1
- export { ReifyingInjectionToken, getTokenName, injectionToken } from '../injector/token.js';
2
- export type { ArgumentedInjectionToken, InjectionToken, SimpleInjectionToken } from '../injector/token.js';
@@ -1 +0,0 @@
1
- export { ReifyingInjectionToken, getTokenName, injectionToken } from '../injector/token.js';
@@ -1 +0,0 @@
1
- export * from './undici-http-client.adapter.js';
@@ -1 +0,0 @@
1
- export * from './undici-http-client.adapter.js';