@forklaunch/core 0.3.4 → 0.3.6
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/lib/services/index.d.ts +42 -119
 - package/package.json +13 -13
 
    
        package/lib/services/index.d.ts
    CHANGED
    
    | 
         @@ -1,111 +1,50 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import {
         
     | 
| 
       2 
     | 
    
         
            -
              AnySchemaValidator,
         
     | 
| 
       3 
     | 
    
         
            -
              IdiomaticSchema,
         
     | 
| 
       4 
     | 
    
         
            -
              ParseResult,
         
     | 
| 
       5 
     | 
    
         
            -
              Schema
         
     | 
| 
       6 
     | 
    
         
            -
            } from '@forklaunch/validator';
         
     | 
| 
      
 1 
     | 
    
         
            +
            import { AnySchemaValidator, IdiomaticSchema, Schema, ParseResult } from '@forklaunch/validator';
         
     | 
| 
       7 
2 
     | 
    
         
             
            import { EntityManager as EntityManager$1 } from '@mikro-orm/core';
         
     | 
| 
       8 
3 
     | 
    
         | 
| 
       9 
4 
     | 
    
         
             
            declare enum Lifetime {
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                Singleton = 0,
         
     | 
| 
      
 6 
     | 
    
         
            +
                Transient = 1,
         
     | 
| 
      
 7 
     | 
    
         
            +
                Scoped = 2
         
     | 
| 
       13 
8 
     | 
    
         
             
            }
         
     | 
| 
       14 
9 
     | 
    
         
             
            type Singleton<Value> = {
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
                lifetime: Lifetime.Singleton;
         
     | 
| 
      
 11 
     | 
    
         
            +
                value: Value;
         
     | 
| 
       17 
12 
     | 
    
         
             
            };
         
     | 
| 
       18 
13 
     | 
    
         
             
            type Constructed<Args, Return> = {
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                args: Args,
         
     | 
| 
       22 
     | 
    
         
            -
                resolve: <T extends keyof Args>(
         
     | 
| 
       23 
     | 
    
         
            -
                  token: T,
         
     | 
| 
       24 
     | 
    
         
            -
                  context?: Record<string, unknown>
         
     | 
| 
       25 
     | 
    
         
            -
                ) => Args[T],
         
     | 
| 
       26 
     | 
    
         
            -
                context: Record<string, unknown>
         
     | 
| 
       27 
     | 
    
         
            -
              ) => Return;
         
     | 
| 
      
 14 
     | 
    
         
            +
                lifetime: Lifetime.Transient | Lifetime.Scoped;
         
     | 
| 
      
 15 
     | 
    
         
            +
                factory: (args: Args, resolve: <T extends keyof Args>(token: T, context?: Record<string, unknown>) => Args[T], context: Record<string, unknown>) => Return;
         
     | 
| 
       28 
16 
     | 
    
         
             
            };
         
     | 
| 
       29 
17 
     | 
    
         
             
            type Constructor = new (...args: never[]) => unknown;
         
     | 
| 
       30 
     | 
    
         
            -
            type SchemaConstructor<SV extends AnySchemaValidator> = new (
         
     | 
| 
       31 
     | 
    
         
            -
              ...args: unknown[]
         
     | 
| 
       32 
     | 
    
         
            -
            ) => IdiomaticSchema<SV>;
         
     | 
| 
      
 18 
     | 
    
         
            +
            type SchemaConstructor<SV extends AnySchemaValidator> = new (...args: unknown[]) => IdiomaticSchema<SV>;
         
     | 
| 
       33 
19 
     | 
    
         
             
            type Function = (...args: never[]) => unknown;
         
     | 
| 
       34 
     | 
    
         
            -
            type SchemaFunction<SV extends AnySchemaValidator> = (
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              string,
         
     | 
| 
       39 
     | 
    
         
            -
              | Function
         
     | 
| 
       40 
     | 
    
         
            -
              | SchemaFunction<SV>
         
     | 
| 
       41 
     | 
    
         
            -
              | Constructor
         
     | 
| 
       42 
     | 
    
         
            -
              | SchemaConstructor<SV>
         
     | 
| 
       43 
     | 
    
         
            -
              | IdiomaticSchema<SV>
         
     | 
| 
       44 
     | 
    
         
            -
            >;
         
     | 
| 
       45 
     | 
    
         
            -
            type ResolvedConfigValidator<
         
     | 
| 
       46 
     | 
    
         
            -
              SV extends AnySchemaValidator,
         
     | 
| 
       47 
     | 
    
         
            -
              CV extends ConfigValidator<SV>
         
     | 
| 
       48 
     | 
    
         
            -
            > = {
         
     | 
| 
       49 
     | 
    
         
            -
              [M in keyof CV]: CV[M] extends SchemaConstructor<SV>
         
     | 
| 
       50 
     | 
    
         
            -
                ? Schema<InstanceType<CV[M]>, SV>
         
     | 
| 
       51 
     | 
    
         
            -
                : CV[M] extends SchemaFunction<SV>
         
     | 
| 
       52 
     | 
    
         
            -
                  ? Schema<ReturnType<CV[M]>, SV>
         
     | 
| 
       53 
     | 
    
         
            -
                  : CV[M] extends Function
         
     | 
| 
       54 
     | 
    
         
            -
                    ? ReturnType<CV[M]>
         
     | 
| 
       55 
     | 
    
         
            -
                    : CV[M] extends Constructor
         
     | 
| 
       56 
     | 
    
         
            -
                      ? InstanceType<CV[M]>
         
     | 
| 
       57 
     | 
    
         
            -
                      : Schema<CV[M], SV>;
         
     | 
| 
      
 20 
     | 
    
         
            +
            type SchemaFunction<SV extends AnySchemaValidator> = (args: unknown) => IdiomaticSchema<SV>;
         
     | 
| 
      
 21 
     | 
    
         
            +
            type ConfigValidator<SV extends AnySchemaValidator> = Record<string, Function | SchemaFunction<SV> | Constructor | SchemaConstructor<SV> | IdiomaticSchema<SV>>;
         
     | 
| 
      
 22 
     | 
    
         
            +
            type ResolvedConfigValidator<SV extends AnySchemaValidator, CV extends ConfigValidator<SV>> = {
         
     | 
| 
      
 23 
     | 
    
         
            +
                [M in keyof CV]: CV[M] extends SchemaConstructor<SV> ? Schema<InstanceType<CV[M]>, SV> : CV[M] extends SchemaFunction<SV> ? Schema<ReturnType<CV[M]>, SV> : CV[M] extends Function ? ReturnType<CV[M]> : CV[M] extends Constructor ? InstanceType<CV[M]> : Schema<CV[M], SV>;
         
     | 
| 
       58 
24 
     | 
    
         
             
            };
         
     | 
| 
       59 
     | 
    
         
            -
            type ScopedDependencyFactory<
         
     | 
| 
       60 
     | 
    
         
            -
              SV extends AnySchemaValidator,
         
     | 
| 
       61 
     | 
    
         
            -
              CV extends ConfigValidator<SV>,
         
     | 
| 
       62 
     | 
    
         
            -
              M extends keyof CV
         
     | 
| 
       63 
     | 
    
         
            -
            > = (scope?: ConfigInjector<SV, CV>) => ResolvedConfigValidator<SV, CV>[M];
         
     | 
| 
      
 25 
     | 
    
         
            +
            type ScopedDependencyFactory<SV extends AnySchemaValidator, CV extends ConfigValidator<SV>, M extends keyof CV> = (scope?: ConfigInjector<SV, CV>) => ResolvedConfigValidator<SV, CV>[M];
         
     | 
| 
       64 
26 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
            declare class ConfigInjector<
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                 
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                 
     | 
| 
       79 
     | 
    
         
            -
                 
     | 
| 
       80 
     | 
    
         
            -
                 
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                    | Constructed<
         
     | 
| 
       84 
     | 
    
         
            -
                        Omit<ResolvedConfigValidator<SV, CV>, K>,
         
     | 
| 
       85 
     | 
    
         
            -
                        ResolvedConfigValidator<SV, CV>[K]
         
     | 
| 
       86 
     | 
    
         
            -
                      >;
         
     | 
| 
       87 
     | 
    
         
            -
                }
         
     | 
| 
       88 
     | 
    
         
            -
              );
         
     | 
| 
       89 
     | 
    
         
            -
              safeValidateConfigSingletons(): ParseResult<ValidConfigInjector<SV, CV>>;
         
     | 
| 
       90 
     | 
    
         
            -
              validateConfigSingletons(configName: string): ValidConfigInjector<SV, CV>;
         
     | 
| 
       91 
     | 
    
         
            -
              resolve<T extends keyof CV>(
         
     | 
| 
       92 
     | 
    
         
            -
                token: T,
         
     | 
| 
       93 
     | 
    
         
            -
                context?: Record<string, unknown>,
         
     | 
| 
       94 
     | 
    
         
            -
                resolutionPath?: (keyof CV)[]
         
     | 
| 
       95 
     | 
    
         
            -
              ): ResolvedConfigValidator<SV, CV>[T];
         
     | 
| 
       96 
     | 
    
         
            -
              scopedResolver<T extends keyof CV>(
         
     | 
| 
       97 
     | 
    
         
            -
                token: T,
         
     | 
| 
       98 
     | 
    
         
            -
                context?: Record<string, unknown>,
         
     | 
| 
       99 
     | 
    
         
            -
                resolutionPath?: (keyof CV)[]
         
     | 
| 
       100 
     | 
    
         
            -
              ): (scope?: ConfigInjector<SV, CV>) => ResolvedConfigValidator<SV, CV>[T];
         
     | 
| 
       101 
     | 
    
         
            -
              createScope(): ConfigInjector<SV, CV>;
         
     | 
| 
       102 
     | 
    
         
            -
              dispose(): void;
         
     | 
| 
      
 27 
     | 
    
         
            +
            declare class ConfigInjector<SV extends AnySchemaValidator, CV extends ConfigValidator<SV>> {
         
     | 
| 
      
 28 
     | 
    
         
            +
                private schemaValidator;
         
     | 
| 
      
 29 
     | 
    
         
            +
                private configShapes;
         
     | 
| 
      
 30 
     | 
    
         
            +
                private dependenciesDefinition;
         
     | 
| 
      
 31 
     | 
    
         
            +
                instances: {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    [K in keyof CV]?: ResolvedConfigValidator<SV, CV>[K];
         
     | 
| 
      
 33 
     | 
    
         
            +
                };
         
     | 
| 
      
 34 
     | 
    
         
            +
                private loadSingletons;
         
     | 
| 
      
 35 
     | 
    
         
            +
                private resolveInstance;
         
     | 
| 
      
 36 
     | 
    
         
            +
                constructor(schemaValidator: SV, configShapes: CV, dependenciesDefinition: {
         
     | 
| 
      
 37 
     | 
    
         
            +
                    [K in keyof CV]: Singleton<ResolvedConfigValidator<SV, CV>[K]> | Constructed<Omit<ResolvedConfigValidator<SV, CV>, K>, ResolvedConfigValidator<SV, CV>[K]>;
         
     | 
| 
      
 38 
     | 
    
         
            +
                });
         
     | 
| 
      
 39 
     | 
    
         
            +
                safeValidateConfigSingletons(): ParseResult<ValidConfigInjector<SV, CV>>;
         
     | 
| 
      
 40 
     | 
    
         
            +
                validateConfigSingletons(configName: string): ValidConfigInjector<SV, CV>;
         
     | 
| 
      
 41 
     | 
    
         
            +
                resolve<T extends keyof CV>(token: T, context?: Record<string, unknown>, resolutionPath?: (keyof CV)[]): ResolvedConfigValidator<SV, CV>[T];
         
     | 
| 
      
 42 
     | 
    
         
            +
                scopedResolver<T extends keyof CV>(token: T, context?: Record<string, unknown>, resolutionPath?: (keyof CV)[]): (scope?: ConfigInjector<SV, CV>) => ResolvedConfigValidator<SV, CV>[T];
         
     | 
| 
      
 43 
     | 
    
         
            +
                createScope(): ConfigInjector<SV, CV>;
         
     | 
| 
      
 44 
     | 
    
         
            +
                dispose(): void;
         
     | 
| 
       103 
45 
     | 
    
         
             
            }
         
     | 
| 
       104 
     | 
    
         
            -
            declare class ValidConfigInjector<
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
              CV extends ConfigValidator<SV>
         
     | 
| 
       107 
     | 
    
         
            -
            > extends ConfigInjector<SV, CV> {
         
     | 
| 
       108 
     | 
    
         
            -
              validConfigInjector: void;
         
     | 
| 
      
 46 
     | 
    
         
            +
            declare class ValidConfigInjector<SV extends AnySchemaValidator, CV extends ConfigValidator<SV>> extends ConfigInjector<SV, CV> {
         
     | 
| 
      
 47 
     | 
    
         
            +
                validConfigInjector: void;
         
     | 
| 
       109 
48 
     | 
    
         
             
            }
         
     | 
| 
       110 
49 
     | 
    
         | 
| 
       111 
50 
     | 
    
         
             
            declare function getEnvVar(name: string): string;
         
     | 
| 
         @@ -116,32 +55,16 @@ declare function getEnvVar(name: string): string; 
     | 
|
| 
       116 
55 
     | 
    
         
             
             * @interface BaseService
         
     | 
| 
       117 
56 
     | 
    
         
             
             */
         
     | 
| 
       118 
57 
     | 
    
         
             
            interface BaseService {
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                /**
         
     | 
| 
      
 59 
     | 
    
         
            +
                 * The EntityManager instance for managing entities.
         
     | 
| 
      
 60 
     | 
    
         
            +
                 *
         
     | 
| 
      
 61 
     | 
    
         
            +
                 * @type {EntityManager}
         
     | 
| 
      
 62 
     | 
    
         
            +
                 */
         
     | 
| 
      
 63 
     | 
    
         
            +
                em: EntityManager$1;
         
     | 
| 
       125 
64 
     | 
    
         
             
            }
         
     | 
| 
       126 
65 
     | 
    
         | 
| 
       127 
66 
     | 
    
         
             
            type EntityManager = {
         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
                fork: <Options>(options?: Options) => EntityManager;
         
     | 
| 
       129 
68 
     | 
    
         
             
            };
         
     | 
| 
       130 
69 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
            export {
         
     | 
| 
       132 
     | 
    
         
            -
              ConfigInjector,
         
     | 
| 
       133 
     | 
    
         
            -
              getEnvVar,
         
     | 
| 
       134 
     | 
    
         
            -
              Lifetime,
         
     | 
| 
       135 
     | 
    
         
            -
              ValidConfigInjector,
         
     | 
| 
       136 
     | 
    
         
            -
              type BaseService,
         
     | 
| 
       137 
     | 
    
         
            -
              type ConfigValidator,
         
     | 
| 
       138 
     | 
    
         
            -
              type Constructed,
         
     | 
| 
       139 
     | 
    
         
            -
              type Constructor,
         
     | 
| 
       140 
     | 
    
         
            -
              type EntityManager,
         
     | 
| 
       141 
     | 
    
         
            -
              type Function,
         
     | 
| 
       142 
     | 
    
         
            -
              type ResolvedConfigValidator,
         
     | 
| 
       143 
     | 
    
         
            -
              type SchemaConstructor,
         
     | 
| 
       144 
     | 
    
         
            -
              type SchemaFunction,
         
     | 
| 
       145 
     | 
    
         
            -
              type ScopedDependencyFactory,
         
     | 
| 
       146 
     | 
    
         
            -
              type Singleton
         
     | 
| 
       147 
     | 
    
         
            -
            };
         
     | 
| 
      
 70 
     | 
    
         
            +
            export { type BaseService, ConfigInjector, type ConfigValidator, type Constructed, type Constructor, type EntityManager, type Function, Lifetime, type ResolvedConfigValidator, type SchemaConstructor, type SchemaFunction, type ScopedDependencyFactory, type Singleton, ValidConfigInjector, getEnvVar };
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            {
         
     | 
| 
       2 
2 
     | 
    
         
             
              "name": "@forklaunch/core",
         
     | 
| 
       3 
     | 
    
         
            -
              "version": "0.3. 
     | 
| 
      
 3 
     | 
    
         
            +
              "version": "0.3.6",
         
     | 
| 
       4 
4 
     | 
    
         
             
              "description": "forklaunch-js core package. Contains useful building blocks.",
         
     | 
| 
       5 
5 
     | 
    
         
             
              "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
         
     | 
| 
       6 
6 
     | 
    
         
             
              "bugs": {
         
     | 
| 
         @@ -52,32 +52,32 @@ 
     | 
|
| 
       52 
52 
     | 
    
         
             
                "lib"
         
     | 
| 
       53 
53 
     | 
    
         
             
              ],
         
     | 
| 
       54 
54 
     | 
    
         
             
              "dependencies": {
         
     | 
| 
       55 
     | 
    
         
            -
                "@mikro-orm/core": "^6.4. 
     | 
| 
       56 
     | 
    
         
            -
                "@mikro-orm/mongodb": "^6.4. 
     | 
| 
      
 55 
     | 
    
         
            +
                "@mikro-orm/core": "^6.4.6",
         
     | 
| 
      
 56 
     | 
    
         
            +
                "@mikro-orm/mongodb": "^6.4.6",
         
     | 
| 
       57 
57 
     | 
    
         
             
                "cors": "^2.8.5",
         
     | 
| 
       58 
58 
     | 
    
         
             
                "jose": "^5.9.6",
         
     | 
| 
       59 
59 
     | 
    
         
             
                "openapi3-ts": "^4.4.0",
         
     | 
| 
       60 
60 
     | 
    
         
             
                "redis": "^4.7.0",
         
     | 
| 
       61 
61 
     | 
    
         
             
                "uuid": "^11.0.5",
         
     | 
| 
       62 
     | 
    
         
            -
                "@forklaunch/common": "0.2. 
     | 
| 
       63 
     | 
    
         
            -
                "@forklaunch/validator": "0.4. 
     | 
| 
      
 62 
     | 
    
         
            +
                "@forklaunch/common": "0.2.1",
         
     | 
| 
      
 63 
     | 
    
         
            +
                "@forklaunch/validator": "0.4.4"
         
     | 
| 
       64 
64 
     | 
    
         
             
              },
         
     | 
| 
       65 
65 
     | 
    
         
             
              "devDependencies": {
         
     | 
| 
       66 
     | 
    
         
            -
                "@eslint/js": "^9. 
     | 
| 
      
 66 
     | 
    
         
            +
                "@eslint/js": "^9.20.0",
         
     | 
| 
       67 
67 
     | 
    
         
             
                "@types/cors": "^2.8.17",
         
     | 
| 
       68 
68 
     | 
    
         
             
                "@types/jest": "^29.5.14",
         
     | 
| 
       69 
     | 
    
         
            -
                "@types/qs": "^6.9. 
     | 
| 
      
 69 
     | 
    
         
            +
                "@types/qs": "^6.9.18",
         
     | 
| 
       70 
70 
     | 
    
         
             
                "@types/uuid": "^10.0.0",
         
     | 
| 
       71 
     | 
    
         
            -
                "globals": "^15. 
     | 
| 
      
 71 
     | 
    
         
            +
                "globals": "^15.15.0",
         
     | 
| 
       72 
72 
     | 
    
         
             
                "jest": "^29.7.0",
         
     | 
| 
       73 
     | 
    
         
            -
                "prettier": "^3. 
     | 
| 
       74 
     | 
    
         
            -
                "testcontainers": "^10. 
     | 
| 
      
 73 
     | 
    
         
            +
                "prettier": "^3.5.1",
         
     | 
| 
      
 74 
     | 
    
         
            +
                "testcontainers": "^10.18.0",
         
     | 
| 
       75 
75 
     | 
    
         
             
                "ts-jest": "^29.2.5",
         
     | 
| 
       76 
76 
     | 
    
         
             
                "ts-node": "^10.9.2",
         
     | 
| 
       77 
     | 
    
         
            -
                "tsup": "^8.3. 
     | 
| 
       78 
     | 
    
         
            -
                "typedoc": "^0.27. 
     | 
| 
      
 77 
     | 
    
         
            +
                "tsup": "^8.3.6",
         
     | 
| 
      
 78 
     | 
    
         
            +
                "typedoc": "^0.27.7",
         
     | 
| 
       79 
79 
     | 
    
         
             
                "typescript": "^5.7.3",
         
     | 
| 
       80 
     | 
    
         
            -
                "typescript-eslint": "^8. 
     | 
| 
      
 80 
     | 
    
         
            +
                "typescript-eslint": "^8.24.0"
         
     | 
| 
       81 
81 
     | 
    
         
             
              },
         
     | 
| 
       82 
82 
     | 
    
         
             
              "scripts": {
         
     | 
| 
       83 
83 
     | 
    
         
             
                "build": "tsc --noEmit && tsup ./src/cache/index.ts ./src/controllers/index.ts ./src/database/mikro/models/entities/base.entity.ts ./src/database/mikro/models/entities/mongo.base.entity.ts ./src/database/mikro/models/entities/role.entity.ts ./src/database/mikro/models/entities/user.entity.ts ./src/dtoMapper/index.ts ./src/http/index.ts ./src/services/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean --sourcemap",
         
     |