@tstdl/base 0.88.7 → 0.89.0

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 (109) 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 +1 -1
  38. package/examples/api/custom-authentication.js +1 -1
  39. package/function/index.d.ts +5 -0
  40. package/function/index.js +5 -0
  41. package/http/client/index.d.ts +1 -0
  42. package/http/client/index.js +1 -0
  43. package/http/index.d.ts +6 -0
  44. package/http/index.js +6 -0
  45. package/http/server/index.d.ts +2 -1
  46. package/http/server/index.js +2 -1
  47. package/image-service/index.d.ts +6 -0
  48. package/image-service/index.js +6 -0
  49. package/index.d.ts +5 -0
  50. package/index.js +5 -0
  51. package/injector/index.d.ts +5 -0
  52. package/injector/index.js +5 -0
  53. package/json-path/index.d.ts +5 -0
  54. package/json-path/index.js +5 -0
  55. package/key-value-store/index.d.ts +6 -0
  56. package/key-value-store/index.js +6 -0
  57. package/lock/index.d.ts +7 -0
  58. package/lock/index.js +7 -0
  59. package/lock/mongo/lock.d.ts +1 -2
  60. package/lock/mongo/lock.js +9 -9
  61. package/lock/mongo/provider.d.ts +3 -7
  62. package/lock/mongo/provider.js +14 -24
  63. package/logger/index.d.ts +7 -0
  64. package/logger/index.js +7 -0
  65. package/mail/index.d.ts +6 -1
  66. package/mail/index.js +6 -1
  67. package/mail/repositories/index.d.ts +2 -1
  68. package/mail/repositories/index.js +2 -1
  69. package/memory/index.d.ts +5 -0
  70. package/memory/index.js +5 -0
  71. package/message-bus/index.d.ts +7 -0
  72. package/message-bus/index.js +7 -0
  73. package/migration/index.d.ts +6 -0
  74. package/migration/index.js +6 -0
  75. package/module/index.d.ts +6 -0
  76. package/module/index.js +6 -0
  77. package/object-storage/index.d.ts +8 -2
  78. package/object-storage/index.js +8 -2
  79. package/openid-connect/index.d.ts +5 -0
  80. package/openid-connect/index.js +5 -0
  81. package/package.json +6 -24
  82. package/password/index.d.ts +5 -0
  83. package/password/index.js +5 -0
  84. package/pdf/pdf.service.d.ts +5 -0
  85. package/pdf/pdf.service.js +5 -0
  86. package/pool/index.d.ts +5 -0
  87. package/pool/index.js +5 -0
  88. package/promise/cancelable-promise.d.ts +10 -2
  89. package/promise/cancelable-promise.js +23 -19
  90. package/promise/custom-promise.d.ts +6 -0
  91. package/promise/custom-promise.js +14 -0
  92. package/promise/deferred-promise.d.ts +3 -3
  93. package/promise/deferred-promise.js +5 -8
  94. package/promise/index.d.ts +6 -0
  95. package/promise/index.js +6 -0
  96. package/promise/lazy-promise.d.ts +6 -6
  97. package/promise/lazy-promise.js +23 -15
  98. package/promise/types.d.ts +3 -0
  99. package/promise/types.js +1 -0
  100. package/utils/type-guards.d.ts +6 -0
  101. package/utils/type-guards.js +7 -0
  102. package/container/decorators.d.ts +0 -2
  103. package/container/decorators.js +0 -1
  104. package/container/index.d.ts +0 -3
  105. package/container/index.js +0 -3
  106. package/container/interfaces.d.ts +0 -2
  107. package/container/interfaces.js +0 -1
  108. package/container/token.d.ts +0 -2
  109. package/container/token.js +0 -1
@@ -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';