Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- `OneBlinkUploader.uploadAiEnvironmentStylingAttachment()`

### Removed

- **[BREAKING]** `OneBlinkUploader.uploadPDFConversion()`
Expand Down
42 changes: 42 additions & 0 deletions src/OneBlinkUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
UploadEmailAttachmentOptions,
UploadCustomPDFOptions,
UploadAiBuilderAttachmentOptions,
UploadAiEnvironmentStylingAttachmentOptions,
} from './types.js'
import { SubmissionTypes } from '@oneblink/types'
import generateFormSubmissionTags from './generateFormSubmissionTags.js'
Expand Down Expand Up @@ -555,6 +556,47 @@ export default class OneBlinkUploader {
})
}

/**
* Upload an attachment for use with the AI environment styling.
*
* #### Example
*
* ```ts
* const abortController = new AbortController()
* const result = await uploader.uploadAiEnvironmentStylingAttachment({
* onProgress: (progress) => {
* // ...
* },
* data: attachmentData,
* formsAppEnvironmentId: 1,
* abortSignal: abortController.signal,
* })
* ```
*
* @param data The attachment data and options
* @returns The upload result
*/
async uploadAiEnvironmentStylingAttachment({
onProgress,
abortSignal,
data,
formsAppEnvironmentId,
contentType,
fileName,
}: UploadAiEnvironmentStylingAttachmentOptions) {
return await uploadToS3({
...this,
contentType,
body: data,
key: `forms-app-environments/${formsAppEnvironmentId}/ai-builder/attachments`,
requestBodyHeader: {
fileName: encodeURIComponent(fileName),
},
abortSignal,
onProgress,
})
}

/**
* Upload a PDF for a form to be used as a custom PDF in workflow events.
* Custom PDFs are always private.
Expand Down
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,18 @@ export type UploadAiBuilderAttachmentOptions = UploadOptions & {
fileName: string
}

export type UploadAiEnvironmentStylingAttachmentOptions = UploadOptions & {
/** The file data to upload */
data: AttachmentUploadData
/** A standard MIME type describing the format of the contents */
contentType: string
/**
* The id of the Forms App Environment that the AI Environment Styling is
* being used with
*/
formsAppEnvironmentId: number
/** The name of the file being uploaded */
fileName: string
}

export type UploadEmailAttachmentOptions = UploadAssetOptions