Skip to content

Commit 5f19ed9

Browse files
committed
Merge pull request #141 from paxtonhare/140_fix_vet
fixed #140 - vet plugins not working correctly
2 parents 0fc648d + fb26b5b commit 5f19ed9

File tree

1 file changed

+33
-8
lines changed
  • marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/lib

1 file changed

+33
-8
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/lib/flow-lib.xqy

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)