@@ -25,13 +25,13 @@ declare variable $api:definitions := ("api.json");
2525 :) 
2626declare  function  api:get-status ($request as  map (*)) {
2727        <tuttle>
28-             <default>{$ config:default-collection}</default>
28+             <default>{config:default-collection () }</default>
2929            <repos>
30-             {for  $collection in  map:keys ($ config:collections)
31-                 let  $col-config := $ config:collections? ($collection)
32-                 let  $collection-path := $ config:prefix || "/"  || $collection
33-                 let  $hash-staging := $ config:prefix || "/"  || $collection || $ config:suffix || "/gitsha.xml" 
34-                 let  $hash-deploy := $ config:prefix || "/"  || $collection || "/gitsha.xml" 
30+             {for  $collection in  config:list- collections ( )
31+                 let  $col-config := config:collections ($collection)
32+                 let  $collection-path := config:prefix ()  || "/"  || $collection
33+                 let  $hash-staging := config:prefix ()  || "/"  || $collection || config:suffix ()  || "/gitsha.xml" 
34+                 let  $hash-deploy := config:prefix ()  || "/"  || $collection || "/gitsha.xml" 
3535                let  $hash-git := if ($col-config?vcs = "github" ) then  github:get-lastcommit-sha ($col-config)
3636                                    else  gitlab:get-lastcommit-sha ($col-config)
3737                let  $status := if  ($hash-git?sha = ""  ) then 
@@ -66,10 +66,10 @@ declare function api:get-status($request as map(*)) {
6666 :) 
6767declare  function  api:get-hash ($request as  map (*)) {
6868    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
69-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
70-     let  $config := $ config:collections? ($git-collection)
71-     let  $collection := $ config:prefix || "/"  || $git-collection || "/gitsha.xml" 
72-     let  $collection-staging := $ config:prefix || "/"  || $git-collection || $ config:suffix || "/gitsha.xml" 
69+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
70+     let  $config := config:collections ($git-collection)
71+     let  $collection := config:prefix ()  || "/"  || $git-collection || "/gitsha.xml" 
72+     let  $collection-staging := config:prefix ()  || "/"  || $git-collection || config:suffix ()  || "/gitsha.xml" 
7373
7474    return 
7575        if  (exists ($config))  then  (
@@ -90,15 +90,15 @@ declare function api:get-hash($request as map(*)) {
9090:) 
9191declare  function  api:lock-remove ($request as  map (*)) {
9292    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
93-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection)
94-     let  $config := $ config:collections? ($git-collection)
95-     let  $lockfile-path := $ config:prefix || "/"  || $git-collection
96-     let  $lockfile := $lockfile-path || "/"  || $ config:lock
93+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection)
94+     let  $config := config:collections ($git-collection)
95+     let  $lockfile-path := config:prefix ()  || "/"  || $git-collection
96+     let  $lockfile := $lockfile-path || "/"  || config:lock () 
9797
9898    return 
9999        if  (exists ($config))  then  (
100100            if  (exists (doc ($lockfile))) then  (
101-                 let  $remove := xmldb:remove ($lockfile-path, $ config:lock)
101+                 let  $remove := xmldb:remove ($lockfile-path, config:lock () )
102102                let  $message := "lockfile removed: "  || $lockfile 
103103                return 
104104                    map { "message"  : $message}
@@ -118,10 +118,10 @@ declare function api:lock-remove($request as map(*)) {
118118:) 
119119declare  function  api:lock-print ($request as  map (*)) {
120120    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
121-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
122-     let  $config := $ config:collections? ($git-collection)
123-     let  $lockfile-path := $ config:prefix || "/"  || $git-collection
124-     let  $lockfile := $lockfile-path || "/"  || $ config:lock
121+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
122+     let  $config := config:collections ($git-collection)
123+     let  $lockfile-path := config:prefix ()  || "/"  || $git-collection
124+     let  $lockfile := $lockfile-path || "/"  || config:lock () 
125125
126126    return 
127127        if  (exists ($config))  then  (
@@ -144,12 +144,12 @@ declare function api:lock-print($request as map(*)) {
144144 :) 
145145declare  function  api:git-pull ($request as  map (*)) {
146146    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
147-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
148-     let  $config := $ config:collections? ($git-collection)
149-     let  $collection-staging := $ config:prefix || "/"  || $git-collection || $ config:suffix
150-     let  $collection-staging-sha := $ config:prefix || "/"  || $git-collection || $ config:suffix || "/gitsha.xml" 
151-     let  $lockfile := $ config:prefix || "/"  || $git-collection || "/"  || $ config:lock
152-     let  $collection-destination := $ config:prefix || "/"  || $git-collection
147+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
148+     let  $config := config:collections ($git-collection)
149+     let  $collection-staging := config:prefix ()  || "/"  || $git-collection || config:suffix () 
150+     let  $collection-staging-sha := config:prefix ()  || "/"  || $git-collection || config:suffix ()  || "/gitsha.xml" 
151+     let  $lockfile := config:prefix ()  || "/"  || $git-collection || "/"  || config:lock () 
152+     let  $collection-destination := config:prefix ()  || "/"  || $git-collection
153153
154154    return 
155155        if  (exists ($config))  then  (
@@ -183,13 +183,13 @@ declare function api:git-pull($request as map(*)) {
183183
184184declare  function  api:git-deploy ($request as  map (*)) {
185185    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
186-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
187-     let  $config := $ config:collections? ($git-collection)
188-     let  $collection-staging := $git-collection || $ config:suffix
189-     let  $collection-staging-uri := $ config:prefix || "/"  || $collection-staging 
190-     let  $collection-destination := $ config:prefix || "/"  || $git-collection
186+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
187+     let  $config := config:collections ($git-collection)
188+     let  $collection-staging := $git-collection || config:suffix () 
189+     let  $collection-staging-uri := config:prefix ()  || "/"  || $collection-staging 
190+     let  $collection-destination := config:prefix ()  || "/"  || $git-collection
191191    let  $collection-destination-sha := $collection-destination || "/gitsha.xml" 
192-     let  $lockfile := $collection-destination || "/"  || $ config:lock
192+     let  $lockfile := $collection-destination || "/"  || config:lock () 
193193
194194    return 
195195        if  (exists ($config))  then  (
@@ -203,7 +203,7 @@ declare function api:git-deploy($request as map(*)) {
203203                else  (
204204                    let  $check-lock-dst := if  (xmldb:collection-available ($collection-destination)) then  ()
205205                    else  (
206-                         xmldb:create-collection ($ config:prefix, $git-collection)
206+                         xmldb:create-collection (config:prefix () , $git-collection)
207207                    ) 
208208                    let  $write-lock := app:lock-write ($collection-destination, "deploy" )
209209                    let  $xar-list := xmldb:get-child-resources ($collection-staging-uri)
@@ -251,8 +251,8 @@ declare function api:git-deploy($request as map(*)) {
251251 :) 
252252declare  function  api:get-commit ($request as  map (*)) {
253253    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
254-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
255-     let  $config := $ config:collections? ($git-collection)
254+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
255+     let  $config := config:collections ($git-collection)
256256
257257    return 
258258        if  (exists ($config))  then  (
@@ -276,10 +276,10 @@ declare function api:get-commit($request as map(*)) {
276276 :) 
277277declare  function  api:incremental ($request as  map (*)) {
278278    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
279-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
280-     let  $config := $ config:collections? ($git-collection)
281-     let  $collection-path := $ config:prefix || "/"  || $git-collection
282-     let  $lockfile := $collection-path || "/"  || $ config:lock
279+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
280+     let  $config := config:collections ($git-collection)
281+     let  $collection-path := config:prefix ()  || "/"  || $git-collection
282+     let  $lockfile := $collection-path || "/"  || config:lock () 
283283    let  $collection-destination-sha := $collection-path || "/gitsha.xml" 
284284
285285    return 
@@ -335,9 +335,9 @@ declare function api:incremental($request as map(*)) {
335335 : APIKey generation for webhooks 
336336 :) 
337337declare  function  api:api-keygen ($request as  map (*)) {
338-     let  $git-collection := $ config:default-collection
339-     let  $config := $ config:collections? ($git-collection)
340-     let  $collection := $ config:default-collection
338+     let  $git-collection := config:default-collection () 
339+     let  $config := config:collections ($git-collection)
340+     let  $collection := config:default-collection () 
341341
342342    return 
343343        if  (exists ($config))  then  (
@@ -357,12 +357,12 @@ declare function api:api-keygen($request as map(*)) {
357357 :) 
358358declare  function  api:hook ($request as  map (*)) {
359359    let  $git-collection := if  (not (exists ($request?parameters?collection))) then   
360-         $ config:default-collection else  xmldb:decode-uri ($request?parameters?collection) 
361-     let  $config := $ config:collections? ($git-collection)
360+         config:default-collection ()  else  xmldb:decode-uri ($request?parameters?collection) 
361+     let  $config := config:collections ($git-collection)
362362
363363    return 
364364        if  (exists ($config))  then  (
365-             let  $apikey := doc ($ config:apikeys)//apikeys/collection[name = $collection]/key/text ()
365+             let  $apikey := doc (config:apikeys () )//apikeys/collection[name = $collection]/key/text ()
366366            return  
367367                if  ($apikey) then  (
368368                    let  $apikey-header := 
@@ -374,8 +374,8 @@ declare function api:hook($request as map(*)) {
374374                            request:get-header ("X-Gitlab-Token" )
375375                    return 
376376                        if  ($apikey-header = $apikey) then  (
377-                             let  $collection-path := $ config:prefix || "/"  || $git-collection
378-                             let  $lockfile := $collection-path || "/"  || $ config:lock
377+                             let  $collection-path := config:prefix ()  || "/"  || $git-collection
378+                             let  $lockfile := $collection-path || "/"  || config:lock () 
379379                            let  $collection-destination-sha := $collection-path || "/gitsha.xml" 
380380                            let  $login := xmldb:login ($collection-path, $config:hookuser, $config:hookpasswd)
381381
0 commit comments