-
Notifications
You must be signed in to change notification settings - Fork 3
feat/df-1006: dlq modify rework #1408
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d539342
Stash with retry
jbarnsley10 5ae463e
Handles message not found
jbarnsley10 6573f35
Sonar fixes
jbarnsley10 f9690a4
Post message content between screens
jbarnsley10 ced8d1c
Stash
jbarnsley10 ebfe213
Merge branch 'main' into feat/df-1006-dlq-modify-2
jbarnsley10 4b12b7f
Reworked
jbarnsley10 2d2bccd
Changes after review, and extra coverage
jbarnsley10 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
This file contains hidden or 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 hidden or 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 hidden or 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
81 changes: 81 additions & 0 deletions
81
designer/server/src/routes/admin/dead-letter-queue-helper.js
This file contains hidden or 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,81 @@ | ||
| import { formAdapterSubmissionMessagePayloadSchema } from '@defra/forms-engine-plugin/engine/types/schema.js' | ||
|
|
||
| import { createJoiError } from '~/src/lib/error-boom-helper.js' | ||
|
|
||
| /** | ||
| * @param {string} messageJson | ||
| */ | ||
| export function validateMessageJson(messageJson) { | ||
| let json | ||
| try { | ||
| json = JSON.parse(messageJson) | ||
| } catch (err) { | ||
| const typedError = /** @type {{ message?: string }} */ (err) | ||
| return { | ||
| error: createJoiError( | ||
| 'messageJson', | ||
| `Invalid JSON: ${typedError.message}` | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @type { FormAdapterSubmissionMessagePayload | undefined } | ||
| */ | ||
| const messageBody = json.Body | ||
| if (!messageBody) { | ||
| return { | ||
| error: createJoiError( | ||
| 'messageJson', | ||
| 'Invalid JSON: Missing "Body" element' | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| const { error } = formAdapterSubmissionMessagePayloadSchema.validate( | ||
| messageBody, | ||
| { | ||
| abortEarly: false, | ||
| stripUnknown: true | ||
| } | ||
| ) | ||
| if (error) { | ||
| const errorText = error.details.map((d) => d.message).join(', ') | ||
| const joiError = createJoiError( | ||
| 'messageJson', | ||
| `JSON does not match the schema: ${errorText}` | ||
| ) | ||
| return { | ||
| error: joiError | ||
| } | ||
| } | ||
| return { | ||
| body: messageBody | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Keep specific properties | ||
| * @param {any} message | ||
| * @returns {{ json: { MessageId: string, Body: any }}} | ||
| */ | ||
| export function dlqMessageMapper(message) { | ||
| return { | ||
| json: { | ||
| MessageId: message.MessageId, | ||
| Body: JSON.parse(message.Body) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param {any[]} messages | ||
| * @returns {{ json: { MessageId: string, Body: any }}[]} | ||
| */ | ||
| export function dlqMessagesMapper(messages) { | ||
| return messages.map(dlqMessageMapper) | ||
| } | ||
|
|
||
| /** | ||
| * @import { FormAdapterSubmissionMessagePayload } from '@defra/forms-engine-plugin/engine/types.js' | ||
| */ |
Oops, something went wrong.
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.
bit confused by this, why would we hardcode a value?
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.
It's a snapshot for a unit test where that message content is setup in the unit test.
The actual NJK file contains dynamic content:
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.
oh so it is !! my bad, i saw this as the actual nunjucks view.