H E I S E N B E R G
H E I S E N B E R G•10mo ago

Write TypeScript scripts interacting with Typeform#6

Needed some clarification on this @Hugo
44 Replies
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
this is something i see when i try to create the form from GUI
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
but the thing is, the docs doesnt mention any key or such so that i can identify what's what. for example, i have no way of to understand what value of question type will evaluate to "Address"
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
https://www.npmjs.com/package/@typeform/api-client#forms PS im using this sdk for interacting with the api
npm
@typeform/api-client
JS SDK for Typeform API. Latest version: 2.3.2, last published: 2 days ago. Start using @typeform/api-client in your project by running npm i @typeform/api-client. There are 5 other projects in the npm registry using @typeform/api-client.
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
everything is an object. should I use any from typecript?
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
nvm i forgot to collapse the thing 🙂 found it now
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
this is what it boiled down to. i didnt have to custom define the types since typeform already has that in their sdk. hope this is doable?
No description
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
@Hugo
Hugo
Hugo•10mo ago
sadly we need to have the types explicitely defined
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
ah cool
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
how would you like to resolve this? I feel the best way would be to create a separate type for this
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
for now i have done something like this
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
- description: Duplicates an existing form in your Typeform account and adds \"(copy)\"
to the end of the title. [See the docs here](https://developer.typeform.com/create/reference/create-form/)
id: duplicate-form
integration: typeform
name: Duplicate a Form
- description: Duplicates an existing form in your Typeform account and adds \"(copy)\"
to the end of the title. [See the docs here](https://developer.typeform.com/create/reference/create-form/)
id: duplicate-form
integration: typeform
name: Duplicate a Form
duplicate form mentions the reference of create-form. what should the logic be?
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
also, this is a bit confusing: https://www.typeform.com/developers/create/reference/update-form-patch/ the integration says Update_Form_Title but this endpoint has no mention of any title
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
im done with the other plugins just stuck with these two: duplicate and update title. can you help me a bit @Hugo ?
Hugo
Hugo•10mo ago
get the fields and other attributes of the first form then create a new one with attributes and the duplicate name (e.g. + (copy) ) in the path enum there is "/title"
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
hmmm okay so i can just update the name to something say, name_copy? ah missed it
Hugo
Hugo•10mo ago
you should create a new form with the name of the old form + " (copy)"
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
btw i opened a PR: https://github.com/windmill-labs/windmill-community-integrations/pull/10 can you have quick glance over it? see if things are good?
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
gotcha
Hugo
Hugo•10mo ago
- type Data should not be defined separately, put all the definition in the function signature - the typeformToken property of the resource type should be renamed to token otherwise looks good
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
Ciol Yeah forgot the first point! made the updates starting with the tests @Hugo there are some inconsistencies with the typeform sdk and the actual API
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
for example this. the layout property doesnt exist
No description
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
now in such cases, i dont think even if i pass the data to the function anyhow, the data will be sent to the api down the line
Hugo
Hugo•10mo ago
then just ignore layout
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
cool
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
@Hugo https://www.typeform.com/developers/responses/ the response API doesnt allow creating a response programatically. how do i implement the test?
Hugo
Hugo•10mo ago
mmm can you do it on the web ui and put as comments in the test file the exact process to follow?
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
so you mean the users will have to create a response from web ui and i put this in the comments in the test file?
Hugo
Hugo•10mo ago
i mean not for the users, it's for me when i check your tests but yes
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
oh
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
ummm... then... how would we implement the idempotent property? for example, in this test im creating a form, testing the get function, then deleting the form
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
leaving the forms to dangle might produce errors ive pushed some tests. just 4 left
Hugo
Hugo•10mo ago
assume the form for the repsonses tests is created manually and the id is passed in the .env file
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
sure
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
https://www.typeform.com/developers/create/reference/update-form/ as per the docs, i will need to pass the entire form object in put request because it will delete any field that i dont pass and is present in the form. im trying to do a test like this, but it is always failing with validation error. and the error doesnt inform much. the same is happening while duplication. im really confused on this one
No description
No description
Hugo
Hugo•10mo ago
are you sure you can spread form in there ?
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
Uhh... Considering the fact that the form object has only stuff from the accepted type, I think that's acceptable Otherwise, addressing each and every field might be a bit tedious
Hugo
Hugo•10mo ago
but in this case the only attribute you need to pass it the title right? so it shouldn't be that tedious and i'm just saying that to try to find where the error comes from
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
ohh yeah sure lemme try that emm no, not just the title. im testing the update form endpoint where i want to add a field to the form. update title (patch) works nicely. but this endpoint is failing.
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
this is some strange thing they have
No description
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
nvm i found the error. it was tricky certainly 🙂 alright everything is fixed, just duplicate isnt working @Hugo done! moved the PR to ready state lmk if you need any more modifications ill be available for another hour
Hugo
Hugo•10mo ago
will have a look tomorrow
H E I S E N B E R G
H E I S E N B E R GOP•10mo ago
cool! btw make a squash merge because i have flooded the PR with commits hey @Hugo fixed the stuff you mentioned in the issue.

Did you find this page helpful?