@@ -37,7 +37,7 @@ const create = function (createCustomMetadataFieldOptions: CreateCustomMetadataF
3737 return ;
3838 }
3939
40- if ( ! ! schema . type ) {
40+ if ( ! schema . type ) {
4141 respond ( true , errorMessages . CMF_SCHEMA_INVALID , callback ) ;
4242 return ;
4343 }
@@ -67,7 +67,12 @@ const list = function (
6767 request ( requestOptions , defaultOptions , callback ) ;
6868} ;
6969
70- const update = function ( updateCustomMetadataFieldOptions : UpdateCustomMetadataFieldOptions , defaultOptions : ImageKitOptions , callback ?: IKCallback < CustomMetadataField > ) {
70+ const update = function ( fieldId : string , updateCustomMetadataFieldOptions : UpdateCustomMetadataFieldOptions , defaultOptions : ImageKitOptions , callback ?: IKCallback < CustomMetadataField > ) {
71+ if ( ! fieldId || typeof fieldId !== "string" || ! fieldId . length ) {
72+ respond ( true , errorMessages . CMF_FIELD_ID_MISSING , callback ) ;
73+ return ;
74+ }
75+
7176 const { label, schema } = updateCustomMetadataFieldOptions ;
7277 if ( ! label && ! schema ) {
7378 respond ( true , errorMessages . CMF_LABEL_SCHEMA_MISSING , callback ) ;
@@ -79,8 +84,8 @@ const update = function (updateCustomMetadataFieldOptions: UpdateCustomMetadataF
7984 if ( schema ) requestBody . schema = schema ;
8085
8186 var requestOptions = {
82- url : " https://api.imagekit.io/v1/customMetadataFields" ,
83- method : "POST " ,
87+ url : ` https://api.imagekit.io/v1/customMetadataFields/ ${ fieldId } ` ,
88+ method : "PATCH " ,
8489 json : requestBody
8590 } ;
8691
@@ -92,6 +97,10 @@ const deleteField = function (
9297 defaultOptions : ImageKitOptions ,
9398 callback ?: IKCallback < void > ,
9499) {
100+ if ( ! fieldId || typeof fieldId !== "string" || ! fieldId . length ) {
101+ respond ( true , errorMessages . CMF_FIELD_ID_MISSING , callback ) ;
102+ return ;
103+ }
95104 var requestOptions = {
96105 url : `https://api.imagekit.io/v1/customMetadataFields/${ fieldId } ` ,
97106 method : "DELETE" ,
0 commit comments