@tstdl/base 0.86.0-beta8 → 0.86.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.
@@ -237,7 +237,7 @@ class Injector {
237
237
  return registration.resolutions.get(argumentIdentity);
238
238
  }
239
239
  const value = this._resolveProvider(resolutionTag, registration, resolveArgument, options, context, injectionContext, chain);
240
- const resolution = { tag: resolutionTag, registration, value, argument, chain };
240
+ const resolution = { tag: resolutionTag, registration, value, argument: injectionContext.argument, chain };
241
241
  context.resolutions.push(resolution);
242
242
  if (resolutionScoped) {
243
243
  context.resolutionScopedResolutions.setFlat(token, argumentIdentity, resolution);
@@ -478,7 +478,7 @@ function throwOnPromise(value, type, chain) {
478
478
  }
479
479
  }
480
480
  function checkOverflow(chain, context) {
481
- if (chain.length > 750 || ++context.resolves > 750) {
481
+ if (chain.length > 100 || ++context.resolves > 7500) {
482
482
  throw new import_resolve_error.ResolveError("Resolve stack overflow. This can happen on circular dependencies with transient lifecycles and self reference. Use scoped or singleton lifecycle or forwardRef instead.", chain);
483
483
  }
484
484
  }
@@ -24,7 +24,6 @@ __export(web_server_module_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(web_server_module_exports);
26
26
  var import_server = require("../../api/server/index.js");
27
- var import_log = require("../../decorators/log.js");
28
27
  var import_disposable = require("../../disposable/disposable.js");
29
28
  var import_http_server = require("../../http/server/http-server.js");
30
29
  var import_decorators = require("../../injector/decorators.js");
@@ -87,7 +86,6 @@ let WebServerModule = class WebServerModule2 extends import_module_base.ModuleBa
87
86
  };
88
87
  WebServerModule = __decorate([
89
88
  (0, import_decorators.Singleton)({ defaultArgumentProvider: () => webServerModuleConfiguration }),
90
- (0, import_log.Log)(),
91
89
  __metadata("design:paramtypes", [])
92
90
  ], WebServerModule);
93
91
  function configureWebServerModule(config) {
@@ -4,5 +4,5 @@ export declare abstract class ObjectStorageProvider<T extends ObjectStorage = Ob
4
4
  * get an object storage instance
5
5
  * @param module name for object container (module) to store objects in. Can be used to isolate objects like profile pictures and log files
6
6
  */
7
- abstract get(module: string): T | Promise<T>;
7
+ abstract get(module: string): T;
8
8
  }
@@ -17,10 +17,6 @@ export declare class S3ObjectStorageProviderConfig {
17
17
  * mutually exclusive with bucket
18
18
  */
19
19
  bucketPerModule?: boolean;
20
- /**
21
- * create bucket for requested storage module if it does not exist
22
- */
23
- autoCreateBucket?: boolean;
24
20
  /**
25
21
  * s3 access key
26
22
  */
@@ -34,9 +30,8 @@ export declare const bucketPerModule: unique symbol;
34
30
  export declare class S3ObjectStorageProvider extends ObjectStorageProvider<S3ObjectStorage> {
35
31
  private readonly client;
36
32
  private readonly bucket;
37
- private readonly createBucket;
38
33
  constructor(config: S3ObjectStorageProviderConfig);
39
- get(module: string): Promise<S3ObjectStorage>;
34
+ get(module: string): S3ObjectStorage;
40
35
  }
41
36
  /**
42
37
  * configure s3 object storage provider
@@ -61,10 +61,6 @@ class S3ObjectStorageProviderConfig {
61
61
  * mutually exclusive with bucket
62
62
  */
63
63
  bucketPerModule;
64
- /**
65
- * create bucket for requested storage module if it does not exist
66
- */
67
- autoCreateBucket;
68
64
  /**
69
65
  * s3 access key
70
66
  */
@@ -78,14 +74,12 @@ const bucketPerModule = Symbol("bucket per module");
78
74
  let S3ObjectStorageProvider = class S3ObjectStorageProvider2 extends import_object_storage.ObjectStorageProvider {
79
75
  client;
80
76
  bucket;
81
- createBucket;
82
77
  constructor(config) {
83
78
  super();
84
79
  const { hostname, port, protocol } = new URL(config.endpoint);
85
80
  if ((0, import_type_guards.isDefined)(config.bucket) && config.bucketPerModule == true) {
86
81
  throw new Error("bucket and bucketPerModule is mutually exclusive");
87
82
  }
88
- this.createBucket = config.autoCreateBucket ?? false;
89
83
  this.client = new import_minio.Client({
90
84
  endPoint: hostname,
91
85
  port: port.length > 0 ? parseInt(port, 10) : void 0,
@@ -95,14 +89,10 @@ let S3ObjectStorageProvider = class S3ObjectStorageProvider2 extends import_obje
95
89
  });
96
90
  this.bucket = (0, import_type_guards.assertDefinedPass)(config.bucketPerModule == true ? true : config.bucket, "either bucket or bucketPerModule must be specified");
97
91
  }
98
- async get(module2) {
92
+ get(module2) {
99
93
  const bucket = this.bucket == true ? module2 : (0, import_type_guards.assertStringPass)(this.bucket);
100
94
  const prefix = this.bucket == true ? "" : module2 == "" ? "" : `${module2}/`;
101
- const objectStorage = new import_s3_object_storage.S3ObjectStorage(this.client, bucket, module2, prefix);
102
- if (this.createBucket) {
103
- await objectStorage.ensureBucketExists();
104
- }
105
- return objectStorage;
95
+ return new import_s3_object_storage.S3ObjectStorage(this.client, bucket, module2, prefix);
106
96
  }
107
97
  };
108
98
  S3ObjectStorageProvider = __decorate([
@@ -152,7 +152,10 @@ let S3ObjectStorage = class S3ObjectStorage2 extends import_object_storage.Objec
152
152
  S3ObjectStorage = __decorate([
153
153
  (0, import_decorators.Singleton)({
154
154
  provider: {
155
- useFactory: async (argument, context) => context.resolve(import_s3_object_storage_provider.S3ObjectStorageProvider).get((0, import_type_guards.assertStringPass)(argument, "resolve argument must be a string (object storage module)"))
155
+ useFactory: (argument, context) => context.resolve(import_s3_object_storage_provider.S3ObjectStorageProvider).get((0, import_type_guards.assertStringPass)(argument, "resolve argument must be a string (object storage module)")),
156
+ async afterResolve(value) {
157
+ await value.ensureBucketExists();
158
+ }
156
159
  }
157
160
  }),
158
161
  __metadata("design:paramtypes", [import_minio.Client, String, String, String])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.86.0-beta8",
3
+ "version": "0.86.0",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -47,7 +47,7 @@
47
47
  "peerDependencies": {
48
48
  "@elastic/elasticsearch": "^8.9",
49
49
  "@koa/router": "^12.0",
50
- "@tstdl/angular": "^0.85",
50
+ "@tstdl/angular": "^0.86",
51
51
  "@zxcvbn-ts/core": "^3.0",
52
52
  "@zxcvbn-ts/language-common": "^3.0",
53
53
  "@zxcvbn-ts/language-de": "^3.0",
@@ -1,99 +0,0 @@
1
- import type { Record, TypedOmit } from '../types.js';
2
- import type { Observable } from 'rxjs';
3
- import type { Injectable, InjectableArgument } from './interfaces.js';
4
- import type { Provider } from './provider.js';
5
- import type { InjectionToken } from './token.js';
6
- import type { ArgumentProvider, Mapper } from './types.js';
7
- export declare const injectMetadataSymbol: unique symbol;
8
- /**
9
- * transient: a new instance will be created with each resolve
10
- * singleton: each resolve will return the same instance
11
- * resolution: the same instance will be resolved for each resolution of this dependency during a single resolution chain
12
- */
13
- export type Lifecycle = 'transient' | 'singleton' | 'resolution';
14
- export type RegistrationOptions<T, A = unknown> = {
15
- lifecycle?: Lifecycle;
16
- /** default resolve argument used when neither token nor explicit resolve argument is provided */
17
- defaultArgument?: InjectableArgument<T, A>;
18
- /** default resolve argument used when neither token nor explicit resolve argument is provided */
19
- defaultArgumentProvider?: ArgumentProvider<InjectableArgument<T, A>>;
20
- /**
21
- * value to distinguish scoped and singleton instances based on argument
22
- * by default it uses strict equality (===) on the original argument,
23
- * so modifications to argument objects and literal objects in the call
24
- * may not yield the expected result
25
- *
26
- * hint: {@link JSON.stringify} is a simple solution for many use cases,
27
- * but will fail if properties have different order
28
- */
29
- argumentIdentityProvider?: Mapper<InjectableArgument<T, A> | undefined>;
30
- /** function which gets called after a resolve */
31
- initializer?: (instance: T) => any;
32
- /** custom metadata */
33
- metadata?: Record;
34
- };
35
- export type Registration<T = any, A = any> = {
36
- token: InjectionToken<T, A>;
37
- provider: Provider<T, A>;
38
- options: RegistrationOptions<T, A>;
39
- instances: Map<any, T>;
40
- };
41
- export declare class Container {
42
- private readonly registrationMap;
43
- private readonly registrationSubject;
44
- /** emits on new registration */
45
- readonly registration$: Observable<Registration>;
46
- /** all registrations */
47
- get registrations(): Iterable<Registration>;
48
- constructor();
49
- /**
50
- * register a provider for a token
51
- * @param token token to register
52
- * @param provider provider used to resolve the token
53
- * @param options registration options
54
- */
55
- register<T, A = any>(token: InjectionToken<T, A>, provider: Provider<T, A>, options?: RegistrationOptions<T, A>): void;
56
- /**
57
- * register a provider for a token as a singleton. Alias for {@link register} with `singleton` lifecycle
58
- * @param token token to register
59
- * @param provider provider used to resolve the token
60
- * @param options registration options
61
- */
62
- registerSingleton<T, A = any>(token: InjectionToken<T, A>, provider: Provider<T, A>, options?: TypedOmit<RegistrationOptions<T, A>, 'lifecycle'>): void;
63
- /**
64
- * check if token has a registered provider
65
- * @param token token check
66
- */
67
- hasRegistration(token: InjectionToken): boolean;
68
- /**
69
- * get registration
70
- * @param token token to get registration for
71
- */
72
- getRegistration<T, A>(token: InjectionToken<T, A>): Registration<T, A>;
73
- /**
74
- * try to get registration
75
- * @param token token to get registration for
76
- */
77
- tryGetRegistration<T, A>(token: InjectionToken<T, A>): Registration<T, A> | undefined;
78
- /**
79
- * resolve a token
80
- * @param token token to resolve
81
- * @param argument argument used for resolving (overrides token and default arguments)
82
- * @returns
83
- */
84
- resolve<T, A = T extends Injectable<infer AInject> ? AInject : any>(token: InjectionToken<T, A>, argument?: T extends Injectable<infer AInject> ? AInject : A, instances?: [InjectionToken, any][]): T;
85
- /**
86
- * resolve a token
87
- * @param token token to resolve
88
- * @param argument argument used for resolving (overrides token and default arguments)
89
- * @returns
90
- */
91
- resolveAsync<T, A = T extends Injectable<infer AInject> ? AInject : any>(token: InjectionToken<T, A>, argument?: T extends Injectable<infer AInject> ? AInject : A, instances?: [InjectionToken, any][]): Promise<T>;
92
- private _resolve;
93
- private _resolveAsync;
94
- private resolveInjection;
95
- private resolveInjectionAsync;
96
- private getResolveContext;
97
- private addInstancesToResolveContext;
98
- }
99
- export declare const container: Container;