Skip to content

Commit 663c168

Browse files
committed
fixed #140 - vet plugins not working correctly
1 parent 0fc648d commit 663c168

File tree

1 file changed

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

1 file changed

+24
-8
lines changed

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,32 @@ 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
616629
try {
617-
flow:run-plugin(
618-
$plugin,
619-
$data-format,
620-
"123",
621-
(),
622-
(),
623-
(),
624-
$options)
630+
if ($type eq $flow:TYPE-XQUERY) then
631+
xdmp:eval(
632+
'import module namespace x = "' || $ns || '" at "' || $module-uri || '"; ' ||
633+
'()',
634+
map:new(map:entry("staticCheck", fn:true()))
635+
)
636+
else
637+
xdmp:javascript-eval(
638+
'var x = require("' || $module-uri || '");',
639+
map:new(map:entry("staticCheck", fn:true()))
640+
)
625641
}
626642
catch($ex) {
627643
json:array-push($errors, flow:make-error-json($ex))

0 commit comments

Comments
 (0)