Write TypeScript scripts interacting with Typeform#6
Needed some clarification on this @Hugo
44 Replies
this is something i see when i try to create the form from GUI
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"
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.everything is an object. should I use
any
from typecript?nvm i forgot to collapse the thing 🙂 found it now
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?
@Hugo
sadly we need to have the types explicitely defined
ah cool
how would you like to resolve this? I feel the best way would be to create a separate type for this
for now i have done something like this
duplicate form mentions the reference of create-form. what should the logic be?
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 titleim done with the other plugins just stuck with these two: duplicate and update title. can you help me a bit @Hugo ?
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"
hmmm okay so i can just update the name to something say, name_copy?
ah missed it
you should create a new form with the name of the old form + " (copy)"
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?
gotcha
- 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 goodCiol
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
for example this. the layout property doesnt exist
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
then just ignore layout
cool
@Hugo https://www.typeform.com/developers/responses/ the response API doesnt allow creating a response programatically. how do i implement the test?
mmm
can you do it on the web ui and put as comments in the test file the exact process to follow?
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?
i mean not for the users, it's for me when i check your tests
but yes
oh
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
leaving the forms to dangle might produce errors
ive pushed some tests. just 4 left
assume the form for the repsonses tests is created manually and the id is passed in the .env file
sure
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
are you sure you can spread
form
in there
?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
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
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.
this is some strange thing they have
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
will have a look tomorrow
cool!
btw make a squash merge because i have flooded the PR with commits
hey @Hugo fixed the stuff you mentioned in the issue.