@clairejs/server 3.28.6 → 3.28.8

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/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## Change Log
2
2
 
3
+ #### 3.28.8
4
+
5
+ - fix CrudHttpController getBody not cache validation
6
+
7
+ #### 3.28.7
8
+
9
+ - fix update records with hasMany field
10
+
3
11
  #### 3.28.6
4
12
 
5
13
  - fix calling stripData in with null / undefined
@@ -62,7 +62,7 @@ export class HttpRequest {
62
62
  getBody() {
63
63
  if (this.endpointMetadata &&
64
64
  (this.endpointMetadata.method === HttpMethod.POST || this.endpointMetadata.method === HttpMethod.PUT) &&
65
- this.endpointMetadata?.bodyDto) {
65
+ this.endpointMetadata?.bodyDto && !this.body.validated) {
66
66
  this.body.data = validateData(this.body.data, this.endpointMetadata.bodyDto, false);
67
67
  this.body.validated = true;
68
68
  }
@@ -510,7 +510,7 @@ export class ModelRepository extends AbstractRepository {
510
510
  const adapter = this.db.use(model, tx);
511
511
  const allInnerRecords = await adapter.getRecords({ _eq: { [field.hasMany.column]: theRecord.id } }, { limit: field.hasMany?.single ? 1 : undefined });
512
512
  const currentIds = allInnerRecords.map((r) => r.id);
513
- const newIds = innerUpdates.map((r) => r.id).filter((id) => !!id);
513
+ const newIds = innerUpdates.flatMap((r) => (r.id ? [r.id] : []));
514
514
  const tobeRemovedIds = currentIds.filter((id) => !newIds.includes(id));
515
515
  const tobeAdded = innerUpdates
516
516
  .filter((r) => !r.id)
@@ -537,7 +537,10 @@ export class ModelRepository extends AbstractRepository {
537
537
  //-- return the new inners records
538
538
  const finalInnerRecords = tobeAdded
539
539
  .map((toAdd, index) => ({ ...toAdd, ...added.records[index] }))
540
- .concat(updatedToBeKept.map((r) => r.modified[0]));
540
+ .concat(tobeKept.map((tbk) => {
541
+ const matched = updatedToBeKept.find((utbk) => utbk.modified[0].id === tbk.id);
542
+ return { ...tbk, ...matched };
543
+ }));
541
544
  theRecord[field.name] = (field.hasMany?.single ? finalInnerRecords[0] : finalInnerRecords);
542
545
  }
543
546
  //-- ok clean up
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.28.6",
3
+ "version": "3.28.8",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",