Add encodeFormBody utility and form data content type support #1607
Add encodeFormBody utility and form data content type support #1607josephjclark merged 22 commits intorelease/nextfrom
encodeFormBody utility and form data content type support #1607Conversation
|
@PiusKariuki this should fix your problem, You will need to pass post(
`/Patient/Prescription/History`,
{
start: 0,
length: -1,
draw: 1,
additionalParameters: {
filter: [
{ fieldName: 'prescriberName', operator: 'Eq', value: 'Dr Super User' },
],
},
},
{
contentType: 'form',
},
) |
encodeFormBody utility and form data content type support
|
SurveyCTO have it's own version of encodeFormBody, Technically the new version of encodeFormBody from common should replace this function, but there are not enough unit test or integration test to do the swap. will discuss with joe next steps for surveyCTO if the pr is approved |
josephjclark
left a comment
There was a problem hiding this comment.
The blob stuff makes me nervous. I can see how we're trying to make it easy to encode form data but I don't actually think it's working 🤔
Let's make the form encoding super simple. Just pass blobs through. You'll probably need to stringify objects, otherwise just ensure strings
To enable files and binaries we need a helper function like createBlob(data, type, filename). This will have to return some kind of wrapped object (maybe a class instance) which the encoder knows how to handle
|
Hiya @josephjclark , i have removed the blob stuff and open a ticket for adding |
primitive are converted to string, `Blob` and `File` are appended as-is
|
Hiya @josephjclark , i have removed the mode option from The idea is, User should still be able to pass a what do you think of this approach ? |
* http:rewrite integration tests to ues koa * add tests of posting formdata * add a skipped test * add test showing current behaviour
Summary
This pr add form data encoding support across the adaptors by adding a shared
encodeFormBodyutility to@openfn/language-commonand use it into@openfn/language-daguand@openfn/language-http.Details
@openfn/language-commonencodeFormBody(data)tosrc/util/http.js— encodes a plain object into aFormDatainstanceencodeFormBodyincluding edge cases (null/undefined skip, Blob passthrough)@openfn/language-dagucontentTypesupport toRequestOptions, enabling requests to be sent asmultipart/form-datausingencodeFormBodyunder the hood@openfn/language-httpencodeFormBodyutility from@openfn/language-commonfor form data encoding.AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to
know!):
You can read more details in our
Responsible AI Policy
Review Checklist
Before merging, the reviewer should check the following items:
production? Is it safe to release?
dev only changes don't need a changeset.