@@ -485,7 +485,7 @@ export default class Apigw {
485485
486486 const unboundSecretIds = await this . getUnboundSecretIds ( {
487487 usagePlanId : usagePlan . usagePlanId ,
488- secretIds : secrets . secretIds ,
488+ secretIds : secrets . secretIds ! ,
489489 } ) ;
490490
491491 if ( unboundSecretIds . length > 0 ) {
@@ -654,7 +654,7 @@ export default class Apigw {
654654 path,
655655 method,
656656 } : {
657- serviceId : string ;
657+ serviceId ? : string ;
658658 path : string ;
659659 method : string ;
660660 } ) {
@@ -704,42 +704,47 @@ export default class Apigw {
704704
705705 async createOrUpdateApi ( { serviceId, endpoint, environment, created } : CreateOrUpdateApiInputs ) {
706706 // compatibility for secret auth config depends on auth & usagePlan
707- const authType = endpoint . auth ? 'SECRET' : endpoint . authType || 'NONE' ;
708- const businessType = endpoint . businessType || 'NORMAL' ;
707+ const authType = endpoint ? .auth ? 'SECRET' : endpoint ? .authType ?? 'NONE' ;
708+ const businessType = endpoint ? .businessType ?? 'NORMAL' ;
709709 const output : ApiDeployerOutputs = {
710- path : endpoint . path ,
711- method : endpoint . method ,
712- apiName : endpoint . apiName || 'index' ,
710+ path : endpoint ? .path ,
711+ method : endpoint ? .method ,
712+ apiName : endpoint ? .apiName || 'index' ,
713713 created : true ,
714714 authType : authType ,
715715 businessType : businessType ,
716- isBase64Encoded : endpoint . isBase64Encoded === true ,
716+ isBase64Encoded : endpoint ? .isBase64Encoded === true ,
717717 } ;
718- if ( endpoint . authRelationApiId ) {
718+ if ( endpoint ? .authRelationApiId ) {
719719 output . authRelationApiId = endpoint . authRelationApiId ;
720720 }
721721
722722 const apiInputs = {
723- protocol : endpoint . protocol || 'HTTP' ,
723+ protocol : endpoint ? .protocol ?? 'HTTP' ,
724724 serviceId : serviceId ,
725- apiName : endpoint . apiName || 'index' ,
726- apiDesc : endpoint . description ,
725+ apiName : endpoint ? .apiName ?? 'index' ,
726+ apiDesc : endpoint ? .description ,
727727 apiType : 'NORMAL' ,
728728 authType : authType ,
729- apiBusinessType : endpoint . businessType || 'NORMAL' ,
730- serviceType : endpoint . serviceType || 'SCF' ,
729+ apiBusinessType : endpoint ? .businessType ?? 'NORMAL' ,
730+ serviceType : endpoint ? .serviceType ?? 'SCF' ,
731731 requestConfig : {
732- path : endpoint . path ,
733- method : endpoint . method ,
732+ path : endpoint ? .path ,
733+ method : endpoint ? .method ,
734734 } ,
735- serviceTimeout : endpoint . serviceTimeout || 15 ,
736- responseType : endpoint . responseType || 'HTML' ,
737- enableCORS : endpoint . enableCORS === true ,
738- isBase64Encoded : endpoint . isBase64Encoded === true ,
735+ serviceTimeout : endpoint ? .serviceTimeout ?? 15 ,
736+ responseType : endpoint ? .responseType ?? 'HTML' ,
737+ enableCORS : endpoint ? .enableCORS === true ,
738+ isBase64Encoded : endpoint ? .isBase64Encoded === true ,
739739 isBase64Trigger : undefined as undefined | boolean ,
740- base64EncodedTriggerRules : undefined as undefined | string [ ] ,
741- oauthConfig : endpoint . oauthConfig ,
742- authRelationApiId : endpoint . authRelationApiId ,
740+ base64EncodedTriggerRules : undefined as
741+ | undefined
742+ | {
743+ name : string ;
744+ value : string [ ] ;
745+ } [ ] ,
746+ oauthConfig : endpoint ?. oauthConfig ,
747+ authRelationApiId : endpoint ?. authRelationApiId ,
743748 } ;
744749
745750 this . marshalApiInput ( endpoint , apiInputs ) ;
@@ -749,20 +754,20 @@ export default class Apigw {
749754 InternalDomain ?: string ;
750755 } ;
751756
752- if ( endpoint . apiId ) {
753- apiDetail = await this . getApiById ( { serviceId, apiId : endpoint . apiId } ) ;
757+ if ( endpoint ? .apiId ) {
758+ apiDetail = await this . getApiById ( { serviceId : serviceId ! , apiId : endpoint . apiId } ) ;
754759 }
755760
756761 if ( ! apiDetail ! ) {
757762 apiDetail = await this . getApiByPathAndMethod ( {
758- serviceId,
759- path : endpoint . path ,
760- method : endpoint . method ,
763+ serviceId : serviceId ! ,
764+ path : endpoint ? .path ! ,
765+ method : endpoint ? .method ! ,
761766 } ) ;
762767 }
763768
764- if ( apiDetail ) {
765- console . log ( `Api method ${ endpoint . method } , path ${ endpoint . path } already exist` ) ;
769+ if ( apiDetail && endpoint ) {
770+ console . log ( `Api method ${ endpoint ? .method } , path ${ endpoint ? .path } already exist` ) ;
766771 endpoint . apiId = apiDetail . ApiId ;
767772
768773 if ( endpoint . isBase64Encoded && endpoint . isBase64Trigger ) {
@@ -796,7 +801,7 @@ export default class Apigw {
796801 } ) ;
797802 output . internalDomain = apiDetail . InternalDomain || '' ;
798803
799- if ( endpoint . isBase64Encoded && endpoint . isBase64Trigger ) {
804+ if ( endpoint ? .isBase64Encoded && endpoint . isBase64Trigger ) {
800805 apiInputs . isBase64Trigger = endpoint . isBase64Trigger ;
801806 apiInputs . base64EncodedTriggerRules = endpoint . base64EncodedTriggerRules ;
802807 }
@@ -810,7 +815,7 @@ export default class Apigw {
810815
811816 output . apiName = apiInputs . apiName ;
812817
813- if ( endpoint . usagePlan ) {
818+ if ( endpoint ? .usagePlan ) {
814819 const usagePlan = await this . bindUsagePlan ( {
815820 apiId : output . apiId ,
816821 serviceId,
@@ -837,7 +842,7 @@ export default class Apigw {
837842 // if exist in state list, set created to be true
838843 const [ exist ] = oldList . filter (
839844 ( item ) =>
840- item . method . toLowerCase ( ) === apiConfig . method . toLowerCase ( ) &&
845+ item ? .method ? .toLowerCase ( ) === apiConfig ? .method ? .toLowerCase ( ) &&
841846 item . path === apiConfig . path ,
842847 ) ;
843848
@@ -855,7 +860,7 @@ export default class Apigw {
855860 if ( authRelationApi ) {
856861 const [ relativeApi ] = apiList . filter (
857862 ( item ) =>
858- item . method . toLowerCase ( ) === authRelationApi . method . toLowerCase ( ) &&
863+ item . method ? .toLowerCase ( ) === authRelationApi . method . toLowerCase ( ) &&
859864 item . path === authRelationApi . path ,
860865 ) ;
861866 if ( relativeApi ) {
0 commit comments