@@ -869,6 +869,143 @@ application:
869869 await expect ( appConfig . load ( { } ) ) . rejects . toThrow ( 'Missing or invalid keys in app.config.yaml' )
870870 } )
871871
872+ test ( 'valid schema: action inputs support array (OpenWhisk spec)' , async ( ) => {
873+ global . fakeFileSystem . addJson (
874+ {
875+ '/package.json' : '{}' ,
876+ '/app.config.yaml' : `
877+ application:
878+ runtimeManifest:
879+ packages:
880+ pkg:
881+ actions:
882+ myaction:
883+ function: actions/test.js
884+ inputs:
885+ TAGS: ['tag1', 'tag2', 'tag3']
886+ EMPTY: []
887+ `
888+ }
889+ )
890+ const config = await appConfig . load ( { } )
891+ const inputs = config . all . application . manifest . full . packages . pkg . actions . myaction . inputs
892+ expect ( inputs . TAGS ) . toEqual ( [ 'tag1' , 'tag2' , 'tag3' ] )
893+ expect ( Array . isArray ( inputs . TAGS ) ) . toBe ( true )
894+ expect ( inputs . EMPTY ) . toEqual ( [ ] )
895+ } )
896+
897+ test ( 'valid schema: action inputs support number (OpenWhisk spec)' , async ( ) => {
898+ global . fakeFileSystem . addJson (
899+ {
900+ '/package.json' : '{}' ,
901+ '/app.config.yaml' : `
902+ application:
903+ runtimeManifest:
904+ packages:
905+ pkg:
906+ actions:
907+ myaction:
908+ function: actions/test.js
909+ inputs:
910+ COUNT: 42
911+ NEGATIVE: -531
912+ FLOAT: 432.43
913+ `
914+ }
915+ )
916+ const config = await appConfig . load ( { } )
917+ const inputs = config . all . application . manifest . full . packages . pkg . actions . myaction . inputs
918+ expect ( inputs . COUNT ) . toBe ( 42 )
919+ expect ( inputs . NEGATIVE ) . toBe ( - 531 )
920+ expect ( inputs . FLOAT ) . toBe ( 432.43 )
921+ } )
922+
923+ test ( 'valid schema: action inputs support null (OpenWhisk spec)' , async ( ) => {
924+ global . fakeFileSystem . addJson (
925+ {
926+ '/package.json' : '{}' ,
927+ '/app.config.yaml' : `
928+ application:
929+ runtimeManifest:
930+ packages:
931+ pkg:
932+ actions:
933+ myaction:
934+ function: actions/test.js
935+ inputs:
936+ OPTIONAL: null
937+ `
938+ }
939+ )
940+ const config = await appConfig . load ( { } )
941+ const inputs = config . all . application . manifest . full . packages . pkg . actions . myaction . inputs
942+ expect ( inputs . OPTIONAL ) . toBeNull ( )
943+ } )
944+
945+ test ( 'valid schema: action inputs support mixed types (OpenWhisk spec)' , async ( ) => {
946+ global . fakeFileSystem . addJson (
947+ {
948+ '/package.json' : '{}' ,
949+ '/app.config.yaml' : `
950+ application:
951+ runtimeManifest:
952+ packages:
953+ pkg:
954+ actions:
955+ myaction:
956+ function: actions/test.js
957+ inputs:
958+ STR: hello
959+ NUM: 1
960+ FLAG: true
961+ ARR: [a, b]
962+ OBJ:
963+ type: string
964+ default: ''
965+ NIL: null
966+ `
967+ }
968+ )
969+ const config = await appConfig . load ( { } )
970+ const inputs = config . all . application . manifest . full . packages . pkg . actions . myaction . inputs
971+ expect ( inputs . STR ) . toBe ( 'hello' )
972+ expect ( inputs . NUM ) . toBe ( 1 )
973+ expect ( inputs . FLAG ) . toBe ( true )
974+ expect ( inputs . ARR ) . toEqual ( [ 'a' , 'b' ] )
975+ expect ( inputs . OBJ ) . toEqual ( { type : 'string' , default : '' } )
976+ expect ( inputs . NIL ) . toBeNull ( )
977+ } )
978+
979+ test ( 'valid schema: package-level inputs (same constraints as action inputs)' , async ( ) => {
980+ global . fakeFileSystem . addJson (
981+ {
982+ '/package.json' : '{}' ,
983+ '/app.config.yaml' : `
984+ application:
985+ runtimeManifest:
986+ packages:
987+ pkg:
988+ license: Apache-2.0
989+ inputs:
990+ PKG_LEVEL: pkg-default
991+ PKG_TAGS: ['a', 'b']
992+ PKG_COUNT: 10
993+ actions:
994+ myaction:
995+ function: actions/test.js
996+ inputs:
997+ ACTION_INPUT: action-value
998+ `
999+ }
1000+ )
1001+ const config = await appConfig . load ( { } )
1002+ const pkg = config . all . application . manifest . full . packages . pkg
1003+ expect ( pkg . inputs . PKG_LEVEL ) . toBe ( 'pkg-default' )
1004+ expect ( pkg . inputs . PKG_TAGS ) . toEqual ( [ 'a' , 'b' ] )
1005+ expect ( pkg . inputs . PKG_COUNT ) . toBe ( 10 )
1006+ expect ( pkg . actions . myaction . inputs . ACTION_INPUT ) . toBe ( 'action-value' )
1007+ } )
1008+
8721009 test ( 'valid schema with productDependencies' , async ( ) => {
8731010 global . fakeFileSystem . addJson (
8741011 {
0 commit comments