couchdb-web-node-plugin 1.0.622 → 1.0.624
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/databaseHelper.js +1 -1
- package/helper.d.ts +2 -1
- package/helper.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/databaseHelper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(){return(r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var o=[null];o.push.apply(o,t);var a=new(Function.bind.apply(e,o));return r&&n(a,r.prototype),a}).apply(null,arguments)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)}function a(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}e.r(t),e.d(t,{DatabaseHelper:()=>l,default:()=>c});var l=function(){function e(){}return e.authenticate=function(e,t,r,n,o,i,l,c,p){var s;void 0===t&&(t=null),void 0===r&&(r={}),void 0===n&&(n={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===i&&(i="_id"),void 0===l&&(l="-type"),void 0===c&&(c="_design/"),void 0===p&&(p=!1);var m=null!==(s=e[l])&&void 0!==s?s:t&&t[l];if(!m)return!0;var u=p?"read":"write",y={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,i)&&e[i].startsWith(c)&&y.read.push("readonlymember");var d,f="Current user doesn't own any role";if(r)if("name"in r||(r.name='"unknown"'),null!=(d=r.roles)&&d.length){if(o&&m&&Object.prototype.hasOwnProperty.call(o,m)){for(var h,g,v=o[m],b=a(["read","write"]);!(h=b()).done;)y[g=h.value]=y[g].concat(v[g]||[]);y.properties=v.properties}for(var O,w,P=y[u],j=a(r.roles);!(O=j()).done;)if(w=O.value,P.includes(w))return!0;f='Current user "'+r.name+'" owns the following roles: "'+r.roles.join('", "')+'"'}else f='Current user "'+r.name+"\" doesn't own any role";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+u+' action: "'+[].concat(y[u]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,t,n,i,l,c,p){void 0===c&&(c={});var s=function(e,t,r){var n;throw void 0===t&&(t="forbidden"),void 0===r&&(r={}),o(((n={})[t]=e,n.message=e,n.name=t,n),r)},m=new Date,u=Date.UTC(m.getUTCFullYear(),m.getUTCMonth(),m.getUTCDate(),m.getUTCHours(),m.getUTCMinutes(),m.getUTCSeconds(),m.getUTCMilliseconds())/1e3,y=!l.dateTimeFormat.startsWith("iso"),d=l.property.name.special,f=d.id,h=d.revision,g=d.type;t&&t[g]&&!e[g]&&(e[g]=t[g]);var v="",b="",O=function(){v=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",b=Object.prototype.hasOwnProperty.call(e,h)?e[h]:""};if(O(),Object.prototype.hasOwnProperty.call(i,l.property.name.validatedDocumentsCache)&&i[l.property.name.validatedDocumentsCache].has(v+"-"+b))return i[l.property.name.validatedDocumentsCache].delete(v+"-"+b),e;["latest","upsert"].includes(b)&&(t&&Object.prototype.hasOwnProperty.call(t,h)?b=e[h]=t[h]:"latest"===b?s("Revision: No old document available to update."):delete e[h]);var w=l.updateStrategy;Object.prototype.hasOwnProperty.call(e,d.strategy)&&(w=e[d.strategy],delete e[d.strategy]);var P,j={};if("migrate"===w)for(var x=0,N=Object.entries(c);x<N.length;x++){var A=N[x],S=A[0],C=A[1];if(Object.prototype.hasOwnProperty.call(C,d.oldType)&&C[d.oldType])for(var k,T,D=a([].concat(C[d.oldType]));!(k=D()).done;)T=k.value,j[T]=S}p?P=p:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?P=function(e){return JSON.stringify(e,null,4)}:s('Needed "serializer" is not available.');var E=[d.additional,d.allowedRole,d.constraint.execution,d.constraint.expression,d.create.execution,d.create.expression,d.extend,d.maximumAggregatedSize,d.minimumAggregatedSize,d.oldType,d.update.execution,d.update.expression],z=function(e){return e instanceof Error?""+e:P(e)},M=function(e){return"string"==typeof e?e.trim():""},R=function(e){if(y)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},U=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return[].concat(r.fileName.regularExpressionPattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},_=function(t,r){if(r||(r=e[d.attachment]),t){for(var n,o=0,a=Object.keys(r);o<a.length;o++)if((n=a[o]).startsWith(t))return n}else{var i=Object.keys(r);if(i.length)return i[0]}return null},H=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var a=M(e);if(a){var i,l=(t?"return ":"")+a,c=o({},I,{code:l},n),p=Object.keys(c);try{i=r(Function,p.concat([l]))}catch(e){s(z(e),"compilation",{code:l,error:e,scope:c})}var m={code:l,result:void 0,scope:c};try{m.result=i.apply(void 0,p.map((function(e){return c[e]})))}catch(e){s(z(e),"runtime",{code:l,error:e,scope:c})}return m}s("No expression to evaluate provided.","empty")},L=function(e,t,n){void 0===n&&(n=[]);var o=n.length?" in "+n.join(" -> "):"",i=[],p=function(){Object.prototype.hasOwnProperty.call(e,g)||(t&&Object.prototype.hasOwnProperty.call(t,g)&&["fillUp","migrate"].includes(w)?e[g]=t[g]:s('Type: You have to specify a model type via property "'+g+'"'+o+".")),n.length||new RegExp(l.property.name.typeRegularExpressionPattern.public).test(e[g])||s('TypeName: You have to specify a model type which matches "'+l.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+e[g]+'")'+o+"."),Object.prototype.hasOwnProperty.call(c,e[g])||(Object.prototype.hasOwnProperty.call(j,e[g])?e[g]=j[e[g]]:s('Model: Given model "'+e[g]+'" is not specified'+o+"."))};p();var m=e[g],u=c[m],v=void 0;Object.prototype.hasOwnProperty.call(u,d.additional)&&u[d.additional]&&(v=u[d.additional]);var b=function(i,l,c,p,y){void 0===y&&(y=["constraintExecution","constraintExpression"]);for(var d,f,h=a(y);!(d=h()).done;)if(f=d.value,Object.prototype.hasOwnProperty.call(c,f)){var g=void 0;try{g=H(c[f].evaluation,f.endsWith("Expression"),{checkPropertyContent:P,model:u,modelName:m,name:l,type:f,newDocument:e,newValue:i,oldDocument:t,oldValue:p,parentNames:n,pathDescription:o,propertySpecification:c})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+f+'" has invalid code "'+e.code+'": "'+e.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+f+'" has throw an error with code "'+e.code+'": "'+e.message+'"'+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(g&&!g.result){var v=M(c[f].description);s(f.charAt(0).toUpperCase()+(f.substring(1)+": ")+(v?r(Function,Object.keys(g.scope).concat(["return "+v])).apply(void 0,Object.values(g.scope)):'Property "'+l+'" should satisfy constraint "'+g.code+'" (given "'+z(i)+'")'+o+"."))}}},P=function(e,t,r,i){var l=[],p=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,g)&&1===p.length&&Object.prototype.hasOwnProperty.call(c,p[0])&&(e[g]=p[0]);for(var m,u,d=!1,h=a(p);!(m=h()).done;)if(u=m.value,Object.prototype.hasOwnProperty.call(c,u)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]!==u&&"migrate"===w&&1===p.length&&(e[g]=u,l=n.concat(t+"","migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]===u){var v=L(e,i,n.concat(t+""));if(v.changedPath.length&&(l=v.changedPath),e=v.newDocument,z(e)===z({}))return{newValue:void 0,changedPath:l};d=!0;break}1===p.length&&s('NestedType: Under key "'+t+'" isn\'t of type "'+u+'" (given "'+z(e)+'" of type '+typeof e+")"+o+".")}else if("DateTime"===u){var O=e;if(e=R(e),!(y&&("number"!=typeof e||isNaN(e))||!y&&"string"!=typeof e)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'"isn\'t of (valid) type "DateTime" (given"'+z(O).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof O+'")'+o+".")}else if(["boolean","integer","number","string"].includes(u)){if(!("number"==typeof e&&isNaN(e)||"integer"!==u&&typeof e!==u||"integer"===u&&parseInt(e,10)!==e)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+u+'" (given "'+z(e)+'" of type "'+typeof e+'")'+o+".")}else if("string"==typeof u&&u.startsWith("foreignKey:")){var P=c[u.substring(11)][f].type;if(P===typeof e){d=!0;break}1===p.length&&s('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+P+'" (given "'+z(e)+'" of type "'+typeof e+'")'+o+".")}else{if("any"===u||z(e)===z(u)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t value "'+u+'" (given "'+z(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+o+".")}if(d||s('PropertyType: None of the specified types "'+p.join('", "')+'" for property "'+t+'" matches value "'+z(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+o+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&s('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+o+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&s('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+o+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&s('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+o+"."),"number"==typeof r.maximum&&e>r.maximum&&s('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+o+".")),r.selection){var j=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(j=j.map(R)),j.includes(e)||s('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+j.join('", "')+'". But is "'+e+'"'+o+".")}if(r.regularExpressionPattern){for(var x,N,A=[].concat(r.regularExpressionPattern),S=!1,C=a(A);!(x=C()).done;)if(N=x.value,new RegExp(N).test(e)){S=!0;break}S||s('PatternMatch: Property "'+t+'" should match one regular expression pattern "'+A.join('", "')+'" (given "'+e+'")'+o+".")}if(r.invertedRegularExpressionPattern)for(var k,T,D=a([].concat(r.invertedRegularExpressionPattern));!(k=D()).done;)T=k.value,new RegExp(T).test(e)&&s('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+T+' (given "'+e+'")'+o+".");return b(e,t,r,i),z(e)!==z(i)&&(l=n.concat(t+"","value updated")),{newValue:e,changedPath:l}},x=function(e,t,r,o,a){var c=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&z(c)===z(r[o]))return o!==f&&"incremental"===w&&delete t[o],!0;s('Readonly: Property "'+o+'" is not writable (old document "'+z(r)+'")'+a+".")}else s('Readonly: Property "'+o+'" is not writable'+a+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(z(c)===z(r[o]))return"incremental"!==w||l.property.name.reserved.concat(d.deleted,f,h).includes(o+"")||delete t[o],!0;"migrate"!==w&&s('Immutable: Property "'+o+'"is not writable (old document "'+z(r)+'")'+a+".")}if(null===c){if(e.nullable)return"incremental"===w&&r&&void 0!==r[o]||delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(i=n.concat(o+"","delete property")),!0;s('NotNull: Property "'+o+'" should not be "null"'+a+".")}return!1},N=function(e,t,r,i,l){if(!r)for(var c,p,y=a(["onCreateExecution","onCreateExpression"]);!(c=y()).done;)if(p=c.value,Object.prototype.hasOwnProperty.call(e,p)){var d=void 0;try{d=H(e[p],p.endsWith("Expression"),{attachmentsTarget:l,checkPropertyContent:P,model:u,modelName:m,name:i+"",type:p,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:o,propertySpecification:e})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+p+'" has invalid code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+p+'" has throw an error with code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}d&&![null,void 0].includes(d.result)&&(l?l[i]=d.result:t[i]=d.result)}},A=function(e,t,r,i,l){if(!l){if(!Object.prototype.hasOwnProperty.call(t,i))return;e.trim&&"string"==typeof t[i]&&(t[i]=t[i].trim()),e.emptyEqualsNull&&(""===t[i]||Array.isArray(t[i])&&0===t[i].length||null!==t[i]&&"object"==typeof t[i]&&0===Object.keys(t).length)&&(t[i]=null)}for(var c,p,y=a(["onUpdateExecution","onUpdateExpression"]);!(c=y()).done;)if(p=c.value,Object.prototype.hasOwnProperty.call(e,p))try{var d=H(e[p],p.endsWith("Expression"),{attachmentsTarget:l,checkPropertyContent:P,model:u,modelName:m,name:i+"",type:p,newDocument:t,oldDocument:r,newValue:t[i],oldValue:r&&r[i]||void 0,parentNames:n,pathDescription:o,propertySpecification:e});l?l[i]=d.result:t[i]=d.result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+p+'" has invalid code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+p+'" has throw an error with code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}},S=Object.keys(u).filter((function(e){return!E.includes(e)}));if("migrate"===w)for(var C,k,T=a(S);!(C=T()).done;)if(k=C.value,u[k].oldName)for(var D,_,I=a([].concat(u[k].oldName));!(D=I()).done;)_=D.value,Object.prototype.hasOwnProperty.call(e,_)&&(e[k]=e[_],delete e[_]);if(!t)for(var W,V=0,F=[d.create.execution,d.create.expression];V<F.length;V++)if(W=F[V],Object.prototype.hasOwnProperty.call(u,W)){var B=void 0;try{B=H(u[W],W.endsWith("Expression"),{checkPropertyContent:P,model:u,modelName:m,type:W,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+W+'" has invalid code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+W+'" has throw an error with code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(B)||(e=B),p(),m=e[g],0===n.length&&O()}for(var q,Y=0,$=[d.update.execution,d.update.expression];Y<$.length;Y++)if(q=$[Y],Object.prototype.hasOwnProperty.call(u,q)){var J=void 0;try{J=H(u[q],q.endsWith("Expression"),{checkPropertyContent:P,model:u,modelName:m,type:q,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+q+'" has invalid code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+q+'" has throw an error with code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(J)||(e=J),p(),m=e[g],0===n.length&&O()}for(var G,K,Z=v?Object.keys(e).filter((function(e){return!S.includes(e)})):[],Q=a(S.concat(Z));!(G=Q()).done;)if(K=G.value,d.attachment===K)for(var X=function(){var r=te[ee],l=r[0],c=r[1];Object.prototype.hasOwnProperty.call(e,K)&&null!==e[d.attachment]||(e[d.attachment]={}),t&&!Object.prototype.hasOwnProperty.call(t,K)&&(t[d.attachment]={});var p=Object.keys(e[d.attachment]).filter((function(t){return null!==e[d.attachment][t].data&&U(l,t,c)})),m=e[d.attachment],u=[];if(t){var y=t[K];u=Object.keys(y).filter((function(e){return!(Object.prototype.hasOwnProperty.call(m,e)&&Object.prototype.hasOwnProperty.call(m[e],"data")&&null===m[e].data)&&!!y[e]&&(Object.prototype.hasOwnProperty.call(y[e],"data")&&null!==y[e].data||y[e].stub&&!!y[e].digest)&&!!U(l,e,c)}))}for(var f,h,g=c,v=a(p);!(f=v()).done;)h=f.value,N(g,e,t&&t[K]?t[K]:null,h,m);for(var b,O,P=a(p);!(b=P()).done;)O=b.value,A(g,e,t&&t[K]?t[K]:null,O,m);if(void 0===g.default){if(g.nullable||0<p.length||0<u.length||s('AttachmentMissing: Missing attachment for type "'+l+'"'+o+"."),"fillUp"===w&&0===p.length&&0<u.length)for(var j,x,S=a(u);!(j=S()).done;)x=j.value,null===m[x]?i=n.concat(K,x,"file removed"):m[x]=t[K][x]}else if(0===p.length)if(0===u.length)for(var C in g.default)Object.prototype.hasOwnProperty.call(g.default,C)&&(m[C]=g.default[C],i=n.concat(K,l,"add default file"));else if("fillUp"===w)for(var k,T,D=a(u);!(k=D()).done;)T=k.value,m[T]=t[K][T]},ee=0,te=Object.entries(u[d.attachment]);ee<te.length;ee++)X();else{var re=S.includes(K)?u[K]:v;N(re,e,t,K),A(re,e,t,K),[null,void 0].includes(re.default)?(!(re.nullable||Object.prototype.hasOwnProperty.call(e,K)&&void 0!==e[K]||t&&Object.prototype.hasOwnProperty.call(t,K)&&w)&&s('MissingProperty: Missing property "'+K+'"'+o+"."),(!Object.prototype.hasOwnProperty.call(e,K)||void 0===e[K])&&t&&Object.prototype.hasOwnProperty.call(t,K)&&("fillUp"===w?e[K]=t[K]:!w&&(i=n.concat(K+"","property removed")))):(!Object.prototype.hasOwnProperty.call(e,K)||[null,void 0].includes(e[K]))&&(t?null!==e[K]&&"fillUp"===w?e[K]=t[K]:"migrate"===w&&(e[K]=re.default,i=n.concat(K+"","migrate default value")):(e[K]=re.default,i=i.concat(K+"","add default value")))}if(t&&"incremental"===w)for(var ne=0,oe=Object.entries(e);ne<oe.length;ne++){var ae=oe[ne],ie=ae[0],le=ae[1];Object.prototype.hasOwnProperty.call(t,ie)&&!l.property.name.reserved.concat(f,h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,g).includes(ie)&&(t[ie]===le||z(t[ie])===z(le))&&delete e[ie]}for(var ce=0,pe=Object.entries(e);ce<pe.length;ce++){var se=pe[ce],me=se[0],ue=se[1];if(!l.property.name.reserved.concat(h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,d.strategy).includes(me)){var ye=void 0;if(Object.prototype.hasOwnProperty.call(u,me))ye=u[me];else if(v)ye=v;else{if("migrate"===w){delete e[me],i=n.concat(me+"","migrate removed property");continue}s('Property: Given property "'+me+'" isn\'t specified in model "'+m+'"'+o+".")}if(!ye)continue;if(d.attachment===me){var de=ue;for(var fe in de)if(Object.prototype.hasOwnProperty.call(de,fe))for(var he in u[me])if(U(he,fe,u[d.attachment][he])){x(u[d.attachment][he],e,t,fe,o);break}continue}if(x(ye,e,t,me,o))continue;if("string"==typeof ye.type&&ye.type.endsWith("[]")||Array.isArray(ye.type)&&ye.type.length&&Array.isArray(ye.type[0])){var ge,ve=ue;Array.isArray(ve)?"number"==typeof ye.minimumNumber&&ve.length<ye.minimumNumber?s('MinimumArrayLength: Property "'+me+'" (array of length '+ve.length+") doesn't fullfill minimum array length of "+ye.minimumNumber+o+"."):"number"==typeof ye.maximumNumber&&ye.maximumNumber<ve.length&&s('MaximumArrayLength: Property "'+me+'" (array of length '+ve.length+") doesn't fullfill maximum array length of "+ye.maximumNumber+o+"."):s('PropertyType: Property "'+me+'" isn\'t of type "array -> '+ye.type+'" (given "'+z(ve)+'")'+o+"."),b(ve,me+"",ye,t&&Object.prototype.hasOwnProperty.call(t,me)&&t[me]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var be={};for(var Oe in ye)Object.prototype.hasOwnProperty.call(ye,Oe)&&(be[Oe]="type"===Oe?Array.isArray(ye[Oe])?ye[Oe][0]:[ye[Oe].substring(0,ye.type.length-2)]:ye[Oe]);if(1===(null==(ge=be.type)?void 0:ge.length)&&Object.prototype.hasOwnProperty.call(c,be.type[0]))for(var we,Pe,je=a(ve.slice());!(we=je()).done;)"object"!=typeof(Pe=we.value)||Object.getPrototypeOf(Pe)!==Object.prototype||Object.prototype.hasOwnProperty.call(Pe,g)||(Pe[g]=be.type[0]);for(var xe,Ne,Ae=0,Se=a(ve.slice());!(xe=Se()).done;)Ne=xe.value,ve[Ae]=P(Ne,Ae+1+". value in "+me,be).newValue,[null,void 0].includes(ve[Ae])&&ve.splice(Ae,1),Ae+=1;t&&Object.prototype.hasOwnProperty.call(t,me)&&Array.isArray(t[me])&&t[me].length===ve.length&&z(t[me])===z(ve)||(i=n.concat(me+"","array updated"))}else{var Ce=t&&Object.prototype.hasOwnProperty.call(t,me)?t[me]:null,ke=P(ue,me+"",ye,Ce);e[me]=ke.newValue,ke.changedPath.length&&(i=ke.changedPath),[null,void 0].includes(e[me])&&(null!==Ce&&(i=n.concat(me+"","property removed")),("incremental"!==w||null!==Ce)&&delete e[me])}}}for(var Te=0,De=Object.keys(d.constraint);Te<De.length;Te++){var Ee=De[Te],ze=d.constraint[Ee];if(Object.prototype.hasOwnProperty.call(u,ze))for(var Me,Re=a([].concat(u[ze]));!(Me=Re()).done;){var Ue=Me.value,_e=void 0;try{_e=H(Ue.evaluation,ze===d.constraint.expression,{checkPropertyContent:P,model:u,modelName:m,type:ze,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+ze+'" has invalid code "'+e.code+'": "'+e.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+ze+'" has thrown an error with code "'+e.code+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(_e&&!_e.result){var He=ze.replace(/^[^a-zA-Z]+/,"");s(He.charAt(0).toUpperCase()+(He.substring(1)+": ")+(Ue.description?r(Function,Object.keys(_e.scope).concat(["return "+Ue.description.trim()])).apply(void 0,Object.values(_e.scope)):'Model "'+m+'" should satisfy constraint "'+_e.code+'" (given "'+z(e)+'")'+o+"."))}}}if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var Le=e[d.attachment];("object"!=typeof Le||Object.getPrototypeOf(Le)!==Object.prototype)&&s("AttachmentType: given attachment has invalid type"+o+".");var Ie=null;if(t&&Object.prototype.hasOwnProperty.call(t,d.attachment)&&(null!==(Ie=t[d.attachment])&&"object"==typeof Ie))for(var We=0,Ve=Object.entries(Ie);We<Ve.length;We++){var Fe=Ve[We],Be=Fe[0],qe=Fe[1];if(Object.prototype.hasOwnProperty.call(Le,Be)){var Ye=Le[Be];null===Ye||null===Ye.data||Ye.content_type===qe.content_type&&(Ye.data===qe.data||Ye.digest===qe.digest)?((null===Ye||null===Ye.data)&&(i=n.concat(d.attachment,Be,"attachment removed")),"incremental"===w&&delete Le[Be]):i=n.concat(d.attachment,Be,"attachment updated")}else"fillUp"===w?Le[Be]=qe:w||(i=n.concat(d.attachment,Be,"attachment removed"))}for(var $e=0,Je=Object.entries(Le);$e<Je.length;$e++){var Ge=Je[$e],Ke=Ge[0],Ze=Ge[1];[null,void 0].includes(Ze)||null===Ze.data?delete Le[Ke]:(!Ie||!Object.prototype.hasOwnProperty.call(Ie,Ke)||Ze.content_type!==Ie[Ke].content_type||Ze.data!==Ie[Ke].data&&Ze.digest!==Ie[Ke].digest)&&(i=n.concat(d.attachment,Ke,"attachment updated"))}0===Object.keys(Le).length&&delete e[d.attachment];for(var Qe={},Xe=0,et=Object.keys(u[d.attachment]);Xe<et.length;Xe++)Qe[et[Xe]]=[];for(var tt=0,rt=Object.keys(Le);tt<rt.length;tt++){for(var nt=rt[tt],ot=!1,at=0,it=Object.entries(u[d.attachment]);at<it.length;at++){var lt=it[at],ct=lt[0],pt=lt[1];if(U(ct,nt,pt)){Qe[ct].push(nt),ot=!0;break}}ot||s('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(u[d.attachment]).join('", "')+'") matches given one ("'+nt+'")'+o+".")}for(var st=0,mt=0,ut=Object.keys(Qe);mt<ut.length;mt++){var yt=ut[mt],dt=u[d.attachment][yt];if(Object.prototype.hasOwnProperty.call(Qe,yt)){var ft=Qe[yt].length;"number"==typeof dt.maximumNumber&&ft>dt.maximumNumber&&s("AttachmentMaximum: given number of attachments ("+ft+") doesn't satisfy specified maximum of "+dt.maximumNumber+' from type "'+yt+'"'+o+"."),(!dt.nullable||0!==ft)&&"number"==typeof dt.minimumNumber&&ft<dt.minimumNumber&&s("AttachmentMinimum: given number of attachments ("+ft+") doesn't satisfy specified minimum of "+dt.minimumNumber+' from type "'+yt+'"'+o+".");for(var ht,gt=0,vt=a(Qe[yt]);!(ht=vt()).done;){var bt,Ot,wt=ht.value;if(null!=(bt=dt.fileName)&&bt.regularExpressionPattern){for(var Pt,jt,xt=[].concat(dt.fileName.regularExpressionPattern),Nt=!1,At=a(xt);!(Pt=At()).done;)if(jt=Pt.value,new RegExp(jt).test(wt)){Nt=!0;break}Nt||s('AttachmentName: given attachment name "'+wt+'" doesn\'t satisfy one of specified regular expression patterns "'+xt.join('", "')+'" from type "'+yt+'"'+o+".")}if(null!=(Ot=dt.fileName)&&Ot.invertedRegularExpressionPattern)for(var St,Ct,kt=a([].concat(dt.fileName.invertedRegularExpressionPattern));!(St=kt()).done;)Ct=St.value,new RegExp(Ct).test(wt)&&s('InvertedAttachmentName: given attachment name "'+wt+'" does satisfy specified regular expression pattern "'+Ct.toString()+'" from type "'+yt+'"'+o+".");if(Le[wt].content_type){if(dt.contentTypeRegularExpressionPattern){for(var Tt,Dt,Et=[].concat(dt.contentTypeRegularExpressionPattern),zt=!1,Mt=a(Et);!(Tt=Mt()).done;)if(Dt=Tt.value,new RegExp(Dt).test(Le[wt].content_type)){zt=!0;break}zt||s('AttachmentContentType: given attachment content type "'+Le[wt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Et.join('", "')+'" from type "'+yt+'"'+o+".")}var Rt=dt.invertedContentTypeRegularExpressionPattern;if(Rt)for(var Ut,_t,Ht=a([].concat(Rt));!(Ut=Ht()).done;)_t=Ut.value,new RegExp(_t).test(Le[wt].content_type)&&s('InvertedAttachmentContentType: given attachment content type "'+Le[wt].content_type+'" does satisfy specified regular expression pattern "'+_t.toString()+'" from type "'+yt+'"'+o+".")}var Lt=0;"length"in Le[wt]?Lt=Le[wt].length:"data"in Le[wt]&&(Lt=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Le[wt].data,"base64"):Le[wt].data.length),"number"==typeof dt.minimumSize&&dt.minimumSize>Lt?s("AttachmentMinimumSize: given attachment size "+Lt+" byte doesn't satisfy specified minimum of "+dt.minimumSize+" byte "+o+"."):"number"==typeof dt.maximumSize&&dt.maximumSize<Lt&&s("AttachmentMaximumSize: given attachment size "+Lt+" byte doesn't satisfy specified maximum of "+dt.maximumSize+" byte "+o+"."),gt+=Lt}"number"==typeof dt.minimumAggregatedSize&&dt.minimumAggregatedSize>gt?s('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+yt+'" '+gt+" byte doesn't satisfy specified minimum of "+dt.minimumAggregatedSize+" byte "+o+"."):"number"==typeof dt.maximumAggregatedSize&&dt.maximumAggregatedSize<gt&&s('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+yt+'" '+gt+" byte doesn't satisfy specified maximum of "+dt.maximumAggregatedSize+" byte "+o+"."),st+=gt}}Object.prototype.hasOwnProperty.call(u,d.minimumAggregatedSize)&&"number"==typeof u[d.minimumAggregatedSize]&&u[d.minimumAggregatedSize]>st?s("AggregatedMinimumSize: given aggregated size "+st+" byte doesn't satisfy specified minimum of "+u[d.minimumAggregatedSize]+" byte "+o+"."):"number"==typeof u[d.maximumAggregatedSize]&&u[d.maximumAggregatedSize]<st&&s("AggregatedMaximumSize: given aggregated size "+st+" byte doesn't satisfy specified maximum of "+u[d.maximumAggregatedSize]+" byte "+o+".")}if(t&&Object.prototype.hasOwnProperty.call(t,d.attachment)&&0===Object.keys(t[d.attachment]).length&&delete t[d.attachment],0===i.length&&t&&"migrate"===w)for(var It,Wt=0,Vt=Object.keys(t);Wt<Vt.length;Wt++)It=Vt[Wt],Object.prototype.hasOwnProperty.call(e,It)||(i=n.concat(It,"migrate removed property"));return{changedPath:i,newDocument:e}},I={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var r=e[d.attachment],n=_(t);if(n)return Object.prototype.hasOwnProperty.call(r[n],"stub")&&r[n].stub||Object.prototype.hasOwnProperty.call(r[n],"data")&&![null,void 0].includes(r[n].data)}return!1},checkDocument:L,getFileNameByPrefix:_,serialize:z,id:v,revision:b,idName:f,revisionName:h,specialNames:d,typeName:g,modelConfiguration:l,models:c,now:m,nowUTCTimestamp:u,securitySettings:i,userContext:n};if(e[d.attachment])for(var W,V=0,F=Object.values(e[d.attachment]);V<F.length;V++)W=F[V],Object.prototype.hasOwnProperty.call(W,"contentType")&&(W.content_type=W.contentType,delete W.contentType);var B=L(e,t);return(!B.newDocument._deleted||t)&&(B.newDocument._deleted&&B.newDocument._deleted!==(null==t?void 0:t._deleted)||B.changedPath.length)||s("NoChange: No new data given. new document: "+z(e)+"; old document: "+z(t)+"."),Object.prototype.hasOwnProperty.call(i,l.property.name.validatedDocumentsCache)?i[l.property.name.validatedDocumentsCache].add(v+"-"+b):i[l.property.name.validatedDocumentsCache]=new Set([v+"-"+b]),B.newDocument},e}();const c=l;module.exports=t})();
|
|
1
|
+
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(){return(r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var o=[null];o.push.apply(o,t);var a=new(Function.bind.apply(e,o));return r&&n(a,r.prototype),a}).apply(null,arguments)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)}function a(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}e.r(t),e.d(t,{DatabaseHelper:()=>l,default:()=>c});var l=function(){function e(){}return e.authenticate=function(e,t,r,n,o,i,l,c,p){var s;void 0===t&&(t=null),void 0===r&&(r={}),void 0===n&&(n={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===i&&(i="_id"),void 0===l&&(l="-type"),void 0===c&&(c="_design/"),void 0===p&&(p=!1);var m=null!==(s=e[l])&&void 0!==s?s:t&&t[l];if(!m)return!0;var u=p?"read":"write",y={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,i)&&e[i].startsWith(c)&&y.read.push("readonlymember");var d,f="Current user doesn't own any role";if(r)if("name"in r||(r.name='"unknown"'),null!=(d=r.roles)&&d.length){if(o&&m&&Object.prototype.hasOwnProperty.call(o,m)){for(var h,g,v=o[m],b=a(["read","write"]);!(h=b()).done;)y[g=h.value]=y[g].concat(v[g]||[]);y.properties=v.properties}for(var O,w,P=y[u],j=a(r.roles);!(O=j()).done;)if(w=O.value,P.includes(w))return!0;f='Current user "'+r.name+'" owns the following roles: "'+r.roles.join('", "')+'"'}else f='Current user "'+r.name+"\" doesn't own any role";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+u+' action: "'+[].concat(y[u]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,t,n,i,l,c,p){void 0===c&&(c={});var s=function(e,t,r){var n;throw void 0===t&&(t="forbidden"),void 0===r&&(r={}),o(((n={})[t]=e,n.message=e,n.name=t,n),r)},m=new Date,u=Date.UTC(m.getUTCFullYear(),m.getUTCMonth(),m.getUTCDate(),m.getUTCHours(),m.getUTCMinutes(),m.getUTCSeconds(),m.getUTCMilliseconds())/1e3,y=!l.dateTimeFormat.startsWith("iso"),d=l.property.name.special,f=d.id,h=d.revision,g=d.type;t&&t[g]&&!e[g]&&(e[g]=t[g]);var v="",b="",O=function(){v=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",b=Object.prototype.hasOwnProperty.call(e,h)?e[h]:""};if(O(),Object.prototype.hasOwnProperty.call(i,l.property.name.validatedDocumentsCache)&&i[l.property.name.validatedDocumentsCache].has(v+"-"+b))return i[l.property.name.validatedDocumentsCache].delete(v+"-"+b),e;["latest","upsert"].includes(b)&&(t&&Object.prototype.hasOwnProperty.call(t,h)?b=e[h]=t[h]:"latest"===b?s("Revision: No old document available to update."):delete e[h]);var w=l.updateStrategy;Object.prototype.hasOwnProperty.call(e,d.strategy)&&(w=e[d.strategy],delete e[d.strategy]);var P,j={};if("migrate"===w)for(var x=0,N=Object.entries(c);x<N.length;x++){var A=N[x],S=A[0],C=A[1];if(Object.prototype.hasOwnProperty.call(C,d.oldType)&&C[d.oldType])for(var k,T,D=a([].concat(C[d.oldType]));!(k=D()).done;)T=k.value,j[T]=S}p?P=p:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?P=function(e){return JSON.stringify(e,null,4)}:s('Needed "serializer" is not available.');var E=[d.additional,d.allowedRole,d.constraint.execution,d.constraint.expression,d.create.execution,d.create.expression,d.extend,d.maximumAggregatedSize,d.minimumAggregatedSize,d.oldType,d.update.execution,d.update.expression],z=function(e){return e instanceof Error?""+e:P(e)},M=function(e){return"string"==typeof e?e.trim():""},R=function(e){if(y)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},U=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return[].concat(r.fileName.regularExpressionPattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},_=function(t,r){if(r||(r=e[d.attachment]),t){for(var n,o=0,a=Object.keys(r);o<a.length;o++)if((n=a[o]).startsWith(t))return n}else{var i=Object.keys(r);if(i.length)return i[0]}return null},H=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var a=M(e);if(a){var i,l=(t?"return ":"")+a,c=o({},I,{code:l},n),p=Object.keys(c);try{i=r(Function,p.concat([l]))}catch(e){s(z(e),"compilation",{code:l,error:e,scope:c})}var m={code:l,result:void 0,scope:c};try{m.result=i.apply(void 0,p.map((function(e){return c[e]})))}catch(e){s(z(e),"runtime",{code:l,error:e,scope:c})}return m}s("No expression to evaluate provided.","empty")},L=function(e,t,n){void 0===n&&(n=[]);var o=n.length?" in "+n.join(" -> "):"",i=[],p=function(){Object.prototype.hasOwnProperty.call(e,g)||(t&&Object.prototype.hasOwnProperty.call(t,g)&&["fillUp","migrate"].includes(w)?e[g]=t[g]:s('Type: You have to specify a model type via property "'+g+'"'+o+".")),n.length||new RegExp(l.property.name.typeRegularExpressionPattern.public).test(e[g])||s('TypeName: You have to specify a model type which matches "'+l.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+e[g]+'")'+o+"."),Object.prototype.hasOwnProperty.call(c,e[g])||(Object.prototype.hasOwnProperty.call(j,e[g])?e[g]=j[e[g]]:s('Model: Given model "'+e[g]+'" is not specified'+o+"."))};p();var m=e[g],u=c[m],v=void 0;Object.prototype.hasOwnProperty.call(u,d.additional)&&u[d.additional]&&(v=u[d.additional]);var b=function(i,l,c,p,y){void 0===y&&(y=["constraintExecution","constraintExpression"]);for(var d,f,h=a(y);!(d=h()).done;)if(f=d.value,Object.prototype.hasOwnProperty.call(c,f)){var g=void 0;try{g=H(c[f].evaluation,f.endsWith("Expression"),{checkPropertyContent:P,model:u,modelName:m,name:l,type:f,newDocument:e,newValue:i,oldDocument:t,oldValue:p,parentNames:n,pathDescription:o,propertySpecification:c})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+f+'" has invalid code "'+e.code+'": "'+e.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+f+'" has throw an error with code "'+e.code+'": "'+e.message+'"'+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(g&&!g.result){var v=M(c[f].description);s(f.charAt(0).toUpperCase()+(f.substring(1)+": ")+(v?r(Function,Object.keys(g.scope).concat(["return "+v])).apply(void 0,Object.values(g.scope)):'Property "'+l+'" should satisfy constraint "'+g.code+'" (given "'+z(i)+'")'+o+"."))}}},P=function(e,t,r,i){var l=[],p=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,g)&&1===p.length&&Object.prototype.hasOwnProperty.call(c,p[0])&&(e[g]=p[0]);for(var m,u,d=!1,h=a(p);!(m=h()).done;)if(u=m.value,Object.prototype.hasOwnProperty.call(c,u)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]!==u&&"migrate"===w&&1===p.length&&(e[g]=u,l=n.concat(t+"","migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]===u){var v=L(e,i,n.concat(t+""));if(v.changedPath.length&&(l=v.changedPath),e=v.newDocument,z(e)===z({}))return{newValue:void 0,changedPath:l};d=!0;break}1===p.length&&s('NestedType: Under key "'+t+'" isn\'t of type "'+u+'" (given "'+z(e)+'" of type '+typeof e+")"+o+".")}else if("DateTime"===u){var O=e;if(e=R(e),!(y&&("number"!=typeof e||isNaN(e))||!y&&"string"!=typeof e)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'"isn\'t of (valid) type "DateTime" (given"'+z(O).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof O+'")'+o+".")}else if(["boolean","integer","number","string"].includes(u)){if(!("number"==typeof e&&isNaN(e)||"integer"!==u&&typeof e!==u||"integer"===u&&parseInt(e,10)!==e)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+u+'" (given "'+z(e)+'" of type "'+typeof e+'")'+o+".")}else if("string"==typeof u&&u.startsWith("foreignKey:")){var P=c[u.substring(11)][f].type;if(P===typeof e){d=!0;break}1===p.length&&s('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+P+'" (given "'+z(e)+'" of type "'+typeof e+'")'+o+".")}else{if("any"===u||z(e)===z(u)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t value "'+u+'" (given "'+z(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+o+".")}if(d||s('PropertyType: None of the specified types "'+p.join('", "')+'" for property "'+t+'" matches value "'+z(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+o+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&s('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+o+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&s('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+o+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&s('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+o+"."),"number"==typeof r.maximum&&e>r.maximum&&s('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+o+".")),r.selection){var j=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(j=j.map(R)),j.includes(e)||s('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+j.join('", "')+'". But is "'+e+'"'+o+".")}if(r.regularExpressionPattern){for(var x,N,A=[].concat(r.regularExpressionPattern),S=!1,C=a(A);!(x=C()).done;)if(N=x.value,new RegExp(N).test(e)){S=!0;break}S||s('PatternMatch: Property "'+t+'" should match one regular expression pattern "'+A.join('", "')+'" (given "'+e+'")'+o+".")}if(r.invertedRegularExpressionPattern)for(var k,T,D=a([].concat(r.invertedRegularExpressionPattern));!(k=D()).done;)T=k.value,new RegExp(T).test(e)&&s('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+T+' (given "'+e+'")'+o+".");return b(e,t,r,i),z(e)!==z(i)&&(l=n.concat(t+"","value updated")),{newValue:e,changedPath:l}},x=function(e,t,r,o,a){var c=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&z(c)===z(r[o]))return o!==f&&"incremental"===w&&delete t[o],!0;s('Readonly: Property "'+o+'" is not writable (old document "'+z(r)+'")'+a+".")}else s('Readonly: Property "'+o+'" is not writable'+a+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(z(c)===z(r[o]))return"incremental"!==w||l.property.name.reserved.concat(d.deleted,f,h).includes(o+"")||delete t[o],!0;"migrate"!==w&&s('Immutable: Property "'+o+'"is not writable (old document "'+z(r)+'")'+a+".")}if(null===c){if(e.nullable)return"incremental"===w&&r&&void 0!==r[o]||delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(i=n.concat(o+"","delete property")),!0;s('NotNull: Property "'+o+'" should not be "null"'+a+".")}return!1},N=function(e,t,r,i,l){if(!r)for(var c,p,y=a(["onCreateExecution","onCreateExpression"]);!(c=y()).done;)if(p=c.value,Object.prototype.hasOwnProperty.call(e,p)){var d=void 0;try{d=H(e[p],p.endsWith("Expression"),{attachmentsTarget:l,checkPropertyContent:P,model:u,modelName:m,name:i+"",type:p,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:o,propertySpecification:e})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+p+'" has invalid code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+p+'" has throw an error with code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}d&&![null,void 0].includes(d.result)&&(l?l[i]=d.result:t[i]=d.result)}},A=function(e,t,r,i,l){if(!l){if(!Object.prototype.hasOwnProperty.call(t,i))return;e.trim&&"string"==typeof t[i]&&(t[i]=t[i].trim()),e.emptyEqualsNull&&(""===t[i]||Array.isArray(t[i])&&0===t[i].length||null!==t[i]&&"object"==typeof t[i]&&0===Object.keys(t).length)&&(t[i]=null)}for(var c,p,y=a(["onUpdateExecution","onUpdateExpression"]);!(c=y()).done;)if(p=c.value,Object.prototype.hasOwnProperty.call(e,p))try{var d=H(e[p],p.endsWith("Expression"),{attachmentsTarget:l,checkPropertyContent:P,model:u,modelName:m,name:i+"",type:p,newDocument:t,oldDocument:r,newValue:t[i],oldValue:r&&r[i]||void 0,parentNames:n,pathDescription:o,propertySpecification:e});l?l[i]=d.result:t[i]=d.result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+p+'" has invalid code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+p+'" has throw an error with code "'+e.code+'" for property "'+i+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}},S=Object.keys(u).filter((function(e){return!E.includes(e)}));if("migrate"===w)for(var C,k,T=a(S);!(C=T()).done;)if(k=C.value,u[k].oldName)for(var D,_,I=a([].concat(u[k].oldName));!(D=I()).done;)_=D.value,Object.prototype.hasOwnProperty.call(e,_)&&(e[k]=e[_],delete e[_]);if(!t)for(var W,V=0,F=[d.create.execution,d.create.expression];V<F.length;V++)if(W=F[V],Object.prototype.hasOwnProperty.call(u,W)){var B=void 0;try{B=H(u[W],W.endsWith("Expression"),{checkPropertyContent:P,model:u,modelName:m,type:W,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+W+'" has invalid code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+W+'" has throw an error with code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(B)||(e=B),p(),m=e[g],0===n.length&&O()}for(var q,Y=0,$=[d.update.execution,d.update.expression];Y<$.length;Y++)if(q=$[Y],Object.prototype.hasOwnProperty.call(u,q)){var J=void 0;try{J=H(u[q],q.endsWith("Expression"),{checkPropertyContent:P,model:u,modelName:m,type:q,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+q+'" has invalid code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+q+'" has throw an error with code "'+e.code+'" for document "'+m+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(J)||(e=J),p(),m=e[g],0===n.length&&O()}for(var G,K,Z=v?Object.keys(e).filter((function(e){return!S.includes(e)})):[],Q=a(S.concat(Z));!(G=Q()).done;)if(K=G.value,d.attachment===K)for(var X=function(){var r=te[ee],l=r[0],c=r[1];Object.prototype.hasOwnProperty.call(e,K)&&null!==e[d.attachment]||(e[d.attachment]={}),t&&!Object.prototype.hasOwnProperty.call(t,K)&&(t[d.attachment]={});var p=Object.keys(e[d.attachment]).filter((function(t){return null!==e[d.attachment][t].data&&U(l,t,c)})),m=e[d.attachment],u=[];if(t){var y=t[K];u=Object.keys(y).filter((function(e){return!(Object.prototype.hasOwnProperty.call(m,e)&&Object.prototype.hasOwnProperty.call(m[e],"data")&&null===m[e].data)&&!!y[e]&&(Object.prototype.hasOwnProperty.call(y[e],"data")&&null!==y[e].data||y[e].stub&&!!y[e].digest)&&!!U(l,e,c)}))}for(var f,h,g=c,v=a(p);!(f=v()).done;)h=f.value,N(g,e,t&&t[K]?t[K]:null,h,m);for(var b,O,P=a(p);!(b=P()).done;)O=b.value,A(g,e,t&&t[K]?t[K]:null,O,m);if(void 0===g.default){if(g.nullable||0<p.length||0<u.length||s('AttachmentMissing: Missing attachment for type "'+l+'"'+o+"."),"fillUp"===w&&0===p.length&&0<u.length)for(var j,x,S=a(u);!(j=S()).done;)x=j.value,null===m[x]?i=n.concat(K,x,"file removed"):m[x]=t[K][x]}else if(0===p.length)if(0===u.length)for(var C in g.default)Object.prototype.hasOwnProperty.call(g.default,C)&&(m[C]=g.default[C],i=n.concat(K,l,"add default file"));else if("fillUp"===w)for(var k,T,D=a(u);!(k=D()).done;)T=k.value,m[T]=t[K][T]},ee=0,te=Object.entries(u[d.attachment]);ee<te.length;ee++)X();else{var re=S.includes(K)?u[K]:v;N(re,e,t,K),A(re,e,t,K),[null,void 0].includes(re.default)?(!(re.nullable||Object.prototype.hasOwnProperty.call(e,K)&&void 0!==e[K]||t&&Object.prototype.hasOwnProperty.call(t,K)&&w)&&s('MissingProperty: Missing property "'+K+'"'+o+"."),(!Object.prototype.hasOwnProperty.call(e,K)||void 0===e[K])&&t&&Object.prototype.hasOwnProperty.call(t,K)&&("fillUp"===w?e[K]=t[K]:!w&&(i=n.concat(K+"","property removed")))):(!Object.prototype.hasOwnProperty.call(e,K)||[null,void 0].includes(e[K]))&&(t?null!==e[K]&&"fillUp"===w?e[K]=t[K]:"migrate"===w&&(e[K]=re.default,i=n.concat(K+"","migrate default value")):(e[K]=re.default,i=i.concat(K+"","add default value")))}if(t&&"incremental"===w)for(var ne=0,oe=Object.entries(e);ne<oe.length;ne++){var ae=oe[ne],ie=ae[0],le=ae[1];Object.prototype.hasOwnProperty.call(t,ie)&&!l.property.name.reserved.concat(f,h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,g).includes(ie)&&(t[ie]===le||z(t[ie])===z(le))&&delete e[ie]}for(var ce=0,pe=Object.entries(e);ce<pe.length;ce++){var se=pe[ce],me=se[0],ue=se[1];if(!l.property.name.reserved.concat(h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,d.strategy).includes(me)){var ye=void 0;if(Object.prototype.hasOwnProperty.call(u,me))ye=u[me];else if(v)ye=v;else{if("migrate"===w){delete e[me],i=n.concat(me+"","migrate removed property");continue}s('Property: Given property "'+me+'" isn\'t specified in model "'+m+'"'+o+".")}if(!ye)continue;if(d.attachment===me){var de=ue;for(var fe in de)if(Object.prototype.hasOwnProperty.call(de,fe))for(var he in u[me])if(U(he,fe,u[d.attachment][he])){x(u[d.attachment][he],e,t,fe,o);break}continue}if(x(ye,e,t,me,o))continue;if("string"==typeof ye.type&&ye.type.endsWith("[]")||Array.isArray(ye.type)&&ye.type.length&&Array.isArray(ye.type[0])&&![null,void 0].includes(ue)){var ge,ve=ue;Array.isArray(ve)?"number"==typeof ye.minimumNumber&&ve.length<ye.minimumNumber?s('MinimumArrayLength: Property "'+me+'" (array of length '+ve.length+") doesn't fullfill minimum array length of "+ye.minimumNumber+o+"."):"number"==typeof ye.maximumNumber&&ye.maximumNumber<ve.length&&s('MaximumArrayLength: Property "'+me+'" (array of length '+ve.length+") doesn't fullfill maximum array length of "+ye.maximumNumber+o+"."):s('PropertyType: Property "'+me+'" isn\'t of type "array -> '+ye.type+'" (given "'+z(ve)+'")'+o+"."),b(ve,me+"",ye,t&&Object.prototype.hasOwnProperty.call(t,me)&&t[me]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var be={};for(var Oe in ye)Object.prototype.hasOwnProperty.call(ye,Oe)&&(be[Oe]="type"===Oe?Array.isArray(ye[Oe])?ye[Oe][0]:[ye[Oe].substring(0,ye.type.length-2)]:ye[Oe]);if(1===(null==(ge=be.type)?void 0:ge.length)&&Object.prototype.hasOwnProperty.call(c,be.type[0]))for(var we,Pe,je=a(ve.slice());!(we=je()).done;)"object"!=typeof(Pe=we.value)||Object.getPrototypeOf(Pe)!==Object.prototype||Object.prototype.hasOwnProperty.call(Pe,g)||(Pe[g]=be.type[0]);for(var xe,Ne,Ae=0,Se=a(ve.slice());!(xe=Se()).done;)Ne=xe.value,ve[Ae]=P(Ne,Ae+1+". value in "+me,be).newValue,[null,void 0].includes(ve[Ae])&&ve.splice(Ae,1),Ae+=1;t&&Object.prototype.hasOwnProperty.call(t,me)&&Array.isArray(t[me])&&t[me].length===ve.length&&z(t[me])===z(ve)||(i=n.concat(me+"","array updated"))}else{var Ce=t&&Object.prototype.hasOwnProperty.call(t,me)?t[me]:null,ke=P(ue,me+"",ye,Ce);e[me]=ke.newValue,ke.changedPath.length&&(i=ke.changedPath),[null,void 0].includes(e[me])&&(null!==Ce&&(i=n.concat(me+"","property removed")),("incremental"!==w||null!==Ce)&&delete e[me])}}}for(var Te=0,De=Object.keys(d.constraint);Te<De.length;Te++){var Ee=De[Te],ze=d.constraint[Ee];if(Object.prototype.hasOwnProperty.call(u,ze))for(var Me,Re=a([].concat(u[ze]));!(Me=Re()).done;){var Ue=Me.value,_e=void 0;try{_e=H(Ue.evaluation,ze===d.constraint.expression,{checkPropertyContent:P,model:u,modelName:m,type:ze,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+ze+'" has invalid code "'+e.code+'": "'+e.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+ze+'" has thrown an error with code "'+e.code+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(_e&&!_e.result){var He=ze.replace(/^[^a-zA-Z]+/,"");s(He.charAt(0).toUpperCase()+(He.substring(1)+": ")+(Ue.description?r(Function,Object.keys(_e.scope).concat(["return "+Ue.description.trim()])).apply(void 0,Object.values(_e.scope)):'Model "'+m+'" should satisfy constraint "'+_e.code+'" (given "'+z(e)+'")'+o+"."))}}}if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var Le=e[d.attachment];("object"!=typeof Le||Object.getPrototypeOf(Le)!==Object.prototype)&&s("AttachmentType: given attachment has invalid type"+o+".");var Ie=null;if(t&&Object.prototype.hasOwnProperty.call(t,d.attachment)&&(null!==(Ie=t[d.attachment])&&"object"==typeof Ie))for(var We=0,Ve=Object.entries(Ie);We<Ve.length;We++){var Fe=Ve[We],Be=Fe[0],qe=Fe[1];if(Object.prototype.hasOwnProperty.call(Le,Be)){var Ye=Le[Be];null===Ye||null===Ye.data||Ye.content_type===qe.content_type&&(Ye.data===qe.data||Ye.digest===qe.digest)?((null===Ye||null===Ye.data)&&(i=n.concat(d.attachment,Be,"attachment removed")),"incremental"===w&&delete Le[Be]):i=n.concat(d.attachment,Be,"attachment updated")}else"fillUp"===w?Le[Be]=qe:w||(i=n.concat(d.attachment,Be,"attachment removed"))}for(var $e=0,Je=Object.entries(Le);$e<Je.length;$e++){var Ge=Je[$e],Ke=Ge[0],Ze=Ge[1];[null,void 0].includes(Ze)||null===Ze.data?delete Le[Ke]:(!Ie||!Object.prototype.hasOwnProperty.call(Ie,Ke)||Ze.content_type!==Ie[Ke].content_type||Ze.data!==Ie[Ke].data&&Ze.digest!==Ie[Ke].digest)&&(i=n.concat(d.attachment,Ke,"attachment updated"))}0===Object.keys(Le).length&&delete e[d.attachment];for(var Qe={},Xe=0,et=Object.keys(u[d.attachment]);Xe<et.length;Xe++)Qe[et[Xe]]=[];for(var tt=0,rt=Object.keys(Le);tt<rt.length;tt++){for(var nt=rt[tt],ot=!1,at=0,it=Object.entries(u[d.attachment]);at<it.length;at++){var lt=it[at],ct=lt[0],pt=lt[1];if(U(ct,nt,pt)){Qe[ct].push(nt),ot=!0;break}}ot||s('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(u[d.attachment]).join('", "')+'") matches given one ("'+nt+'")'+o+".")}for(var st=0,mt=0,ut=Object.keys(Qe);mt<ut.length;mt++){var yt=ut[mt],dt=u[d.attachment][yt];if(Object.prototype.hasOwnProperty.call(Qe,yt)){var ft=Qe[yt].length;"number"==typeof dt.maximumNumber&&ft>dt.maximumNumber&&s("AttachmentMaximum: given number of attachments ("+ft+") doesn't satisfy specified maximum of "+dt.maximumNumber+' from type "'+yt+'"'+o+"."),(!dt.nullable||0!==ft)&&"number"==typeof dt.minimumNumber&&ft<dt.minimumNumber&&s("AttachmentMinimum: given number of attachments ("+ft+") doesn't satisfy specified minimum of "+dt.minimumNumber+' from type "'+yt+'"'+o+".");for(var ht,gt=0,vt=a(Qe[yt]);!(ht=vt()).done;){var bt,Ot,wt=ht.value;if(null!=(bt=dt.fileName)&&bt.regularExpressionPattern){for(var Pt,jt,xt=[].concat(dt.fileName.regularExpressionPattern),Nt=!1,At=a(xt);!(Pt=At()).done;)if(jt=Pt.value,new RegExp(jt).test(wt)){Nt=!0;break}Nt||s('AttachmentName: given attachment name "'+wt+'" doesn\'t satisfy one of specified regular expression patterns "'+xt.join('", "')+'" from type "'+yt+'"'+o+".")}if(null!=(Ot=dt.fileName)&&Ot.invertedRegularExpressionPattern)for(var St,Ct,kt=a([].concat(dt.fileName.invertedRegularExpressionPattern));!(St=kt()).done;)Ct=St.value,new RegExp(Ct).test(wt)&&s('InvertedAttachmentName: given attachment name "'+wt+'" does satisfy specified regular expression pattern "'+Ct.toString()+'" from type "'+yt+'"'+o+".");if(Le[wt].content_type){if(dt.contentTypeRegularExpressionPattern){for(var Tt,Dt,Et=[].concat(dt.contentTypeRegularExpressionPattern),zt=!1,Mt=a(Et);!(Tt=Mt()).done;)if(Dt=Tt.value,new RegExp(Dt).test(Le[wt].content_type)){zt=!0;break}zt||s('AttachmentContentType: given attachment content type "'+Le[wt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Et.join('", "')+'" from type "'+yt+'"'+o+".")}var Rt=dt.invertedContentTypeRegularExpressionPattern;if(Rt)for(var Ut,_t,Ht=a([].concat(Rt));!(Ut=Ht()).done;)_t=Ut.value,new RegExp(_t).test(Le[wt].content_type)&&s('InvertedAttachmentContentType: given attachment content type "'+Le[wt].content_type+'" does satisfy specified regular expression pattern "'+_t.toString()+'" from type "'+yt+'"'+o+".")}var Lt=0;"length"in Le[wt]?Lt=Le[wt].length:"data"in Le[wt]&&(Lt=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Le[wt].data,"base64"):Le[wt].data.length),"number"==typeof dt.minimumSize&&dt.minimumSize>Lt?s("AttachmentMinimumSize: given attachment size "+Lt+" byte doesn't satisfy specified minimum of "+dt.minimumSize+" byte "+o+"."):"number"==typeof dt.maximumSize&&dt.maximumSize<Lt&&s("AttachmentMaximumSize: given attachment size "+Lt+" byte doesn't satisfy specified maximum of "+dt.maximumSize+" byte "+o+"."),gt+=Lt}"number"==typeof dt.minimumAggregatedSize&&dt.minimumAggregatedSize>gt?s('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+yt+'" '+gt+" byte doesn't satisfy specified minimum of "+dt.minimumAggregatedSize+" byte "+o+"."):"number"==typeof dt.maximumAggregatedSize&&dt.maximumAggregatedSize<gt&&s('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+yt+'" '+gt+" byte doesn't satisfy specified maximum of "+dt.maximumAggregatedSize+" byte "+o+"."),st+=gt}}Object.prototype.hasOwnProperty.call(u,d.minimumAggregatedSize)&&"number"==typeof u[d.minimumAggregatedSize]&&u[d.minimumAggregatedSize]>st?s("AggregatedMinimumSize: given aggregated size "+st+" byte doesn't satisfy specified minimum of "+u[d.minimumAggregatedSize]+" byte "+o+"."):"number"==typeof u[d.maximumAggregatedSize]&&u[d.maximumAggregatedSize]<st&&s("AggregatedMaximumSize: given aggregated size "+st+" byte doesn't satisfy specified maximum of "+u[d.maximumAggregatedSize]+" byte "+o+".")}if(t&&Object.prototype.hasOwnProperty.call(t,d.attachment)&&0===Object.keys(t[d.attachment]).length&&delete t[d.attachment],0===i.length&&t&&"migrate"===w)for(var It,Wt=0,Vt=Object.keys(t);Wt<Vt.length;Wt++)It=Vt[Wt],Object.prototype.hasOwnProperty.call(e,It)||(i=n.concat(It,"migrate removed property"));return{changedPath:i,newDocument:e}},I={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var r=e[d.attachment],n=_(t);if(n)return Object.prototype.hasOwnProperty.call(r[n],"stub")&&r[n].stub||Object.prototype.hasOwnProperty.call(r[n],"data")&&![null,void 0].includes(r[n].data)}return!1},checkDocument:L,getFileNameByPrefix:_,serialize:z,id:v,revision:b,idName:f,revisionName:h,specialNames:d,typeName:g,modelConfiguration:l,models:c,now:m,nowUTCTimestamp:u,securitySettings:i,userContext:n};if(e[d.attachment])for(var W,V=0,F=Object.values(e[d.attachment]);V<F.length;V++)W=F[V],Object.prototype.hasOwnProperty.call(W,"contentType")&&(W.content_type=W.contentType,delete W.contentType);var B=L(e,t);return(!B.newDocument._deleted||t)&&(B.newDocument._deleted&&B.newDocument._deleted!==(null==t?void 0:t._deleted)||B.changedPath.length)||s("NoChange: No new data given. new document: "+z(e)+"; old document: "+z(t)+"."),Object.prototype.hasOwnProperty.call(i,l.property.name.validatedDocumentsCache)?i[l.property.name.validatedDocumentsCache].add(v+"-"+b):i[l.property.name.validatedDocumentsCache]=new Set([v+"-"+b]),B.newDocument},e}();const c=l;module.exports=t})();
|
package/helper.d.ts
CHANGED
|
@@ -29,13 +29,14 @@ export declare const mayStripRepresentation: (object: unknown, maximumRepresenta
|
|
|
29
29
|
* @param description - Used to produce semantic logging messages.
|
|
30
30
|
* @param log - Enables logging.
|
|
31
31
|
* @param idName - Property name for ids.
|
|
32
|
+
* @param revisionName - Property name for revisions.
|
|
32
33
|
* @param designDocumentNamePrefix - Document name prefix indicating deign
|
|
33
34
|
* documents.
|
|
34
35
|
*
|
|
35
36
|
* @returns Promise which will be resolved after given document has updated
|
|
36
37
|
* successfully.
|
|
37
38
|
*/
|
|
38
|
-
export declare const ensureValidationDocumentPresence: (databaseConnection: Connection, documentName: string, documentData: Mapping, description: string, log?: boolean, idName?: SpecialPropertyNames['id'], designDocumentNamePrefix?: string) => Promise<void>;
|
|
39
|
+
export declare const ensureValidationDocumentPresence: (databaseConnection: Connection, documentName: string, documentData: Mapping, description: string, log?: boolean, idName?: SpecialPropertyNames['id'], revisionName?: SpecialPropertyNames['revision'], designDocumentNamePrefix?: string) => Promise<void>;
|
|
39
40
|
/**
|
|
40
41
|
* Initializes a database connection instance.
|
|
41
42
|
* @param services - An object with stored service instances.
|
package/helper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e=[e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")}],t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{r.r(n),r.d(n,{determineAllowedModelRolesMapping:()=>v,determineGenericIndexablePropertyNames:()=>m,ensureValidationDocumentPresence:()=>y,extendModel:()=>g,extendModels:()=>x,getConnectorOptions:()=>d,initializeConnection:()=>b,isPropertySpecification:()=>h,mayStripRepresentation:()=>f,normalizeAllowedRoles:()=>w});var e=r(0),t=r.n(e),o=r(1),a=r.n(o),i=r(2),c=r.n(i),s=r(3),p=r.n(s);function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var d=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){return s.globalContext.fetch(t,p().extend(!0,p().copy(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){return s.globalContext.fetch(e,t)}}},f=function(e,t,r){var n=p().represent(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},y=function(){var e=a()(c().mark((function e(r,n,o,a,i,s,l){var
|
|
1
|
+
(()=>{"use strict";var e=[e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")}],t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{r.r(n),r.d(n,{determineAllowedModelRolesMapping:()=>v,determineGenericIndexablePropertyNames:()=>m,ensureValidationDocumentPresence:()=>y,extendModel:()=>g,extendModels:()=>x,getConnectorOptions:()=>d,initializeConnection:()=>b,isPropertySpecification:()=>h,mayStripRepresentation:()=>f,normalizeAllowedRoles:()=>w});var e=r(0),t=r.n(e),o=r(1),a=r.n(o),i=r(2),c=r.n(i),s=r(3),p=r.n(s);function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var d=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){return s.globalContext.fetch(t,p().extend(!0,p().copy(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){return s.globalContext.fetch(e,t)}}},f=function(e,t,r){var n=p().represent(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},y=function(){var e=a()(c().mark((function e(r,n,o,a,i,s,l,u){var d,f,y;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===i&&(i=!0),void 0===s&&(s="_id"),void 0===l&&(l="_rev"),void 0===u&&(u="_design/"),f=t()(((d={})[s]=""+u+n,d.language="javascript",d),o),e.prev=5,e.next=8,r.get(""+u+n);case 8:return y=e.sent,f[l]=y[l],e.next=12,r.put(f);case 12:case 21:e.next=27;break;case 15:return e.prev=15,e.t0=e.catch(5),i&&e.t0.error,e.prev=18,e.next=21,r.put(f);case 24:throw e.prev=24,e.t1=e.catch(18),new Error(a+" couldn't be installed/updated: \""+p().represent(e.t1)+'".');case 27:case"end":return e.stop()}}),e,null,[[5,15],[18,24]])})));return function(){return e.apply(this,arguments)}}(),b=function(){var e=a()(c().mark((function e(t,r){var n,o,i,u,f,y,b,v;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=r.couchdb,o=p().stringFormat(n.url,n.user.name+":"+n.user.password+"@")+"/"+n.databaseName,t.couchdb.connection=new t.couchdb.connector(o,d(r)),(i=t.couchdb.connection).setMaxListeners(1/0),u=n.model.property.name.special.id,f=n.model.property.name.special.revision,y=c().mark((function(){var e,t;return c().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:e=v.value,t=i[e].bind(i),i[e]=a()(c().mark((function e(r,o){var a,i,s,p,l,d,y=arguments;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,a=y.length,i=Array(2<a?a-2:0),s=2;s<a;s++)i[s-2]=y[s];return e.next=4,t.apply(void 0,[r,o].concat(i));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!((l=r[u])&&n.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(p=e.t0.message)&&p.startsWith("NoChange:"))){e.next=23;break}if(d="object"==typeof o&&f in o?o[f]:r[f],e.t1=l,!(f in r)||["latest","upsert"].includes(d)){e.next=17;break}e.t2=d,e.next=21;break;case 17:return e.next=19,this.get(l);case 19:e.t3=f,e.t2=e.sent[e.t3];case 21:return e.t4=e.t2,e.abrupt("return",{id:e.t1,rev:e.t4,ok:!0});case 23:throw e.t0;case 24:case"end":return e.stop()}}),e,this,[[0,7]])})));case 3:case"end":return r.stop()}}),y)})),b=l(["post","put"]);case 9:if((v=b()).done){e.next=13;break}return e.delegateYield(y(),"t0",11);case 11:e.next=9;break;case 13:return e.prev=13,e.next=16,p().checkReachability(o);case 16:e.next=23;break;case 18:return e.prev=18,e.t1=e.catch(13),e.next=23,s.globalContext.fetch(o,{method:"PUT"});case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,null,[[13,18]])})));return function(){return e.apply(this,arguments)}}(),v=function(e){for(var r=e.property.name.special.allowedRole,n={},o=x(e),a=0,i=Object.entries(o);a<i.length;a++){var c=i[a],s=c[0],p=c[1];if(Object.prototype.hasOwnProperty.call(p,r)){n[s]=t()({properties:{}},w(p[r]));for(var l=0,u=Object.entries(p);l<u.length;l++){var d=u[l],f=d[0],y=d[1];null!==y&&"object"==typeof y&&y.allowedRoles&&(n[s].properties[f]=w(y.allowedRoles))}}else n[s]={properties:{},read:[],write:[]}}return n},h=function(e){return null!==e&&"object"==typeof e},m=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){var o=t[n];return h(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||h(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(r.additional,r.allowedRole,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.id,r.revision,r.revisions,r.revisionsInformation,r.type).includes(n)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([r.id,r.revision]).sort()},g=function(e,t,r){if(void 0===r&&(r="_extends"),"_base"===e)return t[e];if(Object.prototype.hasOwnProperty.call(t,"_base")&&(Object.prototype.hasOwnProperty.call(t[e],r)&&t[e][r]?t[e][r]=["_base"].concat(t[e][r]):t[e][r]="_base"),Object.prototype.hasOwnProperty.call(t[e],r)){for(var n,o,a=l([].concat(t[e][r]));!(n=a()).done;)o=n.value,t[e]=p().extend(!0,p().copy(g(o,t,r)),t[e]);delete t[e][r]}return t[e]},x=function(e){for(var t,r=e.property.name.special,n={},o=e.property.name.typeRegularExpressionPattern,a=0,i=Object.keys(e.entities);a<i.length;a++){if(t=i[a],!new RegExp(o.public).test(t)&&!new RegExp(o.private).test(t))throw new Error('Model names have to match "'+o.public+'" or "'+o.private+'" for private one (given name: "'+t+'").');n[t]=g(t,e.entities,r.extend)}for(var c,s=0,l=Object.values(n);s<l.length;s++){c=l[s];for(var u=0,d=Object.entries(c);u<d.length;u++){var f=d[u],y=f[0],b=f[1];if(y===r.attachment)for(var v=b,h=0,m=Object.entries(v);h<m.length;h++){var x=m[h],w=x[0],O=x[1];v[w]=p().extend(!0,p().copy(e.property.defaultSpecification),O)}else[r.allowedRole,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(y)||(c[y]=p().extend(!0,p().copy(e.property.defaultSpecification),b))}}return n},w=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,r={read:[],write:[]},n=0,o=Object.keys(r);n<o.length;n++)t=o[n],Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?r[t]=e[t]:r[t]=[e[t]]);return r}return{read:[e],write:[e]}}})(),module.exports=n})();
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var __webpack_modules__=[e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},(e,t,r)=>{"use strict";r.d(t,{determineAllowedModelRolesMapping:()=>y,determineGenericIndexablePropertyNames:()=>x,ensureValidationDocumentPresence:()=>f,extendModels:()=>g,getConnectorOptions:()=>d,initializeConnection:()=>b,mayStripRepresentation:()=>m});var n=r(0),o=r.n(n),a=r(1),c=r.n(a),_=r(2),i=r.n(_),s=r(3),l=r.n(s);function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var d=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){return s.globalContext.fetch(t,l().extend(!0,l().copy(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){return s.globalContext.fetch(e,t)}}},m=function(e,t,r){var n=l().represent(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},f=function(){var e=c()(i().mark((function e(t,r,n,a,c,_,s){var u,p,d;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===c&&(c=!0),void 0===_&&(_="_id"),void 0===s&&(s="_design/"),p=o()(((u={})[_]=""+s+r,u.language="javascript",u),n),e.prev=4,e.next=7,t.get(""+s+r);case 7:return d=e.sent,p._rev=d._rev,e.next=11,t.put(p);case 11:case 20:e.next=26;break;case 14:return e.prev=14,e.t0=e.catch(4),c&&e.t0.error,e.prev=17,e.next=20,t.put(p);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(a+" couldn't be installed/updated: \""+l().represent(e.t1)+'".');case 26:case"end":return e.stop()}}),e,null,[[4,14],[17,23]])})));return function(){return e.apply(this,arguments)}}(),b=function(){var e=c()(i().mark((function e(t,r){var n,o,a,_,p,m,f,b;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=r.couchdb,o=l().stringFormat(n.url,n.user.name+":"+n.user.password+"@")+"/"+n.databaseName,t.couchdb.connection=new t.couchdb.connector(o,d(r)),(a=t.couchdb.connection).setMaxListeners(1/0),_=n.model.property.name.special.id,p=n.model.property.name.special.revision,m=i().mark((function(){var e,t;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:e=b.value,t=a[e].bind(a),a[e]=c()(i().mark((function e(r,o){var a,c,s,l,u,d,m=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,a=m.length,c=Array(2<a?a-2:0),s=2;s<a;s++)c[s-2]=m[s];return e.next=4,t.apply(void 0,[r,o].concat(c));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!((u=r[_])&&n.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(l=e.t0.message)&&l.startsWith("NoChange:"))){e.next=23;break}if(d="object"==typeof o&&p in o?o[p]:r[p],e.t1=u,!(p in r)||["latest","upsert"].includes(d)){e.next=17;break}e.t2=d,e.next=21;break;case 17:return e.next=19,this.get(u);case 19:e.t3=p,e.t2=e.sent[e.t3];case 21:return e.t4=e.t2,e.abrupt("return",{id:e.t1,rev:e.t4,ok:!0});case 23:throw e.t0;case 24:case"end":return e.stop()}}),e,this,[[0,7]])})));case 3:case"end":return r.stop()}}),m)})),f=u(["post","put"]);case 9:if((b=f()).done){e.next=13;break}return e.delegateYield(m(),"t0",11);case 11:e.next=9;break;case 13:return e.prev=13,e.next=16,l().checkReachability(o);case 16:e.next=23;break;case 18:return e.prev=18,e.t1=e.catch(13),e.next=23,s.globalContext.fetch(o,{method:"PUT"});case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,null,[[13,18]])})));return function(){return e.apply(this,arguments)}}(),y=function(e){for(var t=e.property.name.special.allowedRole,r={},n=g(e),a=0,c=Object.entries(n);a<c.length;a++){var _=c[a],i=_[0],s=_[1];if(Object.prototype.hasOwnProperty.call(s,t)){r[i]=o()({properties:{}},v(s[t]));for(var l=0,u=Object.entries(s);l<u.length;l++){var p=u[l],d=p[0],m=p[1];null!==m&&"object"==typeof m&&m.allowedRoles&&(r[i].properties[d]=v(m.allowedRoles))}}else r[i]={properties:{},read:[],write:[]}}return r},h=function(e){return null!==e&&"object"==typeof e},x=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){var o=t[n];return h(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||h(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(r.additional,r.allowedRole,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.id,r.revision,r.revisions,r.revisionsInformation,r.type).includes(n)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([r.id,r.revision]).sort()},O=function(e,t,r){if(void 0===r&&(r="_extends"),"_base"===e)return t[e];if(Object.prototype.hasOwnProperty.call(t,"_base")&&(Object.prototype.hasOwnProperty.call(t[e],r)&&t[e][r]?t[e][r]=["_base"].concat(t[e][r]):t[e][r]="_base"),Object.prototype.hasOwnProperty.call(t[e],r)){for(var n,o,a=u([].concat(t[e][r]));!(n=a()).done;)o=n.value,t[e]=l().extend(!0,l().copy(O(o,t,r)),t[e]);delete t[e][r]}return t[e]},g=function(e){for(var t,r=e.property.name.special,n={},o=e.property.name.typeRegularExpressionPattern,a=0,c=Object.keys(e.entities);a<c.length;a++){if(t=c[a],!new RegExp(o.public).test(t)&&!new RegExp(o.private).test(t))throw new Error('Model names have to match "'+o.public+'" or "'+o.private+'" for private one (given name: "'+t+'").');n[t]=O(t,e.entities,r.extend)}for(var _,i=0,s=Object.values(n);i<s.length;i++){_=s[i];for(var u=0,p=Object.entries(_);u<p.length;u++){var d=p[u],m=d[0],f=d[1];if(m===r.attachment)for(var b=f,y=0,h=Object.entries(b);y<h.length;y++){var x=h[y],g=x[0],v=x[1];b[g]=l().extend(!0,l().copy(e.property.defaultSpecification),v)}else[r.allowedRole,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(m)||(_[m]=l().extend(!0,l().copy(e.property.defaultSpecification),f))}}return n},v=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,r={read:[],write:[]},n=0,o=Object.keys(r);n<o.length;n++)t=o[n],Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?r[t]=e[t]:r[t]=[e[t]]);return r}return{read:[e],write:[e]}}},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{!function(){"use strict";function t(){return(t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var a=new(Function.bind.apply(e,o));return n&&r(a,n.prototype),a}).apply(null,arguments)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},n.apply(this,arguments)}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var c={d:function(e,t){for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},_={};c.r(_),c.d(_,{DatabaseHelper:function(){return i},default:function(){return s}});var i=function(){function e(){}return e.authenticate=function(e,t,r,n,a,c,_,i,s){var l;void 0===t&&(t=null),void 0===r&&(r={}),void 0===n&&(n={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===c&&(c="_id"),void 0===_&&(_="-type"),void 0===i&&(i="_design/"),void 0===s&&(s=!1);var u=null!==(l=e[_])&&void 0!==l?l:t&&t[_];if(!u)return!0;var p=s?"read":"write",d={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,c)&&e[c].startsWith(i)&&d.read.push("readonlymember");var m,f="Current user doesn't own any role";if(r)if("name"in r||(r.name='"unknown"'),null!=(m=r.roles)&&m.length){if(a&&u&&Object.prototype.hasOwnProperty.call(a,u)){for(var b,y,h=a[u],x=o(["read","write"]);!(b=x()).done;)d[y=b.value]=d[y].concat(h[y]||[]);d.properties=h.properties}for(var O,g,v=d[p],P=o(r.roles);!(O=P()).done;)if(g=O.value,v.includes(g))return!0;f='Current user "'+r.name+'" owns the following roles: "'+r.roles.join('", "')+'"'}else f='Current user "'+r.name+"\" doesn't own any role";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+p+' action: "'+[].concat(d[p]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,r,a,c,_,i,s){void 0===i&&(i={});var l=function(e,t,r){var o;throw void 0===t&&(t="forbidden"),void 0===r&&(r={}),n(((o={})[t]=e,o.message=e,o.name=t,o),r)},u=new Date,p=Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate(),u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds())/1e3,d=!_.dateTimeFormat.startsWith("iso"),m=_.property.name.special,f=m.id,b=m.revision,y=m.type;r&&r[y]&&!e[y]&&(e[y]=r[y]);var h="",x="",O=function(){h=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",x=Object.prototype.hasOwnProperty.call(e,b)?e[b]:""};if(O(),Object.prototype.hasOwnProperty.call(c,_.property.name.validatedDocumentsCache)&&c[_.property.name.validatedDocumentsCache].has(h+"-"+x))return c[_.property.name.validatedDocumentsCache].delete(h+"-"+x),e;["latest","upsert"].includes(x)&&(r&&Object.prototype.hasOwnProperty.call(r,b)?x=e[b]=r[b]:"latest"===x?l("Revision: No old document available to update."):delete e[b]);var g=_.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(g=e[m.strategy],delete e[m.strategy]);var v,P={};if("migrate"===g)for(var E=0,D=Object.entries(i);E<D.length;E++){var M=D[E],w=M[0],k=M[1];if(Object.prototype.hasOwnProperty.call(k,m.oldType)&&k[m.oldType])for(var C,A,T=o([].concat(k[m.oldType]));!(C=T()).done;)A=C.value,P[A]=w}s?v=s:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?v=function(e){return JSON.stringify(e,null,4)}:l('Needed "serializer" is not available.');var j=[m.additional,m.allowedRole,m.constraint.execution,m.constraint.expression,m.create.execution,m.create.expression,m.extend,m.maximumAggregatedSize,m.minimumAggregatedSize,m.oldType,m.update.execution,m.update.expression],I=function(e){return e instanceof Error?""+e:v(e)},R=function(e){return"string"==typeof e?e.trim():""},U=function(e){if(d)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},L=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return[].concat(r.fileName.regularExpressionPattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},W=function(t,r){if(r||(r=e[m.attachment]),t){for(var n,o=0,a=Object.keys(r);o<a.length;o++)if((n=a[o]).startsWith(t))return n}else{var c=Object.keys(r);if(c.length)return c[0]}return null},B=function(e,r,o){void 0===r&&(r=!1),void 0===o&&(o={});var a=R(e);if(a){var c,_=(r?"return ":"")+a,i=n({},N,{code:_},o),s=Object.keys(i);try{c=t(Function,s.concat([_]))}catch(c){l(I(c),"compilation",{code:_,error:c,scope:i})}var u={code:_,result:void 0,scope:i};try{u.result=c.apply(void 0,s.map((function(e){return i[e]})))}catch(c){l(I(c),"runtime",{code:_,error:c,scope:i})}return u}l("No expression to evaluate provided.","empty")},K=function(e,r,n){void 0===n&&(n=[]);var a=n.length?" in "+n.join(" -> "):"",c=[],s=function(){Object.prototype.hasOwnProperty.call(e,y)||(r&&Object.prototype.hasOwnProperty.call(r,y)&&["fillUp","migrate"].includes(g)?e[y]=r[y]:l('Type: You have to specify a model type via property "'+y+'"'+a+".")),n.length||new RegExp(_.property.name.typeRegularExpressionPattern.public).test(e[y])||l('TypeName: You have to specify a model type which matches "'+_.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+e[y]+'")'+a+"."),Object.prototype.hasOwnProperty.call(i,e[y])||(Object.prototype.hasOwnProperty.call(P,e[y])?e[y]=P[e[y]]:l('Model: Given model "'+e[y]+'" is not specified'+a+"."))};s();var u,p=e[y],h=i[p];Object.prototype.hasOwnProperty.call(h,m.additional)&&h[m.additional]&&(u=h[m.additional]);var x=function(c,_,i,s,u){void 0===u&&(u=["constraintExecution","constraintExpression"]);for(var d,m,f=o(u);!(d=f()).done;)if(m=d.value,Object.prototype.hasOwnProperty.call(i,m)){var b=void 0;try{b=B(i[m].evaluation,m.endsWith("Expression"),{checkPropertyContent:v,model:h,modelName:p,name:_,type:m,newDocument:e,newValue:c,oldDocument:r,oldValue:s,parentNames:n,pathDescription:a,propertySpecification:i})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+m+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+m+'" has throw an error with code "'+e.code+'": "'+e.message+'"'+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(b&&!b.result){var y=R(i[m].description);l(m.charAt(0).toUpperCase()+(m.substring(1)+": ")+(y?t(Function,Object.keys(b.scope).concat(["return "+y])).apply(void 0,Object.values(b.scope)):'Property "'+_+'" should satisfy constraint "'+b.code+'" (given "'+I(c)+'")'+a+"."))}}},v=function(e,t,r,c){var _=[],s=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,y)&&1===s.length&&Object.prototype.hasOwnProperty.call(i,s[0])&&(e[y]=s[0]);for(var u,p,m=!1,b=o(s);!(u=b()).done;)if(p=u.value,Object.prototype.hasOwnProperty.call(i,p)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,y)&&e[y]!==p&&"migrate"===g&&1===s.length&&(e[y]=p,_=n.concat(t+"","migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,y)&&e[y]===p){var h=K(e,c,n.concat(t+""));if(h.changedPath.length&&(_=h.changedPath),e=h.newDocument,I(e)===I({}))return{newValue:void 0,changedPath:_};m=!0;break}1===s.length&&l('NestedType: Under key "'+t+'" isn\'t of type "'+p+'" (given "'+I(e)+'" of type '+typeof e+")"+a+".")}else if("DateTime"===p){var O=e;if(e=U(e),!(d&&("number"!=typeof e||isNaN(e))||!d&&"string"!=typeof e)){m=!0;break}1===s.length&&l('PropertyType: Property "'+t+'"isn\'t of (valid) type "DateTime" (given"'+I(O).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof O+'")'+a+".")}else if(["boolean","integer","number","string"].includes(p)){if(!("number"==typeof e&&isNaN(e)||"integer"!==p&&typeof e!==p||"integer"===p&&parseInt(e,10)!==e)){m=!0;break}1===s.length&&l('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+p+'" (given "'+I(e)+'" of type "'+typeof e+'")'+a+".")}else if("string"==typeof p&&p.startsWith("foreignKey:")){var v=i[p.substring(11)][f].type;if(v===typeof e){m=!0;break}1===s.length&&l('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+v+'" (given "'+I(e)+'" of type "'+typeof e+'")'+a+".")}else{if("any"===p||I(e)===I(p)){m=!0;break}1===s.length&&l('PropertyType: Property "'+t+'" isn\'t value "'+p+'" (given "'+I(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+a+".")}if(m||l('PropertyType: None of the specified types "'+s.join('", "')+'" for property "'+t+'" matches value "'+I(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+a+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&l('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+a+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&l('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+a+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&l('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+a+"."),"number"==typeof r.maximum&&e>r.maximum&&l('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+a+".")),r.selection){var P=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(P=P.map(U)),P.includes(e)||l('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+P.join('", "')+'". But is "'+e+'"'+a+".")}if(r.regularExpressionPattern){for(var E,D,M=[].concat(r.regularExpressionPattern),w=!1,k=o(M);!(E=k()).done;)if(D=E.value,new RegExp(D).test(e)){w=!0;break}w||l('PatternMatch: Property "'+t+'" should match one regular expression pattern "'+M.join('", "')+'" (given "'+e+'")'+a+".")}if(r.invertedRegularExpressionPattern)for(var C,A,T=o([].concat(r.invertedRegularExpressionPattern));!(C=T()).done;)A=C.value,new RegExp(A).test(e)&&l('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+A+' (given "'+e+'")'+a+".");return x(e,t,r,c),I(e)!==I(c)&&(_=n.concat(t+"","value updated")),{newValue:e,changedPath:_}},E=function(e,t,r,o,a){var i=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&I(i)===I(r[o]))return o!==f&&"incremental"===g&&delete t[o],!0;l('Readonly: Property "'+o+'" is not writable (old document "'+I(r)+'")'+a+".")}else l('Readonly: Property "'+o+'" is not writable'+a+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(I(i)===I(r[o]))return"incremental"!==g||_.property.name.reserved.concat(m.deleted,f,b).includes(o+"")||delete t[o],!0;"migrate"!==g&&l('Immutable: Property "'+o+'"is not writable (old document "'+I(r)+'")'+a+".")}if(null===i){if(e.nullable)return"incremental"===g&&r&&void 0!==r[o]||delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(c=n.concat(o+"","delete property")),!0;l('NotNull: Property "'+o+'" should not be "null"'+a+".")}return!1},D=function(e,t,r,c,_){if(!r)for(var i,s,u=o(["onCreateExecution","onCreateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s)){var d=void 0;try{d=B(e[s],s.endsWith("Expression"),{attachmentsTarget:_,checkPropertyContent:v,model:h,modelName:p,name:c+"",type:s,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:a,propertySpecification:e})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+s+'" has invalid code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}d&&![null,void 0].includes(d.result)&&(_?_[c]=d.result:t[c]=d.result)}},M=function(e,t,r,c,_){if(!_){if(!Object.prototype.hasOwnProperty.call(t,c))return;e.trim&&"string"==typeof t[c]&&(t[c]=t[c].trim()),e.emptyEqualsNull&&(""===t[c]||Array.isArray(t[c])&&0===t[c].length||null!==t[c]&&"object"==typeof t[c]&&0===Object.keys(t).length)&&(t[c]=null)}for(var i,s,u=o(["onUpdateExecution","onUpdateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s))try{var d=B(e[s],s.endsWith("Expression"),{attachmentsTarget:_,checkPropertyContent:v,model:h,modelName:p,name:c+"",type:s,newDocument:t,oldDocument:r,newValue:t[c],oldValue:r&&r[c]||void 0,parentNames:n,pathDescription:a,propertySpecification:e});_?_[c]=d.result:t[c]=d.result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+s+'" has invalid code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}},w=Object.keys(h).filter((function(e){return!j.includes(e)}));if("migrate"===g)for(var k,C,A=o(w);!(k=A()).done;)if(C=k.value,h[C].oldName)for(var T,W,N=o([].concat(h[C].oldName));!(T=N()).done;)W=T.value,Object.prototype.hasOwnProperty.call(e,W)&&(e[C]=e[W],delete e[W]);if(!r)for(var S,q=0,$=[m.create.execution,m.create.expression];q<$.length;q++)if(S=$[q],Object.prototype.hasOwnProperty.call(h,S)){var F=void 0;try{F=B(h[S],S.endsWith("Expression"),{checkPropertyContent:v,model:h,modelName:p,type:S,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+S+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+S+'" has throw an error with code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(F)||(e=F),s(),p=e[y],0===n.length&&O()}for(var z,H=0,G=[m.update.execution,m.update.expression];H<G.length;H++)if(z=G[H],Object.prototype.hasOwnProperty.call(h,z)){var V=void 0;try{V=B(h[z],z.endsWith("Expression"),{checkPropertyContent:v,model:h,modelName:p,type:z,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+z+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+z+'" has throw an error with code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(V)||(e=V),s(),p=e[y],0===n.length&&O()}for(var J,Y,X=u?Object.keys(e).filter((function(e){return!w.includes(e)})):[],Z=o(w.concat(X));!(J=Z()).done;)if(Y=J.value,m.attachment===Y)for(var Q=function(){var t=te[ee],_=t[0],i=t[1];Object.prototype.hasOwnProperty.call(e,Y)&&null!==e[m.attachment]||(e[m.attachment]={}),r&&!Object.prototype.hasOwnProperty.call(r,Y)&&(r[m.attachment]={});var s=Object.keys(e[m.attachment]).filter((function(t){return null!==e[m.attachment][t].data&&L(_,t,i)})),u=e[m.attachment],p=[];if(r){var d=r[Y];p=Object.keys(d).filter((function(e){return!(Object.prototype.hasOwnProperty.call(u,e)&&Object.prototype.hasOwnProperty.call(u[e],"data")&&null===u[e].data)&&!!d[e]&&(Object.prototype.hasOwnProperty.call(d[e],"data")&&null!==d[e].data||d[e].stub&&!!d[e].digest)&&!!L(_,e,i)}))}for(var f,b,y=i,h=o(s);!(f=h()).done;)b=f.value,D(y,e,r&&r[Y]?r[Y]:null,b,u);for(var x,O,v=o(s);!(x=v()).done;)O=x.value,M(y,e,r&&r[Y]?r[Y]:null,O,u);if(void 0===y.default){if(y.nullable||0<s.length||0<p.length||l('AttachmentMissing: Missing attachment for type "'+_+'"'+a+"."),"fillUp"===g&&0===s.length&&0<p.length)for(var P,E,w=o(p);!(P=w()).done;)E=P.value,null===u[E]?c=n.concat(Y,E,"file removed"):u[E]=r[Y][E]}else if(0===s.length)if(0===p.length)for(var k in y.default)Object.prototype.hasOwnProperty.call(y.default,k)&&(u[k]=y.default[k],c=n.concat(Y,_,"add default file"));else if("fillUp"===g)for(var C,A,T=o(p);!(C=T()).done;)A=C.value,u[A]=r[Y][A]},ee=0,te=Object.entries(h[m.attachment]);ee<te.length;ee++)Q();else{var re=w.includes(Y)?h[Y]:u;D(re,e,r,Y),M(re,e,r,Y),[null,void 0].includes(re.default)?(!(re.nullable||Object.prototype.hasOwnProperty.call(e,Y)&&void 0!==e[Y]||r&&Object.prototype.hasOwnProperty.call(r,Y)&&g)&&l('MissingProperty: Missing property "'+Y+'"'+a+"."),(!Object.prototype.hasOwnProperty.call(e,Y)||void 0===e[Y])&&r&&Object.prototype.hasOwnProperty.call(r,Y)&&("fillUp"===g?e[Y]=r[Y]:!g&&(c=n.concat(Y+"","property removed")))):(!Object.prototype.hasOwnProperty.call(e,Y)||[null,void 0].includes(e[Y]))&&(r?null!==e[Y]&&"fillUp"===g?e[Y]=r[Y]:"migrate"===g&&(e[Y]=re.default,c=n.concat(Y+"","migrate default value")):(e[Y]=re.default,c=c.concat(Y+"","add default value")))}if(r&&"incremental"===g)for(var ne=0,oe=Object.entries(e);ne<oe.length;ne++){var ae=oe[ne],ce=ae[0],_e=ae[1];Object.prototype.hasOwnProperty.call(r,ce)&&!_.property.name.reserved.concat(f,b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,y).includes(ce)&&(r[ce]===_e||I(r[ce])===I(_e))&&delete e[ce]}for(var ie=0,se=Object.entries(e);ie<se.length;ie++){var le=se[ie],ue=le[0],pe=le[1];if(!_.property.name.reserved.concat(b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(ue)){var de=void 0;if(Object.prototype.hasOwnProperty.call(h,ue))de=h[ue];else if(u)de=u;else{if("migrate"===g){delete e[ue],c=n.concat(ue+"","migrate removed property");continue}l('Property: Given property "'+ue+'" isn\'t specified in model "'+p+'"'+a+".")}if(!de)continue;if(m.attachment===ue){var me=pe;for(var fe in me)if(Object.prototype.hasOwnProperty.call(me,fe))for(var be in h[ue])if(L(be,fe,h[m.attachment][be])){E(h[m.attachment][be],e,r,fe,a);break}continue}if(E(de,e,r,ue,a))continue;if("string"==typeof de.type&&de.type.endsWith("[]")||Array.isArray(de.type)&&de.type.length&&Array.isArray(de.type[0])){var ye,he=pe;Array.isArray(he)?"number"==typeof de.minimumNumber&&he.length<de.minimumNumber?l('MinimumArrayLength: Property "'+ue+'" (array of length '+he.length+") doesn't fullfill minimum array length of "+de.minimumNumber+a+"."):"number"==typeof de.maximumNumber&&de.maximumNumber<he.length&&l('MaximumArrayLength: Property "'+ue+'" (array of length '+he.length+") doesn't fullfill maximum array length of "+de.maximumNumber+a+"."):l('PropertyType: Property "'+ue+'" isn\'t of type "array -> '+de.type+'" (given "'+I(he)+'")'+a+"."),x(he,ue+"",de,r&&Object.prototype.hasOwnProperty.call(r,ue)&&r[ue]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var xe={};for(var Oe in de)Object.prototype.hasOwnProperty.call(de,Oe)&&(xe[Oe]="type"===Oe?Array.isArray(de[Oe])?de[Oe][0]:[de[Oe].substring(0,de.type.length-2)]:de[Oe]);if(1===(null==(ye=xe.type)?void 0:ye.length)&&Object.prototype.hasOwnProperty.call(i,xe.type[0]))for(var ge,ve,Pe=o(he.slice());!(ge=Pe()).done;)"object"!=typeof(ve=ge.value)||Object.getPrototypeOf(ve)!==Object.prototype||Object.prototype.hasOwnProperty.call(ve,y)||(ve[y]=xe.type[0]);for(var Ee,De,Me=0,we=o(he.slice());!(Ee=we()).done;)De=Ee.value,he[Me]=v(De,Me+1+". value in "+ue,xe).newValue,[null,void 0].includes(he[Me])&&he.splice(Me,1),Me+=1;r&&Object.prototype.hasOwnProperty.call(r,ue)&&Array.isArray(r[ue])&&r[ue].length===he.length&&I(r[ue])===I(he)||(c=n.concat(ue+"","array updated"))}else{var ke=r&&Object.prototype.hasOwnProperty.call(r,ue)?r[ue]:null,Ce=v(pe,ue+"",de,ke);e[ue]=Ce.newValue,Ce.changedPath.length&&(c=Ce.changedPath),[null,void 0].includes(e[ue])&&(null!==ke&&(c=n.concat(ue+"","property removed")),("incremental"!==g||null!==ke)&&delete e[ue])}}}for(var Ae=0,Te=Object.keys(m.constraint);Ae<Te.length;Ae++){var je=Te[Ae],Ie=m.constraint[je];if(Object.prototype.hasOwnProperty.call(h,Ie))for(var Re,Ue=o([].concat(h[Ie]));!(Re=Ue()).done;){var Le=Re.value,We=void 0;try{We=B(Le.evaluation,Ie===m.constraint.expression,{checkPropertyContent:v,model:h,modelName:p,type:Ie,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+Ie+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+Ie+'" has thrown an error with code "'+e.code+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(We&&!We.result){var Be=Ie.replace(/^[^a-zA-Z]+/,"");l(Be.charAt(0).toUpperCase()+(Be.substring(1)+": ")+(Le.description?t(Function,Object.keys(We.scope).concat(["return "+Le.description.trim()])).apply(void 0,Object.values(We.scope)):'Model "'+p+'" should satisfy constraint "'+We.code+'" (given "'+I(e)+'")'+a+"."))}}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Ke=e[m.attachment];("object"!=typeof Ke||Object.getPrototypeOf(Ke)!==Object.prototype)&&l("AttachmentType: given attachment has invalid type"+a+".");var Ne=null;if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&null!==(Ne=r[m.attachment])&&"object"==typeof Ne)for(var Se=0,qe=Object.entries(Ne);Se<qe.length;Se++){var $e=qe[Se],Fe=$e[0],ze=$e[1];if(Object.prototype.hasOwnProperty.call(Ke,Fe)){var He=Ke[Fe];null===He||null===He.data||He.content_type===ze.content_type&&(He.data===ze.data||He.digest===ze.digest)?((null===He||null===He.data)&&(c=n.concat(m.attachment,Fe,"attachment removed")),"incremental"===g&&delete Ke[Fe]):c=n.concat(m.attachment,Fe,"attachment updated")}else"fillUp"===g?Ke[Fe]=ze:g||(c=n.concat(m.attachment,Fe,"attachment removed"))}for(var Ge=0,Ve=Object.entries(Ke);Ge<Ve.length;Ge++){var Je=Ve[Ge],Ye=Je[0],Xe=Je[1];[null,void 0].includes(Xe)||null===Xe.data?delete Ke[Ye]:(!Ne||!Object.prototype.hasOwnProperty.call(Ne,Ye)||Xe.content_type!==Ne[Ye].content_type||Xe.data!==Ne[Ye].data&&Xe.digest!==Ne[Ye].digest)&&(c=n.concat(m.attachment,Ye,"attachment updated"))}0===Object.keys(Ke).length&&delete e[m.attachment];for(var Ze={},Qe=0,et=Object.keys(h[m.attachment]);Qe<et.length;Qe++)Ze[et[Qe]]=[];for(var tt=0,rt=Object.keys(Ke);tt<rt.length;tt++){for(var nt=rt[tt],ot=!1,at=0,ct=Object.entries(h[m.attachment]);at<ct.length;at++){var _t=ct[at],it=_t[0],st=_t[1];if(L(it,nt,st)){Ze[it].push(nt),ot=!0;break}}ot||l('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(h[m.attachment]).join('", "')+'") matches given one ("'+nt+'")'+a+".")}for(var lt=0,ut=0,pt=Object.keys(Ze);ut<pt.length;ut++){var dt=pt[ut],mt=h[m.attachment][dt];if(Object.prototype.hasOwnProperty.call(Ze,dt)){var ft=Ze[dt].length;"number"==typeof mt.maximumNumber&&ft>mt.maximumNumber&&l("AttachmentMaximum: given number of attachments ("+ft+") doesn't satisfy specified maximum of "+mt.maximumNumber+' from type "'+dt+'"'+a+"."),(!mt.nullable||0!==ft)&&"number"==typeof mt.minimumNumber&&ft<mt.minimumNumber&&l("AttachmentMinimum: given number of attachments ("+ft+") doesn't satisfy specified minimum of "+mt.minimumNumber+' from type "'+dt+'"'+a+".");for(var bt,yt=0,ht=o(Ze[dt]);!(bt=ht()).done;){var xt,Ot,gt=bt.value;if(null!=(xt=mt.fileName)&&xt.regularExpressionPattern){for(var vt,Pt,Et=[].concat(mt.fileName.regularExpressionPattern),Dt=!1,Mt=o(Et);!(vt=Mt()).done;)if(Pt=vt.value,new RegExp(Pt).test(gt)){Dt=!0;break}Dt||l('AttachmentName: given attachment name "'+gt+'" doesn\'t satisfy one of specified regular expression patterns "'+Et.join('", "')+'" from type "'+dt+'"'+a+".")}if(null!=(Ot=mt.fileName)&&Ot.invertedRegularExpressionPattern)for(var wt,kt,Ct=o([].concat(mt.fileName.invertedRegularExpressionPattern));!(wt=Ct()).done;)kt=wt.value,new RegExp(kt).test(gt)&&l('InvertedAttachmentName: given attachment name "'+gt+'" does satisfy specified regular expression pattern "'+kt.toString()+'" from type "'+dt+'"'+a+".");if(Ke[gt].content_type){if(mt.contentTypeRegularExpressionPattern){for(var At,Tt,jt=[].concat(mt.contentTypeRegularExpressionPattern),It=!1,Rt=o(jt);!(At=Rt()).done;)if(Tt=At.value,new RegExp(Tt).test(Ke[gt].content_type)){It=!0;break}It||l('AttachmentContentType: given attachment content type "'+Ke[gt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+jt.join('", "')+'" from type "'+dt+'"'+a+".")}var Ut=mt.invertedContentTypeRegularExpressionPattern;if(Ut)for(var Lt,Wt,Bt=o([].concat(Ut));!(Lt=Bt()).done;)Wt=Lt.value,new RegExp(Wt).test(Ke[gt].content_type)&&l('InvertedAttachmentContentType: given attachment content type "'+Ke[gt].content_type+'" does satisfy specified regular expression pattern "'+Wt.toString()+'" from type "'+dt+'"'+a+".")}var Kt=0;"length"in Ke[gt]?Kt=Ke[gt].length:"data"in Ke[gt]&&(Kt=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Ke[gt].data,"base64"):Ke[gt].data.length),"number"==typeof mt.minimumSize&&mt.minimumSize>Kt?l("AttachmentMinimumSize: given attachment size "+Kt+" byte doesn't satisfy specified minimum of "+mt.minimumSize+" byte "+a+"."):"number"==typeof mt.maximumSize&&mt.maximumSize<Kt&&l("AttachmentMaximumSize: given attachment size "+Kt+" byte doesn't satisfy specified maximum of "+mt.maximumSize+" byte "+a+"."),yt+=Kt}"number"==typeof mt.minimumAggregatedSize&&mt.minimumAggregatedSize>yt?l('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+dt+'" '+yt+" byte doesn't satisfy specified minimum of "+mt.minimumAggregatedSize+" byte "+a+"."):"number"==typeof mt.maximumAggregatedSize&&mt.maximumAggregatedSize<yt&&l('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+dt+'" '+yt+" byte doesn't satisfy specified maximum of "+mt.maximumAggregatedSize+" byte "+a+"."),lt+=yt}}Object.prototype.hasOwnProperty.call(h,m.minimumAggregatedSize)&&"number"==typeof h[m.minimumAggregatedSize]&&h[m.minimumAggregatedSize]>lt?l("AggregatedMinimumSize: given aggregated size "+lt+" byte doesn't satisfy specified minimum of "+h[m.minimumAggregatedSize]+" byte "+a+"."):"number"==typeof h[m.maximumAggregatedSize]&&h[m.maximumAggregatedSize]<lt&&l("AggregatedMaximumSize: given aggregated size "+lt+" byte doesn't satisfy specified maximum of "+h[m.maximumAggregatedSize]+" byte "+a+".")}if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&0===Object.keys(r[m.attachment]).length&&delete r[m.attachment],0===c.length&&r&&"migrate"===g)for(var Nt,St=0,qt=Object.keys(r);St<qt.length;St++)Nt=qt[St],Object.prototype.hasOwnProperty.call(e,Nt)||(c=n.concat(Nt,"migrate removed property"));return{changedPath:c,newDocument:e}},N={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var r=e[m.attachment],n=W(t);if(n)return Object.prototype.hasOwnProperty.call(r[n],"stub")&&r[n].stub||Object.prototype.hasOwnProperty.call(r[n],"data")&&![null,void 0].includes(r[n].data)}return!1},checkDocument:K,getFileNameByPrefix:W,serialize:I,id:h,revision:x,idName:f,revisionName:b,specialNames:m,typeName:y,modelConfiguration:_,models:i,now:u,nowUTCTimestamp:p,securitySettings:c,userContext:a};if(e[m.attachment])for(var S,q=0,$=Object.values(e[m.attachment]);q<$.length;q++)S=$[q],Object.prototype.hasOwnProperty.call(S,"contentType")&&(S.content_type=S.contentType,delete S.contentType);var F=K(e,r);return(!F.newDocument._deleted||r)&&(F.newDocument._deleted&&F.newDocument._deleted!==(null==r?void 0:r._deleted)||F.changedPath.length)||l("NoChange: No new data given. new document: "+I(e)+"; old document: "+I(r)+"."),Object.prototype.hasOwnProperty.call(c,_.property.name.validatedDocumentsCache)?c[_.property.name.validatedDocumentsCache].add(h+"-"+x):c[_.property.name.validatedDocumentsCache]=new Set([h+"-"+x]),F.newDocument},e}(),s=i;e.exports=_}()},,e=>{"use strict";e.exports=require("pouchdb-node")},e=>{"use strict";e.exports=require("pouchdb-find")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("pouchdb-node/node_modules/node-fetch/lib/index.js")},,(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{BL:()=>start,sT:()=>stop,ur:()=>restart});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(11),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(3),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(12),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(5),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(6),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__),_helper__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(4),_this=void 0;function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch=node_fetch__WEBPACK_IMPORTED_MODULE_5___default();var start=function(){var _ref=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee(services,configuration){var server,runner,binary;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(server=services.couchdb.server,runner=server.runner,binary=configuration.couchdb.binary,!Object.prototype.hasOwnProperty.call(runner,"configurationFile")){_context.next=15;break}return _context.prev=4,_context.next=7,fs__WEBPACK_IMPORTED_MODULE_6__.promises.mkdir((0,path__WEBPACK_IMPORTED_MODULE_7__.dirname)(runner.configurationFile.path),{recursive:!0});case 7:_context.next=13;break;case 9:if(_context.prev=9,_context.t0=_context.catch(4),"EEXIST"===_context.t0.code){_context.next=13;break}throw _context.t0;case 13:return _context.next=15,fs__WEBPACK_IMPORTED_MODULE_6__.promises.writeFile(runner.configurationFile.path,runner.configurationFile.content,{encoding:configuration.core.encoding});case 15:return server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===binary.memoryInMegaByte?runner.binaryFilePath:binary.nodePath,("default"===binary.memoryInMegaByte?[]:["--max-old-space-size="+binary.memoryInMegaByte,runner.binaryFilePath]).concat(runner.arguments?runner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,runner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var r,n,o=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(r=o()).done;)n=r.value,server.process.on(n,clientnode__WEBPACK_IMPORTED_MODULE_4___default().getProcessCloseHandler(e,t,{process:server.process,reason:n}))})).then((function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.resolve&&services.couchdb.server.resolve.call(_this,e)}),(function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.resolve&&services.couchdb.server.reject.call(_this,e)})),_context.next=19,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(configuration.couchdb.url,""),{wait:!0});case 19:case"end":return _context.stop()}}),_callee,null,[[4,9]])})));return function(){return _ref.apply(this,arguments)}}(),restart=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,a,c,_;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.configuration,n=t.pluginAPI,o=t.services,a=o.couchdb.server,c=a.resolve,_=a.reject,a.resolve=a.reject=clientnode__WEBPACK_IMPORTED_MODULE_4___default().noop,e.next=7,stop(o,r);case 7:return a.resolve=c,a.reject=_,e.next=11,start(o,r);case 11:return(0,_helper__WEBPACK_IMPORTED_MODULE_8__.initializeConnection)(o,r),e.next=14,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{hook:"restartCouchdb"}));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),stop=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r){var n,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.couchdb,o=r.couchdb,n.connection&&n.connection.close(),n.server.process&&n.server.process.kill("SIGINT"),e.next=6,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkUnreachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(o.url,""),{wait:!0});case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Database:()=>Database,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),clientnode__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),clientnode__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_3__),fs__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(5),fs__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__),path__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6),path__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__),pouchdb_node__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9),pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_node__WEBPACK_IMPORTED_MODULE_6__),pouchdb_find__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(10),pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_7__),_databaseHelper__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(7),_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_10__),_helper__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(4),_server__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(14);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Database=function(){function Database(){}return Database.preLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,a,c,_,i,s,l,u,p,d,m,f,b,y,h;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.configuration.couchdb,n=t.services,Object.prototype.hasOwnProperty.call(n,"couchdb")||(n.couchdb={}),o=n.couchdb,Object.prototype.hasOwnProperty.call(o,"connector")||(a=r.model.property.name.special.id,c=r.model.property.name.special.revision,o.connector=pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default(),_=o.connector.prototype.bulkDocs,o.connector.plugin({bulkDocs:function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,o,i,s,l,u,p,d,m,f,b,y,h,x,O,g,v,P,E=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=E.length,i=Array(1<o?o-1:0),s=1;s<o;s++)i[s-1]=E[s];return l=0<i.length&&i[i.length-1]===Database.toggleIDDetermining,u=l?!r.skipIDDetermining:r.skipIDDetermining,l&&i.pop(),p=!Array.isArray(t)&&null!==t&&"object"==typeof t&&a in t?[t]:t,null!=(n=r.connector.fetch)&&n.timeout&&(0===i.length||"object"!=typeof i[0])&&i.unshift({timeout:r.connector.fetch.timeout}),e.next=8,_.call.apply(_,[this,p].concat(i));case 8:d=e.sent,m=[],f=[],b=0,y=_createForOfIteratorHelperLoose(d);case 13:if((h=y()).done){e.next=36;break}if(x=h.value,"object"!=typeof p[b]){e.next=33;break}if(!(c in p[b])||"conflict"!==x.name||!["latest","upsert"].includes(p[b][c])){e.next=21;break}f.push(p[b]),m.push(b),e.next=33;break;case 21:if(!(a in p[b]&&r.ignoreNoChangeError&&"name"in x&&"forbidden"===x.name&&"message"in x&&x.message.startsWith("NoChange:"))){e.next=33;break}if(d[b]={id:p[b][a],ok:!0},u){e.next=33;break}if(!(c in p[b])||["latest","upsert"].includes(p[b][c])){e.next=28;break}e.t0=p[b][c],e.next=32;break;case 28:return e.next=30,this.get(d[b].id);case 30:e.t1=c,e.t0=e.sent[e.t1];case 32:d[b].rev=e.t0;case 33:b+=1;case 34:e.next=13;break;case 36:if(!f.length){e.next=43;break}return p=f,l&&i.push(Database.toggleIDDetermining),e.next=41,this.bulkDocs.apply(this,[p].concat(i));case 41:for(O=e.sent,g=_createForOfIteratorHelperLoose(O);!(v=g()).done;)P=v.value,d[m.shift()]=P;case 43:return e.abrupt("return",d);case 44:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}),r.debug&&o.connector.debug.enable("*"),o.connector=o.connector.plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default())),Object.prototype.hasOwnProperty.call(o,"server")){e.next=36;break}o.server={},i=[],s=_createForOfIteratorHelperLoose([].concat(r.binary.runner));case 8:if((l=s()).done){e.next=34;break}u=l.value,p=_createForOfIteratorHelperLoose([].concat(u.location));case 11:if((d=p()).done){e.next=30;break}m=d.value,f=_createForOfIteratorHelperLoose([].concat(u.name));case 14:if((b=f()).done){e.next=26;break}return y=b.value,h=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(m,y),i.push(h),e.next=20,clientnode__WEBPACK_IMPORTED_MODULE_3___default().isFile(h);case 20:if(!e.sent){e.next=24;break}return u.binaryFilePath=h,o.server.runner=u,e.abrupt("break",26);case 24:e.next=14;break;case 26:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=28;break}return e.abrupt("break",30);case 28:e.next=11;break;case 30:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=32;break}return e.abrupt("break",34);case 32:e.next=8;break;case 34:if(Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=36;break}throw new Error('No binary file in one of the following locations found: "'+i.join('", "')+'".');case 36:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database.loadService=function(){function loadService(){return _loadService.apply(this,arguments)}var _loadService=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee3(_ref3){var configuration,services,promise,couchdb,urlPrefix,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,_i,_arr,type,_iterator6,_step6,name,userDatabaseConnection,_userDatabaseConnecti,_iterator7,_step7,prefix,subPath,fullPath,url,_value,response,changeNeeded,modelConfiguration,specialNames,idName,typeName,models,databaseHelperCode,_iterator8,_step8,_type2,code,_i2,_Object$entries,_Object$entries$_i,modelName,model,_i3,_Object$entries2,_Object$entries2$_i,_name,specification,_iterator9,_step9,constraint,_iterator10,_step10,_type,_constraint,migrators,_iterator11,_step11,file,extension,_name2,document,_forbidden,_iterator12,_step12,retrievedDocument,_document,newDocument,_iterator13,_step13,_name3,result,indexes,_i4,_Object$entries3,_Object$entries3$_i,_modelName,_model,_iterator14,_step14,propertyName,_name4,foundPosition,position,_iterator15,_step15,index,_iterator16,_step16,_index,exists,_i5,_Object$entries4,_Object$entries4$_i,_modelName2,_model2,_iterator17,_step17,_name5;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(configuration=_ref3.configuration,services=_ref3.services,promise=null,couchdb=services.couchdb,!Object.prototype.hasOwnProperty.call(couchdb.server,"runner")){_context3.next=10;break}return _context3.next=6,(0,_server__WEBPACK_IMPORTED_MODULE_8__.BL)(services,configuration);case 6:couchdb.server.restart=_server__WEBPACK_IMPORTED_MODULE_8__.ur,couchdb.server.start=_server__WEBPACK_IMPORTED_MODULE_8__.BL,couchdb.server.stop=_server__WEBPACK_IMPORTED_MODULE_8__.sT,promise=new Promise((function(e,t){couchdb.server.resolve=e,couchdb.server.reject=t}));case 10:if(!Object.prototype.hasOwnProperty.call(couchdb,"connection")){_context3.next=12;break}return _context3.abrupt("return",{couchdb:promise});case 12:if(urlPrefix=clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringFormat(configuration.couchdb.url,configuration.couchdb.user.name+":"+configuration.couchdb.user.password+"@"),!configuration.couchdb.ensureAdminPresence){_context3.next=44;break}return unauthenticatedUserDatabaseConnection=new couchdb.connector(clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringFormat(configuration.couchdb.url,"")+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=15,_context3.next=18,unauthenticatedUserDatabaseConnection.allDocs();case 18:return _context3.next=21,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringFormat(configuration.couchdb.url,"")+"/"+couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.user.name,{body:'"'+configuration.couchdb.user.password+'"',method:"PUT"});case 21:_context3.next=41;break;case 23:if(_context3.prev=23,_context3.t0=_context3.catch(15),"unauthorized"!==_context3.t0.name){_context3.next=40;break}return authenticatedUserDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=27,_context3.next=30,authenticatedUserDatabaseConnection.allDocs();case 30:_context3.next=35;break;case 32:_context3.prev=32,_context3.t1=_context3.catch(27);case 35:return _context3.prev=35,authenticatedUserDatabaseConnection.close(),_context3.finish(35);case 38:_context3.next=41;break;case 40:case 41:return _context3.prev=41,unauthenticatedUserDatabaseConnection.close(),_context3.finish(41);case 44:if(!configuration.couchdb.ensureUserPresence){_context3.next=79;break}_i=0,_arr=[configuration.couchdb.security.admins,configuration.couchdb.security.members];case 46:if(!(_i<_arr.length)){_context3.next=79;break}type=_arr[_i],_iterator6=_createForOfIteratorHelperLoose(type.names);case 49:if((_step6=_iterator6()).done){_context3.next=76;break}return name=_step6.value,userDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=52,_context3.next=55,userDatabaseConnection.get("org.couchdb.user:"+name);case 55:_context3.next=71;break;case 57:if(_context3.prev=57,_context3.t2=_context3.catch(52),"not_found"!==_context3.t2.error){_context3.next=70;break}return _context3.prev=60,_context3.next=63,userDatabaseConnection.put((_userDatabaseConnecti={},_userDatabaseConnecti[configuration.couchdb.model.property.name.special.id]="org.couchdb.user:"+name,_userDatabaseConnecti.name=name,_userDatabaseConnecti.password=name,_userDatabaseConnecti.roles=[].concat(type.roles.includes(name+"s")?name+"s":[]),_userDatabaseConnecti.type="user",_userDatabaseConnecti));case 63:_context3.next=68;break;case 65:throw _context3.prev=65,_context3.t3=_context3.catch(60),new Error("Couldn't create missing user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t3));case 68:_context3.next=71;break;case 70:throw new Error("Couldn't check for presence of user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t2));case 71:return _context3.prev=71,userDatabaseConnection.close(),_context3.finish(71);case 74:_context3.next=49;break;case 76:_i++,_context3.next=46;break;case 79:if(!configuration.couchdb.model.updateConfiguration){_context3.next=134;break}_iterator7=_createForOfIteratorHelperLoose(configuration.couchdb.backend.prefixes);case 81:if((_step7=_iterator7()).done){_context3.next=134;break}prefix=_step7.value,_context3.t4=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().keys(configuration.couchdb.backend.configuration);case 84:if((_context3.t5=_context3.t4()).done){_context3.next=132;break}if(subPath=_context3.t5.value,!Object.prototype.hasOwnProperty.call(configuration.couchdb.backend.configuration,subPath)){_context3.next=130;break}return fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,_value=configuration.couchdb.backend.configuration[subPath],response=void 0,_context3.prev=91,_context3.next=94,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url);case 94:response=_context3.sent,_context3.next=100;break;case 97:_context3.prev=97,_context3.t6=_context3.catch(91);case 100:if(!response){_context3.next=130;break}if(!response.ok){_context3.next=129;break}if(changeNeeded=!0,"function"!=typeof response.text){_context3.next=115;break}return _context3.prev=104,_context3.t7=_value,_context3.next=108,response["string"==typeof _value?"text":"json"]();case 108:_context3.t8=_context3.sent,changeNeeded=_context3.t7===_context3.t8,_context3.next=115;break;case 112:_context3.prev=112,_context3.t9=_context3.catch(104);case 115:if(!changeNeeded){_context3.next=126;break}return _context3.prev=116,_context3.next=119,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url,{body:'"'+configuration.couchdb.backend.configuration[subPath]+'"',method:"PUT"});case 119:_context3.next=124;break;case 121:_context3.prev=121,_context3.t10=_context3.catch(116);case 124:_context3.next=127;break;case 126:case 127:_context3.next=130;break;case 129:case 130:_context3.next=84;break;case 132:_context3.next=81;break;case 134:return _context3.next=136,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.initializeConnection)(services,configuration);case 136:if(!configuration.couchdb.ensureSecuritySettingsPresence){_context3.next=145;break}return _context3.prev=137,_context3.next=140,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/"+configuration.couchdb.databaseName+"/_security",{body:JSON.stringify(configuration.couchdb.security),method:"PUT"});case 140:_context3.next=145;break;case 142:_context3.prev=142,_context3.t11=_context3.catch(137);case 145:if(modelConfiguration=clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(configuration.couchdb.model),delete modelConfiguration.property.defaultSpecification,delete modelConfiguration.entities,specialNames=modelConfiguration.property.name.special,idName=specialNames.id,typeName=specialNames.type,models=(0,_helper__WEBPACK_IMPORTED_MODULE_9__.extendModels)(configuration.couchdb.model),!configuration.couchdb.model.updateValidation){_context3.next=214;break}return _context3.next=154,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(eval("require.resolve('./databaseHelper')"),{encoding:configuration.core.encoding,flag:"r"});case 154:databaseHelperCode=_context3.sent,_iterator8=_createForOfIteratorHelperLoose([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineAllowedModelRolesMapping)(configuration.couchdb.model))+", '"+idName+"', '"+typeName+"', '"+specialNames.designDocumentNamePrefix+"'"}]);case 156:if((_step8=_iterator8()).done){_context3.next=171;break}_type2=_step8.value,code="function(...parameters) {\n return require('helper').default."+_type2.methodName+"(...parameters.concat(["+_type2.serializedParameter+"]))\n}",_context3.prev=159,new Function("return "+code),_context3.next=166;break;case 163:throw _context3.prev=163,_context3.t12=_context3.catch(159),new Error("Generated "+_type2.name+' code "'+code+"\" doesn't compile: "+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t12));case 166:return configuration.core.debug,_context3.next=169,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.ensureValidationDocumentPresence)(couchdb.connection,_type2.name,{helper:databaseHelperCode,validate_doc_update:code},_type2.description,!0,idName,specialNames.designDocumentNamePrefix);case 169:_context3.next=156;break;case 171:_i2=0,_Object$entries=Object.entries(models);case 172:if(!(_i2<_Object$entries.length)){_context3.next=214;break}_Object$entries$_i=_Object$entries[_i2],modelName=_Object$entries$_i[0],model=_Object$entries$_i[1],_i3=0,_Object$entries2=Object.entries(model);case 175:if(!(_i3<_Object$entries2.length)){_context3.next=211;break}if(_Object$entries2$_i=_Object$entries2[_i3],_name=_Object$entries2$_i[0],specification=_Object$entries2$_i[1],![specialNames.constraint.execution,specialNames.constraint.expression].includes(_name)){_context3.next=193;break}_iterator9=_createForOfIteratorHelperLoose([].concat(specification));case 179:if((_step9=_iterator9()).done){_context3.next=191;break}if(constraint=_step9.value,!constraint.description){_context3.next=189;break}_context3.prev=182,new Function("return "+constraint.description),_context3.next=189;break;case 186:throw _context3.prev=186,_context3.t13=_context3.catch(182),new Error('Specified constraint description "'+constraint.description+'" for model "'+modelName+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t13)+'".');case 189:_context3.next=179;break;case 191:_context3.next=208;break;case 193:_iterator10=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 194:if((_step10=_iterator10()).done){_context3.next=208;break}if(_type=_step10.value,null===specification||"object"!=typeof specification){_context3.next=206;break}if(_constraint=specification[_type],null==_constraint||!_constraint.description){_context3.next=206;break}_context3.prev=199,new Function(_constraint.description),_context3.next=206;break;case 203:throw _context3.prev=203,_context3.t14=_context3.catch(199),new Error('Specified constraint description "'+_constraint.description+'" for model "'+modelName+'" in property "'+_name+'" as "'+_type+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t14)+'".');case 206:_context3.next=194;break;case 208:_i3++,_context3.next=175;break;case 211:_i2++,_context3.next=172;break;case 214:if(!configuration.couchdb.model.autoMigrationPath){_context3.next=313;break}return migrators={},_context3.next=218,clientnode__WEBPACK_IMPORTED_MODULE_3___default().isDirectory((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath));case 218:if(!_context3.sent){_context3.next=265;break}return _context3.t15=_createForOfIteratorHelperLoose,_context3.next=222,clientnode__WEBPACK_IMPORTED_MODULE_3___default().walkDirectoryRecursively((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_3___default().noop:function(e){return"debug"!==e.name});case 222:_context3.t16=_context3.sent,_iterator11=(0,_context3.t15)(_context3.t16);case 224:if((_step11=_iterator11()).done){_context3.next=265;break}if(file=_step11.value,extension=(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name),_name2=(0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(file.name,extension),".json"!==extension){_context3.next=255;break}return document=void 0,_context3.prev=230,_context3.t17=JSON,_context3.next=234,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(file.path,{encoding:configuration.core.encoding,flag:"r"});case 234:_context3.t18=_context3.sent,document=_context3.t17.parse.call(_context3.t17,_context3.t18),_context3.next=241;break;case 238:throw _context3.prev=238,_context3.t19=_context3.catch(230),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t19));case 241:return document[idName]=_name2,document[configuration.couchdb.model.property.name.special.revision]="upsert",_context3.prev=243,_context3.next=246,couchdb.connection.put(document);case 246:_context3.next=252;break;case 248:throw _context3.prev=248,_context3.t20=_context3.catch(243),null!=(_forbidden=_context3.t20.forbidden)&&_forbidden.startsWith("NoChange:"),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t20));case 252:_context3.next=263;break;case 255:if(![".js"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=259;break}migrators[file.path]=eval("require('"+file.path+"')").default,_context3.next=263;break;case 259:if(![".mjs"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=263;break}return _context3.next=262,eval("import('"+file.path+"')");case 262:migrators[file.path]=_context3.sent.default;case 263:_context3.next=224;break;case 265:return _context3.t21=_createForOfIteratorHelperLoose,_context3.next=268,couchdb.connection.allDocs({include_docs:!0});case 268:_context3.t22=_context3.sent.rows,_iterator12=(0,_context3.t21)(_context3.t22);case 270:if((_step12=_iterator12()).done){_context3.next=313;break}if(retrievedDocument=_step12.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context3.next=311;break}_document=retrievedDocument.doc,newDocument=clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(_document),newDocument[configuration.couchdb.model.property.name.special.strategy]="migrate",_iterator13=_createForOfIteratorHelperLoose(Object.keys(migrators).sort());case 277:if((_step13=_iterator13()).done){_context3.next=290;break}_name3=_step13.value,result=null,_context3.prev=280,result=migrators[_name3](newDocument,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default(),Tools:clientnode__WEBPACK_IMPORTED_MODULE_3___default(),idName,typeName,migrators,models,modelConfiguration,selfFilePath:_name3,services}),_context3.next=287;break;case 284:throw _context3.prev=284,_context3.t23=_context3.catch(280),new Error('Running migrater "'+_name3+'" in document '+(0,_helper__WEBPACK_IMPORTED_MODULE_9__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t23));case 287:result&&(newDocument=result);case 288:_context3.next=277;break;case 290:_context3.prev=290,_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default().validateDocumentUpdate(clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(newDocument),clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(_document),{db:configuration.couchdb.databaseName,name:configuration.couchdb.user.name,roles:["_admin"]},clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(configuration.couchdb.security),modelConfiguration,models),_context3.next=302;break;case 294:if(_context3.prev=294,_context3.t24=_context3.catch(290),!Object.prototype.hasOwnProperty.call(_context3.t24,"forbidden")){_context3.next=301;break}return _context3.t24.forbidden.startsWith("NoChange:"),_context3.abrupt("continue",311);case 301:throw _context3.t24;case 302:return _context3.prev=302,_context3.next=305,couchdb.connection.put(newDocument);case 305:_context3.next=310;break;case 307:throw _context3.prev=307,_context3.t25=_context3.catch(302),new Error('Replacing auto migrated document "'+newDocument[idName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t25));case 310:case 311:_context3.next=270;break;case 313:if(!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath){_context3.next=368;break}return _context3.next=316,couchdb.connection.getIndexes();case 316:indexes=_context3.sent.indexes,_i4=0,_Object$entries3=Object.entries(models);case 318:if(!(_i4<_Object$entries3.length)){_context3.next=349;break}if(_Object$entries3$_i=_Object$entries3[_i4],_modelName=_Object$entries3$_i[0],_model=_Object$entries3$_i[1],!new RegExp(configuration.couchdb.model.property.name.typeRegularExpressionPattern.public).test(_modelName)){_context3.next=346;break}return _context3.next=323,couchdb.connection.createIndex({index:{ddoc:_modelName+"-GenericIndex",fields:[typeName],name:_modelName+"-GenericIndex"}});case 323:_iterator14=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model));case 324:if((_step14=_iterator14()).done){_context3.next=346;break}propertyName=_step14.value,_name4=_modelName+"-"+propertyName+"-GenericIndex",foundPosition=-1,position=0,_iterator15=_createForOfIteratorHelperLoose(indexes);case 330:if((_step15=_iterator15()).done){_context3.next=338;break}if(index=_step15.value,index.name!==_name4){_context3.next=335;break}return foundPosition=position,_context3.abrupt("break",338);case 335:position+=1;case 336:_context3.next=330;break;case 338:if(-1!==foundPosition){_context3.next=343;break}return _context3.next=341,couchdb.connection.createIndex({index:{ddoc:_name4,fields:[typeName,propertyName],name:_name4}});case 341:_context3.next=344;break;case 343:indexes.slice(position,1);case 344:_context3.next=324;break;case 346:_i4++,_context3.next=318;break;case 349:_iterator16=_createForOfIteratorHelperLoose(indexes);case 350:if((_step16=_iterator16()).done){_context3.next=368;break}if(_index=_step16.value,!_index.name.endsWith("-GenericIndex")){_context3.next=366;break}exists=!1,_i5=0,_Object$entries4=Object.entries(models);case 355:if(!(_i5<_Object$entries4.length)){_context3.next=363;break}if(_Object$entries4$_i=_Object$entries4[_i5],_modelName2=_Object$entries4$_i[0],_model2=_Object$entries4$_i[1],!_index.name.startsWith(_modelName2+"-")){_context3.next=360;break}for(_iterator17=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model2));!(_step17=_iterator17()).done;)_name5=_step17.value,[_modelName2+"-"+_name5+"-GenericIndex",_modelName2+"-GenericIndex"].includes(_index.name)&&(exists=!0);return _context3.abrupt("break",363);case 360:_i5++,_context3.next=355;break;case 363:if(exists){_context3.next=366;break}return _context3.next=366,couchdb.connection.deleteIndex(_index);case 366:_context3.next=350;break;case 368:if(!configuration.couchdb.model.triggerInitialCompaction){_context3.next=377;break}return _context3.prev=369,_context3.next=372,couchdb.connection.compact();case 372:_context3.next=377;break;case 374:_context3.prev=374,_context3.t26=_context3.catch(369);case 377:return _context3.abrupt("return",{couchdb:promise});case 378:case"end":return _context3.stop()}}),_callee3,null,[[15,23,41,44],[27,32,35,38],[52,57,71,74],[60,65],[91,97],[104,112],[116,121],[137,142],[159,163],[182,186],[199,203],[230,238],[243,248],[280,284],[290,294],[302,307],[369,374]])})));return loadService}(),Database.postLoadService=function(e){var t=e.configuration.couchdb,r=e.pluginAPI,n=e.services.couchdb,o=0;setInterval((function(){0<o&&(o=0)}),3e4);var a=clientnode__WEBPACK_IMPORTED_MODULE_3___default().debounce(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function c(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return n.changesStream&&n.changesStream.cancel(),n.changesStream=n.connection.changes(t.changesStream),n.changesStream.on("error",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function t(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(3<(o+=1))){t.next=9;break}return o=0,n.changesStream.cancel(),t.next=7,n.server.restart(e);case 7:t.next=10;break;case 9:case 10:a();case 11:case"end":return t.stop()}}),t)})))),c.next=5,r.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,{data:n.changesStream,hook:"couchdbInitializeChangesStream"}));case 5:case"end":return c.stop()}}),c)}))));return t.attachAutoRestarter&&a(),Promise.resolve()},Database.shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.configuration,n=t.services,e.next=3,(0,_server__WEBPACK_IMPORTED_MODULE_8__.sT)(n,r);case 3:return delete n.couchdb,o="log.txt",e.next=7,clientnode__WEBPACK_IMPORTED_MODULE_3___default().isFile(o);case 7:if(!e.sent){e.next=10;break}return e.next=10,fs__WEBPACK_IMPORTED_MODULE_4__.promises.unlink(o);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database}();Database.toggleIDDetermining=Symbol("toggleIDDetermining");const __WEBPACK_DEFAULT_EXPORT__=Database})(),module.exports=__webpack_exports__})();
|
|
1
|
+
(()=>{var __webpack_modules__=[e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},(e,t,r)=>{"use strict";r.d(t,{determineAllowedModelRolesMapping:()=>y,determineGenericIndexablePropertyNames:()=>x,ensureValidationDocumentPresence:()=>f,extendModels:()=>g,getConnectorOptions:()=>d,initializeConnection:()=>b,mayStripRepresentation:()=>m});var n=r(0),o=r.n(n),a=r(1),c=r.n(a),_=r(2),i=r.n(_),s=r(3),l=r.n(s);function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var d=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){return s.globalContext.fetch(t,l().extend(!0,l().copy(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){return s.globalContext.fetch(e,t)}}},m=function(e,t,r){var n=l().represent(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},f=function(){var e=c()(i().mark((function e(t,r,n,a,c,_,s,u){var p,d,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===c&&(c=!0),void 0===_&&(_="_id"),void 0===s&&(s="_rev"),void 0===u&&(u="_design/"),d=o()(((p={})[_]=""+u+r,p.language="javascript",p),n),e.prev=5,e.next=8,t.get(""+u+r);case 8:return m=e.sent,d[s]=m[s],e.next=12,t.put(d);case 12:case 21:e.next=27;break;case 15:return e.prev=15,e.t0=e.catch(5),c&&e.t0.error,e.prev=18,e.next=21,t.put(d);case 24:throw e.prev=24,e.t1=e.catch(18),new Error(a+" couldn't be installed/updated: \""+l().represent(e.t1)+'".');case 27:case"end":return e.stop()}}),e,null,[[5,15],[18,24]])})));return function(){return e.apply(this,arguments)}}(),b=function(){var e=c()(i().mark((function e(t,r){var n,o,a,_,p,m,f,b;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=r.couchdb,o=l().stringFormat(n.url,n.user.name+":"+n.user.password+"@")+"/"+n.databaseName,t.couchdb.connection=new t.couchdb.connector(o,d(r)),(a=t.couchdb.connection).setMaxListeners(1/0),_=n.model.property.name.special.id,p=n.model.property.name.special.revision,m=i().mark((function(){var e,t;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:e=b.value,t=a[e].bind(a),a[e]=c()(i().mark((function e(r,o){var a,c,s,l,u,d,m=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,a=m.length,c=Array(2<a?a-2:0),s=2;s<a;s++)c[s-2]=m[s];return e.next=4,t.apply(void 0,[r,o].concat(c));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!((u=r[_])&&n.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(l=e.t0.message)&&l.startsWith("NoChange:"))){e.next=23;break}if(d="object"==typeof o&&p in o?o[p]:r[p],e.t1=u,!(p in r)||["latest","upsert"].includes(d)){e.next=17;break}e.t2=d,e.next=21;break;case 17:return e.next=19,this.get(u);case 19:e.t3=p,e.t2=e.sent[e.t3];case 21:return e.t4=e.t2,e.abrupt("return",{id:e.t1,rev:e.t4,ok:!0});case 23:throw e.t0;case 24:case"end":return e.stop()}}),e,this,[[0,7]])})));case 3:case"end":return r.stop()}}),m)})),f=u(["post","put"]);case 9:if((b=f()).done){e.next=13;break}return e.delegateYield(m(),"t0",11);case 11:e.next=9;break;case 13:return e.prev=13,e.next=16,l().checkReachability(o);case 16:e.next=23;break;case 18:return e.prev=18,e.t1=e.catch(13),e.next=23,s.globalContext.fetch(o,{method:"PUT"});case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,null,[[13,18]])})));return function(){return e.apply(this,arguments)}}(),y=function(e){for(var t=e.property.name.special.allowedRole,r={},n=g(e),a=0,c=Object.entries(n);a<c.length;a++){var _=c[a],i=_[0],s=_[1];if(Object.prototype.hasOwnProperty.call(s,t)){r[i]=o()({properties:{}},v(s[t]));for(var l=0,u=Object.entries(s);l<u.length;l++){var p=u[l],d=p[0],m=p[1];null!==m&&"object"==typeof m&&m.allowedRoles&&(r[i].properties[d]=v(m.allowedRoles))}}else r[i]={properties:{},read:[],write:[]}}return r},h=function(e){return null!==e&&"object"==typeof e},x=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){var o=t[n];return h(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||h(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(r.additional,r.allowedRole,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.id,r.revision,r.revisions,r.revisionsInformation,r.type).includes(n)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([r.id,r.revision]).sort()},O=function(e,t,r){if(void 0===r&&(r="_extends"),"_base"===e)return t[e];if(Object.prototype.hasOwnProperty.call(t,"_base")&&(Object.prototype.hasOwnProperty.call(t[e],r)&&t[e][r]?t[e][r]=["_base"].concat(t[e][r]):t[e][r]="_base"),Object.prototype.hasOwnProperty.call(t[e],r)){for(var n,o,a=u([].concat(t[e][r]));!(n=a()).done;)o=n.value,t[e]=l().extend(!0,l().copy(O(o,t,r)),t[e]);delete t[e][r]}return t[e]},g=function(e){for(var t,r=e.property.name.special,n={},o=e.property.name.typeRegularExpressionPattern,a=0,c=Object.keys(e.entities);a<c.length;a++){if(t=c[a],!new RegExp(o.public).test(t)&&!new RegExp(o.private).test(t))throw new Error('Model names have to match "'+o.public+'" or "'+o.private+'" for private one (given name: "'+t+'").');n[t]=O(t,e.entities,r.extend)}for(var _,i=0,s=Object.values(n);i<s.length;i++){_=s[i];for(var u=0,p=Object.entries(_);u<p.length;u++){var d=p[u],m=d[0],f=d[1];if(m===r.attachment)for(var b=f,y=0,h=Object.entries(b);y<h.length;y++){var x=h[y],g=x[0],v=x[1];b[g]=l().extend(!0,l().copy(e.property.defaultSpecification),v)}else[r.allowedRole,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(m)||(_[m]=l().extend(!0,l().copy(e.property.defaultSpecification),f))}}return n},v=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,r={read:[],write:[]},n=0,o=Object.keys(r);n<o.length;n++)t=o[n],Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?r[t]=e[t]:r[t]=[e[t]]);return r}return{read:[e],write:[e]}}},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{!function(){"use strict";function t(){return(t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var a=new(Function.bind.apply(e,o));return n&&r(a,n.prototype),a}).apply(null,arguments)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},n.apply(this,arguments)}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var c={d:function(e,t){for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},_={};c.r(_),c.d(_,{DatabaseHelper:function(){return i},default:function(){return s}});var i=function(){function e(){}return e.authenticate=function(e,t,r,n,a,c,_,i,s){var l;void 0===t&&(t=null),void 0===r&&(r={}),void 0===n&&(n={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===c&&(c="_id"),void 0===_&&(_="-type"),void 0===i&&(i="_design/"),void 0===s&&(s=!1);var u=null!==(l=e[_])&&void 0!==l?l:t&&t[_];if(!u)return!0;var p=s?"read":"write",d={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,c)&&e[c].startsWith(i)&&d.read.push("readonlymember");var m,f="Current user doesn't own any role";if(r)if("name"in r||(r.name='"unknown"'),null!=(m=r.roles)&&m.length){if(a&&u&&Object.prototype.hasOwnProperty.call(a,u)){for(var b,y,h=a[u],x=o(["read","write"]);!(b=x()).done;)d[y=b.value]=d[y].concat(h[y]||[]);d.properties=h.properties}for(var O,g,v=d[p],E=o(r.roles);!(O=E()).done;)if(g=O.value,v.includes(g))return!0;f='Current user "'+r.name+'" owns the following roles: "'+r.roles.join('", "')+'"'}else f='Current user "'+r.name+"\" doesn't own any role";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+p+' action: "'+[].concat(d[p]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,r,a,c,_,i,s){void 0===i&&(i={});var l=function(e,t,r){var o;throw void 0===t&&(t="forbidden"),void 0===r&&(r={}),n(((o={})[t]=e,o.message=e,o.name=t,o),r)},u=new Date,p=Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate(),u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds())/1e3,d=!_.dateTimeFormat.startsWith("iso"),m=_.property.name.special,f=m.id,b=m.revision,y=m.type;r&&r[y]&&!e[y]&&(e[y]=r[y]);var h="",x="",O=function(){h=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",x=Object.prototype.hasOwnProperty.call(e,b)?e[b]:""};if(O(),Object.prototype.hasOwnProperty.call(c,_.property.name.validatedDocumentsCache)&&c[_.property.name.validatedDocumentsCache].has(h+"-"+x))return c[_.property.name.validatedDocumentsCache].delete(h+"-"+x),e;["latest","upsert"].includes(x)&&(r&&Object.prototype.hasOwnProperty.call(r,b)?x=e[b]=r[b]:"latest"===x?l("Revision: No old document available to update."):delete e[b]);var g=_.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(g=e[m.strategy],delete e[m.strategy]);var v,E={};if("migrate"===g)for(var P=0,D=Object.entries(i);P<D.length;P++){var M=D[P],w=M[0],k=M[1];if(Object.prototype.hasOwnProperty.call(k,m.oldType)&&k[m.oldType])for(var C,A,T=o([].concat(k[m.oldType]));!(C=T()).done;)A=C.value,E[A]=w}s?v=s:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?v=function(e){return JSON.stringify(e,null,4)}:l('Needed "serializer" is not available.');var j=[m.additional,m.allowedRole,m.constraint.execution,m.constraint.expression,m.create.execution,m.create.expression,m.extend,m.maximumAggregatedSize,m.minimumAggregatedSize,m.oldType,m.update.execution,m.update.expression],I=function(e){return e instanceof Error?""+e:v(e)},R=function(e){return"string"==typeof e?e.trim():""},U=function(e){if(d)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},L=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return[].concat(r.fileName.regularExpressionPattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},W=function(t,r){if(r||(r=e[m.attachment]),t){for(var n,o=0,a=Object.keys(r);o<a.length;o++)if((n=a[o]).startsWith(t))return n}else{var c=Object.keys(r);if(c.length)return c[0]}return null},B=function(e,r,o){void 0===r&&(r=!1),void 0===o&&(o={});var a=R(e);if(a){var c,_=(r?"return ":"")+a,i=n({},N,{code:_},o),s=Object.keys(i);try{c=t(Function,s.concat([_]))}catch(c){l(I(c),"compilation",{code:_,error:c,scope:i})}var u={code:_,result:void 0,scope:i};try{u.result=c.apply(void 0,s.map((function(e){return i[e]})))}catch(c){l(I(c),"runtime",{code:_,error:c,scope:i})}return u}l("No expression to evaluate provided.","empty")},K=function(e,r,n){void 0===n&&(n=[]);var a=n.length?" in "+n.join(" -> "):"",c=[],s=function(){Object.prototype.hasOwnProperty.call(e,y)||(r&&Object.prototype.hasOwnProperty.call(r,y)&&["fillUp","migrate"].includes(g)?e[y]=r[y]:l('Type: You have to specify a model type via property "'+y+'"'+a+".")),n.length||new RegExp(_.property.name.typeRegularExpressionPattern.public).test(e[y])||l('TypeName: You have to specify a model type which matches "'+_.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+e[y]+'")'+a+"."),Object.prototype.hasOwnProperty.call(i,e[y])||(Object.prototype.hasOwnProperty.call(E,e[y])?e[y]=E[e[y]]:l('Model: Given model "'+e[y]+'" is not specified'+a+"."))};s();var u,p=e[y],h=i[p];Object.prototype.hasOwnProperty.call(h,m.additional)&&h[m.additional]&&(u=h[m.additional]);var x=function(c,_,i,s,u){void 0===u&&(u=["constraintExecution","constraintExpression"]);for(var d,m,f=o(u);!(d=f()).done;)if(m=d.value,Object.prototype.hasOwnProperty.call(i,m)){var b=void 0;try{b=B(i[m].evaluation,m.endsWith("Expression"),{checkPropertyContent:v,model:h,modelName:p,name:_,type:m,newDocument:e,newValue:c,oldDocument:r,oldValue:s,parentNames:n,pathDescription:a,propertySpecification:i})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+m+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+m+'" has throw an error with code "'+e.code+'": "'+e.message+'"'+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(b&&!b.result){var y=R(i[m].description);l(m.charAt(0).toUpperCase()+(m.substring(1)+": ")+(y?t(Function,Object.keys(b.scope).concat(["return "+y])).apply(void 0,Object.values(b.scope)):'Property "'+_+'" should satisfy constraint "'+b.code+'" (given "'+I(c)+'")'+a+"."))}}},v=function(e,t,r,c){var _=[],s=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,y)&&1===s.length&&Object.prototype.hasOwnProperty.call(i,s[0])&&(e[y]=s[0]);for(var u,p,m=!1,b=o(s);!(u=b()).done;)if(p=u.value,Object.prototype.hasOwnProperty.call(i,p)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,y)&&e[y]!==p&&"migrate"===g&&1===s.length&&(e[y]=p,_=n.concat(t+"","migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,y)&&e[y]===p){var h=K(e,c,n.concat(t+""));if(h.changedPath.length&&(_=h.changedPath),e=h.newDocument,I(e)===I({}))return{newValue:void 0,changedPath:_};m=!0;break}1===s.length&&l('NestedType: Under key "'+t+'" isn\'t of type "'+p+'" (given "'+I(e)+'" of type '+typeof e+")"+a+".")}else if("DateTime"===p){var O=e;if(e=U(e),!(d&&("number"!=typeof e||isNaN(e))||!d&&"string"!=typeof e)){m=!0;break}1===s.length&&l('PropertyType: Property "'+t+'"isn\'t of (valid) type "DateTime" (given"'+I(O).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof O+'")'+a+".")}else if(["boolean","integer","number","string"].includes(p)){if(!("number"==typeof e&&isNaN(e)||"integer"!==p&&typeof e!==p||"integer"===p&&parseInt(e,10)!==e)){m=!0;break}1===s.length&&l('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+p+'" (given "'+I(e)+'" of type "'+typeof e+'")'+a+".")}else if("string"==typeof p&&p.startsWith("foreignKey:")){var v=i[p.substring(11)][f].type;if(v===typeof e){m=!0;break}1===s.length&&l('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+v+'" (given "'+I(e)+'" of type "'+typeof e+'")'+a+".")}else{if("any"===p||I(e)===I(p)){m=!0;break}1===s.length&&l('PropertyType: Property "'+t+'" isn\'t value "'+p+'" (given "'+I(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+a+".")}if(m||l('PropertyType: None of the specified types "'+s.join('", "')+'" for property "'+t+'" matches value "'+I(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+a+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&l('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+a+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&l('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+a+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&l('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+a+"."),"number"==typeof r.maximum&&e>r.maximum&&l('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+a+".")),r.selection){var E=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(E=E.map(U)),E.includes(e)||l('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+E.join('", "')+'". But is "'+e+'"'+a+".")}if(r.regularExpressionPattern){for(var P,D,M=[].concat(r.regularExpressionPattern),w=!1,k=o(M);!(P=k()).done;)if(D=P.value,new RegExp(D).test(e)){w=!0;break}w||l('PatternMatch: Property "'+t+'" should match one regular expression pattern "'+M.join('", "')+'" (given "'+e+'")'+a+".")}if(r.invertedRegularExpressionPattern)for(var C,A,T=o([].concat(r.invertedRegularExpressionPattern));!(C=T()).done;)A=C.value,new RegExp(A).test(e)&&l('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+A+' (given "'+e+'")'+a+".");return x(e,t,r,c),I(e)!==I(c)&&(_=n.concat(t+"","value updated")),{newValue:e,changedPath:_}},P=function(e,t,r,o,a){var i=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&I(i)===I(r[o]))return o!==f&&"incremental"===g&&delete t[o],!0;l('Readonly: Property "'+o+'" is not writable (old document "'+I(r)+'")'+a+".")}else l('Readonly: Property "'+o+'" is not writable'+a+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(I(i)===I(r[o]))return"incremental"!==g||_.property.name.reserved.concat(m.deleted,f,b).includes(o+"")||delete t[o],!0;"migrate"!==g&&l('Immutable: Property "'+o+'"is not writable (old document "'+I(r)+'")'+a+".")}if(null===i){if(e.nullable)return"incremental"===g&&r&&void 0!==r[o]||delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(c=n.concat(o+"","delete property")),!0;l('NotNull: Property "'+o+'" should not be "null"'+a+".")}return!1},D=function(e,t,r,c,_){if(!r)for(var i,s,u=o(["onCreateExecution","onCreateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s)){var d=void 0;try{d=B(e[s],s.endsWith("Expression"),{attachmentsTarget:_,checkPropertyContent:v,model:h,modelName:p,name:c+"",type:s,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:a,propertySpecification:e})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+s+'" has invalid code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}d&&![null,void 0].includes(d.result)&&(_?_[c]=d.result:t[c]=d.result)}},M=function(e,t,r,c,_){if(!_){if(!Object.prototype.hasOwnProperty.call(t,c))return;e.trim&&"string"==typeof t[c]&&(t[c]=t[c].trim()),e.emptyEqualsNull&&(""===t[c]||Array.isArray(t[c])&&0===t[c].length||null!==t[c]&&"object"==typeof t[c]&&0===Object.keys(t).length)&&(t[c]=null)}for(var i,s,u=o(["onUpdateExecution","onUpdateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s))try{var d=B(e[s],s.endsWith("Expression"),{attachmentsTarget:_,checkPropertyContent:v,model:h,modelName:p,name:c+"",type:s,newDocument:t,oldDocument:r,newValue:t[c],oldValue:r&&r[c]||void 0,parentNames:n,pathDescription:a,propertySpecification:e});_?_[c]=d.result:t[c]=d.result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+s+'" has invalid code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+e.code+'" for property "'+c+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}},w=Object.keys(h).filter((function(e){return!j.includes(e)}));if("migrate"===g)for(var k,C,A=o(w);!(k=A()).done;)if(C=k.value,h[C].oldName)for(var T,W,N=o([].concat(h[C].oldName));!(T=N()).done;)W=T.value,Object.prototype.hasOwnProperty.call(e,W)&&(e[C]=e[W],delete e[W]);if(!r)for(var S,q=0,$=[m.create.execution,m.create.expression];q<$.length;q++)if(S=$[q],Object.prototype.hasOwnProperty.call(h,S)){var F=void 0;try{F=B(h[S],S.endsWith("Expression"),{checkPropertyContent:v,model:h,modelName:p,type:S,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+S+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+S+'" has throw an error with code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(F)||(e=F),s(),p=e[y],0===n.length&&O()}for(var z,H=0,G=[m.update.execution,m.update.expression];H<G.length;H++)if(z=G[H],Object.prototype.hasOwnProperty.call(h,z)){var V=void 0;try{V=B(h[z],z.endsWith("Expression"),{checkPropertyContent:v,model:h,modelName:p,type:z,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+z+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+z+'" has throw an error with code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(V)||(e=V),s(),p=e[y],0===n.length&&O()}for(var J,Y,X=u?Object.keys(e).filter((function(e){return!w.includes(e)})):[],Z=o(w.concat(X));!(J=Z()).done;)if(Y=J.value,m.attachment===Y)for(var Q=function(){var t=te[ee],_=t[0],i=t[1];Object.prototype.hasOwnProperty.call(e,Y)&&null!==e[m.attachment]||(e[m.attachment]={}),r&&!Object.prototype.hasOwnProperty.call(r,Y)&&(r[m.attachment]={});var s=Object.keys(e[m.attachment]).filter((function(t){return null!==e[m.attachment][t].data&&L(_,t,i)})),u=e[m.attachment],p=[];if(r){var d=r[Y];p=Object.keys(d).filter((function(e){return!(Object.prototype.hasOwnProperty.call(u,e)&&Object.prototype.hasOwnProperty.call(u[e],"data")&&null===u[e].data)&&!!d[e]&&(Object.prototype.hasOwnProperty.call(d[e],"data")&&null!==d[e].data||d[e].stub&&!!d[e].digest)&&!!L(_,e,i)}))}for(var f,b,y=i,h=o(s);!(f=h()).done;)b=f.value,D(y,e,r&&r[Y]?r[Y]:null,b,u);for(var x,O,v=o(s);!(x=v()).done;)O=x.value,M(y,e,r&&r[Y]?r[Y]:null,O,u);if(void 0===y.default){if(y.nullable||0<s.length||0<p.length||l('AttachmentMissing: Missing attachment for type "'+_+'"'+a+"."),"fillUp"===g&&0===s.length&&0<p.length)for(var E,P,w=o(p);!(E=w()).done;)P=E.value,null===u[P]?c=n.concat(Y,P,"file removed"):u[P]=r[Y][P]}else if(0===s.length)if(0===p.length)for(var k in y.default)Object.prototype.hasOwnProperty.call(y.default,k)&&(u[k]=y.default[k],c=n.concat(Y,_,"add default file"));else if("fillUp"===g)for(var C,A,T=o(p);!(C=T()).done;)A=C.value,u[A]=r[Y][A]},ee=0,te=Object.entries(h[m.attachment]);ee<te.length;ee++)Q();else{var re=w.includes(Y)?h[Y]:u;D(re,e,r,Y),M(re,e,r,Y),[null,void 0].includes(re.default)?(!(re.nullable||Object.prototype.hasOwnProperty.call(e,Y)&&void 0!==e[Y]||r&&Object.prototype.hasOwnProperty.call(r,Y)&&g)&&l('MissingProperty: Missing property "'+Y+'"'+a+"."),(!Object.prototype.hasOwnProperty.call(e,Y)||void 0===e[Y])&&r&&Object.prototype.hasOwnProperty.call(r,Y)&&("fillUp"===g?e[Y]=r[Y]:!g&&(c=n.concat(Y+"","property removed")))):(!Object.prototype.hasOwnProperty.call(e,Y)||[null,void 0].includes(e[Y]))&&(r?null!==e[Y]&&"fillUp"===g?e[Y]=r[Y]:"migrate"===g&&(e[Y]=re.default,c=n.concat(Y+"","migrate default value")):(e[Y]=re.default,c=c.concat(Y+"","add default value")))}if(r&&"incremental"===g)for(var ne=0,oe=Object.entries(e);ne<oe.length;ne++){var ae=oe[ne],ce=ae[0],_e=ae[1];Object.prototype.hasOwnProperty.call(r,ce)&&!_.property.name.reserved.concat(f,b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,y).includes(ce)&&(r[ce]===_e||I(r[ce])===I(_e))&&delete e[ce]}for(var ie=0,se=Object.entries(e);ie<se.length;ie++){var le=se[ie],ue=le[0],pe=le[1];if(!_.property.name.reserved.concat(b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(ue)){var de=void 0;if(Object.prototype.hasOwnProperty.call(h,ue))de=h[ue];else if(u)de=u;else{if("migrate"===g){delete e[ue],c=n.concat(ue+"","migrate removed property");continue}l('Property: Given property "'+ue+'" isn\'t specified in model "'+p+'"'+a+".")}if(!de)continue;if(m.attachment===ue){var me=pe;for(var fe in me)if(Object.prototype.hasOwnProperty.call(me,fe))for(var be in h[ue])if(L(be,fe,h[m.attachment][be])){P(h[m.attachment][be],e,r,fe,a);break}continue}if(P(de,e,r,ue,a))continue;if("string"==typeof de.type&&de.type.endsWith("[]")||Array.isArray(de.type)&&de.type.length&&Array.isArray(de.type[0])&&![null,void 0].includes(pe)){var ye,he=pe;Array.isArray(he)?"number"==typeof de.minimumNumber&&he.length<de.minimumNumber?l('MinimumArrayLength: Property "'+ue+'" (array of length '+he.length+") doesn't fullfill minimum array length of "+de.minimumNumber+a+"."):"number"==typeof de.maximumNumber&&de.maximumNumber<he.length&&l('MaximumArrayLength: Property "'+ue+'" (array of length '+he.length+") doesn't fullfill maximum array length of "+de.maximumNumber+a+"."):l('PropertyType: Property "'+ue+'" isn\'t of type "array -> '+de.type+'" (given "'+I(he)+'")'+a+"."),x(he,ue+"",de,r&&Object.prototype.hasOwnProperty.call(r,ue)&&r[ue]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var xe={};for(var Oe in de)Object.prototype.hasOwnProperty.call(de,Oe)&&(xe[Oe]="type"===Oe?Array.isArray(de[Oe])?de[Oe][0]:[de[Oe].substring(0,de.type.length-2)]:de[Oe]);if(1===(null==(ye=xe.type)?void 0:ye.length)&&Object.prototype.hasOwnProperty.call(i,xe.type[0]))for(var ge,ve,Ee=o(he.slice());!(ge=Ee()).done;)"object"!=typeof(ve=ge.value)||Object.getPrototypeOf(ve)!==Object.prototype||Object.prototype.hasOwnProperty.call(ve,y)||(ve[y]=xe.type[0]);for(var Pe,De,Me=0,we=o(he.slice());!(Pe=we()).done;)De=Pe.value,he[Me]=v(De,Me+1+". value in "+ue,xe).newValue,[null,void 0].includes(he[Me])&&he.splice(Me,1),Me+=1;r&&Object.prototype.hasOwnProperty.call(r,ue)&&Array.isArray(r[ue])&&r[ue].length===he.length&&I(r[ue])===I(he)||(c=n.concat(ue+"","array updated"))}else{var ke=r&&Object.prototype.hasOwnProperty.call(r,ue)?r[ue]:null,Ce=v(pe,ue+"",de,ke);e[ue]=Ce.newValue,Ce.changedPath.length&&(c=Ce.changedPath),[null,void 0].includes(e[ue])&&(null!==ke&&(c=n.concat(ue+"","property removed")),("incremental"!==g||null!==ke)&&delete e[ue])}}}for(var Ae=0,Te=Object.keys(m.constraint);Ae<Te.length;Ae++){var je=Te[Ae],Ie=m.constraint[je];if(Object.prototype.hasOwnProperty.call(h,Ie))for(var Re,Ue=o([].concat(h[Ie]));!(Re=Ue()).done;){var Le=Re.value,We=void 0;try{We=B(Le.evaluation,Ie===m.constraint.expression,{checkPropertyContent:v,model:h,modelName:p,type:Ie,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&l('Compilation: Hook "'+Ie+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&l('Runtime: Hook "'+Ie+'" has thrown an error with code "'+e.code+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(We&&!We.result){var Be=Ie.replace(/^[^a-zA-Z]+/,"");l(Be.charAt(0).toUpperCase()+(Be.substring(1)+": ")+(Le.description?t(Function,Object.keys(We.scope).concat(["return "+Le.description.trim()])).apply(void 0,Object.values(We.scope)):'Model "'+p+'" should satisfy constraint "'+We.code+'" (given "'+I(e)+'")'+a+"."))}}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Ke=e[m.attachment];("object"!=typeof Ke||Object.getPrototypeOf(Ke)!==Object.prototype)&&l("AttachmentType: given attachment has invalid type"+a+".");var Ne=null;if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&null!==(Ne=r[m.attachment])&&"object"==typeof Ne)for(var Se=0,qe=Object.entries(Ne);Se<qe.length;Se++){var $e=qe[Se],Fe=$e[0],ze=$e[1];if(Object.prototype.hasOwnProperty.call(Ke,Fe)){var He=Ke[Fe];null===He||null===He.data||He.content_type===ze.content_type&&(He.data===ze.data||He.digest===ze.digest)?((null===He||null===He.data)&&(c=n.concat(m.attachment,Fe,"attachment removed")),"incremental"===g&&delete Ke[Fe]):c=n.concat(m.attachment,Fe,"attachment updated")}else"fillUp"===g?Ke[Fe]=ze:g||(c=n.concat(m.attachment,Fe,"attachment removed"))}for(var Ge=0,Ve=Object.entries(Ke);Ge<Ve.length;Ge++){var Je=Ve[Ge],Ye=Je[0],Xe=Je[1];[null,void 0].includes(Xe)||null===Xe.data?delete Ke[Ye]:(!Ne||!Object.prototype.hasOwnProperty.call(Ne,Ye)||Xe.content_type!==Ne[Ye].content_type||Xe.data!==Ne[Ye].data&&Xe.digest!==Ne[Ye].digest)&&(c=n.concat(m.attachment,Ye,"attachment updated"))}0===Object.keys(Ke).length&&delete e[m.attachment];for(var Ze={},Qe=0,et=Object.keys(h[m.attachment]);Qe<et.length;Qe++)Ze[et[Qe]]=[];for(var tt=0,rt=Object.keys(Ke);tt<rt.length;tt++){for(var nt=rt[tt],ot=!1,at=0,ct=Object.entries(h[m.attachment]);at<ct.length;at++){var _t=ct[at],it=_t[0],st=_t[1];if(L(it,nt,st)){Ze[it].push(nt),ot=!0;break}}ot||l('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(h[m.attachment]).join('", "')+'") matches given one ("'+nt+'")'+a+".")}for(var lt=0,ut=0,pt=Object.keys(Ze);ut<pt.length;ut++){var dt=pt[ut],mt=h[m.attachment][dt];if(Object.prototype.hasOwnProperty.call(Ze,dt)){var ft=Ze[dt].length;"number"==typeof mt.maximumNumber&&ft>mt.maximumNumber&&l("AttachmentMaximum: given number of attachments ("+ft+") doesn't satisfy specified maximum of "+mt.maximumNumber+' from type "'+dt+'"'+a+"."),(!mt.nullable||0!==ft)&&"number"==typeof mt.minimumNumber&&ft<mt.minimumNumber&&l("AttachmentMinimum: given number of attachments ("+ft+") doesn't satisfy specified minimum of "+mt.minimumNumber+' from type "'+dt+'"'+a+".");for(var bt,yt=0,ht=o(Ze[dt]);!(bt=ht()).done;){var xt,Ot,gt=bt.value;if(null!=(xt=mt.fileName)&&xt.regularExpressionPattern){for(var vt,Et,Pt=[].concat(mt.fileName.regularExpressionPattern),Dt=!1,Mt=o(Pt);!(vt=Mt()).done;)if(Et=vt.value,new RegExp(Et).test(gt)){Dt=!0;break}Dt||l('AttachmentName: given attachment name "'+gt+'" doesn\'t satisfy one of specified regular expression patterns "'+Pt.join('", "')+'" from type "'+dt+'"'+a+".")}if(null!=(Ot=mt.fileName)&&Ot.invertedRegularExpressionPattern)for(var wt,kt,Ct=o([].concat(mt.fileName.invertedRegularExpressionPattern));!(wt=Ct()).done;)kt=wt.value,new RegExp(kt).test(gt)&&l('InvertedAttachmentName: given attachment name "'+gt+'" does satisfy specified regular expression pattern "'+kt.toString()+'" from type "'+dt+'"'+a+".");if(Ke[gt].content_type){if(mt.contentTypeRegularExpressionPattern){for(var At,Tt,jt=[].concat(mt.contentTypeRegularExpressionPattern),It=!1,Rt=o(jt);!(At=Rt()).done;)if(Tt=At.value,new RegExp(Tt).test(Ke[gt].content_type)){It=!0;break}It||l('AttachmentContentType: given attachment content type "'+Ke[gt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+jt.join('", "')+'" from type "'+dt+'"'+a+".")}var Ut=mt.invertedContentTypeRegularExpressionPattern;if(Ut)for(var Lt,Wt,Bt=o([].concat(Ut));!(Lt=Bt()).done;)Wt=Lt.value,new RegExp(Wt).test(Ke[gt].content_type)&&l('InvertedAttachmentContentType: given attachment content type "'+Ke[gt].content_type+'" does satisfy specified regular expression pattern "'+Wt.toString()+'" from type "'+dt+'"'+a+".")}var Kt=0;"length"in Ke[gt]?Kt=Ke[gt].length:"data"in Ke[gt]&&(Kt=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Ke[gt].data,"base64"):Ke[gt].data.length),"number"==typeof mt.minimumSize&&mt.minimumSize>Kt?l("AttachmentMinimumSize: given attachment size "+Kt+" byte doesn't satisfy specified minimum of "+mt.minimumSize+" byte "+a+"."):"number"==typeof mt.maximumSize&&mt.maximumSize<Kt&&l("AttachmentMaximumSize: given attachment size "+Kt+" byte doesn't satisfy specified maximum of "+mt.maximumSize+" byte "+a+"."),yt+=Kt}"number"==typeof mt.minimumAggregatedSize&&mt.minimumAggregatedSize>yt?l('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+dt+'" '+yt+" byte doesn't satisfy specified minimum of "+mt.minimumAggregatedSize+" byte "+a+"."):"number"==typeof mt.maximumAggregatedSize&&mt.maximumAggregatedSize<yt&&l('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+dt+'" '+yt+" byte doesn't satisfy specified maximum of "+mt.maximumAggregatedSize+" byte "+a+"."),lt+=yt}}Object.prototype.hasOwnProperty.call(h,m.minimumAggregatedSize)&&"number"==typeof h[m.minimumAggregatedSize]&&h[m.minimumAggregatedSize]>lt?l("AggregatedMinimumSize: given aggregated size "+lt+" byte doesn't satisfy specified minimum of "+h[m.minimumAggregatedSize]+" byte "+a+"."):"number"==typeof h[m.maximumAggregatedSize]&&h[m.maximumAggregatedSize]<lt&&l("AggregatedMaximumSize: given aggregated size "+lt+" byte doesn't satisfy specified maximum of "+h[m.maximumAggregatedSize]+" byte "+a+".")}if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&0===Object.keys(r[m.attachment]).length&&delete r[m.attachment],0===c.length&&r&&"migrate"===g)for(var Nt,St=0,qt=Object.keys(r);St<qt.length;St++)Nt=qt[St],Object.prototype.hasOwnProperty.call(e,Nt)||(c=n.concat(Nt,"migrate removed property"));return{changedPath:c,newDocument:e}},N={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var r=e[m.attachment],n=W(t);if(n)return Object.prototype.hasOwnProperty.call(r[n],"stub")&&r[n].stub||Object.prototype.hasOwnProperty.call(r[n],"data")&&![null,void 0].includes(r[n].data)}return!1},checkDocument:K,getFileNameByPrefix:W,serialize:I,id:h,revision:x,idName:f,revisionName:b,specialNames:m,typeName:y,modelConfiguration:_,models:i,now:u,nowUTCTimestamp:p,securitySettings:c,userContext:a};if(e[m.attachment])for(var S,q=0,$=Object.values(e[m.attachment]);q<$.length;q++)S=$[q],Object.prototype.hasOwnProperty.call(S,"contentType")&&(S.content_type=S.contentType,delete S.contentType);var F=K(e,r);return(!F.newDocument._deleted||r)&&(F.newDocument._deleted&&F.newDocument._deleted!==(null==r?void 0:r._deleted)||F.changedPath.length)||l("NoChange: No new data given. new document: "+I(e)+"; old document: "+I(r)+"."),Object.prototype.hasOwnProperty.call(c,_.property.name.validatedDocumentsCache)?c[_.property.name.validatedDocumentsCache].add(h+"-"+x):c[_.property.name.validatedDocumentsCache]=new Set([h+"-"+x]),F.newDocument},e}(),s=i;e.exports=_}()},,e=>{"use strict";e.exports=require("pouchdb-node")},e=>{"use strict";e.exports=require("pouchdb-find")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("pouchdb-node/node_modules/node-fetch/lib/index.js")},,(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{BL:()=>start,sT:()=>stop,ur:()=>restart});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(11),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(3),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(12),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(5),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(6),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__),_helper__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(4),_this=void 0;function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch=node_fetch__WEBPACK_IMPORTED_MODULE_5___default();var start=function(){var _ref=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee(services,configuration){var server,runner,binary;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(server=services.couchdb.server,runner=server.runner,binary=configuration.couchdb.binary,!Object.prototype.hasOwnProperty.call(runner,"configurationFile")){_context.next=15;break}return _context.prev=4,_context.next=7,fs__WEBPACK_IMPORTED_MODULE_6__.promises.mkdir((0,path__WEBPACK_IMPORTED_MODULE_7__.dirname)(runner.configurationFile.path),{recursive:!0});case 7:_context.next=13;break;case 9:if(_context.prev=9,_context.t0=_context.catch(4),"EEXIST"===_context.t0.code){_context.next=13;break}throw _context.t0;case 13:return _context.next=15,fs__WEBPACK_IMPORTED_MODULE_6__.promises.writeFile(runner.configurationFile.path,runner.configurationFile.content,{encoding:configuration.core.encoding});case 15:return server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===binary.memoryInMegaByte?runner.binaryFilePath:binary.nodePath,("default"===binary.memoryInMegaByte?[]:["--max-old-space-size="+binary.memoryInMegaByte,runner.binaryFilePath]).concat(runner.arguments?runner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,runner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var r,n,o=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(r=o()).done;)n=r.value,server.process.on(n,clientnode__WEBPACK_IMPORTED_MODULE_4___default().getProcessCloseHandler(e,t,{process:server.process,reason:n}))})).then((function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.resolve&&services.couchdb.server.resolve.call(_this,e)}),(function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.resolve&&services.couchdb.server.reject.call(_this,e)})),_context.next=19,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(configuration.couchdb.url,""),{wait:!0});case 19:case"end":return _context.stop()}}),_callee,null,[[4,9]])})));return function(){return _ref.apply(this,arguments)}}(),restart=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,a,c,_;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.configuration,n=t.pluginAPI,o=t.services,a=o.couchdb.server,c=a.resolve,_=a.reject,a.resolve=a.reject=clientnode__WEBPACK_IMPORTED_MODULE_4___default().noop,e.next=7,stop(o,r);case 7:return a.resolve=c,a.reject=_,e.next=11,start(o,r);case 11:return(0,_helper__WEBPACK_IMPORTED_MODULE_8__.initializeConnection)(o,r),e.next=14,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{hook:"restartCouchdb"}));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),stop=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r){var n,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.couchdb,o=r.couchdb,n.connection&&n.connection.close(),n.server.process&&n.server.process.kill("SIGINT"),e.next=6,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkUnreachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(o.url,""),{wait:!0});case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},e=>{"use strict";e.exports={i8:"1.0.624"}}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Database:()=>Database,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),clientnode__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),clientnode__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_3__),fs__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(5),fs__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__),path__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6),path__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__),pouchdb_node__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9),pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_node__WEBPACK_IMPORTED_MODULE_6__),pouchdb_find__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(10),pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_7__),_databaseHelper__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(7),_databaseHelper__WEBPACK_IMPORTED_MODULE_11___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_11__),_helper__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(4),_package_json__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(15),_server__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(14);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Database=function(){function Database(){}return Database.preLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,a,c,_,i,s,l,u,p,d,m,f,b,y,h;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.configuration.couchdb,n=t.services,Object.prototype.hasOwnProperty.call(n,"couchdb")||(n.couchdb={}),o=n.couchdb,Object.prototype.hasOwnProperty.call(o,"connector")||(a=r.model.property.name.special.id,c=r.model.property.name.special.revision,o.connector=pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default(),_=o.connector.prototype.bulkDocs,o.connector.plugin({bulkDocs:function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,o,i,s,l,u,p,d,m,f,b,y,h,x,O,g,v,E,P=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=P.length,i=Array(1<o?o-1:0),s=1;s<o;s++)i[s-1]=P[s];return l=0<i.length&&i[i.length-1]===Database.toggleIDDetermining,u=l?!r.skipIDDetermining:r.skipIDDetermining,l&&i.pop(),p=!Array.isArray(t)&&null!==t&&"object"==typeof t&&a in t?[t]:t,null!=(n=r.connector.fetch)&&n.timeout&&(0===i.length||"object"!=typeof i[0])&&i.unshift({timeout:r.connector.fetch.timeout}),e.next=8,_.call.apply(_,[this,p].concat(i));case 8:d=e.sent,m=[],f=[],b=0,y=_createForOfIteratorHelperLoose(d);case 13:if((h=y()).done){e.next=36;break}if(x=h.value,"object"!=typeof p[b]){e.next=33;break}if(!(c in p[b])||"conflict"!==x.name||!["latest","upsert"].includes(p[b][c])){e.next=21;break}f.push(p[b]),m.push(b),e.next=33;break;case 21:if(!(a in p[b]&&r.ignoreNoChangeError&&"name"in x&&"forbidden"===x.name&&"message"in x&&x.message.startsWith("NoChange:"))){e.next=33;break}if(d[b]={id:p[b][a],ok:!0},u){e.next=33;break}if(!(c in p[b])||["latest","upsert"].includes(p[b][c])){e.next=28;break}e.t0=p[b][c],e.next=32;break;case 28:return e.next=30,this.get(d[b].id);case 30:e.t1=c,e.t0=e.sent[e.t1];case 32:d[b].rev=e.t0;case 33:b+=1;case 34:e.next=13;break;case 36:if(!f.length){e.next=43;break}return p=f,l&&i.push(Database.toggleIDDetermining),e.next=41,this.bulkDocs.apply(this,[p].concat(i));case 41:for(O=e.sent,g=_createForOfIteratorHelperLoose(O);!(v=g()).done;)E=v.value,d[m.shift()]=E;case 43:return e.abrupt("return",d);case 44:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}),r.debug&&o.connector.debug.enable("*"),o.connector=o.connector.plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default())),Object.prototype.hasOwnProperty.call(o,"server")){e.next=36;break}o.server={},i=[],s=_createForOfIteratorHelperLoose([].concat(r.binary.runner));case 8:if((l=s()).done){e.next=34;break}u=l.value,p=_createForOfIteratorHelperLoose([].concat(u.location));case 11:if((d=p()).done){e.next=30;break}m=d.value,f=_createForOfIteratorHelperLoose([].concat(u.name));case 14:if((b=f()).done){e.next=26;break}return y=b.value,h=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(m,y),i.push(h),e.next=20,clientnode__WEBPACK_IMPORTED_MODULE_3___default().isFile(h);case 20:if(!e.sent){e.next=24;break}return u.binaryFilePath=h,o.server.runner=u,e.abrupt("break",26);case 24:e.next=14;break;case 26:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=28;break}return e.abrupt("break",30);case 28:e.next=11;break;case 30:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=32;break}return e.abrupt("break",34);case 32:e.next=8;break;case 34:if(Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=36;break}throw new Error('No binary file in one of the following locations found: "'+i.join('", "')+'".');case 36:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database.loadService=function(){function loadService(){return _loadService.apply(this,arguments)}var _loadService=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee3(_ref3){var configuration,services,promise,couchdb,urlPrefix,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,_i,_arr,type,_iterator6,_step6,name,userDatabaseConnection,_userDatabaseConnecti,_iterator7,_step7,prefix,subPath,fullPath,url,_value,response,changeNeeded,modelConfiguration,specialNames,idName,revisionName,typeName,models,databaseHelperCode,_iterator8,_step8,_type2,code,_i2,_Object$entries,_Object$entries$_i,modelName,model,_i3,_Object$entries2,_Object$entries2$_i,_name,specification,_iterator9,_step9,constraint,_iterator10,_step10,_type,_constraint,migrators,_iterator11,_step11,file,extension,_name2,document,_forbidden,_iterator12,_step12,retrievedDocument,_document,newDocument,_iterator13,_step13,_name3,result,indexes,_i4,_Object$entries3,_Object$entries3$_i,_modelName,_model,_iterator14,_step14,propertyName,_name4,foundPosition,position,_iterator15,_step15,index,_iterator16,_step16,_index,exists,_i5,_Object$entries4,_Object$entries4$_i,_modelName2,_model2,_iterator17,_step17,_name5;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(configuration=_ref3.configuration,services=_ref3.services,promise=null,couchdb=services.couchdb,!Object.prototype.hasOwnProperty.call(couchdb.server,"runner")){_context3.next=10;break}return _context3.next=6,(0,_server__WEBPACK_IMPORTED_MODULE_8__.BL)(services,configuration);case 6:couchdb.server.restart=_server__WEBPACK_IMPORTED_MODULE_8__.ur,couchdb.server.start=_server__WEBPACK_IMPORTED_MODULE_8__.BL,couchdb.server.stop=_server__WEBPACK_IMPORTED_MODULE_8__.sT,promise=new Promise((function(e,t){couchdb.server.resolve=e,couchdb.server.reject=t}));case 10:if(!Object.prototype.hasOwnProperty.call(couchdb,"connection")){_context3.next=12;break}return _context3.abrupt("return",{couchdb:promise});case 12:if(urlPrefix=clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringFormat(configuration.couchdb.url,configuration.couchdb.user.name+":"+configuration.couchdb.user.password+"@"),!configuration.couchdb.ensureAdminPresence){_context3.next=44;break}return unauthenticatedUserDatabaseConnection=new couchdb.connector(clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringFormat(configuration.couchdb.url,"")+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=15,_context3.next=18,unauthenticatedUserDatabaseConnection.allDocs();case 18:return _context3.next=21,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringFormat(configuration.couchdb.url,"")+"/"+couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.user.name,{body:'"'+configuration.couchdb.user.password+'"',method:"PUT"});case 21:_context3.next=41;break;case 23:if(_context3.prev=23,_context3.t0=_context3.catch(15),"unauthorized"!==_context3.t0.name){_context3.next=40;break}return authenticatedUserDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=27,_context3.next=30,authenticatedUserDatabaseConnection.allDocs();case 30:_context3.next=35;break;case 32:_context3.prev=32,_context3.t1=_context3.catch(27);case 35:return _context3.prev=35,authenticatedUserDatabaseConnection.close(),_context3.finish(35);case 38:_context3.next=41;break;case 40:case 41:return _context3.prev=41,unauthenticatedUserDatabaseConnection.close(),_context3.finish(41);case 44:if(!configuration.couchdb.ensureUserPresence){_context3.next=79;break}_i=0,_arr=[configuration.couchdb.security.admins,configuration.couchdb.security.members];case 46:if(!(_i<_arr.length)){_context3.next=79;break}type=_arr[_i],_iterator6=_createForOfIteratorHelperLoose(type.names);case 49:if((_step6=_iterator6()).done){_context3.next=76;break}return name=_step6.value,userDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=52,_context3.next=55,userDatabaseConnection.get("org.couchdb.user:"+name);case 55:_context3.next=71;break;case 57:if(_context3.prev=57,_context3.t2=_context3.catch(52),"not_found"!==_context3.t2.error){_context3.next=70;break}return _context3.prev=60,_context3.next=63,userDatabaseConnection.put((_userDatabaseConnecti={},_userDatabaseConnecti[configuration.couchdb.model.property.name.special.id]="org.couchdb.user:"+name,_userDatabaseConnecti.name=name,_userDatabaseConnecti.password=name,_userDatabaseConnecti.roles=[].concat(type.roles.includes(name+"s")?name+"s":[]),_userDatabaseConnecti.type="user",_userDatabaseConnecti));case 63:_context3.next=68;break;case 65:throw _context3.prev=65,_context3.t3=_context3.catch(60),new Error("Couldn't create missing user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t3));case 68:_context3.next=71;break;case 70:throw new Error("Couldn't check for presence of user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t2));case 71:return _context3.prev=71,userDatabaseConnection.close(),_context3.finish(71);case 74:_context3.next=49;break;case 76:_i++,_context3.next=46;break;case 79:if(!configuration.couchdb.model.updateConfiguration){_context3.next=134;break}_iterator7=_createForOfIteratorHelperLoose(configuration.couchdb.backend.prefixes);case 81:if((_step7=_iterator7()).done){_context3.next=134;break}prefix=_step7.value,_context3.t4=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().keys(configuration.couchdb.backend.configuration);case 84:if((_context3.t5=_context3.t4()).done){_context3.next=132;break}if(subPath=_context3.t5.value,!Object.prototype.hasOwnProperty.call(configuration.couchdb.backend.configuration,subPath)){_context3.next=130;break}return fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,_value=configuration.couchdb.backend.configuration[subPath],response=void 0,_context3.prev=91,_context3.next=94,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url);case 94:response=_context3.sent,_context3.next=100;break;case 97:_context3.prev=97,_context3.t6=_context3.catch(91);case 100:if(!response){_context3.next=130;break}if(!response.ok){_context3.next=129;break}if(changeNeeded=!0,"function"!=typeof response.text){_context3.next=115;break}return _context3.prev=104,_context3.t7=_value,_context3.next=108,response["string"==typeof _value?"text":"json"]();case 108:_context3.t8=_context3.sent,changeNeeded=_context3.t7===_context3.t8,_context3.next=115;break;case 112:_context3.prev=112,_context3.t9=_context3.catch(104);case 115:if(!changeNeeded){_context3.next=126;break}return _context3.prev=116,_context3.next=119,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url,{body:'"'+configuration.couchdb.backend.configuration[subPath]+'"',method:"PUT"});case 119:_context3.next=124;break;case 121:_context3.prev=121,_context3.t10=_context3.catch(116);case 124:_context3.next=127;break;case 126:case 127:_context3.next=130;break;case 129:case 130:_context3.next=84;break;case 132:_context3.next=81;break;case 134:return _context3.next=136,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.initializeConnection)(services,configuration);case 136:if(!configuration.couchdb.ensureSecuritySettingsPresence){_context3.next=145;break}return _context3.prev=137,_context3.next=140,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/"+configuration.couchdb.databaseName+"/_security",{body:JSON.stringify(configuration.couchdb.security),method:"PUT"});case 140:_context3.next=145;break;case 142:_context3.prev=142,_context3.t11=_context3.catch(137);case 145:if(modelConfiguration=clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(configuration.couchdb.model),delete modelConfiguration.property.defaultSpecification,delete modelConfiguration.entities,specialNames=modelConfiguration.property.name.special,idName=specialNames.id,revisionName=specialNames.revision,typeName=specialNames.type,models=(0,_helper__WEBPACK_IMPORTED_MODULE_9__.extendModels)(configuration.couchdb.model),!configuration.couchdb.model.updateValidation){_context3.next=214;break}return _context3.next=154,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(eval("require.resolve('./databaseHelper')"),{encoding:configuration.core.encoding,flag:"r"});case 154:databaseHelperCode=_context3.sent,_iterator8=_createForOfIteratorHelperLoose([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineAllowedModelRolesMapping)(configuration.couchdb.model))+", '"+idName+"', '"+typeName+"', '"+specialNames.designDocumentNamePrefix+"'"}]);case 156:if((_step8=_iterator8()).done){_context3.next=171;break}_type2=_step8.value,code="function(...parameters) {\n return require('helper').default."+_type2.methodName+"(...parameters.concat(["+_type2.serializedParameter+"]))\n}",_context3.prev=159,new Function("return "+code),_context3.next=166;break;case 163:throw _context3.prev=163,_context3.t12=_context3.catch(159),new Error("Generated "+_type2.name+' code "'+code+"\" doesn't compile: "+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t12));case 166:return configuration.core.debug,_context3.next=169,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.ensureValidationDocumentPresence)(couchdb.connection,_type2.name,{helper:databaseHelperCode,validate_doc_update:code,version:_package_json__WEBPACK_IMPORTED_MODULE_10__.i8},_type2.description,!0,idName,revisionName,specialNames.designDocumentNamePrefix);case 169:_context3.next=156;break;case 171:_i2=0,_Object$entries=Object.entries(models);case 172:if(!(_i2<_Object$entries.length)){_context3.next=214;break}_Object$entries$_i=_Object$entries[_i2],modelName=_Object$entries$_i[0],model=_Object$entries$_i[1],_i3=0,_Object$entries2=Object.entries(model);case 175:if(!(_i3<_Object$entries2.length)){_context3.next=211;break}if(_Object$entries2$_i=_Object$entries2[_i3],_name=_Object$entries2$_i[0],specification=_Object$entries2$_i[1],![specialNames.constraint.execution,specialNames.constraint.expression].includes(_name)){_context3.next=193;break}_iterator9=_createForOfIteratorHelperLoose([].concat(specification));case 179:if((_step9=_iterator9()).done){_context3.next=191;break}if(constraint=_step9.value,!constraint.description){_context3.next=189;break}_context3.prev=182,new Function("return "+constraint.description),_context3.next=189;break;case 186:throw _context3.prev=186,_context3.t13=_context3.catch(182),new Error('Specified constraint description "'+constraint.description+'" for model "'+modelName+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t13)+'".');case 189:_context3.next=179;break;case 191:_context3.next=208;break;case 193:_iterator10=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 194:if((_step10=_iterator10()).done){_context3.next=208;break}if(_type=_step10.value,null===specification||"object"!=typeof specification){_context3.next=206;break}if(_constraint=specification[_type],null==_constraint||!_constraint.description){_context3.next=206;break}_context3.prev=199,new Function(_constraint.description),_context3.next=206;break;case 203:throw _context3.prev=203,_context3.t14=_context3.catch(199),new Error('Specified constraint description "'+_constraint.description+'" for model "'+modelName+'" in property "'+_name+'" as "'+_type+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t14)+'".');case 206:_context3.next=194;break;case 208:_i3++,_context3.next=175;break;case 211:_i2++,_context3.next=172;break;case 214:if(!configuration.couchdb.model.autoMigrationPath){_context3.next=313;break}return migrators={},_context3.next=218,clientnode__WEBPACK_IMPORTED_MODULE_3___default().isDirectory((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath));case 218:if(!_context3.sent){_context3.next=265;break}return _context3.t15=_createForOfIteratorHelperLoose,_context3.next=222,clientnode__WEBPACK_IMPORTED_MODULE_3___default().walkDirectoryRecursively((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_3___default().noop:function(e){return"debug"!==e.name});case 222:_context3.t16=_context3.sent,_iterator11=(0,_context3.t15)(_context3.t16);case 224:if((_step11=_iterator11()).done){_context3.next=265;break}if(file=_step11.value,extension=(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name),_name2=(0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(file.name,extension),".json"!==extension){_context3.next=255;break}return document=void 0,_context3.prev=230,_context3.t17=JSON,_context3.next=234,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(file.path,{encoding:configuration.core.encoding,flag:"r"});case 234:_context3.t18=_context3.sent,document=_context3.t17.parse.call(_context3.t17,_context3.t18),_context3.next=241;break;case 238:throw _context3.prev=238,_context3.t19=_context3.catch(230),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t19));case 241:return document[idName]=_name2,document[revisionName]="upsert",_context3.prev=243,_context3.next=246,couchdb.connection.put(document);case 246:_context3.next=252;break;case 248:throw _context3.prev=248,_context3.t20=_context3.catch(243),null!=(_forbidden=_context3.t20.forbidden)&&_forbidden.startsWith("NoChange:"),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t20));case 252:_context3.next=263;break;case 255:if(![".js"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=259;break}migrators[file.path]=eval("require('"+file.path+"')").default,_context3.next=263;break;case 259:if(![".mjs"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=263;break}return _context3.next=262,eval("import('"+file.path+"')");case 262:migrators[file.path]=_context3.sent.default;case 263:_context3.next=224;break;case 265:return _context3.t21=_createForOfIteratorHelperLoose,_context3.next=268,couchdb.connection.allDocs({include_docs:!0});case 268:_context3.t22=_context3.sent.rows,_iterator12=(0,_context3.t21)(_context3.t22);case 270:if((_step12=_iterator12()).done){_context3.next=313;break}if(retrievedDocument=_step12.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context3.next=311;break}_document=retrievedDocument.doc,newDocument=clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(_document),newDocument[configuration.couchdb.model.property.name.special.strategy]="migrate",_iterator13=_createForOfIteratorHelperLoose(Object.keys(migrators).sort());case 277:if((_step13=_iterator13()).done){_context3.next=290;break}_name3=_step13.value,result=null,_context3.prev=280,result=migrators[_name3](newDocument,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_11___default(),Tools:clientnode__WEBPACK_IMPORTED_MODULE_3___default(),idName,typeName,migrators,models,modelConfiguration,selfFilePath:_name3,services}),_context3.next=287;break;case 284:throw _context3.prev=284,_context3.t23=_context3.catch(280),new Error('Running migrater "'+_name3+'" in document '+(0,_helper__WEBPACK_IMPORTED_MODULE_9__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t23));case 287:result&&(newDocument=result);case 288:_context3.next=277;break;case 290:_context3.prev=290,_databaseHelper__WEBPACK_IMPORTED_MODULE_11___default().validateDocumentUpdate(clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(newDocument),clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(_document),{db:configuration.couchdb.databaseName,name:configuration.couchdb.user.name,roles:["_admin"]},clientnode__WEBPACK_IMPORTED_MODULE_3___default().copy(configuration.couchdb.security),modelConfiguration,models),_context3.next=302;break;case 294:if(_context3.prev=294,_context3.t24=_context3.catch(290),!Object.prototype.hasOwnProperty.call(_context3.t24,"forbidden")){_context3.next=301;break}return _context3.t24.forbidden.startsWith("NoChange:"),_context3.abrupt("continue",311);case 301:throw _context3.t24;case 302:return _context3.prev=302,_context3.next=305,couchdb.connection.put(newDocument);case 305:_context3.next=310;break;case 307:throw _context3.prev=307,_context3.t25=_context3.catch(302),new Error('Replacing auto migrated document "'+newDocument[idName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(_context3.t25));case 310:case 311:_context3.next=270;break;case 313:if(!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath){_context3.next=368;break}return _context3.next=316,couchdb.connection.getIndexes();case 316:indexes=_context3.sent.indexes,_i4=0,_Object$entries3=Object.entries(models);case 318:if(!(_i4<_Object$entries3.length)){_context3.next=349;break}if(_Object$entries3$_i=_Object$entries3[_i4],_modelName=_Object$entries3$_i[0],_model=_Object$entries3$_i[1],!new RegExp(configuration.couchdb.model.property.name.typeRegularExpressionPattern.public).test(_modelName)){_context3.next=346;break}return _context3.next=323,couchdb.connection.createIndex({index:{ddoc:_modelName+"-GenericIndex",fields:[typeName],name:_modelName+"-GenericIndex"}});case 323:_iterator14=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model));case 324:if((_step14=_iterator14()).done){_context3.next=346;break}propertyName=_step14.value,_name4=_modelName+"-"+propertyName+"-GenericIndex",foundPosition=-1,position=0,_iterator15=_createForOfIteratorHelperLoose(indexes);case 330:if((_step15=_iterator15()).done){_context3.next=338;break}if(index=_step15.value,index.name!==_name4){_context3.next=335;break}return foundPosition=position,_context3.abrupt("break",338);case 335:position+=1;case 336:_context3.next=330;break;case 338:if(-1!==foundPosition){_context3.next=343;break}return _context3.next=341,couchdb.connection.createIndex({index:{ddoc:_name4,fields:[typeName,propertyName],name:_name4}});case 341:_context3.next=344;break;case 343:indexes.slice(position,1);case 344:_context3.next=324;break;case 346:_i4++,_context3.next=318;break;case 349:_iterator16=_createForOfIteratorHelperLoose(indexes);case 350:if((_step16=_iterator16()).done){_context3.next=368;break}if(_index=_step16.value,!_index.name.endsWith("-GenericIndex")){_context3.next=366;break}exists=!1,_i5=0,_Object$entries4=Object.entries(models);case 355:if(!(_i5<_Object$entries4.length)){_context3.next=363;break}if(_Object$entries4$_i=_Object$entries4[_i5],_modelName2=_Object$entries4$_i[0],_model2=_Object$entries4$_i[1],!_index.name.startsWith(_modelName2+"-")){_context3.next=360;break}for(_iterator17=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model2));!(_step17=_iterator17()).done;)_name5=_step17.value,[_modelName2+"-"+_name5+"-GenericIndex",_modelName2+"-GenericIndex"].includes(_index.name)&&(exists=!0);return _context3.abrupt("break",363);case 360:_i5++,_context3.next=355;break;case 363:if(exists){_context3.next=366;break}return _context3.next=366,couchdb.connection.deleteIndex(_index);case 366:_context3.next=350;break;case 368:if(!configuration.couchdb.model.triggerInitialCompaction){_context3.next=377;break}return _context3.prev=369,_context3.next=372,couchdb.connection.compact();case 372:_context3.next=377;break;case 374:_context3.prev=374,_context3.t26=_context3.catch(369);case 377:return _context3.abrupt("return",{couchdb:promise});case 378:case"end":return _context3.stop()}}),_callee3,null,[[15,23,41,44],[27,32,35,38],[52,57,71,74],[60,65],[91,97],[104,112],[116,121],[137,142],[159,163],[182,186],[199,203],[230,238],[243,248],[280,284],[290,294],[302,307],[369,374]])})));return loadService}(),Database.postLoadService=function(e){var t=e.configuration.couchdb,r=e.pluginAPI,n=e.services.couchdb,o=0;setInterval((function(){0<o&&(o=0)}),3e4);var a=clientnode__WEBPACK_IMPORTED_MODULE_3___default().debounce(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function c(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return n.changesStream&&n.changesStream.cancel(),n.changesStream=n.connection.changes(t.changesStream),n.changesStream.on("error",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function t(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(3<(o+=1))){t.next=9;break}return o=0,n.changesStream.cancel(),t.next=7,n.server.restart(e);case 7:t.next=10;break;case 9:case 10:a();case 11:case"end":return t.stop()}}),t)})))),c.next=5,r.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,{data:n.changesStream,hook:"couchdbInitializeChangesStream"}));case 5:case"end":return c.stop()}}),c)}))));return t.attachAutoRestarter&&a(),Promise.resolve()},Database.shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.configuration,n=t.services,e.next=3,(0,_server__WEBPACK_IMPORTED_MODULE_8__.sT)(n,r);case 3:return delete n.couchdb,o="log.txt",e.next=7,clientnode__WEBPACK_IMPORTED_MODULE_3___default().isFile(o);case 7:if(!e.sent){e.next=10;break}return e.next=10,fs__WEBPACK_IMPORTED_MODULE_4__.promises.unlink(o);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database}();Database.toggleIDDetermining=Symbol("toggleIDDetermining");const __WEBPACK_DEFAULT_EXPORT__=Database})(),module.exports=__webpack_exports__})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "couchdb-web-node-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.624",
|
|
4
4
|
"description": "A couchdb server, model instance conflict handler, rest api, authentication, session management, schema validator and model relation guarantee for webNode.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|