pre updating version control
This commit is contained in:
@@ -21,6 +21,43 @@ export type CreateEntityPayload = {
|
||||
status?: number | null;
|
||||
};
|
||||
|
||||
export type EntityBatchCreateChange =
|
||||
| ({
|
||||
action: "create";
|
||||
entity: CreateEntityPayload & { id?: string };
|
||||
})
|
||||
| ({
|
||||
action: "create";
|
||||
id?: string;
|
||||
} & CreateEntityPayload);
|
||||
|
||||
export type EntityBatchUpdateChange =
|
||||
| ({
|
||||
action: "update";
|
||||
id: string;
|
||||
entity: Partial<CreateEntityPayload> & { id?: string };
|
||||
})
|
||||
| ({
|
||||
action: "update";
|
||||
id: string;
|
||||
} & Partial<CreateEntityPayload>);
|
||||
|
||||
export type EntityBatchDeleteChange = {
|
||||
action: "delete";
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type EntityBatchChange =
|
||||
| EntityBatchCreateChange
|
||||
| EntityBatchUpdateChange
|
||||
| EntityBatchDeleteChange;
|
||||
|
||||
export type EntityBatchSaveResponse = {
|
||||
success: boolean;
|
||||
applied: number;
|
||||
created_entity_ids: string[];
|
||||
};
|
||||
|
||||
export async function fetchEntities(query?: { q?: string }): Promise<Entity[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (query?.q) {
|
||||
@@ -61,3 +98,11 @@ export async function updateEntity(id: string, payload: CreateEntityPayload): Pr
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveEntityBatchChanges(changes: EntityBatchChange[]): Promise<EntityBatchSaveResponse> {
|
||||
return requestJson<EntityBatchSaveResponse>(API_ENDPOINTS.entitiesBatch, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ changes }),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user