Skip to content

Commit 7bd3a75

Browse files
committed
performance fix for entity api
1 parent b0ea6b6 commit 7bd3a75

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • src/core/resources/entity

src/core/resources/entity/api.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import { getAppClient } from "@core/utils";
1+
import { getAppClient } from "@core/utils/index.js";
22
import { SyncEntitiesResponseSchema } from "./schema.js";
33
import type { SyncEntitiesResponse, Entity } from "./schema.js";
44

55
export async function pushEntities(
66
entities: Entity[]
77
): Promise<SyncEntitiesResponse> {
88
const appClient = getAppClient();
9-
const schemaSyncPayload = entities.reduce((acc, current) => {
10-
return {
11-
...acc,
12-
[current.name]: current,
13-
};
14-
}, {});
9+
const schemaSyncPayload = Object.fromEntries(
10+
entities.map((entity) => [entity.name, entity])
11+
);
1512

1613
const response = await appClient.put("entities-schemas/sync-all", {
1714
json: {

0 commit comments

Comments
 (0)