@@ -612,16 +612,41 @@ declare function flow:validate-entities()
612612 let $_ :=
613613 for $plugin in $flow/hub:plugins/hub:plugin
614614 let $destination := $plugin/@dest
615+ let $module-uri := $plugin/@module
616+ let $module-name := hul:get-module-name ($module-uri)
617+ let $filename as xs:string := hul:get-file-from-uri ($module-uri)
618+ let $type := flow:get-type ($filename)
619+ let $ns :=
620+ if ($type eq $flow:TYPE-JAVASCRIPT) then ()
621+ else
622+ $flow:PLUGIN-NS || fn:lower-case ($module-name)
623+ let $func-name :=
624+ if ($type eq $flow:TYPE-JAVASCRIPT) then
625+ "create" || functx:capitalize-first ($destination)
626+ else
627+ "create-" || $destination
615628 return
629+ (:
630+ : Note that we are static checking the files.
631+ : This is because there is no reasonable way to actually
632+ : call the plugins and pass in data that will work for all plugins.
633+ :
634+ : The disadvantage to static checking is that we will not catch typos
635+ : like ctsdoc <- (missing period) because Javascript is dynamically
636+ : typed. Static checking will only catch syntax errors in sjs.
637+ :)
616638 try {
617- flow:run-plugin (
618- $plugin,
619- $data-format,
620- "123" ,
621- (),
622- (),
623- (),
624- $options)
639+ if ($type eq $flow:TYPE-XQUERY) then
640+ xdmp:eval (
641+ 'import module namespace x = "' || $ns || '" at "' || $module-uri || '"; ' ||
642+ '()' ,
643+ map:new (map:entry ("staticCheck" , fn:true ()))
644+ )
645+ else
646+ xdmp:javascript-eval (
647+ 'var x = require("' || $module-uri || '");' ,
648+ map:new (map:entry ("staticCheck" , fn:true ()))
649+ )
625650 }
626651 catch ($ex) {
627652 json:array-push ($errors, flow:make-error-json ($ex))
0 commit comments