@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
|
@@ -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.
|
|
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(
|
|
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
|