const FormData = require('form-data'); const perform = async (z, bundle) => { const form = new FormData(); form.append( 'metadata', JSON.stringify({ title: bundle.inputData.title, note: bundle.inputData.note }), ); if (bundle.inputData.file) { const fileResponse = await z.request({ url: bundle.inputData.file, raw: true, redirect: 'follow', }); form.append('attachments', fileResponse.body, { filename: bundle.inputData.filename || 'attachment.bin', }); } const response = await z.request({ url: `${bundle.authData.baseUrl}/v1/storage`, method: 'POST', body: form, headers: form.getHeaders(), }); return response.data; }; module.exports = { key: 'store_data', noun: 'Stored Item', display: { label: 'Store Data', description: 'Stores metadata and an optional file attachment. Priced per call plus metadata KB and attachment MB on your plan.', }, operation: { inputFields: [ { key: 'title', label: 'Title', type: 'string', required: true }, { key: 'note', label: 'Note', type: 'text', required: false }, { key: 'file', label: 'Attachment', type: 'file', required: false, helpText: 'Optional file. Attachment size is billed per MB on your plan.', }, { key: 'filename', label: 'Filename', type: 'string', required: false }, ], perform, sample: { id: '3fa85f64-5717-4562-b3fc-2c963f66afa6' }, }, };