File tree Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,23 @@ export class Forms {
7373 return request ( page , pageSize )
7474 }
7575
76- public update ( args : {
76+ public update < T extends boolean > ( args : {
7777 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 > {
8193 const { uid, override, data } = args
8294 const methodType = override ? 'put' : 'patch'
8395
Original file line number Diff line number Diff line change @@ -113,9 +113,9 @@ export namespace Typeform {
113113 items : Workspace [ ]
114114 }
115115 }
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
119119 value : any
120120 }
121121 }
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ import { Typeform } from './typeform-types'
22
33export const createMemberPatchQuery = (
44 members : string [ ] ,
5- operation : string
6- ) : Typeform . API . PATCH [ ] => {
5+ operation : Typeform . API . PATCH < '/members' > [ 'op' ]
6+ ) : Typeform . API . PATCH < '/members' > [ ] => {
77 return members . map ( ( member ) => ( {
88 op : operation ,
99 path : '/members' ,
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export class Workspaces {
9393
9494 public update ( args : {
9595 id : string
96- data : Typeform . API . PATCH [ ]
96+ data : Typeform . API . PATCH < '/name' | '/members' > [ ]
9797 } ) : Promise < null > {
9898 const { id, data } = args
9999
@@ -109,9 +109,9 @@ export class Workspaces {
109109}
110110
111111const addOrRemoveMembers = (
112- operation : string ,
112+ operation : Typeform . API . PATCH < '/members' > [ 'op' ] ,
113113 members : string | string [ ]
114- ) : Typeform . API . PATCH [ ] => {
114+ ) : Typeform . API . PATCH < '/members' > [ ] => {
115115 if ( ! isMemberPropValid ( members ) ) {
116116 throw new Error ( `No member(s) provided` )
117117 }
You can’t perform that action at this time.
0 commit comments