Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions src/services/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,45 @@ export default async function submit({
abortSignal,
)

const downloadSubmissionPdfUrl = () => {
if (!data.pdfAccessToken) {
return undefined
const getDownloadSubmissionPdfUrls = () => {
const allowPDFDownload =
formSubmission.definition.postSubmissionReceipt?.allowPDFDownload
if (!data.pdfAccessToken || !allowPDFDownload) {
return {
downloadSubmissionPdfUrl: undefined,
downloadSubmissionPdfs: undefined,
}
}
if (
formSubmission.definition.postSubmissionReceipt?.allowPDFDownload &&
!Array.isArray(
formSubmission.definition.postSubmissionReceipt?.allowPDFDownload,
)
) {
return `${tenants.current.apiOrigin}/forms/${formSubmission.definition.id}/submissions/${data.submissionId}/pdf-document?accessToken=${data.pdfAccessToken}`
if (allowPDFDownload && !Array.isArray(allowPDFDownload)) {
// Cater for legacy config
const url = `${tenants.current.apiOrigin}/forms/${formSubmission.definition.id}/submissions/${data.submissionId}/pdf-document?accessToken=${data.pdfAccessToken}`
return {
downloadSubmissionPdfUrl: url,
downloadSubmissionPdfs: [
{
id: 'default',
configuration: allowPDFDownload,
url,
},
],
}
}

return {
downloadSubmissionPdfUrl: undefined,
downloadSubmissionPdfs: allowPDFDownload.map((pdfConfiguration) => {
const url = `${tenants.current.apiOrigin}/forms/${formSubmission.definition.id}/submissions/${data.submissionId}/pdf-document?accessToken=${data.pdfAccessToken}&configurationId=${pdfConfiguration.id}`
return {
...pdfConfiguration,
url,
}
}),
}
}

const { downloadSubmissionPdfUrl, downloadSubmissionPdfs } =
getDownloadSubmissionPdfUrls()

const formSubmissionResult: FormSubmissionResult = {
...formSubmission,
payment: null,
Expand All @@ -195,11 +221,8 @@ export default async function submit({
submissionTimestamp: data.submissionTimestamp,
submissionId: data.submissionId,
isUploadingAttachments: false,
downloadSubmissionPdfUrl: downloadSubmissionPdfUrl(),
getDownloadSubmissionPdfUrl: !data.pdfAccessToken
? undefined
: (configurationId: string) =>
`${tenants.current.apiOrigin}/forms/${formSubmission.definition.id}/submissions/${data.submissionId}/pdf-document?accessToken=${data.pdfAccessToken}&configurationId=${configurationId}`,
downloadSubmissionPdfUrl,
downloadSubmissionPdfs,
attachmentsAccessToken: data.attachmentsAccessToken,
}

Expand Down
14 changes: 7 additions & 7 deletions src/types/submissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ export type FormSubmissionResult = FormSubmission & {
/**
* @deprecated Only returned when legacy post submission download
* configuration is in use. For non legacy configured forms, use
* `getDownloadSubmissionPdfUrl` instead.
* `downloadSubmissionPdfs` instead.
*/
downloadSubmissionPdfUrl?: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please make a breaking change and remove this, no need to keep maintaining it. By returning it, every thing consuming @oneblink/apps has to cater for it potentially being there with a value.

@Zaxist Zaxist Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By returning it, every thing consuming @oneblink/apps has to cater for it potentially being there with a value.

This isn't true though. Its just there for backwards compatibility. Anyone that wants to use the new config is free to do so without needing to support this, as the doc comment says.

@Zaxist Zaxist Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, I'm not completely opposed to removing it, but surely we can discuss that without exaggerating.

@mymattcarroll mymattcarroll Nov 20, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now. Not trying to exaggerate, just made a mistake. I missed the change to return the legacy data in the new array. This was not how it worked in the first commit. But I think we are on the same page in regards to continuing to support the downloadSubmissionPdfUrl property seeming redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only thing is, I don't love the idea of an unwitting console change requiring a major version update to an apps integration. (Yes I recognise probably no one uses this).

/**
* The URL to download the form submission PDF.
*
* @param configurationId - The configuration ID to use for the PDF download.
*/
getDownloadSubmissionPdfUrl?: (configurationId: string) => string

downloadSubmissionPdfs?: Array<{
id: string
configuration: SubmissionEventTypes.PDFConfiguration
url: string
}>
/** The access token to download post-submission attachment urls and metadata. */
attachmentsAccessToken?: string
}
Expand Down