File tree 4 files changed +24
-12
lines changed
4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,23 @@ export class Forms {
73
73
return request ( page , pageSize )
74
74
}
75
75
76
- public update ( args : {
76
+ public update < T extends boolean > ( args : {
77
77
uid : string
78
- override ?: boolean
79
- data : Typeform . Form
80
- } ) : Promise < Typeform . Form > {
78
+ override ?: T
79
+ data : T extends true
80
+ ? Typeform . Form
81
+ : Typeform . API . PATCH <
82
+ | '/settings/facebook_pixel'
83
+ | '/settings/google_analytics'
84
+ | '/settings/google_tag_manager'
85
+ | '/settings/is_public'
86
+ | '/settings/meta'
87
+ | '/cui_settings'
88
+ | '/theme'
89
+ | '/title'
90
+ | '/workspace'
91
+ > [ ]
92
+ } ) : Promise < T extends true ? Typeform . Form : null > {
81
93
const { uid, override, data } = args
82
94
const methodType = override ? 'put' : 'patch'
83
95
Original file line number Diff line number Diff line change @@ -113,9 +113,9 @@ export namespace Typeform {
113
113
items : Workspace [ ]
114
114
}
115
115
}
116
- export interface PATCH {
117
- op : string
118
- path : string
116
+ export interface PATCH < T extends string > {
117
+ op : 'add' | 'remove' | 'replace'
118
+ path : T
119
119
value : any
120
120
}
121
121
}
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ import { Typeform } from './typeform-types'
2
2
3
3
export const createMemberPatchQuery = (
4
4
members : string [ ] ,
5
- operation : string
6
- ) : Typeform . API . PATCH [ ] => {
5
+ operation : Typeform . API . PATCH < '/members' > [ 'op' ]
6
+ ) : Typeform . API . PATCH < '/members' > [ ] => {
7
7
return members . map ( ( member ) => ( {
8
8
op : operation ,
9
9
path : '/members' ,
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export class Workspaces {
93
93
94
94
public update ( args : {
95
95
id : string
96
- data : Typeform . API . PATCH [ ]
96
+ data : Typeform . API . PATCH < '/name' | '/members' > [ ]
97
97
} ) : Promise < null > {
98
98
const { id, data } = args
99
99
@@ -109,9 +109,9 @@ export class Workspaces {
109
109
}
110
110
111
111
const addOrRemoveMembers = (
112
- operation : string ,
112
+ operation : Typeform . API . PATCH < '/members' > [ 'op' ] ,
113
113
members : string | string [ ]
114
- ) : Typeform . API . PATCH [ ] => {
114
+ ) : Typeform . API . PATCH < '/members' > [ ] => {
115
115
if ( ! isMemberPropValid ( members ) ) {
116
116
throw new Error ( `No member(s) provided` )
117
117
}
You can’t perform that action at this time.
0 commit comments