@loomcore/api 0.1.73 → 0.1.74

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.
@@ -7,7 +7,7 @@ export interface IGenericQueryService<T extends IEntity> {
7
7
  operations: Operation[];
8
8
  };
9
9
  prepareQueryOptions(userContext: IUserContext | undefined, queryOptions: IQueryOptions): IQueryOptions;
10
- postProcessEntity(userContext: IUserContext, entity: T): T;
10
+ postProcessEntity(userContext: IUserContext, entity: any): T;
11
11
  getAll(userContext: IUserContext): Promise<T[]>;
12
12
  get(userContext: IUserContext, queryOptions: IQueryOptions): Promise<IPagedResult<T>>;
13
13
  getById(userContext: IUserContext, id: AppIdType): Promise<T>;
@@ -14,7 +14,8 @@ export declare class GenericQueryService<T extends IEntity> implements IGenericQ
14
14
  operations: Operation[];
15
15
  };
16
16
  prepareQueryOptions(userContext: IUserContext | undefined, queryOptions: IQueryOptions): IQueryOptions;
17
- postProcessEntity(userContext: IUserContext, entity: T): T;
17
+ protected postProcessEntityInternal(userContext: IUserContext, entity: any): T;
18
+ postProcessEntity(userContext: IUserContext, entity: any): T;
18
19
  getAll(userContext: IUserContext): Promise<T[]>;
19
20
  get(userContext: IUserContext, queryOptions?: IQueryOptions): Promise<IPagedResult<T>>;
20
21
  getById(userContext: IUserContext, id: AppIdType): Promise<T>;
@@ -18,19 +18,23 @@ export class GenericQueryService {
18
18
  prepareQueryOptions(userContext, queryOptions) {
19
19
  return queryOptions;
20
20
  }
21
+ postProcessEntityInternal(userContext, entity) {
22
+ const dbPostProcessedEntity = this.database.postProcessEntity(entity, this.modelSpec.fullSchema);
23
+ return this.postProcessEntity(userContext, dbPostProcessedEntity);
24
+ }
21
25
  postProcessEntity(userContext, entity) {
22
- return this.database.postProcessEntity(entity, this.modelSpec.fullSchema);
26
+ return entity;
23
27
  }
24
28
  async getAll(userContext) {
25
29
  const { operations } = this.prepareQuery(userContext, {}, []);
26
30
  const entities = await this.database.getAll(operations, this.rootTableName);
27
- return entities.map(entity => this.postProcessEntity(userContext, entity));
31
+ return entities.map(entity => this.postProcessEntityInternal(userContext, entity));
28
32
  }
29
33
  async get(userContext, queryOptions = { ...DefaultQueryOptions }) {
30
34
  const preparedOptions = this.prepareQueryOptions(userContext, queryOptions);
31
35
  const { operations } = this.prepareQuery(userContext, {}, []);
32
36
  const pagedResult = await this.database.get(operations, preparedOptions, this.modelSpec, this.rootTableName);
33
- const transformedEntities = (pagedResult.entities || []).map(entity => this.postProcessEntity(userContext, entity));
37
+ const transformedEntities = (pagedResult.entities || []).map(entity => this.postProcessEntityInternal(userContext, entity));
34
38
  return {
35
39
  ...pagedResult,
36
40
  entities: transformedEntities
@@ -42,7 +46,7 @@ export class GenericQueryService {
42
46
  if (!entity) {
43
47
  throw new IdNotFoundError();
44
48
  }
45
- return this.postProcessEntity(userContext, entity);
49
+ return this.postProcessEntityInternal(userContext, entity);
46
50
  }
47
51
  async getCount(userContext) {
48
52
  const { operations } = this.prepareQuery(userContext, {}, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb or PostgreSQL",
6
6
  "scripts": {