Skip to content

Commit

Permalink
add changemade and types to Document type
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanyvu committed Dec 11, 2024
1 parent 37e424b commit 46cb421
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/lambda/update/updatePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,19 @@ const sendUpdateIdMessage = async (
currentPackage: ItemResult,
updatedId: string,
) => {
// get fields of package with old id and copy
//eslint-disable-next-line
const { _id, _index, ...originalFields } = currentPackage;
const { _id, _index, _source } = currentPackage;
//eslint-disable-next-line
const { id, ...source } = originalFields._source;
const { id, changeMade, ...remainingFields } = _source;
console.log({ ..._source }, "ORIGINAL SPREAD");
await sendDeleteMessage(topicName, currentPackage._id);
// send message with new id and old fields
console.log({ ...originalFields._source }, "ORIGINAL SPREAD");
await produceMessage(
topicName,
updatedId,
JSON.stringify({
id: updatedId,
...source,
...remainingFields,
changeMade: "ID has been updated.",
isAdminChange: true,
adminChangeType: "update-id",
}),
Expand Down
3 changes: 3 additions & 0 deletions lib/packages/shared-types/opensearch/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export type Document = AppkDocument &
makoChangedDate: string;
changelog?: Changelog[];
appkChildren?: Omit<ItemResult, "found">[];
deleted?: boolean;
adminChangeType?: string;
changeMade?: string;
};

export type Response = Res<Document>;
Expand Down

0 comments on commit 46cb421

Please sign in to comment.