-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lambda): functionality for updating ID, values, and deleting packages #923
Merged
Merged
Changes from 146 commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
8a50578
wip
tiffanyvu cdfdb4e
check sinkmain
tiffanyvu 26fd75b
remove deleted code
tiffanyvu 46e3dc3
rename to handler
tiffanyvu 5ffe3f3
add env config
tiffanyvu 5d7df68
fix parse
tiffanyvu 1183248
fix event body type
tiffanyvu 5db0419
add origin
tiffanyvu b8814ee
add logs
tiffanyvu 2bf5fb6
log
tiffanyvu 77740a2
fix test and add log
tiffanyvu 4791235
temp bypass record event
tiffanyvu 444faf2
change order of sinkmain if
tiffanyvu bfc92eb
push into sinkmain
tiffanyvu b85b6ef
add id into doc
tiffanyvu 0bfcbc4
log in sinkmain
tiffanyvu 89520bf
format deleted package
tiffanyvu 21f1968
add sink change log
tiffanyvu a981b4a
change order of sinklog changelog
tiffanyvu 839f218
fix schema
tiffanyvu 4f29673
add logs changelog
tiffanyvu 2830a45
try adding delete property
tiffanyvu 5a7a65a
fix property
tiffanyvu 96bf0d8
log query
tiffanyvu b4ff2cd
change term
tiffanyvu 8b1e39e
letter s
tiffanyvu db5e947
must not
tiffanyvu b350788
wip update package fields
tiffanyvu c4d5e23
add log
tiffanyvu bfee3a8
omg
tiffanyvu 2c8a6ff
try fix test and changelog update fields
tiffanyvu f20f10a
transform updated values?
tiffanyvu 2936adb
typo
tiffanyvu bab9ab9
again
tiffanyvu 07f656f
try
tiffanyvu a890751
remove origin
tiffanyvu 231bee9
add timestamp?
tiffanyvu dd76406
fix changelog not showing
tiffanyvu 428f1e0
edit changelog text
tiffanyvu 26a80a9
meg
tiffanyvu cd8e0d2
changelog admin changes updates, language TBD
tiffanyvu b4afe70
edit schema parsing for sinkmain
tiffanyvu 333a867
change schema parsing in changelog
tiffanyvu c877258
rm commented out code
tiffanyvu 54681e2
fix eslint
tiffanyvu 97fe983
clean up
tiffanyvu 0c703fa
remove more logs
tiffanyvu 78cf0d7
readd comment
tiffanyvu 856adb3
cleanup zod schema logic
tiffanyvu a63755a
change event name
tiffanyvu 4232711
test adminchange for delete
tiffanyvu 6469a36
attachments is undefined for soft deleted packages, add optional
tiffanyvu 5d3183f
Merge branch 'main' into lambda-update-package
tiffanyvu 56a0ab0
wip
tiffanyvu 634e51c
revert safeparse
tiffanyvu 6aa7b0a
remove empty test
tiffanyvu c45832d
set default attachments value
tiffanyvu a511c72
move default attachments default value
tiffanyvu d2de296
delete test, will be handled by sinkmain tests
tiffanyvu 95f8d5b
edit todo msg
tiffanyvu 58e7321
rm unused code
tiffanyvu 601189e
Merge branch 'main' into lambda-update-package
tiffanyvu d30bba8
Merge branch 'main' into lambda-update-id
tiffanyvu 0d31401
remove origin property
tiffanyvu abc9719
Merge branch 'main' into lambda-update-id
tiffanyvu 60c31d4
Merge branch 'main' into lambda-update-package
tiffanyvu a8a6dbc
test
tiffanyvu e786b18
check for existing package id
tiffanyvu 35b52ca
add update id schema
tiffanyvu 66f6cd8
add admin change type
tiffanyvu e979456
typo
tiffanyvu d0c16ed
again
tiffanyvu 8442250
add log
tiffanyvu f43b796
edit log
tiffanyvu b7a04cb
edit changelog
tiffanyvu b2f7ec0
exclude _index
tiffanyvu e6a38df
fix destructuring
tiffanyvu 684c055
source?
tiffanyvu 81dafd2
test log
tiffanyvu 01d0e5c
hide changelog
tiffanyvu 37e424b
ew test
tiffanyvu 46cb421
add changemade and types to Document type
tiffanyvu 38633c1
add zod to event body
tiffanyvu 266f791
update response status codes
tiffanyvu f807d7e
Merge branch 'main' into lambda-update-package
tiffanyvu a59e302
Merge branch 'main' into lambda-update-id
tiffanyvu ffaf219
Merge branch 'lambda-update-package' into lambda-update-package-funct…
tiffanyvu c3fb5f5
merge and rm console log
tiffanyvu b391d25
rm comment
tiffanyvu 493e31e
wip id validation
tiffanyvu b742679
Merge branch 'main' into update-package-func
asharonbaltazar 5565b2a
test logs
tiffanyvu aacc361
Merge branch 'update-package-func' of https://github.com/Enterprise-C…
tiffanyvu 3646259
again
tiffanyvu 978ca6d
add logs
tiffanyvu 556aac6
logs
tiffanyvu 73c359c
fix
tiffanyvu 3b6686b
Merge branch 'main' into update-package-func
asharonbaltazar d45535b
test format
tiffanyvu f0da974
log
tiffanyvu 902588d
test moving responses into funcs
tiffanyvu 4b7dc81
test
tiffanyvu 0d42864
fix punctuation
tiffanyvu af196d6
wip address comments
tiffanyvu fa838cd
rm old code
tiffanyvu aad435d
add comment
tiffanyvu d1febcc
Merge branch 'main' into update-package-func
tiffanyvu ecceed5
rm eslint ignore
tiffanyvu 7d003b3
move topicname logic
tiffanyvu 2f68a24
test package event type in changelog
tiffanyvu 15f00c0
log
tiffanyvu 654aa38
logs
tiffanyvu 64177f3
fix
tiffanyvu 3479e33
move event
tiffanyvu f3df9b1
move logic
tiffanyvu 78a4d61
logs
tiffanyvu d86b23f
typo
tiffanyvu dbcd80f
what
tiffanyvu b172846
log
tiffanyvu 24e86fd
add mako origin to get to transforms
tiffanyvu 5d968b4
umm touching opensearch
tiffanyvu a81684e
typo
tiffanyvu f1bdb10
logs
tiffanyvu f9e5858
revert
tiffanyvu 7c897d1
try
tiffanyvu be77182
revert
tiffanyvu 482422c
revert changelog
tiffanyvu 2671c39
hi
tiffanyvu 6aed3b0
logs
tiffanyvu 176e985
add old id to changelog
tiffanyvu 1d25971
offset stuff
tiffanyvu 140485b
logs
tiffanyvu 7b967ed
logs
tiffanyvu a1e0ea4
duplicate offset
tiffanyvu 31aafc0
fix
tiffanyvu 0a5494b
log hits
tiffanyvu 85217cf
logs
tiffanyvu 9879466
test
tiffanyvu 0a83a4b
fix
tiffanyvu 090e570
fix
tiffanyvu 257ed25
idToBeUpdated
tiffanyvu 5df41a9
add onemac
tiffanyvu d06cf1d
fix
tiffanyvu 6e1e5e2
clean
tiffanyvu c0c2906
move around
tiffanyvu a3575f1
clean
tiffanyvu 622aad9
remove casting
tiffanyvu 2d33626
casting throws type error
tiffanyvu 099d878
sinkmain conflicts
tiffanyvu b9bd169
fix import and add test
tiffanyvu ce4ac62
Merge branch 'main' into update-package-func
tiffanyvu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file changed significantly. Lemme know if you wanna pair up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { z } from "zod"; | ||
|
||
export const deleteAdminChangeSchema = z | ||
.object({ | ||
id: z.string(), | ||
deleted: z.boolean(), | ||
adminChangeType: z.literal("delete"), | ||
}) | ||
.and(z.record(z.string(), z.any())); | ||
|
||
export const updateValuesAdminChangeSchema = z | ||
.object({ | ||
id: z.string(), | ||
adminChangeType: z.literal("update-values"), | ||
}) | ||
.and(z.record(z.string(), z.any())); | ||
|
||
export const updateIdAdminChangeSchema = z | ||
.object({ | ||
id: z.string(), | ||
adminChangeType: z.literal("update-id"), | ||
idToBeUpdated: z.string(), | ||
}) | ||
.and(z.record(z.string(), z.any())); | ||
|
||
export const transformDeleteSchema = (offset: number) => | ||
deleteAdminChangeSchema.transform((data) => ({ | ||
...data, | ||
event: "delete", | ||
packageId: data.id, | ||
id: `${data.id}-${offset}`, | ||
timestamp: Date.now(), | ||
})); | ||
|
||
export const transformUpdateValuesSchema = (offset: number) => | ||
updateValuesAdminChangeSchema.transform((data) => ({ | ||
...data, | ||
event: "update-values", | ||
packageId: data.id, | ||
id: `${data.id}-${offset}`, | ||
timestamp: Date.now(), | ||
})); | ||
|
||
export const transformedUpdateIdSchema = updateIdAdminChangeSchema.transform((data) => ({ | ||
...data, | ||
event: "update-id", | ||
packageId: data.id, | ||
id: `${data.id}`, | ||
timestamp: Date.now(), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { response } from "lib/libs/handler-lib"; | ||
import { events } from "lib/packages/shared-types"; | ||
import { getPackageChangelog } from "lib/libs/api/package"; | ||
|
||
export const getPackageType = async (packageId: string) => { | ||
// use event of current package to determine how ID should be formatted | ||
try { | ||
const packageChangelog = await getPackageChangelog(packageId); | ||
if (!packageChangelog.hits.hits.length) { | ||
throw new Error("The type of package could not be determined."); | ||
} | ||
|
||
const packageWithSubmissionType = packageChangelog.hits.hits.find((pkg) => { | ||
return pkg._source.event in events; | ||
}); | ||
const packageEvent = packageWithSubmissionType?._source.event; | ||
tiffanyvu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return packageEvent; | ||
} catch (error) { | ||
return response({ | ||
statusCode: 500, | ||
body: { message: error }, | ||
}); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap these calls with
vi.mocked
to get the same benefit without casting