Skip to content

Commit 58a7fa7

Browse files
build: use rollup to build esm, cjs, and browser bundles
2 parents 0e8ba7a + 2437eaf commit 58a7fa7

27 files changed

+3622
-5772
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"@babel/plugin-proposal-object-rest-spread",
77
"@babel/transform-async-to-generator"
88
]
9-
}
9+
}

LICENSE renamed to LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

README.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,24 @@ npm install @typeform/api-client --save
3939
### Initialize
4040

4141
1. Import client library
42+
4243
``` javascript
44+
// If using ESM syntax
4345
import { createClient } from '@typeform/api-client'
46+
// If using CJS syntax
47+
const { createClient } = require('@typeform/api-client')
4448
```
4549

4650
2. Create an instance with your personal token
51+
4752
``` javascript
4853
const typeformAPI = createClient({
4954
token: '<your token>'
5055
})
5156
```
5257

5358
3. Use any of the methods available in the [reference](#reference)
59+
5460
``` javascript
5561
// will retrieve all forms
5662
typeformAPI
@@ -63,16 +69,19 @@ npm install @typeform/api-client --save
6369

6470
## Reference
6571

66-
#### `createClient({token})`
72+
### `createClient({token})`
73+
6774
- Creates a new instance of Typeform's JS client
6875
- Returns an instance with the methods described below
76+
6977
``` javascript
7078
const typeformClient = createClient({
7179
token: '<your token>'
7280
})
7381
```
7482

7583
Client returns the following properties:
84+
7685
- `forms`
7786
- `images`
7887
- `teams`
@@ -83,39 +92,48 @@ Client returns the following properties:
8392

8493
Each one of them encapsulates the operations related to it (like listing, updating, deleting the resource).
8594

86-
### Forms
95+
### Forms
8796

8897
#### `forms.list({ page: 1, pageSize = 10, search = '', page })`
98+
8999
- Get a list of your typeforms
90100
- Returns a list of typeforms with the payload [referenced here](https://developer.typeform.com/create/reference/retrieve-forms/).
91101

92102
#### `forms.get({ uid })`
103+
93104
- Get a typeform by UID
94105
- Returns a typeform with the payload [referenced here](https://developer.typeform.com/create/reference/retrieve-form/).
95106

96107
#### `forms.create({ data = {} })`
108+
97109
- Create a typeform
98110
- Returns a typeform with the payload [referenced here](https://developer.typeform.com/create/reference/create-form/).
99111

100112
#### `forms.update({ uid, data = {}, override = false })`
113+
101114
- Update a typeform by UID
102115
- Returns a typeform with the payload [referenced here](https://developer.typeform.com/create/reference/update-form/).
103116

104117
#### `forms.delete({ uid })`
118+
105119
- Deletes a typeform by UID
106120

107121
#### `forms.messages.get({ uid })`
122+
108123
- Get custom messages of the typeform with the given UID
109124

110125
#### `forms.messages.update({ uid })`
126+
111127
- Updates custom messages of the typeform with the given UID
112128

113129
### Images
114130

115131
#### `images.list()`
132+
116133
- Get your images collection
117134

118135
#### `images.get({ id, size, backgroundSize, choiceSize })`
136+
119137
- Get custom image by ID
120138
- `size`: default, thumbnail, mobile
121139
- `backgroundSize`: default, thumbnail, mobile, tablet
@@ -129,42 +147,51 @@ Each one of them encapsulates the operations related to it (like listing, updati
129147
- `fileName`: File name for the image
130148

131149
#### `images.delete({ id })`
150+
132151
- Deletes an image with the given ID
133152

134153
### Teams
135154

136155
#### `teams.get({ id })`
156+
137157
- Gets team information for the given ID
138158

139159
#### `teams.addMembers({ id, members })`
160+
140161
- Add members to a team for the given ID
141162
- `members`: `string` or an `array` and should be the email for the user
142163
- Adding multiple members at once is possible using an array of emails
143164

144165
#### `teams.removeMembers({ id, members })`
166+
145167
- Remove members to a team for the given ID
146168
- `members`: `string` or an `array` and should be the email for the user
147169
- Deleting multiple members at once is possible using an array of emails
148170

149171
### Themes
150172

151173
#### `themes.list({ page, pageSize })`
174+
152175
- Gets your themes collection
153176
- `page`: default `1`
154-
- `pageSize: default `10`
177+
- `pageSize: default `10`
155178

156179
#### `themes.get({ id })`
180+
157181
- Gets a theme for the given ID
158182

159183
#### `themes.create({ background, colors, font, hasTransparentButton, name })`
184+
160185
- Creates a theme with the given configuration
161186
- See more details of the payload in [the documentation](https://developer.typeform.com/create/reference/create-theme/)
162187

163188
#### `themes.update({ background, colors, font, hasTransparentButton, name })`
189+
164190
- Updates a theme with the given configuration
165191
- See more details of the payload in [the documentation](https://developer.typeform.com/create/reference/update-theme/)
166192

167193
#### `themes.delete({ id })`
194+
168195
- Deletes the theme with the given ID
169196

170197
### Workspaces
@@ -275,7 +302,7 @@ Each one of them encapsulates the operations related to it (like listing, updati
275302

276303
## Examples
277304

278-
##### Update specific typeform property, as [referenced here](https://developer.typeform.com/create/reference/update-form-patch/)
305+
### Update specific typeform property, as [referenced here](https://developer.typeform.com/create/reference/update-form-patch/)
279306

280307
``` javascript
281308
typeformClient
@@ -291,11 +318,11 @@ Each one of them encapsulates the operations related to it (like listing, updati
291318
]
292319
})
293320
.then(response => {
294-
//...
321+
//...
295322
})
296323
```
297324

298-
##### Update the whole typeform
325+
### Update the whole typeform
299326

300327
``` javascript
301328
typeformClient
@@ -311,14 +338,15 @@ Each one of them encapsulates the operations related to it (like listing, updati
311338
}
312339
})
313340
.then(response => {
314-
//...
341+
//...
315342
})
316343
```
317344

318345
**Note:**
319346
The theme property applies a `theme` to the form. If you don't specify a value for the 'theme' property, Typeform applies a new copy of the default theme to the form, **even if you already have a copy of the default theme applied to this form**.
320347

321-
##### Uploading an image
348+
### Uploading an image
349+
322350
``` javascript
323351
typeformClient
324352
.images
@@ -333,7 +361,7 @@ The theme property applies a `theme` to the form. If you don't specify a value f
333361

334362
```
335363

336-
##### Getting the thumbnail of an image
364+
### Getting the thumbnail of an image
337365

338366
``` javascript
339367
typeformClient
@@ -345,7 +373,7 @@ The theme property applies a `theme` to the form. If you don't specify a value f
345373

346374
```
347375

348-
### Testing
376+
## Testing
349377

350378
To run unit tests.
351379

@@ -357,6 +385,6 @@ yarn test:unit
357385

358386
```
359387

360-
### Suggestions or feedback?
388+
## Suggestions or feedback
361389

362390
Fill out this [conversation](https://bit.ly/2wmzCXi) 🙂

0 commit comments

Comments
 (0)