@koalarx/nest 3.1.48 → 3.1.49

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.
@@ -2,8 +2,12 @@ import { Type } from '@nestjs/common';
2
2
  import { ListResponse } from '..';
3
3
  import { PaginationDto } from '../dtos/pagination.dto';
4
4
  import { IComparableId } from '../utils/interfaces/icomparable';
5
+ import { List } from '../utils/list';
5
6
  import { EntityBase } from './entity.base';
6
7
  import { PrismaTransactionalClient } from './prisma-transactional-client';
8
+ type RepositoryInclude<TEntity> = Omit<{
9
+ [K in keyof TEntity as TEntity[K] extends Function ? never : K]?: boolean | (TEntity[K] extends List<infer U> ? RepositoryInclude<U> : RepositoryInclude<TEntity[K]>);
10
+ }, '_id' | '_action'>;
7
11
  interface RepositoryInitProps<TEntity extends EntityBase<TEntity>, TContext extends PrismaTransactionalClient> {
8
12
  context: TContext;
9
13
  modelName: Type<TEntity>;
@@ -11,31 +15,58 @@ interface RepositoryInitProps<TEntity extends EntityBase<TEntity>, TContext exte
11
15
  }
12
16
  export declare abstract class RepositoryBase<TEntity extends EntityBase<TEntity>, TContext extends PrismaTransactionalClient = PrismaTransactionalClient, TModelKey extends keyof TContext = keyof TContext> {
13
17
  protected _context: TContext;
14
- private readonly _modelName;
15
- private readonly _includeFindMany?;
18
+ protected readonly _modelName: Type<TEntity>;
19
+ protected readonly _includeFindMany?: RepositoryInclude<TEntity>;
16
20
  constructor({ context, modelName }: RepositoryInitProps<TEntity, TContext>);
17
- private get entityInstance();
18
- private getIdPropName;
19
- private getWhereByIdSchema;
20
- private getConnectPrismaSchemaForRelation;
21
- private checkIdHasValue;
22
- private getSelectRootPrismaSchema;
23
- private getSelectWithRelationsId;
24
- private getPropNameFromEntitySource;
25
- private listRelationEntities;
26
- private listToRelationActionList;
27
- private entityToPrisma;
28
- private getInclude;
29
- private findManySchema;
30
- private createEntity;
31
- private orphanRemoval;
32
- private getIdOnEntity;
33
- private loadRelationForEntity;
34
- private loadEntityFromCache;
35
- private enrichEntityWithRelations;
36
- private persistRelations;
37
- private setIdOnEntity;
38
- private autofillCreatedId;
21
+ protected get entityInstance(): any;
22
+ protected getIdPropName(entity?: TEntity): string | string[];
23
+ protected getWhereByIdSchema(entity: TEntity, value: any): {};
24
+ protected getConnectPrismaSchemaForRelation(entity: TEntity | Type<TEntity>, data?: any): {
25
+ connect: {};
26
+ };
27
+ protected checkIdHasValue(entity: TEntity, value: any): boolean;
28
+ protected getSelectRootPrismaSchema(entity: TEntity): {};
29
+ protected getSelectWithRelationsId(entity: TEntity): {};
30
+ protected getPropNameFromEntitySource(source: TEntity, entity: Type<TEntity>): string | undefined;
31
+ protected listRelationEntities(entity: TEntity, fromList?: boolean): TEntity[];
32
+ protected listToRelationActionList(entity: TEntity): {
33
+ relationCreates: {
34
+ modelName: string;
35
+ entityInstance: Type<TEntity>;
36
+ schema: any;
37
+ relations: TEntity[];
38
+ }[];
39
+ relationUpdates: {
40
+ modelName: string;
41
+ entityInstance: Type<TEntity>;
42
+ schema: any;
43
+ relations: TEntity[];
44
+ }[];
45
+ relationDeletes: {
46
+ modelName: string;
47
+ entityInstance: Type<TEntity>;
48
+ schema: any;
49
+ relations: TEntity[];
50
+ }[];
51
+ };
52
+ protected entityToPrisma(entity: TEntity): {};
53
+ protected getInclude(include?: RepositoryInclude<TEntity>): {};
54
+ protected findManySchema<T>(where: T, pagination?: PaginationDto): {
55
+ include: {};
56
+ where: T;
57
+ orderBy: {} | undefined;
58
+ skip: number | undefined;
59
+ take: number | undefined;
60
+ };
61
+ protected createEntity(data: any, entityClass?: Type<TEntity>): TEntity;
62
+ protected orphanRemoval(client: PrismaTransactionalClient, entity: EntityBase<TEntity>): any;
63
+ protected getIdOnEntity(entity: TEntity, data: any): string;
64
+ protected loadRelationForEntity(where: Record<string, any>, entity: TEntity, cache: Map<string, any>): Promise<any>;
65
+ protected loadEntityFromCache(entity: TEntity, data: any, cache: Map<string, any>): any;
66
+ protected enrichEntityWithRelations(entity: TEntity, data: any, cache?: Map<string, any>): Promise<any>;
67
+ protected persistRelations(transaction: PrismaTransactionalClient, entity: TEntity): Promise<void>;
68
+ protected setIdOnEntity(entityInstance: TEntity, data: any): void;
69
+ protected autofillCreatedId(entity: TEntity, response: any): void;
39
70
  protected context(transactionalClient?: TContext): TContext[TModelKey];
40
71
  protected findById(id: IComparableId): Promise<TEntity | null>;
41
72
  protected findFirst<T>(where: T): Promise<TEntity | null>;
@@ -46,6 +77,6 @@ export declare abstract class RepositoryBase<TEntity extends EntityBase<TEntity>
46
77
  protected saveMany<TWhere = any>(entities: TEntity[], updateWhere?: TWhere): Promise<void>;
47
78
  protected remove<TWhere = any>(where: TWhere, notCascadeEntityProps?: Array<keyof TEntity>, externalServices?: Promise<any>): Promise<any>;
48
79
  protected removeMany<TWhere = any>(where: TWhere, notCascadeEntityProps?: Array<keyof TEntity>, externalServices?: Promise<any>): Promise<void>;
49
- withTransaction(fn: (prisma: TContext) => Promise<any>): Promise<any>;
80
+ protected withTransaction(fn: (prisma: TContext) => Promise<any>): Promise<any>;
50
81
  }
51
82
  export {};
package/core/koala-app.js CHANGED
@@ -6,7 +6,6 @@ const swagger_1 = require("@nestjs/swagger");
6
6
  const nestjs_api_reference_1 = require("@scalar/nestjs-api-reference");
7
7
  const consola = require("consola");
8
8
  const expressBasicAuth = require("express-basic-auth");
9
- const ngrok = require("ngrok");
10
9
  const env_service_1 = require("../env/env.service");
11
10
  const domain_errors_filter_1 = require("../filters/domain-errors.filter");
12
11
  const global_exception_filter_1 = require("../filters/global-exception.filter");
@@ -225,6 +224,13 @@ class KoalaApp {
225
224
  this.app.useGlobalGuards(guard);
226
225
  }
227
226
  if (this._ngrokKey) {
227
+ let ngrok;
228
+ try {
229
+ ngrok = require('ngrok');
230
+ }
231
+ catch {
232
+ throw new common_1.InternalServerErrorException('Para usar o suporte ao ngrok, instale a dependência opcional "ngrok" (ex: bun add ngrok ou npm install ngrok)');
233
+ }
228
234
  const envService = this.app.get(env_service_1.EnvService);
229
235
  const port = envService.get('PORT') ?? 3000;
230
236
  await ngrok
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalarx/nest",
3
- "version": "3.1.48",
3
+ "version": "3.1.49",
4
4
  "description": "",
5
5
  "author": "Igor D. Rangel",
6
6
  "license": "MIT",
@@ -26,7 +26,6 @@
26
26
  "dotenv": "^16.0.3",
27
27
  "express-basic-auth": "^1.2.1",
28
28
  "ioredis": "^5.3.2",
29
- "ngrok": "^5.0.0-beta.2",
30
29
  "passport": "^0.7.0",
31
30
  "passport-custom": "^1.1.1",
32
31
  "pg": "^8.11.3",